@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
package/dist/registry.js
CHANGED
|
@@ -7,16 +7,17 @@ import {
|
|
|
7
7
|
MODEL_SONNET,
|
|
8
8
|
MODEL_OPUS,
|
|
9
9
|
MODEL_FABLE,
|
|
10
|
+
MODEL_FABLE_5_2,
|
|
10
11
|
assertUuidLike,
|
|
11
12
|
ensureCwdExists,
|
|
12
13
|
extractChatPairs2,
|
|
13
14
|
hostedCodexHomePath,
|
|
14
15
|
writeCodexRollout2
|
|
15
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-ng13grfj.js";
|
|
16
17
|
import {
|
|
17
18
|
encodeClaudeCwd2,
|
|
18
19
|
writeClaudeRollout2
|
|
19
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-m1ngkjdd.js";
|
|
20
21
|
|
|
21
22
|
// ../../packages/core/src/agents/claude-registry.ts
|
|
22
23
|
import { existsSync, mkdirSync, readdirSync, renameSync, unlinkSync } from "fs";
|
|
@@ -25,7 +26,8 @@ import { join } from "path";
|
|
|
25
26
|
var ALIAS_MAP = {
|
|
26
27
|
sonnet: MODEL_SONNET,
|
|
27
28
|
opus: MODEL_OPUS,
|
|
28
|
-
fable: MODEL_FABLE
|
|
29
|
+
fable: MODEL_FABLE,
|
|
30
|
+
"fable-5.2": MODEL_FABLE_5_2
|
|
29
31
|
};
|
|
30
32
|
var VALID_ALIASES = new Set(Object.keys(ALIAS_MAP));
|
|
31
33
|
var VALID_EFFORTS = new Set(CLAUDE_EFFORT_VALUES);
|
|
@@ -131,7 +133,7 @@ var codexRegistryOperations = {
|
|
|
131
133
|
return { sessionId: threadId, rolloutPath };
|
|
132
134
|
},
|
|
133
135
|
async forkSession({ parentSessionId }) {
|
|
134
|
-
const { forkCodexSession } = await import("./chunk-
|
|
136
|
+
const { forkCodexSession } = await import("./chunk-3hf8y6bd.js");
|
|
135
137
|
return await forkCodexSession(parentSessionId);
|
|
136
138
|
},
|
|
137
139
|
async cleanupRollouts({ sessionIds }) {
|
|
@@ -332,4 +334,4 @@ export {
|
|
|
332
334
|
getRegistryOperations2 as getRegistryOperations
|
|
333
335
|
};
|
|
334
336
|
|
|
335
|
-
//# debugId=
|
|
337
|
+
//# debugId=8D84891E880A5CC664756E2164756E21
|
package/dist/registry.js.map
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../packages/core/src/agents/claude-registry.ts", "../../../packages/core/src/agents/codex-registry.ts", "../../../packages/core/src/agents/maestro-registry.ts", "../../../packages/core/src/agents/registry.ts", "../src/registry.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import { existsSync, mkdirSync, readdirSync, renameSync, unlinkSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport type { AgentRegistry, AgentRegistryOperations } from \"#agents/contracts\";\nimport { encodeClaudeCwd, writeClaudeRollout } from \"#agents/rollout/claude\";\nimport { MODEL_FABLE, MODEL_OPUS, MODEL_SONNET } from \"#platform/config\";\nimport { logger } from \"#platform/logger\";\nimport { CLAUDE_EFFORT_VALUES, type EffortLevel } from \"#types\";\n\nconst ALIAS_MAP: Record<string, string> = {\n sonnet: MODEL_SONNET,\n opus: MODEL_OPUS,\n fable: MODEL_FABLE,\n};\n\nconst VALID_ALIASES = new Set(Object.keys(ALIAS_MAP));\nconst VALID_EFFORTS = new Set<EffortLevel>(CLAUDE_EFFORT_VALUES);\n\nexport const claudeRegistry: AgentRegistry = {\n kind: \"claude\",\n defaultModel: \"sonnet\",\n defaultEffort: \"high\",\n\n expandModelAlias(s) {\n return ALIAS_MAP[s] ?? s;\n },\n\n validateModel(s) {\n return VALID_ALIASES.has(s);\n },\n\n validEfforts: CLAUDE_EFFORT_VALUES,\n validateEffort(s) {\n return VALID_EFFORTS.has(s);\n },\n\n footerLabel(model, effort) {\n return effort ? `${model} · ${effort}` : model;\n },\n};\n\nexport const claudeRegistryOperations: AgentRegistryOperations = {\n writeRollout(opts) {\n // `reuseSessionId` (if any) becomes the SDK resume key + path component,\n // so claude→codex→claude lands at the original `~/.claude/projects/<dir>/<id>.jsonl`\n // instead of orphaning a fresh UUID every switch.\n const { sessionId, rolloutPath } = writeClaudeRollout({\n cwd: opts.cwd,\n entries: opts.entries,\n model: claudeRegistry.expandModelAlias(opts.model ?? claudeRegistry.defaultModel),\n ...(opts.reuseSessionId ? { sessionId: opts.reuseSessionId } : {}),\n });\n return { sessionId, rolloutPath };\n },\n\n // Claude has a native fork API in @anthropic-ai/claude-agent-sdk that produces\n // a byte-equivalent copy of the parent rollout. Preserves tool history\n // structurally, so the fork is indistinguishable from the parent on resume.\n //\n // SDK ≥0.3.19x semantics: `dir` is where to FIND the parent session (lookup\n // scope), NOT the destination — passing the derived topic's cwd made lookup\n // fail (\"Session … not found in project directory\"). The fork file is always\n // written NEXT TO the parent rollout, so after forking we move it into the\n // derived cwd's project dir where a resume from that cwd expects it.\n async forkSession({ parentSessionId, cwd, title }) {\n const { forkSession } = await import(\"@anthropic-ai/claude-agent-sdk\");\n // Omit `dir`: the parent session lives under the SOURCE topic's project\n // dir, which this registry never receives — global search finds it.\n const result = await forkSession(parentSessionId, {\n ...(title ? { title } : {}),\n });\n const projectsRoot = join(homedir(), \".claude\", \"projects\");\n const destDir = join(projectsRoot, encodeClaudeCwd(cwd));\n const destPath = join(destDir, `${result.sessionId}.jsonl`);\n if (!existsSync(destPath)) {\n const sourcePath = readdirSync(projectsRoot)\n .map((d) => join(projectsRoot, d, `${result.sessionId}.jsonl`))\n .find((p) => existsSync(p));\n if (!sourcePath) {\n throw new Error(\n `claude forkSession: fork rollout ${result.sessionId}.jsonl not found under ${projectsRoot}`,\n );\n }\n mkdirSync(destDir, { recursive: true });\n renameSync(sourcePath, destPath);\n }\n return {\n forkId: result.sessionId,\n // Same project-dir layout as cleanupRollouts below — NOT under\n // `cwd/.claude/sessions/`. A wrong path here makes cleanupAgentFork's\n // existsSync always false, so silent-fork rollouts accumulate forever.\n rolloutPath: destPath,\n };\n },\n\n // Each Claude rollout lives at `~/.claude/projects/<encoded-cwd>/<sessionId>.jsonl`.\n // The encoded-cwd is deterministic so we can compute the path directly\n // without globbing — fast and robust against the SDK changing date layout.\n async cleanupRollouts({ cwd, sessionIds }) {\n const projectsDir = join(homedir(), \".claude\", \"projects\", encodeClaudeCwd(cwd));\n const failures: unknown[] = [];\n for (const sid of sessionIds) {\n const path = join(projectsDir, `${sid}.jsonl`);\n try {\n unlinkSync(path);\n } catch (e) {\n if ((e as NodeJS.ErrnoException)?.code !== \"ENOENT\") {\n logger.warn({ err: e, path }, \"claude cleanupRollouts: unlink failed\");\n failures.push(e);\n }\n }\n }\n if (failures.length > 0) {\n throw new AggregateError(failures, \"claude cleanupRollouts failed\");\n }\n },\n};\n",
|
|
5
|
+
"import { existsSync, mkdirSync, readdirSync, renameSync, unlinkSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { join } from \"node:path\";\nimport type { AgentRegistry, AgentRegistryOperations } from \"#agents/contracts\";\nimport { encodeClaudeCwd, writeClaudeRollout } from \"#agents/rollout/claude\";\nimport { MODEL_FABLE, MODEL_FABLE_5_2, MODEL_OPUS, MODEL_SONNET } from \"#platform/config\";\nimport { logger } from \"#platform/logger\";\nimport { CLAUDE_EFFORT_VALUES, type EffortLevel } from \"#types\";\n\nconst ALIAS_MAP: Record<string, string> = {\n sonnet: MODEL_SONNET,\n opus: MODEL_OPUS,\n fable: MODEL_FABLE,\n \"fable-5.2\": MODEL_FABLE_5_2,\n};\n\nconst VALID_ALIASES = new Set(Object.keys(ALIAS_MAP));\nconst VALID_EFFORTS = new Set<EffortLevel>(CLAUDE_EFFORT_VALUES);\n\nexport const claudeRegistry: AgentRegistry = {\n kind: \"claude\",\n defaultModel: \"sonnet\",\n defaultEffort: \"high\",\n\n expandModelAlias(s) {\n return ALIAS_MAP[s] ?? s;\n },\n\n validateModel(s) {\n return VALID_ALIASES.has(s);\n },\n\n validEfforts: CLAUDE_EFFORT_VALUES,\n validateEffort(s) {\n return VALID_EFFORTS.has(s);\n },\n\n footerLabel(model, effort) {\n return effort ? `${model} · ${effort}` : model;\n },\n};\n\nexport const claudeRegistryOperations: AgentRegistryOperations = {\n writeRollout(opts) {\n // `reuseSessionId` (if any) becomes the SDK resume key + path component,\n // so claude→codex→claude lands at the original `~/.claude/projects/<dir>/<id>.jsonl`\n // instead of orphaning a fresh UUID every switch.\n const { sessionId, rolloutPath } = writeClaudeRollout({\n cwd: opts.cwd,\n entries: opts.entries,\n model: claudeRegistry.expandModelAlias(opts.model ?? claudeRegistry.defaultModel),\n ...(opts.reuseSessionId ? { sessionId: opts.reuseSessionId } : {}),\n });\n return { sessionId, rolloutPath };\n },\n\n // Claude has a native fork API in @anthropic-ai/claude-agent-sdk that produces\n // a byte-equivalent copy of the parent rollout. Preserves tool history\n // structurally, so the fork is indistinguishable from the parent on resume.\n //\n // SDK ≥0.3.19x semantics: `dir` is where to FIND the parent session (lookup\n // scope), NOT the destination — passing the derived topic's cwd made lookup\n // fail (\"Session … not found in project directory\"). The fork file is always\n // written NEXT TO the parent rollout, so after forking we move it into the\n // derived cwd's project dir where a resume from that cwd expects it.\n async forkSession({ parentSessionId, cwd, title }) {\n const { forkSession } = await import(\"@anthropic-ai/claude-agent-sdk\");\n // Omit `dir`: the parent session lives under the SOURCE topic's project\n // dir, which this registry never receives — global search finds it.\n const result = await forkSession(parentSessionId, {\n ...(title ? { title } : {}),\n });\n const projectsRoot = join(homedir(), \".claude\", \"projects\");\n const destDir = join(projectsRoot, encodeClaudeCwd(cwd));\n const destPath = join(destDir, `${result.sessionId}.jsonl`);\n if (!existsSync(destPath)) {\n const sourcePath = readdirSync(projectsRoot)\n .map((d) => join(projectsRoot, d, `${result.sessionId}.jsonl`))\n .find((p) => existsSync(p));\n if (!sourcePath) {\n throw new Error(\n `claude forkSession: fork rollout ${result.sessionId}.jsonl not found under ${projectsRoot}`,\n );\n }\n mkdirSync(destDir, { recursive: true });\n renameSync(sourcePath, destPath);\n }\n return {\n forkId: result.sessionId,\n // Same project-dir layout as cleanupRollouts below — NOT under\n // `cwd/.claude/sessions/`. A wrong path here makes cleanupAgentFork's\n // existsSync always false, so silent-fork rollouts accumulate forever.\n rolloutPath: destPath,\n };\n },\n\n // Each Claude rollout lives at `~/.claude/projects/<encoded-cwd>/<sessionId>.jsonl`.\n // The encoded-cwd is deterministic so we can compute the path directly\n // without globbing — fast and robust against the SDK changing date layout.\n async cleanupRollouts({ cwd, sessionIds }) {\n const projectsDir = join(homedir(), \".claude\", \"projects\", encodeClaudeCwd(cwd));\n const failures: unknown[] = [];\n for (const sid of sessionIds) {\n const path = join(projectsDir, `${sid}.jsonl`);\n try {\n unlinkSync(path);\n } catch (e) {\n if ((e as NodeJS.ErrnoException)?.code !== \"ENOENT\") {\n logger.warn({ err: e, path }, \"claude cleanupRollouts: unlink failed\");\n failures.push(e);\n }\n }\n }\n if (failures.length > 0) {\n throw new AggregateError(failures, \"claude cleanupRollouts failed\");\n }\n },\n};\n",
|
|
6
6
|
"import { existsSync, unlinkSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { AgentRegistry, AgentRegistryOperations } from \"#agents/contracts\";\nimport { hostedCodexHomePath } from \"#agents/execution-host\";\nimport { writeCodexRollout } from \"#agents/rollout/codex\";\nimport { logger } from \"#platform/logger\";\nimport { CODEX_EFFORT_VALUES, type EffortLevel } from \"#types\";\n\nconst VALID_EFFORTS = new Set<EffortLevel>(CODEX_EFFORT_VALUES);\n\n// Codex CLI's own bundled default became gpt-6-astra as of v0.153.4\n// (2026-09-05); before that it was gpt-5.6-sol (`codex exec` 2026-07-10 →\n// \"model: gpt-5.6-sol\"). We deliberately default to the luna tier — the\n// cheapest/fastest GPT-6 tier — for a general always-on assistant where most\n// queries are light. Heavier work escalates to terra/sol/astra via set_model. The\n// GPT-5.6 Sol/Luna/Terra ids are retired aliases of their GPT-6 successors (see\n// canonicalModelId), so a stored gpt-5.6-luna normalizes to luna. The provider\n// resolves the tier immediately before passing it to the SDK.\nexport const codexRegistry: AgentRegistry = {\n kind: \"codex\",\n defaultModel: \"luna\",\n // defaultEffort intentionally omitted — Codex SDK treats absence as\n // \"reasoning off\". Setting \"high\"/etc. would silently flip on reasoning.\n\n expandModelAlias(s) {\n return s;\n },\n\n validateModel(s) {\n // Codex doesn't publish a closed model list and OpenAI ships new IDs\n // (gpt-6-astra, gpt-6-sol, gpt-6.1-terra, gpt-6-luna, o3, ...) frequently. Best-effort: accept any\n // non-empty string. Bad IDs surface at SDK call time with a clear error.\n return typeof s === \"string\" && s.length > 0;\n },\n\n validEfforts: CODEX_EFFORT_VALUES,\n validateEffort(s) {\n // GPT-5.6 accepts low/medium/high/xhigh/max; 'minimal'\n // was removed because the Codex API rejects it when default tools\n // (image_gen, web_search) are active.\n return VALID_EFFORTS.has(s);\n },\n\n footerLabel(model, effort) {\n // Codex omits effort to mean \"reasoning off\". Show `(off)` explicitly so\n // the user can distinguish from claude (which always has a default).\n return `${model} · ${effort ?? \"(off)\"}`;\n },\n};\n\nexport const codexRegistryOperations: AgentRegistryOperations = {\n writeRollout(opts) {\n // Codex SDK exposes the resume key as `threadId`; AgentRegistry unifies\n // the name to `sessionId` so callers don't branch on agent.\n // `reuseSessionId` (if any) is forwarded as `threadId` so claude→codex→claude\n // round-trips also keep one continuous codex thread instead of orphaning a\n // fresh uuidv7 on every switch.\n const { threadId, rolloutPath } = writeCodexRollout({\n cwd: opts.cwd,\n entries: opts.entries,\n model: opts.model ?? codexRegistry.defaultModel,\n ...(opts.effort ? { effort: opts.effort } : {}),\n ...(opts.reuseSessionId ? { threadId: opts.reuseSessionId } : {}),\n });\n return { sessionId: threadId, rolloutPath };\n },\n\n // The TypeScript SDK does not expose forking yet, but the bundled Codex App\n // Server does. Native thread/fork preserves the provider's stored prefix,\n // including tool structure, which gives prompt caching the best chance to\n // reuse the parent context. Callers retain unified-log synthesis as fallback.\n async forkSession({ parentSessionId }) {\n // The app-server integration resolves the SDK's bundled CLI. Keep that\n // provider-only dependency out of lightweight registry consumers such as\n // the stdio Cron MCP server, which runs under Node + tsx.\n const { forkCodexSession } = await import(\"#agents/codex-app-server\");\n return await forkCodexSession(parentSessionId);\n },\n\n // Codex stores rollouts at `~/.codex/sessions/<YYYY>/<MM>/<DD>/rollout-<ts>-<threadId>.jsonl`.\n // The date prefix is unknown at cleanup time (it's the *original* write\n // timestamp, not \"now\"), so we glob across the whole sessions tree by\n // threadId suffix. With at most a few thousand files in active use this\n // is well under a millisecond on a warm filesystem.\n async cleanupRollouts({ sessionIds }) {\n if (sessionIds.length === 0) return;\n const sessionsDir = join(hostedCodexHomePath(), \"sessions\");\n // No sessions directory means there are no provider rollouts left to remove.\n if (!existsSync(sessionsDir)) return;\n const failures: unknown[] = [];\n // One Glob per threadId so a single corrupt entry can't poison the rest.\n // Bun.Glob's `scan` yields paths relative to its base dir.\n for (const tid of sessionIds) {\n try {\n const glob = new Bun.Glob(`**/rollout-*-${tid}.jsonl`);\n for await (const rel of glob.scan({ cwd: sessionsDir, onlyFiles: true })) {\n const path = join(sessionsDir, rel);\n try {\n unlinkSync(path);\n } catch (e) {\n if ((e as NodeJS.ErrnoException)?.code !== \"ENOENT\") {\n logger.warn({ err: e, path }, \"codex cleanupRollouts: unlink failed\");\n failures.push(e);\n }\n }\n }\n } catch (e) {\n logger.warn({ err: e, threadId: tid }, \"codex cleanupRollouts: scan failed\");\n failures.push(e);\n }\n }\n if (failures.length > 0) {\n throw new AggregateError(failures, \"codex cleanupRollouts failed\");\n }\n },\n};\n",
|
|
7
7
|
"import { randomUUID } from \"node:crypto\";\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { join, resolve } from \"node:path\";\nimport type { AgentRegistry, AgentRegistryOperations } from \"#agents/contracts\";\nimport { assertUuidLike, ensureCwdExists, extractChatPairs } from \"#agents/rollout/shared\";\nimport { logger } from \"#platform/logger\";\nimport { MAESTRO_EFFORT_VALUES } from \"#types\";\n\nconst ALIAS_MAP: Record<string, string> = {\n \"deepseek-pro\": \"deepseek-v4-pro\",\n // \"deepseek-flash\" was disabled in 0.1.25 because DeepSeek had retired its\n // old flash model. \"DeepSeek-V4-Flash-0731\" (released 2026-07-31) is an\n // unrelated, currently-live model reusing a similar name — verified with a\n // live API call before re-enabling this alias.\n \"deepseek-flash\": \"deepseek-v4-flash\",\n kimi: \"kimi-k3\",\n \"kimi-pro\": \"kimi-k3\",\n \"kimi-code\": \"kimi-k2.7-code\",\n glm: \"glm-5.3\",\n \"glm-pro\": \"glm-5.3\",\n \"glm-flash\": \"glm-5.3-flash\",\n};\nconst VALID_MODELS = new Set([...Object.keys(ALIAS_MAP), ...Object.values(ALIAS_MAP)]);\nconst VALID_EFFORTS = new Set(MAESTRO_EFFORT_VALUES);\n\nexport const maestroRegistry: AgentRegistry = {\n kind: \"maestro\",\n defaultModel: \"deepseek-pro\",\n defaultEffort: \"medium\",\n expandModelAlias(model) {\n return ALIAS_MAP[model] ?? model;\n },\n validateModel(model) {\n return VALID_MODELS.has(model);\n },\n validEfforts: MAESTRO_EFFORT_VALUES,\n validateEffort(effort) {\n return VALID_EFFORTS.has(effort);\n },\n footerLabel(model, effort) {\n return effort ? `${model} · ${effort}` : model;\n },\n};\n\nfunction maestroSessionsDir(): string {\n return join(\n process.env.MAESTRO_DATA_DIR\n ? resolve(process.env.MAESTRO_DATA_DIR)\n : join(homedir(), \".maestro\"),\n \"sessions\",\n );\n}\n\nfunction maestroSessionPath(sessionId: string): string {\n return join(maestroSessionsDir(), `${sessionId}.jsonl`);\n}\n\nfunction maestroActiveSessionPath(sessionId: string): string {\n return join(maestroSessionsDir(), `${sessionId}.active.jsonl`);\n}\n\nfunction existingCreatedAt(path: string): string | undefined {\n if (!existsSync(path)) return undefined;\n try {\n const firstLine = readFileSync(path, \"utf8\").split(\"\\n\", 1)[0];\n const parsed = JSON.parse(firstLine) as { _meta?: { createdAt?: unknown } };\n return typeof parsed._meta?.createdAt === \"string\" ? parsed._meta.createdAt : undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * Placeholder for a synthesized turn whose text is blank.\n *\n * Moonshot (Kimi) hard-rejects the *whole* request when any history message has\n * empty content — `Kimi API 400: the message at position N with role 'user'\n * must not be empty` (verified against the live API, kimi-k3). DeepSeek's\n * validator is laxer today but the same shape is not worth relying on.\n *\n * maestro-agent-sdk 0.2.1 drops empty assistant slots, but only in the\n * *content-block* form (`content: []`); the pair encoder below writes plain\n * strings, and `content: \"\"` still reaches the wire and 400s. Blank sides are\n * reachable here from real conversations — an attachment-only user submission\n * records a `user_message` with `content: \"\"`, and `renderUserPromptBatch`\n * passes it through verbatim — so the synthesized session must not contain one.\n *\n * We substitute rather than drop: dropping a pair would silently delete a turn\n * from the historical narrative the next agent reads, while a one-line marker\n * keeps the turn boundary and tells the model why the slot is thin.\n */\nconst BLANK_TURN_PLACEHOLDER = \"(no text content in this turn)\";\n\nfunction nonEmptyTurnText(text: string): string {\n return text.trim().length > 0 ? text : BLANK_TURN_PLACEHOLDER;\n}\n\nfunction writeRollout(options: Parameters<AgentRegistryOperations[\"writeRollout\"]>[0]) {\n const sessionId = options.reuseSessionId ?? randomUUID();\n assertUuidLike(\"sessionId\", sessionId);\n ensureCwdExists(options.cwd);\n const path = maestroSessionPath(sessionId);\n mkdirSync(maestroSessionsDir(), { recursive: true });\n const messages = extractChatPairs(options.entries).flatMap((pair) => [\n { role: \"user\", content: nonEmptyTurnText(pair.userText) },\n { role: \"assistant\", content: nonEmptyTurnText(pair.assistantText) },\n ]);\n const lines = [\n {\n _meta: {\n version: 1,\n cwd: options.cwd,\n createdAt: existingCreatedAt(path) ?? new Date().toISOString(),\n // Deliberately a literal, not the SDK's `MAESTRO_SDK_VERSION`: this\n // module must not statically import maestro-agent-sdk (asserted by\n // tests/core/daemon-import-boundaries.test.ts — the SDK stays off the\n // daemon startup path). The value names the session *format* version\n // this encoder targets, which is what a reader of the header needs.\n sdkVersion: \"0.2.0\",\n },\n },\n ...messages,\n ];\n writeFileSync(path, `${lines.map((line) => JSON.stringify(line)).join(\"\\n\")}\\n`, {\n mode: 0o600,\n });\n return { sessionId, rolloutPath: path };\n}\n\nexport const maestroRegistryOperations: AgentRegistryOperations = {\n writeRollout(options) {\n return writeRollout(options);\n },\n async forkSession(options) {\n // Fork the full raw history while preserving the compacted working view.\n // A compacted parent that cannot copy its active projection is not a usable\n // cache-preserving fork, so let the caller fall back to bounded synthesis.\n const { deleteMaestroSession, forkSessionAt, loadRawMaestroSession } = await import(\n \"maestro-agent-sdk\"\n );\n const parentMessages = loadRawMaestroSession(options.parentSessionId);\n if (!parentMessages) {\n throw new Error(`Maestro parent session not found: ${options.parentSessionId}`);\n }\n const parentHasActiveProjection = existsSync(maestroActiveSessionPath(options.parentSessionId));\n const fork = forkSessionAt({\n parentSessionId: options.parentSessionId,\n messageIndex: parentMessages.length,\n cwd: options.cwd,\n userId: String(options.userId),\n });\n if (parentHasActiveProjection && !fork.activeProjectionForked) {\n deleteMaestroSession(fork.sessionId);\n throw new Error(`Maestro active projection could not be forked: ${options.parentSessionId}`);\n }\n const activePath = maestroActiveSessionPath(fork.sessionId);\n return {\n forkId: fork.sessionId,\n rolloutPath: fork.rolloutPath,\n ...(existsSync(activePath) ? { cleanupPaths: [activePath] } : {}),\n };\n },\n async cleanupRollouts(options) {\n // Keep the SDK off the daemon startup path, but use its canonical cleanup\n // once a Maestro session is actually being removed. It also clears memory,\n // task, todo, and in-process file-state sidecars.\n const { deleteMaestroSession } = await import(\"maestro-agent-sdk\");\n const failures: unknown[] = [];\n for (const sessionId of options.sessionIds) {\n try {\n deleteMaestroSession(sessionId);\n const remaining = [\n maestroSessionPath(sessionId),\n maestroActiveSessionPath(sessionId),\n ].filter(existsSync);\n if (remaining.length > 0) {\n throw new Error(`Maestro session files remain after cleanup: ${remaining.join(\", \")}`);\n }\n } catch (error) {\n logger.warn({ err: error, sessionId }, \"maestro cleanupRollouts: cleanup failed\");\n failures.push(error);\n }\n }\n if (failures.length > 0) {\n throw new AggregateError(failures, \"Maestro rollout cleanup failed\");\n }\n },\n};\n",
|
|
8
8
|
"import { claudeRegistry, claudeRegistryOperations } from \"#agents/claude-registry\";\nimport { codexRegistry, codexRegistryOperations } from \"#agents/codex-registry\";\nimport type { AgentRegistry, AgentRegistryOperations } from \"#agents/contracts\";\nimport { maestroRegistry, maestroRegistryOperations } from \"#agents/maestro-registry\";\nimport type { AgentKind } from \"#types\";\n\nexport type {\n AgentRegistry,\n AgentRegistryOperations,\n CleanupRolloutsOptions,\n ForkRegistryOptions,\n ForkRegistryResult,\n WriteRolloutOptions,\n WriteRolloutResult,\n} from \"#agents/contracts\";\n\nconst REGISTRIES: Record<AgentKind, AgentRegistry> = {\n claude: claudeRegistry,\n codex: codexRegistry,\n maestro: maestroRegistry,\n};\n\nexport function getRegistry(agent: AgentKind): AgentRegistry {\n return REGISTRIES[agent];\n}\n\nconst OPERATIONS: Record<AgentKind, AgentRegistryOperations> = {\n claude: claudeRegistryOperations,\n codex: codexRegistryOperations,\n maestro: maestroRegistryOperations,\n};\n\nexport function getRegistryOperations(agent: AgentKind): AgentRegistryOperations {\n return OPERATIONS[agent];\n}\n",
|
|
9
9
|
"import {\n type AgentRegistry,\n type AgentRegistryOperations,\n type CleanupRolloutsOptions,\n type ForkRegistryOptions,\n type ForkRegistryResult,\n getRegistry as resolveCoreRegistry,\n getRegistryOperations as resolveCoreRegistryOperations,\n type WriteRolloutOptions,\n type WriteRolloutResult,\n} from \"@negotium/core/registry\";\n\nexport type {\n AgentRegistry,\n AgentRegistryOperations,\n CleanupRolloutsOptions,\n ForkRegistryOptions,\n ForkRegistryResult,\n WriteRolloutOptions,\n WriteRolloutResult,\n};\n\nexport const getRegistry: typeof resolveCoreRegistry = (agent) => resolveCoreRegistry(agent);\n\nexport const getRegistryOperations: typeof resolveCoreRegistryOperations = (agent) =>\n resolveCoreRegistryOperations(agent);\n"
|
|
10
10
|
],
|
|
11
|
-
"mappings": "
|
|
12
|
-
"debugId": "
|
|
11
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AAOA,IAAM,YAAoC;AAAA,EACxC,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,OAAO;AAAA,EACP,aAAa;AACf;AAEA,IAAM,gBAAgB,IAAI,IAAI,OAAO,KAAK,SAAS,CAAC;AACpD,IAAM,gBAAgB,IAAI,IAAiB,oBAAoB;AAExD,IAAM,iBAAgC;AAAA,EAC3C,MAAM;AAAA,EACN,cAAc;AAAA,EACd,eAAe;AAAA,EAEf,gBAAgB,CAAC,GAAG;AAAA,IAClB,OAAO,UAAU,MAAM;AAAA;AAAA,EAGzB,aAAa,CAAC,GAAG;AAAA,IACf,OAAO,cAAc,IAAI,CAAC;AAAA;AAAA,EAG5B,cAAc;AAAA,EACd,cAAc,CAAC,GAAG;AAAA,IAChB,OAAO,cAAc,IAAI,CAAC;AAAA;AAAA,EAG5B,WAAW,CAAC,OAAO,QAAQ;AAA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ChF,SAAS,KAAK,KAAK;AAAA;AAAA,IAEvB;AAAA,IACA,IAAI,SAAS,SAAS,GAAG;AAAA,MACvB,MAAM,IAAI,eAAe,UAAU,gCAAgC;AAAA,IACrE;AAAA;AAEJ;;;AC5KA,IAAM,aAA+C;AAAA,EACnD,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,SAAS;AACX;AAEO,SAAS,WAAW,CAAC,OAAiC;AAAA,EAC3D,OAAO,WAAW;AAAA;AAGpB,IAAM,aAAyD;AAAA,EAC7D,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,SAAS;AACX;AAEO,SAAS,qBAAqB,CAAC,OAA2C;AAAA,EAC/E,OAAO,WAAW;AAAA;;;ACXb,IAAM,eAA0C,CAAC,UAAU,YAAoB,KAAK;AAEpF,IAAM,yBAA8D,CAAC,UAC1E,sBAA8B,KAAK;",
|
|
12
|
+
"debugId": "8D84891E880A5CC664756E2164756E21",
|
|
13
13
|
"names": []
|
|
14
14
|
}
|
package/dist/rollout.js
CHANGED
|
@@ -11,12 +11,12 @@ import {
|
|
|
11
11
|
migrateCodexRolloutNativeMultiAgentMetadata2,
|
|
12
12
|
writeCodexRollout2,
|
|
13
13
|
decodeUuidV7Timestamp2
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-ng13grfj.js";
|
|
15
15
|
import {
|
|
16
16
|
encodeClaudeCwd2,
|
|
17
17
|
writeClaudeRollout2,
|
|
18
18
|
repairPoisonedRollout2
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-m1ngkjdd.js";
|
|
20
20
|
|
|
21
21
|
// src/rollout.ts
|
|
22
22
|
import { fileURLToPath } from "url";
|
|
@@ -3,7 +3,7 @@ import { homedir } from "node:os";
|
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import type { AgentRegistry, AgentRegistryOperations } from "#agents/contracts";
|
|
5
5
|
import { encodeClaudeCwd, writeClaudeRollout } from "#agents/rollout/claude";
|
|
6
|
-
import { MODEL_FABLE, MODEL_OPUS, MODEL_SONNET } from "#platform/config";
|
|
6
|
+
import { MODEL_FABLE, MODEL_FABLE_5_2, MODEL_OPUS, MODEL_SONNET } from "#platform/config";
|
|
7
7
|
import { logger } from "#platform/logger";
|
|
8
8
|
import { CLAUDE_EFFORT_VALUES, type EffortLevel } from "#types";
|
|
9
9
|
|
|
@@ -11,6 +11,7 @@ const ALIAS_MAP: Record<string, string> = {
|
|
|
11
11
|
sonnet: MODEL_SONNET,
|
|
12
12
|
opus: MODEL_OPUS,
|
|
13
13
|
fable: MODEL_FABLE,
|
|
14
|
+
"fable-5.2": MODEL_FABLE_5_2,
|
|
14
15
|
};
|
|
15
16
|
|
|
16
17
|
const VALID_ALIASES = new Set(Object.keys(ALIAS_MAP));
|
|
@@ -34,7 +34,7 @@ function agentAliases(agent: AgentKind): string[] {
|
|
|
34
34
|
"gpt-6-astra",
|
|
35
35
|
];
|
|
36
36
|
case "claude":
|
|
37
|
-
return ["claude", "클로드", "sonnet", "opus", "fable"];
|
|
37
|
+
return ["claude", "클로드", "sonnet", "opus", "fable", "fable-5.2"];
|
|
38
38
|
case "maestro":
|
|
39
39
|
return [
|
|
40
40
|
"maestro",
|
|
@@ -125,7 +125,7 @@ export function createSelfConfigToolDefinitionsForCore(
|
|
|
125
125
|
description: toolDescription(
|
|
126
126
|
core,
|
|
127
127
|
"set_model",
|
|
128
|
-
"Set the model for THIS topic; it persists and applies from the NEXT turn. Use a model from the system prompt's same-agent catalog. Cross-agent changes require an explicit user-requested set_agent first. Fails if the user locked this setting. NEVER use 'fable' unless explicitly requested.",
|
|
128
|
+
"Set the model for THIS topic; it persists and applies from the NEXT turn. Use a model from the system prompt's same-agent catalog. Cross-agent changes require an explicit user-requested set_agent first. Fails if the user locked this setting. NEVER use 'fable' or 'fable-5.2' unless explicitly requested.",
|
|
129
129
|
),
|
|
130
130
|
schema: { model: z.string().describe("Model id valid for the topic's current agent.") },
|
|
131
131
|
async handler({ model }: { model: string }) {
|
|
@@ -304,9 +304,17 @@ export function createSubagentLifecycle<TContext extends SpawnSubagentToolContex
|
|
|
304
304
|
return depth;
|
|
305
305
|
}
|
|
306
306
|
|
|
307
|
+
/**
|
|
308
|
+
* Whether this room gets the subagent tools and the prompt lines about them.
|
|
309
|
+
* Otium rooms do every task themselves, on any engine, so they get neither.
|
|
310
|
+
*/
|
|
307
311
|
function canSpawnSubagentsFromTopic(topicId: string): boolean {
|
|
308
312
|
const topic = host.storage.getTopic(topicId);
|
|
309
|
-
return
|
|
313
|
+
return (
|
|
314
|
+
topic?.kind === "agent" &&
|
|
315
|
+
topic.surface !== "otium" &&
|
|
316
|
+
computeSubagentDepth(topicId) < limits.maxDepth
|
|
317
|
+
);
|
|
310
318
|
}
|
|
311
319
|
|
|
312
320
|
/** Read-merge-write the parent card and broadcast the patch. */
|
|
@@ -21,6 +21,7 @@ export const MODEL_OWNER: Record<string, AgentKind> = {
|
|
|
21
21
|
opus: "claude",
|
|
22
22
|
haiku: "claude",
|
|
23
23
|
fable: "claude",
|
|
24
|
+
"fable-5.2": "claude",
|
|
24
25
|
astra: "codex",
|
|
25
26
|
sol: "codex",
|
|
26
27
|
luna: "codex",
|
|
@@ -161,6 +162,18 @@ export const SELECTABLE_MODELS: readonly SelectableModel[] = [
|
|
|
161
162
|
"Claude API/extra usage: $10/M input, $12.50/M cache write, $0.25/M cache read (cut from $1/M in Fable 5.1, 2026-09-01), $50/M output",
|
|
162
163
|
estimatedUsage: `${CLAUDE_COMMUNITY_SESSION}; Fable drains weighted quota fastest, so use only on explicit user request. No stable per-model token cap is published.`,
|
|
163
164
|
},
|
|
165
|
+
{
|
|
166
|
+
model: "fable-5.2",
|
|
167
|
+
agent: "claude",
|
|
168
|
+
description:
|
|
169
|
+
"Claude Fable 5.2 (2026-11-09): same top-tier route as fable, newer and cheaper, for the hardest and longest-running tasks.",
|
|
170
|
+
intelligenceTier: "fable",
|
|
171
|
+
routingSummary: "hardest long-running work; cheaper than fable (5.1); explicit request only",
|
|
172
|
+
accessCost: CLAUDE_MAX_20X_COST,
|
|
173
|
+
marginalTokenCost:
|
|
174
|
+
"Claude API/extra usage: $8/M input, $40/M output (cache rates not published; assumed $10/M cache write, $0.20/M cache read)",
|
|
175
|
+
estimatedUsage: `${CLAUDE_COMMUNITY_SESSION}; Fable drains weighted quota fastest, so use only on explicit user request. No stable per-model token cap is published.`,
|
|
176
|
+
},
|
|
164
177
|
{
|
|
165
178
|
model: "opus",
|
|
166
179
|
agent: "claude",
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { accessSync, constants, statSync } from "node:fs";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import { delimiter, isAbsolute, join } from "node:path";
|
|
5
|
+
import { promisify } from "node:util";
|
|
6
|
+
|
|
7
|
+
export type BrowserBackend = "chrome" | "egolite";
|
|
8
|
+
|
|
9
|
+
/** Resolve once at node startup; explicit overrides never depend on local discovery. */
|
|
10
|
+
export function resolveBrowserBackend(
|
|
11
|
+
value?: string,
|
|
12
|
+
findEgoBrowser: () => string | undefined = resolveEgoBrowserBin,
|
|
13
|
+
): BrowserBackend {
|
|
14
|
+
const backend = value?.trim();
|
|
15
|
+
if (!backend) return findEgoBrowser() ? "egolite" : "chrome";
|
|
16
|
+
if (backend === "chrome" || backend === "egolite") return backend;
|
|
17
|
+
throw new Error("NEGOTIUM_BROWSER_BACKEND must be chrome or egolite");
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Search executable locations only; never resolve a tool from the topic's cwd. */
|
|
21
|
+
export function resolveEgoBrowserBin(
|
|
22
|
+
path = process.env.PATH ?? "",
|
|
23
|
+
home = homedir(),
|
|
24
|
+
): string | undefined {
|
|
25
|
+
const names = process.platform === "win32" ? ["ego-browser.exe"] : ["ego-browser"];
|
|
26
|
+
const directories = [...path.split(delimiter).filter(isAbsolute), join(home, ".local", "bin")];
|
|
27
|
+
for (const directory of directories) {
|
|
28
|
+
for (const name of names) {
|
|
29
|
+
const candidate = join(directory, name);
|
|
30
|
+
try {
|
|
31
|
+
accessSync(candidate, constants.X_OK);
|
|
32
|
+
if (statSync(candidate).isFile()) return candidate;
|
|
33
|
+
} catch {
|
|
34
|
+
// The CLI is optional; continue looking in the documented user install location.
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Probe the CLI without opening a browser, changing profiles, or importing user data. */
|
|
42
|
+
export async function prepareEgoBrowser(): Promise<string> {
|
|
43
|
+
const command = resolveEgoBrowserBin();
|
|
44
|
+
if (!command) {
|
|
45
|
+
throw new Error("ego-browser is not installed on this Negotium node or is not executable");
|
|
46
|
+
}
|
|
47
|
+
await promisify(execFile)(command, ["--version"], {
|
|
48
|
+
timeout: 5_000,
|
|
49
|
+
maxBuffer: 16_384,
|
|
50
|
+
windowsHide: true,
|
|
51
|
+
});
|
|
52
|
+
return command;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export const EGO_BROWSER_INSTRUCTIONS = `## Browser
|
|
56
|
+
This node uses ego lite through the official ego-browser CLI, using its existing logged-in browser.
|
|
57
|
+
The Chrome browser_* MCP tools are not registered. Never start browser-rs, point AB_CHROME at ego lite,
|
|
58
|
+
attach to its debugging port, or create a replacement browser/profile.
|
|
59
|
+
Use browser automation only when this turn's runtime reminder authorizes it. If it is unavailable or
|
|
60
|
+
the topic owner check denies access, do not bypass that decision through a shell or another tool.
|
|
61
|
+
When authorized, use the executable supplied by the runtime through your foreground shell tool.
|
|
62
|
+
Before the first browser action in a session, run that executable with "skill" and read its entire
|
|
63
|
+
installed-version guide. Use its "nodejs" command and documented APIs; do not assume Playwright APIs.
|
|
64
|
+
Create one task space for the user goal and retain its spaceId across commands and follow-up turns.
|
|
65
|
+
Use a unique task name tied to this topic and goal; never claim another topic's or a user's space
|
|
66
|
+
without explicit authorization. Existing login state is shared, not the user's other task spaces.
|
|
67
|
+
Stop when the user takes control. Hand off authentication to the user and resume the same task space
|
|
68
|
+
only after confirmation. On successful completion, call finish({ keep: [] }) unless the user needs
|
|
69
|
+
specific result tabs. On interruption, preserve the space for resumption; never kill the browser or
|
|
70
|
+
delete its profile. Do not close a space just because an AI turn ended.
|
|
71
|
+
Verify each action through the guide's observation APIs. Report CLI/browser errors as errors and do
|
|
72
|
+
not silently switch to Chrome. The CLI probe does not prove the browser is connected or authenticated.
|
|
73
|
+
Vault secret injection through browser-rs is not available here; do not copy secrets into scripts or logs.`;
|
|
@@ -13,6 +13,7 @@ import { createRequire } from "node:module";
|
|
|
13
13
|
import { homedir } from "node:os";
|
|
14
14
|
import { dirname, join, resolve } from "node:path";
|
|
15
15
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
16
|
+
import { resolveBrowserBackend } from "#platform/browser-backend";
|
|
16
17
|
import {
|
|
17
18
|
parseRuntimePort,
|
|
18
19
|
readEnvText,
|
|
@@ -99,6 +100,7 @@ export const TOPIC_WORKSPACE_DIR = resolve(WORKSPACE_DIR, "topics");
|
|
|
99
100
|
export const SHARED_WIKI_DIR = resolve(WORKSPACE_DIR, "wiki");
|
|
100
101
|
export const CRON_WORKSPACE_DIR = resolve(WORKSPACE_DIR, "cron");
|
|
101
102
|
export const BROWSER_DIR = resolveLocalStateDir("NEGOTIUM_BROWSER_DIR", "browser");
|
|
103
|
+
export const BROWSER_BACKEND = resolveBrowserBackend(envText("NEGOTIUM_BROWSER_BACKEND"));
|
|
102
104
|
export const BROWSER_PROFILES_DIR = resolve(BROWSER_DIR, "profiles");
|
|
103
105
|
export const BINARIES_DIR = resolve(STATE_DIR, "binaries");
|
|
104
106
|
export const SECRETS_DIR = resolve(STATE_DIR, "secrets");
|
|
@@ -530,6 +532,7 @@ export const MODEL_SONNET = "claude-sonnet-5";
|
|
|
530
532
|
export const MODEL_OPUS = "claude-opus-5-5";
|
|
531
533
|
export const MODEL_HAIKU = "claude-haiku-4-5-20251001";
|
|
532
534
|
export const MODEL_FABLE = "claude-fable-5-1"; // Mythos-class, Fable 5.1 announced 2026-09-01 (was claude-fable-5)
|
|
535
|
+
export const MODEL_FABLE_5_2 = "claude-fable-5-2"; // Fable 5.2 announced 2026-11-09; selectable as `fable-5.2`, `fable` stays on 5.1
|
|
533
536
|
|
|
534
537
|
// DeepSeek V4 (released 2026-04-24). API is OpenAI-compatible at
|
|
535
538
|
// https://api.deepseek.com/v1/chat/completions; thinking mode is enabled via
|
|
@@ -14,6 +14,7 @@ import { peerSessionBridgeIpcEnv } from "#mcp/session-comm/bridge-ipc-config";
|
|
|
14
14
|
import { bgBashContextCapability } from "#platform/background-bash/manager";
|
|
15
15
|
import {
|
|
16
16
|
AGENT_HEALTH_SERVER,
|
|
17
|
+
BROWSER_BACKEND,
|
|
17
18
|
CANONICAL_MCP_PROXY_SERVER,
|
|
18
19
|
DECISION_SERVER,
|
|
19
20
|
envText,
|
|
@@ -365,6 +366,8 @@ const MCP_CATALOG: Record<string, RuntimeMcpCatalogEntry> = {
|
|
|
365
366
|
playwright: {
|
|
366
367
|
...commonRuntimeMcpPolicy("playwright"),
|
|
367
368
|
build({ userId, session, topicId, playwrightPort, playwrightCapability, agent }) {
|
|
369
|
+
// ego lite is driven by its native CLI; no Chrome process, MCP, or missing-port alert.
|
|
370
|
+
if (BROWSER_BACKEND === "egolite") return null;
|
|
368
371
|
// Codex and Maestro use Streamable HTTP while Claude uses SSE. Both
|
|
369
372
|
// transports terminate at the same long-lived browser/profile server.
|
|
370
373
|
if (playwrightPort && playwrightCapability) {
|
|
@@ -5,8 +5,10 @@ import {
|
|
|
5
5
|
MODEL_COST_ROUTING_SUMMARY,
|
|
6
6
|
SELECTABLE_MODELS,
|
|
7
7
|
} from "#agents/model-catalog";
|
|
8
|
+
import { EGO_BROWSER_INSTRUCTIONS } from "#platform/browser-backend";
|
|
8
9
|
import {
|
|
9
10
|
AGENTS_PROMPTS_DIR,
|
|
11
|
+
BROWSER_BACKEND,
|
|
10
12
|
PROJECT_ROOT,
|
|
11
13
|
RESOURCES_DIR,
|
|
12
14
|
resolveOutputLanguage,
|
|
@@ -87,7 +89,14 @@ function loadSessionPrompt(filename: string, fallback: string): string {
|
|
|
87
89
|
// `{{KEY}}` placeholders are resolved by the caller's replaceVars pass.
|
|
88
90
|
function sharedToolsPartial(): string {
|
|
89
91
|
if (_sharedToolsPartial === null) {
|
|
90
|
-
|
|
92
|
+
const shared = loadSessionPrompt("_shared-tools.md", "");
|
|
93
|
+
_sharedToolsPartial = shared.replace(
|
|
94
|
+
/<!-- CHROME_BROWSER_START -->[\s\S]*?<!-- CHROME_BROWSER_END -->/,
|
|
95
|
+
(chrome) =>
|
|
96
|
+
BROWSER_BACKEND === "egolite"
|
|
97
|
+
? EGO_BROWSER_INSTRUCTIONS
|
|
98
|
+
: chrome.replace(/<!-- CHROME_BROWSER_(?:START|END) -->\n?/g, ""),
|
|
99
|
+
);
|
|
91
100
|
}
|
|
92
101
|
return _sharedToolsPartial;
|
|
93
102
|
}
|
|
@@ -453,7 +462,7 @@ function buildRuntimeToolSection(
|
|
|
453
462
|
"`set_effort` is available but discouraged; use it only when the user explicitly requests an effort change.",
|
|
454
463
|
"`set_model` may be called autonomously only when the current model is clearly below the task's required capability, such as complex algorithm design, proof-level math, or broad multi-file refactoring. Choose the best-fit model directly from the same-agent catalog; model selection is not a mandatory one-step ladder. End the turn after changing it. Do not use vague task complexity as a trigger.",
|
|
455
464
|
"`set_agent` autonomous calls are forbidden. Only switch agent when the user explicitly asks to switch runtime, e.g. “switch to codex”, “use claude”.",
|
|
456
|
-
"Never use `fable` unless the user explicitly requests it;
|
|
465
|
+
"Never use `fable` or `fable-5.2` unless the user explicitly requests it; they are expensive.",
|
|
457
466
|
"",
|
|
458
467
|
"Model catalog (capability/cost routing guidance):",
|
|
459
468
|
MODEL_COST_ROUTING_SUMMARY,
|
|
@@ -18,6 +18,7 @@ Use a tool only when it is actually available; otherwise say so instead of prete
|
|
|
18
18
|
- Heavy work (large files, video encode, big crawls, browser automation): check `get_system_health` first and back off under resource pressure.
|
|
19
19
|
- Computer Use: if unavailable, check `get_mcp_config` for optional `cua-rs`; MCP changes apply next session.
|
|
20
20
|
|
|
21
|
+
<!-- CHROME_BROWSER_START -->
|
|
21
22
|
## Browser
|
|
22
23
|
Reading pages:
|
|
23
24
|
- Escalate in this order: `browser_snapshot` (interactive elements only) → full snapshot → wait briefly and re-snapshot if the page is still changing → screenshot as a last resort. Never make a screenshot the first move.
|
|
@@ -36,3 +37,4 @@ When something fails:
|
|
|
36
37
|
|
|
37
38
|
Coordinate input:
|
|
38
39
|
- Use `browser_pointer`, `browser_wheel`, and `browser_drag` only for things the accessibility tree cannot expose (canvases, drag handles, maps), and return to ref-based actions immediately afterward.
|
|
40
|
+
<!-- CHROME_BROWSER_END -->
|
|
@@ -175,6 +175,12 @@ export async function runTurnEventStream(
|
|
|
175
175
|
// Display-only text from `text_preview`, shown after pendingText until the
|
|
176
176
|
// provider's completed `text` for that block arrives.
|
|
177
177
|
let previewText = "";
|
|
178
|
+
// Where the text block currently streaming started in `accumulatedText` and
|
|
179
|
+
// `pendingText`, and the last completed block since the last tool boundary.
|
|
180
|
+
// A model can send the same sentence twice in a row (once as an interim note,
|
|
181
|
+
// once as the final answer); the second copy must not be glued onto the first.
|
|
182
|
+
let blockStart: { accumulated: number; pending: number } | null = null;
|
|
183
|
+
let lastCompletedBlock = "";
|
|
178
184
|
let pendingMessage: { id: string; createdAt: string } | null = null;
|
|
179
185
|
let previewTimer: ReturnType<typeof setTimeout> | null = null;
|
|
180
186
|
const clearPreviewTimer = (): void => {
|
|
@@ -287,6 +293,8 @@ export async function runTurnEventStream(
|
|
|
287
293
|
const text = pendingText.trimEnd();
|
|
288
294
|
pendingText = "";
|
|
289
295
|
previewText = "";
|
|
296
|
+
lastCompletedBlock = "";
|
|
297
|
+
blockStart = null;
|
|
290
298
|
if (silent || !text.trim()) {
|
|
291
299
|
// A `text_preview` that never got a completed `text` may already be on
|
|
292
300
|
// screen; take it back like a discarded turn's preview.
|
|
@@ -409,6 +417,9 @@ export async function runTurnEventStream(
|
|
|
409
417
|
|
|
410
418
|
switch (event.type) {
|
|
411
419
|
case "text_delta": {
|
|
420
|
+
if (!pendingSawDelta) {
|
|
421
|
+
blockStart = { accumulated: accumulatedText.length, pending: pendingText.length };
|
|
422
|
+
}
|
|
412
423
|
pendingSawDelta = true;
|
|
413
424
|
const incoming = event.content;
|
|
414
425
|
accumulatedText += incoming;
|
|
@@ -425,12 +436,29 @@ export async function runTurnEventStream(
|
|
|
425
436
|
case "text":
|
|
426
437
|
// The completed block replaces whatever preview was shown for it.
|
|
427
438
|
previewText = "";
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
439
|
+
{
|
|
440
|
+
const completed = event.content.trim();
|
|
441
|
+
const repeatsPreviousBlock = completed !== "" && completed === lastCompletedBlock;
|
|
442
|
+
if (pendingSawDelta) {
|
|
443
|
+
// Some providers emit tool_use before the completed copy of the
|
|
444
|
+
// streamed text block. A tool flush must not make that copy look
|
|
445
|
+
// like a new segment; consume it here as the delta terminator.
|
|
446
|
+
pendingSawDelta = false;
|
|
447
|
+
if (repeatsPreviousBlock && blockStart) {
|
|
448
|
+
// The repeat already streamed in as deltas: take it back out.
|
|
449
|
+
accumulatedText = accumulatedText.slice(0, blockStart.accumulated);
|
|
450
|
+
pendingText = pendingText.slice(0, blockStart.pending);
|
|
451
|
+
assistantContextTokens = estimateTextTokens(accumulatedText);
|
|
452
|
+
broadcastContextProgress();
|
|
453
|
+
} else if (completed) {
|
|
454
|
+
lastCompletedBlock = completed;
|
|
455
|
+
}
|
|
456
|
+
blockStart = null;
|
|
457
|
+
break;
|
|
458
|
+
}
|
|
459
|
+
// The same block twice in a row, with no tool call between: keep one.
|
|
460
|
+
if (repeatsPreviousBlock) break;
|
|
461
|
+
if (completed) lastCompletedBlock = completed;
|
|
434
462
|
}
|
|
435
463
|
{
|
|
436
464
|
const incoming = event.content;
|
|
@@ -20,6 +20,8 @@ import { getRegistryOperations } from "#agents/registry";
|
|
|
20
20
|
import { WsHub } from "#bus";
|
|
21
21
|
import { asTurnId, asTurnSlotKey, type TurnSlotKey } from "#identifiers";
|
|
22
22
|
import { ensureBgBash } from "#platform/background-bash/manager";
|
|
23
|
+
import { prepareEgoBrowser } from "#platform/browser-backend";
|
|
24
|
+
import { BROWSER_BACKEND } from "#platform/config";
|
|
23
25
|
import { FROM_AUTO_CONTINUE } from "#platform/constants";
|
|
24
26
|
import { logger } from "#platform/logger";
|
|
25
27
|
import { consumePlaywrightUnavailable, markPlaywrightUnavailable } from "#platform/mcp-config";
|
|
@@ -985,6 +987,29 @@ async function drainOneDurableUserTurn(): Promise<void> {
|
|
|
985
987
|
try {
|
|
986
988
|
const request = claimNextRuntimeUserTurnRequest(RUNTIME_INSTANCE_ID);
|
|
987
989
|
if (!request) return;
|
|
990
|
+
// The claim only proves the topic's turn lease *looked* stale. When the
|
|
991
|
+
// host sleeps, or this event loop stalls, past TURN_LEASE_STALE_MS, this
|
|
992
|
+
// process's own running turn looks abandoned too, and the worker claims
|
|
993
|
+
// the row that turn is executing. Starting it again would take the
|
|
994
|
+
// same-actor steering path and fold the request into itself, doubling its
|
|
995
|
+
// messages, then re-queue the doubled row for the next tick to double
|
|
996
|
+
// again. A turn this process is running is never someone else's to
|
|
997
|
+
// recover: keep its row marked running, or hand a different row back to
|
|
998
|
+
// be claimed once the local turn releases the room.
|
|
999
|
+
const localTurn = getRoomQuery(request.topicId);
|
|
1000
|
+
if (localTurn) {
|
|
1001
|
+
if (localTurn.durableRequestIds?.includes(request.requestId)) {
|
|
1002
|
+
markRuntimeUserTurnRunning(
|
|
1003
|
+
request.topicId,
|
|
1004
|
+
request.requestId,
|
|
1005
|
+
RUNTIME_INSTANCE_ID,
|
|
1006
|
+
localTurn.queryId,
|
|
1007
|
+
);
|
|
1008
|
+
} else {
|
|
1009
|
+
releaseRuntimeUserTurnClaim(request.topicId, request.requestId, RUNTIME_INSTANCE_ID);
|
|
1010
|
+
}
|
|
1011
|
+
return;
|
|
1012
|
+
}
|
|
988
1013
|
const topic = getTopic(request.topicId);
|
|
989
1014
|
if (!topic?.agent) {
|
|
990
1015
|
completeRuntimeUserTurnRequest(request.topicId, request.requestId, RUNTIME_INSTANCE_ID);
|
|
@@ -1273,6 +1298,22 @@ export function startAiTurn(params: StartAiTurnParams): string | null {
|
|
|
1273
1298
|
}
|
|
1274
1299
|
if (decision.action === "abort-replace") {
|
|
1275
1300
|
const running = decision.running;
|
|
1301
|
+
// A replay of the very request this room is already running carries no
|
|
1302
|
+
// new message. Steering with it would append the running turn's messages
|
|
1303
|
+
// to themselves and replace the turn with a doubled copy of the same
|
|
1304
|
+
// request. Leave the running turn alone; its own settlement completes the
|
|
1305
|
+
// durable row.
|
|
1306
|
+
const runningRequestIds = new Set(running.durableRequestIds ?? []);
|
|
1307
|
+
if (
|
|
1308
|
+
durableRequestIds.length > 0 &&
|
|
1309
|
+
durableRequestIds.every((requestId) => runningRequestIds.has(requestId))
|
|
1310
|
+
) {
|
|
1311
|
+
logger.warn(
|
|
1312
|
+
{ topicId, queryId: running.queryId, durableRequestIds },
|
|
1313
|
+
"ai: ignored a replay of the durable request this room is already running",
|
|
1314
|
+
);
|
|
1315
|
+
return running.queryId;
|
|
1316
|
+
}
|
|
1276
1317
|
// Another person's running answer is not this message's to interrupt. The
|
|
1277
1318
|
// message keeps its own durable row (the merge never folds across actors)
|
|
1278
1319
|
// and the worker claims it once the running turn releases the room. A
|
|
@@ -1748,7 +1789,10 @@ export function startAiTurn(params: StartAiTurnParams): string | null {
|
|
|
1748
1789
|
const enabledMcp = withDefaultPlaywright(configuredMcp, isManager);
|
|
1749
1790
|
const playwrightRequested = !isManager && enabledMcp.includes("playwright");
|
|
1750
1791
|
const browserProfileOwner = isTopicBrowserProfileOwner(topic.id, userId);
|
|
1751
|
-
const wantsPlaywright =
|
|
1792
|
+
const wantsPlaywright =
|
|
1793
|
+
playwrightRequested && browserProfileOwner && BROWSER_BACKEND === "chrome";
|
|
1794
|
+
const wantsEgoBrowser =
|
|
1795
|
+
playwrightRequested && browserProfileOwner && BROWSER_BACKEND === "egolite";
|
|
1752
1796
|
const turnMcpEnabled = browserProfileOwner
|
|
1753
1797
|
? enabledMcp
|
|
1754
1798
|
: enabledMcp.filter((name) => name !== "playwright");
|
|
@@ -1778,6 +1822,19 @@ export function startAiTurn(params: StartAiTurnParams): string | null {
|
|
|
1778
1822
|
let playwrightCapability: string | undefined;
|
|
1779
1823
|
let playwrightInstanceKey: string | undefined;
|
|
1780
1824
|
let bgBashPort: number | undefined;
|
|
1825
|
+
if (wantsEgoBrowser) {
|
|
1826
|
+
try {
|
|
1827
|
+
const command = await prepareEgoBrowser();
|
|
1828
|
+
turnReminders.push(
|
|
1829
|
+
`<system-reminder>Browser backend: ego lite. Browser automation is authorized for this topic owner on this Negotium node. Use the foreground shell with executable ${JSON.stringify(command)}. Read its full "skill" guide before the first browser action. Reuse this goal's task space across turns. No Chrome browser_* MCP tools are available. This probe checked only the CLI; actual browser connection and login must be verified when used.</system-reminder>`,
|
|
1830
|
+
);
|
|
1831
|
+
} catch (err) {
|
|
1832
|
+
logger.warn({ topicId, err }, "ai: ego-browser CLI unavailable");
|
|
1833
|
+
turnReminders.push(
|
|
1834
|
+
"<system-reminder>ego lite browser automation is UNAVAILABLE this turn: the ego-browser executable could not be found or its --version probe failed on this Negotium node. Tell the user when browser work is needed. Do not start Chrome, install software, or use another browser as a fallback.</system-reminder>",
|
|
1835
|
+
);
|
|
1836
|
+
}
|
|
1837
|
+
}
|
|
1781
1838
|
if (wantsPlaywright) {
|
|
1782
1839
|
try {
|
|
1783
1840
|
playwrightInstanceKey = makeInstanceKey(userId, topic.id);
|
|
@@ -1821,7 +1878,7 @@ export function startAiTurn(params: StartAiTurnParams): string | null {
|
|
|
1821
1878
|
}
|
|
1822
1879
|
if (playwrightRequested && !browserProfileOwner) {
|
|
1823
1880
|
turnReminders.push(
|
|
1824
|
-
"<system-reminder>Browser tools are unavailable in this turn because browser profiles are private to the topic owner. Do not attempt browser calls or ask to reuse the owner's login state.</system-reminder>",
|
|
1881
|
+
"<system-reminder>Browser tools are unavailable in this turn because browser profiles are private to the topic owner. Do not attempt browser calls, run ego-browser through a shell, or ask to reuse the owner's login state.</system-reminder>",
|
|
1825
1882
|
);
|
|
1826
1883
|
}
|
|
1827
1884
|
if (consumePlaywrightUnavailable(userId, topic.title)) {
|
|
@@ -132,6 +132,10 @@ const TOKEN_PRICES: Record<string, TokenPrices> = {
|
|
|
132
132
|
"codex:gpt-5.6-luna": { input: 1, cacheRead: 0.1, output: 6 },
|
|
133
133
|
// Fable 5.1 (2026-09-01) cut cache-read pricing 75% from $1/M to $0.25/M.
|
|
134
134
|
"claude:fable": { input: 10, cacheWrite: 12.5, cacheRead: 0.25, output: 50 },
|
|
135
|
+
// Fable 5.2 (2026-11-09): $8/$40. Cache rates are not published; assumed to
|
|
136
|
+
// keep Fable 5.1's ratios (write 1.25x input, read 0.025x input).
|
|
137
|
+
"claude:fable-5.2": { input: 8, cacheWrite: 10, cacheRead: 0.2, output: 40 },
|
|
138
|
+
"claude:claude-fable-5-2": { input: 8, cacheWrite: 10, cacheRead: 0.2, output: 40 },
|
|
135
139
|
"claude:opus": { input: 4, cacheWrite: 5, cacheRead: 0.4, output: 20 },
|
|
136
140
|
"claude:claude-opus-5-5": { input: 4, cacheWrite: 5, cacheRead: 0.4, output: 20 },
|
|
137
141
|
"claude:sonnet": { input: 2, cacheWrite: 2.5, cacheRead: 0.2, output: 10 },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const NEGOTIUM_VERSION = "0.23.
|
|
1
|
+
export const NEGOTIUM_VERSION = "0.23.15";
|