@touchcastllc/napster-companion-api-dev 1.0.0-alpha.78 → 1.0.0-alpha.80
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 +45 -3
- package/lib/index.css +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/edge-mcp/edge-mcp-bridge.d.ts +33 -15
- package/lib/services/webrtc.d.ts +1 -2
- package/lib/types/index.d.ts +10 -2
- package/package.json +1 -1
|
@@ -76,17 +76,25 @@ export declare class EdgeMcpBridge {
|
|
|
76
76
|
* Relay the current value of every registered resource to the agent once, as
|
|
77
77
|
* an initial state seed — batched into a SINGLE `send_message` rather than one
|
|
78
78
|
* per resource, so the agent gets the whole starting state in one context
|
|
79
|
-
* injection.
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
79
|
+
* injection. Deferred until the session's "ready" state, exactly like tool
|
|
80
|
+
* registration: before that the data channel isn't open and a send would be
|
|
81
|
+
* silently dropped — onSessionReady() runs the seed at the first moment it
|
|
82
|
+
* can succeed, reading each value fresh at that point. Feature-detects the
|
|
83
|
+
* toolkit's resource extension (`getResources` / `readResource`) — a bare
|
|
84
|
+
* WebMCP surface has neither, so this is a no-op there. Already-seeded URIs
|
|
85
|
+
* are skipped so a `resourcelistchanged` re-seed only emits genuinely new
|
|
86
|
+
* resources; URIs are marked seeded only after a successful send, so a
|
|
87
|
+
* refused send stays owed to the agent. (Ongoing changes still relay
|
|
88
|
+
* per-resource via `relayResourceUpdate`, since they happen one at a time.)
|
|
84
89
|
*/
|
|
85
90
|
private seedResources;
|
|
86
91
|
/**
|
|
87
92
|
* Send the whole initial state set to the agent as ONE `role: 'system'`
|
|
88
93
|
* message (one line per resource). `trigger_response: false` so the avatar
|
|
89
94
|
* doesn't speak on the seed; `delay: true` to wait for any current speech.
|
|
95
|
+
* Returns true when the send went out; false when the channel refused it
|
|
96
|
+
* (not open / interaction stopped) so the caller leaves the URIs unmarked
|
|
97
|
+
* and a later seed trigger re-reads and re-delivers them.
|
|
90
98
|
*/
|
|
91
99
|
private relayInitialState;
|
|
92
100
|
/** Re-read the tool catalog from the model context. */
|
|
@@ -95,19 +103,26 @@ export declare class EdgeMcpBridge {
|
|
|
95
103
|
private buildInlineFunctions;
|
|
96
104
|
/**
|
|
97
105
|
* Called by the SDK when the session reaches the "ready" state
|
|
98
|
-
* (`avatar_state_changed` → `state: "ready"`). This is the
|
|
99
|
-
*
|
|
100
|
-
* before it's ready
|
|
101
|
-
*
|
|
102
|
-
*
|
|
106
|
+
* (`avatar_state_changed` → `state: "ready"`). This is the first moment the
|
|
107
|
+
* agent is reachable — the realtime session silently drops `inline_functions`
|
|
108
|
+
* sent before it's ready, and the data channel isn't open earlier (the
|
|
109
|
+
* "ready" event itself arrives over it). Marks the session ready, pushes the
|
|
110
|
+
* current tools, and delivers the initial state seed that bind() deferred.
|
|
111
|
+
*
|
|
112
|
+
* The backend can emit "ready" more than once per session; repeats are
|
|
113
|
+
* no-ops when nothing changed (the push dedupes on catalog content, the seed
|
|
114
|
+
* on delivered URIs). A genuinely NEW session never reaches this method on a
|
|
115
|
+
* live bridge: the SDK tears the whole instance down (destroyInstance →
|
|
116
|
+
* dispose) and the next init builds a fresh bridge with clean dedupe state.
|
|
103
117
|
*/
|
|
104
118
|
onSessionReady(): void;
|
|
105
119
|
/**
|
|
106
120
|
* Register the page's WebMCP tools with the agent by sending the complete
|
|
107
|
-
* current catalog as `set_settings.inline_functions`. Called on attach
|
|
108
|
-
*
|
|
109
|
-
* reach the agent. No-op when not attached,
|
|
110
|
-
* disabled, or when the catalog is
|
|
121
|
+
* current catalog as `set_settings.inline_functions`. Called on attach
|
|
122
|
+
* (deferred until ready), on session ready, and on every toolchange, so
|
|
123
|
+
* tools registered mid-session reach the agent. No-op when not attached,
|
|
124
|
+
* when `registerInlineFunctions` is disabled, or when the catalog is
|
|
125
|
+
* unchanged since the last successful push.
|
|
111
126
|
*/
|
|
112
127
|
private pushInlineFunctions;
|
|
113
128
|
/** True if `attach()` succeeded and the bridge has a live model context. */
|
|
@@ -126,7 +141,10 @@ export declare class EdgeMcpBridge {
|
|
|
126
141
|
/**
|
|
127
142
|
* Forward a toolkit resource update to the agent as a system message.
|
|
128
143
|
* `trigger_response: false` keeps the avatar from speaking on every change;
|
|
129
|
-
* `delay: true` waits for it to finish its current speech first.
|
|
144
|
+
* `delay: true` waits for it to finish its current speech first. Before the
|
|
145
|
+
* session's first "ready" this is a deliberate no-op — the channel can't
|
|
146
|
+
* carry the message yet, and the session-ready seed reads the then-current
|
|
147
|
+
* value anyway, so relaying earlier would only warn and drop.
|
|
130
148
|
*/
|
|
131
149
|
private relayResourceUpdate;
|
|
132
150
|
/**
|
package/lib/services/webrtc.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type EventMessage
|
|
1
|
+
import { type EventMessage } from "../types";
|
|
2
2
|
import type { MediaCapture } from "../utils/MediaCapture";
|
|
3
3
|
export interface WebRTCController {
|
|
4
4
|
startWithToken: (token: string) => Promise<void>;
|
|
@@ -11,7 +11,6 @@ export interface WebRTCController {
|
|
|
11
11
|
}
|
|
12
12
|
interface WebRTCParams {
|
|
13
13
|
currentAudioDeviceId?: string;
|
|
14
|
-
functions?: CompanionFunction[];
|
|
15
14
|
screenShareCapture?: MediaCapture | null;
|
|
16
15
|
onChatMessage?: (data: EventMessage) => void;
|
|
17
16
|
onConnectionSuccess?: () => void;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -182,6 +182,8 @@ export interface FeatureConfig {
|
|
|
182
182
|
color?: string;
|
|
183
183
|
/** Optional loader animation type. */
|
|
184
184
|
type?: "spinner" | "pulse";
|
|
185
|
+
/** Optional CSS class name(s) to add to the loader spinner element. */
|
|
186
|
+
className?: string;
|
|
185
187
|
};
|
|
186
188
|
/** Document Picture-in-Picture. When enabled, the avatar automatically
|
|
187
189
|
* opens in a PiP window when the user switches browser tabs (Chrome/Edge 116+). */
|
|
@@ -329,8 +331,14 @@ export interface NapsterCompanionApiConfig {
|
|
|
329
331
|
layout?: "fixed" | "inline";
|
|
330
332
|
/**
|
|
331
333
|
* AI companion function definitions for function calling support.
|
|
332
|
-
*
|
|
333
|
-
*
|
|
334
|
+
*
|
|
335
|
+
* Functions are configured server-side and baked into the connection at
|
|
336
|
+
* session-creation time (the connection API / token). To register tools
|
|
337
|
+
* mid-session from the page, use the WebMCP bridge, which pushes them as
|
|
338
|
+
* `set_settings.inline_functions` after the session reaches "ready".
|
|
339
|
+
*
|
|
340
|
+
* @deprecated The SDK no longer sends these over the data channel — supplying
|
|
341
|
+
* them here has no effect. Configure functions via the connection API instead.
|
|
334
342
|
*/
|
|
335
343
|
functions?: CompanionFunction[];
|
|
336
344
|
/** Enable debug logging throughout the SDK. When enabled, detailed logs will be output to the console. */
|