@agent-surface/webmcp 0.16.0 → 0.17.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/dist/index.d.ts +5 -3
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -32,10 +32,12 @@ interface WebMcpModelContext {
|
|
|
32
32
|
interface CreateWebMcpAdapterOptions {
|
|
33
33
|
snapshotContext?: Omit<SnapshotContext, "consumer">;
|
|
34
34
|
/**
|
|
35
|
-
*
|
|
36
|
-
* to
|
|
35
|
+
* Curate presentation before exposing. Execution always remains registry-routed.
|
|
36
|
+
* Return null to skip; undefined to keep defaults.
|
|
37
37
|
*/
|
|
38
|
-
exposeCapability?: (descriptor: AgentCapabilityDescriptorUnion) =>
|
|
38
|
+
exposeCapability?: (descriptor: AgentCapabilityDescriptorUnion) => {
|
|
39
|
+
description?: string;
|
|
40
|
+
} | null | undefined;
|
|
39
41
|
/** Test seam: defaults to (navigator as any).modelContext. */
|
|
40
42
|
modelContext?: WebMcpModelContext;
|
|
41
43
|
}
|
package/dist/index.js
CHANGED
|
@@ -51,12 +51,12 @@ function createWebMcpAdapter(options) {
|
|
|
51
51
|
const curated = options?.exposeCapability?.(obs);
|
|
52
52
|
if (options?.exposeCapability && curated === null) continue;
|
|
53
53
|
tools.push(
|
|
54
|
-
|
|
54
|
+
toTool(
|
|
55
55
|
obs,
|
|
56
56
|
obs.capabilityId,
|
|
57
57
|
component.registrationId,
|
|
58
58
|
{ type: "object", properties: {}, additionalProperties: false },
|
|
59
|
-
`[view \xB7 read] ${obs.description}`
|
|
59
|
+
curated?.description ?? `[view \xB7 read] ${obs.description}`
|
|
60
60
|
)
|
|
61
61
|
);
|
|
62
62
|
}
|
|
@@ -65,12 +65,12 @@ function createWebMcpAdapter(options) {
|
|
|
65
65
|
const curated = options?.exposeCapability?.(act);
|
|
66
66
|
if (options?.exposeCapability && curated === null) continue;
|
|
67
67
|
tools.push(
|
|
68
|
-
|
|
68
|
+
toTool(
|
|
69
69
|
act,
|
|
70
70
|
act.capabilityId,
|
|
71
71
|
component.registrationId,
|
|
72
72
|
act.inputSchema,
|
|
73
|
-
`[view \xB7 ${act.effect}] ${act.description}`
|
|
73
|
+
curated?.description ?? `[view \xB7 ${act.effect}] ${act.description}`
|
|
74
74
|
)
|
|
75
75
|
);
|
|
76
76
|
}
|
|
@@ -80,12 +80,12 @@ function createWebMcpAdapter(options) {
|
|
|
80
80
|
const curated = options?.exposeCapability?.(proc);
|
|
81
81
|
if (options?.exposeCapability && curated === null) continue;
|
|
82
82
|
tools.push(
|
|
83
|
-
|
|
83
|
+
toTool(
|
|
84
84
|
proc,
|
|
85
85
|
proc.procedureId,
|
|
86
86
|
proc.registrationId,
|
|
87
87
|
proc.inputSchema,
|
|
88
|
-
`[domain \xB7 ${proc.effect}${proc.confirmation === "required" ? " \xB7 requires confirmation" : ""}] ${proc.description}`
|
|
88
|
+
curated?.description ?? `[domain \xB7 ${proc.effect}${proc.confirmation === "required" ? " \xB7 requires confirmation" : ""}] ${proc.description}`
|
|
89
89
|
)
|
|
90
90
|
);
|
|
91
91
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core-facade.ts","../src/index.ts"],"sourcesContent":["export { encodeWireName, encodeWireNameForInstance } from \"@agent-surface/core\";\nexport type {\n AgentCapabilityDescriptorUnion,\n AgentConsumer,\n AgentSurfaceRegistry,\n JsonSchema,\n JsonValue,\n SnapshotContext,\n} from \"@agent-surface/core\";\n\nexport function randomInvocationId(): string {\n return `inv_${Math.random().toString(36).slice(2, 14)}`;\n}\n","import {\n encodeWireName,\n randomInvocationId,\n type AgentCapabilityDescriptorUnion,\n type AgentConsumer,\n type AgentSurfaceRegistry,\n type JsonSchema,\n type JsonValue,\n type SnapshotContext,\n} from \"./core-facade.js\";\n\n/* ───────────────────────── adapter contract (docs/09) ───────────────────────── */\n\nexport interface AdapterHost {\n registry: AgentSurfaceRegistry;\n consumer: AgentConsumer; // identity this adapter acts as\n /** Adapter-scoped snapshot defaults (scope, budget). */\n snapshotContext?: Omit<SnapshotContext, \"consumer\">;\n}\n\nexport interface AgentSurfaceAdapter {\n readonly name: string;\n start(host: AdapterHost): void | Promise<void>;\n stop(): void | Promise<void>;\n}\n\n/* ───────────── assumed navigator.modelContext shape (Experimental) ─────────────\n * The WebMCP surface area is unstable (OQ-2); this module encodes the current\n * assumption and absorbs drift so nothing WebMCP-shaped leaks into core.\n */\n\nexport interface WebMcpToolInit {\n name: string;\n description: string;\n inputSchema: JsonSchema;\n execute(input: JsonValue): Promise<WebMcpToolResult>;\n}\n\nexport interface WebMcpToolResult {\n content: Array<{ type: \"text\"; text: string }>;\n isError?: boolean;\n}\n\nexport interface WebMcpModelContext {\n provideContext(context: { tools: WebMcpToolInit[] }): void;\n}\n\nexport interface CreateWebMcpAdapterOptions {\n snapshotContext?: Omit<SnapshotContext, \"consumer\">;\n /**\n *
|
|
1
|
+
{"version":3,"sources":["../src/core-facade.ts","../src/index.ts"],"sourcesContent":["export { encodeWireName, encodeWireNameForInstance } from \"@agent-surface/core\";\nexport type {\n AgentCapabilityDescriptorUnion,\n AgentConsumer,\n AgentSurfaceRegistry,\n JsonSchema,\n JsonValue,\n SnapshotContext,\n} from \"@agent-surface/core\";\n\nexport function randomInvocationId(): string {\n return `inv_${Math.random().toString(36).slice(2, 14)}`;\n}\n","import {\n encodeWireName,\n randomInvocationId,\n type AgentCapabilityDescriptorUnion,\n type AgentConsumer,\n type AgentSurfaceRegistry,\n type JsonSchema,\n type JsonValue,\n type SnapshotContext,\n} from \"./core-facade.js\";\n\n/* ───────────────────────── adapter contract (docs/09) ───────────────────────── */\n\nexport interface AdapterHost {\n registry: AgentSurfaceRegistry;\n consumer: AgentConsumer; // identity this adapter acts as\n /** Adapter-scoped snapshot defaults (scope, budget). */\n snapshotContext?: Omit<SnapshotContext, \"consumer\">;\n}\n\nexport interface AgentSurfaceAdapter {\n readonly name: string;\n start(host: AdapterHost): void | Promise<void>;\n stop(): void | Promise<void>;\n}\n\n/* ───────────── assumed navigator.modelContext shape (Experimental) ─────────────\n * The WebMCP surface area is unstable (OQ-2); this module encodes the current\n * assumption and absorbs drift so nothing WebMCP-shaped leaks into core.\n */\n\nexport interface WebMcpToolInit {\n name: string;\n description: string;\n inputSchema: JsonSchema;\n execute(input: JsonValue): Promise<WebMcpToolResult>;\n}\n\nexport interface WebMcpToolResult {\n content: Array<{ type: \"text\"; text: string }>;\n isError?: boolean;\n}\n\nexport interface WebMcpModelContext {\n provideContext(context: { tools: WebMcpToolInit[] }): void;\n}\n\nexport interface CreateWebMcpAdapterOptions {\n snapshotContext?: Omit<SnapshotContext, \"consumer\">;\n /**\n * Curate presentation before exposing. Execution always remains registry-routed.\n * Return null to skip; undefined to keep defaults.\n */\n exposeCapability?: (\n descriptor: AgentCapabilityDescriptorUnion,\n ) => { description?: string } | null | undefined;\n /** Test seam: defaults to (navigator as any).modelContext. */\n modelContext?: WebMcpModelContext;\n}\n\n/**\n * Maps the registry onto `navigator.modelContext`, treating WebMCP strictly\n * as transport/discovery: one wire-named tool per AVAILABLE capability,\n * re-provided on every surface-changed; unavailable capabilities are not\n * registered (WebMCP has no disabled state today — accepted limitation);\n * confirmations stay two-phase; absent modelContext ⇒ start() does nothing.\n */\nexport function createWebMcpAdapter(options?: CreateWebMcpAdapterOptions): AgentSurfaceAdapter {\n let unsubscribe: (() => void) | undefined;\n\n return {\n name: \"webmcp\",\n\n start(host: AdapterHost): void {\n const modelContext =\n options?.modelContext ??\n (globalThis as { navigator?: { modelContext?: WebMcpModelContext } }).navigator\n ?.modelContext;\n if (!modelContext) return; // feature-detect, never polyfill\n\n const provide = (): void => {\n const snapshot = host.registry.snapshot({\n consumer: host.consumer,\n ...(options?.snapshotContext ?? host.snapshotContext ?? {}),\n includeUnavailable: false,\n });\n\n const tools: WebMcpToolInit[] = [];\n\n const toTool = (\n descriptor: AgentCapabilityDescriptorUnion,\n capabilityId: string,\n registrationId: string,\n inputSchema: JsonSchema,\n description: string,\n ): WebMcpToolInit => ({\n name: encodeWireName(capabilityId),\n description,\n inputSchema,\n execute: async (input: JsonValue): Promise<WebMcpToolResult> => {\n const result = await host.registry.invoke(\n {\n invocationId: randomInvocationId(),\n capabilityId,\n registrationId,\n surfaceVersion: snapshot.surfaceVersion,\n ...(input !== undefined && Object.keys(input as object).length > 0\n ? { input }\n : {}),\n },\n { consumer: host.consumer },\n );\n // Capability errors ride in tool CONTENT, never protocol errors\n // (docs/07 adapter mapping): code/retry/details preserved.\n if (result.status === \"ok\") {\n return {\n content: [{ type: \"text\", text: JSON.stringify(result.output ?? null) }],\n };\n }\n return {\n content: [{ type: \"text\", text: JSON.stringify(result.error) }],\n isError: true,\n };\n },\n });\n\n for (const component of snapshot.components) {\n for (const obs of component.observations) {\n if (!obs.available) continue;\n const curated = options?.exposeCapability?.(obs);\n if (options?.exposeCapability && curated === null) continue;\n tools.push(\n toTool(\n obs,\n obs.capabilityId,\n component.registrationId,\n { type: \"object\", properties: {}, additionalProperties: false },\n curated?.description ?? `[view · read] ${obs.description}`,\n ),\n );\n }\n for (const act of component.actions) {\n if (!act.available) continue;\n const curated = options?.exposeCapability?.(act);\n if (options?.exposeCapability && curated === null) continue;\n tools.push(\n toTool(\n act,\n act.capabilityId,\n component.registrationId,\n act.inputSchema,\n curated?.description ?? `[view · ${act.effect}] ${act.description}`,\n ),\n );\n }\n }\n for (const proc of snapshot.procedures) {\n if (!proc.available) continue;\n const curated = options?.exposeCapability?.(proc);\n if (options?.exposeCapability && curated === null) continue;\n tools.push(\n toTool(\n proc,\n proc.procedureId,\n proc.registrationId,\n proc.inputSchema,\n curated?.description ??\n `[domain · ${proc.effect}${proc.confirmation === \"required\" ? \" · requires confirmation\" : \"\"}] ${proc.description}`,\n ),\n );\n }\n\n modelContext.provideContext({ tools });\n };\n\n provide();\n unsubscribe = host.registry.subscribe((event) => {\n if (event.type === \"surface-changed\") provide();\n });\n },\n\n stop(): void {\n unsubscribe?.();\n unsubscribe = undefined;\n },\n };\n}\n"],"mappings":";AAAA,SAAS,gBAAgB,iCAAiC;AAUnD,SAAS,qBAA6B;AAC3C,SAAO,OAAO,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,GAAG,EAAE,CAAC;AACvD;;;ACuDO,SAAS,oBAAoB,SAA2D;AAC7F,MAAI;AAEJ,SAAO;AAAA,IACL,MAAM;AAAA,IAEN,MAAM,MAAyB;AAC7B,YAAM,eACJ,SAAS,gBACR,WAAqE,WAClE;AACN,UAAI,CAAC,aAAc;AAEnB,YAAM,UAAU,MAAY;AAC1B,cAAM,WAAW,KAAK,SAAS,SAAS;AAAA,UACtC,UAAU,KAAK;AAAA,UACf,GAAI,SAAS,mBAAmB,KAAK,mBAAmB,CAAC;AAAA,UACzD,oBAAoB;AAAA,QACtB,CAAC;AAED,cAAM,QAA0B,CAAC;AAEjC,cAAM,SAAS,CACb,YACA,cACA,gBACA,aACA,iBACoB;AAAA,UACpB,MAAM,eAAe,YAAY;AAAA,UACjC;AAAA,UACA;AAAA,UACA,SAAS,OAAO,UAAgD;AAC9D,kBAAM,SAAS,MAAM,KAAK,SAAS;AAAA,cACjC;AAAA,gBACE,cAAc,mBAAmB;AAAA,gBACjC;AAAA,gBACA;AAAA,gBACA,gBAAgB,SAAS;AAAA,gBACzB,GAAI,UAAU,UAAa,OAAO,KAAK,KAAe,EAAE,SAAS,IAC7D,EAAE,MAAM,IACR,CAAC;AAAA,cACP;AAAA,cACA,EAAE,UAAU,KAAK,SAAS;AAAA,YAC5B;AAGA,gBAAI,OAAO,WAAW,MAAM;AAC1B,qBAAO;AAAA,gBACL,SAAS,CAAC,EAAE,MAAM,QAAQ,MAAM,KAAK,UAAU,OAAO,UAAU,IAAI,EAAE,CAAC;AAAA,cACzE;AAAA,YACF;AACA,mBAAO;AAAA,cACL,SAAS,CAAC,EAAE,MAAM,QAAQ,MAAM,K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AEA,cAAQ;AACR,oBAAc,KAAK,SAAS,UAAU,CAAC,UAAU;AAC/C,YAAI,MAAM,SAAS,kBAAmB,SAAQ;AAAA,MAChD,CAAC;AAAA,IACH;AAAA,IAEA,OAAa;AACX,oBAAc;AACd,oBAAc;AAAA,IAChB;AAAA,EACF;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-surface/webmcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.1",
|
|
4
4
|
"description": "[Experimental] WebMCP (navigator.modelContext) transport adapter for agent-surface",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
"LICENSE"
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@agent-surface/core": "^0.
|
|
21
|
+
"@agent-surface/core": "^0.18.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"zod": "^4.1.5",
|
|
25
|
-
"@agent-surface/testing": "0.
|
|
25
|
+
"@agent-surface/testing": "0.17.1"
|
|
26
26
|
},
|
|
27
27
|
"author": "Paolo Barbato",
|
|
28
28
|
"engines": {
|