@namzu/sdk 65.2.0 → 67.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 +161 -0
- package/dist/account/lock.d.ts +4 -12
- package/dist/account/lock.d.ts.map +1 -1
- package/dist/account/lock.js +5 -140
- package/dist/account/lock.js.map +1 -1
- package/dist/account/registry.d.ts.map +1 -1
- package/dist/account/registry.js +50 -6
- package/dist/account/registry.js.map +1 -1
- package/dist/account/types.d.ts +7 -5
- package/dist/account/types.d.ts.map +1 -1
- package/dist/account/types.js +6 -7
- package/dist/account/types.js.map +1 -1
- package/dist/authorization/dangerous-commands.d.ts +64 -0
- package/dist/authorization/dangerous-commands.d.ts.map +1 -0
- package/dist/authorization/dangerous-commands.js +479 -0
- package/dist/authorization/dangerous-commands.js.map +1 -0
- package/dist/authorization/gate.d.ts.map +1 -1
- package/dist/authorization/gate.js +19 -5
- package/dist/authorization/gate.js.map +1 -1
- package/dist/authorization/protected-paths.d.ts +11 -6
- package/dist/authorization/protected-paths.d.ts.map +1 -1
- package/dist/authorization/protected-paths.js +13 -8
- package/dist/authorization/protected-paths.js.map +1 -1
- package/dist/authorization/readonly-commands.d.ts +6 -1
- package/dist/authorization/readonly-commands.d.ts.map +1 -1
- package/dist/authorization/readonly-commands.js +35 -1
- package/dist/authorization/readonly-commands.js.map +1 -1
- package/dist/authorization/removal.d.ts +10 -0
- package/dist/authorization/removal.d.ts.map +1 -1
- package/dist/authorization/removal.js +7 -7
- package/dist/authorization/removal.js.map +1 -1
- package/dist/authorization/rules.d.ts +10 -0
- package/dist/authorization/rules.d.ts.map +1 -1
- package/dist/authorization/rules.js +60 -14
- package/dist/authorization/rules.js.map +1 -1
- package/dist/authorization/shell-lexer.d.ts +10 -0
- package/dist/authorization/shell-lexer.d.ts.map +1 -1
- package/dist/authorization/shell-lexer.js +15 -0
- package/dist/authorization/shell-lexer.js.map +1 -1
- package/dist/bridge/acp/permission.d.ts +5 -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 +8 -1
- package/dist/bridge/acp/server.d.ts.map +1 -1
- package/dist/bridge/acp/server.js +48 -6
- package/dist/bridge/acp/server.js.map +1 -1
- package/dist/compaction/context-breakdown.d.ts +25 -6
- package/dist/compaction/context-breakdown.d.ts.map +1 -1
- package/dist/compaction/context-breakdown.js +27 -7
- package/dist/compaction/context-breakdown.js.map +1 -1
- package/dist/compaction/dangling.d.ts.map +1 -1
- package/dist/compaction/dangling.js +2 -0
- package/dist/compaction/dangling.js.map +1 -1
- package/dist/compaction/extractor.d.ts +7 -1
- package/dist/compaction/extractor.d.ts.map +1 -1
- package/dist/compaction/extractor.js +8 -1
- package/dist/compaction/extractor.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/managers/structured.js +2 -2
- package/dist/compaction/managers/structured.js.map +1 -1
- package/dist/compaction/manual.d.ts.map +1 -1
- package/dist/compaction/manual.js +11 -6
- package/dist/compaction/manual.js.map +1 -1
- package/dist/compaction/model-summary.d.ts.map +1 -1
- package/dist/compaction/model-summary.js +7 -1
- package/dist/compaction/model-summary.js.map +1 -1
- package/dist/compaction/summary.d.ts +13 -2
- package/dist/compaction/summary.d.ts.map +1 -1
- package/dist/compaction/summary.js +46 -3
- package/dist/compaction/summary.js.map +1 -1
- package/dist/constants/tools/index.d.ts +18 -1
- package/dist/constants/tools/index.d.ts.map +1 -1
- package/dist/constants/tools/index.js +28 -16
- package/dist/constants/tools/index.js.map +1 -1
- package/dist/manager/session/turn-recorder.d.ts +6 -0
- package/dist/manager/session/turn-recorder.d.ts.map +1 -1
- package/dist/manager/session/turn-recorder.js +29 -1
- package/dist/manager/session/turn-recorder.js.map +1 -1
- package/dist/network/audit.d.ts +49 -0
- package/dist/network/audit.d.ts.map +1 -0
- package/dist/network/audit.js +84 -0
- package/dist/network/audit.js.map +1 -0
- package/dist/network/clock.d.ts +21 -0
- package/dist/network/clock.d.ts.map +1 -0
- package/dist/network/clock.js +51 -0
- package/dist/network/clock.js.map +1 -0
- package/dist/network/discovery-mdns.d.ts +120 -0
- package/dist/network/discovery-mdns.d.ts.map +1 -0
- package/dist/network/discovery-mdns.js +442 -0
- package/dist/network/discovery-mdns.js.map +1 -0
- package/dist/network/discovery.d.ts +63 -0
- package/dist/network/discovery.d.ts.map +1 -0
- package/dist/network/discovery.js +163 -0
- package/dist/network/discovery.js.map +1 -0
- package/dist/network/fingerprint.d.ts +73 -0
- package/dist/network/fingerprint.d.ts.map +1 -0
- package/dist/network/fingerprint.js +208 -0
- package/dist/network/fingerprint.js.map +1 -0
- package/dist/network/identity.d.ts +38 -0
- package/dist/network/identity.d.ts.map +1 -0
- package/dist/network/identity.js +71 -0
- package/dist/network/identity.js.map +1 -0
- package/dist/network/index.d.ts +39 -0
- package/dist/network/index.d.ts.map +1 -0
- package/dist/network/index.js +25 -0
- package/dist/network/index.js.map +1 -0
- package/dist/network/join.d.ts +69 -0
- package/dist/network/join.d.ts.map +1 -0
- package/dist/network/join.js +136 -0
- package/dist/network/join.js.map +1 -0
- package/dist/network/mail-policy.d.ts +97 -0
- package/dist/network/mail-policy.d.ts.map +1 -0
- package/dist/network/mail-policy.js +147 -0
- package/dist/network/mail-policy.js.map +1 -0
- package/dist/network/membership.d.ts +76 -0
- package/dist/network/membership.d.ts.map +1 -0
- package/dist/network/membership.js +225 -0
- package/dist/network/membership.js.map +1 -0
- package/dist/network/roster.d.ts +59 -0
- package/dist/network/roster.d.ts.map +1 -0
- package/dist/network/roster.js +120 -0
- package/dist/network/roster.js.map +1 -0
- package/dist/network/service.d.ts +303 -0
- package/dist/network/service.d.ts.map +1 -0
- package/dist/network/service.js +1891 -0
- package/dist/network/service.js.map +1 -0
- package/dist/network/store.d.ts +141 -0
- package/dist/network/store.d.ts.map +1 -0
- package/dist/network/store.js +198 -0
- package/dist/network/store.js.map +1 -0
- package/dist/network/transport.d.ts +96 -0
- package/dist/network/transport.d.ts.map +1 -0
- package/dist/network/transport.js +342 -0
- package/dist/network/transport.js.map +1 -0
- package/dist/network/wire.d.ts +345 -0
- package/dist/network/wire.d.ts.map +1 -0
- package/dist/network/wire.js +212 -0
- package/dist/network/wire.js.map +1 -0
- package/dist/network/x509.d.ts +28 -0
- package/dist/network/x509.d.ts.map +1 -0
- package/dist/network/x509.js +84 -0
- package/dist/network/x509.js.map +1 -0
- package/dist/pals/activity/causality.d.ts.map +1 -1
- package/dist/pals/activity/causality.js +14 -2
- package/dist/pals/activity/causality.js.map +1 -1
- package/dist/peers/endpoint.d.ts.map +1 -1
- package/dist/peers/endpoint.js +6 -0
- package/dist/peers/endpoint.js.map +1 -1
- package/dist/peers/envelope.d.ts +18 -0
- package/dist/peers/envelope.d.ts.map +1 -1
- package/dist/peers/envelope.js +68 -5
- package/dist/peers/envelope.js.map +1 -1
- package/dist/peers/index.d.ts +5 -4
- package/dist/peers/index.d.ts.map +1 -1
- package/dist/peers/index.js +3 -2
- package/dist/peers/index.js.map +1 -1
- package/dist/peers/mode-word.d.ts +10 -0
- package/dist/peers/mode-word.d.ts.map +1 -0
- package/dist/peers/mode-word.js +19 -0
- package/dist/peers/mode-word.js.map +1 -0
- package/dist/peers/protocol.d.ts +42 -0
- package/dist/peers/protocol.d.ts.map +1 -1
- package/dist/peers/protocol.js +22 -1
- package/dist/peers/protocol.js.map +1 -1
- package/dist/peers/record.d.ts +8 -0
- package/dist/peers/record.d.ts.map +1 -1
- package/dist/peers/record.js +5 -0
- package/dist/peers/record.js.map +1 -1
- package/dist/plugin/session-hook-env.d.ts.map +1 -1
- package/dist/plugin/session-hook-env.js +22 -2
- package/dist/plugin/session-hook-env.js.map +1 -1
- package/dist/plugin/shell-hook.d.ts +16 -2
- package/dist/plugin/shell-hook.d.ts.map +1 -1
- package/dist/plugin/shell-hook.js +183 -14
- package/dist/plugin/shell-hook.js.map +1 -1
- package/dist/prompt/coding-agent-doctrine.d.ts +4 -2
- package/dist/prompt/coding-agent-doctrine.d.ts.map +1 -1
- package/dist/prompt/coding-agent-doctrine.js +33 -38
- package/dist/prompt/coding-agent-doctrine.js.map +1 -1
- package/dist/public-runtime.d.ts +14 -6
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +22 -5
- package/dist/public-runtime.js.map +1 -1
- package/dist/public-tools.d.ts +3 -2
- package/dist/public-tools.d.ts.map +1 -1
- package/dist/public-tools.js +2 -2
- package/dist/public-tools.js.map +1 -1
- package/dist/public-types.d.ts +7 -2
- package/dist/public-types.d.ts.map +1 -1
- package/dist/runtime/jobs/registry.d.ts +29 -1
- package/dist/runtime/jobs/registry.d.ts.map +1 -1
- package/dist/runtime/jobs/registry.js +64 -0
- package/dist/runtime/jobs/registry.js.map +1 -1
- package/dist/runtime/query/auto-review/classifier.d.ts +30 -6
- package/dist/runtime/query/auto-review/classifier.d.ts.map +1 -1
- package/dist/runtime/query/auto-review/classifier.js +40 -12
- package/dist/runtime/query/auto-review/classifier.js.map +1 -1
- package/dist/runtime/query/auto-review/feedback.d.ts +37 -0
- package/dist/runtime/query/auto-review/feedback.d.ts.map +1 -0
- package/dist/runtime/query/auto-review/feedback.js +45 -0
- package/dist/runtime/query/auto-review/feedback.js.map +1 -0
- package/dist/runtime/query/auto-review/git-status.d.ts +59 -0
- package/dist/runtime/query/auto-review/git-status.d.ts.map +1 -0
- package/dist/runtime/query/auto-review/git-status.js +379 -0
- package/dist/runtime/query/auto-review/git-status.js.map +1 -0
- package/dist/runtime/query/auto-review/index.d.ts +3 -3
- package/dist/runtime/query/auto-review/index.d.ts.map +1 -1
- package/dist/runtime/query/auto-review/index.js +2 -2
- package/dist/runtime/query/auto-review/index.js.map +1 -1
- package/dist/runtime/query/auto-review/prompt.d.ts.map +1 -1
- package/dist/runtime/query/auto-review/prompt.js +6 -1
- package/dist/runtime/query/auto-review/prompt.js.map +1 -1
- package/dist/runtime/query/auto-review/transcript.d.ts +14 -1
- package/dist/runtime/query/auto-review/transcript.d.ts.map +1 -1
- package/dist/runtime/query/auto-review/transcript.js +48 -2
- package/dist/runtime/query/auto-review/transcript.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 +40 -3
- package/dist/runtime/query/executor/tool-call-admission.js.map +1 -1
- package/dist/runtime/query/executor.d.ts +32 -10
- package/dist/runtime/query/executor.d.ts.map +1 -1
- package/dist/runtime/query/executor.js +78 -17
- package/dist/runtime/query/executor.js.map +1 -1
- package/dist/runtime/query/index.d.ts +9 -0
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +54 -17
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/runtime/query/iteration/index.d.ts.map +1 -1
- package/dist/runtime/query/iteration/index.js +17 -3
- package/dist/runtime/query/iteration/index.js.map +1 -1
- package/dist/runtime/query/iteration/phases/compaction.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/compaction.js +5 -2
- package/dist/runtime/query/iteration/phases/compaction.js.map +1 -1
- package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/context.js +5 -0
- package/dist/runtime/query/iteration/phases/context.js.map +1 -1
- package/dist/runtime/query/iteration/phases/per-call-review.d.ts +1 -2
- package/dist/runtime/query/iteration/phases/per-call-review.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/per-call-review.js +2 -5
- package/dist/runtime/query/iteration/phases/per-call-review.js.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.js +6 -1
- package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
- package/dist/runtime/query/pasted-frames.d.ts +34 -0
- package/dist/runtime/query/pasted-frames.d.ts.map +1 -0
- package/dist/runtime/query/pasted-frames.js +108 -0
- package/dist/runtime/query/pasted-frames.js.map +1 -0
- package/dist/runtime/query/path-escalation.d.ts +6 -0
- package/dist/runtime/query/path-escalation.d.ts.map +1 -1
- package/dist/runtime/query/path-escalation.js +15 -3
- package/dist/runtime/query/path-escalation.js.map +1 -1
- package/dist/runtime/query/request-interrupted-turns.d.ts +20 -0
- package/dist/runtime/query/request-interrupted-turns.d.ts.map +1 -0
- package/dist/runtime/query/request-interrupted-turns.js +43 -0
- package/dist/runtime/query/request-interrupted-turns.js.map +1 -0
- package/dist/runtime/query/review-policy.d.ts +16 -6
- package/dist/runtime/query/review-policy.d.ts.map +1 -1
- package/dist/runtime/query/review-policy.js +111 -15
- package/dist/runtime/query/review-policy.js.map +1 -1
- package/dist/runtime/query/turn/outcome-ledger.d.ts +9 -0
- package/dist/runtime/query/turn/outcome-ledger.d.ts.map +1 -1
- package/dist/runtime/query/turn/outcome-ledger.js +94 -6
- package/dist/runtime/query/turn/outcome-ledger.js.map +1 -1
- package/dist/runtime/query/unanswered.d.ts +19 -0
- package/dist/runtime/query/unanswered.d.ts.map +1 -0
- package/dist/runtime/query/unanswered.js +25 -0
- package/dist/runtime/query/unanswered.js.map +1 -0
- package/dist/runtime/system-events.d.ts +4 -4
- package/dist/runtime/system-events.d.ts.map +1 -1
- package/dist/runtime/system-events.js +2 -0
- package/dist/runtime/system-events.js.map +1 -1
- package/dist/session/workspace/git-worktree.d.ts +8 -0
- package/dist/session/workspace/git-worktree.d.ts.map +1 -1
- package/dist/session/workspace/git-worktree.js +21 -3
- package/dist/session/workspace/git-worktree.js.map +1 -1
- package/dist/store/evidence/source-kind.d.ts +1 -1
- package/dist/store/evidence/source-kind.d.ts.map +1 -1
- package/dist/store/evidence/source-kind.js +1 -1
- package/dist/store/evidence/source-kind.js.map +1 -1
- package/dist/store/session-index/sqlite.d.ts.map +1 -1
- package/dist/store/session-index/sqlite.js +42 -3
- package/dist/store/session-index/sqlite.js.map +1 -1
- package/dist/store/session-log/disk.js +1 -1
- package/dist/store/session-log/disk.js.map +1 -1
- package/dist/store/session-log/lease.d.ts.map +1 -1
- package/dist/store/session-log/lease.js +3 -2
- package/dist/store/session-log/lease.js.map +1 -1
- package/dist/tools/admit-facts.d.ts.map +1 -1
- package/dist/tools/admit-facts.js +2 -0
- package/dist/tools/admit-facts.js.map +1 -1
- package/dist/tools/builtins/bash.d.ts +10 -2
- package/dist/tools/builtins/bash.d.ts.map +1 -1
- package/dist/tools/builtins/bash.js +56 -17
- package/dist/tools/builtins/bash.js.map +1 -1
- package/dist/tools/builtins/browser-local.d.ts +117 -0
- package/dist/tools/builtins/browser-local.d.ts.map +1 -0
- package/dist/tools/builtins/browser-local.js +437 -0
- package/dist/tools/builtins/browser-local.js.map +1 -0
- package/dist/tools/builtins/browser.d.ts +18 -1
- package/dist/tools/builtins/browser.d.ts.map +1 -1
- package/dist/tools/builtins/browser.js +98 -8
- package/dist/tools/builtins/browser.js.map +1 -1
- package/dist/tools/builtins/computer-use-window-id.d.ts +16 -0
- package/dist/tools/builtins/computer-use-window-id.d.ts.map +1 -0
- package/dist/tools/builtins/computer-use-window-id.js +52 -0
- package/dist/tools/builtins/computer-use-window-id.js.map +1 -0
- package/dist/tools/builtins/computer-use.d.ts +65 -7
- package/dist/tools/builtins/computer-use.d.ts.map +1 -1
- package/dist/tools/builtins/computer-use.js +384 -71
- package/dist/tools/builtins/computer-use.js.map +1 -1
- package/dist/tools/builtins/content-fingerprint.d.ts +6 -0
- package/dist/tools/builtins/content-fingerprint.d.ts.map +1 -1
- package/dist/tools/builtins/content-fingerprint.js +7 -1
- package/dist/tools/builtins/content-fingerprint.js.map +1 -1
- package/dist/tools/builtins/edit.d.ts.map +1 -1
- package/dist/tools/builtins/edit.js +89 -7
- package/dist/tools/builtins/edit.js.map +1 -1
- package/dist/tools/builtins/file-write-result.d.ts.map +1 -1
- package/dist/tools/builtins/file-write-result.js +2 -1
- package/dist/tools/builtins/file-write-result.js.map +1 -1
- package/dist/tools/builtins/grep.js +1 -1
- package/dist/tools/builtins/grep.js.map +1 -1
- package/dist/tools/builtins/job.d.ts.map +1 -1
- package/dist/tools/builtins/job.js +4 -2
- package/dist/tools/builtins/job.js.map +1 -1
- package/dist/tools/builtins/monitor.d.ts.map +1 -1
- package/dist/tools/builtins/monitor.js +6 -1
- package/dist/tools/builtins/monitor.js.map +1 -1
- package/dist/tools/builtins/search-tools.d.ts +12 -1
- package/dist/tools/builtins/search-tools.d.ts.map +1 -1
- package/dist/tools/builtins/search-tools.js +166 -20
- package/dist/tools/builtins/search-tools.js.map +1 -1
- package/dist/tools/builtins/shell-read-credit.d.ts +18 -6
- package/dist/tools/builtins/shell-read-credit.d.ts.map +1 -1
- package/dist/tools/builtins/shell-read-credit.js +95 -27
- package/dist/tools/builtins/shell-read-credit.js.map +1 -1
- package/dist/tools/builtins/wait-for-job.d.ts.map +1 -1
- package/dist/tools/builtins/wait-for-job.js +14 -3
- package/dist/tools/builtins/wait-for-job.js.map +1 -1
- package/dist/tools/builtins/web-guidance.d.ts +6 -0
- package/dist/tools/builtins/web-guidance.d.ts.map +1 -1
- package/dist/tools/builtins/web-guidance.js +6 -0
- package/dist/tools/builtins/web-guidance.js.map +1 -1
- package/dist/tools/builtins/web.d.ts.map +1 -1
- package/dist/tools/builtins/web.js +2 -1
- package/dist/tools/builtins/web.js.map +1 -1
- package/dist/tools/builtins/write-file.d.ts.map +1 -1
- package/dist/tools/builtins/write-file.js +32 -2
- package/dist/tools/builtins/write-file.js.map +1 -1
- package/dist/tools/command-shell.d.ts +1 -1
- package/dist/tools/command-shell.d.ts.map +1 -1
- package/dist/tools/command-shell.js +6 -8
- package/dist/tools/command-shell.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 +17 -1
- package/dist/tools/defineTool.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 +8 -6
- package/dist/tools/schedules/loop-tool.js.map +1 -1
- package/dist/tools/schedules/present.js +1 -1
- package/dist/tools/schedules/present.js.map +1 -1
- package/dist/tools/schedules/timer-tools.d.ts +36 -0
- package/dist/tools/schedules/timer-tools.d.ts.map +1 -0
- package/dist/tools/schedules/timer-tools.js +234 -0
- package/dist/tools/schedules/timer-tools.js.map +1 -0
- package/dist/tools/schedules/types.d.ts +68 -3
- package/dist/tools/schedules/types.d.ts.map +1 -1
- package/dist/tools/task/create.d.ts.map +1 -1
- package/dist/tools/task/create.js +2 -0
- package/dist/tools/task/create.js.map +1 -1
- package/dist/toolsets/manager.d.ts +49 -7
- package/dist/toolsets/manager.d.ts.map +1 -1
- package/dist/toolsets/manager.js +239 -40
- package/dist/toolsets/manager.js.map +1 -1
- package/dist/turn/evidence-query.d.ts +18 -1
- package/dist/turn/evidence-query.d.ts.map +1 -1
- package/dist/turn/evidence-query.js +177 -35
- package/dist/turn/evidence-query.js.map +1 -1
- package/dist/turn/evidence-recall.d.ts +8 -1
- package/dist/turn/evidence-recall.d.ts.map +1 -1
- package/dist/turn/evidence-recall.js +82 -22
- package/dist/turn/evidence-recall.js.map +1 -1
- package/dist/turn/history-shed.d.ts +15 -0
- package/dist/turn/history-shed.d.ts.map +1 -0
- package/dist/turn/history-shed.js +23 -0
- package/dist/turn/history-shed.js.map +1 -0
- package/dist/types/acp/index.d.ts +26 -0
- package/dist/types/acp/index.d.ts.map +1 -1
- package/dist/types/authorization/index.d.ts +9 -1
- package/dist/types/authorization/index.d.ts.map +1 -1
- package/dist/types/authorization/index.js +11 -2
- package/dist/types/authorization/index.js.map +1 -1
- package/dist/types/browser/index.d.ts +12 -0
- package/dist/types/browser/index.d.ts.map +1 -1
- package/dist/types/hitl/index.d.ts +10 -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 +56 -1
- package/dist/types/message/index.d.ts.map +1 -1
- package/dist/types/message/index.js +2 -1
- package/dist/types/message/index.js.map +1 -1
- package/dist/types/permission/index.d.ts +14 -0
- package/dist/types/permission/index.d.ts.map +1 -1
- package/dist/types/permission/index.js +14 -0
- package/dist/types/permission/index.js.map +1 -1
- package/dist/types/plugin/index.d.ts +148 -1
- package/dist/types/plugin/index.d.ts.map +1 -1
- package/dist/types/plugin/index.js +9 -0
- package/dist/types/plugin/index.js.map +1 -1
- package/dist/types/provider/index.d.ts +1 -0
- package/dist/types/provider/index.d.ts.map +1 -1
- package/dist/types/provider/interface.d.ts +12 -0
- package/dist/types/provider/interface.d.ts.map +1 -1
- package/dist/types/provider/limits.d.ts +33 -0
- package/dist/types/provider/limits.d.ts.map +1 -0
- package/dist/types/provider/limits.js +7 -0
- package/dist/types/provider/limits.js.map +1 -0
- package/dist/types/tool/index.d.ts +30 -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 +4 -0
- package/dist/types/tool/presentation.d.ts.map +1 -1
- package/dist/utils/file-lock.d.ts +88 -0
- package/dist/utils/file-lock.d.ts.map +1 -0
- package/dist/utils/file-lock.js +281 -0
- package/dist/utils/file-lock.js.map +1 -0
- package/dist/utils/state-backup.d.ts +87 -0
- package/dist/utils/state-backup.d.ts.map +1 -0
- package/dist/utils/state-backup.js +272 -0
- package/dist/utils/state-backup.js.map +1 -0
- package/dist/utils/temp-sweep.d.ts +66 -0
- package/dist/utils/temp-sweep.d.ts.map +1 -0
- package/dist/utils/temp-sweep.js +311 -0
- package/dist/utils/temp-sweep.js.map +1 -0
- package/dist/utils/temp.d.ts +14 -0
- package/dist/utils/temp.d.ts.map +1 -1
- package/dist/utils/temp.js +70 -2
- package/dist/utils/temp.js.map +1 -1
- package/package.json +1 -1
- package/src/account/lock.ts +13 -133
- package/src/account/registry.ts +75 -21
- package/src/account/types.ts +8 -9
- package/src/authorization/dangerous-commands.ts +542 -0
- package/src/authorization/gate.ts +19 -5
- package/src/authorization/protected-paths.ts +13 -8
- package/src/authorization/readonly-commands.ts +35 -1
- package/src/authorization/removal.ts +7 -7
- package/src/authorization/rules.ts +75 -15
- package/src/authorization/shell-lexer.ts +19 -0
- package/src/bridge/acp/permission.ts +2 -0
- package/src/bridge/acp/server.ts +66 -6
- package/src/compaction/context-breakdown.ts +53 -11
- package/src/compaction/dangling.ts +2 -0
- package/src/compaction/extractor.ts +9 -1
- package/src/compaction/index.ts +1 -0
- package/src/compaction/managers/structured.ts +2 -2
- package/src/compaction/manual.ts +11 -3
- package/src/compaction/model-summary.ts +8 -1
- package/src/compaction/summary.ts +54 -7
- package/src/constants/tools/index.ts +30 -16
- package/src/manager/session/turn-recorder.ts +37 -1
- package/src/network/audit.ts +113 -0
- package/src/network/clock.ts +62 -0
- package/src/network/discovery-mdns.ts +485 -0
- package/src/network/discovery.ts +210 -0
- package/src/network/fingerprint.ts +241 -0
- package/src/network/identity.ts +98 -0
- package/src/network/index.ts +134 -0
- package/src/network/join.ts +177 -0
- package/src/network/mail-policy.ts +199 -0
- package/src/network/membership.ts +290 -0
- package/src/network/roster.ts +165 -0
- package/src/network/service.ts +2304 -0
- package/src/network/store.ts +261 -0
- package/src/network/transport.ts +445 -0
- package/src/network/wire.ts +250 -0
- package/src/network/x509.ts +114 -0
- package/src/pals/activity/causality.ts +16 -2
- package/src/peers/endpoint.ts +6 -0
- package/src/peers/envelope.ts +82 -5
- package/src/peers/index.ts +10 -2
- package/src/peers/mode-word.ts +18 -0
- package/src/peers/protocol.ts +24 -1
- package/src/peers/record.ts +5 -0
- package/src/plugin/session-hook-env.ts +25 -2
- package/src/plugin/shell-hook.ts +208 -14
- package/src/prompt/coding-agent-doctrine.ts +33 -38
- package/src/public-runtime.ts +107 -1
- package/src/public-tools.ts +11 -0
- package/src/public-types.ts +67 -1
- package/src/runtime/jobs/registry.ts +93 -3
- package/src/runtime/query/auto-review/classifier.ts +76 -14
- package/src/runtime/query/auto-review/feedback.ts +50 -0
- package/src/runtime/query/auto-review/git-status.ts +437 -0
- package/src/runtime/query/auto-review/index.ts +7 -2
- package/src/runtime/query/auto-review/prompt.ts +6 -1
- package/src/runtime/query/auto-review/transcript.ts +67 -4
- package/src/runtime/query/executor/tool-call-admission.ts +49 -3
- package/src/runtime/query/executor.ts +104 -21
- package/src/runtime/query/index.ts +66 -17
- package/src/runtime/query/iteration/index.ts +24 -3
- package/src/runtime/query/iteration/phases/compaction.ts +4 -0
- package/src/runtime/query/iteration/phases/context.ts +5 -0
- package/src/runtime/query/iteration/phases/per-call-review.ts +8 -13
- package/src/runtime/query/iteration/phases/tool-review.ts +7 -1
- package/src/runtime/query/pasted-frames.ts +119 -0
- package/src/runtime/query/path-escalation.ts +27 -3
- package/src/runtime/query/request-interrupted-turns.ts +47 -0
- package/src/runtime/query/review-policy.ts +125 -22
- package/src/runtime/query/turn/outcome-ledger.ts +99 -6
- package/src/runtime/query/unanswered.ts +35 -0
- package/src/runtime/system-events.ts +2 -0
- package/src/session/workspace/git-worktree.ts +34 -3
- package/src/store/evidence/source-kind.ts +1 -1
- package/src/store/session-index/sqlite.ts +40 -3
- package/src/store/session-log/disk.ts +1 -1
- package/src/store/session-log/lease.ts +3 -2
- package/src/tools/admit-facts.ts +2 -0
- package/src/tools/builtins/bash.ts +62 -19
- package/src/tools/builtins/browser-local.ts +504 -0
- package/src/tools/builtins/browser.ts +121 -8
- package/src/tools/builtins/computer-use-window-id.ts +50 -0
- package/src/tools/builtins/computer-use.ts +460 -68
- package/src/tools/builtins/content-fingerprint.ts +8 -1
- package/src/tools/builtins/edit.ts +93 -7
- package/src/tools/builtins/file-write-result.ts +2 -1
- package/src/tools/builtins/grep.ts +1 -1
- package/src/tools/builtins/job.ts +4 -2
- package/src/tools/builtins/monitor.ts +6 -1
- package/src/tools/builtins/search-tools.ts +196 -21
- package/src/tools/builtins/shell-read-credit.ts +97 -33
- package/src/tools/builtins/wait-for-job.ts +13 -3
- package/src/tools/builtins/web-guidance.ts +6 -0
- package/src/tools/builtins/web.ts +2 -1
- package/src/tools/builtins/write-file.ts +31 -3
- package/src/tools/command-shell.ts +6 -8
- package/src/tools/defineTool.ts +20 -1
- package/src/tools/schedules/index.ts +11 -0
- package/src/tools/schedules/loop-tool.ts +10 -6
- package/src/tools/schedules/present.ts +1 -1
- package/src/tools/schedules/timer-tools.ts +258 -0
- package/src/tools/schedules/types.ts +72 -3
- package/src/tools/task/create.ts +2 -0
- package/src/toolsets/manager.ts +262 -46
- package/src/turn/evidence-query.ts +183 -42
- package/src/turn/evidence-recall.ts +96 -19
- package/src/turn/history-shed.ts +30 -0
- package/src/types/acp/index.ts +24 -0
- package/src/types/authorization/index.ts +20 -3
- package/src/types/browser/index.ts +9 -0
- package/src/types/hitl/index.ts +10 -0
- package/src/types/message/index.ts +65 -0
- package/src/types/permission/index.ts +18 -0
- package/src/types/plugin/index.ts +205 -26
- package/src/types/provider/index.ts +1 -0
- package/src/types/provider/interface.ts +13 -0
- package/src/types/provider/limits.ts +35 -0
- package/src/types/tool/index.ts +30 -2
- package/src/types/tool/presentation.ts +4 -0
- package/src/utils/file-lock.ts +328 -0
- package/src/utils/state-backup.ts +318 -0
- package/src/utils/temp-sweep.ts +327 -0
- package/src/utils/temp.ts +73 -2
|
@@ -44,6 +44,7 @@ import {
|
|
|
44
44
|
fitPng,
|
|
45
45
|
pngSize,
|
|
46
46
|
} from './computer-use-image.js'
|
|
47
|
+
import { coerceWindowId, windowKey } from './computer-use-window-id.js'
|
|
47
48
|
|
|
48
49
|
export {
|
|
49
50
|
HIGH_RES_SCREENSHOT_LIMITS,
|
|
@@ -188,8 +189,56 @@ export interface ComputerUseToolOptions {
|
|
|
188
189
|
* touching the host.
|
|
189
190
|
*/
|
|
190
191
|
readonly unavailableReason?: string
|
|
192
|
+
/**
|
|
193
|
+
* Told after each call that returned a screenshot: the picture the model
|
|
194
|
+
* received (made small), the application it shows, and where a click
|
|
195
|
+
* landed. For a host that shows a person what the model saw; it never
|
|
196
|
+
* changes what the model is given. A throw in it is ignored.
|
|
197
|
+
*/
|
|
198
|
+
readonly onObservation?: (observation: ComputerUseObservation) => void
|
|
199
|
+
/**
|
|
200
|
+
* Applications the tool never acts in, as the host's window list names them
|
|
201
|
+
* (case and a trailing `.exe` do not matter). A call that works in one is
|
|
202
|
+
* refused before it reaches the host: the window it names, a window
|
|
203
|
+
* screenshot's window, and for a click or key the window under the point or
|
|
204
|
+
* in front. A look at the whole display is not refused, since it is not
|
|
205
|
+
* aimed at one application. When the host cannot list windows, an action is
|
|
206
|
+
* refused outright while this list is not empty, because the tool cannot
|
|
207
|
+
* tell where it would land. Absent or empty: no application is off limits.
|
|
208
|
+
*/
|
|
209
|
+
readonly deniedApps?: readonly string[]
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** How an application name is compared: trimmed, lower case, without a trailing `.exe`. */
|
|
213
|
+
function deniedAppKey(app: string): string {
|
|
214
|
+
return app
|
|
215
|
+
.trim()
|
|
216
|
+
.toLowerCase()
|
|
217
|
+
.replace(/\.exe$/, '')
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/** What {@link ComputerUseToolOptions.onObservation} is told. */
|
|
221
|
+
export interface ComputerUseObservation {
|
|
222
|
+
/** The tool call this belongs to, when the runtime named it. */
|
|
223
|
+
readonly toolUseId?: string
|
|
224
|
+
/** The screenshot's id as the model knows it (`s3`). */
|
|
225
|
+
readonly frameId: string
|
|
226
|
+
/** What the model did that produced this picture, as the call row says it. */
|
|
227
|
+
readonly action: string
|
|
228
|
+
/** The application the call worked on, when it could be told. */
|
|
229
|
+
readonly app?: string
|
|
230
|
+
/** The picture, a PNG made small enough to keep a few of. */
|
|
231
|
+
readonly mimeType: 'image/png'
|
|
232
|
+
readonly data: string
|
|
233
|
+
readonly width: number
|
|
234
|
+
readonly height: number
|
|
235
|
+
/** Where a click landed, as fractions of the picture (0 to 1), when the call clicked. */
|
|
236
|
+
readonly point?: { readonly x: number; readonly y: number }
|
|
191
237
|
}
|
|
192
238
|
|
|
239
|
+
/** The longest edge, in pixels, of the picture {@link ComputerUseToolOptions.onObservation} gets. */
|
|
240
|
+
export const OBSERVATION_LONG_EDGE = 720
|
|
241
|
+
|
|
193
242
|
/**
|
|
194
243
|
* Why `provider` cannot drive `computer_use`, or undefined when it can.
|
|
195
244
|
*
|
|
@@ -279,6 +328,7 @@ const keySchema = z.object({
|
|
|
279
328
|
at: pointSchema.optional(),
|
|
280
329
|
delivery_mode: z.enum(['background', 'foreground']).optional(),
|
|
281
330
|
})
|
|
331
|
+
const windowIdSchema = z.preprocess(coerceWindowId, z.string().min(1))
|
|
282
332
|
const waitSchema = z.object({
|
|
283
333
|
type: z.literal('wait'),
|
|
284
334
|
ms: z.number().int().nonnegative(),
|
|
@@ -286,7 +336,7 @@ const waitSchema = z.object({
|
|
|
286
336
|
const listWindowsSchema = z.object({ type: z.literal('list_windows') })
|
|
287
337
|
const focusWindowSchema = z.object({
|
|
288
338
|
type: z.literal('focus_window'),
|
|
289
|
-
window_id:
|
|
339
|
+
window_id: windowIdSchema,
|
|
290
340
|
})
|
|
291
341
|
const UI_ACTIONS = [
|
|
292
342
|
'invoke',
|
|
@@ -300,7 +350,7 @@ const UI_ACTIONS = [
|
|
|
300
350
|
] as const satisfies readonly UiElementAction[]
|
|
301
351
|
const uiSnapshotSchema = z.object({
|
|
302
352
|
type: z.literal('ui_snapshot'),
|
|
303
|
-
window_id:
|
|
353
|
+
window_id: windowIdSchema.optional(),
|
|
304
354
|
/** A ref shown by an earlier ui_snapshot: read only that region or control. */
|
|
305
355
|
root: z.string().min(1).optional(),
|
|
306
356
|
/** With root: skip this many of the region's children (the next page of a long region). */
|
|
@@ -323,7 +373,7 @@ const waitForSchema = z.object({
|
|
|
323
373
|
match: z.string().min(1),
|
|
324
374
|
/** Narrows element_* to controls of this role, such as Button. */
|
|
325
375
|
role: z.string().min(1).optional(),
|
|
326
|
-
window_id:
|
|
376
|
+
window_id: windowIdSchema.optional(),
|
|
327
377
|
timeout_ms: z.number().int().positive().optional(),
|
|
328
378
|
})
|
|
329
379
|
const uiActSchema = z.object({
|
|
@@ -340,7 +390,7 @@ const uiDoSchema = z.object({
|
|
|
340
390
|
target: z.string().min(1).max(200),
|
|
341
391
|
action: z.enum(UI_ACTIONS),
|
|
342
392
|
value: z.string().optional(),
|
|
343
|
-
window_id:
|
|
393
|
+
window_id: windowIdSchema.optional(),
|
|
344
394
|
})
|
|
345
395
|
|
|
346
396
|
/** What a batch may carry: everything but the image-returning actions and another batch. */
|
|
@@ -359,12 +409,23 @@ const batchItemSchema = z.discriminatedUnion('type', [
|
|
|
359
409
|
uiDoSchema,
|
|
360
410
|
])
|
|
361
411
|
|
|
412
|
+
/** The actions that read a place or a window off the latest screenshot. */
|
|
413
|
+
const NEEDS_FRAME: ReadonlySet<string> = new Set([
|
|
414
|
+
'cursor_position',
|
|
415
|
+
'mouse_move',
|
|
416
|
+
'mouse_click',
|
|
417
|
+
'mouse_drag',
|
|
418
|
+
'scroll',
|
|
419
|
+
'type_text',
|
|
420
|
+
'key',
|
|
421
|
+
])
|
|
422
|
+
|
|
362
423
|
const withFrame = { screenshot_id: screenshotIdSchema }
|
|
363
424
|
|
|
364
425
|
const actionSchema = z.discriminatedUnion('type', [
|
|
365
426
|
z.object({
|
|
366
427
|
type: z.literal('screenshot'),
|
|
367
|
-
window_id:
|
|
428
|
+
window_id: windowIdSchema.optional(),
|
|
368
429
|
}),
|
|
369
430
|
z.object({ type: z.literal('zoom'), region: regionSchema, ...withFrame }),
|
|
370
431
|
cursorPositionSchema.extend(withFrame),
|
|
@@ -644,6 +705,10 @@ function buildDescription(
|
|
|
644
705
|
? `Offers the available computer controls on a ${caps.displayServer} host.`
|
|
645
706
|
: `Computer control is unavailable on this ${caps.displayServer} host; this tool reports the limitation.`
|
|
646
707
|
const lines = [intro, `Available actions: ${available.join('; ') || 'none'}.`]
|
|
708
|
+
if (available.length > 0)
|
|
709
|
+
lines.push(
|
|
710
|
+
'When the person asks you to use an application on the screen ("open the text editor and type …", "click …"), do it here, on the screen, so they watch it happen (start the program from the shell if it is not open, then work in its window with the actions below): a script that writes the file or runs the program is a different way of getting the result, and is fine only when the result is all they asked for. Say in your reply which way you did the work, and never say you typed or clicked in an application when you wrote a file or ran a command instead.',
|
|
711
|
+
)
|
|
647
712
|
if (unavailable.length > 0) {
|
|
648
713
|
lines.push(
|
|
649
714
|
caps.unavailableReason
|
|
@@ -1387,6 +1452,41 @@ export interface ComputerUseTool extends ToolDefinition<ActionInput> {
|
|
|
1387
1452
|
* @experimental Follows the UI-tree surface; see `ComputerUseCapabilities.uiTree`.
|
|
1388
1453
|
*/
|
|
1389
1454
|
describeUiRef(ref: string): string | undefined
|
|
1455
|
+
/**
|
|
1456
|
+
* The application a call works on, as far as it can be told before the
|
|
1457
|
+
* call runs: the window a window screenshot is bound to, or the window
|
|
1458
|
+
* under a click on the display. Undefined when it cannot be told.
|
|
1459
|
+
*/
|
|
1460
|
+
appOf(input: unknown): Promise<string | undefined>
|
|
1461
|
+
/**
|
|
1462
|
+
* Every application a call works on, in the order it reaches them: a batch
|
|
1463
|
+
* can act in more than one. Empty when it cannot be told.
|
|
1464
|
+
*/
|
|
1465
|
+
appsOf(input: unknown): Promise<string[]>
|
|
1466
|
+
/**
|
|
1467
|
+
* Why a call should be put to a person even where its application was
|
|
1468
|
+
* allowed: it closes, deletes, sends or submits. Undefined for an
|
|
1469
|
+
* ordinary action. A reading of the call's own words, not of the screen.
|
|
1470
|
+
*/
|
|
1471
|
+
consequence(input: unknown): string | undefined
|
|
1472
|
+
}
|
|
1473
|
+
|
|
1474
|
+
const CONSEQUENTIAL_KEYS =
|
|
1475
|
+
/(^|\+)(alt\+f4|ctrl\+q|cmd\+q|super\+q|ctrl\+w|ctrl\+shift\+delete|shift\+delete|ctrl\+enter|cmd\+enter|delete)$/i
|
|
1476
|
+
const CONSEQUENTIAL_WORDS =
|
|
1477
|
+
/(?<!\p{L})(delete|remove|erase|discard|don'?t save|do not save|close|quit|exit|send|submit|pay|purchase|buy|order|sign out|log ?out|empty|format|uninstall|kaydetme|sil|gönder|kapat|çık|çıkış|satın al|öde)(?!\p{L})/iu
|
|
1478
|
+
|
|
1479
|
+
/** An application as a person reads it: no `.exe`, and a lowercase process name starts with a capital. */
|
|
1480
|
+
function applicationName(name: string): string {
|
|
1481
|
+
const bare = name.trim().replace(/\.exe$/i, '')
|
|
1482
|
+
return bare && bare === bare.toLowerCase()
|
|
1483
|
+
? `${bare.charAt(0).toUpperCase()}${bare.slice(1)}`
|
|
1484
|
+
: bare
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1487
|
+
/** Words that make a control's name or an intent one a person should answer for. */
|
|
1488
|
+
function consequentialWords(text: string | undefined): boolean {
|
|
1489
|
+
return text !== undefined && CONSEQUENTIAL_WORDS.test(text)
|
|
1390
1490
|
}
|
|
1391
1491
|
|
|
1392
1492
|
/** Whether a call sends the screen to the provider (see `ToolDefinition.capturesScreen`). */
|
|
@@ -1521,7 +1621,7 @@ export function createComputerUseTool(
|
|
|
1521
1621
|
windowId: string | undefined,
|
|
1522
1622
|
action?: UiElementAction,
|
|
1523
1623
|
): ComputerUseAdvisorCandidate[] => {
|
|
1524
|
-
const shown = shownRefs.get(windowId
|
|
1624
|
+
const shown = shownRefs.get(windowKey(windowId))
|
|
1525
1625
|
const out: ComputerUseAdvisorCandidate[] = []
|
|
1526
1626
|
if (!shown) return out
|
|
1527
1627
|
for (const ref of shown) {
|
|
@@ -2056,11 +2156,12 @@ export function createComputerUseTool(
|
|
|
2056
2156
|
}
|
|
2057
2157
|
uiSnapshotWindowId = snapshot.windowId ?? requestedWindowId
|
|
2058
2158
|
{
|
|
2059
|
-
const key = uiSnapshotWindowId
|
|
2159
|
+
const key = windowKey(uiSnapshotWindowId)
|
|
2060
2160
|
const now = new Set(refs.keys())
|
|
2061
2161
|
shownRefs.set(key, snapshot.region ? new Set([...(shownRefs.get(key) ?? []), ...now]) : now)
|
|
2062
2162
|
}
|
|
2063
|
-
if (uiSnapshotWindowId !== undefined)
|
|
2163
|
+
if (uiSnapshotWindowId !== undefined)
|
|
2164
|
+
treeUsable.set(windowKey(uiSnapshotWindowId), refs.size > 0)
|
|
2064
2165
|
uiSnapshotFrame = frames.latest()
|
|
2065
2166
|
const window =
|
|
2066
2167
|
snapshot.windowId && /^[\w.:-]{1,64}$/.test(snapshot.windowId) ? snapshot.windowId : undefined
|
|
@@ -2208,8 +2309,8 @@ export function createComputerUseTool(
|
|
|
2208
2309
|
if (signal?.aborted) throw new StepFailure('cancelled')
|
|
2209
2310
|
try {
|
|
2210
2311
|
if (windowCondition) {
|
|
2211
|
-
const windows =
|
|
2212
|
-
callSignal,
|
|
2312
|
+
const windows = rememberWindows(
|
|
2313
|
+
await (host.listWindows as NonNullable<ComputerUseHost['listWindows']>)(callSignal),
|
|
2213
2314
|
)
|
|
2214
2315
|
const open = windows.some((window) => window.title.toLowerCase().includes(needle))
|
|
2215
2316
|
if (open === input.until.endsWith('appears')) {
|
|
@@ -2257,7 +2358,7 @@ export function createComputerUseTool(
|
|
|
2257
2358
|
/** Said once per window, after its first coordinate click: the tree is the surer way in. */
|
|
2258
2359
|
const coordinateNudge = (frame: ScreenshotFrame): string | undefined => {
|
|
2259
2360
|
if (!frame.window || !available.has('ui_snapshot')) return undefined
|
|
2260
|
-
const id = frame.window.window.id
|
|
2361
|
+
const id = windowKey(frame.window.window.id)
|
|
2261
2362
|
if (nudgedWindows.has(id)) return undefined
|
|
2262
2363
|
const usable = treeUsable.get(id)
|
|
2263
2364
|
if (usable === false) return undefined
|
|
@@ -2280,7 +2381,9 @@ export function createComputerUseTool(
|
|
|
2280
2381
|
if (!available.has('list_windows')) return
|
|
2281
2382
|
let windows: readonly WindowInfo[]
|
|
2282
2383
|
try {
|
|
2283
|
-
windows =
|
|
2384
|
+
windows = rememberWindows(
|
|
2385
|
+
await (host.listWindows as NonNullable<ComputerUseHost['listWindows']>)(callSignal),
|
|
2386
|
+
)
|
|
2284
2387
|
} catch (error) {
|
|
2285
2388
|
throw new StepFailure(
|
|
2286
2389
|
`the window in front could not be read, so nothing was typed: ${errorText(error)}`,
|
|
@@ -2296,7 +2399,9 @@ export function createComputerUseTool(
|
|
|
2296
2399
|
const listWindows = async (): Promise<string> => {
|
|
2297
2400
|
let windows: readonly WindowInfo[]
|
|
2298
2401
|
try {
|
|
2299
|
-
windows =
|
|
2402
|
+
windows = rememberWindows(
|
|
2403
|
+
await (host.listWindows as NonNullable<ComputerUseHost['listWindows']>)(callSignal),
|
|
2404
|
+
)
|
|
2300
2405
|
} catch (error) {
|
|
2301
2406
|
throw new StepFailure(errorText(error))
|
|
2302
2407
|
}
|
|
@@ -2517,6 +2622,18 @@ export function createComputerUseTool(
|
|
|
2517
2622
|
// the screenshot in step 5 should not arrive after steps 1–4 changed
|
|
2518
2623
|
// the desktop.
|
|
2519
2624
|
const planned: PlannedStep[] = []
|
|
2625
|
+
// An input that reads its place off a screenshot, when none was ever taken: it is not sent. The
|
|
2626
|
+
// tool takes the display screenshot and returns it, so the model chooses its target on a frame it
|
|
2627
|
+
// has seen. Actions before that input still run; it and everything after it do not.
|
|
2628
|
+
const blockedAt =
|
|
2629
|
+
frameId === undefined &&
|
|
2630
|
+
!frames.latest() &&
|
|
2631
|
+
available.has('screenshot') &&
|
|
2632
|
+
hostActionAvailable(caps, 'screenshot')
|
|
2633
|
+
? items.findIndex((item) => NEEDS_FRAME.has(item.type))
|
|
2634
|
+
: -1
|
|
2635
|
+
const unsent: readonly BatchItem[] = blockedAt >= 0 ? items.slice(blockedAt) : []
|
|
2636
|
+
const toPlan: readonly BatchItem[] = blockedAt >= 0 ? items.slice(0, blockedAt) : items
|
|
2520
2637
|
const actionFrame = frameId ? frames.get(frameId) : frames.latest()
|
|
2521
2638
|
const explicitDisplayFrame =
|
|
2522
2639
|
frameId !== undefined && actionFrame !== undefined && !actionFrame.window
|
|
@@ -2541,7 +2658,7 @@ export function createComputerUseTool(
|
|
|
2541
2658
|
let postWindowId =
|
|
2542
2659
|
actionFrame?.window?.window.id ??
|
|
2543
2660
|
(!hostActionAvailable(caps, 'screenshot') ? uiSnapshotWindowId : undefined)
|
|
2544
|
-
for (const [index, item] of
|
|
2661
|
+
for (const [index, item] of toPlan.entries()) {
|
|
2545
2662
|
try {
|
|
2546
2663
|
planned.push(plan(item, frameId))
|
|
2547
2664
|
} catch (error) {
|
|
@@ -2629,6 +2746,33 @@ export function createComputerUseTool(
|
|
|
2629
2746
|
}
|
|
2630
2747
|
for (const step of planned.slice(records.length))
|
|
2631
2748
|
records.push({ label: step.label, status: 'not run' })
|
|
2749
|
+
for (const item of unsent) records.push({ label: label(item), status: 'not run' })
|
|
2750
|
+
const total = planned.length + unsent.length
|
|
2751
|
+
|
|
2752
|
+
// The frame the unsent input needed, taken after the actions that did run.
|
|
2753
|
+
let framePrelude: string | undefined
|
|
2754
|
+
let frameShot: Capture | undefined
|
|
2755
|
+
if (unsent.length > 0 && !failure && !signal?.aborted) {
|
|
2756
|
+
try {
|
|
2757
|
+
if (changed) await settleAfterActions(host, undefined, settings.settleMs, signal)
|
|
2758
|
+
frameShot = await capture()
|
|
2759
|
+
const before = single
|
|
2760
|
+
? ''
|
|
2761
|
+
: planned.length === 0
|
|
2762
|
+
? ' Nothing in the batch ran.'
|
|
2763
|
+
: ` Actions 1-${planned.length} ran; action ${planned.length + 1}${unsent.length > 1 ? ' and the ones after it' : ''} did not.`
|
|
2764
|
+
framePrelude = `No screenshot had been taken yet, so nothing was clicked or typed: the ${single ? 'action' : 'input'} was not sent.${before} The display screenshot follows (${frameShot.frame.id}, ${frameShot.frame.imageWidth}x${frameShot.frame.imageHeight}); choose the target on it and send the action again.`
|
|
2765
|
+
} catch (error) {
|
|
2766
|
+
const why = signal?.aborted ? 'cancelled' : errorText(error)
|
|
2767
|
+
const reason = `no screenshot has been taken yet, so nothing was clicked or typed, and the display screenshot could not be taken: ${why}`
|
|
2768
|
+
failure = { index: planned.length, error: reason }
|
|
2769
|
+
records[planned.length] = {
|
|
2770
|
+
label: records[planned.length]?.label ?? '',
|
|
2771
|
+
status: 'failed',
|
|
2772
|
+
error: reason,
|
|
2773
|
+
}
|
|
2774
|
+
}
|
|
2775
|
+
}
|
|
2632
2776
|
|
|
2633
2777
|
// The screen after the batch: after anything that may have changed it,
|
|
2634
2778
|
// and after a wait, whose whole point is to look again.
|
|
@@ -2637,8 +2781,9 @@ export function createComputerUseTool(
|
|
|
2637
2781
|
available.has('screenshot') &&
|
|
2638
2782
|
(hostActionAvailable(caps, 'screenshot') || postWindowId !== undefined) &&
|
|
2639
2783
|
(changed || planned.some((step) => step.item.type === 'wait')) &&
|
|
2784
|
+
unsent.length === 0 &&
|
|
2640
2785
|
!signal?.aborted
|
|
2641
|
-
let shot: Capture | undefined
|
|
2786
|
+
let shot: Capture | undefined = frameShot
|
|
2642
2787
|
let shotError: string | undefined
|
|
2643
2788
|
if (looks) {
|
|
2644
2789
|
try {
|
|
@@ -2660,13 +2805,18 @@ export function createComputerUseTool(
|
|
|
2660
2805
|
return `${n}${record.label}: not run`
|
|
2661
2806
|
}
|
|
2662
2807
|
}
|
|
2663
|
-
const header =
|
|
2664
|
-
? []
|
|
2665
|
-
|
|
2666
|
-
? [
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2808
|
+
const header = [
|
|
2809
|
+
...(framePrelude ? [framePrelude] : []),
|
|
2810
|
+
...(single
|
|
2811
|
+
? []
|
|
2812
|
+
: failure
|
|
2813
|
+
? [
|
|
2814
|
+
`Batch stopped at action ${failure.index + 1} of ${total}; ${total - failure.index - 1} not run.`,
|
|
2815
|
+
]
|
|
2816
|
+
: unsent.length > 0
|
|
2817
|
+
? []
|
|
2818
|
+
: [`Batch: all ${total} actions done.`]),
|
|
2819
|
+
]
|
|
2670
2820
|
const stepLines = records.map(summary)
|
|
2671
2821
|
const shotLines = shot
|
|
2672
2822
|
? [describeFrame(shot.frame)]
|
|
@@ -2728,7 +2878,7 @@ export function createComputerUseTool(
|
|
|
2728
2878
|
? failure.unknown.message
|
|
2729
2879
|
: single
|
|
2730
2880
|
? `computer_use failed: ${failure.error}`
|
|
2731
|
-
: `Batch stopped at action ${failure.index + 1} of ${
|
|
2881
|
+
: `Batch stopped at action ${failure.index + 1} of ${total} (${planned[failure.index]?.label}): ${failure.error}`
|
|
2732
2882
|
return result
|
|
2733
2883
|
}
|
|
2734
2884
|
|
|
@@ -2740,6 +2890,267 @@ export function createComputerUseTool(
|
|
|
2740
2890
|
const capturesScreen = (input: ActionInput): boolean =>
|
|
2741
2891
|
observes && capturesScreenInput(input, settings.screenshotAfterActions)
|
|
2742
2892
|
|
|
2893
|
+
/** The newest window list this tool read, so naming an application costs the host no call of its own. */
|
|
2894
|
+
let knownWindows: readonly WindowInfo[] = []
|
|
2895
|
+
function rememberWindows(listed: readonly WindowInfo[]): readonly WindowInfo[] {
|
|
2896
|
+
knownWindows = listed
|
|
2897
|
+
return listed
|
|
2898
|
+
}
|
|
2899
|
+
|
|
2900
|
+
/**
|
|
2901
|
+
* The application a call works on, from what is already known: the window a call names, the
|
|
2902
|
+
* window a window screenshot is bound to, and on a display screenshot the window under the
|
|
2903
|
+
* click or the one in front, as the newest list this tool read has them.
|
|
2904
|
+
*/
|
|
2905
|
+
/** A tree read or a wait on a control or text with no window named: it reads a window the tool already bound, or else the one in front. */
|
|
2906
|
+
const readsFrontWindow = (item: Record<string, unknown>): boolean =>
|
|
2907
|
+
item.type === 'ui_snapshot' ||
|
|
2908
|
+
(item.type === 'wait_for' && !String(item.until ?? '').startsWith('window_'))
|
|
2909
|
+
/** The window such a call is bound to by a ref or an earlier tree read, when it names none. */
|
|
2910
|
+
const boundWindowId = (item: Record<string, unknown>): string | undefined => {
|
|
2911
|
+
if (typeof item.window_id === 'string') return item.window_id
|
|
2912
|
+
if (item.type === 'ui_snapshot' && typeof item.root === 'string')
|
|
2913
|
+
return uiRefs.get(item.root)?.windowId
|
|
2914
|
+
if (item.type === 'wait_for' && readsFrontWindow(item)) return uiSnapshotWindowId
|
|
2915
|
+
return undefined
|
|
2916
|
+
}
|
|
2917
|
+
const appsKnown = (input: unknown, namedOnly = false): string[] => {
|
|
2918
|
+
const found: string[] = []
|
|
2919
|
+
const add = (app: string | undefined): void => {
|
|
2920
|
+
if (app && !found.includes(app)) found.push(app)
|
|
2921
|
+
}
|
|
2922
|
+
const items = batchActions(input) ?? [input]
|
|
2923
|
+
for (const item of items) {
|
|
2924
|
+
if (!isRecord(item)) continue
|
|
2925
|
+
if (typeof item.window_id === 'string') {
|
|
2926
|
+
add(knownWindows.find((window) => window.id === item.window_id)?.app)
|
|
2927
|
+
continue
|
|
2928
|
+
}
|
|
2929
|
+
const bound = boundWindowId(item)
|
|
2930
|
+
if (bound !== undefined) {
|
|
2931
|
+
add(knownWindows.find((window) => window.id === bound)?.app)
|
|
2932
|
+
continue
|
|
2933
|
+
}
|
|
2934
|
+
if (readsFrontWindow(item)) {
|
|
2935
|
+
add(knownWindows.find((window) => window.focused && !window.minimized)?.app)
|
|
2936
|
+
continue
|
|
2937
|
+
}
|
|
2938
|
+
const shotId =
|
|
2939
|
+
typeof item.screenshot_id === 'string'
|
|
2940
|
+
? item.screenshot_id
|
|
2941
|
+
: isRecord(input) && typeof input.screenshot_id === 'string'
|
|
2942
|
+
? input.screenshot_id
|
|
2943
|
+
: undefined
|
|
2944
|
+
const frame = shotId ? frames.get(shotId) : frames.latest()
|
|
2945
|
+
if (frame?.window) {
|
|
2946
|
+
add(frame.window.window.app)
|
|
2947
|
+
continue
|
|
2948
|
+
}
|
|
2949
|
+
// A look at the whole display names no application.
|
|
2950
|
+
if (namedOnly) continue
|
|
2951
|
+
const listed = knownWindows.filter((window) => !window.minimized)
|
|
2952
|
+
const at = isRecord(item.at) ? item.at : undefined
|
|
2953
|
+
if (frame && at && typeof at.x === 'number' && typeof at.y === 'number') {
|
|
2954
|
+
const point = toDisplayPoint(frame, { x: at.x, y: at.y })
|
|
2955
|
+
const x = frame.display.x + point.x
|
|
2956
|
+
const y = frame.display.y + point.y
|
|
2957
|
+
const hit = listed.filter(
|
|
2958
|
+
(window) =>
|
|
2959
|
+
x >= window.bounds.x &&
|
|
2960
|
+
y >= window.bounds.y &&
|
|
2961
|
+
x < window.bounds.x + window.bounds.width &&
|
|
2962
|
+
y < window.bounds.y + window.bounds.height,
|
|
2963
|
+
)
|
|
2964
|
+
const best = hit.find((window) => window.focused) ?? hit[0]
|
|
2965
|
+
if (best) {
|
|
2966
|
+
add(best.app)
|
|
2967
|
+
continue
|
|
2968
|
+
}
|
|
2969
|
+
}
|
|
2970
|
+
add(listed.find((window) => window.focused)?.app)
|
|
2971
|
+
}
|
|
2972
|
+
return found
|
|
2973
|
+
}
|
|
2974
|
+
/** The first application a call works on; see {@link appsKnown} for every one. */
|
|
2975
|
+
const appKnown = (input: unknown): string | undefined => appsKnown(input)[0]
|
|
2976
|
+
|
|
2977
|
+
/**
|
|
2978
|
+
* The application a call works on, before it runs. It reads the windows afresh when the host can
|
|
2979
|
+
* list them, so a review screen names the application as it is now.
|
|
2980
|
+
*/
|
|
2981
|
+
const appsOf = async (input: unknown): Promise<string[]> => {
|
|
2982
|
+
if (typeof host.listWindows === 'function') {
|
|
2983
|
+
try {
|
|
2984
|
+
rememberWindows(await host.listWindows(callSignal))
|
|
2985
|
+
} catch {
|
|
2986
|
+
/* The application is a nicety; a host that cannot list windows says nothing. */
|
|
2987
|
+
}
|
|
2988
|
+
}
|
|
2989
|
+
return appsKnown(input)
|
|
2990
|
+
}
|
|
2991
|
+
const appOf = async (input: unknown): Promise<string | undefined> => (await appsOf(input))[0]
|
|
2992
|
+
|
|
2993
|
+
/** Why one call must be answered for even in an allowed application; see {@link ComputerUseTool.consequence}. */
|
|
2994
|
+
const consequence = (input: unknown): string | undefined => {
|
|
2995
|
+
const items = batchActions(input) ?? [input]
|
|
2996
|
+
for (const item of items) {
|
|
2997
|
+
if (!isRecord(item)) continue
|
|
2998
|
+
if (
|
|
2999
|
+
item.type === 'key' &&
|
|
3000
|
+
typeof item.keys === 'string' &&
|
|
3001
|
+
CONSEQUENTIAL_KEYS.test(item.keys.trim())
|
|
3002
|
+
)
|
|
3003
|
+
return `presses ${item.keys}`
|
|
3004
|
+
if (item.type === 'ui_act' || item.type === 'ui_do') {
|
|
3005
|
+
const named =
|
|
3006
|
+
typeof item.ref === 'string'
|
|
3007
|
+
? describeUiRef(item.ref)
|
|
3008
|
+
: typeof item.target === 'string'
|
|
3009
|
+
? item.target
|
|
3010
|
+
: undefined
|
|
3011
|
+
const intent = typeof item.intent === 'string' ? item.intent : undefined
|
|
3012
|
+
if (consequentialWords(named) || consequentialWords(intent))
|
|
3013
|
+
return `acts on ${named ?? intent}`
|
|
3014
|
+
}
|
|
3015
|
+
}
|
|
3016
|
+
return undefined
|
|
3017
|
+
}
|
|
3018
|
+
|
|
3019
|
+
// The applications this conversation's calls have worked on, so the first use of each is listed.
|
|
3020
|
+
const appsUsed = new Set<string>()
|
|
3021
|
+
|
|
3022
|
+
/** What the person gets of the picture the model received: small, with where a click landed. */
|
|
3023
|
+
const observe = async (
|
|
3024
|
+
input: ActionInput,
|
|
3025
|
+
before: ScreenshotFrame | undefined,
|
|
3026
|
+
result: ToolResult,
|
|
3027
|
+
toolUseId: string | undefined,
|
|
3028
|
+
app: string | undefined,
|
|
3029
|
+
): Promise<void> => {
|
|
3030
|
+
if (!options.onObservation) return
|
|
3031
|
+
try {
|
|
3032
|
+
const data = result.data as { screenshot?: { id?: string } } | undefined
|
|
3033
|
+
const image = Array.isArray(result.content)
|
|
3034
|
+
? result.content.find((block) => block.type === 'image')
|
|
3035
|
+
: undefined
|
|
3036
|
+
const frameId = data?.screenshot?.id
|
|
3037
|
+
if (!image || image.type !== 'image' || typeof frameId !== 'string') return
|
|
3038
|
+
const small = await fitPng(Buffer.from(image.data, 'base64'), {
|
|
3039
|
+
maxLongEdge: OBSERVATION_LONG_EDGE,
|
|
3040
|
+
maxTiles: 600,
|
|
3041
|
+
})
|
|
3042
|
+
const items = batchActions(input) ?? [input]
|
|
3043
|
+
const click = [...items]
|
|
3044
|
+
.reverse()
|
|
3045
|
+
.find((item) => isRecord(item) && item.type === 'mouse_click' && isRecord(item.at))
|
|
3046
|
+
const at = isRecord(click) && isRecord(click.at) ? click.at : undefined
|
|
3047
|
+
const point =
|
|
3048
|
+
before && at && typeof at.x === 'number' && typeof at.y === 'number'
|
|
3049
|
+
? {
|
|
3050
|
+
x: Math.min(1, Math.max(0, at.x / Math.max(1, before.imageWidth))),
|
|
3051
|
+
y: Math.min(1, Math.max(0, at.y / Math.max(1, before.imageHeight))),
|
|
3052
|
+
}
|
|
3053
|
+
: undefined
|
|
3054
|
+
options.onObservation({
|
|
3055
|
+
...(toolUseId ? { toolUseId } : {}),
|
|
3056
|
+
frameId,
|
|
3057
|
+
action: label(input),
|
|
3058
|
+
...(app ? { app } : {}),
|
|
3059
|
+
mimeType: 'image/png',
|
|
3060
|
+
data: small.data.toString('base64'),
|
|
3061
|
+
width: small.width,
|
|
3062
|
+
height: small.height,
|
|
3063
|
+
...(point ? { point } : {}),
|
|
3064
|
+
})
|
|
3065
|
+
} catch {
|
|
3066
|
+
/* What the person is shown never changes what the model gets. */
|
|
3067
|
+
}
|
|
3068
|
+
}
|
|
3069
|
+
|
|
3070
|
+
const deniedKeys = new Set(
|
|
3071
|
+
(options.deniedApps ?? []).map(deniedAppKey).filter((key) => key !== ''),
|
|
3072
|
+
)
|
|
3073
|
+
/**
|
|
3074
|
+
* Why this call may not run because of the denied-application list, or undefined. Checked
|
|
3075
|
+
* before the host is touched, so no look, click or key reaches a window of a listed application.
|
|
3076
|
+
*/
|
|
3077
|
+
const deniedAppRefusal = async (
|
|
3078
|
+
input: ActionInput,
|
|
3079
|
+
context: ToolContext,
|
|
3080
|
+
): Promise<string | undefined> => {
|
|
3081
|
+
if (deniedKeys.size === 0) return undefined
|
|
3082
|
+
const readOnly = isReadOnlyInput(input)
|
|
3083
|
+
let refreshFailed = false
|
|
3084
|
+
if (typeof host.listWindows === 'function') {
|
|
3085
|
+
try {
|
|
3086
|
+
rememberWindows(await host.listWindows(context.abortSignal))
|
|
3087
|
+
} catch (error) {
|
|
3088
|
+
refreshFailed = true
|
|
3089
|
+
if (!readOnly)
|
|
3090
|
+
return `computer_use could not read which application this would act in (${errorText(error)}), and some applications are off limits, so nothing was done.`
|
|
3091
|
+
}
|
|
3092
|
+
} else if (!readOnly) {
|
|
3093
|
+
return 'computer_use cannot tell which application this would act in on this computer, and some applications are off limits, so nothing was done.'
|
|
3094
|
+
}
|
|
3095
|
+
// A window the list cannot place may belong to a listed application: refuse it.
|
|
3096
|
+
const stale = refreshFailed
|
|
3097
|
+
for (const item of batchActions(input) ?? [input]) {
|
|
3098
|
+
if (!isRecord(item)) continue
|
|
3099
|
+
const id = boundWindowId(item)
|
|
3100
|
+
const placeable = id === undefined || knownWindows.some((window) => window.id === id)
|
|
3101
|
+
if (!placeable || (stale && (id !== undefined || readsFrontWindow(item))))
|
|
3102
|
+
return 'computer_use cannot tell which application that window belongs to, and some applications are off limits, so nothing was done.'
|
|
3103
|
+
}
|
|
3104
|
+
const app = appsKnown(input, readOnly).find((name) => deniedKeys.has(deniedAppKey(name)))
|
|
3105
|
+
if (app === undefined) return undefined
|
|
3106
|
+
return `computer_use does not act in ${applicationName(app)}: the person put it off limits. Nothing was done. Use another application, or tell the person you need it and let them change the list.`
|
|
3107
|
+
}
|
|
3108
|
+
|
|
3109
|
+
const runAction = async (input: ActionInput, context: ToolContext): Promise<ToolResult> => {
|
|
3110
|
+
const denied = refusal(input.type)
|
|
3111
|
+
if (denied) return { success: false, output: '', error: denied }
|
|
3112
|
+
// The host keeps per-turn state (an Escape stop, refused permissions); it
|
|
3113
|
+
// is told which turn this is and released when the turn is cut short.
|
|
3114
|
+
host.beginTurn?.(context.turnId)
|
|
3115
|
+
callSignal = context.abortSignal
|
|
3116
|
+
if (host.endTurn) {
|
|
3117
|
+
const release = () => void Promise.resolve(host.endTurn?.()).catch(() => undefined)
|
|
3118
|
+
if (context.abortSignal.aborted) release()
|
|
3119
|
+
else
|
|
3120
|
+
context.abortSignal.addEventListener('abort', release, {
|
|
3121
|
+
once: true,
|
|
3122
|
+
})
|
|
3123
|
+
}
|
|
3124
|
+
try {
|
|
3125
|
+
switch (input.type) {
|
|
3126
|
+
case 'screenshot':
|
|
3127
|
+
return screenshotResult(await capture(input.window_id))
|
|
3128
|
+
case 'zoom':
|
|
3129
|
+
return await zoom(input)
|
|
3130
|
+
case 'ui_snapshot':
|
|
3131
|
+
return await uiSnapshot(input)
|
|
3132
|
+
case 'wait_for':
|
|
3133
|
+
return await waitFor(input, context)
|
|
3134
|
+
case 'batch':
|
|
3135
|
+
return await runSteps(input.actions, input.screenshot_id, context, false)
|
|
3136
|
+
default: {
|
|
3137
|
+
const { screenshot_id: frameId, ...item } = input
|
|
3138
|
+
return await runSteps([item as BatchItem], frameId, context, true)
|
|
3139
|
+
}
|
|
3140
|
+
}
|
|
3141
|
+
} catch (error) {
|
|
3142
|
+
if (error instanceof StepFailure)
|
|
3143
|
+
return {
|
|
3144
|
+
success: false,
|
|
3145
|
+
output: '',
|
|
3146
|
+
error: `computer_use failed: ${error.message}`,
|
|
3147
|
+
}
|
|
3148
|
+
throw error
|
|
3149
|
+
} finally {
|
|
3150
|
+
callSignal = undefined
|
|
3151
|
+
}
|
|
3152
|
+
}
|
|
3153
|
+
|
|
2743
3154
|
const tool = defineTool({
|
|
2744
3155
|
name: COMPUTER_USE_TOOL_NAME,
|
|
2745
3156
|
description: buildDescription(host, caps, settings, options.advisor),
|
|
@@ -2761,55 +3172,36 @@ export function createComputerUseTool(
|
|
|
2761
3172
|
// without its input (the CLI passes `{}`). An action that only reports
|
|
2762
3173
|
// "done" — and the screenshot that followed it, which is for the model —
|
|
2763
3174
|
// adds nothing to the call row; observations, batches and failures do.
|
|
2764
|
-
presentResult: (_input, result) =>
|
|
2765
|
-
|
|
3175
|
+
presentResult: (_input, result) => {
|
|
3176
|
+
// The first call to work on an application says so, so a person reading the
|
|
3177
|
+
// conversation can see which applications this conversation has used.
|
|
3178
|
+
const first = isRecord(result.data) ? result.data.firstUseOf : undefined
|
|
3179
|
+
if (result.success && typeof first === 'string')
|
|
3180
|
+
return {
|
|
3181
|
+
kind: 'generic',
|
|
3182
|
+
label: `Using ${applicationName(first)}`,
|
|
3183
|
+
presentation: 'activity',
|
|
3184
|
+
}
|
|
3185
|
+
return result.success && ACKNOWLEDGEMENT.test(result.output)
|
|
2766
3186
|
? { kind: 'generic', label: result.output, visibility: 'hidden' }
|
|
2767
|
-
: undefined
|
|
3187
|
+
: undefined
|
|
3188
|
+
},
|
|
2768
3189
|
|
|
2769
3190
|
async execute(input, context): Promise<ToolResult> {
|
|
2770
|
-
const
|
|
2771
|
-
if (
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
host.
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
context.abortSignal.addEventListener('abort', release, {
|
|
2781
|
-
once: true,
|
|
2782
|
-
})
|
|
2783
|
-
}
|
|
2784
|
-
try {
|
|
2785
|
-
switch (input.type) {
|
|
2786
|
-
case 'screenshot':
|
|
2787
|
-
return screenshotResult(await capture(input.window_id))
|
|
2788
|
-
case 'zoom':
|
|
2789
|
-
return await zoom(input)
|
|
2790
|
-
case 'ui_snapshot':
|
|
2791
|
-
return await uiSnapshot(input)
|
|
2792
|
-
case 'wait_for':
|
|
2793
|
-
return await waitFor(input, context)
|
|
2794
|
-
case 'batch':
|
|
2795
|
-
return await runSteps(input.actions, input.screenshot_id, context, false)
|
|
2796
|
-
default: {
|
|
2797
|
-
const { screenshot_id: frameId, ...item } = input
|
|
2798
|
-
return await runSteps([item as BatchItem], frameId, context, true)
|
|
2799
|
-
}
|
|
2800
|
-
}
|
|
2801
|
-
} catch (error) {
|
|
2802
|
-
if (error instanceof StepFailure)
|
|
2803
|
-
return {
|
|
2804
|
-
success: false,
|
|
2805
|
-
output: '',
|
|
2806
|
-
error: `computer_use failed: ${error.message}`,
|
|
2807
|
-
}
|
|
2808
|
-
throw error
|
|
2809
|
-
} finally {
|
|
2810
|
-
callSignal = undefined
|
|
3191
|
+
const keptOut = await deniedAppRefusal(input, context)
|
|
3192
|
+
if (keptOut) return { success: false, output: '', error: keptOut }
|
|
3193
|
+
const shotId = 'screenshot_id' in input ? input.screenshot_id : undefined
|
|
3194
|
+
const before = shotId ? frames.get(shotId) : frames.latest()
|
|
3195
|
+
// Only what is already known: acting must not cost the host a call it would not make.
|
|
3196
|
+
const app = appKnown(input)
|
|
3197
|
+
const result = await runAction(input, context)
|
|
3198
|
+
if (app && result.success !== false && !appsUsed.has(app) && !isReadOnlyInput(input)) {
|
|
3199
|
+
appsUsed.add(app)
|
|
3200
|
+
result.data = { ...(isRecord(result.data) ? result.data : {}), firstUseOf: app }
|
|
2811
3201
|
}
|
|
3202
|
+
await observe(input, before, result, context.toolUseId, app)
|
|
3203
|
+
return result
|
|
2812
3204
|
},
|
|
2813
3205
|
})
|
|
2814
|
-
return Object.assign(tool, { describeUiRef })
|
|
3206
|
+
return Object.assign(tool, { describeUiRef, appOf, appsOf, consequence })
|
|
2815
3207
|
}
|