@otium-team/negotium 0.23.13 → 0.23.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/dist/agent-helpers.js +321 -198
- package/dist/agent-helpers.js.map +16 -15
- package/dist/background-bash.js +37 -8
- package/dist/background-bash.js.map +5 -4
- package/dist/browser-runtime.js +55 -26
- package/dist/browser-runtime.js.map +5 -4
- package/dist/{chunk-mk9x18jn.js → chunk-3hf8y6bd.js} +3 -3
- package/dist/{chunk-mk9x18jn.js.map → chunk-3hf8y6bd.js.map} +2 -2
- package/dist/{chunk-22kg3fsw.js → chunk-d1c2wt8q.js} +6 -2
- package/dist/{chunk-22kg3fsw.js.map → chunk-d1c2wt8q.js.map} +1 -1
- package/dist/{chunk-wf7ny8eq.js → chunk-m1ngkjdd.js} +1 -1
- package/dist/{chunk-qd0vtfm2.js → chunk-ng13grfj.js} +69 -37
- package/dist/{chunk-qd0vtfm2.js.map → chunk-ng13grfj.js.map} +7 -6
- package/dist/{chunk-d4j77adx.js → chunk-pesnv5zv.js} +41 -11
- package/dist/chunk-pesnv5zv.js.map +14 -0
- package/dist/hosted-agent.js +11 -6
- package/dist/hosted-agent.js.map +6 -6
- package/dist/main.js +37054 -36798
- package/dist/main.js.map +86 -84
- package/dist/mcp-factories.js +338 -215
- package/dist/mcp-factories.js.map +15 -14
- package/dist/media.js +40 -11
- package/dist/media.js.map +5 -4
- package/dist/prompts.js +69 -10
- package/dist/prompts.js.map +7 -6
- package/dist/query-runtime.js +42 -13
- package/dist/query-runtime.js.map +5 -4
- package/dist/registry.js +7 -5
- package/dist/registry.js.map +3 -3
- package/dist/rollout.js +2 -2
- package/dist/runtime/src/agents/claude-registry.ts +2 -1
- package/dist/runtime/src/agents/explicit-agent-switch.ts +1 -1
- package/dist/runtime/src/agents/mcp-tools/self-config.ts +1 -1
- package/dist/runtime/src/agents/mcp-tools/spawn-subagent.ts +9 -1
- package/dist/runtime/src/agents/model-catalog.ts +13 -0
- package/dist/runtime/src/platform/browser-backend.ts +73 -0
- package/dist/runtime/src/platform/config.ts +3 -0
- package/dist/runtime/src/platform/mcp-config.ts +3 -0
- package/dist/runtime/src/prompts/builders.ts +11 -2
- package/dist/runtime/src/prompts/sessions/_shared-tools.md +2 -0
- package/dist/runtime/src/runtime/turn-event-stream.ts +34 -6
- package/dist/runtime/src/runtime/turn-runner.ts +59 -2
- package/dist/runtime/src/storage/token-stats.ts +4 -0
- package/dist/runtime/src/version.ts +1 -1
- package/dist/runtime-helpers.js +56 -27
- package/dist/runtime-helpers.js.map +5 -4
- package/dist/storage.js +3 -1
- package/dist/storage.js.map +3 -3
- package/dist/types/packages/core/src/platform/browser-backend.d.ts +8 -0
- package/dist/types/packages/core/src/platform/config.d.ts +2 -0
- package/dist/types/packages/core/src/version.d.ts +1 -1
- package/dist/vault.js +45 -16
- package/dist/vault.js.map +5 -4
- package/package.json +1 -1
- package/dist/chunk-d4j77adx.js.map +0 -13
- /package/dist/{chunk-wf7ny8eq.js.map → chunk-m1ngkjdd.js.map} +0 -0
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
"sourcesContent": [
|
|
5
5
|
"import { type ChildProcessWithoutNullStreams, spawn } from \"node:child_process\";\nimport { codexCliScriptPath } from \"#agents/codex-native-multi-agent\";\nimport { hostedCodexHomePath } from \"#agents/execution-host\";\nimport { latestCodexRolloutPath } from \"#agents/rollout/codex\";\nimport { NEGOTIUM_VERSION } from \"#version\";\n\ninterface CodexAppServerForkResult {\n forkId: string;\n rolloutPath: string;\n}\n\ninterface CodexAppServerForkHost {\n spawnServer(): ChildProcessWithoutNullStreams;\n findRolloutPath(threadId: string): string | undefined;\n timeoutMs: number;\n}\n\ntype JsonRpcResponse = {\n id?: number;\n result?: { thread?: { id?: unknown } };\n error?: { message?: unknown };\n};\n\nexport function createCodexAppServerForker(host: CodexAppServerForkHost) {\n return async (parentThreadId: string): Promise<CodexAppServerForkResult> => {\n const child = host.spawnServer();\n\n return await new Promise<CodexAppServerForkResult>((resolve, reject) => {\n let settled = false;\n let stdoutBuffer = \"\";\n let stderr = \"\";\n const timer = setTimeout(\n () => finish(new Error(\"Codex thread fork timed out\")),\n host.timeoutMs,\n );\n\n const finish = (error?: Error, result?: CodexAppServerForkResult) => {\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n try {\n child.stdin.end();\n child.kill();\n } catch {\n // The app server may already have exited after stdin closed.\n }\n if (error) reject(error);\n else if (result) resolve(result);\n else reject(new Error(\"Codex thread fork returned no result\"));\n };\n\n const send = (message: Record<string, unknown>) => {\n child.stdin.write(`${JSON.stringify(message)}\\n`);\n };\n\n child.stderr.on(\"data\", (chunk) => {\n if (stderr.length < 8_192) stderr += String(chunk);\n });\n child.on(\"error\", (error) => finish(error));\n child.on(\"exit\", (code, signal) => {\n if (settled) return;\n const detail = signal ? `signal ${signal}` : `code ${code ?? 1}`;\n finish(\n new Error(\n `Codex app server exited with ${detail}${stderr.trim() ? `: ${stderr.trim()}` : \"\"}`,\n ),\n );\n });\n child.stdout.on(\"data\", (chunk) => {\n stdoutBuffer += String(chunk);\n for (;;) {\n const newline = stdoutBuffer.indexOf(\"\\n\");\n if (newline < 0) break;\n const line = stdoutBuffer.slice(0, newline);\n stdoutBuffer = stdoutBuffer.slice(newline + 1);\n let message: JsonRpcResponse;\n try {\n message = JSON.parse(line) as JsonRpcResponse;\n } catch {\n continue;\n }\n\n if (message.id === 1) {\n if (message.error) {\n finish(new Error(String(message.error.message || \"Codex initialization failed\")));\n return;\n }\n send({ method: \"initialized\" });\n send({ id: 2, method: \"thread/fork\", params: { threadId: parentThreadId } });\n continue;\n }\n if (message.id !== 2) continue;\n if (message.error) {\n finish(new Error(String(message.error.message || \"Codex thread fork failed\")));\n return;\n }\n const forkId = message.result?.thread?.id;\n if (typeof forkId !== \"string\" || !forkId) {\n finish(new Error(\"Codex thread fork returned no thread id\"));\n return;\n }\n const rolloutPath = host.findRolloutPath(forkId);\n if (!rolloutPath) {\n finish(new Error(`Codex thread fork rollout was not found for ${forkId}`));\n return;\n }\n finish(undefined, { forkId, rolloutPath });\n return;\n }\n });\n\n send({\n id: 1,\n method: \"initialize\",\n params: {\n clientInfo: { name: \"negotium\", version: NEGOTIUM_VERSION },\n },\n });\n });\n };\n}\n\nconst forkCodexThread = createCodexAppServerForker({\n spawnServer() {\n return spawn(process.execPath, [codexCliScriptPath(), \"app-server\", \"--stdio\"], {\n env: { ...process.env, CODEX_HOME: hostedCodexHomePath() },\n stdio: [\"pipe\", \"pipe\", \"pipe\"],\n // Background stdio server — no console window on Windows. Ignored on POSIX.\n windowsHide: true,\n });\n },\n findRolloutPath: latestCodexRolloutPath,\n timeoutMs: 15_000,\n});\n\nexport async function forkCodexSession(parentThreadId: string): Promise<CodexAppServerForkResult> {\n return await forkCodexThread(parentThreadId);\n}\n",
|
|
6
6
|
"import { type ChildProcess, spawn } from \"node:child_process\";\nimport { randomUUID } from \"node:crypto\";\nimport {\n chmodSync,\n copyFileSync,\n existsSync,\n mkdtempSync,\n readFileSync,\n renameSync,\n rmSync,\n unlinkSync,\n writeFileSync,\n} from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { NEGOTIUM_VERSION } from \"#version\";\n\ntype CodexModel = Record<string, unknown>;\ntype CodexModelCache = {\n client_version?: unknown;\n models?: unknown;\n};\n\n// Resolving these as *modules* (`require.resolve`/`import.meta.resolve`) broke\n// under a plain Node process (which is how Codex itself spawns this server —\n// Bun's resolver is lax enough that it didn't notice) once `@openai/codex-sdk`\n// 0.165.0 dropped CommonJS support (no `\"require\"` condition in its `exports`\n// map), and `@openai/codex` was never importable to begin with — it ships only\n// a CLI `bin`, no `main`/`exports` at all. Neither package needs to be\n// imported here, only located, so this reimplements Node's own node_modules\n// directory-walk (the same algorithm `require`/`import` use internally) over\n// plain filesystem checks instead, which doesn't care what either package's\n// module shape is.\nfunction findPackageJson(specifier: string, searchFromDir: string): string {\n let dir = searchFromDir;\n for (;;) {\n const candidate = join(dir, \"node_modules\", specifier, \"package.json\");\n if (existsSync(candidate)) return candidate;\n const parent = dirname(dir);\n if (parent === dir) {\n throw new Error(`Could not locate node_modules/${specifier} starting from ${searchFromDir}`);\n }\n dir = parent;\n }\n}\n\nconst thisModuleDir = dirname(fileURLToPath(import.meta.url));\nconst codexSdkPackagePath = findPackageJson(\"@openai/codex-sdk\", thisModuleDir);\nconst bundledCodexPackagePath = findPackageJson(\"@openai/codex\", dirname(codexSdkPackagePath));\n\nfunction readPackageVersion(packageJsonPath: string): string {\n const parsed = JSON.parse(readFileSync(packageJsonPath, \"utf8\")) as { version?: unknown };\n if (typeof parsed.version !== \"string\" || !parsed.version.trim()) {\n throw new Error(`Codex package has no valid version: ${packageJsonPath}`);\n }\n return parsed.version;\n}\n\nexport const BUNDLED_CODEX_VERSION = readPackageVersion(bundledCodexPackagePath);\nconst SAFE_BUNDLED_CODEX_VERSION = BUNDLED_CODEX_VERSION.replace(/[^a-zA-Z0-9._-]/g, \"_\");\nconst NEGOTIUM_MODEL_CACHE = `negotium-models-cache-${SAFE_BUNDLED_CODEX_VERSION}.json`;\nconst NEGOTIUM_MODEL_CATALOG = `negotium-model-catalog-${SAFE_BUNDLED_CODEX_VERSION}.json`;\n\nexport function codexCliScriptPath(): string {\n return join(dirname(bundledCodexPackagePath), \"bin\", \"codex.js\");\n}\n\nfunction parseCodexModelCache(contents: string, sourcePath: string): CodexModelCache {\n let parsed: CodexModelCache;\n try {\n parsed = JSON.parse(contents) as CodexModelCache;\n } catch (error) {\n throw new Error(`Codex model cache is invalid JSON: ${sourcePath}`, { cause: error });\n }\n if (!Array.isArray(parsed.models) || parsed.models.length === 0) {\n throw new Error(`Codex model cache has no models: ${sourcePath}`);\n }\n return parsed;\n}\n\nfunction readCodexModelCache(cachePath: string): {\n contents: string;\n parsed: CodexModelCache;\n} {\n const contents = readFileSync(cachePath, \"utf8\");\n return { contents, parsed: parseCodexModelCache(contents, cachePath) };\n}\n\nexport function readCompatibleCodexModelCache(cachePath: string): {\n contents: string;\n parsed: CodexModelCache;\n} {\n const cache = readCodexModelCache(cachePath);\n if (cache.parsed.client_version !== BUNDLED_CODEX_VERSION) {\n const found =\n typeof cache.parsed.client_version === \"string\"\n ? cache.parsed.client_version\n : \"missing or invalid\";\n throw new Error(\n `Codex model cache version ${found} does not match Negotium's bundled Codex ${BUNDLED_CODEX_VERSION}: ${cachePath}`,\n );\n }\n return cache;\n}\n\nfunction writePrivateFileAtomic(path: string, contents: string): void {\n if (existsSync(path) && readFileSync(path, \"utf8\") === contents) return;\n\n const tempPath = `${path}.${process.pid}.${randomUUID()}.tmp`;\n try {\n writeFileSync(tempPath, contents, { encoding: \"utf8\", mode: 0o600 });\n renameSync(tempPath, path);\n chmodSync(path, 0o600);\n } finally {\n try {\n unlinkSync(tempPath);\n } catch {\n // renameSync normally consumed the temporary file.\n }\n }\n}\n\nexport function bundledCodexModelCachePath(authFilePath: string): string {\n return join(dirname(authFilePath), NEGOTIUM_MODEL_CACHE);\n}\n\nasync function bootstrapCodexModelCache(codexHome: string, cachePath: string): Promise<void> {\n const child = spawn(process.execPath, [codexCliScriptPath(), \"app-server\", \"--stdio\"], {\n env: { ...process.env, CODEX_HOME: codexHome },\n stdio: [\"pipe\", \"pipe\", \"pipe\"],\n // Background stdio server — no console window on Windows. Ignored on POSIX.\n windowsHide: true,\n });\n\n const refreshed = new Promise<void>((resolve, reject) => {\n let settled = false;\n let stdoutBuffer = \"\";\n let stderr = \"\";\n const timer = setTimeout(\n () => finish(new Error(\"timed out while refreshing the Codex model catalog\")),\n 15_000,\n );\n\n const finish = (error?: Error) => {\n if (settled) return;\n settled = true;\n clearTimeout(timer);\n try {\n child.stdin.end();\n child.kill();\n } catch {\n // The app server may already have exited after stdin closed.\n }\n if (error) reject(error);\n else if (!existsSync(cachePath)) reject(new Error(\"Codex did not create its model cache\"));\n else resolve();\n };\n\n const send = (message: Record<string, unknown>) => {\n child.stdin.write(`${JSON.stringify(message)}\\n`);\n };\n\n child.stderr.on(\"data\", (chunk) => {\n if (stderr.length < 4_096) stderr += String(chunk);\n });\n child.on(\"error\", (error) => finish(error));\n child.on(\"exit\", (code, signal) => {\n if (!settled) {\n finish(\n new Error(\n `Codex model catalog refresh exited with ${signal ? `signal ${signal}` : `code ${code ?? 1}`}${stderr.trim() ? `: ${stderr.trim()}` : \"\"}`,\n ),\n );\n }\n });\n child.stdout.on(\"data\", (chunk) => {\n stdoutBuffer += String(chunk);\n for (;;) {\n const newline = stdoutBuffer.indexOf(\"\\n\");\n if (newline < 0) break;\n const line = stdoutBuffer.slice(0, newline);\n stdoutBuffer = stdoutBuffer.slice(newline + 1);\n let message: { id?: number; error?: { message?: string } };\n try {\n message = JSON.parse(line) as typeof message;\n } catch {\n continue;\n }\n if (message.id === 1) {\n if (message.error) {\n finish(new Error(message.error.message || \"Codex initialization failed\"));\n return;\n }\n send({ method: \"initialized\" });\n send({ id: 2, method: \"model/list\", params: { includeHidden: true } });\n } else if (message.id === 2) {\n if (message.error) {\n finish(new Error(message.error.message || \"Codex model listing failed\"));\n } else {\n finish();\n }\n return;\n }\n }\n });\n\n send({\n id: 1,\n method: \"initialize\",\n params: {\n clientInfo: { name: \"negotium\", version: NEGOTIUM_VERSION },\n capabilities: { experimentalApi: true },\n },\n });\n });\n\n try {\n await refreshed;\n } finally {\n // `child.kill()` only signals. The caller deletes CODEX_HOME right after we\n // return, and Windows cannot delete a directory the child still holds open\n // (EBUSY), so wait for the process to actually exit first.\n await waitForChildExit(child, CODEX_BOOTSTRAP_EXIT_WAIT_MS);\n }\n}\n\nconst CODEX_BOOTSTRAP_EXIT_WAIT_MS = 3_000;\n\nfunction waitForChildExit(child: ChildProcess, timeoutMs: number): Promise<void> {\n if (child.exitCode !== null || child.signalCode !== null) return Promise.resolve();\n return new Promise((resolve) => {\n const timer = setTimeout(resolve, timeoutMs);\n timer.unref?.();\n child.once(\"exit\", () => {\n clearTimeout(timer);\n resolve();\n });\n });\n}\n\n/**\n * Remove the temporary CODEX_HOME. On Windows a just-exited child (or an\n * antivirus scan of the files it wrote) can keep the directory busy for a\n * moment, so retry, and never let cleanup of a throwaway directory fail a turn\n * whose result was already read. POSIX keeps the original behaviour: unlinking\n * open files works there, and a genuine failure still surfaces.\n */\nfunction removeIsolatedCodexHome(dir: string): void {\n if (process.platform !== \"win32\") {\n rmSync(dir, { recursive: true, force: true });\n return;\n }\n try {\n rmSync(dir, { recursive: true, force: true, maxRetries: 10, retryDelay: 100 });\n } catch {\n // Best effort: the OS temp cleaner will reclaim it.\n }\n}\n\nasync function bootstrapIsolatedCodexModelCache(\n authFilePath: string,\n bootstrap: (codexHome: string, cachePath: string) => Promise<void>,\n): Promise<string> {\n const sourceHome = dirname(authFilePath);\n const isolatedHome = mkdtempSync(join(tmpdir(), \"negotium-codex-models-\"));\n const isolatedCachePath = join(isolatedHome, \"models_cache.json\");\n\n try {\n const isolatedAuthPath = join(isolatedHome, \"auth.json\");\n copyFileSync(authFilePath, isolatedAuthPath);\n chmodSync(isolatedAuthPath, 0o600);\n\n // Preserve custom provider configuration while keeping the bundled CLI's\n // cache write completely outside the user's shared CODEX_HOME.\n const sourceConfigPath = join(sourceHome, \"config.toml\");\n if (existsSync(sourceConfigPath)) {\n const isolatedConfigPath = join(isolatedHome, \"config.toml\");\n copyFileSync(sourceConfigPath, isolatedConfigPath);\n chmodSync(isolatedConfigPath, 0o600);\n }\n\n await bootstrap(isolatedHome, isolatedCachePath);\n return readCompatibleCodexModelCache(isolatedCachePath).contents;\n } finally {\n removeIsolatedCodexHome(isolatedHome);\n }\n}\n\nexport async function ensureCodexModelCache(\n authFilePath: string,\n bootstrap: (codexHome: string, cachePath: string) => Promise<void> = bootstrapCodexModelCache,\n): Promise<string> {\n const codexHome = dirname(authFilePath);\n const configuredCachePath = process.env.NEGOTIUM_CODEX_MODELS_CACHE_FILE;\n if (configuredCachePath) {\n if (!existsSync(configuredCachePath)) {\n throw new Error(`Configured Codex model cache does not exist: ${configuredCachePath}`);\n }\n readCompatibleCodexModelCache(configuredCachePath);\n return configuredCachePath;\n }\n\n // The global Codex CLI owns models_cache.json and may update it to a schema\n // newer than the SDK bundled by Negotium. Snapshot a cache generated for our\n // exact bundled version so later global CLI updates cannot break turns.\n const bundledCachePath = bundledCodexModelCachePath(authFilePath);\n const sharedCachePath = join(codexHome, \"models_cache.json\");\n if (existsSync(sharedCachePath)) {\n try {\n const shared = readCompatibleCodexModelCache(sharedCachePath);\n // Keep model metadata fresh while the global CLI remains compatible.\n writePrivateFileAtomic(bundledCachePath, shared.contents);\n return bundledCachePath;\n } catch {\n // A compatible private snapshot is safer than failing because another\n // process briefly exposed an incomplete shared-cache write.\n }\n }\n\n if (existsSync(bundledCachePath)) {\n try {\n readCompatibleCodexModelCache(bundledCachePath);\n return bundledCachePath;\n } catch {\n // Re-bootstrap below instead of passing a corrupt or version-mismatched\n // private snapshot into this SDK version.\n }\n }\n\n const refreshedContents = await bootstrapIsolatedCodexModelCache(authFilePath, bootstrap);\n writePrivateFileAtomic(bundledCachePath, refreshedContents);\n return bundledCachePath;\n}\n\n/**\n * Codex can resolve model metadata before `features.multi_agent=false`, so a\n * model-advertised v1/v2 value may still register native collaboration tools.\n * Feed Codex an authoritative copy of its own catalog with only that field\n * disabled. Runtime MCP delegation remains available independently.\n */\nexport function writeCodexCatalogWithNativeMultiAgentDisabled(\n authFilePath: string,\n sourcePath: string,\n): string {\n const codexHome = dirname(authFilePath);\n const outputPath = join(codexHome, NEGOTIUM_MODEL_CATALOG);\n\n const parsed = readCodexModelCache(sourcePath).parsed;\n\n const models = (parsed.models as unknown[]).map((model, index): CodexModel => {\n if (!model || typeof model !== \"object\" || Array.isArray(model)) {\n throw new Error(`Codex model cache entry ${index} is invalid: ${sourcePath}`);\n }\n return { ...(model as CodexModel), multi_agent_version: \"disabled\" };\n });\n const contents = `${JSON.stringify({ models }, null, 2)}\\n`;\n writePrivateFileAtomic(outputPath, contents);\n return outputPath;\n}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C;AAAA,UACzC;AAAA,QACF;AAAA,OACD;AAAA,MAED,KAAK;AAAA,QACH,IAAI;AAAA,QACJ,QAAQ;AAAA,QACR,QAAQ;AAAA,UACN,YAAY,EAAE,MAAM,YAAY,SAAS,iBAAiB;AAAA,QAC5D;AAAA,MACF,CAAC;AAAA,KACF;AAAA;AAAA;AAIL,IAAM,kBAAkB,2BAA2B;AAAA,EACjD,WAAW,GAAG;AAAA,IACZ,OAAO,MAAM,QAAQ,UAAU,CAAC,mBAAmB,GAAG,cAAc,SAAS,GAAG;AAAA,MAC9E,KAAK,KAAK,QAAQ,KAAK,YAAY,oBAAoB,EAAE;AAAA,MACzD,OAAO,CAAC,QAAQ,QAAQ,MAAM;AAAA,MAE9B,aAAa;AAAA,IACf,CAAC;AAAA;AAAA,EAEH,iBAAiB;AAAA,EACjB,WAAW;AACb,CAAC;AAED,eAAsB,gBAAgB,CAAC,gBAA2D;AAAA,EAChG,OAAO,MAAM,gBAAgB,cAAc;AAAA;",
|
|
10
|
-
"debugId": "
|
|
10
|
+
"debugId": "68F309711105428864756E2164756E21",
|
|
11
11
|
"names": []
|
|
12
12
|
}
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
PROJECT_ROOT2,
|
|
5
5
|
WORKSPACE_DIR2,
|
|
6
6
|
TOPIC_WORKSPACE_DIR2,
|
|
7
|
+
BROWSER_BACKEND2,
|
|
7
8
|
BINARIES_DIR2,
|
|
8
9
|
DM_WORKSPACE_DIR2,
|
|
9
10
|
SESSION_WORKSPACE_DIR2,
|
|
@@ -34,9 +35,10 @@ import {
|
|
|
34
35
|
MODEL_SONNET2,
|
|
35
36
|
MODEL_OPUS2,
|
|
36
37
|
MODEL_FABLE2,
|
|
38
|
+
MODEL_FABLE_5_22,
|
|
37
39
|
FALLBACK_AGENT2,
|
|
38
40
|
codexAuthFilePath2
|
|
39
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-pesnv5zv.js";
|
|
40
42
|
export {
|
|
41
43
|
AGENT_HEALTH_SERVER2 as AGENT_HEALTH_SERVER,
|
|
42
44
|
BASHRS_SPILL_ROOT2 as BASHRS_SPILL_ROOT,
|
|
@@ -45,6 +47,7 @@ export {
|
|
|
45
47
|
BG_BASH_BASE_PORT2 as BG_BASH_BASE_PORT,
|
|
46
48
|
BG_BASH_MAX_PORT2 as BG_BASH_MAX_PORT,
|
|
47
49
|
BINARIES_DIR2 as BINARIES_DIR,
|
|
50
|
+
BROWSER_BACKEND2 as BROWSER_BACKEND,
|
|
48
51
|
CANONICAL_MCP_PROXY_SERVER2 as CANONICAL_MCP_PROXY_SERVER,
|
|
49
52
|
CLAUDE_EXECUTABLE2 as CLAUDE_EXECUTABLE,
|
|
50
53
|
DECISION_SERVER2 as DECISION_SERVER,
|
|
@@ -52,6 +55,7 @@ export {
|
|
|
52
55
|
FALLBACK_AGENT2 as FALLBACK_AGENT,
|
|
53
56
|
FILE_TAG_REGEX2 as FILE_TAG_REGEX,
|
|
54
57
|
MODEL_FABLE2 as MODEL_FABLE,
|
|
58
|
+
MODEL_FABLE_5_22 as MODEL_FABLE_5_2,
|
|
55
59
|
MODEL_OPUS2 as MODEL_OPUS,
|
|
56
60
|
MODEL_SONNET2 as MODEL_SONNET,
|
|
57
61
|
NEGOTIUM_PORT2 as NEGOTIUM_PORT,
|
|
@@ -76,4 +80,4 @@ export {
|
|
|
76
80
|
resolveTopicWorkspaceDir2 as resolveTopicWorkspaceDir
|
|
77
81
|
};
|
|
78
82
|
|
|
79
|
-
//# debugId=
|
|
83
|
+
//# debugId=2E7AF00597D2B39264756E2164756E21
|
|
@@ -7,19 +7,47 @@ import { resolve as resolve3 } from "path";
|
|
|
7
7
|
import { execFileSync } from "child_process";
|
|
8
8
|
import { randomBytes } from "crypto";
|
|
9
9
|
import {
|
|
10
|
-
accessSync,
|
|
10
|
+
accessSync as accessSync2,
|
|
11
11
|
chmodSync,
|
|
12
|
-
constants,
|
|
12
|
+
constants as constants2,
|
|
13
13
|
existsSync,
|
|
14
14
|
mkdirSync,
|
|
15
15
|
readFileSync,
|
|
16
16
|
writeFileSync
|
|
17
17
|
} from "fs";
|
|
18
18
|
import { createRequire } from "module";
|
|
19
|
-
import { homedir } from "os";
|
|
20
|
-
import { dirname, join, resolve } from "path";
|
|
19
|
+
import { homedir as homedir2 } from "os";
|
|
20
|
+
import { dirname, join as join2, resolve } from "path";
|
|
21
21
|
import { fileURLToPath, pathToFileURL } from "url";
|
|
22
22
|
|
|
23
|
+
// ../../packages/core/src/platform/browser-backend.ts
|
|
24
|
+
import { accessSync, constants, statSync } from "fs";
|
|
25
|
+
import { homedir } from "os";
|
|
26
|
+
import { delimiter, isAbsolute, join } from "path";
|
|
27
|
+
function resolveBrowserBackend(value, findEgoBrowser = resolveEgoBrowserBin) {
|
|
28
|
+
const backend = value?.trim();
|
|
29
|
+
if (!backend)
|
|
30
|
+
return findEgoBrowser() ? "egolite" : "chrome";
|
|
31
|
+
if (backend === "chrome" || backend === "egolite")
|
|
32
|
+
return backend;
|
|
33
|
+
throw new Error("NEGOTIUM_BROWSER_BACKEND must be chrome or egolite");
|
|
34
|
+
}
|
|
35
|
+
function resolveEgoBrowserBin(path = process.env.PATH ?? "", home = homedir()) {
|
|
36
|
+
const names = process.platform === "win32" ? ["ego-browser.exe"] : ["ego-browser"];
|
|
37
|
+
const directories = [...path.split(delimiter).filter(isAbsolute), join(home, ".local", "bin")];
|
|
38
|
+
for (const directory of directories) {
|
|
39
|
+
for (const name of names) {
|
|
40
|
+
const candidate = join(directory, name);
|
|
41
|
+
try {
|
|
42
|
+
accessSync(candidate, constants.X_OK);
|
|
43
|
+
if (statSync(candidate).isFile())
|
|
44
|
+
return candidate;
|
|
45
|
+
} catch {}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
23
51
|
// ../../packages/core/src/types.ts
|
|
24
52
|
var SUPPORTED_AGENTS = ["maestro", "claude", "codex"];
|
|
25
53
|
function isAgentKind(value) {
|
|
@@ -78,7 +106,7 @@ var logger = createStdioLogger();
|
|
|
78
106
|
function envText(envKey) {
|
|
79
107
|
return readEnvText(process.env, envKey);
|
|
80
108
|
}
|
|
81
|
-
var HOME =
|
|
109
|
+
var HOME = homedir2();
|
|
82
110
|
function resolveStateDir() {
|
|
83
111
|
const configured = envText("NEGOTIUM_STATE_DIR");
|
|
84
112
|
if (false) {}
|
|
@@ -127,6 +155,7 @@ var TOPIC_WORKSPACE_DIR = resolve(WORKSPACE_DIR, "topics");
|
|
|
127
155
|
var SHARED_WIKI_DIR = resolve(WORKSPACE_DIR, "wiki");
|
|
128
156
|
var CRON_WORKSPACE_DIR = resolve(WORKSPACE_DIR, "cron");
|
|
129
157
|
var BROWSER_DIR = resolveLocalStateDir("NEGOTIUM_BROWSER_DIR", "browser");
|
|
158
|
+
var BROWSER_BACKEND = resolveBrowserBackend(envText("NEGOTIUM_BROWSER_BACKEND"));
|
|
130
159
|
var BROWSER_PROFILES_DIR = resolve(BROWSER_DIR, "profiles");
|
|
131
160
|
var BINARIES_DIR = resolve(STATE_DIR, "binaries");
|
|
132
161
|
var SECRETS_DIR = resolve(STATE_DIR, "secrets");
|
|
@@ -174,7 +203,7 @@ function resolveBrowserRsBin(envValue) {
|
|
|
174
203
|
}
|
|
175
204
|
const candidate = override ? resolve(override) : resolve(BINARIES_DIR, "browser-rs", BROWSER_RS_VERSION, `browser-rs${BINARY_EXTENSION}`);
|
|
176
205
|
try {
|
|
177
|
-
|
|
206
|
+
accessSync2(candidate, constants2.X_OK);
|
|
178
207
|
return browserRsMeetsMinimumVersion(candidate) ? candidate : undefined;
|
|
179
208
|
} catch {
|
|
180
209
|
return;
|
|
@@ -187,7 +216,7 @@ function resolveBashRsBin(envValue) {
|
|
|
187
216
|
const override = envValue?.trim();
|
|
188
217
|
const candidate = override ? resolve(override) : resolve(BINARIES_DIR, "bash-rs", BASH_RS_VERSION, `bash-rs${BINARY_EXTENSION}`);
|
|
189
218
|
try {
|
|
190
|
-
|
|
219
|
+
accessSync2(candidate, constants2.X_OK);
|
|
191
220
|
return candidate;
|
|
192
221
|
} catch {
|
|
193
222
|
return;
|
|
@@ -222,7 +251,7 @@ function safeWorkspaceSegment(value, fallback) {
|
|
|
222
251
|
return safeRuntimePathSegment(value, fallback);
|
|
223
252
|
}
|
|
224
253
|
function resolveTopicWorkspaceDir(topicId) {
|
|
225
|
-
return
|
|
254
|
+
return join2(TOPIC_WORKSPACE_DIR, safeWorkspaceSegment(topicId, "topic"));
|
|
226
255
|
}
|
|
227
256
|
function loadOrCreateLocalSecret(envKey, filename, options = {}) {
|
|
228
257
|
const envValue = envText(envKey);
|
|
@@ -312,6 +341,7 @@ var FILE_TAG_REGEX = new RegExp(`\\[FILE:(${ABSOLUTE_PATH_PREFIX}[^\\]]+)\\]`, "
|
|
|
312
341
|
var MODEL_SONNET = "claude-sonnet-5";
|
|
313
342
|
var MODEL_OPUS = "claude-opus-5-5";
|
|
314
343
|
var MODEL_FABLE = "claude-fable-5-1";
|
|
344
|
+
var MODEL_FABLE_5_2 = "claude-fable-5-2";
|
|
315
345
|
var FALLBACK_AGENT = resolveFallbackAgent(process.env);
|
|
316
346
|
var FALLBACK_MODEL = envText("FALLBACK_MODEL") ?? envText("DEFAULT_MODEL");
|
|
317
347
|
var DEFAULT_TOPIC_EFFORT = (() => {
|
|
@@ -334,12 +364,12 @@ var WHISPER_MODEL_MLX = envText("WHISPER_MODEL_MLX") ?? "mlx-community/whisper-l
|
|
|
334
364
|
var _envMaxTellDepth = Number.parseInt(process.env.MAX_TELL_DEPTH ?? "", 10);
|
|
335
365
|
var MAX_TELL_DEPTH = Number.isInteger(_envMaxTellDepth) && _envMaxTellDepth > 0 ? _envMaxTellDepth : 20;
|
|
336
366
|
function codexAuthFilePath() {
|
|
337
|
-
return process.env.NEGOTIUM_CODEX_AUTH_FILE ||
|
|
367
|
+
return process.env.NEGOTIUM_CODEX_AUTH_FILE || join2(process.env.CODEX_HOME || join2(homedir2(), ".codex"), "auth.json");
|
|
338
368
|
}
|
|
339
369
|
|
|
340
370
|
// ../../packages/core/src/platform/paths.ts
|
|
341
371
|
import { existsSync as existsSync2, realpathSync } from "fs";
|
|
342
|
-
import { dirname as dirname2, isAbsolute, relative, resolve as resolve2, sep } from "path";
|
|
372
|
+
import { dirname as dirname2, isAbsolute as isAbsolute2, relative, resolve as resolve2, sep } from "path";
|
|
343
373
|
function normalizeExistingOrResolved(filePath) {
|
|
344
374
|
const resolved = resolve2(filePath);
|
|
345
375
|
try {
|
|
@@ -363,7 +393,7 @@ function isInsideDir(childPath, parentDir) {
|
|
|
363
393
|
const parent = normalizeExistingOrResolved(parentDir);
|
|
364
394
|
const child = normalizeExistingOrResolved(childPath);
|
|
365
395
|
const rel = relative(parent, child);
|
|
366
|
-
return rel === "" || !!rel && !rel.startsWith("..") && !
|
|
396
|
+
return rel === "" || !!rel && !rel.startsWith("..") && !isAbsolute2(rel);
|
|
367
397
|
}
|
|
368
398
|
function toDisplayPath(filePath) {
|
|
369
399
|
return filePath.split(sep).join("/");
|
|
@@ -553,7 +583,7 @@ import {
|
|
|
553
583
|
openSync,
|
|
554
584
|
readFileSync as readFileSync2,
|
|
555
585
|
renameSync,
|
|
556
|
-
statSync,
|
|
586
|
+
statSync as statSync2,
|
|
557
587
|
unlinkSync as unlinkSync2,
|
|
558
588
|
writeFileSync as writeFileSync2
|
|
559
589
|
} from "fs";
|
|
@@ -707,7 +737,7 @@ function agentAliases(agent) {
|
|
|
707
737
|
"gpt-6-astra"
|
|
708
738
|
];
|
|
709
739
|
case "claude":
|
|
710
|
-
return ["claude", "\uD074\uB85C\uB4DC", "sonnet", "opus", "fable"];
|
|
740
|
+
return ["claude", "\uD074\uB85C\uB4DC", "sonnet", "opus", "fable", "fable-5.2"];
|
|
711
741
|
case "maestro":
|
|
712
742
|
return [
|
|
713
743
|
"maestro",
|
|
@@ -1393,8 +1423,8 @@ var GENERAL_TOPIC_ID = "general";
|
|
|
1393
1423
|
|
|
1394
1424
|
// ../../packages/core/src/storage/storage-host.ts
|
|
1395
1425
|
import { mkdirSync as mkdirSync4 } from "fs";
|
|
1396
|
-
import { homedir as
|
|
1397
|
-
import { dirname as dirname4, join as
|
|
1426
|
+
import { homedir as homedir3 } from "os";
|
|
1427
|
+
import { dirname as dirname4, join as join3, resolve as resolve5 } from "path";
|
|
1398
1428
|
|
|
1399
1429
|
// ../../packages/core/src/storage/sqlite.ts
|
|
1400
1430
|
var isBun = typeof process.versions.bun === "string";
|
|
@@ -1485,13 +1515,13 @@ function envPath(name, fallback) {
|
|
|
1485
1515
|
return resolve5(value || fallback);
|
|
1486
1516
|
}
|
|
1487
1517
|
function defaultStateDir() {
|
|
1488
|
-
return envPath("NEGOTIUM_STATE_DIR",
|
|
1518
|
+
return envPath("NEGOTIUM_STATE_DIR", join3(homedir3(), ".negotium"));
|
|
1489
1519
|
}
|
|
1490
1520
|
function defaultDataDir() {
|
|
1491
|
-
return envPath("NEGOTIUM_DATA_DIR",
|
|
1521
|
+
return envPath("NEGOTIUM_DATA_DIR", join3(defaultStateDir(), "data"));
|
|
1492
1522
|
}
|
|
1493
1523
|
function defaultSessionsDatabasePath() {
|
|
1494
|
-
return envPath("SESSIONS_DB_PATH",
|
|
1524
|
+
return envPath("SESSIONS_DB_PATH", join3(resolveStorageDataDir(), "sessions.db"));
|
|
1495
1525
|
}
|
|
1496
1526
|
var SQLITE_INIT_RETRY_MS = 25;
|
|
1497
1527
|
var SQLITE_INIT_TIMEOUT_MS = 5000;
|
|
@@ -2668,6 +2698,8 @@ var MCP_CATALOG = {
|
|
|
2668
2698
|
playwright: {
|
|
2669
2699
|
...commonRuntimeMcpPolicy("playwright"),
|
|
2670
2700
|
build({ userId, session, topicId, playwrightPort, playwrightCapability, agent }) {
|
|
2701
|
+
if (BROWSER_BACKEND === "egolite")
|
|
2702
|
+
return null;
|
|
2671
2703
|
if (playwrightPort && playwrightCapability) {
|
|
2672
2704
|
const owner = browserOwnerForContext({ userId, session, topicId });
|
|
2673
2705
|
if (!owner)
|
|
@@ -3208,7 +3240,7 @@ function hideProviderIntrospectionForOtium(servers, topicId) {
|
|
|
3208
3240
|
|
|
3209
3241
|
// ../../packages/core/src/storage/vault.ts
|
|
3210
3242
|
import { chmodSync as chmodSync2, mkdirSync as mkdirSync5 } from "fs";
|
|
3211
|
-
import { join as
|
|
3243
|
+
import { join as join4 } from "path";
|
|
3212
3244
|
|
|
3213
3245
|
// ../../packages/core/src/storage/vault-crypto-core.ts
|
|
3214
3246
|
import { createCipheriv, createDecipheriv, createHash as createHash2, randomBytes as randomBytes3 } from "crypto";
|
|
@@ -3299,8 +3331,8 @@ function initializeVaultDatabase(database) {
|
|
|
3299
3331
|
}
|
|
3300
3332
|
}
|
|
3301
3333
|
function openVaultDatabase(dataDir) {
|
|
3302
|
-
const vaultDir =
|
|
3303
|
-
const path =
|
|
3334
|
+
const vaultDir = join4(dataDir, "vault");
|
|
3335
|
+
const path = join4(vaultDir, "vault.db");
|
|
3304
3336
|
mkdirSync5(vaultDir, { recursive: true, mode: 448 });
|
|
3305
3337
|
const database = new Database(path, { create: true });
|
|
3306
3338
|
chmodSync2(path, 384);
|
|
@@ -3427,16 +3459,16 @@ function hostedCodexHomePath() {
|
|
|
3427
3459
|
|
|
3428
3460
|
// ../../packages/core/src/agents/rollout/codex.ts
|
|
3429
3461
|
import { randomBytes as randomBytes4 } from "crypto";
|
|
3430
|
-
import { existsSync as existsSync3, readFileSync as readFileSync3, realpathSync as realpathSync3, statSync as
|
|
3431
|
-
import { basename, dirname as dirname6, join as
|
|
3462
|
+
import { existsSync as existsSync3, readFileSync as readFileSync3, realpathSync as realpathSync3, statSync as statSync3, unlinkSync as unlinkSync3 } from "fs";
|
|
3463
|
+
import { basename, dirname as dirname6, join as join5, resolve as resolve6 } from "path";
|
|
3432
3464
|
function codexSessionsDir() {
|
|
3433
|
-
return
|
|
3465
|
+
return join5(hostedCodexHomePath(), "sessions");
|
|
3434
3466
|
}
|
|
3435
3467
|
var _shellCache = null;
|
|
3436
3468
|
function loadCodexShell() {
|
|
3437
3469
|
if (_shellCache)
|
|
3438
3470
|
return _shellCache;
|
|
3439
|
-
const raw = readFileSync3(
|
|
3471
|
+
const raw = readFileSync3(join5(FIXTURES_DIR, "codex-shell.jsonl"), "utf8");
|
|
3440
3472
|
const lines = parseJsonlText(raw);
|
|
3441
3473
|
if (lines.length < 5) {
|
|
3442
3474
|
throw new Error(`loadCodexShell: expected >=5 entries in codex-shell.jsonl, got ${lines.length}`);
|
|
@@ -3503,8 +3535,8 @@ function codexRolloutPath(threadId, fallback) {
|
|
|
3503
3535
|
const hh = String(createdAt.getHours()).padStart(2, "0");
|
|
3504
3536
|
const min = String(createdAt.getMinutes()).padStart(2, "0");
|
|
3505
3537
|
const ss = String(createdAt.getSeconds()).padStart(2, "0");
|
|
3506
|
-
const dir =
|
|
3507
|
-
return
|
|
3538
|
+
const dir = join5(codexSessionsDir(), yyyy, mm, dd);
|
|
3539
|
+
return join5(dir, `rollout-${yyyy}-${mm}-${dd}T${hh}-${min}-${ss}-${threadId}.jsonl`);
|
|
3508
3540
|
}
|
|
3509
3541
|
function canonicalFilePath(path) {
|
|
3510
3542
|
const absolute = resolve6(path);
|
|
@@ -3512,7 +3544,7 @@ function canonicalFilePath(path) {
|
|
|
3512
3544
|
return realpathSync3(absolute);
|
|
3513
3545
|
} catch {
|
|
3514
3546
|
try {
|
|
3515
|
-
return
|
|
3547
|
+
return join5(realpathSync3(dirname6(absolute)), basename(absolute));
|
|
3516
3548
|
} catch {
|
|
3517
3549
|
return absolute;
|
|
3518
3550
|
}
|
|
@@ -3701,22 +3733,22 @@ function latestCodexRolloutPath(threadId) {
|
|
|
3701
3733
|
try {
|
|
3702
3734
|
if (buckets) {
|
|
3703
3735
|
for (const bucket of buckets) {
|
|
3704
|
-
const dir =
|
|
3736
|
+
const dir = join5(sessionsDir, bucket);
|
|
3705
3737
|
if (!existsSync3(dir))
|
|
3706
3738
|
continue;
|
|
3707
3739
|
const glob = new Bun.Glob(`rollout-*-${threadId}.jsonl`);
|
|
3708
3740
|
for (const rel of glob.scanSync({ cwd: dir, onlyFiles: true })) {
|
|
3709
|
-
candidates.push(
|
|
3741
|
+
candidates.push(join5(dir, rel));
|
|
3710
3742
|
}
|
|
3711
3743
|
}
|
|
3712
3744
|
}
|
|
3713
3745
|
if (candidates.length === 0) {
|
|
3714
3746
|
const glob = new Bun.Glob(`**/rollout-*-${threadId}.jsonl`);
|
|
3715
3747
|
for (const rel of glob.scanSync({ cwd: sessionsDir, onlyFiles: true })) {
|
|
3716
|
-
candidates.push(
|
|
3748
|
+
candidates.push(join5(sessionsDir, rel));
|
|
3717
3749
|
}
|
|
3718
3750
|
}
|
|
3719
|
-
return candidates.sort((a, b) =>
|
|
3751
|
+
return candidates.sort((a, b) => statSync3(b).mtimeMs - statSync3(a).mtimeMs)[0];
|
|
3720
3752
|
} catch (error) {
|
|
3721
3753
|
logger.debug({ error, threadId }, "codex rollout lookup failed");
|
|
3722
3754
|
return;
|
|
@@ -3837,13 +3869,13 @@ function sweepPriorRolloutsForThread(threadId) {
|
|
|
3837
3869
|
return;
|
|
3838
3870
|
}
|
|
3839
3871
|
for (const bucket of buckets) {
|
|
3840
|
-
const dir =
|
|
3872
|
+
const dir = join5(sessionsDir, bucket);
|
|
3841
3873
|
if (!existsSync3(dir))
|
|
3842
3874
|
continue;
|
|
3843
3875
|
try {
|
|
3844
3876
|
const glob = new Bun.Glob(`rollout-*-${threadId}.jsonl`);
|
|
3845
3877
|
for (const rel of glob.scanSync({ cwd: dir, onlyFiles: true })) {
|
|
3846
|
-
const fullPath =
|
|
3878
|
+
const fullPath = join5(dir, rel);
|
|
3847
3879
|
try {
|
|
3848
3880
|
unlinkSync3(fullPath);
|
|
3849
3881
|
} catch (e) {
|
|
@@ -3861,7 +3893,7 @@ function sweepPriorRolloutsFullTree(threadId, sessionsDir) {
|
|
|
3861
3893
|
try {
|
|
3862
3894
|
const glob = new Bun.Glob(`**/rollout-*-${threadId}.jsonl`);
|
|
3863
3895
|
for (const rel of glob.scanSync({ cwd: sessionsDir, onlyFiles: true })) {
|
|
3864
|
-
const fullPath =
|
|
3896
|
+
const fullPath = join5(sessionsDir, rel);
|
|
3865
3897
|
try {
|
|
3866
3898
|
unlinkSync3(fullPath);
|
|
3867
3899
|
} catch (e) {
|
|
@@ -3918,6 +3950,6 @@ function formatDateBucket(d) {
|
|
|
3918
3950
|
return `${yyyy}/${mm}/${dd}`;
|
|
3919
3951
|
}
|
|
3920
3952
|
|
|
3921
|
-
export { CLAUDE_EFFORT_VALUES, CODEX_EFFORT_VALUES, MAESTRO_EFFORT_VALUES, logger, MODEL_SONNET, MODEL_OPUS, MODEL_FABLE, configureRolloutHost2, FIXTURES_DIR, clone, assertUuidLike, ensureCwdExists, extractChatPairs2, parseJsonlText, writeJsonlFile, hostedCodexHomePath, extractLatestCodexPatchPreview2, extractCodexPatchCallIds2, readCodexPatchCallIds2, readLatestCodexPatchPreview2, extractLatestCodexContextUsage2, readLatestCodexContextUsage2, migrateCodexRolloutNativeMultiAgentMetadata2, latestCodexRolloutPath, writeCodexRollout2, decodeUuidV7Timestamp2 };
|
|
3953
|
+
export { CLAUDE_EFFORT_VALUES, CODEX_EFFORT_VALUES, MAESTRO_EFFORT_VALUES, logger, MODEL_SONNET, MODEL_OPUS, MODEL_FABLE, MODEL_FABLE_5_2, configureRolloutHost2, FIXTURES_DIR, clone, assertUuidLike, ensureCwdExists, extractChatPairs2, parseJsonlText, writeJsonlFile, hostedCodexHomePath, extractLatestCodexPatchPreview2, extractCodexPatchCallIds2, readCodexPatchCallIds2, readLatestCodexPatchPreview2, extractLatestCodexContextUsage2, readLatestCodexContextUsage2, migrateCodexRolloutNativeMultiAgentMetadata2, latestCodexRolloutPath, writeCodexRollout2, decodeUuidV7Timestamp2 };
|
|
3922
3954
|
|
|
3923
|
-
//# debugId=
|
|
3955
|
+
//# debugId=D1C688B1C671E0A464756E2164756E21
|