@namzu/sdk 71.1.0 → 73.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 +55 -0
- package/dist/agents/QueryAgent.d.ts.map +1 -1
- package/dist/agents/QueryAgent.js +1 -0
- package/dist/agents/QueryAgent.js.map +1 -1
- 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.map +1 -1
- package/dist/authorization/protected-paths.js +4 -0
- package/dist/authorization/protected-paths.js.map +1 -1
- package/dist/compaction/index.d.ts +1 -1
- 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 +24 -1
- package/dist/compaction/manual.d.ts.map +1 -1
- package/dist/compaction/manual.js +80 -21
- package/dist/compaction/manual.js.map +1 -1
- package/dist/compaction/model-summary.d.ts +24 -6
- package/dist/compaction/model-summary.d.ts.map +1 -1
- package/dist/compaction/model-summary.js +108 -23
- package/dist/compaction/model-summary.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/restore.d.ts +23 -0
- package/dist/compaction/restore.d.ts.map +1 -1
- package/dist/compaction/restore.js +59 -1
- package/dist/compaction/restore.js.map +1 -1
- package/dist/compaction/summary.d.ts +37 -2
- package/dist/compaction/summary.d.ts.map +1 -1
- package/dist/compaction/summary.js +46 -6
- package/dist/compaction/summary.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 +20 -3
- package/dist/config/runtime.js.map +1 -1
- package/dist/connector/index.d.ts +2 -2
- package/dist/connector/index.d.ts.map +1 -1
- package/dist/connector/index.js +1 -1
- package/dist/connector/index.js.map +1 -1
- package/dist/connector/mcp/client.d.ts +26 -6
- package/dist/connector/mcp/client.d.ts.map +1 -1
- package/dist/connector/mcp/client.js +49 -7
- package/dist/connector/mcp/client.js.map +1 -1
- package/dist/connector/mcp/index.d.ts +2 -0
- package/dist/connector/mcp/index.d.ts.map +1 -1
- package/dist/connector/mcp/index.js +1 -0
- package/dist/connector/mcp/index.js.map +1 -1
- package/dist/connector/mcp/sandbox-stdio.d.ts +67 -0
- package/dist/connector/mcp/sandbox-stdio.d.ts.map +1 -0
- package/dist/connector/mcp/sandbox-stdio.js +178 -0
- package/dist/connector/mcp/sandbox-stdio.js.map +1 -0
- package/dist/connector/mcp/stdio-program.d.ts +34 -0
- package/dist/connector/mcp/stdio-program.d.ts.map +1 -0
- package/dist/connector/mcp/stdio-program.js +47 -0
- package/dist/connector/mcp/stdio-program.js.map +1 -0
- package/dist/connector/mcp/stdio.d.ts.map +1 -1
- package/dist/connector/mcp/stdio.js +5 -2
- package/dist/connector/mcp/stdio.js.map +1 -1
- package/dist/connector/web/guarded-fetch.d.ts +51 -2
- package/dist/connector/web/guarded-fetch.d.ts.map +1 -1
- package/dist/connector/web/guarded-fetch.js +140 -19
- package/dist/connector/web/guarded-fetch.js.map +1 -1
- package/dist/connector/web/index.d.ts +2 -2
- package/dist/connector/web/index.d.ts.map +1 -1
- package/dist/connector/web/index.js +1 -1
- package/dist/connector/web/index.js.map +1 -1
- package/dist/manager/agent/lifecycle.d.ts.map +1 -1
- package/dist/manager/agent/lifecycle.js +9 -1
- 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/hook-module/capabilities.d.ts.map +1 -1
- package/dist/plugin/hook-module/capabilities.js +24 -13
- package/dist/plugin/hook-module/capabilities.js.map +1 -1
- package/dist/plugin/hook-module/host.d.ts +31 -0
- package/dist/plugin/hook-module/host.d.ts.map +1 -1
- package/dist/plugin/hook-module/host.js +56 -13
- package/dist/plugin/hook-module/host.js.map +1 -1
- package/dist/plugin/hook-module/index.d.ts +3 -2
- package/dist/plugin/hook-module/index.d.ts.map +1 -1
- package/dist/plugin/hook-module/index.js +2 -1
- package/dist/plugin/hook-module/index.js.map +1 -1
- package/dist/plugin/index.d.ts +3 -2
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.js +2 -1
- package/dist/plugin/index.js.map +1 -1
- package/dist/plugin/shell-hook-execute.d.ts +55 -0
- package/dist/plugin/shell-hook-execute.d.ts.map +1 -0
- package/dist/plugin/shell-hook-execute.js +73 -0
- package/dist/plugin/shell-hook-execute.js.map +1 -0
- package/dist/plugin/shell-hook-restrict.d.ts +31 -0
- package/dist/plugin/shell-hook-restrict.d.ts.map +1 -0
- package/dist/plugin/shell-hook-restrict.js +69 -0
- package/dist/plugin/shell-hook-restrict.js.map +1 -0
- package/dist/plugin/shell-hook.d.ts +59 -2
- package/dist/plugin/shell-hook.d.ts.map +1 -1
- package/dist/plugin/shell-hook.js +79 -12
- package/dist/plugin/shell-hook.js.map +1 -1
- package/dist/public-runtime.d.ts +11 -7
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +9 -6
- 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 +5 -2
- package/dist/public-types.d.ts.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/jobs/websocket-source.d.ts +2 -22
- package/dist/runtime/jobs/websocket-source.d.ts.map +1 -1
- package/dist/runtime/jobs/websocket-source.js +2 -33
- package/dist/runtime/jobs/websocket-source.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 +9 -0
- package/dist/runtime/query/compact-session.d.ts.map +1 -1
- package/dist/runtime/query/compact-session.js +158 -76
- package/dist/runtime/query/compact-session.js.map +1 -1
- package/dist/runtime/query/events.d.ts +7 -0
- package/dist/runtime/query/events.d.ts.map +1 -1
- package/dist/runtime/query/events.js +29 -11
- package/dist/runtime/query/events.js.map +1 -1
- package/dist/runtime/query/executor/tool-call-admission.d.ts.map +1 -1
- package/dist/runtime/query/executor/tool-call-admission.js +51 -10
- package/dist/runtime/query/executor/tool-call-admission.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 +6 -0
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +3 -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 +27 -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 +164 -43
- package/dist/runtime/query/iteration/phases/compaction.js.map +1 -1
- package/dist/runtime/query/iteration/phases/context.d.ts +4 -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/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/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/scheduler/completion-inbox.d.ts.map +1 -1
- package/dist/scheduler/completion-inbox.js +15 -0
- package/dist/scheduler/completion-inbox.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/session-index/index.d.ts +13 -0
- package/dist/store/session-index/index.d.ts.map +1 -1
- package/dist/store/session-index/index.js +1 -0
- package/dist/store/session-index/index.js.map +1 -1
- package/dist/store/session-index/rebuild.d.ts +12 -0
- package/dist/store/session-index/rebuild.d.ts.map +1 -1
- package/dist/store/session-index/rebuild.js +20 -4
- package/dist/store/session-index/rebuild.js.map +1 -1
- package/dist/store/session-index/sqlite.d.ts +20 -0
- package/dist/store/session-index/sqlite.d.ts.map +1 -1
- package/dist/store/session-index/sqlite.js +50 -12
- package/dist/store/session-index/sqlite.js.map +1 -1
- package/dist/tools/admit-facts.d.ts.map +1 -1
- package/dist/tools/admit-facts.js +59 -0
- package/dist/tools/admit-facts.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/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 +92 -3
- 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 +10 -0
- package/dist/toolsets/manager.d.ts.map +1 -1
- package/dist/toolsets/manager.js +56 -7
- package/dist/toolsets/manager.js.map +1 -1
- package/dist/turn/memory-promoter.d.ts.map +1 -1
- package/dist/turn/memory-promoter.js +20 -4
- package/dist/turn/memory-promoter.js.map +1 -1
- package/dist/types/agent/base.d.ts +6 -0
- package/dist/types/agent/base.d.ts.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 +11 -0
- package/dist/types/agent/task.d.ts.map +1 -1
- package/dist/types/agent/task.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 +8 -0
- package/dist/types/hitl/index.d.ts.map +1 -1
- package/dist/types/hitl/index.js.map +1 -1
- package/dist/types/message/index.d.ts +7 -0
- package/dist/types/message/index.d.ts.map +1 -1
- package/dist/types/message/index.js.map +1 -1
- package/dist/types/session/events.d.ts +7 -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 +79 -1
- package/dist/types/session/records.d.ts.map +1 -1
- package/dist/types/session/records.js +24 -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/types/tool/presentation.d.ts +21 -0
- package/dist/types/tool/presentation.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/agents/QueryAgent.ts +1 -0
- package/src/agents/examples/SupervisorAgent.ts +5 -0
- package/src/authorization/protected-paths.ts +4 -0
- package/src/compaction/index.ts +1 -0
- package/src/compaction/manual.ts +130 -23
- package/src/compaction/model-summary.ts +118 -23
- package/src/compaction/precompute.ts +390 -0
- package/src/compaction/restore.ts +74 -1
- package/src/compaction/summary.ts +69 -3
- package/src/config/runtime.ts +20 -3
- package/src/connector/index.ts +3 -0
- package/src/connector/mcp/client.ts +49 -7
- package/src/connector/mcp/index.ts +5 -0
- package/src/connector/mcp/sandbox-stdio.ts +214 -0
- package/src/connector/mcp/stdio-program.ts +68 -0
- package/src/connector/mcp/stdio.ts +5 -2
- package/src/connector/web/guarded-fetch.ts +197 -30
- package/src/connector/web/index.ts +4 -1
- package/src/manager/agent/lifecycle.ts +10 -1
- 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/hook-module/capabilities.ts +36 -14
- package/src/plugin/hook-module/host.ts +86 -13
- package/src/plugin/hook-module/index.ts +3 -0
- package/src/plugin/index.ts +3 -0
- package/src/plugin/shell-hook-execute.ts +126 -0
- package/src/plugin/shell-hook-restrict.ts +66 -0
- package/src/plugin/shell-hook.ts +138 -10
- package/src/public-runtime.ts +41 -0
- package/src/public-tools.ts +2 -0
- package/src/public-types.ts +21 -0
- package/src/registry/command/kernel-commands.ts +62 -3
- package/src/registry/tool/execute.ts +14 -0
- package/src/runtime/jobs/websocket-source.ts +2 -46
- package/src/runtime/query/budget-nudge.ts +92 -0
- package/src/runtime/query/compact-session.ts +195 -70
- package/src/runtime/query/events.ts +29 -11
- package/src/runtime/query/executor/tool-call-admission.ts +62 -17
- package/src/runtime/query/guard.ts +22 -0
- package/src/runtime/query/index.ts +10 -0
- package/src/runtime/query/iteration/index.ts +26 -1
- package/src/runtime/query/iteration/phases/compaction.ts +173 -43
- package/src/runtime/query/iteration/phases/context.ts +6 -0
- package/src/runtime/query/iteration/phases/precompute.ts +277 -0
- package/src/runtime/query/turn/outcome-ledger.ts +34 -0
- package/src/scheduler/completion-inbox.ts +14 -0
- package/src/store/goal/gates.ts +738 -0
- package/src/store/goal/index.ts +109 -0
- package/src/store/session-index/index.ts +14 -0
- package/src/store/session-index/rebuild.ts +22 -4
- package/src/store/session-index/sqlite.ts +63 -14
- package/src/tools/admit-facts.ts +64 -0
- package/src/tools/builtins/bash.ts +1 -1
- package/src/tools/builtins/browser.ts +4 -0
- 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 +124 -13
- 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 +55 -8
- package/src/turn/memory-promoter.ts +24 -3
- package/src/types/agent/base.ts +7 -0
- package/src/types/agent/supervisor.ts +11 -0
- package/src/types/agent/task.ts +12 -0
- package/src/types/goal/index.ts +72 -0
- package/src/types/hitl/index.ts +8 -0
- package/src/types/message/index.ts +7 -0
- package/src/types/session/events.ts +7 -0
- package/src/types/session/outcome.ts +16 -1
- package/src/types/session/records.ts +27 -0
- package/src/types/tool/index.ts +7 -0
- package/src/types/tool/presentation.ts +22 -0
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,
|
|
@@ -177,6 +177,13 @@ export interface SessionLogLocation {
|
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
export interface SessionIndex {
|
|
180
|
+
/**
|
|
181
|
+
* True while the index was opened on demand and no read has caught it up with
|
|
182
|
+
* the logs yet: the next list, search or lookup reads every log first, so a
|
|
183
|
+
* caller that makes a person wait can say so. Absent on a backend that does
|
|
184
|
+
* not defer.
|
|
185
|
+
*/
|
|
186
|
+
readonly syncPending?: boolean
|
|
180
187
|
readonly backend: 'sqlite' | 'scan'
|
|
181
188
|
/** Derive (or continue deriving) one session from its records. */
|
|
182
189
|
indexSession(input: SessionLogInput): Promise<IndexedSession | undefined>
|
|
@@ -216,6 +223,12 @@ export interface OpenSessionIndexOptions {
|
|
|
216
223
|
* catch up with the logs in the background; every read waits for it.
|
|
217
224
|
*/
|
|
218
225
|
readonly syncInBackground?: boolean
|
|
226
|
+
/**
|
|
227
|
+
* SQLite only: open without reading any log, and catch up with the logs the
|
|
228
|
+
* first time a read asks. A write never starts the catch-up. The scan
|
|
229
|
+
* backend reads on first use already.
|
|
230
|
+
*/
|
|
231
|
+
readonly syncOnDemand?: boolean
|
|
219
232
|
}
|
|
220
233
|
|
|
221
234
|
/**
|
|
@@ -234,6 +247,7 @@ export async function openSessionIndex(
|
|
|
234
247
|
home,
|
|
235
248
|
path: options.path ?? join(home, 'index.sqlite'),
|
|
236
249
|
...(options.syncInBackground === true ? { syncInBackground: true } : {}),
|
|
250
|
+
...(options.syncOnDemand === true ? { syncOnDemand: true } : {}),
|
|
237
251
|
})
|
|
238
252
|
}
|
|
239
253
|
|
|
@@ -745,8 +745,26 @@ export abstract class SessionIndexBase implements SessionIndex {
|
|
|
745
745
|
return Promise.resolve()
|
|
746
746
|
}
|
|
747
747
|
|
|
748
|
+
/**
|
|
749
|
+
* What a read about one session waits for. A backend that syncs on first read
|
|
750
|
+
* overrides it to bring only that session's rows current, so a lookup the turn
|
|
751
|
+
* itself makes does not read every log.
|
|
752
|
+
*/
|
|
753
|
+
protected settledFor(_sessionId: SessionId | undefined): Promise<void> {
|
|
754
|
+
return this.settled()
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
/**
|
|
758
|
+
* What a write waits for: a catch-up already running, never one that has not
|
|
759
|
+
* started. A backend that syncs on first read overrides it, so a write at the
|
|
760
|
+
* start of a conversation does not pay for reading every log.
|
|
761
|
+
*/
|
|
762
|
+
protected settledForWrite(): Promise<void> {
|
|
763
|
+
return this.settled()
|
|
764
|
+
}
|
|
765
|
+
|
|
748
766
|
async getSession(sessionId: SessionId): Promise<IndexedSession | undefined> {
|
|
749
|
-
await this.
|
|
767
|
+
await this.settledFor(sessionId)
|
|
750
768
|
return this.sessionNow(sessionId)
|
|
751
769
|
}
|
|
752
770
|
|
|
@@ -765,7 +783,7 @@ export abstract class SessionIndexBase implements SessionIndex {
|
|
|
765
783
|
* clears the row, so a write that ran beside it could be undone.
|
|
766
784
|
*/
|
|
767
785
|
async indexSession(input: SessionLogInput): Promise<IndexedSession | undefined> {
|
|
768
|
-
await this.
|
|
786
|
+
await this.settledForWrite()
|
|
769
787
|
return this.indexSessionNow(input)
|
|
770
788
|
}
|
|
771
789
|
|
|
@@ -882,7 +900,7 @@ export abstract class SessionIndexBase implements SessionIndex {
|
|
|
882
900
|
}
|
|
883
901
|
|
|
884
902
|
async refresh(location: SessionLogLocation): Promise<SessionStaleness> {
|
|
885
|
-
await this.
|
|
903
|
+
await this.settledForWrite()
|
|
886
904
|
return this.refreshNow(location)
|
|
887
905
|
}
|
|
888
906
|
|
|
@@ -912,7 +930,7 @@ export abstract class SessionIndexBase implements SessionIndex {
|
|
|
912
930
|
}
|
|
913
931
|
|
|
914
932
|
async sync(home: string): Promise<void> {
|
|
915
|
-
await this.
|
|
933
|
+
await this.settledForWrite()
|
|
916
934
|
return this.syncNow(home)
|
|
917
935
|
}
|
|
918
936
|
|
|
@@ -477,6 +477,13 @@ export interface SqliteSessionIndexOptions {
|
|
|
477
477
|
* longer waits on a home with thousands of logs.
|
|
478
478
|
*/
|
|
479
479
|
readonly syncInBackground?: boolean
|
|
480
|
+
/**
|
|
481
|
+
* Return once the index is open and current in version, and read the logs
|
|
482
|
+
* only when something first asks for a list, a search or a lookup. Opening
|
|
483
|
+
* does no session work; that first read waits for the catch-up, later reads
|
|
484
|
+
* find it done, and a write never starts it.
|
|
485
|
+
*/
|
|
486
|
+
readonly syncOnDemand?: boolean
|
|
480
487
|
}
|
|
481
488
|
|
|
482
489
|
export interface RebuildSqliteSessionIndexOptions extends SqliteSessionIndexOptions {
|
|
@@ -485,6 +492,8 @@ export interface RebuildSqliteSessionIndexOptions extends SqliteSessionIndexOpti
|
|
|
485
492
|
* index already in place (another process finished first) discards its own.
|
|
486
493
|
*/
|
|
487
494
|
readonly force?: boolean
|
|
495
|
+
/** Build the schema only and index no log; a later sync fills it. Opening on demand uses it. */
|
|
496
|
+
readonly empty?: boolean
|
|
488
497
|
}
|
|
489
498
|
|
|
490
499
|
/**
|
|
@@ -520,17 +529,52 @@ export class SqliteSessionIndex extends SessionIndexBase {
|
|
|
520
529
|
readonly #sink: IndexSink
|
|
521
530
|
readonly #statements = new Map<string, StatementSync>()
|
|
522
531
|
#open = true
|
|
523
|
-
/** The catch-up started by `syncInBackground`; reads wait on it. */
|
|
532
|
+
/** The catch-up started by `syncInBackground`, or on the first read under `syncOnDemand`; reads wait on it. */
|
|
524
533
|
#catchUp: Promise<void> | undefined
|
|
534
|
+
/** The home a first read catches up with, kept only while the catch-up has not started. */
|
|
535
|
+
#pendingHome: string | undefined
|
|
536
|
+
|
|
537
|
+
/** True while opening promised a catch-up that no read has started yet. */
|
|
538
|
+
get syncPending(): boolean {
|
|
539
|
+
return this.#pendingHome !== undefined
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
/** True while a catch-up is reading the logs. */
|
|
543
|
+
get syncing(): boolean {
|
|
544
|
+
return this.#catchUp !== undefined && !this.#caughtUp
|
|
545
|
+
}
|
|
546
|
+
#caughtUp = false
|
|
525
547
|
|
|
526
548
|
#startBackgroundSync(home: string): void {
|
|
527
|
-
this.#
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
549
|
+
this.#pendingHome = undefined
|
|
550
|
+
this.#catchUp = this.syncNow(home)
|
|
551
|
+
.catch(() => {
|
|
552
|
+
// A failed catch-up (the index closed, a log vanished mid-read) leaves the
|
|
553
|
+
// rows the last sync wrote; the next open syncs again.
|
|
554
|
+
})
|
|
555
|
+
.then(() => {
|
|
556
|
+
this.#caughtUp = true
|
|
557
|
+
})
|
|
531
558
|
}
|
|
532
559
|
|
|
533
560
|
protected override async settled(): Promise<void> {
|
|
561
|
+
if (this.#pendingHome !== undefined) this.#startBackgroundSync(this.#pendingHome)
|
|
562
|
+
await this.#catchUp
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
/**
|
|
566
|
+
* A read about one session before any catch-up has started: bring that session's
|
|
567
|
+
* rows current from its own log and leave the other logs unread. A session with
|
|
568
|
+
* no row yet has no known log, so that read waits for the whole catch-up.
|
|
569
|
+
*/
|
|
570
|
+
protected override async settledFor(sessionId: SessionId | undefined): Promise<void> {
|
|
571
|
+
if (this.#pendingHome === undefined || sessionId === undefined) return this.settled()
|
|
572
|
+
const row = this.readSession(sessionId)
|
|
573
|
+
if (row === undefined) return this.settled()
|
|
574
|
+
await this.refreshNow({ sessionId, slug: row.slug, logPath: row.logPath })
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
protected override async settledForWrite(): Promise<void> {
|
|
534
578
|
await this.#catchUp
|
|
535
579
|
}
|
|
536
580
|
|
|
@@ -740,7 +784,9 @@ export class SqliteSessionIndex extends SessionIndexBase {
|
|
|
740
784
|
try {
|
|
741
785
|
configure(db)
|
|
742
786
|
db.exec(`BEGIN IMMEDIATE; ${SCHEMA} COMMIT;`)
|
|
743
|
-
|
|
787
|
+
if (options.empty !== true) {
|
|
788
|
+
for (const log of await discoverSessionLogs(options.home)) await index.refresh(log)
|
|
789
|
+
}
|
|
744
790
|
} finally {
|
|
745
791
|
index.close()
|
|
746
792
|
}
|
|
@@ -764,7 +810,9 @@ export class SqliteSessionIndex extends SessionIndexBase {
|
|
|
764
810
|
if (indexVersion(options.path) !== SESSION_INDEX_VERSION) {
|
|
765
811
|
// Not forced: if another process renames a current index into place
|
|
766
812
|
// first, this one discards its own and opens that one.
|
|
767
|
-
await SqliteSessionIndex.rebuild(
|
|
813
|
+
await SqliteSessionIndex.rebuild(
|
|
814
|
+
options.syncOnDemand === true ? { ...options, empty: true } : options,
|
|
815
|
+
)
|
|
768
816
|
} else {
|
|
769
817
|
await sweepAbandonedRebuilds(options.path)
|
|
770
818
|
}
|
|
@@ -780,7 +828,8 @@ export class SqliteSessionIndex extends SessionIndexBase {
|
|
|
780
828
|
throw error
|
|
781
829
|
}
|
|
782
830
|
const index = new SqliteSessionIndex(db, options.path)
|
|
783
|
-
if (options.
|
|
831
|
+
if (options.syncOnDemand === true) index.#pendingHome = options.home
|
|
832
|
+
else if (options.syncInBackground === true) index.#startBackgroundSync(options.home)
|
|
784
833
|
else await index.sync(options.home)
|
|
785
834
|
return index
|
|
786
835
|
}
|
|
@@ -885,7 +934,7 @@ export class SqliteSessionIndex extends SessionIndexBase {
|
|
|
885
934
|
}
|
|
886
935
|
|
|
887
936
|
async listTurns(sessionId: SessionId): Promise<IndexedTurn[]> {
|
|
888
|
-
await this.
|
|
937
|
+
await this.settledFor(sessionId)
|
|
889
938
|
return this.#all(
|
|
890
939
|
'SELECT * FROM turns WHERE session_id = ? ORDER BY started_at, id',
|
|
891
940
|
sessionId,
|
|
@@ -893,7 +942,7 @@ export class SqliteSessionIndex extends SessionIndexBase {
|
|
|
893
942
|
}
|
|
894
943
|
|
|
895
944
|
async listChildren(sessionId: SessionId): Promise<ChildSessionSummary[]> {
|
|
896
|
-
await this.
|
|
945
|
+
await this.settledFor(sessionId)
|
|
897
946
|
return this.#all(
|
|
898
947
|
'SELECT * FROM children WHERE session_id = ? ORDER BY spawned_at, child_id',
|
|
899
948
|
sessionId,
|
|
@@ -906,7 +955,7 @@ export class SqliteSessionIndex extends SessionIndexBase {
|
|
|
906
955
|
async listPendingDecisions(
|
|
907
956
|
options: { sessionId?: SessionId } = {},
|
|
908
957
|
): Promise<IndexedPendingDecision[]> {
|
|
909
|
-
await this.
|
|
958
|
+
await this.settledFor(options.sessionId)
|
|
910
959
|
const rows =
|
|
911
960
|
options.sessionId === undefined
|
|
912
961
|
? this.#all('SELECT * FROM pending_decisions ORDER BY session_id, decision_id')
|
|
@@ -934,7 +983,7 @@ export class SqliteSessionIndex extends SessionIndexBase {
|
|
|
934
983
|
}
|
|
935
984
|
|
|
936
985
|
async listExternalRefs(sessionId: SessionId): Promise<ExternalRefTarget[]> {
|
|
937
|
-
await this.
|
|
986
|
+
await this.settledFor(sessionId)
|
|
938
987
|
return this.#all(
|
|
939
988
|
'SELECT * FROM external_refs WHERE session_id = ? ORDER BY protocol, kind, external_id',
|
|
940
989
|
sessionId,
|
|
@@ -942,7 +991,7 @@ export class SqliteSessionIndex extends SessionIndexBase {
|
|
|
942
991
|
}
|
|
943
992
|
|
|
944
993
|
async batches(options: { sessionId?: SessionId } = {}): Promise<IndexedBatch[]> {
|
|
945
|
-
await this.
|
|
994
|
+
await this.settledFor(options.sessionId)
|
|
946
995
|
const rows =
|
|
947
996
|
options.sessionId === undefined
|
|
948
997
|
? this.#all('SELECT * FROM batches ORDER BY session_id, batch_id')
|
|
@@ -954,7 +1003,7 @@ export class SqliteSessionIndex extends SessionIndexBase {
|
|
|
954
1003
|
}
|
|
955
1004
|
|
|
956
1005
|
async searchEvidence(options: EvidenceSearchOptions): Promise<EvidenceHit[]> {
|
|
957
|
-
await this.
|
|
1006
|
+
await this.settledFor(options.sessionId)
|
|
958
1007
|
const match = evidenceMatcher(options)
|
|
959
1008
|
const narrowing = ftsMatchExpression(options)
|
|
960
1009
|
const limit = options.limit ?? 100
|
package/src/tools/admit-facts.ts
CHANGED
|
@@ -44,6 +44,34 @@ function flag(value: unknown): true | undefined {
|
|
|
44
44
|
return value === true ? true : undefined
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
/** The person's own words are kept whole well past an ordinary field's bound. */
|
|
48
|
+
const MAX_ANSWER_TEXT = 20_000
|
|
49
|
+
|
|
50
|
+
function answerText(value: unknown): string | undefined {
|
|
51
|
+
return typeof value === 'string' && value.length <= MAX_ANSWER_TEXT ? value : undefined
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The person's own words, cut rather than dropped past the bound: a dropped
|
|
56
|
+
* field would leave an answered row with nothing after its arrow. The model
|
|
57
|
+
* already has the whole text in the tool result; this is what is drawn.
|
|
58
|
+
*/
|
|
59
|
+
function ownWords(value: unknown): string | undefined {
|
|
60
|
+
if (typeof value !== 'string') return undefined
|
|
61
|
+
return value.length <= MAX_ANSWER_TEXT ? value : `${value.slice(0, MAX_ANSWER_TEXT - 1)}…`
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function labels(value: unknown): readonly string[] | undefined {
|
|
65
|
+
if (!Array.isArray(value) || value.length > 50) return undefined
|
|
66
|
+
const out: string[] = []
|
|
67
|
+
for (const item of value) {
|
|
68
|
+
const label = answerText(item)
|
|
69
|
+
if (label === undefined) return undefined
|
|
70
|
+
out.push(label)
|
|
71
|
+
}
|
|
72
|
+
return out
|
|
73
|
+
}
|
|
74
|
+
|
|
47
75
|
function pick<T extends object>(entries: Record<string, unknown>): T {
|
|
48
76
|
const out: Record<string, unknown> = {}
|
|
49
77
|
for (const [key, value] of Object.entries(entries)) if (value !== undefined) out[key] = value
|
|
@@ -210,6 +238,42 @@ export function admitToolFacts(value: unknown): ToolFacts | undefined {
|
|
|
210
238
|
generatedImage: generated === undefined ? undefined : { prompt: generated },
|
|
211
239
|
})
|
|
212
240
|
}
|
|
241
|
+
case 'questions': {
|
|
242
|
+
const outcome =
|
|
243
|
+
value.outcome === 'discussed'
|
|
244
|
+
? 'discussed'
|
|
245
|
+
: value.outcome === 'answered'
|
|
246
|
+
? 'answered'
|
|
247
|
+
: undefined
|
|
248
|
+
if (outcome === undefined || !Array.isArray(value.questions)) return undefined
|
|
249
|
+
if (value.questions.length === 0 || value.questions.length > 8) return undefined
|
|
250
|
+
const questions: {
|
|
251
|
+
question: string
|
|
252
|
+
header?: string
|
|
253
|
+
options?: readonly string[]
|
|
254
|
+
picked?: readonly string[]
|
|
255
|
+
freeText?: string
|
|
256
|
+
answered: boolean
|
|
257
|
+
}[] = []
|
|
258
|
+
for (const entry of value.questions) {
|
|
259
|
+
if (!isRecord(entry)) return undefined
|
|
260
|
+
const question = answerText(entry.question)
|
|
261
|
+
if (question === undefined || typeof entry.answered !== 'boolean') return undefined
|
|
262
|
+
const header = answerText(entry.header)
|
|
263
|
+
const options = labels(entry.options)
|
|
264
|
+
const picked = labels(entry.picked)
|
|
265
|
+
const freeText = ownWords(entry.freeText)
|
|
266
|
+
questions.push({
|
|
267
|
+
question,
|
|
268
|
+
...(header === undefined ? {} : { header }),
|
|
269
|
+
...(options === undefined ? {} : { options }),
|
|
270
|
+
...(picked === undefined ? {} : { picked }),
|
|
271
|
+
...(freeText === undefined ? {} : { freeText }),
|
|
272
|
+
answered: entry.answered,
|
|
273
|
+
})
|
|
274
|
+
}
|
|
275
|
+
return { kind: 'questions', outcome, questions }
|
|
276
|
+
}
|
|
213
277
|
case 'failure': {
|
|
214
278
|
const reason = FAILURE_REASONS.find((candidate) => candidate === value.reason)
|
|
215
279
|
if (reason === undefined) return undefined
|
|
@@ -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),
|
|
@@ -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'],
|