appduct 0.9.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (230) hide show
  1. package/README.md +122 -52
  2. package/dist/artifact-inspect.d.ts +5 -4
  3. package/dist/bin.d.ts +0 -1
  4. package/dist/bin.js +1250 -2
  5. package/dist/cli/command-options.d.ts +8 -1
  6. package/dist/cli/create-cli.d.ts +0 -1
  7. package/dist/cli/dispatch.d.ts +10 -1
  8. package/dist/cli/envelope.d.ts +19 -0
  9. package/dist/cli/global-flags.d.ts +30 -0
  10. package/dist/cli/open-target.d.ts +25 -8
  11. package/dist/cli/result-types.d.ts +30 -5
  12. package/dist/cli/router.d.ts +78 -0
  13. package/dist/cli/routes/daemon/index.d.ts +9 -0
  14. package/dist/cli/routes/daemon/index.js +848 -0
  15. package/dist/cli/routes/daemon/run.d.ts +3 -0
  16. package/dist/cli/routes/daemon/run.js +3246 -0
  17. package/dist/cli/routes/daemon/start.d.ts +3 -0
  18. package/dist/cli/routes/daemon/start.js +1668 -0
  19. package/dist/cli/routes/daemon/status.d.ts +4 -0
  20. package/dist/cli/routes/daemon/status.js +1676 -0
  21. package/dist/cli/routes/daemon/stop.d.ts +4 -0
  22. package/dist/cli/routes/daemon/stop.js +1646 -0
  23. package/dist/cli/routes/doctor.d.ts +3 -0
  24. package/dist/cli/routes/doctor.js +1075 -0
  25. package/dist/cli/routes/events.d.ts +3 -0
  26. package/dist/cli/routes/events.js +1906 -0
  27. package/dist/cli/routes/init.d.ts +3 -0
  28. package/dist/cli/routes/init.js +1486 -0
  29. package/dist/cli/routes/invoke.d.ts +3 -0
  30. package/dist/cli/routes/invoke.js +1884 -0
  31. package/dist/cli/routes/keygen.d.ts +3 -0
  32. package/dist/cli/routes/keygen.js +928 -0
  33. package/dist/cli/routes/link.d.ts +3 -0
  34. package/dist/cli/routes/link.js +2705 -0
  35. package/dist/cli/routes/ls.d.ts +3 -0
  36. package/dist/cli/routes/ls.js +1659 -0
  37. package/dist/cli/routes/mcp.d.ts +5 -0
  38. package/dist/cli/routes/mcp.js +3917 -0
  39. package/dist/cli/routes/revoke.d.ts +3 -0
  40. package/dist/cli/routes/revoke.js +1675 -0
  41. package/dist/cli/routes/tools.d.ts +3 -0
  42. package/dist/cli/routes/tools.js +1851 -0
  43. package/dist/cli/runner.d.ts +3 -11
  44. package/dist/cli/types.d.ts +9 -6
  45. package/dist/cli/version-guard.d.ts +20 -0
  46. package/dist/cli.d.ts +0 -1
  47. package/dist/client/app-client.d.ts +0 -1
  48. package/dist/client/bootstrap.d.ts +4 -4
  49. package/dist/client/connect.d.ts +0 -1
  50. package/dist/client/errors.d.ts +0 -1
  51. package/dist/client/index.d.ts +0 -1
  52. package/dist/client/index.js +2379 -16
  53. package/dist/commands/daemon/context.d.ts +14 -0
  54. package/dist/commands/daemon/run.d.ts +11 -0
  55. package/dist/commands/daemon/start.d.ts +5 -0
  56. package/dist/commands/daemon/status.d.ts +5 -0
  57. package/dist/commands/daemon/stop.d.ts +5 -0
  58. package/dist/commands/doctor.d.ts +0 -1
  59. package/dist/commands/events.d.ts +0 -1
  60. package/dist/commands/init.d.ts +17 -4
  61. package/dist/commands/invoke.d.ts +0 -1
  62. package/dist/commands/keygen.d.ts +0 -1
  63. package/dist/commands/link.d.ts +1 -2
  64. package/dist/commands/ls.d.ts +0 -1
  65. package/dist/commands/mcp.d.ts +2 -4
  66. package/dist/commands/revoke.d.ts +0 -1
  67. package/dist/commands/tools.d.ts +19 -3
  68. package/dist/daemon/address.d.ts +0 -1
  69. package/dist/daemon/audit.d.ts +6 -11
  70. package/dist/daemon/calls.d.ts +0 -1
  71. package/dist/daemon/config.d.ts +13 -16
  72. package/dist/daemon/daemon.d.ts +0 -1
  73. package/dist/daemon/event-bus.d.ts +0 -1
  74. package/dist/daemon/links.d.ts +0 -1
  75. package/dist/daemon/listener.d.ts +0 -1
  76. package/dist/daemon/log-rotation.d.ts +0 -1
  77. package/dist/daemon/pidfile.d.ts +14 -8
  78. package/dist/daemon/policy.d.ts +0 -1
  79. package/dist/daemon/registry.d.ts +0 -1
  80. package/dist/daemon/rpc-errors.d.ts +16 -0
  81. package/dist/daemon/rpc-server.d.ts +0 -11
  82. package/dist/daemon/sessions.d.ts +0 -1
  83. package/dist/daemon/socket-probe.d.ts +0 -1
  84. package/dist/daemon/state-dir.d.ts +0 -1
  85. package/dist/daemon/timers.d.ts +0 -1
  86. package/dist/daemon/tls.d.ts +0 -1
  87. package/dist/errors.d.ts +0 -1
  88. package/dist/host-certificate.d.ts +0 -1
  89. package/dist/index.d.ts +0 -1
  90. package/dist/index.js +1307 -3
  91. package/dist/key-material.d.ts +0 -1
  92. package/dist/link.d.ts +8 -7
  93. package/dist/mcp/app-tools.d.ts +153 -0
  94. package/dist/mcp/connect-tool.d.ts +14 -8
  95. package/dist/mcp/daemon-tools.d.ts +2 -11
  96. package/dist/mcp/events-tool.d.ts +0 -1
  97. package/dist/mcp/server.d.ts +33 -14
  98. package/dist/native-scheme.d.ts +0 -1
  99. package/dist/output.d.ts +8 -11
  100. package/dist/package-root.d.ts +11 -0
  101. package/dist/package-version.d.ts +0 -1
  102. package/dist/qr-terminal.d.ts +0 -1
  103. package/dist/rpc/client.d.ts +0 -1
  104. package/dist/scheme.d.ts +60 -2
  105. package/dist/spki-pin.d.ts +0 -1
  106. package/package.json +4 -3
  107. package/dist/artifact-inspect.d.ts.map +0 -1
  108. package/dist/artifact-inspect.js +0 -315
  109. package/dist/bin.d.ts.map +0 -1
  110. package/dist/cli/command-options.d.ts.map +0 -1
  111. package/dist/cli/command-options.js +0 -95
  112. package/dist/cli/create-cli.d.ts.map +0 -1
  113. package/dist/cli/create-cli.js +0 -56
  114. package/dist/cli/dispatch.d.ts.map +0 -1
  115. package/dist/cli/dispatch.js +0 -275
  116. package/dist/cli/open-target.d.ts.map +0 -1
  117. package/dist/cli/open-target.js +0 -438
  118. package/dist/cli/result-types.d.ts.map +0 -1
  119. package/dist/cli/result-types.js +0 -6
  120. package/dist/cli/runner.d.ts.map +0 -1
  121. package/dist/cli/runner.js +0 -111
  122. package/dist/cli/types.d.ts.map +0 -1
  123. package/dist/cli/types.js +0 -10
  124. package/dist/cli.d.ts.map +0 -1
  125. package/dist/cli.js +0 -2
  126. package/dist/client/app-client.d.ts.map +0 -1
  127. package/dist/client/app-client.js +0 -223
  128. package/dist/client/bootstrap.d.ts.map +0 -1
  129. package/dist/client/bootstrap.js +0 -108
  130. package/dist/client/connect.d.ts.map +0 -1
  131. package/dist/client/connect.js +0 -38
  132. package/dist/client/errors.d.ts.map +0 -1
  133. package/dist/client/errors.js +0 -40
  134. package/dist/client/index.d.ts.map +0 -1
  135. package/dist/commands/daemon.d.ts +0 -22
  136. package/dist/commands/daemon.d.ts.map +0 -1
  137. package/dist/commands/daemon.js +0 -128
  138. package/dist/commands/doctor.d.ts.map +0 -1
  139. package/dist/commands/doctor.js +0 -42
  140. package/dist/commands/events.d.ts.map +0 -1
  141. package/dist/commands/events.js +0 -76
  142. package/dist/commands/init.d.ts.map +0 -1
  143. package/dist/commands/init.js +0 -231
  144. package/dist/commands/invoke.d.ts.map +0 -1
  145. package/dist/commands/invoke.js +0 -54
  146. package/dist/commands/keygen.d.ts.map +0 -1
  147. package/dist/commands/keygen.js +0 -46
  148. package/dist/commands/link.d.ts.map +0 -1
  149. package/dist/commands/link.js +0 -43
  150. package/dist/commands/ls.d.ts.map +0 -1
  151. package/dist/commands/ls.js +0 -7
  152. package/dist/commands/mcp.d.ts.map +0 -1
  153. package/dist/commands/mcp.js +0 -98
  154. package/dist/commands/revoke.d.ts.map +0 -1
  155. package/dist/commands/revoke.js +0 -7
  156. package/dist/commands/tools.d.ts.map +0 -1
  157. package/dist/commands/tools.js +0 -52
  158. package/dist/daemon/address.d.ts.map +0 -1
  159. package/dist/daemon/address.js +0 -71
  160. package/dist/daemon/audit.d.ts.map +0 -1
  161. package/dist/daemon/audit.js +0 -237
  162. package/dist/daemon/calls.d.ts.map +0 -1
  163. package/dist/daemon/calls.js +0 -158
  164. package/dist/daemon/config.d.ts.map +0 -1
  165. package/dist/daemon/config.js +0 -170
  166. package/dist/daemon/daemon.d.ts.map +0 -1
  167. package/dist/daemon/daemon.js +0 -560
  168. package/dist/daemon/event-bus.d.ts.map +0 -1
  169. package/dist/daemon/event-bus.js +0 -111
  170. package/dist/daemon/links.d.ts.map +0 -1
  171. package/dist/daemon/links.js +0 -118
  172. package/dist/daemon/listener.d.ts.map +0 -1
  173. package/dist/daemon/listener.js +0 -132
  174. package/dist/daemon/log-rotation.d.ts.map +0 -1
  175. package/dist/daemon/log-rotation.js +0 -136
  176. package/dist/daemon/pidfile.d.ts.map +0 -1
  177. package/dist/daemon/pidfile.js +0 -90
  178. package/dist/daemon/policy.d.ts.map +0 -1
  179. package/dist/daemon/policy.js +0 -24
  180. package/dist/daemon/registry.d.ts.map +0 -1
  181. package/dist/daemon/registry.js +0 -31
  182. package/dist/daemon/rpc-server.d.ts.map +0 -1
  183. package/dist/daemon/rpc-server.js +0 -203
  184. package/dist/daemon/sessions.d.ts.map +0 -1
  185. package/dist/daemon/sessions.js +0 -429
  186. package/dist/daemon/socket-probe.d.ts.map +0 -1
  187. package/dist/daemon/socket-probe.js +0 -28
  188. package/dist/daemon/state-dir.d.ts.map +0 -1
  189. package/dist/daemon/state-dir.js +0 -43
  190. package/dist/daemon/timers.d.ts.map +0 -1
  191. package/dist/daemon/timers.js +0 -12
  192. package/dist/daemon/tls.d.ts.map +0 -1
  193. package/dist/daemon/tls.js +0 -79
  194. package/dist/errors.d.ts.map +0 -1
  195. package/dist/errors.js +0 -162
  196. package/dist/host-certificate.d.ts.map +0 -1
  197. package/dist/host-certificate.js +0 -111
  198. package/dist/index.d.ts.map +0 -1
  199. package/dist/key-material.d.ts.map +0 -1
  200. package/dist/key-material.js +0 -42
  201. package/dist/link.d.ts.map +0 -1
  202. package/dist/link.js +0 -117
  203. package/dist/mcp/connect-tool.d.ts.map +0 -1
  204. package/dist/mcp/connect-tool.js +0 -396
  205. package/dist/mcp/daemon-tools.d.ts.map +0 -1
  206. package/dist/mcp/daemon-tools.js +0 -29
  207. package/dist/mcp/events-tool.d.ts.map +0 -1
  208. package/dist/mcp/events-tool.js +0 -322
  209. package/dist/mcp/server.d.ts.map +0 -1
  210. package/dist/mcp/server.js +0 -538
  211. package/dist/mcp/tool-mapping.d.ts +0 -58
  212. package/dist/mcp/tool-mapping.d.ts.map +0 -1
  213. package/dist/mcp/tool-mapping.js +0 -143
  214. package/dist/mcp/tool-namespace.d.ts +0 -40
  215. package/dist/mcp/tool-namespace.d.ts.map +0 -1
  216. package/dist/mcp/tool-namespace.js +0 -65
  217. package/dist/native-scheme.d.ts.map +0 -1
  218. package/dist/native-scheme.js +0 -465
  219. package/dist/output.d.ts.map +0 -1
  220. package/dist/output.js +0 -342
  221. package/dist/package-version.d.ts.map +0 -1
  222. package/dist/package-version.js +0 -47
  223. package/dist/qr-terminal.d.ts.map +0 -1
  224. package/dist/qr-terminal.js +0 -45
  225. package/dist/rpc/client.d.ts.map +0 -1
  226. package/dist/rpc/client.js +0 -819
  227. package/dist/scheme.d.ts.map +0 -1
  228. package/dist/scheme.js +0 -321
  229. package/dist/spki-pin.d.ts.map +0 -1
  230. package/dist/spki-pin.js +0 -14
