@namzu/sdk 30.2.0 → 31.0.0
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/CHANGELOG.md +556 -0
- package/README.md +43 -2
- package/dist/advisory/executor.d.ts +2 -1
- package/dist/advisory/executor.d.ts.map +1 -1
- package/dist/advisory/executor.js +4 -1
- package/dist/advisory/executor.js.map +1 -1
- package/dist/agents/ReactiveAgent.d.ts.map +1 -1
- package/dist/agents/ReactiveAgent.js +12 -0
- package/dist/agents/ReactiveAgent.js.map +1 -1
- package/dist/agents/RouterAgent.d.ts.map +1 -1
- package/dist/agents/RouterAgent.js +21 -3
- package/dist/agents/RouterAgent.js.map +1 -1
- package/dist/agents/SupervisorAgent.d.ts.map +1 -1
- package/dist/agents/SupervisorAgent.js +34 -11
- package/dist/agents/SupervisorAgent.js.map +1 -1
- package/dist/agents/runAgent.d.ts +12 -0
- package/dist/agents/runAgent.d.ts.map +1 -1
- package/dist/agents/runAgent.js +26 -2
- package/dist/agents/runAgent.js.map +1 -1
- package/dist/authorization/command-line.d.ts +81 -0
- package/dist/authorization/command-line.d.ts.map +1 -0
- package/dist/authorization/command-line.js +347 -0
- package/dist/authorization/command-line.js.map +1 -0
- package/dist/authorization/rules.d.ts.map +1 -1
- package/dist/authorization/rules.js +22 -1
- package/dist/authorization/rules.js.map +1 -1
- package/dist/bridge/a2a/client.d.ts +23 -5
- package/dist/bridge/a2a/client.d.ts.map +1 -1
- package/dist/bridge/a2a/client.js +320 -73
- package/dist/bridge/a2a/client.js.map +1 -1
- package/dist/bridge/a2a/mapper.d.ts.map +1 -1
- package/dist/bridge/a2a/mapper.js +4 -0
- package/dist/bridge/a2a/mapper.js.map +1 -1
- package/dist/bridge/acp/server.d.ts +13 -1
- package/dist/bridge/acp/server.d.ts.map +1 -1
- package/dist/bridge/acp/server.js +150 -44
- package/dist/bridge/acp/server.js.map +1 -1
- package/dist/bridge/mcp/connector/adapter.d.ts +3 -2
- package/dist/bridge/mcp/connector/adapter.d.ts.map +1 -1
- package/dist/bridge/mcp/connector/adapter.js +17 -21
- package/dist/bridge/mcp/connector/adapter.js.map +1 -1
- package/dist/bridge/sse/mapper.d.ts.map +1 -1
- package/dist/bridge/sse/mapper.js +3 -0
- package/dist/bridge/sse/mapper.js.map +1 -1
- package/dist/compaction/dangling.d.ts +29 -2
- package/dist/compaction/dangling.d.ts.map +1 -1
- package/dist/compaction/dangling.js +172 -35
- package/dist/compaction/dangling.js.map +1 -1
- package/dist/compaction/index.d.ts +3 -2
- package/dist/compaction/index.d.ts.map +1 -1
- package/dist/compaction/index.js +1 -1
- package/dist/compaction/index.js.map +1 -1
- package/dist/compaction/manual.d.ts +11 -1
- package/dist/compaction/manual.d.ts.map +1 -1
- package/dist/compaction/manual.js +89 -14
- package/dist/compaction/manual.js.map +1 -1
- package/dist/compaction/plan.d.ts +19 -6
- package/dist/compaction/plan.d.ts.map +1 -1
- package/dist/compaction/plan.js +18 -4
- package/dist/compaction/plan.js.map +1 -1
- package/dist/compaction/retention.d.ts +10 -7
- package/dist/compaction/retention.d.ts.map +1 -1
- package/dist/compaction/retention.js +26 -8
- package/dist/compaction/retention.js.map +1 -1
- package/dist/compaction/summary.d.ts +4 -4
- package/dist/compaction/summary.js +4 -4
- package/dist/compaction/verifier.d.ts +19 -1
- package/dist/compaction/verifier.d.ts.map +1 -1
- package/dist/compaction/verifier.js +20 -1
- package/dist/compaction/verifier.js.map +1 -1
- package/dist/config/runtime.d.ts +6 -6
- package/dist/connector/BaseConnector.d.ts +6 -4
- package/dist/connector/BaseConnector.d.ts.map +1 -1
- package/dist/connector/BaseConnector.js +8 -2
- package/dist/connector/BaseConnector.js.map +1 -1
- package/dist/connector/builtins/http.d.ts +16 -4
- package/dist/connector/builtins/http.d.ts.map +1 -1
- package/dist/connector/builtins/http.js +177 -44
- package/dist/connector/builtins/http.js.map +1 -1
- package/dist/connector/builtins/webhook.d.ts +15 -4
- package/dist/connector/builtins/webhook.d.ts.map +1 -1
- package/dist/connector/builtins/webhook.js +165 -45
- package/dist/connector/builtins/webhook.js.map +1 -1
- package/dist/connector/execution-contract.d.ts +11 -0
- package/dist/connector/execution-contract.d.ts.map +1 -0
- package/dist/connector/execution-contract.js +14 -0
- package/dist/connector/execution-contract.js.map +1 -0
- package/dist/connector/http-operation.d.ts +48 -0
- package/dist/connector/http-operation.d.ts.map +1 -0
- package/dist/connector/http-operation.js +205 -0
- package/dist/connector/http-operation.js.map +1 -0
- package/dist/connector/mcp/adapter.d.ts.map +1 -1
- package/dist/connector/mcp/adapter.js +8 -3
- package/dist/connector/mcp/adapter.js.map +1 -1
- package/dist/connector/mcp/client.d.ts +14 -8
- package/dist/connector/mcp/client.d.ts.map +1 -1
- package/dist/connector/mcp/client.js +160 -44
- package/dist/connector/mcp/client.js.map +1 -1
- package/dist/connector/mcp/http-sse.d.ts +8 -2
- package/dist/connector/mcp/http-sse.d.ts.map +1 -1
- package/dist/connector/mcp/http-sse.js +70 -17
- package/dist/connector/mcp/http-sse.js.map +1 -1
- package/dist/connector/mcp/prompt-adapter.d.ts.map +1 -1
- package/dist/connector/mcp/prompt-adapter.js +9 -2
- package/dist/connector/mcp/prompt-adapter.js.map +1 -1
- package/dist/connector/mcp/stdio.d.ts +2 -2
- package/dist/connector/mcp/stdio.d.ts.map +1 -1
- package/dist/connector/mcp/stdio.js +14 -50
- package/dist/connector/mcp/stdio.js.map +1 -1
- package/dist/connector/mcp/streamable-http.d.ts +7 -2
- package/dist/connector/mcp/streamable-http.d.ts.map +1 -1
- package/dist/connector/mcp/streamable-http.js +66 -18
- package/dist/connector/mcp/streamable-http.js.map +1 -1
- package/dist/connector/tools/adapter.d.ts +2 -2
- package/dist/connector/tools/adapter.d.ts.map +1 -1
- package/dist/connector/tools/adapter.js +23 -14
- package/dist/connector/tools/adapter.js.map +1 -1
- package/dist/connector/tools/definitions.d.ts.map +1 -1
- package/dist/connector/tools/definitions.js +5 -2
- package/dist/connector/tools/definitions.js.map +1 -1
- package/dist/connector/tools/result.d.ts +4 -0
- package/dist/connector/tools/result.d.ts.map +1 -0
- package/dist/connector/tools/result.js +20 -0
- package/dist/connector/tools/result.js.map +1 -0
- package/dist/connector/web/guarded-fetch.d.ts +4 -2
- package/dist/connector/web/guarded-fetch.d.ts.map +1 -1
- package/dist/connector/web/guarded-fetch.js +157 -43
- package/dist/connector/web/guarded-fetch.js.map +1 -1
- package/dist/constants/sandbox/index.d.ts +3 -2
- package/dist/constants/sandbox/index.d.ts.map +1 -1
- package/dist/constants/sandbox/index.js +3 -2
- package/dist/constants/sandbox/index.js.map +1 -1
- package/dist/contracts/api.d.ts +2 -0
- package/dist/contracts/api.d.ts.map +1 -1
- package/dist/contracts/schemas.d.ts +38 -12
- package/dist/contracts/schemas.d.ts.map +1 -1
- package/dist/contracts/schemas.js +7 -0
- package/dist/contracts/schemas.js.map +1 -1
- package/dist/directory/derive-supervisor.d.ts.map +1 -1
- package/dist/directory/derive-supervisor.js +8 -0
- package/dist/directory/derive-supervisor.js.map +1 -1
- package/dist/directory/derive.d.ts.map +1 -1
- package/dist/directory/derive.js +8 -0
- package/dist/directory/derive.js.map +1 -1
- package/dist/directory/load.d.ts.map +1 -1
- package/dist/directory/load.js +2 -0
- package/dist/directory/load.js.map +1 -1
- package/dist/directory/types.d.ts +4 -0
- package/dist/directory/types.d.ts.map +1 -1
- package/dist/eval/experiment.d.ts +10 -10
- package/dist/eval/experiment.d.ts.map +1 -1
- package/dist/eval/experiment.js +121 -91
- package/dist/eval/experiment.js.map +1 -1
- package/dist/eval/judge.d.ts +6 -0
- package/dist/eval/judge.d.ts.map +1 -1
- package/dist/eval/judge.js +7 -2
- package/dist/eval/judge.js.map +1 -1
- package/dist/eval/types.d.ts +7 -1
- package/dist/eval/types.d.ts.map +1 -1
- package/dist/manager/agent/lifecycle.d.ts +12 -10
- package/dist/manager/agent/lifecycle.d.ts.map +1 -1
- package/dist/manager/agent/lifecycle.js +16 -3
- package/dist/manager/agent/lifecycle.js.map +1 -1
- package/dist/manager/connector/environment.d.ts +2 -2
- package/dist/manager/connector/environment.d.ts.map +1 -1
- package/dist/manager/connector/environment.js +2 -2
- package/dist/manager/connector/environment.js.map +1 -1
- package/dist/manager/connector/lifecycle.d.ts +10 -2
- package/dist/manager/connector/lifecycle.d.ts.map +1 -1
- package/dist/manager/connector/lifecycle.js +273 -24
- package/dist/manager/connector/lifecycle.js.map +1 -1
- package/dist/manager/connector/tenant.d.ts +5 -4
- package/dist/manager/connector/tenant.d.ts.map +1 -1
- package/dist/manager/connector/tenant.js +47 -22
- package/dist/manager/connector/tenant.js.map +1 -1
- package/dist/manager/goal/activation.d.ts +23 -0
- package/dist/manager/goal/activation.d.ts.map +1 -0
- package/dist/manager/goal/activation.js +41 -0
- package/dist/manager/goal/activation.js.map +1 -0
- package/dist/manager/index.d.ts +3 -2
- package/dist/manager/index.d.ts.map +1 -1
- package/dist/manager/index.js.map +1 -1
- package/dist/manager/run/persistence.d.ts +2 -0
- package/dist/manager/run/persistence.d.ts.map +1 -1
- package/dist/manager/run/persistence.js +5 -1
- package/dist/manager/run/persistence.js.map +1 -1
- package/dist/manager/topic/dependency.d.ts +24 -0
- package/dist/manager/topic/dependency.d.ts.map +1 -0
- package/dist/manager/topic/dependency.js +13 -0
- package/dist/manager/topic/dependency.js.map +1 -0
- package/dist/manager/topic/lifecycle.d.ts +9 -21
- package/dist/manager/topic/lifecycle.d.ts.map +1 -1
- package/dist/manager/topic/lifecycle.js +17 -29
- package/dist/manager/topic/lifecycle.js.map +1 -1
- package/dist/plugin/index.d.ts +1 -0
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.js.map +1 -1
- package/dist/plugin/lifecycle.d.ts +15 -0
- package/dist/plugin/lifecycle.d.ts.map +1 -1
- package/dist/plugin/lifecycle.js +144 -38
- package/dist/plugin/lifecycle.js.map +1 -1
- package/dist/plugin/loader.d.ts +3 -3
- package/dist/plugin/loader.d.ts.map +1 -1
- package/dist/plugin/loader.js +58 -12
- package/dist/plugin/loader.js.map +1 -1
- package/dist/provider/collect-chat-completion.d.ts.map +1 -1
- package/dist/provider/collect-chat-completion.js +4 -0
- package/dist/provider/collect-chat-completion.js.map +1 -1
- package/dist/provider/fallback.d.ts +3 -1
- package/dist/provider/fallback.d.ts.map +1 -1
- package/dist/provider/fallback.js +62 -10
- package/dist/provider/fallback.js.map +1 -1
- package/dist/provider/idle-timeout.d.ts +4 -0
- package/dist/provider/idle-timeout.d.ts.map +1 -1
- package/dist/provider/idle-timeout.js +131 -15
- package/dist/provider/idle-timeout.js.map +1 -1
- package/dist/provider/index.d.ts +2 -0
- package/dist/provider/index.d.ts.map +1 -1
- package/dist/provider/index.js +1 -0
- package/dist/provider/index.js.map +1 -1
- package/dist/provider/instrumentation.d.ts.map +1 -1
- package/dist/provider/instrumentation.js +1 -0
- package/dist/provider/instrumentation.js.map +1 -1
- package/dist/provider/retry.d.ts.map +1 -1
- package/dist/provider/retry.js +13 -1
- package/dist/provider/retry.js.map +1 -1
- package/dist/public-runtime.d.ts +57 -24
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +42 -35
- package/dist/public-runtime.js.map +1 -1
- package/dist/public-tools.d.ts +1 -0
- package/dist/public-tools.d.ts.map +1 -1
- package/dist/public-tools.js +5 -0
- package/dist/public-tools.js.map +1 -1
- package/dist/public-types.d.ts +33 -12
- package/dist/public-types.d.ts.map +1 -1
- package/dist/rag/embedding.d.ts +8 -3
- package/dist/rag/embedding.d.ts.map +1 -1
- package/dist/rag/embedding.js +120 -9
- package/dist/rag/embedding.js.map +1 -1
- package/dist/rag/index.d.ts +1 -1
- package/dist/rag/index.d.ts.map +1 -1
- package/dist/rag/index.js +1 -1
- package/dist/rag/index.js.map +1 -1
- package/dist/rag/ingestion.d.ts +2 -2
- package/dist/rag/ingestion.d.ts.map +1 -1
- package/dist/rag/ingestion.js +15 -3
- package/dist/rag/ingestion.js.map +1 -1
- package/dist/rag/knowledge-base.d.ts +3 -3
- package/dist/rag/knowledge-base.d.ts.map +1 -1
- package/dist/rag/knowledge-base.js +8 -4
- package/dist/rag/knowledge-base.js.map +1 -1
- package/dist/rag/operation.d.ts +10 -0
- package/dist/rag/operation.d.ts.map +1 -0
- package/dist/rag/operation.js +26 -0
- package/dist/rag/operation.js.map +1 -0
- package/dist/rag/rag-tool.d.ts.map +1 -1
- package/dist/rag/rag-tool.js +6 -3
- package/dist/rag/rag-tool.js.map +1 -1
- package/dist/rag/retriever.d.ts +2 -2
- package/dist/rag/retriever.d.ts.map +1 -1
- package/dist/rag/retriever.js +31 -15
- package/dist/rag/retriever.js.map +1 -1
- package/dist/rag/vector-store.d.ts +3 -3
- package/dist/rag/vector-store.d.ts.map +1 -1
- package/dist/rag/vector-store.js +4 -2
- package/dist/rag/vector-store.js.map +1 -1
- package/dist/registry/command/kernel-commands.d.ts +16 -4
- package/dist/registry/command/kernel-commands.d.ts.map +1 -1
- package/dist/registry/command/kernel-commands.js +171 -0
- package/dist/registry/command/kernel-commands.js.map +1 -1
- package/dist/run/reporter.d.ts.map +1 -1
- package/dist/run/reporter.js +9 -0
- package/dist/run/reporter.js.map +1 -1
- package/dist/run-query/index.d.ts +15 -1
- package/dist/run-query/index.d.ts.map +1 -1
- package/dist/run-query/index.js +69 -15
- package/dist/run-query/index.js.map +1 -1
- package/dist/runtime/query/context.d.ts.map +1 -1
- package/dist/runtime/query/context.js +10 -3
- package/dist/runtime/query/context.js.map +1 -1
- package/dist/runtime/query/executor.d.ts +3 -0
- package/dist/runtime/query/executor.d.ts.map +1 -1
- package/dist/runtime/query/executor.js +80 -18
- package/dist/runtime/query/executor.js.map +1 -1
- package/dist/runtime/query/guard.d.ts +9 -0
- package/dist/runtime/query/guard.d.ts.map +1 -1
- package/dist/runtime/query/guard.js +11 -0
- package/dist/runtime/query/guard.js.map +1 -1
- package/dist/runtime/query/index.d.ts +30 -1
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +548 -95
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/runtime/query/iteration/index.d.ts.map +1 -1
- package/dist/runtime/query/iteration/index.js +74 -14
- package/dist/runtime/query/iteration/index.js.map +1 -1
- package/dist/runtime/query/iteration/phases/compaction.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/compaction.js +94 -53
- package/dist/runtime/query/iteration/phases/compaction.js.map +1 -1
- package/dist/runtime/query/iteration/phases/context.d.ts +3 -0
- package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/context.js.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.js +21 -0
- package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
- package/dist/runtime/query/iteration/stream-turn.d.ts.map +1 -1
- package/dist/runtime/query/iteration/stream-turn.js +4 -0
- package/dist/runtime/query/iteration/stream-turn.js.map +1 -1
- package/dist/runtime/query/project-instructions.d.ts +69 -0
- package/dist/runtime/query/project-instructions.d.ts.map +1 -0
- package/dist/runtime/query/project-instructions.js +137 -0
- package/dist/runtime/query/project-instructions.js.map +1 -0
- package/dist/runtime/query/request-rich-content.d.ts +22 -0
- package/dist/runtime/query/request-rich-content.d.ts.map +1 -0
- package/dist/runtime/query/request-rich-content.js +122 -0
- package/dist/runtime/query/request-rich-content.js.map +1 -0
- package/dist/runtime/query/result.d.ts.map +1 -1
- package/dist/runtime/query/result.js +12 -1
- package/dist/runtime/query/result.js.map +1 -1
- package/dist/runtime/query/resume-pending.d.ts.map +1 -1
- package/dist/runtime/query/resume-pending.js +19 -20
- package/dist/runtime/query/resume-pending.js.map +1 -1
- package/dist/runtime/query/resume-run.d.ts.map +1 -1
- package/dist/runtime/query/resume-run.js +54 -8
- package/dist/runtime/query/resume-run.js.map +1 -1
- package/dist/runtime/query/run-state.d.ts +5 -0
- package/dist/runtime/query/run-state.d.ts.map +1 -1
- package/dist/runtime/query/run-state.js +6 -1
- package/dist/runtime/query/run-state.js.map +1 -1
- package/dist/runtime/query/sandbox-lifecycle.d.ts +54 -0
- package/dist/runtime/query/sandbox-lifecycle.d.ts.map +1 -0
- package/dist/runtime/query/sandbox-lifecycle.js +167 -0
- package/dist/runtime/query/sandbox-lifecycle.js.map +1 -0
- package/dist/sandbox/isolation.d.ts.map +1 -1
- package/dist/sandbox/isolation.js +9 -0
- package/dist/sandbox/isolation.js.map +1 -1
- package/dist/sandbox/provider/local.d.ts +56 -6
- package/dist/sandbox/provider/local.d.ts.map +1 -1
- package/dist/sandbox/provider/local.js +181 -76
- package/dist/sandbox/provider/local.js.map +1 -1
- package/dist/sandbox/terminal.d.ts +13 -5
- package/dist/sandbox/terminal.d.ts.map +1 -1
- package/dist/sandbox/terminal.js +11 -3
- package/dist/sandbox/terminal.js.map +1 -1
- package/dist/session/errors.d.ts +28 -29
- package/dist/session/errors.d.ts.map +1 -1
- package/dist/session/errors.js +28 -29
- package/dist/session/errors.js.map +1 -1
- package/dist/session/handoff/broadcast.d.ts +5 -8
- package/dist/session/handoff/broadcast.d.ts.map +1 -1
- package/dist/session/handoff/broadcast.js +16 -6
- package/dist/session/handoff/broadcast.js.map +1 -1
- package/dist/session/handoff/single.d.ts +5 -8
- package/dist/session/handoff/single.d.ts.map +1 -1
- package/dist/session/handoff/single.js +7 -4
- package/dist/session/handoff/single.js.map +1 -1
- package/dist/store/attachment/index.d.ts +11 -3
- package/dist/store/attachment/index.d.ts.map +1 -1
- package/dist/store/attachment/index.js +49 -4
- package/dist/store/attachment/index.js.map +1 -1
- package/dist/store/feedback/conformance.d.ts.map +1 -1
- package/dist/store/feedback/conformance.js +32 -0
- package/dist/store/feedback/conformance.js.map +1 -1
- package/dist/store/feedback/disk.d.ts +8 -6
- package/dist/store/feedback/disk.d.ts.map +1 -1
- package/dist/store/feedback/disk.js +111 -76
- package/dist/store/feedback/disk.js.map +1 -1
- package/dist/store/goal/index.d.ts +111 -0
- package/dist/store/goal/index.d.ts.map +1 -0
- package/dist/store/goal/index.js +436 -0
- package/dist/store/goal/index.js.map +1 -0
- package/dist/store/index.d.ts +1 -1
- package/dist/store/index.d.ts.map +1 -1
- package/dist/store/index.js +1 -1
- package/dist/store/index.js.map +1 -1
- package/dist/store/kv/revision-record-store.d.ts +70 -0
- package/dist/store/kv/revision-record-store.d.ts.map +1 -0
- package/dist/store/kv/revision-record-store.js +290 -0
- package/dist/store/kv/revision-record-store.js.map +1 -0
- package/dist/store/memory/disk.d.ts +9 -7
- package/dist/store/memory/disk.d.ts.map +1 -1
- package/dist/store/memory/disk.js +256 -98
- package/dist/store/memory/disk.js.map +1 -1
- package/dist/store/run/disk.d.ts +10 -2
- package/dist/store/run/disk.d.ts.map +1 -1
- package/dist/store/run/disk.js +70 -4
- package/dist/store/run/disk.js.map +1 -1
- package/dist/store/run/memory.d.ts +4 -2
- package/dist/store/run/memory.d.ts.map +1 -1
- package/dist/store/run/memory.js +15 -1
- package/dist/store/run/memory.js.map +1 -1
- package/dist/store/session/disk.d.ts +9 -0
- package/dist/store/session/disk.d.ts.map +1 -1
- package/dist/store/session/disk.js +57 -5
- package/dist/store/session/disk.js.map +1 -1
- package/dist/store/session/memory.d.ts +1 -0
- package/dist/store/session/memory.d.ts.map +1 -1
- package/dist/store/session/memory.js +14 -0
- package/dist/store/session/memory.js.map +1 -1
- package/dist/store/topic/memory.d.ts +1 -2
- package/dist/store/topic/memory.d.ts.map +1 -1
- package/dist/store/topic/memory.js +4 -5
- package/dist/store/topic/memory.js.map +1 -1
- package/dist/store/topic/objective.d.ts +8 -4
- package/dist/store/topic/objective.d.ts.map +1 -1
- package/dist/store/topic/objective.js +185 -100
- package/dist/store/topic/objective.js.map +1 -1
- package/dist/store/topic/state.d.ts +1 -2
- package/dist/store/topic/state.d.ts.map +1 -1
- package/dist/store/topic/state.js +50 -62
- package/dist/store/topic/state.js.map +1 -1
- package/dist/tools/builtins/bash.d.ts.map +1 -1
- package/dist/tools/builtins/bash.js +20 -0
- package/dist/tools/builtins/bash.js.map +1 -1
- package/dist/tools/builtins/computer-use.d.ts +9 -1
- package/dist/tools/builtins/computer-use.d.ts.map +1 -1
- package/dist/tools/builtins/computer-use.js.map +1 -1
- package/dist/tools/builtins/content-fingerprint.d.ts +8 -7
- package/dist/tools/builtins/content-fingerprint.d.ts.map +1 -1
- package/dist/tools/builtins/content-fingerprint.js +9 -10
- package/dist/tools/builtins/content-fingerprint.js.map +1 -1
- package/dist/tools/builtins/edit.d.ts +6 -1
- package/dist/tools/builtins/edit.d.ts.map +1 -1
- package/dist/tools/builtins/edit.js +166 -27
- package/dist/tools/builtins/edit.js.map +1 -1
- package/dist/tools/builtins/write-file.d.ts.map +1 -1
- package/dist/tools/builtins/write-file.js +45 -19
- package/dist/tools/builtins/write-file.js.map +1 -1
- package/dist/tools/command-arguments.d.ts +43 -0
- package/dist/tools/command-arguments.d.ts.map +1 -0
- package/dist/tools/command-arguments.js +52 -0
- package/dist/tools/command-arguments.js.map +1 -0
- package/dist/tools/coordinator/index.d.ts +2 -0
- package/dist/tools/coordinator/index.d.ts.map +1 -1
- package/dist/tools/coordinator/index.js +3 -1
- package/dist/tools/coordinator/index.js.map +1 -1
- package/dist/tools/defineTool.d.ts +10 -0
- package/dist/tools/defineTool.d.ts.map +1 -1
- package/dist/tools/defineTool.js +1 -0
- package/dist/tools/defineTool.js.map +1 -1
- package/dist/tools/env-scrub.d.ts +7 -5
- package/dist/tools/env-scrub.d.ts.map +1 -1
- package/dist/tools/env-scrub.js +7 -5
- package/dist/tools/env-scrub.js.map +1 -1
- package/dist/tools/goal/index.d.ts +20 -0
- package/dist/tools/goal/index.d.ts.map +1 -0
- package/dist/tools/goal/index.js +104 -0
- package/dist/tools/goal/index.js.map +1 -0
- package/dist/tools/memory/index.d.ts +16 -0
- package/dist/tools/memory/index.d.ts.map +1 -1
- package/dist/tools/memory/index.js +6 -2
- package/dist/tools/memory/index.js.map +1 -1
- package/dist/tools/memory/search.d.ts +4 -1
- package/dist/tools/memory/search.d.ts.map +1 -1
- package/dist/tools/memory/search.js +10 -2
- package/dist/tools/memory/search.js.map +1 -1
- package/dist/types/agent/base.d.ts +11 -3
- package/dist/types/agent/base.d.ts.map +1 -1
- package/dist/types/agent/factory.d.ts +2 -0
- package/dist/types/agent/factory.d.ts.map +1 -1
- package/dist/types/agent/reactive.d.ts +2 -0
- package/dist/types/agent/reactive.d.ts.map +1 -1
- package/dist/types/agent/supervisor.d.ts +6 -0
- package/dist/types/agent/supervisor.d.ts.map +1 -1
- package/dist/types/agent/task.d.ts +6 -2
- package/dist/types/agent/task.d.ts.map +1 -1
- package/dist/types/connector/core.d.ts +13 -8
- package/dist/types/connector/core.d.ts.map +1 -1
- package/dist/types/connector/definition.d.ts +37 -18
- package/dist/types/connector/definition.d.ts.map +1 -1
- package/dist/types/connector/http.d.ts +6 -0
- package/dist/types/connector/http.d.ts.map +1 -1
- package/dist/types/connector/mcp.d.ts +24 -6
- package/dist/types/connector/mcp.d.ts.map +1 -1
- package/dist/types/connector/tenant.d.ts +17 -7
- package/dist/types/connector/tenant.d.ts.map +1 -1
- package/dist/types/connector/webhook.d.ts +6 -0
- package/dist/types/connector/webhook.d.ts.map +1 -1
- package/dist/types/goal/index.d.ts +46 -0
- package/dist/types/goal/index.d.ts.map +1 -0
- package/dist/types/goal/index.js +2 -0
- package/dist/types/goal/index.js.map +1 -0
- package/dist/types/ids/index.d.ts +2 -0
- package/dist/types/ids/index.d.ts.map +1 -1
- package/dist/types/ids/index.js.map +1 -1
- package/dist/types/message/index.d.ts +75 -10
- package/dist/types/message/index.d.ts.map +1 -1
- package/dist/types/message/index.js +49 -3
- package/dist/types/message/index.js.map +1 -1
- package/dist/types/plugin/index.d.ts +7 -5
- package/dist/types/plugin/index.d.ts.map +1 -1
- package/dist/types/plugin/index.js.map +1 -1
- package/dist/types/provider/chat.d.ts +27 -4
- package/dist/types/provider/chat.d.ts.map +1 -1
- package/dist/types/provider/interface.d.ts +18 -7
- package/dist/types/provider/interface.d.ts.map +1 -1
- package/dist/types/provider/stream.d.ts +6 -0
- package/dist/types/provider/stream.d.ts.map +1 -1
- package/dist/types/rag/embedding.d.ts +15 -2
- package/dist/types/rag/embedding.d.ts.map +1 -1
- package/dist/types/rag/ingestion.d.ts +2 -2
- package/dist/types/rag/ingestion.d.ts.map +1 -1
- package/dist/types/rag/knowledge-base.d.ts +3 -3
- package/dist/types/rag/knowledge-base.d.ts.map +1 -1
- package/dist/types/rag/retrieval.d.ts +2 -2
- package/dist/types/rag/retrieval.d.ts.map +1 -1
- package/dist/types/rag/scope.d.ts +4 -0
- package/dist/types/rag/scope.d.ts.map +1 -1
- package/dist/types/rag/vector.d.ts +5 -2
- package/dist/types/rag/vector.d.ts.map +1 -1
- package/dist/types/run/config.d.ts +20 -0
- package/dist/types/run/config.d.ts.map +1 -1
- package/dist/types/run/events.d.ts +25 -1
- package/dist/types/run/events.d.ts.map +1 -1
- package/dist/types/run/events.js.map +1 -1
- package/dist/types/run/metadata.d.ts +2 -0
- package/dist/types/run/metadata.d.ts.map +1 -1
- package/dist/types/run/step.d.ts +2 -6
- package/dist/types/run/step.d.ts.map +1 -1
- package/dist/types/run/step.js.map +1 -1
- package/dist/types/run/store.d.ts +55 -2
- package/dist/types/run/store.d.ts.map +1 -1
- package/dist/types/sandbox/index.d.ts +47 -6
- package/dist/types/sandbox/index.d.ts.map +1 -1
- package/dist/types/sandbox/index.js +23 -10
- package/dist/types/sandbox/index.js.map +1 -1
- package/dist/types/session/store.d.ts +13 -0
- package/dist/types/session/store.d.ts.map +1 -1
- package/dist/types/tool/index.d.ts +33 -11
- package/dist/types/tool/index.d.ts.map +1 -1
- package/dist/types/tool/index.js.map +1 -1
- package/dist/types/topic/entity.d.ts +3 -4
- package/dist/types/topic/entity.d.ts.map +1 -1
- package/dist/types/topic/store.d.ts +3 -3
- package/dist/utils/id.d.ts +3 -1
- package/dist/utils/id.d.ts.map +1 -1
- package/dist/utils/id.js +4 -0
- package/dist/utils/id.js.map +1 -1
- package/dist/utils/process-environment.d.ts +26 -0
- package/dist/utils/process-environment.d.ts.map +1 -0
- package/dist/utils/process-environment.js +78 -0
- package/dist/utils/process-environment.js.map +1 -0
- package/dist/vault/InMemoryCredentialVault.d.ts +2 -0
- package/dist/vault/InMemoryCredentialVault.d.ts.map +1 -1
- package/dist/vault/InMemoryCredentialVault.js +24 -4
- package/dist/vault/InMemoryCredentialVault.js.map +1 -1
- package/dist/vault/instrumentation.d.ts.map +1 -1
- package/dist/vault/instrumentation.js +15 -0
- package/dist/vault/instrumentation.js.map +1 -1
- package/package.json +1 -1
- package/src/advisory/executor.ts +4 -1
- package/src/agents/ReactiveAgent.ts +12 -0
- package/src/agents/RouterAgent.ts +25 -3
- package/src/agents/SupervisorAgent.ts +33 -11
- package/src/agents/runAgent.ts +38 -2
- package/src/authorization/command-line.ts +390 -0
- package/src/authorization/rules.ts +22 -1
- package/src/bridge/a2a/client.ts +384 -97
- package/src/bridge/a2a/mapper.ts +5 -0
- package/src/bridge/acp/server.ts +184 -42
- package/src/bridge/mcp/connector/adapter.ts +28 -20
- package/src/bridge/sse/mapper.ts +3 -0
- package/src/compaction/dangling.ts +203 -38
- package/src/compaction/index.ts +9 -2
- package/src/compaction/manual.ts +125 -18
- package/src/compaction/plan.ts +42 -11
- package/src/compaction/retention.ts +23 -8
- package/src/compaction/summary.ts +4 -4
- package/src/compaction/verifier.ts +66 -0
- package/src/connector/BaseConnector.ts +19 -4
- package/src/connector/builtins/http.ts +236 -46
- package/src/connector/builtins/webhook.ts +207 -47
- package/src/connector/execution-contract.ts +27 -0
- package/src/connector/http-operation.ts +238 -0
- package/src/connector/mcp/adapter.ts +8 -3
- package/src/connector/mcp/client.ts +207 -58
- package/src/connector/mcp/http-sse.ts +91 -23
- package/src/connector/mcp/prompt-adapter.ts +8 -2
- package/src/connector/mcp/stdio.ts +21 -46
- package/src/connector/mcp/streamable-http.ts +86 -22
- package/src/connector/tools/adapter.ts +23 -14
- package/src/connector/tools/definitions.ts +5 -2
- package/src/connector/tools/result.ts +21 -0
- package/src/connector/web/guarded-fetch.ts +188 -48
- package/src/constants/sandbox/index.ts +3 -2
- package/src/contracts/api.ts +2 -0
- package/src/contracts/schemas.ts +7 -0
- package/src/directory/derive-supervisor.ts +8 -0
- package/src/directory/derive.ts +8 -0
- package/src/directory/load.ts +2 -0
- package/src/directory/types.ts +4 -0
- package/src/eval/experiment.ts +160 -111
- package/src/eval/judge.ts +13 -2
- package/src/eval/types.ts +7 -1
- package/src/manager/agent/lifecycle.ts +28 -12
- package/src/manager/connector/environment.ts +3 -1
- package/src/manager/connector/lifecycle.ts +364 -24
- package/src/manager/connector/tenant.ts +56 -23
- package/src/manager/goal/activation.ts +52 -0
- package/src/manager/index.ts +10 -2
- package/src/manager/run/persistence.ts +6 -1
- package/src/manager/topic/dependency.ts +39 -0
- package/src/manager/topic/lifecycle.ts +19 -31
- package/src/plugin/index.ts +1 -0
- package/src/plugin/lifecycle.ts +180 -39
- package/src/plugin/loader.ts +70 -13
- package/src/provider/collect-chat-completion.ts +3 -0
- package/src/provider/fallback.ts +79 -11
- package/src/provider/idle-timeout.ts +143 -17
- package/src/provider/index.ts +2 -0
- package/src/provider/instrumentation.ts +1 -0
- package/src/provider/retry.ts +16 -1
- package/src/public-runtime.ts +190 -32
- package/src/public-tools.ts +5 -0
- package/src/public-types.ts +85 -11
- package/src/rag/embedding.ts +147 -19
- package/src/rag/index.ts +1 -1
- package/src/rag/ingestion.ts +16 -2
- package/src/rag/knowledge-base.ts +13 -4
- package/src/rag/operation.ts +28 -0
- package/src/rag/rag-tool.ts +6 -3
- package/src/rag/retriever.ts +62 -11
- package/src/rag/vector-store.ts +8 -2
- package/src/registry/command/kernel-commands.ts +223 -4
- package/src/run/reporter.ts +10 -0
- package/src/run-query/index.ts +84 -15
- package/src/runtime/query/context.ts +13 -3
- package/src/runtime/query/executor.ts +90 -17
- package/src/runtime/query/guard.ts +12 -0
- package/src/runtime/query/index.ts +652 -103
- package/src/runtime/query/iteration/index.ts +89 -13
- package/src/runtime/query/iteration/phases/compaction.ts +120 -55
- package/src/runtime/query/iteration/phases/context.ts +4 -0
- package/src/runtime/query/iteration/phases/tool-review.ts +28 -0
- package/src/runtime/query/iteration/stream-turn.ts +3 -0
- package/src/runtime/query/project-instructions.ts +212 -0
- package/src/runtime/query/request-rich-content.ts +153 -0
- package/src/runtime/query/result.ts +12 -1
- package/src/runtime/query/resume-pending.ts +20 -18
- package/src/runtime/query/resume-run.ts +52 -8
- package/src/runtime/query/run-state.ts +11 -1
- package/src/runtime/query/sandbox-lifecycle.ts +210 -0
- package/src/sandbox/isolation.ts +9 -0
- package/src/sandbox/provider/local.ts +255 -90
- package/src/sandbox/terminal.ts +13 -5
- package/src/session/errors.ts +68 -42
- package/src/session/handoff/broadcast.ts +20 -14
- package/src/session/handoff/single.ts +14 -13
- package/src/store/attachment/index.ts +65 -3
- package/src/store/feedback/conformance.ts +39 -0
- package/src/store/feedback/disk.ts +128 -82
- package/src/store/goal/index.ts +594 -0
- package/src/store/index.ts +1 -1
- package/src/store/kv/revision-record-store.ts +346 -0
- package/src/store/memory/disk.ts +288 -113
- package/src/store/run/disk.ts +96 -5
- package/src/store/run/memory.ts +22 -2
- package/src/store/session/disk.ts +93 -6
- package/src/store/session/memory.ts +22 -0
- package/src/store/topic/memory.ts +4 -5
- package/src/store/topic/objective.ts +215 -100
- package/src/store/topic/state.ts +100 -63
- package/src/tools/builtins/bash.ts +21 -0
- package/src/tools/builtins/computer-use.ts +9 -1
- package/src/tools/builtins/content-fingerprint.ts +9 -12
- package/src/tools/builtins/edit.ts +190 -27
- package/src/tools/builtins/write-file.ts +55 -19
- package/src/tools/command-arguments.ts +54 -0
- package/src/tools/coordinator/index.ts +4 -1
- package/src/tools/defineTool.ts +11 -0
- package/src/tools/env-scrub.ts +7 -5
- package/src/tools/goal/index.ts +129 -0
- package/src/tools/memory/index.ts +26 -3
- package/src/tools/memory/search.ts +20 -3
- package/src/types/agent/base.ts +12 -3
- package/src/types/agent/factory.ts +2 -0
- package/src/types/agent/reactive.ts +2 -0
- package/src/types/agent/supervisor.ts +6 -0
- package/src/types/agent/task.ts +6 -2
- package/src/types/connector/core.ts +13 -8
- package/src/types/connector/definition.ts +54 -20
- package/src/types/connector/http.ts +7 -0
- package/src/types/connector/mcp.ts +27 -6
- package/src/types/connector/tenant.ts +21 -7
- package/src/types/connector/webhook.ts +7 -0
- package/src/types/goal/index.ts +50 -0
- package/src/types/ids/index.ts +2 -0
- package/src/types/message/index.ts +143 -9
- package/src/types/plugin/index.ts +7 -5
- package/src/types/provider/chat.ts +35 -4
- package/src/types/provider/interface.ts +22 -7
- package/src/types/provider/stream.ts +6 -0
- package/src/types/rag/embedding.ts +16 -2
- package/src/types/rag/ingestion.ts +2 -1
- package/src/types/rag/knowledge-base.ts +7 -3
- package/src/types/rag/retrieval.ts +2 -1
- package/src/types/rag/scope.ts +5 -0
- package/src/types/rag/vector.ts +5 -2
- package/src/types/run/config.ts +20 -0
- package/src/types/run/events.ts +28 -3
- package/src/types/run/metadata.ts +2 -0
- package/src/types/run/step.ts +2 -7
- package/src/types/run/store.ts +60 -2
- package/src/types/sandbox/index.ts +57 -14
- package/src/types/session/store.ts +18 -0
- package/src/types/tool/index.ts +33 -11
- package/src/types/topic/entity.ts +3 -4
- package/src/types/topic/store.ts +3 -3
- package/src/utils/id.ts +6 -0
- package/src/utils/process-environment.ts +101 -0
- package/src/vault/InMemoryCredentialVault.ts +29 -4
- package/src/vault/instrumentation.ts +24 -0
package/src/store/run/memory.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import type { AuditEvent } from '../../types/run/audit.js'
|
|
2
2
|
import type { Run } from '../../types/run/entity.js'
|
|
3
3
|
import type { PersistedRunEvent, RunEvent } from '../../types/run/events.js'
|
|
4
|
-
import type {
|
|
4
|
+
import type {
|
|
5
|
+
CompletedToolRecord,
|
|
6
|
+
ReadRunEventsOptions,
|
|
7
|
+
RunMessageSnapshot,
|
|
8
|
+
RunStore,
|
|
9
|
+
} from '../../types/run/store.js'
|
|
5
10
|
|
|
6
11
|
/**
|
|
7
12
|
* Process-local {@link RunStore}: a run's evidence with no filesystem.
|
|
@@ -22,6 +27,7 @@ export class InMemoryRunStore implements RunStore {
|
|
|
22
27
|
private parentRunId: string | undefined
|
|
23
28
|
private meta: Run | null = null
|
|
24
29
|
private messages: Run['messages'] = []
|
|
30
|
+
private messagesThroughEventSeq: number | null = null
|
|
25
31
|
private report: string | null = null
|
|
26
32
|
private events: PersistedRunEvent[] = []
|
|
27
33
|
private auditEvents: AuditEvent[] = []
|
|
@@ -36,6 +42,7 @@ export class InMemoryRunStore implements RunStore {
|
|
|
36
42
|
if (this.runId !== null && this.runId !== runId) {
|
|
37
43
|
this.meta = null
|
|
38
44
|
this.messages = []
|
|
45
|
+
this.messagesThroughEventSeq = null
|
|
39
46
|
this.report = null
|
|
40
47
|
this.events = []
|
|
41
48
|
this.auditEvents = []
|
|
@@ -72,9 +79,22 @@ export class InMemoryRunStore implements RunStore {
|
|
|
72
79
|
this.meta = structuredClone(run)
|
|
73
80
|
}
|
|
74
81
|
|
|
75
|
-
async writeMessages(run: Run): Promise<void> {
|
|
82
|
+
async writeMessages(run: Run, throughEventSeq: number): Promise<void> {
|
|
76
83
|
this.requireInit()
|
|
77
84
|
this.messages = structuredClone(run.messages)
|
|
85
|
+
this.messagesThroughEventSeq = throughEventSeq
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async readMessages(): Promise<RunMessageSnapshot> {
|
|
89
|
+
this.requireInit()
|
|
90
|
+
if (this.messagesThroughEventSeq === null) {
|
|
91
|
+
return { kind: 'unavailable', reason: 'not-persisted' }
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
kind: 'available',
|
|
95
|
+
throughEventSeq: this.messagesThroughEventSeq,
|
|
96
|
+
messages: structuredClone(this.messages),
|
|
97
|
+
}
|
|
78
98
|
}
|
|
79
99
|
|
|
80
100
|
async appendEvent(event: RunEvent): Promise<void> {
|
|
@@ -83,13 +83,36 @@ import type { LinkageView } from './linkage.js'
|
|
|
83
83
|
*/
|
|
84
84
|
const SCHEMA = defineSchema({
|
|
85
85
|
kind: 'session-store',
|
|
86
|
-
current:
|
|
86
|
+
current: 4,
|
|
87
87
|
migrations: {
|
|
88
88
|
1: migrateSessionStoreThreadIdToTopicId,
|
|
89
89
|
2: migrateSessionStoreTopicIdPrefix,
|
|
90
|
+
3: migrateSessionStoreMessageRecordKind,
|
|
90
91
|
},
|
|
91
92
|
})
|
|
92
93
|
|
|
94
|
+
/**
|
|
95
|
+
* v3 → v4: distinguish ordinary message appends from atomic replacements.
|
|
96
|
+
*
|
|
97
|
+
* The schema migrator runs over every record kind in this store, so the
|
|
98
|
+
* predicate names the fields unique to a message-log line and leaves project,
|
|
99
|
+
* session, sub-session and summary records byte-for-byte alone.
|
|
100
|
+
*/
|
|
101
|
+
export function migrateSessionStoreMessageRecordKind(
|
|
102
|
+
record: Record<string, unknown>,
|
|
103
|
+
): Record<string, unknown> {
|
|
104
|
+
if (
|
|
105
|
+
record.recordKind !== undefined ||
|
|
106
|
+
typeof record.id !== 'string' ||
|
|
107
|
+
typeof record.sessionId !== 'string' ||
|
|
108
|
+
!('message' in record) ||
|
|
109
|
+
typeof record.at !== 'string'
|
|
110
|
+
) {
|
|
111
|
+
return record
|
|
112
|
+
}
|
|
113
|
+
return { ...record, recordKind: 'message' }
|
|
114
|
+
}
|
|
115
|
+
|
|
93
116
|
/**
|
|
94
117
|
* Read, write and list, through the one implementation.
|
|
95
118
|
*
|
|
@@ -216,6 +239,7 @@ interface PersistedSubSession {
|
|
|
216
239
|
}
|
|
217
240
|
|
|
218
241
|
interface PersistedMessageLine {
|
|
242
|
+
recordKind: 'message'
|
|
219
243
|
id: MessageId
|
|
220
244
|
sessionId: SessionId
|
|
221
245
|
tenantId: TenantId
|
|
@@ -223,6 +247,26 @@ interface PersistedMessageLine {
|
|
|
223
247
|
at: string
|
|
224
248
|
}
|
|
225
249
|
|
|
250
|
+
/**
|
|
251
|
+
* One atomic projection change inside the append-only message log.
|
|
252
|
+
*
|
|
253
|
+
* Writing the replacement as several ordinary lines would expose a prefix if
|
|
254
|
+
* the process died between appends. One line is the transaction boundary: a
|
|
255
|
+
* reader sees the old conversation or the complete compacted one.
|
|
256
|
+
*/
|
|
257
|
+
interface PersistedMessageReplacementLine {
|
|
258
|
+
recordKind: 'replacement'
|
|
259
|
+
sessionId: SessionId
|
|
260
|
+
tenantId: TenantId
|
|
261
|
+
messages: readonly {
|
|
262
|
+
readonly id: MessageId
|
|
263
|
+
readonly message: Message
|
|
264
|
+
readonly at: string
|
|
265
|
+
}[]
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
type PersistedMessageRecord = PersistedMessageLine | PersistedMessageReplacementLine
|
|
269
|
+
|
|
226
270
|
interface PersistedSummary {
|
|
227
271
|
id: SummaryId
|
|
228
272
|
sessionRef: SessionId
|
|
@@ -738,6 +782,7 @@ export class DiskSessionStore implements SessionStore {
|
|
|
738
782
|
|
|
739
783
|
const id = generateMessageId()
|
|
740
784
|
const entry: PersistedMessageLine = {
|
|
785
|
+
recordKind: 'message',
|
|
741
786
|
id,
|
|
742
787
|
sessionId,
|
|
743
788
|
tenantId,
|
|
@@ -755,6 +800,36 @@ export class DiskSessionStore implements SessionStore {
|
|
|
755
800
|
return id
|
|
756
801
|
}
|
|
757
802
|
|
|
803
|
+
async replaceMessages(
|
|
804
|
+
sessionId: SessionId,
|
|
805
|
+
messages: readonly Message[],
|
|
806
|
+
tenantId: TenantId,
|
|
807
|
+
): Promise<void> {
|
|
808
|
+
const located = await this.locateSession(sessionId)
|
|
809
|
+
if (!located) throw new Error(`Session ${sessionId} not found`)
|
|
810
|
+
|
|
811
|
+
const session = await records.read<PersistedSession>(join(located.path, 'session.json'))
|
|
812
|
+
if (!session) throw new Error(`Session ${sessionId} not found on disk`)
|
|
813
|
+
this.assertTenant(session.tenantId, tenantId, `session(${sessionId})`)
|
|
814
|
+
|
|
815
|
+
const at = new Date().toISOString()
|
|
816
|
+
const entry: PersistedMessageReplacementLine = {
|
|
817
|
+
recordKind: 'replacement',
|
|
818
|
+
sessionId,
|
|
819
|
+
tenantId,
|
|
820
|
+
messages: messages.map((message) => ({ id: generateMessageId(), message, at })),
|
|
821
|
+
}
|
|
822
|
+
// One append, however many projected messages. If the process dies before
|
|
823
|
+
// this line lands, readers see the old projection; after it lands, they
|
|
824
|
+
// see the whole replacement. There is no prefix state to mistake for a
|
|
825
|
+
// successful compaction.
|
|
826
|
+
await appendFile(
|
|
827
|
+
join(located.path, 'messages.jsonl'),
|
|
828
|
+
`${JSON.stringify(stamp(SCHEMA, entry))}\n`,
|
|
829
|
+
'utf-8',
|
|
830
|
+
)
|
|
831
|
+
}
|
|
832
|
+
|
|
758
833
|
async loadMessages(sessionId: SessionId, tenantId: TenantId): Promise<readonly Message[]> {
|
|
759
834
|
const rows = await this.loadSessionMessages(sessionId, tenantId)
|
|
760
835
|
return rows.map((r) => r.message)
|
|
@@ -781,16 +856,28 @@ export class DiskSessionStore implements SessionStore {
|
|
|
781
856
|
throw err
|
|
782
857
|
}
|
|
783
858
|
const lines = raw.split('\n').filter((l) => l.length > 0)
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
859
|
+
let projected: SessionMessage[] = []
|
|
860
|
+
for (const line of lines) {
|
|
861
|
+
const persisted = migrate<PersistedMessageRecord>(SCHEMA, JSON.parse(line))
|
|
862
|
+
if (persisted.recordKind === 'replacement') {
|
|
863
|
+
projected = persisted.messages.map((entry) => ({
|
|
864
|
+
id: entry.id,
|
|
865
|
+
sessionId: persisted.sessionId,
|
|
866
|
+
tenantId: persisted.tenantId,
|
|
867
|
+
message: entry.message,
|
|
868
|
+
at: new Date(entry.at),
|
|
869
|
+
}))
|
|
870
|
+
continue
|
|
871
|
+
}
|
|
872
|
+
projected.push({
|
|
787
873
|
id: persisted.id,
|
|
788
874
|
sessionId: persisted.sessionId,
|
|
789
875
|
tenantId: persisted.tenantId,
|
|
790
876
|
message: persisted.message,
|
|
791
877
|
at: new Date(persisted.at),
|
|
792
|
-
}
|
|
793
|
-
}
|
|
878
|
+
})
|
|
879
|
+
}
|
|
880
|
+
return projected
|
|
794
881
|
}
|
|
795
882
|
|
|
796
883
|
// Linkage -----------------------------------------------------------------
|
|
@@ -424,6 +424,28 @@ export class InMemorySessionStore implements SessionStore {
|
|
|
424
424
|
return id
|
|
425
425
|
}
|
|
426
426
|
|
|
427
|
+
async replaceMessages(
|
|
428
|
+
sessionId: SessionId,
|
|
429
|
+
messages: readonly Message[],
|
|
430
|
+
tenantId: TenantId,
|
|
431
|
+
): Promise<void> {
|
|
432
|
+
const record = this.sessions.get(sessionId)
|
|
433
|
+
if (!record) throw new Error(`Session ${sessionId} not found`)
|
|
434
|
+
this.assertTenant(record.tenantId, tenantId, `session(${sessionId})`)
|
|
435
|
+
|
|
436
|
+
const at = new Date()
|
|
437
|
+
this.messages.set(
|
|
438
|
+
sessionId,
|
|
439
|
+
messages.map((message) => ({
|
|
440
|
+
id: generateMessageId(),
|
|
441
|
+
sessionId,
|
|
442
|
+
tenantId,
|
|
443
|
+
message,
|
|
444
|
+
at,
|
|
445
|
+
})),
|
|
446
|
+
)
|
|
447
|
+
}
|
|
448
|
+
|
|
427
449
|
async loadMessages(sessionId: SessionId, tenantId: TenantId): Promise<readonly Message[]> {
|
|
428
450
|
const record = this.sessions.get(sessionId)
|
|
429
451
|
if (!record) return []
|
|
@@ -4,8 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Mirrors the write-time CAS contract of the disk store: every
|
|
6
6
|
* `updateTopic` compares the supplied `ownerVersion` against the persisted
|
|
7
|
-
* copy and rejects with `
|
|
8
|
-
* unchanged this release — see NZ-TOPIC-01 risks). Convention #17:
|
|
7
|
+
* copy and rejects with `StaleTopicError` on mismatch. Convention #17:
|
|
9
8
|
* cross-tenant access throws `TenantIsolationError` with no fallback.
|
|
10
9
|
*
|
|
11
10
|
* NZ-TOPIC-01 renamed this from `InMemoryThreadStore` (moved from
|
|
@@ -15,7 +14,7 @@
|
|
|
15
14
|
* `InMemoryTopicStore` now.
|
|
16
15
|
*/
|
|
17
16
|
|
|
18
|
-
import {
|
|
17
|
+
import { StaleTopicError, TenantIsolationError } from '../../session/errors.js'
|
|
19
18
|
import type { TenantId } from '../../types/ids/index.js'
|
|
20
19
|
import type { ProjectId, TopicId } from '../../types/session/ids.js'
|
|
21
20
|
import type { Topic } from '../../types/topic/entity.js'
|
|
@@ -70,8 +69,8 @@ export class InMemoryTopicStore implements TopicStore {
|
|
|
70
69
|
// Any drift means another writer already advanced the record; the caller
|
|
71
70
|
// must re-read + re-apply + retry.
|
|
72
71
|
if (topic.ownerVersion !== existing.topic.ownerVersion) {
|
|
73
|
-
throw new
|
|
74
|
-
|
|
72
|
+
throw new StaleTopicError({
|
|
73
|
+
topicId: topic.id,
|
|
75
74
|
expectedVersion: topic.ownerVersion,
|
|
76
75
|
actualVersion: existing.topic.ownerVersion,
|
|
77
76
|
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { mkdir } from 'node:fs/promises'
|
|
2
1
|
import { join } from 'node:path'
|
|
3
2
|
|
|
3
|
+
import { TenantIsolationError } from '../../session/errors.js'
|
|
4
4
|
import type { TenantId, TopicId } from '../../types/ids/index.js'
|
|
5
5
|
import {
|
|
6
6
|
type ObjectivePhase,
|
|
@@ -8,7 +8,13 @@ import {
|
|
|
8
8
|
StaleObjectiveError,
|
|
9
9
|
type TopicObjective,
|
|
10
10
|
} from '../../types/topic/objective.js'
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
DiskRevisionRecordStore,
|
|
13
|
+
type RevisionMutation,
|
|
14
|
+
type RevisionedRecordLocation,
|
|
15
|
+
legacyRevisionFileSegment,
|
|
16
|
+
revisionFileSegment,
|
|
17
|
+
} from '../kv/revision-record-store.js'
|
|
12
18
|
import { defineSchema } from '../schema.js'
|
|
13
19
|
|
|
14
20
|
/**
|
|
@@ -22,8 +28,16 @@ import { defineSchema } from '../schema.js'
|
|
|
22
28
|
* have nothing to say to each other.
|
|
23
29
|
*/
|
|
24
30
|
|
|
25
|
-
const SCHEMA = defineSchema({
|
|
26
|
-
|
|
31
|
+
const SCHEMA = defineSchema({
|
|
32
|
+
kind: 'topic-objective',
|
|
33
|
+
current: 1,
|
|
34
|
+
migrations: {},
|
|
35
|
+
})
|
|
36
|
+
const revisionRecords = new DiskRevisionRecordStore<TopicObjective>(
|
|
37
|
+
SCHEMA,
|
|
38
|
+
'topic objective store',
|
|
39
|
+
(record) => record.revision,
|
|
40
|
+
)
|
|
27
41
|
|
|
28
42
|
export interface CreateObjectiveParams {
|
|
29
43
|
readonly id: string
|
|
@@ -109,6 +123,31 @@ function missing(id: string): Error {
|
|
|
109
123
|
return new Error(`No objective ${id}.`)
|
|
110
124
|
}
|
|
111
125
|
|
|
126
|
+
function assertTenant(record: TopicObjective, tenantId: TenantId): void {
|
|
127
|
+
if (record.tenantId !== tenantId) {
|
|
128
|
+
throw new TenantIsolationError({
|
|
129
|
+
requested: tenantId,
|
|
130
|
+
resource: `objective(${record.id})`,
|
|
131
|
+
})
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
interface ObjectiveBackend {
|
|
136
|
+
readonly read: (id: string) => Promise<TopicObjective | null>
|
|
137
|
+
readonly transact: <R>(
|
|
138
|
+
id: string,
|
|
139
|
+
mutate: (current: TopicObjective | null) => RevisionMutation<TopicObjective, R>,
|
|
140
|
+
) => Promise<R>
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const objectiveBackends = new WeakMap<object, ObjectiveBackend>()
|
|
144
|
+
|
|
145
|
+
function backendFor(store: object): ObjectiveBackend {
|
|
146
|
+
const backend = objectiveBackends.get(store)
|
|
147
|
+
if (!backend) throw new Error('Objective store backend was not initialized.')
|
|
148
|
+
return backend
|
|
149
|
+
}
|
|
150
|
+
|
|
112
151
|
/**
|
|
113
152
|
* The shared write logic.
|
|
114
153
|
*
|
|
@@ -121,35 +160,49 @@ function missing(id: string): Error {
|
|
|
121
160
|
abstract class ObjectiveStoreBase implements TopicObjectiveStore {
|
|
122
161
|
protected constructor(protected readonly now: () => number) {}
|
|
123
162
|
|
|
124
|
-
|
|
163
|
+
/**
|
|
164
|
+
* Commit seam for the shared domain transitions. Shipped implementations
|
|
165
|
+
* enforce an exact next revision here; keeping every transition on this
|
|
166
|
+
* path also preserves a subclass observer without letting it replace the
|
|
167
|
+
* domain rules above.
|
|
168
|
+
*/
|
|
125
169
|
protected abstract put(record: TopicObjective): Promise<void>
|
|
126
170
|
|
|
171
|
+
async getObjective(id: string, tenantId: TenantId): Promise<TopicObjective | null> {
|
|
172
|
+
const found = await backendFor(this).read(id)
|
|
173
|
+
// Enumeration-style reads deliberately hide another tenant's record.
|
|
174
|
+
// Mutations reject instead: treating it as absent would overwrite it.
|
|
175
|
+
return found && found.tenantId === tenantId ? found : null
|
|
176
|
+
}
|
|
177
|
+
|
|
127
178
|
async createObjective(
|
|
128
179
|
params: CreateObjectiveParams,
|
|
129
180
|
tenantId: TenantId,
|
|
130
181
|
): Promise<TopicObjective> {
|
|
131
|
-
if (
|
|
132
|
-
throw new ObjectiveExistsError({ id: params.id })
|
|
133
|
-
}
|
|
134
|
-
if (params.maxRounds < 1) {
|
|
182
|
+
if (!Number.isSafeInteger(params.maxRounds) || params.maxRounds < 1) {
|
|
135
183
|
// A cap of zero is an objective that can never run. Accepting it
|
|
136
184
|
// would produce a record that blocks on its own first round, which
|
|
137
185
|
// reads as a runaway that was stopped rather than a caller mistake.
|
|
138
|
-
throw new Error(`maxRounds must be
|
|
186
|
+
throw new Error(`maxRounds must be a positive safe integer, got ${params.maxRounds}.`)
|
|
139
187
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
188
|
+
return await backendFor(this).transact(params.id, (existing) => {
|
|
189
|
+
if (existing) {
|
|
190
|
+
assertTenant(existing, tenantId)
|
|
191
|
+
throw new ObjectiveExistsError({ id: params.id })
|
|
192
|
+
}
|
|
193
|
+
const record: TopicObjective = {
|
|
194
|
+
id: params.id,
|
|
195
|
+
topicId: params.topicId,
|
|
196
|
+
tenantId,
|
|
197
|
+
revision: 1,
|
|
198
|
+
objective: params.objective,
|
|
199
|
+
phase: 'active',
|
|
200
|
+
maxRounds: params.maxRounds,
|
|
201
|
+
roundsStarted: 0,
|
|
202
|
+
updatedAt: this.now(),
|
|
203
|
+
}
|
|
204
|
+
return { record, result: record }
|
|
205
|
+
})
|
|
153
206
|
}
|
|
154
207
|
|
|
155
208
|
async beginRound(
|
|
@@ -157,36 +210,46 @@ abstract class ObjectiveStoreBase implements TopicObjectiveStore {
|
|
|
157
210
|
tenantId: TenantId,
|
|
158
211
|
opts: { revision: number },
|
|
159
212
|
): Promise<TopicObjective> {
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
213
|
+
const outcome = await backendFor(this).transact<{
|
|
214
|
+
record: TopicObjective
|
|
215
|
+
exhausted: boolean
|
|
216
|
+
}>(id, (existing) => {
|
|
217
|
+
if (!existing) throw missing(id)
|
|
218
|
+
assertTenant(existing, tenantId)
|
|
219
|
+
assertFresh(id, existing, opts.revision)
|
|
220
|
+
if (existing.phase !== 'active') {
|
|
221
|
+
throw new Error(`Objective ${id} is ${existing.phase}, not active.`)
|
|
222
|
+
}
|
|
223
|
+
if (existing.roundsStarted >= existing.maxRounds) {
|
|
224
|
+
const record: TopicObjective = {
|
|
225
|
+
...existing,
|
|
226
|
+
revision: existing.revision + 1,
|
|
227
|
+
phase: 'blocked',
|
|
228
|
+
blockedReason: {
|
|
229
|
+
code: 'round_cap',
|
|
230
|
+
message: `Reached the ${existing.maxRounds}-round cap.`,
|
|
231
|
+
},
|
|
232
|
+
updatedAt: this.now(),
|
|
233
|
+
}
|
|
234
|
+
return { record, result: { record, exhausted: true as const } }
|
|
235
|
+
}
|
|
236
|
+
const record: TopicObjective = {
|
|
171
237
|
...existing,
|
|
172
238
|
revision: existing.revision + 1,
|
|
173
|
-
|
|
174
|
-
blockedReason: {
|
|
175
|
-
code: 'round_cap',
|
|
176
|
-
message: `Reached the ${existing.maxRounds}-round cap.`,
|
|
177
|
-
},
|
|
239
|
+
roundsStarted: existing.roundsStarted + 1,
|
|
178
240
|
updatedAt: this.now(),
|
|
241
|
+
}
|
|
242
|
+
return { record, result: { record, exhausted: false as const } }
|
|
243
|
+
})
|
|
244
|
+
if (outcome.exhausted) {
|
|
245
|
+
// Blocked BEFORE the throw. The committed result is what a reader sees
|
|
246
|
+
// even if this exception is swallowed or the caller exits on it.
|
|
247
|
+
throw new ObjectiveExhaustedError({
|
|
248
|
+
id,
|
|
249
|
+
maxRounds: outcome.record.maxRounds,
|
|
179
250
|
})
|
|
180
|
-
throw new ObjectiveExhaustedError({ id, maxRounds: existing.maxRounds })
|
|
181
|
-
}
|
|
182
|
-
const record: TopicObjective = {
|
|
183
|
-
...existing,
|
|
184
|
-
revision: existing.revision + 1,
|
|
185
|
-
roundsStarted: existing.roundsStarted + 1,
|
|
186
|
-
updatedAt: this.now(),
|
|
187
251
|
}
|
|
188
|
-
|
|
189
|
-
return record
|
|
252
|
+
return outcome.record
|
|
190
253
|
}
|
|
191
254
|
|
|
192
255
|
async settleRound(
|
|
@@ -195,19 +258,20 @@ abstract class ObjectiveStoreBase implements TopicObjectiveStore {
|
|
|
195
258
|
verdict: ObjectiveRoundVerdict,
|
|
196
259
|
opts: { revision: number },
|
|
197
260
|
): Promise<TopicObjective> {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
261
|
+
return await backendFor(this).transact(id, (existing) => {
|
|
262
|
+
if (!existing) throw missing(id)
|
|
263
|
+
assertTenant(existing, tenantId)
|
|
264
|
+
assertFresh(id, existing, opts.revision)
|
|
265
|
+
const record: TopicObjective = {
|
|
266
|
+
...existing,
|
|
267
|
+
revision: existing.revision + 1,
|
|
268
|
+
phase: verdict.phase ?? existing.phase,
|
|
269
|
+
...(verdict.blockedReason ? { blockedReason: verdict.blockedReason } : {}),
|
|
270
|
+
...(verdict.runId ? { lastRunId: verdict.runId } : {}),
|
|
271
|
+
updatedAt: this.now(),
|
|
272
|
+
}
|
|
273
|
+
return { record, result: record }
|
|
274
|
+
})
|
|
211
275
|
}
|
|
212
276
|
|
|
213
277
|
async setPhase(
|
|
@@ -216,29 +280,30 @@ abstract class ObjectiveStoreBase implements TopicObjectiveStore {
|
|
|
216
280
|
phase: ObjectivePhase,
|
|
217
281
|
opts: { revision: number },
|
|
218
282
|
): Promise<TopicObjective> {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
283
|
+
return await backendFor(this).transact(id, (existing) => {
|
|
284
|
+
if (!existing) throw missing(id)
|
|
285
|
+
assertTenant(existing, tenantId)
|
|
286
|
+
assertFresh(id, existing, opts.revision)
|
|
287
|
+
if (existing.phase === 'complete' && phase !== 'complete') {
|
|
288
|
+
// One-way. Reopening a finished objective by writing a phase would
|
|
289
|
+
// let a stale caller restart work somebody already signed off, and
|
|
290
|
+
// the round counter it would run against is the one already spent.
|
|
291
|
+
throw new Error(`Objective ${id} is complete; it cannot be moved to ${phase}.`)
|
|
292
|
+
}
|
|
293
|
+
// A move off `blocked` drops the reason. Carrying it would describe a
|
|
294
|
+
// running objective as blocked by something it no longer is, and that
|
|
295
|
+
// stale sentence is what an operator reads to decide whether to
|
|
296
|
+
// intervene.
|
|
297
|
+
const { blockedReason, ...rest } = existing
|
|
298
|
+
const record: TopicObjective = {
|
|
299
|
+
...rest,
|
|
300
|
+
revision: existing.revision + 1,
|
|
301
|
+
phase,
|
|
302
|
+
...(phase === 'blocked' && blockedReason ? { blockedReason } : {}),
|
|
303
|
+
updatedAt: this.now(),
|
|
304
|
+
}
|
|
305
|
+
return { record, result: record }
|
|
306
|
+
})
|
|
242
307
|
}
|
|
243
308
|
}
|
|
244
309
|
|
|
@@ -247,16 +312,34 @@ export class InMemoryTopicObjectiveStore extends ObjectiveStoreBase {
|
|
|
247
312
|
|
|
248
313
|
constructor(now: () => number = Date.now) {
|
|
249
314
|
super(now)
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
315
|
+
objectiveBackends.set(this, {
|
|
316
|
+
read: async (id) => this.objectives.get(id) ?? null,
|
|
317
|
+
transact: async <R>(
|
|
318
|
+
id: string,
|
|
319
|
+
mutate: (current: TopicObjective | null) => RevisionMutation<TopicObjective, R>,
|
|
320
|
+
): Promise<R> => {
|
|
321
|
+
// Deliberately no await: read, domain checks and publish are one JS
|
|
322
|
+
// turn. `put` executes its map check/set before its returned promise
|
|
323
|
+
// settles; awaiting an async get before this point would let two callers
|
|
324
|
+
// capture the same revision.
|
|
325
|
+
const proposal = mutate(this.objectives.get(id) ?? null)
|
|
326
|
+
await this.put(proposal.record)
|
|
327
|
+
return proposal.result
|
|
328
|
+
},
|
|
329
|
+
})
|
|
257
330
|
}
|
|
258
331
|
|
|
259
332
|
protected async put(record: TopicObjective): Promise<void> {
|
|
333
|
+
const existing = this.objectives.get(record.id)
|
|
334
|
+
if (existing) assertTenant(existing, record.tenantId)
|
|
335
|
+
const expected = (existing?.revision ?? 0) + 1
|
|
336
|
+
if (record.revision !== expected) {
|
|
337
|
+
throw new StaleObjectiveError({
|
|
338
|
+
id: record.id,
|
|
339
|
+
expectedRevision: record.revision - 1,
|
|
340
|
+
actualRevision: existing?.revision ?? 0,
|
|
341
|
+
})
|
|
342
|
+
}
|
|
260
343
|
this.objectives.set(record.id, record)
|
|
261
344
|
}
|
|
262
345
|
}
|
|
@@ -272,19 +355,51 @@ export class DiskTopicObjectiveStore extends ObjectiveStoreBase {
|
|
|
272
355
|
now: () => number = Date.now,
|
|
273
356
|
) {
|
|
274
357
|
super(now)
|
|
358
|
+
objectiveBackends.set(this, {
|
|
359
|
+
read: async (id) => await revisionRecords.read(this.location(id)),
|
|
360
|
+
transact: async <R>(
|
|
361
|
+
id: string,
|
|
362
|
+
mutate: (current: TopicObjective | null) => RevisionMutation<TopicObjective, R>,
|
|
363
|
+
): Promise<R> => {
|
|
364
|
+
const location = this.location(id)
|
|
365
|
+
const proposal = mutate(await revisionRecords.read(location))
|
|
366
|
+
try {
|
|
367
|
+
await this.put(proposal.record)
|
|
368
|
+
} catch (err) {
|
|
369
|
+
if (err instanceof StaleObjectiveError) {
|
|
370
|
+
// Re-run only the domain guard against the durable winner. Creation
|
|
371
|
+
// must report ObjectiveExistsError, while an ordinary mutation keeps
|
|
372
|
+
// the stale error and its actual revision.
|
|
373
|
+
mutate(await revisionRecords.read(location))
|
|
374
|
+
}
|
|
375
|
+
throw err
|
|
376
|
+
}
|
|
377
|
+
return proposal.result
|
|
378
|
+
},
|
|
379
|
+
})
|
|
275
380
|
}
|
|
276
381
|
|
|
277
|
-
private
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
382
|
+
private location(id: string): RevisionedRecordLocation {
|
|
383
|
+
const root = join(this.config.rootDir, 'objectives')
|
|
384
|
+
const segment = revisionFileSegment(id)
|
|
385
|
+
return {
|
|
386
|
+
legacyPath: join(root, `${legacyRevisionFileSegment(id)}.json`),
|
|
387
|
+
revisionsDir: join(root, '.revisions', segment),
|
|
388
|
+
}
|
|
284
389
|
}
|
|
285
390
|
|
|
286
391
|
protected async put(record: TopicObjective): Promise<void> {
|
|
287
|
-
await
|
|
288
|
-
|
|
392
|
+
await revisionRecords.transact(this.location(record.id), (existing) => {
|
|
393
|
+
if (existing) assertTenant(existing, record.tenantId)
|
|
394
|
+
const actual = existing?.revision ?? 0
|
|
395
|
+
if (record.revision !== actual + 1) {
|
|
396
|
+
throw new StaleObjectiveError({
|
|
397
|
+
id: record.id,
|
|
398
|
+
expectedRevision: record.revision - 1,
|
|
399
|
+
actualRevision: actual,
|
|
400
|
+
})
|
|
401
|
+
}
|
|
402
|
+
return { record, result: undefined }
|
|
403
|
+
})
|
|
289
404
|
}
|
|
290
405
|
}
|