@tinyweb_dev/agent-framework-chat-ui 0.2.0 → 0.4.0
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/components/Composer.d.ts +38 -0
- package/dist/components/Composer.d.ts.map +1 -0
- package/dist/components/Header.d.ts +7 -0
- package/dist/components/Header.d.ts.map +1 -0
- package/dist/components/Hero.d.ts +6 -0
- package/dist/components/Hero.d.ts.map +1 -0
- package/dist/components/RealtimeCallOverlay.d.ts +68 -0
- package/dist/components/RealtimeCallOverlay.d.ts.map +1 -0
- package/dist/components/RealtimeOrb.d.ts +21 -0
- package/dist/components/RealtimeOrb.d.ts.map +1 -0
- package/{src/components/Sidebar.tsx → dist/components/Sidebar.d.ts} +5 -9
- package/dist/components/Sidebar.d.ts.map +1 -0
- package/dist/components/TinywebChat.d.ts +3 -0
- package/dist/components/TinywebChat.d.ts.map +1 -0
- package/dist/components/Transcript.d.ts +20 -0
- package/dist/components/Transcript.d.ts.map +1 -0
- package/dist/components/WireOrbEffect.d.ts +17 -0
- package/dist/components/WireOrbEffect.d.ts.map +1 -0
- package/dist/components/condense/CondensePill.d.ts +11 -0
- package/dist/components/condense/CondensePill.d.ts.map +1 -0
- package/dist/components/messages/AssistantMessage.d.ts +10 -0
- package/dist/components/messages/AssistantMessage.d.ts.map +1 -0
- package/dist/components/messages/ErrorMessage.d.ts +7 -0
- package/dist/components/messages/ErrorMessage.d.ts.map +1 -0
- package/dist/components/messages/ToolMessage.d.ts +17 -0
- package/dist/components/messages/ToolMessage.d.ts.map +1 -0
- package/dist/components/messages/UserMessage.d.ts +7 -0
- package/dist/components/messages/UserMessage.d.ts.map +1 -0
- package/dist/components/tool/ExecRenderer.d.ts +14 -0
- package/dist/components/tool/ExecRenderer.d.ts.map +1 -0
- package/dist/components/tool/ImageRenderer.d.ts +16 -0
- package/dist/components/tool/ImageRenderer.d.ts.map +1 -0
- package/dist/components/tool/JsonRenderer.d.ts +11 -0
- package/dist/components/tool/JsonRenderer.d.ts.map +1 -0
- package/dist/components/tool/ToolCard.d.ts +29 -0
- package/dist/components/tool/ToolCard.d.ts.map +1 -0
- package/dist/components/tool/builtinRenderers.d.ts +9 -0
- package/dist/components/tool/builtinRenderers.d.ts.map +1 -0
- package/dist/hooks/useAgentChat.d.ts +46 -0
- package/dist/hooks/useAgentChat.d.ts.map +1 -0
- package/dist/hooks/useAnchorLatestUser.d.ts +15 -0
- package/dist/hooks/useAnchorLatestUser.d.ts.map +1 -0
- package/dist/hooks/useInitialScrollToEnd.d.ts +15 -0
- package/dist/hooks/useInitialScrollToEnd.d.ts.map +1 -0
- package/dist/hooks/useNdjsonStream.d.ts +11 -0
- package/dist/hooks/useNdjsonStream.d.ts.map +1 -0
- package/dist/hooks/useRealtimeCall.d.ts +112 -0
- package/dist/hooks/useRealtimeCall.d.ts.map +1 -0
- package/dist/index.cjs +3243 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3209 -0
- package/dist/index.js.map +1 -0
- package/dist/markdown/render.d.ts +2 -0
- package/dist/markdown/render.d.ts.map +1 -0
- package/{src → dist}/styles.css +29 -0
- package/dist/types.d.ts +257 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/util/attachments.d.ts +28 -0
- package/dist/util/attachments.d.ts.map +1 -0
- package/dist/util/escape.d.ts +2 -0
- package/dist/util/escape.d.ts.map +1 -0
- package/dist/util/theme.d.ts +13 -0
- package/dist/util/theme.d.ts.map +1 -0
- package/dist/util/tool-detect.d.ts +26 -0
- package/dist/util/tool-detect.d.ts.map +1 -0
- package/dist/util/tool-labels.d.ts +11 -0
- package/dist/util/tool-labels.d.ts.map +1 -0
- package/package.json +14 -14
- package/src/components/Composer.tsx +0 -267
- package/src/components/Header.tsx +0 -16
- package/src/components/Hero.tsx +0 -16
- package/src/components/RealtimeCallOverlay.tsx +0 -894
- package/src/components/RealtimeOrb.tsx +0 -388
- package/src/components/TinywebChat.tsx +0 -95
- package/src/components/Transcript.tsx +0 -146
- package/src/components/WireOrbEffect.tsx +0 -556
- package/src/components/condense/CondensePill.tsx +0 -77
- package/src/components/messages/AssistantMessage.tsx +0 -15
- package/src/components/messages/ErrorMessage.tsx +0 -12
- package/src/components/messages/ToolMessage.tsx +0 -49
- package/src/components/messages/UserMessage.tsx +0 -37
- package/src/components/tool/ExecRenderer.tsx +0 -71
- package/src/components/tool/ImageRenderer.tsx +0 -47
- package/src/components/tool/JsonRenderer.tsx +0 -24
- package/src/components/tool/ToolCard.tsx +0 -65
- package/src/components/tool/builtinRenderers.tsx +0 -456
- package/src/hooks/useAgentChat.ts +0 -454
- package/src/hooks/useAnchorLatestUser.ts +0 -99
- package/src/hooks/useInitialScrollToEnd.ts +0 -41
- package/src/hooks/useNdjsonStream.ts +0 -71
- package/src/hooks/useRealtimeCall.ts +0 -452
- package/src/index.ts +0 -45
- package/src/markdown/render.ts +0 -121
- package/src/types.ts +0 -241
- package/src/util/attachments.ts +0 -87
- package/src/util/escape.ts +0 -16
- package/src/util/theme.ts +0 -40
- package/src/util/tool-detect.ts +0 -65
- package/src/util/tool-labels.ts +0 -34
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { RealtimeEvent } from "@tinyweb_dev/agent-framework-realtime/events";
|
|
2
|
+
/**
|
|
3
|
+
* Lifecycle phase of the call. Mirrors what the overlay renders.
|
|
4
|
+
*/
|
|
5
|
+
export type CallStatus = "idle" | "connecting" | "active" | "ending" | "error";
|
|
6
|
+
/** Tool name → async handler. Runs in browser; no secrets. */
|
|
7
|
+
export type ToolHandlerMap = Record<string, (args: Record<string, unknown>) => Promise<unknown>>;
|
|
8
|
+
export type UseRealtimeCallOptions = {
|
|
9
|
+
/**
|
|
10
|
+
* POST endpoint that mints ephemeral tokens. Response must match
|
|
11
|
+
* [`TokenEndpointResponse`](../../../realtime/src/client/session.ts).
|
|
12
|
+
* Endpoint is responsible for auth (Bearer / cookie). Optional
|
|
13
|
+
* `body` is merged into the POST body so the host can scope tokens
|
|
14
|
+
* to e.g. an agentId or sessionId.
|
|
15
|
+
*/
|
|
16
|
+
readonly tokenEndpoint: string;
|
|
17
|
+
readonly tokenHeaders?: HeadersInit;
|
|
18
|
+
readonly tokenBody?: Record<string, unknown> | (() => Record<string, unknown>);
|
|
19
|
+
/**
|
|
20
|
+
* Per-tool client handlers. Use this only for tools that are safe to
|
|
21
|
+
* execute in the browser with no server secrets (e.g. `time_now`, or
|
|
22
|
+
* a pure JS calculator). Most useful tools need server access and
|
|
23
|
+
* should go through `toolProxyPath` instead.
|
|
24
|
+
*/
|
|
25
|
+
readonly toolHandlers?: ToolHandlerMap;
|
|
26
|
+
/**
|
|
27
|
+
* Optional base path for a server tool proxy (e.g. `/api/tools`). When
|
|
28
|
+
* set, any `tool-call` whose name is NOT covered by `toolHandlers`
|
|
29
|
+
* falls back to `POST {toolProxyPath}/{name}` with the call args as
|
|
30
|
+
* JSON. Server is expected to execute the tool and return the JSON
|
|
31
|
+
* result. Use [`serverExecuteTool`](../../../realtime/src/tools/server.ts:1)
|
|
32
|
+
* to implement the route.
|
|
33
|
+
*
|
|
34
|
+
* Combine with `toolHandlers` to override specific tools client-side
|
|
35
|
+
* while letting everything else go through the server proxy.
|
|
36
|
+
*/
|
|
37
|
+
readonly toolProxyPath?: string;
|
|
38
|
+
/** Optional headers (auth cookie / Bearer) forwarded to the proxy. */
|
|
39
|
+
readonly toolProxyHeaders?: HeadersInit;
|
|
40
|
+
/**
|
|
41
|
+
* Idle hang-up timeout. Default 10 minutes. The hook only resets the
|
|
42
|
+
* idle timer on inbound events — silent calls eventually drop.
|
|
43
|
+
*/
|
|
44
|
+
readonly idleTimeoutMs?: number;
|
|
45
|
+
/** Fires once per event. Useful for analytics / extra side effects. */
|
|
46
|
+
readonly onEvent?: (event: RealtimeEvent) => void;
|
|
47
|
+
/**
|
|
48
|
+
* Prior conversation history to replay into the new Gemini Live
|
|
49
|
+
* session at startup. Closes the "agent forgets everything when I
|
|
50
|
+
* hang up and call again" gap — without it each new call is a clean
|
|
51
|
+
* slate, since a new WebSocket = a new server-side session.
|
|
52
|
+
*
|
|
53
|
+
* Pass an array (or a thunk returning one) of `{role, text}` pairs.
|
|
54
|
+
* `role` is `"user"` for the human's turns and `"model"` for the
|
|
55
|
+
* agent's prior replies (Gemini's vocabulary, NOT `"assistant"`).
|
|
56
|
+
*
|
|
57
|
+
* Resolved once per `start()` call so consumers can lazily derive
|
|
58
|
+
* from a chat store without re-creating the hook on every node
|
|
59
|
+
* append.
|
|
60
|
+
*/
|
|
61
|
+
readonly initialHistory?: ReadonlyArray<{
|
|
62
|
+
readonly role: "user" | "model";
|
|
63
|
+
readonly text: string;
|
|
64
|
+
}> | (() => ReadonlyArray<{
|
|
65
|
+
readonly role: "user" | "model";
|
|
66
|
+
readonly text: string;
|
|
67
|
+
}> | undefined);
|
|
68
|
+
};
|
|
69
|
+
export type UseRealtimeCallReturn = {
|
|
70
|
+
readonly status: CallStatus;
|
|
71
|
+
readonly error: string | null;
|
|
72
|
+
/** Streaming partial transcript of the local user. */
|
|
73
|
+
readonly userTranscript: string;
|
|
74
|
+
/** Streaming partial transcript of the agent. */
|
|
75
|
+
readonly agentTranscript: string;
|
|
76
|
+
/** Most recent tool call (for UI display). Cleared on next call. */
|
|
77
|
+
readonly lastToolCall: {
|
|
78
|
+
name: string;
|
|
79
|
+
args: Record<string, unknown>;
|
|
80
|
+
} | null;
|
|
81
|
+
/**
|
|
82
|
+
* True while a client-side tool is executing (between `tool-call` and
|
|
83
|
+
* `tool-result`/`tool-error`). UI uses this to switch the orb into the
|
|
84
|
+
* `thinking` visual state — audio output is suspended while the model
|
|
85
|
+
* waits for the tool response.
|
|
86
|
+
*/
|
|
87
|
+
readonly toolRunning: boolean;
|
|
88
|
+
/** True when the user has muted their mic locally. */
|
|
89
|
+
readonly muted: boolean;
|
|
90
|
+
readonly start: () => Promise<void>;
|
|
91
|
+
readonly hangup: () => Promise<void>;
|
|
92
|
+
readonly setMuted: (muted: boolean) => void;
|
|
93
|
+
/**
|
|
94
|
+
* Mutable ref holding the latest audio level (0..1). Updated each
|
|
95
|
+
* animation frame from a Web Audio analyser. Reads max(agent, user)
|
|
96
|
+
* — useful for visualizations that just need "something is happening".
|
|
97
|
+
* Stays at 0 outside an active call. Consumers read via `.current`.
|
|
98
|
+
*/
|
|
99
|
+
readonly levelRef: {
|
|
100
|
+
current: number;
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Live analyser node on the agent output. `null` until the session
|
|
104
|
+
* is `active`. Consumers needing FFT detail (e.g. 3D shader noise)
|
|
105
|
+
* can call `getByteFrequencyData()` on this directly.
|
|
106
|
+
*/
|
|
107
|
+
readonly outputAnalyser: AnalyserNode | null;
|
|
108
|
+
/** Live analyser node on the local mic input. */
|
|
109
|
+
readonly inputAnalyser: AnalyserNode | null;
|
|
110
|
+
};
|
|
111
|
+
export declare const useRealtimeCall: (options: UseRealtimeCallOptions) => UseRealtimeCallReturn;
|
|
112
|
+
//# sourceMappingURL=useRealtimeCall.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRealtimeCall.d.ts","sourceRoot":"","sources":["../../src/hooks/useRealtimeCall.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAA;AAE7E;;GAEG;AACH,MAAM,MAAM,UAAU,GAClB,MAAM,GACN,YAAY,GACZ,QAAQ,GACR,QAAQ,GACR,OAAO,CAAA;AAEX,8DAA8D;AAC9D,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC,CAAA;AAEhG,MAAM,MAAM,sBAAsB,GAAG;IACnC;;;;;;OAMG;IACH,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,YAAY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