stitchkit 0.116.0 → 0.117.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.
Files changed (120) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/dist/agent-runtime/run-acquisition.d.ts +9 -2
  3. package/dist/agent-runtime/run-acquisition.d.ts.map +1 -1
  4. package/dist/agent-runtime/run-execution.d.ts +3 -0
  5. package/dist/agent-runtime/run-execution.d.ts.map +1 -1
  6. package/dist/agent-runtime/run-failure.d.ts +4 -1
  7. package/dist/agent-runtime/run-failure.d.ts.map +1 -1
  8. package/dist/agent-runtime/run-store-retry.d.ts +8 -0
  9. package/dist/agent-runtime/run-store-retry.d.ts.map +1 -0
  10. package/dist/agent-runtime/run-terminal.d.ts.map +1 -1
  11. package/dist/agent-runtime/run-unacquired.d.ts +19 -0
  12. package/dist/agent-runtime/run-unacquired.d.ts.map +1 -0
  13. package/dist/agent-runtime/store-conformance.d.ts +8 -0
  14. package/dist/agent-runtime/store-conformance.d.ts.map +1 -1
  15. package/dist/agent-runtime/store-driver-contract.d.ts +5 -0
  16. package/dist/agent-runtime/store-driver-contract.d.ts.map +1 -1
  17. package/dist/agent-runtime/terminal-commit.d.ts +34 -4
  18. package/dist/agent-runtime/terminal-commit.d.ts.map +1 -1
  19. package/dist/entrypoints/agent-runtime/harness.js +2 -2
  20. package/dist/entrypoints/agent-runtime/sqlite/bun.js +3 -3
  21. package/dist/entrypoints/agent-runtime/sqlite/node.js +3 -3
  22. package/dist/entrypoints/agent-runtime/testing.js +22 -4
  23. package/dist/entrypoints/agent-runtime.d.ts +1 -1
  24. package/dist/entrypoints/agent-runtime.d.ts.map +1 -1
  25. package/dist/entrypoints/agent-runtime.js +13 -11
  26. package/dist/entrypoints/application/diagnostic-journal.js +1 -1
  27. package/dist/entrypoints/application/directory-inbox.js +3 -3
  28. package/dist/entrypoints/cli/publish.js +2 -2
  29. package/dist/entrypoints/files.js +2 -2
  30. package/dist/entrypoints/primitives.js +51 -154
  31. package/dist/entrypoints/server.js +6 -6
  32. package/dist/entrypoints/telegram.d.ts +1 -1
  33. package/dist/entrypoints/telegram.d.ts.map +1 -1
  34. package/dist/entrypoints/telegram.js +196 -76
  35. package/dist/entrypoints/tracking/contract.d.ts +11 -0
  36. package/dist/entrypoints/tracking/contract.d.ts.map +1 -0
  37. package/dist/entrypoints/tracking/contract.js +162 -0
  38. package/dist/entrypoints/tracking/performance.d.ts +8 -0
  39. package/dist/entrypoints/tracking/performance.d.ts.map +1 -0
  40. package/dist/entrypoints/tracking/performance.js +181 -0
  41. package/dist/entrypoints/tracking/server.d.ts +1 -0
  42. package/dist/entrypoints/tracking/server.d.ts.map +1 -1
  43. package/dist/entrypoints/tracking/server.js +40 -12
  44. package/dist/entrypoints/tracking.d.ts +4 -3
  45. package/dist/entrypoints/tracking.d.ts.map +1 -1
  46. package/dist/entrypoints/tracking.js +43 -143
  47. package/dist/entrypoints/xlsx.d.ts +4 -0
  48. package/dist/entrypoints/xlsx.d.ts.map +1 -0
  49. package/dist/entrypoints/xlsx.js +406 -0
  50. package/dist/{index-fa435yq2.js → index-073nw9qr.js} +8 -8
  51. package/dist/index-1f40z584.js +7 -0
  52. package/dist/{index-fdk4r4r6.js → index-75ns2ybj.js} +1 -1
  53. package/dist/{index-jq2ky8fw.js → index-cycp3r3e.js} +124 -181
  54. package/dist/{index-4g6qmgdx.js → index-ghtpfz4z.js} +9 -9
  55. package/dist/{index-n3v695sb.js → index-hdjmdwsj.js} +277 -96
  56. package/dist/{index-zqkz4af9.js → index-nqxrm176.js} +1 -1
  57. package/dist/index-qezhmp51.js +242 -0
  58. package/dist/index-vv1sch8a.js +94 -0
  59. package/dist/{index-fggxgbrk.js → index-xx1j310k.js} +165 -102
  60. package/dist/internal/exclusive-lock.d.ts.map +1 -1
  61. package/dist/primitives/decimal.d.ts +10 -0
  62. package/dist/primitives/decimal.d.ts.map +1 -1
  63. package/dist/primitives/index.d.ts +3 -1
  64. package/dist/primitives/index.d.ts.map +1 -1
  65. package/dist/primitives/money.d.ts +20 -0
  66. package/dist/primitives/money.d.ts.map +1 -1
  67. package/dist/primitives/quantity.d.ts.map +1 -1
  68. package/dist/primitives/rounding.d.ts +40 -0
  69. package/dist/primitives/rounding.d.ts.map +1 -0
  70. package/dist/telegram/budget-transformer.d.ts +2 -2
  71. package/dist/telegram/not-dispatched.d.ts +2 -2
  72. package/dist/telegram/not-dispatched.d.ts.map +1 -1
  73. package/dist/telegram/outbound-budget.d.ts +53 -16
  74. package/dist/telegram/outbound-budget.d.ts.map +1 -1
  75. package/dist/telegram/outbound-cost.d.ts +5 -0
  76. package/dist/telegram/outbound-cost.d.ts.map +1 -0
  77. package/dist/telegram/outbound-pauses.d.ts +17 -0
  78. package/dist/telegram/outbound-pauses.d.ts.map +1 -0
  79. package/dist/telegram/outbound-queue.d.ts +17 -0
  80. package/dist/telegram/outbound-queue.d.ts.map +1 -0
  81. package/dist/tracking/attribution.d.ts +1 -1
  82. package/dist/tracking/attribution.d.ts.map +1 -1
  83. package/dist/tracking/client-visit.d.ts +3 -1
  84. package/dist/tracking/client-visit.d.ts.map +1 -1
  85. package/dist/tracking/client.d.ts.map +1 -1
  86. package/dist/tracking/performance/collector.d.ts +61 -0
  87. package/dist/tracking/performance/collector.d.ts.map +1 -0
  88. package/dist/tracking/performance/schema.d.ts +45 -0
  89. package/dist/tracking/performance/schema.d.ts.map +1 -0
  90. package/dist/tracking/performance/summary.d.ts +12 -0
  91. package/dist/tracking/performance/summary.d.ts.map +1 -0
  92. package/dist/tracking/privacy.d.ts +5 -0
  93. package/dist/tracking/privacy.d.ts.map +1 -0
  94. package/dist/tracking/server/telemetry-health.d.ts +31 -0
  95. package/dist/tracking/server/telemetry-health.d.ts.map +1 -0
  96. package/dist/xlsx/cells.d.ts +17 -0
  97. package/dist/xlsx/cells.d.ts.map +1 -0
  98. package/dist/xlsx/render.d.ts +11 -0
  99. package/dist/xlsx/render.d.ts.map +1 -0
  100. package/dist/xlsx/schema.d.ts +119 -0
  101. package/dist/xlsx/schema.d.ts.map +1 -0
  102. package/dist/xlsx/zip.d.ts +13 -0
  103. package/dist/xlsx/zip.d.ts.map +1 -0
  104. package/llms/agent-runtime.2.txt +40 -16
  105. package/llms/agent-runtime.3.txt +17 -0
  106. package/llms/agent-runtime.txt +4 -1
  107. package/llms/primitives.txt +21 -0
  108. package/llms/stitchkit.txt +9 -6
  109. package/llms/telegram.txt +32 -12
  110. package/llms/tracking-contract.txt +32 -0
  111. package/llms/tracking-performance.txt +21 -0
  112. package/llms/tracking-server.txt +1 -0
  113. package/llms/tracking.txt +75 -12
  114. package/llms/{upgrading-0.105.0-0.116.0.txt → upgrading-0.105.0-0.117.0.txt} +50 -3
  115. package/llms/upgrading.txt +1 -1
  116. package/llms/xlsx.txt +107 -0
  117. package/llms-full.txt +355 -31
  118. package/llms.txt +11 -7
  119. package/package.json +27 -9
  120. package/dist/{index-z3d6smer.js → index-tdpmfks8.js} +5 -5
