@aria-cli/tools 1.0.12 → 1.0.14

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.
Files changed (233) hide show
  1. package/dist/index.js +378 -70
  2. package/dist/network-runtime/index.js +8 -12
  3. package/dist-cjs/index.js +400 -435
  4. package/dist-cjs/network-runtime/index.js +8 -172
  5. package/package.json +8 -6
  6. package/dist/.tsbuildinfo +0 -1
  7. package/dist/ask-user-interaction.js +0 -22
  8. package/dist/cache/web-cache.js +0 -66
  9. package/dist/definitions/arion.js +0 -104
  10. package/dist/definitions/browser/browser.js +0 -418
  11. package/dist/definitions/browser/index.js +0 -4
  12. package/dist/definitions/browser/pw-downloads.js +0 -114
  13. package/dist/definitions/browser/pw-interactions.js +0 -199
  14. package/dist/definitions/browser/pw-responses.js +0 -76
  15. package/dist/definitions/browser/pw-session.js +0 -310
  16. package/dist/definitions/browser/pw-shared.js +0 -66
  17. package/dist/definitions/browser/pw-snapshot.js +0 -301
  18. package/dist/definitions/browser/pw-state.js +0 -62
  19. package/dist/definitions/browser/types.js +0 -4
  20. package/dist/definitions/code-intelligence.js +0 -470
  21. package/dist/definitions/core.js +0 -109
  22. package/dist/definitions/delegation.js +0 -512
  23. package/dist/definitions/deploy.js +0 -65
  24. package/dist/definitions/filesystem.js +0 -196
  25. package/dist/definitions/frg.js +0 -63
  26. package/dist/definitions/index.js +0 -20
  27. package/dist/definitions/memory.js +0 -123
  28. package/dist/definitions/messaging.js +0 -625
  29. package/dist/definitions/meta.js +0 -349
  30. package/dist/definitions/network.js +0 -159
  31. package/dist/definitions/outlook.js +0 -277
  32. package/dist/definitions/patch/apply-patch.js +0 -184
  33. package/dist/definitions/patch/fuzzy-match.js +0 -166
  34. package/dist/definitions/patch/index.js +0 -1
  35. package/dist/definitions/patch/patch-parser.js +0 -207
  36. package/dist/definitions/patch/sandbox-paths.js +0 -105
  37. package/dist/definitions/process/index.js +0 -4
  38. package/dist/definitions/process/process-registry.js +0 -213
  39. package/dist/definitions/process/process.js +0 -386
  40. package/dist/definitions/process/pty-keys.js +0 -254
  41. package/dist/definitions/process/session-slug.js +0 -142
  42. package/dist/definitions/quip.js +0 -195
  43. package/dist/definitions/search.js +0 -60
  44. package/dist/definitions/session-history.js +0 -69
  45. package/dist/definitions/shell.js +0 -181
  46. package/dist/definitions/slack.js +0 -180
  47. package/dist/definitions/web.js +0 -109
  48. package/dist/executors/apply-patch.js +0 -901
  49. package/dist/executors/arion.js +0 -119
  50. package/dist/executors/code-intelligence.js +0 -882
  51. package/dist/executors/deploy.js +0 -848
  52. package/dist/executors/filesystem.js +0 -1122
  53. package/dist/executors/frg-freshness.js +0 -576
  54. package/dist/executors/frg.js +0 -298
  55. package/dist/executors/index.js +0 -46
  56. package/dist/executors/learning-meta.js +0 -1146
  57. package/dist/executors/lsp-client.js +0 -296
  58. package/dist/executors/memory.js +0 -750
  59. package/dist/executors/meta.js +0 -220
  60. package/dist/executors/process-registry.js +0 -465
  61. package/dist/executors/pty-session-store.js +0 -30
  62. package/dist/executors/pty.js +0 -271
  63. package/dist/executors/restart.js +0 -119
  64. package/dist/executors/search-freshness.js +0 -195
  65. package/dist/executors/search-types.js +0 -52
  66. package/dist/executors/search.js +0 -66
  67. package/dist/executors/self-diagnose.js +0 -398
  68. package/dist/executors/session-history.js +0 -283
  69. package/dist/executors/shell-safety.js +0 -473
  70. package/dist/executors/shell.js +0 -954
  71. package/dist/executors/utils.js +0 -33
  72. package/dist/executors/web.js +0 -542
  73. package/dist/extraction/content-extraction.js +0 -235
  74. package/dist/extraction/index.js +0 -4
  75. package/dist/headless-control-contract.js +0 -967
  76. package/dist/local-control-http-auth.js +0 -2
  77. package/dist/mcp/client.js +0 -181
  78. package/dist/mcp/connection.js +0 -480
  79. package/dist/mcp/index.js +0 -10
  80. package/dist/mcp/jsonrpc.js +0 -144
  81. package/dist/mcp/types.js +0 -7
  82. package/dist/network-control-adapter.js +0 -72
  83. package/dist/network-runtime/address-types.js +0 -165
  84. package/dist/network-runtime/db-owner-fencing.js +0 -69
  85. package/dist/network-runtime/delivery-receipts.js +0 -267
  86. package/dist/network-runtime/direct-endpoint-authority.js +0 -25
  87. package/dist/network-runtime/local-control-contract.js +0 -627
  88. package/dist/network-runtime/node-store-contract.js +0 -34
  89. package/dist/network-runtime/pair-route-contract.js +0 -77
  90. package/dist/network-runtime/peer-capabilities.js +0 -28
  91. package/dist/network-runtime/peer-principal-ref.js +0 -12
  92. package/dist/network-runtime/peer-state-machine.js +0 -121
  93. package/dist/network-runtime/protocol-schemas.js +0 -205
  94. package/dist/network-runtime/runtime-bootstrap-contract.js +0 -60
  95. package/dist/outlook/desktop-session.js +0 -279
  96. package/dist/policy.js +0 -149
  97. package/dist/providers/brave.js +0 -62
  98. package/dist/providers/duckduckgo.js +0 -176
  99. package/dist/providers/exa.js +0 -63
  100. package/dist/providers/firecrawl.js +0 -55
  101. package/dist/providers/index.js +0 -7
  102. package/dist/providers/jina.js +0 -49
  103. package/dist/providers/router.js +0 -96
  104. package/dist/providers/search-provider.js +0 -32
  105. package/dist/providers/tavily.js +0 -54
  106. package/dist/quip/desktop-session.js +0 -317
  107. package/dist/registry/index.js +0 -1
  108. package/dist/registry/registry.js +0 -756
  109. package/dist/runtime-socket-local-control-client.js +0 -330
  110. package/dist/security/dns-normalization.js +0 -19
  111. package/dist/security/dns-pinning.js +0 -123
  112. package/dist/security/external-content.js +0 -91
  113. package/dist/security/ssrf.js +0 -181
  114. package/dist/slack/desktop-session.js +0 -324
  115. package/dist/tool-factory.js +0 -47
  116. package/dist/types.js +0 -7
  117. package/dist/utils/retry.js +0 -132
  118. package/dist/utils/safe-parse-json.js +0 -160
  119. package/dist/utils/url.js +0 -19
  120. package/dist-cjs/.tsbuildinfo +0 -1
  121. package/dist-cjs/ask-user-interaction.js +0 -27
  122. package/dist-cjs/cache/web-cache.js +0 -70
  123. package/dist-cjs/definitions/arion.js +0 -107
  124. package/dist-cjs/definitions/browser/browser.js +0 -421
  125. package/dist-cjs/definitions/browser/index.js +0 -8
  126. package/dist-cjs/definitions/browser/pw-downloads.js +0 -117
  127. package/dist-cjs/definitions/browser/pw-interactions.js +0 -213
  128. package/dist-cjs/definitions/browser/pw-responses.js +0 -84
  129. package/dist-cjs/definitions/browser/pw-session.js +0 -326
  130. package/dist-cjs/definitions/browser/pw-shared.js +0 -72
  131. package/dist-cjs/definitions/browser/pw-snapshot.js +0 -307
  132. package/dist-cjs/definitions/browser/pw-state.js +0 -70
  133. package/dist-cjs/definitions/browser/types.js +0 -5
  134. package/dist-cjs/definitions/code-intelligence.js +0 -473
  135. package/dist-cjs/definitions/core.js +0 -133
  136. package/dist-cjs/definitions/delegation.js +0 -515
  137. package/dist-cjs/definitions/deploy.js +0 -68
  138. package/dist-cjs/definitions/filesystem.js +0 -199
  139. package/dist-cjs/definitions/frg.js +0 -66
  140. package/dist-cjs/definitions/index.js +0 -43
  141. package/dist-cjs/definitions/memory.js +0 -126
  142. package/dist-cjs/definitions/messaging.js +0 -631
  143. package/dist-cjs/definitions/meta.js +0 -352
  144. package/dist-cjs/definitions/network.js +0 -162
  145. package/dist-cjs/definitions/outlook.js +0 -280
  146. package/dist-cjs/definitions/patch/apply-patch.js +0 -191
  147. package/dist-cjs/definitions/patch/fuzzy-match.js +0 -172
  148. package/dist-cjs/definitions/patch/index.js +0 -5
  149. package/dist-cjs/definitions/patch/patch-parser.js +0 -215
  150. package/dist-cjs/definitions/patch/sandbox-paths.js +0 -113
  151. package/dist-cjs/definitions/process/index.js +0 -8
  152. package/dist-cjs/definitions/process/process-registry.js +0 -231
  153. package/dist-cjs/definitions/process/process.js +0 -389
  154. package/dist-cjs/definitions/process/pty-keys.js +0 -259
  155. package/dist-cjs/definitions/process/session-slug.js +0 -145
  156. package/dist-cjs/definitions/quip.js +0 -198
  157. package/dist-cjs/definitions/search.js +0 -63
  158. package/dist-cjs/definitions/session-history.js +0 -72
  159. package/dist-cjs/definitions/shell.js +0 -184
  160. package/dist-cjs/definitions/slack.js +0 -183
  161. package/dist-cjs/definitions/web.js +0 -112
  162. package/dist-cjs/executors/apply-patch.js +0 -938
  163. package/dist-cjs/executors/arion.js +0 -125
  164. package/dist-cjs/executors/code-intelligence.js +0 -925
  165. package/dist-cjs/executors/deploy.js +0 -869
  166. package/dist-cjs/executors/filesystem.js +0 -1167
  167. package/dist-cjs/executors/frg-freshness.js +0 -627
  168. package/dist-cjs/executors/frg.js +0 -334
  169. package/dist-cjs/executors/index.js +0 -143
  170. package/dist-cjs/executors/learning-meta.js +0 -1165
  171. package/dist-cjs/executors/lsp-client.js +0 -310
  172. package/dist-cjs/executors/memory.js +0 -796
  173. package/dist-cjs/executors/meta.js +0 -226
  174. package/dist-cjs/executors/process-registry.js +0 -469
  175. package/dist-cjs/executors/pty-session-store.js +0 -34
  176. package/dist-cjs/executors/pty.js +0 -312
  177. package/dist-cjs/executors/restart.js +0 -155
  178. package/dist-cjs/executors/search-freshness.js +0 -234
  179. package/dist-cjs/executors/search-types.js +0 -56
  180. package/dist-cjs/executors/search.js +0 -102
  181. package/dist-cjs/executors/self-diagnose.js +0 -434
  182. package/dist-cjs/executors/session-history.js +0 -320
  183. package/dist-cjs/executors/shell-safety.js +0 -478
  184. package/dist-cjs/executors/shell.js +0 -1001
  185. package/dist-cjs/executors/utils.js +0 -73
  186. package/dist-cjs/executors/web.js +0 -547
  187. package/dist-cjs/extraction/content-extraction.js +0 -243
  188. package/dist-cjs/extraction/index.js +0 -8
  189. package/dist-cjs/headless-control-contract.js +0 -972
  190. package/dist-cjs/local-control-http-auth.js +0 -5
  191. package/dist-cjs/mcp/client.js +0 -185
  192. package/dist-cjs/mcp/connection.js +0 -484
  193. package/dist-cjs/mcp/index.js +0 -30
  194. package/dist-cjs/mcp/jsonrpc.js +0 -148
  195. package/dist-cjs/mcp/types.js +0 -8
  196. package/dist-cjs/network-control-adapter.js +0 -77
  197. package/dist-cjs/network-runtime/address-types.js +0 -168
  198. package/dist-cjs/network-runtime/db-owner-fencing.js +0 -76
  199. package/dist-cjs/network-runtime/delivery-receipts.js +0 -276
  200. package/dist-cjs/network-runtime/direct-endpoint-authority.js +0 -29
  201. package/dist-cjs/network-runtime/local-control-contract.js +0 -633
  202. package/dist-cjs/network-runtime/node-store-contract.js +0 -38
  203. package/dist-cjs/network-runtime/pair-route-contract.js +0 -80
  204. package/dist-cjs/network-runtime/peer-capabilities.js +0 -37
  205. package/dist-cjs/network-runtime/peer-principal-ref.js +0 -15
  206. package/dist-cjs/network-runtime/peer-state-machine.js +0 -129
  207. package/dist-cjs/network-runtime/protocol-schemas.js +0 -212
  208. package/dist-cjs/network-runtime/runtime-bootstrap-contract.js +0 -63
  209. package/dist-cjs/outlook/desktop-session.js +0 -318
  210. package/dist-cjs/policy.js +0 -155
  211. package/dist-cjs/providers/brave.js +0 -66
  212. package/dist-cjs/providers/duckduckgo.js +0 -180
  213. package/dist-cjs/providers/exa.js +0 -67
  214. package/dist-cjs/providers/firecrawl.js +0 -59
  215. package/dist-cjs/providers/index.js +0 -17
  216. package/dist-cjs/providers/jina.js +0 -53
  217. package/dist-cjs/providers/router.js +0 -100
  218. package/dist-cjs/providers/search-provider.js +0 -36
  219. package/dist-cjs/providers/tavily.js +0 -58
  220. package/dist-cjs/quip/desktop-session.js +0 -353
  221. package/dist-cjs/registry/index.js +0 -6
  222. package/dist-cjs/registry/registry.js +0 -761
  223. package/dist-cjs/runtime-socket-local-control-client.js +0 -367
  224. package/dist-cjs/security/dns-normalization.js +0 -22
  225. package/dist-cjs/security/dns-pinning.js +0 -160
  226. package/dist-cjs/security/external-content.js +0 -95
  227. package/dist-cjs/security/ssrf.js +0 -221
  228. package/dist-cjs/slack/desktop-session.js +0 -366
  229. package/dist-cjs/tool-factory.js +0 -50
  230. package/dist-cjs/types.js +0 -8
  231. package/dist-cjs/utils/retry.js +0 -169
  232. package/dist-cjs/utils/safe-parse-json.js +0 -164
  233. package/dist-cjs/utils/url.js +0 -23