@@ -1,143 +0,0 @@
1
- /**
2
- * Maps a `NamespacedTool` (daemon `ToolDescriptor` + resolved external name) onto the MCP SDK's
3
- * `Tool` wire shape (ARCHITECTURE.md §9/§7): `description` maps directly and `annotations` map
4
- * verbatim, while `input_schema`/`output_schema` are emitted only if the SDK's own `ToolSchema`
5
- * accepts them (issue #26) — a rejected `input_schema` is replaced with an empty, permissive
6
- * object schema and a rejected `output_schema` is dropped entirely. Either way the tool stays
7
- * listed and callable: one app-side schema MCP cannot represent must never take down the whole
8
- * `tools/list`.
9
- *
10
- * The gate is the SDK schema itself rather than a hand-rolled `type === "object"` check, because
11
- * MCP constrains more than the root type — `properties` must be a record of *object* subschemas
12
- * (the JSON Schema shorthand `properties: { a: true }` is rejected) and `required` must be an
13
- * array. Any of those makes a client reject the entire `tools/list` result, so the only safe
14
- * predicate is the one the client will actually apply.
15
- *
16
- * A tool whose effective policy is `"prompt"` (ARCHITECTURE.md §12) gets
17
- * `_meta["anthropic/requiresUserInteraction"] = true` — but only when the caller says to
18
- * (`emitRequiresUserInteractionFlag`), which `mcp/server.ts` decides is true only when the
19
- * connected client is known to enforce the flag (issue #14) *and* it hasn't already preferred the
20
- * elicitation channel instead (issue #10). Emitting the flag for a client that ignores it would
21
- * create a false sense of security; emitting it *and* using elicitation for the same tool would
22
- * arm two consent prompts for one call — so this function never decides that itself, only renders
23
- * the decision it's handed.
24
- */
25
- import { ToolSchema } from "@modelcontextprotocol/sdk/types.js";
26
- /** MCP requires `inputSchema.type === "object"`; an app that registered a tool without a schema
27
- * gets the most permissive possible one rather than an MCP-invalid `{}`. */
28
- const EMPTY_OBJECT_SCHEMA = { type: "object", additionalProperties: true };
29
- /**
30
- * Why the SDK's `ToolSchema` would reject `schema` in this slot, or `undefined` when it accepts
31
- * it. The probe wraps the schema in an otherwise-minimal valid `Tool` so the only thing under test
32
- * is the schema; the returned reason is the first issue, with the leading `inputSchema`/
33
- * `outputSchema` path segment stripped so the message reads from the app author's point of view.
34
- */
35
- const mcpSchemaRejection = (schema, slot) => {
36
- const probe = slot === "input"
37
- ? { name: "probe", inputSchema: schema }
38
- : { name: "probe", inputSchema: EMPTY_OBJECT_SCHEMA, outputSchema: schema };
39
- const parsed = ToolSchema.safeParse(probe);
40
- if (parsed.success) {
41
- return undefined;
42
- }
43
- const issue = parsed.error.issues[0];
44
- if (!issue) {
45
- return "it does not match MCP's tool schema";
46
- }
47
- const path = issue.path.slice(1).join(".");
48
- return path.length > 0 ? `${path}: ${issue.message}` : issue.message;
49
- };
50
- /**
51
- * Whether `tools/list` will carry an `outputSchema` for this descriptor. `server.ts`'s success
52
- * path shares this predicate so the "did we advertise a schema?" and "must this result carry
53
- * `structuredContent`?" decisions can never disagree — a client demands the latter exactly when
54
- * it saw the former.
55
- */
56
- export const emitsMcpOutputSchema = (schema) => {
57
- return schema !== undefined && mcpSchemaRejection(schema, "output") === undefined;
58
- };
59
- /** stderr only — stdout carries the MCP transport's protocol frames (ARCHITECTURE.md §9). */
60
- const defaultWarn = (message) => {
61
- console.error(`appduct mcp: ${message}`);
62
- };
63
- /**
64
- * Upper bound on remembered notices. A key embeds the offending schema, and an app is free to
65
- * build a schema from live data (a `z.enum` over rows it just fetched), so an unbounded set would
66
- * grow with every distinct broken schema for the life of the process. Past the cap the oldest key
67
- * is evicted, which at worst re-prints a notice the operator has already seen.
68
- */
69
- const MAX_REMEMBERED_NOTICES = 256;
70
- /**
71
- * Builds a mapper with its own degradation-notice dedup, so nothing here is module state and no
72
- * reset hook has to be exported for tests: a server owns one mapper for its lifetime, and a test
73
- * owns one per case. `warn` defaults to stderr and exists so a test can capture notices without
74
- * spying on the console.
75
- *
76
- * Notices dedupe on session + tool name + the offending schema, because `tools/list` is
77
- * re-answered on every client request and on every `notifications/tools/list_changed` refresh. Two
78
- * devices exposing the same broken tool each get their own notice, and re-registering a tool with
79
- * a *differently* broken schema warns again; only the same problem on the same tool of the same
80
- * session stays quiet. The session's `selector` is the key rather than the namespaced `mcpName` so
81
- * the single↔multi session flip, which rewrites every `mcpName`, does not re-warn about tools
82
- * nothing changed about.
83
- */
84
- export const createMcpToolMapper = (warn = defaultWarn) => {
85
- const warned = new Set();
86
- const warnOnce = (tool, slot, schema, message) => {
87
- const key = `${tool.selector}\u0000${tool.descriptor.name}\u0000${slot}\u0000${JSON.stringify(schema)}`;
88
- if (warned.has(key)) {
89
- return;
90
- }
91
- // A `Set` iterates in insertion order, so the first key is the oldest.
92
- if (warned.size >= MAX_REMEMBERED_NOTICES) {
93
- const oldest = warned.values().next();
94
- if (!oldest.done) {
95
- warned.delete(oldest.value);
96
- }
97
- }
98
- warned.add(key);
99
- warn(message);
100
- };
101
- const mapInputSchema = (tool) => {
102
- const schema = tool.descriptor.input_schema;
103
- if (schema === undefined) {
104
- return EMPTY_OBJECT_SCHEMA;
105
- }
106
- const rejection = mcpSchemaRejection(schema, "input");
107
- if (rejection === undefined) {
108
- return schema;
109
- }
110
- warnOnce(tool, "input", schema, `Tool "${tool.mcpName}" declares an input schema MCP cannot accept (${rejection}); MCP tool ` +
111
- "arguments are always an object, so the schema was replaced with a permissive empty object " +
112
- "schema and agents cannot see the tool's real arguments. Wrap the input in an object schema.");
113
- return EMPTY_OBJECT_SCHEMA;
114
- };
115
- const mapOutputSchema = (tool) => {
116
- const schema = tool.descriptor.output_schema;
117
- if (schema === undefined) {
118
- return undefined;
119
- }
120
- const rejection = mcpSchemaRejection(schema, "output");
121
- if (rejection === undefined) {
122
- return schema;
123
- }
124
- warnOnce(tool, "output", schema, `Tool "${tool.mcpName}" declares an output schema MCP cannot accept (${rejection}); it was ` +
125
- "dropped from tools/list, so agents get the result without a schema to validate it against. " +
126
- "Wrap the output in an object schema to give agents a described, structured result.");
127
- return undefined;
128
- };
129
- return (tool, emitRequiresUserInteractionFlag) => {
130
- const { descriptor } = tool;
131
- const requiresUserInteraction = tool.policy === "prompt" && emitRequiresUserInteractionFlag;
132
- const outputSchema = mapOutputSchema(tool);
133
- return {
134
- name: tool.mcpName,
135
- description: descriptor.description,
136
- inputSchema: mapInputSchema(tool),
137
- ...(outputSchema ? { outputSchema } : {}),
138
- ...(descriptor.annotations ? { annotations: { ...descriptor.annotations } } : {}),
139
- // Must be the JSON boolean `true` literal — any other value is ignored by the client.
140
- ...(requiresUserInteraction ? { _meta: { "anthropic/requiresUserInteraction": true } } : {}),
141
- };
142
- };
143
- };
@@ -1,40 +0,0 @@
1
- /**
2
- * Builds the effective MCP tool list from live daemon sessions and their tool registries
3
- * (ARCHITECTURE.md §9): exactly one live session exposes tools under their
4
- * own names; two or more namespace every tool as `<alias>__<name>` so names never collide across
5
- * devices.
6
- *
7
- * The `__` separator is unambiguous to split back apart even though a tool's own name
8
- * (`[a-zA-Z0-9_-]{1,64}`, `daemon/registry.ts`) may itself contain underscores: aliases
9
- * (`daemon/sessions.ts`'s `slugifyDeviceModel`/`dedupeAlias`) only ever contain lowercase
10
- * alphanumerics and hyphens, so the alias half of a namespaced name never itself contains `__` —
11
- * the first occurrence of `__` in a namespaced name is always the alias/tool-name boundary.
12
- */
13
- import type { EffectivePolicyDecision, SessionSummary, ToolDescriptor, ToolsListEntry } from "@appduct/shared";
14
- export declare const TOOL_NAMESPACE_SEPARATOR = "__";
15
- export type NamespacedTool = {
16
- /** The name exposed to MCP clients: `descriptor.name` verbatim when exactly one session is live,
17
- * else `<alias>__<name>`. */
18
- mcpName: string;
19
- /** The session alias `tools.call`'s `selector` should target for this tool. */
20
- selector: string;
21
- descriptor: ToolDescriptor;
22
- /** The effective policy decision for this tool right now (ARCHITECTURE.md §12), as resolved by
23
- * the daemon's `tools.list` — carried through so the MCP server can emit
24
- * `_meta["anthropic/requiresUserInteraction"]` and set `consent` on `tools.call` without a
25
- * second round trip (issue #14). */
26
- policy: EffectivePolicyDecision;
27
- };
28
- /** Builds the namespaced (or not) tool list for the current set of live sessions. `toolsByAlias`
29
- * is looked up by `session.alias` (not `sessionId`) to match `tools.list`'s `selector` semantics. */
30
- export declare const buildNamespacedTools: (sessions: readonly SessionSummary[], toolsByAlias: ReadonlyMap<string, readonly ToolsListEntry[]>) => NamespacedTool[];
31
- export declare const findNamespacedTool: (tools: readonly NamespacedTool[], mcpName: string) => NamespacedTool | undefined;
32
- /** A stable, order-independent key used to detect whether the effective tool list actually
33
- * changed (name, target session, and the descriptor fields a client can see) — used to decide
34
- * whether to fire `notifications/tools/list_changed` rather than on every qualifying daemon event.
35
- *
36
- * `timeout_ms` is deliberately excluded: it never reaches the MCP `Tool` JSON (`tool-mapping.ts`),
37
- * so an app re-registering a tool with only a different deadline changes nothing a client could
38
- * observe, and telling it the list changed would just make it re-fetch an identical list. */
39
- export declare const namespacedToolsSnapshotKey: (tools: readonly NamespacedTool[]) => string;
40
- //# sourceMappingURL=tool-namespace.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tool-namespace.d.ts","sourceRoot":"","sources":["../../src/mcp/tool-namespace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAE/G,eAAO,MAAM,wBAAwB,OAAO,CAAC;AAE7C,MAAM,MAAM,cAAc,GAAG;IAC3B;iCAC6B;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,+EAA+E;IAC/E,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,cAAc,CAAC;IAC3B;;;wCAGoC;IACpC,MAAM,EAAE,uBAAuB,CAAC;CACjC,CAAC;AAEF;qGACqG;AACrG,eAAO,MAAM,oBAAoB,GAC/B,UAAU,SAAS,cAAc,EAAE,EACnC,cAAc,WAAW,CAAC,MAAM,EAAE,SAAS,cAAc,EAAE,CAAC,KAC3D,cAAc,EA4BhB,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC7B,OAAO,SAAS,cAAc,EAAE,EAChC,SAAS,MAAM,KACd,cAAc,GAAG,SAEnB,CAAC;AAEF;;;;;;6FAM6F;AAC7F,eAAO,MAAM,0BAA0B,GAAI,OAAO,SAAS,cAAc,EAAE,KAAG,MAe7E,CAAC"}
@@ -1,65 +0,0 @@
1
- /**
2
- * Builds the effective MCP tool list from live daemon sessions and their tool registries
3
- * (ARCHITECTURE.md §9): exactly one live session exposes tools under their
4
- * own names; two or more namespace every tool as `<alias>__<name>` so names never collide across
5
- * devices.
6
- *
7
- * The `__` separator is unambiguous to split back apart even though a tool's own name
8
- * (`[a-zA-Z0-9_-]{1,64}`, `daemon/registry.ts`) may itself contain underscores: aliases
9
- * (`daemon/sessions.ts`'s `slugifyDeviceModel`/`dedupeAlias`) only ever contain lowercase
10
- * alphanumerics and hyphens, so the alias half of a namespaced name never itself contains `__` —
11
- * the first occurrence of `__` in a namespaced name is always the alias/tool-name boundary.
12
- */
13
- export const TOOL_NAMESPACE_SEPARATOR = "__";
14
- /** Builds the namespaced (or not) tool list for the current set of live sessions. `toolsByAlias`
15
- * is looked up by `session.alias` (not `sessionId`) to match `tools.list`'s `selector` semantics. */
16
- export const buildNamespacedTools = (sessions, toolsByAlias) => {
17
- const namespaced = sessions.length > 1;
18
- const tools = [];
19
- for (const session of sessions) {
20
- for (const entry of toolsByAlias.get(session.alias) ?? []) {
21
- // Explicit pick (not a `{ policy, ...descriptor }` rest-spread) so a future non-descriptor
22
- // field added to `ToolsListEntry` can't silently leak into `descriptor` and from there into
23
- // the MCP tool surface and the snapshot key below.
24
- const descriptor = {
25
- name: entry.name,
26
- description: entry.description,
27
- input_schema: entry.input_schema,
28
- output_schema: entry.output_schema,
29
- annotations: entry.annotations,
30
- timeout_ms: entry.timeout_ms,
31
- };
32
- tools.push({
33
- mcpName: namespaced ? `${session.alias}${TOOL_NAMESPACE_SEPARATOR}${descriptor.name}` : descriptor.name,
34
- selector: session.alias,
35
- descriptor,
36
- policy: entry.policy,
37
- });
38
- }
39
- }
40
- return tools;
41
- };
42
- export const findNamespacedTool = (tools, mcpName) => {
43
- return tools.find((tool) => tool.mcpName === mcpName);
44
- };
45
- /** A stable, order-independent key used to detect whether the effective tool list actually
46
- * changed (name, target session, and the descriptor fields a client can see) — used to decide
47
- * whether to fire `notifications/tools/list_changed` rather than on every qualifying daemon event.
48
- *
49
- * `timeout_ms` is deliberately excluded: it never reaches the MCP `Tool` JSON (`tool-mapping.ts`),
50
- * so an app re-registering a tool with only a different deadline changes nothing a client could
51
- * observe, and telling it the list changed would just make it re-fetch an identical list. */
52
- export const namespacedToolsSnapshotKey = (tools) => {
53
- const sorted = tools
54
- .map((tool) => {
55
- const { timeout_ms: _timeoutMs, ...clientVisibleDescriptor } = tool.descriptor;
56
- return {
57
- name: tool.mcpName,
58
- selector: tool.selector,
59
- descriptor: clientVisibleDescriptor,
60
- policy: tool.policy,
61
- };
62
- })
63
- .sort((a, b) => a.name.localeCompare(b.name));
64
- return JSON.stringify(sorted);
65
- };
@@ -1 +0,0 @@
1
- {"version":3,"file":"native-scheme.d.ts","sourceRoot":"","sources":["../src/native-scheme.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAQH,MAAM,MAAM,kBAAkB,GAC1B,gBAAgB,GAChB,kBAAkB,GAClB,gBAAgB,GAChB,iBAAiB,CAAC;AAEtB,MAAM,MAAM,uBAAuB,GAAG;IACpC,MAAM,EAAE,kBAAkB,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,mGAAmG;IACnG,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,mDAAmD;IACnD,MAAM,CAAC,EAAE,uBAAuB,CAAC;IACjC;iGAC6F;IAC7F,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB,CAAC;AAihBF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,oBAAoB,GAAU,MAAM,MAAM,KAAG,OAAO,CAAC,qBAAqB,CA4BtF,CAAC"}