@otium-team/negotium 0.23.11 → 0.23.13
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/dist/agent-helpers.js +510 -1323
- package/dist/agent-helpers.js.map +10 -10
- package/dist/background-bash.js +12 -12
- package/dist/background-bash.js.map +3 -3
- package/dist/browser-runtime.js +42 -44
- package/dist/browser-runtime.js.map +3 -3
- package/dist/canonical-mcp-bridge.js +8 -9
- package/dist/canonical-mcp-bridge.js.map +1 -1
- package/dist/chunk-22kg3fsw.js +79 -0
- package/dist/{chunk-ad7kxsaq.js.map → chunk-22kg3fsw.js.map} +1 -1
- package/dist/{chunk-mxxwx5mg.js → chunk-d4j77adx.js} +96 -135
- package/dist/{chunk-mxxwx5mg.js.map → chunk-d4j77adx.js.map} +6 -6
- package/dist/{chunk-0fenxbe6.js → chunk-mk9x18jn.js} +4 -5
- package/dist/{chunk-0fenxbe6.js.map → chunk-mk9x18jn.js.map} +2 -2
- package/dist/{chunk-da9ad838.js → chunk-qd0vtfm2.js} +115 -119
- package/dist/{chunk-da9ad838.js.map → chunk-qd0vtfm2.js.map} +7 -7
- package/dist/{chunk-jtv8yzy1.js → chunk-wf7ny8eq.js} +12 -12
- package/dist/{chunk-jtv8yzy1.js.map → chunk-wf7ny8eq.js.map} +2 -2
- package/dist/{chunk-f7p0h1gs.js → chunk-ww8a4ej4.js} +5 -5
- package/dist/{chunk-f7p0h1gs.js.map → chunk-ww8a4ej4.js.map} +2 -2
- package/dist/hosted-agent.js +198 -135
- package/dist/hosted-agent.js.map +4 -4
- package/dist/main.js +3906 -4213
- package/dist/main.js.map +20 -18
- package/dist/mcp-catalog.js +4 -4
- package/dist/mcp-catalog.js.map +1 -1
- package/dist/mcp-factories.js +753 -1558
- package/dist/mcp-factories.js.map +10 -10
- package/dist/mcp-servers.js +5 -5
- package/dist/mcp-servers.js.map +1 -1
- package/dist/media.js +3 -3
- package/dist/media.js.map +2 -2
- package/dist/outbox.js +15 -15
- package/dist/outbox.js.map +2 -2
- package/dist/platform-runtime.js +7 -7
- package/dist/platform-runtime.js.map +1 -1
- package/dist/prompts.js +6 -6
- package/dist/prompts.js.map +3 -3
- package/dist/query-runtime.js +16 -18
- package/dist/query-runtime.js.map +4 -4
- package/dist/registry.js +19 -20
- package/dist/registry.js.map +2 -2
- package/dist/rollout.js +41 -41
- package/dist/rollout.js.map +2 -2
- package/dist/runtime/src/agents/claude-provider.ts +80 -5
- package/dist/runtime/src/application/submit-runtime-gateway-turn.ts +84 -20
- package/dist/runtime/src/application/topic-service.ts +6 -2
- package/dist/runtime/src/application/turn-follow-ups.ts +291 -0
- package/dist/runtime/src/bus.ts +6 -0
- package/dist/runtime/src/node-host.ts +11 -0
- package/dist/runtime/src/query/active-rooms.ts +7 -1
- package/dist/runtime/src/runtime/turn-runner.ts +34 -7
- package/dist/runtime/src/runtime-gateway.ts +198 -1
- package/dist/runtime/src/storage/runtime-follow-ups.ts +212 -0
- package/dist/runtime/src/storage/runtime-turn-requests.ts +43 -2
- package/dist/runtime/src/types/api.ts +9 -0
- package/dist/runtime/src/types.ts +23 -0
- package/dist/runtime/src/version.ts +1 -1
- package/dist/runtime-gateway.js +73 -12
- package/dist/runtime-gateway.js.map +3 -3
- package/dist/runtime-helpers.js +52 -54
- package/dist/runtime-helpers.js.map +3 -3
- package/dist/sqlite.js +3 -5
- package/dist/sqlite.js.map +2 -2
- package/dist/storage.js +4841 -4812
- package/dist/storage.js.map +3 -3
- package/dist/types/packages/core/src/bus.d.ts +3 -0
- package/dist/types/packages/core/src/query/active-rooms.d.ts +7 -1
- package/dist/types/packages/core/src/runtime-gateway.d.ts +59 -1
- package/dist/types/packages/core/src/storage/runtime-turn-requests.d.ts +25 -0
- package/dist/types/packages/core/src/types/api.d.ts +5 -0
- package/dist/types/packages/core/src/types.d.ts +21 -0
- package/dist/types/packages/core/src/version.d.ts +1 -1
- package/dist/vault.js +20 -22
- package/dist/vault.js.map +3 -3
- package/package.json +1 -1
- package/dist/chunk-2mx7fq49.js +0 -6
- package/dist/chunk-2mx7fq49.js.map +0 -9
- package/dist/chunk-ad7kxsaq.js +0 -202
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
hostedCodexHomePath,
|
|
4
4
|
latestCodexRolloutPath
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-qd0vtfm2.js";
|
|
6
6
|
|
|
7
7
|
// ../../packages/core/src/agents/codex-app-server.ts
|
|
8
8
|
import { spawn } from "child_process";
|
|
@@ -23,7 +23,7 @@ import { dirname, join } from "path";
|
|
|
23
23
|
import { fileURLToPath } from "url";
|
|
24
24
|
|
|
25
25
|
// ../../packages/core/src/version.ts
|
|
26
|
-
var NEGOTIUM_VERSION = "0.23.
|
|
26
|
+
var NEGOTIUM_VERSION = "0.23.13";
|
|
27
27
|
|
|
28
28
|
// ../../packages/core/src/agents/codex-native-multi-agent.ts
|
|
29
29
|
function findPackageJson(specifier, searchFromDir) {
|
|
@@ -166,8 +166,7 @@ async function forkCodexSession(parentThreadId) {
|
|
|
166
166
|
return await forkCodexThread(parentThreadId);
|
|
167
167
|
}
|
|
168
168
|
export {
|
|
169
|
-
forkCodexSession
|
|
170
|
-
createCodexAppServerForker
|
|
169
|
+
forkCodexSession
|
|
171
170
|
};
|
|
172
171
|
|
|
173
|
-
//# debugId=
|
|
172
|
+
//# debugId=06A6D0D3F3FFDE3964756E2164756E21
|
|
@@ -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}\n",
|
|
7
|
-
"export const NEGOTIUM_VERSION = \"0.23.
|
|
7
|
+
"export const NEGOTIUM_VERSION = \"0.23.13\";\n"
|
|
8
8
|
],
|
|
9
9
|
"mappings": "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",
|
|
10
|
-
"debugId": "
|
|
10
|
+
"debugId": "06A6D0D3F3FFDE3964756E2164756E21",
|
|
11
11
|
"names": []
|
|
12
12
|
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var __require = import.meta.require;
|
|
3
|
-
|
|
4
2
|
// ../../packages/core/src/agents/rollout/shared.ts
|
|
5
3
|
import { mkdirSync as mkdirSync2 } from "fs";
|
|
6
4
|
import { resolve as resolve3 } from "path";
|
|
@@ -390,7 +388,7 @@ var trustedWorkspaceRoots = [
|
|
|
390
388
|
SESSION_WORKSPACE_DIR,
|
|
391
389
|
TOPIC_WORKSPACE_DIR
|
|
392
390
|
].map((root) => resolve3(root));
|
|
393
|
-
function
|
|
391
|
+
function configureRolloutHost2(options) {
|
|
394
392
|
if (!options.workspaceRoots && !options.fixturesDir) {
|
|
395
393
|
throw new Error("configureRolloutHost requires workspaceRoots or fixturesDir");
|
|
396
394
|
}
|
|
@@ -442,7 +440,7 @@ function truncate(text, n) {
|
|
|
442
440
|
const cps = Array.from(text);
|
|
443
441
|
return cps.length > n ? `${cps.slice(0, n).join("")}\u2026` : text;
|
|
444
442
|
}
|
|
445
|
-
function
|
|
443
|
+
function extractChatPairs2(entries, opts = { includeToolAnnotations: true }) {
|
|
446
444
|
const pairs = [];
|
|
447
445
|
let pendingUsers = [];
|
|
448
446
|
let pendingBatchSize = null;
|
|
@@ -546,9 +544,91 @@ ${toolBuffer.join(`
|
|
|
546
544
|
return pairs;
|
|
547
545
|
}
|
|
548
546
|
|
|
547
|
+
// ../../packages/core/src/platform/jsonl.ts
|
|
548
|
+
import {
|
|
549
|
+
appendFileSync,
|
|
550
|
+
closeSync,
|
|
551
|
+
fsyncSync,
|
|
552
|
+
mkdirSync as mkdirSync3,
|
|
553
|
+
openSync,
|
|
554
|
+
readFileSync as readFileSync2,
|
|
555
|
+
renameSync,
|
|
556
|
+
statSync,
|
|
557
|
+
unlinkSync as unlinkSync2,
|
|
558
|
+
writeFileSync as writeFileSync2
|
|
559
|
+
} from "fs";
|
|
560
|
+
import { dirname as dirname3 } from "path";
|
|
561
|
+
|
|
562
|
+
// ../../packages/core/src/platform/file-utils.ts
|
|
563
|
+
import { unlinkSync } from "fs";
|
|
564
|
+
function createSafeUnlink(host) {
|
|
565
|
+
return (path, warnLabel) => {
|
|
566
|
+
try {
|
|
567
|
+
host.unlink(path);
|
|
568
|
+
} catch (e) {
|
|
569
|
+
if (e?.code === "ENOENT")
|
|
570
|
+
return;
|
|
571
|
+
if (warnLabel)
|
|
572
|
+
host.warn({ err: e, path }, warnLabel);
|
|
573
|
+
}
|
|
574
|
+
};
|
|
575
|
+
}
|
|
576
|
+
var defaultSafeUnlink = createSafeUnlink({
|
|
577
|
+
unlink: unlinkSync,
|
|
578
|
+
warn: (context, message) => logger.warn(context, message)
|
|
579
|
+
});
|
|
580
|
+
|
|
581
|
+
// ../../packages/core/src/platform/jsonl.ts
|
|
582
|
+
function parseJsonlText(raw) {
|
|
583
|
+
return raw.trim().split(`
|
|
584
|
+
`).filter(Boolean).map((line) => JSON.parse(line));
|
|
585
|
+
}
|
|
586
|
+
var LOCK_SLEEP = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
|
587
|
+
function writeJsonlFile(filePath, entries) {
|
|
588
|
+
const dir = dirname3(filePath);
|
|
589
|
+
mkdirSync3(dir, { recursive: true });
|
|
590
|
+
const tmpPath = `${filePath}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
591
|
+
const payload = `${entries.map((e) => JSON.stringify(e)).join(`
|
|
592
|
+
`)}
|
|
593
|
+
`;
|
|
594
|
+
let fd = null;
|
|
595
|
+
try {
|
|
596
|
+
fd = openSync(tmpPath, "w");
|
|
597
|
+
writeFileSync2(fd, payload);
|
|
598
|
+
fsyncSync(fd);
|
|
599
|
+
closeSync(fd);
|
|
600
|
+
fd = null;
|
|
601
|
+
renameSync(tmpPath, filePath);
|
|
602
|
+
fsyncDirectoryBestEffort(dir);
|
|
603
|
+
} catch (err) {
|
|
604
|
+
if (fd !== null) {
|
|
605
|
+
try {
|
|
606
|
+
closeSync(fd);
|
|
607
|
+
} catch {}
|
|
608
|
+
}
|
|
609
|
+
try {
|
|
610
|
+
unlinkSync2(tmpPath);
|
|
611
|
+
} catch {}
|
|
612
|
+
throw err;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
function fsyncDirectoryBestEffort(dir) {
|
|
616
|
+
let fd = null;
|
|
617
|
+
try {
|
|
618
|
+
fd = openSync(dir, "r");
|
|
619
|
+
fsyncSync(fd);
|
|
620
|
+
} catch {} finally {
|
|
621
|
+
if (fd !== null) {
|
|
622
|
+
try {
|
|
623
|
+
closeSync(fd);
|
|
624
|
+
} catch {}
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
|
|
549
629
|
// ../../packages/core/src/agents/execution-host.ts
|
|
550
630
|
import { AsyncLocalStorage } from "async_hooks";
|
|
551
|
-
import { dirname as
|
|
631
|
+
import { dirname as dirname5 } from "path";
|
|
552
632
|
|
|
553
633
|
// ../../packages/core/src/security/sensitive-path.ts
|
|
554
634
|
import { realpathSync as realpathSync2 } from "fs";
|
|
@@ -1211,12 +1291,12 @@ function createBackgroundBashManager(options = {}) {
|
|
|
1211
1291
|
usedPorts.clear();
|
|
1212
1292
|
knownContexts.clear();
|
|
1213
1293
|
const deadline = now() + 3000;
|
|
1214
|
-
await Promise.all(entries.map((instance) => new Promise((
|
|
1294
|
+
await Promise.all(entries.map((instance) => new Promise((resolve) => {
|
|
1215
1295
|
if (instance.process.exitCode !== null || instance.process.killed)
|
|
1216
|
-
return
|
|
1217
|
-
instance.process.once("exit",
|
|
1218
|
-
instance.process.once("error",
|
|
1219
|
-
const timer = setTimeout(
|
|
1296
|
+
return resolve();
|
|
1297
|
+
instance.process.once("exit", resolve);
|
|
1298
|
+
instance.process.once("error", resolve);
|
|
1299
|
+
const timer = setTimeout(resolve, Math.max(0, deadline - now()));
|
|
1220
1300
|
timer.unref?.();
|
|
1221
1301
|
})));
|
|
1222
1302
|
}
|
|
@@ -1312,9 +1392,9 @@ var RESERVED_TOPIC_NAMES = new Set([
|
|
|
1312
1392
|
var GENERAL_TOPIC_ID = "general";
|
|
1313
1393
|
|
|
1314
1394
|
// ../../packages/core/src/storage/storage-host.ts
|
|
1315
|
-
import { mkdirSync as
|
|
1395
|
+
import { mkdirSync as mkdirSync4 } from "fs";
|
|
1316
1396
|
import { homedir as homedir2 } from "os";
|
|
1317
|
-
import { dirname as
|
|
1397
|
+
import { dirname as dirname4, join as join2, resolve as resolve5 } from "path";
|
|
1318
1398
|
|
|
1319
1399
|
// ../../packages/core/src/storage/sqlite.ts
|
|
1320
1400
|
var isBun = typeof process.versions.bun === "string";
|
|
@@ -1449,7 +1529,7 @@ function defaultDatabase() {
|
|
|
1449
1529
|
return state.fallbackDatabase;
|
|
1450
1530
|
if (state.fallbackDatabase)
|
|
1451
1531
|
closeDatabase(state.fallbackDatabase);
|
|
1452
|
-
|
|
1532
|
+
mkdirSync4(dirname4(path), { recursive: true });
|
|
1453
1533
|
state.fallbackDatabase = new Database(path, { create: true });
|
|
1454
1534
|
state.fallbackDatabasePath = path;
|
|
1455
1535
|
initializeDatabase(state.fallbackDatabase);
|
|
@@ -1649,7 +1729,7 @@ var SCHEMA_TRIGGERS = {
|
|
|
1649
1729
|
};
|
|
1650
1730
|
var OTIUM_TOPIC_SCOPE_IMMUTABLE_ERROR = "otium_topic_scope_immutable";
|
|
1651
1731
|
function topicLinkSchemaIsCurrent(database, nodeId) {
|
|
1652
|
-
const objects = new Map(database.query("SELECT name, sql FROM sqlite_master WHERE type IN ('table','index','trigger')").all().map((
|
|
1732
|
+
const objects = new Map(database.query("SELECT name, sql FROM sqlite_master WHERE type IN ('table','index','trigger')").all().map((row) => [row.name, row.sql ?? ""]));
|
|
1653
1733
|
for (const name of [...SCHEMA_TABLES, ...SCHEMA_INDEXES, ...SCHEMA_INDEXES_TOMBSTONES]) {
|
|
1654
1734
|
if (!objects.has(name))
|
|
1655
1735
|
return false;
|
|
@@ -1666,7 +1746,7 @@ function topicLinkSchemaIsCurrent(database, nodeId) {
|
|
|
1666
1746
|
return false;
|
|
1667
1747
|
}
|
|
1668
1748
|
const identity = database.query("SELECT node_id, epoch_id FROM api_node_identity WHERE singleton = 1").all();
|
|
1669
|
-
if (identity.some((
|
|
1749
|
+
if (identity.some((row) => row.epoch_id === null))
|
|
1670
1750
|
return false;
|
|
1671
1751
|
if (nodeId && identity[0]?.node_id !== nodeId)
|
|
1672
1752
|
return false;
|
|
@@ -3127,7 +3207,7 @@ function hideProviderIntrospectionForOtium(servers, topicId) {
|
|
|
3127
3207
|
}
|
|
3128
3208
|
|
|
3129
3209
|
// ../../packages/core/src/storage/vault.ts
|
|
3130
|
-
import { chmodSync as chmodSync2, mkdirSync as
|
|
3210
|
+
import { chmodSync as chmodSync2, mkdirSync as mkdirSync5 } from "fs";
|
|
3131
3211
|
import { join as join3 } from "path";
|
|
3132
3212
|
|
|
3133
3213
|
// ../../packages/core/src/storage/vault-crypto-core.ts
|
|
@@ -3221,7 +3301,7 @@ function initializeVaultDatabase(database) {
|
|
|
3221
3301
|
function openVaultDatabase(dataDir) {
|
|
3222
3302
|
const vaultDir = join3(dataDir, "vault");
|
|
3223
3303
|
const path = join3(vaultDir, "vault.db");
|
|
3224
|
-
|
|
3304
|
+
mkdirSync5(vaultDir, { recursive: true, mode: 448 });
|
|
3225
3305
|
const database = new Database(path, { create: true });
|
|
3226
3306
|
chmodSync2(path, 384);
|
|
3227
3307
|
initializeVaultDatabase(database);
|
|
@@ -3342,97 +3422,13 @@ function hostedCodexAuthFilePath() {
|
|
|
3342
3422
|
return activeHost().codexAuthFilePath();
|
|
3343
3423
|
}
|
|
3344
3424
|
function hostedCodexHomePath() {
|
|
3345
|
-
return
|
|
3425
|
+
return dirname5(hostedCodexAuthFilePath());
|
|
3346
3426
|
}
|
|
3347
3427
|
|
|
3348
3428
|
// ../../packages/core/src/agents/rollout/codex.ts
|
|
3349
3429
|
import { randomBytes as randomBytes4 } from "crypto";
|
|
3350
3430
|
import { existsSync as existsSync3, readFileSync as readFileSync3, realpathSync as realpathSync3, statSync as statSync2, unlinkSync as unlinkSync3 } from "fs";
|
|
3351
3431
|
import { basename, dirname as dirname6, join as join4, resolve as resolve6 } from "path";
|
|
3352
|
-
|
|
3353
|
-
// ../../packages/core/src/platform/jsonl.ts
|
|
3354
|
-
import {
|
|
3355
|
-
appendFileSync,
|
|
3356
|
-
closeSync,
|
|
3357
|
-
fsyncSync,
|
|
3358
|
-
mkdirSync as mkdirSync5,
|
|
3359
|
-
openSync,
|
|
3360
|
-
readFileSync as readFileSync2,
|
|
3361
|
-
renameSync,
|
|
3362
|
-
statSync,
|
|
3363
|
-
unlinkSync as unlinkSync2,
|
|
3364
|
-
writeFileSync as writeFileSync2
|
|
3365
|
-
} from "fs";
|
|
3366
|
-
import { dirname as dirname5 } from "path";
|
|
3367
|
-
|
|
3368
|
-
// ../../packages/core/src/platform/file-utils.ts
|
|
3369
|
-
import { unlinkSync } from "fs";
|
|
3370
|
-
function createSafeUnlink(host) {
|
|
3371
|
-
return (path, warnLabel) => {
|
|
3372
|
-
try {
|
|
3373
|
-
host.unlink(path);
|
|
3374
|
-
} catch (e) {
|
|
3375
|
-
if (e?.code === "ENOENT")
|
|
3376
|
-
return;
|
|
3377
|
-
if (warnLabel)
|
|
3378
|
-
host.warn({ err: e, path }, warnLabel);
|
|
3379
|
-
}
|
|
3380
|
-
};
|
|
3381
|
-
}
|
|
3382
|
-
var defaultSafeUnlink = createSafeUnlink({
|
|
3383
|
-
unlink: unlinkSync,
|
|
3384
|
-
warn: (context, message) => logger.warn(context, message)
|
|
3385
|
-
});
|
|
3386
|
-
|
|
3387
|
-
// ../../packages/core/src/platform/jsonl.ts
|
|
3388
|
-
function parseJsonlText(raw) {
|
|
3389
|
-
return raw.trim().split(`
|
|
3390
|
-
`).filter(Boolean).map((line) => JSON.parse(line));
|
|
3391
|
-
}
|
|
3392
|
-
var LOCK_SLEEP = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));
|
|
3393
|
-
function writeJsonlFile(filePath, entries) {
|
|
3394
|
-
const dir = dirname5(filePath);
|
|
3395
|
-
mkdirSync5(dir, { recursive: true });
|
|
3396
|
-
const tmpPath = `${filePath}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
3397
|
-
const payload = `${entries.map((e) => JSON.stringify(e)).join(`
|
|
3398
|
-
`)}
|
|
3399
|
-
`;
|
|
3400
|
-
let fd = null;
|
|
3401
|
-
try {
|
|
3402
|
-
fd = openSync(tmpPath, "w");
|
|
3403
|
-
writeFileSync2(fd, payload);
|
|
3404
|
-
fsyncSync(fd);
|
|
3405
|
-
closeSync(fd);
|
|
3406
|
-
fd = null;
|
|
3407
|
-
renameSync(tmpPath, filePath);
|
|
3408
|
-
fsyncDirectoryBestEffort(dir);
|
|
3409
|
-
} catch (err) {
|
|
3410
|
-
if (fd !== null) {
|
|
3411
|
-
try {
|
|
3412
|
-
closeSync(fd);
|
|
3413
|
-
} catch {}
|
|
3414
|
-
}
|
|
3415
|
-
try {
|
|
3416
|
-
unlinkSync2(tmpPath);
|
|
3417
|
-
} catch {}
|
|
3418
|
-
throw err;
|
|
3419
|
-
}
|
|
3420
|
-
}
|
|
3421
|
-
function fsyncDirectoryBestEffort(dir) {
|
|
3422
|
-
let fd = null;
|
|
3423
|
-
try {
|
|
3424
|
-
fd = openSync(dir, "r");
|
|
3425
|
-
fsyncSync(fd);
|
|
3426
|
-
} catch {} finally {
|
|
3427
|
-
if (fd !== null) {
|
|
3428
|
-
try {
|
|
3429
|
-
closeSync(fd);
|
|
3430
|
-
} catch {}
|
|
3431
|
-
}
|
|
3432
|
-
}
|
|
3433
|
-
}
|
|
3434
|
-
|
|
3435
|
-
// ../../packages/core/src/agents/rollout/codex.ts
|
|
3436
3432
|
function codexSessionsDir() {
|
|
3437
3433
|
return join4(hostedCodexHomePath(), "sessions");
|
|
3438
3434
|
}
|
|
@@ -3499,7 +3495,7 @@ function patchEnvContext(envContext, cwd, currentDate, timezone) {
|
|
|
3499
3495
|
}
|
|
3500
3496
|
}
|
|
3501
3497
|
function codexRolloutPath(threadId, fallback) {
|
|
3502
|
-
const threadCreatedAt =
|
|
3498
|
+
const threadCreatedAt = decodeUuidV7Timestamp2(threadId);
|
|
3503
3499
|
const createdAt = threadCreatedAt === null ? fallback : new Date(threadCreatedAt);
|
|
3504
3500
|
const yyyy = String(createdAt.getFullYear());
|
|
3505
3501
|
const mm = String(createdAt.getMonth() + 1).padStart(2, "0");
|
|
@@ -3571,7 +3567,7 @@ function changedPatchLines(value) {
|
|
|
3571
3567
|
`) } : {}
|
|
3572
3568
|
};
|
|
3573
3569
|
}
|
|
3574
|
-
function
|
|
3570
|
+
function extractLatestCodexPatchPreview2(jsonl, expectedPaths, consumedCallIds = new Set, expectedCallId) {
|
|
3575
3571
|
const expected = expectedPaths.map(canonicalFilePath);
|
|
3576
3572
|
const lines = jsonl.trimEnd().split(`
|
|
3577
3573
|
`);
|
|
@@ -3608,7 +3604,7 @@ function extractLatestCodexPatchPreview(jsonl, expectedPaths, consumedCallIds =
|
|
|
3608
3604
|
}
|
|
3609
3605
|
return;
|
|
3610
3606
|
}
|
|
3611
|
-
function
|
|
3607
|
+
function extractCodexPatchCallIds2(jsonl) {
|
|
3612
3608
|
const callIds = [];
|
|
3613
3609
|
for (const line of jsonl.trimEnd().split(`
|
|
3614
3610
|
`)) {
|
|
@@ -3621,29 +3617,29 @@ function extractCodexPatchCallIds(jsonl) {
|
|
|
3621
3617
|
}
|
|
3622
3618
|
return callIds;
|
|
3623
3619
|
}
|
|
3624
|
-
function
|
|
3620
|
+
function readCodexPatchCallIds2(threadId) {
|
|
3625
3621
|
const path = latestCodexRolloutPath(threadId);
|
|
3626
3622
|
if (!path)
|
|
3627
3623
|
return [];
|
|
3628
3624
|
try {
|
|
3629
|
-
return
|
|
3625
|
+
return extractCodexPatchCallIds2(readFileSync3(path, "utf8"));
|
|
3630
3626
|
} catch (error) {
|
|
3631
3627
|
logger.debug({ error, threadId }, "codex patch ids: rollout read failed");
|
|
3632
3628
|
return [];
|
|
3633
3629
|
}
|
|
3634
3630
|
}
|
|
3635
|
-
function
|
|
3631
|
+
function readLatestCodexPatchPreview2(threadId, expectedPaths, consumedCallIds = new Set, expectedCallId) {
|
|
3636
3632
|
const path = latestCodexRolloutPath(threadId);
|
|
3637
3633
|
if (!path)
|
|
3638
3634
|
return;
|
|
3639
3635
|
try {
|
|
3640
|
-
return
|
|
3636
|
+
return extractLatestCodexPatchPreview2(readFileSync3(path, "utf8"), expectedPaths, consumedCallIds, expectedCallId);
|
|
3641
3637
|
} catch (error) {
|
|
3642
3638
|
logger.debug({ error, threadId }, "codex patch preview: rollout read failed");
|
|
3643
3639
|
return;
|
|
3644
3640
|
}
|
|
3645
3641
|
}
|
|
3646
|
-
function
|
|
3642
|
+
function extractLatestCodexContextUsage2(jsonl) {
|
|
3647
3643
|
const lines = jsonl.trimEnd().split(`
|
|
3648
3644
|
`);
|
|
3649
3645
|
for (let index = lines.length - 1;index >= 0; index -= 1) {
|
|
@@ -3660,18 +3656,18 @@ function extractLatestCodexContextUsage(jsonl) {
|
|
|
3660
3656
|
}
|
|
3661
3657
|
return;
|
|
3662
3658
|
}
|
|
3663
|
-
function
|
|
3659
|
+
function readLatestCodexContextUsage2(threadId) {
|
|
3664
3660
|
const path = latestCodexRolloutPath(threadId);
|
|
3665
3661
|
if (!path)
|
|
3666
3662
|
return;
|
|
3667
3663
|
try {
|
|
3668
|
-
return
|
|
3664
|
+
return extractLatestCodexContextUsage2(readFileSync3(path, "utf8"));
|
|
3669
3665
|
} catch (error) {
|
|
3670
3666
|
logger.debug({ error, threadId }, "codex context usage: rollout read failed");
|
|
3671
3667
|
return;
|
|
3672
3668
|
}
|
|
3673
3669
|
}
|
|
3674
|
-
function
|
|
3670
|
+
function migrateCodexRolloutNativeMultiAgentMetadata2(threadId) {
|
|
3675
3671
|
const path = latestCodexRolloutPath(threadId);
|
|
3676
3672
|
if (!path)
|
|
3677
3673
|
return false;
|
|
@@ -3726,11 +3722,11 @@ function latestCodexRolloutPath(threadId) {
|
|
|
3726
3722
|
return;
|
|
3727
3723
|
}
|
|
3728
3724
|
}
|
|
3729
|
-
function
|
|
3725
|
+
function writeCodexRollout2(opts) {
|
|
3730
3726
|
const threadId = opts.threadId ?? uuidv7();
|
|
3731
3727
|
assertUuidLike("threadId", threadId);
|
|
3732
3728
|
ensureCwdExists(opts.cwd);
|
|
3733
|
-
const pairs = opts.pairs ??
|
|
3729
|
+
const pairs = opts.pairs ?? extractChatPairs2(opts.entries ?? []);
|
|
3734
3730
|
const now = new Date;
|
|
3735
3731
|
const tsIso = now.toISOString();
|
|
3736
3732
|
const currentDate = [
|
|
@@ -3882,7 +3878,7 @@ var MAX_DAY_SPAN = 30;
|
|
|
3882
3878
|
var DAY_MS = 86400000;
|
|
3883
3879
|
var LOCAL_DATE_SKEW_DAYS = 1;
|
|
3884
3880
|
function candidateDateBuckets(threadId) {
|
|
3885
|
-
const tidMs =
|
|
3881
|
+
const tidMs = decodeUuidV7Timestamp2(threadId);
|
|
3886
3882
|
if (tidMs === null)
|
|
3887
3883
|
return null;
|
|
3888
3884
|
const nowMs = Date.now();
|
|
@@ -3899,7 +3895,7 @@ function candidateDateBuckets(threadId) {
|
|
|
3899
3895
|
}
|
|
3900
3896
|
return buckets;
|
|
3901
3897
|
}
|
|
3902
|
-
function
|
|
3898
|
+
function decodeUuidV7Timestamp2(threadId) {
|
|
3903
3899
|
if (typeof threadId !== "string")
|
|
3904
3900
|
return null;
|
|
3905
3901
|
const m = /^([0-9a-fA-F]{8})-([0-9a-fA-F]{4})-7[0-9a-fA-F]{3}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/.exec(threadId);
|
|
@@ -3922,6 +3918,6 @@ function formatDateBucket(d) {
|
|
|
3922
3918
|
return `${yyyy}/${mm}/${dd}`;
|
|
3923
3919
|
}
|
|
3924
3920
|
|
|
3925
|
-
export {
|
|
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 };
|
|
3926
3922
|
|
|
3927
|
-
//# debugId=
|
|
3923
|
+
//# debugId=3B8CD69F2572988264756E2164756E21
|