appduct 0.10.0 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +122 -52
- package/dist/artifact-inspect.d.ts +0 -1
- package/dist/bin.d.ts +0 -1
- package/dist/bin.js +1250 -2
- package/dist/cli/command-options.d.ts +8 -1
- package/dist/cli/create-cli.d.ts +0 -1
- package/dist/cli/dispatch.d.ts +10 -1
- package/dist/cli/envelope.d.ts +19 -0
- package/dist/cli/global-flags.d.ts +30 -0
- package/dist/cli/open-target.d.ts +25 -8
- package/dist/cli/result-types.d.ts +31 -5
- package/dist/cli/router.d.ts +78 -0
- package/dist/cli/routes/daemon/index.d.ts +9 -0
- package/dist/cli/routes/daemon/index.js +848 -0
- package/dist/cli/routes/daemon/run.d.ts +3 -0
- package/dist/cli/routes/daemon/run.js +3246 -0
- package/dist/cli/routes/daemon/start.d.ts +3 -0
- package/dist/cli/routes/daemon/start.js +1677 -0
- package/dist/cli/routes/daemon/status.d.ts +4 -0
- package/dist/cli/routes/daemon/status.js +1685 -0
- package/dist/cli/routes/daemon/stop.d.ts +4 -0
- package/dist/cli/routes/daemon/stop.js +1655 -0
- package/dist/cli/routes/doctor.d.ts +3 -0
- package/dist/cli/routes/doctor.js +1075 -0
- package/dist/cli/routes/events.d.ts +3 -0
- package/dist/cli/routes/events.js +1915 -0
- package/dist/cli/routes/init.d.ts +3 -0
- package/dist/cli/routes/init.js +1486 -0
- package/dist/cli/routes/invoke.d.ts +3 -0
- package/dist/cli/routes/invoke.js +1893 -0
- package/dist/cli/routes/keygen.d.ts +3 -0
- package/dist/cli/routes/keygen.js +928 -0
- package/dist/cli/routes/link.d.ts +3 -0
- package/dist/cli/routes/link.js +2714 -0
- package/dist/cli/routes/ls.d.ts +3 -0
- package/dist/cli/routes/ls.js +1668 -0
- package/dist/cli/routes/mcp.d.ts +5 -0
- package/dist/cli/routes/mcp.js +3929 -0
- package/dist/cli/routes/revoke.d.ts +3 -0
- package/dist/cli/routes/revoke.js +1684 -0
- package/dist/cli/routes/tools.d.ts +3 -0
- package/dist/cli/routes/tools.js +1860 -0
- package/dist/cli/runner.d.ts +3 -11
- package/dist/cli/types.d.ts +9 -6
- package/dist/cli/version-guard.d.ts +20 -0
- package/dist/cli.d.ts +0 -1
- package/dist/client/app-client.d.ts +4 -4
- package/dist/client/bootstrap.d.ts +4 -4
- package/dist/client/connect.d.ts +0 -1
- package/dist/client/errors.d.ts +0 -1
- package/dist/client/index.d.ts +1 -2
- package/dist/client/index.js +2389 -16
- package/dist/commands/daemon/context.d.ts +14 -0
- package/dist/commands/daemon/run.d.ts +11 -0
- package/dist/commands/daemon/start.d.ts +5 -0
- package/dist/commands/daemon/status.d.ts +5 -0
- package/dist/commands/daemon/stop.d.ts +5 -0
- package/dist/commands/doctor.d.ts +0 -1
- package/dist/commands/events.d.ts +0 -1
- package/dist/commands/init.d.ts +17 -4
- package/dist/commands/invoke.d.ts +0 -1
- package/dist/commands/keygen.d.ts +0 -1
- package/dist/commands/link.d.ts +1 -2
- package/dist/commands/ls.d.ts +0 -1
- package/dist/commands/mcp.d.ts +2 -4
- package/dist/commands/revoke.d.ts +0 -1
- package/dist/commands/tools.d.ts +19 -3
- package/dist/daemon/address.d.ts +0 -1
- package/dist/daemon/audit.d.ts +6 -11
- package/dist/daemon/calls.d.ts +0 -1
- package/dist/daemon/config.d.ts +13 -16
- package/dist/daemon/daemon.d.ts +0 -1
- package/dist/daemon/event-bus.d.ts +0 -1
- package/dist/daemon/links.d.ts +0 -1
- package/dist/daemon/listener.d.ts +0 -1
- package/dist/daemon/log-rotation.d.ts +0 -1
- package/dist/daemon/pidfile.d.ts +14 -8
- package/dist/daemon/policy.d.ts +0 -1
- package/dist/daemon/registry.d.ts +0 -1
- package/dist/daemon/rpc-errors.d.ts +16 -0
- package/dist/daemon/rpc-server.d.ts +0 -11
- package/dist/daemon/sessions.d.ts +0 -1
- package/dist/daemon/socket-probe.d.ts +0 -1
- package/dist/daemon/state-dir.d.ts +0 -1
- package/dist/daemon/timers.d.ts +0 -1
- package/dist/daemon/tls.d.ts +0 -1
- package/dist/errors.d.ts +0 -1
- package/dist/host-certificate.d.ts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1307 -3
- package/dist/key-material.d.ts +0 -1
- package/dist/link.d.ts +8 -7
- package/dist/mcp/app-tools.d.ts +153 -0
- package/dist/mcp/connect-tool.d.ts +14 -8
- package/dist/mcp/daemon-tools.d.ts +2 -11
- package/dist/mcp/events-tool.d.ts +0 -1
- package/dist/mcp/server.d.ts +33 -14
- package/dist/native-scheme.d.ts +0 -1
- package/dist/output.d.ts +8 -11
- package/dist/package-root.d.ts +11 -0
- package/dist/package-version.d.ts +0 -1
- package/dist/qr-terminal.d.ts +0 -1
- package/dist/rpc/client.d.ts +3 -3
- package/dist/scheme.d.ts +60 -2
- package/dist/spki-pin.d.ts +0 -1
- package/package.json +6 -3
- package/dist/artifact-inspect.d.ts.map +0 -1
- package/dist/artifact-inspect.js +0 -334
- package/dist/bin.d.ts.map +0 -1
- package/dist/cli/command-options.d.ts.map +0 -1
- package/dist/cli/command-options.js +0 -95
- package/dist/cli/create-cli.d.ts.map +0 -1
- package/dist/cli/create-cli.js +0 -56
- package/dist/cli/dispatch.d.ts.map +0 -1
- package/dist/cli/dispatch.js +0 -275
- package/dist/cli/open-target.d.ts.map +0 -1
- package/dist/cli/open-target.js +0 -438
- package/dist/cli/result-types.d.ts.map +0 -1
- package/dist/cli/result-types.js +0 -6
- package/dist/cli/runner.d.ts.map +0 -1
- package/dist/cli/runner.js +0 -111
- package/dist/cli/types.d.ts.map +0 -1
- package/dist/cli/types.js +0 -10
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -2
- package/dist/client/app-client.d.ts.map +0 -1
- package/dist/client/app-client.js +0 -223
- package/dist/client/bootstrap.d.ts.map +0 -1
- package/dist/client/bootstrap.js +0 -108
- package/dist/client/connect.d.ts.map +0 -1
- package/dist/client/connect.js +0 -38
- package/dist/client/errors.d.ts.map +0 -1
- package/dist/client/errors.js +0 -40
- package/dist/client/index.d.ts.map +0 -1
- package/dist/commands/daemon.d.ts +0 -22
- package/dist/commands/daemon.d.ts.map +0 -1
- package/dist/commands/daemon.js +0 -128
- package/dist/commands/doctor.d.ts.map +0 -1
- package/dist/commands/doctor.js +0 -42
- package/dist/commands/events.d.ts.map +0 -1
- package/dist/commands/events.js +0 -76
- package/dist/commands/init.d.ts.map +0 -1
- package/dist/commands/init.js +0 -231
- package/dist/commands/invoke.d.ts.map +0 -1
- package/dist/commands/invoke.js +0 -54
- package/dist/commands/keygen.d.ts.map +0 -1
- package/dist/commands/keygen.js +0 -46
- package/dist/commands/link.d.ts.map +0 -1
- package/dist/commands/link.js +0 -43
- package/dist/commands/ls.d.ts.map +0 -1
- package/dist/commands/ls.js +0 -7
- package/dist/commands/mcp.d.ts.map +0 -1
- package/dist/commands/mcp.js +0 -98
- package/dist/commands/revoke.d.ts.map +0 -1
- package/dist/commands/revoke.js +0 -7
- package/dist/commands/tools.d.ts.map +0 -1
- package/dist/commands/tools.js +0 -52
- package/dist/daemon/address.d.ts.map +0 -1
- package/dist/daemon/address.js +0 -71
- package/dist/daemon/audit.d.ts.map +0 -1
- package/dist/daemon/audit.js +0 -237
- package/dist/daemon/calls.d.ts.map +0 -1
- package/dist/daemon/calls.js +0 -158
- package/dist/daemon/config.d.ts.map +0 -1
- package/dist/daemon/config.js +0 -170
- package/dist/daemon/daemon.d.ts.map +0 -1
- package/dist/daemon/daemon.js +0 -560
- package/dist/daemon/event-bus.d.ts.map +0 -1
- package/dist/daemon/event-bus.js +0 -111
- package/dist/daemon/links.d.ts.map +0 -1
- package/dist/daemon/links.js +0 -118
- package/dist/daemon/listener.d.ts.map +0 -1
- package/dist/daemon/listener.js +0 -132
- package/dist/daemon/log-rotation.d.ts.map +0 -1
- package/dist/daemon/log-rotation.js +0 -136
- package/dist/daemon/pidfile.d.ts.map +0 -1
- package/dist/daemon/pidfile.js +0 -90
- package/dist/daemon/policy.d.ts.map +0 -1
- package/dist/daemon/policy.js +0 -24
- package/dist/daemon/registry.d.ts.map +0 -1
- package/dist/daemon/registry.js +0 -31
- package/dist/daemon/rpc-server.d.ts.map +0 -1
- package/dist/daemon/rpc-server.js +0 -203
- package/dist/daemon/sessions.d.ts.map +0 -1
- package/dist/daemon/sessions.js +0 -429
- package/dist/daemon/socket-probe.d.ts.map +0 -1
- package/dist/daemon/socket-probe.js +0 -28
- package/dist/daemon/state-dir.d.ts.map +0 -1
- package/dist/daemon/state-dir.js +0 -43
- package/dist/daemon/timers.d.ts.map +0 -1
- package/dist/daemon/timers.js +0 -12
- package/dist/daemon/tls.d.ts.map +0 -1
- package/dist/daemon/tls.js +0 -79
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -162
- package/dist/host-certificate.d.ts.map +0 -1
- package/dist/host-certificate.js +0 -111
- package/dist/index.d.ts.map +0 -1
- package/dist/key-material.d.ts.map +0 -1
- package/dist/key-material.js +0 -42
- package/dist/link.d.ts.map +0 -1
- package/dist/link.js +0 -117
- package/dist/mcp/connect-tool.d.ts.map +0 -1
- package/dist/mcp/connect-tool.js +0 -396
- package/dist/mcp/daemon-tools.d.ts.map +0 -1
- package/dist/mcp/daemon-tools.js +0 -29
- package/dist/mcp/events-tool.d.ts.map +0 -1
- package/dist/mcp/events-tool.js +0 -322
- package/dist/mcp/server.d.ts.map +0 -1
- package/dist/mcp/server.js +0 -538
- package/dist/mcp/tool-mapping.d.ts +0 -58
- package/dist/mcp/tool-mapping.d.ts.map +0 -1
- package/dist/mcp/tool-mapping.js +0 -143
- package/dist/mcp/tool-namespace.d.ts +0 -40
- package/dist/mcp/tool-namespace.d.ts.map +0 -1
- package/dist/mcp/tool-namespace.js +0 -65
- package/dist/native-scheme.d.ts.map +0 -1
- package/dist/native-scheme.js +0 -465
- package/dist/output.d.ts.map +0 -1
- package/dist/output.js +0 -342
- package/dist/package-version.d.ts.map +0 -1
- package/dist/package-version.js +0 -47
- package/dist/qr-terminal.d.ts.map +0 -1
- package/dist/qr-terminal.js +0 -45
- package/dist/rpc/client.d.ts.map +0 -1
- package/dist/rpc/client.js +0 -819
- package/dist/scheme.d.ts.map +0 -1
- package/dist/scheme.js +0 -321
- package/dist/spki-pin.d.ts.map +0 -1
- package/dist/spki-pin.js +0 -14
package/dist/mcp/tool-mapping.js
DELETED
|
@@ -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"}
|