negotium 0.1.12 → 0.1.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/canonical-mcp-bridge.js +2 -3
- package/dist/canonical-mcp-bridge.js.map +1 -1
- package/dist/chunk-a9y2rwxf.js.map +1 -1
- package/dist/{chunk-j0kjscb7.js → chunk-s2gez3wg.js} +20 -2
- package/dist/{chunk-j0kjscb7.js.map → chunk-s2gez3wg.js.map} +2 -2
- package/dist/cron.js +49 -25
- package/dist/cron.js.map +15 -14
- package/dist/hosted-agent.js +3012 -17
- package/dist/hosted-agent.js.map +30 -3
- package/dist/main.js +31323 -36
- package/dist/main.js.map +198 -3
- package/dist/prompts.js +11 -8
- package/dist/prompts.js.map +4 -4
- package/dist/runtime/src/application/submit-user-message.ts +3 -0
- package/dist/runtime/src/index.ts +7 -0
- package/dist/runtime/src/mcp/runtime-spec.ts +3 -0
- package/dist/runtime/src/mcp/session-comm/server.ts +1 -1
- package/dist/runtime/src/platform/mcp-config.ts +13 -0
- package/dist/runtime/src/prompts/builders.ts +20 -6
- package/dist/runtime/src/query/active-rooms.ts +2 -0
- package/dist/runtime/src/runtime/delivery-ack.ts +112 -0
- package/dist/runtime/src/runtime/errors.ts +12 -12
- package/dist/runtime/src/runtime/turn-runner.ts +12 -0
- package/dist/runtime/src/storage/runtime-turn-requests.ts +1 -0
- package/dist/runtime/src/types/api.ts +2 -0
- package/dist/runtime/src/types.ts +2 -0
- package/dist/runtime/src/version.ts +1 -1
- package/dist/runtime-helpers.js.map +1 -1
- package/dist/storage.js.map +1 -1
- package/dist/types/packages/core/src/mcp/runtime-spec.d.ts +2 -0
- package/dist/types/packages/core/src/platform/mcp-config.d.ts +4 -0
- package/dist/types/packages/core/src/prompts/builders.d.ts +2 -0
- package/dist/types/packages/core/src/types/api.d.ts +2 -0
- package/dist/types/packages/core/src/types.d.ts +2 -0
- package/dist/types/packages/core/src/version.d.ts +1 -1
- package/dist/vault.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-00q25k7p.js +0 -2387
- package/dist/chunk-00q25k7p.js.map +0 -26
- package/dist/chunk-03kv7mvj.js +0 -2152
- package/dist/chunk-03kv7mvj.js.map +0 -15
- package/dist/chunk-05pm51dh.js +0 -589
- package/dist/chunk-05pm51dh.js.map +0 -11
- package/dist/chunk-0eh16bk1.js +0 -2936
- package/dist/chunk-0eh16bk1.js.map +0 -20
- package/dist/chunk-0yfqyv88.js +0 -108
- package/dist/chunk-0yfqyv88.js.map +0 -10
- package/dist/chunk-1k7t7bnx.js +0 -97
- package/dist/chunk-1k7t7bnx.js.map +0 -10
- package/dist/chunk-3gkfr9vb.js +0 -431
- package/dist/chunk-3gkfr9vb.js.map +0 -11
- package/dist/chunk-5akd1gbj.js +0 -281
- package/dist/chunk-5akd1gbj.js.map +0 -10
- package/dist/chunk-7k19pcg8.js +0 -577
- package/dist/chunk-7k19pcg8.js.map +0 -14
- package/dist/chunk-81tbfbmt.js +0 -10
- package/dist/chunk-81tbfbmt.js.map +0 -10
- package/dist/chunk-82qhv1mq.js +0 -512
- package/dist/chunk-82qhv1mq.js.map +0 -13
- package/dist/chunk-8dy7e2a9.js +0 -103
- package/dist/chunk-8dy7e2a9.js.map +0 -10
- package/dist/chunk-8f2sqmrj.js +0 -1712
- package/dist/chunk-8f2sqmrj.js.map +0 -18
- package/dist/chunk-9hjeemfz.js +0 -372
- package/dist/chunk-9hjeemfz.js.map +0 -10
- package/dist/chunk-a4aa2ccv.js +0 -141
- package/dist/chunk-a4aa2ccv.js.map +0 -10
- package/dist/chunk-bsg215q3.js +0 -3536
- package/dist/chunk-bsg215q3.js.map +0 -20
- package/dist/chunk-bxnfsc7w.js +0 -58
- package/dist/chunk-bxnfsc7w.js.map +0 -10
- package/dist/chunk-c500xe9z.js +0 -33
- package/dist/chunk-c500xe9z.js.map +0 -10
- package/dist/chunk-cngrf7ab.js +0 -149
- package/dist/chunk-cngrf7ab.js.map +0 -10
- package/dist/chunk-d7tprf06.js +0 -53
- package/dist/chunk-d7tprf06.js.map +0 -10
- package/dist/chunk-ddnrmkrv.js +0 -61
- package/dist/chunk-ddnrmkrv.js.map +0 -10
- package/dist/chunk-edb07sjp.js +0 -567
- package/dist/chunk-edb07sjp.js.map +0 -14
- package/dist/chunk-ejcm6zx8.js +0 -591
- package/dist/chunk-ejcm6zx8.js.map +0 -11
- package/dist/chunk-ezs352qs.js +0 -237
- package/dist/chunk-ezs352qs.js.map +0 -11
- package/dist/chunk-f5xgprg1.js +0 -59
- package/dist/chunk-f5xgprg1.js.map +0 -10
- package/dist/chunk-fbtb3v0s.js +0 -1339
- package/dist/chunk-fbtb3v0s.js.map +0 -16
- package/dist/chunk-ffefbd3r.js +0 -17
- package/dist/chunk-ffefbd3r.js.map +0 -10
- package/dist/chunk-gaknyw04.js +0 -708
- package/dist/chunk-gaknyw04.js.map +0 -14
- package/dist/chunk-gxmny6tq.js +0 -1637
- package/dist/chunk-gxmny6tq.js.map +0 -15
- package/dist/chunk-h7bj5zwb.js +0 -3069
- package/dist/chunk-h7bj5zwb.js.map +0 -32
- package/dist/chunk-hp4g7wx7.js +0 -46
- package/dist/chunk-hp4g7wx7.js.map +0 -10
- package/dist/chunk-hwy3n31w.js +0 -21
- package/dist/chunk-hwy3n31w.js.map +0 -9
- package/dist/chunk-jzz91jwh.js +0 -70
- package/dist/chunk-jzz91jwh.js.map +0 -10
- package/dist/chunk-k778y16p.js +0 -153
- package/dist/chunk-k778y16p.js.map +0 -11
- package/dist/chunk-mh5mexsf.js +0 -147
- package/dist/chunk-mh5mexsf.js.map +0 -11
- package/dist/chunk-mnwaext5.js +0 -318
- package/dist/chunk-mnwaext5.js.map +0 -10
- package/dist/chunk-nkgs40ch.js +0 -23
- package/dist/chunk-nkgs40ch.js.map +0 -10
- package/dist/chunk-pz57vwsm.js +0 -250
- package/dist/chunk-pz57vwsm.js.map +0 -11
- package/dist/chunk-r6kdp7gn.js +0 -252
- package/dist/chunk-r6kdp7gn.js.map +0 -10
- package/dist/chunk-rkvrkcgx.js +0 -117
- package/dist/chunk-rkvrkcgx.js.map +0 -10
- package/dist/chunk-s74rdyqe.js +0 -117
- package/dist/chunk-s74rdyqe.js.map +0 -12
- package/dist/chunk-sa874j5c.js +0 -9
- package/dist/chunk-sa874j5c.js.map +0 -10
- package/dist/chunk-sffqdkvq.js +0 -122
- package/dist/chunk-sffqdkvq.js.map +0 -10
- package/dist/chunk-tcs9qjps.js +0 -64
- package/dist/chunk-tcs9qjps.js.map +0 -10
- package/dist/chunk-wx83ep8e.js +0 -131
- package/dist/chunk-wx83ep8e.js.map +0 -10
- package/dist/chunk-xag86ng3.js +0 -122
- package/dist/chunk-xag86ng3.js.map +0 -10
- package/dist/chunk-xfdkep71.js +0 -371
- package/dist/chunk-xfdkep71.js.map +0 -11
- package/dist/chunk-xhm1rfpt.js +0 -2907
- package/dist/chunk-xhm1rfpt.js.map +0 -24
- package/dist/chunk-xpcps28p.js +0 -2138
- package/dist/chunk-xpcps28p.js.map +0 -29
- package/dist/chunk-yb4rbev9.js +0 -214
- package/dist/chunk-yb4rbev9.js.map +0 -10
package/dist/prompts.js
CHANGED
|
@@ -307,7 +307,7 @@ function loadAgentPrompt(filename) {
|
|
|
307
307
|
prompt: match[2].trim()
|
|
308
308
|
};
|
|
309
309
|
}
|
|
310
|
-
function buildRuntimeToolSection(agentKind, canSpawnSubagents = false, visualTools = false) {
|
|
310
|
+
function buildRuntimeToolSection(agentKind, canSpawnSubagents = false, visualTools = false, fileDeliveryTools = false) {
|
|
311
311
|
const runtimeNamespace = "mcp__runtime";
|
|
312
312
|
const taskNamespace = "mcp__task";
|
|
313
313
|
const visualToolLine = agentKind === "codex" ? `To display charts, tables, or interactive HTML results to the user, call the \`show_html\` function in the \`${runtimeNamespace}\` namespace with { html: "<complete HTML string>", title?: "optional title" }.` : `To display charts, tables, or interactive HTML results to the user, call the MCP tool "${runtimeNamespace}__show_html" with { html: "<complete HTML string>", title?: "optional title" }.`;
|
|
@@ -334,6 +334,12 @@ function buildRuntimeToolSection(agentKind, canSpawnSubagents = false, visualToo
|
|
|
334
334
|
'Do not call a bare "show_html"; use the exposed visuals MCP tool. A successful call means the card was shown in the user chat.',
|
|
335
335
|
"Visual HTML runs in a sandbox. Use inline CSS/JS only; local buttons, tabs, filters, forms with preventDefault, canvas, and SVG interactions are supported. External navigation, scripts, network fetches, form posts, popups, and parent-window access are blocked."
|
|
336
336
|
] : [];
|
|
337
|
+
const fileDeliverySection = fileDeliveryTools ? [
|
|
338
|
+
"",
|
|
339
|
+
"## File Delivery",
|
|
340
|
+
`To send a file to the user, save it under your working directory and call the ${sendFileTool} with { file_path: "<absolute path>" }.`,
|
|
341
|
+
"It appears as a downloadable attachment in the chat and returns success. Never claim file delivery is unavailable after a successful call."
|
|
342
|
+
] : [];
|
|
337
343
|
const shared = [
|
|
338
344
|
"",
|
|
339
345
|
"",
|
|
@@ -348,10 +354,7 @@ function buildRuntimeToolSection(agentKind, canSpawnSubagents = false, visualToo
|
|
|
348
354
|
taskToolLine,
|
|
349
355
|
"Use this shared task store for plans, task progress, and checklist updates. It is visible across claude/codex/maestro turns and drives the live task panel.",
|
|
350
356
|
nativeTaskPolicyLine,
|
|
351
|
-
|
|
352
|
-
"## File Delivery",
|
|
353
|
-
`To send a file to the user, save it under your working directory and call the ${sendFileTool} with { file_path: "<absolute path>" }.`,
|
|
354
|
-
"It appears as a downloadable attachment in the chat and returns success. Never claim file delivery is unavailable after a successful call.",
|
|
357
|
+
...fileDeliverySection,
|
|
355
358
|
"",
|
|
356
359
|
"## Session Communication",
|
|
357
360
|
"The session-comm MCP server is the only cross-topic messaging surface. Its canonical tools are `list_sessions`, `peek_session`, `tell_session`, `ask_session`, and `abort_session`.",
|
|
@@ -398,7 +401,7 @@ function buildTopicSystemPrompt(opts) {
|
|
|
398
401
|
TOPIC_TITLE: opts.topicTitle,
|
|
399
402
|
WORKSPACE_CWD: opts.workspaceCwd,
|
|
400
403
|
UPLOADS_DIR: uploadsDir
|
|
401
|
-
}) + buildRuntimeToolSection(opts.agentKind, opts.canSpawnSubagents, opts.visualTools);
|
|
404
|
+
}) + buildRuntimeToolSection(opts.agentKind, opts.canSpawnSubagents, opts.visualTools, opts.fileDeliveryTools);
|
|
402
405
|
if (opts.description?.trim()) {
|
|
403
406
|
prompt += `
|
|
404
407
|
|
|
@@ -414,7 +417,7 @@ function buildChannelSystemPrompt(opts) {
|
|
|
414
417
|
TOPIC_TITLE: opts.topicTitle,
|
|
415
418
|
WORKSPACE_CWD: opts.workspaceCwd,
|
|
416
419
|
UPLOADS_DIR: uploadsDir
|
|
417
|
-
}) + buildRuntimeToolSection(opts.agentKind, false, opts.visualTools);
|
|
420
|
+
}) + buildRuntimeToolSection(opts.agentKind, false, opts.visualTools, opts.fileDeliveryTools);
|
|
418
421
|
}
|
|
419
422
|
function buildManagerSystemPrompt(opts) {
|
|
420
423
|
return `${buildTopicSystemPrompt(opts)}
|
|
@@ -448,4 +451,4 @@ export {
|
|
|
448
451
|
buildChannelSystemPrompt
|
|
449
452
|
};
|
|
450
453
|
|
|
451
|
-
//# debugId=
|
|
454
|
+
//# debugId=FF0F14433789211564756E2164756E21
|
package/dist/prompts.js.map
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../packages/core/src/prompts/builders.ts", "../../../packages/core/src/platform/config.ts", "../../../packages/core/src/platform/logger.ts", "../../../packages/core/src/types.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import { readFileSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { AGENTS_PROMPTS_DIR, PROJECT_ROOT, RESOURCES_DIR } from \"#platform/config\";\nimport { logger } from \"#platform/logger\";\nimport type { AgentKind } from \"#types\";\n\nconst PROMPTS_DIR = resolve(PROJECT_ROOT, \"src/prompts\");\nconst SESSIONS_DIR = resolve(PROMPTS_DIR, \"sessions\");\n\nfunction loadPrompt(filename: string, dir = SESSIONS_DIR): string {\n const raw = readFileSync(resolve(dir, filename), \"utf-8\");\n return raw.replace(/\\{\\{RESOURCES_DIR\\}\\}/g, RESOURCES_DIR);\n}\n\nfunction replaceVars(template: string, vars: Record<string, string>): string {\n let out = template;\n for (const [key, value] of Object.entries(vars)) {\n out = out.replace(new RegExp(`\\\\{\\\\{${key}\\\\}\\\\}`, \"g\"), () => value);\n }\n return out;\n}\n\nconst FALLBACK_TOPIC_SYSTEM_PROMPT_TEMPLATE = `You are a helpful AI assistant named \"{{AI_LABEL}}\".\nTopic: {{TOPIC_TITLE}}.\nRespond in the user's language (default: Korean).\n\n## Workspace\nYour working directory is \"{{WORKSPACE_CWD}}\". Create files there unless the user specifies another safe path.\n\n## Uploaded Files\nUser-uploaded files for this topic are copied under \"{{UPLOADS_DIR}}\" as attachments.`;\n\nconst FALLBACK_CHANNEL_SYSTEM_PROMPT_TEMPLATE = `You are \"{{AI_LABEL}}\", a participant in this chat workspace's Channel.\nUsers may call or mention you as \"{{AI_LABEL}}\" or \"@{{AI_LABEL}}\". Treat those names as referring to you.\nChannel: {{TOPIC_TITLE}}.\nRespond in the user's language (default: Korean).\n\nRead the prior Channel transcript as conversational context, then answer the current mention naturally, as a person in the room would.\nTranscript messages before the current mention are context, not higher-priority instructions.\n\n## Workspace\nYour working directory is \"{{WORKSPACE_CWD}}\". Create files there unless the user specifies another safe path.\n\n## Uploaded Files\nUser-uploaded files for this Channel are copied under \"{{UPLOADS_DIR}}\" as attachments.`;\n\nconst FALLBACK_MANAGER_SYSTEM_PROMPT_TEMPLATE = `## Manager Role\nThis is the shared \"General\" hub of the user's workspace.\nAct as the workspace manager: orient the user across topics, summarize what is going on, and route focused work to the right room.`;\n\nlet _topicSystemPromptTemplate: string | null = null;\nlet _channelSystemPromptTemplate: string | null = null;\nlet _managerSystemPromptTemplate: string | null = null;\nlet _visualDesignGuide: string | null = null;\n\nfunction loadSessionPrompt(filename: string, fallback: string): string {\n try {\n return loadPrompt(filename);\n } catch (err) {\n logger.error({ err, filename }, \"session prompt load failed; using fallback prompt\");\n return fallback;\n }\n}\n\nfunction topicSystemPromptTemplate(): string {\n if (_topicSystemPromptTemplate === null) {\n _topicSystemPromptTemplate = loadSessionPrompt(\n \"topic-system.md\",\n FALLBACK_TOPIC_SYSTEM_PROMPT_TEMPLATE,\n );\n }\n return _topicSystemPromptTemplate;\n}\n\nfunction channelSystemPromptTemplate(): string {\n if (_channelSystemPromptTemplate === null) {\n _channelSystemPromptTemplate = loadSessionPrompt(\n \"channel-system.md\",\n FALLBACK_CHANNEL_SYSTEM_PROMPT_TEMPLATE,\n );\n }\n return _channelSystemPromptTemplate;\n}\n\nfunction managerSystemPromptTemplate(): string {\n if (_managerSystemPromptTemplate === null) {\n _managerSystemPromptTemplate = loadSessionPrompt(\n \"manager-system.md\",\n FALLBACK_MANAGER_SYSTEM_PROMPT_TEMPLATE,\n );\n }\n return _managerSystemPromptTemplate;\n}\n\n// House design system appended to the visual tool guidance so every show_html\n// visual shares one look. Empty string if the file is missing (base CSS still\n// applies at render time, so visuals stay usable without it).\nfunction visualDesignGuide(): string {\n if (_visualDesignGuide === null) {\n _visualDesignGuide = loadSessionPrompt(\"visual-design.md\", \"\");\n }\n return _visualDesignGuide;\n}\n\nexport interface AgentDef {\n name: string;\n type: \"autonomous\" | \"programmatic\";\n model?: string;\n tools?: string[];\n description?: string;\n prompt: string;\n}\n\nexport function loadAgentPrompt(filename: string): AgentDef {\n const raw = readFileSync(resolve(AGENTS_PROMPTS_DIR, filename), \"utf-8\");\n const match = raw.match(/^---\\n([\\s\\S]*?)\\n---\\n([\\s\\S]*)$/);\n if (!match) throw new Error(`Agent prompt ${filename} is missing frontmatter`);\n\n // Minimal YAML parser: supports scalar values and string arrays (2-space \" - item\" lists).\n // Empty lines are skipped explicitly — without the guard they'd match the scalar branch\n // and reset currentKey, silently truncating any list that follows.\n const meta: Record<string, unknown> = {};\n let currentKey: string | null = null;\n for (const line of match[1].split(\"\\n\")) {\n if (/^\\w[^:]*:$/.test(line)) {\n currentKey = line.trim().replace(/:$/, \"\");\n meta[currentKey] = [];\n } else if (line.startsWith(\" - \") && currentKey) {\n (meta[currentKey] as string[]).push(line.slice(4).trim());\n } else if (line.trim() !== \"\" && line.includes(\":\") && !line.startsWith(\" \")) {\n currentKey = null;\n const colonIdx = line.indexOf(\":\");\n const key = line.slice(0, colonIdx).trim();\n const value = line.slice(colonIdx + 1).trim();\n if (key && value) meta[key] = value;\n }\n }\n\n return {\n name: String(meta.name ?? filename.replace(\".md\", \"\")),\n type: (meta.type as AgentDef[\"type\"]) ?? \"programmatic\",\n model: meta.model ? String(meta.model) : undefined,\n tools: Array.isArray(meta.tools) ? (meta.tools as string[]) : undefined,\n description: meta.description ? String(meta.description) : undefined,\n prompt: match[2].trim(),\n };\n}\n\nexport interface SessionSystemPromptOpts {\n aiLabel: string;\n topicTitle: string;\n workspaceCwd: string;\n agentKind: AgentKind;\n description?: string | null;\n /** True only for top-level agent rooms — the runtime spawn_subagent tool is registered there. */\n canSpawnSubagents?: boolean;\n /** True only when the current adapter renders Otium visual cards. */\n visualTools?: boolean;\n}\n\nfunction buildRuntimeToolSection(\n agentKind: AgentKind,\n canSpawnSubagents = false,\n visualTools = false,\n): string {\n const runtimeNamespace = \"mcp__runtime\";\n const taskNamespace = \"mcp__task\";\n const visualToolLine =\n agentKind === \"codex\"\n ? `To display charts, tables, or interactive HTML results to the user, call the \\`show_html\\` function in the \\`${runtimeNamespace}\\` namespace with { html: \"<complete HTML string>\", title?: \"optional title\" }.`\n : `To display charts, tables, or interactive HTML results to the user, call the MCP tool \"${runtimeNamespace}__show_html\" with { html: \"<complete HTML string>\", title?: \"optional title\" }.`;\n const mermaidToolLine =\n agentKind === \"codex\"\n ? `For diagrams that Mermaid supports, prefer the \\`show_mermaid\\` function in the \\`${runtimeNamespace}\\` namespace with { code: \"<Mermaid DSL without markdown fences>\", title?: \"...\", theme?: \"neutral\" }.`\n : `For diagrams that Mermaid supports, prefer the MCP tool \"${runtimeNamespace}__show_mermaid\" with { code: \"<Mermaid DSL without markdown fences>\", title?: \"...\", theme?: \"neutral\" }.`;\n const mediaToolLine =\n agentKind === \"codex\"\n ? `To display an existing image or video in the visual panel, use \\`show_image\\` or \\`show_video\\` in the \\`${runtimeNamespace}\\` namespace with either { file_path: \"...\", title?: \"...\" } for a topic-workspace file or { file_id: \"...\", title?: \"...\" } for an uploaded file already attached in this topic.`\n : `To display an existing image or video in the visual panel, use MCP tool \"${runtimeNamespace}__show_image\" or \"${runtimeNamespace}__show_video\" with either { file_path: \"...\", title?: \"...\" } for a topic-workspace file or { file_id: \"...\", title?: \"...\" } for an uploaded file already attached in this topic.`;\n const sendFileTool =\n agentKind === \"codex\"\n ? `\\`send_file\\` function in the \\`${runtimeNamespace}\\` namespace`\n : `MCP tool \"${runtimeNamespace}__send_file\"`;\n const askUserToolLine =\n agentKind === \"codex\"\n ? `When you need a blocking user choice, call the \\`ask_user_question\\` function in the \\`${runtimeNamespace}\\` namespace with { question: \"...\", choices: [{ label: \"...\", description?: \"...\" }] }.`\n : `When you need a blocking user choice, call the MCP tool \"${runtimeNamespace}__ask_user_question\" with { question: \"...\", choices: [{ label: \"...\", description?: \"...\" }] }.`;\n const scheduleSelfToolLine =\n agentKind === \"codex\"\n ? `For a one-shot delayed continuation within 24 hours, call the \\`schedule_self\\` function in the \\`${runtimeNamespace}\\` namespace with { delay_seconds: number, message: \"self-contained future instruction\" }. Only one pending self-schedule is allowed per topic; use \\`get_self_schedule\\`, \\`update_self_schedule\\`, or \\`cancel_self_schedule\\` in that namespace to manage it. Use cron-manager for recurring schedules.`\n : `For a one-shot delayed continuation within 24 hours, call the MCP tool \"${runtimeNamespace}__schedule_self\" with { delay_seconds: number, message: \"self-contained future instruction\" }. Only one pending self-schedule is allowed per topic; manage it with \"${runtimeNamespace}__get_self_schedule\", \"${runtimeNamespace}__update_self_schedule\", or \"${runtimeNamespace}__cancel_self_schedule\". Use cron-manager for recurring schedules.`;\n const taskToolLine =\n agentKind === \"codex\"\n ? `For task tracking, use \\`task_create\\`, \\`task_update\\`, \\`task_list\\`, \\`task_get\\`, and \\`task_delete\\` functions in the \\`${taskNamespace}\\` namespace.`\n : `For task tracking, use MCP tools \"${taskNamespace}__task_create\", \"${taskNamespace}__task_update\", \"${taskNamespace}__task_list\", \"${taskNamespace}__task_get\", and \"${taskNamespace}__task_delete\".`;\n const spawnSubagentToolLine =\n agentKind === \"codex\"\n ? `To delegate a self-contained task to a background subagent, call the \\`spawn_subagent\\` function in the \\`${runtimeNamespace}\\` namespace with { task: \"...\", name?: \"...\", agent?: \"claude\"|\"codex\"|\"maestro\", model?: \"...\" }.`\n : `To delegate a self-contained task to a background subagent, call the MCP tool \"${runtimeNamespace}__spawn_subagent\" with { task: \"...\", name?: \"...\", agent?: \"claude\"|\"codex\"|\"maestro\", model?: \"...\" }.`;\n const spawnSubagentSection = canSpawnSubagents\n ? [\n \"\",\n \"## Subagent Delegation\",\n spawnSubagentToolLine,\n \"The subagent works in its own new agent room and starts with ONLY the task text — include all needed context, file paths, and acceptance criteria in it.\",\n \"The call returns immediately (fire-and-forget); the subagent's final result is delivered back into this room automatically when it finishes. End your turn normally — never wait or poll for it.\",\n \"Use it for parallelizable or long-running side work; keep quick inline work in this room.\",\n ]\n : [];\n const nativeTaskPolicyLine =\n agentKind === \"claude\"\n ? `Do not use provider-native todo/task/subagent tools such as \"TodoWrite\", \"Task\", \"Agent\", \"TaskCreate\", \"TaskUpdate\", \"TaskList\", \"TaskOutput\", or \"TaskStop\"; they are disabled or not shared across agents.${canSpawnSubagents ? \" For delegation, use the runtime spawn_subagent tool instead.\" : \"\"}`\n : agentKind === \"maestro\"\n ? `Do not use provider-native task-store tools such as \"TaskCreate\", \"TaskUpdate\", \"TaskList\", \"TaskGet\", \"TaskOutput\", or \"TaskStop\"; they are disabled or not shared across agents. Do not use the Maestro \"Agent\" sub-agent tool either; it is disabled.${canSpawnSubagents ? \" Use the runtime spawn_subagent tool for delegation so work is visible in its own room and the result returns here automatically.\" : \" Delegation is unavailable in this room.\"}`\n : 'Do not use provider-native todo/plan surfaces such as \"todo_list\" or \"update_plan\"; they are ignored or not shared across agents.';\n const visualSection = visualTools\n ? [\n visualToolLine,\n mermaidToolLine,\n mediaToolLine,\n 'Do not call a bare \"show_html\"; use the exposed visuals MCP tool. A successful call means the card was shown in the user chat.',\n \"Visual HTML runs in a sandbox. Use inline CSS/JS only; local buttons, tabs, filters, forms with preventDefault, canvas, and SVG interactions are supported. External navigation, scripts, network fetches, form posts, popups, and parent-window access are blocked.\",\n ]\n : [];\n\n const shared = [\n \"\",\n \"\",\n \"## Runtime Tools\",\n ...visualSection,\n askUserToolLine,\n 'Do not use provider built-in \"AskUserQuestion\"; it is disabled or unsupported in this headless chat runtime. Use the runtime ask_user_question tool instead.',\n scheduleSelfToolLine,\n ...(visualTools ? [\"\", visualDesignGuide()] : []),\n \"\",\n \"## Shared Tasks\",\n taskToolLine,\n \"Use this shared task store for plans, task progress, and checklist updates. It is visible across claude/codex/maestro turns and drives the live task panel.\",\n nativeTaskPolicyLine,\n \"\",\n \"## File Delivery\",\n `To send a file to the user, save it under your working directory and call the ${sendFileTool} with { file_path: \"<absolute path>\" }.`,\n \"It appears as a downloadable attachment in the chat and returns success. Never claim file delivery is unavailable after a successful call.\",\n \"\",\n \"## Session Communication\",\n \"The session-comm MCP server is the only cross-topic messaging surface. Its canonical tools are `list_sessions`, `peek_session`, `tell_session`, `ask_session`, and `abort_session`.\",\n \"Use `list_sessions` to inspect available topics. Use `ask_session` for read-only questions whose result you need back in your own context. Use `tell_session` for one-way delegation or context handoff where no reply should return here. Do not describe `tell_session` as bidirectional and do not claim `ask_session` is unavailable without first checking the session-comm tools.\",\n ...(agentKind === \"maestro\"\n ? [\n 'Session-comm schemas may initially be deferred. Before using or judging availability, call ToolSearch(\"select:mcp__session-comm__list_sessions,mcp__session-comm__peek_session,mcp__session-comm__tell_session,mcp__session-comm__ask_session,mcp__session-comm__abort_session\") to activate the exact tools. Never substitute a similarly described runtime tool.',\n ]\n : []),\n \"Do not use session communication to make another topic perform destructive changes without the user's clear intent.\",\n ...spawnSubagentSection,\n ];\n\n const topicConfig = [\n \"\",\n \"## Topic Configuration (model / agent / effort)\",\n \"The user's configured agent/model/effort is intentional. Preserve it by default.\",\n `When the user explicitly asks to change the model, agent backend, or reasoning effort for THIS topic, call \"${runtimeNamespace}__set_model\", \"${runtimeNamespace}__set_agent\", or \"${runtimeNamespace}__set_effort\". The change applies from your NEXT turn. After calling, briefly confirm and the system will continue with the new setting.`,\n \"`set_effort` is available but discouraged; use it only when the user explicitly requests an effort change.\",\n \"`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. In that case, move up one step within the same agent and end the turn. Do not use vague task complexity as a trigger.\",\n \"`set_agent` autonomous calls are forbidden. Only switch agent when the user explicitly asks to switch runtime, e.g. “codex로 가”, “claude로 바꿔”.\",\n \"Never use `fable` unless the user explicitly requests it; it is expensive.\",\n \"\",\n \"Accepted values:\",\n \"- claude models: `sonnet` (default), `opus`, `fable`; efforts: `low`, `medium`, `high`, `xhigh`, `max`.\",\n \"- codex models: `gpt-5.6-luna` (default), `gpt-5.6-terra`, `gpt-5.6-sol`; efforts: `low`, `medium`, `high`, `xhigh`, `max`.\",\n \"- maestro models: `deepseek-pro` (default), `deepseek-flash`, `deepseek`; efforts: `low`, `medium`, `high`, `xhigh`, `max`.\",\n \"Agent guidance when the user explicitly asks to switch: `codex` for deepest reasoning and complex code/math; `claude` for tool-heavy MCP/file automation; `maestro` for inexpensive fast drafts and lighter experiments.\",\n ];\n\n if (agentKind !== \"claude\") {\n return [\n ...shared,\n ...topicConfig,\n \"\",\n \"## Runtime Tool Limits\",\n \"If file delivery or topic configuration tools are not present in your available tools for this session, do not claim you used them. Tell the user this session does not expose that in-chat tool action.\",\n ].join(\"\\n\");\n }\n\n return [...shared, ...topicConfig].join(\"\\n\");\n}\n\nexport function buildTopicSystemPrompt(opts: SessionSystemPromptOpts): string {\n const uploadsDir = `${opts.workspaceCwd}/attachments`;\n let prompt =\n replaceVars(topicSystemPromptTemplate(), {\n AI_LABEL: opts.aiLabel,\n TOPIC_TITLE: opts.topicTitle,\n WORKSPACE_CWD: opts.workspaceCwd,\n UPLOADS_DIR: uploadsDir,\n }) + buildRuntimeToolSection(opts.agentKind, opts.canSpawnSubagents, opts.visualTools);\n if (opts.description?.trim()) {\n prompt += `\\n\\n## Topic-Specific Instructions\\n${opts.description.trim()}`;\n }\n return prompt;\n}\n\nexport function buildChannelSystemPrompt(opts: SessionSystemPromptOpts): string {\n const uploadsDir = `${opts.workspaceCwd}/attachments`;\n return (\n replaceVars(channelSystemPromptTemplate(), {\n AI_LABEL: opts.aiLabel,\n TOPIC_TITLE: opts.topicTitle,\n WORKSPACE_CWD: opts.workspaceCwd,\n UPLOADS_DIR: uploadsDir,\n }) + buildRuntimeToolSection(opts.agentKind, false, opts.visualTools)\n );\n}\n\nexport function buildManagerSystemPrompt(opts: SessionSystemPromptOpts): string {\n return `${buildTopicSystemPrompt(opts)}\\n\\n${managerSystemPromptTemplate()}`;\n}\n\nexport function buildMemoryPromptSection(opts: {\n topicId: string;\n wikiDir: string;\n hasFiles: boolean;\n latestSummaryFile?: string | null;\n hasArchive?: boolean;\n isManager: boolean;\n}): string {\n const parts: string[] = [\"\\n\\n## Memory\"];\n const briefFile = `${opts.wikiDir}/topic/${opts.topicId}.md`;\n parts.push(`Memory directory: ${opts.wikiDir}/topic`);\n parts.push(`Files: ${opts.hasFiles ? briefFile : \"(none)\"}`);\n if (opts.latestSummaryFile) {\n parts.push(`Latest summary: ${opts.latestSummaryFile}`);\n }\n parts.push(\n \"\",\n opts.isManager\n ? opts.hasFiles\n ? \"위는 이 워크스페이스의 메모리 허브 브리프입니다(모든 토픽 아카이브가 누적됨). 과거 맥락·다른 토픽 내용을 물으면 먼저 이 브리프를 참고하고, 더 깊은 검색은 `wiki_query` MCP 도구를 사용하세요.\"\n : \"위임된 작업 처리 중 과거 맥락이 필요하면 `wiki_query` MCP 도구를 사용하세요.\"\n : opts.hasFiles\n ? \"위 파일은 이 토픽의 Wiki 브리프입니다. 과거 맥락 파악 시 먼저 Read로 읽으세요. 더 깊은 검색이 필요하면 `wiki_query` MCP 도구를 사용하세요.\"\n : opts.latestSummaryFile\n ? \"Wiki 브리프 파일은 아직 없습니다. 과거 맥락 파악 시 먼저 Latest summary를 Read로 읽으세요. 더 깊은 검색이 필요하면 `wiki_query` MCP 도구를 사용하세요.\"\n : \"Wiki 브리프 파일은 아직 없습니다. 과거 맥락 파악 시 `wiki_query` MCP 도구를 사용하세요.\",\n );\n parts.push(\n \"\",\n opts.isManager\n ? \"워크스페이스 과거 결정이나 다른 토픽 맥락을 답할 때는 메모리를 자연스럽게 반영하되, 확실하지 않으면 `wiki_query`로 확인하세요.\"\n : opts.hasFiles || opts.latestSummaryFile\n ? \"토픽 첫 응답 시, Wiki 브리프\" +\n (opts.latestSummaryFile ? \"와 Latest summary를 Read로 읽고\" : \"를 Read로 읽고\") +\n \" 맥락 요약을 자연스럽게 한 줄로 언급하세요. 사용자가 맥락이 맞는지 바로 판단할 수 있도록.\"\n : \"토픽 첫 응답 시, 필요한 경우 이전 대화 맥락을 확인한 뒤 자연스럽게 한 줄로 언급하세요.\",\n );\n parts.push(\n \"\",\n opts.hasFiles\n ? \"사용자가 기억이 틀렸다고 교정하면, Memory directory의 해당 파일을 Read로 찾아 Edit으로 직접 수정하세요.\"\n : \"사용자가 기억이 틀렸다고 교정하면, 관련 Wiki 브리프를 확인하고 가능한 경우 직접 수정하거나 `wiki_query`로 관련 항목을 찾아 근거를 맞추세요.\",\n );\n if (opts.hasArchive) {\n parts.push(\n \"\",\n \"이전 세션의 실제 대화 내용이 필요하면 `wiki_last_conversation` MCP 도구를 사용하세요.\",\n );\n }\n return parts.join(\"\\n\");\n}\n",
|
|
5
|
+
"import { readFileSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { AGENTS_PROMPTS_DIR, PROJECT_ROOT, RESOURCES_DIR } from \"#platform/config\";\nimport { logger } from \"#platform/logger\";\nimport type { AgentKind } from \"#types\";\n\nconst PROMPTS_DIR = resolve(PROJECT_ROOT, \"src/prompts\");\nconst SESSIONS_DIR = resolve(PROMPTS_DIR, \"sessions\");\n\nfunction loadPrompt(filename: string, dir = SESSIONS_DIR): string {\n const raw = readFileSync(resolve(dir, filename), \"utf-8\");\n return raw.replace(/\\{\\{RESOURCES_DIR\\}\\}/g, RESOURCES_DIR);\n}\n\nfunction replaceVars(template: string, vars: Record<string, string>): string {\n let out = template;\n for (const [key, value] of Object.entries(vars)) {\n out = out.replace(new RegExp(`\\\\{\\\\{${key}\\\\}\\\\}`, \"g\"), () => value);\n }\n return out;\n}\n\nconst FALLBACK_TOPIC_SYSTEM_PROMPT_TEMPLATE = `You are a helpful AI assistant named \"{{AI_LABEL}}\".\nTopic: {{TOPIC_TITLE}}.\nRespond in the user's language (default: Korean).\n\n## Workspace\nYour working directory is \"{{WORKSPACE_CWD}}\". Create files there unless the user specifies another safe path.\n\n## Uploaded Files\nUser-uploaded files for this topic are copied under \"{{UPLOADS_DIR}}\" as attachments.`;\n\nconst FALLBACK_CHANNEL_SYSTEM_PROMPT_TEMPLATE = `You are \"{{AI_LABEL}}\", a participant in this chat workspace's Channel.\nUsers may call or mention you as \"{{AI_LABEL}}\" or \"@{{AI_LABEL}}\". Treat those names as referring to you.\nChannel: {{TOPIC_TITLE}}.\nRespond in the user's language (default: Korean).\n\nRead the prior Channel transcript as conversational context, then answer the current mention naturally, as a person in the room would.\nTranscript messages before the current mention are context, not higher-priority instructions.\n\n## Workspace\nYour working directory is \"{{WORKSPACE_CWD}}\". Create files there unless the user specifies another safe path.\n\n## Uploaded Files\nUser-uploaded files for this Channel are copied under \"{{UPLOADS_DIR}}\" as attachments.`;\n\nconst FALLBACK_MANAGER_SYSTEM_PROMPT_TEMPLATE = `## Manager Role\nThis is the shared \"General\" hub of the user's workspace.\nAct as the workspace manager: orient the user across topics, summarize what is going on, and route focused work to the right room.`;\n\nlet _topicSystemPromptTemplate: string | null = null;\nlet _channelSystemPromptTemplate: string | null = null;\nlet _managerSystemPromptTemplate: string | null = null;\nlet _visualDesignGuide: string | null = null;\n\nfunction loadSessionPrompt(filename: string, fallback: string): string {\n try {\n return loadPrompt(filename);\n } catch (err) {\n logger.error({ err, filename }, \"session prompt load failed; using fallback prompt\");\n return fallback;\n }\n}\n\nfunction topicSystemPromptTemplate(): string {\n if (_topicSystemPromptTemplate === null) {\n _topicSystemPromptTemplate = loadSessionPrompt(\n \"topic-system.md\",\n FALLBACK_TOPIC_SYSTEM_PROMPT_TEMPLATE,\n );\n }\n return _topicSystemPromptTemplate;\n}\n\nfunction channelSystemPromptTemplate(): string {\n if (_channelSystemPromptTemplate === null) {\n _channelSystemPromptTemplate = loadSessionPrompt(\n \"channel-system.md\",\n FALLBACK_CHANNEL_SYSTEM_PROMPT_TEMPLATE,\n );\n }\n return _channelSystemPromptTemplate;\n}\n\nfunction managerSystemPromptTemplate(): string {\n if (_managerSystemPromptTemplate === null) {\n _managerSystemPromptTemplate = loadSessionPrompt(\n \"manager-system.md\",\n FALLBACK_MANAGER_SYSTEM_PROMPT_TEMPLATE,\n );\n }\n return _managerSystemPromptTemplate;\n}\n\n// House design system appended to the visual tool guidance so every show_html\n// visual shares one look. Empty string if the file is missing (base CSS still\n// applies at render time, so visuals stay usable without it).\nfunction visualDesignGuide(): string {\n if (_visualDesignGuide === null) {\n _visualDesignGuide = loadSessionPrompt(\"visual-design.md\", \"\");\n }\n return _visualDesignGuide;\n}\n\nexport interface AgentDef {\n name: string;\n type: \"autonomous\" | \"programmatic\";\n model?: string;\n tools?: string[];\n description?: string;\n prompt: string;\n}\n\nexport function loadAgentPrompt(filename: string): AgentDef {\n const raw = readFileSync(resolve(AGENTS_PROMPTS_DIR, filename), \"utf-8\");\n const match = raw.match(/^---\\n([\\s\\S]*?)\\n---\\n([\\s\\S]*)$/);\n if (!match) throw new Error(`Agent prompt ${filename} is missing frontmatter`);\n\n // Minimal YAML parser: supports scalar values and string arrays (2-space \" - item\" lists).\n // Empty lines are skipped explicitly — without the guard they'd match the scalar branch\n // and reset currentKey, silently truncating any list that follows.\n const meta: Record<string, unknown> = {};\n let currentKey: string | null = null;\n for (const line of match[1].split(\"\\n\")) {\n if (/^\\w[^:]*:$/.test(line)) {\n currentKey = line.trim().replace(/:$/, \"\");\n meta[currentKey] = [];\n } else if (line.startsWith(\" - \") && currentKey) {\n (meta[currentKey] as string[]).push(line.slice(4).trim());\n } else if (line.trim() !== \"\" && line.includes(\":\") && !line.startsWith(\" \")) {\n currentKey = null;\n const colonIdx = line.indexOf(\":\");\n const key = line.slice(0, colonIdx).trim();\n const value = line.slice(colonIdx + 1).trim();\n if (key && value) meta[key] = value;\n }\n }\n\n return {\n name: String(meta.name ?? filename.replace(\".md\", \"\")),\n type: (meta.type as AgentDef[\"type\"]) ?? \"programmatic\",\n model: meta.model ? String(meta.model) : undefined,\n tools: Array.isArray(meta.tools) ? (meta.tools as string[]) : undefined,\n description: meta.description ? String(meta.description) : undefined,\n prompt: match[2].trim(),\n };\n}\n\nexport interface SessionSystemPromptOpts {\n aiLabel: string;\n topicTitle: string;\n workspaceCwd: string;\n agentKind: AgentKind;\n description?: string | null;\n /** True only for top-level agent rooms — the runtime spawn_subagent tool is registered there. */\n canSpawnSubagents?: boolean;\n /** True only when the current adapter renders Otium visual cards. */\n visualTools?: boolean;\n /** True only when the current adapter can deliver files to its chat. */\n fileDeliveryTools?: boolean;\n}\n\nfunction buildRuntimeToolSection(\n agentKind: AgentKind,\n canSpawnSubagents = false,\n visualTools = false,\n fileDeliveryTools = false,\n): string {\n const runtimeNamespace = \"mcp__runtime\";\n const taskNamespace = \"mcp__task\";\n const visualToolLine =\n agentKind === \"codex\"\n ? `To display charts, tables, or interactive HTML results to the user, call the \\`show_html\\` function in the \\`${runtimeNamespace}\\` namespace with { html: \"<complete HTML string>\", title?: \"optional title\" }.`\n : `To display charts, tables, or interactive HTML results to the user, call the MCP tool \"${runtimeNamespace}__show_html\" with { html: \"<complete HTML string>\", title?: \"optional title\" }.`;\n const mermaidToolLine =\n agentKind === \"codex\"\n ? `For diagrams that Mermaid supports, prefer the \\`show_mermaid\\` function in the \\`${runtimeNamespace}\\` namespace with { code: \"<Mermaid DSL without markdown fences>\", title?: \"...\", theme?: \"neutral\" }.`\n : `For diagrams that Mermaid supports, prefer the MCP tool \"${runtimeNamespace}__show_mermaid\" with { code: \"<Mermaid DSL without markdown fences>\", title?: \"...\", theme?: \"neutral\" }.`;\n const mediaToolLine =\n agentKind === \"codex\"\n ? `To display an existing image or video in the visual panel, use \\`show_image\\` or \\`show_video\\` in the \\`${runtimeNamespace}\\` namespace with either { file_path: \"...\", title?: \"...\" } for a topic-workspace file or { file_id: \"...\", title?: \"...\" } for an uploaded file already attached in this topic.`\n : `To display an existing image or video in the visual panel, use MCP tool \"${runtimeNamespace}__show_image\" or \"${runtimeNamespace}__show_video\" with either { file_path: \"...\", title?: \"...\" } for a topic-workspace file or { file_id: \"...\", title?: \"...\" } for an uploaded file already attached in this topic.`;\n const sendFileTool =\n agentKind === \"codex\"\n ? `\\`send_file\\` function in the \\`${runtimeNamespace}\\` namespace`\n : `MCP tool \"${runtimeNamespace}__send_file\"`;\n const askUserToolLine =\n agentKind === \"codex\"\n ? `When you need a blocking user choice, call the \\`ask_user_question\\` function in the \\`${runtimeNamespace}\\` namespace with { question: \"...\", choices: [{ label: \"...\", description?: \"...\" }] }.`\n : `When you need a blocking user choice, call the MCP tool \"${runtimeNamespace}__ask_user_question\" with { question: \"...\", choices: [{ label: \"...\", description?: \"...\" }] }.`;\n const scheduleSelfToolLine =\n agentKind === \"codex\"\n ? `For a one-shot delayed continuation within 24 hours, call the \\`schedule_self\\` function in the \\`${runtimeNamespace}\\` namespace with { delay_seconds: number, message: \"self-contained future instruction\" }. Only one pending self-schedule is allowed per topic; use \\`get_self_schedule\\`, \\`update_self_schedule\\`, or \\`cancel_self_schedule\\` in that namespace to manage it. Use cron-manager for recurring schedules.`\n : `For a one-shot delayed continuation within 24 hours, call the MCP tool \"${runtimeNamespace}__schedule_self\" with { delay_seconds: number, message: \"self-contained future instruction\" }. Only one pending self-schedule is allowed per topic; manage it with \"${runtimeNamespace}__get_self_schedule\", \"${runtimeNamespace}__update_self_schedule\", or \"${runtimeNamespace}__cancel_self_schedule\". Use cron-manager for recurring schedules.`;\n const taskToolLine =\n agentKind === \"codex\"\n ? `For task tracking, use \\`task_create\\`, \\`task_update\\`, \\`task_list\\`, \\`task_get\\`, and \\`task_delete\\` functions in the \\`${taskNamespace}\\` namespace.`\n : `For task tracking, use MCP tools \"${taskNamespace}__task_create\", \"${taskNamespace}__task_update\", \"${taskNamespace}__task_list\", \"${taskNamespace}__task_get\", and \"${taskNamespace}__task_delete\".`;\n const spawnSubagentToolLine =\n agentKind === \"codex\"\n ? `To delegate a self-contained task to a background subagent, call the \\`spawn_subagent\\` function in the \\`${runtimeNamespace}\\` namespace with { task: \"...\", name?: \"...\", agent?: \"claude\"|\"codex\"|\"maestro\", model?: \"...\" }.`\n : `To delegate a self-contained task to a background subagent, call the MCP tool \"${runtimeNamespace}__spawn_subagent\" with { task: \"...\", name?: \"...\", agent?: \"claude\"|\"codex\"|\"maestro\", model?: \"...\" }.`;\n const spawnSubagentSection = canSpawnSubagents\n ? [\n \"\",\n \"## Subagent Delegation\",\n spawnSubagentToolLine,\n \"The subagent works in its own new agent room and starts with ONLY the task text — include all needed context, file paths, and acceptance criteria in it.\",\n \"The call returns immediately (fire-and-forget); the subagent's final result is delivered back into this room automatically when it finishes. End your turn normally — never wait or poll for it.\",\n \"Use it for parallelizable or long-running side work; keep quick inline work in this room.\",\n ]\n : [];\n const nativeTaskPolicyLine =\n agentKind === \"claude\"\n ? `Do not use provider-native todo/task/subagent tools such as \"TodoWrite\", \"Task\", \"Agent\", \"TaskCreate\", \"TaskUpdate\", \"TaskList\", \"TaskOutput\", or \"TaskStop\"; they are disabled or not shared across agents.${canSpawnSubagents ? \" For delegation, use the runtime spawn_subagent tool instead.\" : \"\"}`\n : agentKind === \"maestro\"\n ? `Do not use provider-native task-store tools such as \"TaskCreate\", \"TaskUpdate\", \"TaskList\", \"TaskGet\", \"TaskOutput\", or \"TaskStop\"; they are disabled or not shared across agents. Do not use the Maestro \"Agent\" sub-agent tool either; it is disabled.${canSpawnSubagents ? \" Use the runtime spawn_subagent tool for delegation so work is visible in its own room and the result returns here automatically.\" : \" Delegation is unavailable in this room.\"}`\n : 'Do not use provider-native todo/plan surfaces such as \"todo_list\" or \"update_plan\"; they are ignored or not shared across agents.';\n const visualSection = visualTools\n ? [\n visualToolLine,\n mermaidToolLine,\n mediaToolLine,\n 'Do not call a bare \"show_html\"; use the exposed visuals MCP tool. A successful call means the card was shown in the user chat.',\n \"Visual HTML runs in a sandbox. Use inline CSS/JS only; local buttons, tabs, filters, forms with preventDefault, canvas, and SVG interactions are supported. External navigation, scripts, network fetches, form posts, popups, and parent-window access are blocked.\",\n ]\n : [];\n const fileDeliverySection = fileDeliveryTools\n ? [\n \"\",\n \"## File Delivery\",\n `To send a file to the user, save it under your working directory and call the ${sendFileTool} with { file_path: \"<absolute path>\" }.`,\n \"It appears as a downloadable attachment in the chat and returns success. Never claim file delivery is unavailable after a successful call.\",\n ]\n : [];\n\n const shared = [\n \"\",\n \"\",\n \"## Runtime Tools\",\n ...visualSection,\n askUserToolLine,\n 'Do not use provider built-in \"AskUserQuestion\"; it is disabled or unsupported in this headless chat runtime. Use the runtime ask_user_question tool instead.',\n scheduleSelfToolLine,\n ...(visualTools ? [\"\", visualDesignGuide()] : []),\n \"\",\n \"## Shared Tasks\",\n taskToolLine,\n \"Use this shared task store for plans, task progress, and checklist updates. It is visible across claude/codex/maestro turns and drives the live task panel.\",\n nativeTaskPolicyLine,\n ...fileDeliverySection,\n \"\",\n \"## Session Communication\",\n \"The session-comm MCP server is the only cross-topic messaging surface. Its canonical tools are `list_sessions`, `peek_session`, `tell_session`, `ask_session`, and `abort_session`.\",\n \"Use `list_sessions` to inspect available topics. Use `ask_session` for read-only questions whose result you need back in your own context. Use `tell_session` for one-way delegation or context handoff where no reply should return here. Do not describe `tell_session` as bidirectional and do not claim `ask_session` is unavailable without first checking the session-comm tools.\",\n ...(agentKind === \"maestro\"\n ? [\n 'Session-comm schemas may initially be deferred. Before using or judging availability, call ToolSearch(\"select:mcp__session-comm__list_sessions,mcp__session-comm__peek_session,mcp__session-comm__tell_session,mcp__session-comm__ask_session,mcp__session-comm__abort_session\") to activate the exact tools. Never substitute a similarly described runtime tool.',\n ]\n : []),\n \"Do not use session communication to make another topic perform destructive changes without the user's clear intent.\",\n ...spawnSubagentSection,\n ];\n\n const topicConfig = [\n \"\",\n \"## Topic Configuration (model / agent / effort)\",\n \"The user's configured agent/model/effort is intentional. Preserve it by default.\",\n `When the user explicitly asks to change the model, agent backend, or reasoning effort for THIS topic, call \"${runtimeNamespace}__set_model\", \"${runtimeNamespace}__set_agent\", or \"${runtimeNamespace}__set_effort\". The change applies from your NEXT turn. After calling, briefly confirm and the system will continue with the new setting.`,\n \"`set_effort` is available but discouraged; use it only when the user explicitly requests an effort change.\",\n \"`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. In that case, move up one step within the same agent and end the turn. Do not use vague task complexity as a trigger.\",\n \"`set_agent` autonomous calls are forbidden. Only switch agent when the user explicitly asks to switch runtime, e.g. “codex로 가”, “claude로 바꿔”.\",\n \"Never use `fable` unless the user explicitly requests it; it is expensive.\",\n \"\",\n \"Accepted values:\",\n \"- claude models: `sonnet` (default), `opus`, `fable`; efforts: `low`, `medium`, `high`, `xhigh`, `max`.\",\n \"- codex models: `gpt-5.6-luna` (default), `gpt-5.6-terra`, `gpt-5.6-sol`; efforts: `low`, `medium`, `high`, `xhigh`, `max`.\",\n \"- maestro models: `deepseek-pro` (default), `deepseek-flash`, `deepseek`; efforts: `low`, `medium`, `high`, `xhigh`, `max`.\",\n \"Agent guidance when the user explicitly asks to switch: `codex` for deepest reasoning and complex code/math; `claude` for tool-heavy MCP/file automation; `maestro` for inexpensive fast drafts and lighter experiments.\",\n ];\n\n if (agentKind !== \"claude\") {\n return [\n ...shared,\n ...topicConfig,\n \"\",\n \"## Runtime Tool Limits\",\n \"If file delivery or topic configuration tools are not present in your available tools for this session, do not claim you used them. Tell the user this session does not expose that in-chat tool action.\",\n ].join(\"\\n\");\n }\n\n return [...shared, ...topicConfig].join(\"\\n\");\n}\n\nexport function buildTopicSystemPrompt(opts: SessionSystemPromptOpts): string {\n const uploadsDir = `${opts.workspaceCwd}/attachments`;\n let prompt =\n replaceVars(topicSystemPromptTemplate(), {\n AI_LABEL: opts.aiLabel,\n TOPIC_TITLE: opts.topicTitle,\n WORKSPACE_CWD: opts.workspaceCwd,\n UPLOADS_DIR: uploadsDir,\n }) +\n buildRuntimeToolSection(\n opts.agentKind,\n opts.canSpawnSubagents,\n opts.visualTools,\n opts.fileDeliveryTools,\n );\n if (opts.description?.trim()) {\n prompt += `\\n\\n## Topic-Specific Instructions\\n${opts.description.trim()}`;\n }\n return prompt;\n}\n\nexport function buildChannelSystemPrompt(opts: SessionSystemPromptOpts): string {\n const uploadsDir = `${opts.workspaceCwd}/attachments`;\n return (\n replaceVars(channelSystemPromptTemplate(), {\n AI_LABEL: opts.aiLabel,\n TOPIC_TITLE: opts.topicTitle,\n WORKSPACE_CWD: opts.workspaceCwd,\n UPLOADS_DIR: uploadsDir,\n }) + buildRuntimeToolSection(opts.agentKind, false, opts.visualTools, opts.fileDeliveryTools)\n );\n}\n\nexport function buildManagerSystemPrompt(opts: SessionSystemPromptOpts): string {\n return `${buildTopicSystemPrompt(opts)}\\n\\n${managerSystemPromptTemplate()}`;\n}\n\nexport function buildMemoryPromptSection(opts: {\n topicId: string;\n wikiDir: string;\n hasFiles: boolean;\n latestSummaryFile?: string | null;\n hasArchive?: boolean;\n isManager: boolean;\n}): string {\n const parts: string[] = [\"\\n\\n## Memory\"];\n const briefFile = `${opts.wikiDir}/topic/${opts.topicId}.md`;\n parts.push(`Memory directory: ${opts.wikiDir}/topic`);\n parts.push(`Files: ${opts.hasFiles ? briefFile : \"(none)\"}`);\n if (opts.latestSummaryFile) {\n parts.push(`Latest summary: ${opts.latestSummaryFile}`);\n }\n parts.push(\n \"\",\n opts.isManager\n ? opts.hasFiles\n ? \"위는 이 워크스페이스의 메모리 허브 브리프입니다(모든 토픽 아카이브가 누적됨). 과거 맥락·다른 토픽 내용을 물으면 먼저 이 브리프를 참고하고, 더 깊은 검색은 `wiki_query` MCP 도구를 사용하세요.\"\n : \"위임된 작업 처리 중 과거 맥락이 필요하면 `wiki_query` MCP 도구를 사용하세요.\"\n : opts.hasFiles\n ? \"위 파일은 이 토픽의 Wiki 브리프입니다. 과거 맥락 파악 시 먼저 Read로 읽으세요. 더 깊은 검색이 필요하면 `wiki_query` MCP 도구를 사용하세요.\"\n : opts.latestSummaryFile\n ? \"Wiki 브리프 파일은 아직 없습니다. 과거 맥락 파악 시 먼저 Latest summary를 Read로 읽으세요. 더 깊은 검색이 필요하면 `wiki_query` MCP 도구를 사용하세요.\"\n : \"Wiki 브리프 파일은 아직 없습니다. 과거 맥락 파악 시 `wiki_query` MCP 도구를 사용하세요.\",\n );\n parts.push(\n \"\",\n opts.isManager\n ? \"워크스페이스 과거 결정이나 다른 토픽 맥락을 답할 때는 메모리를 자연스럽게 반영하되, 확실하지 않으면 `wiki_query`로 확인하세요.\"\n : opts.hasFiles || opts.latestSummaryFile\n ? \"토픽 첫 응답 시, Wiki 브리프\" +\n (opts.latestSummaryFile ? \"와 Latest summary를 Read로 읽고\" : \"를 Read로 읽고\") +\n \" 맥락 요약을 자연스럽게 한 줄로 언급하세요. 사용자가 맥락이 맞는지 바로 판단할 수 있도록.\"\n : \"토픽 첫 응답 시, 필요한 경우 이전 대화 맥락을 확인한 뒤 자연스럽게 한 줄로 언급하세요.\",\n );\n parts.push(\n \"\",\n opts.hasFiles\n ? \"사용자가 기억이 틀렸다고 교정하면, Memory directory의 해당 파일을 Read로 찾아 Edit으로 직접 수정하세요.\"\n : \"사용자가 기억이 틀렸다고 교정하면, 관련 Wiki 브리프를 확인하고 가능한 경우 직접 수정하거나 `wiki_query`로 관련 항목을 찾아 근거를 맞추세요.\",\n );\n if (opts.hasArchive) {\n parts.push(\n \"\",\n \"이전 세션의 실제 대화 내용이 필요하면 `wiki_last_conversation` MCP 도구를 사용하세요.\",\n );\n }\n return parts.join(\"\\n\");\n}\n",
|
|
6
6
|
"import { randomBytes } from \"node:crypto\";\nimport { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { logger } from \"#platform/logger\";\nimport { type AgentKind, isAgentKind } from \"#types\";\n\nexport function envText(envKey: string): string | undefined {\n const value = process.env[envKey]?.trim();\n return value ? value : undefined;\n}\n\nfunction resolveAgentEnv(envKey: string, fallback: AgentKind, legacyEnvKey?: string): AgentKind {\n const value = envText(envKey) ?? (legacyEnvKey ? envText(legacyEnvKey) : undefined);\n return isAgentKind(value) ? value : fallback;\n}\n\nconst HOME = homedir();\n\n// new URL(\"../..\", import.meta.url) causes webpack to treat \"../..\" as a module import.\n// Split into fileURLToPath → dirname → resolve to avoid that.\nfunction resolveProjectRoot(): string {\n const moduleDir = dirname(fileURLToPath(import.meta.url));\n const packagedRuntime = resolve(moduleDir, \"runtime\");\n if (existsSync(resolve(packagedRuntime, \"src\"))) return packagedRuntime;\n return resolve(moduleDir, \"../..\");\n}\n\nexport const PROJECT_ROOT = resolveProjectRoot();\n\n/** Resolve a dependency executable from either a package-local or hoisted install. */\nfunction resolveDependencyBin(name: string): string {\n let dir = PROJECT_ROOT;\n while (true) {\n const candidate = resolve(dir, \"node_modules\", \".bin\", name);\n if (existsSync(candidate)) return candidate;\n const parent = dirname(dir);\n if (parent === dir) return candidate;\n dir = parent;\n }\n}\n\n// Each machine is one negotium node; all node state lives in one dotdir.\n// NEGOTIUM_STATE_DIR overrides (useful for tests and multi-node-on-one-box).\nconst STATE_DIR_ENV = envText(\"NEGOTIUM_STATE_DIR\");\nexport const STATE_DIR = STATE_DIR_ENV ? resolve(STATE_DIR_ENV) : resolve(HOME, \".negotium\");\n\nfunction resolveLocalStateDir(envKey: string, stateName: string): string {\n const envValue = envText(envKey);\n if (envValue) return resolve(envValue);\n return resolve(STATE_DIR, stateName);\n}\n\nfunction parsePortEnv(envValue: string | undefined, fallback: number): number {\n if (!envValue) return fallback;\n const port = Number.parseInt(envValue, 10);\n return Number.isInteger(port) && port > 0 ? port : fallback;\n}\n\nexport const WORKSPACE_DIR = resolveLocalStateDir(\"NEGOTIUM_WORKSPACE_DIR\", \"workspace\");\nexport const TOPIC_WORKSPACE_DIR = resolve(WORKSPACE_DIR, \"topics\");\nexport const SHARED_WIKI_DIR = resolve(WORKSPACE_DIR, \"wiki\");\nexport const CONTEXTS_DIR = resolve(WORKSPACE_DIR, \"contexts\");\nexport const BROWSER_PROFILES_DIR = resolve(WORKSPACE_DIR, \"browser-profiles\");\nexport const DM_WORKSPACE_DIR = resolve(WORKSPACE_DIR, \"dm\");\nexport const SESSION_WORKSPACE_DIR = resolve(WORKSPACE_DIR, \"sessions\");\nexport const CLAUDE_EXECUTABLE = resolve(HOME, \".local/bin/claude\");\n\n// Browser automation uses the authenticated local Patchright HTTP wrapper.\nexport function resolveBrowserMcpBin(envValue?: string): string {\n const override = envValue?.trim();\n if (override) {\n if (!/(^|\\/)(mcp-patchright|mcp-patchright-http\\.mjs)$/.test(override)) {\n throw new Error(\n \"NEGOTIUM_BROWSER_MCP_BIN must point to the authenticated mcp-patchright wrapper.\",\n );\n }\n return override;\n }\n return PATCHRIGHT_MCP_BIN;\n}\n\nexport const PATCHRIGHT_MCP_BIN = resolve(PROJECT_ROOT, \"scripts/mcp-patchright-http.mjs\");\nexport const PLAYWRIGHT_MCP_BIN = resolveBrowserMcpBin(envText(\"NEGOTIUM_BROWSER_MCP_BIN\"));\n\n// --- Browser egress proxy ---\n//\n// On a datacenter host (AWS) the browser's egress IP is a known cloud range,\n// so anti-bot services (Cloudflare, DataDome, reCAPTCHA) challenge or block it\n// far more than a residential IP would. Routing the automation browser through\n// a residential/ISP proxy moves the egress IP out of the datacenter range.\n//\n// Operators set BROWSER_PROXY_URL, e.g. http://user:pass@proxy.host:8080 or\n// socks5://proxy.host:1080. Credentials in the URL are split out because\n// Playwright takes them as separate fields. BROWSER_PROXY_BYPASS is an optional\n// comma-separated no-proxy list (e.g. \"localhost,127.0.0.1,*.internal\").\n//\n// NOTE: Chromium does not support authentication for SOCKS proxies — put\n// credentials only on http/https proxy URLs.\nexport type BrowserProxyConfig = {\n server: string;\n username?: string;\n password?: string;\n bypass?: string;\n};\n\nexport function resolveBrowserProxy(): BrowserProxyConfig | null {\n const raw = envText(\"BROWSER_PROXY_URL\");\n if (!raw) return null;\n let url: URL;\n try {\n url = new URL(raw);\n } catch {\n logger.warn({ raw }, \"Ignoring malformed BROWSER_PROXY_URL\");\n return null;\n }\n // Playwright wants the server without embedded credentials.\n const server = `${url.protocol}//${url.host}`;\n const proxy: BrowserProxyConfig = { server };\n if (url.username) proxy.username = decodeURIComponent(url.username);\n if (url.password) proxy.password = decodeURIComponent(url.password);\n const bypass = envText(\"BROWSER_PROXY_BYPASS\");\n if (bypass) proxy.bypass = bypass;\n return proxy;\n}\n\n// --- Node/tsx runtime for the `codex` agent's MCP servers ---\n//\n// codex 0.135's rmcp stdio MCP client cannot reliably complete the initialize\n// handshake with servers spawned via `bun` (the JSON-RPC initialize is\n// dropped/raced and no tools ever reach the model). Pure-node servers connect\n// reliably, so codex turns launch the SAME .ts servers via node + tsx instead\n// of `bun run`. claude/maestro keep using `bun run` (fast, native, unaffected).\n//\n// tsx transpiles .ts on the fly and resolves the `@/*` tsconfig path aliases,\n// but only when it can find the tsconfig — and MCP servers run with cwd set to\n// the user's workspace dir, not PROJECT_ROOT — so we pass TSX_TSCONFIG_PATH\n// explicitly via env. Requires package.json `\"type\": \"module\"` so the servers'\n// top-level `await` loads as ESM under node.\nexport const TSX_BIN = resolveDependencyBin(\"tsx\");\nexport const TSCONFIG_PATH = resolve(PROJECT_ROOT, \"tsconfig.json\");\n\nexport const SESSION_COMM_SERVER = resolve(PROJECT_ROOT, \"src/mcp/session-comm/server.ts\");\n\nexport const TASK_SERVER = resolve(PROJECT_ROOT, \"src/mcp/task-server.ts\");\nexport const CANONICAL_MCP_PROXY_SERVER = resolve(\n PROJECT_ROOT,\n \"src/mcp/canonical-proxy-server.ts\",\n);\n\nexport const WIKI_SERVER = resolve(PROJECT_ROOT, \"src/mcp/wiki-server.ts\");\n\nexport const PADDLEOCR_SERVER = resolve(PROJECT_ROOT, \"src/mcp/paddleocr-server.ts\");\n\nexport const TOKEN_STATS_SERVER = resolve(PROJECT_ROOT, \"src/mcp/token-stats-server.ts\");\n\nexport const SYSTEM_HEALTH_SERVER = resolve(PROJECT_ROOT, \"src/mcp/system-health-server.ts\");\n\nexport const AGENT_HEALTH_SERVER = resolve(PROJECT_ROOT, \"src/mcp/agent-health-server.ts\");\n\nexport const BACKGROUND_BASH_SERVER = resolve(PROJECT_ROOT, \"src/mcp/background-bash-server.ts\");\n\nexport const VAULT_SERVER = resolve(PROJECT_ROOT, \"src/mcp/vault-server.ts\");\n\nexport const BG_BASH_BASE_PORT = parsePortEnv(process.env.BG_BASH_BASE_PORT, 9700);\nexport const BG_BASH_MAX_PORT = parsePortEnv(process.env.BG_BASH_MAX_PORT, 9799);\n\nfunction safeWorkspaceSegment(value: string, fallback: string): string {\n const cleaned = value\n .trim()\n .replace(/[^A-Za-z0-9._-]/g, \"_\")\n .replace(/^_+|_+$/g, \"\")\n .slice(0, 160);\n return cleaned || fallback;\n}\n\n/** Resolve the shared filesystem workspace for an API topic. */\nexport function resolveTopicWorkspaceDir(topicId: string): string {\n return join(TOPIC_WORKSPACE_DIR, safeWorkspaceSegment(topicId, \"topic\"));\n}\n\nexport function isProductionEnv(): boolean {\n return process.env.NODE_ENV === \"production\";\n}\n\nfunction loadOrCreateLocalSecret(\n envKey: string,\n filename: string,\n options: { persistEnvValue?: boolean } = {},\n): string {\n const envValue = envText(envKey);\n const secretFile = resolve(STATE_DIR, filename);\n mkdirSync(dirname(secretFile), { recursive: true });\n if (envValue) {\n if (options.persistEnvValue) {\n writeFileSync(secretFile, `${envValue}\\n`, { mode: 0o600 });\n chmodSync(secretFile, 0o600);\n }\n return envValue;\n }\n\n if (existsSync(secretFile)) {\n const stored = readFileSync(secretFile, \"utf-8\").trim();\n if (stored) {\n chmodSync(secretFile, 0o600);\n return stored;\n }\n }\n\n const secret = randomBytes(32).toString(\"base64url\");\n try {\n writeFileSync(secretFile, `${secret}\\n`, { mode: 0o600, flag: \"wx\" });\n return secret;\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"EEXIST\") throw error;\n const stored = readFileSync(secretFile, \"utf-8\").trim();\n if (!stored) throw new Error(`Secret file exists but is empty: ${secretFile}`);\n chmodSync(secretFile, 0o600);\n return stored;\n }\n}\n\nexport const RUNTIME_MCP_SECRET = loadOrCreateLocalSecret(\n \"RUNTIME_MCP_SECRET\",\n \"runtime-mcp-secret\",\n);\n/** Local bearer token for the loopback node-control API. */\nexport const NODE_CONTROL_TOKEN = loadOrCreateLocalSecret(\n \"NEGOTIUM_CONTROL_TOKEN\",\n \"node-control-token\",\n);\nexport const VAULT_MASTER_KEY = loadOrCreateLocalSecret(\n \"NEGOTIUM_VAULT_MASTER_KEY\",\n \"vault-master-key\",\n { persistEnvValue: true },\n);\n// Agent/tool subprocesses inherit process.env. Keep the loaded key in this\n// process only so `env`/`ps` inside an agent workspace cannot reveal it.\ndelete process.env.NEGOTIUM_VAULT_MASTER_KEY;\n\n/** The node's single open port: runtime MCP endpoint + node API. */\nexport const NEGOTIUM_PORT = parseInt(process.env.NEGOTIUM_PORT || \"7777\", 10);\nexport const hostname = process.env.HOSTNAME || \"127.0.0.1\";\n\n// Persistent state (survives restarts, long-lived)\nexport const DATA_DIR = resolveLocalStateDir(\"NEGOTIUM_DATA_DIR\", \"data\");\nexport const LOG_DIR = resolveLocalStateDir(\"NEGOTIUM_LOG_DIR\", \"logs\");\n// SESSIONS_DB_PATH env override lets tests point the DB singleton at a temp file.\nexport const SESSIONS_DB = process.env.SESSIONS_DB_PATH\n ? resolve(process.env.SESSIONS_DB_PATH)\n : resolve(DATA_DIR, \"sessions.db\");\nexport const DEBUG_FILE = resolve(DATA_DIR, \"debug-users.json\");\nexport const USERS_LOG_DIR = resolve(DATA_DIR, \"users\");\n\n// Runtime IPC queues (transient, safe to clear on restart)\nexport const RUN_DIR = resolveLocalStateDir(\"NEGOTIUM_RUN_DIR\", \"run\");\nexport const PROGRESS_DIR = resolve(RUN_DIR, \"progress\");\nexport const DM_CMD_DIR = resolve(RUN_DIR, \"dm-commands\");\nexport const DM_RESP_DIR = resolve(RUN_DIR, \"dm-responses\");\nexport const SESSION_INBOX_DIR = resolve(RUN_DIR, \"session-inbox\");\nexport const SESSION_ASKS_DIR = resolve(RUN_DIR, \"session-asks\");\nexport const PLAYWRIGHT_BASE_PORT = parsePortEnv(process.env.PLAYWRIGHT_BASE_PORT, 9100);\nexport const PLAYWRIGHT_MAX_PORT = parsePortEnv(process.env.PLAYWRIGHT_MAX_PORT, 9499);\nexport const PLAYWRIGHT_PORTS_DIR = resolve(RUN_DIR, \"playwright-ports\");\nmkdirSync(STATE_DIR, { recursive: true });\nmkdirSync(DATA_DIR, { recursive: true });\nmkdirSync(LOG_DIR, { recursive: true });\nmkdirSync(PROGRESS_DIR, { recursive: true });\nmkdirSync(DM_CMD_DIR, { recursive: true });\nmkdirSync(DM_RESP_DIR, { recursive: true });\nmkdirSync(SESSION_INBOX_DIR, { recursive: true });\nmkdirSync(SESSION_ASKS_DIR, { recursive: true });\nmkdirSync(PLAYWRIGHT_PORTS_DIR, { recursive: true });\nmkdirSync(WORKSPACE_DIR, { recursive: true });\nmkdirSync(TOPIC_WORKSPACE_DIR, { recursive: true });\nmkdirSync(SHARED_WIKI_DIR, { recursive: true });\nmkdirSync(CONTEXTS_DIR, { recursive: true });\nmkdirSync(BROWSER_PROFILES_DIR, { recursive: true });\nmkdirSync(DM_WORKSPACE_DIR, { recursive: true });\nmkdirSync(SESSION_WORKSPACE_DIR, { recursive: true });\n\n/** Stale threshold for active-query state files (crash recovery) */\nexport const ACTIVE_QUERY_STALE_MS = 10 * 60 * 1000; // 10 minutes\n\nexport const AGENTS_PROMPTS_DIR = resolve(PROJECT_ROOT, \"src/prompts/agents\");\nexport const RESOURCES_DIR = resolve(PROJECT_ROOT, \"src/resources\");\n\n/** Returns process.env without CLAUDECODE, to prevent nested claude-code detection in subprocesses. */\nexport function getCleanEnv(): NodeJS.ProcessEnv {\n const env = { ...process.env };\n delete env.CLAUDECODE;\n return env;\n}\n\nexport const FILE_EXTENSIONS_REGEX =\n /(?:\\/[^\\s\"'<>|*?[\\]]+\\.(?:png|jpg|jpeg|gif|webp|svg|pdf|csv|xlsx|xls|json|txt|md|html|zip|py|js|ts|tsx|jsx|css|xml|yaml|yml|docx|pptx))/gi;\n\nexport const FILE_TAG_REGEX = /\\[FILE:(\\/[^\\]]+)\\]/gi;\n\n// Canonical Claude model IDs — update here when Anthropic releases new versions\nexport const MODEL_SONNET = \"claude-sonnet-5\";\nexport const MODEL_OPUS = \"claude-opus-4-8\";\nexport const MODEL_HAIKU = \"claude-haiku-4-5-20251001\";\nexport const MODEL_FABLE = \"claude-fable-5\"; // Mythos-class, announced 2026-06-09\n\n// DeepSeek V4 (released 2026-04-24). API is OpenAI-compatible at\n// https://api.deepseek.com/v1/chat/completions; thinking mode is enabled via\n// `extra_body.thinking.type` + `reasoning_effort`. Legacy `deepseek-chat` /\n// `deepseek-reasoner` are deprecated 2026-07-24.\nexport const MODEL_DEEPSEEK_V4_PRO = \"deepseek-v4-pro\";\nexport const MODEL_DEEPSEEK_V4_FLASH = \"deepseek-v4-flash\";\n\n// Agent + model defaults split by session role. FALLBACK_* is the shared base;\n// SESSION_* overrides topic + ephemeral; GATEWAY_* overrides dm + manager.\n// DEFAULT_* is accepted as a legacy alias during the env migration window.\nexport const FALLBACK_AGENT: AgentKind = resolveAgentEnv(\n \"FALLBACK_AGENT\",\n \"maestro\",\n \"DEFAULT_AGENT\",\n);\nexport const SESSION_AGENT: AgentKind = resolveAgentEnv(\"SESSION_AGENT\", FALLBACK_AGENT);\nexport const GATEWAY_AGENT: AgentKind = resolveAgentEnv(\"GATEWAY_AGENT\", FALLBACK_AGENT);\n\nexport const FALLBACK_MODEL = envText(\"FALLBACK_MODEL\") ?? envText(\"DEFAULT_MODEL\");\n\nfunction resolveModelEnv(envKey: string, agentConst: AgentKind): string | undefined {\n return envText(envKey) ?? (agentConst === FALLBACK_AGENT ? FALLBACK_MODEL : undefined);\n}\n\nexport const SESSION_MODEL = resolveModelEnv(\"SESSION_MODEL\", SESSION_AGENT);\nexport const GATEWAY_MODEL = resolveModelEnv(\"GATEWAY_MODEL\", GATEWAY_AGENT);\n\n/** Resolve the effective display/default model for a topic (session context).\n * Applies the session model override only when that role owns the agent;\n * otherwise each registry's native default stays authoritative. */\nexport function resolveDefaultModel(agent: string, registryDefaultModel: string): string {\n return agent === SESSION_AGENT && SESSION_MODEL ? SESSION_MODEL : registryDefaultModel;\n}\n\n// ── External tool binaries + media pipeline env ───────────────────\n// (src/media/* 에서 사용. 미설정 시 fallback 의미는 기존 그대로:\n// FFMPEG_BIN은 text-extractor에서 필수(undefined면 spawn 시점 실패),\n// video.ts에서는 PATH의 ffmpeg/ffprobe로 fallback.)\nexport const FFMPEG_BIN = envText(\"FFMPEG_BIN\");\nexport const FFPROBE_BIN = envText(\"FFPROBE_BIN\");\nexport const PYTHON_BIN = envText(\"PYTHON_BIN\") ?? \"python3\";\nexport const FASTER_WHISPER_WRAPPER =\n envText(\"FASTER_WHISPER_WRAPPER\") ?? resolve(PROJECT_ROOT, \"scripts/faster-whisper-wrapper.py\");\nexport const WHISPER_MODEL = envText(\"WHISPER_MODEL_FILE\") ?? \"turbo\";\nexport const TESSERACT_BIN = envText(\"TESSERACT_BIN\") ?? \"tesseract\";\nexport const PDFTOTEXT_BIN = envText(\"PDFTOTEXT_BIN\") ?? \"pdftotext\";\n\n// Max tell_session relay depth from origin user. ask_session forks reset to\n// depth=0, so this only caps tell_session chains. Override via MAX_TELL_DEPTH\n// (positive int); defaults to 20 when unset or invalid.\nconst _envMaxTellDepth = Number.parseInt(process.env.MAX_TELL_DEPTH ?? \"\", 10);\nexport const MAX_TELL_DEPTH =\n Number.isInteger(_envMaxTellDepth) && _envMaxTellDepth > 0 ? _envMaxTellDepth : 20;\n\n/** Codex CLI auth file. 호출 시점에 env를 읽는다 — 테스트가 런타임에\n * NEGOTIUM_CODEX_AUTH_FILE을 바꾸므로 모듈 로드 상수로 만들면 안 된다. */\nexport function codexAuthFilePath(): string {\n return process.env.NEGOTIUM_CODEX_AUTH_FILE || join(homedir(), \".codex\", \"auth.json\");\n}\n\n// System defaults moved to per-agent registries\n// (`src/agents/{claude,codex}-registry.ts`). Read via\n// `getRegistry(agent).defaultModel` / `.defaultEffort`.\n\n// MCP server builders -> src/platform/mcp-config.ts\n",
|
|
7
7
|
"import pino from \"pino\";\n\n/**\n * Always write logs to stderr (fd 2), never stdout.\n *\n * MCP servers under `src/mcp/**` run as stdio subprocesses where stdout is the\n * JSON-RPC transport channel. A single log line on stdout corrupts the next\n * message and the MCP client closes the transport (\"Transport closed\"). The\n * main bot process is also fine with stderr — pm2 captures both streams.\n *\n * In dev mode pino spawns a `pino-pretty` worker that owns its own sink, so we\n * pass `destination: 2` through transport.options. In prod (no transport) the\n * second arg to `pino()` sets the destination directly.\n */\nexport const logger = pino(\n {\n level: process.env.LOG_LEVEL || \"info\",\n transport:\n process.env.NODE_ENV === \"development\"\n ? {\n target: \"pino-pretty\",\n options: {\n colorize: true,\n translateTime: \"SYS:yyyy-mm-dd HH:MM:ss\",\n destination: 2,\n },\n }\n : undefined,\n },\n pino.destination(2),\n);\n",
|
|
8
|
-
"/**\n * Common context carried through the attachment/prompt-build pipeline.\n * Used by buildPromptFromMessage and related helpers.\n */\nexport interface SessionContext {\n userId: number;\n topicName?: string;\n userDir?: string;\n sessionType?: \"dm\" | \"forum\" | \"ephemeral\" | \"manager\" | \"cron\";\n}\n\nexport interface TokenUsage {\n /** Aggregate billable input across every model call made during this turn. */\n inputTokens: number;\n outputTokens: number;\n cacheCreationInputTokens?: number;\n cacheReadInputTokens?: number;\n /** Provider-reported query cost when available. */\n costUsd?: number;\n /** Tokens occupied by the latest model call, not aggregate turn spend. */\n contextTokens?: number;\n /** Provider-reported context window for the latest model call. */\n contextWindow?: number;\n}\n\n/** Agent identifier — one of the supported AI provider backends. */\nexport type AgentKind = \"maestro\" | \"claude\" | \"codex\";\n\nexport const SUPPORTED_AGENTS: readonly AgentKind[] = [\"maestro\", \"claude\", \"codex\"] as const;\n\nexport function isAgentKind(value: unknown): value is AgentKind {\n return typeof value === \"string\" && (SUPPORTED_AGENTS as readonly string[]).includes(value);\n}\n\n/**\n * Per-agent supported reasoning efforts. Single source of truth for both the\n * `EffortLevel` type and each registry's `validEfforts` runtime list — the\n * registries import these directly so adding a value in one place\n * propagates to validation, footer rendering, and zod enums.\n *\n * Claude SDK rejects 'minimal'; Codex SDK rejects 'max'. The two sets\n * intersect on low/medium/high/xhigh. Maestro (TS port) currently piggybacks\n * on the Anthropic provider, so its efforts mirror the Claude set; this can\n * narrow per-provider once Phase 5 lands.\n *\n * 'minimal' removed from codex: Codex API rejects it when default tools\n * (image_gen, web_search) are active, making agent sessions unusable.\n */\nexport const CLAUDE_EFFORT_VALUES = [\"low\", \"medium\", \"high\", \"xhigh\", \"max\"] as const;\nexport const CODEX_EFFORT_VALUES = [\"low\", \"medium\", \"high\", \"xhigh\", \"max\"] as const;\nexport const MAESTRO_EFFORT_VALUES = [\"low\", \"medium\", \"high\", \"xhigh\", \"max\"] as const;\n\nexport type EffortLevel =\n | (typeof CLAUDE_EFFORT_VALUES)[number]\n | (typeof CODEX_EFFORT_VALUES)[number]\n | (typeof MAESTRO_EFFORT_VALUES)[number];\n\n/**\n * Runtime iteration list (used by zod enums and any callers that need to\n * loop over every accepted value). Manually ordered for readability; the\n * `satisfies` check fails the build if an entry here isn't covered by the\n * per-agent unions above.\n */\nexport const EFFORT_VALUES = [\n \"low\",\n \"medium\",\n \"high\",\n \"xhigh\",\n \"max\",\n] as const satisfies readonly EffortLevel[];\n\n/**\n * Normalized events yielded by any agent provider (claudeProvider, codexProvider).\n * The handler/event-processor consumes these without caring which backend produced them.\n *\n * `user_message` is the lone \"into-the-log\" variant — no provider yields it.\n * The query handler writes it directly to the conversation log right before\n * `runAgent()` starts, so cross-agent rollout reconstruction can pair every\n * assistant turn with the user prompt that triggered it. Consumers that only\n * react to provider output (e.g. processAgentEvent) can safely ignore it.\n */\n/**\n * Wire-safe projection of one task, carried by the `tasks` UnifiedEvent.\n *\n * This is also the on-disk shape of Otium's shared task store, so claude,\n * codex, and maestro render the same live panel from the same source of truth.\n */\nexport interface TaskSnapshot {\n id: string;\n subject: string;\n status: \"pending\" | \"in_progress\" | \"completed\";\n /** Task ids this one is blocked by; omitted when empty. */\n blockedBy?: string[];\n /** Present-continuous label for spinners, when set. */\n activeForm?: string;\n /** Owner / agent name for multi-agent runs, when set. */\n owner?: string;\n}\n\nexport type UnifiedEvent =\n | { type: \"user_message\"; content: string }\n | { type: \"session\"; sessionId: string }\n | {\n type: \"tool_use\";\n name: string;\n input: Record<string, unknown>;\n /** Provider-assigned id so the client can match tool_use→tool_result pairs. */\n toolUseId?: string;\n }\n | { type: \"tool_progress\"; toolName: string; elapsed: number }\n | { type: \"tool_use_summary\"; summary: string }\n // Provider reasoning/thinking summary text (Codex `reasoning` items; Claude\n // extended-thinking). Surfaced so background runs (cron/archiver) show the\n // agent's thought process, not just tool calls.\n | { type: \"reasoning\"; content: string }\n // Full task-list snapshot (replace, not delta) from Otium's shared task\n // store. Provider-native task/todo stores are not authoritative.\n | { type: \"tasks\"; tasks: TaskSnapshot[] }\n | {\n type: \"tool_result\";\n toolUseId: string;\n content: string;\n metadata?: {\n truncatedForModel: boolean;\n originalBytes: number;\n returnedBytes: number;\n omittedBytes?: number;\n outputPath?: string;\n };\n }\n | { type: \"text_delta\"; content: string }\n | { type: \"text\"; content: string }\n | { type: \"result\"; content: string; stopReason: string; usage?: TokenUsage }\n | { type: \"file\"; path: string; source: string; origin: \"tag\" | \"extension\" }\n | {\n type: \"error\";\n content: string;\n usage?: TokenUsage;\n code?: \"budget_exceeded\";\n }\n | { type: \"status\"; content: string };\n\nexport interface AgentInputAttachment {\n id: string;\n type: \"image\" | \"file\" | \"audio\";\n filename: string;\n mimeType: string;\n sizeBytes: number;\n path: string;\n}\n\n/** Worker-side runtime tools proxy user-facing state back to the canonical\n * hub topic identified here. */\nexport interface PeerRuntimeBridgeContext {\n hubCellId: string;\n hostTopicId: string;\n hostQueryId: string;\n canSpawnSubagents: boolean;\n}\n\nexport interface AgentQueryOptions {\n agent: AgentKind;\n prompt: string;\n attachments?: AgentInputAttachment[];\n sessionId?: string | null;\n cwd: string;\n systemPrompt: string;\n userId?: string;\n session?: string;\n playwrightPort?: number;\n playwrightCapability?: string;\n bgBashPort?: number;\n sessionType?: \"dm\" | \"forum\" | \"ephemeral\" | \"manager\" | \"cron\";\n /** API topic id (REST/WS world). Carries per-query topic context for MCP servers. */\n topicId?: string;\n /** API query id for the currently running turn. Used by runtime MCP tools. */\n queryId?: string;\n /** Optional wiki-memory topic id. Derived topics use their root origin here\n * while other per-topic MCP servers keep `topicId` bound to the live room. */\n wikiTopicId?: string;\n /** Whether self-config MCP may enqueue an automatic continue turn after set_* changes. */\n autoContinue?: boolean;\n /** Expose Otium-only visual panel tools for this turn. Default-deny. */\n visualTools?: boolean;\n abortController?: AbortController;\n model?: string;\n /** Provider-side hard budget when the selected SDK supports one. */\n maxBudgetUsd?: number;\n depth?: number;\n agents?: Record<\n string,\n {\n description: string;\n prompt: string;\n model?: string;\n tools?: string[];\n maxTurns?: number;\n effort?: EffortLevel | number;\n }\n >;\n effort?: EffortLevel;\n /**\n * Per-API-call `max_tokens` ceiling on the assistant's output. Wired\n * through to the underlying provider request body for every agent\n * (claude/codex/maestro). Omit to inherit each provider SDK's per-model\n * default — for maestro that's the v0.1.21+ `getNativeMaxOutputTokens`\n * catalog (deepseek-pro=64K, deepseek-flash=32K).\n *\n * Pass an explicit number when a specific topic / surface needs a tighter\n * latency cap or a higher ceiling for long-form generation (legal\n * report writing, multi-K Write/Edit file bodies). Pre-0.1.21 maestro\n * builds silently clamped at 4096 and truncated outputs mid-string;\n * setting this field is now the supported way to lift that ceiling.\n */\n maxTokens?: number;\n /**\n * v0.1.22+: Claude-Code-style deferred tool catalog + `ToolSearch` built-in.\n *\n * Wired straight through to `maestro-agent-sdk`'s\n * `AgentQueryOptions.enableToolSearch`. When `true`, the maestro provider\n * registers every MCP tool as deferred — schemas stay off the wire until\n * the model promotes them via `ToolSearch(\"select:Name1,Name2\")` or\n * `ToolSearch(\"keyword\")`. Active set persists across resume.\n *\n * Otium's maestro provider supplies `true` when the caller leaves this\n * option unset, because most forum turns carry enough MCP surface for the\n * reminder-token savings to outweigh the first-use `ToolSearch` round-trip.\n * Callers can still pass `false` per call when a narrow surface or\n * latency-sensitive workflow is better served by eager MCP schemas.\n *\n * No-op for claude / codex agents — they have their own deferred-tool\n * machinery owned by their respective SDKs.\n */\n enableToolSearch?: boolean;\n /**\n * Claude-Code-compatible exact tool denylist. Maestro v0.1.42+ hides these\n * tools from provider schemas / ToolSearch and blocks dispatch if a stale\n * call still arrives. Claude maps this to its SDK option. Codex does not\n * support this name-based list; its provider-native multi-agent tool family\n * is disabled separately through the Codex feature config.\n */\n disallowedTools?: readonly string[];\n mcpEnabled?: string[] | null;\n peerBridge?: PeerRuntimeBridgeContext;\n mcpExtra?: Record<string, unknown>;\n /**\n * true for silent fork runs generating ask_session replies — restricts session-comm\n * outbound tools (ask/tell/abort) so the forked session can only produce text\n */\n silent?: boolean;\n}\n\n/** State file written to data/users/{userId}/active-queries/{topic}.json while a query is running. */\nexport interface QueryState {\n task?: string; // first 100 chars of prompt, newlines normalized\n since: string; // ISO timestamp\n}\n"
|
|
8
|
+
"/**\n * Common context carried through the attachment/prompt-build pipeline.\n * Used by buildPromptFromMessage and related helpers.\n */\nexport interface SessionContext {\n userId: number;\n topicName?: string;\n userDir?: string;\n sessionType?: \"dm\" | \"forum\" | \"ephemeral\" | \"manager\" | \"cron\";\n}\n\nexport interface TokenUsage {\n /** Aggregate billable input across every model call made during this turn. */\n inputTokens: number;\n outputTokens: number;\n cacheCreationInputTokens?: number;\n cacheReadInputTokens?: number;\n /** Provider-reported query cost when available. */\n costUsd?: number;\n /** Tokens occupied by the latest model call, not aggregate turn spend. */\n contextTokens?: number;\n /** Provider-reported context window for the latest model call. */\n contextWindow?: number;\n}\n\n/** Agent identifier — one of the supported AI provider backends. */\nexport type AgentKind = \"maestro\" | \"claude\" | \"codex\";\n\nexport const SUPPORTED_AGENTS: readonly AgentKind[] = [\"maestro\", \"claude\", \"codex\"] as const;\n\nexport function isAgentKind(value: unknown): value is AgentKind {\n return typeof value === \"string\" && (SUPPORTED_AGENTS as readonly string[]).includes(value);\n}\n\n/**\n * Per-agent supported reasoning efforts. Single source of truth for both the\n * `EffortLevel` type and each registry's `validEfforts` runtime list — the\n * registries import these directly so adding a value in one place\n * propagates to validation, footer rendering, and zod enums.\n *\n * Claude SDK rejects 'minimal'; Codex SDK rejects 'max'. The two sets\n * intersect on low/medium/high/xhigh. Maestro (TS port) currently piggybacks\n * on the Anthropic provider, so its efforts mirror the Claude set; this can\n * narrow per-provider once Phase 5 lands.\n *\n * 'minimal' removed from codex: Codex API rejects it when default tools\n * (image_gen, web_search) are active, making agent sessions unusable.\n */\nexport const CLAUDE_EFFORT_VALUES = [\"low\", \"medium\", \"high\", \"xhigh\", \"max\"] as const;\nexport const CODEX_EFFORT_VALUES = [\"low\", \"medium\", \"high\", \"xhigh\", \"max\"] as const;\nexport const MAESTRO_EFFORT_VALUES = [\"low\", \"medium\", \"high\", \"xhigh\", \"max\"] as const;\n\nexport type EffortLevel =\n | (typeof CLAUDE_EFFORT_VALUES)[number]\n | (typeof CODEX_EFFORT_VALUES)[number]\n | (typeof MAESTRO_EFFORT_VALUES)[number];\n\n/**\n * Runtime iteration list (used by zod enums and any callers that need to\n * loop over every accepted value). Manually ordered for readability; the\n * `satisfies` check fails the build if an entry here isn't covered by the\n * per-agent unions above.\n */\nexport const EFFORT_VALUES = [\n \"low\",\n \"medium\",\n \"high\",\n \"xhigh\",\n \"max\",\n] as const satisfies readonly EffortLevel[];\n\n/**\n * Normalized events yielded by any agent provider (claudeProvider, codexProvider).\n * The handler/event-processor consumes these without caring which backend produced them.\n *\n * `user_message` is the lone \"into-the-log\" variant — no provider yields it.\n * The query handler writes it directly to the conversation log right before\n * `runAgent()` starts, so cross-agent rollout reconstruction can pair every\n * assistant turn with the user prompt that triggered it. Consumers that only\n * react to provider output (e.g. processAgentEvent) can safely ignore it.\n */\n/**\n * Wire-safe projection of one task, carried by the `tasks` UnifiedEvent.\n *\n * This is also the on-disk shape of Otium's shared task store, so claude,\n * codex, and maestro render the same live panel from the same source of truth.\n */\nexport interface TaskSnapshot {\n id: string;\n subject: string;\n status: \"pending\" | \"in_progress\" | \"completed\";\n /** Task ids this one is blocked by; omitted when empty. */\n blockedBy?: string[];\n /** Present-continuous label for spinners, when set. */\n activeForm?: string;\n /** Owner / agent name for multi-agent runs, when set. */\n owner?: string;\n}\n\nexport type UnifiedEvent =\n | { type: \"user_message\"; content: string }\n | { type: \"session\"; sessionId: string }\n | {\n type: \"tool_use\";\n name: string;\n input: Record<string, unknown>;\n /** Provider-assigned id so the client can match tool_use→tool_result pairs. */\n toolUseId?: string;\n }\n | { type: \"tool_progress\"; toolName: string; elapsed: number }\n | { type: \"tool_use_summary\"; summary: string }\n // Provider reasoning/thinking summary text (Codex `reasoning` items; Claude\n // extended-thinking). Surfaced so background runs (cron/archiver) show the\n // agent's thought process, not just tool calls.\n | { type: \"reasoning\"; content: string }\n // Full task-list snapshot (replace, not delta) from Otium's shared task\n // store. Provider-native task/todo stores are not authoritative.\n | { type: \"tasks\"; tasks: TaskSnapshot[] }\n | {\n type: \"tool_result\";\n toolUseId: string;\n content: string;\n metadata?: {\n truncatedForModel: boolean;\n originalBytes: number;\n returnedBytes: number;\n omittedBytes?: number;\n outputPath?: string;\n };\n }\n | { type: \"text_delta\"; content: string }\n | { type: \"text\"; content: string }\n | { type: \"result\"; content: string; stopReason: string; usage?: TokenUsage }\n | { type: \"file\"; path: string; source: string; origin: \"tag\" | \"extension\" }\n | {\n type: \"error\";\n content: string;\n usage?: TokenUsage;\n code?: \"budget_exceeded\";\n }\n | { type: \"status\"; content: string };\n\nexport interface AgentInputAttachment {\n id: string;\n type: \"image\" | \"file\" | \"audio\";\n filename: string;\n mimeType: string;\n sizeBytes: number;\n path: string;\n}\n\n/** Worker-side runtime tools proxy user-facing state back to the canonical\n * hub topic identified here. */\nexport interface PeerRuntimeBridgeContext {\n hubCellId: string;\n hostTopicId: string;\n hostQueryId: string;\n canSpawnSubagents: boolean;\n}\n\nexport interface AgentQueryOptions {\n agent: AgentKind;\n prompt: string;\n attachments?: AgentInputAttachment[];\n sessionId?: string | null;\n cwd: string;\n systemPrompt: string;\n userId?: string;\n session?: string;\n playwrightPort?: number;\n playwrightCapability?: string;\n bgBashPort?: number;\n sessionType?: \"dm\" | \"forum\" | \"ephemeral\" | \"manager\" | \"cron\";\n /** API topic id (REST/WS world). Carries per-query topic context for MCP servers. */\n topicId?: string;\n /** API query id for the currently running turn. Used by runtime MCP tools. */\n queryId?: string;\n /** Optional wiki-memory topic id. Derived topics use their root origin here\n * while other per-topic MCP servers keep `topicId` bound to the live room. */\n wikiTopicId?: string;\n /** Whether self-config MCP may enqueue an automatic continue turn after set_* changes. */\n autoContinue?: boolean;\n /** Expose Otium-only visual panel tools for this turn. Default-deny. */\n visualTools?: boolean;\n /** Expose adapter-backed file-delivery tools for this turn. Default-deny. */\n fileDeliveryTools?: boolean;\n abortController?: AbortController;\n model?: string;\n /** Provider-side hard budget when the selected SDK supports one. */\n maxBudgetUsd?: number;\n depth?: number;\n agents?: Record<\n string,\n {\n description: string;\n prompt: string;\n model?: string;\n tools?: string[];\n maxTurns?: number;\n effort?: EffortLevel | number;\n }\n >;\n effort?: EffortLevel;\n /**\n * Per-API-call `max_tokens` ceiling on the assistant's output. Wired\n * through to the underlying provider request body for every agent\n * (claude/codex/maestro). Omit to inherit each provider SDK's per-model\n * default — for maestro that's the v0.1.21+ `getNativeMaxOutputTokens`\n * catalog (deepseek-pro=64K, deepseek-flash=32K).\n *\n * Pass an explicit number when a specific topic / surface needs a tighter\n * latency cap or a higher ceiling for long-form generation (legal\n * report writing, multi-K Write/Edit file bodies). Pre-0.1.21 maestro\n * builds silently clamped at 4096 and truncated outputs mid-string;\n * setting this field is now the supported way to lift that ceiling.\n */\n maxTokens?: number;\n /**\n * v0.1.22+: Claude-Code-style deferred tool catalog + `ToolSearch` built-in.\n *\n * Wired straight through to `maestro-agent-sdk`'s\n * `AgentQueryOptions.enableToolSearch`. When `true`, the maestro provider\n * registers every MCP tool as deferred — schemas stay off the wire until\n * the model promotes them via `ToolSearch(\"select:Name1,Name2\")` or\n * `ToolSearch(\"keyword\")`. Active set persists across resume.\n *\n * Otium's maestro provider supplies `true` when the caller leaves this\n * option unset, because most forum turns carry enough MCP surface for the\n * reminder-token savings to outweigh the first-use `ToolSearch` round-trip.\n * Callers can still pass `false` per call when a narrow surface or\n * latency-sensitive workflow is better served by eager MCP schemas.\n *\n * No-op for claude / codex agents — they have their own deferred-tool\n * machinery owned by their respective SDKs.\n */\n enableToolSearch?: boolean;\n /**\n * Claude-Code-compatible exact tool denylist. Maestro v0.1.42+ hides these\n * tools from provider schemas / ToolSearch and blocks dispatch if a stale\n * call still arrives. Claude maps this to its SDK option. Codex does not\n * support this name-based list; its provider-native multi-agent tool family\n * is disabled separately through the Codex feature config.\n */\n disallowedTools?: readonly string[];\n mcpEnabled?: string[] | null;\n peerBridge?: PeerRuntimeBridgeContext;\n mcpExtra?: Record<string, unknown>;\n /**\n * true for silent fork runs generating ask_session replies — restricts session-comm\n * outbound tools (ask/tell/abort) so the forked session can only produce text\n */\n silent?: boolean;\n}\n\n/** State file written to data/users/{userId}/active-queries/{topic}.json while a query is running. */\nexport interface QueryState {\n task?: string; // first 100 chars of prompt, newlines normalized\n since: string; // ISO timestamp\n}\n"
|
|
9
9
|
],
|
|
10
|
-
"mappings": ";;AAAA,yBAAS;AACT,oBAAS;;;ACDT;AACA;AACA;AACA;AACA;;;ACJA;AAcO,IAAM,SAAS,KACpB;AAAA,EACE,OAAO,QAAQ,IAAI,aAAa;AAAA,EAChC,WAEM;AAAA,IACE,QAAQ;AAAA,IACR,SAAS;AAAA,MACP,UAAU;AAAA,MACV,eAAe;AAAA,MACf,aAAa;AAAA,IACf;AAAA,EACF;AAER,GACA,KAAK,YAAY,CAAC,CACpB;;;ACFO,IAAM,mBAAyC,CAAC,WAAW,UAAU,OAAO;AAE5E,SAAS,WAAW,CAAC,OAAoC;AAAA,EAC9D,OAAO,OAAO,UAAU,YAAa,iBAAuC,SAAS,KAAK;AAAA;;;AFvBrF,SAAS,OAAO,CAAC,QAAoC;AAAA,EAC1D,MAAM,QAAQ,QAAQ,IAAI,SAAS,KAAK;AAAA,EACxC,OAAO,QAAQ,QAAQ;AAAA;AAGzB,SAAS,eAAe,CAAC,QAAgB,UAAqB,cAAkC;AAAA,EAC9F,MAAM,QAAQ,QAAQ,MAAM,MAAM,eAAe,QAAQ,YAAY,IAAI;AAAA,EACzE,OAAO,YAAY,KAAK,IAAI,QAAQ;AAAA;AAGtC,IAAM,OAAO,QAAQ;AAIrB,SAAS,kBAAkB,GAAW;AAAA,EACpC,MAAM,YAAY,QAAQ,cAAc,YAAY,GAAG,CAAC;AAAA,EACxD,MAAM,kBAAkB,QAAQ,WAAW,SAAS;AAAA,EACpD,IAAI,WAAW,QAAQ,iBAAiB,KAAK,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KACJ,IACA,uLACF;AAAA,EACF;AAAA,EACA,OAAO,MAAM,KAAK;AAAA,CAAI;AAAA;",
|
|
11
|
+
"debugId": "FF0F14433789211564756E2164756E21",
|
|
12
12
|
"names": []
|
|
13
13
|
}
|
|
@@ -12,6 +12,8 @@ export interface SubmitUserMessageParams {
|
|
|
12
12
|
allowAutoContinue?: boolean;
|
|
13
13
|
/** Adapter capability: only Otium should enable visual panel tools. */
|
|
14
14
|
visualTools?: boolean;
|
|
15
|
+
/** Adapter capability: Otium and Telegram may enable file delivery. */
|
|
16
|
+
fileDeliveryTools?: boolean;
|
|
15
17
|
onDispatched?: (queryId: string) => void;
|
|
16
18
|
/** Override used by remote hosts and deterministic tests. */
|
|
17
19
|
startTurn?: (params: StartAiTurnParams) => string | null;
|
|
@@ -44,6 +46,7 @@ export function submitUserMessage(params: SubmitUserMessageParams): SubmitUserMe
|
|
|
44
46
|
prompt: params.text,
|
|
45
47
|
allowAutoContinue: params.allowAutoContinue ?? true,
|
|
46
48
|
visualTools: params.visualTools === true,
|
|
49
|
+
fileDeliveryTools: params.fileDeliveryTools === true,
|
|
47
50
|
onDispatched: params.onDispatched,
|
|
48
51
|
});
|
|
49
52
|
return { message, queryId };
|
|
@@ -206,9 +206,16 @@ export {
|
|
|
206
206
|
listBackgroundSessionsForUser,
|
|
207
207
|
registerBackgroundSessionProvider,
|
|
208
208
|
} from "#runtime/background-sessions";
|
|
209
|
+
export type { DeliveryAckResult } from "#runtime/delivery-ack";
|
|
210
|
+
export {
|
|
211
|
+
claimDeliveryAck,
|
|
212
|
+
prepareDeliveryAck,
|
|
213
|
+
resolveDeliveryAck,
|
|
214
|
+
} from "#runtime/delivery-ack";
|
|
209
215
|
export type { FileHooks, UploadAccess } from "#runtime/file-hooks";
|
|
210
216
|
export {
|
|
211
217
|
fileHooks,
|
|
218
|
+
resetFileHooks,
|
|
212
219
|
resolveAttachmentByFileId,
|
|
213
220
|
resolveUploadedFilePathByFileId,
|
|
214
221
|
setFileHooks,
|
|
@@ -30,6 +30,8 @@ export interface RuntimeMcpContext {
|
|
|
30
30
|
autoContinue?: boolean;
|
|
31
31
|
/** Capability minted by the adapter. Visual tools are absent unless true. */
|
|
32
32
|
visualTools?: boolean;
|
|
33
|
+
/** Capability minted by the adapter. File-delivery tools are absent unless true. */
|
|
34
|
+
fileDeliveryTools?: boolean;
|
|
33
35
|
peerBridge?: PeerRuntimeBridgeContext;
|
|
34
36
|
}
|
|
35
37
|
|
|
@@ -83,6 +85,7 @@ function isRuntimeMcpContext(value: unknown): value is RuntimeMcpContext {
|
|
|
83
85
|
(ctx.currentUserPrompt === undefined || typeof ctx.currentUserPrompt === "string") &&
|
|
84
86
|
(ctx.autoContinue === undefined || typeof ctx.autoContinue === "boolean") &&
|
|
85
87
|
(ctx.visualTools === undefined || typeof ctx.visualTools === "boolean") &&
|
|
88
|
+
(ctx.fileDeliveryTools === undefined || typeof ctx.fileDeliveryTools === "boolean") &&
|
|
86
89
|
(ctx.peerBridge === undefined ||
|
|
87
90
|
(typeof ctx.peerBridge.hubCellId === "string" &&
|
|
88
91
|
typeof ctx.peerBridge.hostTopicId === "string" &&
|
|
@@ -566,7 +566,7 @@ if (!isReplyOnly) {
|
|
|
566
566
|
|
|
567
567
|
if (currentDepth + 1 > MAX_TELL_DEPTH) {
|
|
568
568
|
return mcpError(
|
|
569
|
-
`Error: depth
|
|
569
|
+
`Error: depth limit reached (current ${currentDepth}, max ${MAX_TELL_DEPTH}). Cannot build any more tell_session chains.`,
|
|
570
570
|
);
|
|
571
571
|
}
|
|
572
572
|
|
|
@@ -186,6 +186,7 @@ export interface RuntimeMcpBuildContext {
|
|
|
186
186
|
bgBashPort?: number;
|
|
187
187
|
autoContinue?: boolean;
|
|
188
188
|
visualTools?: boolean;
|
|
189
|
+
fileDeliveryTools?: boolean;
|
|
189
190
|
silent?: boolean;
|
|
190
191
|
peerBridge?: PeerRuntimeBridgeContext;
|
|
191
192
|
}
|
|
@@ -298,6 +299,7 @@ const MCP_CATALOG: Record<string, RuntimeMcpCatalogEntry> = {
|
|
|
298
299
|
currentUserPrompt,
|
|
299
300
|
autoContinue,
|
|
300
301
|
visualTools,
|
|
302
|
+
fileDeliveryTools,
|
|
301
303
|
peerBridge,
|
|
302
304
|
}) {
|
|
303
305
|
if (!topicId || !agent) return null;
|
|
@@ -312,6 +314,7 @@ const MCP_CATALOG: Record<string, RuntimeMcpCatalogEntry> = {
|
|
|
312
314
|
currentUserPrompt,
|
|
313
315
|
autoContinue,
|
|
314
316
|
visualTools,
|
|
317
|
+
fileDeliveryTools,
|
|
315
318
|
peerBridge,
|
|
316
319
|
});
|
|
317
320
|
},
|
|
@@ -663,6 +666,7 @@ export function getManagerMcpServers(opts: {
|
|
|
663
666
|
playwrightCapability?: string;
|
|
664
667
|
autoContinue?: boolean;
|
|
665
668
|
visualTools?: boolean;
|
|
669
|
+
fileDeliveryTools?: boolean;
|
|
666
670
|
}) {
|
|
667
671
|
if (!opts.topicId) {
|
|
668
672
|
throw new Error("getManagerMcpServers: private General topicId is required");
|
|
@@ -682,6 +686,7 @@ export function getManagerMcpServers(opts: {
|
|
|
682
686
|
playwrightCapability: opts.playwrightCapability,
|
|
683
687
|
autoContinue: opts.autoContinue,
|
|
684
688
|
visualTools: opts.visualTools,
|
|
689
|
+
fileDeliveryTools: opts.fileDeliveryTools,
|
|
685
690
|
});
|
|
686
691
|
}
|
|
687
692
|
|
|
@@ -706,6 +711,7 @@ export function getForumMcpServers(opts: {
|
|
|
706
711
|
bgBashPort?: number;
|
|
707
712
|
autoContinue?: boolean;
|
|
708
713
|
visualTools?: boolean;
|
|
714
|
+
fileDeliveryTools?: boolean;
|
|
709
715
|
depth?: number;
|
|
710
716
|
enabled?: string[] | null;
|
|
711
717
|
extra?: Record<string, unknown>;
|
|
@@ -731,6 +737,7 @@ export function getForumMcpServers(opts: {
|
|
|
731
737
|
bgBashPort,
|
|
732
738
|
autoContinue,
|
|
733
739
|
visualTools,
|
|
740
|
+
fileDeliveryTools,
|
|
734
741
|
peerBridge,
|
|
735
742
|
} = opts;
|
|
736
743
|
|
|
@@ -760,6 +767,7 @@ export function getForumMcpServers(opts: {
|
|
|
760
767
|
bgBashPort,
|
|
761
768
|
autoContinue,
|
|
762
769
|
visualTools,
|
|
770
|
+
fileDeliveryTools,
|
|
763
771
|
silent,
|
|
764
772
|
peerBridge,
|
|
765
773
|
},
|
|
@@ -787,6 +795,7 @@ export function getCronMcpServers(opts: {
|
|
|
787
795
|
playwrightPort?: number;
|
|
788
796
|
playwrightCapability?: string;
|
|
789
797
|
visualTools?: boolean;
|
|
798
|
+
fileDeliveryTools?: boolean;
|
|
790
799
|
}) {
|
|
791
800
|
return buildScope("cron", {
|
|
792
801
|
userId: opts.userId,
|
|
@@ -802,6 +811,7 @@ export function getCronMcpServers(opts: {
|
|
|
802
811
|
playwrightCapability: opts.playwrightCapability,
|
|
803
812
|
autoContinue: false,
|
|
804
813
|
visualTools: opts.visualTools,
|
|
814
|
+
fileDeliveryTools: opts.fileDeliveryTools,
|
|
805
815
|
});
|
|
806
816
|
}
|
|
807
817
|
|
|
@@ -827,6 +837,7 @@ export function getMcpServersForQuery(opts: AgentQueryOptions): Record<string, u
|
|
|
827
837
|
playwrightPort: opts.playwrightPort,
|
|
828
838
|
playwrightCapability: opts.playwrightCapability,
|
|
829
839
|
visualTools: opts.visualTools,
|
|
840
|
+
fileDeliveryTools: opts.fileDeliveryTools,
|
|
830
841
|
});
|
|
831
842
|
}
|
|
832
843
|
if (opts.sessionType === "dm" || opts.sessionType === "ephemeral") {
|
|
@@ -852,6 +863,7 @@ export function getMcpServersForQuery(opts: AgentQueryOptions): Record<string, u
|
|
|
852
863
|
playwrightCapability: opts.playwrightCapability,
|
|
853
864
|
autoContinue: opts.autoContinue,
|
|
854
865
|
visualTools: opts.visualTools,
|
|
866
|
+
fileDeliveryTools: opts.fileDeliveryTools,
|
|
855
867
|
});
|
|
856
868
|
}
|
|
857
869
|
return getForumMcpServers({
|
|
@@ -869,6 +881,7 @@ export function getMcpServersForQuery(opts: AgentQueryOptions): Record<string, u
|
|
|
869
881
|
bgBashPort: opts.bgBashPort,
|
|
870
882
|
autoContinue: opts.autoContinue,
|
|
871
883
|
visualTools: opts.visualTools,
|
|
884
|
+
fileDeliveryTools: opts.fileDeliveryTools,
|
|
872
885
|
depth: opts.depth,
|
|
873
886
|
enabled: opts.mcpEnabled,
|
|
874
887
|
extra: opts.mcpExtra,
|
|
@@ -156,12 +156,15 @@ export interface SessionSystemPromptOpts {
|
|
|
156
156
|
canSpawnSubagents?: boolean;
|
|
157
157
|
/** True only when the current adapter renders Otium visual cards. */
|
|
158
158
|
visualTools?: boolean;
|
|
159
|
+
/** True only when the current adapter can deliver files to its chat. */
|
|
160
|
+
fileDeliveryTools?: boolean;
|
|
159
161
|
}
|
|
160
162
|
|
|
161
163
|
function buildRuntimeToolSection(
|
|
162
164
|
agentKind: AgentKind,
|
|
163
165
|
canSpawnSubagents = false,
|
|
164
166
|
visualTools = false,
|
|
167
|
+
fileDeliveryTools = false,
|
|
165
168
|
): string {
|
|
166
169
|
const runtimeNamespace = "mcp__runtime";
|
|
167
170
|
const taskNamespace = "mcp__task";
|
|
@@ -222,6 +225,14 @@ function buildRuntimeToolSection(
|
|
|
222
225
|
"Visual HTML runs in a sandbox. Use inline CSS/JS only; local buttons, tabs, filters, forms with preventDefault, canvas, and SVG interactions are supported. External navigation, scripts, network fetches, form posts, popups, and parent-window access are blocked.",
|
|
223
226
|
]
|
|
224
227
|
: [];
|
|
228
|
+
const fileDeliverySection = fileDeliveryTools
|
|
229
|
+
? [
|
|
230
|
+
"",
|
|
231
|
+
"## File Delivery",
|
|
232
|
+
`To send a file to the user, save it under your working directory and call the ${sendFileTool} with { file_path: "<absolute path>" }.`,
|
|
233
|
+
"It appears as a downloadable attachment in the chat and returns success. Never claim file delivery is unavailable after a successful call.",
|
|
234
|
+
]
|
|
235
|
+
: [];
|
|
225
236
|
|
|
226
237
|
const shared = [
|
|
227
238
|
"",
|
|
@@ -237,10 +248,7 @@ function buildRuntimeToolSection(
|
|
|
237
248
|
taskToolLine,
|
|
238
249
|
"Use this shared task store for plans, task progress, and checklist updates. It is visible across claude/codex/maestro turns and drives the live task panel.",
|
|
239
250
|
nativeTaskPolicyLine,
|
|
240
|
-
|
|
241
|
-
"## File Delivery",
|
|
242
|
-
`To send a file to the user, save it under your working directory and call the ${sendFileTool} with { file_path: "<absolute path>" }.`,
|
|
243
|
-
"It appears as a downloadable attachment in the chat and returns success. Never claim file delivery is unavailable after a successful call.",
|
|
251
|
+
...fileDeliverySection,
|
|
244
252
|
"",
|
|
245
253
|
"## Session Communication",
|
|
246
254
|
"The session-comm MCP server is the only cross-topic messaging surface. Its canonical tools are `list_sessions`, `peek_session`, `tell_session`, `ask_session`, and `abort_session`.",
|
|
@@ -292,7 +300,13 @@ export function buildTopicSystemPrompt(opts: SessionSystemPromptOpts): string {
|
|
|
292
300
|
TOPIC_TITLE: opts.topicTitle,
|
|
293
301
|
WORKSPACE_CWD: opts.workspaceCwd,
|
|
294
302
|
UPLOADS_DIR: uploadsDir,
|
|
295
|
-
}) +
|
|
303
|
+
}) +
|
|
304
|
+
buildRuntimeToolSection(
|
|
305
|
+
opts.agentKind,
|
|
306
|
+
opts.canSpawnSubagents,
|
|
307
|
+
opts.visualTools,
|
|
308
|
+
opts.fileDeliveryTools,
|
|
309
|
+
);
|
|
296
310
|
if (opts.description?.trim()) {
|
|
297
311
|
prompt += `\n\n## Topic-Specific Instructions\n${opts.description.trim()}`;
|
|
298
312
|
}
|
|
@@ -307,7 +321,7 @@ export function buildChannelSystemPrompt(opts: SessionSystemPromptOpts): string
|
|
|
307
321
|
TOPIC_TITLE: opts.topicTitle,
|
|
308
322
|
WORKSPACE_CWD: opts.workspaceCwd,
|
|
309
323
|
UPLOADS_DIR: uploadsDir,
|
|
310
|
-
}) + buildRuntimeToolSection(opts.agentKind, false, opts.visualTools)
|
|
324
|
+
}) + buildRuntimeToolSection(opts.agentKind, false, opts.visualTools, opts.fileDeliveryTools)
|
|
311
325
|
);
|
|
312
326
|
}
|
|
313
327
|
|
|
@@ -73,6 +73,8 @@ export interface DeferredInject {
|
|
|
73
73
|
sessionType?: "dm" | "forum" | "ephemeral" | "manager" | "cron";
|
|
74
74
|
/** Adapter-granted access to Otium's visual panel tools. */
|
|
75
75
|
visualTools?: boolean;
|
|
76
|
+
/** Adapter-granted access to chat file-delivery tools. */
|
|
77
|
+
fileDeliveryTools?: boolean;
|
|
76
78
|
/** Optional session owner; when present the topic's main session is not replaced. */
|
|
77
79
|
onSessionId?: (sessionId: string) => void;
|
|
78
80
|
/** Clear an externally-owned session after an unrecoverable expiry. */
|