@touchcastllc/napster-companion-api-dev 1.0.0-alpha.72 → 1.0.0-alpha.74
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/lib/index.d.ts +1 -1
- package/lib/index.esm.js +1 -1
- package/lib/index.js +1 -1
- package/lib/index.standalone.js +1 -1
- package/lib/services/{webmcp/webmcp-bridge.d.ts → edge-mcp/edge-mcp-bridge.d.ts} +24 -5
- package/lib/services/{webmcp/webmcp-discovery.d.ts → edge-mcp/edge-mcp-discovery.d.ts} +3 -3
- package/lib/services/{webmcp/webmcp-types.d.ts → edge-mcp/edge-mcp-types.d.ts} +30 -7
- package/lib/services/edge-mcp/index.d.ts +5 -0
- package/lib/services/{webmcp → edge-mcp}/normalizeFunctionCallEvent.d.ts +2 -2
- package/package.json +1 -1
- package/lib/services/webmcp/index.d.ts +0 -5
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { FunctionCallEvent, SendCommand,
|
|
2
|
-
export interface
|
|
1
|
+
import type { FunctionCallEvent, SendCommand, EdgeMcpModelContext } from "./edge-mcp-types";
|
|
2
|
+
export interface EdgeMcpBridgeOptions {
|
|
3
3
|
/**
|
|
4
4
|
* The SDK's `sendCommand`, bound to the live instance so the bridge can emit
|
|
5
5
|
* `send_message` (state relays) and `send_function_output` (tool results).
|
|
@@ -21,25 +21,44 @@ export interface WebMcpBridgeOptions {
|
|
|
21
21
|
*/
|
|
22
22
|
registerInlineFunctions?: boolean;
|
|
23
23
|
}
|
|
24
|
-
export declare class
|
|
24
|
+
export declare class EdgeMcpBridge {
|
|
25
25
|
private mc;
|
|
26
26
|
private tools;
|
|
27
27
|
private onToolChange;
|
|
28
28
|
private onResourceUpdated;
|
|
29
|
+
private onResourceListChanged;
|
|
30
|
+
private readonly seededUris;
|
|
29
31
|
private lastInlineSig;
|
|
30
32
|
private sessionReady;
|
|
31
33
|
private disposed;
|
|
32
34
|
private readonly options;
|
|
33
|
-
constructor(options:
|
|
35
|
+
constructor(options: EdgeMcpBridgeOptions);
|
|
34
36
|
/**
|
|
35
37
|
* Discover `document.modelContext` in the page, cache its tools, and wire up
|
|
36
38
|
* the `toolchange` / `resourceupdated` listeners. Returns the model context,
|
|
37
39
|
* or `null` if none appears within the timeout. Safe to fire from `init()` —
|
|
38
40
|
* failure is silent and non-fatal.
|
|
39
41
|
*/
|
|
40
|
-
attach(): Promise<
|
|
42
|
+
attach(): Promise<EdgeMcpModelContext | null>;
|
|
41
43
|
/** Attach to a known model context: cache tools and subscribe to events. */
|
|
42
44
|
private bind;
|
|
45
|
+
/**
|
|
46
|
+
* Relay the current value of every registered resource to the agent once, as
|
|
47
|
+
* an initial state seed — batched into a SINGLE `send_message` rather than one
|
|
48
|
+
* per resource, so the agent gets the whole starting state in one context
|
|
49
|
+
* injection. Feature-detects the toolkit's resource extension (`getResources` /
|
|
50
|
+
* `readResource`) — a bare WebMCP surface has neither, so this is a no-op there.
|
|
51
|
+
* Already-seeded URIs are skipped so a `resourcelistchanged` re-seed only emits
|
|
52
|
+
* genuinely new resources. (Ongoing changes still relay per-resource via
|
|
53
|
+
* `relayResourceUpdate`, since they happen one at a time.)
|
|
54
|
+
*/
|
|
55
|
+
private seedResources;
|
|
56
|
+
/**
|
|
57
|
+
* Send the whole initial state set to the agent as ONE `role: 'system'`
|
|
58
|
+
* message (one line per resource). `trigger_response: false` so the avatar
|
|
59
|
+
* doesn't speak on the seed; `delay: true` to wait for any current speech.
|
|
60
|
+
*/
|
|
61
|
+
private relayInitialState;
|
|
43
62
|
/** Re-read the tool catalog from the model context. */
|
|
44
63
|
private refreshTools;
|
|
45
64
|
/** Map the current WebMCP tools to `set_settings.inline_functions` definitions. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { EdgeMcpModelContext } from "./edge-mcp-types";
|
|
2
2
|
/** Read `document.modelContext`, falling back to the deprecated navigator alias. */
|
|
3
|
-
export declare function getModelContext():
|
|
3
|
+
export declare function getModelContext(): EdgeMcpModelContext | null;
|
|
4
4
|
/**
|
|
5
5
|
* Discover `document.modelContext`, polling briefly if it is not present yet.
|
|
6
6
|
*
|
|
@@ -11,4 +11,4 @@ export declare function getModelContext(): WebMcpModelContext | null;
|
|
|
11
11
|
* 1500ms — long enough to cover normal hydration ordering,
|
|
12
12
|
* short enough not to delay the SDK noticeably.
|
|
13
13
|
*/
|
|
14
|
-
export declare function discoverModelContext(timeoutMs?: number): Promise<
|
|
14
|
+
export declare function discoverModelContext(timeoutMs?: number): Promise<EdgeMcpModelContext | null>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Tool metadata as returned by `document.modelContext.getTools()`. */
|
|
2
|
-
export interface
|
|
2
|
+
export interface EdgeMcpToolInfo {
|
|
3
3
|
/** Domain-named identifier, e.g. `'docs.search'` or `'cart.add'`. */
|
|
4
4
|
name: string;
|
|
5
5
|
/** One-sentence description the agent uses to decide WHEN to invoke. */
|
|
@@ -12,13 +12,36 @@ export interface WebMcpToolInfo {
|
|
|
12
12
|
inputSchema?: Record<string, unknown> | string;
|
|
13
13
|
/** Optional human-readable label. */
|
|
14
14
|
title?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Standard WebMCP/MCP annotation hints, surfaced by the polyfill's
|
|
17
|
+
* `getTools()`. The bridge reads these to gate agent behavior — most
|
|
18
|
+
* importantly, `destructiveHint` ⇒ the agent must confirm with the user before
|
|
19
|
+
* calling. A bare WebMCP surface (or older polyfill) may omit this entirely, so
|
|
20
|
+
* every field is optional and the bridge treats a missing object as "no hints."
|
|
21
|
+
*/
|
|
22
|
+
annotations?: EdgeMcpToolAnnotations;
|
|
23
|
+
}
|
|
24
|
+
/** The standard MCP tool annotation hints the bridge understands. */
|
|
25
|
+
export interface EdgeMcpToolAnnotations {
|
|
26
|
+
/** Tool only reads state — safe to call freely, no confirmation. */
|
|
27
|
+
readOnlyHint?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Tool performs a destructive / final action. Bridge convention: treat this as
|
|
30
|
+
* "confirm with the user before calling" (covers additive-but-final actions
|
|
31
|
+
* like submit / send / place-order too).
|
|
32
|
+
*/
|
|
33
|
+
destructiveHint?: boolean;
|
|
34
|
+
/** Safe to retry with the same args (no extra effect). */
|
|
35
|
+
idempotentHint?: boolean;
|
|
36
|
+
/** Output may contain untrusted / third-party content (injection risk). */
|
|
37
|
+
untrustedContentHint?: boolean;
|
|
15
38
|
}
|
|
16
39
|
/**
|
|
17
40
|
* Payload of the toolkit's `resourceupdated` event (live-state extension).
|
|
18
41
|
* Mirrors MCP's `notifications/resources/updated`, but carries the value
|
|
19
42
|
* inline so the SDK can relay it without a follow-up read.
|
|
20
43
|
*/
|
|
21
|
-
export interface
|
|
44
|
+
export interface EdgeMcpResourceUpdate {
|
|
22
45
|
uri: string;
|
|
23
46
|
value: unknown;
|
|
24
47
|
}
|
|
@@ -32,9 +55,9 @@ export interface WebMcpResourceUpdate {
|
|
|
32
55
|
* `document.modelContext` is an `EventTarget`: it dispatches `toolchange` when
|
|
33
56
|
* the tool list changes and (with the toolkit) `resourceupdated` on state push.
|
|
34
57
|
*/
|
|
35
|
-
export interface
|
|
36
|
-
getTools(): Promise<
|
|
37
|
-
executeTool(tool:
|
|
58
|
+
export interface EdgeMcpModelContext extends EventTarget {
|
|
59
|
+
getTools(): Promise<EdgeMcpToolInfo[]>;
|
|
60
|
+
executeTool(tool: EdgeMcpToolInfo, inputArgsJson: string, options?: {
|
|
38
61
|
signal?: AbortSignal;
|
|
39
62
|
}): Promise<string | null>;
|
|
40
63
|
getResources?: () => Array<{
|
|
@@ -42,14 +65,14 @@ export interface WebMcpModelContext extends EventTarget {
|
|
|
42
65
|
name: string;
|
|
43
66
|
}>;
|
|
44
67
|
readResource?: (uri: string) => Promise<unknown>;
|
|
45
|
-
subscribeResource?: (uri: string, handler: (update:
|
|
68
|
+
subscribeResource?: (uri: string, handler: (update: EdgeMcpResourceUpdate) => void) => () => void;
|
|
46
69
|
}
|
|
47
70
|
/**
|
|
48
71
|
* Normalized shape of an incoming function-call event.
|
|
49
72
|
*
|
|
50
73
|
* The server signals an agent tool call with a `function_implicitly_called`
|
|
51
74
|
* event; the SDK's data-channel handler extracts these three fields before
|
|
52
|
-
* calling `
|
|
75
|
+
* calling `EdgeMcpBridge.dispatchFunctionCall`.
|
|
53
76
|
*/
|
|
54
77
|
export interface FunctionCallEvent {
|
|
55
78
|
/** The tool/function name the agent invoked. */
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { EdgeMcpBridge } from "./edge-mcp-bridge";
|
|
2
|
+
export type { EdgeMcpBridgeOptions } from "./edge-mcp-bridge";
|
|
3
|
+
export { normalizeFunctionCallEvent } from "./normalizeFunctionCallEvent";
|
|
4
|
+
export { getModelContext, discoverModelContext } from "./edge-mcp-discovery";
|
|
5
|
+
export type { EdgeMcpModelContext, EdgeMcpToolInfo, EdgeMcpToolAnnotations, EdgeMcpResourceUpdate, FunctionCallEvent, SendCommand, } from "./edge-mcp-types";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { FunctionCallEvent } from "./
|
|
1
|
+
import type { FunctionCallEvent } from "./edge-mcp-types";
|
|
2
2
|
/**
|
|
3
3
|
* Returns a normalized `FunctionCallEvent` if `message` represents a function
|
|
4
4
|
* call, otherwise `null`. Callers route a non-null result to
|
|
5
|
-
* `
|
|
5
|
+
* `EdgeMcpBridge.dispatchFunctionCall` and skip normal chat handling.
|
|
6
6
|
*
|
|
7
7
|
* Requires `name` and `call_id`. `arguments` is passed through as-is (object
|
|
8
8
|
* for `function_implicitly_called`, JSON string for realtime protocols, or
|
package/package.json
CHANGED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export { WebMcpBridge } from "./webmcp-bridge";
|
|
2
|
-
export type { WebMcpBridgeOptions } from "./webmcp-bridge";
|
|
3
|
-
export { normalizeFunctionCallEvent } from "./normalizeFunctionCallEvent";
|
|
4
|
-
export { getModelContext, discoverModelContext } from "./webmcp-discovery";
|
|
5
|
-
export type { WebMcpModelContext, WebMcpToolInfo, WebMcpResourceUpdate, FunctionCallEvent, SendCommand, } from "./webmcp-types";
|