@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,274 @@
|
|
|
1
|
+
import type { AgentKind, EffortLevel } from "../types";
|
|
2
|
+
import type { AiMode, TopicDto, TopicKind, TopicSurface, TopicVisibility } from "../types/api";
|
|
3
|
+
/**
|
|
4
|
+
* Surface used when a caller does not name one — and the value every existing
|
|
5
|
+
* row is backfilled with on first boot after the surface migration.
|
|
6
|
+
*
|
|
7
|
+
* Hosts that only ever serve one surface declare it once in their environment
|
|
8
|
+
* (`NEGOTIUM_DEFAULT_SURFACE=otium` on the Otium hub and worker); a developer
|
|
9
|
+
* Mac leaves it unset and gets `terminal`, with the telegram adapter
|
|
10
|
+
* reclassifying its own mapped rooms afterwards.
|
|
11
|
+
*/
|
|
12
|
+
export declare function defaultTopicSurface(): TopicSurface;
|
|
13
|
+
export declare function normalizeTopicSurface(value: unknown): TopicSurface;
|
|
14
|
+
export declare function normalizeSurfaceScope(value: unknown): string | null;
|
|
15
|
+
export declare function defaultSurfaceScope(): string | null;
|
|
16
|
+
/** Install (or clear) the scope new rooms inherit. Returns the previous value. */
|
|
17
|
+
export declare function setDefaultSurfaceScope(scope: string | null): string | null;
|
|
18
|
+
export declare function setSurfaceScopeRequired(required: boolean): void;
|
|
19
|
+
export declare function isSurfaceScopeRequired(): boolean;
|
|
20
|
+
export declare function setMountedSurfaceScopeCount(count: number | null): void;
|
|
21
|
+
export interface LocalSurfaceScopeStatus {
|
|
22
|
+
/** The workspace an unscoped (loopback) caller's otium rooms are filed under. */
|
|
23
|
+
surfaceScope: string | null;
|
|
24
|
+
/** False while the scope cannot be stated (several workspaces, or one not resolved yet). */
|
|
25
|
+
resolved: boolean;
|
|
26
|
+
/** True while several workspaces are mounted: a room must name one. */
|
|
27
|
+
scopeRequired: boolean;
|
|
28
|
+
/** Mounted Otium workspaces; 0 when no adapter reported. */
|
|
29
|
+
joinsMounted: number;
|
|
30
|
+
}
|
|
31
|
+
/** The scope a loopback (no scope header) gateway caller gets. */
|
|
32
|
+
export declare function localSurfaceScopeStatus(): LocalSurfaceScopeStatus;
|
|
33
|
+
/** Persist the authoritative agent and, when supplied, its normalized base defaults. */
|
|
34
|
+
export declare function setApiTopicAgent(topicId: string, agent: AgentKind, defaults?: {
|
|
35
|
+
model: string;
|
|
36
|
+
effort?: EffortLevel;
|
|
37
|
+
}): void;
|
|
38
|
+
/**
|
|
39
|
+
* Minimum spacing between two unforced retries of an incomplete M-9 stamp.
|
|
40
|
+
* The retry is driven by timers / scope refreshes, never by request traffic,
|
|
41
|
+
* and this bound keeps even a tight caller from turning it into a hot path.
|
|
42
|
+
*/
|
|
43
|
+
export declare const SURFACE_SCOPE_STAMP_RETRY_INTERVAL_MS = 30000;
|
|
44
|
+
export interface SurfaceScopeStampStatus {
|
|
45
|
+
/** The completion marker is written: every pre-existing room was filed. */
|
|
46
|
+
complete: boolean;
|
|
47
|
+
/** Rooms the stamp skipped and will retry (maintenance, title conflict ...). */
|
|
48
|
+
pending: number;
|
|
49
|
+
/** Workspace the pending rooms will be filed under (pinned at first attempt). */
|
|
50
|
+
scope: string | null;
|
|
51
|
+
pendingTopics: Array<{
|
|
52
|
+
topicId: string;
|
|
53
|
+
reason: string;
|
|
54
|
+
detail: string | null;
|
|
55
|
+
attempts: number;
|
|
56
|
+
}>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Operator view of the M-9 stamp (diagnostics; `unscopedPending` on
|
|
60
|
+
* `GET /surface-scope`). Read-only: the tables exist from schema init.
|
|
61
|
+
*/
|
|
62
|
+
export declare function surfaceScopeStampStatus(): SurfaceScopeStampStatus;
|
|
63
|
+
/**
|
|
64
|
+
* M-9 — file every pre-existing Otium room under the workspace attached now.
|
|
65
|
+
*
|
|
66
|
+
* Deliberately *not* a schema-init step. The scope is only knowable after the
|
|
67
|
+
* first successful Central contact (M-3), which happens long after the store
|
|
68
|
+
* opens; a boot-time migration would see no scope, record itself as applied and
|
|
69
|
+
* leave every room unstamped forever. The Otium runtime calls this instead, once,
|
|
70
|
+
* as soon as it has resolved its workspace.
|
|
71
|
+
*
|
|
72
|
+
* Completes at most once per store: rooms created after this point are stamped
|
|
73
|
+
* at creation, and a second workspace joined later must not swallow the first
|
|
74
|
+
* one's rooms. Unlike the surface migration this can never rename anything —
|
|
75
|
+
* the scope enters the uniqueness key in the same release, so nothing can start
|
|
76
|
+
* colliding because of it.
|
|
77
|
+
*
|
|
78
|
+
* Revision 5: the completion marker is written only when NO room was skipped.
|
|
79
|
+
* A room refused for a retryable reason (live maintenance, title conflict) is
|
|
80
|
+
* recorded in `api_surface_scope_stamp_pending` with the first attempt's scope,
|
|
81
|
+
* and later calls retry exactly those rooms under that pinned scope — never a
|
|
82
|
+
* fresh sweep, never the caller's (possibly different) scope. Rooms already
|
|
83
|
+
* stamped are no longer unscoped and drop out, so every pass is idempotent. The
|
|
84
|
+
* whole pass is one `BEGIN IMMEDIATE`, so concurrent boots serialize: the
|
|
85
|
+
* second sees the first one's marker or pending set and re-checks it.
|
|
86
|
+
*/
|
|
87
|
+
export declare function stampUnscopedOtiumTopics(scope: string): number;
|
|
88
|
+
/**
|
|
89
|
+
* Retry an incomplete M-9 stamp under its pinned scope. No-op (no write lock)
|
|
90
|
+
* when the stamp never started or already completed. Unforced calls run at most
|
|
91
|
+
* once per {@link SURFACE_SCOPE_STAMP_RETRY_INTERVAL_MS} per process; `force`
|
|
92
|
+
* is for discrete events (a pending room's maintenance released, a scope
|
|
93
|
+
* refresh). Never throws: a busy database just waits for the next trigger.
|
|
94
|
+
*/
|
|
95
|
+
export declare function retryPendingSurfaceScopeStamp(options?: {
|
|
96
|
+
force?: boolean;
|
|
97
|
+
now?: number;
|
|
98
|
+
}): number;
|
|
99
|
+
/** Whether `topicId` is waiting for the M-9 stamp (cheap point lookup). */
|
|
100
|
+
export declare function isSurfaceScopeStampPending(topicId: string): boolean;
|
|
101
|
+
export interface TopicRow {
|
|
102
|
+
id: string;
|
|
103
|
+
title: string;
|
|
104
|
+
kind: string | null;
|
|
105
|
+
description: string | null;
|
|
106
|
+
agent: string | null;
|
|
107
|
+
base_model: string | null;
|
|
108
|
+
base_effort: string | null;
|
|
109
|
+
response_policy: string;
|
|
110
|
+
created_at: string;
|
|
111
|
+
last_message_at: string | null;
|
|
112
|
+
parent_topic_id: string | null;
|
|
113
|
+
memory_topic_id: string | null;
|
|
114
|
+
memory_key: string | null;
|
|
115
|
+
is_fork: number;
|
|
116
|
+
is_subagent: number;
|
|
117
|
+
subagent_report_mode: string | null;
|
|
118
|
+
derived_by_user_id: string | null;
|
|
119
|
+
visibility: string | null;
|
|
120
|
+
surface: string | null;
|
|
121
|
+
surface_scope: string | null;
|
|
122
|
+
browser_profile_owner: string | null;
|
|
123
|
+
browser_connect_port: number | null;
|
|
124
|
+
session_id: string | null;
|
|
125
|
+
}
|
|
126
|
+
export interface TopicSessionLogContext {
|
|
127
|
+
reason?: string;
|
|
128
|
+
queryId?: string;
|
|
129
|
+
agent?: AgentKind;
|
|
130
|
+
}
|
|
131
|
+
export declare function normalizeTopicVisibility(value: unknown): TopicVisibility;
|
|
132
|
+
/** Discovery boundary shared by user-facing adapters. */
|
|
133
|
+
export declare function isTopicVisible(topic: Pick<TopicDto, "visibility">): boolean;
|
|
134
|
+
export declare function normalizeTopicKind(value: unknown): TopicKind | null;
|
|
135
|
+
export declare function normalizeAiMode(value: unknown): AiMode | null;
|
|
136
|
+
export declare function aiMentionFromMode(mode: AiMode): boolean;
|
|
137
|
+
export declare function inferTopicKind(input: {
|
|
138
|
+
agent?: string | null;
|
|
139
|
+
aiMention?: boolean | null;
|
|
140
|
+
}): TopicKind;
|
|
141
|
+
export declare function inferAiMode(input: {
|
|
142
|
+
kind?: TopicKind | null;
|
|
143
|
+
agent?: string | null;
|
|
144
|
+
aiMode?: AiMode | null;
|
|
145
|
+
aiMention?: boolean | null;
|
|
146
|
+
}): AiMode;
|
|
147
|
+
export declare function normalizeTopicState(input: {
|
|
148
|
+
id?: string;
|
|
149
|
+
kind?: TopicKind | null;
|
|
150
|
+
agent?: AgentKind | null;
|
|
151
|
+
aiMode?: AiMode | null;
|
|
152
|
+
aiMention?: boolean | null;
|
|
153
|
+
}): {
|
|
154
|
+
kind: TopicKind;
|
|
155
|
+
aiMode: AiMode;
|
|
156
|
+
agent?: AgentKind;
|
|
157
|
+
};
|
|
158
|
+
export declare function upsertTopic(t: TopicDto): void;
|
|
159
|
+
/**
|
|
160
|
+
* List topics, optionally restricted to one surface.
|
|
161
|
+
*
|
|
162
|
+
* The filter lives here rather than in each adapter so a forgotten call site
|
|
163
|
+
* cannot leak a telegram room into the terminal picker; adapters pass their own
|
|
164
|
+
* surface and get a closed world back.
|
|
165
|
+
*/
|
|
166
|
+
export declare function listTopics(opts?: {
|
|
167
|
+
surface?: TopicSurface;
|
|
168
|
+
surfaceScope?: string | null;
|
|
169
|
+
}): TopicDto[];
|
|
170
|
+
export declare function getTopic(id: string): TopicDto | null;
|
|
171
|
+
/** Return the private manager room owned by a user, excluding the retired shared General row. */
|
|
172
|
+
/**
|
|
173
|
+
* The user's own manager room, optionally on one surface.
|
|
174
|
+
*
|
|
175
|
+
* A manager room is one per user **per surface**: Terminal and Telegram each
|
|
176
|
+
* give the same person their own personal room, and returning one surface's
|
|
177
|
+
* room to the other adapter lets that adapter bind to — and reclassify — a room
|
|
178
|
+
* belonging to a different surface. Callers that represent an adapter pass
|
|
179
|
+
* theirs; unscoped lookups stay for maintenance paths that work by user alone.
|
|
180
|
+
*/
|
|
181
|
+
export declare function getManagerTopicForUser(userId: string, surface?: TopicSurface, opts?: {
|
|
182
|
+
surfaceScope?: string | null;
|
|
183
|
+
}): TopicDto | null;
|
|
184
|
+
/**
|
|
185
|
+
* Resolve the topic whose wiki memory should be used for this topic.
|
|
186
|
+
*
|
|
187
|
+
* Derived rooms keep `parentTopicId` as an immediate UI link. Memory normally
|
|
188
|
+
* follows the chain to its original root, while `memoryTopicId` can redirect a
|
|
189
|
+
* subagent to another accessible topic's accumulated knowledge.
|
|
190
|
+
*/
|
|
191
|
+
export declare function getTopicMemoryOrigin(id: string): TopicDto | null;
|
|
192
|
+
/** Look up a topic by its user-visible title (case-insensitive exact match). */
|
|
193
|
+
export declare function getTopicByName(title: string): TopicDto | null;
|
|
194
|
+
export declare function getTopicByNameAndKind(title: string, kind: TopicKind): TopicDto | null;
|
|
195
|
+
/**
|
|
196
|
+
* Titles are unique **per surface namespace**, not per node: the same title may
|
|
197
|
+
* exist on terminal, in multiple Telegram groups, and in each attached Otium
|
|
198
|
+
* workspace. Independent namespaces never see each other, so a name taken in
|
|
199
|
+
* one says nothing about another.
|
|
200
|
+
*/
|
|
201
|
+
export declare function findTopicTitleConflict(title: string, kind: TopicKind, opts?: {
|
|
202
|
+
excludeTopicId?: string;
|
|
203
|
+
surface?: TopicSurface;
|
|
204
|
+
surfaceScope?: string | null;
|
|
205
|
+
}): TopicDto | null;
|
|
206
|
+
/**
|
|
207
|
+
* Move topics onto a surface. Used by adapters that own a classification the
|
|
208
|
+
* canonical store cannot derive on its own (the telegram chat↔topic mapping
|
|
209
|
+
* lives in that adapter's database, not this one).
|
|
210
|
+
*/
|
|
211
|
+
export declare function setTopicSurfaces(topicIds: readonly string[], surface: TopicSurface): number;
|
|
212
|
+
/**
|
|
213
|
+
* File an existing topic into one surface namespace without changing its id.
|
|
214
|
+
* Adapter-owned migrations use this when their local mapping store is the only
|
|
215
|
+
* authority capable of deriving the namespace (for example Telegram chat id).
|
|
216
|
+
*/
|
|
217
|
+
export declare function setTopicSurfaceScope(topicId: string, surface: TopicSurface, surfaceScope: string | null): boolean;
|
|
218
|
+
/**
|
|
219
|
+
* How wide a title lookup is allowed to reach.
|
|
220
|
+
*
|
|
221
|
+
* `surface` is required rather than optional. It used to default to "search
|
|
222
|
+
* every surface", which contradicted S-6's promise that a missed call site
|
|
223
|
+
* "cannot leak a topic across surfaces" — the guarantee only held where a
|
|
224
|
+
* caller remembered to opt in, and four did not: Telegram's `/load` and `/del`
|
|
225
|
+
* (the latter could delete a terminal room), the runtime MCP id path, the cron
|
|
226
|
+
* id path, and the session inbox. Every one of those was a silent leak with a
|
|
227
|
+
* correct-looking call. Making the parameter explicit turns each future
|
|
228
|
+
* omission into a compile error instead.
|
|
229
|
+
*
|
|
230
|
+
* `{ scope: "all" }` is the deliberate way to search every surface. It exists
|
|
231
|
+
* for operator tooling — the CLI manages jobs across surfaces on purpose — and
|
|
232
|
+
* reads as a decision at the call site rather than as an oversight.
|
|
233
|
+
*/
|
|
234
|
+
export type TopicNameLookupScope = {
|
|
235
|
+
surface: TopicSurface;
|
|
236
|
+
surfaceScope?: string | null;
|
|
237
|
+
} | {
|
|
238
|
+
scope: "all";
|
|
239
|
+
};
|
|
240
|
+
/**
|
|
241
|
+
* Look up a topic by title, restricted to topics where `userId` participates.
|
|
242
|
+
*
|
|
243
|
+
* Answers only on a single match: a title is unique per surface (S-3), so an
|
|
244
|
+
* `{ scope: "all" }` lookup of a name used on two surfaces resolves to null
|
|
245
|
+
* rather than picking one.
|
|
246
|
+
*/
|
|
247
|
+
export declare function getTopicByNameForUser(title: string, userId: string, lookupScope: TopicNameLookupScope): TopicDto | null;
|
|
248
|
+
/** Persist the agent session ID for a topic after a successful turn. */
|
|
249
|
+
export declare function setTopicSessionId(topicId: string, sessionId: string, context?: TopicSessionLogContext): void;
|
|
250
|
+
/** Clear the session ID (e.g. on topic reset). */
|
|
251
|
+
export declare function clearTopicSessionId(topicId: string, reason?: string): void;
|
|
252
|
+
/** Read the persisted session ID for a topic, or null if none. */
|
|
253
|
+
export declare function getTopicSessionId(topicId: string): string | null;
|
|
254
|
+
/**
|
|
255
|
+
* Hard-delete a topic row. Irreversible — the caller is responsible for also
|
|
256
|
+
* deleting the topic's messages (see `deleteMessagesForTopic`). Returns false
|
|
257
|
+
* if the topic didn't exist.
|
|
258
|
+
*/
|
|
259
|
+
export declare function deleteTopic(id: string, options?: {
|
|
260
|
+
allowManager?: boolean;
|
|
261
|
+
}): boolean;
|
|
262
|
+
export declare function listSubagentTellTargetIds(subagentTopicId: string): string[];
|
|
263
|
+
export declare function grantSubagentTellTarget(subagentTopicId: string, targetTopicId: string, grantedByTopicId: string): void;
|
|
264
|
+
export declare function revokeSubagentTellTarget(subagentTopicId: string, targetTopicId: string): boolean;
|
|
265
|
+
/**
|
|
266
|
+
* Preserve a derived-topic chain when an intermediate parent is deleted.
|
|
267
|
+
* Direct children move to the deleted topic's parent (or become roots) rather
|
|
268
|
+
* than retaining a dangling parent id that would break memory-origin lookup.
|
|
269
|
+
*/
|
|
270
|
+
/** Ids of the subagent worker rooms spawned directly from `parentTopicId`. */
|
|
271
|
+
export declare function listSubagentChildTopicIds(parentTopicId: string): string[];
|
|
272
|
+
export declare function reparentTopicChildren(deletedTopicId: string, replacementParentTopicId: string | null): string[];
|
|
273
|
+
export declare function addParticipantToDB(topicId: string, userId: string, role: "member" | "owner"): boolean;
|
|
274
|
+
export declare function removeParticipantFromDB(topicId: string, userId: string): boolean;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { AskUserQuestionDto } from "../types/api";
|
|
2
|
+
export type AskUserGateState = "pending" | "claimed" | "answered" | "cancelled" | "quarantined";
|
|
3
|
+
export interface AskUserGateRecord {
|
|
4
|
+
gateId: string;
|
|
5
|
+
topicId: string;
|
|
6
|
+
queryId?: string;
|
|
7
|
+
idempotencyKey: string;
|
|
8
|
+
bodyHash: string;
|
|
9
|
+
messageId: string;
|
|
10
|
+
ownerId: string;
|
|
11
|
+
state: AskUserGateState;
|
|
12
|
+
selectedLabel?: string;
|
|
13
|
+
answeredBy?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface AskUserGateCardUpdate {
|
|
16
|
+
topicId: string;
|
|
17
|
+
messageId: string;
|
|
18
|
+
askUserQuestion: AskUserQuestionDto;
|
|
19
|
+
editedAt: string;
|
|
20
|
+
}
|
|
21
|
+
export type PrepareAskUserGateResult = {
|
|
22
|
+
outcome: "created";
|
|
23
|
+
gate: AskUserGateRecord;
|
|
24
|
+
} | {
|
|
25
|
+
outcome: "pending";
|
|
26
|
+
gate: AskUserGateRecord;
|
|
27
|
+
} | {
|
|
28
|
+
outcome: "replay";
|
|
29
|
+
gate: AskUserGateRecord;
|
|
30
|
+
} | {
|
|
31
|
+
outcome: "conflict";
|
|
32
|
+
gate: AskUserGateRecord;
|
|
33
|
+
};
|
|
34
|
+
export declare function prepareAskUserGate(args: {
|
|
35
|
+
gateId: string;
|
|
36
|
+
topicId: string;
|
|
37
|
+
queryId?: string;
|
|
38
|
+
idempotencyKey: string;
|
|
39
|
+
bodyHash: string;
|
|
40
|
+
messageId: string;
|
|
41
|
+
ownerId: string;
|
|
42
|
+
now: string;
|
|
43
|
+
}): PrepareAskUserGateResult;
|
|
44
|
+
export declare function quarantineAskUserGate(gateId: string, ownerId: string, now?: string): AskUserGateCardUpdate | null;
|
|
45
|
+
export declare function quarantineForeignAskUserGates(liveOwnerIds: ReadonlySet<string>, now?: string): AskUserGateCardUpdate[];
|
|
46
|
+
export type ClaimAskUserGateResult = {
|
|
47
|
+
outcome: "claimed";
|
|
48
|
+
gate: AskUserGateRecord;
|
|
49
|
+
askUserQuestion: AskUserQuestionDto;
|
|
50
|
+
editedAt: string;
|
|
51
|
+
} | {
|
|
52
|
+
outcome: "unavailable";
|
|
53
|
+
};
|
|
54
|
+
export declare function claimAskUserGateAndSelect(args: {
|
|
55
|
+
topicId: string;
|
|
56
|
+
messageId: string;
|
|
57
|
+
label: string;
|
|
58
|
+
/** Accept a label that is not one of the card's choices (free-text answer or skip). */
|
|
59
|
+
allowAnyLabel?: boolean;
|
|
60
|
+
userId: string;
|
|
61
|
+
ownerId: string;
|
|
62
|
+
source: string;
|
|
63
|
+
now: string;
|
|
64
|
+
}): ClaimAskUserGateResult;
|
|
65
|
+
export declare function cancelAskUserGate(topicId: string, messageId: string, ownerId: string, now?: string): AskUserGateCardUpdate | null;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export declare const DEFAULT_BROWSER_PROFILE = "default";
|
|
2
|
+
export interface BrowserProfileRecord {
|
|
3
|
+
name: string;
|
|
4
|
+
createdAt: string | null;
|
|
5
|
+
topics: Array<{
|
|
6
|
+
id: string;
|
|
7
|
+
title: string;
|
|
8
|
+
}>;
|
|
9
|
+
deletable: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function normalizeBrowserProfileName(name: string): string;
|
|
12
|
+
export declare function getBrowserProfileOwner(topicId: string, fallbackUserId: string): string;
|
|
13
|
+
export declare function isTopicBrowserProfileOwner(topicId: string, userId: string): boolean;
|
|
14
|
+
export declare function getTopicBrowserProfile(topicId: string): string;
|
|
15
|
+
/** Unprivileged TCP ports only: a CDP endpoint never needs a system port. */
|
|
16
|
+
export declare function isBrowserConnectPort(value: unknown): value is number;
|
|
17
|
+
export declare function getTopicBrowserConnectPort(topicId: string): number | undefined;
|
|
18
|
+
export declare function setTopicBrowserConnectPort(topicId: string, port: number | null): void;
|
|
19
|
+
export declare function hasBrowserProfileTopic(topicId: string): boolean;
|
|
20
|
+
export declare function createBrowserProfile(ownerId: string, rawName: string): string;
|
|
21
|
+
export declare function assignTopicBrowserProfile(opts: {
|
|
22
|
+
topicId: string;
|
|
23
|
+
actorUserId: string;
|
|
24
|
+
profile: string;
|
|
25
|
+
}): {
|
|
26
|
+
previous: string;
|
|
27
|
+
profile: string;
|
|
28
|
+
};
|
|
29
|
+
export declare function listBrowserProfiles(ownerId: string): BrowserProfileRecord[];
|
|
30
|
+
export declare function assertBrowserProfileDeletable(ownerId: string, rawName: string): string;
|
|
31
|
+
export declare function deleteBrowserProfile(ownerId: string, rawName: string): boolean;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import type { AgentKind, UnifiedEvent } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Per-topic conversation log (UnifiedEvent stream) used as the
|
|
4
|
+
* **provider-agnostic source of truth** for cross-agent portability.
|
|
5
|
+
*
|
|
6
|
+
* Storage layout:
|
|
7
|
+
* {DATA_DIR}/conversations/{sanitizedTopicName}.jsonl
|
|
8
|
+
* {DATA_DIR}/conversations/{sanitizedTopicName}.active.jsonl
|
|
9
|
+
*
|
|
10
|
+
* A private General is the one room several users may hold at once, so its
|
|
11
|
+
* pair is qualified with the owner — see {@link topicFilename}.
|
|
12
|
+
*
|
|
13
|
+
* The first file is append-only and retains every yielded UnifiedEvent for
|
|
14
|
+
* archive and teardown. The optional active file is a replaceable provider
|
|
15
|
+
* projection: compaction writes its summary there and later turns append to
|
|
16
|
+
* both streams. Agent switches and rollout repair read the active projection.
|
|
17
|
+
*
|
|
18
|
+
* The Claude/Codex SDK rollouts (~/.claude/projects/, ~/.codex/sessions/) are
|
|
19
|
+
* intentionally treated as opaque side-effects of the SDKs. The raw stream
|
|
20
|
+
* remains the forensic source of truth.
|
|
21
|
+
*/
|
|
22
|
+
export interface ConversationEntry {
|
|
23
|
+
ts: string;
|
|
24
|
+
/**
|
|
25
|
+
* Agent that produced this event, frozen at write time. A topic that has
|
|
26
|
+
* been switched (via `set_agent`) will have a mixed-agent log: earlier
|
|
27
|
+
* entries keep the agent that originally generated them. Replay code
|
|
28
|
+
* (rollout-codec `extractChatPairs`) intentionally ignores this field —
|
|
29
|
+
* the cross-agent rollout's whole point is to feed past dialogue, no
|
|
30
|
+
* matter who produced it, into the *new* SDK as if it were native.
|
|
31
|
+
*/
|
|
32
|
+
agent: AgentKind;
|
|
33
|
+
event: UnifiedEvent;
|
|
34
|
+
}
|
|
35
|
+
/** Compute the absolute path for a given user/topic conversation log. */
|
|
36
|
+
export declare function getConversationPath(userId: number | string, topicName: string): string;
|
|
37
|
+
/** Replaceable provider context derived from the append-only raw conversation log. */
|
|
38
|
+
export declare function getActiveConversationPath(userId: number | string, topicName: string): string;
|
|
39
|
+
export declare function hasActiveConversation(userId: number | string, topicName: string): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Append a single UnifiedEvent for the given topic. Creates the parent
|
|
42
|
+
* directory and the file as needed. Best-effort: I/O failures are logged but
|
|
43
|
+
* never throw, since recording must not break the live stream to Telegram.
|
|
44
|
+
*
|
|
45
|
+
* **Concurrency note (review item M2, revised):** within the bot process the
|
|
46
|
+
* single-threaded event loop already serializes writes — but this module is
|
|
47
|
+
* NOT single-process: the self-config MCP server (a separate stdio process,
|
|
48
|
+
* via `topic-agent-switch`) and provider bridge helpers append to the same
|
|
49
|
+
* topic logs.
|
|
50
|
+
* Cross-process interleaving on macOS is real for lines beyond PIPE_BUF
|
|
51
|
+
* (512B), and a torn line is silently dropped by `readConversation` —
|
|
52
|
+
* corrupting the canonical source for cross-agent rollout reconstruction.
|
|
53
|
+
* Writes therefore go through `appendJsonlLine` (sidecar `.lock` via O_EXCL,
|
|
54
|
+
* stale-lock reclaim, and a `JsonlLockTimeoutError` when the lock stays busy —
|
|
55
|
+
* nothing is written unlocked, so a contended append fails instead of risking
|
|
56
|
+
* an interleaved line that `readConversationPath` would later discard).
|
|
57
|
+
*
|
|
58
|
+
* The append stays SYNCHRONOUS on purpose: a previous attempt at a
|
|
59
|
+
* Promise-chained per-topic queue made writes async (durability gap before a
|
|
60
|
+
* synchronous `readConversation`) and broke `set_agent` in the bridge tests.
|
|
61
|
+
*/
|
|
62
|
+
export declare function appendConversationEvent(userId: number | string, topicName: string, agent: AgentKind, event: UnifiedEvent): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* The raw manifest accepted an entry that the active projection rejected.
|
|
65
|
+
*
|
|
66
|
+
* Distinct from a plain write failure because the two logs are now out of sync
|
|
67
|
+
* rather than merely un-updated: `raw` records the event, `active` — the log
|
|
68
|
+
* replayed to the provider — does not.
|
|
69
|
+
*/
|
|
70
|
+
export declare class ConversationLogDivergedError extends Error {
|
|
71
|
+
readonly rawPath: string;
|
|
72
|
+
readonly activePath: string;
|
|
73
|
+
readonly cause: unknown;
|
|
74
|
+
constructor(rawPath: string, activePath: string, cause: unknown);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Strict variant for state transitions where the conversation log is a manifest
|
|
78
|
+
* rather than telemetry. Throws on I/O failure so callers can avoid committing
|
|
79
|
+
* DB state that points at an unmanifested SDK session.
|
|
80
|
+
*/
|
|
81
|
+
export declare function appendConversationEventStrict(userId: number | string, topicName: string, agent: AgentKind, event: UnifiedEvent): void;
|
|
82
|
+
/** Append lifecycle metadata to the raw manifest without changing active context. */
|
|
83
|
+
export declare function appendRawConversationEventStrict(userId: number | string, topicName: string, agent: AgentKind, event: UnifiedEvent): void;
|
|
84
|
+
/**
|
|
85
|
+
* Read the context the next provider turn should receive. Before the first
|
|
86
|
+
* compaction this is the raw stream. Afterwards the replaceable active stream
|
|
87
|
+
* contains the compacted summary plus every subsequently recorded event.
|
|
88
|
+
*
|
|
89
|
+
* NOTE(perf): reads the whole file each call. Topics in the kilobyte range
|
|
90
|
+
* are fine; if a single topic ever grows into multi-megabyte territory,
|
|
91
|
+
* consider a streaming reader (`readline`/`Bun.file().stream()`) and a
|
|
92
|
+
* size-bounded tail.
|
|
93
|
+
*/
|
|
94
|
+
export declare function readConversation(userId: number | string, topicName: string): ConversationEntry[];
|
|
95
|
+
/** Read the immutable full-fidelity stream used for archive and teardown. */
|
|
96
|
+
export declare function readRawConversation(userId: number | string, topicName: string): ConversationEntry[];
|
|
97
|
+
/** Atomically replace only the provider's active context projection. */
|
|
98
|
+
export declare function replaceConversationStrict(userId: number | string, topicName: string, entries: ConversationEntry[]): void;
|
|
99
|
+
/** Atomically seed or restore the append-only stream before it becomes live. */
|
|
100
|
+
export declare function replaceRawConversationStrict(userId: number | string, topicName: string, entries: ConversationEntry[]): void;
|
|
101
|
+
/**
|
|
102
|
+
* Copy the unified conversation log of `srcTopic` into the file path that
|
|
103
|
+
* `dstTopic` will read from. Used by `/fork` so a forked child topic inherits
|
|
104
|
+
* the parent's full cross-agent history, not just the agent's native SDK
|
|
105
|
+
* rollout. `/spawn` intentionally does not call this; it starts with no
|
|
106
|
+
* conversation history. Without this copy, a fork followed immediately by
|
|
107
|
+
* `/agent <other>` would feed the empty child log to `switchTopicAgent` and
|
|
108
|
+
* the new agent would start from zero — see the bug report from 2026-05-24.
|
|
109
|
+
*
|
|
110
|
+
* Semantics:
|
|
111
|
+
* - Copies the parent's raw stream and its active projection when present.
|
|
112
|
+
* - Writes independent files so parent and child can diverge after the fork.
|
|
113
|
+
* - Refuses to overwrite a non-empty destination (returns `{copied:false}`).
|
|
114
|
+
* `/fork`'s only caller runs this immediately after topic creation when
|
|
115
|
+
* the dst file is guaranteed empty, so a non-empty dst means a programmer
|
|
116
|
+
* error somewhere upstream — fail loud rather than silently merging.
|
|
117
|
+
* - On any I/O error: throws. The caller (`createChildTopic`) already has
|
|
118
|
+
* a rollback path that wraps this call.
|
|
119
|
+
*/
|
|
120
|
+
export declare function cloneConversationLog(opts: {
|
|
121
|
+
userId: number | string;
|
|
122
|
+
srcTopic: string;
|
|
123
|
+
dstTopic: string;
|
|
124
|
+
}): {
|
|
125
|
+
copied: boolean;
|
|
126
|
+
entries: number;
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* Walk the unified log backwards and return the most recent SDK-emitted
|
|
130
|
+
* session id for the given agent — or null if that agent has never run on
|
|
131
|
+
* this topic.
|
|
132
|
+
*
|
|
133
|
+
* Used by `set_agent` to round-trip the SAME native rollout file across
|
|
134
|
+
* agent switches: when the user does claude → codex → claude, we reuse
|
|
135
|
+
* the original claude sessionId so the synthetic rollout lands at the
|
|
136
|
+
* same path the SDK already manages, preserving prompt-cache continuity
|
|
137
|
+
* and avoiding orphan `~/.claude/projects/<dir>/<id>.jsonl` files.
|
|
138
|
+
*
|
|
139
|
+
* Behavior:
|
|
140
|
+
* - First-ever switch to an agent (no prior session events) → null,
|
|
141
|
+
* caller falls back to a fresh randomUUID/uuidv7. Same as before.
|
|
142
|
+
* - Roundtrip switch (prior session exists) → that sessionId.
|
|
143
|
+
*
|
|
144
|
+
* `session` events are emitted on every turn by claude-/codex-provider and
|
|
145
|
+
* captured into the unified log by runAgent's append wrapper. The most
|
|
146
|
+
* recent one for the target agent is by definition the current SDK-side
|
|
147
|
+
* resume key for that agent.
|
|
148
|
+
*/
|
|
149
|
+
export declare function findLastSessionIdForAgent(entries: ConversationEntry[], agent: AgentKind): string | null;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { AgentKind, DecisionSnapshot } from "../types";
|
|
2
|
+
export type StoredDecision = DecisionSnapshot;
|
|
3
|
+
export declare const DECISION_STATUS_VALUES: readonly ["proposed", "accepted", "executed", "rejected", "superseded"];
|
|
4
|
+
export declare function decisionScopeKey(opts: {
|
|
5
|
+
topicId?: string;
|
|
6
|
+
session: string;
|
|
7
|
+
}): string;
|
|
8
|
+
export declare function getDecisionFilePath(userId: number | string, scopeKey: string): string;
|
|
9
|
+
export declare function getDecisionGraphSvgPath(userId: number | string, scopeKey: string): string;
|
|
10
|
+
export declare function writeDecisionGraphSvg(userId: number | string, scopeKey: string, svg: string): string;
|
|
11
|
+
export declare function readDecisions(userId: number | string, scopeKey: string): StoredDecision[];
|
|
12
|
+
export declare function writeDecisions(userId: number | string, scopeKey: string, decisions: StoredDecision[]): void;
|
|
13
|
+
export interface DecisionCreateInput {
|
|
14
|
+
action: string;
|
|
15
|
+
reasoning: string;
|
|
16
|
+
agent: AgentKind;
|
|
17
|
+
model?: string;
|
|
18
|
+
status?: StoredDecision["status"];
|
|
19
|
+
causedBy?: string[];
|
|
20
|
+
timestamp?: number;
|
|
21
|
+
}
|
|
22
|
+
export interface DecisionUpdateInput {
|
|
23
|
+
id: string;
|
|
24
|
+
action?: string;
|
|
25
|
+
reasoning?: string;
|
|
26
|
+
status?: StoredDecision["status"];
|
|
27
|
+
causedBy?: string[];
|
|
28
|
+
}
|
|
29
|
+
export declare function validateDecisionGraph(decisions: StoredDecision[]): void;
|
|
30
|
+
export declare function createDecisions(decisions: StoredDecision[], inputs: DecisionCreateInput[]): {
|
|
31
|
+
decisions: StoredDecision[];
|
|
32
|
+
created: StoredDecision[];
|
|
33
|
+
};
|
|
34
|
+
export declare function updateDecisions(decisions: StoredDecision[], updates: DecisionUpdateInput[]): {
|
|
35
|
+
decisions: StoredDecision[];
|
|
36
|
+
missing: string[];
|
|
37
|
+
};
|
|
38
|
+
export declare function deleteDecisions(decisions: StoredDecision[], opts: {
|
|
39
|
+
ids?: string[];
|
|
40
|
+
all?: boolean;
|
|
41
|
+
}): {
|
|
42
|
+
decisions: StoredDecision[];
|
|
43
|
+
removed: number;
|
|
44
|
+
};
|
|
45
|
+
export declare function renderDecisionList(decisions: StoredDecision[]): string;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type AgentKind } from "../../types";
|
|
2
|
+
import { type ForumTopicInfo, type UserForumConfig } from "./schema";
|
|
3
|
+
export declare function getUserConfig(userId: number): UserForumConfig | null;
|
|
4
|
+
export declare function getTopicByName(userId: number, name: string): ForumTopicInfo | null;
|
|
5
|
+
export declare function findUserByThread(threadId: number): {
|
|
6
|
+
userId: number;
|
|
7
|
+
topic: ForumTopicInfo;
|
|
8
|
+
} | null;
|
|
9
|
+
export declare function getSessionForTopic(userId: number, topicName: string): string | null;
|
|
10
|
+
export declare function getTopicNames(userId: number): string[];
|
|
11
|
+
export declare function getAllTopics(userId: number): ForumTopicInfo[];
|
|
12
|
+
export declare function getAllUserIds(): number[];
|
|
13
|
+
export declare function getCommunicateThreadId(userId: number): number | null;
|
|
14
|
+
export declare function getDmSessionId(userId: number): string | null;
|
|
15
|
+
export declare function getTopicDescription(userId: number, topicName: string): string | null;
|
|
16
|
+
export declare function getTopicMcpConfig(userId: number, topicName: string): {
|
|
17
|
+
enabled: string[] | null;
|
|
18
|
+
extra: Record<string, unknown>;
|
|
19
|
+
};
|
|
20
|
+
export declare function addTopic(userId: number, name: string, messageThreadId: number, sessionId?: string, createdAt?: string): boolean;
|
|
21
|
+
export declare function renameTopic(userId: number, oldName: string, newName: string): {
|
|
22
|
+
ok: true;
|
|
23
|
+
} | {
|
|
24
|
+
ok: false;
|
|
25
|
+
reason: "not_found" | "name_taken";
|
|
26
|
+
};
|
|
27
|
+
export declare function removeTopic(userId: number, name: string): void;
|
|
28
|
+
export declare function setSessionForTopic(userId: number, topicName: string, sessionId: string): void;
|
|
29
|
+
export declare function clearSessionForTopic(userId: number, topicName: string): void;
|
|
30
|
+
export declare function setDmSessionId(userId: number, sessionId: string): void;
|
|
31
|
+
export declare function clearDmSessionId(userId: number): void;
|
|
32
|
+
export declare function setTopicDescription(userId: number, topicName: string, description: string): boolean;
|
|
33
|
+
export declare function getLastShownConfig(userId: number, topicName: string): {
|
|
34
|
+
agent: AgentKind | null;
|
|
35
|
+
model: string | null;
|
|
36
|
+
effort: string | null;
|
|
37
|
+
} | null;
|
|
38
|
+
export declare function setLastShownConfig(userId: number, topicName: string, agent: AgentKind, model: string, effort: string | undefined): boolean;
|
|
39
|
+
export declare function setTopicForkOrigin(userId: number, topicName: string, origin: string): boolean;
|
|
40
|
+
export declare function updateTopicThreadId(userId: number, topicName: string, newThreadId: number): boolean;
|
|
41
|
+
export declare function setTopicMcpEnabled(userId: number, topicName: string, enabled: string[] | null): boolean;
|
|
42
|
+
export declare function setTopicMcpExtra(userId: number, topicName: string, extra: Record<string, unknown>): boolean;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { logger } from "../../platform/logger";
|
|
2
|
+
import { db } from "../forum-db";
|
|
3
|
+
import { type AgentKind } from "../../types";
|
|
4
|
+
export { db };
|
|
5
|
+
export interface ForumTopicInfo {
|
|
6
|
+
messageThreadId: number;
|
|
7
|
+
sessionId: string;
|
|
8
|
+
createdAt: string;
|
|
9
|
+
name: string;
|
|
10
|
+
description?: string;
|
|
11
|
+
forkOrigin?: string;
|
|
12
|
+
agent: AgentKind;
|
|
13
|
+
}
|
|
14
|
+
export interface UserForumConfig {
|
|
15
|
+
communicateThreadId?: number;
|
|
16
|
+
dmSessionId?: string;
|
|
17
|
+
topics: {
|
|
18
|
+
[topicName: string]: ForumTopicInfo;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export type TopicRow = {
|
|
22
|
+
user_id: string;
|
|
23
|
+
name: string;
|
|
24
|
+
message_thread_id: number;
|
|
25
|
+
session_id: string | null;
|
|
26
|
+
created_at: string;
|
|
27
|
+
description: string | null;
|
|
28
|
+
fork_origin: string | null;
|
|
29
|
+
agent: string | null;
|
|
30
|
+
};
|
|
31
|
+
export type UserRow = {
|
|
32
|
+
id: string;
|
|
33
|
+
dm_session_id: string | null;
|
|
34
|
+
communicate_thread_id: number | null;
|
|
35
|
+
};
|
|
36
|
+
export declare function rowToTopic(row: TopicRow): ForumTopicInfo;
|
|
37
|
+
export declare function flushSessionCache(): void;
|
|
38
|
+
export { logger };
|