@wildix/wilma-copilot-headless 0.1.0 → 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.
- package/dist/hooks/CopilotSessionStreamSlot.d.ts +18 -0
- package/dist/hooks/CopilotSessionStreamSlot.d.ts.map +1 -0
- package/dist/hooks/CopilotSessionStreamSlot.js +20 -0
- package/dist/hooks/CopilotSessionStreamSlot.js.map +1 -0
- package/dist/hooks/index.d.ts +10 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +10 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/shared.d.ts +8 -0
- package/dist/hooks/shared.d.ts.map +1 -0
- package/dist/hooks/shared.js +5 -0
- package/dist/hooks/shared.js.map +1 -0
- package/dist/hooks/useCopilotActions.d.ts +36 -0
- package/dist/hooks/useCopilotActions.d.ts.map +1 -0
- package/dist/hooks/useCopilotActions.js +64 -0
- package/dist/hooks/useCopilotActions.js.map +1 -0
- package/dist/hooks/useCopilotAlerts.d.ts +24 -0
- package/dist/hooks/useCopilotAlerts.d.ts.map +1 -0
- package/dist/hooks/useCopilotAlerts.js +32 -0
- package/dist/hooks/useCopilotAlerts.js.map +1 -0
- package/dist/hooks/useCopilotAsk.d.ts +11 -0
- package/dist/hooks/useCopilotAsk.d.ts.map +1 -0
- package/dist/hooks/useCopilotAsk.js +31 -0
- package/dist/hooks/useCopilotAsk.js.map +1 -0
- package/dist/hooks/useCopilotPanelView.d.ts +48 -0
- package/dist/hooks/useCopilotPanelView.d.ts.map +1 -0
- package/dist/hooks/useCopilotPanelView.js +41 -0
- package/dist/hooks/useCopilotPanelView.js.map +1 -0
- package/dist/hooks/useCopilotRecentSessions.d.ts +12 -0
- package/dist/hooks/useCopilotRecentSessions.d.ts.map +1 -0
- package/dist/hooks/useCopilotRecentSessions.js +38 -0
- package/dist/hooks/useCopilotRecentSessions.js.map +1 -0
- package/dist/hooks/useCopilotRelationship.d.ts +10 -0
- package/dist/hooks/useCopilotRelationship.d.ts.map +1 -0
- package/dist/hooks/useCopilotRelationship.js +74 -0
- package/dist/hooks/useCopilotRelationship.js.map +1 -0
- package/dist/hooks/useCopilotSessionStream.d.ts +12 -0
- package/dist/hooks/useCopilotSessionStream.d.ts.map +1 -0
- package/dist/hooks/useCopilotSessionStream.js +61 -0
- package/dist/hooks/useCopilotSessionStream.js.map +1 -0
- package/package.json +14 -14
- package/src/hooks/CopilotSessionStreamSlot.tsx +28 -0
- package/src/hooks/index.ts +9 -0
- package/src/hooks/shared.ts +12 -0
- package/src/hooks/useCopilotActions.ts +115 -0
- package/src/hooks/useCopilotAlerts.ts +50 -0
- package/src/hooks/useCopilotAsk.ts +46 -0
- package/src/hooks/useCopilotPanelView.ts +84 -0
- package/src/hooks/useCopilotRecentSessions.ts +45 -0
- package/src/hooks/useCopilotRelationship.ts +102 -0
- package/src/hooks/useCopilotSessionStream.ts +94 -0
- package/dist/hooks.d.ts +0 -80
- package/dist/hooks.d.ts.map +0 -1
- package/dist/hooks.js +0 -257
- package/dist/hooks.js.map +0 -1
- package/src/hooks.ts +0 -406
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type ReactElement, type ReactNode } from 'react';
|
|
2
|
+
import type { CopilotSessionStreamHandle } from '@wildix/wilma-copilot-core';
|
|
3
|
+
import { type UseCopilotSessionStreamOptions } from './useCopilotSessionStream';
|
|
4
|
+
export interface CopilotSessionStreamSlotProps extends UseCopilotSessionStreamOptions {
|
|
5
|
+
children: (handle: CopilotSessionStreamHandle) => ReactNode;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Runs `useCopilotSessionStream` for one included session and hands the result to
|
|
9
|
+
* `children`.
|
|
10
|
+
*
|
|
11
|
+
* Hooks cannot be called in a loop, and an "included" session list is exactly that — an
|
|
12
|
+
* array whose length changes at runtime. Rendering one of these per included session id
|
|
13
|
+
* gives each its own stream and its own component identity, so React (not a manual map
|
|
14
|
+
* of subscriptions) is what starts and tears them down as sessions are included and
|
|
15
|
+
* removed.
|
|
16
|
+
*/
|
|
17
|
+
export declare function CopilotSessionStreamSlot({ children, ...options }: CopilotSessionStreamSlotProps): ReactElement;
|
|
18
|
+
//# sourceMappingURL=CopilotSessionStreamSlot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CopilotSessionStreamSlot.d.ts","sourceRoot":"","sources":["../../src/hooks/CopilotSessionStreamSlot.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA0B,KAAK,YAAY,EAAE,KAAK,SAAS,EAAC,MAAM,OAAO,CAAC;AAEjF,OAAO,KAAK,EAAC,0BAA0B,EAAC,MAAM,4BAA4B,CAAC;AAE3E,OAAO,EAA0B,KAAK,8BAA8B,EAAC,MAAM,2BAA2B,CAAC;AAEvG,MAAM,WAAW,6BAA8B,SAAQ,8BAA8B;IACnF,QAAQ,EAAE,CAAC,MAAM,EAAE,0BAA0B,KAAK,SAAS,CAAC;CAC7D;AAED;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CAAC,EAAC,QAAQ,EAAE,GAAG,OAAO,EAAC,EAAE,6BAA6B,GAAG,YAAY,CAO5G"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createElement, Fragment } from 'react';
|
|
2
|
+
import { useCopilotSessionStream } from './useCopilotSessionStream';
|
|
3
|
+
/**
|
|
4
|
+
* Runs `useCopilotSessionStream` for one included session and hands the result to
|
|
5
|
+
* `children`.
|
|
6
|
+
*
|
|
7
|
+
* Hooks cannot be called in a loop, and an "included" session list is exactly that — an
|
|
8
|
+
* array whose length changes at runtime. Rendering one of these per included session id
|
|
9
|
+
* gives each its own stream and its own component identity, so React (not a manual map
|
|
10
|
+
* of subscriptions) is what starts and tears them down as sessions are included and
|
|
11
|
+
* removed.
|
|
12
|
+
*/
|
|
13
|
+
export function CopilotSessionStreamSlot({ children, ...options }) {
|
|
14
|
+
const handle = useCopilotSessionStream(options);
|
|
15
|
+
// `createElement` rather than JSX: this package ships `.ts` sources with no JSX
|
|
16
|
+
// transform configured, and a bare fragment is the only wrapper a "returns whatever
|
|
17
|
+
// `children` produced" component needs.
|
|
18
|
+
return createElement(Fragment, null, children(handle));
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=CopilotSessionStreamSlot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CopilotSessionStreamSlot.js","sourceRoot":"","sources":["../../src/hooks/CopilotSessionStreamSlot.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAE,QAAQ,EAAoC,MAAM,OAAO,CAAC;AAIjF,OAAO,EAAC,uBAAuB,EAAsC,MAAM,2BAA2B,CAAC;AAMvG;;;;;;;;;GASG;AACH,MAAM,UAAU,wBAAwB,CAAC,EAAC,QAAQ,EAAE,GAAG,OAAO,EAAgC;IAC5F,MAAM,MAAM,GAAG,uBAAuB,CAAC,OAAO,CAAC,CAAC;IAEhD,gFAAgF;IAChF,oFAAoF;IACpF,wCAAwC;IACxC,OAAO,aAAa,CAAC,QAAQ,EAAE,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;AACzD,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './CopilotSessionStreamSlot';
|
|
2
|
+
export * from './shared';
|
|
3
|
+
export * from './useCopilotActions';
|
|
4
|
+
export * from './useCopilotAlerts';
|
|
5
|
+
export * from './useCopilotAsk';
|
|
6
|
+
export * from './useCopilotPanelView';
|
|
7
|
+
export * from './useCopilotRecentSessions';
|
|
8
|
+
export * from './useCopilotRelationship';
|
|
9
|
+
export * from './useCopilotSessionStream';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './CopilotSessionStreamSlot';
|
|
2
|
+
export * from './shared';
|
|
3
|
+
export * from './useCopilotActions';
|
|
4
|
+
export * from './useCopilotAlerts';
|
|
5
|
+
export * from './useCopilotAsk';
|
|
6
|
+
export * from './useCopilotPanelView';
|
|
7
|
+
export * from './useCopilotRecentSessions';
|
|
8
|
+
export * from './useCopilotRelationship';
|
|
9
|
+
export * from './useCopilotSessionStream';
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CopilotContextLookup, WilmaCopilotSessionsClient } from '@wildix/wilma-copilot-sessions-client';
|
|
2
|
+
export declare const PAGE_LIMIT = 1000;
|
|
3
|
+
export interface CopilotDependencies {
|
|
4
|
+
copilotClient: WilmaCopilotSessionsClient;
|
|
5
|
+
onError?: (error: unknown) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare function lookupKey(lookup: CopilotContextLookup | undefined): string;
|
|
8
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/hooks/shared.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,oBAAoB,EAAE,0BAA0B,EAAC,MAAM,uCAAuC,CAAC;AAE5G,eAAO,MAAM,UAAU,OAAO,CAAC;AAE/B,MAAM,WAAW,mBAAmB;IAClC,aAAa,EAAE,0BAA0B,CAAC;IAC1C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACpC;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE,oBAAoB,GAAG,SAAS,GAAG,MAAM,CAE1E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/hooks/shared.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC;AAO/B,MAAM,UAAU,SAAS,CAAC,MAAwC;IAChE,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type CopilotSmartActionEntry } from '@wildix/wilma-copilot-core';
|
|
2
|
+
import { type CopilotDependencies } from './shared';
|
|
3
|
+
export interface UseCopilotActionsOptions extends CopilotDependencies {
|
|
4
|
+
sessionId?: string;
|
|
5
|
+
/**
|
|
6
|
+
* Opens the URL of an `openUrl` smart action. Navigation belongs to the host, so the
|
|
7
|
+
* SDK reports the invocation and leaves the window to the app.
|
|
8
|
+
*/
|
|
9
|
+
onOpenUrl?: (url: string, openInNewTab: boolean) => void;
|
|
10
|
+
}
|
|
11
|
+
/** Playbook progress the agent made by hand, as `Act` takes it. */
|
|
12
|
+
export interface CopilotPlaybookProgress {
|
|
13
|
+
/** Steps the agent ticked. Append-only server-side, so re-sending an id is a no-op. */
|
|
14
|
+
stepIds?: readonly string[];
|
|
15
|
+
/** Marks the whole playbook complete. Honoured only while the view reports `canMarkComplete`. */
|
|
16
|
+
complete?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface CopilotActionsHandle {
|
|
19
|
+
/** Keys of the smart actions this client already invoked, for the muted styling. */
|
|
20
|
+
usedKeys: ReadonlySet<string>;
|
|
21
|
+
/**
|
|
22
|
+
* Runs a suggestion against `sessionId`, or against `overrideSessionId` when it came
|
|
23
|
+
* from another session. A panel showing included sessions offers their actions too,
|
|
24
|
+
* and an action belongs to the session that suggested it, not to the one in focus.
|
|
25
|
+
*/
|
|
26
|
+
runSmartAction: (entry: CopilotSmartActionEntry, overrideSessionId?: string) => Promise<void>;
|
|
27
|
+
searchKnowledge: (questionId: string, question?: string) => Promise<void>;
|
|
28
|
+
markPlaybookProgress: (assetId: string, progress: CopilotPlaybookProgress) => Promise<void>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The three members of `CopilotClientAction`. All are accepted into the session mailbox, so the
|
|
32
|
+
* outcome arrives as an `action` event and — for a playbook tick or a knowledge answer — as the
|
|
33
|
+
* asset re-emitted under its own id, rather than from the call itself.
|
|
34
|
+
*/
|
|
35
|
+
export declare function useCopilotActions({ copilotClient, sessionId, onOpenUrl, onError, }: UseCopilotActionsOptions): CopilotActionsHandle;
|
|
36
|
+
//# sourceMappingURL=useCopilotActions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCopilotActions.d.ts","sourceRoot":"","sources":["../../src/hooks/useCopilotActions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAW,KAAK,uBAAuB,EAAqB,MAAM,4BAA4B,CAAC;AAGtG,OAAO,EAAC,KAAK,mBAAmB,EAAC,MAAM,UAAU,CAAC;AAElD,MAAM,WAAW,wBAAyB,SAAQ,mBAAmB;IACnE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,KAAK,IAAI,CAAC;CAC1D;AAED,mEAAmE;AACnE,MAAM,WAAW,uBAAuB;IACtC,uFAAuF;IACvF,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B,iGAAiG;IACjG,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,oBAAoB;IACnC,oFAAoF;IACpF,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC9B;;;;OAIG;IACH,cAAc,EAAE,CAAC,KAAK,EAAE,uBAAuB,EAAE,iBAAiB,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9F,eAAe,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1E,oBAAoB,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,uBAAuB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7F;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,aAAa,EACb,SAAS,EACT,SAAS,EACT,OAAO,GACR,EAAE,wBAAwB,GAAG,oBAAoB,CAmEjD"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { useCallback, useState } from 'react';
|
|
2
|
+
import { asRecord, getSmartActionType } from '@wildix/wilma-copilot-core';
|
|
3
|
+
import { ActCommand } from '@wildix/wilma-copilot-sessions-client';
|
|
4
|
+
import {} from './shared';
|
|
5
|
+
/**
|
|
6
|
+
* The three members of `CopilotClientAction`. All are accepted into the session mailbox, so the
|
|
7
|
+
* outcome arrives as an `action` event and — for a playbook tick or a knowledge answer — as the
|
|
8
|
+
* asset re-emitted under its own id, rather than from the call itself.
|
|
9
|
+
*/
|
|
10
|
+
export function useCopilotActions({ copilotClient, sessionId, onOpenUrl, onError, }) {
|
|
11
|
+
const [usedKeys, setUsedKeys] = useState(new Set());
|
|
12
|
+
const runSmartAction = useCallback(async (entry, overrideSessionId) => {
|
|
13
|
+
const type = getSmartActionType(entry.action);
|
|
14
|
+
const target = overrideSessionId ?? sessionId;
|
|
15
|
+
if (!type || !target)
|
|
16
|
+
return;
|
|
17
|
+
setUsedKeys((current) => new Set(current).add(entry.key));
|
|
18
|
+
if (type === 'openUrl') {
|
|
19
|
+
const { url, openInNewTab } = asRecord(entry.action.openUrl);
|
|
20
|
+
if (typeof url === 'string' && url)
|
|
21
|
+
onOpenUrl?.(url, openInNewTab !== false);
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
await copilotClient.send(new ActCommand({
|
|
25
|
+
sessionId: target,
|
|
26
|
+
action: { smartAction: { assetId: entry.assetId, actionId: entry.itemId } },
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
catch (cause) {
|
|
30
|
+
onError?.(cause);
|
|
31
|
+
}
|
|
32
|
+
}, [copilotClient, onError, onOpenUrl, sessionId]);
|
|
33
|
+
const searchKnowledge = useCallback(async (questionId, question) => {
|
|
34
|
+
if (!sessionId)
|
|
35
|
+
return;
|
|
36
|
+
try {
|
|
37
|
+
await copilotClient.send(new ActCommand({ sessionId, action: { knowledgeSearch: { questionId, question } } }));
|
|
38
|
+
}
|
|
39
|
+
catch (cause) {
|
|
40
|
+
onError?.(cause);
|
|
41
|
+
}
|
|
42
|
+
}, [copilotClient, onError, sessionId]);
|
|
43
|
+
const markPlaybookProgress = useCallback(async (assetId, { stepIds, complete }) => {
|
|
44
|
+
if (!sessionId)
|
|
45
|
+
return;
|
|
46
|
+
try {
|
|
47
|
+
await copilotClient.send(new ActCommand({
|
|
48
|
+
sessionId,
|
|
49
|
+
action: {
|
|
50
|
+
playbook: {
|
|
51
|
+
assetId,
|
|
52
|
+
...(stepIds ? { stepIds: [...stepIds] } : {}),
|
|
53
|
+
...(complete === undefined ? {} : { complete }),
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
catch (cause) {
|
|
59
|
+
onError?.(cause);
|
|
60
|
+
}
|
|
61
|
+
}, [copilotClient, onError, sessionId]);
|
|
62
|
+
return { usedKeys, runSmartAction, searchKnowledge, markPlaybookProgress };
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=useCopilotActions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCopilotActions.js","sourceRoot":"","sources":["../../src/hooks/useCopilotActions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAC,QAAQ,EAAgC,kBAAkB,EAAC,MAAM,4BAA4B,CAAC;AACtG,OAAO,EAAC,UAAU,EAAC,MAAM,uCAAuC,CAAC;AAEjE,OAAO,EAA0B,MAAM,UAAU,CAAC;AAgClD;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,EAChC,aAAa,EACb,SAAS,EACT,SAAS,EACT,OAAO,GACkB;IACzB,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAsB,IAAI,GAAG,EAAE,CAAC,CAAC;IAEzE,MAAM,cAAc,GAAG,WAAW,CAChC,KAAK,EAAE,KAA8B,EAAE,iBAA0B,EAAE,EAAE;QACnE,MAAM,IAAI,GAAG,kBAAkB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC9C,MAAM,MAAM,GAAG,iBAAiB,IAAI,SAAS,CAAC;QAC9C,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM;YAAE,OAAO;QAC7B,WAAW,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;QAE1D,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,MAAM,EAAC,GAAG,EAAE,YAAY,EAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAC3D,IAAI,OAAO,GAAG,KAAK,QA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QAAQ,EAAE;wBACR,OAAO;wBACP,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAC,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC;wBAC3C,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAC,QAAQ,EAAC,CAAC;qBAC9C;iBACF;aACF,CAAC,CACH,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;QACnB,CAAC;IACH,CAAC,EACD,CAAC,aAAa,EAAE,OAAO,EAAE,SAAS,CAAC,CACpC,CAAC;IAEF,OAAO,EAAC,QAAQ,EAAE,cAAc,EAAE,eAAe,EAAE,oBAAoB,EAAC,CAAC;AAC3E,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type CopilotAlert, type CopilotUiState } from '@wildix/wilma-copilot-core';
|
|
2
|
+
export interface UseCopilotAlertsOptions {
|
|
3
|
+
state: CopilotUiState;
|
|
4
|
+
/** True while recorded events are replaying. Those are history, and history never alerts. */
|
|
5
|
+
isLoading?: boolean;
|
|
6
|
+
/** Called once per batch of alerts that arrived live, oldest first. */
|
|
7
|
+
onAlert?: (alerts: CopilotAlert[]) => void;
|
|
8
|
+
}
|
|
9
|
+
export interface CopilotAlertsHandle {
|
|
10
|
+
/** Alerts seen since the last `clear`, oldest first. Drives an unread badge. */
|
|
11
|
+
unseen: CopilotAlert[];
|
|
12
|
+
clear: () => void;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Watches a session for the few things worth interrupting for (`collectCopilotAlerts`).
|
|
16
|
+
*
|
|
17
|
+
* The point of the hook is the baseline. A session is rehydrated by replaying its
|
|
18
|
+
* recorded events, so a panel opened next to a call that has been running for ten
|
|
19
|
+
* minutes sees every earlier detection arrive at once — and firing a notification for
|
|
20
|
+
* each would be both wrong and unbearable. Everything present when the stream settles
|
|
21
|
+
* is therefore marked seen without alerting, and only what arrives afterwards is news.
|
|
22
|
+
*/
|
|
23
|
+
export declare function useCopilotAlerts({ state, isLoading, onAlert }: UseCopilotAlertsOptions): CopilotAlertsHandle;
|
|
24
|
+
//# sourceMappingURL=useCopilotAlerts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCopilotAlerts.d.ts","sourceRoot":"","sources":["../../src/hooks/useCopilotAlerts.ts"],"names":[],"mappings":"AAEA,OAAO,EAAuB,KAAK,YAAY,EAAE,KAAK,cAAc,EAAC,MAAM,4BAA4B,CAAC;AAExG,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,cAAc,CAAC;IACtB,6FAA6F;IAC7F,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,uEAAuE;IACvE,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK,IAAI,CAAC;CAC5C;AAED,MAAM,WAAW,mBAAmB;IAClC,gFAAgF;IAChF,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,EAAC,KAAK,EAAE,SAAiB,EAAE,OAAO,EAAC,EAAE,uBAAuB,GAAG,mBAAmB,CAsBlH"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
+
import { collectCopilotAlerts } from '@wildix/wilma-copilot-core';
|
|
3
|
+
/**
|
|
4
|
+
* Watches a session for the few things worth interrupting for (`collectCopilotAlerts`).
|
|
5
|
+
*
|
|
6
|
+
* The point of the hook is the baseline. A session is rehydrated by replaying its
|
|
7
|
+
* recorded events, so a panel opened next to a call that has been running for ten
|
|
8
|
+
* minutes sees every earlier detection arrive at once — and firing a notification for
|
|
9
|
+
* each would be both wrong and unbearable. Everything present when the stream settles
|
|
10
|
+
* is therefore marked seen without alerting, and only what arrives afterwards is news.
|
|
11
|
+
*/
|
|
12
|
+
export function useCopilotAlerts({ state, isLoading = false, onAlert }) {
|
|
13
|
+
const [unseen, setUnseen] = useState([]);
|
|
14
|
+
const alerts = useMemo(() => collectCopilotAlerts(state), [state]);
|
|
15
|
+
const seenRef = useRef(new Set());
|
|
16
|
+
const settledRef = useRef(false);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
const fresh = alerts.filter((alert) => !seenRef.current.has(alert.key));
|
|
19
|
+
for (const alert of fresh)
|
|
20
|
+
seenRef.current.add(alert.key);
|
|
21
|
+
if (!settledRef.current) {
|
|
22
|
+
settledRef.current = !isLoading;
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (fresh.length === 0)
|
|
26
|
+
return;
|
|
27
|
+
setUnseen((current) => [...current, ...fresh]);
|
|
28
|
+
onAlert?.(fresh);
|
|
29
|
+
}, [alerts, isLoading, onAlert]);
|
|
30
|
+
return { unseen, clear: useCallback(() => setUnseen([]), []) };
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=useCopilotAlerts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCopilotAlerts.js","sourceRoot":"","sources":["../../src/hooks/useCopilotAlerts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAExE,OAAO,EAAC,oBAAoB,EAAyC,MAAM,4BAA4B,CAAC;AAgBxG;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAAC,EAAC,KAAK,EAAE,SAAS,GAAG,KAAK,EAAE,OAAO,EAA0B;IAC3F,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAiB,EAAE,CAAC,CAAC;IACzD,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,oBAAoB,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IACnE,MAAM,OAAO,GAAG,MAAM,CAAc,IAAI,GAAG,EAAE,CAAC,CAAC;IAC/C,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAEjC,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;QACxE,KAAK,MAAM,KAAK,IAAI,KAAK;YAAE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAE1D,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;YACxB,UAAU,CAAC,OAAO,GAAG,CAAC,SAAS,CAAC;YAEhC,OAAO;QACT,CAAC;QAED,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO;QAC/B,SAAS,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC;QAC/C,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;IACnB,CAAC,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;IAEjC,OAAO,EAAC,MAAM,EAAE,KAAK,EAAE,WAAW,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,EAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type WilmaAssistantClient } from '@wildix/wilma-assistant-client';
|
|
2
|
+
import { type CopilotDependencies } from './shared';
|
|
3
|
+
export interface UseCopilotAskOptions extends CopilotDependencies {
|
|
4
|
+
assistantClient: WilmaAssistantClient;
|
|
5
|
+
copilotSessionId?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function useCopilotAsk({ assistantClient, copilotClient, copilotSessionId, onError }: UseCopilotAskOptions): {
|
|
8
|
+
ask: (question: string) => Promise<string | undefined>;
|
|
9
|
+
isAsking: boolean;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=useCopilotAsk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCopilotAsk.d.ts","sourceRoot":"","sources":["../../src/hooks/useCopilotAsk.ts"],"names":[],"mappings":"AAEA,OAAO,EAAsB,KAAK,oBAAoB,EAAC,MAAM,gCAAgC,CAAC;AAG9F,OAAO,EAAC,KAAK,mBAAmB,EAAC,MAAM,UAAU,CAAC;AAElD,MAAM,WAAW,oBAAqB,SAAQ,mBAAmB;IAC/D,eAAe,EAAE,oBAAoB,CAAC;IACtC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,wBAAgB,aAAa,CAAC,EAAC,eAAe,EAAE,aAAa,EAAE,gBAAgB,EAAE,OAAO,EAAC,EAAE,oBAAoB,GAAG;IAChH,GAAG,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IACvD,QAAQ,EAAE,OAAO,CAAC;CACnB,CA8BA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useCallback, useState } from 'react';
|
|
2
|
+
import { StartSessionCommand } from '@wildix/wilma-assistant-client';
|
|
3
|
+
import { AskCommand } from '@wildix/wilma-copilot-sessions-client';
|
|
4
|
+
import {} from './shared';
|
|
5
|
+
export function useCopilotAsk({ assistantClient, copilotClient, copilotSessionId, onError }) {
|
|
6
|
+
const [isAsking, setIsAsking] = useState(false);
|
|
7
|
+
const ask = useCallback(async (question) => {
|
|
8
|
+
const message = question.trim();
|
|
9
|
+
if (!message || !copilotSessionId)
|
|
10
|
+
return undefined;
|
|
11
|
+
setIsAsking(true);
|
|
12
|
+
try {
|
|
13
|
+
const started = await assistantClient.send(new StartSessionCommand({
|
|
14
|
+
message,
|
|
15
|
+
visibility: 'hidden',
|
|
16
|
+
target: `copilot://sessions/${copilotSessionId}`,
|
|
17
|
+
}));
|
|
18
|
+
await copilotClient.send(new AskCommand({ sessionId: copilotSessionId, wilmaSessionId: started.sessionId }));
|
|
19
|
+
return started.sessionId;
|
|
20
|
+
}
|
|
21
|
+
catch (cause) {
|
|
22
|
+
onError?.(cause);
|
|
23
|
+
throw cause;
|
|
24
|
+
}
|
|
25
|
+
finally {
|
|
26
|
+
setIsAsking(false);
|
|
27
|
+
}
|
|
28
|
+
}, [assistantClient, copilotClient, copilotSessionId, onError]);
|
|
29
|
+
return { ask, isAsking };
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=useCopilotAsk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCopilotAsk.js","sourceRoot":"","sources":["../../src/hooks/useCopilotAsk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAC,mBAAmB,EAA4B,MAAM,gCAAgC,CAAC;AAC9F,OAAO,EAAC,UAAU,EAAC,MAAM,uCAAuC,CAAC;AAEjE,OAAO,EAA0B,MAAM,UAAU,CAAC;AAOlD,MAAM,UAAU,aAAa,CAAC,EAAC,eAAe,EAAE,aAAa,EAAE,gBAAgB,EAAE,OAAO,EAAuB;IAI7G,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAChD,MAAM,GAAG,GAAG,WAAW,CACrB,KAAK,EAAE,QAAgB,EAAE,EAAE;QACzB,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC;QAChC,IAAI,CAAC,OAAO,IAAI,CAAC,gBAAgB;YAAE,OAAO,SAAS,CAAC;QACpD,WAAW,CAAC,IAAI,CAAC,CAAC;QAElB,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,eAAe,CAAC,IAAI,CACxC,IAAI,mBAAmB,CAAC;gBACtB,OAAO;gBACP,UAAU,EAAE,QAAQ;gBACpB,MAAM,EAAE,sBAAsB,gBAAgB,EAAE;aACjD,CAAC,CACH,CAAC;YACF,MAAM,aAAa,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,EAAC,SAAS,EAAE,gBAAgB,EAAE,cAAc,EAAE,OAAO,CAAC,SAAS,EAAC,CAAC,CAAC,CAAC;YAE3G,OAAO,OAAO,CAAC,SAAS,CAAC;QAC3B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;YACjB,MAAM,KAAK,CAAC;QACd,CAAC;gBAAS,CAAC;YACT,WAAW,CAAC,KAAK,CAAC,CAAC;QACrB,CAAC;IACH,CAAC,EACD,CAAC,eAAe,EAAE,aAAa,EAAE,gBAAgB,EAAE,OAAO,CAAC,CAC5D,CAAC;IAEF,OAAO,EAAC,GAAG,EAAE,QAAQ,EAAC,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export type CopilotPanelView =
|
|
2
|
+
/** The session the panel opened on: guidance, smart actions and the composer. */
|
|
3
|
+
{
|
|
4
|
+
kind: 'live';
|
|
5
|
+
} | {
|
|
6
|
+
kind: 'history';
|
|
7
|
+
}
|
|
8
|
+
/** An earlier session from the history, read-only. */
|
|
9
|
+
| {
|
|
10
|
+
kind: 'session';
|
|
11
|
+
sessionId: string;
|
|
12
|
+
};
|
|
13
|
+
export interface CopilotPanelViewHandle {
|
|
14
|
+
view: CopilotPanelView;
|
|
15
|
+
/** The session the current view is about, if it is about one. */
|
|
16
|
+
sessionId: string | undefined;
|
|
17
|
+
/** Whether transcript lines are interleaved in the live timeline. */
|
|
18
|
+
showTranscript: boolean;
|
|
19
|
+
toggleTranscript: () => void;
|
|
20
|
+
setShowTranscript: (value: boolean) => void;
|
|
21
|
+
openHistory: () => void;
|
|
22
|
+
openSession: (sessionId: string) => void;
|
|
23
|
+
/** Returns to the view that opened this one, and to the live view from the root. */
|
|
24
|
+
back: () => void;
|
|
25
|
+
goLive: () => void;
|
|
26
|
+
/**
|
|
27
|
+
* Past sessions folded into the live timeline instead of opened on their own, oldest
|
|
28
|
+
* first. History offers this as "include" beside "switch to", for pulling an earlier
|
|
29
|
+
* conversation's guidance into view without losing the current one.
|
|
30
|
+
*/
|
|
31
|
+
includedSessionIds: string[];
|
|
32
|
+
isIncluded: (sessionId: string) => boolean;
|
|
33
|
+
includeSession: (sessionId: string) => void;
|
|
34
|
+
removeIncludedSession: (sessionId: string) => void;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Which view the panel is showing, as a stack.
|
|
38
|
+
*
|
|
39
|
+
* A stack rather than a flag because the views nest: history opens a session, and every
|
|
40
|
+
* back step has to land where the reader came from rather than dropping them at the live
|
|
41
|
+
* session. Transcript lines are toggled inline on the timeline instead of opening a
|
|
42
|
+
* separate view.
|
|
43
|
+
*
|
|
44
|
+
* `initialView` opens the panel on that view with the live one beneath it, so a deep
|
|
45
|
+
* link into the history still has somewhere to go back to.
|
|
46
|
+
*/
|
|
47
|
+
export declare function useCopilotPanelView(initialView?: CopilotPanelView): CopilotPanelViewHandle;
|
|
48
|
+
//# sourceMappingURL=useCopilotPanelView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCopilotPanelView.d.ts","sourceRoot":"","sources":["../../src/hooks/useCopilotPanelView.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,gBAAgB;AAC1B,iFAAiF;AAC/E;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,GACd;IAAC,IAAI,EAAE,SAAS,CAAA;CAAC;AACnB,sDAAsD;GACpD;IAAC,IAAI,EAAE,SAAS,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAC,CAAC;AAEzC,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,gBAAgB,CAAC;IACvB,iEAAiE;IACjE,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,qEAAqE;IACrE,cAAc,EAAE,OAAO,CAAC;IACxB,gBAAgB,EAAE,MAAM,IAAI,CAAC;IAC7B,iBAAiB,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAC5C,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,WAAW,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,oFAAoF;IACpF,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB;;;;OAIG;IACH,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAC7B,UAAU,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC;IAC3C,cAAc,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5C,qBAAqB,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CACpD;AAID;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,CAAC,EAAE,gBAAgB,GAAG,sBAAsB,CAqC1F"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
2
|
+
const LIVE_VIEW = { kind: 'live' };
|
|
3
|
+
/**
|
|
4
|
+
* Which view the panel is showing, as a stack.
|
|
5
|
+
*
|
|
6
|
+
* A stack rather than a flag because the views nest: history opens a session, and every
|
|
7
|
+
* back step has to land where the reader came from rather than dropping them at the live
|
|
8
|
+
* session. Transcript lines are toggled inline on the timeline instead of opening a
|
|
9
|
+
* separate view.
|
|
10
|
+
*
|
|
11
|
+
* `initialView` opens the panel on that view with the live one beneath it, so a deep
|
|
12
|
+
* link into the history still has somewhere to go back to.
|
|
13
|
+
*/
|
|
14
|
+
export function useCopilotPanelView(initialView) {
|
|
15
|
+
const [stack, setStack] = useState(() => initialView && initialView.kind !== 'live' ? [LIVE_VIEW, initialView] : [LIVE_VIEW]);
|
|
16
|
+
const [showTranscript, setShowTranscript] = useState(false);
|
|
17
|
+
const [includedSessionIds, setIncludedSessionIds] = useState([]);
|
|
18
|
+
const view = stack[stack.length - 1] ?? LIVE_VIEW;
|
|
19
|
+
const sessionId = view.kind === 'session' ? view.sessionId : undefined;
|
|
20
|
+
const push = useCallback((next) => setStack((current) => [...current, next]), []);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
setShowTranscript(false);
|
|
23
|
+
}, [sessionId, view.kind]);
|
|
24
|
+
const includedSet = useMemo(() => new Set(includedSessionIds), [includedSessionIds]);
|
|
25
|
+
return {
|
|
26
|
+
view,
|
|
27
|
+
sessionId,
|
|
28
|
+
showTranscript,
|
|
29
|
+
toggleTranscript: useCallback(() => setShowTranscript((current) => !current), []),
|
|
30
|
+
setShowTranscript,
|
|
31
|
+
openHistory: useCallback(() => push({ kind: 'history' }), [push]),
|
|
32
|
+
openSession: useCallback((id) => push({ kind: 'session', sessionId: id }), [push]),
|
|
33
|
+
back: useCallback(() => setStack((current) => (current.length > 1 ? current.slice(0, -1) : current)), []),
|
|
34
|
+
goLive: useCallback(() => setStack([LIVE_VIEW]), []),
|
|
35
|
+
includedSessionIds,
|
|
36
|
+
isIncluded: useCallback((id) => includedSet.has(id), [includedSet]),
|
|
37
|
+
includeSession: useCallback((id) => setIncludedSessionIds((current) => (current.includes(id) ? current : [...current, id])), []),
|
|
38
|
+
removeIncludedSession: useCallback((id) => setIncludedSessionIds((current) => current.filter((entry) => entry !== id)), []),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=useCopilotPanelView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCopilotPanelView.js","sourceRoot":"","sources":["../../src/hooks/useCopilotPanelView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,QA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CAAC,EAAU,EAAE,EAAE,CAAC,qBAAqB,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC,EAC3F,EAAE,CACH;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type CopilotSessionSummary } from '@wildix/wilma-copilot-sessions-client';
|
|
2
|
+
import { type CopilotDependencies } from './shared';
|
|
3
|
+
export declare function useCopilotRecentSessions(options: CopilotDependencies & {
|
|
4
|
+
enabled?: boolean;
|
|
5
|
+
limit?: number;
|
|
6
|
+
}): {
|
|
7
|
+
sessions: CopilotSessionSummary[];
|
|
8
|
+
isLoading: boolean;
|
|
9
|
+
error?: Error;
|
|
10
|
+
refresh: () => void;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=useCopilotRecentSessions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCopilotRecentSessions.d.ts","sourceRoot":"","sources":["../../src/hooks/useCopilotRecentSessions.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,KAAK,qBAAqB,EAAsB,MAAM,uCAAuC,CAAC;AAEtG,OAAO,EAAC,KAAK,mBAAmB,EAAC,MAAM,UAAU,CAAC;AAElD,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"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { sortSessionsRecentFirst } from '@wildix/wilma-copilot-core';
|
|
3
|
+
import { ListSessionsCommand } from '@wildix/wilma-copilot-sessions-client';
|
|
4
|
+
import {} from './shared';
|
|
5
|
+
export function useCopilotRecentSessions(options) {
|
|
6
|
+
const { copilotClient, enabled = true, limit = 20, onError } = options;
|
|
7
|
+
const [sessions, setSessions] = useState([]);
|
|
8
|
+
const [isLoading, setIsLoading] = useState(enabled);
|
|
9
|
+
const [error, setError] = useState();
|
|
10
|
+
const [nonce, setNonce] = useState(0);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (!enabled)
|
|
13
|
+
return;
|
|
14
|
+
let cancelled = false;
|
|
15
|
+
setIsLoading(true);
|
|
16
|
+
void copilotClient
|
|
17
|
+
.send(new ListSessionsCommand({ limit }))
|
|
18
|
+
.then((result) => {
|
|
19
|
+
if (!cancelled)
|
|
20
|
+
setSessions(sortSessionsRecentFirst(result.sessions ?? []));
|
|
21
|
+
})
|
|
22
|
+
.catch((cause) => {
|
|
23
|
+
if (!cancelled) {
|
|
24
|
+
setError(cause instanceof Error ? cause : new Error(String(cause)));
|
|
25
|
+
onError?.(cause);
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
.finally(() => {
|
|
29
|
+
if (!cancelled)
|
|
30
|
+
setIsLoading(false);
|
|
31
|
+
});
|
|
32
|
+
return () => {
|
|
33
|
+
cancelled = true;
|
|
34
|
+
};
|
|
35
|
+
}, [copilotClient, enabled, limit, nonce, onError]);
|
|
36
|
+
return { sessions, isLoading, error, refresh: () => setNonce((value) => value + 1) };
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=useCopilotRecentSessions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCopilotRecentSessions.js","sourceRoot":"","sources":["../../src/hooks/useCopilotRecentSessions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAC,uBAAuB,EAAC,MAAM,4BAA4B,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,CAAC;aACD,OAAO,CAAC,GAAG,EAAE;YACZ,IAAI,CAAC,SAAS;gBAAE,YAAY,CAAC,KAAK,CAAC,CAAC;QACtC,CAAC,CAAC,CAAC;QAEL,OAAO,GAAG,EAAE;YACV,SAAS,GAAG,IAAI,CAAC;QACnB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,aAAa,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC;IAEpD,OAAO,EAAC,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,GAAG,CAAC,CAAC,EAAC,CAAC;AACrF,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type CopilotRelationshipHandle } from '@wildix/wilma-copilot-core';
|
|
2
|
+
import { type CopilotContextLookup } from '@wildix/wilma-copilot-sessions-client';
|
|
3
|
+
import { type CopilotDependencies } from './shared';
|
|
4
|
+
export interface UseCopilotRelationshipOptions extends CopilotDependencies {
|
|
5
|
+
lookup?: CopilotContextLookup;
|
|
6
|
+
enabled?: boolean;
|
|
7
|
+
sessionsLimit?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare function useCopilotRelationship({ copilotClient, lookup, enabled, sessionsLimit, onError, }: UseCopilotRelationshipOptions): CopilotRelationshipHandle;
|
|
10
|
+
//# sourceMappingURL=useCopilotRelationship.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCopilotRelationship.d.ts","sourceRoot":"","sources":["../../src/hooks/useCopilotRelationship.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,KAAK,yBAAyB,EAA0B,MAAM,4BAA4B,CAAC;AACnG,OAAO,EACL,KAAK,oBAAoB,EAK1B,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAC,KAAK,mBAAmB,EAAY,MAAM,UAAU,CAAC;AAE7D,MAAM,WAAW,6BAA8B,SAAQ,mBAAmB;IACxE,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,wBAAgB,sBAAsB,CAAC,EACrC,aAAa,EACb,MAAM,EACN,OAAc,EACd,aAAkB,EAClB,OAAO,GACR,EAAE,6BAA6B,GAAG,yBAAyB,CA4E3D"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { sortSessionsRecentFirst } from '@wildix/wilma-copilot-core';
|
|
3
|
+
import { EnrichCommand, ListRelationshipSessionsCommand, OpenCommand, } from '@wildix/wilma-copilot-sessions-client';
|
|
4
|
+
import { lookupKey } from './shared';
|
|
5
|
+
export function useCopilotRelationship({ copilotClient, lookup, enabled = true, sessionsLimit = 50, onError, }) {
|
|
6
|
+
const [relationshipId, setRelationshipId] = useState();
|
|
7
|
+
const [defaultSessionId, setDefaultSessionId] = useState();
|
|
8
|
+
const [sessions, setSessions] = useState([]);
|
|
9
|
+
const [isLoading, setIsLoading] = useState(enabled);
|
|
10
|
+
const [error, setError] = useState();
|
|
11
|
+
const [attempt, setAttempt] = useState(0);
|
|
12
|
+
const relationshipRef = useRef(undefined);
|
|
13
|
+
const openedLookupRef = useRef(undefined);
|
|
14
|
+
relationshipRef.current = relationshipId;
|
|
15
|
+
const loadSessions = useCallback(async (id, signal) => {
|
|
16
|
+
const result = await copilotClient.send(new ListRelationshipSessionsCommand({ relationshipId: id, limit: sessionsLimit }), signal ? { abortSignal: signal } : undefined);
|
|
17
|
+
if (!signal?.aborted)
|
|
18
|
+
setSessions(sortSessionsRecentFirst(result.sessions ?? []));
|
|
19
|
+
}, [copilotClient, sessionsLimit]);
|
|
20
|
+
const refresh = useCallback(() => {
|
|
21
|
+
if (relationshipRef.current)
|
|
22
|
+
void loadSessions(relationshipRef.current).catch(onError);
|
|
23
|
+
}, [loadSessions, onError]);
|
|
24
|
+
const retry = useCallback(() => {
|
|
25
|
+
setError(undefined);
|
|
26
|
+
setAttempt((value) => value + 1);
|
|
27
|
+
}, []);
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (!enabled)
|
|
30
|
+
return;
|
|
31
|
+
const abort = new AbortController();
|
|
32
|
+
setIsLoading(true);
|
|
33
|
+
void (async () => {
|
|
34
|
+
try {
|
|
35
|
+
const result = await copilotClient.send(new OpenCommand({ lookup }), { abortSignal: abort.signal });
|
|
36
|
+
if (abort.signal.aborted)
|
|
37
|
+
return;
|
|
38
|
+
openedLookupRef.current = lookupKey(lookup);
|
|
39
|
+
setRelationshipId(result.relationshipId);
|
|
40
|
+
setDefaultSessionId(result.session.id);
|
|
41
|
+
await loadSessions(result.relationshipId, abort.signal);
|
|
42
|
+
setError(undefined);
|
|
43
|
+
}
|
|
44
|
+
catch (cause) {
|
|
45
|
+
if (!abort.signal.aborted) {
|
|
46
|
+
const next = cause instanceof Error ? cause : new Error(String(cause));
|
|
47
|
+
setError(next);
|
|
48
|
+
onError?.(cause);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
finally {
|
|
52
|
+
if (!abort.signal.aborted)
|
|
53
|
+
setIsLoading(false);
|
|
54
|
+
}
|
|
55
|
+
})();
|
|
56
|
+
return () => abort.abort();
|
|
57
|
+
}, [attempt, copilotClient, enabled, loadSessions, onError]);
|
|
58
|
+
const key = lookupKey(lookup);
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
const currentId = relationshipRef.current;
|
|
61
|
+
if (!enabled || !currentId || openedLookupRef.current === undefined || openedLookupRef.current === key)
|
|
62
|
+
return;
|
|
63
|
+
openedLookupRef.current = key;
|
|
64
|
+
void copilotClient
|
|
65
|
+
.send(new EnrichCommand({ relationshipId: currentId, lookup: lookup }))
|
|
66
|
+
.then((result) => {
|
|
67
|
+
setRelationshipId(result.relationshipId);
|
|
68
|
+
setSessions(sortSessionsRecentFirst(result.related ?? []));
|
|
69
|
+
})
|
|
70
|
+
.catch(onError);
|
|
71
|
+
}, [copilotClient, enabled, key, lookup, onError]);
|
|
72
|
+
return { relationshipId, sessions, defaultSessionId, isLoading, error, retry, refresh };
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=useCopilotRelationship.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCopilotRelationship.js","sourceRoot":"","sources":["../../src/hooks/useCopilotRelationship.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAE/D,OAAO,EAAiC,uBAAuB,EAAC,MAAM,4BAA4B,CAAC;AACnG,OAAO,EAGL,aAAa,EACb,+BAA+B,EAC/B,WAAW,GACZ,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAA2B,SAAS,EAAC,MAAM,UAAU,CAAC;AAQ7D,MAAM,UAAU,sBAAsB,CAAC,EACrC,aAAa,EACb,MAAM,EACN,OAAO,GAAG,IAAI,EACd,aAAa,GAAG,EAAE,EAClB,OAAO,GACuB;IAC9B,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,EAAU,CAAC;IAC/D,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,QAAQ,EAAU,CAAC;IACnE,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAA0B,EAAE,CAAC,CAAC;IACtE,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;IACpD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,EAAS,CAAC;IAC5C,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC1C,MAAM,eAAe,GAAG,MAAM,CAAqB,SAAS,CAAC,CAAC;IAC9D,MAAM,eAAe,GA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AAe,CAAC,OAAO,CAAC;QAC1C,IAAI,CAAC,OAAO,IAAI,CAAC,SAAS,IAAI,eAAe,CAAC,OAAO,KAAK,SAAS,IAAI,eAAe,CAAC,OAAO,KAAK,GAAG;YAAE,OAAO;QAC/G,eAAe,CAAC,OAAO,GAAG,GAAG,CAAC;QAE9B,KAAK,aAAa;aACf,IAAI,CAAC,IAAI,aAAa,CAAC,EAAC,cAAc,EAAE,SAAS,EAAE,MAAM,EAAE,MAA8B,EAAC,CAAC,CAAC;aAC5F,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;YACf,iBAAiB,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;YACzC,WAAW,CAAC,uBAAuB,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,CAAC;QAC7D,CAAC,CAAC;aACD,KAAK,CAAC,OAAO,CAAC,CAAC;IACpB,CAAC,EAAE,CAAC,aAAa,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAEnD,OAAO,EAAC,cAAc,EAAE,QAAQ,EAAE,gBAAgB,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAC,CAAC;AACxF,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type CopilotSessionStreamHandle } from '@wildix/wilma-copilot-core';
|
|
2
|
+
import { type CopilotSessionEvent } from '@wildix/wilma-copilot-sessions-client';
|
|
3
|
+
import { type CopilotDependencies } from './shared';
|
|
4
|
+
export type CopilotEventStream = (sessionId: string, startIndex: number, signal: AbortSignal) => AsyncIterable<CopilotSessionEvent>;
|
|
5
|
+
export interface UseCopilotSessionStreamOptions extends CopilotDependencies {
|
|
6
|
+
sessionId?: string;
|
|
7
|
+
live?: boolean;
|
|
8
|
+
streamEvents?: CopilotEventStream;
|
|
9
|
+
onRelationship?: (sessionId: string | undefined) => void;
|
|
10
|
+
}
|
|
11
|
+
export declare function useCopilotSessionStream({ copilotClient, sessionId, live, streamEvents, onRelationship, onError, }: UseCopilotSessionStreamOptions): CopilotSessionStreamHandle;
|
|
12
|
+
//# sourceMappingURL=useCopilotSessionStream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCopilotSessionStream.d.ts","sourceRoot":"","sources":["../../src/hooks/useCopilotSessionStream.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,0BAA0B,EAIhC,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAC,KAAK,mBAAmB,EAA0B,MAAM,uCAAuC,CAAC;AAExG,OAAO,EAAC,KAAK,mBAAmB,EAAa,MAAM,UAAU,CAAC;AAE9D,MAAM,MAAM,kBAAkB,GAAG,CAC/B,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,WAAW,KAChB,aAAa,CAAC,mBAAmB,CAAC,CAAC;AAExC,MAAM,WAAW,8BAA+B,SAAQ,mBAAmB;IACzE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAClC,cAAc,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;CAC1D;AAED,wBAAgB,uBAAuB,CAAC,EACtC,aAAa,EACb,SAAS,EACT,IAAW,EACX,YAAY,EACZ,cAAc,EACd,OAAO,GACR,EAAE,8BAA8B,GAAG,0BAA0B,CA6D7D"}
|