@aria-cli/tools 1.0.9 → 1.0.11

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 (241) hide show
  1. package/package.json +9 -5
  2. package/src/__tests__/web-fetch-download.test.ts +0 -433
  3. package/src/__tests__/web-tools.test.ts +0 -619
  4. package/src/ask-user-interaction.ts +0 -33
  5. package/src/cache/web-cache.ts +0 -110
  6. package/src/definitions/arion.ts +0 -118
  7. package/src/definitions/browser/browser.ts +0 -502
  8. package/src/definitions/browser/index.ts +0 -5
  9. package/src/definitions/browser/pw-downloads.ts +0 -142
  10. package/src/definitions/browser/pw-interactions.ts +0 -282
  11. package/src/definitions/browser/pw-responses.ts +0 -98
  12. package/src/definitions/browser/pw-session.ts +0 -405
  13. package/src/definitions/browser/pw-shared.ts +0 -85
  14. package/src/definitions/browser/pw-snapshot.ts +0 -383
  15. package/src/definitions/browser/pw-state.ts +0 -101
  16. package/src/definitions/browser/types.ts +0 -203
  17. package/src/definitions/code-intelligence.ts +0 -526
  18. package/src/definitions/core.ts +0 -118
  19. package/src/definitions/delegation.ts +0 -567
  20. package/src/definitions/deploy.ts +0 -73
  21. package/src/definitions/filesystem.ts +0 -217
  22. package/src/definitions/frg.ts +0 -67
  23. package/src/definitions/index.ts +0 -28
  24. package/src/definitions/memory.ts +0 -150
  25. package/src/definitions/messaging.ts +0 -734
  26. package/src/definitions/meta.ts +0 -392
  27. package/src/definitions/network.ts +0 -179
  28. package/src/definitions/outlook.ts +0 -318
  29. package/src/definitions/patch/apply-patch.ts +0 -235
  30. package/src/definitions/patch/fuzzy-match.ts +0 -217
  31. package/src/definitions/patch/index.ts +0 -1
  32. package/src/definitions/patch/patch-parser.ts +0 -297
  33. package/src/definitions/patch/sandbox-paths.ts +0 -129
  34. package/src/definitions/process/index.ts +0 -5
  35. package/src/definitions/process/process-registry.ts +0 -303
  36. package/src/definitions/process/process.ts +0 -456
  37. package/src/definitions/process/pty-keys.ts +0 -298
  38. package/src/definitions/process/session-slug.ts +0 -147
  39. package/src/definitions/quip.ts +0 -225
  40. package/src/definitions/search.ts +0 -67
  41. package/src/definitions/session-history.ts +0 -79
  42. package/src/definitions/shell.ts +0 -202
  43. package/src/definitions/slack.ts +0 -211
  44. package/src/definitions/web.ts +0 -119
  45. package/src/executors/apply-patch.ts +0 -1035
  46. package/src/executors/arion.ts +0 -199
  47. package/src/executors/code-intelligence.ts +0 -1179
  48. package/src/executors/deploy.ts +0 -1066
  49. package/src/executors/filesystem.ts +0 -1428
  50. package/src/executors/frg-freshness.ts +0 -743
  51. package/src/executors/frg.ts +0 -394
  52. package/src/executors/index.ts +0 -280
  53. package/src/executors/learning-meta.ts +0 -1367
  54. package/src/executors/lsp-client.ts +0 -355
  55. package/src/executors/memory.ts +0 -978
  56. package/src/executors/meta.ts +0 -293
  57. package/src/executors/process-registry.ts +0 -570
  58. package/src/executors/pty-session-store.ts +0 -43
  59. package/src/executors/pty.ts +0 -342
  60. package/src/executors/restart.ts +0 -133
  61. package/src/executors/search-freshness.ts +0 -249
  62. package/src/executors/search-types.ts +0 -98
  63. package/src/executors/search.ts +0 -89
  64. package/src/executors/self-diagnose.ts +0 -552
  65. package/src/executors/session-history.ts +0 -435
  66. package/src/executors/shell-safety.ts +0 -519
  67. package/src/executors/shell.ts +0 -1243
  68. package/src/executors/utils.ts +0 -40
  69. package/src/executors/web.ts +0 -786
  70. package/src/extraction/content-extraction.ts +0 -281
  71. package/src/extraction/index.ts +0 -5
  72. package/src/headless-control-contract.ts +0 -1149
  73. package/src/index.ts +0 -788
  74. package/src/local-control-http-auth.ts +0 -2
  75. package/src/mcp/client.ts +0 -218
  76. package/src/mcp/connection.ts +0 -568
  77. package/src/mcp/index.ts +0 -11
  78. package/src/mcp/jsonrpc.ts +0 -195
  79. package/src/mcp/types.ts +0 -199
  80. package/src/network-control-adapter.ts +0 -88
  81. package/src/network-runtime/address-types.ts +0 -218
  82. package/src/network-runtime/db-owner-fencing.ts +0 -91
  83. package/src/network-runtime/delivery-receipts.ts +0 -372
  84. package/src/network-runtime/direct-endpoint-authority.ts +0 -35
  85. package/src/network-runtime/index.ts +0 -316
  86. package/src/network-runtime/local-control-contract.ts +0 -784
  87. package/src/network-runtime/node-store-contract.ts +0 -46
  88. package/src/network-runtime/pair-route-contract.ts +0 -97
  89. package/src/network-runtime/peer-capabilities.ts +0 -48
  90. package/src/network-runtime/peer-principal-ref.ts +0 -20
  91. package/src/network-runtime/peer-state-machine.ts +0 -160
  92. package/src/network-runtime/protocol-schemas.ts +0 -265
  93. package/src/network-runtime/runtime-bootstrap-contract.ts +0 -83
  94. package/src/outlook/desktop-session.ts +0 -409
  95. package/src/policy.ts +0 -171
  96. package/src/providers/brave.ts +0 -80
  97. package/src/providers/duckduckgo.ts +0 -199
  98. package/src/providers/exa.ts +0 -85
  99. package/src/providers/firecrawl.ts +0 -77
  100. package/src/providers/index.ts +0 -8
  101. package/src/providers/jina.ts +0 -70
  102. package/src/providers/router.ts +0 -121
  103. package/src/providers/search-provider.ts +0 -74
  104. package/src/providers/tavily.ts +0 -74
  105. package/src/quip/desktop-session.ts +0 -435
  106. package/src/registry/index.ts +0 -1
  107. package/src/registry/registry.ts +0 -905
  108. package/src/runtime-socket-local-control-client.ts +0 -632
  109. package/src/security/dns-normalization.ts +0 -34
  110. package/src/security/dns-pinning.ts +0 -138
  111. package/src/security/external-content.ts +0 -129
  112. package/src/security/ssrf.ts +0 -207
  113. package/src/slack/desktop-session.ts +0 -493
  114. package/src/tool-factory.ts +0 -91
  115. package/src/types.ts +0 -1341
  116. package/src/utils/retry.ts +0 -163
  117. package/src/utils/safe-parse-json.ts +0 -176
  118. package/src/utils/url.ts +0 -20
  119. package/tests/benchmarks/registry.bench.ts +0 -57
  120. package/tests/cache/web-cache.test.ts +0 -147
  121. package/tests/critical-integration.test.ts +0 -1465
  122. package/tests/definitions/apply-patch.test.ts +0 -586
  123. package/tests/definitions/browser.test.ts +0 -495
  124. package/tests/definitions/delegation-pause-resume.test.ts +0 -758
  125. package/tests/definitions/execution.test.ts +0 -671
  126. package/tests/definitions/messaging-inbox-scope.test.ts +0 -229
  127. package/tests/definitions/messaging.test.ts +0 -1468
  128. package/tests/definitions/outlook.test.ts +0 -30
  129. package/tests/definitions/process.test.ts +0 -469
  130. package/tests/definitions/slack.test.ts +0 -28
  131. package/tests/definitions/tool-inventory.test.ts +0 -218
  132. package/tests/e2e/delegation-quest-orchestration.e2e.test.ts +0 -433
  133. package/tests/e2e/memory-tool-discovery-contract.e2e.test.ts +0 -81
  134. package/tests/executors/apply-patch.test.ts +0 -538
  135. package/tests/executors/arion.test.ts +0 -309
  136. package/tests/executors/conversation-primitives.test.ts +0 -250
  137. package/tests/executors/deploy.test.ts +0 -746
  138. package/tests/executors/filesystem-tools.test.ts +0 -357
  139. package/tests/executors/filesystem.test.ts +0 -959
  140. package/tests/executors/frg-freshness.test.ts +0 -136
  141. package/tests/executors/frg-merge.test.ts +0 -70
  142. package/tests/executors/frg-session-content.test.ts +0 -40
  143. package/tests/executors/frg.test.ts +0 -56
  144. package/tests/executors/memory-bugfixes.test.ts +0 -257
  145. package/tests/executors/memory-real-memoria.integration.test.ts +0 -316
  146. package/tests/executors/memory.test.ts +0 -853
  147. package/tests/executors/meta-tools.test.ts +0 -411
  148. package/tests/executors/meta.test.ts +0 -683
  149. package/tests/executors/path-containment.test.ts +0 -51
  150. package/tests/executors/process-registry.test.ts +0 -505
  151. package/tests/executors/pty.test.ts +0 -664
  152. package/tests/executors/quest-security.test.ts +0 -249
  153. package/tests/executors/read-file-media.test.ts +0 -230
  154. package/tests/executors/recall-knowledge-schema.test.ts +0 -209
  155. package/tests/executors/recall-tags.test.ts +0 -278
  156. package/tests/executors/remember-null-safety.contract.test.ts +0 -41
  157. package/tests/executors/restart.test.ts +0 -67
  158. package/tests/executors/search-unified.test.ts +0 -381
  159. package/tests/executors/session-history.test.ts +0 -340
  160. package/tests/executors/session-transcript.test.ts +0 -561
  161. package/tests/executors/shell-abort.test.ts +0 -416
  162. package/tests/executors/shell-env-blocklist.test.ts +0 -648
  163. package/tests/executors/shell-env-process.test.ts +0 -245
  164. package/tests/executors/shell-process-registry.test.ts +0 -334
  165. package/tests/executors/shell-tools.test.ts +0 -393
  166. package/tests/executors/shell.test.ts +0 -690
  167. package/tests/executors/web-abort-vs-timeout.test.ts +0 -213
  168. package/tests/executors/web-integration.test.ts +0 -633
  169. package/tests/executors/web-symlink.test.ts +0 -18
  170. package/tests/executors/web.test.ts +0 -1400
  171. package/tests/executors/write-stdin.test.ts +0 -145
  172. package/tests/extraction/content-extraction.test.ts +0 -153
  173. package/tests/guards/tools-default-test-lane.integration.test.ts +0 -21
  174. package/tests/guards/tools-package-test-commands.e2e.test.ts +0 -43
  175. package/tests/guards/tools-test-lane-manifest.contract.test.ts +0 -76
  176. package/tests/guards/tools-vitest-workspace-alias.contract.test.ts +0 -63
  177. package/tests/helpers/async-waits.ts +0 -53
  178. package/tests/integration/headless-control-contract.integration.test.ts +0 -153
  179. package/tests/integration/memory-tool-schema-parity.integration.test.ts +0 -67
  180. package/tests/integration/meta-tools-round-trip.integration.test.ts +0 -506
  181. package/tests/integration/quest-round-trip.test.ts +0 -303
  182. package/tests/integration/registry-executor-flow.test.ts +0 -85
  183. package/tests/integration.test.ts +0 -177
  184. package/tests/loading-tier.test.ts +0 -126
  185. package/tests/mcp/client-reconnect.test.ts +0 -267
  186. package/tests/mcp/connection.test.ts +0 -846
  187. package/tests/mcp/injectable-logger.test.ts +0 -83
  188. package/tests/mcp/jsonrpc.test.ts +0 -109
  189. package/tests/mcp/lifecycle.test.ts +0 -879
  190. package/tests/network-runtime/address-types.contract.test.ts +0 -143
  191. package/tests/network-runtime/continuity-bind-schema.contract.test.ts +0 -203
  192. package/tests/network-runtime/local-control-contract.test.ts +0 -869
  193. package/tests/network-runtime/local-control-invite-token.contract.test.ts +0 -146
  194. package/tests/network-runtime/node-store-contract.test.ts +0 -11
  195. package/tests/network-runtime/pair-protocol-nodeid.contract.test.ts +0 -15
  196. package/tests/network-runtime/peer-state-machine.contract.test.ts +0 -148
  197. package/tests/network-runtime/protocol-schemas.contract.test.ts +0 -512
  198. package/tests/network-runtime/relay-pending-nodeid.contract.test.ts +0 -62
  199. package/tests/network-runtime/runtime-bootstrap-contract.test.ts +0 -227
  200. package/tests/network-runtime/runtime-socket-local-control-client.test.ts +0 -621
  201. package/tests/network-runtime/wait-for-message-script.test.ts +0 -288
  202. package/tests/parallel.test.ts +0 -71
  203. package/tests/policy.test.ts +0 -184
  204. package/tests/print-default-test-lane.ts +0 -14
  205. package/tests/print-test-lane-manifest.ts +0 -22
  206. package/tests/providers/brave.test.ts +0 -159
  207. package/tests/providers/duckduckgo.test.ts +0 -207
  208. package/tests/providers/exa.test.ts +0 -175
  209. package/tests/providers/firecrawl.test.ts +0 -168
  210. package/tests/providers/jina.test.ts +0 -144
  211. package/tests/providers/router.test.ts +0 -328
  212. package/tests/providers/tavily.test.ts +0 -165
  213. package/tests/registry/discovery.test.ts +0 -154
  214. package/tests/registry/injectable-logger.test.ts +0 -230
  215. package/tests/registry/input-validation.test.ts +0 -361
  216. package/tests/registry/interface-completeness.test.ts +0 -85
  217. package/tests/registry/mcp-integration.test.ts +0 -103
  218. package/tests/registry/mcp-read-only-hint.test.ts +0 -60
  219. package/tests/registry/memoria-discovery.test.ts +0 -390
  220. package/tests/registry/nested-validation.test.ts +0 -283
  221. package/tests/registry/pseudo-tool-filtering.test.ts +0 -258
  222. package/tests/registry/registration-lifecycle.test.ts +0 -133
  223. package/tests/registry-validation.test.ts +0 -424
  224. package/tests/registry.test.ts +0 -460
  225. package/tests/security/dns-pinning.test.ts +0 -162
  226. package/tests/security/external-content.test.ts +0 -144
  227. package/tests/security/ssrf.test.ts +0 -118
  228. package/tests/shell-safety-integration.test.ts +0 -32
  229. package/tests/shell-safety.test.ts +0 -365
  230. package/tests/slack/desktop-session.test.ts +0 -50
  231. package/tests/test-lane-manifest.ts +0 -440
  232. package/tests/test-utils.ts +0 -27
  233. package/tests/tool-factory.test.ts +0 -188
  234. package/tests/utils/retry.test.ts +0 -231
  235. package/tests/utils/url.test.ts +0 -63
  236. package/tsconfig.cjs.json +0 -24
  237. package/tsconfig.json +0 -12
  238. package/vitest.config.ts +0 -55
  239. package/vitest.e2e.config.ts +0 -24
  240. package/vitest.integration.config.ts +0 -24
  241. package/vitest.native.config.ts +0 -24
