@langchain/langgraph-sdk 1.6.5 → 1.7.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/client.cjs +2 -1
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts.map +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +2 -1
- package/dist/client.js.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/react/index.cjs +46 -10
- package/dist/react/index.cjs.map +1 -0
- package/dist/react/index.d.cts +14 -11
- package/dist/react/index.d.cts.map +1 -0
- package/dist/react/index.d.ts +14 -11
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +14 -4
- package/dist/react/index.js.map +1 -0
- package/dist/react-ui/index.cjs +38 -13
- package/dist/react-ui/index.d.cts +1 -2
- package/dist/react-ui/index.d.ts +1 -2
- package/dist/react-ui/index.js +2 -8
- package/dist/react-ui/server/index.cjs +14 -4
- package/dist/react-ui/server/index.d.cts +1 -2
- package/dist/react-ui/server/index.d.ts +1 -2
- package/dist/react-ui/server/index.js +1 -2
- package/dist/types.messages.d.cts +5 -3
- package/dist/types.messages.d.cts.map +1 -1
- package/dist/types.messages.d.ts +5 -3
- package/dist/types.messages.d.ts.map +1 -1
- package/dist/ui/branching.cjs +24 -0
- package/dist/ui/branching.cjs.map +1 -1
- package/dist/ui/branching.d.cts +26 -1
- package/dist/ui/branching.d.cts.map +1 -1
- package/dist/ui/branching.d.ts +26 -1
- package/dist/ui/branching.d.ts.map +1 -1
- package/dist/ui/branching.js +25 -1
- package/dist/ui/branching.js.map +1 -1
- package/dist/ui/index.cjs +30 -0
- package/dist/ui/index.d.cts +15 -0
- package/dist/ui/index.d.ts +15 -0
- package/dist/ui/index.js +11 -0
- package/dist/ui/interrupts.cjs +21 -0
- package/dist/ui/interrupts.cjs.map +1 -0
- package/dist/ui/interrupts.d.cts +11 -0
- package/dist/ui/interrupts.d.cts.map +1 -0
- package/dist/ui/interrupts.d.ts +11 -0
- package/dist/ui/interrupts.d.ts.map +1 -0
- package/dist/ui/interrupts.js +20 -0
- package/dist/ui/interrupts.js.map +1 -0
- package/dist/ui/manager.cjs +8 -3
- package/dist/ui/manager.cjs.map +1 -1
- package/dist/ui/manager.d.cts +224 -0
- package/dist/ui/manager.d.cts.map +1 -0
- package/dist/ui/manager.d.ts +224 -0
- package/dist/ui/manager.d.ts.map +1 -0
- package/dist/ui/manager.js +8 -3
- package/dist/ui/manager.js.map +1 -1
- package/dist/ui/messages.cjs +19 -0
- package/dist/ui/messages.cjs.map +1 -1
- package/dist/ui/messages.d.cts +36 -0
- package/dist/ui/messages.d.cts.map +1 -0
- package/dist/ui/messages.d.ts +36 -0
- package/dist/ui/messages.d.ts.map +1 -0
- package/dist/ui/messages.js +18 -1
- package/dist/ui/messages.js.map +1 -1
- package/dist/ui/queue.cjs +75 -0
- package/dist/ui/queue.cjs.map +1 -0
- package/dist/ui/queue.d.cts +72 -0
- package/dist/ui/queue.d.cts.map +1 -0
- package/dist/ui/queue.d.ts +72 -0
- package/dist/ui/queue.d.ts.map +1 -0
- package/dist/ui/queue.js +74 -0
- package/dist/ui/queue.js.map +1 -0
- package/dist/ui/stream/base.d.cts +11 -0
- package/dist/ui/stream/base.d.cts.map +1 -1
- package/dist/ui/stream/base.d.ts +11 -0
- package/dist/ui/stream/base.d.ts.map +1 -1
- package/dist/ui/stream/index.d.cts +4 -4
- package/dist/ui/stream/index.d.cts.map +1 -1
- package/dist/ui/stream/index.d.ts +4 -4
- package/dist/ui/stream/index.d.ts.map +1 -1
- package/dist/ui/subagents.cjs +4 -1
- package/dist/ui/subagents.cjs.map +1 -1
- package/dist/ui/subagents.d.cts +7 -0
- package/dist/ui/subagents.d.cts.map +1 -1
- package/dist/ui/subagents.d.ts +7 -0
- package/dist/ui/subagents.d.ts.map +1 -1
- package/dist/ui/subagents.js +4 -1
- package/dist/ui/subagents.js.map +1 -1
- package/dist/ui/transport.cjs +31 -0
- package/dist/ui/transport.cjs.map +1 -0
- package/dist/{react/stream.custom.d.cts → ui/transport.d.cts} +3 -3
- package/dist/ui/transport.d.cts.map +1 -0
- package/dist/{react/stream.custom.d.ts → ui/transport.d.ts} +3 -3
- package/dist/ui/transport.d.ts.map +1 -0
- package/dist/ui/transport.js +31 -0
- package/dist/ui/transport.js.map +1 -0
- package/dist/ui/types.d.cts +125 -16
- package/dist/ui/types.d.cts.map +1 -1
- package/dist/ui/types.d.ts +125 -16
- package/dist/ui/types.d.ts.map +1 -1
- package/dist/ui/utils.d.cts +7 -0
- package/dist/ui/utils.d.cts.map +1 -0
- package/dist/ui/utils.d.ts +7 -0
- package/dist/ui/utils.d.ts.map +1 -0
- package/dist/utils/index.cjs +9 -0
- package/dist/utils/index.d.cts +4 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.js +5 -0
- package/dist/utils/sse.d.cts +11 -0
- package/dist/utils/sse.d.cts.map +1 -0
- package/dist/utils/sse.d.ts +11 -0
- package/dist/utils/sse.d.ts.map +1 -0
- package/dist/utils/stream.d.cts +19 -0
- package/dist/utils/stream.d.cts.map +1 -0
- package/dist/utils/stream.d.ts +19 -0
- package/dist/utils/stream.d.ts.map +1 -0
- package/dist/utils/tools.cjs +26 -17
- package/dist/utils/tools.cjs.map +1 -1
- package/dist/utils/tools.d.cts +7 -0
- package/dist/utils/tools.d.cts.map +1 -0
- package/dist/utils/tools.d.ts +7 -0
- package/dist/utils/tools.d.ts.map +1 -0
- package/dist/utils/tools.js +26 -17
- package/dist/utils/tools.js.map +1 -1
- package/package.json +41 -12
- package/dist/react/stream.cjs +0 -18
- package/dist/react/stream.cjs.map +0 -1
- package/dist/react/stream.custom.cjs +0 -164
- package/dist/react/stream.custom.cjs.map +0 -1
- package/dist/react/stream.custom.d.cts.map +0 -1
- package/dist/react/stream.custom.d.ts.map +0 -1
- package/dist/react/stream.custom.js +0 -162
- package/dist/react/stream.custom.js.map +0 -1
- package/dist/react/stream.d.cts +0 -174
- package/dist/react/stream.d.cts.map +0 -1
- package/dist/react/stream.d.ts +0 -174
- package/dist/react/stream.d.ts.map +0 -1
- package/dist/react/stream.js +0 -17
- package/dist/react/stream.js.map +0 -1
- package/dist/react/stream.lgp.cjs +0 -544
- package/dist/react/stream.lgp.cjs.map +0 -1
- package/dist/react/stream.lgp.js +0 -543
- package/dist/react/stream.lgp.js.map +0 -1
- package/dist/react/thread.cjs +0 -21
- package/dist/react/thread.cjs.map +0 -1
- package/dist/react/thread.js +0 -20
- package/dist/react/thread.js.map +0 -1
- package/dist/react/types.d.cts +0 -79
- package/dist/react/types.d.cts.map +0 -1
- package/dist/react/types.d.ts +0 -79
- package/dist/react/types.d.ts.map +0 -1
- package/dist/react-ui/client.cjs +0 -138
- package/dist/react-ui/client.cjs.map +0 -1
- package/dist/react-ui/client.d.cts +0 -76
- package/dist/react-ui/client.d.cts.map +0 -1
- package/dist/react-ui/client.d.ts +0 -76
- package/dist/react-ui/client.d.ts.map +0 -1
- package/dist/react-ui/client.js +0 -132
- package/dist/react-ui/client.js.map +0 -1
- package/dist/react-ui/index.cjs.map +0 -1
- package/dist/react-ui/index.js.map +0 -1
- package/dist/react-ui/server/server.cjs +0 -57
- package/dist/react-ui/server/server.cjs.map +0 -1
- package/dist/react-ui/server/server.d.cts +0 -54
- package/dist/react-ui/server/server.d.cts.map +0 -1
- package/dist/react-ui/server/server.d.ts +0 -54
- package/dist/react-ui/server/server.d.ts.map +0 -1
- package/dist/react-ui/server/server.js +0 -56
- package/dist/react-ui/server/server.js.map +0 -1
- package/dist/react-ui/types.cjs +0 -38
- package/dist/react-ui/types.cjs.map +0 -1
- package/dist/react-ui/types.d.cts +0 -25
- package/dist/react-ui/types.d.cts.map +0 -1
- package/dist/react-ui/types.d.ts +0 -25
- package/dist/react-ui/types.d.ts.map +0 -1
- package/dist/react-ui/types.js +0 -35
- package/dist/react-ui/types.js.map +0 -1
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/ui/queue.ts
|
|
3
|
+
/**
|
|
4
|
+
* Tracks pending server-side runs created via `multitaskStrategy: "enqueue"`.
|
|
5
|
+
*
|
|
6
|
+
* Uses the same subscribe/getSnapshot pattern as StreamManager
|
|
7
|
+
* to integrate with framework-specific reactivity systems.
|
|
8
|
+
*/
|
|
9
|
+
var PendingRunsTracker = class {
|
|
10
|
+
pending = [];
|
|
11
|
+
listeners = /* @__PURE__ */ new Set();
|
|
12
|
+
/**
|
|
13
|
+
* Add a pending run entry.
|
|
14
|
+
*/
|
|
15
|
+
add(entry) {
|
|
16
|
+
this.pending.push(entry);
|
|
17
|
+
this.notifyListeners();
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Remove and return the next pending entry (FIFO).
|
|
21
|
+
*/
|
|
22
|
+
shift() {
|
|
23
|
+
const entry = this.pending.shift();
|
|
24
|
+
if (entry) this.notifyListeners();
|
|
25
|
+
return entry;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Remove a specific entry by ID.
|
|
29
|
+
* @returns true if the entry was found and removed.
|
|
30
|
+
*/
|
|
31
|
+
remove = (id) => {
|
|
32
|
+
const index = this.pending.findIndex((e) => e.id === id);
|
|
33
|
+
if (index === -1) return false;
|
|
34
|
+
this.pending.splice(index, 1);
|
|
35
|
+
this.notifyListeners();
|
|
36
|
+
return true;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Remove all entries from the tracker.
|
|
40
|
+
* @returns The removed entries (for server-side cancellation).
|
|
41
|
+
*/
|
|
42
|
+
removeAll = () => {
|
|
43
|
+
if (this.pending.length === 0) return [];
|
|
44
|
+
const entries = [...this.pending];
|
|
45
|
+
this.pending = [];
|
|
46
|
+
this.notifyListeners();
|
|
47
|
+
return entries;
|
|
48
|
+
};
|
|
49
|
+
/** Read-only snapshot of all pending entries. */
|
|
50
|
+
get entries() {
|
|
51
|
+
return this.pending;
|
|
52
|
+
}
|
|
53
|
+
/** Number of pending entries. */
|
|
54
|
+
get size() {
|
|
55
|
+
return this.pending.length;
|
|
56
|
+
}
|
|
57
|
+
/** Subscribe to state changes. Returns an unsubscribe function. */
|
|
58
|
+
subscribe = (listener) => {
|
|
59
|
+
this.listeners.add(listener);
|
|
60
|
+
return () => {
|
|
61
|
+
this.listeners.delete(listener);
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
/** Snapshot token for useSyncExternalStore compatibility. */
|
|
65
|
+
getSnapshot = () => {
|
|
66
|
+
return this.pending.length;
|
|
67
|
+
};
|
|
68
|
+
notifyListeners() {
|
|
69
|
+
for (const listener of this.listeners) listener();
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
//#endregion
|
|
74
|
+
exports.PendingRunsTracker = PendingRunsTracker;
|
|
75
|
+
//# sourceMappingURL=queue.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue.cjs","names":[],"sources":["../../src/ui/queue.ts"],"sourcesContent":["import type { SubmitOptions, CustomSubmitOptions } from \"./types.js\";\n\n/**\n * A single queued submission entry representing a server-side pending run.\n * Each entry corresponds to a run created on the server via\n * `client.runs.create()` with `multitaskStrategy: \"enqueue\"`.\n */\nexport interface QueueEntry<\n StateType extends Record<string, unknown> = Record<string, unknown>,\n OptionsType = SubmitOptions<StateType> | CustomSubmitOptions<StateType>\n> {\n /** Server-side run ID (from `client.runs.create()`) */\n id: string;\n\n /** The state update values passed to submit() */\n values: Partial<StateType> | null | undefined;\n\n /** The submit options passed to submit() */\n options?: OptionsType;\n\n /** Timestamp when the entry was created */\n createdAt: Date;\n}\n\n/**\n * Reactive interface exposed to framework consumers for observing\n * and managing the server-side submission queue.\n */\nexport interface QueueInterface<\n StateType extends Record<string, unknown> = Record<string, unknown>,\n OptionsType = SubmitOptions<StateType> | CustomSubmitOptions<StateType>\n> {\n /** Read-only array of pending queue entries */\n readonly entries: ReadonlyArray<QueueEntry<StateType, OptionsType>>;\n\n /** Number of pending entries */\n readonly size: number;\n\n /** Cancel a specific pending run by its server run ID. Returns true if found and cancelled. */\n cancel: (id: string) => Promise<boolean>;\n\n /** Cancel all pending runs on the server and clear the queue. */\n clear: () => Promise<void>;\n}\n\n/**\n * Tracks pending server-side runs created via `multitaskStrategy: \"enqueue\"`.\n *\n * Uses the same subscribe/getSnapshot pattern as StreamManager\n * to integrate with framework-specific reactivity systems.\n */\nexport class PendingRunsTracker<\n StateType extends Record<string, unknown> = Record<string, unknown>,\n OptionsType = SubmitOptions<StateType> | CustomSubmitOptions<StateType>\n> {\n private pending: QueueEntry<StateType, OptionsType>[] = [];\n\n private listeners = new Set<() => void>();\n\n /**\n * Add a pending run entry.\n */\n add(entry: QueueEntry<StateType, OptionsType>): void {\n this.pending.push(entry);\n this.notifyListeners();\n }\n\n /**\n * Remove and return the next pending entry (FIFO).\n */\n shift(): QueueEntry<StateType, OptionsType> | undefined {\n const entry = this.pending.shift();\n if (entry) this.notifyListeners();\n return entry;\n }\n\n /**\n * Remove a specific entry by ID.\n * @returns true if the entry was found and removed.\n */\n remove = (id: string): boolean => {\n const index = this.pending.findIndex((e) => e.id === id);\n if (index === -1) return false;\n this.pending.splice(index, 1);\n this.notifyListeners();\n return true;\n };\n\n /**\n * Remove all entries from the tracker.\n * @returns The removed entries (for server-side cancellation).\n */\n removeAll = (): QueueEntry<StateType, OptionsType>[] => {\n if (this.pending.length === 0) return [];\n const entries = [...this.pending];\n this.pending = [];\n this.notifyListeners();\n return entries;\n };\n\n /** Read-only snapshot of all pending entries. */\n get entries(): ReadonlyArray<QueueEntry<StateType, OptionsType>> {\n return this.pending;\n }\n\n /** Number of pending entries. */\n get size(): number {\n return this.pending.length;\n }\n\n /** Subscribe to state changes. Returns an unsubscribe function. */\n subscribe = (listener: () => void): (() => void) => {\n this.listeners.add(listener);\n return () => {\n this.listeners.delete(listener);\n };\n };\n\n /** Snapshot token for useSyncExternalStore compatibility. */\n getSnapshot = (): number => {\n return this.pending.length;\n };\n\n private notifyListeners(): void {\n for (const listener of this.listeners) {\n listener();\n }\n }\n}\n"],"mappings":";;;;;;;;AAmDA,IAAa,qBAAb,MAGE;CACA,AAAQ,UAAgD,EAAE;CAE1D,AAAQ,4BAAY,IAAI,KAAiB;;;;CAKzC,IAAI,OAAiD;AACnD,OAAK,QAAQ,KAAK,MAAM;AACxB,OAAK,iBAAiB;;;;;CAMxB,QAAwD;EACtD,MAAM,QAAQ,KAAK,QAAQ,OAAO;AAClC,MAAI,MAAO,MAAK,iBAAiB;AACjC,SAAO;;;;;;CAOT,UAAU,OAAwB;EAChC,MAAM,QAAQ,KAAK,QAAQ,WAAW,MAAM,EAAE,OAAO,GAAG;AACxD,MAAI,UAAU,GAAI,QAAO;AACzB,OAAK,QAAQ,OAAO,OAAO,EAAE;AAC7B,OAAK,iBAAiB;AACtB,SAAO;;;;;;CAOT,kBAAwD;AACtD,MAAI,KAAK,QAAQ,WAAW,EAAG,QAAO,EAAE;EACxC,MAAM,UAAU,CAAC,GAAG,KAAK,QAAQ;AACjC,OAAK,UAAU,EAAE;AACjB,OAAK,iBAAiB;AACtB,SAAO;;;CAIT,IAAI,UAA6D;AAC/D,SAAO,KAAK;;;CAId,IAAI,OAAe;AACjB,SAAO,KAAK,QAAQ;;;CAItB,aAAa,aAAuC;AAClD,OAAK,UAAU,IAAI,SAAS;AAC5B,eAAa;AACX,QAAK,UAAU,OAAO,SAAS;;;;CAKnC,oBAA4B;AAC1B,SAAO,KAAK,QAAQ;;CAGtB,AAAQ,kBAAwB;AAC9B,OAAK,MAAM,YAAY,KAAK,UAC1B,WAAU"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { CustomSubmitOptions, SubmitOptions } from "./types.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/ui/queue.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* A single queued submission entry representing a server-side pending run.
|
|
6
|
+
* Each entry corresponds to a run created on the server via
|
|
7
|
+
* `client.runs.create()` with `multitaskStrategy: "enqueue"`.
|
|
8
|
+
*/
|
|
9
|
+
interface QueueEntry<StateType extends Record<string, unknown> = Record<string, unknown>, OptionsType = SubmitOptions<StateType> | CustomSubmitOptions<StateType>> {
|
|
10
|
+
/** Server-side run ID (from `client.runs.create()`) */
|
|
11
|
+
id: string;
|
|
12
|
+
/** The state update values passed to submit() */
|
|
13
|
+
values: Partial<StateType> | null | undefined;
|
|
14
|
+
/** The submit options passed to submit() */
|
|
15
|
+
options?: OptionsType;
|
|
16
|
+
/** Timestamp when the entry was created */
|
|
17
|
+
createdAt: Date;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Reactive interface exposed to framework consumers for observing
|
|
21
|
+
* and managing the server-side submission queue.
|
|
22
|
+
*/
|
|
23
|
+
interface QueueInterface<StateType extends Record<string, unknown> = Record<string, unknown>, OptionsType = SubmitOptions<StateType> | CustomSubmitOptions<StateType>> {
|
|
24
|
+
/** Read-only array of pending queue entries */
|
|
25
|
+
readonly entries: ReadonlyArray<QueueEntry<StateType, OptionsType>>;
|
|
26
|
+
/** Number of pending entries */
|
|
27
|
+
readonly size: number;
|
|
28
|
+
/** Cancel a specific pending run by its server run ID. Returns true if found and cancelled. */
|
|
29
|
+
cancel: (id: string) => Promise<boolean>;
|
|
30
|
+
/** Cancel all pending runs on the server and clear the queue. */
|
|
31
|
+
clear: () => Promise<void>;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Tracks pending server-side runs created via `multitaskStrategy: "enqueue"`.
|
|
35
|
+
*
|
|
36
|
+
* Uses the same subscribe/getSnapshot pattern as StreamManager
|
|
37
|
+
* to integrate with framework-specific reactivity systems.
|
|
38
|
+
*/
|
|
39
|
+
declare class PendingRunsTracker<StateType extends Record<string, unknown> = Record<string, unknown>, OptionsType = SubmitOptions<StateType> | CustomSubmitOptions<StateType>> {
|
|
40
|
+
private pending;
|
|
41
|
+
private listeners;
|
|
42
|
+
/**
|
|
43
|
+
* Add a pending run entry.
|
|
44
|
+
*/
|
|
45
|
+
add(entry: QueueEntry<StateType, OptionsType>): void;
|
|
46
|
+
/**
|
|
47
|
+
* Remove and return the next pending entry (FIFO).
|
|
48
|
+
*/
|
|
49
|
+
shift(): QueueEntry<StateType, OptionsType> | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* Remove a specific entry by ID.
|
|
52
|
+
* @returns true if the entry was found and removed.
|
|
53
|
+
*/
|
|
54
|
+
remove: (id: string) => boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Remove all entries from the tracker.
|
|
57
|
+
* @returns The removed entries (for server-side cancellation).
|
|
58
|
+
*/
|
|
59
|
+
removeAll: () => QueueEntry<StateType, OptionsType>[];
|
|
60
|
+
/** Read-only snapshot of all pending entries. */
|
|
61
|
+
get entries(): ReadonlyArray<QueueEntry<StateType, OptionsType>>;
|
|
62
|
+
/** Number of pending entries. */
|
|
63
|
+
get size(): number;
|
|
64
|
+
/** Subscribe to state changes. Returns an unsubscribe function. */
|
|
65
|
+
subscribe: (listener: () => void) => () => void;
|
|
66
|
+
/** Snapshot token for useSyncExternalStore compatibility. */
|
|
67
|
+
getSnapshot: () => number;
|
|
68
|
+
private notifyListeners;
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
export { PendingRunsTracker, QueueEntry, QueueInterface };
|
|
72
|
+
//# sourceMappingURL=queue.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue.d.cts","names":[],"sources":["../../src/ui/queue.ts"],"mappings":";;;;;AAOA;;;UAAiB,UAAA,mBACG,MAAA,oBAA0B,MAAA,iCAC9B,aAAA,CAAc,SAAA,IAAa,mBAAA,CAAoB,SAAA;EADjB;EAI5C,EAAA;EAHc;EAMd,MAAA,EAAQ,OAAA,CAAQ,SAAA;EANyB;EASzC,OAAA,GAAU,WAAA;EAHF;EAMR,SAAA,EAAW,IAAA;AAAA;;;;;UAOI,cAAA,mBACG,MAAA,oBAA0B,MAAA,iCAC9B,aAAA,CAAc,SAAA,IAAa,mBAAA,CAAoB,SAAA;EArB7D;EAAA,SAwBS,OAAA,EAAS,aAAA,CAAc,UAAA,CAAW,SAAA,EAAW,WAAA;EAxB1B;EAAA,SA2BnB,IAAA;EA3BoD;EA8B7D,MAAA,GAAS,EAAA,aAAe,OAAA;EAxBxB;EA2BA,KAAA,QAAa,OAAA;AAAA;;;;;;;cASF,kBAAA,mBACO,MAAA,oBAA0B,MAAA,iCAC9B,aAAA,CAAc,SAAA,IAAa,mBAAA,CAAoB,SAAA;EAAA,QAErD,OAAA;EAAA,QAEA,SAAA;EA5BU;;;EAiClB,GAAA,CAAI,KAAA,EAAO,UAAA,CAAW,SAAA,EAAW,WAAA;EAhC4B;;;EAwC7D,KAAA,CAAA,GAAS,UAAA,CAAW,SAAA,EAAW,WAAA;EArCC;;;;EA+ChC,MAAA,GAAM,EAAA;EAtCc;;;;EAkDpB,SAAA,QAAS,UAAA,CAAA,SAAA,EAAA,WAAA;EA9DK;EAAA,IAuEV,OAAA,CAAA,GAAW,aAAA,CAAc,UAAA,CAAW,SAAA,EAAW,WAAA;EAvEV;EAAA,IA4ErC,IAAA,CAAA;EAzEK;EA8ET,SAAA,GAAS,QAAA;EA9EuB;EAsFhC,WAAA;EAAA,QAIQ,eAAA;AAAA"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { CustomSubmitOptions, SubmitOptions } from "./types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/ui/queue.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* A single queued submission entry representing a server-side pending run.
|
|
6
|
+
* Each entry corresponds to a run created on the server via
|
|
7
|
+
* `client.runs.create()` with `multitaskStrategy: "enqueue"`.
|
|
8
|
+
*/
|
|
9
|
+
interface QueueEntry<StateType extends Record<string, unknown> = Record<string, unknown>, OptionsType = SubmitOptions<StateType> | CustomSubmitOptions<StateType>> {
|
|
10
|
+
/** Server-side run ID (from `client.runs.create()`) */
|
|
11
|
+
id: string;
|
|
12
|
+
/** The state update values passed to submit() */
|
|
13
|
+
values: Partial<StateType> | null | undefined;
|
|
14
|
+
/** The submit options passed to submit() */
|
|
15
|
+
options?: OptionsType;
|
|
16
|
+
/** Timestamp when the entry was created */
|
|
17
|
+
createdAt: Date;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Reactive interface exposed to framework consumers for observing
|
|
21
|
+
* and managing the server-side submission queue.
|
|
22
|
+
*/
|
|
23
|
+
interface QueueInterface<StateType extends Record<string, unknown> = Record<string, unknown>, OptionsType = SubmitOptions<StateType> | CustomSubmitOptions<StateType>> {
|
|
24
|
+
/** Read-only array of pending queue entries */
|
|
25
|
+
readonly entries: ReadonlyArray<QueueEntry<StateType, OptionsType>>;
|
|
26
|
+
/** Number of pending entries */
|
|
27
|
+
readonly size: number;
|
|
28
|
+
/** Cancel a specific pending run by its server run ID. Returns true if found and cancelled. */
|
|
29
|
+
cancel: (id: string) => Promise<boolean>;
|
|
30
|
+
/** Cancel all pending runs on the server and clear the queue. */
|
|
31
|
+
clear: () => Promise<void>;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Tracks pending server-side runs created via `multitaskStrategy: "enqueue"`.
|
|
35
|
+
*
|
|
36
|
+
* Uses the same subscribe/getSnapshot pattern as StreamManager
|
|
37
|
+
* to integrate with framework-specific reactivity systems.
|
|
38
|
+
*/
|
|
39
|
+
declare class PendingRunsTracker<StateType extends Record<string, unknown> = Record<string, unknown>, OptionsType = SubmitOptions<StateType> | CustomSubmitOptions<StateType>> {
|
|
40
|
+
private pending;
|
|
41
|
+
private listeners;
|
|
42
|
+
/**
|
|
43
|
+
* Add a pending run entry.
|
|
44
|
+
*/
|
|
45
|
+
add(entry: QueueEntry<StateType, OptionsType>): void;
|
|
46
|
+
/**
|
|
47
|
+
* Remove and return the next pending entry (FIFO).
|
|
48
|
+
*/
|
|
49
|
+
shift(): QueueEntry<StateType, OptionsType> | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* Remove a specific entry by ID.
|
|
52
|
+
* @returns true if the entry was found and removed.
|
|
53
|
+
*/
|
|
54
|
+
remove: (id: string) => boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Remove all entries from the tracker.
|
|
57
|
+
* @returns The removed entries (for server-side cancellation).
|
|
58
|
+
*/
|
|
59
|
+
removeAll: () => QueueEntry<StateType, OptionsType>[];
|
|
60
|
+
/** Read-only snapshot of all pending entries. */
|
|
61
|
+
get entries(): ReadonlyArray<QueueEntry<StateType, OptionsType>>;
|
|
62
|
+
/** Number of pending entries. */
|
|
63
|
+
get size(): number;
|
|
64
|
+
/** Subscribe to state changes. Returns an unsubscribe function. */
|
|
65
|
+
subscribe: (listener: () => void) => () => void;
|
|
66
|
+
/** Snapshot token for useSyncExternalStore compatibility. */
|
|
67
|
+
getSnapshot: () => number;
|
|
68
|
+
private notifyListeners;
|
|
69
|
+
}
|
|
70
|
+
//#endregion
|
|
71
|
+
export { PendingRunsTracker, QueueEntry, QueueInterface };
|
|
72
|
+
//# sourceMappingURL=queue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue.d.ts","names":[],"sources":["../../src/ui/queue.ts"],"mappings":";;;;;AAOA;;;UAAiB,UAAA,mBACG,MAAA,oBAA0B,MAAA,iCAC9B,aAAA,CAAc,SAAA,IAAa,mBAAA,CAAoB,SAAA;EADjB;EAI5C,EAAA;EAHc;EAMd,MAAA,EAAQ,OAAA,CAAQ,SAAA;EANyB;EASzC,OAAA,GAAU,WAAA;EAHF;EAMR,SAAA,EAAW,IAAA;AAAA;;;;;UAOI,cAAA,mBACG,MAAA,oBAA0B,MAAA,iCAC9B,aAAA,CAAc,SAAA,IAAa,mBAAA,CAAoB,SAAA;EArB7D;EAAA,SAwBS,OAAA,EAAS,aAAA,CAAc,UAAA,CAAW,SAAA,EAAW,WAAA;EAxB1B;EAAA,SA2BnB,IAAA;EA3BoD;EA8B7D,MAAA,GAAS,EAAA,aAAe,OAAA;EAxBxB;EA2BA,KAAA,QAAa,OAAA;AAAA;;;;;;;cASF,kBAAA,mBACO,MAAA,oBAA0B,MAAA,iCAC9B,aAAA,CAAc,SAAA,IAAa,mBAAA,CAAoB,SAAA;EAAA,QAErD,OAAA;EAAA,QAEA,SAAA;EA5BU;;;EAiClB,GAAA,CAAI,KAAA,EAAO,UAAA,CAAW,SAAA,EAAW,WAAA;EAhC4B;;;EAwC7D,KAAA,CAAA,GAAS,UAAA,CAAW,SAAA,EAAW,WAAA;EArCC;;;;EA+ChC,MAAA,GAAM,EAAA;EAtCc;;;;EAkDpB,SAAA,QAAS,UAAA,CAAA,SAAA,EAAA,WAAA;EA9DK;EAAA,IAuEV,OAAA,CAAA,GAAW,aAAA,CAAc,UAAA,CAAW,SAAA,EAAW,WAAA;EAvEV;EAAA,IA4ErC,IAAA,CAAA;EAzEK;EA8ET,SAAA,GAAS,QAAA;EA9EuB;EAsFhC,WAAA;EAAA,QAIQ,eAAA;AAAA"}
|
package/dist/ui/queue.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
//#region src/ui/queue.ts
|
|
2
|
+
/**
|
|
3
|
+
* Tracks pending server-side runs created via `multitaskStrategy: "enqueue"`.
|
|
4
|
+
*
|
|
5
|
+
* Uses the same subscribe/getSnapshot pattern as StreamManager
|
|
6
|
+
* to integrate with framework-specific reactivity systems.
|
|
7
|
+
*/
|
|
8
|
+
var PendingRunsTracker = class {
|
|
9
|
+
pending = [];
|
|
10
|
+
listeners = /* @__PURE__ */ new Set();
|
|
11
|
+
/**
|
|
12
|
+
* Add a pending run entry.
|
|
13
|
+
*/
|
|
14
|
+
add(entry) {
|
|
15
|
+
this.pending.push(entry);
|
|
16
|
+
this.notifyListeners();
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Remove and return the next pending entry (FIFO).
|
|
20
|
+
*/
|
|
21
|
+
shift() {
|
|
22
|
+
const entry = this.pending.shift();
|
|
23
|
+
if (entry) this.notifyListeners();
|
|
24
|
+
return entry;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Remove a specific entry by ID.
|
|
28
|
+
* @returns true if the entry was found and removed.
|
|
29
|
+
*/
|
|
30
|
+
remove = (id) => {
|
|
31
|
+
const index = this.pending.findIndex((e) => e.id === id);
|
|
32
|
+
if (index === -1) return false;
|
|
33
|
+
this.pending.splice(index, 1);
|
|
34
|
+
this.notifyListeners();
|
|
35
|
+
return true;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Remove all entries from the tracker.
|
|
39
|
+
* @returns The removed entries (for server-side cancellation).
|
|
40
|
+
*/
|
|
41
|
+
removeAll = () => {
|
|
42
|
+
if (this.pending.length === 0) return [];
|
|
43
|
+
const entries = [...this.pending];
|
|
44
|
+
this.pending = [];
|
|
45
|
+
this.notifyListeners();
|
|
46
|
+
return entries;
|
|
47
|
+
};
|
|
48
|
+
/** Read-only snapshot of all pending entries. */
|
|
49
|
+
get entries() {
|
|
50
|
+
return this.pending;
|
|
51
|
+
}
|
|
52
|
+
/** Number of pending entries. */
|
|
53
|
+
get size() {
|
|
54
|
+
return this.pending.length;
|
|
55
|
+
}
|
|
56
|
+
/** Subscribe to state changes. Returns an unsubscribe function. */
|
|
57
|
+
subscribe = (listener) => {
|
|
58
|
+
this.listeners.add(listener);
|
|
59
|
+
return () => {
|
|
60
|
+
this.listeners.delete(listener);
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
/** Snapshot token for useSyncExternalStore compatibility. */
|
|
64
|
+
getSnapshot = () => {
|
|
65
|
+
return this.pending.length;
|
|
66
|
+
};
|
|
67
|
+
notifyListeners() {
|
|
68
|
+
for (const listener of this.listeners) listener();
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
//#endregion
|
|
73
|
+
export { PendingRunsTracker };
|
|
74
|
+
//# sourceMappingURL=queue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue.js","names":[],"sources":["../../src/ui/queue.ts"],"sourcesContent":["import type { SubmitOptions, CustomSubmitOptions } from \"./types.js\";\n\n/**\n * A single queued submission entry representing a server-side pending run.\n * Each entry corresponds to a run created on the server via\n * `client.runs.create()` with `multitaskStrategy: \"enqueue\"`.\n */\nexport interface QueueEntry<\n StateType extends Record<string, unknown> = Record<string, unknown>,\n OptionsType = SubmitOptions<StateType> | CustomSubmitOptions<StateType>\n> {\n /** Server-side run ID (from `client.runs.create()`) */\n id: string;\n\n /** The state update values passed to submit() */\n values: Partial<StateType> | null | undefined;\n\n /** The submit options passed to submit() */\n options?: OptionsType;\n\n /** Timestamp when the entry was created */\n createdAt: Date;\n}\n\n/**\n * Reactive interface exposed to framework consumers for observing\n * and managing the server-side submission queue.\n */\nexport interface QueueInterface<\n StateType extends Record<string, unknown> = Record<string, unknown>,\n OptionsType = SubmitOptions<StateType> | CustomSubmitOptions<StateType>\n> {\n /** Read-only array of pending queue entries */\n readonly entries: ReadonlyArray<QueueEntry<StateType, OptionsType>>;\n\n /** Number of pending entries */\n readonly size: number;\n\n /** Cancel a specific pending run by its server run ID. Returns true if found and cancelled. */\n cancel: (id: string) => Promise<boolean>;\n\n /** Cancel all pending runs on the server and clear the queue. */\n clear: () => Promise<void>;\n}\n\n/**\n * Tracks pending server-side runs created via `multitaskStrategy: \"enqueue\"`.\n *\n * Uses the same subscribe/getSnapshot pattern as StreamManager\n * to integrate with framework-specific reactivity systems.\n */\nexport class PendingRunsTracker<\n StateType extends Record<string, unknown> = Record<string, unknown>,\n OptionsType = SubmitOptions<StateType> | CustomSubmitOptions<StateType>\n> {\n private pending: QueueEntry<StateType, OptionsType>[] = [];\n\n private listeners = new Set<() => void>();\n\n /**\n * Add a pending run entry.\n */\n add(entry: QueueEntry<StateType, OptionsType>): void {\n this.pending.push(entry);\n this.notifyListeners();\n }\n\n /**\n * Remove and return the next pending entry (FIFO).\n */\n shift(): QueueEntry<StateType, OptionsType> | undefined {\n const entry = this.pending.shift();\n if (entry) this.notifyListeners();\n return entry;\n }\n\n /**\n * Remove a specific entry by ID.\n * @returns true if the entry was found and removed.\n */\n remove = (id: string): boolean => {\n const index = this.pending.findIndex((e) => e.id === id);\n if (index === -1) return false;\n this.pending.splice(index, 1);\n this.notifyListeners();\n return true;\n };\n\n /**\n * Remove all entries from the tracker.\n * @returns The removed entries (for server-side cancellation).\n */\n removeAll = (): QueueEntry<StateType, OptionsType>[] => {\n if (this.pending.length === 0) return [];\n const entries = [...this.pending];\n this.pending = [];\n this.notifyListeners();\n return entries;\n };\n\n /** Read-only snapshot of all pending entries. */\n get entries(): ReadonlyArray<QueueEntry<StateType, OptionsType>> {\n return this.pending;\n }\n\n /** Number of pending entries. */\n get size(): number {\n return this.pending.length;\n }\n\n /** Subscribe to state changes. Returns an unsubscribe function. */\n subscribe = (listener: () => void): (() => void) => {\n this.listeners.add(listener);\n return () => {\n this.listeners.delete(listener);\n };\n };\n\n /** Snapshot token for useSyncExternalStore compatibility. */\n getSnapshot = (): number => {\n return this.pending.length;\n };\n\n private notifyListeners(): void {\n for (const listener of this.listeners) {\n listener();\n }\n }\n}\n"],"mappings":";;;;;;;AAmDA,IAAa,qBAAb,MAGE;CACA,AAAQ,UAAgD,EAAE;CAE1D,AAAQ,4BAAY,IAAI,KAAiB;;;;CAKzC,IAAI,OAAiD;AACnD,OAAK,QAAQ,KAAK,MAAM;AACxB,OAAK,iBAAiB;;;;;CAMxB,QAAwD;EACtD,MAAM,QAAQ,KAAK,QAAQ,OAAO;AAClC,MAAI,MAAO,MAAK,iBAAiB;AACjC,SAAO;;;;;;CAOT,UAAU,OAAwB;EAChC,MAAM,QAAQ,KAAK,QAAQ,WAAW,MAAM,EAAE,OAAO,GAAG;AACxD,MAAI,UAAU,GAAI,QAAO;AACzB,OAAK,QAAQ,OAAO,OAAO,EAAE;AAC7B,OAAK,iBAAiB;AACtB,SAAO;;;;;;CAOT,kBAAwD;AACtD,MAAI,KAAK,QAAQ,WAAW,EAAG,QAAO,EAAE;EACxC,MAAM,UAAU,CAAC,GAAG,KAAK,QAAQ;AACjC,OAAK,UAAU,EAAE;AACjB,OAAK,iBAAiB;AACtB,SAAO;;;CAIT,IAAI,UAA6D;AAC/D,SAAO,KAAK;;;CAId,IAAI,OAAe;AACjB,SAAO,KAAK,QAAQ;;;CAItB,aAAa,aAAuC;AAClD,OAAK,UAAU,IAAI,SAAS;AAC5B,eAAa;AACX,QAAK,UAAU,OAAO,SAAS;;;;CAKnC,oBAA4B;AAC1B,SAAO,KAAK,QAAQ;;CAGtB,AAAQ,kBAAwB;AAC9B,OAAK,MAAM,YAAY,KAAK,UAC1B,WAAU"}
|
|
@@ -6,6 +6,7 @@ import { Client } from "../../client.cjs";
|
|
|
6
6
|
import { BagTemplate } from "../../types.template.cjs";
|
|
7
7
|
import { GetConfigurableType, GetInterruptType, GetUpdateType, MessageMetadata, SubmitOptions } from "../types.cjs";
|
|
8
8
|
import { Sequence } from "../branching.cjs";
|
|
9
|
+
import { QueueInterface } from "../queue.cjs";
|
|
9
10
|
|
|
10
11
|
//#region src/ui/stream/base.d.ts
|
|
11
12
|
/**
|
|
@@ -142,6 +143,16 @@ interface BaseStream<StateType extends Record<string, unknown> = Record<string,
|
|
|
142
143
|
data: unknown;
|
|
143
144
|
}) => boolean;
|
|
144
145
|
}) => Promise<void>;
|
|
146
|
+
/**
|
|
147
|
+
* Switch to a different thread, clearing the current stream state.
|
|
148
|
+
* Pass `null` to reset to no thread (a new thread will be created on next submit).
|
|
149
|
+
*/
|
|
150
|
+
switchThread: (newThreadId: string | null) => void;
|
|
151
|
+
/**
|
|
152
|
+
* Server-side submission queue. Pending runs created via
|
|
153
|
+
* `multitaskStrategy: "enqueue"` when submitting while the agent is busy.
|
|
154
|
+
*/
|
|
155
|
+
queue: QueueInterface<StateType, SubmitOptions<StateType, GetConfigurableType<Bag>>>;
|
|
145
156
|
}
|
|
146
157
|
//#endregion
|
|
147
158
|
export { BaseStream };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.cts","names":[],"sources":["../../../src/ui/stream/base.ts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AA,GAAe,WAAA;;;;;EAMf,KAAA,EAAO,cAAA,CACL,SAAA,EACA,aAAA,CAAc,SAAA,EAAW,mBAAA,CAAoB,GAAA;AAAA"}
|
package/dist/ui/stream/base.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { Client } from "../../client.js";
|
|
|
6
6
|
import { BagTemplate } from "../../types.template.js";
|
|
7
7
|
import { GetConfigurableType, GetInterruptType, GetUpdateType, MessageMetadata, SubmitOptions } from "../types.js";
|
|
8
8
|
import { Sequence } from "../branching.js";
|
|
9
|
+
import { QueueInterface } from "../queue.js";
|
|
9
10
|
|
|
10
11
|
//#region src/ui/stream/base.d.ts
|
|
11
12
|
/**
|
|
@@ -142,6 +143,16 @@ interface BaseStream<StateType extends Record<string, unknown> = Record<string,
|
|
|
142
143
|
data: unknown;
|
|
143
144
|
}) => boolean;
|
|
144
145
|
}) => Promise<void>;
|
|
146
|
+
/**
|
|
147
|
+
* Switch to a different thread, clearing the current stream state.
|
|
148
|
+
* Pass `null` to reset to no thread (a new thread will be created on next submit).
|
|
149
|
+
*/
|
|
150
|
+
switchThread: (newThreadId: string | null) => void;
|
|
151
|
+
/**
|
|
152
|
+
* Server-side submission queue. Pending runs created via
|
|
153
|
+
* `multitaskStrategy: "enqueue"` when submitting while the agent is busy.
|
|
154
|
+
*/
|
|
155
|
+
queue: QueueInterface<StateType, SubmitOptions<StateType, GetConfigurableType<Bag>>>;
|
|
145
156
|
}
|
|
146
157
|
//#endregion
|
|
147
158
|
export { BaseStream };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","names":[],"sources":["../../../src/ui/stream/base.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"base.d.ts","names":[],"sources":["../../../src/ui/stream/base.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAkDiB,UAAA,mBACG,MAAA,oBAA0B,MAAA,8BACjC,eAAA,cACC,WAAA,GAAc,WAAA;EAoGL;;;;EA9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- Excludes: subagents, getSubagentsByType
|
|
108
108
|
*
|
|
109
|
-
* 3. **CompiledGraph** / **Default** → {@link
|
|
110
|
-
* - Includes: values, messages, submit, stop
|
|
111
|
-
* -
|
|
109
|
+
* 3. **CompiledGraph** / **Default** → {@link BaseStream}
|
|
110
|
+
* - Includes: values, messages, submit, stop
|
|
111
|
+
* - Does NOT include: toolCalls, subagents (not applicable to raw graphs)
|
|
112
112
|
*
|
|
113
113
|
* @template T - The agent or graph type (use `typeof agent` or `typeof graph`)
|
|
114
114
|
* @template Bag - Type configuration bag for interrupts, configurable, etc.
|
|
@@ -126,7 +126,7 @@ type InferSubagentStates<T> = T extends {
|
|
|
126
126
|
* // → UseDeepAgentStream (has toolCalls AND subagents)
|
|
127
127
|
* ```
|
|
128
128
|
*/
|
|
129
|
-
type ResolveStreamInterface<T, Bag extends BagTemplate = BagTemplate> = IsDeepAgent<T> extends true ? UseDeepAgentStream<InferStateType<T>, InferToolCalls<T>, InferSubagentStates<T>, Bag> : IsReactAgent<T> extends true ? UseAgentStream<InferStateType<T>, InferToolCalls<T>, Bag> :
|
|
129
|
+
type ResolveStreamInterface<T, Bag extends BagTemplate = BagTemplate> = IsDeepAgent<T> extends true ? UseDeepAgentStream<InferStateType<T>, InferToolCalls<T>, InferSubagentStates<T>, Bag> : IsReactAgent<T> extends true ? UseAgentStream<InferStateType<T>, InferToolCalls<T>, Bag> : BaseStream<InferStateType<T>, InferToolCalls<T>, Bag>;
|
|
130
130
|
/**
|
|
131
131
|
* Resolves the appropriate options interface based on the agent/graph type.
|
|
132
132
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../../../src/ui/stream/index.ts"],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../../src/ui/stream/index.ts"],"mappings":";;;;;;;;;;;KAgDK,WAAA,MAAiB,CAAA;EAAY,iBAAA,EAAmB,uBAAA;AAAA;;;;KAOh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;;;;;;;;AAZrD;;;;;;;;;;;;KA4CY,oBAAA,gBAEE,WAAA,GAAc,WAAA,IACxB,WAAA,CAAY,CAAA,iBACZ,yBAAA,CAA0B,cAAA,CAAe,CAAA,GAAI,GAAA,IAC7C,YAAA,CAAa,CAAA,iBACb,qBAAA,CAAsB,cAAA,CAAe,CAAA,GAAI,GAAA,IACzC,gBAAA,CAAiB,cAAA,CAAe,CAAA,GAAI,GAAA;;;;;;;KAY5B,QAAA,cAAsB,WAAA,GAAc,WAAA,IAAe,CAAA;EAC7D,aAAA;AAAA,IAEE,WAAA,GACA,CAAA"}
|
|
@@ -106,9 +106,9 @@ type InferSubagentStates<T> = T extends {
|
|
|
106
106
|
* - Includes: values, messages, toolCalls, getToolCalls
|
|
107
107
|
* - Excludes: subagents, getSubagentsByType
|
|
108
108
|
*
|
|
109
|
-
* 3. **CompiledGraph** / **Default** → {@link
|
|
110
|
-
* - Includes: values, messages, submit, stop
|
|
111
|
-
* -
|
|
109
|
+
* 3. **CompiledGraph** / **Default** → {@link BaseStream}
|
|
110
|
+
* - Includes: values, messages, submit, stop
|
|
111
|
+
* - Does NOT include: toolCalls, subagents (not applicable to raw graphs)
|
|
112
112
|
*
|
|
113
113
|
* @template T - The agent or graph type (use `typeof agent` or `typeof graph`)
|
|
114
114
|
* @template Bag - Type configuration bag for interrupts, configurable, etc.
|
|
@@ -126,7 +126,7 @@ type InferSubagentStates<T> = T extends {
|
|
|
126
126
|
* // → UseDeepAgentStream (has toolCalls AND subagents)
|
|
127
127
|
* ```
|
|
128
128
|
*/
|
|
129
|
-
type ResolveStreamInterface<T, Bag extends BagTemplate = BagTemplate> = IsDeepAgent<T> extends true ? UseDeepAgentStream<InferStateType<T>, InferToolCalls<T>, InferSubagentStates<T>, Bag> : IsReactAgent<T> extends true ? UseAgentStream<InferStateType<T>, InferToolCalls<T>, Bag> :
|
|
129
|
+
type ResolveStreamInterface<T, Bag extends BagTemplate = BagTemplate> = IsDeepAgent<T> extends true ? UseDeepAgentStream<InferStateType<T>, InferToolCalls<T>, InferSubagentStates<T>, Bag> : IsReactAgent<T> extends true ? UseAgentStream<InferStateType<T>, InferToolCalls<T>, Bag> : BaseStream<InferStateType<T>, InferToolCalls<T>, Bag>;
|
|
130
130
|
/**
|
|
131
131
|
* Resolves the appropriate options interface based on the agent/graph type.
|
|
132
132
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/ui/stream/index.ts"],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/ui/stream/index.ts"],"mappings":";;;;;;;;;;;KAgDK,WAAA,MAAiB,CAAA;EAAY,iBAAA,EAAmB,uBAAA;AAAA;;;;KAOhD,YAAA,MAAkB,CAAA;EAAY,aAAA,EAAe,mBAAA;AAAA,IAC9C,CAAA;EAAY,iBAAA;AAAA;;;;;;;;;;KAkBJ,cAAA,MAAoB,CAAA;EAAY,aAAA;AAAA,IACxC,eAAA,CAAgB,CAAA,IAChB,CAAA;EAAY,YAAA;AAAA,IACZ,CAAA,SAAU,MAAA,oBACR,CAAA,GACA,MAAA,oBACF,CAAA;EAAY,aAAA;AAAA,IACZ,CAAA,SAAU,MAAA,oBACR,CAAA,GACA,MAAA,oBACF,CAAA,SAAU,MAAA,oBACV,CAAA,GACA,MAAA;;;;;;;;;;;;;;;;;KAkBQ,cAAA,MAAoB,CAAA;EAAY,WAAA;AAAA,IACxC,CAAA,kBACE,OAAA,CAAQ,CAAA;;;;;;;;AAFd;;;;;;;;;;KAuBY,oBAAA,MAA0B,CAAA;EAAY,iBAAA;AAAA,IAC9C,CAAA,SAAU,MAAA,oBACR,CAAA,GACA,MAAA,SAAe,MAAA,qBACjB,MAAA,SAAe,MAAA;;;;;AAJnB;;KAYY,cAAA,MAAoB,CAAA;EAAY,aAAA;AAAA,IACxC,mBAAA,CAAoB,CAAA,IACpB,eAAA;;;;;;;KAQQ,mBAAA,MAAyB,CAAA;EAAY,iBAAA;AAAA,IAC7C,gBAAA,CAAiB,CAAA,EAAG,mBAAA,CAAoB,CAAA,KACxC,qBAAA;;;;;;;;;;;AAZJ;;;;;;;;;;;;;;;;;AAUA;;;;;;KAyCY,sBAAA,gBAEE,WAAA,GAAc,WAAA,IACxB,WAAA,CAAY,CAAA,iBACZ,kBAAA,CACE,cAAA,CAAe,CAAA,GACf,cAAA,CAAe,CAAA,GACf,mBAAA,CAAoB,CAAA,GACpB,GAAA,IAEF,YAAA,CAAa,CAAA,iBACb,cAAA,CAAe,cAAA,CAAe,CAAA,GAAI,cAAA,CAAe,CAAA,GAAI,GAAA,IACrD,UAAA,CAAW,cAAA,CAAe,CAAA,GAAI,cAAA,CAAe,CAAA,GAAI,GAAA;;;;;;;;;;;;;;;AAZrD;;;;;;;;;;;;KA4CY,oBAAA,gBAEE,WAAA,GAAc,WAAA,IACxB,WAAA,CAAY,CAAA,iBACZ,yBAAA,CAA0B,cAAA,CAAe,CAAA,GAAI,GAAA,IAC7C,YAAA,CAAa,CAAA,iBACb,qBAAA,CAAsB,cAAA,CAAe,CAAA,GAAI,GAAA,IACzC,gBAAA,CAAiB,cAAA,CAAe,CAAA,GAAI,GAAA;;;;;;;KAY5B,QAAA,cAAsB,WAAA,GAAc,WAAA,IAAe,CAAA;EAC7D,aAAA;AAAA,IAEE,WAAA,GACA,CAAA"}
|
package/dist/ui/subagents.cjs
CHANGED
|
@@ -87,9 +87,11 @@ var SubagentManager = class {
|
|
|
87
87
|
messageManagers = /* @__PURE__ */ new Map();
|
|
88
88
|
subagentToolNames;
|
|
89
89
|
onSubagentChange;
|
|
90
|
+
toMessage;
|
|
90
91
|
constructor(options) {
|
|
91
92
|
this.subagentToolNames = new Set(options?.subagentToolNames ?? DEFAULT_SUBAGENT_TOOL_NAMES);
|
|
92
93
|
this.onSubagentChange = options?.onSubagentChange;
|
|
94
|
+
this.toMessage = options?.toMessage ?? require_messages.toMessageDict;
|
|
93
95
|
}
|
|
94
96
|
/**
|
|
95
97
|
* Get or create a MessageTupleManager for a subagent.
|
|
@@ -110,7 +112,7 @@ var SubagentManager = class {
|
|
|
110
112
|
const manager = this.messageManagers.get(toolCallId);
|
|
111
113
|
if (!manager) return [];
|
|
112
114
|
const messages = [];
|
|
113
|
-
for (const entry of Object.values(manager.chunks)) if (entry.chunk) messages.push(
|
|
115
|
+
for (const entry of Object.values(manager.chunks)) if (entry.chunk) messages.push(this.toMessage(entry.chunk));
|
|
114
116
|
return messages;
|
|
115
117
|
}
|
|
116
118
|
/**
|
|
@@ -129,6 +131,7 @@ var SubagentManager = class {
|
|
|
129
131
|
},
|
|
130
132
|
interrupt: void 0,
|
|
131
133
|
interrupts: [],
|
|
134
|
+
switchThread: () => {},
|
|
132
135
|
subagents: /* @__PURE__ */ new Map(),
|
|
133
136
|
activeSubagents: [],
|
|
134
137
|
getSubagent: () => void 0,
|