@@ -0,0 +1,31 @@
1
+ /** What one visit said about its browser's outbox. */
2
+ export interface TrackingOutboxReport {
3
+ /** The browser across its visits: `browserStreamId` of a visit's bootstrap. */
4
+ readonly stream: string;
5
+ readonly state: 'available' | 'unavailable' | 'unknown';
6
+ readonly queued: number;
7
+ /** Lifetime: a browser repeats it with every visit. */
8
+ readonly dropped: number;
9
+ }
10
+ export interface TrackingTelemetryHealth {
11
+ readonly status: 'ok' | 'degraded' | 'unknown';
12
+ readonly observedVisits: number;
13
+ readonly unknownVisits: number;
14
+ readonly unavailable: number;
15
+ /** What each browser last said it still holds. */
16
+ readonly queued: number;
17
+ /** Events lost inside the window. */
18
+ readonly dropped: number;
19
+ }
20
+ /**
21
+ * Is tracking losing events? A browser keeps `dropped` for life and sends it with
22
+ * every visit, so a sum over visits multiplies an old loss by the number of
23
+ * returns. A loss of this window is what each browser's counter grew by over
24
+ * `baselines`, what it reported before the window; a browser with no earlier report
25
+ * counts from zero, because its loss cannot be told from a new one.
26
+ *
27
+ * `queued` stays out of the verdict: those are a past visit's events, which the
28
+ * next visit delivers. They become a loss only by being dropped.
29
+ */
30
+ export declare function trackingTelemetryHealth(reports: readonly TrackingOutboxReport[], baselines?: ReadonlyMap<string, number>): TrackingTelemetryHealth;
31
+ //# sourceMappingURL=telemetry-health.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"telemetry-health.d.ts","sourceRoot":"","sources":["../../../src/tracking/server/telemetry-health.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,MAAM,WAAW,oBAAoB;IACnC,+EAA+E;IAC/E,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,aAAa,GAAG,SAAS,CAAC;IACxD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,uDAAuD;IACvD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,MAAM,EAAE,IAAI,GAAG,UAAU,GAAG,SAAS,CAAC;IAC/C,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,kDAAkD;IAClD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,qCAAqC;IACrC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,SAAS,oBAAoB,EAAE,EACxC,SAAS,GAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAa,GACjD,uBAAuB,CAgCzB"}
@@ -0,0 +1,17 @@
1
+ import type { XlsxColumn } from './schema.js';
2
+ export declare class XlsxCellError extends TypeError {
3
+ readonly name = "XlsxCellError";
4
+ }
5
+ /** What goes into `<c>`: a number as written, a flag, or text. */
6
+ export type XlsxCell = {
7
+ readonly kind: 'number';
8
+ readonly value: string;
9
+ } | {
10
+ readonly kind: 'boolean';
11
+ readonly value: boolean;
12
+ } | {
13
+ readonly kind: 'text';
14
+ readonly value: string;
15
+ };
16
+ export declare function cellOf(value: unknown, column: XlsxColumn, where: string): XlsxCell;
17
+ //# sourceMappingURL=cells.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cells.d.ts","sourceRoot":"","sources":["../../src/xlsx/cells.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAY3C,qBAAa,aAAc,SAAQ,SAAS;IAC1C,SAAkB,IAAI,mBAAmB;CAC1C;AAED,kEAAkE;AAClE,MAAM,MAAM,QAAQ,GAChB;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACnD;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GACrD;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AA4HtD,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,QAAQ,CAkBlF"}
@@ -0,0 +1,11 @@
1
+ import { type XlsxWorkbook } from './schema.js';
2
+ export declare const XLSX_MEDIA_TYPE = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
3
+ /**
4
+ * A workbook as XLSX bytes: typed cells from rows, identical bytes for identical
5
+ * input on one runtime. Text is stored as text, so a cell that reads `=HYPERLINK("x")` is what it
6
+ * says and the file holds no formula at all. A value of the wrong type, or one
7
+ * Excel could not hold exactly, refuses with the cell's address instead of
8
+ * landing wrong. The whole workbook is built in memory.
9
+ */
10
+ export declare function renderXlsx(workbook: XlsxWorkbook): Promise<Uint8Array>;
11
+ //# sourceMappingURL=render.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/xlsx/render.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,KAAK,YAAY,EAAsB,MAAM,UAAU,CAAC;AAGlF,eAAO,MAAM,eAAe,sEACyC,CAAC;AAsJtE;;;;;;GAMG;AACH,wBAAsB,UAAU,CAAC,QAAQ,EAAE,YAAY,GAAG,OAAO,CAAC,UAAU,CAAC,CAoC5E"}
@@ -0,0 +1,119 @@
1
+ import { z } from 'zod';
2
+ export declare const XlsxColumnSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
3
+ key: z.ZodString;
4
+ header: z.ZodString;
5
+ width: z.ZodOptional<z.ZodNumber>;
6
+ type: z.ZodLiteral<"text">;
7
+ }, z.core.$strip>, z.ZodObject<{
8
+ key: z.ZodString;
9
+ header: z.ZodString;
10
+ width: z.ZodOptional<z.ZodNumber>;
11
+ type: z.ZodLiteral<"number">;
12
+ format: z.ZodOptional<z.ZodString>;
13
+ }, z.core.$strip>, z.ZodObject<{
14
+ key: z.ZodString;
15
+ header: z.ZodString;
16
+ width: z.ZodOptional<z.ZodNumber>;
17
+ type: z.ZodLiteral<"date">;
18
+ }, z.core.$strip>, z.ZodObject<{
19
+ key: z.ZodString;
20
+ header: z.ZodString;
21
+ width: z.ZodOptional<z.ZodNumber>;
22
+ type: z.ZodLiteral<"datetime">;
23
+ timeZone: z.ZodString;
24
+ }, z.core.$strip>, z.ZodObject<{
25
+ key: z.ZodString;
26
+ header: z.ZodString;
27
+ width: z.ZodOptional<z.ZodNumber>;
28
+ type: z.ZodLiteral<"money">;
29
+ currency: z.ZodString;
30
+ scale: z.ZodNumber;
31
+ }, z.core.$strip>, z.ZodObject<{
32
+ key: z.ZodString;
33
+ header: z.ZodString;
34
+ width: z.ZodOptional<z.ZodNumber>;
35
+ type: z.ZodLiteral<"boolean">;
36
+ }, z.core.$strip>], "type">;
37
+ export type XlsxColumn = z.infer<typeof XlsxColumnSchema>;
38
+ export declare const XlsxSheetSchema: z.ZodObject<{
39
+ name: z.ZodString;
40
+ columns: z.ZodReadonly<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
41
+ key: z.ZodString;
42
+ header: z.ZodString;
43
+ width: z.ZodOptional<z.ZodNumber>;
44
+ type: z.ZodLiteral<"text">;
45
+ }, z.core.$strip>, z.ZodObject<{
46
+ key: z.ZodString;
47
+ header: z.ZodString;
48
+ width: z.ZodOptional<z.ZodNumber>;
49
+ type: z.ZodLiteral<"number">;
50
+ format: z.ZodOptional<z.ZodString>;
51
+ }, z.core.$strip>, z.ZodObject<{
52
+ key: z.ZodString;
53
+ header: z.ZodString;
54
+ width: z.ZodOptional<z.ZodNumber>;
55
+ type: z.ZodLiteral<"date">;
56
+ }, z.core.$strip>, z.ZodObject<{
57
+ key: z.ZodString;
58
+ header: z.ZodString;
59
+ width: z.ZodOptional<z.ZodNumber>;
60
+ type: z.ZodLiteral<"datetime">;
61
+ timeZone: z.ZodString;
62
+ }, z.core.$strip>, z.ZodObject<{
63
+ key: z.ZodString;
64
+ header: z.ZodString;
65
+ width: z.ZodOptional<z.ZodNumber>;
66
+ type: z.ZodLiteral<"money">;
67
+ currency: z.ZodString;
68
+ scale: z.ZodNumber;
69
+ }, z.core.$strip>, z.ZodObject<{
70
+ key: z.ZodString;
71
+ header: z.ZodString;
72
+ width: z.ZodOptional<z.ZodNumber>;
73
+ type: z.ZodLiteral<"boolean">;
74
+ }, z.core.$strip>], "type">>>;
75
+ rows: z.ZodReadonly<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
76
+ }, z.core.$strip>;
77
+ export declare const XlsxWorkbookSchema: z.ZodObject<{
78
+ sheets: z.ZodReadonly<z.ZodArray<z.ZodObject<{
79
+ name: z.ZodString;
80
+ columns: z.ZodReadonly<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
81
+ key: z.ZodString;
82
+ header: z.ZodString;
83
+ width: z.ZodOptional<z.ZodNumber>;
84
+ type: z.ZodLiteral<"text">;
85
+ }, z.core.$strip>, z.ZodObject<{
86
+ key: z.ZodString;
87
+ header: z.ZodString;
88
+ width: z.ZodOptional<z.ZodNumber>;
89
+ type: z.ZodLiteral<"number">;
90
+ format: z.ZodOptional<z.ZodString>;
91
+ }, z.core.$strip>, z.ZodObject<{
92
+ key: z.ZodString;
93
+ header: z.ZodString;
94
+ width: z.ZodOptional<z.ZodNumber>;
95
+ type: z.ZodLiteral<"date">;
96
+ }, z.core.$strip>, z.ZodObject<{
97
+ key: z.ZodString;
98
+ header: z.ZodString;
99
+ width: z.ZodOptional<z.ZodNumber>;
100
+ type: z.ZodLiteral<"datetime">;
101
+ timeZone: z.ZodString;
102
+ }, z.core.$strip>, z.ZodObject<{
103
+ key: z.ZodString;
104
+ header: z.ZodString;
105
+ width: z.ZodOptional<z.ZodNumber>;
106
+ type: z.ZodLiteral<"money">;
107
+ currency: z.ZodString;
108
+ scale: z.ZodNumber;
109
+ }, z.core.$strip>, z.ZodObject<{
110
+ key: z.ZodString;
111
+ header: z.ZodString;
112
+ width: z.ZodOptional<z.ZodNumber>;
113
+ type: z.ZodLiteral<"boolean">;
114
+ }, z.core.$strip>], "type">>>;
115
+ rows: z.ZodReadonly<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
116
+ }, z.core.$strip>>>;
117
+ }, z.core.$strip>;
118
+ export type XlsxWorkbook = z.input<typeof XlsxWorkbookSchema>;
119
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/xlsx/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAmBxB,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAqB3B,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAK1D,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAQ1B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAU7B,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * The ZIP container an XLSX is: deflated entries, no directories, no extras.
3
+ *
4
+ * Written here rather than taken from a library because the package has one
5
+ * runtime dependency and this format needs about a hundred lines. Compression
6
+ * goes through the platform's `CompressionStream`. Entry times are the format's
7
+ * epoch, so the same workbook always produces the same bytes.
8
+ */
9
+ export declare function zip(entries: readonly {
10
+ readonly name: string;
11
+ readonly content: string;
12
+ }[]): Promise<Uint8Array>;
13
+ //# sourceMappingURL=zip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zip.d.ts","sourceRoot":"","sources":["../../src/xlsx/zip.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAuDH,wBAAsB,GAAG,CACvB,OAAO,EAAE,SAAS;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,EAAE,GACtE,OAAO,CAAC,UAAU,CAAC,CA8DrB"}
@@ -237,6 +237,46 @@ canonical run and failed assistant atomically, removes the run from recovery
237
237
  indexes, and publishes the resulting `run-state`. A run that moved since it was