@@ -1,195 +0,0 @@
1
- /**
2
- * JSON-RPC 2.0 Client for MCP
3
- *
4
- * Handles newline-delimited JSON over stdio streams.
5
- */
6
-
7
- import { Readable, Writable } from "stream";
8
- import { EventEmitter } from "events";
9
- import { randomUUID } from "crypto";
10
-
11
- interface JSONRPCRequest {
12
- jsonrpc: "2.0";
13
- id: string | number;
14
- method: string;
15
- params?: unknown;
16
- }
17
-
18
- interface JSONRPCResponse {
19
- jsonrpc: "2.0";
20
- id: string | number;
21
- result?: unknown;
22
- error?: { code: number; message: string; data?: unknown };
23
- }
24
-
25
- interface JSONRPCNotification {
26
- jsonrpc: "2.0";
27
- method: string;
28
- params?: unknown;
29
- }
30
-
31
- type PendingRequest = {
32
- resolve: (value: unknown) => void;
33
- reject: (error: Error) => void;
34
- timeout: NodeJS.Timeout;
35
- };
36
-
37
- export class JSONRPCClient extends EventEmitter {
38
- private stdin?: Writable;
39
- private stdout?: Readable;
40
- private pending: Map<string, PendingRequest> = new Map();
41
- private buffer = "";
42
- private requestTimeout: number;
43
-
44
- constructor(options: { timeout?: number } = {}) {
45
- super();
46
- this.requestTimeout = options.timeout ?? 30000;
47
- }
48
-
49
- /**
50
- * Connect to a process via stdio streams
51
- */
52
- connect(stdin: Writable, stdout: Readable): void {
53
- this.stdin = stdin;
54
- this.stdout = stdout;
55
-
56
- stdout.on("data", (chunk: Buffer) => {
57
- this.buffer += chunk.toString();
58
- this.processBuffer();
59
- });
60
-
61
- stdout.on("error", (error) => {
62
- this.emit("error", error);
63
- });
64
-
65
- stdout.on("end", () => {
66
- this.emit("close");
67
- });
68
- }
69
-
70
- private processBuffer(): void {
71
- let newlineIdx: number;
72
- while ((newlineIdx = this.buffer.indexOf("\n")) !== -1) {
73
- const line = this.buffer.slice(0, newlineIdx).trim();
74
- this.buffer = this.buffer.slice(newlineIdx + 1);
75
-
76
- if (line) {
77
- try {
78
- this.handleMessage(JSON.parse(line));
79
- } catch (e) {
80
- this.emit("error", new Error(`Invalid JSON: ${line}`));
81
- }
82
- }
83
- }
84
- }
85
-
86
- private handleMessage(msg: unknown): void {
87
- // Ignore messages that aren't valid JSON-RPC 2.0
88
- if (
89
- typeof msg !== "object" ||
90
- msg === null ||
91
- !("jsonrpc" in msg) ||
92
- (msg as { jsonrpc: unknown }).jsonrpc !== "2.0"
93
- )
94
- return;
95
-
96
- const rpcMsg = msg as JSONRPCResponse | JSONRPCNotification;
97
-
98
- // Response to our request
99
- if ("id" in rpcMsg && (rpcMsg as JSONRPCResponse).id !== undefined) {
100
- const response = rpcMsg as JSONRPCResponse;
101
- const pending = this.pending.get(String(response.id));
102
- if (pending) {
103
- this.pending.delete(String(response.id));
104
- clearTimeout(pending.timeout);
105
-
106
- if (response.error) {
107
- pending.reject(
108
- new Error(`${response.error.code}: ${response.error.message}`),
109
- );
110
- } else {
111
- pending.resolve(response.result);
112
- }
113
- }
114
- return;
115
- }
116
-
117
- // Notification from server
118
- if ("method" in rpcMsg) {
119
- const notification = rpcMsg as JSONRPCNotification;
120
- this.emit(notification.method, notification.params);
121
- this.emit("notification", {
122
- method: notification.method,
123
- params: notification.params,
124
- });
125
- }
126
- }
127
-
128
- /**
129
- * Send a request and wait for response
130
- */
131
- async request<T = unknown>(method: string, params?: unknown): Promise<T> {
132
- if (!this.stdin) {
133
- throw new Error("Not connected");
134
- }
135
-
136
- const id = randomUUID();
137
-
138
- const message: JSONRPCRequest = {
139
- jsonrpc: "2.0",
140
- id,
141
- method,
142
- params,
143
- };
144
-
145
- return new Promise((resolve, reject) => {
146
- const timeout = setTimeout(() => {
147
- if (this.pending.has(id)) {
148
- this.pending.delete(id);
149
- reject(new Error(`Request timeout: ${method}`));
150
- }
151
- }, this.requestTimeout);
152
-
153
- this.pending.set(id, {
154
- resolve: resolve as (v: unknown) => void,
155
- reject,
156
- timeout,
157
- });
158
- this.send(message);
159
- });
160
- }
161
-
162
- /**
163
- * Send a notification (no response expected)
164
- */
165
- notify(method: string, params?: unknown): void {
166
- const message: JSONRPCNotification = {
167
- jsonrpc: "2.0",
168
- method,
169
- params,
170
- };
171
- this.send(message);
172
- }
173
-
174
- private send(message: JSONRPCRequest | JSONRPCNotification): void {
175
- if (!this.stdin) {
176
- throw new Error("Not connected");
177
- }
178
- this.stdin.write(JSON.stringify(message) + "\n");
179
- }
180
-
181
- /**
182
- * Close and cleanup
183
- */
184
- close(): void {
185
- for (const [, pending] of this.pending) {
186
- clearTimeout(pending.timeout);
187
- pending.reject(new Error("Connection closed"));
188
- }
189
- this.pending.clear();
190
- this.buffer = "";
191
- this.stdin = undefined;
192
- this.stdout?.removeAllListeners();
193
- this.stdout = undefined;
194
- }
195
- }
package/src/mcp/types.ts DELETED
@@ -1,199 +0,0 @@
1
- /**
2
- * MCP (Model Context Protocol) Types
3
- *
4
- * Protocol version: 2024-11-05
5
- * https://modelcontextprotocol.io
6
- */
7
-
8
- import type { JSONSchema7 } from "json-schema";
9
-
10
- // ============================================================================
11
- // Configuration
12
- // ============================================================================
13
-
14
- /**
15
- * MCP server configuration
16
- */
17
- export interface MCPServerConfig {
18
- /** Unique server identifier */
19
- name: string;
20
- /** Transport type (defaults to 'stdio' if omitted) */
21
- transport?: "stdio" | "sse";
22
- /** Command to spawn (stdio transport) */
23
- command?: string;
24
- /** Command arguments */
25
- args?: string[];
26
- /** SSE endpoint URL */
27
- url?: string;
28
- /** Environment variables for server process */
29
- env?: Record<string, string>;
30
- /** Configuration scope */
31
- scope?: "project" | "global";
32
- }
33
-
34
- // ============================================================================
35
- // Protocol Messages
36
- // ============================================================================
37
-
38
- /**
39
- * Server capabilities from initialize response
40
- */
41
- export interface MCPCapabilities {
42
- tools?: { listChanged?: boolean };
43
- resources?: { subscribe?: boolean; listChanged?: boolean };
44
- prompts?: { listChanged?: boolean };
45
- logging?: Record<string, never>;
46
- }
47
-
48
- /**
49
- * Initialize request params
50
- */
51
- export interface MCPInitializeParams {
52
- protocolVersion: string;
53
- capabilities: {
54
- roots?: { listChanged?: boolean };
55
- sampling?: Record<string, never>;
56
- };
57
- clientInfo: {
58
- name: string;
59
- version: string;
60
- };
61
- }
62
-
63
- /**
64
- * Initialize response
65
- */
66
- export interface MCPInitializeResult {
67
- protocolVersion: string;
68
- capabilities: MCPCapabilities;
69
- serverInfo: {
70
- name: string;
71
- version: string;
72
- };
73
- }
74
-
75
- // ============================================================================
76
- // Tools
77
- // ============================================================================
78
-
79
- /**
80
- * Tool definition from tools/list
81
- */
82
- export interface MCPTool {
83
- name: string;
84
- description?: string;
85
- inputSchema: JSONSchema7;
86
- annotations?: {
87
- readOnlyHint?: boolean;
88
- };
89
- }
90
-
91
- /**
92
- * Tool call request params
93
- */
94
- export interface MCPToolCallParams {
95
- name: string;
96
- arguments?: Record<string, unknown>;
97
- }
98
-
99
- /**
100
- * Content types in tool results
101
- */
102
- export type MCPContent =
103
- | { type: "text"; text: string }
104
- | { type: "image"; data: string; mimeType: string }
105
- | { type: "resource"; resource: { uri: string; mimeType?: string; text?: string } };
106
-
107
- /**
108
- * Tool call result
109
- */
110
- export interface MCPToolCallResult {
111
- content: MCPContent[];
112
- isError?: boolean;
113
- }
114
-
115
- // ============================================================================
116
- // Resources
117
- // ============================================================================
118
-
119
- /**
120
- * Resource definition from resources/list
121
- */
122
- export interface MCPResource {
123
- uri: string;
124
- name: string;
125
- description?: string;
126
- mimeType?: string;
127
- }
128
-
129
- /**
130
- * Resource content from resources/read
131
- */
132
- export interface MCPResourceContent {
133
- uri: string;
134
- mimeType?: string;
135
- text?: string;
136
- blob?: string;
137
- }
138
-
139
- /**
140
- * Resources read result
141
- */
142
- export interface MCPResourceReadResult {
143
- contents: MCPResourceContent[];
144
- }
145
-
146
- // ============================================================================
147
- // Prompts
148
- // ============================================================================
149
-
150
- /**
151
- * Prompt definition from prompts/list
152
- */
153
- export interface MCPPrompt {
154
- name: string;
155
- description?: string;
156
- arguments?: Array<{
157
- name: string;
158
- description?: string;
159
- required?: boolean;
160
- }>;
161
- }
162
-
163
- /**
164
- * Prompt message from prompts/get
165
- */
166
- export interface MCPPromptMessage {
167
- role: "user" | "assistant";
168
- content: MCPContent;
169
- }
170
-
171
- /**
172
- * Prompts get result
173
- */
174
- export interface MCPPromptGetResult {
175
- description?: string;
176
- messages: MCPPromptMessage[];
177
- }
178
-
179
- // ============================================================================
180
- // Notifications
181
- // ============================================================================
182
-
183
- /**
184
- * Log message from server
185
- */
186
- export interface MCPLogMessage {
187
- level: "debug" | "info" | "warning" | "error";
188
- logger?: string;
189
- data?: unknown;
190
- }
191
-
192
- /**
193
- * Progress notification
194
- */
195
- export interface MCPProgress {
196
- progressToken: string | number;
197
- progress: number;
198
- total?: number;
199
- }
@@ -1,88 +0,0 @@
1
- import { SigningPublicKeySchema, type SigningPublicKey } from "./network-runtime/index.js";
2
- import type {
3
- NetworkControlRef,
4
- NetworkManagerPeerInfo,
5
- NetworkManagerRef,
6
- NetworkManagerStatusView,
7
- NetworkPeerView,
8
- NetworkStatusView,
9
- } from "./types.js";
10
-
11
- export function toNetworkPeerView(peer: NetworkManagerPeerInfo): NetworkPeerView | null {
12
- const parsedSigningPublicKey = SigningPublicKeySchema.safeParse(peer.signingPublicKey?.trim());
13
- if (
14
- !parsedSigningPublicKey.success ||
15
- typeof peer.nodeId !== "string" ||
16
- peer.nodeId.length === 0
17
- ) {
18
- return null;
19
- }
20
- const signingPublicKey = parsedSigningPublicKey.data;
21
- return {
22
- nodeId: peer.nodeId,
23
- transportPublicKey: peer.publicKey,
24
- displayNameSnapshot: peer.name,
25
- endpointHost: peer.endpointHost,
26
- endpointPort: peer.endpointPort,
27
- controlEndpoint: peer.controlEndpoint ?? null,
28
- signingPublicKey,
29
- status: peer.status,
30
- membershipStatus: peer.membershipStatus ?? peer.status,
31
- routeOwnership: peer.routeOwnership,
32
- routeOwnerNodeId: peer.routeOwnerNodeId ?? null,
33
- sessionState: peer.sessionState,
34
- deliveryReadiness: peer.deliveryReadiness,
35
- lastHandshake: peer.lastHandshake,
36
- createdAt: peer.createdAt,
37
- endpointRevision: peer.endpointRevision ?? 0,
38
- updatedAt: peer.updatedAt ?? peer.createdAt,
39
- };
40
- }
41
-
42
- export function toNetworkStatusView(status: NetworkManagerStatusView): NetworkStatusView {
43
- const parsedSigningPublicKey = SigningPublicKeySchema.safeParse(status.signingPublicKey?.trim());
44
- const signingPublicKey: SigningPublicKey | null = parsedSigningPublicKey.success
45
- ? parsedSigningPublicKey.data
46
- : null;
47
- return {
48
- configured: status.configured,
49
- nodeId: status.nodeId,
50
- principalFingerprint: status.principalFingerprint,
51
- transportPublicKey: status.publicKey,
52
- listenPort: status.listenPort,
53
- externalEndpoint: status.externalEndpoint,
54
- activePeers: status.activePeers,
55
- totalPeers: status.totalPeers,
56
- connectedPeers: status.connectedPeers,
57
- handshakingPeers: status.handshakingPeers,
58
- queueOnlyPeers: status.queueOnlyPeers,
59
- supersededPeers: status.supersededPeers,
60
- signingPublicKey,
61
- };
62
- }
63
-
64
- export function toNetworkControlRef(
65
- networkManager?: NetworkManagerRef,
66
- ): NetworkControlRef | undefined {
67
- if (!networkManager) {
68
- return undefined;
69
- }
70
-
71
- return {
72
- invite(displayName, options) {
73
- return networkManager.invite(displayName, options);
74
- },
75
- revokePeer(nodeId) {
76
- return networkManager.revokePeer(nodeId);
77
- },
78
- listPeers() {
79
- return networkManager.listPeers().flatMap((peer) => {
80
- const projected = toNetworkPeerView(peer);
81
- return projected ? [projected] : [];
82
- });
83
- },
84
- status() {
85
- return toNetworkStatusView(networkManager.status());
86
- },
87
- };
88
- }
@@ -1,218 +0,0 @@
1
- import { z } from "zod";
2
-
3
- const NonEmptyStringSchema = z.string().trim().min(1);
4
-
5
- /**
6
- * Stable durable identity for a node.
7
- * Semantic rules are enforced by the runtime cutover plan; the contract layer
8
- * starts by making the shape canonical everywhere.
9
- */
10
- export const NodeIdSchema = NonEmptyStringSchema.brand<"NodeId">();
11
- export type NodeId = z.infer<typeof NodeIdSchema>;
12
-
13
- /** One boot of a given node runtime. */
14
- export const RuntimeIdSchema = NonEmptyStringSchema.brand<"RuntimeId">();
15
- export type RuntimeId = z.infer<typeof RuntimeIdSchema>;
16
-
17
- export const NodeMetadataSchema = z.object({
18
- nodeId: NodeIdSchema,
19
- createdAt: NonEmptyStringSchema,
20
- schemaVersion: z.number().int().positive(),
21
- migratedFromLegacy: z.boolean(),
22
- });
23
- export type NodeMetadata = z.infer<typeof NodeMetadataSchema>;
24
-
25
- /** Monotonic publication revision for externally visible runtime advertisements. */
26
- export const PublicationRevisionSchema = z.number().int().nonnegative();
27
- export type PublicationRevision = z.infer<typeof PublicationRevisionSchema>;
28
-
29
- /** Monotonic endpoint revision for register/discovery refreshes. */
30
- export const EndpointRevisionSchema = z.number().int().nonnegative();
31
- export type EndpointRevision = z.infer<typeof EndpointRevisionSchema>;
32
-
33
- /** Monotonic generation for peer-binding continuity transitions. */
34
- export const BindingGenerationSchema = z.number().int().nonnegative();
35
- export type BindingGeneration = z.infer<typeof BindingGenerationSchema>;
36
-
37
- /** Monotonic generation for revocation precedence and continuity conflict checks. */
38
- export const RevocationGenerationSchema = z.number().int().nonnegative();
39
- export type RevocationGeneration = z.infer<typeof RevocationGenerationSchema>;
40
-
41
- /** How a local operator confirmed a revocation decision. */
42
- export const RevocationOperatorConfirmationSchema = z.enum([
43
- "local_operator_confirmed",
44
- "remote_capability_authenticated",
45
- ]);
46
- export type RevocationOperatorConfirmation = z.infer<typeof RevocationOperatorConfirmationSchema>;
47
-
48
- /** Structured local authority record for a peer revocation decision. */
49
- export const RevocationDecisionSchema = z.object({
50
- localNodeId: NodeIdSchema,
51
- targetNodeId: NodeIdSchema,
52
- revocationGeneration: RevocationGenerationSchema,
53
- operatorConfirmation: RevocationOperatorConfirmationSchema,
54
- });
55
- export type RevocationDecision = z.infer<typeof RevocationDecisionSchema>;
56
-
57
- /** Monotonic owner generation for runtime ownership records. */
58
- export const OwnerGenerationSchema = z.number().int().positive();
59
- export type OwnerGeneration = z.infer<typeof OwnerGenerationSchema>;
60
-
61
- /** Monotonic revision for durable delivery lifecycle state transitions. */
62
- export const DeliveryLifecycleRevisionSchema = z.number().int().nonnegative();
63
- export type DeliveryLifecycleRevision = z.infer<typeof DeliveryLifecycleRevisionSchema>;
64
-
65
- export const RuntimeOwnerRecordSchema = z
66
- .object({
67
- schemaVersion: z.number().int().positive(),
68
- nodeId: NodeIdSchema,
69
- ariaHome: NonEmptyStringSchema,
70
- runtimePid: z.number().int().positive(),
71
- runtimeId: RuntimeIdSchema,
72
- displayNameSnapshot: NonEmptyStringSchema.optional(),
73
- runtimeSocket: NonEmptyStringSchema,
74
- startedAt: NonEmptyStringSchema,
75
- lastHeartbeat: NonEmptyStringSchema,
76
- ownerGeneration: OwnerGenerationSchema,
77
- })
78
- .strict();
79
- export type RuntimeOwnerRecord = z.infer<typeof RuntimeOwnerRecordSchema>;
80
-
81
- /** One attached local client of the runtime. */
82
- export const ClientIdSchema = NonEmptyStringSchema.brand<"ClientId">();
83
- export type ClientId = z.infer<typeof ClientIdSchema>;
84
-
85
- /** Durable principal fingerprint (SHA-256 hex of signing public key DER). Signing-key evidence only. */
86
- export const PrincipalFingerprintSchema = NonEmptyStringSchema.brand<"PrincipalFingerprint">();
87
- export type PrincipalFingerprint = z.infer<typeof PrincipalFingerprintSchema>;
88
-
89
- /** Transport public key / transport identity for a peer. */
90
- export const PeerTransportIdSchema = NonEmptyStringSchema.brand<"PeerTransportId">();
91
- export type PeerTransportId = z.infer<typeof PeerTransportIdSchema>;
92
-
93
- /** TLS CA certificate fingerprint (SHA-256 hex of CA cert DER). Certificate-authority evidence only — distinct from signing-key evidence. */
94
- export const TlsCaFingerprintSchema = NonEmptyStringSchema.brand<"TlsCaFingerprint">();
95
- export type TlsCaFingerprint = z.infer<typeof TlsCaFingerprintSchema>;
96
-
97
- /** Local-only loopback TLS SAN identity used for same-machine control attachment. */
98
- export const LoopbackTlsIdentitySchema = NonEmptyStringSchema.brand<"LoopbackTlsIdentity">();
99
- export type LoopbackTlsIdentity = z.infer<typeof LoopbackTlsIdentitySchema>;
100
- /** Base64-encoded signing public key material crossing runtime/shared boundaries. */
101
- export const SigningPublicKeySchema = NonEmptyStringSchema.brand<"SigningPublicKey">();
102
- export type SigningPublicKey = z.infer<typeof SigningPublicKeySchema>;
103
-
104
- /** Explicit network transport endpoint advertisement. */
105
- export const TransportEndpointAdvertisementSchema = z.object({
106
- host: NonEmptyStringSchema,
107
- port: z.number().int().min(1).max(65535),
108
- });
109
- export type TransportEndpointAdvertisement = z.infer<typeof TransportEndpointAdvertisementSchema>;
110
-
111
- /**
112
- * Runtime-owned local inbox addressing.
113
- * Same-machine clients are local attachments, not mesh peers.
114
- */
115
- export const InboxAddressSchema = z.discriminatedUnion("kind", [
116
- z.object({
117
- kind: z.literal("node"),
118
- nodeId: NodeIdSchema,
119
- }),
120
- z.object({
121
- kind: z.literal("client"),
122
- clientId: ClientIdSchema,
123
- }),
124
- ]);
125
- export type InboxAddress = z.infer<typeof InboxAddressSchema>;
126
-
127
- /**
128
- * Public control-plane endpoint advertisement used by peers for pinned,
129
- * mutating requests.
130
- */
131
- export const ControlEndpointAdvertisementSchema = z.object({
132
- host: NonEmptyStringSchema,
133
- port: z.number().int().min(1).max(65535),
134
- tlsCaFingerprint: TlsCaFingerprintSchema,
135
- tlsServerIdentity: PrincipalFingerprintSchema,
136
- protocolVersion: z.number().int().positive(),
137
- endpointRevision: EndpointRevisionSchema.optional(),
138
- });
139
- export type ControlEndpointAdvertisement = z.infer<typeof ControlEndpointAdvertisementSchema>;
140
-
141
- /**
142
- * Remote/public node advertisement. This deliberately excludes local-only
143
- * runtime/session identity like RuntimeId.
144
- */
145
- export const NodeAdvertisementSchema = z.object({
146
- nodeId: NodeIdSchema,
147
- principalFingerprint: PrincipalFingerprintSchema,
148
- transportPublicKey: PeerTransportIdSchema,
149
- publicationRevision: PublicationRevisionSchema.optional(),
150
- controlEndpoint: ControlEndpointAdvertisementSchema.optional(),
151
- displayNameSnapshot: NonEmptyStringSchema.optional(),
152
- });
153
- export type NodeAdvertisement = z.infer<typeof NodeAdvertisementSchema>;
154
-
155
- /**
156
- * Local-only runtime registry summary. This is not a remote/public mesh
157
- * contract and may include RuntimeId.
158
- */
159
- export const LocalRuntimeSummarySchema = z.object({
160
- nodeId: NodeIdSchema,
161
- runtimeId: RuntimeIdSchema,
162
- lastHeartbeat: NonEmptyStringSchema.optional(),
163
- controlEndpoint: ControlEndpointAdvertisementSchema.optional(),
164
- displayNameSnapshot: NonEmptyStringSchema.optional(),
165
- });
166
- export type LocalRuntimeSummary = z.infer<typeof LocalRuntimeSummarySchema>;
167
-
168
- // ── Durable Delivery Handle ────────────────────────────────────────
169
-
170
- /**
171
- * Branded operation handle for durable delivery.
172
- * Produced ONLY by `submitDurable()` — the caller never mints handles.
173
- */
174
- export const DurableDeliveryHandleSchema = NonEmptyStringSchema.brand<"DurableDeliveryHandle">();
175
- export type DurableDeliveryHandle = z.infer<typeof DurableDeliveryHandleSchema>;
176
-
177
- /**
178
- * Terminal status types for a durable delivery operation.
179
- */
180
- export const DurableDeliveryResultSchema = z.discriminatedUnion("status", [
181
- z.object({
182
- status: z.literal("pending"),
183
- queuedAt: z.string(),
184
- nextAttemptAt: z.string().optional(),
185
- attemptCount: z.number(),
186
- }),
187
- z.object({
188
- status: z.literal("delivered"),
189
- deliveredAt: z.string(),
190
- }),
191
- z.object({
192
- status: z.literal("expired"),
193
- reason: z.literal("ttl_exceeded"),
194
- queuedAt: z.string(),
195
- expiredAt: z.string(),
196
- }),
197
- z.object({
198
- status: z.literal("rejected"),
199
- reason: z.enum(["recipient_revoked", "recipient_unknown", "envelope_invalid"]),
200
- }),
201
- ]);
202
- export type DurableDeliveryResult = z.infer<typeof DurableDeliveryResultSchema>;
203
-
204
- /**
205
- * Submit result — returned immediately from `submitDurable()`.
206
- */
207
- export const DurableSubmitResultSchema = z.discriminatedUnion("status", [
208
- z.object({
209
- status: z.literal("accepted"),
210
- operationId: DurableDeliveryHandleSchema,
211
- queuedAt: z.string(),
212
- }),
213
- z.object({
214
- status: z.literal("rejected"),
215
- reason: z.enum(["recipient_revoked", "recipient_unknown", "envelope_invalid"]),
216
- }),
217
- ]);
218
- export type DurableSubmitResult = z.infer<typeof DurableSubmitResultSchema>;