@tai42/studio-sdk 5.0.0 → 6.0.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/dist/hooks/useApi.d.ts +23 -4
- package/dist/hooks/useApi.d.ts.map +1 -1
- package/dist/hooks/useSse.d.ts +34 -2
- package/dist/hooks/useSse.d.ts.map +1 -1
- package/dist/hooks/useSse.js +252 -153
- package/dist/hooks/useSse.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/hooks/useSse.ts +310 -161
- package/src/index.ts +5 -1
package/dist/hooks/useApi.d.ts
CHANGED
|
@@ -843,6 +843,29 @@ export declare const ApiProvider: import("react").Provider<{
|
|
|
843
843
|
nav_entries: string[];
|
|
844
844
|
};
|
|
845
845
|
}[]>;
|
|
846
|
+
readonly listInteractions: (page: number, pageSize: number, signal?: AbortSignal) => Promise<{
|
|
847
|
+
items: {
|
|
848
|
+
created_at: string;
|
|
849
|
+
interaction_id: string;
|
|
850
|
+
group_id: string;
|
|
851
|
+
question: string;
|
|
852
|
+
answer_format: "text" | "confirm" | "select" | "form" | "external";
|
|
853
|
+
format_payload: Record<string, unknown>;
|
|
854
|
+
timeout_at: string;
|
|
855
|
+
sensitive: boolean;
|
|
856
|
+
origin?: string | undefined;
|
|
857
|
+
server_verified?: boolean | undefined;
|
|
858
|
+
channel?: string | undefined;
|
|
859
|
+
recipient?: string | undefined;
|
|
860
|
+
audience?: string | undefined;
|
|
861
|
+
media?: unknown[] | undefined;
|
|
862
|
+
}[];
|
|
863
|
+
total: number;
|
|
864
|
+
page: number;
|
|
865
|
+
page_size: number;
|
|
866
|
+
next_page: number | null;
|
|
867
|
+
truncated: boolean;
|
|
868
|
+
}>;
|
|
846
869
|
readonly answerInteraction: (interactionId: string, answer: unknown) => Promise<{
|
|
847
870
|
status: string;
|
|
848
871
|
interaction_id: string;
|
|
@@ -1406,7 +1429,6 @@ export declare const ApiProvider: import("react").Provider<{
|
|
|
1406
1429
|
readonly listRuns: (params?: import("@tai42/api-client").RunsQuery, signal?: AbortSignal) => Promise<{
|
|
1407
1430
|
items: {
|
|
1408
1431
|
status: "error" | "success";
|
|
1409
|
-
model: string | null;
|
|
1410
1432
|
tags: string[];
|
|
1411
1433
|
id: string;
|
|
1412
1434
|
totalTokens: number | null;
|
|
@@ -1414,7 +1436,6 @@ export declare const ApiProvider: import("react").Provider<{
|
|
|
1414
1436
|
traceId: string;
|
|
1415
1437
|
createdAt: string | null;
|
|
1416
1438
|
latencyMs: number | null;
|
|
1417
|
-
fetchError: string | null;
|
|
1418
1439
|
inputPreview?: unknown;
|
|
1419
1440
|
outputPreview?: unknown;
|
|
1420
1441
|
}[];
|
|
@@ -1425,9 +1446,7 @@ export declare const ApiProvider: import("react").Provider<{
|
|
|
1425
1446
|
tags: string[];
|
|
1426
1447
|
totalCost: number | null;
|
|
1427
1448
|
traceId: string;
|
|
1428
|
-
fetchError: string | null;
|
|
1429
1449
|
timestamp: string | null;
|
|
1430
|
-
availability: "partial" | "unavailable" | "full";
|
|
1431
1450
|
spans: {
|
|
1432
1451
|
name: string | null;
|
|
1433
1452
|
type: string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useApi.d.ts","sourceRoot":"","sources":["../../src/hooks/useApi.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAInD,eAAO,MAAM,WAAW;;+BAW8jc,CAAC;iDAAsF,CAAC;;;;;uCAAuM,CAAC;;;;;4EAAgO,CAAC;wFAAgG,CAAC;;;+CAA2G,CAAC;;;;;aAAqL,CAAC;cAAoC,CAAC;mBAA8B,CAAC;;oDAAkF,CAAC;;;;;mBAA2L,CAAC;;kCAAkE,CAAC;;;;;;iCAAwK,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6CAAw8B,CAAC;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8CAAg0F,CAAC;;;;;;;;;;;;+BAAkW,CAAC;oCAAuE,CAAC;;;;;;wCAAgoB,CAAC;SAX5mvE,CAAC;AAE/C,wBAAgB,MAAM,IAAI,SAAS,CAMlC;AAED,YAAY,EAAE,SAAS,EAAE,CAAC"}
|
package/dist/hooks/useSse.d.ts
CHANGED
|
@@ -3,10 +3,42 @@ import type { Interaction } from '@tai42/api-client';
|
|
|
3
3
|
export type StreamInteraction = Interaction & {
|
|
4
4
|
readonly answered: boolean;
|
|
5
5
|
};
|
|
6
|
+
/** The inputs the caller drives the tail-only stream with. */
|
|
7
|
+
export interface InteractionsStreamOptions {
|
|
8
|
+
/**
|
|
9
|
+
* The pending set from the paged `GET /api/interactions` door — the base the
|
|
10
|
+
* live tail overlays. A stable reference between refetches (memoize it upstream);
|
|
11
|
+
* a new reference re-merges but does NOT reopen the stream.
|
|
12
|
+
*/
|
|
13
|
+
readonly seed: readonly Interaction[];
|
|
14
|
+
/**
|
|
15
|
+
* The door's authoritative pending TOTAL for the current `seed` (the paged
|
|
16
|
+
* response's `total`). The published `count` derives the live pending tally from
|
|
17
|
+
* this plus the overlay delta, so the badge stays live without a refetch.
|
|
18
|
+
*/
|
|
19
|
+
readonly total: number;
|
|
20
|
+
/**
|
|
21
|
+
* Refetch `seed`. Called on every (re)connect ONLY — the tail carries no backlog,
|
|
22
|
+
* so this reconciles anything missed while disconnected. A live delta never calls
|
|
23
|
+
* it: the overlay updates the list and the derived `count` in place. MUST resolve
|
|
24
|
+
* `true` only when the refetch LANDED a fresh `total`, and `false` when it failed:
|
|
25
|
+
* the hook advances `countEpoch` only on `true`, so terminals and adds already
|
|
26
|
+
* folded into the fresh `total` are not applied to the count again, while after a
|
|
27
|
+
* failed refetch the prior-epoch deltas keep applying against the unchanged prior
|
|
28
|
+
* total instead of being discarded against a stale one.
|
|
29
|
+
*/
|
|
30
|
+
readonly onResync: () => boolean | Promise<boolean>;
|
|
31
|
+
}
|
|
6
32
|
export interface InteractionsStreamState {
|
|
7
33
|
readonly interactions: StreamInteraction[];
|
|
34
|
+
/**
|
|
35
|
+
* The live pending count: the seed `total` adjusted by the overlay delta stamped at
|
|
36
|
+
* or after the last landed resync's epoch (adds not in the seed, minus one per
|
|
37
|
+
* terminal id). Stays live without a refetch; a delta stamped before `countEpoch` is
|
|
38
|
+
* already reflected in `total` and not applied again.
|
|
39
|
+
*/
|
|
40
|
+
readonly count: number;
|
|
8
41
|
readonly connected: boolean;
|
|
9
|
-
readonly backlogLoaded: boolean;
|
|
10
42
|
readonly error: Error | null;
|
|
11
43
|
/**
|
|
12
44
|
* The interactions store is not configured on this deployment: the stream
|
|
@@ -16,5 +48,5 @@ export interface InteractionsStreamState {
|
|
|
16
48
|
*/
|
|
17
49
|
readonly disabled: boolean;
|
|
18
50
|
}
|
|
19
|
-
export declare function useInteractionsStream(): InteractionsStreamState;
|
|
51
|
+
export declare function useInteractionsStream(options: InteractionsStreamOptions): InteractionsStreamState;
|
|
20
52
|
//# sourceMappingURL=useSse.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSse.d.ts","sourceRoot":"","sources":["../../src/hooks/useSse.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useSse.d.ts","sourceRoot":"","sources":["../../src/hooks/useSse.ts"],"names":[],"mappings":"AAsDA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAMrD,qEAAqE;AACrE,MAAM,MAAM,iBAAiB,GAAG,WAAW,GAAG;IAAE,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,CAAC;AAE7E,8DAA8D;AAC9D,MAAM,WAAW,yBAAyB;IACxC;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,SAAS,WAAW,EAAE,CAAC;IACtC;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB;;;;;;;;;OASG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACrD;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,YAAY,EAAE,iBAAiB,EAAE,CAAC;IAC3C;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAC7B;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B;AAwND,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,yBAAyB,GAAG,uBAAuB,CAwPjG"}
|