@wildix/wilma-copilot-headless 0.1.1 → 0.1.2

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.
Files changed (56) hide show
  1. package/dist/hooks/CopilotSessionStreamSlot.d.ts +18 -0
  2. package/dist/hooks/CopilotSessionStreamSlot.d.ts.map +1 -0
  3. package/dist/hooks/CopilotSessionStreamSlot.js +20 -0
  4. package/dist/hooks/CopilotSessionStreamSlot.js.map +1 -0
  5. package/dist/hooks/index.d.ts +10 -0
  6. package/dist/hooks/index.d.ts.map +1 -0
  7. package/dist/hooks/index.js +10 -0
  8. package/dist/hooks/index.js.map +1 -0
  9. package/dist/hooks/shared.d.ts +8 -0
  10. package/dist/hooks/shared.d.ts.map +1 -0
  11. package/dist/hooks/shared.js +5 -0
  12. package/dist/hooks/shared.js.map +1 -0
  13. package/dist/hooks/useCopilotActions.d.ts +36 -0
  14. package/dist/hooks/useCopilotActions.d.ts.map +1 -0
  15. package/dist/hooks/useCopilotActions.js +64 -0
  16. package/dist/hooks/useCopilotActions.js.map +1 -0
  17. package/dist/hooks/useCopilotAlerts.d.ts +24 -0
  18. package/dist/hooks/useCopilotAlerts.d.ts.map +1 -0
  19. package/dist/hooks/useCopilotAlerts.js +32 -0
  20. package/dist/hooks/useCopilotAlerts.js.map +1 -0
  21. package/dist/hooks/useCopilotAsk.d.ts +11 -0
  22. package/dist/hooks/useCopilotAsk.d.ts.map +1 -0
  23. package/dist/hooks/useCopilotAsk.js +31 -0
  24. package/dist/hooks/useCopilotAsk.js.map +1 -0
  25. package/dist/hooks/useCopilotPanelView.d.ts +48 -0
  26. package/dist/hooks/useCopilotPanelView.d.ts.map +1 -0
  27. package/dist/hooks/useCopilotPanelView.js +41 -0
  28. package/dist/hooks/useCopilotPanelView.js.map +1 -0
  29. package/dist/hooks/useCopilotRecentSessions.d.ts +12 -0
  30. package/dist/hooks/useCopilotRecentSessions.d.ts.map +1 -0
  31. package/dist/hooks/useCopilotRecentSessions.js +38 -0
  32. package/dist/hooks/useCopilotRecentSessions.js.map +1 -0
  33. package/dist/hooks/useCopilotRelationship.d.ts +10 -0
  34. package/dist/hooks/useCopilotRelationship.d.ts.map +1 -0
  35. package/dist/hooks/useCopilotRelationship.js +74 -0
  36. package/dist/hooks/useCopilotRelationship.js.map +1 -0
  37. package/dist/hooks/useCopilotSessionStream.d.ts +12 -0
  38. package/dist/hooks/useCopilotSessionStream.d.ts.map +1 -0
  39. package/dist/hooks/useCopilotSessionStream.js +61 -0
  40. package/dist/hooks/useCopilotSessionStream.js.map +1 -0
  41. package/package.json +5 -5
  42. package/src/hooks/CopilotSessionStreamSlot.tsx +28 -0
  43. package/src/hooks/index.ts +9 -0
  44. package/src/hooks/shared.ts +12 -0
  45. package/src/hooks/useCopilotActions.ts +115 -0
  46. package/src/hooks/useCopilotAlerts.ts +50 -0
  47. package/src/hooks/useCopilotAsk.ts +46 -0
  48. package/src/hooks/useCopilotPanelView.ts +84 -0
  49. package/src/hooks/useCopilotRecentSessions.ts +45 -0
  50. package/src/hooks/useCopilotRelationship.ts +102 -0
  51. package/src/hooks/useCopilotSessionStream.ts +94 -0
  52. package/dist/hooks.d.ts +0 -119
  53. package/dist/hooks.d.ts.map +0 -1
  54. package/dist/hooks.js +0 -282
  55. package/dist/hooks.js.map +0 -1
  56. package/src/hooks.ts +0 -457
