@otium-team/negotium 0.0.0-stage → 0.23.11
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 +23903 -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 +2336 -0
- package/dist/browser-runtime.js.map +35 -0
- package/dist/canonical-mcp-bridge.js +14 -0
- package/dist/canonical-mcp-bridge.js.map +9 -0
- package/dist/chunk-0fenxbe6.js +173 -0
- package/dist/chunk-0fenxbe6.js.map +12 -0
- package/dist/chunk-2mx7fq49.js +6 -0
- package/dist/chunk-2mx7fq49.js.map +9 -0
- package/dist/chunk-ad7kxsaq.js +202 -0
- package/dist/chunk-ad7kxsaq.js.map +9 -0
- package/dist/chunk-da9ad838.js +3927 -0
- package/dist/chunk-da9ad838.js.map +47 -0
- package/dist/chunk-f7p0h1gs.js +54 -0
- package/dist/chunk-f7p0h1gs.js.map +10 -0
- package/dist/chunk-jtv8yzy1.js +206 -0
- package/dist/chunk-jtv8yzy1.js.map +10 -0
- package/dist/chunk-mxxwx5mg.js +375 -0
- package/dist/chunk-mxxwx5mg.js.map +13 -0
- package/dist/cron.js +1 -0
- package/dist/hosted-agent.js +5919 -0
- package/dist/hosted-agent.js.map +62 -0
- package/dist/main.js +60536 -0
- package/dist/main.js.map +338 -0
- package/dist/mcp-catalog.js +39 -0
- package/dist/mcp-catalog.js.map +10 -0
- package/dist/mcp-factories.js +26572 -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 +1073 -0
- package/dist/query-runtime.js.map +26 -0
- package/dist/registry.js +336 -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 +866 -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 +420 -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 +186 -0
- package/dist/runtime/src/application/vault-command.ts +170 -0
- package/dist/runtime/src/bus.ts +403 -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 +200 -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 +508 -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 +2284 -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 +848 -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-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 +805 -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 +582 -0
- package/dist/runtime/src/types.ts +395 -0
- package/dist/runtime/src/version.ts +1 -0
- package/dist/runtime/tsconfig.json +13 -0
- package/dist/runtime-gateway.js +453 -0
- package/dist/runtime-gateway.js.map +10 -0
- package/dist/runtime-helpers.js +1794 -0
- package/dist/runtime-helpers.js.map +40 -0
- package/dist/sqlite.js +68 -0
- package/dist/sqlite.js.map +10 -0
- package/dist/storage.js +5194 -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 +138 -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 +234 -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 +224 -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 +138 -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 +546 -0
- package/dist/types/packages/core/src/types.d.ts +384 -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 +850 -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
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export interface OutboxLogger {
|
|
2
|
+
debug(fields: Record<string, unknown>, message: string): void;
|
|
3
|
+
info(fields: Record<string, unknown>, message: string): void;
|
|
4
|
+
warn(fields: Record<string, unknown>, message: string): void;
|
|
5
|
+
error(fields: Record<string, unknown>, message: string): void;
|
|
6
|
+
}
|
|
7
|
+
export interface OutboxFileHost {
|
|
8
|
+
logger: OutboxLogger;
|
|
9
|
+
readJsonlLines(path: string): string[];
|
|
10
|
+
}
|
|
11
|
+
export interface OutboxFileOps {
|
|
12
|
+
isProcessingFile(name: string): boolean;
|
|
13
|
+
drainOutboxFile(filePath: string, label: string): {
|
|
14
|
+
lines: string[];
|
|
15
|
+
processingPath: string;
|
|
16
|
+
} | null;
|
|
17
|
+
deleteProcessingFile(processingPath: string, label: string, consumedLines?: number): void;
|
|
18
|
+
parseOutboxLine<T>(line: string, label: string): T | null;
|
|
19
|
+
processOutboxFile<T extends Record<string, unknown>>(filePath: string, label: string, handler: (entry: T) => Promise<void>, opts?: {
|
|
20
|
+
maxRetries?: number;
|
|
21
|
+
}): Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
/** True if `name` is an in-flight `.processing` claim file written by drainOutboxFile. */
|
|
24
|
+
export declare function isProcessingFile(name: string): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Atomically claim a .jsonl outbox file for processing.
|
|
27
|
+
* Recovers leftover .processing files from crashes, renames the pending file
|
|
28
|
+
* to .processing to prevent race conditions, and returns the parsed lines.
|
|
29
|
+
* Returns null if the file doesn't exist or can't be claimed.
|
|
30
|
+
*
|
|
31
|
+
* Partial-failure edge case: when a crash leftover is merged back into pending,
|
|
32
|
+
* `readFileSync` → `appendFileSync` → `unlinkSync` runs sequentially. If
|
|
33
|
+
* `appendFileSync` throws mid-write (e.g. ENOSPC), the pending file receives a
|
|
34
|
+
* partial copy of the leftover and the catch branch still unlinks the leftover
|
|
35
|
+
* to avoid an infinite retry loop — so the tail of the leftover can be lost.
|
|
36
|
+
* In practice the next drain parses the partial line as invalid JSON and drops
|
|
37
|
+
* it via `parseOutboxLine`. This is a deliberate trade-off: we accept the rare
|
|
38
|
+
* partial loss instead of stalling the outbox when the disk is full.
|
|
39
|
+
*/
|
|
40
|
+
export declare function drainOutboxFile(filePath: string, label: string): {
|
|
41
|
+
lines: string[];
|
|
42
|
+
processingPath: string;
|
|
43
|
+
} | null;
|
|
44
|
+
/**
|
|
45
|
+
* Delete the .processing file after all entries are consumed.
|
|
46
|
+
*
|
|
47
|
+
* Writer-race salvage: `appendFileSync` racing `drainOutboxFile`'s rename can
|
|
48
|
+
* land a line on the claimed inode AFTER the drainer already read it. Without
|
|
49
|
+
* a recheck, unlinking here would silently destroy that entry. When
|
|
50
|
+
* `consumedLines` is provided, any lines beyond it are appended back to the
|
|
51
|
+
* original pending file before the claim is deleted (at-least-once preserved).
|
|
52
|
+
*/
|
|
53
|
+
export declare function deleteProcessingFile(processingPath: string, label: string, consumedLines?: number): void;
|
|
54
|
+
/**
|
|
55
|
+
* Parse a single JSONL line. Returns null (and logs an error) on invalid JSON.
|
|
56
|
+
* Keeps the parse + error-log pattern in one place instead of repeating it in
|
|
57
|
+
* every flush function.
|
|
58
|
+
*/
|
|
59
|
+
export declare function parseOutboxLine<T>(line: string, label: string): T | null;
|
|
60
|
+
/**
|
|
61
|
+
* Drain an outbox file and invoke `handler` for each parsed entry.
|
|
62
|
+
* Handles drain → parse → process → delete-processing → write-back-failures in one call.
|
|
63
|
+
*
|
|
64
|
+
* `handler` should throw to signal a retryable failure.
|
|
65
|
+
* Failed entries are written back to `filePath` for the next flush cycle.
|
|
66
|
+
* Pass `maxRetries` to drop entries that have exceeded the retry budget.
|
|
67
|
+
*
|
|
68
|
+
* Delivery: at-least-once. The `.processing` claim is deleted only AFTER all
|
|
69
|
+
* entries were handled — a crash mid-processing leaves the claim on disk and
|
|
70
|
+
* the next drain's leftover-merge redelivers the whole batch (including
|
|
71
|
+
* already-handled entries). Handlers must therefore be idempotent or accept
|
|
72
|
+
* duplicates; deleting the claim up-front would instead silently lose every
|
|
73
|
+
* unprocessed entry on crash, which is worse for every queue using this path.
|
|
74
|
+
*/
|
|
75
|
+
export declare function processOutboxFile<T extends Record<string, unknown>>(filePath: string, label: string, handler: (entry: T) => Promise<void>, opts?: {
|
|
76
|
+
maxRetries?: number;
|
|
77
|
+
}): Promise<void>;
|
|
78
|
+
/** Bind outbox processing to caller-owned logging and JSONL parsing dependencies. */
|
|
79
|
+
export declare function createOutboxFileOps(boundHost: OutboxFileHost): OutboxFileOps;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { type CoalescingRunner, type CoalescingRunnerLogger, type CoalescingRunnerOptions, createCoalescingRunner, } from "./coalescing-runner";
|
|
2
|
+
export { createOutboxFileOps, deleteProcessingFile, drainOutboxFile, isProcessingFile, type OutboxFileHost, type OutboxFileOps, type OutboxLogger, parseOutboxLine, processOutboxFile, } from "./file-ops";
|
|
3
|
+
export { createOutboxWatchOps, debouncedFlush, FALLBACK_INTERVAL_MS, type OutboxWatchHost, type OutboxWatchLogger, type OutboxWatchOps, watchDir, } from "./utils";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type FSWatcher } from "node:fs";
|
|
2
|
+
export declare const FALLBACK_INTERVAL_MS = 5000;
|
|
3
|
+
export interface OutboxWatchLogger {
|
|
4
|
+
error(fields: Record<string, unknown>, message: string): void;
|
|
5
|
+
warn(fields: Record<string, unknown>, message: string): void;
|
|
6
|
+
}
|
|
7
|
+
export interface OutboxWatchHost {
|
|
8
|
+
logger: OutboxWatchLogger;
|
|
9
|
+
}
|
|
10
|
+
export interface OutboxWatchOps {
|
|
11
|
+
debouncedFlush(fn: () => Promise<void>, label: string, delayMs: number): () => void;
|
|
12
|
+
watchDir(dir: string, onChange: () => void): FSWatcher | null;
|
|
13
|
+
}
|
|
14
|
+
export declare function createOutboxWatchOps(host: OutboxWatchHost): OutboxWatchOps;
|
|
15
|
+
export declare const debouncedFlush: (fn: () => Promise<void>, label: string, delayMs: number) => () => void;
|
|
16
|
+
export declare const watchDir: (dir: string, onChange: () => void) => FSWatcher | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function deriveBgBashContextCapability(runtimeCapability: string, userId: string, topic: string): string;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type ChildProcess, spawn } from "node:child_process";
|
|
2
|
+
export declare function makeBgBashKey(_userId: string, _topic: string): string;
|
|
3
|
+
export interface BackgroundBashManager {
|
|
4
|
+
contextCapability(userId: string, topic: string): string;
|
|
5
|
+
ensure(userId: string, topic: string): Promise<number>;
|
|
6
|
+
clear(userId: string, topic: string): void;
|
|
7
|
+
clearUser(userId: string): void;
|
|
8
|
+
killAll(): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
export interface BackgroundBashManagerOptions {
|
|
11
|
+
/**
|
|
12
|
+
* bash-rs executable. Defaults to the installed binary; injectable so a test
|
|
13
|
+
* can drive the manager's bookkeeping with a fake `spawn` on a host that has
|
|
14
|
+
* no binary at all.
|
|
15
|
+
*/
|
|
16
|
+
bashRsBin?: string;
|
|
17
|
+
basePort?: number;
|
|
18
|
+
maxPort?: number;
|
|
19
|
+
capability?: string;
|
|
20
|
+
serverId?: string;
|
|
21
|
+
env?: NodeJS.ProcessEnv;
|
|
22
|
+
fetch?: typeof globalThis.fetch;
|
|
23
|
+
now?: () => number;
|
|
24
|
+
delay?: (milliseconds: number) => Promise<void>;
|
|
25
|
+
portPids?: (port: number) => readonly number[];
|
|
26
|
+
spawn?: (command: string, args: readonly string[], options: Parameters<typeof spawn>[2]) => ChildProcess;
|
|
27
|
+
}
|
|
28
|
+
/** Create a fully isolated manager. All mutable process/port/context state belongs to the caller. */
|
|
29
|
+
export declare function createBackgroundBashManager(options?: BackgroundBashManagerOptions): BackgroundBashManager;
|
|
30
|
+
export declare const bgBashContextCapability: (userId: string, topic: string) => string;
|
|
31
|
+
export declare const ensureBgBash: (userId: string, topic: string) => Promise<number>;
|
|
32
|
+
export declare const killBgBash: (userId: string, topic: string) => void;
|
|
33
|
+
export declare const killBgBashForUser: (userId: string) => void;
|
|
34
|
+
export declare const killAllBgBash: () => Promise<void>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type AgentKind } from "../types";
|
|
2
|
+
export type RuntimeEnvironment = Readonly<Record<string, string | undefined>>;
|
|
3
|
+
export declare function readEnvText(env: RuntimeEnvironment, key: string): string | undefined;
|
|
4
|
+
/**
|
|
5
|
+
* Node-wide default agent (FALLBACK_AGENT env, legacy DEFAULT_AGENT, else
|
|
6
|
+
* "claude"). Lives in this side-effect-free leaf module — not #platform/config
|
|
7
|
+
* — so storage layers that only need this one value (e.g. the forum/api-topics
|
|
8
|
+
* repositories, re-exported through the public storage facade) don't drag in
|
|
9
|
+
* config.ts's eager `mkdirSync` of every node data directory just by
|
|
10
|
+
* importing it.
|
|
11
|
+
*/
|
|
12
|
+
export declare function resolveFallbackAgent(env?: RuntimeEnvironment): AgentKind;
|
|
13
|
+
export declare function parseRuntimePort(value: string | undefined, fallback: number): number;
|
|
14
|
+
export declare function resolveRuntimeStateDir(options: {
|
|
15
|
+
env: RuntimeEnvironment;
|
|
16
|
+
envKey: string;
|
|
17
|
+
fallbackRoot: string;
|
|
18
|
+
fallbackName: string;
|
|
19
|
+
}): string;
|
|
20
|
+
export declare function safeRuntimePathSegment(value: string, fallback: string, maxLength?: number): string;
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { type AgentKind, type EffortLevel } from "../types";
|
|
2
|
+
export declare function envText(envKey: string): string | undefined;
|
|
3
|
+
export declare const PROJECT_ROOT: string;
|
|
4
|
+
export declare const STATE_DIR: string;
|
|
5
|
+
export declare const WORKSPACE_DIR: string;
|
|
6
|
+
export declare const TOPIC_WORKSPACE_DIR: string;
|
|
7
|
+
export declare const SHARED_WIKI_DIR: string;
|
|
8
|
+
export declare const CRON_WORKSPACE_DIR: string;
|
|
9
|
+
export declare const BROWSER_DIR: string;
|
|
10
|
+
export declare const BROWSER_PROFILES_DIR: string;
|
|
11
|
+
export declare const BINARIES_DIR: string;
|
|
12
|
+
export declare const SECRETS_DIR: string;
|
|
13
|
+
export declare const DM_WORKSPACE_DIR: string;
|
|
14
|
+
export declare const SESSION_WORKSPACE_DIR: string;
|
|
15
|
+
export declare const CLAUDE_EXECUTABLE: string | undefined;
|
|
16
|
+
export declare const DEFAULT_OUTPUT_LANGUAGE = "English";
|
|
17
|
+
export declare function resolveOutputLanguage(): string;
|
|
18
|
+
/**
|
|
19
|
+
* Suffix the managed Rust helpers carry on this platform.
|
|
20
|
+
*
|
|
21
|
+
* The installers write the binary under its plain name, which on Windows is
|
|
22
|
+
* not executable — the release asset is `browser-rs.exe` and the resolver has
|
|
23
|
+
* to look for exactly that. Empty everywhere else, so POSIX paths are
|
|
24
|
+
* unchanged.
|
|
25
|
+
*/
|
|
26
|
+
export declare const BINARY_EXTENSION: string;
|
|
27
|
+
/** Browser.rs release tested with this Negotium version. */
|
|
28
|
+
export declare const BROWSER_RS_VERSION = "v0.7.7";
|
|
29
|
+
/** Require the authenticated listener and the current Browser.rs tool contract. */
|
|
30
|
+
export declare const BROWSER_RS_MIN_SECURE_VERSION = "0.2.1";
|
|
31
|
+
/**
|
|
32
|
+
* Resolve the preferred Browser.rs engine without consulting PATH. The
|
|
33
|
+
* versioned private location keeps different Negotium releases reproducible
|
|
34
|
+
* and avoids changing a user's global browser-rs installation.
|
|
35
|
+
*/
|
|
36
|
+
export declare function resolveBrowserRsBin(envValue?: string): string | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Backend that stores documents published by `publish_html` and serves them
|
|
39
|
+
* at `<base>/snippets/<id>`. Unset means the deployment has nowhere to
|
|
40
|
+
* publish, and the publish tools are omitted from the catalog rather than
|
|
41
|
+
* offering a link that cannot be minted.
|
|
42
|
+
*/
|
|
43
|
+
export declare const SNIPPETS_API_URL: string;
|
|
44
|
+
export declare const BROWSER_RS_BIN: string | undefined;
|
|
45
|
+
/** bash-rs release tested with this Negotium version — see apps/negotium/install-bash-rs.mjs. */
|
|
46
|
+
export declare const BASH_RS_VERSION = "v0.1.10";
|
|
47
|
+
/**
|
|
48
|
+
* Resolve the bash-rs binary the same way `resolveBrowserRsBin` resolves
|
|
49
|
+
* Browser.rs: a versioned private location, no PATH lookup, `undefined`
|
|
50
|
+
* (rather than throwing) when it's missing. There is no substitute: the manager
|
|
51
|
+
* throws when a turn tries to prepare background-bash without a binary (see
|
|
52
|
+
* `background-bash/manager.ts`), the turn runner catches that and continues
|
|
53
|
+
* with a reminder that the tools are gone, so background-bash is simply
|
|
54
|
+
* unavailable on a platform without a prebuilt binary.
|
|
55
|
+
*/
|
|
56
|
+
export declare function resolveBashRsBin(envValue?: string): string | undefined;
|
|
57
|
+
export declare const BASH_RS_BIN: string | undefined;
|
|
58
|
+
export declare function resolveBrowserMcpBin(envValue?: string): string;
|
|
59
|
+
export declare const PLAYWRIGHT_MCP_BIN: string;
|
|
60
|
+
export type BrowserProxyConfig = {
|
|
61
|
+
server: string;
|
|
62
|
+
username?: string;
|
|
63
|
+
password?: string;
|
|
64
|
+
bypass?: string;
|
|
65
|
+
};
|
|
66
|
+
export declare function resolveBrowserProxy(): BrowserProxyConfig | null;
|
|
67
|
+
export declare const TSX_BIN: string;
|
|
68
|
+
export declare const TSX_LOADER: string;
|
|
69
|
+
export declare const TSCONFIG_PATH: string;
|
|
70
|
+
export declare const SESSION_COMM_SERVER: string;
|
|
71
|
+
export declare const TASK_SERVER: string;
|
|
72
|
+
export declare const DECISION_SERVER: string;
|
|
73
|
+
export declare const CANONICAL_MCP_PROXY_SERVER: string;
|
|
74
|
+
export declare const WIKI_SERVER: string;
|
|
75
|
+
export declare const TOKEN_STATS_SERVER: string;
|
|
76
|
+
export declare const COMPACTION_LOG_SERVER: string;
|
|
77
|
+
export declare const SESSION_HISTORY_SERVER: string;
|
|
78
|
+
export declare const SYSTEM_HEALTH_SERVER: string;
|
|
79
|
+
export declare const AGENT_HEALTH_SERVER: string;
|
|
80
|
+
export declare const VAULT_SERVER: string;
|
|
81
|
+
export declare const BG_BASH_BASE_PORT: number;
|
|
82
|
+
export declare const BG_BASH_MAX_PORT: number;
|
|
83
|
+
/** Resolve the shared filesystem workspace for an API topic. */
|
|
84
|
+
export declare function resolveTopicWorkspaceDir(topicId: string): string;
|
|
85
|
+
export declare function isProductionEnv(): boolean;
|
|
86
|
+
export declare const RUNTIME_MCP_SECRET: string;
|
|
87
|
+
/** Local bearer token for the loopback node-control API. */
|
|
88
|
+
export declare const NODE_CONTROL_TOKEN: string;
|
|
89
|
+
/**
|
|
90
|
+
* Stable identity of this node's store, minted once and kept across restarts.
|
|
91
|
+
*
|
|
92
|
+
* Deliberately not a secret: it is published in the gateway health response so a
|
|
93
|
+
* host can tell "the node I recorded a mapping against" apart from "whatever is
|
|
94
|
+
* answering on that port today". Without it, pointing a host at a different node
|
|
95
|
+
* makes every existing mapping look like a topic whose owner withdrew it, and the
|
|
96
|
+
* same topics come back as duplicate rooms. It shares the secrets directory only
|
|
97
|
+
* because that is already where per-install state that must survive restarts
|
|
98
|
+
* lives; the stricter file mode costs nothing.
|
|
99
|
+
*/
|
|
100
|
+
export declare const NODE_ID: string;
|
|
101
|
+
export declare const VAULT_MASTER_KEY: string;
|
|
102
|
+
/** The node's single open port: runtime MCP endpoint + node API. */
|
|
103
|
+
export declare const NEGOTIUM_PORT: number;
|
|
104
|
+
export declare const hostname: string;
|
|
105
|
+
export declare const DATA_DIR: string;
|
|
106
|
+
export declare const LOG_DIR: string;
|
|
107
|
+
export declare const UPLOADS_DIR: string;
|
|
108
|
+
export declare const VAULT_DIR: string;
|
|
109
|
+
export declare const SESSIONS_DB: string;
|
|
110
|
+
export declare const DEBUG_FILE: string;
|
|
111
|
+
export declare const USERS_LOG_DIR: string;
|
|
112
|
+
/** @deprecated Use the runtime layout name; NEGOTIUM_RUN_DIR remains a compatibility override. */
|
|
113
|
+
export declare const RUN_DIR: string;
|
|
114
|
+
export declare const RUNTIME_DIR: string;
|
|
115
|
+
export declare const PROGRESS_DIR: string;
|
|
116
|
+
export declare const DM_CMD_DIR: string;
|
|
117
|
+
export declare const DM_RESP_DIR: string;
|
|
118
|
+
export declare const SESSION_INBOX_DIR: string;
|
|
119
|
+
export declare const SESSION_ASKS_DIR: string;
|
|
120
|
+
/**
|
|
121
|
+
* Passed to `bash-rs` as `BASHRS_SPILL_ROOT`. Each job gets a subdirectory
|
|
122
|
+
* here (`{bash_id}/meta.json`, `result.json`, `stdout.log`, `stderr.log`) —
|
|
123
|
+
* see bash-rs-mcp's `journal.rs`. `runtime/bashrs-completions.ts` watches
|
|
124
|
+
* this directory and turns `result.json` into a session-inbox `tell`. The
|
|
125
|
+
* retired TypeScript server used to write one directly instead.
|
|
126
|
+
*/
|
|
127
|
+
export declare const BASHRS_SPILL_ROOT: string;
|
|
128
|
+
export declare const PLAYWRIGHT_BASE_PORT: number;
|
|
129
|
+
export declare const PLAYWRIGHT_MAX_PORT: number;
|
|
130
|
+
export declare const PLAYWRIGHT_PORTS_DIR: string;
|
|
131
|
+
/** Stale threshold for active-query state files (crash recovery) */
|
|
132
|
+
export declare const ACTIVE_QUERY_STALE_MS: number;
|
|
133
|
+
export declare const AGENTS_PROMPTS_DIR: string;
|
|
134
|
+
export declare const RESOURCES_DIR: string;
|
|
135
|
+
/** Returns process.env without CLAUDECODE, to prevent nested claude-code detection in subprocesses. */
|
|
136
|
+
export declare function getCleanEnv(): NodeJS.ProcessEnv;
|
|
137
|
+
export declare const FILE_EXTENSIONS_REGEX: RegExp;
|
|
138
|
+
export declare const FILE_TAG_REGEX: RegExp;
|
|
139
|
+
export declare const MODEL_SONNET = "claude-sonnet-5";
|
|
140
|
+
export declare const MODEL_OPUS = "claude-opus-5-5";
|
|
141
|
+
export declare const MODEL_HAIKU = "claude-haiku-4-5-20251001";
|
|
142
|
+
export declare const MODEL_FABLE = "claude-fable-5-1";
|
|
143
|
+
export declare const MODEL_DEEPSEEK_V4_PRO = "deepseek-v4-pro";
|
|
144
|
+
export declare const MODEL_DEEPSEEK_V4_FLASH = "deepseek-v4-flash";
|
|
145
|
+
export declare const FALLBACK_AGENT: AgentKind;
|
|
146
|
+
export declare const FALLBACK_MODEL: string | undefined;
|
|
147
|
+
/**
|
|
148
|
+
* Effort used when a caller (or an archiver assignment) names a model but no
|
|
149
|
+
* effort. Deliberately one fixed node-wide value instead of each agent's
|
|
150
|
+
* registry default: a model-derived agent switch would otherwise move effort —
|
|
151
|
+
* and therefore cost — without anyone asking for it.
|
|
152
|
+
*/
|
|
153
|
+
export declare const DEFAULT_TOPIC_EFFORT: EffortLevel;
|
|
154
|
+
export declare const FFMPEG_BIN: string | undefined;
|
|
155
|
+
export declare const FFPROBE_BIN: string | undefined;
|
|
156
|
+
export declare const PYTHON_BIN: string;
|
|
157
|
+
export declare const FASTER_WHISPER_WRAPPER: string;
|
|
158
|
+
export declare const WHISPER_MODEL: string;
|
|
159
|
+
export declare const TESSERACT_BIN: string;
|
|
160
|
+
export declare const PDFTOTEXT_BIN: string;
|
|
161
|
+
export type WhisperBackend = "faster-whisper" | "mlx-whisper";
|
|
162
|
+
export declare const WHISPER_BACKEND: WhisperBackend;
|
|
163
|
+
/** Path to the `mlx_whisper` CLI (only used when WHISPER_BACKEND=mlx-whisper). */
|
|
164
|
+
export declare const MLX_WHISPER_BIN: string | undefined;
|
|
165
|
+
/** mlx-whisper model id, e.g. "mlx-community/whisper-large-v3-turbo".
|
|
166
|
+
*
|
|
167
|
+
* Deliberately does NOT fall back to WHISPER_MODEL: that env defaults to the
|
|
168
|
+
* bare alias "turbo", which faster-whisper's own model-name normalization
|
|
169
|
+
* accepts but mlx_whisper's `--model` does not — it expects a full
|
|
170
|
+
* HuggingFace repo id and otherwise fails hard with a 401
|
|
171
|
+
* RepositoryNotFoundError trying to resolve "turbo" as a repo. Confirmed by
|
|
172
|
+
* actually running mlx_whisper with each value while wiring up the
|
|
173
|
+
* mlx-whisper hub in production. */
|
|
174
|
+
export declare const WHISPER_MODEL_MLX: string;
|
|
175
|
+
export declare const MAX_TELL_DEPTH: number;
|
|
176
|
+
/** Codex CLI auth file. 호출 시점에 env를 읽는다 — 테스트가 런타임에
|
|
177
|
+
* NEGOTIUM_CODEX_AUTH_FILE을 바꾸므로 모듈 로드 상수로 만들면 안 된다. */
|
|
178
|
+
export declare function codexAuthFilePath(): string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** "from" field for session-inbox entries injected after a setting change. */
|
|
2
|
+
export declare const FROM_AUTO_CONTINUE = "auto-continue";
|
|
3
|
+
/** "from" field for durable delayed continuations created by schedule_self. */
|
|
4
|
+
export declare const FROM_SELF_SCHEDULE = "self-schedule";
|
|
5
|
+
/** Topic names that collide with internal sentinels and must not be used. */
|
|
6
|
+
export declare const RESERVED_TOPIC_NAMES: ReadonlySet<string>;
|
|
7
|
+
/** Legacy shared General id. New General rooms use per-user UUIDs. */
|
|
8
|
+
export declare const GENERAL_TOPIC_ID = "general";
|
|
9
|
+
/**
|
|
10
|
+
* Sanitized log name every private General resolves to.
|
|
11
|
+
*
|
|
12
|
+
* `general` is reserved above, so a manager room is the only room that can
|
|
13
|
+
* produce it — which is what lets conversation storage qualify just that one
|
|
14
|
+
* file per owner instead of namespacing the whole directory.
|
|
15
|
+
*/
|
|
16
|
+
export declare const MANAGER_TOPIC_LOG_NAME = "general";
|
|
17
|
+
/** The principal a standalone node runs as when no hub names another. */
|
|
18
|
+
export declare const NODE_LOCAL_USER_ID = "local";
|
|
19
|
+
/** Internal topic name for the forum manager session (General topic). */
|
|
20
|
+
export declare const TOPIC_MANAGER = "__manager__";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const delay: (ms: number) => Promise<void>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stringify an unknown thrown value for logging or user-visible messages.
|
|
3
|
+
* Default fallback is `String(e)`. Pass an explicit fallback (e.g. "unknown")
|
|
4
|
+
* to override what non-Error throws turn into.
|
|
5
|
+
*/
|
|
6
|
+
export declare function errMsg(e: unknown, fallback?: string): string;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface SafeUnlinkHost {
|
|
2
|
+
unlink(path: string): void;
|
|
3
|
+
warn(context: {
|
|
4
|
+
err: unknown;
|
|
5
|
+
path: string;
|
|
6
|
+
}, message: string): void;
|
|
7
|
+
}
|
|
8
|
+
export type SafeUnlink = (path: string, warnLabel?: string) => void;
|
|
9
|
+
/** Create an isolated best-effort unlink helper using caller-owned I/O and logging. */
|
|
10
|
+
export declare function createSafeUnlink(host: SafeUnlinkHost): SafeUnlink;
|
|
11
|
+
/**
|
|
12
|
+
* Best-effort unlink. ENOENT is always swallowed (the file is already gone).
|
|
13
|
+
* Other errors are silent unless `warnLabel` is provided, in which case they
|
|
14
|
+
* are logged at warn level with `{ err, path }` context.
|
|
15
|
+
*/
|
|
16
|
+
export declare function safeUnlink(path: string, warnLabel?: string): void;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local IPC endpoints that work on both a Unix-domain socket host and Windows.
|
|
3
|
+
*
|
|
4
|
+
* Node's local IPC is a Unix-domain socket on POSIX and a named pipe on
|
|
5
|
+
* Windows, and the two differ in more than spelling: a pipe name lives in the
|
|
6
|
+
* kernel's pipe namespace, not the filesystem, so it cannot be placed inside a
|
|
7
|
+
* mode-0700 directory, cannot be `chmod`ed, and does not need unlinking. Route
|
|
8
|
+
* endpoint construction through here so each caller states the POSIX path it
|
|
9
|
+
* wants and gets a listenable address on either host.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Map a would-be socket path to an address `net.Server#listen` accepts here.
|
|
13
|
+
*
|
|
14
|
+
* On POSIX the path is returned unchanged. On Windows it becomes
|
|
15
|
+
* `\\.\pipe\negotium-<label>-<digest>`, where the digest is taken over the
|
|
16
|
+
* full POSIX path so two endpoints that differ only in their containing
|
|
17
|
+
* directory — the usual shape, where a per-instance mkdtemp supplies the
|
|
18
|
+
* uniqueness and the basename is a constant like `hook.sock` — stay distinct.
|
|
19
|
+
*/
|
|
20
|
+
export declare function ipcEndpoint(posixSocketPath: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Restrict an endpoint to this user, where the platform expresses that as file
|
|
23
|
+
* permissions.
|
|
24
|
+
*
|
|
25
|
+
* On POSIX this is the 0600 on the socket inode. Windows named pipes are not
|
|
26
|
+
* filesystem objects and Node exposes no way to set their DACL, so there is
|
|
27
|
+
* nothing to narrow — every caller of this module additionally authenticates
|
|
28
|
+
* with a random per-instance token, which is what carries the boundary there.
|
|
29
|
+
*/
|
|
30
|
+
export declare function restrictIpcEndpoint(endpoint: string): void;
|
|
31
|
+
/** True when `endpoint` is a Windows named pipe rather than a filesystem path. */
|
|
32
|
+
export declare function isNamedPipe(endpoint: string): boolean;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export declare function readJsonlLines(filePath: string): string[];
|
|
2
|
+
/**
|
|
3
|
+
* Parse a JSONL string (one JSON value per line) into an array of `T`.
|
|
4
|
+
* Throws on malformed lines — use when a corrupt fixture/log should fail
|
|
5
|
+
* loudly rather than silently drop entries (paired with `readJsonlLines`'
|
|
6
|
+
* resilient counterpart for live data streams).
|
|
7
|
+
*/
|
|
8
|
+
export declare function parseJsonlText<T = unknown>(raw: string): T[];
|
|
9
|
+
/**
|
|
10
|
+
* Read and JSON-parse a file. Returns null if the file is missing or contains
|
|
11
|
+
* invalid JSON. Use when a missing/corrupt file should fall through to a
|
|
12
|
+
* default rather than throw.
|
|
13
|
+
*/
|
|
14
|
+
export declare function readJsonFile<T = unknown>(filePath: string): T | null;
|
|
15
|
+
/** Atomically replace a JSON file and fsync the new contents before rename. */
|
|
16
|
+
export declare function writeJsonFileAtomic(filePath: string, value: unknown): void;
|
|
17
|
+
/**
|
|
18
|
+
* The append lock could not be acquired, so nothing was written.
|
|
19
|
+
*
|
|
20
|
+
* Distinguishable from an I/O error so callers can retry, degrade, or report
|
|
21
|
+
* contention specifically. Nothing was appended when this is thrown.
|
|
22
|
+
*/
|
|
23
|
+
export declare class JsonlLockTimeoutError extends Error {
|
|
24
|
+
readonly filePath: string;
|
|
25
|
+
readonly timeoutMs: number;
|
|
26
|
+
constructor(filePath: string, timeoutMs: number);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Append a JSON-encoded entry + newline to a JSONL file. Ensures the parent
|
|
30
|
+
* directory exists and serializes concurrent multi-process appends through a
|
|
31
|
+
* sidecar lock so payloads larger than PIPE_BUF do not interleave.
|
|
32
|
+
*
|
|
33
|
+
* The drainer side (`outbox/file-ops.ts`) claims the file via atomic rename
|
|
34
|
+
* and handles recovery of leftover `.processing` files from crashes.
|
|
35
|
+
*/
|
|
36
|
+
export declare function appendJsonlEntry(filePath: string, entry: unknown): void;
|
|
37
|
+
/**
|
|
38
|
+
* Append an already-serialized JSONL line (must end with "\n") under the
|
|
39
|
+
* same cross-process append lock as `appendJsonlEntry`. Use when you
|
|
40
|
+
* want to write back a raw line **exactly** — e.g. flusher tail-writeback
|
|
41
|
+
* preserving lines that current parser can't decode, so a future parser
|
|
42
|
+
* release still sees them.
|
|
43
|
+
*/
|
|
44
|
+
export declare function appendJsonlLine(filePath: string, line: string): void;
|
|
45
|
+
/** Overwrite a JSONL file with the given entries. Trailing newline included. */
|
|
46
|
+
export declare function writeJsonlFile(filePath: string, entries: readonly unknown[]): void;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface ShutdownHandler {
|
|
2
|
+
name: string;
|
|
3
|
+
priority: number;
|
|
4
|
+
fn: () => Promise<void> | void;
|
|
5
|
+
}
|
|
6
|
+
export type SignalReason = "beforeExit" | "SIGINT" | "SIGTERM" | "test" | "manual" | "singleton-lease-lost";
|
|
7
|
+
export interface LifecycleLogger {
|
|
8
|
+
info(fields: Record<string, unknown>, message: string): void;
|
|
9
|
+
warn(fields: Record<string, unknown>, message: string): void;
|
|
10
|
+
error(fields: Record<string, unknown>, message: string): void;
|
|
11
|
+
}
|
|
12
|
+
export interface LifecycleProcessHost {
|
|
13
|
+
once(event: "beforeExit" | "SIGINT" | "SIGTERM", listener: () => void): unknown;
|
|
14
|
+
removeListener(event: "beforeExit" | "SIGINT" | "SIGTERM", listener: () => void): unknown;
|
|
15
|
+
exit(code: number): never;
|
|
16
|
+
}
|
|
17
|
+
export interface LifecycleManagerOptions {
|
|
18
|
+
logger: LifecycleLogger;
|
|
19
|
+
process: LifecycleProcessHost;
|
|
20
|
+
handlerTimeoutMs?: number;
|
|
21
|
+
hardExitTimeoutMs?: number;
|
|
22
|
+
}
|
|
23
|
+
export interface LifecycleManager {
|
|
24
|
+
onShutdown(name: string, priority: number, fn: () => Promise<void> | void): void;
|
|
25
|
+
runShutdown(reason: SignalReason): Promise<void>;
|
|
26
|
+
reset(): void;
|
|
27
|
+
handlerCount(): number;
|
|
28
|
+
isTriggered(): boolean;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Create an isolated shutdown registry. Callers own the registry and process
|
|
32
|
+
* hooks, so embedding this helper cannot collide with another runtime's
|
|
33
|
+
* handlers or test state.
|
|
34
|
+
*/
|
|
35
|
+
export declare function createLifecycleManager(options: LifecycleManagerOptions): LifecycleManager;
|
|
36
|
+
export declare const onShutdown: (name: string, priority: number, fn: () => Promise<void> | void) => void;
|
|
37
|
+
export declare const runShutdown: (reason: SignalReason) => Promise<void>;
|
|
38
|
+
export declare function __resetForTests(): void;
|
|
39
|
+
export declare function __handlerCount(): number;
|
|
40
|
+
export declare function __triggered(): boolean;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import pino from "pino";
|
|
2
|
+
export interface StdioLoggerOptions {
|
|
3
|
+
level?: string;
|
|
4
|
+
development?: boolean;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Always write logs to stderr (fd 2), never stdout.
|
|
8
|
+
*
|
|
9
|
+
* MCP servers under `src/mcp/**` run as stdio subprocesses where stdout is the
|
|
10
|
+
* JSON-RPC transport channel. A single log line on stdout corrupts the next
|
|
11
|
+
* message and the MCP client closes the transport ("Transport closed"). The
|
|
12
|
+
* main bot process is also fine with stderr — pm2 captures both streams.
|
|
13
|
+
*
|
|
14
|
+
* In dev mode pino spawns a `pino-pretty` worker that owns its own sink, so we
|
|
15
|
+
* pass `destination: 2` through transport.options. In prod (no transport) the
|
|
16
|
+
* second arg to `pino()` sets the destination directly.
|
|
17
|
+
*/
|
|
18
|
+
export declare function createStdioLogger(options?: StdioLoggerOptions): pino.Logger<never, boolean>;
|
|
19
|
+
export type StdioLogger = ReturnType<typeof createStdioLogger>;
|
|
20
|
+
export declare const logger: pino.Logger<never, boolean>;
|
|
File without changes
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
export type RuntimeMcpScope = "dm" | "forum" | "fork" | "manager" | "cron";
|
|
2
|
+
export interface RuntimeMcpPolicyEntry {
|
|
3
|
+
scopes: readonly RuntimeMcpScope[];
|
|
4
|
+
/** Forum entries marked required cannot be disabled by a topic whitelist. */
|
|
5
|
+
forumRequired?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare const COMMON_RUNTIME_MCP_POLICY: {
|
|
8
|
+
readonly playwright: {
|
|
9
|
+
readonly scopes: readonly ["dm", "forum", "fork", "cron"];
|
|
10
|
+
readonly forumRequired: true;
|
|
11
|
+
};
|
|
12
|
+
readonly runtime: {
|
|
13
|
+
readonly scopes: readonly ["forum", "manager", "fork", "cron"];
|
|
14
|
+
readonly forumRequired: true;
|
|
15
|
+
};
|
|
16
|
+
readonly "token-stats": {
|
|
17
|
+
readonly scopes: readonly ["dm", "forum", "manager", "cron"];
|
|
18
|
+
readonly forumRequired: true;
|
|
19
|
+
};
|
|
20
|
+
readonly task: {
|
|
21
|
+
readonly scopes: readonly ["dm", "forum", "manager", "cron"];
|
|
22
|
+
readonly forumRequired: true;
|
|
23
|
+
};
|
|
24
|
+
readonly decision: {
|
|
25
|
+
readonly scopes: readonly ["dm", "forum", "manager", "cron"];
|
|
26
|
+
readonly forumRequired: true;
|
|
27
|
+
};
|
|
28
|
+
readonly "session-comm": {
|
|
29
|
+
readonly scopes: readonly ["forum", "fork", "manager"];
|
|
30
|
+
readonly forumRequired: true;
|
|
31
|
+
};
|
|
32
|
+
readonly wiki: {
|
|
33
|
+
readonly scopes: readonly ["dm", "forum", "manager", "cron"];
|
|
34
|
+
readonly forumRequired: true;
|
|
35
|
+
};
|
|
36
|
+
readonly skills: {
|
|
37
|
+
readonly scopes: readonly ["dm", "forum", "manager", "cron"];
|
|
38
|
+
readonly forumRequired: true;
|
|
39
|
+
};
|
|
40
|
+
readonly "system-health": {
|
|
41
|
+
readonly scopes: readonly ["dm", "forum", "manager", "cron"];
|
|
42
|
+
readonly forumRequired: true;
|
|
43
|
+
};
|
|
44
|
+
readonly "background-bash": {
|
|
45
|
+
readonly scopes: readonly ["forum"];
|
|
46
|
+
readonly forumRequired: true;
|
|
47
|
+
};
|
|
48
|
+
readonly "agent-health": {
|
|
49
|
+
readonly scopes: readonly ["forum", "manager", "cron"];
|
|
50
|
+
readonly forumRequired: true;
|
|
51
|
+
};
|
|
52
|
+
readonly vault: {
|
|
53
|
+
readonly scopes: readonly ["dm", "forum", "manager", "cron"];
|
|
54
|
+
readonly forumRequired: true;
|
|
55
|
+
};
|
|
56
|
+
readonly "cua-rs": {
|
|
57
|
+
readonly scopes: readonly ["dm", "forum", "fork"];
|
|
58
|
+
readonly forumRequired: false;
|
|
59
|
+
};
|
|
60
|
+
readonly "session-history": {
|
|
61
|
+
readonly scopes: readonly ["dm", "forum", "manager"];
|
|
62
|
+
readonly forumRequired: true;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
export type CommonRuntimeMcpName = keyof typeof COMMON_RUNTIME_MCP_POLICY;
|
|
66
|
+
export interface ForumMcpClassification {
|
|
67
|
+
all: string[];
|
|
68
|
+
required: string[];
|
|
69
|
+
optional: string[];
|
|
70
|
+
}
|
|
71
|
+
export declare function classifyForumMcpServers(catalog: Readonly<Record<string, RuntimeMcpPolicyEntry>>): ForumMcpClassification;
|
|
72
|
+
export declare function commonRuntimeMcpPolicy(name: CommonRuntimeMcpName): RuntimeMcpPolicyEntry;
|
|
73
|
+
export declare function isForumRequiredMcp(name: string): boolean;
|