238
238
  read returns a conflict; `staleOwner: true` is mandatory evidence, not a default.
239
239
 
240
+ The same evidence holds inside one process when a store failure outlives the
241
+ run's own handling. A store call around execution that throws is retried for
242
+ about half a second, then decided by where the run stood. Retries bound a call
243
+ that fails, not one that hangs, so give the store its own timeouts:
244
+
245
+ | Failure | Outcome of `result` |
246
+ |---|---|
247
+ | reading or acquiring the run, retries spent, or a lost reply to the acquisition | resolves with reason `abandoned`, the cause on the operator's `run-terminal` |
248
+ | the first assistant draft | resolves with reason `runtime_failure`, like a checkpoint later in the turn |
249
+ | a conflict on a run another executor holds | rejects with the conflict; the record stays that executor's |
250
+ | a conflict on a run still queued, behind another run | rejects with `AgentRunUnsettledError`; `recover()` or `resume` picks it up |
251
+ | the terminal commit, or closing the run, retries spent | rejects with `AgentRunUnsettledError` |
252
+
253
+ `AgentRunUnsettledError.run` is the record as last read, and the store may be ahead
254
+ of it. Nothing in this process executes that run, and later turns of its
255
+ conversation wait behind it. `recover()` skips a `running` run with a live owner, so
256
+ a long-running process closes it itself once the store answers. Read the record
257
+ first: with no owner or with `error.ownerId` it is this runtime's, and any other
258
+ owner is executing it.
259
+
260
+ ```ts
261
+ const settled = await ticket.result.catch(async (error) => {
262
+ if (!(error instanceof AgentRunUnsettledError)) throw error
263
+ const { conversationId, id: runId } = error.run
264
+ const current = await store.loadRun({ conversationId, runId })
265
+ if (current && [undefined, error.ownerId].includes(current.run.ownerId)) {
266
+ await runtime.abandon({
267
+ conversationId,
268
+ runId,
269
+ expectedRevision: current.run.revision,
270
+ staleOwner: true,
271
+ })
272
+ }
273
+ throw error
274
+ })
275
+ ```
276
+
277
+ A `queued` run lost to a run ahead of it, and `runtime.resume()` can run it instead
278
+ once that one ends.
279
+
240
280
  ## Store operations
