@namzu/sdk 72.0.0 → 74.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 +61 -0
- package/README.md +34 -34
- package/dist/agents/examples/SupervisorAgent.d.ts.map +1 -1
- package/dist/agents/examples/SupervisorAgent.js +5 -0
- package/dist/agents/examples/SupervisorAgent.js.map +1 -1
- package/dist/authorization/protected-paths.d.ts +7 -0
- package/dist/authorization/protected-paths.d.ts.map +1 -1
- package/dist/authorization/protected-paths.js +11 -0
- package/dist/authorization/protected-paths.js.map +1 -1
- package/dist/authorization/readonly-commands.d.ts +23 -0
- package/dist/authorization/readonly-commands.d.ts.map +1 -1
- package/dist/authorization/readonly-commands.js +89 -3
- package/dist/authorization/readonly-commands.js.map +1 -1
- package/dist/authorization/shell-paths.d.ts +8 -0
- package/dist/authorization/shell-paths.d.ts.map +1 -1
- package/dist/authorization/shell-paths.js +125 -2
- package/dist/authorization/shell-paths.js.map +1 -1
- package/dist/bridge/acp/permission.d.ts +6 -0
- package/dist/bridge/acp/permission.d.ts.map +1 -1
- package/dist/bridge/acp/permission.js.map +1 -1
- package/dist/bridge/acp/server.d.ts.map +1 -1
- package/dist/bridge/acp/server.js +21 -3
- package/dist/bridge/acp/server.js.map +1 -1
- package/dist/compaction/context-window.d.ts.map +1 -1
- package/dist/compaction/context-window.js +11 -0
- package/dist/compaction/context-window.js.map +1 -1
- package/dist/compaction/manual.d.ts +16 -1
- package/dist/compaction/manual.d.ts.map +1 -1
- package/dist/compaction/manual.js +75 -13
- package/dist/compaction/manual.js.map +1 -1
- package/dist/compaction/plan.d.ts +2 -1
- package/dist/compaction/plan.d.ts.map +1 -1
- package/dist/compaction/plan.js +6 -5
- package/dist/compaction/plan.js.map +1 -1
- package/dist/compaction/precompute.d.ts +179 -0
- package/dist/compaction/precompute.d.ts.map +1 -0
- package/dist/compaction/precompute.js +274 -0
- package/dist/compaction/precompute.js.map +1 -0
- package/dist/compaction/retained-images.d.ts +16 -0
- package/dist/compaction/retained-images.d.ts.map +1 -0
- package/dist/compaction/retained-images.js +113 -0
- package/dist/compaction/retained-images.js.map +1 -0
- package/dist/compaction/token-estimate.d.ts +8 -3
- package/dist/compaction/token-estimate.d.ts.map +1 -1
- package/dist/compaction/token-estimate.js +76 -8
- package/dist/compaction/token-estimate.js.map +1 -1
- package/dist/compaction/tool-result-editing.d.ts.map +1 -1
- package/dist/compaction/tool-result-editing.js +15 -8
- package/dist/compaction/tool-result-editing.js.map +1 -1
- package/dist/config/runtime.d.ts +4 -0
- package/dist/config/runtime.d.ts.map +1 -1
- package/dist/config/runtime.js +17 -0
- package/dist/config/runtime.js.map +1 -1
- package/dist/constants/acp/index.d.ts +2 -0
- package/dist/constants/acp/index.d.ts.map +1 -1
- package/dist/constants/acp/index.js +2 -0
- package/dist/constants/acp/index.js.map +1 -1
- package/dist/manager/agent/lifecycle.d.ts.map +1 -1
- package/dist/manager/agent/lifecycle.js +8 -0
- package/dist/manager/agent/lifecycle.js.map +1 -1
- package/dist/manager/session/turn-recorder.d.ts +26 -0
- package/dist/manager/session/turn-recorder.d.ts.map +1 -1
- package/dist/manager/session/turn-recorder.js +72 -5
- package/dist/manager/session/turn-recorder.js.map +1 -1
- package/dist/peers/protocol.d.ts +9 -0
- package/dist/peers/protocol.d.ts.map +1 -1
- package/dist/peers/protocol.js +4 -0
- package/dist/peers/protocol.js.map +1 -1
- package/dist/peers/record.d.ts +6 -0
- package/dist/peers/record.d.ts.map +1 -1
- package/dist/peers/record.js +4 -0
- package/dist/peers/record.js.map +1 -1
- package/dist/plugin/index.d.ts +2 -2
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.js +1 -1
- package/dist/plugin/index.js.map +1 -1
- package/dist/plugin/shell-hook.d.ts +30 -0
- package/dist/plugin/shell-hook.d.ts.map +1 -1
- package/dist/plugin/shell-hook.js +35 -0
- package/dist/plugin/shell-hook.js.map +1 -1
- package/dist/pricing/catalogue.generated.d.ts.map +1 -1
- package/dist/pricing/catalogue.generated.js +178 -1
- package/dist/pricing/catalogue.generated.js.map +1 -1
- package/dist/provider/attribution.js +1 -1
- package/dist/provider/attribution.js.map +1 -1
- package/dist/public-runtime.d.ts +9 -5
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +12 -4
- package/dist/public-runtime.js.map +1 -1
- package/dist/public-tools.d.ts +1 -1
- package/dist/public-tools.d.ts.map +1 -1
- package/dist/public-tools.js +1 -1
- package/dist/public-tools.js.map +1 -1
- package/dist/public-types.d.ts +3 -2
- package/dist/public-types.d.ts.map +1 -1
- package/dist/rag/embedding.d.ts +5 -1
- package/dist/rag/embedding.d.ts.map +1 -1
- package/dist/rag/embedding.js +22 -7
- package/dist/rag/embedding.js.map +1 -1
- package/dist/registry/command/kernel-commands.d.ts +7 -1
- package/dist/registry/command/kernel-commands.d.ts.map +1 -1
- package/dist/registry/command/kernel-commands.js +40 -2
- package/dist/registry/command/kernel-commands.js.map +1 -1
- package/dist/registry/tool/execute.d.ts +8 -0
- package/dist/registry/tool/execute.d.ts.map +1 -1
- package/dist/registry/tool/execute.js +12 -0
- package/dist/registry/tool/execute.js.map +1 -1
- package/dist/runtime/query/abandon-turn.d.ts.map +1 -1
- package/dist/runtime/query/abandon-turn.js +9 -0
- package/dist/runtime/query/abandon-turn.js.map +1 -1
- package/dist/runtime/query/budget-nudge.d.ts +27 -0
- package/dist/runtime/query/budget-nudge.d.ts.map +1 -0
- package/dist/runtime/query/budget-nudge.js +66 -0
- package/dist/runtime/query/budget-nudge.js.map +1 -0
- package/dist/runtime/query/compact-session.d.ts +19 -3
- package/dist/runtime/query/compact-session.d.ts.map +1 -1
- package/dist/runtime/query/compact-session.js +180 -93
- package/dist/runtime/query/compact-session.js.map +1 -1
- package/dist/runtime/query/guard.d.ts +8 -0
- package/dist/runtime/query/guard.d.ts.map +1 -1
- package/dist/runtime/query/guard.js +20 -0
- package/dist/runtime/query/guard.js.map +1 -1
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +1 -0
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/runtime/query/iteration/index.d.ts +2 -0
- package/dist/runtime/query/iteration/index.d.ts.map +1 -1
- package/dist/runtime/query/iteration/index.js +41 -1
- package/dist/runtime/query/iteration/index.js.map +1 -1
- package/dist/runtime/query/iteration/phases/compaction.d.ts +1 -0
- package/dist/runtime/query/iteration/phases/compaction.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/compaction.js +203 -45
- package/dist/runtime/query/iteration/phases/compaction.js.map +1 -1
- package/dist/runtime/query/iteration/phases/context.d.ts +2 -0
- package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/context.js +1 -0
- package/dist/runtime/query/iteration/phases/context.js.map +1 -1
- package/dist/runtime/query/iteration/phases/precompute.d.ts +60 -0
- package/dist/runtime/query/iteration/phases/precompute.d.ts.map +1 -0
- package/dist/runtime/query/iteration/phases/precompute.js +240 -0
- package/dist/runtime/query/iteration/phases/precompute.js.map +1 -0
- package/dist/runtime/query/iteration/request-prefix.d.ts +21 -0
- package/dist/runtime/query/iteration/request-prefix.d.ts.map +1 -0
- package/dist/runtime/query/iteration/request-prefix.js +111 -0
- package/dist/runtime/query/iteration/request-prefix.js.map +1 -0
- package/dist/runtime/query/review-policy.d.ts +11 -3
- package/dist/runtime/query/review-policy.d.ts.map +1 -1
- package/dist/runtime/query/review-policy.js +54 -3
- package/dist/runtime/query/review-policy.js.map +1 -1
- package/dist/runtime/query/turn/outcome-ledger.d.ts +14 -0
- package/dist/runtime/query/turn/outcome-ledger.d.ts.map +1 -1
- package/dist/runtime/query/turn/outcome-ledger.js +28 -0
- package/dist/runtime/query/turn/outcome-ledger.js.map +1 -1
- package/dist/sandbox/exec-stdin.d.ts +21 -0
- package/dist/sandbox/exec-stdin.d.ts.map +1 -0
- package/dist/sandbox/exec-stdin.js +40 -0
- package/dist/sandbox/exec-stdin.js.map +1 -0
- package/dist/sandbox/file-walk.d.ts +12 -7
- package/dist/sandbox/file-walk.d.ts.map +1 -1
- package/dist/sandbox/file-walk.js +13 -4
- package/dist/sandbox/file-walk.js.map +1 -1
- package/dist/sandbox/ignore-matcher.d.ts +1 -0
- package/dist/sandbox/ignore-matcher.d.ts.map +1 -1
- package/dist/sandbox/ignore-matcher.js.map +1 -1
- package/dist/sandbox/ignore-source.js +1 -1
- package/dist/sandbox/index.d.ts +3 -2
- package/dist/sandbox/index.d.ts.map +1 -1
- package/dist/sandbox/index.js +2 -1
- package/dist/sandbox/index.js.map +1 -1
- package/dist/sandbox/provider/local.d.ts.map +1 -1
- package/dist/sandbox/provider/local.js +2 -0
- package/dist/sandbox/provider/local.js.map +1 -1
- package/dist/session/paths.d.ts +6 -0
- package/dist/session/paths.d.ts.map +1 -1
- package/dist/session/paths.js +7 -0
- package/dist/session/paths.js.map +1 -1
- package/dist/session-query/index.d.ts +1 -0
- package/dist/session-query/index.d.ts.map +1 -1
- package/dist/session-query/index.js +26 -15
- package/dist/session-query/index.js.map +1 -1
- package/dist/store/evidence/disk.js +3 -1
- package/dist/store/evidence/disk.js.map +1 -1
- package/dist/store/evidence/index-page.d.ts +1 -0
- package/dist/store/evidence/index-page.d.ts.map +1 -1
- package/dist/store/evidence/index-page.js +8 -0
- package/dist/store/evidence/index-page.js.map +1 -1
- package/dist/store/goal/gates.d.ts +53 -0
- package/dist/store/goal/gates.d.ts.map +1 -0
- package/dist/store/goal/gates.js +664 -0
- package/dist/store/goal/gates.js.map +1 -0
- package/dist/store/goal/index.d.ts +16 -1
- package/dist/store/goal/index.d.ts.map +1 -1
- package/dist/store/goal/index.js +74 -0
- package/dist/store/goal/index.js.map +1 -1
- package/dist/store/memory/operation-lock.d.ts.map +1 -1
- package/dist/store/memory/operation-lock.js +15 -1
- package/dist/store/memory/operation-lock.js.map +1 -1
- package/dist/store/session-log/core.d.ts.map +1 -1
- package/dist/store/session-log/core.js +23 -0
- package/dist/store/session-log/core.js.map +1 -1
- package/dist/tools/builtins/bash.js +1 -1
- package/dist/tools/builtins/bash.js.map +1 -1
- package/dist/tools/builtins/browser.d.ts.map +1 -1
- package/dist/tools/builtins/browser.js +2 -0
- package/dist/tools/builtins/browser.js.map +1 -1
- package/dist/tools/builtins/computer-use-image.d.ts +9 -0
- package/dist/tools/builtins/computer-use-image.d.ts.map +1 -1
- package/dist/tools/builtins/computer-use-image.js +21 -0
- package/dist/tools/builtins/computer-use-image.js.map +1 -1
- package/dist/tools/builtins/computer-use.d.ts +1 -9
- package/dist/tools/builtins/computer-use.d.ts.map +1 -1
- package/dist/tools/builtins/computer-use.js +2 -22
- package/dist/tools/builtins/computer-use.js.map +1 -1
- package/dist/tools/builtins/monitor.d.ts.map +1 -1
- package/dist/tools/builtins/monitor.js +1 -0
- package/dist/tools/builtins/monitor.js.map +1 -1
- package/dist/tools/builtins/search-tools.js +2 -2
- package/dist/tools/builtins/search-tools.js.map +1 -1
- package/dist/tools/builtins/sleep-guard.js +1 -1
- package/dist/tools/builtins/sleep-guard.js.map +1 -1
- package/dist/tools/builtins/wait-for-job.js +1 -1
- package/dist/tools/builtins/wait-for-job.js.map +1 -1
- package/dist/tools/coordinator/ask-user-question.d.ts.map +1 -1
- package/dist/tools/coordinator/ask-user-question.js +25 -0
- package/dist/tools/coordinator/ask-user-question.js.map +1 -1
- package/dist/tools/coordinator/index.d.ts.map +1 -1
- package/dist/tools/coordinator/index.js +3 -0
- package/dist/tools/coordinator/index.js.map +1 -1
- package/dist/tools/defineTool.d.ts +2 -0
- package/dist/tools/defineTool.d.ts.map +1 -1
- package/dist/tools/defineTool.js +3 -0
- package/dist/tools/defineTool.js.map +1 -1
- package/dist/tools/goal/confirmation.d.ts +40 -2
- package/dist/tools/goal/confirmation.d.ts.map +1 -1
- package/dist/tools/goal/confirmation.js +117 -0
- package/dist/tools/goal/confirmation.js.map +1 -1
- package/dist/tools/goal/index.d.ts.map +1 -1
- package/dist/tools/goal/index.js +14 -2
- package/dist/tools/goal/index.js.map +1 -1
- package/dist/tools/memory/save.d.ts.map +1 -1
- package/dist/tools/memory/save.js +1 -0
- package/dist/tools/memory/save.js.map +1 -1
- package/dist/tools/schedules/index.d.ts +1 -0
- package/dist/tools/schedules/index.d.ts.map +1 -1
- package/dist/tools/schedules/index.js +1 -0
- package/dist/tools/schedules/index.js.map +1 -1
- package/dist/tools/schedules/loop-tool.d.ts.map +1 -1
- package/dist/tools/schedules/loop-tool.js +1 -0
- package/dist/tools/schedules/loop-tool.js.map +1 -1
- package/dist/tools/schedules/present.d.ts.map +1 -1
- package/dist/tools/schedules/present.js +2 -0
- package/dist/tools/schedules/present.js.map +1 -1
- package/dist/tools/schedules/schedule-tool.d.ts.map +1 -1
- package/dist/tools/schedules/schedule-tool.js +79 -9
- package/dist/tools/schedules/schedule-tool.js.map +1 -1
- package/dist/tools/schedules/self-tool.d.ts +16 -0
- package/dist/tools/schedules/self-tool.d.ts.map +1 -0
- package/dist/tools/schedules/self-tool.js +140 -0
- package/dist/tools/schedules/self-tool.js.map +1 -0
- package/dist/tools/schedules/timer-tools.d.ts.map +1 -1
- package/dist/tools/schedules/timer-tools.js +1 -0
- package/dist/tools/schedules/timer-tools.js.map +1 -1
- package/dist/tools/schedules/types.d.ts +63 -0
- package/dist/tools/schedules/types.d.ts.map +1 -1
- package/dist/toolsets/manager.d.ts +14 -0
- package/dist/toolsets/manager.d.ts.map +1 -1
- package/dist/toolsets/manager.js +60 -7
- package/dist/toolsets/manager.js.map +1 -1
- package/dist/types/agent/supervisor.d.ts +10 -0
- package/dist/types/agent/supervisor.d.ts.map +1 -1
- package/dist/types/agent/task.d.ts +6 -0
- package/dist/types/agent/task.d.ts.map +1 -1
- package/dist/types/common/index.d.ts +20 -0
- package/dist/types/common/index.d.ts.map +1 -1
- package/dist/types/common/index.js +4 -1
- package/dist/types/common/index.js.map +1 -1
- package/dist/types/goal/index.d.ts +66 -0
- package/dist/types/goal/index.d.ts.map +1 -1
- package/dist/types/hitl/index.d.ts +11 -0
- package/dist/types/hitl/index.d.ts.map +1 -1
- package/dist/types/hitl/index.js.map +1 -1
- package/dist/types/rag/embedding.d.ts +4 -0
- package/dist/types/rag/embedding.d.ts.map +1 -1
- package/dist/types/sandbox/index.d.ts +19 -0
- package/dist/types/sandbox/index.d.ts.map +1 -1
- package/dist/types/sandbox/index.js.map +1 -1
- package/dist/types/session/events.d.ts +55 -0
- package/dist/types/session/events.d.ts.map +1 -1
- package/dist/types/session/events.js.map +1 -1
- package/dist/types/session/outcome.d.ts +12 -0
- package/dist/types/session/outcome.d.ts.map +1 -1
- package/dist/types/session/outcome.js.map +1 -1
- package/dist/types/session/records.d.ts +81 -1
- package/dist/types/session/records.d.ts.map +1 -1
- package/dist/types/session/records.js +33 -0
- package/dist/types/session/records.js.map +1 -1
- package/dist/types/tool/index.d.ts +7 -0
- package/dist/types/tool/index.d.ts.map +1 -1
- package/dist/types/tool/index.js.map +1 -1
- package/dist/utils/cost.d.ts +15 -0
- package/dist/utils/cost.d.ts.map +1 -1
- package/dist/utils/cost.js +24 -1
- package/dist/utils/cost.js.map +1 -1
- package/package.json +2 -2
- package/src/agents/examples/SupervisorAgent.ts +5 -0
- package/src/authorization/protected-paths.ts +11 -0
- package/src/authorization/readonly-commands.ts +85 -3
- package/src/authorization/shell-paths.ts +141 -3
- package/src/bridge/acp/permission.ts +6 -0
- package/src/bridge/acp/server.ts +20 -1
- package/src/compaction/context-window.ts +11 -0
- package/src/compaction/manual.ts +103 -17
- package/src/compaction/plan.ts +11 -5
- package/src/compaction/precompute.ts +390 -0
- package/src/compaction/retained-images.ts +130 -0
- package/src/compaction/token-estimate.ts +86 -8
- package/src/compaction/tool-result-editing.ts +20 -8
- package/src/config/runtime.ts +17 -0
- package/src/constants/acp/index.ts +2 -0
- package/src/manager/agent/lifecycle.ts +9 -0
- package/src/manager/session/turn-recorder.ts +92 -5
- package/src/peers/protocol.ts +4 -0
- package/src/peers/record.ts +4 -0
- package/src/plugin/index.ts +2 -0
- package/src/plugin/shell-hook.ts +60 -0
- package/src/pricing/catalogue.generated.ts +178 -1
- package/src/pricing/rates.source.json +155 -2
- package/src/provider/attribution.ts +1 -1
- package/src/public-runtime.ts +48 -0
- package/src/public-tools.ts +2 -0
- package/src/public-types.ts +8 -0
- package/src/rag/embedding.ts +23 -7
- package/src/registry/command/kernel-commands.ts +62 -3
- package/src/registry/tool/execute.ts +14 -0
- package/src/runtime/query/abandon-turn.ts +9 -0
- package/src/runtime/query/budget-nudge.ts +92 -0
- package/src/runtime/query/compact-session.ts +242 -87
- package/src/runtime/query/guard.ts +22 -0
- package/src/runtime/query/index.ts +1 -0
- package/src/runtime/query/iteration/index.ts +40 -1
- package/src/runtime/query/iteration/phases/compaction.ts +224 -46
- package/src/runtime/query/iteration/phases/context.ts +3 -0
- package/src/runtime/query/iteration/phases/precompute.ts +277 -0
- package/src/runtime/query/iteration/request-prefix.ts +161 -0
- package/src/runtime/query/review-policy.ts +79 -11
- package/src/runtime/query/turn/outcome-ledger.ts +34 -0
- package/src/sandbox/exec-stdin.ts +54 -0
- package/src/sandbox/file-walk.ts +25 -18
- package/src/sandbox/ignore-matcher.ts +1 -0
- package/src/sandbox/ignore-source.ts +1 -1
- package/src/sandbox/index.ts +8 -2
- package/src/sandbox/provider/local.ts +2 -0
- package/src/session/paths.ts +9 -0
- package/src/session-query/index.ts +23 -14
- package/src/store/evidence/disk.ts +3 -1
- package/src/store/evidence/index-page.ts +11 -0
- package/src/store/goal/gates.ts +738 -0
- package/src/store/goal/index.ts +109 -0
- package/src/store/memory/operation-lock.ts +19 -1
- package/src/store/session-log/core.ts +26 -0
- package/src/tools/builtins/bash.ts +1 -1
- package/src/tools/builtins/browser.ts +4 -0
- package/src/tools/builtins/computer-use-image.ts +20 -0
- package/src/tools/builtins/computer-use.ts +1 -20
- package/src/tools/builtins/monitor.ts +2 -0
- package/src/tools/builtins/search-tools.ts +2 -2
- package/src/tools/builtins/sleep-guard.ts +1 -1
- package/src/tools/builtins/wait-for-job.ts +1 -1
- package/src/tools/coordinator/ask-user-question.ts +37 -10
- package/src/tools/coordinator/index.ts +3 -0
- package/src/tools/defineTool.ts +5 -0
- package/src/tools/goal/confirmation.ts +171 -3
- package/src/tools/goal/index.ts +15 -3
- package/src/tools/memory/save.ts +2 -0
- package/src/tools/schedules/index.ts +1 -0
- package/src/tools/schedules/loop-tool.ts +2 -0
- package/src/tools/schedules/present.ts +2 -0
- package/src/tools/schedules/schedule-tool.ts +84 -9
- package/src/tools/schedules/self-tool.ts +152 -0
- package/src/tools/schedules/timer-tools.ts +2 -0
- package/src/tools/schedules/types.ts +62 -0
- package/src/toolsets/manager.ts +59 -8
- package/src/types/agent/supervisor.ts +11 -0
- package/src/types/agent/task.ts +7 -0
- package/src/types/common/index.ts +26 -1
- package/src/types/goal/index.ts +72 -0
- package/src/types/hitl/index.ts +11 -0
- package/src/types/rag/embedding.ts +7 -0
- package/src/types/sandbox/index.ts +19 -0
- package/src/types/session/events.ts +56 -0
- package/src/types/session/outcome.ts +16 -1
- package/src/types/session/records.ts +41 -0
- package/src/types/tool/index.ts +7 -0
- package/src/utils/cost.ts +44 -1
package/src/store/goal/index.ts
CHANGED
|
@@ -4,6 +4,8 @@ import { TenantIsolationError } from '../../session/errors.js'
|
|
|
4
4
|
import type {
|
|
5
5
|
GoalBlockReason,
|
|
6
6
|
GoalConfirmedBy,
|
|
7
|
+
GoalGateRoundReport,
|
|
8
|
+
GoalGatesSpec,
|
|
7
9
|
GoalGuards,
|
|
8
10
|
GoalPhase,
|
|
9
11
|
GoalRef,
|
|
@@ -21,6 +23,14 @@ import {
|
|
|
21
23
|
revisionFileSegment,
|
|
22
24
|
} from '../kv/revision-record-store.js'
|
|
23
25
|
import { defineSchema } from '../schema.js'
|
|
26
|
+
import {
|
|
27
|
+
GOAL_GATES_BLOCK_CODE,
|
|
28
|
+
GOAL_GATE_MAX_TAIL_CHARS,
|
|
29
|
+
goalGateFailedNames,
|
|
30
|
+
goalGateTail,
|
|
31
|
+
goalGatesBlockSentence,
|
|
32
|
+
goalGatesFrom,
|
|
33
|
+
} from './gates.js'
|
|
24
34
|
|
|
25
35
|
/** Current source-backed limit for a human goal objective. */
|
|
26
36
|
export const MAX_GOAL_OBJECTIVE_CHARS = 4_000
|
|
@@ -47,6 +57,12 @@ export interface CreateSessionGoalParams {
|
|
|
47
57
|
readonly guards?: GoalGuards
|
|
48
58
|
/** Set only when this goal chooses; absent leaves the choice to the host's setting. */
|
|
49
59
|
readonly confirmedBy?: GoalConfirmedBy
|
|
60
|
+
/**
|
|
61
|
+
* Commands the host runs at the end of each round; the goal completes only
|
|
62
|
+
* when they all pass. Checked here (see `parseGoalGateEntry`) and fixed for the
|
|
63
|
+
* life of the goal.
|
|
64
|
+
*/
|
|
65
|
+
readonly gates?: GoalGatesSpec
|
|
50
66
|
}
|
|
51
67
|
|
|
52
68
|
export interface EditSessionGoalParams {
|
|
@@ -94,6 +110,19 @@ export interface SessionGoalStore {
|
|
|
94
110
|
goalId: GoalId,
|
|
95
111
|
outcome: GoalRoundOutcome,
|
|
96
112
|
): Promise<SessionGoal | null>
|
|
113
|
+
/**
|
|
114
|
+
* Write down what the gates showed when a round ended: the last result of
|
|
115
|
+
* each, and, once per admitted round, whether the round ended with a failing
|
|
116
|
+
* gate. The goal is blocked (`gates-failing`) when that many rounds in a row
|
|
117
|
+
* did, which is the cap on retries. A goal without gates, or a store written
|
|
118
|
+
* before this existed, returns `null` or lacks the method.
|
|
119
|
+
*/
|
|
120
|
+
recordGateRound?(
|
|
121
|
+
sessionId: SessionId,
|
|
122
|
+
tenantId: TenantId,
|
|
123
|
+
goalId: GoalId,
|
|
124
|
+
report: GoalGateRoundReport,
|
|
125
|
+
): Promise<SessionGoal | null>
|
|
97
126
|
}
|
|
98
127
|
|
|
99
128
|
/** What a resume may raise so that a goal stopped by a limit can go on. */
|
|
@@ -309,6 +338,14 @@ function goalGuards(value: GoalGuards | undefined): GoalGuards | undefined {
|
|
|
309
338
|
return Object.keys(guards).length > 0 ? guards : undefined
|
|
310
339
|
}
|
|
311
340
|
|
|
341
|
+
/** The authority's view of the gates that did not pass: what leads the next round. */
|
|
342
|
+
function failuresOf(
|
|
343
|
+
goal: SessionGoal,
|
|
344
|
+
): Pick<GoalRoundAuthority, 'gateFailures'> | Record<string, never> {
|
|
345
|
+
const failing = goal.gates?.results.filter((result) => result.status !== 'passed') ?? []
|
|
346
|
+
return failing.length > 0 ? { gateFailures: failing } : {}
|
|
347
|
+
}
|
|
348
|
+
|
|
312
349
|
function blockReason(value: GoalBlockReason): GoalBlockReason {
|
|
313
350
|
if (
|
|
314
351
|
typeof value?.code !== 'string' ||
|
|
@@ -384,6 +421,7 @@ abstract class SessionGoalStoreBase implements SessionGoalStore {
|
|
|
384
421
|
const text = objective(params.objective)
|
|
385
422
|
const maxRounds = maxGoalRounds(params.maxGoalRounds)
|
|
386
423
|
const guards = goalGuards(params.guards)
|
|
424
|
+
const gates = goalGatesFrom(params.gates)
|
|
387
425
|
if (
|
|
388
426
|
params.confirmedBy !== undefined &&
|
|
389
427
|
params.confirmedBy !== 'model' &&
|
|
@@ -410,6 +448,7 @@ abstract class SessionGoalStoreBase implements SessionGoalStore {
|
|
|
410
448
|
roundsAdmitted: 0,
|
|
411
449
|
...(guards !== undefined ? { guards } : {}),
|
|
412
450
|
...(params.confirmedBy !== undefined ? { confirmedBy: params.confirmedBy } : {}),
|
|
451
|
+
...(gates !== undefined ? { gates } : {}),
|
|
413
452
|
createdAt: now,
|
|
414
453
|
updatedAt: now,
|
|
415
454
|
}
|
|
@@ -491,9 +530,18 @@ abstract class SessionGoalStoreBase implements SessionGoalStore {
|
|
|
491
530
|
filled?.checkInEvery !== undefined &&
|
|
492
531
|
filled.checkInEvery > 0 &&
|
|
493
532
|
filled.checkInEvery !== goal.guards?.checkInEvery
|
|
533
|
+
// A resume gives the gates their retries back; their last results stay, so a
|
|
534
|
+
// gate that failed on these files is still not run again until they change.
|
|
535
|
+
const gates = goal.gates
|
|
536
|
+
? (() => {
|
|
537
|
+
const { countedRound: _counted, ...kept } = goal.gates
|
|
538
|
+
return { ...kept, failingRounds: 0 }
|
|
539
|
+
})()
|
|
540
|
+
: undefined
|
|
494
541
|
return {
|
|
495
542
|
...rest,
|
|
496
543
|
phase: 'active',
|
|
544
|
+
...(gates !== undefined ? { gates } : {}),
|
|
497
545
|
...(newCheckIn ? { checkedInAtRound: goal.roundsAdmitted } : {}),
|
|
498
546
|
maxGoalRounds:
|
|
499
547
|
raisedRounds !== undefined && raisedRounds > goal.maxGoalRounds
|
|
@@ -603,6 +651,7 @@ abstract class SessionGoalStoreBase implements SessionGoalStore {
|
|
|
603
651
|
...(goal.costUsd !== undefined ? { costUsd: goal.costUsd } : {}),
|
|
604
652
|
...(overBudget ? { wrapUp: true } : {}),
|
|
605
653
|
...(goal.missing && goal.missing.length > 0 ? { missing: goal.missing } : {}),
|
|
654
|
+
...failuresOf(goal),
|
|
606
655
|
}
|
|
607
656
|
return {
|
|
608
657
|
record: {
|
|
@@ -714,6 +763,66 @@ abstract class SessionGoalStoreBase implements SessionGoalStore {
|
|
|
714
763
|
})
|
|
715
764
|
}
|
|
716
765
|
|
|
766
|
+
async recordGateRound(
|
|
767
|
+
sessionId: SessionId,
|
|
768
|
+
tenantId: TenantId,
|
|
769
|
+
goalId: GoalId,
|
|
770
|
+
report: GoalGateRoundReport,
|
|
771
|
+
): Promise<SessionGoal | null> {
|
|
772
|
+
const checked = await this.requireSession(sessionId, tenantId)
|
|
773
|
+
const id = asGoalId(goalId)
|
|
774
|
+
const before = await backendFor(this).read(checked)
|
|
775
|
+
if (!before || before.goal?.id !== id) return null
|
|
776
|
+
return await backendFor(this).transact<SessionGoal | null>(checked, (existing) => {
|
|
777
|
+
if (!existing) throw new GoalNotFoundError(checked)
|
|
778
|
+
assertTenant(existing, tenantId)
|
|
779
|
+
const goal = existing.goal
|
|
780
|
+
const now = this.now()
|
|
781
|
+
const keep = (result: SessionGoal | null, next: SessionGoal | null = existing.goal) => ({
|
|
782
|
+
record: {
|
|
783
|
+
sessionId: checked,
|
|
784
|
+
tenantId,
|
|
785
|
+
storageRevision: existing.storageRevision + 1,
|
|
786
|
+
goal: next,
|
|
787
|
+
updatedAt: now,
|
|
788
|
+
},
|
|
789
|
+
result,
|
|
790
|
+
})
|
|
791
|
+
if (!goal || goal.id !== id || goal.gates === undefined) return keep(null)
|
|
792
|
+
const gates = goal.gates
|
|
793
|
+
const results = report.results.slice(0, gates.entries.length).map((result) => ({
|
|
794
|
+
...result,
|
|
795
|
+
...(result.tail !== undefined
|
|
796
|
+
? { tail: goalGateTail(result.tail, GOAL_GATE_MAX_TAIL_CHARS) }
|
|
797
|
+
: {}),
|
|
798
|
+
}))
|
|
799
|
+
const failed = goalGateFailedNames(results)
|
|
800
|
+
// A round that looks twice (the model was sent back and looked again) counts once.
|
|
801
|
+
const counted = gates.countedRound === report.round
|
|
802
|
+
const failingRounds =
|
|
803
|
+
failed.length === 0 ? 0 : counted ? gates.failingRounds : gates.failingRounds + 1
|
|
804
|
+
const nextGates = {
|
|
805
|
+
...gates,
|
|
806
|
+
results,
|
|
807
|
+
failingRounds,
|
|
808
|
+
...(failed.length === 0 ? {} : { countedRound: report.round }),
|
|
809
|
+
}
|
|
810
|
+
let updated: SessionGoal = { ...goal, gates: nextGates, updatedAt: now }
|
|
811
|
+
if (goal.phase === 'active' && failed.length > 0 && failingRounds >= gates.maxFailingRounds) {
|
|
812
|
+
updated = {
|
|
813
|
+
...updated,
|
|
814
|
+
revision: goal.revision + 1,
|
|
815
|
+
phase: 'blocked',
|
|
816
|
+
blockedReason: {
|
|
817
|
+
code: GOAL_GATES_BLOCK_CODE,
|
|
818
|
+
message: goalGatesBlockSentence(gates, failed),
|
|
819
|
+
},
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
return keep(updated, updated)
|
|
823
|
+
})
|
|
824
|
+
}
|
|
825
|
+
|
|
717
826
|
async completeGoal(sessionId: SessionId, tenantId: TenantId, ref: GoalRef): Promise<SessionGoal> {
|
|
718
827
|
return await this.transition(
|
|
719
828
|
sessionId,
|
|
@@ -122,11 +122,16 @@ async function inspect(path: string, env: Resolved): Promise<Inspection | undefi
|
|
|
122
122
|
return { stats: before, content: '', pid: undefined, staleReason: undefined }
|
|
123
123
|
const content = await readFile(path, 'utf8').catch((error: NodeJS.ErrnoException) => {
|
|
124
124
|
if (error.code === 'ENOENT') return undefined
|
|
125
|
+
// Windows can deny reads while another handle still holds the lock file.
|
|
126
|
+
// Treat an unreadable owner as unverifiable, so it cannot be broken.
|
|
127
|
+
if (error.code === 'EACCES' || error.code === 'EPERM' || error.code === 'EBUSY') return null
|
|
125
128
|
throw error
|
|
126
129
|
})
|
|
127
130
|
if (content === undefined) return undefined
|
|
128
131
|
const after = await lstat(path).catch(() => undefined)
|
|
129
132
|
if (!after || after.dev !== before.dev || after.ino !== before.ino) return undefined
|
|
133
|
+
if (content === null)
|
|
134
|
+
return { stats: before, content: '', pid: undefined, staleReason: undefined }
|
|
130
135
|
|
|
131
136
|
const owner = parseOwner(content)
|
|
132
137
|
if (owner) {
|
|
@@ -167,7 +172,20 @@ async function createOwned(
|
|
|
167
172
|
try {
|
|
168
173
|
handle = await open(path, 'wx', 0o600)
|
|
169
174
|
} catch (error) {
|
|
170
|
-
|
|
175
|
+
const code = (error as NodeJS.ErrnoException).code
|
|
176
|
+
if (code === 'EEXIST') return undefined
|
|
177
|
+
// Windows reports an exclusive create over a file another process still
|
|
178
|
+
// holds open (or is deleting) as a sharing error, not EEXIST. When the
|
|
179
|
+
// path is there, it is occupied; otherwise the error is real.
|
|
180
|
+
if (code === 'EACCES' || code === 'EPERM' || code === 'EBUSY') {
|
|
181
|
+
if (
|
|
182
|
+
await lstat(path).then(
|
|
183
|
+
() => true,
|
|
184
|
+
() => false,
|
|
185
|
+
)
|
|
186
|
+
)
|
|
187
|
+
return undefined
|
|
188
|
+
}
|
|
171
189
|
throw error
|
|
172
190
|
}
|
|
173
191
|
const owner = `${JSON.stringify({
|
|
@@ -976,6 +976,7 @@ export class SessionLogCore implements SessionLog {
|
|
|
976
976
|
type !== 'message_replaced' &&
|
|
977
977
|
type !== 'message_edited' &&
|
|
978
978
|
type !== 'compaction' &&
|
|
979
|
+
type !== 'compaction_shed' &&
|
|
979
980
|
type !== 'turn_completed'
|
|
980
981
|
)
|
|
981
982
|
return candidate
|
|
@@ -984,6 +985,31 @@ export class SessionLogCore implements SessionLog {
|
|
|
984
985
|
// single large one never sits inline and bloats the log.
|
|
985
986
|
const spillAbove = type === 'compaction' ? this.#compactionSpillAbove : this.#spillAbove
|
|
986
987
|
if (size <= spillAbove) return candidate
|
|
988
|
+
if (type === 'compaction_shed') {
|
|
989
|
+
if (!Array.isArray(candidate.messages) || candidate.messagesSpill !== undefined)
|
|
990
|
+
return candidate
|
|
991
|
+
const messages = candidate.messages as Message[]
|
|
992
|
+
const messagesSpill = await this.#spills.write(
|
|
993
|
+
`shed:${String(candidate.id)}`,
|
|
994
|
+
'messages',
|
|
995
|
+
JSON.stringify(messages),
|
|
996
|
+
)
|
|
997
|
+
// Keep the exact searchable text and tool pairing inline when they fit.
|
|
998
|
+
const projected = messages.map((message) => {
|
|
999
|
+
if (message.role === 'tool' && Array.isArray(message.content)) {
|
|
1000
|
+
return {
|
|
1001
|
+
...message,
|
|
1002
|
+
content: message.content.filter((block) => block.type === 'text'),
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
if (message.role === 'user') return { ...message, attachments: undefined }
|
|
1006
|
+
return message
|
|
1007
|
+
})
|
|
1008
|
+
const record = { ...candidate, messages: projected, messagesSpill }
|
|
1009
|
+
return Buffer.byteLength(`${JSON.stringify(record)}\n`, 'utf8') <= this.#spillAbove
|
|
1010
|
+
? record
|
|
1011
|
+
: { ...record, messages: [] }
|
|
1012
|
+
}
|
|
987
1013
|
if (type === 'turn_completed') {
|
|
988
1014
|
if (typeof candidate.result !== 'string') return candidate
|
|
989
1015
|
const ref = await this.#spillOrLose(
|
|
@@ -174,7 +174,7 @@ const inputSchema = z.object({
|
|
|
174
174
|
.boolean()
|
|
175
175
|
.optional()
|
|
176
176
|
.describe(
|
|
177
|
-
'Start the command as a background job and return its id at once. You are told when it exits: end your turn or keep working, and do not poll or wait for it. A command that waits for a person (it prints a sign-in URL) goes here too, with no `timeout` wrapper: tell them the step and end your turn. For a persistent server, `wait_for_job` with output_contains observes its readiness marker; verify health separately. Use `job` action "read" for output. Background a command with this parameter, since `cmd &` is not a registered job: strict execution ownership can retire the allocation when the launcher exits with live descendants. An interactive application may belong to a dedicated computer only when that computer explicitly supports application lifetime; its launch result is not a registered job or proof the application has finished.',
|
|
177
|
+
'Start the command as a background job and return its id at once. You are told when it exits: end your turn or keep working, and do not poll or wait for it. A command that waits for a person (it prints a sign-in URL) goes here too, with no `timeout` wrapper: tell them the step and end your turn. To wait for a condition, background an until-loop (`until <check>; do sleep 2; done`) and end your turn, or give it to `monitor`. For a persistent server, `wait_for_job` with output_contains observes its readiness marker; verify health separately. Use `job` action "read" for output. Background a command with this parameter, since `cmd &` is not a registered job: strict execution ownership can retire the allocation when the launcher exits with live descendants. An interactive application may belong to a dedicated computer only when that computer explicitly supports application lifetime; its launch result is not a registered job or proof the application has finished.',
|
|
178
178
|
),
|
|
179
179
|
dangerously_disable_sandbox: z
|
|
180
180
|
.boolean()
|
|
@@ -1177,6 +1177,8 @@ export function createBrowserTools(
|
|
|
1177
1177
|
|
|
1178
1178
|
const browser = defineTool({
|
|
1179
1179
|
name: BROWSER_TOOL_NAME,
|
|
1180
|
+
discoveryHint:
|
|
1181
|
+
'Real browser: sign-in pages, script-drawn pages, reading what is on screen; use over web_fetch then',
|
|
1180
1182
|
description: observeDescription(caps),
|
|
1181
1183
|
inputSchema: observeSchema,
|
|
1182
1184
|
// An unavailable host keeps the full enum: an empty one is invalid on
|
|
@@ -1240,6 +1242,8 @@ export function createBrowserTools(
|
|
|
1240
1242
|
|
|
1241
1243
|
const browserAct = defineTool({
|
|
1242
1244
|
name: BROWSER_ACT_TOOL_NAME,
|
|
1245
|
+
discoveryHint:
|
|
1246
|
+
'Act on a browser page: click, type, fill a form, select, press a key, upload, answer a dialog',
|
|
1243
1247
|
description: actDescription(caps),
|
|
1244
1248
|
inputSchema: actSchema,
|
|
1245
1249
|
modelInputSchema: actModelSchema(actActions.length > 0 ? actActions : ACT_ACTIONS),
|
|
@@ -52,6 +52,26 @@ export const HIGH_RES_SCREENSHOT_LIMITS: ScreenshotLimits = Object.freeze({
|
|
|
52
52
|
maxTiles: 4784,
|
|
53
53
|
})
|
|
54
54
|
|
|
55
|
+
/**
|
|
56
|
+
* The limits to fit a screenshot to for `model`: the high-resolution tier for
|
|
57
|
+
* a model known to read it (the 4.7 and later models of the vendor behind that
|
|
58
|
+
* tier, with or without a vendor prefix or a dated suffix), the standard tier for every
|
|
59
|
+
* other model, including one the table does not know. A wrong "high" costs a
|
|
60
|
+
* rejected tool result; a wrong "standard" only costs detail, so an unknown
|
|
61
|
+
* model gets the standard tier.
|
|
62
|
+
*/
|
|
63
|
+
export function screenshotLimitsForModel(model: string | undefined): ScreenshotLimits {
|
|
64
|
+
if (model === undefined) return STANDARD_SCREENSHOT_LIMITS
|
|
65
|
+
const match = /claude-(?:opus|sonnet|haiku|fable)-(\d+)(?:[-.](\d{1,2})(?!\d))?/i.exec(model)
|
|
66
|
+
if (!match) return STANDARD_SCREENSHOT_LIMITS
|
|
67
|
+
const major = Number(match[1])
|
|
68
|
+
const minor = match[2] === undefined ? 0 : Number(match[2])
|
|
69
|
+
// A dated id such as `claude-sonnet-4-20250514` has no minor: the date is not one.
|
|
70
|
+
return major > 4 || (major === 4 && minor >= 7)
|
|
71
|
+
? HIGH_RES_SCREENSHOT_LIMITS
|
|
72
|
+
: STANDARD_SCREENSHOT_LIMITS
|
|
73
|
+
}
|
|
74
|
+
|
|
55
75
|
export interface ImageSize {
|
|
56
76
|
readonly width: number
|
|
57
77
|
readonly height: number
|
|
@@ -39,7 +39,6 @@ import {
|
|
|
39
39
|
} from './computer-use-coordinates.js'
|
|
40
40
|
import {
|
|
41
41
|
type FittedImage,
|
|
42
|
-
HIGH_RES_SCREENSHOT_LIMITS,
|
|
43
42
|
STANDARD_SCREENSHOT_LIMITS,
|
|
44
43
|
type ScreenshotLimits,
|
|
45
44
|
cropAndFitPng,
|
|
@@ -55,25 +54,7 @@ export {
|
|
|
55
54
|
} from './computer-use-image.js'
|
|
56
55
|
export type { ImageSize, ScreenshotLimits } from './computer-use-image.js'
|
|
57
56
|
|
|
58
|
-
|
|
59
|
-
* The limits to fit a screenshot to for `model`: the high-resolution tier for
|
|
60
|
-
* a model known to read it (the 4.7 and later models of the vendor behind that
|
|
61
|
-
* tier, with or without a vendor prefix or a dated suffix), the standard tier for every
|
|
62
|
-
* other model, including one the table does not know. A wrong "high" costs a
|
|
63
|
-
* rejected tool result; a wrong "standard" only costs detail, so an unknown
|
|
64
|
-
* model gets the standard tier.
|
|
65
|
-
*/
|
|
66
|
-
export function screenshotLimitsForModel(model: string | undefined): ScreenshotLimits {
|
|
67
|
-
if (model === undefined) return STANDARD_SCREENSHOT_LIMITS
|
|
68
|
-
const match = /claude-(?:opus|sonnet|haiku|fable)-(\d+)(?:[-.](\d{1,2})(?!\d))?/i.exec(model)
|
|
69
|
-
if (!match) return STANDARD_SCREENSHOT_LIMITS
|
|
70
|
-
const major = Number(match[1])
|
|
71
|
-
const minor = match[2] === undefined ? 0 : Number(match[2])
|
|
72
|
-
// A dated id such as `claude-sonnet-4-20250514` has no minor: the date is not one.
|
|
73
|
-
return major > 4 || (major === 4 && minor >= 7)
|
|
74
|
-
? HIGH_RES_SCREENSHOT_LIMITS
|
|
75
|
-
: STANDARD_SCREENSHOT_LIMITS
|
|
76
|
-
}
|
|
57
|
+
export { screenshotLimitsForModel } from './computer-use-image.js'
|
|
77
58
|
|
|
78
59
|
export const COMPUTER_USE_TOOL_NAME = 'computer_use' as const
|
|
79
60
|
|
|
@@ -170,6 +170,8 @@ const MONITOR_WEBSOCKET_NOT_SUPPORTED =
|
|
|
170
170
|
export function createMonitorTool(options: MonitorToolOptions = {}) {
|
|
171
171
|
return defineTool({
|
|
172
172
|
name: MONITOR_TOOL_NAME,
|
|
173
|
+
discoveryHint:
|
|
174
|
+
'Watch a command and hear each output line as it prints, while you keep working, instead of polling',
|
|
173
175
|
description: MONITOR_DESCRIPTION,
|
|
174
176
|
inputSchema,
|
|
175
177
|
category: 'shell',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod'
|
|
2
|
-
import {
|
|
2
|
+
import { toolCatalogueHint } from '../../registry/tool/execute.js'
|
|
3
3
|
import type { ToolDefinition } from '../../types/tool/index.js'
|
|
4
4
|
import { defineTool } from '../defineTool.js'
|
|
5
5
|
|
|
@@ -202,7 +202,7 @@ export const SearchToolsTool = defineTool({
|
|
|
202
202
|
if (nearMisses.length > 0) {
|
|
203
203
|
const hints = nearMisses
|
|
204
204
|
.map((t) => {
|
|
205
|
-
const hint =
|
|
205
|
+
const hint = toolCatalogueHint(t)
|
|
206
206
|
return hint.length > 0 ? `- ${t.name}: ${hint}` : `- ${t.name}`
|
|
207
207
|
})
|
|
208
208
|
.join('\n')
|
|
@@ -27,7 +27,7 @@ export function leadingLongSleep(command: string): string | null {
|
|
|
27
27
|
|
|
28
28
|
/** What the model is told when a long leading sleep is refused. */
|
|
29
29
|
export function longSleepRefusal(what: string): string {
|
|
30
|
-
return `Blocked: ${what}. Do not wait with sleeps.
|
|
30
|
+
return `Blocked: ${what}. Do not wait with sleeps. To wait until a condition is true, run a background until-loop (\`until <check>; do sleep 2; done\`) with run_in_background: true and end your turn, you are told when it exits, or give the same loop to monitor, where its exit or an output line is the event; for a stream of events, use monitor. Do not chain shorter sleeps to work around this block.`
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
/**
|
|
@@ -97,7 +97,7 @@ type WaitForJobInput = z.infer<typeof inputSchema>
|
|
|
97
97
|
export const WaitForJobTool = defineTool({
|
|
98
98
|
name: 'wait_for_job',
|
|
99
99
|
description:
|
|
100
|
-
'Wait for an owned background job to exit, or set output_contains to observe an exact output marker while it stays running. Only for
|
|
100
|
+
'Wait for an owned background job to exit, or set output_contains to observe an exact output marker while it stays running. Only for a result needed inside this step in a host that cannot be woken later. Otherwise end your turn: you are told when a job exits, or use monitor. Never use it, or a short timeout_ms, for something that waits for a person. Output markers do not prove service health or completion and never express intent to wait until exit. A bounded wait returns output and next_offset without stopping the job; pass that cursor as from_offset to exclude earlier output.',
|
|
101
101
|
inputSchema,
|
|
102
102
|
category: 'shell',
|
|
103
103
|
permissions: ['shell_execute'],
|
|
@@ -20,7 +20,7 @@ import type {
|
|
|
20
20
|
UserQuestionOption,
|
|
21
21
|
} from '../../types/hitl/index.js'
|
|
22
22
|
import type { SessionId, TurnId } from '../../types/ids/index.js'
|
|
23
|
-
import type { ToolDefinition, ToolFacts } from '../../types/tool/index.js'
|
|
23
|
+
import type { ToolDefinition, ToolFacts, ToolResult } from '../../types/tool/index.js'
|
|
24
24
|
import { generateCheckpointId } from '../../utils/id.js'
|
|
25
25
|
import { defineTool } from '../defineTool.js'
|
|
26
26
|
import { questionOptions } from './question-options.js'
|
|
@@ -453,7 +453,22 @@ export function buildAskUserQuestionTool(config: AskUserQuestionToolOptions): To
|
|
|
453
453
|
// registries by turn — concurrent parks on one turn clobber each
|
|
454
454
|
// other and the first promise never resolves (the turn hangs to TTL).
|
|
455
455
|
concurrencySafe: false,
|
|
456
|
+
// No deadline: the wait is a person's, and a person takes as long as
|
|
457
|
+
// they take. The executor's two-minute default is a bound for a tool
|
|
458
|
+
// call; at that bound it gave up on the question, told the model it had
|
|
459
|
+
// timed out, and the answers typed afterwards reached nobody. The wait
|
|
460
|
+
// still ends when the turn is stopped: `context.abortSignal` fires, is
|
|
461
|
+
// handed to the host below, and the host takes the question off screen.
|
|
462
|
+
timeoutMs: Number.POSITIVE_INFINITY,
|
|
456
463
|
async execute(input, context) {
|
|
464
|
+
const gone = (): ToolResult => ({
|
|
465
|
+
success: false,
|
|
466
|
+
output: '',
|
|
467
|
+
error:
|
|
468
|
+
'The question was withdrawn before the user answered it, so nothing was asked or answered.',
|
|
469
|
+
})
|
|
470
|
+
// A call that was abandoned before it began asks nothing.
|
|
471
|
+
if (context.abortSignal?.aborted) return gone()
|
|
457
472
|
// A host that calls the tool without going through the registry
|
|
458
473
|
// hands over the older single-question shape or unfilled defaults;
|
|
459
474
|
// parsing again is a no-op for input the registry already parsed.
|
|
@@ -516,15 +531,23 @@ export function buildAskUserQuestionTool(config: AskUserQuestionToolOptions): To
|
|
|
516
531
|
|
|
517
532
|
const decision =
|
|
518
533
|
carried ??
|
|
519
|
-
(await parkHandler(
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
534
|
+
(await parkHandler(
|
|
535
|
+
{
|
|
536
|
+
type: 'user_question',
|
|
537
|
+
sessionId: config.sessionId ?? context.sessionId,
|
|
538
|
+
turnId: config.turnId ?? context.turnId,
|
|
539
|
+
// Provider correlation ids remain verbatim in questionData;
|
|
540
|
+
// an unpersisted park gets its own safe checkpoint identifier.
|
|
541
|
+
checkpointId: parkedAt ?? generateCheckpointId(),
|
|
542
|
+
question: questionData,
|
|
543
|
+
},
|
|
544
|
+
// The signal is how the host learns nobody is waiting any more
|
|
545
|
+
// (the turn was stopped) and takes the question off screen.
|
|
546
|
+
{
|
|
547
|
+
transcript: () => context.conversation?.messages() ?? [],
|
|
548
|
+
...(context.abortSignal ? { signal: context.abortSignal } : {}),
|
|
549
|
+
},
|
|
550
|
+
))
|
|
528
551
|
|
|
529
552
|
// Clear the park once the answer is in, so an approval queue
|
|
530
553
|
// stops serving a question that has been answered.
|
|
@@ -549,6 +572,10 @@ export function buildAskUserQuestionTool(config: AskUserQuestionToolOptions): To
|
|
|
549
572
|
: { question: first.question, answered: false },
|
|
550
573
|
}
|
|
551
574
|
|
|
575
|
+
// Answers that arrive after the call was abandoned have no one to
|
|
576
|
+
// receive them: the turn that asked has stopped.
|
|
577
|
+
if (context.abortSignal?.aborted) return gone()
|
|
578
|
+
|
|
552
579
|
if (decision.action === 'abort') {
|
|
553
580
|
// One decline ends the whole batch: there is no partial refusal.
|
|
554
581
|
return {
|
|
@@ -1302,6 +1302,9 @@ export function buildCoordinatorTools(opts: CoordinatorToolsOptions): ToolDefini
|
|
|
1302
1302
|
// registry entry and deadlock the loser, so the executor must
|
|
1303
1303
|
// serialize this tool exactly like the question tool.
|
|
1304
1304
|
concurrencySafe: false,
|
|
1305
|
+
// A person decides, and takes as long as they take: no deadline. The
|
|
1306
|
+
// two-minute default abandoned the approval while it was on screen.
|
|
1307
|
+
timeoutMs: Number.POSITIVE_INFINITY,
|
|
1305
1308
|
async execute({ title, summary, steps }) {
|
|
1306
1309
|
const pm = getPlanManager()
|
|
1307
1310
|
if (!pm) {
|
package/src/tools/defineTool.ts
CHANGED
|
@@ -87,6 +87,8 @@ export interface DefineToolOptions<S extends z.ZodType> {
|
|
|
87
87
|
pathArgument?: string
|
|
88
88
|
/** Tools `search_tools` loads together with this one; see {@link ToolDefinition.loadsWith}. */
|
|
89
89
|
loadsWith?: readonly string[]
|
|
90
|
+
/** The catalogue line of a deferred tool; see {@link ToolDefinition.discoveryHint}. */
|
|
91
|
+
discoveryHint?: string
|
|
90
92
|
/** A refusal known before any reviewer is asked; see {@link ToolDefinition.refuseBeforeReview}. */
|
|
91
93
|
refuseBeforeReview?: ToolDefinition<z.infer<S>>['refuseBeforeReview']
|
|
92
94
|
/** The argument holding a canonical URL; see {@link ToolDefinition.urlArgument}. */
|
|
@@ -155,6 +157,9 @@ export function defineTool<S extends z.ZodType>(
|
|
|
155
157
|
...(options.loadsWith !== undefined && options.loadsWith.length > 0
|
|
156
158
|
? { loadsWith: options.loadsWith }
|
|
157
159
|
: {}),
|
|
160
|
+
...(options.discoveryHint !== undefined && options.discoveryHint.trim().length > 0
|
|
161
|
+
? { discoveryHint: options.discoveryHint.trim() }
|
|
162
|
+
: {}),
|
|
158
163
|
...(options.refuseBeforeReview ? { refuseBeforeReview: options.refuseBeforeReview } : {}),
|
|
159
164
|
...(options.urlArgument !== undefined ? { urlArgument: options.urlArgument } : {}),
|
|
160
165
|
...(options.sandboxEscapeArgument !== undefined
|