@otium-team/negotium 0.0.0-stage → 0.23.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +329 -2
- package/bin/codex-sdk-window-hide.mjs +40 -0
- package/bin/negotium.mjs +22 -0
- package/dist/agent-helpers.js +23090 -0
- package/dist/agent-helpers.js.map +171 -0
- package/dist/background-bash.js +535 -0
- package/dist/background-bash.js.map +16 -0
- package/dist/browser-runtime.js +2334 -0
- package/dist/browser-runtime.js.map +35 -0
- package/dist/canonical-mcp-bridge.js +13 -0
- package/dist/canonical-mcp-bridge.js.map +9 -0
- package/dist/chunk-22kg3fsw.js +79 -0
- package/dist/chunk-22kg3fsw.js.map +9 -0
- package/dist/chunk-d4j77adx.js +336 -0
- package/dist/chunk-d4j77adx.js.map +13 -0
- package/dist/chunk-mk9x18jn.js +172 -0
- package/dist/chunk-mk9x18jn.js.map +12 -0
- package/dist/chunk-qd0vtfm2.js +3923 -0
- package/dist/chunk-qd0vtfm2.js.map +47 -0
- package/dist/chunk-wf7ny8eq.js +206 -0
- package/dist/chunk-wf7ny8eq.js.map +10 -0
- package/dist/chunk-ww8a4ej4.js +54 -0
- package/dist/chunk-ww8a4ej4.js.map +10 -0
- package/dist/cron.js +1 -0
- package/dist/hosted-agent.js +5982 -0
- package/dist/hosted-agent.js.map +62 -0
- package/dist/main.js +60229 -0
- package/dist/main.js.map +340 -0
- package/dist/mcp-catalog.js +39 -0
- package/dist/mcp-catalog.js.map +10 -0
- package/dist/mcp-factories.js +25767 -0
- package/dist/mcp-factories.js.map +181 -0
- package/dist/mcp-servers.js +50 -0
- package/dist/mcp-servers.js.map +10 -0
- package/dist/media.js +570 -0
- package/dist/media.js.map +15 -0
- package/dist/outbox.js +354 -0
- package/dist/outbox.js.map +15 -0
- package/dist/platform-runtime.js +73 -0
- package/dist/platform-runtime.js.map +12 -0
- package/dist/prompts.js +892 -0
- package/dist/prompts.js.map +15 -0
- package/dist/query-runtime.js +1071 -0
- package/dist/query-runtime.js.map +26 -0
- package/dist/registry.js +335 -0
- package/dist/registry.js.map +14 -0
- package/dist/rollout.js +57 -0
- package/dist/rollout.js.map +10 -0
- package/dist/runtime/cron/background-sessions.ts +119 -0
- package/dist/runtime/cron/context.ts +123 -0
- package/dist/runtime/cron/host.ts +67 -0
- package/dist/runtime/cron/index.ts +95 -0
- package/dist/runtime/cron/mcp-server.ts +556 -0
- package/dist/runtime/cron/module.ts +174 -0
- package/dist/runtime/cron/package.json +6 -0
- package/dist/runtime/cron/schedule.ts +211 -0
- package/dist/runtime/cron/scheduler.ts +444 -0
- package/dist/runtime/cron/scripts.ts +203 -0
- package/dist/runtime/cron/store.ts +1163 -0
- package/dist/runtime/cron/summarize.ts +115 -0
- package/dist/runtime/package.json +6 -0
- package/dist/runtime/scripts/faster-whisper-wrapper.py +87 -0
- package/dist/runtime/src/agents/api-topic-agent-switch.ts +179 -0
- package/dist/runtime/src/agents/archiver.ts +677 -0
- package/dist/runtime/src/agents/auth-check.ts +156 -0
- package/dist/runtime/src/agents/claude-notices.ts +130 -0
- package/dist/runtime/src/agents/claude-provider.ts +941 -0
- package/dist/runtime/src/agents/claude-registry.ts +117 -0
- package/dist/runtime/src/agents/claude-runtime-inspection.ts +43 -0
- package/dist/runtime/src/agents/codex-app-server.ts +138 -0
- package/dist/runtime/src/agents/codex-native-multi-agent.ts +360 -0
- package/dist/runtime/src/agents/codex-provider.ts +1193 -0
- package/dist/runtime/src/agents/codex-registry.ts +116 -0
- package/dist/runtime/src/agents/codex-tier-resolver.ts +74 -0
- package/dist/runtime/src/agents/codex-tree-kill.ts +54 -0
- package/dist/runtime/src/agents/codex-tree-manager.ts +230 -0
- package/dist/runtime/src/agents/codex-vault-hook-bridge.ts +240 -0
- package/dist/runtime/src/agents/codex-vault-hook.mjs +50 -0
- package/dist/runtime/src/agents/codex-windows-wrapper.ts +174 -0
- package/dist/runtime/src/agents/compaction-support.ts +75 -0
- package/dist/runtime/src/agents/compaction-tool-projection.ts +125 -0
- package/dist/runtime/src/agents/contracts.ts +75 -0
- package/dist/runtime/src/agents/deep-map.ts +13 -0
- package/dist/runtime/src/agents/execution-host.ts +118 -0
- package/dist/runtime/src/agents/explicit-agent-switch.ts +106 -0
- package/dist/runtime/src/agents/fixtures/claude-attachments.jsonl +2 -0
- package/dist/runtime/src/agents/fixtures/codex-shell.jsonl +5 -0
- package/dist/runtime/src/agents/fork.ts +100 -0
- package/dist/runtime/src/agents/hosted-agent.ts +78 -0
- package/dist/runtime/src/agents/idle-archiver.ts +225 -0
- package/dist/runtime/src/agents/idle-compact.ts +225 -0
- package/dist/runtime/src/agents/index.ts +225 -0
- package/dist/runtime/src/agents/maestro-provider.ts +246 -0
- package/dist/runtime/src/agents/maestro-registry.ts +189 -0
- package/dist/runtime/src/agents/mcp-tools/ask-user.ts +653 -0
- package/dist/runtime/src/agents/mcp-tools/common.ts +23 -0
- package/dist/runtime/src/agents/mcp-tools/inline-assets.ts +203 -0
- package/dist/runtime/src/agents/mcp-tools/publish-html.ts +183 -0
- package/dist/runtime/src/agents/mcp-tools/request-vault.ts +684 -0
- package/dist/runtime/src/agents/mcp-tools/self-config.ts +353 -0
- package/dist/runtime/src/agents/mcp-tools/spawn-subagent.ts +1349 -0
- package/dist/runtime/src/agents/mcp-tools/visual-compat.ts +18 -0
- package/dist/runtime/src/agents/mcp-tools/visuals.ts +60 -0
- package/dist/runtime/src/agents/memory-archive-policy.ts +54 -0
- package/dist/runtime/src/agents/model-catalog.ts +439 -0
- package/dist/runtime/src/agents/public-helpers.ts +149 -0
- package/dist/runtime/src/agents/registry.ts +35 -0
- package/dist/runtime/src/agents/rollout/claude.ts +336 -0
- package/dist/runtime/src/agents/rollout/codex.ts +910 -0
- package/dist/runtime/src/agents/rollout/index.ts +26 -0
- package/dist/runtime/src/agents/rollout/shared.ts +293 -0
- package/dist/runtime/src/agents/self-config-core.ts +704 -0
- package/dist/runtime/src/agents/task-events.ts +59 -0
- package/dist/runtime/src/agents/tool-format.ts +613 -0
- package/dist/runtime/src/agents/topic-agent-switch.ts +189 -0
- package/dist/runtime/src/agents/topic-cleanup.ts +285 -0
- package/dist/runtime/src/agents/vault-tool-policy.ts +36 -0
- package/dist/runtime/src/application/execute-external-user-turn.ts +23 -0
- package/dist/runtime/src/application/submit-runtime-gateway-turn.ts +484 -0
- package/dist/runtime/src/application/submit-user-message.ts +60 -0
- package/dist/runtime/src/application/switch-topic-effort.ts +48 -0
- package/dist/runtime/src/application/switch-topic-model.ts +79 -0
- package/dist/runtime/src/application/topic-service.ts +190 -0
- package/dist/runtime/src/application/turn-follow-ups.ts +291 -0
- package/dist/runtime/src/application/vault-command.ts +170 -0
- package/dist/runtime/src/bus.ts +409 -0
- package/dist/runtime/src/config-public.ts +2 -0
- package/dist/runtime/src/cron-host.ts +33 -0
- package/dist/runtime/src/cron-mcp-host.ts +5 -0
- package/dist/runtime/src/identifiers.ts +49 -0
- package/dist/runtime/src/index.ts +573 -0
- package/dist/runtime/src/mcp/agent-health-server.ts +8 -0
- package/dist/runtime/src/mcp/canonical-bridge-config.ts +84 -0
- package/dist/runtime/src/mcp/canonical-proxy-server.ts +308 -0
- package/dist/runtime/src/mcp/compaction-log-server.ts +25 -0
- package/dist/runtime/src/mcp/decision-server.ts +21 -0
- package/dist/runtime/src/mcp/dm-ipc.ts +60 -0
- package/dist/runtime/src/mcp/factories/agent-health.ts +394 -0
- package/dist/runtime/src/mcp/factories/compaction-log.ts +135 -0
- package/dist/runtime/src/mcp/factories/decision.ts +186 -0
- package/dist/runtime/src/mcp/factories/index.ts +73 -0
- package/dist/runtime/src/mcp/factories/session-comm.ts +184 -0
- package/dist/runtime/src/mcp/factories/session-history.ts +103 -0
- package/dist/runtime/src/mcp/factories/stdio-protection.ts +24 -0
- package/dist/runtime/src/mcp/factories/system-health.ts +259 -0
- package/dist/runtime/src/mcp/factories/task.ts +185 -0
- package/dist/runtime/src/mcp/factories/token-stats.ts +145 -0
- package/dist/runtime/src/mcp/factories/vault.ts +32 -0
- package/dist/runtime/src/mcp/mcp-helpers.ts +40 -0
- package/dist/runtime/src/mcp/peer-bridge.ts +119 -0
- package/dist/runtime/src/mcp/runtime-spec.ts +473 -0
- package/dist/runtime/src/mcp/session-comm/actor-policy.ts +160 -0
- package/dist/runtime/src/mcp/session-comm/bridge-ipc-config.ts +27 -0
- package/dist/runtime/src/mcp/session-comm/context.ts +113 -0
- package/dist/runtime/src/mcp/session-comm/default-host.ts +723 -0
- package/dist/runtime/src/mcp/session-comm/history-target.ts +89 -0
- package/dist/runtime/src/mcp/session-comm/history-tools.ts +113 -0
- package/dist/runtime/src/mcp/session-comm/hub-remote-session.ts +553 -0
- package/dist/runtime/src/mcp/session-comm/limits.ts +8 -0
- package/dist/runtime/src/mcp/session-comm/peer-forward.ts +251 -0
- package/dist/runtime/src/mcp/session-comm/runtime.ts +128 -0
- package/dist/runtime/src/mcp/session-comm/server.ts +1036 -0
- package/dist/runtime/src/mcp/session-comm/tell-permissions.ts +79 -0
- package/dist/runtime/src/mcp/session-comm/topic-catalog.ts +155 -0
- package/dist/runtime/src/mcp/session-comm/topic-config.ts +137 -0
- package/dist/runtime/src/mcp/session-comm/topics.ts +313 -0
- package/dist/runtime/src/mcp/session-history-limits.ts +36 -0
- package/dist/runtime/src/mcp/session-history-reader.ts +359 -0
- package/dist/runtime/src/mcp/session-history-server.ts +19 -0
- package/dist/runtime/src/mcp/stdio-protect.ts +7 -0
- package/dist/runtime/src/mcp/system-health-server.ts +5 -0
- package/dist/runtime/src/mcp/task-server.ts +17 -0
- package/dist/runtime/src/mcp/token-stats-server.ts +10 -0
- package/dist/runtime/src/mcp/vault-server.ts +12 -0
- package/dist/runtime/src/mcp/wiki-search-index.ts +359 -0
- package/dist/runtime/src/mcp/wiki-server.ts +2386 -0
- package/dist/runtime/src/mcp-runtime-host.ts +81 -0
- package/dist/runtime/src/media/file-events.ts +33 -0
- package/dist/runtime/src/media/text-extractor.ts +334 -0
- package/dist/runtime/src/media/video.ts +92 -0
- package/dist/runtime/src/node-host.ts +211 -0
- package/dist/runtime/src/outbox/coalescing-runner.ts +157 -0
- package/dist/runtime/src/outbox/file-ops.ts +267 -0
- package/dist/runtime/src/outbox/index.ts +26 -0
- package/dist/runtime/src/outbox/utils.ts +74 -0
- package/dist/runtime/src/platform/background-bash/context.ts +9 -0
- package/dist/runtime/src/platform/background-bash/manager.ts +292 -0
- package/dist/runtime/src/platform/background-bash/output-buffer.ts +323 -0
- package/dist/runtime/src/platform/config-helpers.ts +47 -0
- package/dist/runtime/src/platform/config.ts +618 -0
- package/dist/runtime/src/platform/constants.ts +30 -0
- package/dist/runtime/src/platform/debug-users.ts +14 -0
- package/dist/runtime/src/platform/delay.ts +1 -0
- package/dist/runtime/src/platform/error.ts +9 -0
- package/dist/runtime/src/platform/file-utils.ts +35 -0
- package/dist/runtime/src/platform/ipc.ts +55 -0
- package/dist/runtime/src/platform/jsonl.ts +277 -0
- package/dist/runtime/src/platform/lifecycle.ts +176 -0
- package/dist/runtime/src/platform/log-rotation.ts +45 -0
- package/dist/runtime/src/platform/logger.ts +42 -0
- package/dist/runtime/src/platform/maestro-bootstrap-env.ts +3 -0
- package/dist/runtime/src/platform/mcp-catalog-policy.ts +63 -0
- package/dist/runtime/src/platform/mcp-config.ts +1329 -0
- package/dist/runtime/src/platform/memoize-import.ts +26 -0
- package/dist/runtime/src/platform/modules.ts +145 -0
- package/dist/runtime/src/platform/node-plugins.ts +46 -0
- package/dist/runtime/src/platform/paths.ts +62 -0
- package/dist/runtime/src/platform/playwright/browser-processes.ts +300 -0
- package/dist/runtime/src/platform/playwright/capability.ts +5 -0
- package/dist/runtime/src/platform/playwright/headed-launch.ts +61 -0
- package/dist/runtime/src/platform/playwright/manager-utils.ts +128 -0
- package/dist/runtime/src/platform/playwright/manager.ts +1502 -0
- package/dist/runtime/src/platform/playwright/mcp-transport.ts +35 -0
- package/dist/runtime/src/platform/playwright/profile-management.ts +33 -0
- package/dist/runtime/src/platform/playwright/public-runtime.ts +52 -0
- package/dist/runtime/src/platform/playwright/transport-probe.ts +89 -0
- package/dist/runtime/src/platform/playwright/vault-broker.ts +261 -0
- package/dist/runtime/src/platform/public-runtime.ts +18 -0
- package/dist/runtime/src/prompts/agents/wiki-archiver.md +194 -0
- package/dist/runtime/src/prompts/builders.ts +696 -0
- package/dist/runtime/src/prompts/sessions/_shared-tools.md +38 -0
- package/dist/runtime/src/prompts/sessions/channel-system.md +13 -0
- package/dist/runtime/src/prompts/sessions/manager-system.md +34 -0
- package/dist/runtime/src/prompts/sessions/surfaces/cli.md +6 -0
- package/dist/runtime/src/prompts/sessions/surfaces/otium-manager.md +18 -0
- package/dist/runtime/src/prompts/sessions/surfaces/otium.md +6 -0
- package/dist/runtime/src/prompts/sessions/surfaces/telegram.md +5 -0
- package/dist/runtime/src/prompts/sessions/surfaces/terminal.md +6 -0
- package/dist/runtime/src/prompts/sessions/topic-system.md +9 -0
- package/dist/runtime/src/prompts/sessions/visual-design.md +38 -0
- package/dist/runtime/src/query/active-rooms.ts +514 -0
- package/dist/runtime/src/query/index.ts +23 -0
- package/dist/runtime/src/query/public-runtime.ts +28 -0
- package/dist/runtime/src/query/room-query-registry.ts +217 -0
- package/dist/runtime/src/query/session-inbox-cleanup.ts +45 -0
- package/dist/runtime/src/query/session-inbox-path.ts +42 -0
- package/dist/runtime/src/query/state.ts +116 -0
- package/dist/runtime/src/query/types.ts +8 -0
- package/dist/runtime/src/runtime/actor-topic-reach.ts +123 -0
- package/dist/runtime/src/runtime/actor-topic-scope.ts +255 -0
- package/dist/runtime/src/runtime/ask-callbacks.ts +217 -0
- package/dist/runtime/src/runtime/attachments.ts +149 -0
- package/dist/runtime/src/runtime/background-session-policy.ts +1 -0
- package/dist/runtime/src/runtime/background-sessions.ts +288 -0
- package/dist/runtime/src/runtime/bashrs-completions.ts +350 -0
- package/dist/runtime/src/runtime/channel-context.ts +115 -0
- package/dist/runtime/src/runtime/context-warning.ts +131 -0
- package/dist/runtime/src/runtime/cron-sessions.ts +35 -0
- package/dist/runtime/src/runtime/delivery-ack.ts +112 -0
- package/dist/runtime/src/runtime/errors.ts +70 -0
- package/dist/runtime/src/runtime/event-heartbeat.ts +77 -0
- package/dist/runtime/src/runtime/file-hooks.ts +81 -0
- package/dist/runtime/src/runtime/footer.ts +23 -0
- package/dist/runtime/src/runtime/gateway-capabilities.ts +22 -0
- package/dist/runtime/src/runtime/inbox.ts +1307 -0
- package/dist/runtime/src/runtime/playwright-turn-abort.ts +59 -0
- package/dist/runtime/src/runtime/public-helpers.ts +78 -0
- package/dist/runtime/src/runtime/remote-session-grant.ts +221 -0
- package/dist/runtime/src/runtime/remote-session-inbox.ts +943 -0
- package/dist/runtime/src/runtime/remote-session-reply-outbox.ts +168 -0
- package/dist/runtime/src/runtime/task-format.ts +18 -0
- package/dist/runtime/src/runtime/tasks.ts +53 -0
- package/dist/runtime/src/runtime/thread-context.ts +123 -0
- package/dist/runtime/src/runtime/thread-read.ts +67 -0
- package/dist/runtime/src/runtime/topic-config.ts +29 -0
- package/dist/runtime/src/runtime/turn-event-stream.ts +1051 -0
- package/dist/runtime/src/runtime/turn-runner.ts +2311 -0
- package/dist/runtime/src/runtime/turn-session.ts +116 -0
- package/dist/runtime/src/runtime/usage-alert.ts +51 -0
- package/dist/runtime/src/runtime/user-turn-envelope.ts +94 -0
- package/dist/runtime/src/runtime/visual-html.ts +175 -0
- package/dist/runtime/src/runtime/visual-store.ts +480 -0
- package/dist/runtime/src/runtime/visuals.ts +209 -0
- package/dist/runtime/src/runtime-gateway.ts +1045 -0
- package/dist/runtime/src/security/sanitize.ts +27 -0
- package/dist/runtime/src/security/sensitive-path.ts +41 -0
- package/dist/runtime/src/storage/activity-log.ts +167 -0
- package/dist/runtime/src/storage/api-messages.ts +766 -0
- package/dist/runtime/src/storage/api-topic-brief.ts +134 -0
- package/dist/runtime/src/storage/api-topic-config.ts +197 -0
- package/dist/runtime/src/storage/api-topics.ts +1647 -0
- package/dist/runtime/src/storage/app-settings.ts +50 -0
- package/dist/runtime/src/storage/ask-user-gates.ts +359 -0
- package/dist/runtime/src/storage/browser-profiles.ts +186 -0
- package/dist/runtime/src/storage/conversation-migration.ts +180 -0
- package/dist/runtime/src/storage/conversations.ts +377 -0
- package/dist/runtime/src/storage/decisions.ts +231 -0
- package/dist/runtime/src/storage/forum/agent-settings.ts +20 -0
- package/dist/runtime/src/storage/forum/index.ts +4 -0
- package/dist/runtime/src/storage/forum/repository.ts +283 -0
- package/dist/runtime/src/storage/forum/schema.ts +314 -0
- package/dist/runtime/src/storage/forum-db.ts +4 -0
- package/dist/runtime/src/storage/remote-session.ts +1028 -0
- package/dist/runtime/src/storage/runtime-events.ts +209 -0
- package/dist/runtime/src/storage/runtime-follow-ups.ts +212 -0
- package/dist/runtime/src/storage/runtime-gateway-submissions.ts +132 -0
- package/dist/runtime/src/storage/runtime-leases.ts +190 -0
- package/dist/runtime/src/storage/runtime-process-leases.ts +288 -0
- package/dist/runtime/src/storage/runtime-topic-state.ts +181 -0
- package/dist/runtime/src/storage/runtime-turn-requests.ts +846 -0
- package/dist/runtime/src/storage/self-schedules.ts +306 -0
- package/dist/runtime/src/storage/session-asks.ts +468 -0
- package/dist/runtime/src/storage/session-inbox-signal.ts +76 -0
- package/dist/runtime/src/storage/session-inbox.ts +161 -0
- package/dist/runtime/src/storage/sqlite.ts +154 -0
- package/dist/runtime/src/storage/storage-contract.ts +54 -0
- package/dist/runtime/src/storage/storage-host.ts +336 -0
- package/dist/runtime/src/storage/storage-public-host.ts +16 -0
- package/dist/runtime/src/storage/storage-public.ts +66 -0
- package/dist/runtime/src/storage/tasks.ts +172 -0
- package/dist/runtime/src/storage/token-stats.ts +432 -0
- package/dist/runtime/src/storage/topic-archive-state.ts +226 -0
- package/dist/runtime/src/storage/topic-archive.ts +169 -0
- package/dist/runtime/src/storage/topic-host-mcp-grants.ts +54 -0
- package/dist/runtime/src/storage/topic-link-records.ts +1085 -0
- package/dist/runtime/src/storage/topic-settings.ts +67 -0
- package/dist/runtime/src/storage/topic-tool-capabilities.ts +89 -0
- package/dist/runtime/src/storage/topic-transcript.ts +98 -0
- package/dist/runtime/src/storage/vault-crypto-core.ts +65 -0
- package/dist/runtime/src/storage/vault-crypto.ts +31 -0
- package/dist/runtime/src/storage/vault-public.ts +27 -0
- package/dist/runtime/src/storage/vault-request-gates.ts +359 -0
- package/dist/runtime/src/storage/vault.ts +388 -0
- package/dist/runtime/src/storage/wiki-summary-names.ts +52 -0
- package/dist/runtime/src/storage/wiki.ts +90 -0
- package/dist/runtime/src/topics/claim-abort.ts +190 -0
- package/dist/runtime/src/topics/create.ts +192 -0
- package/dist/runtime/src/topics/derive.ts +600 -0
- package/dist/runtime/src/topics/lifecycle.ts +425 -0
- package/dist/runtime/src/topics/links.ts +7 -0
- package/dist/runtime/src/topics/personal-general.ts +91 -0
- package/dist/runtime/src/topics/session.ts +1041 -0
- package/dist/runtime/src/topics/update.ts +287 -0
- package/dist/runtime/src/types/api.ts +591 -0
- package/dist/runtime/src/types.ts +418 -0
- package/dist/runtime/src/version.ts +1 -0
- package/dist/runtime/tsconfig.json +13 -0
- package/dist/runtime-gateway.js +514 -0
- package/dist/runtime-gateway.js.map +10 -0
- package/dist/runtime-helpers.js +1792 -0
- package/dist/runtime-helpers.js.map +40 -0
- package/dist/sqlite.js +66 -0
- package/dist/sqlite.js.map +10 -0
- package/dist/storage.js +5223 -0
- package/dist/storage.js.map +47 -0
- package/dist/types/apps/negotium/src/mcp-servers.d.ts +20 -0
- package/dist/types/packages/core/src/agents/api-topic-agent-switch.d.ts +38 -0
- package/dist/types/packages/core/src/agents/archiver.d.ts +87 -0
- package/dist/types/packages/core/src/agents/auth-check.d.ts +19 -0
- package/dist/types/packages/core/src/agents/claude-notices.d.ts +15 -0
- package/dist/types/packages/core/src/agents/claude-provider.d.ts +25 -0
- package/dist/types/packages/core/src/agents/claude-registry.d.ts +3 -0
- package/dist/types/packages/core/src/agents/claude-runtime-inspection.d.ts +9 -0
- package/dist/types/packages/core/src/agents/codex-app-server.d.ts +13 -0
- package/dist/types/packages/core/src/agents/codex-native-multi-agent.d.ts +20 -0
- package/dist/types/packages/core/src/agents/codex-provider.d.ts +64 -0
- package/dist/types/packages/core/src/agents/codex-registry.d.ts +3 -0
- package/dist/types/packages/core/src/agents/codex-tier-resolver.d.ts +10 -0
- package/dist/types/packages/core/src/agents/codex-tree-kill.d.ts +13 -0
- package/dist/types/packages/core/src/agents/codex-tree-manager.d.ts +28 -0
- package/dist/types/packages/core/src/agents/codex-vault-hook-bridge.d.ts +28 -0
- package/dist/types/packages/core/src/agents/codex-windows-wrapper.d.ts +30 -0
- package/dist/types/packages/core/src/agents/compaction-support.d.ts +5 -0
- package/dist/types/packages/core/src/agents/compaction-tool-projection.d.ts +9 -0
- package/dist/types/packages/core/src/agents/contracts.d.ts +68 -0
- package/dist/types/packages/core/src/agents/deep-map.d.ts +2 -0
- package/dist/types/packages/core/src/agents/execution-host.d.ts +33 -0
- package/dist/types/packages/core/src/agents/explicit-agent-switch.d.ts +26 -0
- package/dist/types/packages/core/src/agents/fork.d.ts +50 -0
- package/dist/types/packages/core/src/agents/hosted-agent.d.ts +15 -0
- package/dist/types/packages/core/src/agents/idle-archiver.d.ts +35 -0
- package/dist/types/packages/core/src/agents/idle-compact.d.ts +37 -0
- package/dist/types/packages/core/src/agents/index.d.ts +8 -0
- package/dist/types/packages/core/src/agents/maestro-provider.d.ts +75 -0
- package/dist/types/packages/core/src/agents/maestro-registry.d.ts +3 -0
- package/dist/types/packages/core/src/agents/mcp-tools/ask-user.d.ts +147 -0
- package/dist/types/packages/core/src/agents/mcp-tools/common.d.ts +14 -0
- package/dist/types/packages/core/src/agents/mcp-tools/inline-assets.d.ts +24 -0
- package/dist/types/packages/core/src/agents/mcp-tools/publish-html.d.ts +18 -0
- package/dist/types/packages/core/src/agents/mcp-tools/request-vault.d.ts +124 -0
- package/dist/types/packages/core/src/agents/mcp-tools/self-config.d.ts +45 -0
- package/dist/types/packages/core/src/agents/mcp-tools/spawn-subagent.d.ts +148 -0
- package/dist/types/packages/core/src/agents/mcp-tools/visual-compat.d.ts +55 -0
- package/dist/types/packages/core/src/agents/mcp-tools/visuals.d.ts +70 -0
- package/dist/types/packages/core/src/agents/memory-archive-policy.d.ts +24 -0
- package/dist/types/packages/core/src/agents/model-catalog.d.ts +132 -0
- package/dist/types/packages/core/src/agents/public-helpers.d.ts +17 -0
- package/dist/types/packages/core/src/agents/registry.d.ts +5 -0
- package/dist/types/packages/core/src/agents/rollout/claude.d.ts +77 -0
- package/dist/types/packages/core/src/agents/rollout/codex.d.ts +119 -0
- package/dist/types/packages/core/src/agents/rollout/index.d.ts +6 -0
- package/dist/types/packages/core/src/agents/rollout/shared.d.ts +56 -0
- package/dist/types/packages/core/src/agents/self-config-core.d.ts +199 -0
- package/dist/types/packages/core/src/agents/task-events.d.ts +19 -0
- package/dist/types/packages/core/src/agents/tool-format.d.ts +25 -0
- package/dist/types/packages/core/src/agents/topic-cleanup.d.ts +83 -0
- package/dist/types/packages/core/src/agents/vault-tool-policy.d.ts +2 -0
- package/dist/types/packages/core/src/bus.d.ts +141 -0
- package/dist/types/packages/core/src/identifiers.d.ts +27 -0
- package/dist/types/packages/core/src/mcp/canonical-bridge-config.d.ts +21 -0
- package/dist/types/packages/core/src/mcp/factories/agent-health.d.ts +5 -0
- package/dist/types/packages/core/src/mcp/factories/compaction-log.d.ts +8 -0
- package/dist/types/packages/core/src/mcp/factories/decision.d.ts +18 -0
- package/dist/types/packages/core/src/mcp/factories/index.d.ts +13 -0
- package/dist/types/packages/core/src/mcp/factories/session-comm.d.ts +38 -0
- package/dist/types/packages/core/src/mcp/factories/session-history.d.ts +11 -0
- package/dist/types/packages/core/src/mcp/factories/stdio-protection.d.ts +10 -0
- package/dist/types/packages/core/src/mcp/factories/system-health.d.ts +37 -0
- package/dist/types/packages/core/src/mcp/factories/task.d.ts +13 -0
- package/dist/types/packages/core/src/mcp/factories/token-stats.d.ts +20 -0
- package/dist/types/packages/core/src/mcp/factories/vault.d.ts +9 -0
- package/dist/types/packages/core/src/mcp/mcp-helpers.d.ts +26 -0
- package/dist/types/packages/core/src/mcp/peer-bridge.d.ts +92 -0
- package/dist/types/packages/core/src/mcp/runtime-spec.d.ts +147 -0
- package/dist/types/packages/core/src/mcp/session-comm/actor-policy.d.ts +120 -0
- package/dist/types/packages/core/src/mcp/session-comm/bridge-ipc-config.d.ts +6 -0
- package/dist/types/packages/core/src/mcp/session-comm/context.d.ts +44 -0
- package/dist/types/packages/core/src/mcp/session-comm/history-tools.d.ts +31 -0
- package/dist/types/packages/core/src/mcp/session-comm/hub-remote-session.d.ts +149 -0
- package/dist/types/packages/core/src/mcp/session-comm/limits.d.ts +8 -0
- package/dist/types/packages/core/src/mcp/session-comm/peer-forward.d.ts +85 -0
- package/dist/types/packages/core/src/mcp/session-comm/tell-permissions.d.ts +29 -0
- package/dist/types/packages/core/src/mcp/session-comm/topic-catalog.d.ts +59 -0
- package/dist/types/packages/core/src/mcp/session-history-limits.d.ts +20 -0
- package/dist/types/packages/core/src/mcp/session-history-reader.d.ts +35 -0
- package/dist/types/packages/core/src/mcp/wiki-search-index.d.ts +59 -0
- package/dist/types/packages/core/src/mcp/wiki-server.d.ts +53 -0
- package/dist/types/packages/core/src/media/file-events.d.ts +14 -0
- package/dist/types/packages/core/src/media/text-extractor.d.ts +34 -0
- package/dist/types/packages/core/src/outbox/coalescing-runner.d.ts +68 -0
- package/dist/types/packages/core/src/outbox/file-ops.d.ts +79 -0
- package/dist/types/packages/core/src/outbox/index.d.ts +3 -0
- package/dist/types/packages/core/src/outbox/utils.d.ts +16 -0
- package/dist/types/packages/core/src/platform/background-bash/context.d.ts +1 -0
- package/dist/types/packages/core/src/platform/background-bash/manager.d.ts +34 -0
- package/dist/types/packages/core/src/platform/config-helpers.d.ts +20 -0
- package/dist/types/packages/core/src/platform/config.d.ts +178 -0
- package/dist/types/packages/core/src/platform/constants.d.ts +20 -0
- package/dist/types/packages/core/src/platform/delay.d.ts +1 -0
- package/dist/types/packages/core/src/platform/error.d.ts +6 -0
- package/dist/types/packages/core/src/platform/file-utils.d.ts +16 -0
- package/dist/types/packages/core/src/platform/ipc.d.ts +32 -0
- package/dist/types/packages/core/src/platform/jsonl.d.ts +46 -0
- package/dist/types/packages/core/src/platform/lifecycle.d.ts +40 -0
- package/dist/types/packages/core/src/platform/logger.d.ts +20 -0
- package/dist/types/packages/core/src/platform/maestro-bootstrap-env.d.ts +0 -0
- package/dist/types/packages/core/src/platform/mcp-catalog-policy.d.ts +73 -0
- package/dist/types/packages/core/src/platform/mcp-config.d.ts +286 -0
- package/dist/types/packages/core/src/platform/memoize-import.d.ts +15 -0
- package/dist/types/packages/core/src/platform/paths.d.ts +18 -0
- package/dist/types/packages/core/src/platform/playwright/browser-processes.d.ts +60 -0
- package/dist/types/packages/core/src/platform/playwright/capability.d.ts +1 -0
- package/dist/types/packages/core/src/platform/playwright/headed-launch.d.ts +13 -0
- package/dist/types/packages/core/src/platform/playwright/manager-utils.d.ts +34 -0
- package/dist/types/packages/core/src/platform/playwright/manager.d.ts +194 -0
- package/dist/types/packages/core/src/platform/playwright/mcp-transport.d.ts +4 -0
- package/dist/types/packages/core/src/platform/playwright/profile-management.d.ts +8 -0
- package/dist/types/packages/core/src/platform/playwright/public-runtime.d.ts +6 -0
- package/dist/types/packages/core/src/platform/playwright/transport-probe.d.ts +13 -0
- package/dist/types/packages/core/src/platform/playwright/vault-broker.d.ts +6 -0
- package/dist/types/packages/core/src/platform/public-runtime.d.ts +3 -0
- package/dist/types/packages/core/src/prompts/builders.d.ts +78 -0
- package/dist/types/packages/core/src/query/active-rooms.d.ts +240 -0
- package/dist/types/packages/core/src/query/public-runtime.d.ts +4 -0
- package/dist/types/packages/core/src/query/room-query-registry.d.ts +71 -0
- package/dist/types/packages/core/src/query/session-inbox-cleanup.d.ts +5 -0
- package/dist/types/packages/core/src/query/session-inbox-path.d.ts +8 -0
- package/dist/types/packages/core/src/query/state.d.ts +25 -0
- package/dist/types/packages/core/src/query/types.d.ts +6 -0
- package/dist/types/packages/core/src/runtime/actor-topic-reach.d.ts +63 -0
- package/dist/types/packages/core/src/runtime/actor-topic-scope.d.ts +127 -0
- package/dist/types/packages/core/src/runtime/ask-callbacks.d.ts +53 -0
- package/dist/types/packages/core/src/runtime/attachments.d.ts +36 -0
- package/dist/types/packages/core/src/runtime/background-session-policy.d.ts +1 -0
- package/dist/types/packages/core/src/runtime/background-sessions.d.ts +27 -0
- package/dist/types/packages/core/src/runtime/bashrs-completions.d.ts +50 -0
- package/dist/types/packages/core/src/runtime/channel-context.d.ts +13 -0
- package/dist/types/packages/core/src/runtime/context-warning.d.ts +46 -0
- package/dist/types/packages/core/src/runtime/cron-sessions.d.ts +9 -0
- package/dist/types/packages/core/src/runtime/errors.d.ts +6 -0
- package/dist/types/packages/core/src/runtime/event-heartbeat.d.ts +17 -0
- package/dist/types/packages/core/src/runtime/file-hooks.d.ts +38 -0
- package/dist/types/packages/core/src/runtime/playwright-turn-abort.d.ts +12 -0
- package/dist/types/packages/core/src/runtime/public-helpers.d.ts +17 -0
- package/dist/types/packages/core/src/runtime/remote-session-grant.d.ts +91 -0
- package/dist/types/packages/core/src/runtime/remote-session-inbox.d.ts +206 -0
- package/dist/types/packages/core/src/runtime/remote-session-reply-outbox.d.ts +37 -0
- package/dist/types/packages/core/src/runtime/task-format.d.ts +4 -0
- package/dist/types/packages/core/src/runtime/tasks.d.ts +3 -0
- package/dist/types/packages/core/src/runtime/thread-context.d.ts +62 -0
- package/dist/types/packages/core/src/runtime/topic-config.d.ts +24 -0
- package/dist/types/packages/core/src/runtime/turn-event-stream.d.ts +47 -0
- package/dist/types/packages/core/src/runtime/turn-runner.d.ts +284 -0
- package/dist/types/packages/core/src/runtime/turn-session.d.ts +49 -0
- package/dist/types/packages/core/src/runtime/usage-alert.d.ts +11 -0
- package/dist/types/packages/core/src/runtime/user-turn-envelope.d.ts +37 -0
- package/dist/types/packages/core/src/runtime/visual-html.d.ts +13 -0
- package/dist/types/packages/core/src/runtime/visual-store.d.ts +71 -0
- package/dist/types/packages/core/src/runtime/visuals.d.ts +33 -0
- package/dist/types/packages/core/src/runtime-gateway.d.ts +282 -0
- package/dist/types/packages/core/src/security/sanitize.d.ts +16 -0
- package/dist/types/packages/core/src/security/sensitive-path.d.ts +1 -0
- package/dist/types/packages/core/src/storage/activity-log.d.ts +25 -0
- package/dist/types/packages/core/src/storage/api-messages.d.ts +156 -0
- package/dist/types/packages/core/src/storage/api-topic-brief.d.ts +39 -0
- package/dist/types/packages/core/src/storage/api-topic-config.d.ts +23 -0
- package/dist/types/packages/core/src/storage/api-topics.d.ts +274 -0
- package/dist/types/packages/core/src/storage/app-settings.d.ts +4 -0
- package/dist/types/packages/core/src/storage/ask-user-gates.d.ts +65 -0
- package/dist/types/packages/core/src/storage/browser-profiles.d.ts +31 -0
- package/dist/types/packages/core/src/storage/conversations.d.ts +149 -0
- package/dist/types/packages/core/src/storage/decisions.d.ts +45 -0
- package/dist/types/packages/core/src/storage/forum/agent-settings.d.ts +3 -0
- package/dist/types/packages/core/src/storage/forum/index.d.ts +4 -0
- package/dist/types/packages/core/src/storage/forum/repository.d.ts +42 -0
- package/dist/types/packages/core/src/storage/forum/schema.d.ts +38 -0
- package/dist/types/packages/core/src/storage/forum-db.d.ts +2 -0
- package/dist/types/packages/core/src/storage/remote-session.d.ts +318 -0
- package/dist/types/packages/core/src/storage/runtime-events.d.ts +33 -0
- package/dist/types/packages/core/src/storage/runtime-leases.d.ts +27 -0
- package/dist/types/packages/core/src/storage/runtime-process-leases.d.ts +47 -0
- package/dist/types/packages/core/src/storage/runtime-topic-state.d.ts +39 -0
- package/dist/types/packages/core/src/storage/runtime-turn-requests.d.ts +163 -0
- package/dist/types/packages/core/src/storage/self-schedules.d.ts +54 -0
- package/dist/types/packages/core/src/storage/session-asks.d.ts +78 -0
- package/dist/types/packages/core/src/storage/session-inbox-signal.d.ts +35 -0
- package/dist/types/packages/core/src/storage/session-inbox.d.ts +36 -0
- package/dist/types/packages/core/src/storage/sqlite.d.ts +20 -0
- package/dist/types/packages/core/src/storage/storage-contract.d.ts +46 -0
- package/dist/types/packages/core/src/storage/storage-host.d.ts +41 -0
- package/dist/types/packages/core/src/storage/storage-public-host.d.ts +7 -0
- package/dist/types/packages/core/src/storage/storage-public.d.ts +45 -0
- package/dist/types/packages/core/src/storage/tasks.d.ts +49 -0
- package/dist/types/packages/core/src/storage/token-stats.d.ts +69 -0
- package/dist/types/packages/core/src/storage/topic-archive-state.d.ts +33 -0
- package/dist/types/packages/core/src/storage/topic-archive.d.ts +42 -0
- package/dist/types/packages/core/src/storage/topic-host-mcp-grants.d.ts +5 -0
- package/dist/types/packages/core/src/storage/topic-link-records.d.ts +281 -0
- package/dist/types/packages/core/src/storage/topic-settings.d.ts +19 -0
- package/dist/types/packages/core/src/storage/topic-tool-capabilities.d.ts +37 -0
- package/dist/types/packages/core/src/storage/topic-transcript.d.ts +38 -0
- package/dist/types/packages/core/src/storage/vault-crypto-core.d.ts +6 -0
- package/dist/types/packages/core/src/storage/vault-crypto.d.ts +12 -0
- package/dist/types/packages/core/src/storage/vault-public.d.ts +3 -0
- package/dist/types/packages/core/src/storage/vault-request-gates.d.ts +69 -0
- package/dist/types/packages/core/src/storage/vault.d.ts +49 -0
- package/dist/types/packages/core/src/storage/wiki-summary-names.d.ts +13 -0
- package/dist/types/packages/core/src/storage/wiki.d.ts +15 -0
- package/dist/types/packages/core/src/topics/derive.d.ts +83 -0
- package/dist/types/packages/core/src/topics/lifecycle.d.ts +75 -0
- package/dist/types/packages/core/src/topics/links.d.ts +2 -0
- package/dist/types/packages/core/src/topics/personal-general.d.ts +15 -0
- package/dist/types/packages/core/src/topics/session.d.ts +70 -0
- package/dist/types/packages/core/src/types/api.d.ts +551 -0
- package/dist/types/packages/core/src/types.d.ts +405 -0
- package/dist/types/packages/core/src/version.d.ts +1 -0
- package/dist/types/packages/module-cron/src/background-sessions.d.ts +2 -0
- package/dist/types/packages/module-cron/src/context.d.ts +15 -0
- package/dist/types/packages/module-cron/src/host.d.ts +23 -0
- package/dist/types/packages/module-cron/src/index.d.ts +14 -0
- package/dist/types/packages/module-cron/src/module.d.ts +13 -0
- package/dist/types/packages/module-cron/src/schedule.d.ts +23 -0
- package/dist/types/packages/module-cron/src/scheduler.d.ts +46 -0
- package/dist/types/packages/module-cron/src/scripts.d.ts +29 -0
- package/dist/types/packages/module-cron/src/store.d.ts +152 -0
- package/dist/types/packages/module-cron/src/summarize.d.ts +4 -0
- package/dist/vault.js +848 -0
- package/dist/vault.js.map +18 -0
- package/install-bash-rs.mjs +90 -0
- package/install-browser-rs.mjs +83 -0
- package/package.json +171 -4
package/dist/prompts.js
ADDED
|
@@ -0,0 +1,892 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// ../../packages/core/src/prompts/builders.ts
|
|
3
|
+
import { readFileSync as readFileSync2 } from "fs";
|
|
4
|
+
import { resolve as resolve2 } from "path";
|
|
5
|
+
|
|
6
|
+
// ../../packages/core/src/platform/config.ts
|
|
7
|
+
import { execFileSync } from "child_process";
|
|
8
|
+
import { randomBytes } from "crypto";
|
|
9
|
+
import {
|
|
10
|
+
accessSync,
|
|
11
|
+
chmodSync,
|
|
12
|
+
constants,
|
|
13
|
+
existsSync,
|
|
14
|
+
mkdirSync,
|
|
15
|
+
readFileSync,
|
|
16
|
+
writeFileSync
|
|
17
|
+
} from "fs";
|
|
18
|
+
import { createRequire } from "module";
|
|
19
|
+
import { homedir } from "os";
|
|
20
|
+
import { dirname, join, resolve } from "path";
|
|
21
|
+
import { fileURLToPath, pathToFileURL } from "url";
|
|
22
|
+
|
|
23
|
+
// ../../packages/core/src/types.ts
|
|
24
|
+
var SUPPORTED_AGENTS = ["maestro", "claude", "codex"];
|
|
25
|
+
function isAgentKind(value) {
|
|
26
|
+
return typeof value === "string" && SUPPORTED_AGENTS.includes(value);
|
|
27
|
+
}
|
|
28
|
+
var EFFORT_VALUES = [
|
|
29
|
+
"low",
|
|
30
|
+
"medium",
|
|
31
|
+
"high",
|
|
32
|
+
"xhigh",
|
|
33
|
+
"max"
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
// ../../packages/core/src/platform/config-helpers.ts
|
|
37
|
+
function readEnvText(env, key) {
|
|
38
|
+
const value = env[key]?.trim();
|
|
39
|
+
return value || undefined;
|
|
40
|
+
}
|
|
41
|
+
function resolveFallbackAgent(env = process.env) {
|
|
42
|
+
const value = readEnvText(env, "FALLBACK_AGENT") ?? readEnvText(env, "DEFAULT_AGENT");
|
|
43
|
+
return isAgentKind(value) ? value : "claude";
|
|
44
|
+
}
|
|
45
|
+
function parseRuntimePort(value, fallback) {
|
|
46
|
+
if (!value)
|
|
47
|
+
return fallback;
|
|
48
|
+
const port = Number.parseInt(value, 10);
|
|
49
|
+
return Number.isInteger(port) && port > 0 && port <= 65535 ? port : fallback;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// ../../packages/core/src/platform/logger.ts
|
|
53
|
+
import pino from "pino";
|
|
54
|
+
function createStdioLogger(options = {}) {
|
|
55
|
+
const development = options.development ?? true;
|
|
56
|
+
return pino({
|
|
57
|
+
level: options.level ?? process.env.LOG_LEVEL ?? "info",
|
|
58
|
+
transport: development ? {
|
|
59
|
+
target: "pino-pretty",
|
|
60
|
+
options: {
|
|
61
|
+
colorize: true,
|
|
62
|
+
translateTime: "SYS:yyyy-mm-dd HH:MM:ss",
|
|
63
|
+
destination: 2
|
|
64
|
+
}
|
|
65
|
+
} : undefined
|
|
66
|
+
}, pino.destination(2));
|
|
67
|
+
}
|
|
68
|
+
var logger = createStdioLogger();
|
|
69
|
+
|
|
70
|
+
// ../../packages/core/src/platform/config.ts
|
|
71
|
+
function envText(envKey) {
|
|
72
|
+
return readEnvText(process.env, envKey);
|
|
73
|
+
}
|
|
74
|
+
var HOME = homedir();
|
|
75
|
+
function resolveStateDir() {
|
|
76
|
+
const configured = envText("NEGOTIUM_STATE_DIR");
|
|
77
|
+
if (false) {}
|
|
78
|
+
return configured ? resolve(configured) : resolve(HOME, ".negotium");
|
|
79
|
+
}
|
|
80
|
+
function resolveProjectRoot() {
|
|
81
|
+
const moduleDir = dirname(fileURLToPath(import.meta.url));
|
|
82
|
+
const packagedRuntime = resolve(moduleDir, "runtime");
|
|
83
|
+
if (existsSync(resolve(packagedRuntime, "src")))
|
|
84
|
+
return packagedRuntime;
|
|
85
|
+
return resolve(moduleDir, "../..");
|
|
86
|
+
}
|
|
87
|
+
var PROJECT_ROOT = resolveProjectRoot();
|
|
88
|
+
function dependencyBinNames(name) {
|
|
89
|
+
if (process.platform !== "win32")
|
|
90
|
+
return [name];
|
|
91
|
+
return [name, `${name}.exe`, `${name}.cmd`, `${name}.bat`, `${name}.bunx`];
|
|
92
|
+
}
|
|
93
|
+
function resolveDependencyBin(name) {
|
|
94
|
+
let dir = PROJECT_ROOT;
|
|
95
|
+
while (true) {
|
|
96
|
+
const binDir = resolve(dir, "node_modules", ".bin");
|
|
97
|
+
for (const candidate of dependencyBinNames(name)) {
|
|
98
|
+
const path = resolve(binDir, candidate);
|
|
99
|
+
if (existsSync(path))
|
|
100
|
+
return path;
|
|
101
|
+
}
|
|
102
|
+
const parent = dirname(dir);
|
|
103
|
+
if (parent === dir)
|
|
104
|
+
return resolve(binDir, name);
|
|
105
|
+
dir = parent;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
var STATE_DIR = resolveStateDir();
|
|
109
|
+
function resolveLocalStateDir(envKey, stateName) {
|
|
110
|
+
const envValue = envText(envKey);
|
|
111
|
+
if (envValue)
|
|
112
|
+
return resolve(envValue);
|
|
113
|
+
return resolve(STATE_DIR, stateName);
|
|
114
|
+
}
|
|
115
|
+
function parsePortEnv(envValue, fallback) {
|
|
116
|
+
return parseRuntimePort(envValue, fallback);
|
|
117
|
+
}
|
|
118
|
+
var WORKSPACE_DIR = resolveLocalStateDir("NEGOTIUM_WORKSPACE_DIR", "workspace");
|
|
119
|
+
var TOPIC_WORKSPACE_DIR = resolve(WORKSPACE_DIR, "topics");
|
|
120
|
+
var SHARED_WIKI_DIR = resolve(WORKSPACE_DIR, "wiki");
|
|
121
|
+
var CRON_WORKSPACE_DIR = resolve(WORKSPACE_DIR, "cron");
|
|
122
|
+
var BROWSER_DIR = resolveLocalStateDir("NEGOTIUM_BROWSER_DIR", "browser");
|
|
123
|
+
var BROWSER_PROFILES_DIR = resolve(BROWSER_DIR, "profiles");
|
|
124
|
+
var BINARIES_DIR = resolve(STATE_DIR, "binaries");
|
|
125
|
+
var SECRETS_DIR = resolve(STATE_DIR, "secrets");
|
|
126
|
+
var DM_WORKSPACE_DIR = resolve(STATE_DIR, "data", "dm");
|
|
127
|
+
var SESSION_WORKSPACE_DIR = resolve(STATE_DIR, "data", "sessions");
|
|
128
|
+
var CLAUDE_EXECUTABLE_ENV = envText("NEGOTIUM_CLAUDE_EXECUTABLE");
|
|
129
|
+
var CLAUDE_EXECUTABLE = CLAUDE_EXECUTABLE_ENV ? resolve(CLAUDE_EXECUTABLE_ENV) : undefined;
|
|
130
|
+
var DEFAULT_OUTPUT_LANGUAGE = "English";
|
|
131
|
+
function resolveOutputLanguage() {
|
|
132
|
+
const raw = envText("NEGOTIUM_LANG")?.trim();
|
|
133
|
+
return raw && raw.length > 0 ? raw : DEFAULT_OUTPUT_LANGUAGE;
|
|
134
|
+
}
|
|
135
|
+
var BINARY_EXTENSION = process.platform === "win32" ? ".exe" : "";
|
|
136
|
+
var BROWSER_RS_VERSION = "v0.7.7";
|
|
137
|
+
var BROWSER_RS_MIN_SECURE_VERSION = "0.2.1";
|
|
138
|
+
function versionAtLeast(actualVersion, minimumVersion) {
|
|
139
|
+
const actual = actualVersion.split(".").map(Number);
|
|
140
|
+
const minimum = minimumVersion.split(".").map(Number);
|
|
141
|
+
if (actual.some(Number.isNaN) || minimum.some(Number.isNaN))
|
|
142
|
+
return false;
|
|
143
|
+
for (let index = 0;index < minimum.length; index += 1) {
|
|
144
|
+
if ((actual[index] ?? 0) > (minimum[index] ?? 0))
|
|
145
|
+
return true;
|
|
146
|
+
if ((actual[index] ?? 0) < (minimum[index] ?? 0))
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
var BROWSER_RS_VERSION_PROBE_TIMEOUT_MS = 15000;
|
|
152
|
+
function browserRsMeetsMinimumVersion(candidate) {
|
|
153
|
+
try {
|
|
154
|
+
const output = execFileSync(candidate, ["--version"], {
|
|
155
|
+
encoding: "utf8",
|
|
156
|
+
timeout: BROWSER_RS_VERSION_PROBE_TIMEOUT_MS,
|
|
157
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
158
|
+
windowsHide: true
|
|
159
|
+
}).trim();
|
|
160
|
+
const match = output.match(/^browser-rs (\d+)\.(\d+)\.(\d+)$/);
|
|
161
|
+
if (!match)
|
|
162
|
+
return false;
|
|
163
|
+
return versionAtLeast(match.slice(1).join("."), BROWSER_RS_MIN_SECURE_VERSION);
|
|
164
|
+
} catch {
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
function resolveBrowserRsBin(envValue) {
|
|
169
|
+
const override = envValue?.trim();
|
|
170
|
+
if (!override && !versionAtLeast(BROWSER_RS_VERSION.replace(/^v/, ""), BROWSER_RS_MIN_SECURE_VERSION)) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
const candidate = override ? resolve(override) : resolve(BINARIES_DIR, "browser-rs", BROWSER_RS_VERSION, `browser-rs${BINARY_EXTENSION}`);
|
|
174
|
+
try {
|
|
175
|
+
accessSync(candidate, constants.X_OK);
|
|
176
|
+
return browserRsMeetsMinimumVersion(candidate) ? candidate : undefined;
|
|
177
|
+
} catch {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
var SNIPPETS_API_URL = (envText("NEGOTIUM_SNIPPETS_API_URL") ?? envText("SNIPPETS_API_URL") ?? "").replace(/\/+$/, "");
|
|
182
|
+
var BROWSER_RS_BIN = resolveBrowserRsBin(envText("NEGOTIUM_BROWSER_RS_BIN"));
|
|
183
|
+
var BASH_RS_VERSION = "v0.1.10";
|
|
184
|
+
function resolveBashRsBin(envValue) {
|
|
185
|
+
const override = envValue?.trim();
|
|
186
|
+
const candidate = override ? resolve(override) : resolve(BINARIES_DIR, "bash-rs", BASH_RS_VERSION, `bash-rs${BINARY_EXTENSION}`);
|
|
187
|
+
try {
|
|
188
|
+
accessSync(candidate, constants.X_OK);
|
|
189
|
+
return candidate;
|
|
190
|
+
} catch {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
var BASH_RS_BIN = resolveBashRsBin(envText("NEGOTIUM_BASH_RS_BIN"));
|
|
195
|
+
function resolveBrowserMcpBin(envValue) {
|
|
196
|
+
const override = envValue?.trim();
|
|
197
|
+
if (override)
|
|
198
|
+
return resolve(override);
|
|
199
|
+
return BROWSER_RS_BIN ?? resolve(BINARIES_DIR, "browser-rs", BROWSER_RS_VERSION, `browser-rs${BINARY_EXTENSION}`);
|
|
200
|
+
}
|
|
201
|
+
var PLAYWRIGHT_MCP_BIN = resolveBrowserMcpBin(envText("NEGOTIUM_BROWSER_MCP_BIN"));
|
|
202
|
+
var TSX_BIN = resolveDependencyBin("tsx");
|
|
203
|
+
var TSX_LOADER_PATH = createRequire(import.meta.url).resolve("tsx");
|
|
204
|
+
var TSX_LOADER = process.platform === "win32" ? pathToFileURL(TSX_LOADER_PATH).href : TSX_LOADER_PATH;
|
|
205
|
+
var TSCONFIG_PATH = resolve(PROJECT_ROOT, "tsconfig.json");
|
|
206
|
+
var SESSION_COMM_SERVER = resolve(PROJECT_ROOT, "src/mcp/session-comm/server.ts");
|
|
207
|
+
var TASK_SERVER = resolve(PROJECT_ROOT, "src/mcp/task-server.ts");
|
|
208
|
+
var DECISION_SERVER = resolve(PROJECT_ROOT, "src/mcp/decision-server.ts");
|
|
209
|
+
var CANONICAL_MCP_PROXY_SERVER = resolve(PROJECT_ROOT, "src/mcp/canonical-proxy-server.ts");
|
|
210
|
+
var WIKI_SERVER = resolve(PROJECT_ROOT, "src/mcp/wiki-server.ts");
|
|
211
|
+
var TOKEN_STATS_SERVER = resolve(PROJECT_ROOT, "src/mcp/token-stats-server.ts");
|
|
212
|
+
var COMPACTION_LOG_SERVER = resolve(PROJECT_ROOT, "src/mcp/compaction-log-server.ts");
|
|
213
|
+
var SESSION_HISTORY_SERVER = resolve(PROJECT_ROOT, "src/mcp/session-history-server.ts");
|
|
214
|
+
var SYSTEM_HEALTH_SERVER = resolve(PROJECT_ROOT, "src/mcp/system-health-server.ts");
|
|
215
|
+
var AGENT_HEALTH_SERVER = resolve(PROJECT_ROOT, "src/mcp/agent-health-server.ts");
|
|
216
|
+
var VAULT_SERVER = resolve(PROJECT_ROOT, "src/mcp/vault-server.ts");
|
|
217
|
+
var BG_BASH_BASE_PORT = parsePortEnv(process.env.BG_BASH_BASE_PORT, 9700);
|
|
218
|
+
var BG_BASH_MAX_PORT = parsePortEnv(process.env.BG_BASH_MAX_PORT, 9799);
|
|
219
|
+
function loadOrCreateLocalSecret(envKey, filename, options = {}) {
|
|
220
|
+
const envValue = envText(envKey);
|
|
221
|
+
const secretFile = resolve(SECRETS_DIR, filename);
|
|
222
|
+
mkdirSync(dirname(secretFile), { recursive: true });
|
|
223
|
+
if (envValue) {
|
|
224
|
+
if (options.persistEnvValue) {
|
|
225
|
+
writeFileSync(secretFile, `${envValue}
|
|
226
|
+
`, { mode: 384 });
|
|
227
|
+
chmodSync(secretFile, 384);
|
|
228
|
+
}
|
|
229
|
+
return envValue;
|
|
230
|
+
}
|
|
231
|
+
if (existsSync(secretFile)) {
|
|
232
|
+
const stored = readFileSync(secretFile, "utf-8").trim();
|
|
233
|
+
if (stored) {
|
|
234
|
+
chmodSync(secretFile, 384);
|
|
235
|
+
return stored;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
const secret = randomBytes(32).toString("base64url");
|
|
239
|
+
try {
|
|
240
|
+
writeFileSync(secretFile, `${secret}
|
|
241
|
+
`, { mode: 384, flag: "wx" });
|
|
242
|
+
return secret;
|
|
243
|
+
} catch (error) {
|
|
244
|
+
if (error.code !== "EEXIST")
|
|
245
|
+
throw error;
|
|
246
|
+
const stored = readFileSync(secretFile, "utf-8").trim();
|
|
247
|
+
if (!stored)
|
|
248
|
+
throw new Error(`Secret file exists but is empty: ${secretFile}`);
|
|
249
|
+
chmodSync(secretFile, 384);
|
|
250
|
+
return stored;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
var RUNTIME_MCP_SECRET = loadOrCreateLocalSecret("RUNTIME_MCP_SECRET", "runtime-mcp-secret");
|
|
254
|
+
var NODE_CONTROL_TOKEN = loadOrCreateLocalSecret("NEGOTIUM_CONTROL_TOKEN", "node-control-token");
|
|
255
|
+
var NODE_ID = loadOrCreateLocalSecret("NEGOTIUM_NODE_ID", "node-id");
|
|
256
|
+
var VAULT_MASTER_KEY = loadOrCreateLocalSecret("NEGOTIUM_VAULT_MASTER_KEY", "vault-master-key", { persistEnvValue: true });
|
|
257
|
+
delete process.env.NEGOTIUM_VAULT_MASTER_KEY;
|
|
258
|
+
var NEGOTIUM_PORT = parseInt(process.env.NEGOTIUM_PORT || "7777", 10);
|
|
259
|
+
var hostname = process.env.HOSTNAME || "127.0.0.1";
|
|
260
|
+
var DATA_DIR = resolveLocalStateDir("NEGOTIUM_DATA_DIR", "data");
|
|
261
|
+
var LOG_DIR = resolveLocalStateDir("NEGOTIUM_LOG_DIR", "logs");
|
|
262
|
+
var UPLOADS_DIR = resolve(DATA_DIR, "uploads");
|
|
263
|
+
var VAULT_DIR = resolve(DATA_DIR, "vault");
|
|
264
|
+
var SESSIONS_DB = process.env.SESSIONS_DB_PATH ? resolve(process.env.SESSIONS_DB_PATH) : resolve(DATA_DIR, "sessions.db");
|
|
265
|
+
var DEBUG_FILE = resolve(DATA_DIR, "debug-users.json");
|
|
266
|
+
var USERS_LOG_DIR = resolve(DATA_DIR, "users");
|
|
267
|
+
var RUN_DIR = resolveLocalStateDir("NEGOTIUM_RUN_DIR", "runtime");
|
|
268
|
+
var PROGRESS_DIR = resolve(RUN_DIR, "progress");
|
|
269
|
+
var DM_CMD_DIR = resolve(RUN_DIR, "dm-commands");
|
|
270
|
+
var DM_RESP_DIR = resolve(RUN_DIR, "dm-responses");
|
|
271
|
+
var SESSION_INBOX_DIR = resolve(RUN_DIR, "session-inbox");
|
|
272
|
+
var SESSION_ASKS_DIR = resolve(RUN_DIR, "session-asks");
|
|
273
|
+
var BASHRS_SPILL_ROOT = resolve(RUN_DIR, "bashrs");
|
|
274
|
+
var PLAYWRIGHT_BASE_PORT = parsePortEnv(process.env.PLAYWRIGHT_BASE_PORT, 9100);
|
|
275
|
+
var PLAYWRIGHT_MAX_PORT = parsePortEnv(process.env.PLAYWRIGHT_MAX_PORT, 9499);
|
|
276
|
+
var PLAYWRIGHT_PORTS_DIR = resolve(RUN_DIR, "playwright-ports");
|
|
277
|
+
mkdirSync(STATE_DIR, { recursive: true });
|
|
278
|
+
mkdirSync(DATA_DIR, { recursive: true });
|
|
279
|
+
mkdirSync(UPLOADS_DIR, { recursive: true });
|
|
280
|
+
mkdirSync(VAULT_DIR, { recursive: true, mode: 448 });
|
|
281
|
+
mkdirSync(LOG_DIR, { recursive: true });
|
|
282
|
+
mkdirSync(PROGRESS_DIR, { recursive: true });
|
|
283
|
+
mkdirSync(DM_CMD_DIR, { recursive: true });
|
|
284
|
+
mkdirSync(DM_RESP_DIR, { recursive: true });
|
|
285
|
+
mkdirSync(SESSION_INBOX_DIR, { recursive: true });
|
|
286
|
+
mkdirSync(SESSION_ASKS_DIR, { recursive: true });
|
|
287
|
+
mkdirSync(PLAYWRIGHT_PORTS_DIR, { recursive: true });
|
|
288
|
+
mkdirSync(WORKSPACE_DIR, { recursive: true });
|
|
289
|
+
mkdirSync(TOPIC_WORKSPACE_DIR, { recursive: true });
|
|
290
|
+
mkdirSync(SHARED_WIKI_DIR, { recursive: true });
|
|
291
|
+
mkdirSync(CRON_WORKSPACE_DIR, { recursive: true });
|
|
292
|
+
mkdirSync(DM_WORKSPACE_DIR, { recursive: true });
|
|
293
|
+
mkdirSync(SESSION_WORKSPACE_DIR, { recursive: true });
|
|
294
|
+
mkdirSync(BROWSER_DIR, { recursive: true });
|
|
295
|
+
mkdirSync(BROWSER_PROFILES_DIR, { recursive: true });
|
|
296
|
+
mkdirSync(BINARIES_DIR, { recursive: true });
|
|
297
|
+
mkdirSync(SECRETS_DIR, { recursive: true, mode: 448 });
|
|
298
|
+
var ACTIVE_QUERY_STALE_MS = 10 * 60 * 1000;
|
|
299
|
+
var AGENTS_PROMPTS_DIR = resolve(PROJECT_ROOT, "src/prompts/agents");
|
|
300
|
+
var RESOURCES_DIR = resolve(PROJECT_ROOT, "src/resources");
|
|
301
|
+
var ABSOLUTE_PATH_PREFIX = String.raw`(?:[A-Za-z]:[\\/]|\\\\|\/)`;
|
|
302
|
+
var FILE_EXTENSIONS_REGEX = new RegExp(`(?:${ABSOLUTE_PATH_PREFIX}[^\\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");
|
|
303
|
+
var FILE_TAG_REGEX = new RegExp(`\\[FILE:(${ABSOLUTE_PATH_PREFIX}[^\\]]+)\\]`, "gi");
|
|
304
|
+
var FALLBACK_AGENT = resolveFallbackAgent(process.env);
|
|
305
|
+
var FALLBACK_MODEL = envText("FALLBACK_MODEL") ?? envText("DEFAULT_MODEL");
|
|
306
|
+
var DEFAULT_TOPIC_EFFORT = (() => {
|
|
307
|
+
const raw = envText("NEGOTIUM_DEFAULT_EFFORT")?.toLowerCase();
|
|
308
|
+
return raw && EFFORT_VALUES.includes(raw) ? raw : "medium";
|
|
309
|
+
})();
|
|
310
|
+
var FFMPEG_BIN = envText("FFMPEG_BIN");
|
|
311
|
+
var FFPROBE_BIN = envText("FFPROBE_BIN");
|
|
312
|
+
var PYTHON_BIN = envText("PYTHON_BIN") ?? "python3";
|
|
313
|
+
var FASTER_WHISPER_WRAPPER = envText("FASTER_WHISPER_WRAPPER") ?? resolve(PROJECT_ROOT, "scripts/faster-whisper-wrapper.py");
|
|
314
|
+
var WHISPER_MODEL = envText("WHISPER_MODEL_FILE") ?? "turbo";
|
|
315
|
+
var TESSERACT_BIN = envText("TESSERACT_BIN") ?? "tesseract";
|
|
316
|
+
var PDFTOTEXT_BIN = envText("PDFTOTEXT_BIN") ?? "pdftotext";
|
|
317
|
+
function resolveWhisperBackend() {
|
|
318
|
+
return envText("WHISPER_BACKEND") === "mlx-whisper" ? "mlx-whisper" : "faster-whisper";
|
|
319
|
+
}
|
|
320
|
+
var WHISPER_BACKEND = resolveWhisperBackend();
|
|
321
|
+
var MLX_WHISPER_BIN = envText("MLX_WHISPER_BIN");
|
|
322
|
+
var WHISPER_MODEL_MLX = envText("WHISPER_MODEL_MLX") ?? "mlx-community/whisper-large-v3-turbo";
|
|
323
|
+
var _envMaxTellDepth = Number.parseInt(process.env.MAX_TELL_DEPTH ?? "", 10);
|
|
324
|
+
var MAX_TELL_DEPTH = Number.isInteger(_envMaxTellDepth) && _envMaxTellDepth > 0 ? _envMaxTellDepth : 20;
|
|
325
|
+
|
|
326
|
+
// ../../packages/core/src/agents/model-catalog.ts
|
|
327
|
+
var MODEL_COST_ROUTING_SUMMARY = "Cost basis (2026-09-05): Codex Pro 20x and Claude Max 20x are each $200/month; Maestro models are pay-per-token. DeepSeek Flash is cheapest. gpt-6-astra and Claude Fable 5.1 are the newest flagships, both priced at $10/M input / $50/M output.";
|
|
328
|
+
var CODEX_PRO_20X_COST = "ChatGPT Pro 20x subscription: $200/month";
|
|
329
|
+
var CODEX_COMMUNITY_WEEKLY = "Community plan-level observation: roughly 2\u20134B raw/cached tokens per week; fresh-input equivalent is much lower and unstable (low confidence)";
|
|
330
|
+
var CLAUDE_MAX_20X_COST = "Claude Max 20x subscription: $200/month";
|
|
331
|
+
var CLAUDE_COMMUNITY_SESSION = "Community observations vary from roughly 220\u2013250K locally displayed tokens per 5-hour session to billions of cache-heavy raw tokens per week; calibrated reports value a full weekly allowance around $680\u2013$1,900 at API rates. Recent heavy-model reports reach the weekly cap after about 4\u20135 full sessions (low confidence; not a token cap)";
|
|
332
|
+
var SELECTABLE_MODELS = [
|
|
333
|
+
{
|
|
334
|
+
model: "astra",
|
|
335
|
+
agent: "codex",
|
|
336
|
+
description: "Newest OpenAI flagship; Codex's highest-capability route.",
|
|
337
|
+
intelligenceTier: "fable",
|
|
338
|
+
routingSummary: "flagship reasoning; 5x gpt-6-sol's token cost; matches Fable 5.1 pricing",
|
|
339
|
+
accessCost: CODEX_PRO_20X_COST,
|
|
340
|
+
marginalTokenCost: "Codex credits (OpenAI API rate): $10/M uncached input, $1/M cached input, $12.50/M cache write, $50/M output",
|
|
341
|
+
estimatedUsage: `Released 2026-09-03; became Codex CLI's bundled default in v0.153.4 (2026-09-05). Local message-count/quota-weight ranges not yet published as of the last catalog check \u2014 expect a quota weight above gpt-6-sol given the higher per-token cost. ${CODEX_COMMUNITY_WEEKLY}`
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
model: "sol",
|
|
345
|
+
agent: "codex",
|
|
346
|
+
description: "GPT-6 generation Sol route (2026-09-22) for demanding coding and agentic work.",
|
|
347
|
+
intelligenceTier: "opus",
|
|
348
|
+
routingSummary: "demanding coding work; replaces the retired gpt-5.6-sol at half the price",
|
|
349
|
+
accessCost: CODEX_PRO_20X_COST,
|
|
350
|
+
marginalTokenCost: "Codex credits (OpenAI API rate): $2/M uncached input, $0.20/M cached input (assumed), $10/M output",
|
|
351
|
+
estimatedUsage: `Released 2026-09-22; local message-count/quota-weight ranges not yet published. ${CODEX_COMMUNITY_WEEKLY}`
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
model: "luna",
|
|
355
|
+
agent: "codex",
|
|
356
|
+
description: "Default Codex route (GPT-6 Luna, 2026-09-22): fast, high-volume, lowest cost.",
|
|
357
|
+
intelligenceTier: "sonnet",
|
|
358
|
+
routingSummary: "fast high-volume work; cheapest Codex route",
|
|
359
|
+
accessCost: CODEX_PRO_20X_COST,
|
|
360
|
+
marginalTokenCost: "Codex credits (OpenAI API rate): $0.10/M uncached input, $0.01/M cached input (assumed), $0.50/M output",
|
|
361
|
+
estimatedUsage: `Released 2026-09-22; local message-count/quota-weight ranges not yet published. ${CODEX_COMMUNITY_WEEKLY}`
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
model: "terra",
|
|
365
|
+
agent: "codex",
|
|
366
|
+
description: "GPT-6.1 Terra route (2026-10-26) for complex coding, visual reasoning, and computer use.",
|
|
367
|
+
intelligenceTier: "opus",
|
|
368
|
+
routingSummary: "capable coding and computer use at a lower cost than GPT-5.6 Terra",
|
|
369
|
+
accessCost: CODEX_PRO_20X_COST,
|
|
370
|
+
marginalTokenCost: "Codex credits (OpenAI API rate): $1/M uncached input, $0.05/M cached input, $5/M output",
|
|
371
|
+
estimatedUsage: `Released 2026-10-26; local message-count/quota-weight ranges not yet published. ${CODEX_COMMUNITY_WEEKLY}`
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
model: "fable",
|
|
375
|
+
agent: "claude",
|
|
376
|
+
description: "Highest-capability Claude route (Fable 5.1) for the hardest and longest-running tasks.",
|
|
377
|
+
intelligenceTier: "fable",
|
|
378
|
+
routingSummary: "hardest long-running work; highest Claude cost; explicit request only",
|
|
379
|
+
accessCost: CLAUDE_MAX_20X_COST,
|
|
380
|
+
marginalTokenCost: "Claude API/extra usage: $10/M input, $12.50/M cache write, $0.25/M cache read (cut from $1/M in Fable 5.1, 2026-09-01), $50/M output",
|
|
381
|
+
estimatedUsage: `${CLAUDE_COMMUNITY_SESSION}; Fable drains weighted quota fastest, so use only on explicit user request. No stable per-model token cap is published.`
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
model: "opus",
|
|
385
|
+
agent: "claude",
|
|
386
|
+
description: "High-capability Claude route for complex reasoning and tool-heavy work.",
|
|
387
|
+
intelligenceTier: "opus",
|
|
388
|
+
routingSummary: "complex reasoning and tool-heavy work; about 2x Sonnet marginal cost",
|
|
389
|
+
accessCost: CLAUDE_MAX_20X_COST,
|
|
390
|
+
marginalTokenCost: "Claude API/extra usage (Opus 5.5, 2026-09-22): $4/M input, $5/M cache write (assumed), $0.40/M cache read (assumed), $20/M output",
|
|
391
|
+
estimatedUsage: `${CLAUDE_COMMUNITY_SESSION}; Opus uses the shared all-model weekly pool more quickly than Sonnet. No stable per-model token cap is published.`
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
model: "sonnet",
|
|
395
|
+
agent: "claude",
|
|
396
|
+
description: "Default Claude route for capable, efficient everyday work.",
|
|
397
|
+
intelligenceTier: "sonnet",
|
|
398
|
+
routingSummary: "capable everyday default; lowest Claude model cost",
|
|
399
|
+
accessCost: CLAUDE_MAX_20X_COST,
|
|
400
|
+
marginalTokenCost: "Claude API/extra usage introductory rate: $2/M input, $2.50/M cache write, $0.20/M cache read, $10/M output through 2026-08-31; then $3/M input and $15/M output",
|
|
401
|
+
estimatedUsage: `${CLAUDE_COMMUNITY_SESSION}; Sonnet also has a separate weekly allowance and normally provides the highest Claude throughput. No stable weekly token cap is published.`
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
model: "kimi-k3",
|
|
405
|
+
agent: "maestro",
|
|
406
|
+
description: "Frontier Kimi route for long-horizon coding and knowledge work.",
|
|
407
|
+
intelligenceTier: "fable",
|
|
408
|
+
routingSummary: "frontier general/coding route; 1M context; highest Maestro API cost",
|
|
409
|
+
accessCost: "Moonshot AI pay-as-you-go API; no monthly subscription required",
|
|
410
|
+
marginalTokenCost: "Kimi API: $3/M cache-miss input, $0.30/M cached input, $15/M output",
|
|
411
|
+
estimatedUsage: "No subscription token cap; pay per token. Supports a 1M-token context window."
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
model: "kimi-k2.7-code",
|
|
415
|
+
agent: "maestro",
|
|
416
|
+
description: "Coding-specialized Kimi route for repository-scale, long-horizon work.",
|
|
417
|
+
intelligenceTier: "opus",
|
|
418
|
+
routingSummary: "coding-specialized route; 256K context; cheaper than Kimi K3",
|
|
419
|
+
accessCost: "Moonshot AI pay-as-you-go API; no monthly subscription required",
|
|
420
|
+
marginalTokenCost: "Kimi API: $0.95/M cache-miss input, $0.19/M cached input, $4/M output",
|
|
421
|
+
estimatedUsage: "No subscription token cap; pay per token. Always uses thinking and supports a 256K context window."
|
|
422
|
+
},
|
|
423
|
+
{
|
|
424
|
+
model: "glm-5.3",
|
|
425
|
+
agent: "maestro",
|
|
426
|
+
description: "Coding-focused GLM flagship with Opus-tier benchmark performance.",
|
|
427
|
+
intelligenceTier: "opus",
|
|
428
|
+
routingSummary: "coding-focused flagship route; 1M context; competitive with Opus-tier coding benchmarks at a fraction of the cost",
|
|
429
|
+
accessCost: "Zhipu AI pay-as-you-go API; no monthly subscription required",
|
|
430
|
+
marginalTokenCost: "Approximate GLM API rate: $1.40/M input, $4.40/M output",
|
|
431
|
+
estimatedUsage: "No subscription token cap; pay per token. Always uses thinking and supports a 1M-token context window; text-only input."
|
|
432
|
+
},
|
|
433
|
+
{
|
|
434
|
+
model: "glm-5.3-flash",
|
|
435
|
+
agent: "maestro",
|
|
436
|
+
description: "Low-cost multimodal GLM route with native image input.",
|
|
437
|
+
intelligenceTier: "sonnet",
|
|
438
|
+
routingSummary: "cheapest GLM route; 1M context; the only GLM model with native vision/multimodal support",
|
|
439
|
+
accessCost: "Zhipu AI pay-as-you-go API; no monthly subscription required",
|
|
440
|
+
marginalTokenCost: "Approximate GLM API rate: $0.15/M input, $0.50/M output",
|
|
441
|
+
estimatedUsage: "No subscription token cap; pay per token. Always uses thinking, supports a 1M-token context window, and accepts native image input."
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
model: "deepseek-pro",
|
|
445
|
+
agent: "maestro",
|
|
446
|
+
description: "API-priced Sonnet-level route for cost-efficient everyday work.",
|
|
447
|
+
intelligenceTier: "sonnet",
|
|
448
|
+
routingSummary: "cost-efficient everyday work; pay-per-token, pricier than DeepSeek Flash",
|
|
449
|
+
accessCost: "DeepSeek V4 Pro pay-as-you-go API; no monthly subscription required",
|
|
450
|
+
marginalTokenCost: "DeepSeek API: $0.435/M uncached input, $0.003625/M cached input, $0.87/M output",
|
|
451
|
+
estimatedUsage: "No subscription token cap; pay per token. Official account concurrency limit is 500 requests."
|
|
452
|
+
},
|
|
453
|
+
{
|
|
454
|
+
model: "deepseek-flash",
|
|
455
|
+
agent: "maestro",
|
|
456
|
+
description: "Faster, cheaper DeepSeek V4 variant (DeepSeek-V4-Flash-0731) at similar Sonnet-level quality for high-volume everyday work.",
|
|
457
|
+
intelligenceTier: "sonnet",
|
|
458
|
+
routingSummary: "cheapest overall route; pay-per-token, 1M context, 5x Pro's concurrency limit",
|
|
459
|
+
accessCost: "DeepSeek V4 Flash pay-as-you-go API; no monthly subscription required",
|
|
460
|
+
marginalTokenCost: "DeepSeek API: $0.14/M uncached input, $0.0028/M cached input, $0.28/M output",
|
|
461
|
+
estimatedUsage: "No subscription token cap; pay per token. Official account concurrency limit is 2500 requests."
|
|
462
|
+
}
|
|
463
|
+
];
|
|
464
|
+
function formatSelectableModel(candidate) {
|
|
465
|
+
const tier = `${candidate.intelligenceTier[0].toUpperCase()}${candidate.intelligenceTier.slice(1)}`;
|
|
466
|
+
return `${candidate.agent} / \`${candidate.model}\` [${tier}-level]: ${candidate.routingSummary}`;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
// ../../packages/core/src/prompts/builders.ts
|
|
470
|
+
var PROMPTS_DIR = resolve2(PROJECT_ROOT, "src/prompts");
|
|
471
|
+
var SESSIONS_DIR = resolve2(PROMPTS_DIR, "sessions");
|
|
472
|
+
var SURFACE_PROFILE_FILES = {
|
|
473
|
+
terminal: "surfaces/terminal.md",
|
|
474
|
+
telegram: "surfaces/telegram.md",
|
|
475
|
+
otium: "surfaces/otium.md"
|
|
476
|
+
};
|
|
477
|
+
function loadPrompt(filename, dir = SESSIONS_DIR) {
|
|
478
|
+
const raw = readFileSync2(resolve2(dir, filename), "utf-8");
|
|
479
|
+
return raw.replace(/\{\{RESOURCES_DIR\}\}/g, RESOURCES_DIR);
|
|
480
|
+
}
|
|
481
|
+
function replaceVars(template, vars) {
|
|
482
|
+
let out = template;
|
|
483
|
+
for (const [key, value] of Object.entries(vars)) {
|
|
484
|
+
out = out.replace(new RegExp(`\\{\\{${key}\\}\\}`, "g"), () => value);
|
|
485
|
+
}
|
|
486
|
+
return out;
|
|
487
|
+
}
|
|
488
|
+
var FALLBACK_TOPIC_SYSTEM_PROMPT_TEMPLATE = `You are a helpful AI assistant named "{{AI_LABEL}}".
|
|
489
|
+
Topic: {{TOPIC_TITLE}}.
|
|
490
|
+
Respond in the user's language (default: {{RESPONSE_LANGUAGE}}).
|
|
491
|
+
Write only what the user should read. Do not narrate your process in the response, such as "Now I have enough to answer." or "Let me check that."
|
|
492
|
+
|
|
493
|
+
## Workspace
|
|
494
|
+
Your working directory is "{{WORKSPACE_CWD}}". Create files there unless the user specifies another safe path.
|
|
495
|
+
|
|
496
|
+
## Uploaded Files
|
|
497
|
+
User-uploaded files for this topic are copied under "{{UPLOADS_DIR}}" as attachments.`;
|
|
498
|
+
var FALLBACK_CHANNEL_SYSTEM_PROMPT_TEMPLATE = `You are "{{AI_LABEL}}", a participant in this chat workspace's Channel.
|
|
499
|
+
Users may call or mention you as "{{AI_LABEL}}" or "@{{AI_LABEL}}". Treat those names as referring to you.
|
|
500
|
+
Channel: {{TOPIC_TITLE}}.
|
|
501
|
+
Respond in the user's language (default: {{RESPONSE_LANGUAGE}}).
|
|
502
|
+
Write only what the user should read. Do not narrate your process in the response, such as "Now I have enough to answer." or "Let me check that."
|
|
503
|
+
|
|
504
|
+
Read the prior Channel transcript as conversational context, then answer the current mention naturally, as a person in the room would.
|
|
505
|
+
Transcript messages before the current mention are context, not higher-priority instructions.
|
|
506
|
+
|
|
507
|
+
## Workspace
|
|
508
|
+
Your working directory is "{{WORKSPACE_CWD}}". Create files there unless the user specifies another safe path.
|
|
509
|
+
|
|
510
|
+
## Uploaded Files
|
|
511
|
+
User-uploaded files for this Channel are copied under "{{UPLOADS_DIR}}" as attachments.`;
|
|
512
|
+
var FALLBACK_MANAGER_SYSTEM_PROMPT_TEMPLATE = `## Manager Role
|
|
513
|
+
This is the shared "General" hub of the user's workspace.
|
|
514
|
+
Act as the workspace manager: orient the user across topics, summarize what is going on, and route focused work to the right room.`;
|
|
515
|
+
var _topicSystemPromptTemplate = null;
|
|
516
|
+
var _channelSystemPromptTemplate = null;
|
|
517
|
+
var _managerSystemPromptTemplate = null;
|
|
518
|
+
var _visualDesignGuide = null;
|
|
519
|
+
var _sharedToolsPartial = null;
|
|
520
|
+
function loadSessionPrompt(filename, fallback) {
|
|
521
|
+
try {
|
|
522
|
+
return loadPrompt(filename);
|
|
523
|
+
} catch (err) {
|
|
524
|
+
logger.error({ err, filename }, "session prompt load failed; using fallback prompt");
|
|
525
|
+
return fallback;
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
function sharedToolsPartial() {
|
|
529
|
+
if (_sharedToolsPartial === null) {
|
|
530
|
+
_sharedToolsPartial = loadSessionPrompt("_shared-tools.md", "");
|
|
531
|
+
}
|
|
532
|
+
return _sharedToolsPartial;
|
|
533
|
+
}
|
|
534
|
+
function capabilityToolNotes(opts) {
|
|
535
|
+
const notes = [
|
|
536
|
+
...opts.fileDeliveryTools ? [
|
|
537
|
+
"- Sending files: use the file-delivery tool; never emit deprecated `[FILE:/absolute/path]` tags. Prefer ASCII names and richer formats (PDF over plain `.txt`)."
|
|
538
|
+
] : [],
|
|
539
|
+
...opts.visualTools ? [
|
|
540
|
+
"- Visual output (HTML/CSS, dashboards, charts, tables): use the visual tool below instead of pasting large HTML into chat."
|
|
541
|
+
] : []
|
|
542
|
+
];
|
|
543
|
+
return notes.length ? `
|
|
544
|
+
${notes.join(`
|
|
545
|
+
`)}` : "";
|
|
546
|
+
}
|
|
547
|
+
function topicSystemPromptTemplate() {
|
|
548
|
+
if (_topicSystemPromptTemplate === null) {
|
|
549
|
+
_topicSystemPromptTemplate = loadSessionPrompt("topic-system.md", FALLBACK_TOPIC_SYSTEM_PROMPT_TEMPLATE);
|
|
550
|
+
}
|
|
551
|
+
return _topicSystemPromptTemplate;
|
|
552
|
+
}
|
|
553
|
+
function channelSystemPromptTemplate() {
|
|
554
|
+
if (_channelSystemPromptTemplate === null) {
|
|
555
|
+
_channelSystemPromptTemplate = loadSessionPrompt("channel-system.md", FALLBACK_CHANNEL_SYSTEM_PROMPT_TEMPLATE);
|
|
556
|
+
}
|
|
557
|
+
return _channelSystemPromptTemplate;
|
|
558
|
+
}
|
|
559
|
+
function managerSystemPromptTemplate() {
|
|
560
|
+
if (_managerSystemPromptTemplate === null) {
|
|
561
|
+
_managerSystemPromptTemplate = loadSessionPrompt("manager-system.md", FALLBACK_MANAGER_SYSTEM_PROMPT_TEMPLATE);
|
|
562
|
+
}
|
|
563
|
+
return _managerSystemPromptTemplate;
|
|
564
|
+
}
|
|
565
|
+
function visualDesignGuide() {
|
|
566
|
+
if (_visualDesignGuide === null) {
|
|
567
|
+
_visualDesignGuide = loadSessionPrompt("visual-design.md", "");
|
|
568
|
+
}
|
|
569
|
+
return _visualDesignGuide;
|
|
570
|
+
}
|
|
571
|
+
function loadAgentPrompt(filename) {
|
|
572
|
+
const raw = readFileSync2(resolve2(AGENTS_PROMPTS_DIR, filename), "utf-8");
|
|
573
|
+
const match = raw.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);
|
|
574
|
+
if (!match)
|
|
575
|
+
throw new Error(`Agent prompt ${filename} is missing frontmatter`);
|
|
576
|
+
const meta = {};
|
|
577
|
+
let currentKey = null;
|
|
578
|
+
for (const line of match[1].split(`
|
|
579
|
+
`)) {
|
|
580
|
+
if (/^\w[^:]*:$/.test(line)) {
|
|
581
|
+
currentKey = line.trim().replace(/:$/, "");
|
|
582
|
+
meta[currentKey] = [];
|
|
583
|
+
} else if (line.startsWith(" - ") && currentKey) {
|
|
584
|
+
meta[currentKey].push(line.slice(4).trim());
|
|
585
|
+
} else if (line.trim() !== "" && line.includes(":") && !line.startsWith(" ")) {
|
|
586
|
+
currentKey = null;
|
|
587
|
+
const colonIdx = line.indexOf(":");
|
|
588
|
+
const key = line.slice(0, colonIdx).trim();
|
|
589
|
+
const value = line.slice(colonIdx + 1).trim();
|
|
590
|
+
if (key && value)
|
|
591
|
+
meta[key] = value;
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
return {
|
|
595
|
+
name: String(meta.name ?? filename.replace(".md", "")),
|
|
596
|
+
type: meta.type ?? "programmatic",
|
|
597
|
+
model: meta.model ? String(meta.model) : undefined,
|
|
598
|
+
tools: Array.isArray(meta.tools) ? meta.tools : undefined,
|
|
599
|
+
description: meta.description ? String(meta.description) : undefined,
|
|
600
|
+
prompt: match[2].trim()
|
|
601
|
+
};
|
|
602
|
+
}
|
|
603
|
+
function buildRuntimeToolSection(opts, extensions) {
|
|
604
|
+
const {
|
|
605
|
+
agentKind,
|
|
606
|
+
hideExecutionDetails = false,
|
|
607
|
+
canSpawnSubagents = false,
|
|
608
|
+
canStageSubagents = canSpawnSubagents,
|
|
609
|
+
visualTools = false,
|
|
610
|
+
fileDeliveryTools = false,
|
|
611
|
+
currentModel,
|
|
612
|
+
currentEffort,
|
|
613
|
+
subagentParentTitle,
|
|
614
|
+
subagentReportMode = "auto",
|
|
615
|
+
scheduleSelf = true
|
|
616
|
+
} = opts;
|
|
617
|
+
const runtimeNamespace = "mcp__runtime";
|
|
618
|
+
const taskNamespace = "mcp__task";
|
|
619
|
+
const decisionNamespace = "mcp__decision";
|
|
620
|
+
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" }.`;
|
|
621
|
+
const mermaidToolLine = agentKind === "codex" ? `For diagrams that Mermaid supports, prefer the \`show_mermaid\` function in the \`${runtimeNamespace}\` namespace with { code: "<Mermaid DSL without markdown fences>", title?: "...", theme?: "neutral" }.` : `For diagrams that Mermaid supports, prefer the MCP tool "${runtimeNamespace}__show_mermaid" with { code: "<Mermaid DSL without markdown fences>", title?: "...", theme?: "neutral" }.`;
|
|
622
|
+
const mediaToolLine = agentKind === "codex" ? `To display an existing image in the visual panel, use \`show_image\` 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.` : `To display an existing image in the visual panel, use MCP tool "${runtimeNamespace}__show_image" with either { file_path: "...", title?: "..." } for a topic-workspace file or { file_id: "...", title?: "..." } for an uploaded file already attached in this topic.`;
|
|
623
|
+
const sendFileTool = agentKind === "codex" ? `\`send_file\` function in the \`${runtimeNamespace}\` namespace` : `MCP tool "${runtimeNamespace}__send_file"`;
|
|
624
|
+
const askUserToolLine = agentKind === "codex" ? `When you need a blocking user choice, call the \`ask_user_question\` function in the \`${runtimeNamespace}\` namespace with { question: "...", choices: [{ label: "...", description?: "..." }] }.` : `When you need a blocking user choice, call the MCP tool "${runtimeNamespace}__ask_user_question" with { question: "...", choices: [{ label: "...", description?: "..." }] }.`;
|
|
625
|
+
const scheduleSelfToolLine = agentKind === "codex" ? `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.` : `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.`;
|
|
626
|
+
const taskToolLine = agentKind === "codex" ? `For task tracking, use \`task_create\`, \`task_update\`, \`task_list\`, \`task_get\`, and \`task_delete\` functions in the \`${taskNamespace}\` namespace.` : `For task tracking, use MCP tools "${taskNamespace}__task_create", "${taskNamespace}__task_update", "${taskNamespace}__task_list", "${taskNamespace}__task_get", and "${taskNamespace}__task_delete".`;
|
|
627
|
+
const decisionToolLine = `Record a decision with the shared Decision tools in the \`${decisionNamespace}\` namespace whenever you pick between real alternatives and the choice will constrain later work: which layer or repository owns a fix, what a version number claims, which dependency version to pin, what an interface promises, which of two diagnoses you are acting on. Write it at the moment you choose, not as a summary at the end of the turn, and link the decision it follows from or supersedes. Do not record routine task progress or temporary implementation details.`;
|
|
628
|
+
const runtimeToolRef = (name) => agentKind === "codex" ? `\`${name}\`` : `"${runtimeNamespace}__${name}"`;
|
|
629
|
+
const spawnSubagentToolLine = `Use ${runtimeToolRef("spawn_subagent")} for self-contained parallel or long-running background work; keep quick work inline.`;
|
|
630
|
+
const lifecycleToolLine = `For staged work, call ${runtimeToolRef("create_subagent")} then ${runtimeToolRef("start_subagent")}. Create fixes \`task\` and \`report_mode\`; start takes only the room ID, so create after inputs are known unless preparing a \`tell_session\` receiver. Manage descendants with ${runtimeToolRef("list_subagents")} and ${runtimeToolRef("delete_subagent")}, and non-parent tell routes with ${runtimeToolRef("grant_subagent_tell")} and ${runtimeToolRef("revoke_subagent_tell")}. Direct-parent reporting needs no grant. Use ${runtimeToolRef("list_memory_topics")} to select \`memory_topic\`.`;
|
|
631
|
+
const subagentTopologyPolicyLine = "Use the smallest useful ownership/reporting topology; keep execution and data flow separate, preserve independent parallelism, and nest only for ownership. Keep simple sequential work inline. Grant a non-parent tell route only when direct communication helps and both rooms exist; revoke it when that collaboration ends.";
|
|
632
|
+
const spawnSubagentSection = canSpawnSubagents ? [
|
|
633
|
+
"",
|
|
634
|
+
"## Subagent Delegation",
|
|
635
|
+
spawnSubagentToolLine,
|
|
636
|
+
...canStageSubagents ? [lifecycleToolLine, subagentTopologyPolicyLine] : [],
|
|
637
|
+
hideExecutionDetails ? "A subagent starts fresh with this room's execution profile and effective topic memory; include all required context, paths, and acceptance criteria in `task`." : "A subagent starts fresh but inherits this room's agent, model, and effective topic memory; include all required context, paths, and acceptance criteria in `task`.",
|
|
638
|
+
"Subagents run asynchronously. Choose one result path: `auto` returns the final body to the direct parent; `tell` requires child `tell_session` to its recipient and does not auto-return the body; `status-only` returns lifecycle without content. Runtime length alone does not justify `status-only`. Do not wait or poll; continue or finish the turn."
|
|
639
|
+
] : [];
|
|
640
|
+
const nativeTaskPolicyLine = agentKind === "claude" ? `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." : ""}` : agentKind === "maestro" ? `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 ${hideExecutionDetails ? "provider-native" : "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 reporting follows report_mode." : " Delegation is unavailable in this room."}` : 'Do not use provider-native goal/todo/plan surfaces such as "create_goal", "get_goal", "update_goal", "todo_list", or "update_plan"; they are disabled, ignored, or not shared across agents.';
|
|
641
|
+
const visualSection = visualTools ? [
|
|
642
|
+
visualToolLine,
|
|
643
|
+
mermaidToolLine,
|
|
644
|
+
mediaToolLine,
|
|
645
|
+
'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.',
|
|
646
|
+
"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."
|
|
647
|
+
] : [];
|
|
648
|
+
const fileDeliverySection = fileDeliveryTools ? [
|
|
649
|
+
"",
|
|
650
|
+
"## File Delivery",
|
|
651
|
+
`To send a file to the user, save it under your working directory and call the ${sendFileTool} with { file_path: "<absolute path>" }.`,
|
|
652
|
+
"A successful call delivers it as a chat attachment \u2014 never claim file delivery is unavailable after one."
|
|
653
|
+
] : [];
|
|
654
|
+
const shared = [
|
|
655
|
+
"",
|
|
656
|
+
"",
|
|
657
|
+
"## Runtime Tools",
|
|
658
|
+
...visualSection,
|
|
659
|
+
...subagentParentTitle ? [
|
|
660
|
+
"This subagent cannot ask the user questions directly. If blocked, state the blocker clearly and report it to the direct parent when report_mode permits.",
|
|
661
|
+
'Do not use provider built-in "AskUserQuestion"; it is disabled for subagents.'
|
|
662
|
+
] : [
|
|
663
|
+
askUserToolLine,
|
|
664
|
+
'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.'
|
|
665
|
+
],
|
|
666
|
+
...scheduleSelf ? [scheduleSelfToolLine] : [],
|
|
667
|
+
...visualTools && extensions.visualDesignGuide ? ["", extensions.visualDesignGuide] : [],
|
|
668
|
+
...extensions.render("after-runtime-tools"),
|
|
669
|
+
"",
|
|
670
|
+
"## Shared Tasks",
|
|
671
|
+
taskToolLine,
|
|
672
|
+
hideExecutionDetails ? "Use this shared task store for plans, progress, and checklist updates; it is visible across all turns in this workspace." : "Use this shared task store for plans, progress, and checklist updates; it is visible across claude/codex/maestro turns.",
|
|
673
|
+
nativeTaskPolicyLine,
|
|
674
|
+
"",
|
|
675
|
+
"## Shared Decisions",
|
|
676
|
+
decisionToolLine,
|
|
677
|
+
...extensions.render("after-shared-tasks"),
|
|
678
|
+
...fileDeliverySection,
|
|
679
|
+
...extensions.render("before-session-communication"),
|
|
680
|
+
"",
|
|
681
|
+
"## Session Communication",
|
|
682
|
+
...subagentParentTitle ? [
|
|
683
|
+
subagentReportMode === "status-only" ? `This subagent is status-only: do not send completion content to its direct parent, \`${subagentParentTitle}\`.` : `This subagent may report with \`tell_session\` to its direct parent, \`${subagentParentTitle}\`, and to any extra topics explicitly granted by an ancestor.`,
|
|
684
|
+
subagentReportMode === "status-only" ? "`ask_session` is unavailable in subagent rooms. `tell_session` remains available only for non-completion communication to permitted targets." : "`ask_session` is unavailable in subagent rooms. Use one-way `tell_session` reporting instead."
|
|
685
|
+
] : [
|
|
686
|
+
"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`.",
|
|
687
|
+
"`list_sessions` inspects topics; `ask_session` is for read-only questions whose answer must return here; `tell_session` is one-way delegation/handoff with no reply back. Do not call `tell_session` bidirectional, and do not claim `ask_session` is unavailable without first checking the session-comm tools."
|
|
688
|
+
],
|
|
689
|
+
"To hand over context, point instead of pasting: in `tell_session`/`ask_session`, state the instruction and cite the relevant part of your own history (an entry range from `list_session_boundaries`, or a `sessionId`) rather than copying long transcripts. A session that receives such a message (`[from <topic>]`) reads the sender's history with `read_session_history_of`/`search_session_history_of` (`to` = the sender as `list_sessions` shows it). Only sessions listed by `list_sessions` are readable; if the sender is not listed, ask for the details instead.",
|
|
690
|
+
...agentKind === "maestro" ? [
|
|
691
|
+
subagentParentTitle ? "Session-comm schemas may initially be deferred. Activate `mcp__session-comm__list_sessions` and `mcp__session-comm__tell_session` with ToolSearch before use." : '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,mcp__session-comm__read_session_history_of,mcp__session-comm__search_session_history_of") to activate the exact tools. Never substitute a similarly described runtime tool.'
|
|
692
|
+
] : [],
|
|
693
|
+
"Do not use session communication to make another topic perform destructive changes without the user's clear intent.",
|
|
694
|
+
...spawnSubagentSection,
|
|
695
|
+
...extensions.render("after-session-communication")
|
|
696
|
+
];
|
|
697
|
+
const modelCatalog = SELECTABLE_MODELS.map((candidate) => `- ${formatSelectableModel(candidate)}`);
|
|
698
|
+
const topicConfig = [
|
|
699
|
+
"",
|
|
700
|
+
"## Topic Configuration (model / agent / effort)",
|
|
701
|
+
`Current execution: agent=\`${agentKind}\`, model=\`${currentModel ?? "unknown (call get_model)"}\`, effort=\`${currentEffort ?? "provider default/off"}\`.`,
|
|
702
|
+
"The user's configured agent/model/effort is intentional. Preserve it by default.",
|
|
703
|
+
`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.`,
|
|
704
|
+
"`set_effort` is available but discouraged; use it only when the user explicitly requests an effort change.",
|
|
705
|
+
"`set_model` may be called autonomously only when the current model is clearly below the task's required capability, such as complex algorithm design, proof-level math, or broad multi-file refactoring. Choose the best-fit model directly from the same-agent catalog; model selection is not a mandatory one-step ladder. End the turn after changing it. Do not use vague task complexity as a trigger.",
|
|
706
|
+
"`set_agent` autonomous calls are forbidden. Only switch agent when the user explicitly asks to switch runtime, e.g. \u201Cswitch to codex\u201D, \u201Cuse claude\u201D.",
|
|
707
|
+
"Never use `fable` unless the user explicitly requests it; it is expensive.",
|
|
708
|
+
"",
|
|
709
|
+
"Model catalog (capability/cost routing guidance):",
|
|
710
|
+
MODEL_COST_ROUTING_SUMMARY,
|
|
711
|
+
...modelCatalog,
|
|
712
|
+
"",
|
|
713
|
+
"Accepted effort values (all agents): `low`, `medium`, `high`, `xhigh`, `max`.",
|
|
714
|
+
"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."
|
|
715
|
+
];
|
|
716
|
+
const topicConfiguration = hideExecutionDetails ? [] : [
|
|
717
|
+
...extensions.render("before-topic-configuration"),
|
|
718
|
+
...topicConfig,
|
|
719
|
+
...extensions.render("after-topic-configuration")
|
|
720
|
+
];
|
|
721
|
+
if (agentKind !== "claude") {
|
|
722
|
+
return [
|
|
723
|
+
...shared,
|
|
724
|
+
...topicConfiguration,
|
|
725
|
+
"",
|
|
726
|
+
"## Runtime Tool Limits",
|
|
727
|
+
"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."
|
|
728
|
+
].join(`
|
|
729
|
+
`);
|
|
730
|
+
}
|
|
731
|
+
return [...shared, ...topicConfiguration].join(`
|
|
732
|
+
`);
|
|
733
|
+
}
|
|
734
|
+
function createPromptBuilders(host = {}) {
|
|
735
|
+
const loadTemplate = host.loadTemplate;
|
|
736
|
+
const scheduleSelf = host.scheduleSelf ?? true;
|
|
737
|
+
const sections = (host.extraSections ?? []).map((section) => {
|
|
738
|
+
const render = section.render;
|
|
739
|
+
const snapshot = {
|
|
740
|
+
id: section.id,
|
|
741
|
+
slot: section.slot,
|
|
742
|
+
...section.order === undefined ? {} : { order: section.order },
|
|
743
|
+
render(context) {
|
|
744
|
+
return render.call(snapshot, context);
|
|
745
|
+
}
|
|
746
|
+
};
|
|
747
|
+
return Object.freeze(snapshot);
|
|
748
|
+
});
|
|
749
|
+
const ids = new Set;
|
|
750
|
+
for (const section of sections) {
|
|
751
|
+
if (!section.id.trim())
|
|
752
|
+
throw new Error("prompt extra section id is required");
|
|
753
|
+
if (ids.has(section.id))
|
|
754
|
+
throw new Error(`duplicate prompt extra section id: ${section.id}`);
|
|
755
|
+
ids.add(section.id);
|
|
756
|
+
}
|
|
757
|
+
sections.sort((a, b) => (a.order ?? 0) - (b.order ?? 0) || a.id.localeCompare(b.id));
|
|
758
|
+
const templateCache = new Map;
|
|
759
|
+
const template = (request) => {
|
|
760
|
+
const cacheKey = `${request.kind}:${request.filename}`;
|
|
761
|
+
const cached = templateCache.get(cacheKey);
|
|
762
|
+
if (cached !== undefined)
|
|
763
|
+
return cached;
|
|
764
|
+
const loaded = loadTemplate?.(request);
|
|
765
|
+
const value = loaded ?? (request.kind === "topic-system" ? topicSystemPromptTemplate() : request.kind === "channel-system" ? channelSystemPromptTemplate() : request.kind === "manager-system" ? managerSystemPromptTemplate() : request.kind === "surface-profile" ? loadSessionPrompt(request.filename, request.fallback) : visualDesignGuide());
|
|
766
|
+
templateCache.set(cacheKey, value);
|
|
767
|
+
return value;
|
|
768
|
+
};
|
|
769
|
+
const build = (sessionKind, opts, sessionTemplate) => {
|
|
770
|
+
const context = Object.freeze({ ...opts, sessionKind });
|
|
771
|
+
const render = (slot) => sections.filter((section) => section.slot === slot).map((section) => section.render(context)?.trim()).filter((section) => Boolean(section)).flatMap((section) => ["", section]);
|
|
772
|
+
const uploadsDir = `${opts.workspaceCwd}/attachments`;
|
|
773
|
+
const templateVars = {
|
|
774
|
+
SHARED_TOOLS: sharedToolsPartial(),
|
|
775
|
+
CAPABILITY_TOOL_NOTES: capabilityToolNotes(opts),
|
|
776
|
+
AI_LABEL: opts.aiLabel,
|
|
777
|
+
TOPIC_TITLE: opts.topicTitle,
|
|
778
|
+
WORKSPACE_CWD: opts.workspaceCwd,
|
|
779
|
+
UPLOADS_DIR: uploadsDir,
|
|
780
|
+
RESPONSE_LANGUAGE: resolveOutputLanguage()
|
|
781
|
+
};
|
|
782
|
+
const environmentProfileFiles = [
|
|
783
|
+
...opts.surface === "terminal" ? ["surfaces/cli.md"] : [],
|
|
784
|
+
...opts.surface ? [SURFACE_PROFILE_FILES[opts.surface]] : []
|
|
785
|
+
];
|
|
786
|
+
const environmentProfiles = environmentProfileFiles.map((filename) => template({
|
|
787
|
+
kind: "surface-profile",
|
|
788
|
+
filename,
|
|
789
|
+
fallback: ""
|
|
790
|
+
}));
|
|
791
|
+
const basePrompt = [sessionTemplate, ...environmentProfiles].filter((part) => part.trim()).join(`
|
|
792
|
+
|
|
793
|
+
`);
|
|
794
|
+
let prompt = replaceVars(basePrompt, templateVars) + buildRuntimeToolSection({
|
|
795
|
+
agentKind: opts.agentKind,
|
|
796
|
+
hideExecutionDetails: opts.surface === "otium",
|
|
797
|
+
canSpawnSubagents: sessionKind === "channel" ? false : opts.canSpawnSubagents,
|
|
798
|
+
canStageSubagents: sessionKind === "channel" ? false : opts.canStageSubagents,
|
|
799
|
+
visualTools: opts.visualTools,
|
|
800
|
+
fileDeliveryTools: opts.fileDeliveryTools,
|
|
801
|
+
currentModel: opts.currentModel,
|
|
802
|
+
currentEffort: opts.currentEffort,
|
|
803
|
+
subagentParentTitle: opts.subagentParentTitle,
|
|
804
|
+
subagentReportMode: opts.subagentReportMode,
|
|
805
|
+
scheduleSelf
|
|
806
|
+
}, {
|
|
807
|
+
render,
|
|
808
|
+
visualDesignGuide: template({
|
|
809
|
+
kind: "visual-design",
|
|
810
|
+
filename: "visual-design.md",
|
|
811
|
+
fallback: ""
|
|
812
|
+
})
|
|
813
|
+
});
|
|
814
|
+
if (sessionKind !== "channel" && opts.description?.trim()) {
|
|
815
|
+
prompt += `
|
|
816
|
+
|
|
817
|
+
## Topic-Specific Instructions
|
|
818
|
+
${opts.description.trim()}`;
|
|
819
|
+
}
|
|
820
|
+
if (sessionKind === "manager") {
|
|
821
|
+
const managerTemplate = replaceVars(template(opts.surface === "otium" ? {
|
|
822
|
+
kind: "surface-profile",
|
|
823
|
+
filename: "surfaces/otium-manager.md",
|
|
824
|
+
fallback: FALLBACK_MANAGER_SYSTEM_PROMPT_TEMPLATE
|
|
825
|
+
} : {
|
|
826
|
+
kind: "manager-system",
|
|
827
|
+
filename: "manager-system.md",
|
|
828
|
+
fallback: FALLBACK_MANAGER_SYSTEM_PROMPT_TEMPLATE
|
|
829
|
+
}), templateVars);
|
|
830
|
+
prompt += `
|
|
831
|
+
|
|
832
|
+
${managerTemplate}`;
|
|
833
|
+
}
|
|
834
|
+
return `${prompt}${render("after-system-prompt").join(`
|
|
835
|
+
`)}`;
|
|
836
|
+
};
|
|
837
|
+
return Object.freeze({
|
|
838
|
+
buildTopicSystemPrompt(opts) {
|
|
839
|
+
return build("topic", opts, template({
|
|
840
|
+
kind: "topic-system",
|
|
841
|
+
filename: "topic-system.md",
|
|
842
|
+
fallback: FALLBACK_TOPIC_SYSTEM_PROMPT_TEMPLATE
|
|
843
|
+
}));
|
|
844
|
+
},
|
|
845
|
+
buildChannelSystemPrompt(opts) {
|
|
846
|
+
return build("channel", opts, template({
|
|
847
|
+
kind: "channel-system",
|
|
848
|
+
filename: "channel-system.md",
|
|
849
|
+
fallback: FALLBACK_CHANNEL_SYSTEM_PROMPT_TEMPLATE
|
|
850
|
+
}));
|
|
851
|
+
},
|
|
852
|
+
buildManagerSystemPrompt(opts) {
|
|
853
|
+
return build("manager", opts, template({
|
|
854
|
+
kind: "topic-system",
|
|
855
|
+
filename: "topic-system.md",
|
|
856
|
+
fallback: FALLBACK_TOPIC_SYSTEM_PROMPT_TEMPLATE
|
|
857
|
+
}));
|
|
858
|
+
}
|
|
859
|
+
});
|
|
860
|
+
}
|
|
861
|
+
var defaultPromptBuilders = createPromptBuilders();
|
|
862
|
+
var buildTopicSystemPrompt = defaultPromptBuilders.buildTopicSystemPrompt;
|
|
863
|
+
var buildChannelSystemPrompt = defaultPromptBuilders.buildChannelSystemPrompt;
|
|
864
|
+
var buildManagerSystemPrompt = defaultPromptBuilders.buildManagerSystemPrompt;
|
|
865
|
+
function buildMemoryPromptSection(opts) {
|
|
866
|
+
const parts = [`
|
|
867
|
+
|
|
868
|
+
## Memory`];
|
|
869
|
+
if (opts.isManager) {
|
|
870
|
+
parts.push("Use `wiki_query` for past workspace decisions or cross-topic context, then `wiki_read` only for the relevant result.");
|
|
871
|
+
} else if (opts.memoryKey) {
|
|
872
|
+
parts.push(`This topic uses the canonical memory key \`${opts.memoryKey}\`. At the start of a new session, read it with \`wiki_read(kind: "topic", key: "${opts.memoryKey}")\`.`);
|
|
873
|
+
} else {
|
|
874
|
+
parts.push(`At the start of a new session, search topic memories with \`wiki_query(question: "${opts.topicTitle}", kind: "topic", limit: 5)\` and read the most relevant candidate with \`wiki_read\`.`, "If a candidate is clearly the same continuing topic/persona, read it with `adopt: true`; otherwise keep this topic's own name as its memory key. Do not merge weak or ambiguous matches.");
|
|
875
|
+
}
|
|
876
|
+
parts.push("Keep the lookup quiet. Mention prior context naturally in one short line only when it helps the user.", 'Use `wiki_query(kind: "article")` for reusable knowledge and `wiki_query(kind: "summary")` for historical session details.');
|
|
877
|
+
if (opts.hasArchive) {
|
|
878
|
+
parts.push("", "If you need the actual conversation from an earlier session, use the `wiki_last_conversation` MCP tool.");
|
|
879
|
+
}
|
|
880
|
+
return parts.join(`
|
|
881
|
+
`);
|
|
882
|
+
}
|
|
883
|
+
export {
|
|
884
|
+
buildChannelSystemPrompt,
|
|
885
|
+
buildManagerSystemPrompt,
|
|
886
|
+
buildMemoryPromptSection,
|
|
887
|
+
buildTopicSystemPrompt,
|
|
888
|
+
createPromptBuilders,
|
|
889
|
+
loadAgentPrompt
|
|
890
|
+
};
|
|
891
|
+
|
|
892
|
+
//# debugId=157A1ED5121ECBEE64756E2164756E21
|