241
281
 
242
282
  `AgentRuntimeStore` remains the runtime-facing aggregate. Application adapters
@@ -837,19 +877,3 @@ reconcile.
837
877
 
838
878
  The sink deduplicates stable event IDs by default. Cross-crash exactly-once still requires a durable
839
879
  outbox.
840
-
841
- ## Deterministic race and adapter proof
842
-
843
- `stitchkit/agent-runtime/testing` exports `createAgentRaceBarrier`, `createAgentRaceDriver`,
844
- `createAgentRaceTrace` and `runAgentStoreConformance` — agent testing tools live beside the agent
845
- runtime, and `stitchkit/testing` imports none of it. Barriers have bounded teardown, traces assert exact partial order, and the
846
- helpers are exercised from packed Bun and Node consumers. `runAgentStoreConformance` runs duplicate,
847
- coalescing, collision, stale checkpoint, replay safety, terminal race, absorption, bounded reads,
848
- causal queued-history order, durable interrupt priority, compaction and recovery invariants against
849
- any fresh durable adapter.
850
-
851
- It picks its conversation identities itself and passes them to `createStore(context)` **before the
852
- first mutation**, so an adapter whose runtime rows reference an application-owned conversation row
853
- can provision those parents; the optional `cleanup(context)` removes them again, and runs once
854
- whether the scenario passed or failed. A factory that owns no fixture state ignores the argument and
855
- keeps working unchanged.
@@ -12,6 +12,22 @@ Parts of this slice:
12
12
  # Guide: Agent application runtime (docs/guide/agent-runtime.md) (continued)
13
13
  ==============================================================================
14
14
 
15
+ ## Deterministic race and adapter proof
16
+
17
+ `stitchkit/agent-runtime/testing` exports `createAgentRaceBarrier`, `createAgentRaceDriver`,
18
+ `createAgentRaceTrace` and `runAgentStoreConformance` — agent testing tools live beside the agent
19
+ runtime, and `stitchkit/testing` imports none of it. Barriers have bounded teardown, traces assert exact partial order, and the
20
+ helpers are exercised from packed Bun and Node consumers. `runAgentStoreConformance` runs duplicate,
21
+ coalescing, collision, stale checkpoint, replay safety, terminal race, absorption, bounded reads,
22
+ causal queued-history order, durable interrupt priority, compaction and recovery invariants against
23
+ any fresh durable adapter.
24
+
25
+ It picks its conversation identities itself and passes them to `createStore(context)` **before the
26
+ first mutation**, so an adapter whose runtime rows reference an application-owned conversation row
27
+ can provision those parents; the optional `cleanup(context)` removes them again, and runs once
28
+ whether the scenario passed or failed. A factory that owns no fixture state ignores the argument and
29
+ keeps working unchanged.
30
+
15
31
  ## Plain completions and shared invocation receipts
16
32
 
17
33
  Use `createModelInvocationLedger` from `stitchkit/agent-runtime` when a direct text
@@ -191,6 +207,7 @@ Server-only optional application runtime. See the
191
207
  | `AgentRuntimeRecoverOptions` | _type_ | bounded paged startup recovery with causal per-conversation scheduling, context resolver and explicit evidence policy |
192
208
  | `AgentRuntimeAbandonInput` | _type_ | one known orphan identity, expected revision and mandatory stale-owner evidence for `runtime.abandon()` |
193
209
  | `AgentRuntimeConflictError` | class | thrown when a store mutation loses to a concurrent writer — catchable by type from `stitchkit/agent-runtime` |
210
+ | `AgentRunUnsettledError` | class | rejects `result` when the store never answered: `.run` is still active with no executor, close it with `runtime.abandon()` |
194
211
  | `AgentSessionCloseOptions` | _type_ | `gracePeriodMs` for natural settlement, then abort, then `forceTimeoutMs` for bounded settlement after it |
195
212
  | `AgentSessionCloseResult` | _type_ | what `close()` achieved: `settled`, or `timedOut` with `remaining` runs still in flight. Only omitting `forceTimeoutMs` guarantees nothing is in flight on return |
196
213
  | `AgentHistoryProjectionOptions` | _type_ | storage-neutral file resolver, explicit unresolved-file behavior, and how an interrupted turn reaches the model (`interruptedAssistant`) |
@@ -420,7 +420,10 @@ remains the signal-only compatibility surface and additionally waits for admissi
420
420
 
421
421
  The in-memory store is a reference adapter and has process-local durability
422
422
  only. Production applications normally call `createAgentRuntimeStore()` and
