@brainpilot/protocol 0.0.14 → 0.1.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/domain.d.ts CHANGED
@@ -41,6 +41,21 @@ export type Session = z.infer<typeof SessionSchema>;
41
41
  /** §10 state authority enum. */
42
42
  export declare const AgentStatusEnumSchema: z.ZodEnum<["idle", "running", "error", "stopped"]>;
43
43
  export type AgentStatusEnum = z.infer<typeof AgentStatusEnumSchema>;
44
+ /** Live provider retry state for an agent run. */
45
+ export declare const AgentRetryStateSchema: z.ZodObject<{
46
+ attempt: z.ZodNumber;
47
+ maxAttempts: z.ZodNumber;
48
+ delayMs: z.ZodNumber;
49
+ }, "strip", z.ZodTypeAny, {
50
+ attempt: number;
51
+ maxAttempts: number;
52
+ delayMs: number;
53
+ }, {
54
+ attempt: number;
55
+ maxAttempts: number;
56
+ delayMs: number;
57
+ }>;
58
+ export type AgentRetryState = z.infer<typeof AgentRetryStateSchema>;
44
59
  /**
45
60
  * AgentStatus as exposed in SessionStateSnapshot.agents (backend.ts). `status`
46
61
  * is kept open (string) for forward-compat with runtime values beyond the
@@ -52,18 +67,41 @@ export declare const AgentStatusSchema: z.ZodObject<{
52
67
  task: z.ZodString;
53
68
  updatedAt: z.ZodOptional<z.ZodString>;
54
69
  alive: z.ZodOptional<z.ZodBoolean>;
70
+ retry: z.ZodOptional<z.ZodObject<{
71
+ attempt: z.ZodNumber;
72
+ maxAttempts: z.ZodNumber;
73
+ delayMs: z.ZodNumber;
74
+ }, "strip", z.ZodTypeAny, {
75
+ attempt: number;
76
+ maxAttempts: number;
77
+ delayMs: number;
78
+ }, {
79
+ attempt: number;
80
+ maxAttempts: number;
81
+ delayMs: number;
82
+ }>>;
55
83
  }, "strip", z.ZodTypeAny, {
56
84
  status: string;
57
85
  name: string;
58
86
  task: string;
59
87
  updatedAt?: string | undefined;
60
88
  alive?: boolean | undefined;
89
+ retry?: {
90
+ attempt: number;
91
+ maxAttempts: number;
92
+ delayMs: number;
93
+ } | undefined;
61
94
  }, {
62
95
  status: string;
63
96
  name: string;
64
97
  task: string;
65
98
  updatedAt?: string | undefined;
66
99
  alive?: boolean | undefined;
100
+ retry?: {
101
+ attempt: number;
102
+ maxAttempts: number;
103
+ delayMs: number;
104
+ } | undefined;
67
105
  }>;
68
106
  export type AgentStatus = z.infer<typeof AgentStatusSchema>;
69
107
  /**
@@ -74,6 +112,19 @@ export declare const AgentStateSchema: z.ZodObject<{
74
112
  status: z.ZodEnum<["idle", "running", "error", "stopped"]>;
75
113
  activeRunId: z.ZodOptional<z.ZodString>;
76
114
  activeToolExecutions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
115
+ retry: z.ZodOptional<z.ZodObject<{
116
+ attempt: z.ZodNumber;
117
+ maxAttempts: z.ZodNumber;
118
+ delayMs: z.ZodNumber;
119
+ }, "strip", z.ZodTypeAny, {
120
+ attempt: number;
121
+ maxAttempts: number;
122
+ delayMs: number;
123
+ }, {
124
+ attempt: number;
125
+ maxAttempts: number;
126
+ delayMs: number;
127
+ }>>;
77
128
  lastError: z.ZodOptional<z.ZodObject<{
78
129
  message: z.ZodString;
79
130
  timestamp: z.ZodString;
@@ -90,6 +141,11 @@ export declare const AgentStateSchema: z.ZodObject<{
90
141
  }, "strip", z.ZodTypeAny, {
91
142
  status: "idle" | "running" | "error" | "stopped";
92
143
  name: string;
144
+ retry?: {
145
+ attempt: number;
146
+ maxAttempts: number;
147
+ delayMs: number;
148
+ } | undefined;
93
149
  activeRunId?: string | undefined;
94
150
  activeToolExecutions?: string[] | undefined;
95
151
  lastError?: {
@@ -100,6 +156,11 @@ export declare const AgentStateSchema: z.ZodObject<{
100
156
  }, {
101
157
  status: "idle" | "running" | "error" | "stopped";
102
158
  name: string;
159
+ retry?: {
160
+ attempt: number;
161
+ maxAttempts: number;
162
+ delayMs: number;
163
+ } | undefined;
103
164
  activeRunId?: string | undefined;
104
165
  activeToolExecutions?: string[] | undefined;
105
166
  lastError?: {
@@ -212,6 +273,632 @@ export declare const SessionTokenUsageSchema: z.ZodObject<{
212
273
  }>;
213
274
  }>;
214
275
  export type SessionTokenUsage = z.infer<typeof SessionTokenUsageSchema>;
276
+ /**
277
+ * Per-agent per-tool invocation counter. Key is the tool name (`"read"`,
278
+ * `"bash"`, `"skill_search"`, external-MCP-bridged names, …). Value is the
279
+ * number of times the runtime observed a `tool_execution_start` for that
280
+ * tool. Aborted mid-run tools still count — we count *invocations*, not
281
+ * *successful completions*; see `errors` on `AgentStatsSchema` for the
282
+ * failure counter.
283
+ */
284
+ export declare const ToolCallCountsSchema: z.ZodRecord<z.ZodString, z.ZodNumber>;
285
+ export type ToolCallCounts = z.infer<typeof ToolCallCountsSchema>;
286
+ /**
287
+ * Per-skill invocation counter. Split by the three `skill_search` sub-modes
288
+ * (see packages/runtime/src/tools/skill-search.ts):
289
+ * - `queries` — `mode="query"` with `keywords` (exploration; no body read)
290
+ * - `loads` — `mode="query"` with `skill_name` (returns full SKILL.md)
291
+ * - `browses` — `mode="browse"` (directory/file browse under a skill)
292
+ *
293
+ * A special key `"__search__"` collects `queries` where the args carried no
294
+ * `skill_name` (pure keyword search — the agent looked around but did not
295
+ * commit to a named skill). Args that fail to parse are also charged to
296
+ * `__search__.queries` so counters are never dropped silently.
297
+ */
298
+ export declare const SkillCounterSchema: z.ZodObject<{
299
+ queries: z.ZodNumber;
300
+ loads: z.ZodNumber;
301
+ browses: z.ZodNumber;
302
+ }, "strip", z.ZodTypeAny, {
303
+ queries: number;
304
+ loads: number;
305
+ browses: number;
306
+ }, {
307
+ queries: number;
308
+ loads: number;
309
+ browses: number;
310
+ }>;
311
+ export type SkillCounter = z.infer<typeof SkillCounterSchema>;
312
+ export declare const SkillCountsSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
313
+ queries: z.ZodNumber;
314
+ loads: z.ZodNumber;
315
+ browses: z.ZodNumber;
316
+ }, "strip", z.ZodTypeAny, {
317
+ queries: number;
318
+ loads: number;
319
+ browses: number;
320
+ }, {
321
+ queries: number;
322
+ loads: number;
323
+ browses: number;
324
+ }>>;
325
+ export type SkillCounts = z.infer<typeof SkillCountsSchema>;
326
+ /**
327
+ * All countable stats for one agent, in one accounting unit (session
328
+ * cumulative, or a single RUN_STATS delta).
329
+ *
330
+ * `errors` counts `tool_execution_end.isError === true` per tool name; it is
331
+ * additive to `tools` — `tools[name]` is "attempted N times", `errors[name]`
332
+ * is "of those, M failed". We do not subtract.
333
+ */
334
+ export declare const AgentStatsSchema: z.ZodObject<{
335
+ tokens: z.ZodObject<{
336
+ input: z.ZodNumber;
337
+ output: z.ZodNumber;
338
+ cacheRead: z.ZodNumber;
339
+ cacheWrite: z.ZodNumber;
340
+ total: z.ZodNumber;
341
+ }, "strip", z.ZodTypeAny, {
342
+ input: number;
343
+ output: number;
344
+ cacheRead: number;
345
+ cacheWrite: number;
346
+ total: number;
347
+ }, {
348
+ input: number;
349
+ output: number;
350
+ cacheRead: number;
351
+ cacheWrite: number;
352
+ total: number;
353
+ }>;
354
+ tools: z.ZodRecord<z.ZodString, z.ZodNumber>;
355
+ skills: z.ZodRecord<z.ZodString, z.ZodObject<{
356
+ queries: z.ZodNumber;
357
+ loads: z.ZodNumber;
358
+ browses: z.ZodNumber;
359
+ }, "strip", z.ZodTypeAny, {
360
+ queries: number;
361
+ loads: number;
362
+ browses: number;
363
+ }, {
364
+ queries: number;
365
+ loads: number;
366
+ browses: number;
367
+ }>>;
368
+ errors: z.ZodRecord<z.ZodString, z.ZodNumber>;
369
+ }, "strip", z.ZodTypeAny, {
370
+ tokens: {
371
+ input: number;
372
+ output: number;
373
+ cacheRead: number;
374
+ cacheWrite: number;
375
+ total: number;
376
+ };
377
+ tools: Record<string, number>;
378
+ skills: Record<string, {
379
+ queries: number;
380
+ loads: number;
381
+ browses: number;
382
+ }>;
383
+ errors: Record<string, number>;
384
+ }, {
385
+ tokens: {
386
+ input: number;
387
+ output: number;
388
+ cacheRead: number;
389
+ cacheWrite: number;
390
+ total: number;
391
+ };
392
+ tools: Record<string, number>;
393
+ skills: Record<string, {
394
+ queries: number;
395
+ loads: number;
396
+ browses: number;
397
+ }>;
398
+ errors: Record<string, number>;
399
+ }>;
400
+ export type AgentStats = z.infer<typeof AgentStatsSchema>;
401
+ /** Status stamped onto a `RunStats` entry when it is finalized. */
402
+ export declare const RunStatsStatusSchema: z.ZodEnum<["ok", "error", "aborted"]>;
403
+ export type RunStatsStatus = z.infer<typeof RunStatsStatusSchema>;
404
+ /**
405
+ * One completed run's contribution, computed as `cumulative_after -
406
+ * cumulative_before`. Appended to `SessionStats.byRun` when the run reaches
407
+ * a terminal event (`RUN_FINISHED` / `RUN_ERROR`) or is aborted.
408
+ */
409
+ export declare const RunStatsSchema: z.ZodObject<{
410
+ runId: z.ZodString;
411
+ agentName: z.ZodString;
412
+ startedAt: z.ZodNumber;
413
+ finishedAt: z.ZodNumber;
414
+ status: z.ZodEnum<["ok", "error", "aborted"]>;
415
+ delta: z.ZodObject<{
416
+ tokens: z.ZodObject<{
417
+ input: z.ZodNumber;
418
+ output: z.ZodNumber;
419
+ cacheRead: z.ZodNumber;
420
+ cacheWrite: z.ZodNumber;
421
+ total: z.ZodNumber;
422
+ }, "strip", z.ZodTypeAny, {
423
+ input: number;
424
+ output: number;
425
+ cacheRead: number;
426
+ cacheWrite: number;
427
+ total: number;
428
+ }, {
429
+ input: number;
430
+ output: number;
431
+ cacheRead: number;
432
+ cacheWrite: number;
433
+ total: number;
434
+ }>;
435
+ tools: z.ZodRecord<z.ZodString, z.ZodNumber>;
436
+ skills: z.ZodRecord<z.ZodString, z.ZodObject<{
437
+ queries: z.ZodNumber;
438
+ loads: z.ZodNumber;
439
+ browses: z.ZodNumber;
440
+ }, "strip", z.ZodTypeAny, {
441
+ queries: number;
442
+ loads: number;
443
+ browses: number;
444
+ }, {
445
+ queries: number;
446
+ loads: number;
447
+ browses: number;
448
+ }>>;
449
+ errors: z.ZodRecord<z.ZodString, z.ZodNumber>;
450
+ }, "strip", z.ZodTypeAny, {
451
+ tokens: {
452
+ input: number;
453
+ output: number;
454
+ cacheRead: number;
455
+ cacheWrite: number;
456
+ total: number;
457
+ };
458
+ tools: Record<string, number>;
459
+ skills: Record<string, {
460
+ queries: number;
461
+ loads: number;
462
+ browses: number;
463
+ }>;
464
+ errors: Record<string, number>;
465
+ }, {
466
+ tokens: {
467
+ input: number;
468
+ output: number;
469
+ cacheRead: number;
470
+ cacheWrite: number;
471
+ total: number;
472
+ };
473
+ tools: Record<string, number>;
474
+ skills: Record<string, {
475
+ queries: number;
476
+ loads: number;
477
+ browses: number;
478
+ }>;
479
+ errors: Record<string, number>;
480
+ }>;
481
+ }, "strip", z.ZodTypeAny, {
482
+ status: "aborted" | "error" | "ok";
483
+ runId: string;
484
+ agentName: string;
485
+ startedAt: number;
486
+ finishedAt: number;
487
+ delta: {
488
+ tokens: {
489
+ input: number;
490
+ output: number;
491
+ cacheRead: number;
492
+ cacheWrite: number;
493
+ total: number;
494
+ };
495
+ tools: Record<string, number>;
496
+ skills: Record<string, {
497
+ queries: number;
498
+ loads: number;
499
+ browses: number;
500
+ }>;
501
+ errors: Record<string, number>;
502
+ };
503
+ }, {
504
+ status: "aborted" | "error" | "ok";
505
+ runId: string;
506
+ agentName: string;
507
+ startedAt: number;
508
+ finishedAt: number;
509
+ delta: {
510
+ tokens: {
511
+ input: number;
512
+ output: number;
513
+ cacheRead: number;
514
+ cacheWrite: number;
515
+ total: number;
516
+ };
517
+ tools: Record<string, number>;
518
+ skills: Record<string, {
519
+ queries: number;
520
+ loads: number;
521
+ browses: number;
522
+ }>;
523
+ errors: Record<string, number>;
524
+ };
525
+ }>;
526
+ export type RunStats = z.infer<typeof RunStatsSchema>;
527
+ /**
528
+ * Full stats snapshot for one session:
529
+ * - `total` — everything summed across agents and runs.
530
+ * - `byAgent` — per-agent cumulative (mirrors `SessionTokenUsage.byAgent`).
531
+ * - `byRun` — time-ordered per-run deltas. Append-only; never truncated
532
+ * (`events.jsonl` is the ultimate SSOT and is uncapped, so
533
+ * this stays bounded by the same envelope).
534
+ */
535
+ export declare const SessionStatsSchema: z.ZodObject<{
536
+ sessionId: z.ZodString;
537
+ total: z.ZodObject<{
538
+ tokens: z.ZodObject<{
539
+ input: z.ZodNumber;
540
+ output: z.ZodNumber;
541
+ cacheRead: z.ZodNumber;
542
+ cacheWrite: z.ZodNumber;
543
+ total: z.ZodNumber;
544
+ }, "strip", z.ZodTypeAny, {
545
+ input: number;
546
+ output: number;
547
+ cacheRead: number;
548
+ cacheWrite: number;
549
+ total: number;
550
+ }, {
551
+ input: number;
552
+ output: number;
553
+ cacheRead: number;
554
+ cacheWrite: number;
555
+ total: number;
556
+ }>;
557
+ tools: z.ZodRecord<z.ZodString, z.ZodNumber>;
558
+ skills: z.ZodRecord<z.ZodString, z.ZodObject<{
559
+ queries: z.ZodNumber;
560
+ loads: z.ZodNumber;
561
+ browses: z.ZodNumber;
562
+ }, "strip", z.ZodTypeAny, {
563
+ queries: number;
564
+ loads: number;
565
+ browses: number;
566
+ }, {
567
+ queries: number;
568
+ loads: number;
569
+ browses: number;
570
+ }>>;
571
+ errors: z.ZodRecord<z.ZodString, z.ZodNumber>;
572
+ }, "strip", z.ZodTypeAny, {
573
+ tokens: {
574
+ input: number;
575
+ output: number;
576
+ cacheRead: number;
577
+ cacheWrite: number;
578
+ total: number;
579
+ };
580
+ tools: Record<string, number>;
581
+ skills: Record<string, {
582
+ queries: number;
583
+ loads: number;
584
+ browses: number;
585
+ }>;
586
+ errors: Record<string, number>;
587
+ }, {
588
+ tokens: {
589
+ input: number;
590
+ output: number;
591
+ cacheRead: number;
592
+ cacheWrite: number;
593
+ total: number;
594
+ };
595
+ tools: Record<string, number>;
596
+ skills: Record<string, {
597
+ queries: number;
598
+ loads: number;
599
+ browses: number;
600
+ }>;
601
+ errors: Record<string, number>;
602
+ }>;
603
+ byAgent: z.ZodRecord<z.ZodString, z.ZodObject<{
604
+ tokens: z.ZodObject<{
605
+ input: z.ZodNumber;
606
+ output: z.ZodNumber;
607
+ cacheRead: z.ZodNumber;
608
+ cacheWrite: z.ZodNumber;
609
+ total: z.ZodNumber;
610
+ }, "strip", z.ZodTypeAny, {
611
+ input: number;
612
+ output: number;
613
+ cacheRead: number;
614
+ cacheWrite: number;
615
+ total: number;
616
+ }, {
617
+ input: number;
618
+ output: number;
619
+ cacheRead: number;
620
+ cacheWrite: number;
621
+ total: number;
622
+ }>;
623
+ tools: z.ZodRecord<z.ZodString, z.ZodNumber>;
624
+ skills: z.ZodRecord<z.ZodString, z.ZodObject<{
625
+ queries: z.ZodNumber;
626
+ loads: z.ZodNumber;
627
+ browses: z.ZodNumber;
628
+ }, "strip", z.ZodTypeAny, {
629
+ queries: number;
630
+ loads: number;
631
+ browses: number;
632
+ }, {
633
+ queries: number;
634
+ loads: number;
635
+ browses: number;
636
+ }>>;
637
+ errors: z.ZodRecord<z.ZodString, z.ZodNumber>;
638
+ }, "strip", z.ZodTypeAny, {
639
+ tokens: {
640
+ input: number;
641
+ output: number;
642
+ cacheRead: number;
643
+ cacheWrite: number;
644
+ total: number;
645
+ };
646
+ tools: Record<string, number>;
647
+ skills: Record<string, {
648
+ queries: number;
649
+ loads: number;
650
+ browses: number;
651
+ }>;
652
+ errors: Record<string, number>;
653
+ }, {
654
+ tokens: {
655
+ input: number;
656
+ output: number;
657
+ cacheRead: number;
658
+ cacheWrite: number;
659
+ total: number;
660
+ };
661
+ tools: Record<string, number>;
662
+ skills: Record<string, {
663
+ queries: number;
664
+ loads: number;
665
+ browses: number;
666
+ }>;
667
+ errors: Record<string, number>;
668
+ }>>;
669
+ byRun: z.ZodArray<z.ZodObject<{
670
+ runId: z.ZodString;
671
+ agentName: z.ZodString;
672
+ startedAt: z.ZodNumber;
673
+ finishedAt: z.ZodNumber;
674
+ status: z.ZodEnum<["ok", "error", "aborted"]>;
675
+ delta: z.ZodObject<{
676
+ tokens: z.ZodObject<{
677
+ input: z.ZodNumber;
678
+ output: z.ZodNumber;
679
+ cacheRead: z.ZodNumber;
680
+ cacheWrite: z.ZodNumber;
681
+ total: z.ZodNumber;
682
+ }, "strip", z.ZodTypeAny, {
683
+ input: number;
684
+ output: number;
685
+ cacheRead: number;
686
+ cacheWrite: number;
687
+ total: number;
688
+ }, {
689
+ input: number;
690
+ output: number;
691
+ cacheRead: number;
692
+ cacheWrite: number;
693
+ total: number;
694
+ }>;
695
+ tools: z.ZodRecord<z.ZodString, z.ZodNumber>;
696
+ skills: z.ZodRecord<z.ZodString, z.ZodObject<{
697
+ queries: z.ZodNumber;
698
+ loads: z.ZodNumber;
699
+ browses: z.ZodNumber;
700
+ }, "strip", z.ZodTypeAny, {
701
+ queries: number;
702
+ loads: number;
703
+ browses: number;
704
+ }, {
705
+ queries: number;
706
+ loads: number;
707
+ browses: number;
708
+ }>>;
709
+ errors: z.ZodRecord<z.ZodString, z.ZodNumber>;
710
+ }, "strip", z.ZodTypeAny, {
711
+ tokens: {
712
+ input: number;
713
+ output: number;
714
+ cacheRead: number;
715
+ cacheWrite: number;
716
+ total: number;
717
+ };
718
+ tools: Record<string, number>;
719
+ skills: Record<string, {
720
+ queries: number;
721
+ loads: number;
722
+ browses: number;
723
+ }>;
724
+ errors: Record<string, number>;
725
+ }, {
726
+ tokens: {
727
+ input: number;
728
+ output: number;
729
+ cacheRead: number;
730
+ cacheWrite: number;
731
+ total: number;
732
+ };
733
+ tools: Record<string, number>;
734
+ skills: Record<string, {
735
+ queries: number;
736
+ loads: number;
737
+ browses: number;
738
+ }>;
739
+ errors: Record<string, number>;
740
+ }>;
741
+ }, "strip", z.ZodTypeAny, {
742
+ status: "aborted" | "error" | "ok";
743
+ runId: string;
744
+ agentName: string;
745
+ startedAt: number;
746
+ finishedAt: number;
747
+ delta: {
748
+ tokens: {
749
+ input: number;
750
+ output: number;
751
+ cacheRead: number;
752
+ cacheWrite: number;
753
+ total: number;
754
+ };
755
+ tools: Record<string, number>;
756
+ skills: Record<string, {
757
+ queries: number;
758
+ loads: number;
759
+ browses: number;
760
+ }>;
761
+ errors: Record<string, number>;
762
+ };
763
+ }, {
764
+ status: "aborted" | "error" | "ok";
765
+ runId: string;
766
+ agentName: string;
767
+ startedAt: number;
768
+ finishedAt: number;
769
+ delta: {
770
+ tokens: {
771
+ input: number;
772
+ output: number;
773
+ cacheRead: number;
774
+ cacheWrite: number;
775
+ total: number;
776
+ };
777
+ tools: Record<string, number>;
778
+ skills: Record<string, {
779
+ queries: number;
780
+ loads: number;
781
+ browses: number;
782
+ }>;
783
+ errors: Record<string, number>;
784
+ };
785
+ }>, "many">;
786
+ }, "strip", z.ZodTypeAny, {
787
+ total: {
788
+ tokens: {
789
+ input: number;
790
+ output: number;
791
+ cacheRead: number;
792
+ cacheWrite: number;
793
+ total: number;
794
+ };
795
+ tools: Record<string, number>;
796
+ skills: Record<string, {
797
+ queries: number;
798
+ loads: number;
799
+ browses: number;
800
+ }>;
801
+ errors: Record<string, number>;
802
+ };
803
+ byAgent: Record<string, {
804
+ tokens: {
805
+ input: number;
806
+ output: number;
807
+ cacheRead: number;
808
+ cacheWrite: number;
809
+ total: number;
810
+ };
811
+ tools: Record<string, number>;
812
+ skills: Record<string, {
813
+ queries: number;
814
+ loads: number;
815
+ browses: number;
816
+ }>;
817
+ errors: Record<string, number>;
818
+ }>;
819
+ sessionId: string;
820
+ byRun: {
821
+ status: "aborted" | "error" | "ok";
822
+ runId: string;
823
+ agentName: string;
824
+ startedAt: number;
825
+ finishedAt: number;
826
+ delta: {
827
+ tokens: {
828
+ input: number;
829
+ output: number;
830
+ cacheRead: number;
831
+ cacheWrite: number;
832
+ total: number;
833
+ };
834
+ tools: Record<string, number>;
835
+ skills: Record<string, {
836
+ queries: number;
837
+ loads: number;
838
+ browses: number;
839
+ }>;
840
+ errors: Record<string, number>;
841
+ };
842
+ }[];
843
+ }, {
844
+ total: {
845
+ tokens: {
846
+ input: number;
847
+ output: number;
848
+ cacheRead: number;
849
+ cacheWrite: number;
850
+ total: number;
851
+ };
852
+ tools: Record<string, number>;
853
+ skills: Record<string, {
854
+ queries: number;
855
+ loads: number;
856
+ browses: number;
857
+ }>;
858
+ errors: Record<string, number>;
859
+ };
860
+ byAgent: Record<string, {
861
+ tokens: {
862
+ input: number;
863
+ output: number;
864
+ cacheRead: number;
865
+ cacheWrite: number;
866
+ total: number;
867
+ };
868
+ tools: Record<string, number>;
869
+ skills: Record<string, {
870
+ queries: number;
871
+ loads: number;
872
+ browses: number;
873
+ }>;
874
+ errors: Record<string, number>;
875
+ }>;
876
+ sessionId: string;
877
+ byRun: {
878
+ status: "aborted" | "error" | "ok";
879
+ runId: string;
880
+ agentName: string;
881
+ startedAt: number;
882
+ finishedAt: number;
883
+ delta: {
884
+ tokens: {
885
+ input: number;
886
+ output: number;
887
+ cacheRead: number;
888
+ cacheWrite: number;
889
+ total: number;
890
+ };
891
+ tools: Record<string, number>;
892
+ skills: Record<string, {
893
+ queries: number;
894
+ loads: number;
895
+ browses: number;
896
+ }>;
897
+ errors: Record<string, number>;
898
+ };
899
+ }[];
900
+ }>;
901
+ export type SessionStats = z.infer<typeof SessionStatsSchema>;
215
902
  /**
216
903
  * Authoritative live session state. Identical shape across SSE first frame
217
904
  * (`CUSTOM:session_state`), push events, and `GET /sessions/:id/state`.
@@ -221,11 +908,11 @@ export declare const SessionStateSnapshotSchema: z.ZodObject<{
221
908
  active: z.ZodBoolean;
222
909
  runId: z.ZodNullable<z.ZodString>;
223
910
  }, "strip", z.ZodTypeAny, {
224
- active: boolean;
225
911
  runId: string | null;
226
- }, {
227
912
  active: boolean;
913
+ }, {
228
914
  runId: string | null;
915
+ active: boolean;
229
916
  }>;
230
917
  agents: z.ZodArray<z.ZodObject<{
231
918
  name: z.ZodString;
@@ -233,18 +920,41 @@ export declare const SessionStateSnapshotSchema: z.ZodObject<{
233
920
  task: z.ZodString;
234
921
  updatedAt: z.ZodOptional<z.ZodString>;
235
922
  alive: z.ZodOptional<z.ZodBoolean>;
923
+ retry: z.ZodOptional<z.ZodObject<{
924
+ attempt: z.ZodNumber;
925
+ maxAttempts: z.ZodNumber;
926
+ delayMs: z.ZodNumber;
927
+ }, "strip", z.ZodTypeAny, {
928
+ attempt: number;
929
+ maxAttempts: number;
930
+ delayMs: number;
931
+ }, {
932
+ attempt: number;
933
+ maxAttempts: number;
934
+ delayMs: number;
935
+ }>>;
236
936
  }, "strip", z.ZodTypeAny, {
237
937
  status: string;
238
938
  name: string;
239
939
  task: string;
240
940
  updatedAt?: string | undefined;
241
941
  alive?: boolean | undefined;
942
+ retry?: {
943
+ attempt: number;
944
+ maxAttempts: number;
945
+ delayMs: number;
946
+ } | undefined;
242
947
  }, {
243
948
  status: string;
244
949
  name: string;
245
950
  task: string;
246
951
  updatedAt?: string | undefined;
247
952
  alive?: boolean | undefined;
953
+ retry?: {
954
+ attempt: number;
955
+ maxAttempts: number;
956
+ delayMs: number;
957
+ } | undefined;
248
958
  }>, "many">;
249
959
  lastActivityTs: z.ZodString;
250
960
  /** Frozen when the session is created and persisted across restore. */
