@namzu/sdk 30.2.0 → 31.1.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 +562 -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 +79 -13
- 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/index.d.ts +1 -1
- package/dist/types/provider/index.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/model.d.ts +12 -0
- package/dist/types/provider/model.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 +147 -12
- package/src/types/plugin/index.ts +7 -5
- package/src/types/provider/chat.ts +35 -4
- package/src/types/provider/index.ts +1 -1
- package/src/types/provider/interface.ts +22 -7
- package/src/types/provider/model.ts +13 -0
- 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
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { realpathSync } from 'node:fs'
|
|
1
|
+
import { spawn, spawnSync } from 'node:child_process'
|
|
2
|
+
import { constants, accessSync, existsSync, realpathSync } from 'node:fs'
|
|
3
3
|
import {
|
|
4
4
|
readFile as fsReadFile,
|
|
5
5
|
writeFile as fsWriteFile,
|
|
@@ -29,6 +29,7 @@ import type { SandboxId } from '../../types/ids/index.js'
|
|
|
29
29
|
import type {
|
|
30
30
|
Sandbox,
|
|
31
31
|
SandboxCreateConfig,
|
|
32
|
+
SandboxDestroyOptions,
|
|
32
33
|
SandboxEnvironment,
|
|
33
34
|
SandboxExecOptions,
|
|
34
35
|
SandboxExecResult,
|
|
@@ -39,14 +40,13 @@ import type {
|
|
|
39
40
|
} from '../../types/sandbox/index.js'
|
|
40
41
|
import { generateSandboxId } from '../../utils/id.js'
|
|
41
42
|
import type { Logger } from '../../utils/logger.js'
|
|
42
|
-
import { assertIsolation, describeIsolation } from '../isolation.js'
|
|
43
43
|
import {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
} from '../terminal.js'
|
|
44
|
+
WINDOWS_CORE_ENV_KEYS,
|
|
45
|
+
applyEnvironmentOverrides,
|
|
46
|
+
pickEnvironmentEntries,
|
|
47
|
+
} from '../../utils/process-environment.js'
|
|
48
|
+
import { assertIsolation, describeIsolation } from '../isolation.js'
|
|
49
|
+
import type { PtyLoader } from '../terminal.js'
|
|
50
50
|
|
|
51
51
|
// ---------------------------------------------------------------------------
|
|
52
52
|
// Path safety
|
|
@@ -71,6 +71,71 @@ function assertInsideSandbox(sandboxRoot: string, targetPath: string): string {
|
|
|
71
71
|
*/
|
|
72
72
|
const LINUX_UNSHARE_FLAGS = ['--mount', '--pid', '--fork', '--map-root-user', '--net']
|
|
73
73
|
|
|
74
|
+
const SPAWN_PROBE_SENTINEL = 'namzu-sandbox-spawn-probe'
|
|
75
|
+
|
|
76
|
+
interface SpawnProbeObservation {
|
|
77
|
+
readonly error?: unknown
|
|
78
|
+
readonly status: number | null
|
|
79
|
+
readonly signal: NodeJS.Signals | null
|
|
80
|
+
readonly stdout: string | null
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* A wrapper is usable only when the same direct-spawn shape as a real command
|
|
85
|
+
* can execute and carry its output back through a pipe.
|
|
86
|
+
*
|
|
87
|
+
* Checking only the exit status is insufficient: a host policy can let a
|
|
88
|
+
* shell launch a namespace helper while refusing or partially virtualising a
|
|
89
|
+
* direct `spawn()` of that helper. In that state the old shell-string probe
|
|
90
|
+
* selected the tier, but production commands returned exit zero with empty
|
|
91
|
+
* output. Treat a spawn error, signal, or damaged pipe as an unavailable tier.
|
|
92
|
+
*/
|
|
93
|
+
export function acceptsSandboxSpawnProbe(observation: SpawnProbeObservation): boolean {
|
|
94
|
+
return (
|
|
95
|
+
observation.error === undefined &&
|
|
96
|
+
observation.status === 0 &&
|
|
97
|
+
observation.signal === null &&
|
|
98
|
+
observation.stdout === SPAWN_PROBE_SENTINEL
|
|
99
|
+
)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function probeSandboxSpawn(command: string, wrapperArgs: readonly string[]): boolean {
|
|
103
|
+
const observation = spawnSync(
|
|
104
|
+
command,
|
|
105
|
+
[
|
|
106
|
+
...wrapperArgs,
|
|
107
|
+
'--',
|
|
108
|
+
process.execPath,
|
|
109
|
+
'-e',
|
|
110
|
+
`process.stdout.write(${JSON.stringify(SPAWN_PROBE_SENTINEL)})`,
|
|
111
|
+
],
|
|
112
|
+
{
|
|
113
|
+
encoding: 'utf8',
|
|
114
|
+
timeout: 5_000,
|
|
115
|
+
},
|
|
116
|
+
)
|
|
117
|
+
return acceptsSandboxSpawnProbe(observation)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const TRUSTED_WRAPPER_CANDIDATES = {
|
|
121
|
+
bwrap: ['/usr/bin/bwrap', '/bin/bwrap', '/usr/sbin/bwrap'],
|
|
122
|
+
unshare: ['/usr/bin/unshare', '/bin/unshare', '/usr/sbin/unshare'],
|
|
123
|
+
'sandbox-exec': ['/usr/bin/sandbox-exec'],
|
|
124
|
+
} as const
|
|
125
|
+
|
|
126
|
+
function resolveTrustedWrapper(name: keyof typeof TRUSTED_WRAPPER_CANDIDATES): string | undefined {
|
|
127
|
+
for (const candidate of TRUSTED_WRAPPER_CANDIDATES[name]) {
|
|
128
|
+
try {
|
|
129
|
+
accessSync(candidate, constants.X_OK)
|
|
130
|
+
return realpathSync(candidate)
|
|
131
|
+
} catch {
|
|
132
|
+
// Try the next fixed system location. Caller-controlled PATH is not
|
|
133
|
+
// part of wrapper discovery because it is also configurable per run.
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return undefined
|
|
137
|
+
}
|
|
138
|
+
|
|
74
139
|
/**
|
|
75
140
|
* One output stream, accumulated under a byte cap that it reports hitting.
|
|
76
141
|
*
|
|
@@ -105,6 +170,8 @@ export class CappedStream {
|
|
|
105
170
|
|
|
106
171
|
export interface LimitedSpawnRequest {
|
|
107
172
|
readonly environment: SandboxEnvironment
|
|
173
|
+
/** Canonical outer wrapper selected and probed by the provider. */
|
|
174
|
+
readonly wrapperCommand?: string
|
|
108
175
|
readonly command: string
|
|
109
176
|
readonly args: readonly string[]
|
|
110
177
|
readonly rootDir: string
|
|
@@ -112,6 +179,15 @@ export interface LimitedSpawnRequest {
|
|
|
112
179
|
readonly maxProcesses?: number
|
|
113
180
|
}
|
|
114
181
|
|
|
182
|
+
function requiredWrapper(request: LimitedSpawnRequest): string {
|
|
183
|
+
if (request.wrapperCommand === undefined || !isAbsolute(request.wrapperCommand)) {
|
|
184
|
+
throw new Error(
|
|
185
|
+
`Sandbox environment ${request.environment} requires the absolute wrapper path that was probed`,
|
|
186
|
+
)
|
|
187
|
+
}
|
|
188
|
+
return request.wrapperCommand
|
|
189
|
+
}
|
|
190
|
+
|
|
115
191
|
/** Single-quote for a shell, escaping any quote already inside. */
|
|
116
192
|
function shellQuote(value: string): string {
|
|
117
193
|
return `'${value.replace(/'/g, "'\\''")}'`
|
|
@@ -153,15 +229,21 @@ export function buildLimitedSpawn(request: LimitedSpawnRequest): {
|
|
|
153
229
|
: [command, ...args]
|
|
154
230
|
|
|
155
231
|
switch (environment) {
|
|
232
|
+
case 'linux-bwrap':
|
|
233
|
+
return {
|
|
234
|
+
spawnCommand: requiredWrapper(request),
|
|
235
|
+
spawnArgs: [...buildBwrapArgs(rootDir), '--', ...inner],
|
|
236
|
+
}
|
|
237
|
+
|
|
156
238
|
case 'linux-namespace':
|
|
157
239
|
return {
|
|
158
|
-
spawnCommand:
|
|
240
|
+
spawnCommand: requiredWrapper(request),
|
|
159
241
|
spawnArgs: [...LINUX_UNSHARE_FLAGS, '--', ...inner],
|
|
160
242
|
}
|
|
161
243
|
|
|
162
244
|
case 'macos-seatbelt':
|
|
163
245
|
return {
|
|
164
|
-
spawnCommand:
|
|
246
|
+
spawnCommand: requiredWrapper(request),
|
|
165
247
|
spawnArgs: ['-p', buildSeatbeltProfile(rootDir), '--', ...inner],
|
|
166
248
|
}
|
|
167
249
|
|
|
@@ -177,35 +259,43 @@ export function buildLimitedSpawn(request: LimitedSpawnRequest): {
|
|
|
177
259
|
}
|
|
178
260
|
}
|
|
179
261
|
|
|
180
|
-
|
|
262
|
+
type DetectedEnvironment =
|
|
263
|
+
| { readonly environment: 'basic' }
|
|
264
|
+
| {
|
|
265
|
+
readonly environment: Exclude<SandboxEnvironment, 'basic'>
|
|
266
|
+
readonly wrapperCommand: string
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function detectEnvironment(): DetectedEnvironment {
|
|
181
270
|
const { platform } = process
|
|
182
271
|
|
|
183
272
|
if (platform === 'linux') {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
273
|
+
// Probe the direct child-process boundary used in production, including
|
|
274
|
+
// its stdout pipe. A shell-string probe is a different capability on
|
|
275
|
+
// hosts that mediate namespace helpers and can claim a tier production
|
|
276
|
+
// cannot actually drive.
|
|
277
|
+
const bwrap = resolveTrustedWrapper('bwrap')
|
|
278
|
+
if (bwrap !== undefined && probeSandboxSpawn(bwrap, buildBwrapArgs(tmpdir()))) {
|
|
279
|
+
return { environment: 'linux-bwrap', wrapperCommand: bwrap }
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
const unshare = resolveTrustedWrapper('unshare')
|
|
283
|
+
if (unshare !== undefined && probeSandboxSpawn(unshare, LINUX_UNSHARE_FLAGS)) {
|
|
284
|
+
return { environment: 'linux-namespace', wrapperCommand: unshare }
|
|
196
285
|
}
|
|
197
286
|
}
|
|
198
287
|
|
|
199
288
|
if (platform === 'darwin') {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
289
|
+
const seatbelt = resolveTrustedWrapper('sandbox-exec')
|
|
290
|
+
if (
|
|
291
|
+
seatbelt !== undefined &&
|
|
292
|
+
probeSandboxSpawn(seatbelt, ['-p', buildSeatbeltProfile(tmpdir())])
|
|
293
|
+
) {
|
|
294
|
+
return { environment: 'macos-seatbelt', wrapperCommand: seatbelt }
|
|
205
295
|
}
|
|
206
296
|
}
|
|
207
297
|
|
|
208
|
-
return 'basic'
|
|
298
|
+
return { environment: 'basic' }
|
|
209
299
|
}
|
|
210
300
|
|
|
211
301
|
// ---------------------------------------------------------------------------
|
|
@@ -233,6 +323,103 @@ function canonicalizePath(p: string): string {
|
|
|
233
323
|
*
|
|
234
324
|
* Key principle: (deny default) + explicit allows. Network always denied.
|
|
235
325
|
*/
|
|
326
|
+
/**
|
|
327
|
+
* A mount table containing the sandbox and the system paths a binary needs,
|
|
328
|
+
* and nothing else.
|
|
329
|
+
*
|
|
330
|
+
* The difference from the namespace tier is the whole point: that one unshares
|
|
331
|
+
* a mount table and keeps the host's contents in it, so the child sees
|
|
332
|
+
* everything and this file reports `filesystem: false` for it. Here each path
|
|
333
|
+
* is bound in deliberately, so a path nobody listed is not unreadable — it is
|
|
334
|
+
* absent. `ls /home` fails with ENOENT rather than EACCES, which is the
|
|
335
|
+
* behaviour a caller relying on `filesystem` isolation is entitled to.
|
|
336
|
+
*
|
|
337
|
+
* `--unshare-all` covers the network and process controls in the same call, so
|
|
338
|
+
* all three rows of this tier's isolation report come from one spawn rather
|
|
339
|
+
* than from three mechanisms that could drift apart.
|
|
340
|
+
*
|
|
341
|
+
* The system paths are bound READ-ONLY and only when present: a distribution
|
|
342
|
+
* with a merged `/usr` has no real `/lib`, and binding a path that does not
|
|
343
|
+
* exist is a hard failure rather than a no-op. `/proc` and `/dev` get their
|
|
344
|
+
* own fresh instances instead of a bind, so the child cannot read the host's
|
|
345
|
+
* process table through them — a bound `/proc` would hand back the process
|
|
346
|
+
* isolation the same flag just removed.
|
|
347
|
+
*/
|
|
348
|
+
export function buildBwrapArgs(sandboxRoot: string): string[] {
|
|
349
|
+
const root = canonicalizePath(sandboxRoot)
|
|
350
|
+
|
|
351
|
+
const args = [
|
|
352
|
+
'--unshare-all',
|
|
353
|
+
// The child dies with the parent rather than outliving a killed run.
|
|
354
|
+
// Without it an escaped grandchild keeps the mount namespace alive and
|
|
355
|
+
// the sandbox's temporary root cannot be removed.
|
|
356
|
+
'--die-with-parent',
|
|
357
|
+
'--new-session',
|
|
358
|
+
]
|
|
359
|
+
|
|
360
|
+
for (const path of BWRAP_SYSTEM_PATHS) {
|
|
361
|
+
if (existsSync(path)) args.push('--ro-bind', path, path)
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// The runtime this process is running under, when it lives outside those.
|
|
365
|
+
//
|
|
366
|
+
// Found by the tier breaking four existing tests the moment it worked: they
|
|
367
|
+
// spawn `node` inside the sandbox, and a Node installed under a home
|
|
368
|
+
// directory — a tarball, a version manager, anything but the distribution's
|
|
369
|
+
// package — is simply not there once the host filesystem is gone. The
|
|
370
|
+
// failure reads as `execvp: No such file or directory`, which sounds like a
|
|
371
|
+
// broken test rather than a sandbox doing its job.
|
|
372
|
+
//
|
|
373
|
+
// The PREFIX rather than the `bin` directory: `bin` alone is enough to run
|
|
374
|
+
// `node`, but `npm` and `npx` resolve their own code through `../lib`, and a
|
|
375
|
+
// model that runs one of those is not doing anything unusual.
|
|
376
|
+
//
|
|
377
|
+
// Read-only, and skipped when a system path already covers it, so a
|
|
378
|
+
// distribution-packaged runtime adds no second bind.
|
|
379
|
+
const interpreterPrefix = dirname(dirname(canonicalizePath(process.execPath)))
|
|
380
|
+
const alreadyCovered = BWRAP_SYSTEM_PATHS.some(
|
|
381
|
+
(path) => interpreterPrefix === path || interpreterPrefix.startsWith(`${path}/`),
|
|
382
|
+
)
|
|
383
|
+
if (!alreadyCovered && existsSync(interpreterPrefix)) {
|
|
384
|
+
args.push('--ro-bind', interpreterPrefix, interpreterPrefix)
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
args.push(
|
|
388
|
+
'--proc',
|
|
389
|
+
'/proc',
|
|
390
|
+
'--dev',
|
|
391
|
+
'/dev',
|
|
392
|
+
// A private /tmp, because the sandbox root is where writes belong and a
|
|
393
|
+
// shared /tmp is a channel between runs.
|
|
394
|
+
'--tmpfs',
|
|
395
|
+
'/tmp',
|
|
396
|
+
'--bind',
|
|
397
|
+
root,
|
|
398
|
+
root,
|
|
399
|
+
'--chdir',
|
|
400
|
+
root,
|
|
401
|
+
)
|
|
402
|
+
|
|
403
|
+
return args
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Read-only host paths a spawned binary needs to run at all.
|
|
408
|
+
*
|
|
409
|
+
* Bound rather than assumed: `/etc` carries the resolver and user database a
|
|
410
|
+
* shell reads on startup, and omitting it produces failures that look like the
|
|
411
|
+
* command is broken rather than like the sandbox is doing its job.
|
|
412
|
+
*/
|
|
413
|
+
const BWRAP_SYSTEM_PATHS: readonly string[] = [
|
|
414
|
+
'/usr',
|
|
415
|
+
'/bin',
|
|
416
|
+
'/sbin',
|
|
417
|
+
'/lib',
|
|
418
|
+
'/lib64',
|
|
419
|
+
'/etc',
|
|
420
|
+
'/opt',
|
|
421
|
+
]
|
|
422
|
+
|
|
236
423
|
function buildSeatbeltProfile(sandboxRoot: string): string {
|
|
237
424
|
const root = canonicalizePath(sandboxRoot)
|
|
238
425
|
|
|
@@ -323,21 +510,14 @@ function buildSafeEnv(
|
|
|
323
510
|
configEnv?: Record<string, string>,
|
|
324
511
|
optsEnv?: Record<string, string>,
|
|
325
512
|
): Record<string, string> {
|
|
326
|
-
const
|
|
513
|
+
const allowed =
|
|
514
|
+
process.platform === 'win32'
|
|
515
|
+
? [...SANDBOX_SAFE_ENV_KEYS, ...WINDOWS_CORE_ENV_KEYS]
|
|
516
|
+
: SANDBOX_SAFE_ENV_KEYS
|
|
517
|
+
const env = pickEnvironmentEntries(allowed)
|
|
327
518
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
if (value !== undefined) {
|
|
331
|
-
env[key] = value
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
if (configEnv) {
|
|
336
|
-
Object.assign(env, configEnv)
|
|
337
|
-
}
|
|
338
|
-
if (optsEnv) {
|
|
339
|
-
Object.assign(env, optsEnv)
|
|
340
|
-
}
|
|
519
|
+
applyEnvironmentOverrides(env, configEnv)
|
|
520
|
+
applyEnvironmentOverrides(env, optsEnv)
|
|
341
521
|
|
|
342
522
|
return env
|
|
343
523
|
}
|
|
@@ -359,22 +539,14 @@ class LocalSandbox implements Sandbox {
|
|
|
359
539
|
return this._status
|
|
360
540
|
}
|
|
361
541
|
|
|
362
|
-
/**
|
|
363
|
-
* How the pty binding is loaded. Injectable so a test needs no native
|
|
364
|
-
* build — the refusal path and the session wiring are both worth
|
|
365
|
-
* covering, and neither should require compiling C++ on CI.
|
|
366
|
-
*/
|
|
367
|
-
private readonly ptyLoader: PtyLoader | undefined
|
|
368
|
-
|
|
369
542
|
constructor(
|
|
370
543
|
id: SandboxId,
|
|
371
544
|
rootDir: string,
|
|
372
545
|
environment: SandboxEnvironment,
|
|
546
|
+
private readonly wrapperCommand: string | undefined,
|
|
373
547
|
config: SandboxCreateConfig,
|
|
374
548
|
log: Logger,
|
|
375
|
-
ptyLoader?: PtyLoader,
|
|
376
549
|
) {
|
|
377
|
-
this.ptyLoader = ptyLoader
|
|
378
550
|
this.id = id
|
|
379
551
|
this.rootDir = rootDir
|
|
380
552
|
this.environment = environment
|
|
@@ -440,33 +612,6 @@ class LocalSandbox implements Sandbox {
|
|
|
440
612
|
}
|
|
441
613
|
}
|
|
442
614
|
|
|
443
|
-
/**
|
|
444
|
-
* A real pseudo-terminal, or a refusal that says what to install.
|
|
445
|
-
*
|
|
446
|
-
* Deliberately NOT confined the way `exec` is. `exec` wraps every
|
|
447
|
-
* command in this class's isolation tiers (`unshare …`,
|
|
448
|
-
* `sandbox-exec …`); a terminal is an interactive session a human is
|
|
449
|
-
* driving, and wrapping it would put the tier's own shell between the
|
|
450
|
-
* operator's keystrokes and the program. So this runs inside the
|
|
451
|
-
* sandbox's ROOT DIRECTORY and nothing more — which is stated here
|
|
452
|
-
* because a caller reading "sandbox" would otherwise assume the tier
|
|
453
|
-
* applies, and it is exactly the assumption that makes a boundary
|
|
454
|
-
* imaginary.
|
|
455
|
-
*
|
|
456
|
-
* A host that needs the tier runs its interactive program through
|
|
457
|
-
* `exec` and accepts that it is not a terminal, or supplies a backend
|
|
458
|
-
* whose terminals are confined by construction — a container's `exec`,
|
|
459
|
-
* for instance, where the confinement is the container and not a
|
|
460
|
-
* wrapper.
|
|
461
|
-
*/
|
|
462
|
-
async openTerminal(options: OpenTerminalOptions): Promise<TerminalSession> {
|
|
463
|
-
if (this._status === 'destroyed') {
|
|
464
|
-
throw new Error(`Sandbox ${this.id} is destroyed`)
|
|
465
|
-
}
|
|
466
|
-
const pty = await loadPty(this.ptyLoader)
|
|
467
|
-
return openTerminalWith(pty, options, { shell: '/bin/sh', cwd: this.rootDir })
|
|
468
|
-
}
|
|
469
|
-
|
|
470
615
|
async writeFile(path: string, content: string | Buffer): Promise<void> {
|
|
471
616
|
if (this._status === 'destroyed') {
|
|
472
617
|
throw new Error(`Sandbox ${this.id} is destroyed`)
|
|
@@ -522,7 +667,7 @@ class LocalSandbox implements Sandbox {
|
|
|
522
667
|
return entries
|
|
523
668
|
}
|
|
524
669
|
|
|
525
|
-
async destroy(): Promise<void> {
|
|
670
|
+
async destroy(_options?: SandboxDestroyOptions): Promise<void> {
|
|
526
671
|
if (this._status === 'destroyed') {
|
|
527
672
|
return
|
|
528
673
|
}
|
|
@@ -543,6 +688,7 @@ class LocalSandbox implements Sandbox {
|
|
|
543
688
|
): { spawnCommand: string; spawnArgs: string[] } {
|
|
544
689
|
return buildLimitedSpawn({
|
|
545
690
|
environment: this.environment,
|
|
691
|
+
...(this.wrapperCommand !== undefined ? { wrapperCommand: this.wrapperCommand } : {}),
|
|
546
692
|
command,
|
|
547
693
|
args,
|
|
548
694
|
rootDir: this.rootDir,
|
|
@@ -646,11 +792,13 @@ export interface LocalSandboxProviderOptions {
|
|
|
646
792
|
*/
|
|
647
793
|
readonly requireIsolation?: readonly SandboxIsolationControl[]
|
|
648
794
|
/**
|
|
649
|
-
*
|
|
795
|
+
* Legacy test injection for the local backend's former terminal method.
|
|
650
796
|
*
|
|
651
|
-
*
|
|
652
|
-
*
|
|
653
|
-
*
|
|
797
|
+
* @deprecated The local backend cannot preserve its selected isolation
|
|
798
|
+
* tier or own the complete terminal process tree, so it no longer exposes
|
|
799
|
+
* `Sandbox.openTerminal`. Supplying this option now throws. Use the
|
|
800
|
+
* host-scoped terminal helpers directly only when unconfined execution is
|
|
801
|
+
* intentional, or provide a backend that owns confinement and teardown.
|
|
654
802
|
*/
|
|
655
803
|
readonly ptyLoader?: PtyLoader
|
|
656
804
|
}
|
|
@@ -661,12 +809,17 @@ export class LocalSandboxProvider implements SandboxProvider {
|
|
|
661
809
|
readonly environment: SandboxEnvironment
|
|
662
810
|
|
|
663
811
|
private readonly log: Logger
|
|
664
|
-
|
|
665
|
-
private readonly ptyLoader: PtyLoader | undefined
|
|
812
|
+
private readonly wrapperCommand: string | undefined
|
|
666
813
|
|
|
667
814
|
constructor(log: Logger, options: LocalSandboxProviderOptions = {}) {
|
|
668
|
-
|
|
669
|
-
|
|
815
|
+
if (options.ptyLoader !== undefined) {
|
|
816
|
+
throw new Error(
|
|
817
|
+
'LocalSandboxProvider no longer accepts ptyLoader because its terminal could not preserve the selected isolation tier or sandbox teardown ownership. Use the host-scoped terminal helpers only for intentional host execution, or provide a confined terminal backend.',
|
|
818
|
+
)
|
|
819
|
+
}
|
|
820
|
+
const detected = detectEnvironment()
|
|
821
|
+
this.environment = detected.environment
|
|
822
|
+
this.wrapperCommand = 'wrapperCommand' in detected ? detected.wrapperCommand : undefined
|
|
670
823
|
this.log = log.child({ [SCOPE_ATTRIBUTE]: 'sandbox/provider/local' })
|
|
671
824
|
|
|
672
825
|
assertIsolation(this.environment, options.requireIsolation ?? [])
|
|
@@ -693,17 +846,29 @@ export class LocalSandboxProvider implements SandboxProvider {
|
|
|
693
846
|
}
|
|
694
847
|
|
|
695
848
|
async create(config?: SandboxCreateConfig): Promise<Sandbox> {
|
|
849
|
+
config?.signal?.throwIfAborted()
|
|
696
850
|
const id = generateSandboxId()
|
|
697
851
|
|
|
698
852
|
// mkdtemp is in node:fs/promises but requires an async import-style usage.
|
|
699
853
|
// We use the same pattern: create a unique dir under os.tmpdir().
|
|
700
854
|
const { mkdtemp } = await import('node:fs/promises')
|
|
701
855
|
const rawDir = await mkdtemp(join(tmpdir(), SANDBOX_TEMP_DIR_PREFIX))
|
|
856
|
+
if (config?.signal?.aborted) {
|
|
857
|
+
await rm(rawDir, { recursive: true, force: true })
|
|
858
|
+
throw config.signal.reason
|
|
859
|
+
}
|
|
702
860
|
// Canonicalize — macOS symlinks like /var → /private/var must be resolved
|
|
703
861
|
const rootDir = canonicalizePath(rawDir)
|
|
704
862
|
|
|
705
863
|
this.log.info('Creating sandbox', { 'namzu.sandbox.id': id, 'namzu.sandbox.root_dir': rootDir })
|
|
706
864
|
|
|
707
|
-
return new LocalSandbox(
|
|
865
|
+
return new LocalSandbox(
|
|
866
|
+
id,
|
|
867
|
+
rootDir,
|
|
868
|
+
this.environment,
|
|
869
|
+
this.wrapperCommand,
|
|
870
|
+
config ?? {},
|
|
871
|
+
this.log,
|
|
872
|
+
)
|
|
708
873
|
}
|
|
709
874
|
}
|
package/src/sandbox/terminal.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A real terminal
|
|
2
|
+
* A real host pseudo-terminal, or nothing.
|
|
3
3
|
*
|
|
4
4
|
* `exec` runs a command and hands back what it printed. That is the whole
|
|
5
5
|
* shape of it, and a large class of work does not fit: an interactive
|
|
@@ -18,6 +18,12 @@
|
|
|
18
18
|
* why. That is the same rule `Sandbox.setNetworkPolicy` states for itself:
|
|
19
19
|
* a capability accepted and not applied is worse than one never offered,
|
|
20
20
|
* because the caller stops looking.
|
|
21
|
+
*
|
|
22
|
+
* Nothing in this module creates a sandbox or owns a complete descendant
|
|
23
|
+
* process tree. `openTerminalWith` starts exactly the program, arguments and
|
|
24
|
+
* working directory it is handed through the supplied binding. A sandbox or
|
|
25
|
+
* durable terminal backend must wrap that argv under its own confinement and
|
|
26
|
+
* make teardown await every process it owns before using this primitive.
|
|
21
27
|
*/
|
|
22
28
|
|
|
23
29
|
export interface TerminalSize {
|
|
@@ -26,7 +32,7 @@ export interface TerminalSize {
|
|
|
26
32
|
}
|
|
27
33
|
|
|
28
34
|
export interface OpenTerminalOptions {
|
|
29
|
-
/** The program to run. Defaults to the
|
|
35
|
+
/** The program to run. Defaults to the caller-supplied shell. */
|
|
30
36
|
readonly command?: string
|
|
31
37
|
readonly args?: readonly string[]
|
|
32
38
|
readonly cwd?: string
|
|
@@ -57,7 +63,7 @@ export interface TerminalSession {
|
|
|
57
63
|
onData(listener: (chunk: string) => void): () => void
|
|
58
64
|
/** Resolves when the program exits. */
|
|
59
65
|
readonly exited: Promise<{ exitCode: number; signal?: number }>
|
|
60
|
-
/**
|
|
66
|
+
/** Ask the backing binding to stop its top-level terminal process. */
|
|
61
67
|
kill(signal?: string): void
|
|
62
68
|
}
|
|
63
69
|
|
|
@@ -142,11 +148,13 @@ export async function loadPty(loader?: PtyLoader): Promise<PtyModule> {
|
|
|
142
148
|
}
|
|
143
149
|
|
|
144
150
|
/**
|
|
145
|
-
* Open a terminal, given a loaded binding.
|
|
151
|
+
* Open a host terminal, given a loaded binding.
|
|
146
152
|
*
|
|
147
153
|
* Separated from `loadPty` so the refusal and the session are testable
|
|
148
154
|
* apart: one is about a missing dependency, the other about wiring a
|
|
149
|
-
* process that exists.
|
|
155
|
+
* process that exists. This helper does not add confinement or descendant
|
|
156
|
+
* cleanup; those belong to the backend that supplies its argv and owns the
|
|
157
|
+
* returned session.
|
|
150
158
|
*/
|
|
151
159
|
export function openTerminalWith(
|
|
152
160
|
pty: PtyModule,
|