@theoremjs/react 0.3.0 → 0.3.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 +728 -202
- package/client/composer-hints.js +1 -1
- package/client/decision-images.d.ts +76 -0
- package/client/decision-images.js +139 -0
- package/client/decision-transport.d.ts +26 -4
- package/client/decision-transport.js +79 -6
- package/client/embedding-input.d.ts +84 -0
- package/client/embedding-input.js +194 -0
- package/client/embedding-space.d.ts +82 -0
- package/client/embedding-space.js +389 -0
- package/client/embedding-transport.d.ts +40 -0
- package/client/embedding-transport.js +71 -0
- package/client/failure.d.ts +7 -10
- package/client/failure.js +9 -9
- package/client/host-call.d.ts +1 -1
- package/client/host-call.js +7 -2
- package/client/host-transport.d.ts +2 -0
- package/client/host-transport.js +3 -2
- package/client/index.d.ts +19 -11
- package/client/index.js +14 -10
- package/client/ink-waveform.d.ts +1 -1
- package/client/ink-waveform.js +1 -2
- package/client/live/apply-live-turn-tool-event.js +1 -1
- package/client/live/live-captions.d.ts +30 -0
- package/client/live/live-captions.js +105 -1
- package/client/live/live-mic-forward.d.ts +1 -0
- package/client/live/live-mic-forward.js +11 -2
- package/client/live/live-page-tool.d.ts +34 -0
- package/client/live/live-page-tool.js +11 -0
- package/client/live/live-state.d.ts +4 -2
- package/client/live/live-state.js +2 -0
- package/client/live/live-video.js +1 -1
- package/client/live/run-live-tool-call.d.ts +7 -2
- package/client/live/run-live-tool-call.js +48 -10
- package/client/live/use-live-caption-log.d.ts +17 -0
- package/client/live/use-live-caption-log.js +51 -0
- package/client/live-client.d.ts +52 -4
- package/client/live-client.js +250 -59
- package/client/live-messages.d.ts +51 -13
- package/client/live-messages.js +42 -9
- package/client/page-dispatch.d.ts +15 -0
- package/client/page-dispatch.js +63 -0
- package/client/run-commit.d.ts +16 -43
- package/client/run-commit.js +26 -101
- package/client/run-session.d.ts +40 -41
- package/client/run-session.js +104 -112
- package/client/schema-fields.js +27 -6
- package/client/shaped-data.js +37 -8
- package/client/source-citations.js +1 -1
- package/client/space-geometry.d.ts +39 -0
- package/client/space-geometry.js +183 -0
- package/client/state-fields.js +1 -1
- package/client/tool-result.js +30 -12
- package/client/tool-resume.d.ts +18 -1
- package/client/tool-resume.js +4 -1
- package/client/trace-feed.d.ts +1 -1
- package/client/trace-story.d.ts +2 -2
- package/client/trace-story.js +43 -19
- package/client/trace-view.d.ts +2 -2
- package/client/trace-view.js +56 -16
- package/client/transcript-groups.d.ts +28 -2
- package/client/transcript-groups.js +63 -13
- package/client/transcript-schema.d.ts +10 -0
- package/client/transcript-schema.js +120 -0
- package/client/transport.d.ts +114 -26
- package/client/transport.js +106 -32
- package/client/turn-client.d.ts +17 -8
- package/client/turn-client.js +26 -31
- package/client/voice-recorder.d.ts +1 -1
- package/client/voice-recorder.js +2 -5
- package/client/wire-line.js +5 -5
- package/client/worklets/mic-capture.js +9 -9
- package/components/InkWaveform.d.ts +12 -1
- package/components/InkWaveform.js +65 -42
- package/components/live/use-live-runner-controls.d.ts +3 -4
- package/components/live/use-live-runner-controls.js +6 -10
- package/components/live/use-live-runner-model.d.ts +10 -6
- package/components/live/use-live-runner-model.js +29 -14
- package/components/live/use-live-runner-ui.d.ts +10 -8
- package/components/live/use-live-runner-ui.js +19 -11
- package/components/live/use-live-session-client.d.ts +4 -4
- package/components/live/use-live-session-client.js +11 -8
- package/components/use-composer-voice.d.ts +4 -4
- package/components/use-composer-voice.js +8 -8
- package/components/use-editor-selection.js +4 -1
- package/components/use-voice-playback.d.ts +2 -1
- package/components/use-voice-playback.js +4 -4
- package/hooks/use-described.d.ts +5 -1
- package/hooks/use-described.js +11 -9
- package/hooks/use-embedding-index.d.ts +27 -0
- package/hooks/use-embedding-index.js +43 -0
- package/hooks/use-one-call.d.ts +31 -0
- package/hooks/use-one-call.js +76 -0
- package/hooks/use-page-tool-warnings.d.ts +6 -0
- package/hooks/use-page-tool-warnings.js +25 -0
- package/hooks/use-second-ticker.d.ts +2 -0
- package/hooks/use-second-ticker.js +13 -0
- package/hooks/use-theorem-chat-actions.d.ts +25 -21
- package/hooks/use-theorem-chat-actions.js +67 -45
- package/hooks/use-theorem-chat-state.d.ts +6 -6
- package/hooks/use-theorem-chat-state.js +13 -9
- package/hooks/use-theorem-chat.d.ts +48 -14
- package/hooks/use-theorem-chat.js +329 -141
- package/hooks/use-theorem-decision.d.ts +5 -10
- package/hooks/use-theorem-decision.js +4 -67
- package/hooks/use-theorem-embedding.d.ts +18 -0
- package/hooks/use-theorem-embedding.js +12 -0
- package/hooks/use-theorem-host.d.ts +5 -4
- package/hooks/use-theorem-host.js +26 -8
- package/hooks/use-theorem-interface.d.ts +6 -3
- package/hooks/use-theorem-interface.js +12 -22
- package/index.d.ts +6 -3
- package/index.js +5 -2
- package/live.d.ts +1 -0
- package/live.js +1 -1
- package/package.json +6 -5
- package/server/checkpoint-ownership.d.ts +6 -0
- package/server/checkpoint-ownership.js +42 -0
- package/server/conversation-store.d.ts +92 -0
- package/server/conversation-store.js +131 -0
- package/server/conversation.d.ts +193 -0
- package/server/conversation.js +552 -0
- package/server/decision-handler.d.ts +12 -4
- package/server/decision-handler.js +29 -38
- package/server/embedding-handler.d.ts +33 -0
- package/server/embedding-handler.js +45 -0
- package/server/handler.d.ts +58 -20
- package/server/handler.js +441 -238
- package/server/mod.d.ts +15 -6
- package/server/mod.js +13 -5
- package/server/page-dispatch.d.ts +22 -0
- package/server/page-dispatch.js +127 -0
- package/server/request-body.d.ts +2 -0
- package/server/request-body.js +42 -0
- package/server/request-check.d.ts +6 -1
- package/server/request-check.js +27 -12
- package/server/session-authority.d.ts +8 -0
- package/server/session-authority.js +78 -0
- package/server/session-boundary.d.ts +26 -0
- package/server/session-boundary.js +64 -0
- package/server/session-identity.d.ts +16 -0
- package/server/session-identity.js +41 -0
- package/server/session-limits.d.ts +12 -0
- package/server/session-limits.js +59 -0
- package/server/session-store.d.ts +69 -20
- package/server/session-store.js +220 -5
- package/server/single-action.d.ts +21 -0
- package/server/single-action.js +30 -0
- package/server/steer-inbox.js +1 -1
- package/server/tool-operations.d.ts +6 -0
- package/server/tool-operations.js +132 -0
- package/server/turn-input.d.ts +10 -0
- package/server/turn-input.js +29 -0
- package/styles/ink-controls.css +78 -78
- package/ui/CardWall.d.ts +10 -0
- package/ui/CardWall.js +61 -0
- package/ui/ChatComposerBar.d.ts +28 -5
- package/ui/ChatComposerBar.js +85 -30
- package/ui/ChatTranscript.d.ts +14 -1
- package/ui/ChatTranscript.js +110 -57
- package/ui/ConsoleFrame.d.ts +61 -4
- package/ui/ConsoleFrame.js +109 -9
- package/ui/DecisionAnswers.d.ts +40 -2
- package/ui/DecisionAnswers.js +166 -35
- package/ui/DecisionImages.d.ts +16 -0
- package/ui/DecisionImages.js +46 -0
- package/ui/EmbeddingDocuments.d.ts +78 -0
- package/ui/EmbeddingDocuments.js +278 -0
- package/ui/EmbeddingQuery.d.ts +27 -0
- package/ui/EmbeddingQuery.js +95 -0
- package/ui/EmbeddingResults.d.ts +41 -0
- package/ui/EmbeddingResults.js +165 -0
- package/ui/EmbeddingSpace.d.ts +26 -0
- package/ui/EmbeddingSpace.js +106 -0
- package/ui/LiveCaptionsPanel.d.ts +22 -0
- package/ui/LiveCaptionsPanel.js +27 -0
- package/ui/LiveRunner.d.ts +6 -4
- package/ui/LiveRunner.js +42 -55
- package/ui/PaneState.d.ts +33 -0
- package/ui/PaneState.js +50 -0
- package/ui/SchemaFields.d.ts +1 -1
- package/ui/SchemaFields.js +54 -26
- package/ui/ShapedData.js +73 -28
- package/ui/SidePanel.d.ts +74 -5
- package/ui/SidePanel.js +82 -9
- package/ui/StateFields.d.ts +10 -2
- package/ui/StateFields.js +56 -13
- package/ui/TheoremChat.d.ts +65 -14
- package/ui/TheoremChat.js +66 -78
- package/ui/TheoremDecision.d.ts +12 -20
- package/ui/TheoremDecision.js +78 -35
- package/ui/TheoremEmbedding.d.ts +27 -0
- package/ui/TheoremEmbedding.js +122 -0
- package/ui/TheoremHost.d.ts +22 -5
- package/ui/TheoremHost.js +127 -37
- package/ui/ToolGateCard.d.ts +5 -1
- package/ui/ToolGateCard.js +30 -23
- package/ui/ToolResult.js +12 -10
- package/ui/ToolResultCharts.js +29 -12
- package/ui/TraceCharts.d.ts +2 -2
- package/ui/TraceCharts.js +48 -17
- package/ui/TraceGuardrails.d.ts +3 -2
- package/ui/TraceGuardrails.js +24 -6
- package/ui/TraceInspector.d.ts +11 -1
- package/ui/TraceInspector.js +45 -28
- package/ui/TraceInspectorPanel.d.ts +31 -9
- package/ui/TraceInspectorPanel.js +77 -39
- package/ui/TraceOverview.d.ts +7 -3
- package/ui/TraceOverview.js +44 -14
- package/ui/TraceSpanDetail.js +24 -22
- package/ui/TraceStory.js +9 -8
- package/ui/TraceValues.js +19 -9
- package/ui/TraceWaterfall.js +12 -9
- package/ui/VoiceNote.js +4 -4
- package/ui/approval-heading.d.ts +4 -0
- package/ui/approval-heading.js +9 -0
- package/ui/arrive.d.ts +18 -0
- package/ui/arrive.js +46 -0
- package/ui/built/theme.css +86 -68
- package/ui/built/theme.css.d.ts +9 -0
- package/ui/built/theorem.d.ts +3 -3
- package/ui/built/theorem.js +34 -5
- package/ui/built/theorem.variants.d.ts +8 -2
- package/ui/code-language.d.ts +12 -0
- package/ui/code-language.js +50 -0
- package/ui/disclosure-motion.js +53 -9
- package/ui/embedding-space-gl.d.ts +37 -0
- package/ui/embedding-space-gl.js +663 -0
- package/ui/embedding-space-view.d.ts +8 -0
- package/ui/embedding-space-view.js +8 -0
- package/ui/glide.d.ts +7 -0
- package/ui/glide.js +44 -0
- package/ui/icons.js +2 -1
- package/ui/index.d.ts +20 -9
- package/ui/index.js +20 -10
- package/ui/labels-provider.js +5 -2
- package/ui/labels.d.ts +374 -85
- package/ui/labels.js +1028 -188
- package/ui/markdown-plugins.d.ts +9 -0
- package/ui/markdown-plugins.js +13 -0
- package/ui/mcp-icon.d.ts +6 -0
- package/ui/mcp-icon.js +8 -0
- package/ui/row-keys.d.ts +19 -0
- package/ui/row-keys.js +33 -0
- package/ui/theme.d.ts +1 -1
- package/ui/theme.js +2 -2
- package/ui/theorem-theme.js +32 -10
- package/ui/trace-palette.d.ts +2 -16
- package/ui/trace-palette.js +2 -16
- package/ui/trace-patterns.d.ts +11 -3
- package/ui/trace-patterns.js +16 -3
- package/ui/transcript-copy-text.js +1 -0
- package/ui/wall-columns.d.ts +8 -0
- package/ui/wall-columns.js +19 -0
- package/client/walk-away.d.ts +0 -34
- package/client/walk-away.js +0 -48
- package/server/walk-away.d.ts +0 -22
- package/server/walk-away.js +0 -41
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
export type LiveSessionStatus = 'disconnected' | 'connecting'
|
|
1
|
+
export type LiveSessionStatus = 'disconnected' | 'connecting'
|
|
2
|
+
/** The call dropped and the client is taking it up again. */
|
|
3
|
+
| 'reconnecting' | 'ready' | 'listening' | 'speaking' | 'working' | 'error';
|
|
2
4
|
export type LiveConnectPhase = 'socket' | 'microphone';
|
|
3
5
|
/** What a live call is doing, for its status line; the UI words it. */
|
|
4
|
-
export type LiveState = 'calling_tool' | 'connecting' | 'requesting_mic' | 'speaking' | 'connected' | 'muted' | 'listening' | 'error' | 'ended';
|
|
6
|
+
export type LiveState = 'calling_tool' | 'connecting' | 'reconnecting' | 'requesting_mic' | 'speaking' | 'connected' | 'muted' | 'listening' | 'error' | 'ended';
|
|
5
7
|
export declare function liveState(args: {
|
|
6
8
|
status: LiveSessionStatus;
|
|
7
9
|
connectPhase: LiveConnectPhase | null;
|
|
@@ -20,7 +20,7 @@ export function startLiveVideoCapture(onFrame, options) {
|
|
|
20
20
|
if (!context) {
|
|
21
21
|
for (const track of stream.getTracks())
|
|
22
22
|
track.stop();
|
|
23
|
-
throw new TheoremError('unsupported', 'no 2d canvas for live video'); //
|
|
23
|
+
throw new TheoremError('unsupported', 'no 2d canvas for live video'); // labels-exempt: internal diagnostic
|
|
24
24
|
}
|
|
25
25
|
let timer = null;
|
|
26
26
|
let stopped = false;
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import type { ExecuteToolOnRelay } from '../live-messages.ts';
|
|
2
|
+
import type { PageTools } from './live-page-tool.ts';
|
|
2
3
|
import type { LiveGateAnswer, LiveToolGatePrompt } from './live-tool.ts';
|
|
3
4
|
/**
|
|
4
|
-
* Live provider tool-call handler:
|
|
5
|
-
*
|
|
5
|
+
* Live provider tool-call handler: the page answers the call if it is the
|
|
6
|
+
* page's; else run the model's call on the relay; at a gate, ask the user and
|
|
7
|
+
* send their decision. The session answers the model
|
|
6
8
|
* however the call ends; its tool events tell the user. A call the model
|
|
7
9
|
* cancels while its gate is open is gone: nothing is sent.
|
|
8
10
|
*/
|
|
9
11
|
export declare function runLiveToolCall(args: {
|
|
10
12
|
executeToolOnRelay: ExecuteToolOnRelay;
|
|
13
|
+
/** The host's page tools, if it has any. */
|
|
14
|
+
pageTools?: PageTools;
|
|
11
15
|
name: string;
|
|
12
16
|
toolArgs: Record<string, unknown>;
|
|
13
17
|
callId: string;
|
|
18
|
+
operationId: string;
|
|
14
19
|
sessionPermissions: string[];
|
|
15
20
|
setSessionPermissions: (next: string[]) => void;
|
|
16
21
|
waitForGateDecision: (prompt: LiveToolGatePrompt) => Promise<LiveGateAnswer>;
|
|
@@ -1,31 +1,69 @@
|
|
|
1
1
|
import { continueGatedToolInvocation } from "../tool-resume.js";
|
|
2
2
|
/**
|
|
3
|
-
* Live provider tool-call handler:
|
|
4
|
-
*
|
|
3
|
+
* Live provider tool-call handler: the page answers the call if it is the
|
|
4
|
+
* page's; else run the model's call on the relay; at a gate, ask the user and
|
|
5
|
+
* send their decision. The session answers the model
|
|
5
6
|
* however the call ends; its tool events tell the user. A call the model
|
|
6
7
|
* cancels while its gate is open is gone: nothing is sent.
|
|
7
8
|
*/
|
|
8
9
|
export async function runLiveToolCall(args) {
|
|
9
|
-
const { executeToolOnRelay, name, toolArgs, callId } = args;
|
|
10
|
+
const { executeToolOnRelay, name, toolArgs, callId, operationId } = args;
|
|
10
11
|
let sessionPermissions = args.sessionPermissions;
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
// why: A name from the model is looked up among the host's own keys only.
|
|
13
|
+
const pageTool = args.pageTools && Object.hasOwn(args.pageTools, name) ? args.pageTools[name] : undefined;
|
|
14
|
+
let step = await executeToolOnRelay({ callId, operationId });
|
|
15
|
+
const dispatched = new Set();
|
|
16
|
+
while (step.status !== 'settled') {
|
|
17
|
+
if (step.status === 'dispatched') {
|
|
18
|
+
if (dispatched.has(step.grantId))
|
|
19
|
+
return;
|
|
20
|
+
dispatched.add(step.grantId);
|
|
21
|
+
const grantId = step.grantId;
|
|
22
|
+
const input = step.arguments;
|
|
23
|
+
const answer = pageTool
|
|
24
|
+
? await Promise.resolve()
|
|
25
|
+
.then(() => pageTool(input, { callId, operationId }))
|
|
26
|
+
.catch(() => undefined)
|
|
27
|
+
: undefined;
|
|
28
|
+
step = await executeToolOnRelay({
|
|
29
|
+
callId,
|
|
30
|
+
operationId,
|
|
31
|
+
grantId,
|
|
32
|
+
...(answer ? { output: answer.output } : { unanswered: true }),
|
|
33
|
+
});
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
13
36
|
const { gate } = step;
|
|
14
|
-
|
|
37
|
+
if (gate.kind === 'page') {
|
|
38
|
+
await executeToolOnRelay({ callId, operationId, decision: 'deny' });
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const resolution = await args.waitForGateDecision({
|
|
42
|
+
callId,
|
|
43
|
+
toolName: name,
|
|
44
|
+
input: gate.preparedArguments ?? toolArgs,
|
|
45
|
+
gate,
|
|
46
|
+
});
|
|
15
47
|
if (resolution === 'withdrawn')
|
|
16
48
|
return;
|
|
17
|
-
const reply = continueGatedToolInvocation({
|
|
49
|
+
const reply = continueGatedToolInvocation({
|
|
50
|
+
toolName: name,
|
|
51
|
+
gate,
|
|
52
|
+
sessionPermissions,
|
|
53
|
+
resolution,
|
|
54
|
+
});
|
|
18
55
|
if (reply.decision === 'deny') {
|
|
19
|
-
// The session settles the refusal; its tool event tells the user.
|
|
20
|
-
await executeToolOnRelay({ callId, decision: 'deny' });
|
|
56
|
+
// why: The session settles the refusal; its tool event tells the user.
|
|
57
|
+
await executeToolOnRelay({ callId, operationId, decision: 'deny' });
|
|
21
58
|
return;
|
|
22
59
|
}
|
|
23
60
|
sessionPermissions = reply.sessionPermissions;
|
|
24
61
|
args.setSessionPermissions(reply.sessionPermissions);
|
|
25
|
-
// Signed in: a typed key goes once, with the approval; after an OAuth callback there is none.
|
|
62
|
+
// why: Signed in: a typed key goes once, with the approval; after an OAuth callback there is none.
|
|
26
63
|
step = await executeToolOnRelay({
|
|
27
64
|
callId,
|
|
28
65
|
decision: 'approve',
|
|
66
|
+
operationId,
|
|
29
67
|
...(reply.secret !== undefined ? { secret: reply.secret } : {}),
|
|
30
68
|
});
|
|
31
69
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { TurnEvent } from '@theoremjs/agents';
|
|
2
|
+
import { type LiveCaptionState, type LiveCaptionTurn } from './live-captions.ts';
|
|
3
|
+
/**
|
|
4
|
+
* The captions a live call shows: this call's lines, and earlier calls kept
|
|
5
|
+
* when it is started again. Speech arrives through `applyTranscript`, and the
|
|
6
|
+
* call's turn events (thoughts, tool calls, the reply's end) through
|
|
7
|
+
* `applyTurnEvent`. A typed send is `noteSentText`, which always starts its own line.
|
|
8
|
+
*/
|
|
9
|
+
export declare function useLiveCaptionLog(): {
|
|
10
|
+
captions: LiveCaptionState;
|
|
11
|
+
pastCalls: LiveCaptionTurn[][];
|
|
12
|
+
applyTranscript: (text: string, isUser: boolean, interim?: boolean) => void;
|
|
13
|
+
applyTurnEvent: (event: TurnEvent) => void;
|
|
14
|
+
noteSentText: (text: string) => void;
|
|
15
|
+
beginNextCall: () => void;
|
|
16
|
+
clear: () => void;
|
|
17
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { useCallback, useRef, useState } from 'react';
|
|
2
|
+
import { applyLiveTranscript, applyLiveTurnEvent, emptyLiveCaptionState, stashLiveCaptionCall, } from "./live-captions.js";
|
|
3
|
+
/**
|
|
4
|
+
* The captions a live call shows: this call's lines, and earlier calls kept
|
|
5
|
+
* when it is started again. Speech arrives through `applyTranscript`, and the
|
|
6
|
+
* call's turn events (thoughts, tool calls, the reply's end) through
|
|
7
|
+
* `applyTurnEvent`. A typed send is `noteSentText`, which always starts its own line.
|
|
8
|
+
*/
|
|
9
|
+
export function useLiveCaptionLog() {
|
|
10
|
+
const [captions, setCaptions] = useState(emptyLiveCaptionState);
|
|
11
|
+
const [pastCalls, setPastCalls] = useState([]);
|
|
12
|
+
const captionsRef = useRef(captions);
|
|
13
|
+
captionsRef.current = captions;
|
|
14
|
+
const applyTranscript = useCallback((text, isUser, interim) => {
|
|
15
|
+
const next = applyLiveTranscript(captionsRef.current, text, isUser, interim);
|
|
16
|
+
captionsRef.current = next;
|
|
17
|
+
setCaptions(next);
|
|
18
|
+
}, []);
|
|
19
|
+
const applyTurnEvent = useCallback((event) => {
|
|
20
|
+
const next = applyLiveTurnEvent(captionsRef.current, event);
|
|
21
|
+
captionsRef.current = next;
|
|
22
|
+
setCaptions(next);
|
|
23
|
+
}, []);
|
|
24
|
+
const noteSentText = useCallback((text) => {
|
|
25
|
+
const next = applyLiveTranscript(captionsRef.current, text, true, false, { forceNew: true });
|
|
26
|
+
captionsRef.current = next;
|
|
27
|
+
setCaptions(next);
|
|
28
|
+
}, []);
|
|
29
|
+
const beginNextCall = useCallback(() => {
|
|
30
|
+
const previous = captionsRef.current.turns;
|
|
31
|
+
setPastCalls((calls) => stashLiveCaptionCall(calls, previous));
|
|
32
|
+
const next = emptyLiveCaptionState();
|
|
33
|
+
captionsRef.current = next;
|
|
34
|
+
setCaptions(next);
|
|
35
|
+
}, []);
|
|
36
|
+
const clear = useCallback(() => {
|
|
37
|
+
setPastCalls([]);
|
|
38
|
+
const next = emptyLiveCaptionState();
|
|
39
|
+
captionsRef.current = next;
|
|
40
|
+
setCaptions(next);
|
|
41
|
+
}, []);
|
|
42
|
+
return {
|
|
43
|
+
captions,
|
|
44
|
+
pastCalls,
|
|
45
|
+
applyTranscript,
|
|
46
|
+
applyTurnEvent,
|
|
47
|
+
noteSentText,
|
|
48
|
+
beginNextCall,
|
|
49
|
+
clear,
|
|
50
|
+
};
|
|
51
|
+
}
|
package/client/live-client.d.ts
CHANGED
|
@@ -19,10 +19,14 @@ export type { LiveConnection, LiveSocket } from './live-messages.ts';
|
|
|
19
19
|
import type { LiveSocket } from './live-messages.ts';
|
|
20
20
|
export interface LiveClientOptions {
|
|
21
21
|
profile?: string;
|
|
22
|
-
/** JSON
|
|
22
|
+
/** The host's own JSON for its relay, sent as the open message's `host`. */
|
|
23
23
|
openMessage?: Record<string, unknown>;
|
|
24
|
+
/** The value chosen for each of the profile's `inputs.slots`, fixed for the call. */
|
|
25
|
+
slots?: Record<string, string>;
|
|
26
|
+
/** What the page tells the agent as the call opens; `setContext` replaces it during the call. */
|
|
27
|
+
context?: unknown;
|
|
24
28
|
relayUrl?: string;
|
|
25
|
-
/** In-process connections reuse the same microphone, playback and tool client. */
|
|
29
|
+
/** In-process connections reuse the same microphone, playback, and tool client. */
|
|
26
30
|
createSocket?: () => LiveSocket;
|
|
27
31
|
/** When false, skip microphone capture; session still receives model audio. */
|
|
28
32
|
voiceIngress?: boolean;
|
|
@@ -38,7 +42,7 @@ export interface LiveClientOptions {
|
|
|
38
42
|
onTurnEvent?: (event: ClientTurnEvent) => void;
|
|
39
43
|
/** A trace record the session wrote, when the relay delivers them. */
|
|
40
44
|
onTrace?: (record: TraceRecord) => void;
|
|
41
|
-
/** A failure, typed by kind; word it with `clientFailure` and the interface's `
|
|
45
|
+
/** A failure, typed by kind; word it with `clientFailure` and the interface's `labels`. */
|
|
42
46
|
onError?: (error: Error) => void;
|
|
43
47
|
/** Provider signalled the upstream session is draining (e.g. goAway). */
|
|
44
48
|
onSessionClosing?: (timeLeftMs?: number) => void;
|
|
@@ -53,6 +57,7 @@ export interface LiveClientOptions {
|
|
|
53
57
|
*/
|
|
54
58
|
onToolCall: (name: string, args: Record<string, unknown>, meta: {
|
|
55
59
|
callId: string;
|
|
60
|
+
operationId: string;
|
|
56
61
|
}) => Promise<void>;
|
|
57
62
|
/** The relay opened the call: the id it gave the call, and the profile it runs. */
|
|
58
63
|
onSessionReady?: (info: {
|
|
@@ -93,16 +98,47 @@ export declare class LiveSessionClient {
|
|
|
93
98
|
/** Bumped on barge-in / cancel so stale audioChain work is skipped. */
|
|
94
99
|
private audioEpoch;
|
|
95
100
|
private pendingExecuteResults;
|
|
101
|
+
/** The page's context package, and the JSON of the one the relay last got. */
|
|
102
|
+
private context;
|
|
103
|
+
private sentContext;
|
|
104
|
+
/** The provider's latest handle for taking this call up again after a drop. */
|
|
105
|
+
private history;
|
|
106
|
+
private providerState;
|
|
107
|
+
/** The session said it ended, or failed: a close after that is the end, not a drop. */
|
|
108
|
+
private sessionOver;
|
|
109
|
+
/** When the call dropped, for the time away a resume reports. */
|
|
110
|
+
private droppedAt;
|
|
111
|
+
/** When the call that could not reconnect dropped: the next call takes it up again. */
|
|
112
|
+
private lostAt;
|
|
113
|
+
private reconnectTries;
|
|
114
|
+
private reconnectTimer;
|
|
96
115
|
constructor(options: LiveClientOptions);
|
|
97
116
|
private setStatus;
|
|
117
|
+
/** Still opening: the first connect, or a try at taking a dropped call up again. */
|
|
118
|
+
private get opening();
|
|
98
119
|
private setConnectPhase;
|
|
99
120
|
private clearConnectTimeout;
|
|
100
121
|
private detachWebSocket;
|
|
122
|
+
private clearReconnect;
|
|
101
123
|
private teardownConnection;
|
|
102
124
|
/** End the session on `error`: a failed connect or a lost socket. */
|
|
103
125
|
private failSession;
|
|
104
126
|
private createSocket;
|
|
127
|
+
/**
|
|
128
|
+
* Start a call. After one that dropped and could not reconnect, it takes that call up again,
|
|
129
|
+
* so the agent neither greets twice nor forgets; after a hang-up it is a new call.
|
|
130
|
+
*/
|
|
105
131
|
connect(): Promise<void>;
|
|
132
|
+
/** A lost call that cannot be taken up again, its handle refused or expired, starts as a new one. */
|
|
133
|
+
private startOver;
|
|
134
|
+
/** The first message: the call's values, and the handle and time away when it takes a dropped call up again. */
|
|
135
|
+
private openMessage;
|
|
136
|
+
/** The socket closed while the call was open: take it up again if the provider gave a handle, else end. */
|
|
137
|
+
private handleDrop;
|
|
138
|
+
private scheduleReconnect;
|
|
139
|
+
/** A try at opening failed: a reconnect waits and tries again, a first connect fails the call. */
|
|
140
|
+
private failOpen;
|
|
141
|
+
private open;
|
|
106
142
|
private ensureAudioContext;
|
|
107
143
|
private activateMicrophone;
|
|
108
144
|
private sendMicFrame;
|
|
@@ -115,6 +151,8 @@ export declare class LiveSessionClient {
|
|
|
115
151
|
private processServerEnvelope;
|
|
116
152
|
private enqueueServerMessage;
|
|
117
153
|
private handleReadyEnvelope;
|
|
154
|
+
/** The call is open, first or again: the page's context catches up with what changed meanwhile. */
|
|
155
|
+
private becomeReady;
|
|
118
156
|
private handleExecuteToolResultEnvelope;
|
|
119
157
|
private tryHandleControlEnvelope;
|
|
120
158
|
private collectInboundTurn;
|
|
@@ -134,7 +172,17 @@ export declare class LiveSessionClient {
|
|
|
134
172
|
cancelPlayback(): void;
|
|
135
173
|
toggleMute(): boolean;
|
|
136
174
|
sendText(text: string): void;
|
|
137
|
-
|
|
175
|
+
/**
|
|
176
|
+
* The call's slot values. An open call is taken up again with them when the provider gave a
|
|
177
|
+
* handle; with none, the next call has them.
|
|
178
|
+
*/
|
|
179
|
+
setSlots(slots: Record<string, string> | undefined): void;
|
|
180
|
+
/**
|
|
181
|
+
* Replace the page's context package. In a call it reaches the agent as
|
|
182
|
+
* background, with no reply; before one, it goes with the call's opening.
|
|
183
|
+
*/
|
|
184
|
+
setContext(context: unknown): void;
|
|
185
|
+
private flushContext;
|
|
138
186
|
sendVideo(data: string, mimeType?: string): void;
|
|
139
187
|
disconnect(): void;
|
|
140
188
|
private cleanupAudio;
|