@@ -326,8 +1036,8 @@ export declare const SessionStateSnapshotSchema: z.ZodObject<{
326
1036
  }>>;
327
1037
  }, "strip", z.ZodTypeAny, {
328
1038
  runState: {
329
- active: boolean;
330
1039
  runId: string | null;
1040
+ active: boolean;
331
1041
  };
332
1042
  agents: {
333
1043
  status: string;
@@ -335,6 +1045,11 @@ export declare const SessionStateSnapshotSchema: z.ZodObject<{
335
1045
  task: string;
336
1046
  updatedAt?: string | undefined;
337
1047
  alive?: boolean | undefined;
1048
+ retry?: {
1049
+ attempt: number;
1050
+ maxAttempts: number;
1051
+ delayMs: number;
1052
+ } | undefined;
338
1053
  }[];
339
1054
  lastActivityTs: string;
340
1055
  domainResources?: "full" | "base" | undefined;
@@ -356,8 +1071,8 @@ export declare const SessionStateSnapshotSchema: z.ZodObject<{
356
1071
  } | undefined;
357
1072
  }, {
358
1073
  runState: {
359
- active: boolean;
360
1074
  runId: string | null;
1075
+ active: boolean;
361
1076
  };
362
1077
  agents: {
363
1078
  status: string;
@@ -365,6 +1080,11 @@ export declare const SessionStateSnapshotSchema: z.ZodObject<{
365
1080
  task: string;
366
1081
  updatedAt?: string | undefined;
367
1082
  alive?: boolean | undefined;
1083
+ retry?: {
1084
+ attempt: number;
1085
+ maxAttempts: number;
1086
+ delayMs: number;
1087
+ } | undefined;
368
1088
  }[];
369
1089
  lastActivityTs: string;
370
1090
  domainResources?: "full" | "base" | undefined;
@@ -490,10 +1210,10 @@ export declare const TraceNodeSchema: z.ZodObject<{
490
1210
  toolCalls: z.ZodArray<z.ZodString, "many">;
491
1211
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
492
1212
  }, "strip", z.ZodTypeAny, {
493
- id: string;
494
- title: string;
495
1213
  type: string;
496
1214
  status: string;
1215
+ id: string;
1216
+ title: string;
497
1217
  parents: {
498
1218
  id: string;
499
1219
  relation?: string | undefined;
@@ -525,10 +1245,10 @@ export declare const TraceNodeSchema: z.ZodObject<{
525
1245
  errorMessage?: string | undefined;
526
1246
  metadata?: Record<string, unknown> | undefined;
527
1247
  }, {
528
- id: string;
529
- title: string;
530
1248
  type: string;
531
1249
  status: string;
1250
+ id: string;
1251
+ title: string;
532
1252
  parents: {
533
1253
  id: string;
534
1254
  relation?: string | undefined;
@@ -641,10 +1361,10 @@ export declare const TraceGraphSchema: z.ZodObject<{
641
1361
  toolCalls: z.ZodArray<z.ZodString, "many">;
642
1362
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
643
1363
  }, "strip", z.ZodTypeAny, {
644
- id: string;
645
- title: string;
646
1364
  type: string;
647
1365
  status: string;
1366
+ id: string;
1367
+ title: string;
648
1368
  parents: {
649
1369
  id: string;
650
1370
  relation?: string | undefined;
@@ -676,10 +1396,10 @@ export declare const TraceGraphSchema: z.ZodObject<{
676
1396
  errorMessage?: string | undefined;
677
1397
  metadata?: Record<string, unknown> | undefined;
678
1398
  }, {
679
- id: string;
680
- title: string;
681
1399
  type: string;
682
1400
  status: string;
1401
+ id: string;
1402
+ title: string;
683
1403
  parents: {
684
1404
  id: string;
685
1405
  relation?: string | undefined;
@@ -722,10 +1442,10 @@ export declare const TraceGraphSchema: z.ZodObject<{
722
1442
  [k: string]: unknown;
723
1443
  };
724
1444
  nodes: {
725
- id: string;
726
- title: string;
727
1445
  type: string;
728
1446
  status: string;
1447
+ id: string;
1448
+ title: string;
729
1449
  parents: {
730
1450
  id: string;
731
1451
  relation?: string | undefined;
@@ -768,10 +1488,10 @@ export declare const TraceGraphSchema: z.ZodObject<{
768
1488
  [k: string]: unknown;
769
1489
  };
770
1490
  nodes: {
771
- id: string;
772
- title: string;
773
1491
  type: string;
774
1492
  status: string;
1493
+ id: string;
1494
+ title: string;
775
1495
  parents: {
776
1496
  id: string;
777
1497
  relation?: string | undefined;