AI Engineering Workspace
PartialChat, files, terminal and preview in one place. Chat sessions run on a durable Postgres-backed queue (chat only: no tools or shell). Live models need an API key; the terminal is unavailable.
Project files
read-onlyapp/src/lib/central-core.mjs
1// Zoo Central integration readiness (pure, testable). Cloud-side contracts only: NO Zoo Central endpoint is documented to this project, so nothing here2// invents one. Every adapter reports an honest state; "live" is only ever set by a recorded successful probe against an operator-configured endpoint.3import crypto from "node:crypto";4export const CONTRACT_SCHEMA = "zoo.cloud.registration/v1";5export const FORBIDDEN_KEY = /secret|token|password|passwd|credential|api[_-]?key|private|source|code|file|terminal|stdin|stdout|command|prompt|message|content|conversation|transcript|body|payload|env|cookie|authorization/i;6export const ORG_CLASSES = ["internal", "customer"];7/** Opaque, domain-independent org reference sent to Central: the explicit mapping if one exists, otherwise a salted hash. Never a hostname. */8export const orgRef = (appId, orgId, mapped) => mapped || "zc_" + crypto.createHash("sha256").update(appId + ":" + orgId).digest("hex").slice(0, 20);910const ENUMS = { template: ["org.created", "node.offline", "quota.nearing", "deployment.failed", "provisioning.decided"], severity: ["info", "warning", "critical"], approvalKind: ["managed-vps-request", "quota-increase", "org-activation"], state: ["operational", "degraded", "down"] };11const SHAPES = {12 "audit.activity": { action: "id", resourceType: "id", orgRef: "id", at: "iso" },13 "service.health": { component: "id", state: ENUMS.state, at: "iso" },14 "notification.request": { template: ENUMS.template, severity: ENUMS.severity, orgRef: "id", at: "iso" },15 "approval.request": { kind: ENUMS.approvalKind, requestId: "id", orgRef: "id", at: "iso" },16};17const KINDS = { id: v => typeof v === "string" && /^[A-Za-z0-9_.:-]{1,80}$/.test(v), iso: v => typeof v === "string" && !isNaN(Date.parse(v)) && v.length <= 40 };18/** Allowlist sanitizer: unknown keys, free text, secrets-looking keys and over-long values are rejected, never silently forwarded. */19export function sanitizeEvent(kind, data) {20 const shape = SHAPES[kind]; if (!shape) throw new Error("unknown event kind");21 const out = {};22 for (const k of Object.keys(data ?? {})) { if (!(k in shape)) throw new Error(FORBIDDEN_KEY.test(k) ? `forbidden field ${k}` : `field not allowed in ${kind}: ${k}`); }23 for (const [k, rule] of Object.entries(shape)) { const v = data?.[k]; const ok = Array.isArray(rule) ? rule.includes(v) : KINDS[rule](v); if (!ok) throw new Error(`invalid ${k}`); out[k] = v; }24 return out;25}26export const NEVER_SYNCED = ["customer secrets and provider API keys", "source code and project files", "terminal contents", "AI conversations and prompts", "node credentials and enrollment tokens", "session cookies"];2728/** The registration document Cloud offers to a Central Application Registry. Identity is the stable appId; every URL is derived from configuration. */29export function buildContract(appId, cfg, history = []) {30 const pub = cfg.PUBLIC_BASE_URL.replace(/\/$/, "");31 return {32 schema: CONTRACT_SCHEMA,33 status: "prepared; not accepted by any Zoo Central registry (no registry endpoint is documented or configured)",34 application: { id: appId, key: "zoo-cloud", name: "Zloud Studio", brand: "Zloud", legacyNames: ["Zloud Studio", "Zloud"], poweredBy: "Zoo Bangladesh", kind: "multi-tenant commercial SaaS", deployableIndependently: true },35 identity: { protocol: "oidc", issuer: cfg.OIDC_ISSUER, clientId: "zoo-cloud-studio", flow: "authorization_code+pkce(S256)", redirectUris: [cfg.OIDC_REDIRECT_URI], backchannelLogoutUri: `${pub}/auth/backchannel-logout`, subjectKey: "(iss, sub)", emailIsIdentity: false, autoAssignAdminByEmail: false },36 endpoints: { public: pub, console: cfg.CONSOLE_BASE_URL, api: cfg.API_BASE_URL, gateway: cfg.GATEWAY_BASE_URL, packages: cfg.PACKAGE_BASE_URL, health: `${pub}/api/status` },37 tenancy: { organizationClasses: ORG_CLASSES, customerAccessToInternalApps: false, entitlementModel: "explicit per (organization, user, application); internal organizations only", isolation: "application checks + PostgreSQL row-level security" },38 dataPolicy: { neverSynchronized: NEVER_SYNCED, metadataOnlyEvents: Object.keys(SHAPES) },39 portability: { identityIndependentOfDomain: true, applicationIdIsStable: true, endpointsConfigurable: true, previousEndpoints: history },40 };41}4243/** Catalogue of the ten Central integrations. `contract` says what exists on the CLOUD side; `central` states what is known about the Central side. */44export const ADAPTERS = [45 { id: "registry", title: "Application Registry", contract: "Registration document served at /.well-known/zoo-cloud-registration.json (zoo.cloud.registration/v1)", central: "No registry API documented", implemented: ["contract document"] },46 { id: "iam", title: "Zoo IAM (OIDC + session revocation)", contract: "OIDC code+PKCE, state/nonce, JWKS verification, back-channel logout; Keycloak client spec in docs/ZOO-IAM-KEYCLOAK.md", central: "Standard OIDC discovery at the configured issuer; client credentials not provisioned", implemented: ["login", "callback", "backchannel-logout", "identity (iss,sub)"], needs: "client secret in ~/.config/zoo-cloud-studio/oidc-client-secret" },47 { id: "access", title: "Central Access Management", contract: "Explicit entitlements per (internal org, user, app); customers never receive internal-app entitlements (DB trigger)", central: "No access-management API documented", implemented: ["entitlement store", "customer separation trigger"] },48 { id: "orghub", title: "Zoo Org Hub / organization mapping", contract: "org_mappings(org_id → opaque central_ref) + organization class internal|customer", central: "No Org Hub API documented", implemented: ["mapping store", "org classes"] },49 { id: "notifications", title: "Central Notification Service", contract: "Enumerated templates only (no free text) via the metadata outbox", central: "No notification API documented", implemented: ["sanitized outbox"] },50 { id: "approvals", title: "Central Approval Service", contract: "Approval requests for managed-VPS, quota and org activation (ids + kind only)", central: "No approval API documented", implemented: ["sanitized outbox"] },51 { id: "audit", title: "Central Audit & activity reporting", contract: "Per-action metadata (action, resource type, opaque org ref, time); never detail text", central: "No audit-ingest API documented", implemented: ["sanitized outbox"] },52 { id: "health", title: "Central service health & status", contract: "Aggregate component health at /api/status (public, non-tenant)", central: "No monitoring API documented", implemented: ["status endpoint", "sanitized outbox"] },53 { id: "myapps", title: "Application discovery / My Apps", contract: "GET /api/myapps → only the caller's explicit entitlements (internal orgs); customers always get an empty internal list", central: "No catalogue API documented", implemented: ["myapps endpoint"] },54 { id: "nexus", title: "Zoo Nexus client (tasks, capabilities, events)", contract: "Signed task envelopes (zoo.nexus.task/v1): scoped, correlation id, deadline, idempotency key, identifier-only params; MCP-style tool descriptors. Zloud is a client only", central: "Nexus is a separate thread; https://nexus.zoobd.com is a proposed endpoint, not assumed live; no API documented", implemented: ["envelope builder/validator", "Ed25519 signing", "MCP tool descriptors"], needs: "Nexus API contract + least-privilege credential" },55 { id: "profile", title: "Identity profile & avatar sync", contract: "display name, e-mail (display only, with verified flag) and picture URL are stored from the ID token on each login", central: "Uses OIDC claims only; no separate profile API documented", implemented: ["claims capture"] },56];57/** state: blocked (a prerequisite outside this project is missing) | contract-prepared (Cloud side done, needs endpoint) | ready-untested (endpoint configured, no successful probe) | live (successful probe recorded) */58export function adapterState(a, { endpoint, probeOk, secretPresent }) {59 if (a.id === "iam") return secretPresent ? (probeOk ? "live" : "ready-untested") : "blocked";60 if (!endpoint) return "contract-prepared"; return probeOk ? "live" : "ready-untested";61}62
Conversation
PartialSign in to start AI sessions.
Task checklist
- Application shell deployed
- Persistent projects
- Agent runtime
- Sandboxed terminal
Execution activity
No agent sessions. Git HEAD a177d6e on master.
Approval requests
None pending.