@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,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PTYSessionStore = void 0;
4
- class PTYSessionStore {
5
- sessions = new Map();
6
- add(pid, session) {
7
- this.sessions.set(pid, session);
8
- }
9
- get(pid) {
10
- return this.sessions.get(pid);
11
- }
12
- has(pid) {
13
- return this.sessions.has(pid);
14
- }
15
- remove(pid) {
16
- this.sessions.delete(pid);
17
- }
18
- async closeAll() {
19
- const sessions = Array.from(this.sessions.values());
20
- this.sessions.clear();
21
- await Promise.allSettled(sessions.map((s) => {
22
- try {
23
- return Promise.resolve(s.close());
24
- }
25
- catch {
26
- return Promise.resolve();
27
- }
28
- }));
29
- }
30
- get size() {
31
- return this.sessions.size;
32
- }
33
- }
34
- exports.PTYSessionStore = PTYSessionStore;
@@ -1,312 +0,0 @@
1
- "use strict";
2
- /**
3
- * @aria/tools - PTY executor for interactive terminal programs
4
- *
5
- * Provides PTY (pseudo-terminal) support for running interactive programs
6
- * that require a terminal environment (like vim, less, etc.)
7
- */
8
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
- if (k2 === undefined) k2 = k;
10
- var desc = Object.getOwnPropertyDescriptor(m, k);
11
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
- desc = { enumerable: true, get: function() { return m[k]; } };
13
- }
14
- Object.defineProperty(o, k2, desc);
15
- }) : (function(o, m, k, k2) {
16
- if (k2 === undefined) k2 = k;
17
- o[k2] = m[k];
18
- }));
19
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
20
- Object.defineProperty(o, "default", { enumerable: true, value: v });
21
- }) : function(o, v) {
22
- o["default"] = v;
23
- });
24
- var __importStar = (this && this.__importStar) || (function () {
25
- var ownKeys = function(o) {
26
- ownKeys = Object.getOwnPropertyNames || function (o) {
27
- var ar = [];
28
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
- return ar;
30
- };
31
- return ownKeys(o);
32
- };
33
- return function (mod) {
34
- if (mod && mod.__esModule) return mod;
35
- var result = {};
36
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
- __setModuleDefault(result, mod);
38
- return result;
39
- };
40
- })();
41
- Object.defineProperty(exports, "__esModule", { value: true });
42
- exports.PTYSession = exports.PTYError = exports.PTYTimeoutError = void 0;
43
- exports.createPTYSession = createPTYSession;
44
- exports.runInPTY = runInPTY;
45
- const nodePty = __importStar(require("node-pty"));
46
- const shell_js_1 = require("./shell.js");
47
- /**
48
- * Error thrown when a PTY operation times out.
49
- */
50
- class PTYTimeoutError extends Error {
51
- output;
52
- constructor(message, output) {
53
- super(message);
54
- this.output = output;
55
- this.name = "PTYTimeoutError";
56
- }
57
- }
58
- exports.PTYTimeoutError = PTYTimeoutError;
59
- /**
60
- * Error thrown when a PTY operation fails.
61
- */
62
- class PTYError extends Error {
63
- output;
64
- constructor(message, output) {
65
- super(message);
66
- this.output = output;
67
- this.name = "PTYError";
68
- }
69
- }
70
- exports.PTYError = PTYError;
71
- /**
72
- * A session wrapping a PTY process.
73
- * Provides methods for interacting with the process and collecting output.
74
- */
75
- class PTYSession {
76
- static MAX_OUTPUT = 10 * 1024 * 1024; // 10MB
77
- _output = "";
78
- _isRunning = true;
79
- _exitCode;
80
- _exitPromise;
81
- _exitResolve;
82
- _pty;
83
- _dataDisposable;
84
- _exitDisposable;
85
- constructor(pty) {
86
- this._pty = pty;
87
- // Set up exit promise
88
- this._exitPromise = new Promise((resolve) => {
89
- this._exitResolve = resolve;
90
- });
91
- // Collect output with buffer cap
92
- this._dataDisposable = pty.onData((data) => {
93
- this._output += data;
94
- if (this._output.length > PTYSession.MAX_OUTPUT) {
95
- this._output = this._output.slice(-PTYSession.MAX_OUTPUT);
96
- }
97
- });
98
- // Handle exit
99
- this._exitDisposable = pty.onExit(({ exitCode }) => {
100
- this._isRunning = false;
101
- this._exitCode = exitCode;
102
- this._exitResolve(exitCode);
103
- });
104
- }
105
- /**
106
- * Write data to the terminal input.
107
- */
108
- write(data) {
109
- if (!this._isRunning) {
110
- throw new PTYError("Cannot write to a closed PTY session");
111
- }
112
- this._pty.write(data);
113
- }
114
- /**
115
- * Resize the terminal.
116
- */
117
- resize(cols, rows) {
118
- if (!this._isRunning) {
119
- throw new PTYError("Cannot resize a closed PTY session");
120
- }
121
- this._pty.resize(cols, rows);
122
- }
123
- /**
124
- * Wait for a pattern to appear in the output.
125
- * @param pattern String or RegExp to match
126
- * @param timeoutMs Timeout in milliseconds (default: 5000)
127
- * @returns The output accumulated up to and including the match
128
- */
129
- async waitFor(pattern, timeoutMs = 5000) {
130
- const startTime = Date.now();
131
- const regex = typeof pattern === "string" ? new RegExp(escapeRegExp(pattern)) : pattern;
132
- // Check if pattern already matches
133
- if (regex.test(this._output)) {
134
- return this._output;
135
- }
136
- return new Promise((resolve, reject) => {
137
- let checkInterval;
138
- let timeoutHandle;
139
- const cleanup = () => {
140
- if (checkInterval)
141
- clearInterval(checkInterval);
142
- if (timeoutHandle)
143
- clearTimeout(timeoutHandle);
144
- };
145
- const check = () => {
146
- if (regex.test(this._output)) {
147
- cleanup();
148
- resolve(this._output);
149
- return true;
150
- }
151
- if (!this._isRunning) {
152
- cleanup();
153
- reject(new PTYError(`Process exited before pattern was found: ${pattern}`, this._output));
154
- return true;
155
- }
156
- return false;
157
- };
158
- // Initial check
159
- if (check())
160
- return;
161
- // Set up polling
162
- checkInterval = setInterval(() => {
163
- check();
164
- }, 10);
165
- // Set up timeout
166
- timeoutHandle = setTimeout(() => {
167
- cleanup();
168
- const elapsed = Date.now() - startTime;
169
- reject(new PTYTimeoutError(`Timeout (${elapsed}ms) waiting for pattern: ${pattern}`, this._output));
170
- }, timeoutMs);
171
- });
172
- }
173
- /**
174
- * Wait for the process to exit.
175
- * @param timeoutMs Timeout in milliseconds (default: 30000)
176
- * @returns The complete output
177
- */
178
- async waitForExit(timeoutMs = 30000) {
179
- if (!this._isRunning) {
180
- return this._output;
181
- }
182
- return new Promise((resolve, reject) => {
183
- let timeoutHandle;
184
- timeoutHandle = setTimeout(() => {
185
- reject(new PTYTimeoutError(`Timeout (${timeoutMs}ms) waiting for process to exit`, this._output));
186
- }, timeoutMs);
187
- this._exitPromise
188
- .then(() => {
189
- if (timeoutHandle)
190
- clearTimeout(timeoutHandle);
191
- resolve(this._output);
192
- })
193
- .catch(reject);
194
- });
195
- }
196
- /**
197
- * Kill the process.
198
- * @param signal Signal to send (default: SIGHUP on Unix)
199
- */
200
- kill(signal) {
201
- if (!this._isRunning) {
202
- return;
203
- }
204
- try {
205
- this._pty.kill(signal);
206
- }
207
- catch {
208
- // Process may already be dead
209
- }
210
- }
211
- /**
212
- * Close the session and clean up resources.
213
- */
214
- close() {
215
- // Kill the process first before disposing handlers
216
- if (this._isRunning) {
217
- this.kill("SIGKILL");
218
- // Mark as not running since we won't receive the exit event
219
- // after disposing the handlers
220
- this._isRunning = false;
221
- // Resolve the exit promise to unblock any waiters
222
- // Use -1 to indicate forced termination
223
- this._exitResolve(-1);
224
- }
225
- this._dataDisposable.dispose();
226
- this._exitDisposable.dispose();
227
- }
228
- /**
229
- * Get the current output buffer.
230
- */
231
- get output() {
232
- return this._output;
233
- }
234
- /**
235
- * Check if the process is still running.
236
- */
237
- get isRunning() {
238
- return this._isRunning;
239
- }
240
- /**
241
- * Get the process ID.
242
- */
243
- get pid() {
244
- return this._pty.pid;
245
- }
246
- /**
247
- * Get the exit code (undefined if still running).
248
- */
249
- get exitCode() {
250
- return this._exitCode;
251
- }
252
- /**
253
- * Get the current terminal columns.
254
- */
255
- get cols() {
256
- return this._pty.cols;
257
- }
258
- /**
259
- * Get the current terminal rows.
260
- */
261
- get rows() {
262
- return this._pty.rows;
263
- }
264
- }
265
- exports.PTYSession = PTYSession;
266
- /**
267
- * Create a new PTY session.
268
- * @param options Options for the PTY
269
- * @returns A PTYSession wrapping the process
270
- */
271
- async function createPTYSession(options) {
272
- const defaultCols = 80;
273
- const defaultRows = 24;
274
- const pty = nodePty.spawn(options.command, options.args ?? [], {
275
- name: "xterm-256color",
276
- cols: options.cols ?? defaultCols,
277
- rows: options.rows ?? defaultRows,
278
- cwd: options.cwd ?? process.cwd(),
279
- env: {
280
- ...(0, shell_js_1.sanitizeEnv)(options.env),
281
- TERM: "xterm-256color",
282
- },
283
- });
284
- return new PTYSession(pty);
285
- }
286
- /**
287
- * Run a command in a PTY and wait for it to complete.
288
- * This is a convenience function for commands that don't require interaction.
289
- *
290
- * @param options Options for the PTY, with optional timeout
291
- * @returns The output and exit code
292
- */
293
- async function runInPTY(options) {
294
- const { timeoutMs = 30000, ...ptyOptions } = options;
295
- const session = await createPTYSession(ptyOptions);
296
- try {
297
- const output = await session.waitForExit(timeoutMs);
298
- return {
299
- output,
300
- exitCode: session.exitCode ?? 0,
301
- };
302
- }
303
- finally {
304
- session.close();
305
- }
306
- }
307
- /**
308
- * Escape special regex characters in a string.
309
- */
310
- function escapeRegExp(string) {
311
- return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
312
- }
@@ -1,155 +0,0 @@
1
- "use strict";
2
- /**
3
- * @aria/tools - Restart executor
4
- *
5
- * Single restart path for both TUI and daemon:
6
- * Register an 'exit' handler to spawn a replacement process, then SIGINT
7
- * the current process for graceful shutdown. The replacement starts fresh
8
- * and goes through normal startup (heap check, createCliContext, REPL/daemon).
9
- */
10
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- var desc = Object.getOwnPropertyDescriptor(m, k);
13
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
14
- desc = { enumerable: true, get: function() { return m[k]; } };
15
- }
16
- Object.defineProperty(o, k2, desc);
17
- }) : (function(o, m, k, k2) {
18
- if (k2 === undefined) k2 = k;
19
- o[k2] = m[k];
20
- }));
21
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
22
- Object.defineProperty(o, "default", { enumerable: true, value: v });
23
- }) : function(o, v) {
24
- o["default"] = v;
25
- });
26
- var __importStar = (this && this.__importStar) || (function () {
27
- var ownKeys = function(o) {
28
- ownKeys = Object.getOwnPropertyNames || function (o) {
29
- var ar = [];
30
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
31
- return ar;
32
- };
33
- return ownKeys(o);
34
- };
35
- return function (mod) {
36
- if (mod && mod.__esModule) return mod;
37
- var result = {};
38
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
39
- __setModuleDefault(result, mod);
40
- return result;
41
- };
42
- })();
43
- Object.defineProperty(exports, "__esModule", { value: true });
44
- exports.executeRestart = executeRestart;
45
- const utils_js_1 = require("./utils.js");
46
- const node_child_process_1 = require("node:child_process");
47
- const node_fs_1 = require("node:fs");
48
- const node_path_1 = require("node:path");
49
- const os = __importStar(require("node:os"));
50
- const types_1 = require("@aria-cli/types");
51
- function findPnpmWorkspaceRoot(startDir) {
52
- let dir = (0, node_path_1.resolve)(startDir);
53
- while (true) {
54
- if ((0, node_fs_1.existsSync)((0, node_path_1.join)(dir, "pnpm-workspace.yaml")))
55
- return dir;
56
- const parent = (0, node_path_1.dirname)(dir);
57
- if (parent === dir)
58
- return null;
59
- dir = parent;
60
- }
61
- }
62
- function getPnpmCommand() {
63
- return process.platform === "win32" ? "pnpm.cmd" : "pnpm";
64
- }
65
- async function rebuildWorkspaceIfPresent(startDir) {
66
- const root = findPnpmWorkspaceRoot(startDir);
67
- if (!root)
68
- return { attempted: false };
69
- const pnpm = getPnpmCommand();
70
- await new Promise((resolvePromise, rejectPromise) => {
71
- const child = (0, node_child_process_1.spawn)(pnpm, ["build"], {
72
- cwd: root,
73
- env: process.env,
74
- stdio: "inherit",
75
- });
76
- child.on("error", rejectPromise);
77
- child.on("close", (code) => {
78
- if (code === 0)
79
- resolvePromise();
80
- else
81
- rejectPromise(new Error(`pnpm build failed with exit code ${code ?? "unknown"}`));
82
- });
83
- });
84
- return { attempted: true };
85
- }
86
- /**
87
- * Find the daemon PID for the current ARIA_HOME by scanning owner records.
88
- * Owner records live at $RUNTIME_ROOT/owners/*.json where RUNTIME_ROOT is
89
- * XDG_RUNTIME_DIR/aria or ~/.aria/run.
90
- */
91
- function findDaemonPid() {
92
- const ariaHome = process.env.ARIA_HOME?.trim() || (0, node_path_1.join)(os.homedir(), ".aria");
93
- const runtimeDir = process.env.XDG_RUNTIME_DIR?.trim();
94
- const runtimeRoot = runtimeDir ? (0, node_path_1.join)(runtimeDir, "aria") : (0, node_path_1.join)(ariaHome, "run");
95
- const ownersDir = (0, node_path_1.join)(runtimeRoot, "owners");
96
- if (!(0, node_fs_1.existsSync)(ownersDir))
97
- return null;
98
- const canonicalHome = (0, node_path_1.resolve)(ariaHome);
99
- for (const file of (0, node_fs_1.readdirSync)(ownersDir).filter((f) => f.endsWith(".json"))) {
100
- try {
101
- const record = JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.join)(ownersDir, file), "utf8"));
102
- if (record.ariaHome && (0, node_path_1.resolve)(record.ariaHome) === canonicalHome) {
103
- return typeof record.runtimePid === "number" ? record.runtimePid : null;
104
- }
105
- }
106
- catch {
107
- // Skip malformed records
108
- }
109
- }
110
- return null;
111
- }
112
- async function executeRestart(input, ctx) {
113
- if (ctx.abortSignal?.aborted)
114
- return (0, utils_js_1.fail)("Operation cancelled");
115
- const reason = (input.reason ?? "").trim() || "Restart requested";
116
- // Note: tool definition has requiresConfirmation: true, so the framework
117
- // already prompts the user before execute() is called. No need to confirm again.
118
- process.stderr.write(`[aria] Rebuilding workspace before restart...\n`);
119
- try {
120
- const rebuilt = await rebuildWorkspaceIfPresent(ctx.workingDir || process.cwd());
121
- if (!rebuilt.attempted) {
122
- process.stderr.write(`[aria] No pnpm workspace detected; skipping build\n`);
123
- }
124
- }
125
- catch (error) {
126
- process.stderr.write(`[aria] Build failed; continuing restart: ${error.message}\n`);
127
- }
128
- process.stderr.write(`[aria] Restarting: ${reason}\n`);
129
- const sessionId = process.env[types_1.RESUME_SESSION_ENV] ?? null;
130
- const arionName = process.env[types_1.RESUME_ARION_ENV] || "ARIA";
131
- // Write disk-backed marker so the replacement process can resume the session.
132
- (0, types_1.writeRelaunchMarker)({
133
- sessionId,
134
- arionName,
135
- pid: process.ppid || process.pid,
136
- timestamp: new Date().toISOString(),
137
- });
138
- // Spawn replacement on exit, then SIGINT for graceful shutdown.
139
- // Works for both TUI and daemon — no supervisor needed.
140
- const targetPid = findDaemonPid() ?? process.pid;
141
- process.once("exit", () => {
142
- (0, node_child_process_1.spawn)(process.execPath, [...process.execArgv, ...process.argv.slice(1)], {
143
- detached: true,
144
- stdio: "ignore",
145
- }).unref();
146
- });
147
- process.stderr.write(`[aria] Sending SIGINT to pid ${targetPid} for graceful restart\n`);
148
- try {
149
- process.kill(targetPid, "SIGINT");
150
- }
151
- catch {
152
- process.kill(process.pid, "SIGINT");
153
- }
154
- return (0, utils_js_1.success)("Restarting...");
155
- }