@shykaruu/jarvis-brain 0.4.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/LICENSE +153 -0
- package/README.md +428 -0
- package/bin/jarvis.ts +449 -0
- package/package.json +79 -0
- package/roles/activity-observer.yaml +60 -0
- package/roles/ceo-founder.yaml +144 -0
- package/roles/chief-of-staff.yaml +158 -0
- package/roles/dev-lead.yaml +182 -0
- package/roles/executive-assistant.yaml +77 -0
- package/roles/marketing-director.yaml +168 -0
- package/roles/personal-assistant.yaml +266 -0
- package/roles/research-specialist.yaml +60 -0
- package/roles/specialists/content-writer.yaml +53 -0
- package/roles/specialists/customer-support.yaml +57 -0
- package/roles/specialists/data-analyst.yaml +57 -0
- package/roles/specialists/financial-analyst.yaml +56 -0
- package/roles/specialists/hr-specialist.yaml +55 -0
- package/roles/specialists/legal-advisor.yaml +58 -0
- package/roles/specialists/marketing-strategist.yaml +56 -0
- package/roles/specialists/project-coordinator.yaml +55 -0
- package/roles/specialists/research-analyst.yaml +58 -0
- package/roles/specialists/software-engineer.yaml +57 -0
- package/roles/specialists/system-administrator.yaml +57 -0
- package/roles/system-admin.yaml +76 -0
- package/scripts/ensure-bun.cjs +16 -0
- package/src/actions/README.md +421 -0
- package/src/actions/app-control/desktop-controller.test.ts +26 -0
- package/src/actions/app-control/desktop-controller.ts +438 -0
- package/src/actions/app-control/interface.ts +64 -0
- package/src/actions/app-control/linux.ts +273 -0
- package/src/actions/app-control/macos.ts +54 -0
- package/src/actions/app-control/sidecar-launcher.test.ts +23 -0
- package/src/actions/app-control/sidecar-launcher.ts +286 -0
- package/src/actions/app-control/windows.ts +44 -0
- package/src/actions/browser/cdp.ts +138 -0
- package/src/actions/browser/chrome-launcher.ts +261 -0
- package/src/actions/browser/session.ts +506 -0
- package/src/actions/browser/stealth.ts +49 -0
- package/src/actions/index.ts +20 -0
- package/src/actions/terminal/executor.ts +157 -0
- package/src/actions/terminal/wsl-bridge.ts +126 -0
- package/src/actions/test.ts +93 -0
- package/src/actions/tools/agents.ts +363 -0
- package/src/actions/tools/builtin.ts +950 -0
- package/src/actions/tools/commitments.ts +192 -0
- package/src/actions/tools/content.ts +217 -0
- package/src/actions/tools/delegate.ts +147 -0
- package/src/actions/tools/desktop.test.ts +55 -0
- package/src/actions/tools/desktop.ts +305 -0
- package/src/actions/tools/documents.ts +169 -0
- package/src/actions/tools/goals.ts +376 -0
- package/src/actions/tools/local-tools-guard.ts +31 -0
- package/src/actions/tools/registry.ts +173 -0
- package/src/actions/tools/research.ts +111 -0
- package/src/actions/tools/sidecar-list.ts +57 -0
- package/src/actions/tools/sidecar-route.ts +105 -0
- package/src/actions/tools/workflows.ts +216 -0
- package/src/agents/agent.ts +132 -0
- package/src/agents/delegation.ts +107 -0
- package/src/agents/hierarchy.ts +113 -0
- package/src/agents/index.ts +19 -0
- package/src/agents/messaging.ts +125 -0
- package/src/agents/orchestrator.ts +592 -0
- package/src/agents/role-discovery.ts +61 -0
- package/src/agents/sub-agent-runner.ts +309 -0
- package/src/agents/task-manager.ts +151 -0
- package/src/authority/approval-delivery.ts +59 -0
- package/src/authority/approval.ts +196 -0
- package/src/authority/audit.ts +158 -0
- package/src/authority/authority.test.ts +519 -0
- package/src/authority/deferred-executor.ts +103 -0
- package/src/authority/emergency.ts +66 -0
- package/src/authority/engine.ts +301 -0
- package/src/authority/index.ts +12 -0
- package/src/authority/learning.ts +111 -0
- package/src/authority/tool-action-map.ts +74 -0
- package/src/awareness/analytics.ts +466 -0
- package/src/awareness/awareness.test.ts +332 -0
- package/src/awareness/capture-engine.ts +305 -0
- package/src/awareness/context-graph.ts +130 -0
- package/src/awareness/context-tracker.ts +349 -0
- package/src/awareness/index.ts +25 -0
- package/src/awareness/intelligence.ts +321 -0
- package/src/awareness/ocr-engine.ts +88 -0
- package/src/awareness/service.ts +528 -0
- package/src/awareness/struggle-detector.ts +342 -0
- package/src/awareness/suggestion-engine.ts +476 -0
- package/src/awareness/types.ts +201 -0
- package/src/cli/autostart.ts +417 -0
- package/src/cli/deps.ts +449 -0
- package/src/cli/doctor.ts +238 -0
- package/src/cli/helpers.ts +401 -0
- package/src/cli/onboard.ts +827 -0
- package/src/cli/uninstall.test.ts +37 -0
- package/src/cli/uninstall.ts +202 -0
- package/src/comms/README.md +329 -0
- package/src/comms/auth-error.html +48 -0
- package/src/comms/channels/discord.ts +228 -0
- package/src/comms/channels/signal.ts +56 -0
- package/src/comms/channels/telegram.ts +316 -0
- package/src/comms/channels/whatsapp.ts +60 -0
- package/src/comms/channels.test.ts +173 -0
- package/src/comms/dashboard-auth.ts +75 -0
- package/src/comms/desktop-notify.ts +114 -0
- package/src/comms/example.ts +129 -0
- package/src/comms/index.ts +129 -0
- package/src/comms/streaming.ts +149 -0
- package/src/comms/voice.test.ts +504 -0
- package/src/comms/voice.ts +341 -0
- package/src/comms/websocket.test.ts +409 -0
- package/src/comms/websocket.ts +669 -0
- package/src/config/README.md +389 -0
- package/src/config/index.ts +6 -0
- package/src/config/loader.test.ts +183 -0
- package/src/config/loader.ts +148 -0
- package/src/config/types.ts +293 -0
- package/src/daemon/README.md +232 -0
- package/src/daemon/agent-service-interface.ts +9 -0
- package/src/daemon/agent-service.ts +667 -0
- package/src/daemon/api-routes.ts +3067 -0
- package/src/daemon/background-agent-service.ts +396 -0
- package/src/daemon/background-agent.test.ts +78 -0
- package/src/daemon/channel-service.ts +201 -0
- package/src/daemon/commitment-executor.ts +297 -0
- package/src/daemon/dashboard-auth.test.ts +170 -0
- package/src/daemon/event-classifier.ts +239 -0
- package/src/daemon/event-coalescer.ts +123 -0
- package/src/daemon/event-reactor.ts +214 -0
- package/src/daemon/flock.c +7 -0
- package/src/daemon/health.ts +220 -0
- package/src/daemon/index.ts +1070 -0
- package/src/daemon/llm-settings.test.ts +78 -0
- package/src/daemon/llm-settings.ts +450 -0
- package/src/daemon/observer-service.ts +150 -0
- package/src/daemon/pid.test.ts +283 -0
- package/src/daemon/pid.ts +224 -0
- package/src/daemon/research-queue.ts +155 -0
- package/src/daemon/services.ts +175 -0
- package/src/daemon/ws-service.ts +926 -0
- package/src/global.d.ts +4 -0
- package/src/goals/accountability.ts +240 -0
- package/src/goals/awareness-bridge.ts +185 -0
- package/src/goals/estimator.ts +185 -0
- package/src/goals/events.ts +28 -0
- package/src/goals/goals.test.ts +400 -0
- package/src/goals/integration.test.ts +329 -0
- package/src/goals/nl-builder.test.ts +220 -0
- package/src/goals/nl-builder.ts +256 -0
- package/src/goals/rhythm.test.ts +177 -0
- package/src/goals/rhythm.ts +275 -0
- package/src/goals/service.test.ts +135 -0
- package/src/goals/service.ts +407 -0
- package/src/goals/types.ts +106 -0
- package/src/goals/workflow-bridge.ts +96 -0
- package/src/integrations/google-api.ts +134 -0
- package/src/integrations/google-auth.ts +175 -0
- package/src/llm/README.md +291 -0
- package/src/llm/anthropic.ts +400 -0
- package/src/llm/gemini.ts +380 -0
- package/src/llm/groq.ts +406 -0
- package/src/llm/history.ts +147 -0
- package/src/llm/index.ts +21 -0
- package/src/llm/manager.ts +226 -0
- package/src/llm/ollama.ts +316 -0
- package/src/llm/openai.ts +411 -0
- package/src/llm/openrouter.ts +390 -0
- package/src/llm/provider.test.ts +487 -0
- package/src/llm/provider.ts +61 -0
- package/src/llm/test.ts +88 -0
- package/src/observers/README.md +278 -0
- package/src/observers/calendar.ts +113 -0
- package/src/observers/clipboard.ts +136 -0
- package/src/observers/email.ts +109 -0
- package/src/observers/example.ts +58 -0
- package/src/observers/file-watcher.ts +124 -0
- package/src/observers/index.ts +159 -0
- package/src/observers/notifications.ts +197 -0
- package/src/observers/observers.test.ts +203 -0
- package/src/observers/processes.ts +225 -0
- package/src/personality/README.md +61 -0
- package/src/personality/adapter.ts +196 -0
- package/src/personality/index.ts +20 -0
- package/src/personality/learner.ts +209 -0
- package/src/personality/model.ts +132 -0
- package/src/personality/personality.test.ts +236 -0
- package/src/roles/README.md +252 -0
- package/src/roles/authority.ts +120 -0
- package/src/roles/example-usage.ts +198 -0
- package/src/roles/index.ts +42 -0
- package/src/roles/loader.ts +143 -0
- package/src/roles/prompt-builder.ts +218 -0
- package/src/roles/test-multi.ts +102 -0
- package/src/roles/test-role.yaml +77 -0
- package/src/roles/test-utils.ts +93 -0
- package/src/roles/test.ts +106 -0
- package/src/roles/tool-guide.ts +195 -0
- package/src/roles/types.ts +36 -0
- package/src/roles/utils.ts +200 -0
- package/src/scripts/google-setup.ts +168 -0
- package/src/sidecar/connection.ts +179 -0
- package/src/sidecar/index.ts +6 -0
- package/src/sidecar/manager.ts +542 -0
- package/src/sidecar/protocol.ts +85 -0
- package/src/sidecar/rpc.ts +161 -0
- package/src/sidecar/scheduler.ts +136 -0
- package/src/sidecar/types.ts +112 -0
- package/src/sidecar/validator.ts +144 -0
- package/src/sites/builder-tools.ts +215 -0
- package/src/sites/dev-server-manager.ts +286 -0
- package/src/sites/fixtures/security-test-site/.jarvis-project.json +6 -0
- package/src/sites/fixtures/security-test-site/Makefile +15 -0
- package/src/sites/fixtures/security-test-site/README.md +18 -0
- package/src/sites/fixtures/security-test-site/index.html +12 -0
- package/src/sites/fixtures/security-test-site/index.ts +16 -0
- package/src/sites/fixtures/security-test-site/package.json +13 -0
- package/src/sites/fixtures/security-test-site/src/app.tsx +780 -0
- package/src/sites/fixtures/security-test-site/tsconfig.json +10 -0
- package/src/sites/git-manager.ts +240 -0
- package/src/sites/github-manager.ts +355 -0
- package/src/sites/index.ts +25 -0
- package/src/sites/project-manager.ts +389 -0
- package/src/sites/proxy.ts +133 -0
- package/src/sites/service.ts +136 -0
- package/src/sites/templates.ts +169 -0
- package/src/sites/types.ts +89 -0
- package/src/user/profile-followup.test.ts +84 -0
- package/src/user/profile-followup.ts +185 -0
- package/src/user/profile.ts +224 -0
- package/src/vault/README.md +110 -0
- package/src/vault/awareness.ts +341 -0
- package/src/vault/commitments.ts +299 -0
- package/src/vault/content-pipeline.ts +270 -0
- package/src/vault/conversations.ts +173 -0
- package/src/vault/dashboard-sessions.ts +44 -0
- package/src/vault/documents.ts +130 -0
- package/src/vault/entities.ts +185 -0
- package/src/vault/extractor.test.ts +356 -0
- package/src/vault/extractor.ts +345 -0
- package/src/vault/facts.ts +190 -0
- package/src/vault/goals.ts +477 -0
- package/src/vault/index.ts +87 -0
- package/src/vault/keychain.ts +99 -0
- package/src/vault/observations.ts +115 -0
- package/src/vault/relationships.ts +178 -0
- package/src/vault/retrieval.test.ts +139 -0
- package/src/vault/retrieval.ts +258 -0
- package/src/vault/schema.ts +709 -0
- package/src/vault/settings.ts +38 -0
- package/src/vault/user-profile.test.ts +113 -0
- package/src/vault/user-profile.ts +176 -0
- package/src/vault/vectors.ts +92 -0
- package/src/vault/webapp-template-seeds.ts +116 -0
- package/src/vault/webapp-templates.ts +244 -0
- package/src/vault/workflows.ts +403 -0
- package/src/workflows/auto-suggest.ts +290 -0
- package/src/workflows/engine.ts +366 -0
- package/src/workflows/events.ts +24 -0
- package/src/workflows/executor.ts +207 -0
- package/src/workflows/nl-builder.ts +198 -0
- package/src/workflows/nodes/actions/agent-task.ts +73 -0
- package/src/workflows/nodes/actions/calendar-action.ts +85 -0
- package/src/workflows/nodes/actions/code-execution.ts +73 -0
- package/src/workflows/nodes/actions/discord.ts +77 -0
- package/src/workflows/nodes/actions/file-write.ts +73 -0
- package/src/workflows/nodes/actions/gmail.ts +69 -0
- package/src/workflows/nodes/actions/http-request.ts +117 -0
- package/src/workflows/nodes/actions/notification.ts +85 -0
- package/src/workflows/nodes/actions/run-tool.ts +55 -0
- package/src/workflows/nodes/actions/send-message.ts +82 -0
- package/src/workflows/nodes/actions/shell-command.ts +76 -0
- package/src/workflows/nodes/actions/telegram.ts +60 -0
- package/src/workflows/nodes/builtin.ts +119 -0
- package/src/workflows/nodes/error/error-handler.ts +37 -0
- package/src/workflows/nodes/error/fallback.ts +47 -0
- package/src/workflows/nodes/error/retry.ts +82 -0
- package/src/workflows/nodes/logic/delay.ts +42 -0
- package/src/workflows/nodes/logic/if-else.ts +41 -0
- package/src/workflows/nodes/logic/loop.ts +90 -0
- package/src/workflows/nodes/logic/merge.ts +38 -0
- package/src/workflows/nodes/logic/race.ts +40 -0
- package/src/workflows/nodes/logic/switch.ts +59 -0
- package/src/workflows/nodes/logic/template-render.ts +53 -0
- package/src/workflows/nodes/logic/variable-get.ts +37 -0
- package/src/workflows/nodes/logic/variable-set.ts +59 -0
- package/src/workflows/nodes/registry.ts +99 -0
- package/src/workflows/nodes/transform/aggregate.ts +99 -0
- package/src/workflows/nodes/transform/csv-parse.ts +70 -0
- package/src/workflows/nodes/transform/json-parse.ts +63 -0
- package/src/workflows/nodes/transform/map-filter.ts +84 -0
- package/src/workflows/nodes/transform/regex-match.ts +89 -0
- package/src/workflows/nodes/triggers/calendar.ts +33 -0
- package/src/workflows/nodes/triggers/clipboard.ts +32 -0
- package/src/workflows/nodes/triggers/cron.ts +40 -0
- package/src/workflows/nodes/triggers/email.ts +40 -0
- package/src/workflows/nodes/triggers/file-change.ts +45 -0
- package/src/workflows/nodes/triggers/git.ts +46 -0
- package/src/workflows/nodes/triggers/manual.ts +23 -0
- package/src/workflows/nodes/triggers/poll.ts +81 -0
- package/src/workflows/nodes/triggers/process.ts +44 -0
- package/src/workflows/nodes/triggers/screen-event.ts +37 -0
- package/src/workflows/nodes/triggers/webhook.ts +39 -0
- package/src/workflows/safe-eval.ts +139 -0
- package/src/workflows/template.ts +118 -0
- package/src/workflows/triggers/cron.ts +311 -0
- package/src/workflows/triggers/manager.ts +285 -0
- package/src/workflows/triggers/observer-bridge.ts +172 -0
- package/src/workflows/triggers/poller.ts +201 -0
- package/src/workflows/triggers/screen-condition.ts +218 -0
- package/src/workflows/triggers/triggers.test.ts +740 -0
- package/src/workflows/triggers/webhook.ts +191 -0
- package/src/workflows/types.ts +133 -0
- package/src/workflows/variables.ts +72 -0
- package/src/workflows/workflows.test.ts +383 -0
- package/src/workflows/yaml.ts +104 -0
- package/ui/dist/index-3gr23jt9.js +112614 -0
- package/ui/dist/index-9vmj8127.css +14239 -0
- package/ui/dist/index-hy9pc1gm.js +112873 -0
- package/ui/dist/index-j2ep5d1w.js +112374 -0
- package/ui/dist/index-jt00vjqs.js +112858 -0
- package/ui/dist/index-k9ymx5qb.js +112374 -0
- package/ui/dist/index.html +16 -0
- package/ui/public/audio/pcm-capture-processor.js +11 -0
- package/ui/public/openwakeword/models/embedding_model.onnx +0 -0
- package/ui/public/openwakeword/models/hey_jarvis_v0.1.onnx +0 -0
- package/ui/public/openwakeword/models/melspectrogram.onnx +0 -0
- package/ui/public/openwakeword/models/silero_vad.onnx +0 -0
- package/ui/public/ort/ort-wasm-simd-threaded.jsep.mjs +106 -0
- package/ui/public/ort/ort-wasm-simd-threaded.jsep.wasm +0 -0
- package/ui/public/ort/ort-wasm-simd-threaded.mjs +59 -0
- package/ui/public/ort/ort-wasm-simd-threaded.wasm +0 -0
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Desktop Tools — Desktop Automation via Sidecar RPC or Local Execution
|
|
3
|
+
*
|
|
4
|
+
* 9 tools for controlling desktop applications. Each tool accepts a `target`
|
|
5
|
+
* parameter to route to a specific sidecar. Without `target`, attempts local
|
|
6
|
+
* execution (currently stub — TODO: implement per-platform AppController).
|
|
7
|
+
* Respects --no-local-tools flag.
|
|
8
|
+
*
|
|
9
|
+
* The same tools work on all platforms (Windows, macOS, Linux). The sidecar
|
|
10
|
+
* handles platform-specific implementation details internally.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import type { ToolDefinition, ToolResult } from './registry.ts';
|
|
14
|
+
import { routeToSidecar } from './sidecar-route.ts';
|
|
15
|
+
import { isNoLocalTools } from './local-tools-guard.ts';
|
|
16
|
+
|
|
17
|
+
const LOCAL_NOT_IMPLEMENTED = 'Error: Local desktop tool execution is not yet implemented. Specify a "target" sidecar to route this command to a remote machine, or use list_sidecars to see available sidecars.';
|
|
18
|
+
const LOCAL_DISABLED_MSG = 'Error: Local tool execution is disabled (--no-local-tools). Specify a "target" sidecar to route this command to a remote machine. Use list_sidecars to see available sidecars.';
|
|
19
|
+
|
|
20
|
+
function localGuard(): string {
|
|
21
|
+
if (isNoLocalTools()) return LOCAL_DISABLED_MSG;
|
|
22
|
+
return LOCAL_NOT_IMPLEMENTED;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// --- Tool definitions ---
|
|
26
|
+
|
|
27
|
+
export const desktopListWindowsTool: ToolDefinition = {
|
|
28
|
+
name: 'desktop_list_windows',
|
|
29
|
+
description: 'List all visible windows on the desktop. Returns window titles, PIDs, class names, and positions. Use the PID with other desktop tools to target a specific window.',
|
|
30
|
+
category: 'desktop',
|
|
31
|
+
parameters: {
|
|
32
|
+
target: {
|
|
33
|
+
type: 'string',
|
|
34
|
+
description: 'Sidecar name or ID to route this command to (omit for local execution)',
|
|
35
|
+
required: false,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
execute: async (params) => {
|
|
39
|
+
const target = params.target as string | undefined;
|
|
40
|
+
if (target) {
|
|
41
|
+
return routeToSidecar(target, 'list_windows', params, 'desktop');
|
|
42
|
+
}
|
|
43
|
+
return localGuard();
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const desktopSnapshotTool: ToolDefinition = {
|
|
48
|
+
name: 'desktop_snapshot',
|
|
49
|
+
description: 'Get the UI element tree of a window (like browser_snapshot but for desktop apps). Each element has an [id] you can use with desktop_click and desktop_type. If no pid is given, snapshots the active (focused) window.',
|
|
50
|
+
category: 'desktop',
|
|
51
|
+
parameters: {
|
|
52
|
+
target: {
|
|
53
|
+
type: 'string',
|
|
54
|
+
description: 'Sidecar name or ID to route this command to (omit for local execution)',
|
|
55
|
+
required: false,
|
|
56
|
+
},
|
|
57
|
+
pid: {
|
|
58
|
+
type: 'number',
|
|
59
|
+
description: 'Process ID of the window (from desktop_list_windows). Omit for the active window.',
|
|
60
|
+
required: false,
|
|
61
|
+
},
|
|
62
|
+
depth: {
|
|
63
|
+
type: 'number',
|
|
64
|
+
description: 'Max tree depth to walk (default: 8). Decrease for faster but shallower snapshots.',
|
|
65
|
+
required: false,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
execute: async (params) => {
|
|
69
|
+
const target = params.target as string | undefined;
|
|
70
|
+
if (target) {
|
|
71
|
+
return routeToSidecar(target, 'get_window_tree', params, 'desktop');
|
|
72
|
+
}
|
|
73
|
+
return localGuard();
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export const desktopClickTool: ToolDefinition = {
|
|
78
|
+
name: 'desktop_click',
|
|
79
|
+
description: 'Click or interact with a UI element by its [id] from the last desktop_snapshot or desktop_find_element. Default action is "click". Use the action parameter for richer interactions like double_click, right_click, invoke, toggle, set_value, expand, etc. Available actions vary by platform.',
|
|
80
|
+
category: 'desktop',
|
|
81
|
+
parameters: {
|
|
82
|
+
target: {
|
|
83
|
+
type: 'string',
|
|
84
|
+
description: 'Sidecar name or ID to route this command to (omit for local execution)',
|
|
85
|
+
required: false,
|
|
86
|
+
},
|
|
87
|
+
element_id: {
|
|
88
|
+
type: 'number',
|
|
89
|
+
description: 'The [id] of the element to interact with (from desktop_snapshot or desktop_find_element)',
|
|
90
|
+
required: true,
|
|
91
|
+
},
|
|
92
|
+
action: {
|
|
93
|
+
type: 'string',
|
|
94
|
+
description: 'Action to perform: click (default), double_click, right_click, invoke, toggle, select, set_value, get_value, get_text, expand, collapse, scroll_into_view, focus',
|
|
95
|
+
required: false,
|
|
96
|
+
},
|
|
97
|
+
value: {
|
|
98
|
+
type: 'string',
|
|
99
|
+
description: 'Value to set (only for set_value action)',
|
|
100
|
+
required: false,
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
execute: async (params) => {
|
|
104
|
+
const target = params.target as string | undefined;
|
|
105
|
+
if (target) {
|
|
106
|
+
return routeToSidecar(target, 'click_element', params, 'desktop');
|
|
107
|
+
}
|
|
108
|
+
return localGuard();
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export const desktopTypeTool: ToolDefinition = {
|
|
113
|
+
name: 'desktop_type',
|
|
114
|
+
description: 'Type text into a UI element. Optionally provide an element_id to click and focus it first. Without element_id, types into whatever is currently focused.',
|
|
115
|
+
category: 'desktop',
|
|
116
|
+
parameters: {
|
|
117
|
+
target: {
|
|
118
|
+
type: 'string',
|
|
119
|
+
description: 'Sidecar name or ID to route this command to (omit for local execution)',
|
|
120
|
+
required: false,
|
|
121
|
+
},
|
|
122
|
+
text: {
|
|
123
|
+
type: 'string',
|
|
124
|
+
description: 'The text to type',
|
|
125
|
+
required: true,
|
|
126
|
+
},
|
|
127
|
+
element_id: {
|
|
128
|
+
type: 'number',
|
|
129
|
+
description: 'Optional [id] of element to click before typing (from desktop_snapshot)',
|
|
130
|
+
required: false,
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
execute: async (params) => {
|
|
134
|
+
const target = params.target as string | undefined;
|
|
135
|
+
if (target) {
|
|
136
|
+
return routeToSidecar(target, 'type_text', params, 'desktop');
|
|
137
|
+
}
|
|
138
|
+
return localGuard();
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export const desktopPressKeysTool: ToolDefinition = {
|
|
143
|
+
name: 'desktop_press_keys',
|
|
144
|
+
description: 'Press a keyboard shortcut or key combination. Keys are pressed simultaneously (e.g., "ctrl,s" for save, "alt,f4" to close). Single keys also work: "enter", "tab", "escape".',
|
|
145
|
+
category: 'desktop',
|
|
146
|
+
parameters: {
|
|
147
|
+
target: {
|
|
148
|
+
type: 'string',
|
|
149
|
+
description: 'Sidecar name or ID to route this command to (omit for local execution)',
|
|
150
|
+
required: false,
|
|
151
|
+
},
|
|
152
|
+
keys: {
|
|
153
|
+
type: 'string',
|
|
154
|
+
description: 'Comma-separated key names (e.g., "ctrl,s" or "alt,f4" or "enter"). Modifiers: ctrl, alt, shift, win.',
|
|
155
|
+
required: true,
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
execute: async (params) => {
|
|
159
|
+
const target = params.target as string | undefined;
|
|
160
|
+
if (target) {
|
|
161
|
+
return routeToSidecar(target, 'press_keys', params, 'desktop');
|
|
162
|
+
}
|
|
163
|
+
return localGuard();
|
|
164
|
+
},
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
export const desktopLaunchAppTool: ToolDefinition = {
|
|
168
|
+
name: 'desktop_launch_app',
|
|
169
|
+
description: 'Launch an application by executable path or name (e.g., "notepad.exe", "calc.exe"). Returns the PID of the launched process.',
|
|
170
|
+
category: 'desktop',
|
|
171
|
+
parameters: {
|
|
172
|
+
target: {
|
|
173
|
+
type: 'string',
|
|
174
|
+
description: 'Sidecar name or ID to route this command to (omit for local execution)',
|
|
175
|
+
required: false,
|
|
176
|
+
},
|
|
177
|
+
executable: {
|
|
178
|
+
type: 'string',
|
|
179
|
+
description: 'Application executable path or name',
|
|
180
|
+
required: true,
|
|
181
|
+
},
|
|
182
|
+
args: {
|
|
183
|
+
type: 'string',
|
|
184
|
+
description: 'Optional command-line arguments',
|
|
185
|
+
required: false,
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
execute: async (params) => {
|
|
189
|
+
const target = params.target as string | undefined;
|
|
190
|
+
if (target) {
|
|
191
|
+
return routeToSidecar(target, 'launch_app', params, 'desktop');
|
|
192
|
+
}
|
|
193
|
+
return localGuard();
|
|
194
|
+
},
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
export const desktopScreenshotTool: ToolDefinition = {
|
|
198
|
+
name: 'desktop_screenshot',
|
|
199
|
+
description: 'Take a screenshot of the entire desktop or a specific window. The image is sent directly to the AI for visual analysis. Useful for complex UIs, graphics apps, or when the element tree is insufficient.',
|
|
200
|
+
category: 'desktop',
|
|
201
|
+
parameters: {
|
|
202
|
+
target: {
|
|
203
|
+
type: 'string',
|
|
204
|
+
description: 'Sidecar name or ID to route this command to (omit for local execution)',
|
|
205
|
+
required: false,
|
|
206
|
+
},
|
|
207
|
+
pid: {
|
|
208
|
+
type: 'number',
|
|
209
|
+
description: 'Process ID of window to capture. Omit for full desktop screenshot.',
|
|
210
|
+
required: false,
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
execute: async (params) => {
|
|
214
|
+
const target = params.target as string | undefined;
|
|
215
|
+
if (target) {
|
|
216
|
+
return routeToSidecar(target, 'capture_screen', params, 'screenshot');
|
|
217
|
+
}
|
|
218
|
+
return localGuard();
|
|
219
|
+
},
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
export const desktopFocusWindowTool: ToolDefinition = {
|
|
223
|
+
name: 'desktop_focus_window',
|
|
224
|
+
description: 'Bring a window to the foreground by its PID (from desktop_list_windows). Use this before interacting with a background window.',
|
|
225
|
+
category: 'desktop',
|
|
226
|
+
parameters: {
|
|
227
|
+
target: {
|
|
228
|
+
type: 'string',
|
|
229
|
+
description: 'Sidecar name or ID to route this command to (omit for local execution)',
|
|
230
|
+
required: false,
|
|
231
|
+
},
|
|
232
|
+
pid: {
|
|
233
|
+
type: 'number',
|
|
234
|
+
description: 'Process ID of the window to focus',
|
|
235
|
+
required: true,
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
execute: async (params) => {
|
|
239
|
+
const target = params.target as string | undefined;
|
|
240
|
+
if (target) {
|
|
241
|
+
return routeToSidecar(target, 'focus_window', params, 'desktop');
|
|
242
|
+
}
|
|
243
|
+
return localGuard();
|
|
244
|
+
},
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
export const desktopFindElementTool: ToolDefinition = {
|
|
248
|
+
name: 'desktop_find_element',
|
|
249
|
+
description: 'Search for UI elements by property (name, control type, class name, automation ID). Returns matching elements with [id] for use with desktop_click and desktop_type. Useful when you know what you are looking for without scanning the full tree.',
|
|
250
|
+
category: 'desktop',
|
|
251
|
+
parameters: {
|
|
252
|
+
target: {
|
|
253
|
+
type: 'string',
|
|
254
|
+
description: 'Sidecar name or ID to route this command to (omit for local execution)',
|
|
255
|
+
required: false,
|
|
256
|
+
},
|
|
257
|
+
pid: {
|
|
258
|
+
type: 'number',
|
|
259
|
+
description: 'Process ID of the window. Omit for the foreground window.',
|
|
260
|
+
required: false,
|
|
261
|
+
},
|
|
262
|
+
name: {
|
|
263
|
+
type: 'string',
|
|
264
|
+
description: 'Element name to search for (exact match)',
|
|
265
|
+
required: false,
|
|
266
|
+
},
|
|
267
|
+
control_type: {
|
|
268
|
+
type: 'string',
|
|
269
|
+
description: 'Control type to filter by (e.g., Button, Edit, Text, ComboBox, ListItem, TreeItem, MenuItem, Tab)',
|
|
270
|
+
required: false,
|
|
271
|
+
},
|
|
272
|
+
automation_id: {
|
|
273
|
+
type: 'string',
|
|
274
|
+
description: 'AutomationId to search for (Windows only, ignored on other platforms)',
|
|
275
|
+
required: false,
|
|
276
|
+
},
|
|
277
|
+
class_name: {
|
|
278
|
+
type: 'string',
|
|
279
|
+
description: 'Class name to search for',
|
|
280
|
+
required: false,
|
|
281
|
+
},
|
|
282
|
+
},
|
|
283
|
+
execute: async (params) => {
|
|
284
|
+
const target = params.target as string | undefined;
|
|
285
|
+
if (target) {
|
|
286
|
+
return routeToSidecar(target, 'find_element', params, 'desktop');
|
|
287
|
+
}
|
|
288
|
+
return localGuard();
|
|
289
|
+
},
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* All desktop tools in a single array — platform-agnostic.
|
|
294
|
+
*/
|
|
295
|
+
export const DESKTOP_TOOLS: ToolDefinition[] = [
|
|
296
|
+
desktopListWindowsTool,
|
|
297
|
+
desktopSnapshotTool,
|
|
298
|
+
desktopClickTool,
|
|
299
|
+
desktopTypeTool,
|
|
300
|
+
desktopPressKeysTool,
|
|
301
|
+
desktopLaunchAppTool,
|
|
302
|
+
desktopScreenshotTool,
|
|
303
|
+
desktopFocusWindowTool,
|
|
304
|
+
desktopFindElementTool,
|
|
305
|
+
];
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Document Tool
|
|
3
|
+
*
|
|
4
|
+
* Allows the agent to create, read, update, and list documents stored
|
|
5
|
+
* in the vault. Use this instead of write_file when creating reports,
|
|
6
|
+
* plans, analyses, or any document the user should be able to download.
|
|
7
|
+
*
|
|
8
|
+
* Returns a document marker that the dashboard renders as a card with
|
|
9
|
+
* a download button.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import type { ToolDefinition } from './registry.ts';
|
|
13
|
+
import type { DocumentFormat } from '../../vault/documents.ts';
|
|
14
|
+
import {
|
|
15
|
+
createDocument, getDocument, findDocuments, updateDocument, deleteDocument,
|
|
16
|
+
} from '../../vault/documents.ts';
|
|
17
|
+
|
|
18
|
+
export const documentTool: ToolDefinition = {
|
|
19
|
+
name: 'create_document',
|
|
20
|
+
description: [
|
|
21
|
+
'Create, read, update, or list documents stored in the vault.',
|
|
22
|
+
'Use this tool instead of write_file when producing reports, plans, analyses,',
|
|
23
|
+
'guides, summaries, or any document the user may want to download.',
|
|
24
|
+
'',
|
|
25
|
+
'Actions:',
|
|
26
|
+
' create — Create a new document (returns a preview card in chat)',
|
|
27
|
+
' get — Read a document by ID',
|
|
28
|
+
' list — List all documents, optionally filtered',
|
|
29
|
+
' update — Update an existing document',
|
|
30
|
+
' append — Append text to an existing document (for long content)',
|
|
31
|
+
' delete — Delete a document',
|
|
32
|
+
'',
|
|
33
|
+
'Formats: markdown, plain, html, json, csv, code',
|
|
34
|
+
'',
|
|
35
|
+
'IMPORTANT: For long documents, use create first with the initial section,',
|
|
36
|
+
'then use append to add remaining sections. This prevents token truncation.',
|
|
37
|
+
'',
|
|
38
|
+
'When you create a document, a download card is shown to the user in chat.',
|
|
39
|
+
].join('\n'),
|
|
40
|
+
category: 'documents',
|
|
41
|
+
parameters: {
|
|
42
|
+
action: {
|
|
43
|
+
type: 'string',
|
|
44
|
+
description: 'The action: create, get, list, update, append, delete',
|
|
45
|
+
required: true,
|
|
46
|
+
},
|
|
47
|
+
id: {
|
|
48
|
+
type: 'string',
|
|
49
|
+
description: 'Document ID (required for get, update, append, delete)',
|
|
50
|
+
required: false,
|
|
51
|
+
},
|
|
52
|
+
title: {
|
|
53
|
+
type: 'string',
|
|
54
|
+
description: 'Document title (required for create, optional for update)',
|
|
55
|
+
required: false,
|
|
56
|
+
},
|
|
57
|
+
body: {
|
|
58
|
+
type: 'string',
|
|
59
|
+
description: 'Document content. For create/update: full body. For append: text to add.',
|
|
60
|
+
required: false,
|
|
61
|
+
},
|
|
62
|
+
format: {
|
|
63
|
+
type: 'string',
|
|
64
|
+
description: 'Document format: markdown (default), plain, html, json, csv, code',
|
|
65
|
+
required: false,
|
|
66
|
+
},
|
|
67
|
+
tags: {
|
|
68
|
+
type: 'string',
|
|
69
|
+
description: 'Comma-separated tags for create/update/filter',
|
|
70
|
+
required: false,
|
|
71
|
+
},
|
|
72
|
+
search: {
|
|
73
|
+
type: 'string',
|
|
74
|
+
description: 'Search term for list action (searches title and body)',
|
|
75
|
+
required: false,
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
execute: async (params) => {
|
|
79
|
+
const action = params.action as string;
|
|
80
|
+
|
|
81
|
+
switch (action) {
|
|
82
|
+
case 'create': {
|
|
83
|
+
if (!params.title) return 'Error: "title" is required for create action';
|
|
84
|
+
const tags = params.tags ? (params.tags as string).split(',').map(t => t.trim()) : undefined;
|
|
85
|
+
const doc = createDocument(
|
|
86
|
+
params.title as string,
|
|
87
|
+
(params.body as string) ?? '',
|
|
88
|
+
{
|
|
89
|
+
format: (params.format as DocumentFormat) ?? 'markdown',
|
|
90
|
+
tags,
|
|
91
|
+
},
|
|
92
|
+
);
|
|
93
|
+
// Return the document marker + preview for the chat UI
|
|
94
|
+
const preview = doc.body.length > 200 ? doc.body.slice(0, 200) + '...' : doc.body;
|
|
95
|
+
return [
|
|
96
|
+
`Document created: "${doc.title}" (${doc.format}, ${doc.body.length} chars)`,
|
|
97
|
+
'',
|
|
98
|
+
`<!-- jarvis:document id="${doc.id}" title="${doc.title}" format="${doc.format}" size="${doc.body.length}" -->`,
|
|
99
|
+
'',
|
|
100
|
+
preview ? `Preview:\n${preview}` : '',
|
|
101
|
+
].filter(Boolean).join('\n');
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
case 'get': {
|
|
105
|
+
if (!params.id) return 'Error: "id" is required for get action';
|
|
106
|
+
const doc = getDocument(params.id as string);
|
|
107
|
+
if (!doc) return `Document not found: ${params.id}`;
|
|
108
|
+
return [
|
|
109
|
+
`Title: ${doc.title}`,
|
|
110
|
+
`Format: ${doc.format}`,
|
|
111
|
+
`Tags: ${doc.tags.join(', ') || 'none'}`,
|
|
112
|
+
`Size: ${doc.body.length} chars`,
|
|
113
|
+
`Created: ${new Date(doc.created_at).toLocaleString()}`,
|
|
114
|
+
`Updated: ${new Date(doc.updated_at).toLocaleString()}`,
|
|
115
|
+
'',
|
|
116
|
+
'--- Content ---',
|
|
117
|
+
doc.body || '(empty)',
|
|
118
|
+
].join('\n');
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
case 'list': {
|
|
122
|
+
const query: { format?: DocumentFormat; tag?: string; search?: string } = {};
|
|
123
|
+
if (params.format) query.format = params.format as DocumentFormat;
|
|
124
|
+
if (params.tags) query.tag = params.tags as string;
|
|
125
|
+
if (params.search) query.search = params.search as string;
|
|
126
|
+
const docs = findDocuments(Object.keys(query).length > 0 ? query : undefined);
|
|
127
|
+
if (docs.length === 0) return 'No documents found.';
|
|
128
|
+
return docs.map(d =>
|
|
129
|
+
`[${d.id}] "${d.title}" (${d.format}, ${d.body.length} chars) — tags: ${d.tags.join(', ') || 'none'}, updated: ${new Date(d.updated_at).toLocaleString()}`
|
|
130
|
+
).join('\n');
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
case 'update': {
|
|
134
|
+
if (!params.id) return 'Error: "id" is required for update action';
|
|
135
|
+
const updates: Record<string, unknown> = {};
|
|
136
|
+
if (params.title !== undefined) updates.title = params.title;
|
|
137
|
+
if (params.body !== undefined) updates.body = params.body;
|
|
138
|
+
if (params.format !== undefined) updates.format = params.format;
|
|
139
|
+
if (params.tags !== undefined) {
|
|
140
|
+
updates.tags = (params.tags as string).split(',').map(t => t.trim());
|
|
141
|
+
}
|
|
142
|
+
const updated = updateDocument(params.id as string, updates);
|
|
143
|
+
if (!updated) return `Document not found: ${params.id}`;
|
|
144
|
+
return `Updated: "${updated.title}" — ${updated.body.length} chars`;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
case 'append': {
|
|
148
|
+
if (!params.id) return 'Error: "id" is required for append action';
|
|
149
|
+
if (!params.body) return 'Error: "body" is required for append action (the text to append)';
|
|
150
|
+
const existing = getDocument(params.id as string);
|
|
151
|
+
if (!existing) return `Document not found: ${params.id}`;
|
|
152
|
+
const newBody = existing.body + (existing.body ? '\n\n' : '') + (params.body as string);
|
|
153
|
+
const updated = updateDocument(params.id as string, { body: newBody });
|
|
154
|
+
if (!updated) return 'Failed to append to document';
|
|
155
|
+
return `Appended ${(params.body as string).length} chars. Total: ${updated.body.length} chars for "${updated.title}"`;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
case 'delete': {
|
|
159
|
+
if (!params.id) return 'Error: "id" is required for delete action';
|
|
160
|
+
const deleted = deleteDocument(params.id as string);
|
|
161
|
+
if (!deleted) return `Document not found: ${params.id}`;
|
|
162
|
+
return 'Document deleted.';
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
default:
|
|
166
|
+
return `Unknown action: "${action}". Valid actions: create, get, list, update, append, delete`;
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
};
|