@linnlabs/linnkit 0.32.1 → 0.32.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/CHANGELOG.md +6 -0
- package/dist/cli.cjs +35 -14
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +35 -14
- package/dist/cli.js.map +1 -1
- package/dist/contracts/agentSpec.d.cts +30 -30
- package/dist/contracts/agentSpec.d.ts +30 -30
- package/dist/contracts/audit.d.cts +32 -32
- package/dist/contracts/audit.d.ts +32 -32
- package/dist/contracts/contextPolicy.d.cts +36 -36
- package/dist/contracts/contextPolicy.d.ts +36 -36
- package/dist/contracts/events.d.cts +963 -963
- package/dist/contracts/events.d.ts +963 -963
- package/dist/contracts/execution.d.cts +8 -8
- package/dist/contracts/execution.d.ts +8 -8
- package/dist/contracts/messages.d.cts +204 -204
- package/dist/contracts/messages.d.ts +204 -204
- package/dist/contracts/sse.d.cts +889 -889
- package/dist/contracts/sse.d.ts +889 -889
- package/dist/contracts/sub-run-trace-payload.d.cts +26 -26
- package/dist/contracts/sub-run-trace-payload.d.ts +26 -26
- package/dist/contracts/token-accounting.d.cts +28 -28
- package/dist/contracts/token-accounting.d.ts +28 -28
- package/dist/index.cjs +35 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +35 -14
- package/dist/index.js.map +1 -1
- package/dist/quickstart.cjs +35 -14
- package/dist/quickstart.cjs.map +1 -1
- package/dist/quickstart.js +35 -14
- package/dist/quickstart.js.map +1 -1
- package/dist/runtime-kernel/events/agentEvents.d.cts +98 -98
- package/dist/runtime-kernel/events/agentEvents.d.ts +98 -98
- package/dist/runtime-kernel.cjs +35 -14
- package/dist/runtime-kernel.cjs.map +1 -1
- package/dist/runtime-kernel.js +35 -14
- package/dist/runtime-kernel.js.map +1 -1
- package/dist/testkit.cjs +35 -14
- package/dist/testkit.cjs.map +1 -1
- package/dist/testkit.js +35 -14
- package/dist/testkit.js.map +1 -1
- package/package.json +2 -2
|
@@ -56,8 +56,8 @@ declare const ContextTokenComponent: z.ZodObject<{
|
|
|
56
56
|
profileId: z.ZodOptional<z.ZodString>;
|
|
57
57
|
estimatorVersion: z.ZodOptional<z.ZodString>;
|
|
58
58
|
}, "strip", z.ZodTypeAny, {
|
|
59
|
+
kind: "system" | "user" | "assistant" | "tool" | "context-injection" | "history-summary" | "working-memory" | "fence" | "system-reminder" | "image-attachment" | "other";
|
|
59
60
|
source: "local-estimate" | "provider-preflight-count" | "provider-response-usage" | "host-supplied" | "test-fixture";
|
|
60
|
-
kind: "user" | "system" | "tool" | "assistant" | "context-injection" | "history-summary" | "working-memory" | "fence" | "system-reminder" | "image-attachment" | "other";
|
|
61
61
|
confidence: "estimate" | "provider-estimate" | "actual";
|
|
62
62
|
componentId: string;
|
|
63
63
|
tokens: number;
|
|
@@ -65,9 +65,9 @@ declare const ContextTokenComponent: z.ZodObject<{
|
|
|
65
65
|
width?: number | undefined;
|
|
66
66
|
height?: number | undefined;
|
|
67
67
|
label?: string | undefined;
|
|
68
|
-
action?: string | undefined;
|
|
69
68
|
role?: string | undefined;
|
|
70
69
|
profileId?: string | undefined;
|
|
70
|
+
action?: string | undefined;
|
|
71
71
|
messageId?: string | undefined;
|
|
72
72
|
kept?: boolean | undefined;
|
|
73
73
|
truncatedAtExecution?: boolean | undefined;
|
|
@@ -78,8 +78,8 @@ declare const ContextTokenComponent: z.ZodObject<{
|
|
|
78
78
|
attachmentIndex?: number | undefined;
|
|
79
79
|
estimatorVersion?: string | undefined;
|
|
80
80
|
}, {
|
|
81
|
+
kind: "system" | "user" | "assistant" | "tool" | "context-injection" | "history-summary" | "working-memory" | "fence" | "system-reminder" | "image-attachment" | "other";
|
|
81
82
|
source: "local-estimate" | "provider-preflight-count" | "provider-response-usage" | "host-supplied" | "test-fixture";
|
|
82
|
-
kind: "user" | "system" | "tool" | "assistant" | "context-injection" | "history-summary" | "working-memory" | "fence" | "system-reminder" | "image-attachment" | "other";
|
|
83
83
|
confidence: "estimate" | "provider-estimate" | "actual";
|
|
84
84
|
componentId: string;
|
|
85
85
|
tokens: number;
|
|
@@ -87,9 +87,9 @@ declare const ContextTokenComponent: z.ZodObject<{
|
|
|
87
87
|
width?: number | undefined;
|
|
88
88
|
height?: number | undefined;
|
|
89
89
|
label?: string | undefined;
|
|
90
|
-
action?: string | undefined;
|
|
91
90
|
role?: string | undefined;
|
|
92
91
|
profileId?: string | undefined;
|
|
92
|
+
action?: string | undefined;
|
|
93
93
|
messageId?: string | undefined;
|
|
94
94
|
kept?: boolean | undefined;
|
|
95
95
|
truncatedAtExecution?: boolean | undefined;
|
|
@@ -205,9 +205,9 @@ declare const LlmUsageTokenLedgerEntry: z.ZodObject<{
|
|
|
205
205
|
totalTokens?: number | undefined;
|
|
206
206
|
rawUsage?: unknown;
|
|
207
207
|
};
|
|
208
|
+
conversationId?: string | undefined;
|
|
208
209
|
runId?: string | undefined;
|
|
209
210
|
parentRunId?: string | undefined;
|
|
210
|
-
conversationId?: string | undefined;
|
|
211
211
|
turnId?: string | undefined;
|
|
212
212
|
modelId?: string | undefined;
|
|
213
213
|
stepId?: string | undefined;
|
|
@@ -239,9 +239,9 @@ declare const LlmUsageTokenLedgerEntry: z.ZodObject<{
|
|
|
239
239
|
totalTokens?: number | undefined;
|
|
240
240
|
rawUsage?: unknown;
|
|
241
241
|
};
|
|
242
|
+
conversationId?: string | undefined;
|
|
242
243
|
runId?: string | undefined;
|
|
243
244
|
parentRunId?: string | undefined;
|
|
244
|
-
conversationId?: string | undefined;
|
|
245
245
|
turnId?: string | undefined;
|
|
246
246
|
modelId?: string | undefined;
|
|
247
247
|
stepId?: string | undefined;
|
|
@@ -337,8 +337,8 @@ declare const ContextComponentTokenLedgerEntry: z.ZodObject<{
|
|
|
337
337
|
profileId: z.ZodOptional<z.ZodString>;
|
|
338
338
|
estimatorVersion: z.ZodOptional<z.ZodString>;
|
|
339
339
|
}, "strip", z.ZodTypeAny, {
|
|
340
|
+
kind: "system" | "user" | "assistant" | "tool" | "context-injection" | "history-summary" | "working-memory" | "fence" | "system-reminder" | "image-attachment" | "other";
|
|
340
341
|
source: "local-estimate" | "provider-preflight-count" | "provider-response-usage" | "host-supplied" | "test-fixture";
|
|
341
|
-
kind: "user" | "system" | "tool" | "assistant" | "context-injection" | "history-summary" | "working-memory" | "fence" | "system-reminder" | "image-attachment" | "other";
|
|
342
342
|
confidence: "estimate" | "provider-estimate" | "actual";
|
|
343
343
|
componentId: string;
|
|
344
344
|
tokens: number;
|
|
@@ -346,9 +346,9 @@ declare const ContextComponentTokenLedgerEntry: z.ZodObject<{
|
|
|
346
346
|
width?: number | undefined;
|
|
347
347
|
height?: number | undefined;
|
|
348
348
|
label?: string | undefined;
|
|
349
|
-
action?: string | undefined;
|
|
350
349
|
role?: string | undefined;
|
|
351
350
|
profileId?: string | undefined;
|
|
351
|
+
action?: string | undefined;
|
|
352
352
|
messageId?: string | undefined;
|
|
353
353
|
kept?: boolean | undefined;
|
|
354
354
|
truncatedAtExecution?: boolean | undefined;
|
|
@@ -359,8 +359,8 @@ declare const ContextComponentTokenLedgerEntry: z.ZodObject<{
|
|
|
359
359
|
attachmentIndex?: number | undefined;
|
|
360
360
|
estimatorVersion?: string | undefined;
|
|
361
361
|
}, {
|
|
362
|
+
kind: "system" | "user" | "assistant" | "tool" | "context-injection" | "history-summary" | "working-memory" | "fence" | "system-reminder" | "image-attachment" | "other";
|
|
362
363
|
source: "local-estimate" | "provider-preflight-count" | "provider-response-usage" | "host-supplied" | "test-fixture";
|
|
363
|
-
kind: "user" | "system" | "tool" | "assistant" | "context-injection" | "history-summary" | "working-memory" | "fence" | "system-reminder" | "image-attachment" | "other";
|
|
364
364
|
confidence: "estimate" | "provider-estimate" | "actual";
|
|
365
365
|
componentId: string;
|
|
366
366
|
tokens: number;
|
|
@@ -368,9 +368,9 @@ declare const ContextComponentTokenLedgerEntry: z.ZodObject<{
|
|
|
368
368
|
width?: number | undefined;
|
|
369
369
|
height?: number | undefined;
|
|
370
370
|
label?: string | undefined;
|
|
371
|
-
action?: string | undefined;
|
|
372
371
|
role?: string | undefined;
|
|
373
372
|
profileId?: string | undefined;
|
|
373
|
+
action?: string | undefined;
|
|
374
374
|
messageId?: string | undefined;
|
|
375
375
|
kept?: boolean | undefined;
|
|
376
376
|
truncatedAtExecution?: boolean | undefined;
|
|
@@ -386,8 +386,8 @@ declare const ContextComponentTokenLedgerEntry: z.ZodObject<{
|
|
|
386
386
|
id: string;
|
|
387
387
|
kind: "context-component";
|
|
388
388
|
components: {
|
|
389
|
+
kind: "system" | "user" | "assistant" | "tool" | "context-injection" | "history-summary" | "working-memory" | "fence" | "system-reminder" | "image-attachment" | "other";
|
|
389
390
|
source: "local-estimate" | "provider-preflight-count" | "provider-response-usage" | "host-supplied" | "test-fixture";
|
|
390
|
-
kind: "user" | "system" | "tool" | "assistant" | "context-injection" | "history-summary" | "working-memory" | "fence" | "system-reminder" | "image-attachment" | "other";
|
|
391
391
|
confidence: "estimate" | "provider-estimate" | "actual";
|
|
392
392
|
componentId: string;
|
|
393
393
|
tokens: number;
|
|
@@ -395,9 +395,9 @@ declare const ContextComponentTokenLedgerEntry: z.ZodObject<{
|
|
|
395
395
|
width?: number | undefined;
|
|
396
396
|
height?: number | undefined;
|
|
397
397
|
label?: string | undefined;
|
|
398
|
-
action?: string | undefined;
|
|
399
398
|
role?: string | undefined;
|
|
400
399
|
profileId?: string | undefined;
|
|
400
|
+
action?: string | undefined;
|
|
401
401
|
messageId?: string | undefined;
|
|
402
402
|
kept?: boolean | undefined;
|
|
403
403
|
truncatedAtExecution?: boolean | undefined;
|
|
@@ -409,9 +409,9 @@ declare const ContextComponentTokenLedgerEntry: z.ZodObject<{
|
|
|
409
409
|
estimatorVersion?: string | undefined;
|
|
410
410
|
}[];
|
|
411
411
|
totalTokens: number;
|
|
412
|
+
conversationId?: string | undefined;
|
|
412
413
|
runId?: string | undefined;
|
|
413
414
|
parentRunId?: string | undefined;
|
|
414
|
-
conversationId?: string | undefined;
|
|
415
415
|
turnId?: string | undefined;
|
|
416
416
|
stepId?: string | undefined;
|
|
417
417
|
route?: {
|
|
@@ -431,8 +431,8 @@ declare const ContextComponentTokenLedgerEntry: z.ZodObject<{
|
|
|
431
431
|
id: string;
|
|
432
432
|
kind: "context-component";
|
|
433
433
|
components: {
|
|
434
|
+
kind: "system" | "user" | "assistant" | "tool" | "context-injection" | "history-summary" | "working-memory" | "fence" | "system-reminder" | "image-attachment" | "other";
|
|
434
435
|
source: "local-estimate" | "provider-preflight-count" | "provider-response-usage" | "host-supplied" | "test-fixture";
|
|
435
|
-
kind: "user" | "system" | "tool" | "assistant" | "context-injection" | "history-summary" | "working-memory" | "fence" | "system-reminder" | "image-attachment" | "other";
|
|
436
436
|
confidence: "estimate" | "provider-estimate" | "actual";
|
|
437
437
|
componentId: string;
|
|
438
438
|
tokens: number;
|
|
@@ -440,9 +440,9 @@ declare const ContextComponentTokenLedgerEntry: z.ZodObject<{
|
|
|
440
440
|
width?: number | undefined;
|
|
441
441
|
height?: number | undefined;
|
|
442
442
|
label?: string | undefined;
|
|
443
|
-
action?: string | undefined;
|
|
444
443
|
role?: string | undefined;
|
|
445
444
|
profileId?: string | undefined;
|
|
445
|
+
action?: string | undefined;
|
|
446
446
|
messageId?: string | undefined;
|
|
447
447
|
kept?: boolean | undefined;
|
|
448
448
|
truncatedAtExecution?: boolean | undefined;
|
|
@@ -454,9 +454,9 @@ declare const ContextComponentTokenLedgerEntry: z.ZodObject<{
|
|
|
454
454
|
estimatorVersion?: string | undefined;
|
|
455
455
|
}[];
|
|
456
456
|
totalTokens: number;
|
|
457
|
+
conversationId?: string | undefined;
|
|
457
458
|
runId?: string | undefined;
|
|
458
459
|
parentRunId?: string | undefined;
|
|
459
|
-
conversationId?: string | undefined;
|
|
460
460
|
turnId?: string | undefined;
|
|
461
461
|
stepId?: string | undefined;
|
|
462
462
|
route?: {
|
|
@@ -578,9 +578,9 @@ declare const TokenLedgerEntry: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
|
578
578
|
totalTokens?: number | undefined;
|
|
579
579
|
rawUsage?: unknown;
|
|
580
580
|
};
|
|
581
|
+
conversationId?: string | undefined;
|
|
581
582
|
runId?: string | undefined;
|
|
582
583
|
parentRunId?: string | undefined;
|
|
583
|
-
conversationId?: string | undefined;
|
|
584
584
|
turnId?: string | undefined;
|
|
585
585
|
modelId?: string | undefined;
|
|
586
586
|
stepId?: string | undefined;
|
|
@@ -612,9 +612,9 @@ declare const TokenLedgerEntry: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
|
612
612
|
totalTokens?: number | undefined;
|
|
613
613
|
rawUsage?: unknown;
|
|
614
614
|
};
|
|
615
|
+
conversationId?: string | undefined;
|
|
615
616
|
runId?: string | undefined;
|
|
616
617
|
parentRunId?: string | undefined;
|
|
617
|
-
conversationId?: string | undefined;
|
|
618
618
|
turnId?: string | undefined;
|
|
619
619
|
modelId?: string | undefined;
|
|
620
620
|
stepId?: string | undefined;
|
|
@@ -708,8 +708,8 @@ declare const TokenLedgerEntry: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
|
708
708
|
profileId: z.ZodOptional<z.ZodString>;
|
|
709
709
|
estimatorVersion: z.ZodOptional<z.ZodString>;
|
|
710
710
|
}, "strip", z.ZodTypeAny, {
|
|
711
|
+
kind: "system" | "user" | "assistant" | "tool" | "context-injection" | "history-summary" | "working-memory" | "fence" | "system-reminder" | "image-attachment" | "other";
|
|
711
712
|
source: "local-estimate" | "provider-preflight-count" | "provider-response-usage" | "host-supplied" | "test-fixture";
|
|
712
|
-
kind: "user" | "system" | "tool" | "assistant" | "context-injection" | "history-summary" | "working-memory" | "fence" | "system-reminder" | "image-attachment" | "other";
|
|
713
713
|
confidence: "estimate" | "provider-estimate" | "actual";
|
|
714
714
|
componentId: string;
|
|
715
715
|
tokens: number;
|
|
@@ -717,9 +717,9 @@ declare const TokenLedgerEntry: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
|
717
717
|
width?: number | undefined;
|
|
718
718
|
height?: number | undefined;
|
|
719
719
|
label?: string | undefined;
|
|
720
|
-
action?: string | undefined;
|
|
721
720
|
role?: string | undefined;
|
|
722
721
|
profileId?: string | undefined;
|
|
722
|
+
action?: string | undefined;
|
|
723
723
|
messageId?: string | undefined;
|
|
724
724
|
kept?: boolean | undefined;
|
|
725
725
|
truncatedAtExecution?: boolean | undefined;
|
|
@@ -730,8 +730,8 @@ declare const TokenLedgerEntry: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
|
730
730
|
attachmentIndex?: number | undefined;
|
|
731
731
|
estimatorVersion?: string | undefined;
|
|
732
732
|
}, {
|
|
733
|
+
kind: "system" | "user" | "assistant" | "tool" | "context-injection" | "history-summary" | "working-memory" | "fence" | "system-reminder" | "image-attachment" | "other";
|
|
733
734
|
source: "local-estimate" | "provider-preflight-count" | "provider-response-usage" | "host-supplied" | "test-fixture";
|
|
734
|
-
kind: "user" | "system" | "tool" | "assistant" | "context-injection" | "history-summary" | "working-memory" | "fence" | "system-reminder" | "image-attachment" | "other";
|
|
735
735
|
confidence: "estimate" | "provider-estimate" | "actual";
|
|
736
736
|
componentId: string;
|
|
737
737
|
tokens: number;
|
|
@@ -739,9 +739,9 @@ declare const TokenLedgerEntry: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
|
739
739
|
width?: number | undefined;
|
|
740
740
|
height?: number | undefined;
|
|
741
741
|
label?: string | undefined;
|
|
742
|
-
action?: string | undefined;
|
|
743
742
|
role?: string | undefined;
|
|
744
743
|
profileId?: string | undefined;
|
|
744
|
+
action?: string | undefined;
|
|
745
745
|
messageId?: string | undefined;
|
|
746
746
|
kept?: boolean | undefined;
|
|
747
747
|
truncatedAtExecution?: boolean | undefined;
|
|
@@ -757,8 +757,8 @@ declare const TokenLedgerEntry: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
|
757
757
|
id: string;
|
|
758
758
|
kind: "context-component";
|
|
759
759
|
components: {
|
|
760
|
+
kind: "system" | "user" | "assistant" | "tool" | "context-injection" | "history-summary" | "working-memory" | "fence" | "system-reminder" | "image-attachment" | "other";
|
|
760
761
|
source: "local-estimate" | "provider-preflight-count" | "provider-response-usage" | "host-supplied" | "test-fixture";
|
|
761
|
-
kind: "user" | "system" | "tool" | "assistant" | "context-injection" | "history-summary" | "working-memory" | "fence" | "system-reminder" | "image-attachment" | "other";
|
|
762
762
|
confidence: "estimate" | "provider-estimate" | "actual";
|
|
763
763
|
componentId: string;
|
|
764
764
|
tokens: number;
|
|
@@ -766,9 +766,9 @@ declare const TokenLedgerEntry: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
|
766
766
|
width?: number | undefined;
|
|
767
767
|
height?: number | undefined;
|
|
768
768
|
label?: string | undefined;
|
|
769
|
-
action?: string | undefined;
|
|
770
769
|
role?: string | undefined;
|
|
771
770
|
profileId?: string | undefined;
|
|
771
|
+
action?: string | undefined;
|
|
772
772
|
messageId?: string | undefined;
|
|
773
773
|
kept?: boolean | undefined;
|
|
774
774
|
truncatedAtExecution?: boolean | undefined;
|
|
@@ -780,9 +780,9 @@ declare const TokenLedgerEntry: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
|
780
780
|
estimatorVersion?: string | undefined;
|
|
781
781
|
}[];
|
|
782
782
|
totalTokens: number;
|
|
783
|
+
conversationId?: string | undefined;
|
|
783
784
|
runId?: string | undefined;
|
|
784
785
|
parentRunId?: string | undefined;
|
|
785
|
-
conversationId?: string | undefined;
|
|
786
786
|
turnId?: string | undefined;
|
|
787
787
|
stepId?: string | undefined;
|
|
788
788
|
route?: {
|
|
@@ -802,8 +802,8 @@ declare const TokenLedgerEntry: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
|
802
802
|
id: string;
|
|
803
803
|
kind: "context-component";
|
|
804
804
|
components: {
|
|
805
|
+
kind: "system" | "user" | "assistant" | "tool" | "context-injection" | "history-summary" | "working-memory" | "fence" | "system-reminder" | "image-attachment" | "other";
|
|
805
806
|
source: "local-estimate" | "provider-preflight-count" | "provider-response-usage" | "host-supplied" | "test-fixture";
|
|
806
|
-
kind: "user" | "system" | "tool" | "assistant" | "context-injection" | "history-summary" | "working-memory" | "fence" | "system-reminder" | "image-attachment" | "other";
|
|
807
807
|
confidence: "estimate" | "provider-estimate" | "actual";
|
|
808
808
|
componentId: string;
|
|
809
809
|
tokens: number;
|
|
@@ -811,9 +811,9 @@ declare const TokenLedgerEntry: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
|
811
811
|
width?: number | undefined;
|
|
812
812
|
height?: number | undefined;
|
|
813
813
|
label?: string | undefined;
|
|
814
|
-
action?: string | undefined;
|
|
815
814
|
role?: string | undefined;
|
|
816
815
|
profileId?: string | undefined;
|
|
816
|
+
action?: string | undefined;
|
|
817
817
|
messageId?: string | undefined;
|
|
818
818
|
kept?: boolean | undefined;
|
|
819
819
|
truncatedAtExecution?: boolean | undefined;
|
|
@@ -825,9 +825,9 @@ declare const TokenLedgerEntry: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
|
825
825
|
estimatorVersion?: string | undefined;
|
|
826
826
|
}[];
|
|
827
827
|
totalTokens: number;
|
|
828
|
+
conversationId?: string | undefined;
|
|
828
829
|
runId?: string | undefined;
|
|
829
830
|
parentRunId?: string | undefined;
|
|
830
|
-
conversationId?: string | undefined;
|
|
831
831
|
turnId?: string | undefined;
|
|
832
832
|
stepId?: string | undefined;
|
|
833
833
|
route?: {
|
package/dist/index.cjs
CHANGED
|
@@ -7266,16 +7266,21 @@ var GraphAgentExecutor = class {
|
|
|
7266
7266
|
};
|
|
7267
7267
|
|
|
7268
7268
|
// src/runtime-kernel/graph-engine/nodes/llmNode.state.ts
|
|
7269
|
+
function assertLlmNodeStreamChunkSequence(state, answerId, seq) {
|
|
7270
|
+
const answerChanged = state.answerId !== answerId;
|
|
7271
|
+
const expectedSeq = answerChanged ? 0 : state.chunkSeq;
|
|
7272
|
+
if (seq !== expectedSeq) {
|
|
7273
|
+
throw new Error(
|
|
7274
|
+
`final_answer_chunk sequence mismatch: answer=${answerId}, expected=${expectedSeq}, actual=${seq}`
|
|
7275
|
+
);
|
|
7276
|
+
}
|
|
7277
|
+
}
|
|
7269
7278
|
function llmNodeReducer(state, action) {
|
|
7270
7279
|
switch (action.type) {
|
|
7271
7280
|
case "STREAM_CHUNK_RECEIVED": {
|
|
7281
|
+
assertLlmNodeStreamChunkSequence(state, action.answerId, action.seq);
|
|
7272
7282
|
const answerChanged = state.answerId !== action.answerId;
|
|
7273
7283
|
const expectedSeq = answerChanged ? 0 : state.chunkSeq;
|
|
7274
|
-
if (action.seq !== expectedSeq) {
|
|
7275
|
-
throw new Error(
|
|
7276
|
-
`final_answer_chunk sequence mismatch: answer=${action.answerId}, expected=${expectedSeq}, actual=${action.seq}`
|
|
7277
|
-
);
|
|
7278
|
-
}
|
|
7279
7284
|
return {
|
|
7280
7285
|
...state,
|
|
7281
7286
|
answerId: action.answerId,
|
|
@@ -7966,12 +7971,21 @@ var LlmNodeEventBridge = class {
|
|
|
7966
7971
|
throw new Error("final_answer did not map to a final_answer RuntimeEvent.");
|
|
7967
7972
|
}
|
|
7968
7973
|
const liveChunk = createStandaloneFinalAnswerChunk(finalAnswer);
|
|
7974
|
+
assertLlmNodeStreamChunkSequence(
|
|
7975
|
+
this.deps.getState(),
|
|
7976
|
+
liveChunk.answer_id,
|
|
7977
|
+
liveChunk.seq
|
|
7978
|
+
);
|
|
7979
|
+
const publishedChunk = this.publish(liveChunk, "LlmNode.final_answer_chunk.standalone");
|
|
7980
|
+
if (publishedChunk.type !== "final_answer_chunk") {
|
|
7981
|
+
throw new Error("RuntimeEvent sink changed standalone final_answer_chunk type.");
|
|
7982
|
+
}
|
|
7969
7983
|
this.deps.dispatch({
|
|
7970
7984
|
type: "STREAM_CHUNK_RECEIVED",
|
|
7971
|
-
answerId:
|
|
7972
|
-
seq:
|
|
7985
|
+
answerId: publishedChunk.answer_id,
|
|
7986
|
+
seq: publishedChunk.seq
|
|
7973
7987
|
});
|
|
7974
|
-
this.buffer(
|
|
7988
|
+
this.buffer(publishedChunk);
|
|
7975
7989
|
this.buffer(this.publish(finalAnswer, "LlmNode.final_answer"));
|
|
7976
7990
|
}
|
|
7977
7991
|
this.deps.dispatch({ type: "FINAL_ANSWER_RECEIVED" });
|
|
@@ -7995,15 +8009,20 @@ var LlmNodeEventBridge = class {
|
|
|
7995
8009
|
if (!runtimeEvent || runtimeEvent.type !== "final_answer_chunk") {
|
|
7996
8010
|
throw new Error("stream_chunk did not map to final_answer_chunk.");
|
|
7997
8011
|
}
|
|
7998
|
-
|
|
7999
|
-
|
|
8000
|
-
|
|
8001
|
-
|
|
8002
|
-
|
|
8012
|
+
assertLlmNodeStreamChunkSequence(
|
|
8013
|
+
this.deps.getState(),
|
|
8014
|
+
runtimeEvent.answer_id,
|
|
8015
|
+
runtimeEvent.seq
|
|
8016
|
+
);
|
|
8003
8017
|
const published = this.publish(runtimeEvent, "LlmNode.final_answer_chunk");
|
|
8004
8018
|
if (published.type !== "final_answer_chunk") {
|
|
8005
8019
|
throw new Error("RuntimeEvent sink changed final_answer_chunk type.");
|
|
8006
8020
|
}
|
|
8021
|
+
this.deps.dispatch({
|
|
8022
|
+
type: "STREAM_CHUNK_RECEIVED",
|
|
8023
|
+
answerId: published.answer_id,
|
|
8024
|
+
seq: published.seq
|
|
8025
|
+
});
|
|
8007
8026
|
this.assembler.push(published);
|
|
8008
8027
|
this.buffer(published);
|
|
8009
8028
|
}
|
|
@@ -11845,14 +11864,16 @@ async function callLlmStream(params) {
|
|
|
11845
11864
|
case "answer_delta":
|
|
11846
11865
|
emitThoughtComplete(thoughtSegmenter.onBoundary());
|
|
11847
11866
|
fullResponse += event.text;
|
|
11867
|
+
const seq = streamChunkSeq;
|
|
11848
11868
|
emit({
|
|
11849
11869
|
type: "stream_chunk",
|
|
11850
11870
|
timestamp: Date.now(),
|
|
11851
11871
|
content: event.text,
|
|
11852
11872
|
id: generateRuntimeEventId(),
|
|
11853
11873
|
answer_id: streamAnswerId,
|
|
11854
|
-
seq
|
|
11874
|
+
seq
|
|
11855
11875
|
});
|
|
11876
|
+
streamChunkSeq += 1;
|
|
11856
11877
|
return;
|
|
11857
11878
|
case "thought_delta": {
|
|
11858
11879
|
const delta = thoughtSegmenter.onThoughtDelta(event.text);
|