@tangle-network/agent-app 1.0.24 → 1.0.25
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.
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
* {type:'turn'|'metadata'|'error'|'turn_status', ...} (route-level)
|
|
9
9
|
* {type:'interaction', data:{request}} (sidecar ask)
|
|
10
10
|
*
|
|
11
|
-
* Replayed lines carry an extra `seq` —
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* Replayed lines carry an extra `seq` — `consumeChatStream` tracks the last
|
|
12
|
+
* one so `streamChatTurn` can resume a dropped replay from the tail instead of
|
|
13
|
+
* replaying the whole turn.
|
|
14
14
|
*/
|
|
15
15
|
import { type ChatInteraction, type InteractionCancelData } from './chat-interactions.js';
|
|
16
16
|
import { type ChatPlan } from '../plans/index.js';
|
|
@@ -149,15 +149,23 @@ export interface ConsumeChatStreamResult {
|
|
|
149
149
|
turnId: string | null;
|
|
150
150
|
/** True when any text/reasoning/tool activity was received. */
|
|
151
151
|
receivedContent: boolean;
|
|
152
|
+
/** The last `seq` a replayed line stamped (0 when none did): a resume after
|
|
153
|
+
* a replay continues from here; after a live stream it starts from 0. */
|
|
154
|
+
lastSeq: number;
|
|
152
155
|
}
|
|
153
156
|
/** Parse one NDJSON line into the callbacks. Exposed for tests. */
|
|
154
157
|
export declare function dispatchChatStreamLine(line: string, cb: ChatStreamCallbacks): {
|
|
155
158
|
turnId?: string;
|
|
156
159
|
receivedContent: boolean;
|
|
160
|
+
/** The line's stamped buffer ordinal, when it carried a positive one. */
|
|
161
|
+
seq?: number;
|
|
157
162
|
};
|
|
158
163
|
/** Drain one NDJSON body into the callbacks. Throws on transport failure
|
|
159
|
-
* (caller decides whether to resume).
|
|
160
|
-
|
|
164
|
+
* (caller decides whether to resume). `seen` accumulates the last stamped seq
|
|
165
|
+
* as lines arrive so it survives this stream dropping. */
|
|
166
|
+
export declare function consumeChatStream(body: ReadableStream<Uint8Array>, cb: ChatStreamCallbacks, seen?: {
|
|
167
|
+
lastSeq: number;
|
|
168
|
+
}): Promise<ConsumeChatStreamResult>;
|
|
161
169
|
/** Define options for managing and resuming streaming chat interactions with callbacks */
|
|
162
170
|
export interface StreamChatOptions {
|
|
163
171
|
/** Start the turn (POST the chat request); must return a streaming Response. */
|
|
@@ -166,12 +174,22 @@ export interface StreamChatOptions {
|
|
|
166
174
|
resume?: (turnId: string, fromSeq: number) => Promise<Response>;
|
|
167
175
|
callbacks: ChatStreamCallbacks;
|
|
168
176
|
/** Called before a resume replays from 0 so the UI can reset accumulated
|
|
169
|
-
* turn state (
|
|
177
|
+
* turn state. A tail resume (fromSeq > 0) keeps it and does not call this. */
|
|
170
178
|
onResetForResume?: () => void;
|
|
179
|
+
/** Automatic reconnects after transport drops before the turn fails with the
|
|
180
|
+
* last transport error. Default 5. */
|
|
181
|
+
maxReconnects?: number;
|
|
182
|
+
/** Milliseconds to wait before reconnect attempt N (0-based); default
|
|
183
|
+
* {@link defaultReconnectDelayMs}. */
|
|
184
|
+
reconnectDelayMs?: (attempt: number) => number;
|
|
171
185
|
}
|
|
186
|
+
/** The default reconnect schedule: exponential from 500ms with ±50% jitter, capped at 8s. */
|
|
187
|
+
export declare function defaultReconnectDelayMs(attempt: number, rand?: () => number): number;
|
|
172
188
|
/**
|
|
173
|
-
* Run one chat turn with automatic
|
|
174
|
-
*
|
|
175
|
-
*
|
|
189
|
+
* Run one chat turn with bounded automatic resume: reconnect with backoff and
|
|
190
|
+
* resume from the last stamped seq — a live drop resets and replays from 0, a
|
|
191
|
+
* replay drop resumes the tail only, one reasoning tracker across all of it.
|
|
192
|
+
* The turn keeps running server-side (queued runner); once the reconnect
|
|
193
|
+
* budget is spent the last transport error surfaces.
|
|
176
194
|
*/
|
|
177
195
|
export declare function streamChatTurn(opts: StreamChatOptions): Promise<ConsumeChatStreamResult>;
|
package/dist/web-react/index.js
CHANGED
|
@@ -57,6 +57,7 @@ import {
|
|
|
57
57
|
createInteractionAnswerSubmitter,
|
|
58
58
|
createMemoryInteractionAttemptStore,
|
|
59
59
|
createSessionInteractionAttemptStore,
|
|
60
|
+
defaultReconnectDelayMs,
|
|
60
61
|
describeProvenance,
|
|
61
62
|
describeProvenanceSourceStatus,
|
|
62
63
|
diffRecordGridProposal,
|
|
@@ -151,7 +152,7 @@ import {
|
|
|
151
152
|
withoutRecordGridCreated,
|
|
152
153
|
withoutRecordGridRemoved,
|
|
153
154
|
withoutRecordGridUpdate
|
|
154
|
-
} from "../chunk-
|
|
155
|
+
} from "../chunk-3VEXCVZB.js";
|
|
155
156
|
import {
|
|
156
157
|
useInfiniteScroll
|
|
157
158
|
} from "../chunk-UHSUY6H6.js";
|
|
@@ -446,6 +447,7 @@ export {
|
|
|
446
447
|
createMemoryInteractionAttemptStore,
|
|
447
448
|
createSessionInteractionAttemptStore,
|
|
448
449
|
dedupeQuestionInteractionsByContent,
|
|
450
|
+
defaultReconnectDelayMs,
|
|
449
451
|
describeProvenance,
|
|
450
452
|
describeProvenanceSourceStatus,
|
|
451
453
|
dictationErrorMessage,
|
package/package.json
CHANGED