@@ -0,0 +1,94 @@
1
+ import {useEffect, useState} from 'react';
2
+
3
+ import {
4
+ type CopilotSessionStreamHandle,
5
+ getCopilotEventIndex,
6
+ initialCopilotUiState,
7
+ reduceCopilotEvent,
8
+ } from '@wildix/wilma-copilot-core';
9
+ import {type CopilotSessionEvent, GetSessionEventsCommand} from '@wildix/wilma-copilot-sessions-client';
10
+
11
+ import {type CopilotDependencies, PAGE_LIMIT} from './shared';
12
+
13
+ export type CopilotEventStream = (
14
+ sessionId: string,
15
+ startIndex: number,
16
+ signal: AbortSignal,
17
+ ) => AsyncIterable<CopilotSessionEvent>;
18
+
19
+ export interface UseCopilotSessionStreamOptions extends CopilotDependencies {
20
+ sessionId?: string;
21
+ live?: boolean;
22
+ streamEvents?: CopilotEventStream;
23
+ onRelationship?: (sessionId: string | undefined) => void;
24
+ }
25
+
26
+ export function useCopilotSessionStream({
27
+ copilotClient,
28
+ sessionId,
29
+ live = true,
30
+ streamEvents,
31
+ onRelationship,
32
+ onError,
33
+ }: UseCopilotSessionStreamOptions): CopilotSessionStreamHandle {
34
+ const [state, setState] = useState(initialCopilotUiState);
35
+ const [isLoading, setIsLoading] = useState(Boolean(sessionId));
36
+ const [error, setError] = useState<Error>();
37
+
38
+ useEffect(() => {
39
+ if (!sessionId) {
40
+ setState(initialCopilotUiState);
41
+ setIsLoading(false);
42
+
43
+ return;
44
+ }
45
+
46
+ const abort = new AbortController();
47
+ let nextIndex = 0;
48
+ setState(initialCopilotUiState);
49
+ setIsLoading(true);
50
+ setError(undefined);
51
+
52
+ const apply = (event: CopilotSessionEvent) => {
53
+ nextIndex = Math.max(nextIndex, getCopilotEventIndex(event) + 1);
54
+ if (event.relationship) onRelationship?.(event.relationship.sessionId);
55
+ setState((current) => reduceCopilotEvent(current, event));
56
+ };
57
+
58
+ const replay = async (startIndex = 0): Promise<void> => {
59
+ const output = await copilotClient.send(new GetSessionEventsCommand({sessionId, startIndex, limit: PAGE_LIMIT}), {
60
+ abortSignal: abort.signal,
61
+ });
62
+
63
+ for (const event of output.events ?? []) {
64
+ apply(event);
65
+ }
66
+
67
+ if (output.nextStartIndex != null && !abort.signal.aborted) {
68
+ await replay(output.nextStartIndex);
69
+ }
70
+ };
71
+
72
+ void (async () => {
73
+ try {
74
+ await replay();
75
+ setIsLoading(false);
76
+
77
+ if (live && streamEvents && !abort.signal.aborted) {
78
+ for await (const event of streamEvents(sessionId, nextIndex, abort.signal)) apply(event);
79
+ }
80
+ } catch (cause) {
81
+ if (!abort.signal.aborted) {
82
+ setError(cause instanceof Error ? cause : new Error(String(cause)));
83
+ onError?.(cause);
84
+ }
85
+ } finally {
86
+ if (!abort.signal.aborted) setIsLoading(false);
87
+ }
88
+ })();
89
+
90
+ return () => abort.abort();
91
+ }, [copilotClient, live, onError, onRelationship, sessionId, streamEvents]);
92
+
93
+ return {state, isLoading, error};
94
+ }
package/dist/hooks.d.ts DELETED
@@ -1,119 +0,0 @@
1
- import { type WilmaAssistantClient } from '@wildix/wilma-assistant-client';
2
- import { type CopilotAlert, type CopilotRelationshipHandle, type CopilotSessionStreamHandle, type CopilotSmartActionEntry, type CopilotUiState } from '@wildix/wilma-copilot-core';
3
- import { type CopilotContextLookup, type CopilotSessionEvent, type CopilotSessionSummary, type WilmaCopilotSessionsClient } from '@wildix/wilma-copilot-sessions-client';
4
- export interface CopilotDependencies {
5
- copilotClient: WilmaCopilotSessionsClient;
6
- onError?: (error: unknown) => void;
7
- }
8
- export interface UseCopilotRelationshipOptions extends CopilotDependencies {
9
- lookup?: CopilotContextLookup;
10
- enabled?: boolean;
11
- sessionsLimit?: number;
12
- }
13
- export declare function useCopilotRelationship({ copilotClient, lookup, enabled, sessionsLimit, onError, }: UseCopilotRelationshipOptions): CopilotRelationshipHandle;
14
- export type CopilotEventStream = (sessionId: string, startIndex: number, signal: AbortSignal) => AsyncIterable<CopilotSessionEvent>;
15
- export interface UseCopilotSessionStreamOptions extends CopilotDependencies {
16
- sessionId?: string;
17
- live?: boolean;
18
- streamEvents?: CopilotEventStream;
19
- onRelationship?: (sessionId: string | undefined) => void;
20
- }
21
- export declare function useCopilotSessionStream({ copilotClient, sessionId, live, streamEvents, onRelationship, onError, }: UseCopilotSessionStreamOptions): CopilotSessionStreamHandle;
22
- export interface UseCopilotAskOptions extends CopilotDependencies {
23
- assistantClient: WilmaAssistantClient;
24
- copilotSessionId?: string;
25
- }
26
- export declare function useCopilotAsk({ assistantClient, copilotClient, copilotSessionId, onError }: UseCopilotAskOptions): {
27
- ask: (question: string) => Promise<string | undefined>;
28
- isAsking: boolean;
29
- };
30
- export interface UseCopilotActionsOptions extends CopilotDependencies {
31
- sessionId?: string;
32
- /**
33
- * Opens the URL of an `openUrl` smart action. Navigation belongs to the host, so the
34
- * SDK reports the invocation and leaves the window to the app.
35
- */
36
- onOpenUrl?: (url: string, openInNewTab: boolean) => void;
37
- }
38
- export interface CopilotActionsHandle {
39
- /** Keys of the smart actions this client already invoked, for the muted styling. */
40
- usedKeys: ReadonlySet<string>;
41
- runSmartAction: (entry: CopilotSmartActionEntry) => Promise<void>;
42
- searchKnowledge: (questionId: string, question?: string) => Promise<void>;
43
- }
44
- /**
45
- * The two members of `CopilotClientAction`. Both are accepted into the session mailbox,
46
- * so the outcome arrives as an `action` event rather than from the call itself.
47
- */
48
- export declare function useCopilotActions({ copilotClient, sessionId, onOpenUrl, onError, }: UseCopilotActionsOptions): CopilotActionsHandle;
49
- export interface UseCopilotAlertsOptions {
50
- state: CopilotUiState;
51
- /** True while recorded events are replaying. Those are history, and history never alerts. */
52
- isLoading?: boolean;
53
- /** Called once per batch of alerts that arrived live, oldest first. */
54
- onAlert?: (alerts: CopilotAlert[]) => void;
55
- }
56
- export interface CopilotAlertsHandle {
57
- /** Alerts seen since the last `clear`, oldest first. Drives an unread badge. */
58
- unseen: CopilotAlert[];
59
- clear: () => void;
60
- }
61
- /**
62
- * Watches a session for the few things worth interrupting for (`collectCopilotAlerts`).
63
- *
64
- * The point of the hook is the baseline. A session is rehydrated by replaying its
65
- * recorded events, so a panel opened next to a call that has been running for ten
66
- * minutes sees every earlier detection arrive at once — and firing a notification for
67
- * each would be both wrong and unbearable. Everything present when the stream settles
68
- * is therefore marked seen without alerting, and only what arrives afterwards is news.
69
- */
70
- export declare function useCopilotAlerts({ state, isLoading, onAlert }: UseCopilotAlertsOptions): CopilotAlertsHandle;
71
- export type CopilotPanelView =
72
- /** The session the panel opened on: guidance, smart actions and the composer. */
73
- {
74
- kind: 'live';
75
- } | {
76
- kind: 'history';
77
- }
78
- /** An earlier session from the history, read-only. */
79
- | {
80
- kind: 'session';
81
- sessionId: string;
82
- }
83
- /** The transcript of `sessionId`, or of the live session when it is absent. */
84
- | {
85
- kind: 'transcript';
86
- sessionId?: string;
87
- };
88
- export interface CopilotPanelViewHandle {
89
- view: CopilotPanelView;
90
- /** The session the current view is about, if it is about one. */
91
- sessionId: string | undefined;
92
- openHistory: () => void;
93
- openSession: (sessionId: string) => void;
94
- openTranscript: (sessionId?: string) => void;
95
- /** Returns to the view that opened this one, and to the live view from the root. */
96
- back: () => void;
97
- goLive: () => void;
98
- }
99
- /**
100
- * Which view the panel is showing, as a stack.
101
- *
102
- * A stack rather than a flag because the views nest: history opens a session, a session
103
- * opens its transcript, and every back step has to land where the reader came from
104
- * rather than dropping them at the live session.
105
- *
106
- * `initialView` opens the panel on that view with the live one beneath it, so a deep
107
- * link into the history still has somewhere to go back to.
108
- */
109
- export declare function useCopilotPanelView(initialView?: CopilotPanelView): CopilotPanelViewHandle;
110
- export declare function useCopilotRecentSessions(options: CopilotDependencies & {
111
- enabled?: boolean;
112
- limit?: number;
113
- }): {
114
- sessions: CopilotSessionSummary[];
115
- isLoading: boolean;
116
- error?: Error;
117
- refresh: () => void;
118
- };
119
- //# sourceMappingURL=hooks.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAEA,OAAO,EAAsB,KAAK,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AAC9F,OAAO,EAGL,KAAK,YAAY,EACjB,KAAK,yBAAyB,EAC9B,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,EAC5B,KAAK,cAAc,EAMpB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAGL,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAM1B,KAAK,0BAA0B,EAChC,MAAM,uCAAuC,CAAC;AAI/C,MAAM,WAAW,mBAAmB;IAClC,aAAa,EAAE,0BAA0B,CAAC;IAC1C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,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IAAC,IAAI,EAAE,YAAY,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAC,CAAC;AAE7C,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,gBAAgB,CAAC;IACvB,iEAAiE;IACjE,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,WAAW,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,cAAc,EAAE,CAAC,SAAS,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,oFAAoF;IACpF,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AAID;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,CAAC,EAAE,gBAAgB,GAAG,sBAAsB,CAgB1F;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,mBAAmB,GAAG;IAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAC,GAAG;IAC5G,QAAQ,EAAE,qBAAqB,EAAE,CAAC;IAClC,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAgCA"}
package/dist/hooks.js DELETED
@@ -1,282 +0,0 @@
1
- import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
2
- import { StartSessionCommand } from '@wildix/wilma-assistant-client';
3
- import { asRecord, collectCopilotAlerts, getCopilotEventIndex, getSmartActionType, initialCopilotUiState, reduceCopilotEvent, sortSessionsRecentFirst, } from '@wildix/wilma-copilot-core';
4
- import { ActCommand, AskCommand, EnrichCommand, GetSessionEventsCommand, ListRelationshipSessionsCommand, ListSessionsCommand, OpenCommand, } from '@wildix/wilma-copilot-sessions-client';
5
- const PAGE_LIMIT = 1000;
6
- function lookupKey(lookup) {
7
- return JSON.stringify(lookup ?? {});
8
- }
9
- export function useCopilotRelationship({ copilotClient, lookup, enabled = true, sessionsLimit = 50, onError, }) {
10
- const [relationshipId, setRelationshipId] = useState();
11
- const [defaultSessionId, setDefaultSessionId] = useState();
12
- const [sessions, setSessions] = useState([]);
13
- const [isLoading, setIsLoading] = useState(enabled);
14
- const [error, setError] = useState();
15
- const [attempt, setAttempt] = useState(0);
16
- const relationshipRef = useRef(undefined);
17
- const openedLookupRef = useRef(undefined);
18
- relationshipRef.current = relationshipId;
19
- const loadSessions = useCallback(async (id, signal) => {
20
- const result = await copilotClient.send(new ListRelationshipSessionsCommand({ relationshipId: id, limit: sessionsLimit }), signal ? { abortSignal: signal } : undefined);
21
- if (!signal?.aborted)
22
- setSessions(sortSessionsRecentFirst(result.sessions ?? []));
23
- }, [copilotClient, sessionsLimit]);
24
- const refresh = useCallback(() => {
25
- if (relationshipRef.current)
26
- void loadSessions(relationshipRef.current).catch(onError);
27
- }, [loadSessions, onError]);
28
- const retry = useCallback(() => {
29
- setError(undefined);
30
- setAttempt((value) => value + 1);
31
- }, []);
32
- useEffect(() => {
33
- if (!enabled)
34
- return;
35
- const abort = new AbortController();
36
- setIsLoading(true);
37
- void (async () => {
38
- try {
39
- const result = await copilotClient.send(new OpenCommand({ lookup }), { abortSignal: abort.signal });
40
- if (abort.signal.aborted)
41
- return;
42
- openedLookupRef.current = lookupKey(lookup);
43
- setRelationshipId(result.relationshipId);
44
- setDefaultSessionId(result.session.id);
45
- await loadSessions(result.relationshipId, abort.signal);
46
- setError(undefined);
47
- }
48
- catch (cause) {
49
- if (!abort.signal.aborted) {
50
- const next = cause instanceof Error ? cause : new Error(String(cause));
51
- setError(next);
52
- onError?.(cause);
53
- }
54
- }
55
- finally {
56
- if (!abort.signal.aborted)
57
- setIsLoading(false);
58
- }
59
- })();
60
- return () => abort.abort();
61
- }, [attempt, copilotClient, enabled, loadSessions, onError]);
62
- const key = lookupKey(lookup);
63
- useEffect(() => {
64
- const currentId = relationshipRef.current;
65
- if (!enabled || !currentId || openedLookupRef.current === undefined || openedLookupRef.current === key)
66
- return;
67
- openedLookupRef.current = key;
68
- void copilotClient
69
- .send(new EnrichCommand({ relationshipId: currentId, lookup: lookup }))
70
- .then((result) => {
71
- setRelationshipId(result.relationshipId);
72
- setSessions(sortSessionsRecentFirst(result.related ?? []));
73
- })
74
- .catch(onError);
75
- }, [copilotClient, enabled, key, lookup, onError]);
76
- return { relationshipId, sessions, defaultSessionId, isLoading, error, retry, refresh };
77
- }
78
- export function useCopilotSessionStream({ copilotClient, sessionId, live = true, streamEvents, onRelationship, onError, }) {
79
- const [state, setState] = useState(initialCopilotUiState);
80
- const [isLoading, setIsLoading] = useState(Boolean(sessionId));
81
- const [error, setError] = useState();
82
- useEffect(() => {
83
- if (!sessionId) {
84
- setState(initialCopilotUiState);
85
- setIsLoading(false);
86
- return;
87
- }
88
- const abort = new AbortController();
89
- let nextIndex = 0;
90
- setState(initialCopilotUiState);
91
- setIsLoading(true);
92
- setError(undefined);
93
- const apply = (event) => {
94
- nextIndex = Math.max(nextIndex, getCopilotEventIndex(event) + 1);
95
- if (event.relationship)
96
- onRelationship?.(event.relationship.sessionId);
97
- setState((current) => reduceCopilotEvent(current, event));
98
- };
99
- const replay = async (startIndex = 0) => {
100
- const output = await copilotClient.send(new GetSessionEventsCommand({ sessionId, startIndex, limit: PAGE_LIMIT }), {
101
- abortSignal: abort.signal,
102
- });
103
- for (const event of output.events ?? []) {
104
- apply(event);
105
- }
106
- if (output.nextStartIndex != null && !abort.signal.aborted) {
107
- await replay(output.nextStartIndex);
108
- }
109
- };
110
- void (async () => {
111
- try {
112
- await replay();
113
- setIsLoading(false);
114
- if (live && streamEvents && !abort.signal.aborted) {
115
- for await (const event of streamEvents(sessionId, nextIndex, abort.signal))
116
- apply(event);
117
- }
118
- }
119
- catch (cause) {
120
- if (!abort.signal.aborted) {
121
- setError(cause instanceof Error ? cause : new Error(String(cause)));
122
- onError?.(cause);
123
- }
124
- }
125
- finally {
126
- if (!abort.signal.aborted)
127
- setIsLoading(false);
128
- }
129
- })();
130
- return () => abort.abort();
131
- }, [copilotClient, live, onError, onRelationship, sessionId, streamEvents]);
132
- return { state, isLoading, error };
133
- }
134
- export function useCopilotAsk({ assistantClient, copilotClient, copilotSessionId, onError }) {
135
- const [isAsking, setIsAsking] = useState(false);
136
- const ask = useCallback(async (question) => {
137
- const message = question.trim();
138
- if (!message || !copilotSessionId)
139
- return undefined;
140
- setIsAsking(true);
141
- try {
142
- const started = await assistantClient.send(new StartSessionCommand({
143
- message,
144
- visibility: 'hidden',
145
- target: `copilot://sessions/${copilotSessionId}`,
146
- }));
147
- await copilotClient.send(new AskCommand({ sessionId: copilotSessionId, wilmaSessionId: started.sessionId }));
148
- return started.sessionId;
149
- }
150
- catch (cause) {
151
- onError?.(cause);
152
- throw cause;
153
- }
154
- finally {
155
- setIsAsking(false);
156
- }
157
- }, [assistantClient, copilotClient, copilotSessionId, onError]);
158
- return { ask, isAsking };
159
- }
160
- /**
161
- * The two members of `CopilotClientAction`. Both are accepted into the session mailbox,
162
- * so the outcome arrives as an `action` event rather than from the call itself.
163
- */
164
- export function useCopilotActions({ copilotClient, sessionId, onOpenUrl, onError, }) {
165
- const [usedKeys, setUsedKeys] = useState(new Set());
166
- const runSmartAction = useCallback(async (entry) => {
167
- const type = getSmartActionType(entry.action);
168
- if (!type || !sessionId)
169
- return;
170
- setUsedKeys((current) => new Set(current).add(entry.key));
171
- if (type === 'openUrl') {
172
- const { url, openInNewTab } = asRecord(entry.action.openUrl);
173
- if (typeof url === 'string' && url)
174
- onOpenUrl?.(url, openInNewTab !== false);
175
- }
176
- try {
177
- await copilotClient.send(new ActCommand({ sessionId, action: { smartAction: { assetId: entry.assetId, actionId: entry.itemId } } }));
178
- }
179
- catch (cause) {
180
- onError?.(cause);
181
- }
182
- }, [copilotClient, onError, onOpenUrl, sessionId]);
183
- const searchKnowledge = useCallback(async (questionId, question) => {
184
- if (!sessionId)
185
- return;
186
- try {
187
- await copilotClient.send(new ActCommand({ sessionId, action: { knowledgeSearch: { questionId, question } } }));
188
- }
189
- catch (cause) {
190
- onError?.(cause);
191
- }
192
- }, [copilotClient, onError, sessionId]);
193
- return { usedKeys, runSmartAction, searchKnowledge };
194
- }
195
- /**
196
- * Watches a session for the few things worth interrupting for (`collectCopilotAlerts`).
197
- *
198
- * The point of the hook is the baseline. A session is rehydrated by replaying its
199
- * recorded events, so a panel opened next to a call that has been running for ten
200
- * minutes sees every earlier detection arrive at once — and firing a notification for
201
- * each would be both wrong and unbearable. Everything present when the stream settles
202
- * is therefore marked seen without alerting, and only what arrives afterwards is news.
203
- */
204
- export function useCopilotAlerts({ state, isLoading = false, onAlert }) {
205
- const [unseen, setUnseen] = useState([]);
206
- const alerts = useMemo(() => collectCopilotAlerts(state), [state]);
207
- const seenRef = useRef(new Set());
208
- const settledRef = useRef(false);
209
- useEffect(() => {
210
- const fresh = alerts.filter((alert) => !seenRef.current.has(alert.key));
211
- for (const alert of fresh)
212
- seenRef.current.add(alert.key);
213
- if (!settledRef.current) {
214
- settledRef.current = !isLoading;
215
- return;
216
- }
217
- if (fresh.length === 0)
218
- return;
219
- setUnseen((current) => [...current, ...fresh]);
220
- onAlert?.(fresh);
221
- }, [alerts, isLoading, onAlert]);
222
- return { unseen, clear: useCallback(() => setUnseen([]), []) };
223
- }
224
- const LIVE_VIEW = { kind: 'live' };
225
- /**
226
- * Which view the panel is showing, as a stack.
227
- *
228
- * A stack rather than a flag because the views nest: history opens a session, a session
229
- * opens its transcript, and every back step has to land where the reader came from
230
- * rather than dropping them at the live session.
231
- *
232
- * `initialView` opens the panel on that view with the live one beneath it, so a deep
233
- * link into the history still has somewhere to go back to.
234
- */
235
- export function useCopilotPanelView(initialView) {
236
- const [stack, setStack] = useState(() => initialView && initialView.kind !== 'live' ? [LIVE_VIEW, initialView] : [LIVE_VIEW]);
237
- const view = stack[stack.length - 1] ?? LIVE_VIEW;
238
- const push = useCallback((next) => setStack((current) => [...current, next]), []);
239
- return {
240
- view,
241
- sessionId: view.kind === 'session' ? view.sessionId : view.kind === 'transcript' ? view.sessionId : undefined,
242
- openHistory: useCallback(() => push({ kind: 'history' }), [push]),
243
- openSession: useCallback((sessionId) => push({ kind: 'session', sessionId }), [push]),
244
- openTranscript: useCallback((sessionId) => push({ kind: 'transcript', sessionId }), [push]),
245
- back: useCallback(() => setStack((current) => (current.length > 1 ? current.slice(0, -1) : current)), []),
246
- goLive: useCallback(() => setStack([LIVE_VIEW]), []),
247
- };
248
- }
249
- export function useCopilotRecentSessions(options) {
250
- const { copilotClient, enabled = true, limit = 20, onError } = options;
251
- const [sessions, setSessions] = useState([]);
252
- const [isLoading, setIsLoading] = useState(enabled);
253
- const [error, setError] = useState();
254
- const [nonce, setNonce] = useState(0);
255
- useEffect(() => {
256
- if (!enabled)
257
- return;
258
- let cancelled = false;
259
- setIsLoading(true);
260
- void copilotClient
261
- .send(new ListSessionsCommand({ limit }))
262
- .then((result) => {
263
- if (!cancelled)
264
- setSessions(sortSessionsRecentFirst(result.sessions ?? []));
265
- })
266
- .catch((cause) => {
267
- if (!cancelled) {
268
- setError(cause instanceof Error ? cause : new Error(String(cause)));
269
- onError?.(cause);
270
- }
271
- })
272
- .finally(() => {
273
- if (!cancelled)
274
- setIsLoading(false);
275
- });
276
- return () => {
277
- cancelled = true;
278
- };
279
- }, [copilotClient, enabled, limit, nonce, onError]);
280
- return { sessions, isLoading, error, refresh: () => setNonce((value) => value + 1) };
281
- }
282
- //# sourceMappingURL=hooks.js.map
package/dist/hooks.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAExE,OAAO,EAAC,mBAAmB,EAA4B,MAAM,gCAAgC,CAAC;AAC9F,OAAO,EACL,QAAQ,EACR,oBA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