@@ -1,512 +0,0 @@
1
- /**
2
- * Delegation tool definitions
3
- *
4
- * Tools: delegate_arion, spawn_worker, check_delegation, pause_delegation, resume_delegation, delegate_remote, quest_report (7 tools)
5
- *
6
- * delegate_arion and spawn_worker call context.delegationExecutor (injected by runner).
7
- * check_delegation uses context.delegationRegistry for status queries.
8
- * When the executor/registry aren't wired, tools return a clear error.
9
- */
10
- import { z } from "zod";
11
- import { NodeIdSchema } from "../network-runtime/index.js";
12
- import { tool } from "../tool-factory.js";
13
- /**
14
- * Delegate a task to another arion in the room.
15
- * The arion runs in parallel with its own memory and persona.
16
- */
17
- const delegate_arion = tool({
18
- name: "delegate_arion",
19
- description: "Delegate a task to another arion in the room. The arion runs in parallel with its own memory and persona. Use check_delegation to get results.",
20
- parameters: z.object({
21
- arion: z.string().min(1).max(100).describe("Name of the arion to delegate to"),
22
- task: z.string().min(1).max(100_000).describe("The task description for the delegated arion"),
23
- tier: z
24
- .enum(["fast", "balanced", "powerful", "ensemble"])
25
- .optional()
26
- .describe("Model tier override (fast/balanced/powerful)"),
27
- }),
28
- category: "arion",
29
- riskLevel: "moderate",
30
- isReadOnly: false,
31
- loadingTier: "always",
32
- execute: async (input, context) => {
33
- if (!context.delegationExecutor) {
34
- return {
35
- success: false,
36
- message: "delegate_arion: Delegation executor not available. Ensure RunSession is configured with delegation support.",
37
- };
38
- }
39
- try {
40
- const id = await context.delegationExecutor.delegateToArion(input.arion, input.task, input.tier);
41
- return {
42
- success: true,
43
- message: `Delegation ${id} started. Arion "${input.arion}" is working on the task. Use check_delegation to monitor progress.`,
44
- data: { id, arion: input.arion },
45
- };
46
- }
47
- catch (e) {
48
- return {
49
- success: false,
50
- message: `delegate_arion failed: ${e.message}`,
51
- };
52
- }
53
- },
54
- });
55
- /**
56
- * Spawn a lightweight worker to execute a focused task in parallel.
57
- * No memory or persona. Use for quick, isolated tasks.
58
- */
59
- const spawn_worker = tool({
60
- name: "spawn_worker",
61
- description: "Spawn a lightweight worker to execute a focused task in parallel. No memory or persona. Use for quick, isolated tasks. Use check_delegation to get results.",
62
- parameters: z.object({
63
- task: z.string().min(1).max(100_000).describe("The task for the worker"),
64
- type: z
65
- .enum(["worker", "cli_agent"])
66
- .optional()
67
- .default("worker")
68
- .describe("Delegation type: lightweight worker (default) or external CLI agent"),
69
- tools: z
70
- .array(z
71
- .string()
72
- .min(1)
73
- .max(100)
74
- .regex(/^[a-z0-9_]+$/))
75
- .max(100)
76
- .optional()
77
- .describe("Restrict worker to these tools only"),
78
- tier: z
79
- .enum(["fast", "balanced", "powerful", "ensemble"])
80
- .optional()
81
- .default("fast")
82
- .describe("Model tier"),
83
- driver: z
84
- .string()
85
- .regex(/^[a-z0-9-]+$/)
86
- .max(50)
87
- .optional()
88
- .describe("CLI agent driver ID (for type='cli_agent', e.g. claude-code/codex)"),
89
- workspace: z
90
- .enum(["cwd", "tempdir", "worktree"])
91
- .optional()
92
- .describe("Workspace strategy for CLI agent delegation"),
93
- model: z.string().max(200).optional().describe("CLI model override (for type='cli_agent')"),
94
- resume: z.string().max(200).optional().describe("Resume from an existing CLI session ID"),
95
- timeout: z
96
- .number()
97
- .int()
98
- .min(1000)
99
- .max(3_600_000)
100
- .optional()
101
- .describe("CLI delegation timeout in ms"),
102
- }),
103
- category: "meta",
104
- riskLevel: "moderate",
105
- isReadOnly: false,
106
- loadingTier: "always",
107
- execute: async (input, context) => {
108
- if (!context.delegationExecutor) {
109
- return {
110
- success: false,
111
- message: "spawn_worker: Delegation executor not available. Ensure RunSession is configured with delegation support.",
112
- };
113
- }
114
- try {
115
- if (input.type === "cli_agent") {
116
- const id = await context.delegationExecutor.spawnCliAgent({
117
- task: input.task,
118
- driver: input.driver ?? "claude-code",
119
- workspace: input.workspace,
120
- model: input.model,
121
- resume: input.resume,
122
- timeout: input.timeout,
123
- });
124
- return {
125
- success: true,
126
- message: "CLI agent delegation started",
127
- data: { id },
128
- };
129
- }
130
- const id = await context.delegationExecutor.spawnWorker(input.task, input.tools, input.tier);
131
- return {
132
- success: true,
133
- message: `Worker ${id} spawned. Use check_delegation to monitor progress.`,
134
- data: { id },
135
- };
136
- }
137
- catch (e) {
138
- return {
139
- success: false,
140
- message: `spawn_worker failed: ${e.message}`,
141
- };
142
- }
143
- },
144
- });
145
- /**
146
- * Check the status of a delegated task or spawned worker.
147
- * Uses typed DelegationRegistryRef from ToolContext.
148
- */
149
- const check_delegation = tool({
150
- name: "check_delegation",
151
- description: "Check the status of a delegated task. The ID is always a quest_xxx ID. Returns the result when complete.",
152
- parameters: z.object({
153
- id: z
154
- .string()
155
- .regex(/^quest_[a-z0-9]{6,20}$/)
156
- .max(50)
157
- .describe("Quest ID (quest_xxx)"),
158
- wait: z.boolean().optional().default(false).describe("Wait for completion instead of polling."),
159
- timeout: z
160
- .number()
161
- .int()
162
- .min(1000)
163
- .max(3_600_000)
164
- .optional()
165
- .describe("Max wait time in ms when wait=true (default 300000)"),
166
- }),
167
- category: "meta",
168
- riskLevel: "safe",
169
- isReadOnly: true,
170
- loadingTier: "always",
171
- execute: async (input, context) => {
172
- const registry = context.delegationRegistry;
173
- if (!registry) {
174
- return { success: false, message: "No delegation registry available" };
175
- }
176
- const entry = registry.get(input.id);
177
- // If not in registry (evicted or process died), check quest store
178
- if (!entry && context.questStore) {
179
- const quest = context.questStore.getQuest(input.id);
180
- if (quest) {
181
- const questMessages = context.messageStore?.getByCorrelation(input.id) ?? [];
182
- return {
183
- success: quest.status === "done" || quest.status === "active",
184
- message: quest.status === "done"
185
- ? quest.progress || "Quest completed"
186
- : quest.status === "blocked"
187
- ? quest.progress || "Quest blocked"
188
- : `Quest is ${quest.status}`,
189
- data: {
190
- id: quest.id,
191
- status: quest.status,
192
- progress: quest.progress,
193
- questMessages: questMessages.slice(-10),
194
- },
195
- };
196
- }
197
- }
198
- if (!entry) {
199
- return { success: false, message: `Delegation not found: ${input.id}` };
200
- }
201
- if (input.wait && entry.status === "running") {
202
- try {
203
- const completed = await registry.await(input.id, input.timeout ?? 300_000);
204
- return buildCheckResponse(completed, context);
205
- }
206
- catch (e) {
207
- return { success: false, message: `Wait failed: ${e.message}` };
208
- }
209
- }
210
- return buildCheckResponse(entry, context);
211
- },
212
- });
213
- /** Build check_delegation response, enriching with quest store data when available. */
214
- function buildCheckResponse(entry, context) {
215
- let questProgress;
216
- let questMessages;
217
- if (context.questStore) {
218
- const quest = context.questStore.getQuest(entry.id);
219
- if (quest)
220
- questProgress = quest.progress;
221
- }
222
- if (context.messageStore) {
223
- questMessages = context.messageStore.getByCorrelation(entry.id).slice(-10);
224
- }
225
- const isTerminalFailure = entry.status === "failed" || entry.status === "aborted";
226
- return {
227
- success: entry.status === "completed" || entry.status === "running",
228
- message: entry.status === "completed"
229
- ? (entry.result ?? "Delegation completed")
230
- : isTerminalFailure
231
- ? (entry.error ?? `Delegation ${entry.status}`)
232
- : `Delegation is ${entry.status}`,
233
- data: {
234
- id: entry.id,
235
- type: entry.type,
236
- status: entry.status,
237
- result: entry.result,
238
- error: entry.error,
239
- questProgress,
240
- questMessages,
241
- metadata: entry.metadata,
242
- },
243
- };
244
- }
245
- /**
246
- * Pause a running delegation.
247
- * The agent stops after the AbortController signals cancellation.
248
- * Can be resumed later with resume_delegation.
249
- */
250
- const pause_delegation = tool({
251
- name: "pause_delegation",
252
- description: "Pause a running delegation by terminating it. No in-flight state is preserved. Use resume_delegation to re-create the delegation with the original task.",
253
- parameters: z.object({
254
- id: z
255
- .string()
256
- .regex(/^quest_[a-z0-9]{6,20}$/)
257
- .max(50)
258
- .describe("Quest ID (quest_xxx) to pause"),
259
- reason: z.string().max(1000).optional().describe("Reason for pausing"),
260
- }),
261
- category: "meta",
262
- riskLevel: "moderate",
263
- isReadOnly: false,
264
- loadingTier: "always",
265
- execute: async (input, context) => {
266
- const registry = context.delegationRegistry;
267
- if (!registry) {
268
- return { success: false, message: "No delegation registry available" };
269
- }
270
- const entry = registry.get(input.id);
271
- if (!entry) {
272
- return { success: false, message: `Delegation not found: ${input.id}` };
273
- }
274
- if (entry.status !== "running") {
275
- return {
276
- success: false,
277
- message: `Cannot pause — delegation is ${entry.status}`,
278
- };
279
- }
280
- registry.abort(input.id);
281
- // Sync quest store so check_delegation's fallback path sees "blocked" after registry eviction
282
- if (context.questStore) {
283
- try {
284
- context.questStore.updateQuest(input.id, {
285
- status: "blocked",
286
- progress: input.reason ?? "Paused by user",
287
- });
288
- }
289
- catch {
290
- // Non-fatal — registry is authoritative while process lives
291
- }
292
- }
293
- return {
294
- success: true,
295
- message: `Delegation ${input.id} aborted${input.reason ? `: ${input.reason}` : ""}. Use resume_delegation to re-create with the original task.`,
296
- data: { id: input.id, status: "aborted" },
297
- };
298
- },
299
- });
300
- /**
301
- * Resume a paused delegation from where it stopped.
302
- * Creates a new delegation that continues the original task.
303
- */
304
- const resume_delegation = tool({
305
- name: "resume_delegation",
306
- description: "Resume a paused delegation by creating a new delegation with the original task. Does not restore in-flight state — the agent starts fresh with the original task description.",
307
- parameters: z.object({
308
- id: z
309
- .string()
310
- .regex(/^quest_[a-z0-9]{6,20}$/)
311
- .max(50)
312
- .describe("Quest ID (quest_xxx) to resume"),
313
- additionalContext: z
314
- .string()
315
- .max(50_000)
316
- .optional()
317
- .describe("Additional context or instructions for the resumed agent"),
318
- }),
319
- category: "meta",
320
- riskLevel: "moderate",
321
- isReadOnly: false,
322
- loadingTier: "always",
323
- execute: async (input, context) => {
324
- const executor = context.delegationExecutor;
325
- if (!executor) {
326
- return {
327
- success: false,
328
- message: "Delegation executor not available",
329
- };
330
- }
331
- const registry = context.delegationRegistry;
332
- if (!registry) {
333
- return { success: false, message: "No delegation registry available" };
334
- }
335
- const entry = registry.get(input.id);
336
- if (!entry) {
337
- return { success: false, message: `Delegation not found: ${input.id}` };
338
- }
339
- if (entry.status === "running") {
340
- return {
341
- success: false,
342
- message: `Cannot resume — delegation ${input.id} is still running. Use pause_delegation first.`,
343
- };
344
- }
345
- // Build a continuation task from the original task + optional additional context
346
- const task = input.additionalContext
347
- ? `Continue the previous task: ${entry.task}\n\nAdditional context: ${input.additionalContext}`
348
- : `Continue the previous task: ${entry.task}`;
349
- try {
350
- let newId;
351
- if (entry.type === "arion" && entry.arionName) {
352
- newId = await executor.delegateToArion(entry.arionName, task);
353
- }
354
- else if (entry.type === "cli_agent") {
355
- if (entry.metadata?.driver) {
356
- newId = await executor.spawnCliAgent({
357
- task,
358
- driver: entry.metadata.driver,
359
- workspace: entry.metadata.workspace,
360
- model: entry.metadata.model,
361
- });
362
- }
363
- else {
364
- return {
365
- success: false,
366
- message: "Cannot resume CLI agent delegation — original driver metadata not preserved. Use spawn_worker with type='cli_agent' instead.",
367
- };
368
- }
369
- }
370
- else {
371
- newId = await executor.spawnWorker(task);
372
- }
373
- return {
374
- success: true,
375
- message: `Delegation resumed as ${newId}. Original: ${input.id}`,
376
- data: { originalId: input.id, newId, type: entry.type },
377
- };
378
- }
379
- catch (e) {
380
- return {
381
- success: false,
382
- message: `Resume failed: ${e.message}`,
383
- };
384
- }
385
- },
386
- });
387
- /**
388
- * Delegate a task to a remote ARIA node connected via WireGuard tunnel.
389
- * The remote node receives the task as a quest message and executes it independently.
390
- * Results come back via quest completion messages through the tunnel.
391
- */
392
- const delegate_remote = tool({
393
- name: "delegate_remote",
394
- description: "Delegate a task to a remote ARIA node connected via WireGuard tunnel. The node executes the task independently. Use check_delegation to get results.",
395
- parameters: z.object({
396
- node_id: NodeIdSchema.describe("Durable remote node id to delegate to"),
397
- task: z.string().min(1).max(100_000).describe("Task description for the remote node"),
398
- tier: z
399
- .enum(["fast", "balanced", "powerful"])
400
- .optional()
401
- .describe("Model tier for the remote execution"),
402
- }),
403
- category: "messaging",
404
- riskLevel: "moderate",
405
- isReadOnly: false,
406
- loadingTier: "always",
407
- execute: async (input, context) => {
408
- if (!context.delegationExecutor?.delegateToRemote) {
409
- return {
410
- success: false,
411
- message: "delegate_remote: Remote delegation not available — no delegateToRemote configured. Ensure mailbox and network are wired.",
412
- };
413
- }
414
- try {
415
- const id = await context.delegationExecutor.delegateToRemote(NodeIdSchema.parse(input.node_id), input.task, input.tier);
416
- return {
417
- success: true,
418
- message: `Remote delegation ${id} sent to node "${input.node_id}". Use check_delegation to monitor progress.`,
419
- data: { id, nodeId: input.node_id },
420
- };
421
- }
422
- catch (e) {
423
- return {
424
- success: false,
425
- message: `delegate_remote failed: ${e.message}`,
426
- };
427
- }
428
- },
429
- });
430
- /**
431
- * View the structured completion report for a finished quest.
432
- * Parses the JSON progress field to surface commits, files changed, commands run, and cost.
433
- */
434
- const quest_report = tool({
435
- name: "quest_report",
436
- description: "View the structured completion report for a finished quest, including commits, files changed, commands run, and cost",
437
- parameters: z.object({
438
- quest_id: z.string().min(1).max(100).describe("Quest ID to view report for"),
439
- }),
440
- category: "meta",
441
- riskLevel: "safe",
442
- isReadOnly: true,
443
- loadingTier: "always",
444
- execute: async (input, context) => {
445
- const questId = input.quest_id;
446
- if (!context.questStore) {
447
- return { success: false, message: "Quest store not available" };
448
- }
449
- const quest = context.questStore.getQuest(questId);
450
- if (!quest) {
451
- return { success: false, message: `Quest not found: ${questId}` };
452
- }
453
- if (quest.status !== "done") {
454
- return {
455
- success: true,
456
- message: `Quest not yet completed (status: ${quest.status})`,
457
- data: { questId, status: quest.status },
458
- };
459
- }
460
- // Try to parse structured progress JSON
461
- try {
462
- const report = JSON.parse(quest.progress);
463
- return {
464
- success: true,
465
- message: "Quest completion report",
466
- data: {
467
- questId,
468
- title: quest.title,
469
- status: quest.status,
470
- report: {
471
- summary: report.summary ?? quest.progress.slice(0, 500),
472
- commits: report.commits ?? [],
473
- filesChanged: report.filesChanged ?? [],
474
- commandsRun: report.commandsRun ?? [],
475
- toolsUsed: report.toolsUsed ?? [],
476
- turnCount: report.turnCount ?? 0,
477
- tokensUsed: report.tokensUsed ?? 0,
478
- costUsd: report.costUsd ?? 0,
479
- },
480
- },
481
- };
482
- }
483
- catch {
484
- // Progress is plain text, not structured JSON
485
- return {
486
- success: true,
487
- message: "Quest completion report (plain text)",
488
- data: {
489
- questId,
490
- title: quest.title,
491
- status: quest.status,
492
- report: {
493
- summary: quest.progress,
494
- commits: [],
495
- filesChanged: [],
496
- commandsRun: [],
497
- },
498
- },
499
- };
500
- }
501
- },
502
- });
503
- /** Delegation tool definitions (7) */
504
- export const DELEGATION_TOOL_DEFINITIONS = [
505
- delegate_arion,
506
- spawn_worker,
507
- check_delegation,
508
- pause_delegation,
509
- resume_delegation,
510
- delegate_remote,
511
- quest_report,
512
- ];
@@ -1,65 +0,0 @@
1
- /**
2
- * Deploy tool definition.
3
- *
4
- * Tools: deploy (1 tool)
5
- *
6
- * Deploys ARIA to a remote machine via SSH. Detects OS, installs Node.js + pnpm,
7
- * clones/syncs repo, builds, sets up TLS certs, configures firewall, writes config,
8
- * and starts the daemon.
9
- *
10
- * Safety: requires explicit user confirmation (dangerous risk level).
11
- * Auto-denied in daemon autorun mode.
12
- */
13
- import { executeDeploy } from "../executors/index.js";
14
- const deploy = {
15
- name: "deploy",
16
- description: "Deploy ARIA to a remote machine via SSH. Detects OS, installs Node.js + pnpm, " +
17
- "clones/syncs repo, builds, discovers/provisions TLS certs, opens firewall ports, " +
18
- "configures ~/.aria, and starts the daemon. Returns host, port, fingerprint, and TLS type.",
19
- category: "arion",
20
- parameters: {
21
- type: "object",
22
- properties: {
23
- target: {
24
- type: "string",
25
- description: "SSH target (e.g. 'claude@10.0.0.1' or 'hostname')",
26
- },
27
- repo_url: {
28
- type: "string",
29
- description: "Git repo URL (default: current repo origin)",
30
- },
31
- branch: {
32
- type: "string",
33
- description: "Branch to deploy (default: main)",
34
- },
35
- arion_name: {
36
- type: "string",
37
- description: "Arion identity name (default: hostname of target)",
38
- },
39
- coordination_url: {
40
- type: "string",
41
- description: "Coordination server URL for mesh registration",
42
- },
43
- ssh_key_path: {
44
- type: "string",
45
- description: "Path to SSH private key (default: ~/.ssh/id_ed25519)",
46
- },
47
- commit_hash: {
48
- type: "string",
49
- description: "Git commit hash to checkout after clone (pins exact code version, prevents MITM on branch refs)",
50
- },
51
- verify_signatures: {
52
- type: "boolean",
53
- description: "Verify GPG signature on HEAD commit after checkout. Fails deploy if signature is invalid or missing.",
54
- },
55
- },
56
- required: ["target"],
57
- },
58
- riskLevel: "dangerous",
59
- requiresConfirmation: true,
60
- isReadOnly: false,
61
- loadingTier: "always",
62
- execute: executeDeploy,
63
- };
64
- /** Deploy tool definitions (1) */
65
- export const DEPLOY_TOOL_DEFINITIONS = [deploy];