Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
fix(agora-citizens): copy the repo code the worker imports so the image can actually boot
nirholas2a14da522069
diff --git a/tests/agora-worker-image.test.js b/tests/agora-worker-image.test.jsnew file mode 100644index 000000000..522b19579--- /dev/null+++ b/tests/agora-worker-image.test.js@@ -0,0 +1,89 @@+/**+ * Agora life-engine container: does the image actually carry everything the+ * worker imports? (Task 11 hardening.)+ *+ * The worker runs OUTSIDE api/, but reaches across that boundary anyway+ * (api/_lib/env.js, api/_lib/feed.js, api/_lib/r2.js, packages/forge). The+ * Dockerfile has to COPY each of those explicitly, and nothing about adding a+ * new cross-boundary import reminds you to.+ *+ * This is not a theoretical worry: workers/agora-citizens/config.js grew an+ * `import { resolveDatabaseUrl } from '../../api/_lib/env.js'` while the+ * Dockerfile still copied only `workers/agora-citizens` and `solana-agent-sdk`.+ * The image BUILT clean and then died on boot with+ * "Cannot find module '/app/api/_lib/env.js'" - a failure a build-time check+ * cannot see, because the build genuinely succeeds.+ *+ * So: resolve every path the worker imports from outside its own directory and+ * assert the Dockerfile copies a directory that contains it.+ */++import { describe, it, expect } from 'vitest';+import { readFileSync, readdirSync, statSync } from 'node:fs';+import { join, dirname, resolve, relative } from 'node:path';+import { fileURLToPath } from 'node:url';++const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..');+const WORKER_DIR = join(ROOT, 'workers', 'agora-citizens');+const DOCKERFILE = join(WORKER_DIR, 'Dockerfile');++/** Every .js file under the worker directory. */+function walk(dir, out = []) {+ for (const name of readdirSync(dir)) {+ const full = join(dir, name);+ if (statSync(full).isDirectory()) walk(full, out);+ else if (name.endsWith('.js')) out.push(full);+ }+ return out;+}++/** Repo-relative targets the worker imports from outside its own directory. */+function crossBoundaryImports() {+ const found = new Set();+ // Static `from '...'` and dynamic `import('...')`, relative specifiers only.+ const re = /(?:from|import)\s*\(?\s*['"](\.\.?\/[^'"]+)['"]/g;+ for (const file of walk(WORKER_DIR)) {+ const src = readFileSync(file, 'utf8');+ for (const m of src.matchAll(re)) {+ const target = resolve(dirname(file), m[1]);+ const rel = relative(WORKER_DIR, target);+ if (rel.startsWith('..')) found.add(relative(ROOT, target));+ }+ }+ return [...found].sort();+}++/** Paths the Dockerfile COPYs out of the build context. */+function dockerfileCopies() {+ const copies = [];+ for (const line of readFileSync(DOCKERFILE, 'utf8').split('\n')) {+ const m = line.match(/^COPY\s+(.+)$/i);+ if (!m) continue;+ const parts = m[1].trim().split(/\s+/);+ // Last token is the destination; everything before it is a source.+ for (const src of parts.slice(0, -1)) copies.push(src.replace(/^\.\//, ''));+ }+ return copies;+}++describe('agora-citizens image carries the worker dependencies', () => {+ const imports = crossBoundaryImports();+ const copies = dockerfileCopies();++ it('finds the cross-boundary imports it is meant to guard', () => {+ // A sanity check on the scanner itself: if this ever goes empty, the test+ // above would vacuously pass and guard nothing.+ expect(imports.length).toBeGreaterThan(0);+ expect(imports).toContain('api/_lib/env.js');+ });++ it.each(crossBoundaryImports())('Dockerfile COPYs the source for %s', (target) => {+ const covered = copies.some((c) => target === c || target.startsWith(`${c}/`));+ expect(+ covered,+ `workers/agora-citizens imports ${target}, but no COPY in workers/agora-citizens/Dockerfile ` ++ `brings it into the image. The build will still succeed and the container will crash on boot ` ++ `with "Cannot find module". Add a COPY for it.\nCurrent COPY sources: ${copies.join(', ')}`,+ ).toBe(true);+ });+});diff --git a/workers/agora-citizens/Dockerfile b/workers/agora-citizens/Dockerfileindex db8cad8aa..70da1aa32 100644--- a/workers/agora-citizens/Dockerfile+++ b/workers/agora-citizens/Dockerfile@@ -24,7 +24,19 @@ RUN npm ci --ignore-scripts || npm install --ignore-scriptsCOPY solana-agent-sdk ./solana-agent-sdkRUN cd solana-agent-sdk && (npm ci --ignore-scripts || npm install --ignore-scripts) && npm run build-# Worker source (imports only its own files + @three-ws/solana-agent + node deps).+# Repo code the worker imports from OUTSIDE its own directory. It runs outside+# api/, but still reaches across that boundary:+# config.js -> api/_lib/env.js (resolveDatabaseUrl)+# store.js -> api/_lib/feed.js (the feed's ALLOWED_TYPES)+# work/_skills.js-> api/_lib/r2.js (deliverable upload, dynamic import)+# work/sculptor.js -> packages/forge (text/image -> GLB)+# Omitting any of these makes the image BUILD fine and then crash on boot with+# "Cannot find module", so tests/agora-worker-image.test.js pins this list+# against the real imports.+COPY api/_lib ./api/_lib+COPY packages/forge ./packages/forge++# Worker source.COPY workers/agora-citizens ./workers/agora-citizensRUN npm prune --omit=dev --ignore-scripts || true