423
- provide one database transaction driver:
423
+ provide one database transaction driver. Its `transaction` owns the retry of a
424
+ serialization conflict, wherever the database reports it: on a statement or on
425
+ `COMMIT`, which some clients surface in a different shape. Pass
426
+ `armCommitConflict` to `runAgentStoreConformance` to prove it:
424
427
 
425
428
  ```ts
426
429
  const store = createAgentRuntimeStore({
@@ -60,6 +60,23 @@ migration.
60
60
  literal in the type; division and rational shares return an explicit remainder. It does not own
61
61
  exchange rates.
62
62
 
63
+ `moneyFromDecimal('RUB', '5041.82', 2)` and `moneyToDecimal(value, 2)` cross between major units and
64
+ minor ones with the currency's scale as a parameter, and a value finer than that scale is refused
65
+ rather than cut. `multiplyMoneyByDecimal(price, '2.5', policy)` computes the exact product and rounds it
66
+ once. `roundMoney(value, policy)` brings an amount to a table's steps:
67
+
68
+ ```ts
69
+ const shelfPrice = defineRoundingPolicy({
70
+ mode: 'half-up', // or 'half-even', 'up', 'down'
71
+ tiers: [{ below: '100000', step: '100' }, { step: '1000' }], // minor units
72
+ })
73
+ roundMoney(moneyFromDecimal('RUB', '5041.82', 2), shelfPrice) // { minor: '504000', currency: 'RUB' }
74
+ ```
75
+
76
+ A policy is data, so it can be stored with the prices it produced. `roundDecimal(value, policy)` is
77
+ the same table over a plain decimal. `DecimalStringSchema` accepts one canonical spelling and refuses a
78
+ JSON number; `DecimalInputSchema` takes a spelling such as a database's `10.50` to the canonical one.
79
+
63
80
  `defineUnitSystem` stores exact canonical decimal strings. Every conversion is an application
64
81
  rational with an id. A converted `QuantityProjection` is `derived` and carries both its source and
65
82
  conversion id; a form/database value can be marked `recorded`. Whether a derived projection is
@@ -172,6 +189,10 @@ schedules, transports and file generation remain application-owned.
172
189
  | `PermissionGrantMatrix` / `PermissionCheckResult` | _types_ | compile-time complete matrix and unknown/allowed/denied runtime result |
173
190
  | `defineMoney` / `createMoneySchema` | functions | fixed-currency JSON-safe minor-unit value and Zod schema |
174
191
  | `addMoney` / `subtractMoney` / `multiplyMoney` / `shareMoney` / `splitMoney` | functions | exact same-currency arithmetic with explicit indivisible remainder |
192
+ | `moneyFromDecimal` / `moneyToDecimal` | functions | major units to minor ones and back, with the currency's scale as a parameter |
193
+ | `multiplyMoneyByDecimal` / `roundMoney` | functions | an exact product rounded once, and an amount brought to a policy's steps |
194
+ | `defineRoundingPolicy` / `roundDecimal` / `RoundingPolicySchema` / `RoundingPolicy` / `RoundingModeSchema` / `RoundingMode` | functions, schemas, _types_ | a rounding table as data, by magnitude, and its modes |
195
+ | `DecimalStringSchema` / `DecimalInputSchema` | schemas | one canonical decimal spelling, and the input form that reaches it; a number is refused |
175
196
  | `Money` / `MoneyShare` / `MoneySplit` | _types_ | currency-literal value and remainder-bearing operation results |
176
197
  | `defineUnitSystem` / `createQuantitySchema` / `addQuantity` | functions | exact decimal quantities and caller-declared finite conversions |
177
198
  | `Quantity` / `UnitConversion` / `QuantityProjection` | _types_ | unit-literal value, rational conversion and recorded/derived provenance |
@@ -60,7 +60,7 @@ own, recorded as an ADR.
60
60
  | `stitchkit/realtime` | browser, React Native/Hermes **and** server | evolving | typed realtime clients and retained topics with a required explicit Socket.IO peer loader |
61
61
  | `stitchkit/contract` | browser **and** server | stable | the contract layer alone — `defineContract`, errors, pagination |
62
62
  | `stitchkit/live` | browser **and** server | evolving | `defineEvents` — topic declarations beside the operation contract — and watched reads: `createWatchClient`, the value/difference frame and its reassembly |
63
- | `stitchkit/primitives` | browser **and** server | evolving | generic values and declarations for lifecycle, access, audit, delivery and exports |
63
+ | `stitchkit/primitives` | browser **and** server | evolving | generic values and declarations for lifecycle, access, audit, delivery and exports, exact money and rounding tables |
64
64
  | `stitchkit/server` | server (Bun) | stable | `createServer`, `implement`, hooks, auth, Socket.IO server, server primitives |
65
65
  | `stitchkit/node` | server (Node ≥ 22) | stable | `serveNode` + the runtime-agnostic core — the Node mirror of `/server` |
66
66
  | `stitchkit/tools` | server | stable | `createMcpHandler`, `mountMcp`, `mountAgent`, the OAuth provider, native tools |
@@ -75,24 +75,27 @@ own, recorded as an ADR.
75
75
  | `stitchkit/process/owner-loss` | bundled server entry (Bun, POSIX) | evolving | narrow bootstrap that keeps the process runner lazy while carrying its owner-loss guard in a single-file bundle |
76
76
  | `stitchkit/files/packaging` | build time (Bun or Node) | evolving | installed native asset graph, integrity, Bun packaging plugin and the artifact loader check; no runtime install policy |
77
77
  | `stitchkit/files` | server (Bun or Node) | stable | peer-free managed local-file boundary |
78
- | `stitchkit/telegram` | server (Bun or Node) | evolving | peer-free Telegram platform primitives — Mini App `initData` verification, send-failure classification, one outbound budget per bot token with weighted albums and shared 429 pauses, resumable broadcasts, the operator channel with dedupe, a Bot API transport that separates a request that never left from an unknown outcome, local Bot API files, webhook ownership and durable webhook update intake |
79
- | `stitchkit/telegram/grammy` | server (Bun or Node) | evolving | the token's outbound budget as one grammY client transformer — a 429 that comes back as a response pauses the token, and a cancelled wait is a request that never left |
78
+ | `stitchkit/telegram` | server (Bun or Node) | evolving | peer-free Telegram platform primitives — Mini App `initData` verification, send-failure classification, one outbound budget per bot token with weighted albums and per-chat 429 pauses, resumable broadcasts, the operator channel with dedupe, a Bot API transport that separates a request that never left from an unknown outcome, local Bot API files, webhook ownership and durable webhook update intake |
79
+ | `stitchkit/telegram/grammy` | server (Bun or Node) | evolving | the token's outbound budget as one grammY client transformer — a 429 that comes back as a response pauses its chat, and a cancelled wait is a request that never left |
80
80
  | `stitchkit/telegram/html` | browser and server | evolving | Telegram's HTML as a tree — clean any markup to what Telegram accepts, cut long text into valid parts by what the reader sees, check markup before it is sent |
81
81
  | `stitchkit/telegram/screens` | server (Bun or Node) | evolving | a bot's menus as declared screens over grammY — typed paths, actions and input, message reconciliation, state in any `StorageAdapter`, a test chat |
82
82
  | `stitchkit/tracking` | browser **and** server | evolving | visitor-tracking mechanics — `createTrackingClient`, the tab-shared outbox, the page-leave beacon, attribution, the contract factory; no event vocabulary, no React |
83
+ | `stitchkit/tracking/contract` | browser **and** server | evolving | the wire shapes — the contract factory, event and visit schemas, the performance sample and its trust threshold; brings `zod` |
84
+ | `stitchkit/tracking/performance` | browser **and** server | evolving | Web Vitals from real visitors, collected after load through the optional peer `web-vitals`; no `zod` |
83
85
  | `stitchkit/tracking/server` | server (Bun or Node) | evolving | the decisions a tracking backend makes — dispositions, visit lease over an application-owned store, active intervals, presence; no database |
84
86
  | `stitchkit/release` | browser **and** server | evolving | a page follows the release it was built for — `createReleaseMarker` on the server, `createReleaseWatcher` in the browser, the `X-Build-Id` header and a socket event between them |
85
87
  | `stitchkit/voice` | browser **and** server | evolving | the mechanics of a live voice reply — `SentenceCutter`, `speakableText`, a `SpeechQueue` that synthesises ahead and stops on interruption, the conversation phases |
86
88
  | `stitchkit/geo` | server (Bun or Node) | evolving | managed GeoIP reader generations, last-known-good reload and the optional MaxMind adapter |
89
+ | `stitchkit/xlsx` | browser **and** server | evolving | a workbook from rows and typed columns, with no dependency; text never runs as a formula |
87
90
  | `stitchkit/oauth` | browser **and** server | evolving | provider-neutral Authorization Code + PKCE request and one-shot callback transaction mechanics |
88
91
  | `stitchkit/google` | server (Bun or Node) | evolving | optional Google code exchange and verified OIDC identity adapter |
89
- | `stitchkit/observability` | server | stable<br>_redefined in 2 of the 61 minors since 0.56.2, most recently 0.92.0_ | request/tool event projections — `createObservability`, trace context, sanitisation |
92
+ | `stitchkit/observability` | server | stable<br>_redefined in 2 of the 62 minors since 0.56.2, most recently 0.92.0_ | request/tool event projections — `createObservability`, trace context, sanitisation |
90
93
  | `stitchkit/testing` | tests on Bun or Node | stable | in-process generated clients over a real Fetch handler, the managed-resource conformance kit and manual time for schedules and retries |
91
94
  | `stitchkit/declaration` | browser + build and deployment tooling (Bun or Node) | evolving | `ProjectDeclarationSchema` — the one machine-readable statement a repository makes about itself |
92
95
  | `stitchkit/react` | browser + server rendering | stable | `createCursorQuery`, `createCacheBridge`, QueryClient and `ApiError` retry policy |
93
96
  | `stitchkit/react/keyboard` | browser | evolving | which part of a screen gets a key — ordered layers, one Escape per level, list zones with real focus; see [keyboard guide](keyboard.md) |
94
97
  | `stitchkit/react/keyboard/testing` | server (Bun or Node) | evolving | the keyboard layers and zones without a DOM — fakes for the window, elements and key events beside the two engines, to test the order of layers, `scope`/`inert` and the edges of a zone in milliseconds |
95
- | `stitchkit/agent-runtime` | server | evolving<br>_redefined in 25 of the 61 minors since 0.56.2, most recently 0.115.0_ | optional durable conversation/run loop, history, models, prompts, fencing and events |
98
+ | `stitchkit/agent-runtime` | server | evolving<br>_redefined in 25 of the 62 minors since 0.56.2, most recently 0.115.0_ | optional durable conversation/run loop, history, models, prompts, fencing and events |
96
99
  | `stitchkit/agent-runtime/sandbox` | server | evolving | optional Linux Bubblewrap sessions, durable workspaces and a host HTTP credential gateway; see [sandbox guide](sandbox.md) |
97
100
  | `stitchkit/agent-runtime/testing` | tests on Bun or Node | evolving | credential-free replay, scripted provider faults, deterministic race controls and the agent-store conformance kit |
98
101
  | `stitchkit/agent-runtime/harness` | server | evolving | resource-aware process-local facade over the canonical Agent runtime; supervision stays outside |
@@ -104,7 +107,7 @@ own, recorded as an ADR.
104
107
  | `stitchkit/agent-runtime/sqlite/bun` | server (Bun) | evolving | durable built-in SQLite store for the agent runtime |
105
108
  | `stitchkit/agent-runtime/sqlite/node` | server (Node ≥ 22.5) | evolving | durable built-in SQLite store for the agent runtime |
106
109
  | `stitchkit-tui` | terminal (Bun) | evolving | optional official OpenTUI host over a caller-composed headless runtime |
107
- | `stitchkit/application` | browser + server | evolving<br>_redefined in 14 of the 61 minors since 0.56.2, most recently 0.110.0_ | managed resource graph, readiness, admission, schedules, subtree restart and bounded shutdown |
110
+ | `stitchkit/application` | browser + server | evolving<br>_redefined in 14 of the 62 minors since 0.56.2, most recently 0.110.0_ | managed resource graph, readiness, admission, schedules, subtree restart and bounded shutdown |
108
111
  | `stitchkit/application/grammy` | server | evolving | a grammY bot as application resources — configuration, then polling with updates admitted by batch — and the webhook adapter |
109
112
  | `stitchkit/application/opentelemetry` | server | evolving | maps application snapshots onto an injected OpenTelemetry `Meter` |
110
113
  | `stitchkit/application/schemas` | browser + server | evolving | the application's snapshot, health and shutdown schemas alone, without the kernel |
package/llms/telegram.txt CHANGED
@@ -131,17 +131,37 @@ cast, and a send cancelled in the queue then waits for its slot and fails as
131
131
  `messagesPerSecond`.
132
132
  - **The first send after idle is immediate; the rest are spaced.** This is a
133
133
  strict budget, not a bucket that saves a burst: at 24/s the next send is due
134
- one interval later. A 429 pauses the whole token; when it resumes, one send
135
- is released at the deadline and the queue continues one interval at a time,
136
- never as a stampede.
137
- - **It paces; it does not retry.** `run` calls the send once. A 429 pauses the
138
- token for Telegram's `retry_after` (or `retryAfterFallbackMs` when Telegram
139
- gave none) and rethrows; the caller's retry policy decides what happens next.
134
+ one interval later. When a pause ends, one send is released at the deadline and
135
+ the queue continues one interval at a time, never as a stampede.
136
+ - **A 429 holds the chat that got it.** Telegram words a group's limit, a chat's
137
+ pace and the bot's own limit alike, and only the addressee differs, so `run`
138
+ pauses the `chat_id` of the refused send and every other chat of the token goes
139
+ on at the shared rate. A person's reply does not wait behind a notification
140
+ group on its limit, and neither does a campaign. Refusals from
141
+ `tokenPauseChats` different chats (default 3) inside `tokenPauseWindowMs`
142
+ (default 5000) are read as the bot's own limit and pause the whole token, and so
143
+ does a 429 with no chat in the payload. `stats().pausedChats` counts the chats
144
+ on a pause; `stats().pausedForMs` is the token's.
145
+ - **A chat known to hit its limit can keep a 429 to itself.** A notification group
146
+ runs into its per-minute limit as a matter of course. `{ refusal: 'call' }` on `run`,
147
+ or `telegramBudgetTransformer(budget, { refusal: 'call' })` on that group's own `Api`,
148
+ makes the refusal concern that send alone: nothing pauses and nothing counts towards
149
+ `tokenPauseChats`. The call still spends the budget and waits out other pauses, and
150
+ what to do with the refused message stays the caller's decision.
151
+ - **A wait can be bounded.** A burst to one chat on pause otherwise queues without
152
+ limit. `{ maxWaitMs }` on `run` or `acquire`, or on
153
+ `telegramBudgetTransformer(budget, { maxWaitMs })`, ends a call that waited that
154
+ long with `TelegramNotDispatchedError`, stage `queue`: nothing was sent and no
155
+ message was spent, so repeating it is safe.
156
+ - **It paces; it does not retry.** `run` calls the send once. A 429 pauses for
157
+ Telegram's `retry_after` (or `retryAfterFallbackMs` when Telegram gave none) and
158
+ rethrows; the caller's retry policy decides what happens next.
140
159
  The refusal may be thrown or returned: a client transformer sits below the
141
160
  place where grammY turns Telegram's `{ ok: false, error_code: 429, … }` body into
142
161
  a `GrammyError`, so `run` reads that body too and hands it back unchanged.
143
- A 429 from an edit or a read concerns that call and pauses nothing; `budget.pauseAfter`
144
- remains for a caller who decides otherwise. A network failure is rethrown unchanged and stays `unknown`; a 5xx
162
+ A 429 from an edit or a read concerns that call and pauses nothing;
163
+ `budget.pauseAfter(error, { chatId })` remains for a caller who decides otherwise, and pauses
164
+ the token when it names no chat. A network failure is rethrown unchanged and stays `unknown`; a 5xx
145
165
  is rethrown unchanged and stays `server-error`. Neither is retried by the
146
166
  budget or pauses the token — repeating a send whose outcome is unknown is a
147
167
  decision, not a primitive's silent guess.
@@ -153,9 +173,9 @@ cast, and a send cancelled in the queue then waits for its slot and fails as
153
173
  the client's own error — not evidence that Telegram did not accept it — so
154
174
  keep the outcome unknown rather than retrying it as a definite failure.
155
175
  - **Non-send retries wait without spending.** An edit or delete retry that got
156
- a 429 first records the pause with `budget.pauseAfter(error)` (the `run` path
157
- does this itself), then uses `await budget.waitUntilResumed(signal)`; it shares
158
- the token's pause but does not take a message slot.
176
+ a 429 records the pause with `budget.pauseAfter(error, { chatId })`, then uses
177
+ `await budget.waitUntilResumed(signal, { chatId })`; it shares that chat's pause
178
+ and the token's, and takes no message slot. Without `chatId` it pauses the token.
159
179
 
160
180
  `telegramBroadcastSender` and `telegramOperatorSender` still send through
161
181
  `callTelegramBotApi`; they are not a second budget. Their returned function does
@@ -615,7 +635,7 @@ injected grammY bot. → ADR 0143, ADR 0201, ADR 0274 — [guide](../guide/teleg
615
635
  | `TelegramFetch` / `TelegramBotTransportOpen` / `TelegramBotTransportResolve` / `TelegramBotTransportSocket` | _types_ | the `(url, init) => Promise<Response>` the senders take; the transport's socket factory, resolver and the structural socket it needs (a Node `net.Socket` or `tls.TLSSocket` fits) |
616
636
  | `TelegramNotDispatchedError` / `TelegramNotDispatchedStage` | class / _type_ | a request that provably never left (`lookup`, `connect` or `request`), so repeating it cannot duplicate a message |
617
637
  | `TelegramSendFailureReason` / `TELEGRAM_SEND_FAILURE_REASONS` | _type_ / constant | `blocked-by-user` / `user-deactivated` / `chat-not-found` / `not-started` / `bot-to-bot-disabled` / `rate-limited` / `message-invalid` / `server-error` / `not-dispatched` / `unknown`, and the same as a list; a `Record<TelegramSendFailureReason, …>` over them fails to compile when a reason is added |
618
- | `telegramOutboundBudget` / `TelegramOutboundBudget` / `TelegramOutboundBudgetConfig` / `TelegramOutboundBudgetStats` / `TelegramOutboundCallOptions` / `TelegramOutboundLane` | function / _type_ | one token-wide outbound budget: one object per token in the process, strict 24 messages/s by default, weighted albums and multi-message copies, an `interactive` lane granted before `bulk`, `run(method, payload, signal, send, { lane })` as the transformer adapter (a 429 on a send pauses the token whether `send` throws it or resolves with the Bot API's `{ ok: false, … }` body), `pause`/`pauseAfter` for 429, `waitUntilResumed` for non-send retries and `stats`; it paces and never retries, and no public value carries the token |
638
+ | `telegramOutboundBudget` / `TelegramOutboundBudget` / `TelegramOutboundBudgetConfig` / `TelegramOutboundBudgetStats` / `TelegramOutboundCallOptions` / `TelegramOutboundChatOptions` / `TelegramOutboundLane` | function / _type_ | one token-wide outbound budget: one object per token in the process, strict 24 messages/s by default, weighted albums and multi-message copies, an `interactive` lane granted before `bulk`, `run(method, payload, signal, send, { lane, maxWaitMs })` as the transformer adapter (a 429 on a send pauses its `chat_id` whether `send` throws it or resolves with the Bot API's `{ ok: false, … }` body, and refusals from `tokenPauseChats` chats pause the token), `pause`/`pauseAfter` for 429, `waitUntilResumed` for non-send retries and `stats`; it paces and never retries, and no public value carries the token |
619
639
  | `runTelegramBroadcast` | function | a resumable broadcast by `name` under a state `directory`: audience and journal durably recorded, pacing at `ratePerSecond` (25), exact retry delays within the finite declared budget, injected classifier, uncertain send outcomes never replayed, `dryRun`, one fenced runner per name |
620
640
  | `TelegramBroadcastConfig` / `TelegramBroadcastSend` / `TelegramBroadcastReport` / `TelegramBroadcastRunOutcome` / `TelegramBroadcastOutcome` / `TelegramBroadcastRecipient` | _type_ | `name`, `directory`, `recipients()`, `send({ recipient, attempt })`, `maxAttempts`, `signal`, `onProgress`; counts `delivered` / `unreachable` / `failed` / `uncertain` / `pending` and `finished` / `stopped` / `halted` / `dry-run` |
621
641
  | `TelegramBroadcastFailureSchema` / `TelegramBroadcastFailure` | schema / _type_ | injected `classify` answers retry-after/transient/permanent/ambiguous; exact provider delay is bounded by `maxRetryDelayMs` without shortening, unknown outcome remains uncertain and is never replayed |
@@ -0,0 +1,32 @@
1
+ # stitchkit/tracking/contract — stitchkit docs slice
2
+
3
+ > Generated from the `docs/` tree by `bun run gen:llms`. The index of all slices is
4
+ > `llms.txt` in this package.
5
+
6
+ Contains: API reference: `stitchkit/tracking/contract` (docs/api/reference.md)
7
+
8
+ Also read:
9
+ - see `llms/tracking.txt` for the Visitor tracking guide
10
+
11
+ ==============================================================================
12
+ # API reference: `stitchkit/tracking/contract` (docs/api/reference.md)
13
+ ==============================================================================
14
+
15
+ ## `stitchkit/tracking/contract`
16
+
17
+ The wire shapes of tracking, for a server and a shared contract. It brings `zod`, so
18
+ browser code that only sends events does not import it. → ADR 0280
19
+
20
+ | Export | Kind | Summary |
21
+ |--------|------|---------|
22
+ | `createTrackingContract` / `TrackingContractConfig` / `TrackingContractEndpoints` | function / _type_ | `bootstrap` (`POST /visit`) and `track` (`POST /events`, `safelistedBody`) from the application's event types, scope and optional extras |
23
+ | `createTrackingSchemas` / `TrackingSchemas` / `TrackingSchemasConfig` | function / _type_ | every schema of one surface — `event`, `request`, `response`, `disposition`, `entry`, `bootstrap` — from `eventTypes`, optional `eventExtras`, `buildIdPattern`, `maxEventsPerBatch` |
24
+ | `TrackingEventEnvelope` / `TrackingEventShape` | _type_ | `eventId`, `visitId`, `browserStreamId`, `browserSequence`, `type`, `page`, `metadata`, `clientTimestamp` |
25
+ | `TrackEventsRequest` / `TrackEventsResponse` / `TrackEventsResponseSchema` | _type_ / schema | a batch (`buildId`, `events`, `utm`) and its answer (`accepted`, `dispositions`) |
26
+ | `TrackingDisposition` / `TrackingDispositionSchema` / `TrackingDispositionStatus` / `TrackingDispositionStatusSchema` | _type_ / schema | `accepted` / `duplicate` / `identity-invalid` / `excluded-bot` — every one terminal |
27
+ | `VisitEntryContext` / `VisitEntryContextShape` / `VisitBootstrapResponse` / `VisitBootstrapResponseSchema` | _type_ / schema | what a browser reports to open a visit (lineage, landing, referrer, UTM, display, screen, `buildId`, outbox health) and the lease it gets back |
28
+ | `TrackingOutboxState` / `TrackingOutboxStateSchema` | _type_ / schema | `available` / `unavailable` |
29
+ | `UtmData` / `UtmDataSchema` / `AttributionData` / `AttributionDataSchema` | _type_ / schema | campaign tags and a touch (UTM, referrer, landing page) |
30
+ | `DEFAULT_BUILD_ID_PATTERN` | const | `dev` or a git SHA |
31
+ | `PerformanceSampleSchema` / `PerformanceSample` / `PerformanceVitalsSchema` / `PerformanceVitals` | schemas / _types_ | one page load's wire shape; a metric that did not arrive is `null` |
32
+ | `summarizePerformanceMetric` / `PerformanceMetricSummary` | function / _type_ | sample count, p75, and a p95 only from 100 samples |
@@ -0,0 +1,21 @@
1
+ # stitchkit/tracking/performance — stitchkit docs slice
2
+
3
+ > Generated from the `docs/` tree by `bun run gen:llms`. The index of all slices is
4
+ > `llms.txt` in this package.
5
+
6
+ Contains: API reference: `stitchkit/tracking/performance` (docs/api/reference.md)
7
+
8
+ Also read:
9
+ - see `llms/tracking.txt` for the Visitor tracking guide
10
+
11
+ ==============================================================================
12
+ # API reference: `stitchkit/tracking/performance` (docs/api/reference.md)
13
+ ==============================================================================
14
+
15
+ ## `stitchkit/tracking/performance`
16
+
17
+ | Export | Kind | Summary |
18
+ |--------|------|---------|
19
+ | `createPerformanceCollector` / `PerformanceCollector` / `PerformanceCollectorConfig` | function / _types_ | Web Vitals of this page after load: an `early` sample and a `final` beacon to `url`, undelivered ones kept for the next page; inert for a lab agent |
20
+ | `PerformanceHost` / `VitalsLibrary` / `VitalsMetric` / `VitalsObserver` | _types_ | the seams of the collector: the page, and the part of `web-vitals` it uses |
21
+ | `isLabUserAgent` | function | whether an agent admits to being a lab run or a crawler |
@@ -27,6 +27,7 @@ algorithm over a store the application implements. → ADR 0166
27
27
  | `activeIntervalOf` / `ActiveTimeInterval` / `ActiveIntervalOptions` | function / _type_ | the visible-time interval an event carries, dated by the server clock; `null` for an unshaped or implausible one |
28
28
  | `hashTrackingEvent` | function | `sha256(JSON.stringify(parsedEvent))` — the stored payload hash, unsorted on purpose so it matches what applications already hold |
29
29
  | `isBotUserAgent` / `DEFAULT_BOT_USER_AGENT_PATTERN` | function / const | crawlers, monitors and `headlesschrome` are not visitors |
30
+ | `trackingTelemetryHealth` / `TrackingOutboxReport` / `TrackingTelemetryHealth` | function / _types_ | `ok`, `degraded` or `unknown` from outbox reports; a lifetime `dropped` counts only by what it grew over `baselines` |
30
31
  | `createPresenceRegistry` / `PresenceRegistry` / `PresenceEntry` | function / _type_ | who is here now, in this process: `touch` / `snapshot(filter)` / `presentVisitOf` with a 45 s TTL |
31
32
 
32
33
  ---