rookery-agent 0.1.0 → 0.3.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/README.md +467 -367
- package/docs/migration.md +88 -88
- package/docs/updates.md +112 -0
- package/package.json +13 -3
- package/packages/cli/dist/commands/config.js +2 -2
- package/packages/cli/dist/commands/doctor.d.ts.map +1 -1
- package/packages/cli/dist/commands/doctor.js +13 -9
- package/packages/cli/dist/commands/doctor.js.map +1 -1
- package/packages/cli/dist/commands/memory.js +1 -1
- package/packages/cli/dist/commands/org.d.ts +2 -2
- package/packages/cli/dist/commands/org.d.ts.map +1 -1
- package/packages/cli/dist/commands/org.js +19 -17
- package/packages/cli/dist/commands/org.js.map +1 -1
- package/packages/cli/dist/commands/serve.js +1 -1
- package/packages/cli/dist/commands/serve.js.map +1 -1
- package/packages/cli/dist/commands/shared.d.ts.map +1 -1
- package/packages/cli/dist/commands/shared.js +2 -1
- package/packages/cli/dist/commands/shared.js.map +1 -1
- package/packages/cli/dist/commands/tasks.d.ts.map +1 -1
- package/packages/cli/dist/commands/tasks.js +25 -11
- package/packages/cli/dist/commands/tasks.js.map +1 -1
- package/packages/cli/dist/commands/tools.js +1 -1
- package/packages/cli/dist/commands/tools.js.map +1 -1
- package/packages/cli/dist/index.js +13 -13
- package/packages/cli/dist/index.js.map +1 -1
- package/packages/cli/dist/repl.d.ts +12 -0
- package/packages/cli/dist/repl.d.ts.map +1 -1
- package/packages/cli/dist/repl.js +170 -16
- package/packages/cli/dist/repl.js.map +1 -1
- package/packages/cli/dist/tui/App.d.ts +7 -3
- package/packages/cli/dist/tui/App.d.ts.map +1 -1
- package/packages/cli/dist/tui/App.js +182 -16
- package/packages/cli/dist/tui/App.js.map +1 -1
- package/packages/cli/dist/tui/commands.d.ts +7 -0
- package/packages/cli/dist/tui/commands.d.ts.map +1 -1
- package/packages/cli/dist/tui/commands.js +70 -8
- package/packages/cli/dist/tui/commands.js.map +1 -1
- package/packages/cli/dist/tui/components/AssignmentsView.js +4 -4
- package/packages/cli/dist/tui/components/AssignmentsView.js.map +1 -1
- package/packages/cli/dist/tui/components/Banner.d.ts +11 -2
- package/packages/cli/dist/tui/components/Banner.d.ts.map +1 -1
- package/packages/cli/dist/tui/components/Banner.js +7 -10
- package/packages/cli/dist/tui/components/Banner.js.map +1 -1
- package/packages/cli/dist/tui/components/CodeBlock.js +2 -2
- package/packages/cli/dist/tui/components/CodeBlock.js.map +1 -1
- package/packages/cli/dist/tui/components/InputBox.d.ts.map +1 -1
- package/packages/cli/dist/tui/components/InputBox.js +4 -4
- package/packages/cli/dist/tui/components/InputBox.js.map +1 -1
- package/packages/cli/dist/tui/components/Logo.d.ts +56 -0
- package/packages/cli/dist/tui/components/Logo.d.ts.map +1 -0
- package/packages/cli/dist/tui/components/Logo.js +50 -0
- package/packages/cli/dist/tui/components/Logo.js.map +1 -0
- package/packages/cli/dist/tui/components/Markdown.js +8 -8
- package/packages/cli/dist/tui/components/Markdown.js.map +1 -1
- package/packages/cli/dist/tui/components/Message.d.ts +1 -1
- package/packages/cli/dist/tui/components/Message.d.ts.map +1 -1
- package/packages/cli/dist/tui/components/Message.js +5 -4
- package/packages/cli/dist/tui/components/Message.js.map +1 -1
- package/packages/cli/dist/tui/components/QuestionView.d.ts +29 -0
- package/packages/cli/dist/tui/components/QuestionView.d.ts.map +1 -0
- package/packages/cli/dist/tui/components/QuestionView.js +53 -0
- package/packages/cli/dist/tui/components/QuestionView.js.map +1 -0
- package/packages/cli/dist/tui/components/SlashPalette.d.ts +5 -2
- package/packages/cli/dist/tui/components/SlashPalette.d.ts.map +1 -1
- package/packages/cli/dist/tui/components/SlashPalette.js +2 -2
- package/packages/cli/dist/tui/components/SlashPalette.js.map +1 -1
- package/packages/cli/dist/tui/components/StatusLine.d.ts +0 -2
- package/packages/cli/dist/tui/components/StatusLine.d.ts.map +1 -1
- package/packages/cli/dist/tui/components/StatusLine.js +8 -5
- package/packages/cli/dist/tui/components/StatusLine.js.map +1 -1
- package/packages/cli/dist/tui/components/ToolGroup.js +2 -2
- package/packages/cli/dist/tui/components/ToolGroup.js.map +1 -1
- package/packages/cli/dist/tui/components/WatchView.d.ts +21 -0
- package/packages/cli/dist/tui/components/WatchView.d.ts.map +1 -0
- package/packages/cli/dist/tui/components/WatchView.js +36 -0
- package/packages/cli/dist/tui/components/WatchView.js.map +1 -0
- package/packages/cli/dist/tui/history.d.ts +20 -0
- package/packages/cli/dist/tui/history.d.ts.map +1 -0
- package/packages/cli/dist/tui/history.js +105 -0
- package/packages/cli/dist/tui/history.js.map +1 -0
- package/packages/cli/dist/tui/hooks/useSlash.d.ts.map +1 -1
- package/packages/cli/dist/tui/hooks/useSlash.js +3 -2
- package/packages/cli/dist/tui/hooks/useSlash.js.map +1 -1
- package/packages/cli/dist/tui/hooks/useTurn.d.ts +58 -1
- package/packages/cli/dist/tui/hooks/useTurn.d.ts.map +1 -1
- package/packages/cli/dist/tui/hooks/useTurn.js +214 -36
- package/packages/cli/dist/tui/hooks/useTurn.js.map +1 -1
- package/packages/cli/dist/tui/hooks/useWatch.d.ts +52 -0
- package/packages/cli/dist/tui/hooks/useWatch.d.ts.map +1 -0
- package/packages/cli/dist/tui/hooks/useWatch.js +145 -0
- package/packages/cli/dist/tui/hooks/useWatch.js.map +1 -0
- package/packages/cli/dist/tui/inkTheme.d.ts +19 -0
- package/packages/cli/dist/tui/inkTheme.d.ts.map +1 -0
- package/packages/cli/dist/tui/inkTheme.js +81 -0
- package/packages/cli/dist/tui/inkTheme.js.map +1 -0
- package/packages/cli/dist/tui/theme.d.ts +39 -29
- package/packages/cli/dist/tui/theme.d.ts.map +1 -1
- package/packages/cli/dist/tui/theme.js +35 -25
- package/packages/cli/dist/tui/theme.js.map +1 -1
- package/packages/cli/dist/tui/types.d.ts +56 -3
- package/packages/cli/dist/tui/types.d.ts.map +1 -1
- package/packages/cli/dist/tui/types.js +85 -0
- package/packages/cli/dist/tui/types.js.map +1 -1
- package/packages/cli/dist/ui/modelNames.d.ts +51 -0
- package/packages/cli/dist/ui/modelNames.d.ts.map +1 -0
- package/packages/cli/dist/ui/modelNames.js +134 -0
- package/packages/cli/dist/ui/modelNames.js.map +1 -0
- package/packages/cli/dist/ui/render.d.ts.map +1 -1
- package/packages/cli/dist/ui/render.js +17 -8
- package/packages/cli/dist/ui/render.js.map +1 -1
- package/packages/cli/dist/ui/speech.js +5 -0
- package/packages/cli/dist/ui/speech.js.map +1 -1
- package/packages/cli/dist/ui/theme.d.ts +33 -9
- package/packages/cli/dist/ui/theme.d.ts.map +1 -1
- package/packages/cli/dist/ui/theme.js +33 -9
- package/packages/cli/dist/ui/theme.js.map +1 -1
- package/packages/cli/package.json +1 -1
- package/packages/core/dist/agents/persona.d.ts.map +1 -1
- package/packages/core/dist/agents/persona.js +5 -2
- package/packages/core/dist/agents/persona.js.map +1 -1
- package/packages/core/dist/computer/accessibility.d.ts +78 -0
- package/packages/core/dist/computer/accessibility.d.ts.map +1 -0
- package/packages/core/dist/computer/accessibility.js +270 -0
- package/packages/core/dist/computer/accessibility.js.map +1 -0
- package/packages/core/dist/computer/assemblies.d.ts +17 -0
- package/packages/core/dist/computer/assemblies.d.ts.map +1 -0
- package/packages/core/dist/computer/assemblies.js +55 -0
- package/packages/core/dist/computer/assemblies.js.map +1 -0
- package/packages/core/dist/computer/browser-init.d.ts +9 -0
- package/packages/core/dist/computer/browser-init.d.ts.map +1 -0
- package/packages/core/dist/computer/browser-init.js +133 -0
- package/packages/core/dist/computer/browser-init.js.map +1 -0
- package/packages/core/dist/computer/cursor.d.ts +30 -0
- package/packages/core/dist/computer/cursor.d.ts.map +1 -0
- package/packages/core/dist/computer/cursor.js +30 -0
- package/packages/core/dist/computer/cursor.js.map +1 -0
- package/packages/core/dist/computer/mcp-server.js +524 -82
- package/packages/core/dist/computer/mcp-server.js.map +1 -1
- package/packages/core/dist/computer/powershell.d.ts +4 -0
- package/packages/core/dist/computer/powershell.d.ts.map +1 -1
- package/packages/core/dist/computer/powershell.js +471 -81
- package/packages/core/dist/computer/powershell.js.map +1 -1
- package/packages/core/dist/computer/screen-text.d.ts +82 -0
- package/packages/core/dist/computer/screen-text.d.ts.map +1 -0
- package/packages/core/dist/computer/screen-text.js +243 -0
- package/packages/core/dist/computer/screen-text.js.map +1 -0
- package/packages/core/dist/computer/sketch.d.ts +66 -0
- package/packages/core/dist/computer/sketch.d.ts.map +1 -0
- package/packages/core/dist/computer/sketch.js +540 -0
- package/packages/core/dist/computer/sketch.js.map +1 -0
- package/packages/core/dist/computer/tools.d.ts +8 -8
- package/packages/core/dist/computer/tools.d.ts.map +1 -1
- package/packages/core/dist/computer/tools.js +186 -31
- package/packages/core/dist/computer/tools.js.map +1 -1
- package/packages/core/dist/computer/validation.d.ts +555 -0
- package/packages/core/dist/computer/validation.d.ts.map +1 -0
- package/packages/core/dist/computer/validation.js +111 -0
- package/packages/core/dist/computer/validation.js.map +1 -0
- package/packages/core/dist/computer/windows-cursor.d.ts +14 -0
- package/packages/core/dist/computer/windows-cursor.d.ts.map +1 -0
- package/packages/core/dist/computer/windows-cursor.js +713 -0
- package/packages/core/dist/computer/windows-cursor.js.map +1 -0
- package/packages/core/dist/config.d.ts +34 -1
- package/packages/core/dist/config.d.ts.map +1 -1
- package/packages/core/dist/config.js +362 -11
- package/packages/core/dist/config.js.map +1 -1
- package/packages/core/dist/cron/scheduler.d.ts +59 -6
- package/packages/core/dist/cron/scheduler.d.ts.map +1 -1
- package/packages/core/dist/cron/scheduler.js +295 -27
- package/packages/core/dist/cron/scheduler.js.map +1 -1
- package/packages/core/dist/cron/store.d.ts +19 -1
- package/packages/core/dist/cron/store.d.ts.map +1 -1
- package/packages/core/dist/cron/store.js +36 -8
- package/packages/core/dist/cron/store.js.map +1 -1
- package/packages/core/dist/external/claude-code.d.ts +4 -0
- package/packages/core/dist/external/claude-code.d.ts.map +1 -0
- package/packages/core/dist/external/claude-code.js +111 -0
- package/packages/core/dist/external/claude-code.js.map +1 -0
- package/packages/core/dist/external/discovery.d.ts +33 -0
- package/packages/core/dist/external/discovery.d.ts.map +1 -0
- package/packages/core/dist/external/discovery.js +144 -0
- package/packages/core/dist/external/discovery.js.map +1 -0
- package/packages/core/dist/external/homes.d.ts +26 -0
- package/packages/core/dist/external/homes.d.ts.map +1 -0
- package/packages/core/dist/external/homes.js +49 -0
- package/packages/core/dist/external/homes.js.map +1 -0
- package/packages/core/dist/external/shared.d.ts +201 -0
- package/packages/core/dist/external/shared.d.ts.map +1 -0
- package/packages/core/dist/external/shared.js +308 -0
- package/packages/core/dist/external/shared.js.map +1 -0
- package/packages/core/dist/gateway/policy.d.ts +117 -2
- package/packages/core/dist/gateway/policy.d.ts.map +1 -1
- package/packages/core/dist/gateway/policy.js +286 -6
- package/packages/core/dist/gateway/policy.js.map +1 -1
- package/packages/core/dist/index.d.ts +38 -12
- package/packages/core/dist/index.d.ts.map +1 -1
- package/packages/core/dist/index.js +66 -12
- package/packages/core/dist/index.js.map +1 -1
- package/packages/core/dist/memory/db.d.ts +1 -1
- package/packages/core/dist/memory/db.d.ts.map +1 -1
- package/packages/core/dist/memory/db.js +878 -1
- package/packages/core/dist/memory/db.js.map +1 -1
- package/packages/core/dist/memory/dream/admission.d.ts +124 -0
- package/packages/core/dist/memory/dream/admission.d.ts.map +1 -0
- package/packages/core/dist/memory/dream/admission.js +116 -0
- package/packages/core/dist/memory/dream/admission.js.map +1 -0
- package/packages/core/dist/memory/dream/candidate.d.ts +152 -0
- package/packages/core/dist/memory/dream/candidate.d.ts.map +1 -0
- package/packages/core/dist/memory/dream/candidate.js +547 -0
- package/packages/core/dist/memory/dream/candidate.js.map +1 -0
- package/packages/core/dist/memory/dream/evaluate.d.ts +394 -0
- package/packages/core/dist/memory/dream/evaluate.d.ts.map +1 -0
- package/packages/core/dist/memory/dream/evaluate.js +1032 -0
- package/packages/core/dist/memory/dream/evaluate.js.map +1 -0
- package/packages/core/dist/memory/dream/frame.d.ts +61 -0
- package/packages/core/dist/memory/dream/frame.d.ts.map +1 -0
- package/packages/core/dist/memory/dream/frame.js +292 -0
- package/packages/core/dist/memory/dream/frame.js.map +1 -0
- package/packages/core/dist/memory/dream/label.d.ts +370 -0
- package/packages/core/dist/memory/dream/label.d.ts.map +1 -0
- package/packages/core/dist/memory/dream/label.js +439 -0
- package/packages/core/dist/memory/dream/label.js.map +1 -0
- package/packages/core/dist/memory/dream/measure.d.ts +114 -0
- package/packages/core/dist/memory/dream/measure.d.ts.map +1 -0
- package/packages/core/dist/memory/dream/measure.js +205 -0
- package/packages/core/dist/memory/dream/measure.js.map +1 -0
- package/packages/core/dist/memory/dream/policy.d.ts +21 -0
- package/packages/core/dist/memory/dream/policy.d.ts.map +1 -0
- package/packages/core/dist/memory/dream/policy.js +157 -0
- package/packages/core/dist/memory/dream/policy.js.map +1 -0
- package/packages/core/dist/memory/dream/probe.d.ts +202 -0
- package/packages/core/dist/memory/dream/probe.d.ts.map +1 -0
- package/packages/core/dist/memory/dream/probe.js +671 -0
- package/packages/core/dist/memory/dream/probe.js.map +1 -0
- package/packages/core/dist/memory/dream/promote.d.ts +312 -0
- package/packages/core/dist/memory/dream/promote.d.ts.map +1 -0
- package/packages/core/dist/memory/dream/promote.js +528 -0
- package/packages/core/dist/memory/dream/promote.js.map +1 -0
- package/packages/core/dist/memory/dream/score.d.ts +103 -0
- package/packages/core/dist/memory/dream/score.d.ts.map +1 -0
- package/packages/core/dist/memory/dream/score.js +334 -0
- package/packages/core/dist/memory/dream/score.js.map +1 -0
- package/packages/core/dist/memory/dream/slots.d.ts +193 -0
- package/packages/core/dist/memory/dream/slots.d.ts.map +1 -0
- package/packages/core/dist/memory/dream/slots.js +0 -0
- package/packages/core/dist/memory/dream/slots.js.map +1 -0
- package/packages/core/dist/memory/dream/trajectory.d.ts +262 -0
- package/packages/core/dist/memory/dream/trajectory.d.ts.map +1 -0
- package/packages/core/dist/memory/dream/trajectory.js +366 -0
- package/packages/core/dist/memory/dream/trajectory.js.map +1 -0
- package/packages/core/dist/memory/extractor.d.ts +7 -0
- package/packages/core/dist/memory/extractor.d.ts.map +1 -1
- package/packages/core/dist/memory/extractor.js +35 -12
- package/packages/core/dist/memory/extractor.js.map +1 -1
- package/packages/core/dist/memory/gate.d.ts +43 -7
- package/packages/core/dist/memory/gate.d.ts.map +1 -1
- package/packages/core/dist/memory/gate.js +91 -4
- package/packages/core/dist/memory/gate.js.map +1 -1
- package/packages/core/dist/memory/recall.d.ts +57 -0
- package/packages/core/dist/memory/recall.d.ts.map +1 -1
- package/packages/core/dist/memory/recall.js +60 -123
- package/packages/core/dist/memory/recall.js.map +1 -1
- package/packages/core/dist/memory/sleep.d.ts +131 -4
- package/packages/core/dist/memory/sleep.d.ts.map +1 -1
- package/packages/core/dist/memory/sleep.js +2384 -65
- package/packages/core/dist/memory/sleep.js.map +1 -1
- package/packages/core/dist/memory/store.d.ts +564 -10
- package/packages/core/dist/memory/store.d.ts.map +1 -1
- package/packages/core/dist/memory/store.js +1673 -102
- package/packages/core/dist/memory/store.js.map +1 -1
- package/packages/core/dist/org/controller.d.ts +268 -4
- package/packages/core/dist/org/controller.d.ts.map +1 -1
- package/packages/core/dist/org/controller.js +2298 -248
- package/packages/core/dist/org/controller.js.map +1 -1
- package/packages/core/dist/org/ponytail.d.ts +1 -1
- package/packages/core/dist/org/ponytail.js +1 -1
- package/packages/core/dist/org/project-mcp.d.ts +3 -3
- package/packages/core/dist/org/prompts.d.ts +44 -30
- package/packages/core/dist/org/prompts.d.ts.map +1 -1
- package/packages/core/dist/org/prompts.js +209 -92
- package/packages/core/dist/org/prompts.js.map +1 -1
- package/packages/core/dist/org/questions.d.ts +104 -0
- package/packages/core/dist/org/questions.d.ts.map +1 -0
- package/packages/core/dist/org/questions.js +136 -0
- package/packages/core/dist/org/questions.js.map +1 -0
- package/packages/core/dist/org/review.d.ts +100 -0
- package/packages/core/dist/org/review.d.ts.map +1 -0
- package/packages/core/dist/org/review.js +256 -0
- package/packages/core/dist/org/review.js.map +1 -0
- package/packages/core/dist/org/store.d.ts +311 -2
- package/packages/core/dist/org/store.d.ts.map +1 -1
- package/packages/core/dist/org/store.js +981 -13
- package/packages/core/dist/org/store.js.map +1 -1
- package/packages/core/dist/org/tools.d.ts +33 -3
- package/packages/core/dist/org/tools.d.ts.map +1 -1
- package/packages/core/dist/org/tools.js +380 -67
- package/packages/core/dist/org/tools.js.map +1 -1
- package/packages/core/dist/providers/catalogue.d.ts +1 -1
- package/packages/core/dist/providers/catalogue.d.ts.map +1 -1
- package/packages/core/dist/providers/catalogue.js +2 -2
- package/packages/core/dist/providers/catalogue.js.map +1 -1
- package/packages/core/dist/providers/claude-code.d.ts +19 -3
- package/packages/core/dist/providers/claude-code.d.ts.map +1 -1
- package/packages/core/dist/providers/claude-code.js +501 -40
- package/packages/core/dist/providers/claude-code.js.map +1 -1
- package/packages/core/dist/providers/claude-tui.d.ts +288 -0
- package/packages/core/dist/providers/claude-tui.d.ts.map +1 -0
- package/packages/core/dist/providers/claude-tui.js +1118 -0
- package/packages/core/dist/providers/claude-tui.js.map +1 -0
- package/packages/core/dist/providers/codex-auth.d.ts +15 -0
- package/packages/core/dist/providers/codex-auth.d.ts.map +1 -0
- package/packages/core/dist/providers/codex-auth.js +127 -0
- package/packages/core/dist/providers/codex-auth.js.map +1 -0
- package/packages/core/dist/providers/codex-bridge.d.ts +58 -0
- package/packages/core/dist/providers/codex-bridge.d.ts.map +1 -0
- package/packages/core/dist/providers/codex-bridge.js +375 -0
- package/packages/core/dist/providers/codex-bridge.js.map +1 -0
- package/packages/core/dist/providers/codex-translate.d.ts +75 -0
- package/packages/core/dist/providers/codex-translate.d.ts.map +1 -0
- package/packages/core/dist/providers/codex-translate.js +383 -0
- package/packages/core/dist/providers/codex-translate.js.map +1 -0
- package/packages/core/dist/providers/model-gateway.d.ts +56 -0
- package/packages/core/dist/providers/model-gateway.d.ts.map +1 -0
- package/packages/core/dist/providers/model-gateway.js +119 -0
- package/packages/core/dist/providers/model-gateway.js.map +1 -0
- package/packages/core/dist/providers/process.d.ts +3 -1
- package/packages/core/dist/providers/process.d.ts.map +1 -1
- package/packages/core/dist/providers/process.js +3 -3
- package/packages/core/dist/providers/process.js.map +1 -1
- package/packages/core/dist/providers/profiles.d.ts +11 -0
- package/packages/core/dist/providers/profiles.d.ts.map +1 -0
- package/packages/core/dist/providers/profiles.js +28 -0
- package/packages/core/dist/providers/profiles.js.map +1 -0
- package/packages/core/dist/providers/provider-catalog.d.ts +72 -0
- package/packages/core/dist/providers/provider-catalog.d.ts.map +1 -0
- package/packages/core/dist/providers/provider-catalog.js +144 -0
- package/packages/core/dist/providers/provider-catalog.js.map +1 -0
- package/packages/core/dist/providers/quota.d.ts +40 -1
- package/packages/core/dist/providers/quota.d.ts.map +1 -1
- package/packages/core/dist/providers/quota.js +288 -25
- package/packages/core/dist/providers/quota.js.map +1 -1
- package/packages/core/dist/providers/registry.d.ts +46 -3
- package/packages/core/dist/providers/registry.d.ts.map +1 -1
- package/packages/core/dist/providers/registry.js +148 -13
- package/packages/core/dist/providers/registry.js.map +1 -1
- package/packages/core/dist/providers/router.d.ts +28 -0
- package/packages/core/dist/providers/router.d.ts.map +1 -0
- package/packages/core/dist/providers/router.js +88 -0
- package/packages/core/dist/providers/router.js.map +1 -0
- package/packages/core/dist/providers/user-settings-guard.d.ts +12 -0
- package/packages/core/dist/providers/user-settings-guard.d.ts.map +1 -0
- package/packages/core/dist/providers/user-settings-guard.js +130 -0
- package/packages/core/dist/providers/user-settings-guard.js.map +1 -0
- package/packages/core/dist/runtime.d.ts +193 -7
- package/packages/core/dist/runtime.d.ts.map +1 -1
- package/packages/core/dist/runtime.js +1676 -219
- package/packages/core/dist/runtime.js.map +1 -1
- package/packages/core/dist/skills/builtin.d.ts +34 -0
- package/packages/core/dist/skills/builtin.d.ts.map +1 -0
- package/packages/core/dist/skills/builtin.js +305 -0
- package/packages/core/dist/skills/builtin.js.map +1 -0
- package/packages/core/dist/skills/shelf.d.ts +30 -0
- package/packages/core/dist/skills/shelf.d.ts.map +1 -0
- package/packages/core/dist/skills/shelf.js +159 -0
- package/packages/core/dist/skills/shelf.js.map +1 -0
- package/packages/core/dist/skills/store.d.ts +66 -4
- package/packages/core/dist/skills/store.d.ts.map +1 -1
- package/packages/core/dist/skills/store.js +105 -18
- package/packages/core/dist/skills/store.js.map +1 -1
- package/packages/core/dist/skills/suggest.d.ts +21 -0
- package/packages/core/dist/skills/suggest.d.ts.map +1 -0
- package/packages/core/dist/skills/suggest.js +150 -0
- package/packages/core/dist/skills/suggest.js.map +1 -0
- package/packages/core/dist/tools/catalog.d.ts +1 -3
- package/packages/core/dist/tools/catalog.d.ts.map +1 -1
- package/packages/core/dist/tools/catalog.js +38 -26
- package/packages/core/dist/tools/catalog.js.map +1 -1
- package/packages/core/dist/tools/hub.d.ts +136 -10
- package/packages/core/dist/tools/hub.d.ts.map +1 -1
- package/packages/core/dist/tools/hub.js +418 -24
- package/packages/core/dist/tools/hub.js.map +1 -1
- package/packages/core/dist/turns/journal.d.ts +78 -0
- package/packages/core/dist/turns/journal.d.ts.map +1 -0
- package/packages/core/dist/turns/journal.js +104 -0
- package/packages/core/dist/turns/journal.js.map +1 -0
- package/packages/core/dist/types.d.ts +1776 -12
- package/packages/core/dist/types.d.ts.map +1 -1
- package/packages/core/dist/types.js.map +1 -1
- package/packages/core/dist/util/blocks.d.ts +41 -0
- package/packages/core/dist/util/blocks.d.ts.map +1 -0
- package/packages/core/dist/util/blocks.js +175 -0
- package/packages/core/dist/util/blocks.js.map +1 -0
- package/packages/core/dist/util/queue.d.ts +12 -0
- package/packages/core/dist/util/queue.d.ts.map +1 -1
- package/packages/core/dist/util/queue.js +16 -0
- package/packages/core/dist/util/queue.js.map +1 -1
- package/packages/core/dist/util/time.d.ts +39 -0
- package/packages/core/dist/util/time.d.ts.map +1 -0
- package/packages/core/dist/util/time.js +71 -0
- package/packages/core/dist/util/time.js.map +1 -0
- package/packages/core/package.json +1 -1
- package/packages/server/dist/auth.d.ts +14 -1
- package/packages/server/dist/auth.d.ts.map +1 -1
- package/packages/server/dist/auth.js +19 -0
- package/packages/server/dist/auth.js.map +1 -1
- package/packages/server/dist/context.d.ts +35 -1
- package/packages/server/dist/context.d.ts.map +1 -1
- package/packages/server/dist/context.js +39 -10
- package/packages/server/dist/context.js.map +1 -1
- package/packages/server/dist/gateways/attachments.d.ts +32 -0
- package/packages/server/dist/gateways/attachments.d.ts.map +1 -0
- package/packages/server/dist/gateways/attachments.js +167 -0
- package/packages/server/dist/gateways/attachments.js.map +1 -0
- package/packages/server/dist/gateways/markdown.d.ts +9 -0
- package/packages/server/dist/gateways/markdown.d.ts.map +1 -0
- package/packages/server/dist/gateways/markdown.js +170 -0
- package/packages/server/dist/gateways/markdown.js.map +1 -0
- package/packages/server/dist/gateways/push.d.ts +1 -1
- package/packages/server/dist/gateways/push.d.ts.map +1 -1
- package/packages/server/dist/gateways/push.js +420 -13
- package/packages/server/dist/gateways/push.js.map +1 -1
- package/packages/server/dist/gateways/telegram-api.d.ts +70 -1
- package/packages/server/dist/gateways/telegram-api.d.ts.map +1 -1
- package/packages/server/dist/gateways/telegram-api.js +140 -1
- package/packages/server/dist/gateways/telegram-api.js.map +1 -1
- package/packages/server/dist/gateways/telegram.d.ts +181 -1
- package/packages/server/dist/gateways/telegram.d.ts.map +1 -1
- package/packages/server/dist/gateways/telegram.js +1572 -78
- package/packages/server/dist/gateways/telegram.js.map +1 -1
- package/packages/server/dist/gateways/threads.d.ts +84 -0
- package/packages/server/dist/gateways/threads.d.ts.map +1 -0
- package/packages/server/dist/gateways/threads.js +289 -0
- package/packages/server/dist/gateways/threads.js.map +1 -0
- package/packages/server/dist/index.d.ts +2 -1
- package/packages/server/dist/index.d.ts.map +1 -1
- package/packages/server/dist/index.js +2 -1
- package/packages/server/dist/index.js.map +1 -1
- package/packages/server/dist/listeners/imap.d.ts +13 -0
- package/packages/server/dist/listeners/imap.d.ts.map +1 -0
- package/packages/server/dist/listeners/imap.js +0 -0
- package/packages/server/dist/listeners/imap.js.map +1 -0
- package/packages/server/dist/listeners/registry.d.ts +18 -0
- package/packages/server/dist/listeners/registry.d.ts.map +1 -0
- package/packages/server/dist/listeners/registry.js +88 -0
- package/packages/server/dist/listeners/registry.js.map +1 -0
- package/packages/server/dist/listeners/types.d.ts +55 -0
- package/packages/server/dist/listeners/types.d.ts.map +1 -0
- package/packages/server/dist/listeners/types.js +2 -0
- package/packages/server/dist/listeners/types.js.map +1 -0
- package/packages/server/dist/main.js +15 -1
- package/packages/server/dist/main.js.map +1 -1
- package/packages/server/dist/routes/chat.d.ts +7 -3
- package/packages/server/dist/routes/chat.d.ts.map +1 -1
- package/packages/server/dist/routes/chat.js +8 -17
- package/packages/server/dist/routes/chat.js.map +1 -1
- package/packages/server/dist/routes/config.d.ts.map +1 -1
- package/packages/server/dist/routes/config.js +66 -7
- package/packages/server/dist/routes/config.js.map +1 -1
- package/packages/server/dist/routes/cron.d.ts.map +1 -1
- package/packages/server/dist/routes/cron.js +65 -8
- package/packages/server/dist/routes/cron.js.map +1 -1
- package/packages/server/dist/routes/dream.d.ts +22 -0
- package/packages/server/dist/routes/dream.d.ts.map +1 -0
- package/packages/server/dist/routes/dream.js +152 -0
- package/packages/server/dist/routes/dream.js.map +1 -0
- package/packages/server/dist/routes/hooks.d.ts +18 -0
- package/packages/server/dist/routes/hooks.d.ts.map +1 -0
- package/packages/server/dist/routes/hooks.js +62 -0
- package/packages/server/dist/routes/hooks.js.map +1 -0
- package/packages/server/dist/routes/listeners.d.ts +10 -0
- package/packages/server/dist/routes/listeners.d.ts.map +1 -0
- package/packages/server/dist/routes/listeners.js +12 -0
- package/packages/server/dist/routes/listeners.js.map +1 -0
- package/packages/server/dist/routes/memories.d.ts.map +1 -1
- package/packages/server/dist/routes/memories.js +55 -3
- package/packages/server/dist/routes/memories.js.map +1 -1
- package/packages/server/dist/routes/org.d.ts.map +1 -1
- package/packages/server/dist/routes/org.js +289 -49
- package/packages/server/dist/routes/org.js.map +1 -1
- package/packages/server/dist/routes/profile.d.ts.map +1 -1
- package/packages/server/dist/routes/profile.js +6 -3
- package/packages/server/dist/routes/profile.js.map +1 -1
- package/packages/server/dist/routes/providers.d.ts.map +1 -1
- package/packages/server/dist/routes/providers.js +66 -7
- package/packages/server/dist/routes/providers.js.map +1 -1
- package/packages/server/dist/routes/questions.d.ts +45 -0
- package/packages/server/dist/routes/questions.d.ts.map +1 -0
- package/packages/server/dist/routes/questions.js +73 -0
- package/packages/server/dist/routes/questions.js.map +1 -0
- package/packages/server/dist/routes/sessions.d.ts.map +1 -1
- package/packages/server/dist/routes/sessions.js +26 -6
- package/packages/server/dist/routes/sessions.js.map +1 -1
- package/packages/server/dist/routes/sleep.d.ts.map +1 -1
- package/packages/server/dist/routes/sleep.js +71 -2
- package/packages/server/dist/routes/sleep.js.map +1 -1
- package/packages/server/dist/routes/terminals.d.ts +25 -0
- package/packages/server/dist/routes/terminals.d.ts.map +1 -0
- package/packages/server/dist/routes/terminals.js +35 -0
- package/packages/server/dist/routes/terminals.js.map +1 -0
- package/packages/server/dist/routes/tools.d.ts.map +1 -1
- package/packages/server/dist/routes/tools.js +140 -6
- package/packages/server/dist/routes/tools.js.map +1 -1
- package/packages/server/dist/routes/updates.d.ts +10 -0
- package/packages/server/dist/routes/updates.d.ts.map +1 -0
- package/packages/server/dist/routes/updates.js +22 -0
- package/packages/server/dist/routes/updates.js.map +1 -0
- package/packages/server/dist/routes/ws.d.ts +11 -5
- package/packages/server/dist/routes/ws.d.ts.map +1 -1
- package/packages/server/dist/routes/ws.js +168 -28
- package/packages/server/dist/routes/ws.js.map +1 -1
- package/packages/server/dist/schemas.d.ts +1177 -215
- package/packages/server/dist/schemas.d.ts.map +1 -1
- package/packages/server/dist/schemas.js +317 -12
- package/packages/server/dist/schemas.js.map +1 -1
- package/packages/server/dist/server.d.ts +7 -1
- package/packages/server/dist/server.d.ts.map +1 -1
- package/packages/server/dist/server.js +210 -3
- package/packages/server/dist/server.js.map +1 -1
- package/packages/server/dist/services/stream.d.ts +94 -5
- package/packages/server/dist/services/stream.d.ts.map +1 -1
- package/packages/server/dist/services/stream.js +9 -20
- package/packages/server/dist/services/stream.js.map +1 -1
- package/packages/server/dist/services/stt.d.ts +65 -0
- package/packages/server/dist/services/stt.d.ts.map +1 -0
- package/packages/server/dist/services/stt.js +306 -0
- package/packages/server/dist/services/stt.js.map +1 -0
- package/packages/server/dist/services/turns.d.ts +54 -0
- package/packages/server/dist/services/turns.d.ts.map +1 -0
- package/packages/server/dist/services/turns.js +186 -0
- package/packages/server/dist/services/turns.js.map +1 -0
- package/packages/server/dist/services/updates.d.ts +99 -0
- package/packages/server/dist/services/updates.d.ts.map +1 -0
- package/packages/server/dist/services/updates.js +316 -0
- package/packages/server/dist/services/updates.js.map +1 -0
- package/packages/server/package.json +1 -1
- package/packages/web/dist/app-icon.svg +2 -0
- package/packages/web/dist/apple-touch-icon.png +0 -0
- package/packages/web/dist/assets/abnfDiagram-O67JEVCF-D7YyFndQ.js +1 -0
- package/packages/web/dist/assets/arc-C_Zgk2dJ.js +1 -0
- package/packages/web/dist/assets/architectureDiagram-NJMV4G6O-eI0adu1B.js +36 -0
- package/packages/web/dist/assets/blockDiagram-BEXU5L5S-WAoOFUA9.js +140 -0
- package/packages/web/dist/assets/c4Diagram-YGBWAQC7-DE8Zyhng.js +38 -0
- package/packages/web/dist/assets/channel-egZxcyUK.js +1 -0
- package/packages/web/dist/assets/chunk-2Q5K7J3B-bnqLP2XD.js +1 -0
- package/packages/web/dist/assets/chunk-3FUC2YCW-Ck1_SVe0.js +2 -0
- package/packages/web/dist/assets/chunk-5VM5RSS4-hDmC41gD.js +15 -0
- package/packages/web/dist/assets/chunk-GTNCS2PH-PoWvfCrT.js +88 -0
- package/packages/web/dist/assets/chunk-GWA4HPMP-D3V0IG43.js +1 -0
- package/packages/web/dist/assets/chunk-JWPE2WC7-BryfpHM5.js +1 -0
- package/packages/web/dist/assets/chunk-NETBCI7D-8ic1iEdT.js +1 -0
- package/packages/web/dist/assets/chunk-WEXAMYUT-nM8tmQT2.js +1 -0
- package/packages/web/dist/assets/chunk-XXDRQBXY-Do28F482.js +1 -0
- package/packages/web/dist/assets/classDiagram-v2-NBCMYWYE-Bop9oNNO.js +217 -0
- package/packages/web/dist/assets/cose-bilkent-JH36ORCC-a7f_bpnt.js +1 -0
- package/packages/web/dist/assets/cynefin-OW5HDTMX-DnArcis_.js +178 -0
- package/packages/web/dist/assets/cynefinDiagram-VND7K2PF-vEuTb1GD.js +62 -0
- package/packages/web/dist/assets/cytoscape.esm-Ix0LnXOy.js +331 -0
- package/packages/web/dist/assets/dagre-6A5THRUB-BgG4MynJ.js +4 -0
- package/packages/web/dist/assets/diagram-22UHCM2B-DRCQpafv.js +200 -0
- package/packages/web/dist/assets/diagram-3UASUU5V-BKgmAXde.js +24 -0
- package/packages/web/dist/assets/diagram-ATOU4E4O-B6Hsy36X.js +3 -0
- package/packages/web/dist/assets/diagram-CDSNMT55-JflyfyoB.js +30 -0
- package/packages/web/dist/assets/diagram-MLGK6HIB-Dd2QPJjT.js +24 -0
- package/packages/web/dist/assets/diagram-MPIPVDR6-DE5QU60x.js +41 -0
- package/packages/web/dist/assets/draco_decoder-C32yEggz.wasm +0 -0
- package/packages/web/dist/assets/draco_decoder-Z1_iN-Ht.wasm +0 -0
- package/packages/web/dist/assets/draco_decoder-fzg4nYZr.js +34 -0
- package/packages/web/dist/assets/draco_wasm_wrapper-DxJM36Ib.js +117 -0
- package/packages/web/dist/assets/draco_wasm_wrapper-fZCQGLGb.js +116 -0
- package/packages/web/dist/assets/ebnfDiagram-ZINNZB2B-D7AQ741b.js +1 -0
- package/packages/web/dist/assets/elk-276RUBZZ-CeewBVLF.js +27 -0
- package/packages/web/dist/assets/erDiagram-OPXOYQCR-mLLYkZ5c.js +99 -0
- package/packages/web/dist/assets/flowDiagram-KWPJA3E3-DtpSpsQN.js +213 -0
- package/packages/web/dist/assets/ganttDiagram-FUAMR5RP-1_lh-3ky.js +292 -0
- package/packages/web/dist/assets/gitGraphDiagram-X574FWY7-DoPXZuT5.js +106 -0
- package/packages/web/dist/assets/graph-Bn3Yngep.js +1 -0
- package/packages/web/dist/assets/index-Cw2Opmx7.js +648 -0
- package/packages/web/dist/assets/index-j0zBRCgT.css +32 -0
- package/packages/web/dist/assets/infoDiagram-VRGFBTTK-DQpRGGiD.js +2 -0
- package/packages/web/dist/assets/ishikawaDiagram-OU5B5YK6-gH5C9Q2e.js +70 -0
- package/packages/web/dist/assets/journeyDiagram-ZHPQQLJL-Bg-oeFjb.js +139 -0
- package/packages/web/dist/assets/kanban-definition-PNTS6WVX-BnpI4VH8.js +89 -0
- package/packages/web/dist/assets/katex-C5jXJg4s.js +257 -0
- package/packages/web/dist/assets/mermaid.core-BwBKxlRA.js +313 -0
- package/packages/web/dist/assets/mindmap-definition-NLK3R4M7-NBnnxEoO.js +96 -0
- package/packages/web/dist/assets/pegDiagram-GJSIUBJH-RrXXbIvO.js +1 -0
- package/packages/web/dist/assets/pieDiagram-5QR66LMP-B27q6Gso.js +39 -0
- package/packages/web/dist/assets/quadrantDiagram-O4NWA36T-DGDsdur2.js +7 -0
- package/packages/web/dist/assets/railroadDiagram-XR7U4H2S-GdjkE3mI.js +1 -0
- package/packages/web/dist/assets/requirementDiagram-PLB6GJNP-DjK0GfgO.js +84 -0
- package/packages/web/dist/assets/sankeyDiagram-IPEJSGJF-BG_AIkwF.js +40 -0
- package/packages/web/dist/assets/scene-D4LPicHk.js +4620 -0
- package/packages/web/dist/assets/sequenceDiagram-PO4LG4MO-CIQwUb4y.js +169 -0
- package/packages/web/dist/assets/sizeCapture-INFHLROL-bpIoPxdJ.js +1 -0
- package/packages/web/dist/assets/stateDiagram-v2-GCMORJYK-8hYXvPPv.js +291 -0
- package/packages/web/dist/assets/swimlanes-2SLR337P-gfflUMF9.js +1 -0
- package/packages/web/dist/assets/swimlanesDiagram-TC7HE7FX-9wdzGXU-.js +8 -0
- package/packages/web/dist/assets/timeline-definition-EJHVYXUP-PHMNoGTZ.js +120 -0
- package/packages/web/dist/assets/usecaseDiagram-POWQR4AR-B2j5iteO.js +370 -0
- package/packages/web/dist/assets/vennDiagram-UO4OBE2U-BzxtZ-_2.js +34 -0
- package/packages/web/dist/assets/wardleyDiagram-VNRHLVJA-DL7YbMpY.js +78 -0
- package/packages/web/dist/assets/xychartDiagram-PMCCYNJV-CisgP1cT.js +7 -0
- package/packages/web/dist/draco/draco_decoder.js +33 -0
- package/packages/web/dist/draco/draco_decoder.wasm +0 -0
- package/packages/web/dist/draco/draco_wasm_wrapper.js +116 -0
- package/packages/web/dist/favicon-16.png +0 -0
- package/packages/web/dist/favicon-32.png +0 -0
- package/packages/web/dist/favicon-48.png +0 -0
- package/packages/web/dist/favicon.ico +0 -0
- package/packages/web/dist/favicon.svg +1 -1
- package/packages/web/dist/icon-192.png +0 -0
- package/packages/web/dist/icon-512.png +0 -0
- package/packages/web/dist/index.html +12 -4
- package/packages/web/dist/logo-light.svg +1 -1
- package/packages/web/dist/logo-mono.svg +2 -0
- package/packages/web/dist/logo-stacked-light.svg +2 -0
- package/packages/web/dist/logo-stacked.svg +2 -0
- package/packages/web/dist/logo-white.svg +2 -0
- package/packages/web/dist/logo.svg +1 -1
- package/packages/web/dist/mark-light.svg +1 -1
- package/packages/web/dist/mark-mono.svg +2 -0
- package/packages/web/dist/mark-small-light.svg +2 -0
- package/packages/web/dist/mark-small.svg +2 -0
- package/packages/web/dist/mark-white.svg +2 -0
- package/packages/web/dist/mark.svg +1 -1
- package/packages/web/dist/models/LICENSE.txt +5 -0
- package/packages/web/dist/models/brain.glb +0 -0
- package/packages/web/dist/site.webmanifest +23 -0
- package/packages/web/dist/wordmark-light.svg +2 -0
- package/packages/web/dist/wordmark.svg +2 -0
- package/packages/web/package.json +1 -1
- package/scripts/rookery.mjs +204 -122
- package/scripts/updater.mjs +227 -0
- package/packages/cli/dist/tui/components/Wordmark.d.ts +0 -35
- package/packages/cli/dist/tui/components/Wordmark.d.ts.map +0 -1
- package/packages/cli/dist/tui/components/Wordmark.js +0 -81
- package/packages/cli/dist/tui/components/Wordmark.js.map +0 -1
- package/packages/core/dist/agents/orchestrator.d.ts +0 -24
- package/packages/core/dist/agents/orchestrator.d.ts.map +0 -1
- package/packages/core/dist/agents/orchestrator.js +0 -88
- package/packages/core/dist/agents/orchestrator.js.map +0 -1
- package/packages/core/dist/agents/roles.d.ts +0 -21
- package/packages/core/dist/agents/roles.d.ts.map +0 -1
- package/packages/core/dist/agents/roles.js +0 -81
- package/packages/core/dist/agents/roles.js.map +0 -1
- package/packages/core/dist/agents/team.d.ts +0 -105
- package/packages/core/dist/agents/team.d.ts.map +0 -1
- package/packages/core/dist/agents/team.js +0 -623
- package/packages/core/dist/agents/team.js.map +0 -1
- package/packages/core/dist/providers/codex.d.ts +0 -10
- package/packages/core/dist/providers/codex.d.ts.map +0 -1
- package/packages/core/dist/providers/codex.js +0 -375
- package/packages/core/dist/providers/codex.js.map +0 -1
- package/packages/core/dist/tools/browser.d.ts +0 -20
- package/packages/core/dist/tools/browser.d.ts.map +0 -1
- package/packages/core/dist/tools/browser.js +0 -72
- package/packages/core/dist/tools/browser.js.map +0 -1
- package/packages/server/dist/routes/agents.d.ts +0 -5
- package/packages/server/dist/routes/agents.d.ts.map +0 -1
- package/packages/server/dist/routes/agents.js +0 -6
- package/packages/server/dist/routes/agents.js.map +0 -1
- package/packages/server/dist/routes/team.d.ts +0 -11
- package/packages/server/dist/routes/team.d.ts.map +0 -1
- package/packages/server/dist/routes/team.js +0 -36
- package/packages/server/dist/routes/team.js.map +0 -1
- package/packages/web/dist/assets/3d-force-graph-BPZmoydi.js +0 -1163
- package/packages/web/dist/assets/index-IBSTzK7-.js +0 -1255
- package/packages/web/dist/assets/index-qUXUui7W.css +0 -1
- package/packages/web/dist/assets/three-spritetext-B9ZIW7c-.js +0 -4
- package/packages/web/dist/assets/three.module-cmFfBtHS.js +0 -4228
|
@@ -7,112 +7,492 @@
|
|
|
7
7
|
* need. It speaks the same sliver of MCP (initialize, tools/list, tools/call,
|
|
8
8
|
* ping) and keeps one PowerShell alive for the length of the turn.
|
|
9
9
|
*/
|
|
10
|
-
import { mkdirSync } from 'node:fs';
|
|
10
|
+
import { appendFileSync, mkdirSync } from 'node:fs';
|
|
11
11
|
import { join } from 'node:path';
|
|
12
12
|
import { createInterface } from 'node:readline';
|
|
13
|
+
import { setTimeout as delay } from 'node:timers/promises';
|
|
14
|
+
import { describeAct, describeControl, describeSnapshot } from './accessibility.js';
|
|
13
15
|
import { parseKeySequence } from './keys.js';
|
|
14
16
|
import { PowerShellSession, psQuote } from './powershell.js';
|
|
15
17
|
import { COMPUTER_SERVER_NAME, COMPUTER_TOOLS } from './tools.js';
|
|
18
|
+
import { describeScreen, describeSettle, describeWindow, findText, pickMatch, } from './screen-text.js';
|
|
19
|
+
import { clipStrokes, fitViewBox, multiply, svgStrokes, svgViewBox } from './sketch.js';
|
|
20
|
+
import { batchObservation, validateComputerCall } from './validation.js';
|
|
16
21
|
const PROTOCOL_FALLBACK = '2025-06-18';
|
|
17
|
-
const MAX_WIDTH = Math.max(320, Number(process.env.ROOKERY_COMPUTER_MAX_WIDTH) || 1280);
|
|
22
|
+
const MAX_WIDTH = Math.min(3840, Math.max(320, Number(process.env.ROOKERY_COMPUTER_MAX_WIDTH) || 1280));
|
|
18
23
|
const RUN_DIR = process.env.ROOKERY_COMPUTER_DIR ? join(process.env.ROOKERY_COMPUTER_DIR, 'run') : '';
|
|
24
|
+
const BACKGROUND = process.env.ROOKERY_COMPUTER_MODE === 'background';
|
|
19
25
|
const shell = new PowerShellSession();
|
|
26
|
+
// Warm the worker and its cursor while the model is still writing its first call;
|
|
27
|
+
// the first action then finds everything loaded. A failure here surfaces on that call.
|
|
28
|
+
if (process.platform === 'win32')
|
|
29
|
+
shell.run('Rk-Overlay; @{}').catch(() => undefined);
|
|
30
|
+
let stopped = false;
|
|
31
|
+
let queue = Promise.resolve();
|
|
32
|
+
const pending = new Set();
|
|
33
|
+
const observations = new Set(['screenshot', 'screen_info', 'list_windows', 'snapshot', 'read_screen', 'find_text', 'stop']);
|
|
20
34
|
/* --------------------------------- mapping -------------------------------- */
|
|
21
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* The view: what the last desktop capture showed, and how its pixels map to
|
|
37
|
+
* the screen. Every coordinate the model sends or reads refers to it. A
|
|
38
|
+
* zoomed screenshot narrows it to a region; read_screen and a plain
|
|
39
|
+
* screenshot widen it back to the whole desktop. Whether the screen still
|
|
40
|
+
* looks like that is the worker's business: its guard compares the window in
|
|
41
|
+
* front with what it saw at the end of its own last action or observation.
|
|
42
|
+
*/
|
|
22
43
|
let view = null;
|
|
23
|
-
|
|
24
|
-
if (view)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return view;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
44
|
+
function toScreen(x, y) {
|
|
45
|
+
if (!view)
|
|
46
|
+
throw new Error('Take a desktop screenshot or read_screen before using coordinates. Window screenshots use different coordinates.');
|
|
47
|
+
if (x >= view.width || y >= view.height)
|
|
48
|
+
throw new Error('Coordinates are outside the last desktop screenshot (' + view.width + 'x' + view.height + ').');
|
|
49
|
+
return [Math.round(view.left + x / view.scale), Math.round(view.top + y / view.scale)];
|
|
50
|
+
}
|
|
51
|
+
/** A physical point as the model would write it: in pixels of the current view. */
|
|
52
|
+
function toView(x, y) {
|
|
53
|
+
if (!view)
|
|
54
|
+
return x + ',' + y + ' (screen pixels)';
|
|
55
|
+
return Math.round((x - view.left) * view.scale) + ',' + Math.round((y - view.top) * view.scale);
|
|
56
|
+
}
|
|
57
|
+
/** How a worker report in physical pixels is printed: through the view, or the whole desktop when there is none. */
|
|
58
|
+
function mapping(screen) {
|
|
59
|
+
return view ?? { left: screen.left, top: screen.top, scale: Math.min(1, MAX_WIDTH / screen.width) };
|
|
60
|
+
}
|
|
61
|
+
/** The screen's text lines in the current view, for error messages: the same coordinates the other listings use. */
|
|
62
|
+
function visible(screen, limit = 40) {
|
|
63
|
+
const map = mapping(screen);
|
|
64
|
+
return describeScreen(screen, map.scale, limit, map);
|
|
65
|
+
}
|
|
66
|
+
/** Observations the worker has not made since it was last restarted after a timeout. */
|
|
67
|
+
let restartsSeen = 0;
|
|
68
|
+
/** Physical actions currently dispatched to the worker. */
|
|
69
|
+
let inputInFlight = 0;
|
|
70
|
+
/**
|
|
71
|
+
* A worker killed mid-action (stop, timeout, end of turn) cannot run its own
|
|
72
|
+
* cleanup, so a drag's button or a shortcut's modifier would stay down for the
|
|
73
|
+
* user. A fresh worker lets go of whatever is still held.
|
|
74
|
+
*/
|
|
75
|
+
async function releaseHeld(timeoutMs = 10_000) {
|
|
76
|
+
await shell.run('Rk-Release', timeoutMs).catch(() => undefined);
|
|
77
|
+
}
|
|
78
|
+
/** Serialize physical input across Rookery processes; the worker's guard refuses a changed desktop. */
|
|
79
|
+
async function physical(expression, timeoutMs = 30_000) {
|
|
80
|
+
inputInFlight++;
|
|
81
|
+
try {
|
|
82
|
+
await shell.run('$mutex = New-Object System.Threading.Mutex($false, "Local\\RookeryComputerInput"); ' +
|
|
83
|
+
'$locked = $false; try { try { $locked = $mutex.WaitOne(0) } catch [System.Threading.AbandonedMutexException] { $locked = $true }; ' +
|
|
84
|
+
'if (-not $locked) { throw "Another Rookery session is using desktop input." }; Rk-Guard; ' + expression +
|
|
85
|
+
' } finally { if ($locked) { $mutex.ReleaseMutex() }; $mutex.Dispose() }', timeoutMs);
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
if (!shell.running && !closing)
|
|
89
|
+
await releaseHeld();
|
|
90
|
+
if (shell.restarts > restartsSeen && /before physical input/.test(error.message)) {
|
|
91
|
+
throw new Error('The worker was restarted after a timed-out action, so it has not seen the screen since. Take a fresh screenshot or read_screen before continuing.');
|
|
92
|
+
}
|
|
93
|
+
throw error;
|
|
94
|
+
}
|
|
95
|
+
finally {
|
|
96
|
+
inputInFlight--;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/** After smoothing; the SVG input is bounded by size, not by what it expands to. */
|
|
100
|
+
const DRAWN_POINTS = 60_000;
|
|
101
|
+
/** Physical pixels one pen-down may cover before it is continued as a new stroke. */
|
|
102
|
+
const MAX_STROKE = 2000;
|
|
103
|
+
/**
|
|
104
|
+
* The draw tool's strokes in physical pixels, clipped to the area (or the
|
|
105
|
+
* whole screenshot), rounded and packed the way the native Draw reads them:
|
|
106
|
+
* stroke count, then per stroke its point count and x, y pairs.
|
|
107
|
+
*/
|
|
108
|
+
function planDrawing(args) {
|
|
109
|
+
if (!view)
|
|
110
|
+
throw new Error('Take a desktop screenshot before drawing.');
|
|
111
|
+
const { scale, left, top, width, height } = view;
|
|
112
|
+
const area = args.area ?? { x: 0, y: 0, width: width - 1, height: height - 1 };
|
|
113
|
+
if (area.x + area.width > width || area.y + area.height > height)
|
|
114
|
+
throw new Error('The area reaches outside the last desktop screenshot.');
|
|
115
|
+
const toPhysical = [1 / scale, 0, 0, 1 / scale, left, top];
|
|
116
|
+
const strokes = (args.strokes ?? []).map((stroke) => stroke.flatMap(([x, y]) => [left + x / scale, top + y / scale]));
|
|
117
|
+
if (args.svg) {
|
|
118
|
+
strokes.push(...svgStrokes(args.svg, {
|
|
119
|
+
transform: multiply(toPhysical, fitViewBox(svgViewBox(args.svg), area)),
|
|
120
|
+
tolerance: 0.35,
|
|
121
|
+
hatch: args.hatch && { spacing: args.hatch.spacing / scale, angle: args.hatch.angle, cross: args.hatch.cross },
|
|
122
|
+
}));
|
|
123
|
+
}
|
|
124
|
+
const clip = { x: left + area.x / scale, y: top + area.y / scale, width: area.width / scale, height: area.height / scale };
|
|
125
|
+
const packed = [0];
|
|
126
|
+
let points = 0;
|
|
127
|
+
let ink = 0;
|
|
128
|
+
const emit = (rounded) => {
|
|
129
|
+
packed[0]++;
|
|
130
|
+
packed.push(rounded.length / 2);
|
|
131
|
+
for (const value of rounded)
|
|
132
|
+
packed.push(value);
|
|
133
|
+
points += rounded.length / 2;
|
|
134
|
+
};
|
|
135
|
+
for (const stroke of clipStrokes(strokes, clip)) {
|
|
136
|
+
let rounded = [];
|
|
137
|
+
let length = 0;
|
|
138
|
+
for (let i = 0; i + 1 < stroke.length; i += 2) {
|
|
139
|
+
const x = Math.round(stroke[i]), y = Math.round(stroke[i + 1]);
|
|
140
|
+
const n = rounded.length;
|
|
141
|
+
if (n && rounded[n - 2] === x && rounded[n - 1] === y)
|
|
142
|
+
continue;
|
|
143
|
+
const step = n ? Math.hypot(x - rounded[n - 2], y - rounded[n - 1]) : 0;
|
|
144
|
+
// Some brushes keep only the tail of a very long stroke; continue it as a new one instead.
|
|
145
|
+
if (length + step > MAX_STROKE && n >= 4) {
|
|
146
|
+
emit(rounded);
|
|
147
|
+
rounded = [rounded[n - 2], rounded[n - 1]];
|
|
148
|
+
length = 0;
|
|
149
|
+
}
|
|
150
|
+
ink += step;
|
|
151
|
+
length += step;
|
|
152
|
+
rounded.push(x, y);
|
|
153
|
+
}
|
|
154
|
+
emit(rounded);
|
|
155
|
+
}
|
|
156
|
+
if (!packed[0])
|
|
157
|
+
throw new Error('Nothing to draw: every shape has stroke="none" or lies outside the area.');
|
|
158
|
+
if (points > DRAWN_POINTS)
|
|
159
|
+
throw new Error('Too detailed: ' + points + ' points after smoothing (limit ' + DRAWN_POINTS + '). Split the picture into several draw calls.');
|
|
160
|
+
return {
|
|
161
|
+
packed: Buffer.from(new Int32Array(packed).buffer).toString('base64'),
|
|
162
|
+
strokes: packed[0],
|
|
163
|
+
points,
|
|
164
|
+
// Ink runs at about 3.5 px/ms; each stroke adds a hop and two short holds.
|
|
165
|
+
timeoutMs: 30_000 + ink / 2.5 + packed[0] * 250,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
43
168
|
/* ---------------------------------- tools --------------------------------- */
|
|
44
|
-
|
|
169
|
+
/**
|
|
170
|
+
* The screen's text, without touching the view: for clicking by text and
|
|
171
|
+
* waiting. Before an action, the guard runs first when there is a baseline,
|
|
172
|
+
* so a window the user switched to is refused rather than read and clicked;
|
|
173
|
+
* with no baseline yet (a turn's first call), the reading establishes one.
|
|
174
|
+
*/
|
|
175
|
+
async function ocr(guarded = false) {
|
|
176
|
+
return shell.run((guarded ? 'if ($null -ne $script:rkForeground) { Rk-Guard }; ' : '') + 'Rk-ReadScreen ' + (stopped ? '$false' : '$true'), 20_000);
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Recognise the screen's text. Like a screenshot, it becomes the view that
|
|
180
|
+
* physical input maps through, so its coordinates can be clicked directly.
|
|
181
|
+
*/
|
|
182
|
+
async function readScreen() {
|
|
183
|
+
const screen = await ocr();
|
|
184
|
+
const scale = Math.min(1, MAX_WIDTH / screen.width);
|
|
185
|
+
view = { scale, left: screen.left, top: screen.top, width: Math.round(screen.width * scale), height: Math.round(screen.height * scale) };
|
|
186
|
+
restartsSeen = shell.restarts;
|
|
187
|
+
return { screen, scale };
|
|
188
|
+
}
|
|
189
|
+
/** A match's centre in physical pixels. */
|
|
190
|
+
function centre(match) {
|
|
191
|
+
return [Math.round(match.x + match.width / 2), Math.round(match.y + match.height / 2)];
|
|
192
|
+
}
|
|
193
|
+
/** One line per text match: where it is in the current view, and what the screen says there. */
|
|
194
|
+
function listMatches(matches) {
|
|
195
|
+
return matches.map((m, i) => (i + 1) + '. ' + toView(...centre(m)) + ' "' + m.text + '"' + (m.approximate ? ' (approximate)' : '') + (m.foreground ? '' : ' (outside the active window)')).join('\n');
|
|
196
|
+
}
|
|
197
|
+
/** Controls named exactly like the phrase in one window, with refs act accepts. */
|
|
198
|
+
async function findControls(window, name) {
|
|
199
|
+
return shell.run('Rk-FindControls ' + window + ' ' + psQuote(name), 20_000);
|
|
200
|
+
}
|
|
201
|
+
function listControls(found, from = 0) {
|
|
202
|
+
const map = mapping(found.screen);
|
|
203
|
+
return found.controls.map((control, i) => (from + i + 1) + '. ' + describeControl(control, map)).join('\n');
|
|
204
|
+
}
|
|
205
|
+
/** Wait, but not past a stop. */
|
|
206
|
+
async function pause(ms) {
|
|
207
|
+
const until = Date.now() + ms;
|
|
208
|
+
while (Date.now() < until) {
|
|
209
|
+
if (stopped)
|
|
210
|
+
throw new Error('Computer use stopped.');
|
|
211
|
+
await delay(Math.min(50, until - Date.now()));
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* What a physical action returns: the screen once it has stopped changing,
|
|
216
|
+
* so the model sees the result without a second round trip, and never a
|
|
217
|
+
* half-drawn frame from a fixed sleep. With nothing to observe, a short
|
|
218
|
+
* settle still runs: it records what the action left in front, so a dialog
|
|
219
|
+
* the action opened is not mistaken for the user switching windows, and it
|
|
220
|
+
* tells the model when nothing visibly happened.
|
|
221
|
+
*/
|
|
222
|
+
async function settled(observe) {
|
|
223
|
+
const result = await shell.run(observe === 'none' ? 'Rk-Settle 40 600 80' : 'Rk-Settle', 5_000);
|
|
224
|
+
const note = { type: 'text', text: describeSettle(result) };
|
|
225
|
+
if (observe === 'none')
|
|
226
|
+
return [note];
|
|
227
|
+
const seen = await perform(validateComputerCall(observe === 'text' ? 'read_screen' : 'screenshot', {}, BACKGROUND));
|
|
228
|
+
return [note, ...seen];
|
|
229
|
+
}
|
|
230
|
+
async function call(command) {
|
|
231
|
+
const content = await perform(command);
|
|
232
|
+
// A batch observes once at its own end; background-only mode has nothing on the desktop to settle.
|
|
233
|
+
if (command.name === 'batch' || BACKGROUND)
|
|
234
|
+
return content;
|
|
235
|
+
// An automation action can open a dialog a moment later; the settle records it as the model's own doing.
|
|
236
|
+
const observe = command.name === 'act' ? 'none' : 'observe' in command.args ? command.args.observe : null;
|
|
237
|
+
if (observe === null)
|
|
238
|
+
return content;
|
|
239
|
+
try {
|
|
240
|
+
return [...content, ...(await settled(observe))];
|
|
241
|
+
}
|
|
242
|
+
catch (error) {
|
|
243
|
+
// The input was sent; losing its result would invite a second, duplicate action.
|
|
244
|
+
return [...content, { type: 'text', text: 'The action was sent, but observing afterwards failed: ' + error.message + ' Take a screenshot before continuing.' }];
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
async function perform(command) {
|
|
248
|
+
const { name, args } = command;
|
|
249
|
+
if (stopped && !observations.has(name))
|
|
250
|
+
throw new Error('Computer use stopped. Start a new turn to resume.');
|
|
45
251
|
switch (name) {
|
|
252
|
+
case 'stop':
|
|
253
|
+
stopped = true;
|
|
254
|
+
view = null;
|
|
255
|
+
shell.close();
|
|
256
|
+
return [{ type: 'text', text: 'Computer use stopped. Current and queued actions cancelled.' }];
|
|
257
|
+
case 'snapshot': {
|
|
258
|
+
const result = await shell.run('Rk-Snapshot ' + args.window + ' ' + args.maxNodes + ' ' + args.depth + ' ' + (stopped ? '$false' : '$true'), 15_000);
|
|
259
|
+
return [{ type: 'text', text: describeSnapshot(result, mapping(result.screen)) }];
|
|
260
|
+
}
|
|
261
|
+
case 'act': {
|
|
262
|
+
// The desktop view stays: physical input re-checks foreground and bounds before it moves.
|
|
263
|
+
const result = await shell.run('Rk-Act ' + psQuote(args.ref) + ' ' + psQuote(args.action) + ' ' + psQuote(args.value ?? ''), 15_000);
|
|
264
|
+
if (BACKGROUND && result.focusChanged) {
|
|
265
|
+
stopped = true;
|
|
266
|
+
shell.close();
|
|
267
|
+
throw new Error(describeAct(result) + ' Background-only mode stopped all further actions; inspect the result before retrying in a new turn.');
|
|
268
|
+
}
|
|
269
|
+
return [{ type: 'text', text: describeAct(result) }];
|
|
270
|
+
}
|
|
271
|
+
case 'batch': {
|
|
272
|
+
// Steps run blind; each still settles briefly, and the batch observes once at its end.
|
|
273
|
+
const actions = args.actions.map((step) => {
|
|
274
|
+
const action = validateComputerCall(step.tool, step.arguments, BACKGROUND);
|
|
275
|
+
if ('observe' in action.args)
|
|
276
|
+
action.args.observe = 'none';
|
|
277
|
+
return action;
|
|
278
|
+
});
|
|
279
|
+
const done = [];
|
|
280
|
+
for (const action of actions) {
|
|
281
|
+
const started = performance.now();
|
|
282
|
+
try {
|
|
283
|
+
const content = await call(action);
|
|
284
|
+
const said = content.map((part) => (part.type === 'text' ? part.text : '')).join(' ').trim();
|
|
285
|
+
done.push((done.length + 1) + '. ' + action.name + ': ' + said + ' (' + Math.round(performance.now() - started) + ' ms)');
|
|
286
|
+
}
|
|
287
|
+
catch (error) {
|
|
288
|
+
const step = done.length + 1;
|
|
289
|
+
const skipped = actions.length - step;
|
|
290
|
+
throw new Error('Step ' + step + ' of ' + actions.length + ' (' + action.name + ') failed: ' + error.message +
|
|
291
|
+
(done.length ? '\nCompleted before it:\n' + done.join('\n') : '') +
|
|
292
|
+
(skipped ? '\nSkipped: step' + (skipped > 1 ? 's ' + (step + 1) + '-' + actions.length : ' ' + actions.length) + '.' : '') +
|
|
293
|
+
'\nNothing was rolled back.');
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
const report = { type: 'text', text: done.join('\n') };
|
|
297
|
+
const observe = args.observe ?? batchObservation(args.window, BACKGROUND);
|
|
298
|
+
if (observe === 'none')
|
|
299
|
+
return [report];
|
|
300
|
+
const tool = observe === 'text' ? 'read_screen' : observe;
|
|
301
|
+
try {
|
|
302
|
+
return [report, ...(await call(validateComputerCall(tool, args.window && tool !== 'read_screen' ? { window: args.window } : {}, BACKGROUND)))];
|
|
303
|
+
}
|
|
304
|
+
catch (error) {
|
|
305
|
+
throw new Error(done.join('\n') + '\nAll steps completed; the final ' + observe + ' failed: ' + error.message);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
46
308
|
case 'screenshot': {
|
|
47
309
|
if (RUN_DIR)
|
|
48
310
|
mkdirSync(RUN_DIR, { recursive: true });
|
|
49
|
-
const path = RUN_DIR ? join(RUN_DIR, '
|
|
50
|
-
|
|
51
|
-
|
|
311
|
+
const path = RUN_DIR ? join(RUN_DIR, 'computer-' + process.pid + '.jpg') : '';
|
|
312
|
+
let region = '$null';
|
|
313
|
+
const previous = view;
|
|
314
|
+
if (args.region) {
|
|
315
|
+
if (!previous)
|
|
316
|
+
throw new Error('A region is measured in pixels of the last desktop screenshot; take one first.');
|
|
317
|
+
const r = args.region;
|
|
318
|
+
if (r.x + r.width > previous.width || r.y + r.height > previous.height)
|
|
319
|
+
throw new Error('The region reaches outside the last desktop screenshot (' + previous.width + 'x' + previous.height + ').');
|
|
320
|
+
region = '@(' + [
|
|
321
|
+
Math.round(previous.left + r.x / previous.scale), Math.round(previous.top + r.y / previous.scale),
|
|
322
|
+
Math.max(1, Math.round(r.width / previous.scale)), Math.max(1, Math.round(r.height / previous.scale)),
|
|
323
|
+
].join(',') + ')';
|
|
324
|
+
}
|
|
325
|
+
const shot = await shell.run('Rk-Screenshot ' + MAX_WIDTH + ' ' + psQuote(path) + ' ' + (args.window ?? 0) + ' ' + (stopped ? '$false' : '$true') + ' ' + region + ' ' + (args.screen ?? 0), 15_000);
|
|
326
|
+
if (!args.window) {
|
|
327
|
+
view = { scale: shot.scale, left: shot.left, top: shot.top, width: shot.width, height: shot.height };
|
|
328
|
+
restartsSeen = shell.restarts;
|
|
329
|
+
}
|
|
330
|
+
const pointer = shot.cursorX >= 0 && shot.cursorY >= 0 && shot.cursorX < shot.width && shot.cursorY < shot.height
|
|
331
|
+
? 'Pointer at ' + shot.cursorX + ',' + shot.cursorY + '.'
|
|
332
|
+
: 'Pointer outside this view.';
|
|
333
|
+
let what;
|
|
334
|
+
if (args.window)
|
|
335
|
+
what = 'Window capture (app-dependent); virtual cursor marks the last UIA target. Observe with snapshot if blank.';
|
|
336
|
+
else if (args.region) {
|
|
337
|
+
const zoom = shot.scale / previous.scale;
|
|
338
|
+
what = 'Zoomed ' + zoom.toFixed(1) + 'x into the region ' + args.region.x + ',' + args.region.y + ' ' + args.region.width + 'x' + args.region.height +
|
|
339
|
+
' of the previous screenshot. Coordinates now refer to this image until the next desktop screenshot or read_screen. ' + pointer;
|
|
340
|
+
}
|
|
341
|
+
else if (args.screen)
|
|
342
|
+
what = 'Display ' + args.screen + ' only; coordinates now refer to this image. ' + pointer;
|
|
343
|
+
else
|
|
344
|
+
what = pointer;
|
|
52
345
|
return [
|
|
53
|
-
{ type: 'image', data: shot.
|
|
346
|
+
{ type: 'image', data: shot.jpeg, mimeType: 'image/jpeg' },
|
|
54
347
|
{
|
|
55
348
|
type: 'text',
|
|
56
349
|
text: 'Screenshot ' + shot.width + 'x' + shot.height + ' px' +
|
|
57
|
-
(shot.scale < 1 ? ' (screen scaled by ' + shot.scale.toFixed(3) + ')' : '') +
|
|
58
|
-
|
|
350
|
+
(shot.scale < 1 ? ' (screen scaled by ' + shot.scale.toFixed(3) + ')' : '') + '. ' + what +
|
|
351
|
+
(args.window ? '' : ' Active window: ' + describeWindow(shot.active) + '.') +
|
|
59
352
|
(path ? ' Saved as ' + path + '.' : ''),
|
|
60
353
|
},
|
|
61
354
|
];
|
|
62
355
|
}
|
|
63
356
|
case 'screen_info': {
|
|
64
357
|
const info = await shell.run('Rk-ScreenInfo');
|
|
65
|
-
const m =
|
|
358
|
+
const m = { scale: Math.min(1, MAX_WIDTH / info.width) };
|
|
66
359
|
return [
|
|
67
360
|
{
|
|
68
361
|
type: 'text',
|
|
69
362
|
text: 'Screenshot size ' + Math.round(info.width * m.scale) + 'x' + Math.round(info.height * m.scale) +
|
|
70
363
|
' px, scale ' + m.scale.toFixed(3) + ' of ' + info.width + 'x' + info.height + ' real pixels.\n' +
|
|
71
364
|
info.screens
|
|
72
|
-
.map((s) => '- ' + s.name + (s.primary ? ' (primary)' : '') + ': ' + s.width + 'x' + s.height + ' at ' + s.x + ',' + s.y)
|
|
73
|
-
.join('\n'),
|
|
365
|
+
.map((s, i) => '- screen ' + (i + 1) + ': ' + s.name + (s.primary ? ' (primary)' : '') + ': ' + s.width + 'x' + s.height + ' at ' + s.x + ',' + s.y)
|
|
366
|
+
.join('\n') + '\nObserver: ' + JSON.stringify(info.observer),
|
|
74
367
|
},
|
|
75
368
|
];
|
|
76
369
|
}
|
|
370
|
+
case 'read_screen': {
|
|
371
|
+
const { screen, scale } = await readScreen();
|
|
372
|
+
return [{ type: 'text', text: 'Screen text (OCR), centre x,y in screenshot pixels. Active window: ' + describeWindow(screen.active) + '.\n' + describeScreen(screen, scale) }];
|
|
373
|
+
}
|
|
374
|
+
case 'find_text': {
|
|
375
|
+
const lines = [];
|
|
376
|
+
let screen = null;
|
|
377
|
+
if (!BACKGROUND) {
|
|
378
|
+
({ screen } = await readScreen());
|
|
379
|
+
const matches = findText(screen, args.text);
|
|
380
|
+
if (matches.length)
|
|
381
|
+
lines.push(listMatches(matches));
|
|
382
|
+
}
|
|
383
|
+
// Controls by accessible name: the given window, else the active one when OCR saw nothing.
|
|
384
|
+
const window = args.window ?? (lines.length ? 0 : screen?.foreground ?? 0);
|
|
385
|
+
if (window) {
|
|
386
|
+
const found = await findControls(window, args.text);
|
|
387
|
+
if (found.controls.length)
|
|
388
|
+
lines.push((lines.length ? 'Controls named ' : 'No visible text, but controls named ') + JSON.stringify(args.text) + ':\n' + listControls(found));
|
|
389
|
+
}
|
|
390
|
+
if (!lines.length) {
|
|
391
|
+
return [{ type: 'text', text: 'No text or control named "' + args.text + '"' + (window ? ' in window ' + window : '') + '.' + (screen ? ' Visible text:\n' + visible(screen) : '') }];
|
|
392
|
+
}
|
|
393
|
+
return [{ type: 'text', text: lines.join('\n') }];
|
|
394
|
+
}
|
|
395
|
+
case 'wait_for': {
|
|
396
|
+
const started = Date.now();
|
|
397
|
+
const what = JSON.stringify(args.text);
|
|
398
|
+
let screen = null;
|
|
399
|
+
for (;;) {
|
|
400
|
+
let where = '';
|
|
401
|
+
if (args.window) {
|
|
402
|
+
const found = await findControls(args.window, args.text);
|
|
403
|
+
if (found.controls.length)
|
|
404
|
+
where = listControls(found);
|
|
405
|
+
}
|
|
406
|
+
else {
|
|
407
|
+
({ screen } = await readScreen());
|
|
408
|
+
const matches = findText(screen, args.text);
|
|
409
|
+
if (matches.length)
|
|
410
|
+
where = listMatches(matches);
|
|
411
|
+
}
|
|
412
|
+
const seconds = Math.round((Date.now() - started) / 100) / 10;
|
|
413
|
+
if (Boolean(where) !== args.gone) {
|
|
414
|
+
return [{ type: 'text', text: what + (args.gone ? ' is gone' : ' is on screen') + ' after ' + seconds + ' s.' + (where ? '\n' + where : '') }];
|
|
415
|
+
}
|
|
416
|
+
if (Date.now() - started >= args.timeoutSec * 1000) {
|
|
417
|
+
throw new Error('Timed out after ' + args.timeoutSec + ' s: ' + what + (args.gone ? ' is still on screen.' : ' did not appear.') +
|
|
418
|
+
(screen ? '\nVisible text:\n' + visible(screen) : ''));
|
|
419
|
+
}
|
|
420
|
+
await pause(400);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
case 'hand_over': {
|
|
424
|
+
const timeout = args.timeoutSec * 1000;
|
|
425
|
+
const result = await shell.run('Rk-HandOver ' + psQuote(args.reason) + ' ' + timeout, timeout + 15_000);
|
|
426
|
+
const outcome = { type: 'text', text: result.outcome + ' Waited ' + Math.round(result.waitedMs / 1000) + ' s.' };
|
|
427
|
+
// Background-only mode may not capture the desktop; the model snapshots its window instead.
|
|
428
|
+
return BACKGROUND ? [outcome] : [outcome, ...(await settled('screenshot'))];
|
|
429
|
+
}
|
|
77
430
|
case 'click': {
|
|
78
|
-
const
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
431
|
+
const { button, count } = args;
|
|
432
|
+
const clicked = (what) => [{ type: 'text', text: (count === 2 ? 'Double-clicked ' : 'Clicked ') + (button === 'left' ? '' : 'with the ' + button + ' button ') + what + '.' }];
|
|
433
|
+
let sx, sy, what;
|
|
434
|
+
if (args.text !== undefined) {
|
|
435
|
+
// The view stays as it is: the point comes from what is on screen now, not from the model's coordinates.
|
|
436
|
+
const screen = await ocr(true);
|
|
437
|
+
const matches = findText(screen, args.text);
|
|
438
|
+
let picked = pickMatch(matches, args.text, args.index);
|
|
439
|
+
if (typeof picked === 'string' && !matches.length && args.index === undefined && screen.foreground) {
|
|
440
|
+
// Icon buttons and menu items have names without visible text.
|
|
441
|
+
const found = await findControls(screen.foreground, args.text);
|
|
442
|
+
const control = found.controls[0];
|
|
443
|
+
if (found.controls.length === 1 && control) {
|
|
444
|
+
const [x, y, width, height] = control.bounds;
|
|
445
|
+
[sx, sy] = [Math.round(x + width / 2), Math.round(y + height / 2)];
|
|
446
|
+
await physical('Rk-Click ' + sx + ' ' + sy + ' ' + psQuote(button) + ' ' + count);
|
|
447
|
+
return clicked(control.role + ' "' + control.name + '" at ' + toView(sx, sy));
|
|
448
|
+
}
|
|
449
|
+
if (found.controls.length > 1)
|
|
450
|
+
picked = found.controls.length + ' controls are named "' + args.text + '" and none shows the text; click one of their centres:\n' + listControls(found);
|
|
451
|
+
}
|
|
452
|
+
if (typeof picked === 'string') {
|
|
453
|
+
throw new Error(picked + '\n' + (matches.length ? listMatches(matches) : 'Visible text:\n' + visible(screen)));
|
|
454
|
+
}
|
|
455
|
+
[sx, sy] = centre(picked);
|
|
456
|
+
what = '"' + picked.text + '" at ' + toView(sx, sy) + (picked.foreground ? '' : ' (outside the active window)');
|
|
457
|
+
}
|
|
458
|
+
else {
|
|
459
|
+
[sx, sy] = toScreen(args.x, args.y);
|
|
460
|
+
what = args.x + ',' + args.y;
|
|
461
|
+
}
|
|
462
|
+
await physical('Rk-Click ' + sx + ' ' + sy + ' ' + psQuote(button) + ' ' + count);
|
|
463
|
+
return clicked(what);
|
|
83
464
|
}
|
|
84
465
|
case 'move_mouse': {
|
|
85
|
-
const [x, y] =
|
|
86
|
-
await
|
|
466
|
+
const [x, y] = toScreen(args.x, args.y);
|
|
467
|
+
await physical('Rk-Move ' + x + ' ' + y);
|
|
87
468
|
return [{ type: 'text', text: 'Pointer at ' + args.x + ',' + args.y + '.' }];
|
|
88
469
|
}
|
|
89
470
|
case 'drag': {
|
|
90
|
-
const [x1, y1] =
|
|
91
|
-
const [x2, y2] =
|
|
92
|
-
await
|
|
471
|
+
const [x1, y1] = toScreen(args.fromX, args.fromY);
|
|
472
|
+
const [x2, y2] = toScreen(args.toX, args.toY);
|
|
473
|
+
await physical('Rk-Drag ' + x1 + ' ' + y1 + ' ' + x2 + ' ' + y2);
|
|
93
474
|
return [{ type: 'text', text: 'Dragged from ' + args.fromX + ',' + args.fromY + ' to ' + args.toX + ',' + args.toY + '.' }];
|
|
94
475
|
}
|
|
476
|
+
case 'draw': {
|
|
477
|
+
const plan = planDrawing(args);
|
|
478
|
+
await physical('Rk-Draw ' + psQuote(plan.packed) + ' ' + psQuote(args.button), plan.timeoutMs);
|
|
479
|
+
return [{ type: 'text', text: 'Drew ' + plan.strokes + (plan.strokes === 1 ? ' stroke' : ' strokes') + ' through ' + plan.points + ' points.' }];
|
|
480
|
+
}
|
|
95
481
|
case 'scroll': {
|
|
96
|
-
const [x, y] =
|
|
97
|
-
const direction
|
|
98
|
-
|
|
99
|
-
await shell.run('Rk-Scroll ' + x + ' ' + y + ' ' + psQuote(direction) + ' ' + amount);
|
|
482
|
+
const [x, y] = toScreen(args.x, args.y);
|
|
483
|
+
const { direction, amount } = args;
|
|
484
|
+
await physical('Rk-Scroll ' + x + ' ' + y + ' ' + psQuote(direction) + ' ' + amount);
|
|
100
485
|
return [{ type: 'text', text: 'Scrolled ' + direction + ' by ' + amount + '.' }];
|
|
101
486
|
}
|
|
102
487
|
case 'type_text': {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
throw new Error('Nothing to type.');
|
|
106
|
-
await shell.run('Rk-Type ' + psQuote(value), 120_000);
|
|
107
|
-
return [{ type: 'text', text: 'Typed ' + value.length + ' characters.' }];
|
|
488
|
+
await physical('Rk-Type ' + psQuote(args.text));
|
|
489
|
+
return [{ type: 'text', text: 'Typed ' + args.text.length + ' characters.' }];
|
|
108
490
|
}
|
|
109
491
|
case 'press_keys': {
|
|
110
|
-
const combos = parseKeySequence(
|
|
111
|
-
if (!combos.length)
|
|
112
|
-
throw new Error('Which keys?');
|
|
492
|
+
const combos = parseKeySequence(args.keys);
|
|
113
493
|
const literal = '@(' + combos.map((combo) => ',@(' + combo.join(',') + ')').join(';') + ')';
|
|
114
|
-
await
|
|
115
|
-
return [{ type: 'text', text: 'Pressed ' +
|
|
494
|
+
await physical('Rk-Keys ' + literal);
|
|
495
|
+
return [{ type: 'text', text: 'Pressed ' + args.keys + '.' }];
|
|
116
496
|
}
|
|
117
497
|
case 'list_windows': {
|
|
118
498
|
const rows = await shell.run('Rk-Windows');
|
|
@@ -123,37 +503,39 @@ async function call(name, args) {
|
|
|
123
503
|
{
|
|
124
504
|
type: 'text',
|
|
125
505
|
text: list
|
|
126
|
-
.map((w) => '- ' + (w.active ? '[active] ' : '') + w.title + ' (' + w.process + ') ' +
|
|
506
|
+
.map((w) => '- window=' + w.handle + ' ' + (w.active ? '[active] ' : '') + JSON.stringify(w.title) + ' (' + w.process + ') ' +
|
|
507
|
+
(w.minimized ? 'minimized' : w.width + 'x' + w.height + ' at ' + w.x + ',' + w.y))
|
|
127
508
|
.join('\n'),
|
|
128
509
|
},
|
|
129
510
|
];
|
|
130
511
|
}
|
|
131
512
|
case 'focus_window': {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
const result = await shell.run('Rk-Focus ' + psQuote(needle));
|
|
136
|
-
return [{ type: 'text', text: (result.ok ? 'Focused ' : 'Tried to focus ') + '"' + result.title + '".' }];
|
|
513
|
+
view = null;
|
|
514
|
+
const result = await shell.run('Rk-Focus ' + psQuote(args.title ?? '') + ' ' + (args.window ?? 0));
|
|
515
|
+
return [{ type: 'text', text: 'Focused ' + describeWindow(result) + '.' }];
|
|
137
516
|
}
|
|
138
517
|
case 'open': {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
518
|
+
view = null;
|
|
519
|
+
const result = await shell.run('Rk-Open ' + psQuote(args.target), 15_000);
|
|
520
|
+
if (!result.changed) {
|
|
521
|
+
// Nothing to type into yet: say so as an error, so the model does not send input to whatever is in front.
|
|
522
|
+
throw new Error('Opened ' + args.target + ', but no window came to the front within 3 s' +
|
|
523
|
+
(result.behind ? ': ' + describeWindow(result.behind) + ' stayed behind ' : '; the active window is still ') + describeWindow(result.active) +
|
|
524
|
+
'. Nothing was typed. Use focus_window with the handle, or wait_for, then take a screenshot.');
|
|
525
|
+
}
|
|
526
|
+
return [{ type: 'text', text: 'Opened ' + args.target + '. Active window is now ' + describeWindow(result.active) + '.' }];
|
|
144
527
|
}
|
|
145
528
|
case 'clipboard': {
|
|
146
|
-
if (
|
|
147
|
-
await shell.run('Rk-ClipSet ' + psQuote(text
|
|
148
|
-
return [{ type: 'text', text: 'Clipboard set (' +
|
|
529
|
+
if (args.action === 'set') {
|
|
530
|
+
await shell.run('Rk-ClipSet ' + psQuote(args.text ?? ''));
|
|
531
|
+
return [{ type: 'text', text: 'Clipboard set (' + args.text.length + ' characters).' }];
|
|
149
532
|
}
|
|
150
533
|
const result = await shell.run('Rk-ClipGet');
|
|
151
534
|
return [{ type: 'text', text: result.text ? result.text.slice(0, 20_000) : '(clipboard is empty)' }];
|
|
152
535
|
}
|
|
153
536
|
case 'wait': {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
return [{ type: 'text', text: 'Waited ' + ms + ' ms.' }];
|
|
537
|
+
await pause(args.ms);
|
|
538
|
+
return [{ type: 'text', text: 'Waited ' + args.ms + ' ms.' }];
|
|
157
539
|
}
|
|
158
540
|
default:
|
|
159
541
|
throw new Error('Unknown tool ' + name + '.');
|
|
@@ -165,6 +547,10 @@ function send(message) {
|
|
|
165
547
|
}
|
|
166
548
|
async function handle(message) {
|
|
167
549
|
const { id, method, params } = message;
|
|
550
|
+
if (method === 'notifications/cancelled' && pending.has(params?.requestId)) {
|
|
551
|
+
await call({ name: 'stop', args: {} });
|
|
552
|
+
return;
|
|
553
|
+
}
|
|
168
554
|
if (id === undefined)
|
|
169
555
|
return;
|
|
170
556
|
try {
|
|
@@ -175,7 +561,7 @@ async function handle(message) {
|
|
|
175
561
|
result: {
|
|
176
562
|
protocolVersion: params?.protocolVersion ?? PROTOCOL_FALLBACK,
|
|
177
563
|
capabilities: { tools: {} },
|
|
178
|
-
serverInfo: { name: COMPUTER_SERVER_NAME, version: '0.
|
|
564
|
+
serverInfo: { name: COMPUTER_SERVER_NAME, version: '0.2.0' },
|
|
179
565
|
},
|
|
180
566
|
});
|
|
181
567
|
return;
|
|
@@ -192,11 +578,42 @@ async function handle(message) {
|
|
|
192
578
|
send({ id, result: { content: [{ type: 'text', text: 'Computer control is available on Windows only.' }], isError: true } });
|
|
193
579
|
return;
|
|
194
580
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
581
|
+
pending.add(id);
|
|
582
|
+
const execute = async () => {
|
|
583
|
+
const started = performance.now();
|
|
584
|
+
let failure;
|
|
585
|
+
try {
|
|
586
|
+
const content = await call(validateComputerCall(name, args, BACKGROUND));
|
|
587
|
+
content.push({ type: 'text', text: JSON.stringify({ durationMs: Math.round(performance.now() - started), mode: BACKGROUND ? 'background' : 'desktop' }) });
|
|
588
|
+
send({ id, result: { content, isError: false } });
|
|
589
|
+
}
|
|
590
|
+
catch (error) {
|
|
591
|
+
failure = error.message;
|
|
592
|
+
send({ id, result: { content: [{ type: 'text', text: failure }], isError: true } });
|
|
593
|
+
}
|
|
594
|
+
finally {
|
|
595
|
+
pending.delete(id);
|
|
596
|
+
if (RUN_DIR) {
|
|
597
|
+
// The audit says which tool, how long, and why it failed; never what was typed or seen.
|
|
598
|
+
const steps = name === 'batch' && Array.isArray(args.actions) ? args.actions.length : undefined;
|
|
599
|
+
try {
|
|
600
|
+
mkdirSync(RUN_DIR, { recursive: true });
|
|
601
|
+
appendFileSync(join(RUN_DIR, 'computer-audit.jsonl'), JSON.stringify({
|
|
602
|
+
at: new Date().toISOString(), session: process.pid, tool: name, ...(steps === undefined ? {} : { steps }),
|
|
603
|
+
durationMs: Math.round(performance.now() - started), isError: failure !== undefined,
|
|
604
|
+
...(failure === undefined ? {} : { error: failure.split('\n')[0].replace(/"[^"]*"/g, '"…"').slice(0, 200) }),
|
|
605
|
+
}) + '\n');
|
|
606
|
+
}
|
|
607
|
+
catch { /* Audit storage failure must not retry an already-dispatched action. */ }
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
};
|
|
611
|
+
if (name === 'stop')
|
|
612
|
+
await execute();
|
|
613
|
+
else {
|
|
614
|
+
const task = queue.then(execute);
|
|
615
|
+
queue = task.catch(() => undefined);
|
|
616
|
+
await task;
|
|
200
617
|
}
|
|
201
618
|
return;
|
|
202
619
|
}
|
|
@@ -215,14 +632,39 @@ input.on('line', (line) => {
|
|
|
215
632
|
let message;
|
|
216
633
|
try {
|
|
217
634
|
message = JSON.parse(line);
|
|
635
|
+
if (!message || typeof message !== 'object' || Array.isArray(message))
|
|
636
|
+
return;
|
|
218
637
|
}
|
|
219
638
|
catch {
|
|
220
639
|
return;
|
|
221
640
|
}
|
|
222
641
|
void handle(message);
|
|
223
642
|
});
|
|
224
|
-
|
|
643
|
+
/**
|
|
644
|
+
* The turn is over when the CLI closes our stdin. The cursor fades out
|
|
645
|
+
* first, bounded so a stuck action cannot hold the exit, and a drag or
|
|
646
|
+
* shortcut cut off mid-way lets go of what it held; a hard kill skips this,
|
|
647
|
+
* and the worker then ends itself with this process instead.
|
|
648
|
+
*/
|
|
649
|
+
let closing = false;
|
|
650
|
+
async function shutdown() {
|
|
651
|
+
if (closing)
|
|
652
|
+
return;
|
|
653
|
+
closing = true;
|
|
654
|
+
if (shell.running) {
|
|
655
|
+
await Promise.race([
|
|
656
|
+
shell.run('Rk-CursorDismiss; @{}', 2000).catch(() => undefined),
|
|
657
|
+
delay(700),
|
|
658
|
+
]);
|
|
659
|
+
}
|
|
660
|
+
const held = inputInFlight > 0;
|
|
661
|
+
shell.close();
|
|
662
|
+
if (held)
|
|
663
|
+
await releaseHeld(3000);
|
|
225
664
|
shell.close();
|
|
226
665
|
process.exit(0);
|
|
227
|
-
}
|
|
666
|
+
}
|
|
667
|
+
input.on('close', () => void shutdown());
|
|
668
|
+
process.on('SIGINT', () => void shutdown());
|
|
669
|
+
process.on('SIGTERM', () => void shutdown());
|
|
228
670
|
//# sourceMappingURL=mcp-server.js.map
|