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-only- ..
- ai.ts
- apps.ts
- audit.ts
- auth.ts
- central-core.d.mts
- central-core.mjs
- central.ts
- cloud.ts
- config.ts
- crypto.ts
- db.ts
- design.ts
- engines.ts
- files.ts
- gates.ts
- gateway.ts
- marketplace-core.d.mts
- marketplace-core.mjs
- metrics.ts
- modules.ts
- motion.ts
- nexus-core.d.mts
- nexus-core.mjs
- oidc-core.d.mts
- oidc-core.mjs
- oidc.ts
- providers.ts
- proxy-core.d.mts
- proxy-core.mjs
- pwauth-core.d.mts
- pwauth-core.mjs
- requirements.ts
- rls.sql.d.mts
- rls.sql.mjs
- services-content.ts
- ssrf.ts
- status.ts
- tenant.ts
- tlsgate.ts
- workspace.ts
app/qa/nexus.mjs
1// Zoo Nexus CLIENT contract tests. Nexus is not contacted (no API is documented; the endpoint is only proposed).2import crypto from "node:crypto"; import fs from "node:fs";3import * as N from "../src/lib/nexus-core.mjs";4const results = []; const rec = (n, ok, d = "") => { results.push({ name: n, ok: !!ok }); console.log((ok ? "PASS " : "FAIL ") + n + (ok ? "" : " -> " + d)); };5const throws = (fn, re) => { try { fn(); return false; } catch (e) { return re ? re.test(e.message) : true; } };6const now = 1_800_000_000_000; const kp = crypto.generateKeyPairSync("ed25519"); const other = crypto.generateKeyPairSync("ed25519");7const mk = (o = {}) => N.buildEnvelope({ operation: "task.request", appId: "zca_abc", orgRef: "zc_123", params: { taskType: "deploy-check", projectId: "prj_1" }, now, ...o });8const e = mk();9rec("envelope carries schema, scope, correlation id, idempotency key and a bounded deadline", e.schema === N.NEXUS_SCHEMA && e.scope === "nexus:task:write" && /^cor_/.test(e.correlationId) && /^idem_/.test(e.idempotencyKey) && Date.parse(e.deadline) - Date.parse(e.issuedAt) === 300000);10rec("every operation maps to exactly one scope", N.OPERATIONS.every(o => N.OP_SCOPE[o]) && new Set(Object.values(N.OP_SCOPE)).size === N.OPERATIONS.length);11rec("valid envelope validates", N.validateEnvelope(e, { now }) === true);12const sig = N.signEnvelope(e, kp.privateKey);13rec("Ed25519 signature verifies", N.verifyEnvelope(e, sig, kp.publicKey));14rec("tampered envelope fails verification", !N.verifyEnvelope({ ...e, orgRef: "zc_evil" }, sig, kp.publicKey));15rec("signature from another key fails", !N.verifyEnvelope(e, N.signEnvelope(e, other.privateKey), kp.publicKey));16rec("canonical form is key-order independent", N.canonical({ b: 1, a: { d: 1, c: 2 } }) === N.canonical({ a: { c: 2, d: 1 }, b: 1 }));17rec("expired deadline refused", throws(() => N.validateEnvelope(e, { now: now + 400000 }), /deadline/));18rec("replayed idempotency key refused", throws(() => N.validateEnvelope(e, { now, seenIdempotency: new Set([e.idempotencyKey]) }), /replayed/));19rec("deadline over 24h refused", throws(() => mk({ deadlineMs: 25 * 3600 * 1000 }), /deadline/));20rec("missing scope refused", throws(() => mk({ scopes: ["nexus:task:read"] }), /missing scope/));21rec("unknown operation refused", throws(() => mk({ operation: "shell.exec" }), /unknown operation/));22for (const k of ["apiKey", "password", "sourceCode", "terminal", "prompt", "conversation", "privateKey", "fileContent"]) rec(`params field "${k}" refused (customer secrets, files, terminal and AI conversations never leave Zloud)`, throws(() => mk({ params: { [k]: "x" } }), /forbidden/));23rec("free-text params refused", throws(() => mk({ params: { note: "please deploy my customer's secret site now" } }), /identifier/));24rec("deeply nested params refused", throws(() => mk({ params: { a: { b: { c: { d: { e: "x" } } } } } }), /nested/));25rec("tampered operation/scope pair refused", throws(() => N.validateEnvelope({ ...e, scope: "nexus:health:read" }, { now }), /mismatch/));26rec("MCP descriptors cover every operation, are identifier-only and carry no secrets", N.mcpTools().length === N.OPERATIONS.length && N.mcpTools().every(t => /^zloud\.[a-z]+_[a-z]+$/.test(t.name) && t.inputSchema.additionalProperties === false));27rec("proposed endpoint is only a constant, never contacted", N.PROPOSED_ENDPOINT === "https://nexus.zoobd.com" && !/fetch|https\.request|net\.connect/.test(fs.readFileSync("src/lib/nexus-core.mjs", "utf8").replace(/\/\/.*$/gm, "")));28rec("SSH access to the Zoo IAM server is listed as never requested", N.NEVER_SENT.some(x => /SSH.*IAM/.test(x)));29const f = results.filter(r => !r.ok); console.log(`\n${results.length - f.length}/${results.length} Nexus contract checks passed`);30fs.mkdirSync("../design/verification", { recursive: true }); fs.writeFileSync("../design/verification/nexus.json", JSON.stringify({ at: new Date().toISOString(), live_nexus: "NOT CONTACTED: no API documented; https://nexus.zoobd.com is a proposed endpoint", total: results.length, passed: results.length - f.length, results }, null, 1));31process.exit(f.length ? 1 : 0);32
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 fb22adb on master.
Approval requests
None pending.