stitchkit 0.116.0 → 0.118.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +56 -0
- package/dist/agent-runtime/run-acquisition.d.ts +9 -2
- package/dist/agent-runtime/run-acquisition.d.ts.map +1 -1
- package/dist/agent-runtime/run-execution.d.ts +3 -0
- package/dist/agent-runtime/run-execution.d.ts.map +1 -1
- package/dist/agent-runtime/run-failure.d.ts +4 -1
- package/dist/agent-runtime/run-failure.d.ts.map +1 -1
- package/dist/agent-runtime/run-store-retry.d.ts +8 -0
- package/dist/agent-runtime/run-store-retry.d.ts.map +1 -0
- package/dist/agent-runtime/run-terminal.d.ts.map +1 -1
- package/dist/agent-runtime/run-unacquired.d.ts +19 -0
- package/dist/agent-runtime/run-unacquired.d.ts.map +1 -0
- package/dist/agent-runtime/store-conformance.d.ts +8 -0
- package/dist/agent-runtime/store-conformance.d.ts.map +1 -1
- package/dist/agent-runtime/store-driver-contract.d.ts +5 -0
- package/dist/agent-runtime/store-driver-contract.d.ts.map +1 -1
- package/dist/agent-runtime/terminal-commit.d.ts +34 -4
- package/dist/agent-runtime/terminal-commit.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/harness.js +2 -2
- package/dist/entrypoints/agent-runtime/sqlite/bun.js +3 -3
- package/dist/entrypoints/agent-runtime/sqlite/node.js +3 -3
- package/dist/entrypoints/agent-runtime/testing.js +22 -4
- package/dist/entrypoints/agent-runtime.d.ts +1 -1
- package/dist/entrypoints/agent-runtime.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime.js +13 -11
- package/dist/entrypoints/application/diagnostic-journal.js +1 -1
- package/dist/entrypoints/application/directory-inbox.js +3 -3
- package/dist/entrypoints/cli/publish.js +2 -2
- package/dist/entrypoints/files.js +2 -2
- package/dist/entrypoints/primitives.js +51 -154
- package/dist/entrypoints/server.js +6 -6
- package/dist/entrypoints/telegram.d.ts +1 -1
- package/dist/entrypoints/telegram.d.ts.map +1 -1
- package/dist/entrypoints/telegram.js +352 -137
- package/dist/entrypoints/tracking/contract.d.ts +11 -0
- package/dist/entrypoints/tracking/contract.d.ts.map +1 -0
- package/dist/entrypoints/tracking/contract.js +162 -0
- package/dist/entrypoints/tracking/performance.d.ts +8 -0
- package/dist/entrypoints/tracking/performance.d.ts.map +1 -0
- package/dist/entrypoints/tracking/performance.js +181 -0
- package/dist/entrypoints/tracking/server.d.ts +1 -0
- package/dist/entrypoints/tracking/server.d.ts.map +1 -1
- package/dist/entrypoints/tracking/server.js +40 -12
- package/dist/entrypoints/tracking.d.ts +4 -3
- package/dist/entrypoints/tracking.d.ts.map +1 -1
- package/dist/entrypoints/tracking.js +43 -143
- package/dist/entrypoints/xlsx.d.ts +4 -0
- package/dist/entrypoints/xlsx.d.ts.map +1 -0
- package/dist/entrypoints/xlsx.js +406 -0
- package/dist/{index-fa435yq2.js → index-073nw9qr.js} +8 -8
- package/dist/index-1f40z584.js +7 -0
- package/dist/{index-fdk4r4r6.js → index-75ns2ybj.js} +1 -1
- package/dist/{index-jq2ky8fw.js → index-cycp3r3e.js} +124 -181
- package/dist/{index-4g6qmgdx.js → index-ghtpfz4z.js} +9 -9
- package/dist/{index-n3v695sb.js → index-hdjmdwsj.js} +277 -96
- package/dist/{index-zqkz4af9.js → index-nqxrm176.js} +1 -1
- package/dist/index-qezhmp51.js +242 -0
- package/dist/index-vv1sch8a.js +94 -0
- package/dist/{index-fggxgbrk.js → index-xx1j310k.js} +165 -102
- package/dist/internal/exclusive-lock.d.ts.map +1 -1
- package/dist/primitives/decimal.d.ts +10 -0
- package/dist/primitives/decimal.d.ts.map +1 -1
- package/dist/primitives/index.d.ts +3 -1
- package/dist/primitives/index.d.ts.map +1 -1
- package/dist/primitives/money.d.ts +20 -0
- package/dist/primitives/money.d.ts.map +1 -1
- package/dist/primitives/quantity.d.ts.map +1 -1
- package/dist/primitives/rounding.d.ts +40 -0
- package/dist/primitives/rounding.d.ts.map +1 -0
- package/dist/telegram/budget-transformer.d.ts +2 -2
- package/dist/telegram/not-dispatched.d.ts +2 -2
- package/dist/telegram/not-dispatched.d.ts.map +1 -1
- package/dist/telegram/outbound-budget.d.ts +53 -16
- package/dist/telegram/outbound-budget.d.ts.map +1 -1
- package/dist/telegram/outbound-cost.d.ts +5 -0
- package/dist/telegram/outbound-cost.d.ts.map +1 -0
- package/dist/telegram/outbound-pauses.d.ts +17 -0
- package/dist/telegram/outbound-pauses.d.ts.map +1 -0
- package/dist/telegram/outbound-queue.d.ts +17 -0
- package/dist/telegram/outbound-queue.d.ts.map +1 -0
- package/dist/telegram/update-intake-work.d.ts +20 -1
- package/dist/telegram/update-intake-work.d.ts.map +1 -1
- package/dist/telegram/update-intake.d.ts +12 -3
- package/dist/telegram/update-intake.d.ts.map +1 -1
- package/dist/telegram/update-store-check.d.ts +1 -1
- package/dist/telegram/update-store-check.d.ts.map +1 -1
- package/dist/telegram/update-store-postgres.d.ts.map +1 -1
- package/dist/telegram/update-store-sqlite.d.ts.map +1 -1
- package/dist/telegram/update-store.d.ts +5 -1
- package/dist/telegram/update-store.d.ts.map +1 -1
- package/dist/tracking/attribution.d.ts +1 -1
- package/dist/tracking/attribution.d.ts.map +1 -1
- package/dist/tracking/client-visit.d.ts +3 -1
- package/dist/tracking/client-visit.d.ts.map +1 -1
- package/dist/tracking/client.d.ts.map +1 -1
- package/dist/tracking/performance/collector.d.ts +61 -0
- package/dist/tracking/performance/collector.d.ts.map +1 -0
- package/dist/tracking/performance/schema.d.ts +45 -0
- package/dist/tracking/performance/schema.d.ts.map +1 -0
- package/dist/tracking/performance/summary.d.ts +12 -0
- package/dist/tracking/performance/summary.d.ts.map +1 -0
- package/dist/tracking/privacy.d.ts +5 -0
- package/dist/tracking/privacy.d.ts.map +1 -0
- package/dist/tracking/server/telemetry-health.d.ts +31 -0
- package/dist/tracking/server/telemetry-health.d.ts.map +1 -0
- package/dist/xlsx/cells.d.ts +17 -0
- package/dist/xlsx/cells.d.ts.map +1 -0
- package/dist/xlsx/render.d.ts +11 -0
- package/dist/xlsx/render.d.ts.map +1 -0
- package/dist/xlsx/schema.d.ts +119 -0
- package/dist/xlsx/schema.d.ts.map +1 -0
- package/dist/xlsx/zip.d.ts +13 -0
- package/dist/xlsx/zip.d.ts.map +1 -0
- package/llms/agent-runtime.2.txt +40 -16
- package/llms/agent-runtime.3.txt +17 -0
- package/llms/agent-runtime.txt +4 -1
- package/llms/primitives.txt +21 -0
- package/llms/stitchkit.txt +9 -6
- package/llms/telegram.txt +46 -15
- package/llms/tracking-contract.txt +32 -0
- package/llms/tracking-performance.txt +21 -0
- package/llms/tracking-server.txt +1 -0
- package/llms/tracking.txt +75 -12
- package/llms/{upgrading-0.105.0-0.116.0.txt → upgrading-0.105.0-0.118.0.txt} +73 -3
- package/llms/upgrading.txt +1 -1
- package/llms/xlsx.txt +107 -0
- package/llms-full.txt +392 -34
- package/llms.txt +11 -7
- package/package.json +27 -9
- package/dist/{index-z3d6smer.js → index-tdpmfks8.js} +5 -5
package/llms-full.txt
CHANGED
|
@@ -52,7 +52,7 @@ own, recorded as an ADR.
|
|
|
52
52
|
| `stitchkit/realtime` | browser, React Native/Hermes **and** server | evolving | typed realtime clients and retained topics with a required explicit Socket.IO peer loader |
|
|
53
53
|
| `stitchkit/contract` | browser **and** server | stable | the contract layer alone — `defineContract`, errors, pagination |
|
|
54
54
|
| `stitchkit/live` | browser **and** server | evolving | `defineEvents` — topic declarations beside the operation contract — and watched reads: `createWatchClient`, the value/difference frame and its reassembly |
|
|
55
|
-
| `stitchkit/primitives` | browser **and** server | evolving | generic values and declarations for lifecycle, access, audit, delivery and exports |
|
|
55
|
+
| `stitchkit/primitives` | browser **and** server | evolving | generic values and declarations for lifecycle, access, audit, delivery and exports, exact money and rounding tables |
|
|
56
56
|
| `stitchkit/server` | server (Bun) | stable | `createServer`, `implement`, hooks, auth, Socket.IO server, server primitives |
|
|
57
57
|
| `stitchkit/node` | server (Node ≥ 22) | stable | `serveNode` + the runtime-agnostic core — the Node mirror of `/server` |
|
|
58
58
|
| `stitchkit/tools` | server | stable | `createMcpHandler`, `mountMcp`, `mountAgent`, the OAuth provider, native tools |
|
|
@@ -67,24 +67,27 @@ own, recorded as an ADR.
|
|
|
67
67
|
| `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 |
|
|
68
68
|
| `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 |
|
|
69
69
|
| `stitchkit/files` | server (Bun or Node) | stable | peer-free managed local-file boundary |
|
|
70
|
-
| `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
|
|
71
|
-
| `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
|
|
70
|
+
| `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 |
|
|
71
|
+
| `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 |
|
|
72
72
|
| `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 |
|
|
73
73
|
| `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 |
|
|
74
74
|
| `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 |
|
|
75
|
+
| `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` |
|
|
76
|
+
| `stitchkit/tracking/performance` | browser **and** server | evolving | Web Vitals from real visitors, collected after load through the optional peer `web-vitals`; no `zod` |
|
|
75
77
|
| `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 |
|
|
76
78
|
| `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 |
|
|
77
79
|
| `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 |
|
|
78
80
|
| `stitchkit/geo` | server (Bun or Node) | evolving | managed GeoIP reader generations, last-known-good reload and the optional MaxMind adapter |
|
|
81
|
+
| `stitchkit/xlsx` | browser **and** server | evolving | a workbook from rows and typed columns, with no dependency; text never runs as a formula |
|
|
79
82
|
| `stitchkit/oauth` | browser **and** server | evolving | provider-neutral Authorization Code + PKCE request and one-shot callback transaction mechanics |
|
|
80
83
|
| `stitchkit/google` | server (Bun or Node) | evolving | optional Google code exchange and verified OIDC identity adapter |
|
|
81
|
-
| `stitchkit/observability` | server | stable<br>_redefined in 2 of the
|
|
84
|
+
| `stitchkit/observability` | server | stable<br>_redefined in 2 of the 63 minors since 0.56.2, most recently 0.92.0_ | request/tool event projections — `createObservability`, trace context, sanitisation |
|
|
82
85
|
| `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 |
|
|
83
86
|
| `stitchkit/declaration` | browser + build and deployment tooling (Bun or Node) | evolving | `ProjectDeclarationSchema` — the one machine-readable statement a repository makes about itself |
|
|
84
87
|
| `stitchkit/react` | browser + server rendering | stable | `createCursorQuery`, `createCacheBridge`, QueryClient and `ApiError` retry policy |
|
|
85
88
|
| `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) |
|
|
86
89
|
| `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 |
|
|
87
|
-
| `stitchkit/agent-runtime` | server | evolving<br>_redefined in 25 of the
|
|
90
|
+
| `stitchkit/agent-runtime` | server | evolving<br>_redefined in 25 of the 63 minors since 0.56.2, most recently 0.115.0_ | optional durable conversation/run loop, history, models, prompts, fencing and events |
|
|
88
91
|
| `stitchkit/agent-runtime/sandbox` | server | evolving | optional Linux Bubblewrap sessions, durable workspaces and a host HTTP credential gateway; see [sandbox guide](sandbox.md) |
|
|
89
92
|
| `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 |
|
|
90
93
|
| `stitchkit/agent-runtime/harness` | server | evolving | resource-aware process-local facade over the canonical Agent runtime; supervision stays outside |
|
|
@@ -96,7 +99,7 @@ own, recorded as an ADR.
|
|
|
96
99
|
| `stitchkit/agent-runtime/sqlite/bun` | server (Bun) | evolving | durable built-in SQLite store for the agent runtime |
|
|
97
100
|
| `stitchkit/agent-runtime/sqlite/node` | server (Node ≥ 22.5) | evolving | durable built-in SQLite store for the agent runtime |
|
|
98
101
|
| `stitchkit-tui` | terminal (Bun) | evolving | optional official OpenTUI host over a caller-composed headless runtime |
|
|
99
|
-
| `stitchkit/application` | browser + server | evolving<br>_redefined in 14 of the
|
|
102
|
+
| `stitchkit/application` | browser + server | evolving<br>_redefined in 14 of the 63 minors since 0.56.2, most recently 0.110.0_ | managed resource graph, readiness, admission, schedules, subtree restart and bounded shutdown |
|
|
100
103
|
| `stitchkit/application/grammy` | server | evolving | a grammY bot as application resources — configuration, then polling with updates admitted by batch — and the webhook adapter |
|
|
101
104
|
| `stitchkit/application/opentelemetry` | server | evolving | maps application snapshots onto an injected OpenTelemetry `Meter` |
|
|
102
105
|
| `stitchkit/application/schemas` | browser + server | evolving | the application's snapshot, health and shutdown schemas alone, without the kernel |
|
|
@@ -448,7 +451,7 @@ Both entrypoints are **evolving**.
|
|
|
448
451
|
## Contract
|
|
449
452
|
|
|
450
453
|
```ts
|
|
451
|
-
import { createTrackingContract } from 'stitchkit/tracking'
|
|
454
|
+
import { createTrackingContract } from 'stitchkit/tracking/contract'
|
|
452
455
|
|
|
453
456
|
export const tracking = createTrackingContract({
|
|
454
457
|
scope: 'public',
|
|
@@ -647,6 +650,76 @@ has an identity. A bot gets a lease that no store holds, so its events are
|
|
|
647
650
|
`createPresenceRegistry` is who is here now, in this process: touch it from
|
|
648
651
|
`track`, read it for a live feed. It is honestly empty after a restart.
|
|
649
652
|
|
|
653
|
+
## Real-visitor speed
|
|
654
|
+
|
|
655
|
+
`stitchkit/tracking/performance` collects Web Vitals from the people who use the site. Install the
|
|
656
|
+
optional peer `web-vitals` and call it once on the page:
|
|
657
|
+
|
|
658
|
+
```ts
|
|
659
|
+
import { createPerformanceCollector } from 'stitchkit/tracking/performance'
|
|
660
|
+
|
|
661
|
+
createPerformanceCollector({
|
|
662
|
+
buildId: BUILD_ID,
|
|
663
|
+
url: '/api/tracking/performance',
|
|
664
|
+
visitId: () => client.visitId(),
|
|
665
|
+
})
|
|
666
|
+
```
|
|
667
|
+
|
|
668
|
+
The library is fetched as its own chunk after `load`, when the browser is idle, so the measurement costs
|
|
669
|
+
the page nothing it is measuring. Each load posts an `early` sample five seconds later and a `final` one
|
|
670
|
+
as the page goes, both with `sendBeacon` and the same `id`: keep the later one. The body is a string, so
|
|
671
|
+
the endpoint declares `safelistedBody: true`. A sample that could not leave waits in session storage for the
|
|
672
|
+
next page, up to 20 of them, and of one load only the newest.
|
|
673
|
+
|
|
674
|
+
A browser under automation sends nothing, and neither does an agent that admits to being Lighthouse,
|
|
675
|
+
headless Chrome, GTmetrix or a crawler. Lighthouse with its default settings imitates an ordinary browser, so a
|
|
676
|
+
local run with `webdriver` off cannot be told from a visitor.
|
|
677
|
+
|
|
678
|
+
One load is one document: a client-side navigation stays under the route the page opened on, and whatever
|
|
679
|
+
`web-vitals` reports after a back-forward restore is left out, because it would replace the load's numbers
|
|
680
|
+
with a restore's. A second call on a page returns the running collector.
|
|
681
|
+
|
|
682
|
+
A sample carries the route, the build, `mobile` or `desktop`, and the five metrics. **A metric that did not
|
|
683
|
+
arrive is `null`, never zero**: most visits have no INP at all, and a zero would pull every average down.
|
|
684
|
+
|
|
685
|
+
Parse a sample on your own endpoint and store it in your own table:
|
|
686
|
+
|
|
687
|
+
```ts
|
|
688
|
+
import { redactTrackingText } from 'stitchkit/tracking'
|
|
689
|
+
import { PerformanceSampleSchema, summarizePerformanceMetric } from 'stitchkit/tracking/contract'
|
|
690
|
+
|
|
691
|
+
const sample = PerformanceSampleSchema.parse(await request.json())
|
|
692
|
+
await samples.upsert({ ...sample, route: redactTrackingText(sample.route) })
|
|
693
|
+
|
|
694
|
+
const lcp = summarizePerformanceMetric(rows.map((row) => row.vitals.lcpMs))
|
|
695
|
+
// { samples: 42, p75: 1840, p95: null } — a p95 needs 100 samples
|
|
696
|
+
```
|
|
697
|
+
|
|
698
|
+
The report is yours: which routes matter and what is slow are the application's words.
|
|
699
|
+
|
|
700
|
+
## Privacy
|
|
701
|
+
|
|
702
|
+
`redactTrackingText` masks passwords, sign-in credentials, API keys, bearer tokens and signed Telegram launch
|
|
703
|
+
data in a URL or free text, and leaves paths and campaign parameters byte for byte. Text past 16 KiB is cut
|
|
704
|
+
first, because the endpoint is open to anyone. `code` and `hash` count only beside the
|
|
705
|
+
`state` or `auth_date` that makes them credentials, so a promo code stays. `redactTrackingValue` applies the
|
|
706
|
+
same rule through a value of any shape. The client applies it to the landing path, the referrer and the
|
|
707
|
+
campaign tags before sending or storing them. Apply it again on your ingest: anyone can post to that endpoint without running the client.
|
|
708
|
+
|
|
709
|
+
## Is tracking losing events?
|
|
710
|
+
|
|
711
|
+
`trackingTelemetryHealth(reports, baselines)` reads the outbox figures of a visit's bootstrap
|
|
712
|
+
(`browserStreamId` as `stream`, `outboxState`, `outboxQueued`, `outboxDropped`) and answers `ok`, `degraded` or
|
|
713
|
+
`unknown`. An application running without an outbox reports `unavailable` and reads as `degraded`. A browser repeats its lifetime `dropped` with
|
|
714
|
+
every visit, so pass what each stream reported before the window as `baselines`, and only the growth counts.
|
|
715
|
+
|
|
716
|
+
## Bundle weight
|
|
717
|
+
|
|
718
|
+
`stitchkit/tracking` has no `zod` in its graph: `createTrackingClient` with `indexedDbOutboxStorage` is under
|
|
719
|
+
8 KB gzip, a test holds that, and the build refuses a published file that reaches `zod`. The schemas live in
|
|
720
|
+
`stitchkit/tracking/contract` for the server and a shared contract. Importing that in code a browser loads
|
|
721
|
+
brings `zod` back, so keep a shared contract out of the storefront's client bundle.
|
|
722
|
+
|
|
650
723
|
## Not here
|
|
651
724
|
|
|
652
725
|
GeoIP, event labels, funnels, reports, the analytics page, Socket.IO push into
|
|
@@ -5777,7 +5850,10 @@ remains the signal-only compatibility surface and additionally waits for admissi
|
|
|
5777
5850
|
|
|
5778
5851
|
The in-memory store is a reference adapter and has process-local durability
|
|
5779
5852
|
only. Production applications normally call `createAgentRuntimeStore()` and
|
|
5780
|
-
provide one database transaction driver
|
|
5853
|
+
provide one database transaction driver. Its `transaction` owns the retry of a
|
|
5854
|
+
serialization conflict, wherever the database reports it: on a statement or on
|
|
5855
|
+
`COMMIT`, which some clients surface in a different shape. Pass
|
|
5856
|
+
`armCommitConflict` to `runAgentStoreConformance` to prove it:
|
|
5781
5857
|
|
|
5782
5858
|
```ts
|
|
5783
5859
|
const store = createAgentRuntimeStore({
|
|
@@ -6366,6 +6442,46 @@ canonical run and failed assistant atomically, removes the run from recovery
|
|
|
6366
6442
|
indexes, and publishes the resulting `run-state`. A run that moved since it was
|
|
6367
6443
|
read returns a conflict; `staleOwner: true` is mandatory evidence, not a default.
|
|
6368
6444
|
|
|
6445
|
+
The same evidence holds inside one process when a store failure outlives the
|
|
6446
|
+
run's own handling. A store call around execution that throws is retried for
|
|
6447
|
+
about half a second, then decided by where the run stood. Retries bound a call
|
|
6448
|
+
that fails, not one that hangs, so give the store its own timeouts:
|
|
6449
|
+
|
|
6450
|
+
| Failure | Outcome of `result` |
|
|
6451
|
+
|---|---|
|
|
6452
|
+
| 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` |
|
|
6453
|
+
| the first assistant draft | resolves with reason `runtime_failure`, like a checkpoint later in the turn |
|
|
6454
|
+
| a conflict on a run another executor holds | rejects with the conflict; the record stays that executor's |
|
|
6455
|
+
| a conflict on a run still queued, behind another run | rejects with `AgentRunUnsettledError`; `recover()` or `resume` picks it up |
|
|
6456
|
+
| the terminal commit, or closing the run, retries spent | rejects with `AgentRunUnsettledError` |
|
|
6457
|
+
|
|
6458
|
+
`AgentRunUnsettledError.run` is the record as last read, and the store may be ahead
|
|
6459
|
+
of it. Nothing in this process executes that run, and later turns of its
|
|
6460
|
+
conversation wait behind it. `recover()` skips a `running` run with a live owner, so
|
|
6461
|
+
a long-running process closes it itself once the store answers. Read the record
|
|
6462
|
+
first: with no owner or with `error.ownerId` it is this runtime's, and any other
|
|
6463
|
+
owner is executing it.
|
|
6464
|
+
|
|
6465
|
+
```ts
|
|
6466
|
+
const settled = await ticket.result.catch(async (error) => {
|
|
6467
|
+
if (!(error instanceof AgentRunUnsettledError)) throw error
|
|
6468
|
+
const { conversationId, id: runId } = error.run
|
|
6469
|
+
const current = await store.loadRun({ conversationId, runId })
|
|
6470
|
+
if (current && [undefined, error.ownerId].includes(current.run.ownerId)) {
|
|
6471
|
+
await runtime.abandon({
|
|
6472
|
+
conversationId,
|
|
6473
|
+
runId,
|
|
6474
|
+
expectedRevision: current.run.revision,
|
|
6475
|
+
staleOwner: true,
|
|
6476
|
+
})
|
|
6477
|
+
}
|
|
6478
|
+
throw error
|
|
6479
|
+
})
|
|
6480
|
+
```
|
|
6481
|
+
|
|
6482
|
+
A `queued` run lost to a run ahead of it, and `runtime.resume()` can run it instead
|
|
6483
|
+
once that one ends.
|
|
6484
|
+
|
|
6369
6485
|
## Store operations
|
|
6370
6486
|
|
|
6371
6487
|
`AgentRuntimeStore` remains the runtime-facing aggregate. Application adapters
|
|
@@ -9349,6 +9465,23 @@ migration.
|
|
|
9349
9465
|
literal in the type; division and rational shares return an explicit remainder. It does not own
|
|
9350
9466
|
exchange rates.
|
|
9351
9467
|
|
|
9468
|
+
`moneyFromDecimal('RUB', '5041.82', 2)` and `moneyToDecimal(value, 2)` cross between major units and
|
|
9469
|
+
minor ones with the currency's scale as a parameter, and a value finer than that scale is refused
|
|
9470
|
+
rather than cut. `multiplyMoneyByDecimal(price, '2.5', policy)` computes the exact product and rounds it
|
|
9471
|
+
once. `roundMoney(value, policy)` brings an amount to a table's steps:
|
|
9472
|
+
|
|
9473
|
+
```ts
|
|
9474
|
+
const shelfPrice = defineRoundingPolicy({
|
|
9475
|
+
mode: 'half-up', // or 'half-even', 'up', 'down'
|
|
9476
|
+
tiers: [{ below: '100000', step: '100' }, { step: '1000' }], // minor units
|
|
9477
|
+
})
|
|
9478
|
+
roundMoney(moneyFromDecimal('RUB', '5041.82', 2), shelfPrice) // { minor: '504000', currency: 'RUB' }
|
|
9479
|
+
```
|
|
9480
|
+
|
|
9481
|
+
A policy is data, so it can be stored with the prices it produced. `roundDecimal(value, policy)` is
|
|
9482
|
+
the same table over a plain decimal. `DecimalStringSchema` accepts one canonical spelling and refuses a
|
|
9483
|
+
JSON number; `DecimalInputSchema` takes a spelling such as a database's `10.50` to the canonical one.
|
|
9484
|
+
|
|
9352
9485
|
`defineUnitSystem` stores exact canonical decimal strings. Every conversion is an application
|
|
9353
9486
|
rational with an id. A converted `QuantityProjection` is `derived` and carries both its source and
|
|
9354
9487
|
conversion id; a form/database value can be marked `recorded`. Whether a derived projection is
|
|
@@ -15927,17 +16060,37 @@ cast, and a send cancelled in the queue then waits for its slot and fails as
|
|
|
15927
16060
|
`messagesPerSecond`.
|
|
15928
16061
|
- **The first send after idle is immediate; the rest are spaced.** This is a
|
|
15929
16062
|
strict budget, not a bucket that saves a burst: at 24/s the next send is due
|
|
15930
|
-
one interval later.
|
|
15931
|
-
|
|
15932
|
-
|
|
15933
|
-
|
|
15934
|
-
|
|
15935
|
-
|
|
16063
|
+
one interval later. When a pause ends, one send is released at the deadline and
|
|
16064
|
+
the queue continues one interval at a time, never as a stampede.
|
|
16065
|
+
- **A 429 holds the chat that got it.** Telegram words a group's limit, a chat's
|
|
16066
|
+
pace and the bot's own limit alike, and only the addressee differs, so `run`
|
|
16067
|
+
pauses the `chat_id` of the refused send and every other chat of the token goes
|
|
16068
|
+
on at the shared rate. A person's reply does not wait behind a notification
|
|
16069
|
+
group on its limit, and neither does a campaign. Refusals from
|
|
16070
|
+
`tokenPauseChats` different chats (default 3) inside `tokenPauseWindowMs`
|
|
16071
|
+
(default 5000) are read as the bot's own limit and pause the whole token, and so
|
|
16072
|
+
does a 429 with no chat in the payload. `stats().pausedChats` counts the chats
|
|
16073
|
+
on a pause; `stats().pausedForMs` is the token's.
|
|
16074
|
+
- **A chat known to hit its limit can keep a 429 to itself.** A notification group
|
|
16075
|
+
runs into its per-minute limit as a matter of course. `{ refusal: 'call' }` on `run`,
|
|
16076
|
+
or `telegramBudgetTransformer(budget, { refusal: 'call' })` on that group's own `Api`,
|
|
16077
|
+
makes the refusal concern that send alone: nothing pauses and nothing counts towards
|
|
16078
|
+
`tokenPauseChats`. The call still spends the budget and waits out other pauses, and
|
|
16079
|
+
what to do with the refused message stays the caller's decision.
|
|
16080
|
+
- **A wait can be bounded.** A burst to one chat on pause otherwise queues without
|
|
16081
|
+
limit. `{ maxWaitMs }` on `run` or `acquire`, or on
|
|
16082
|
+
`telegramBudgetTransformer(budget, { maxWaitMs })`, ends a call that waited that
|
|
16083
|
+
long with `TelegramNotDispatchedError`, stage `queue`: nothing was sent and no
|
|
16084
|
+
message was spent, so repeating it is safe.
|
|
16085
|
+
- **It paces; it does not retry.** `run` calls the send once. A 429 pauses for
|
|
16086
|
+
Telegram's `retry_after` (or `retryAfterFallbackMs` when Telegram gave none) and
|
|
16087
|
+
rethrows; the caller's retry policy decides what happens next.
|
|
15936
16088
|
The refusal may be thrown or returned: a client transformer sits below the
|
|
15937
16089
|
place where grammY turns Telegram's `{ ok: false, error_code: 429, … }` body into
|
|
15938
16090
|
a `GrammyError`, so `run` reads that body too and hands it back unchanged.
|
|
15939
|
-
A 429 from an edit or a read concerns that call and pauses nothing;
|
|
15940
|
-
remains for a caller who decides otherwise
|
|
16091
|
+
A 429 from an edit or a read concerns that call and pauses nothing;
|
|
16092
|
+
`budget.pauseAfter(error, { chatId })` remains for a caller who decides otherwise, and pauses
|
|
16093
|
+
the token when it names no chat. A network failure is rethrown unchanged and stays `unknown`; a 5xx
|
|
15941
16094
|
is rethrown unchanged and stays `server-error`. Neither is retried by the
|
|
15942
16095
|
budget or pauses the token — repeating a send whose outcome is unknown is a
|
|
15943
16096
|
decision, not a primitive's silent guess.
|
|
@@ -15949,9 +16102,9 @@ cast, and a send cancelled in the queue then waits for its slot and fails as
|
|
|
15949
16102
|
the client's own error — not evidence that Telegram did not accept it — so
|
|
15950
16103
|
keep the outcome unknown rather than retrying it as a definite failure.
|
|
15951
16104
|
- **Non-send retries wait without spending.** An edit or delete retry that got
|
|
15952
|
-
a 429
|
|
15953
|
-
|
|
15954
|
-
the token's
|
|
16105
|
+
a 429 records the pause with `budget.pauseAfter(error, { chatId })`, then uses
|
|
16106
|
+
`await budget.waitUntilResumed(signal, { chatId })`; it shares that chat's pause
|
|
16107
|
+
and the token's, and takes no message slot. Without `chatId` it pauses the token.
|
|
15955
16108
|
|
|
15956
16109
|
`telegramBroadcastSender` and `telegramOperatorSender` still send through
|
|
15957
16110
|
`callTelegramBotApi`; they are not a second budget. Their returned function does
|
|
@@ -16254,7 +16407,17 @@ intake recorded the body; the handler runs after, outside the request. Updates
|
|
|
16254
16407
|
of one chat run in order, other chats alongside (`maxConcurrent`, 32). An
|
|
16255
16408
|
attempt holds a lease it renews while the handler lives; a sweep takes over what
|
|
16256
16409
|
was left — `pending` whose process never got to it (`pendingGraceMs`), `failed`
|
|
16257
|
-
whose retry is due, `processing` whose process died.
|
|
16410
|
+
whose retry is due, `processing` whose process died. `start` schedules the whole
|
|
16411
|
+
queue the last process left, page by page and without waiting for
|
|
16412
|
+
`pendingGraceMs`, and an update accepted meanwhile takes its place behind it, so
|
|
16413
|
+
a crash keeps each chat in order however long the queue was. The queue sits in
|
|
16414
|
+
memory while it drains, as it did in the process that accepted it. `close`
|
|
16415
|
+
waits for the handlers running and leaves the rest of the queue recorded. Order
|
|
16416
|
+
holds inside one process for updates handled in their turn: the attempt a crash
|
|
16417
|
+
interrupted comes when its lease lapses, a failed update at its retry and one
|
|
16418
|
+
the store refused to claim at a later sweep, each after later updates of its
|
|
16419
|
+
chat. An old release draining beside a new one shares its queue, so the two can
|
|
16420
|
+
run updates of one chat side by side. A failure is retried with
|
|
16258
16421
|
backoff or after Telegram's `retry_after`; one Telegram said repeating cannot
|
|
16259
16422
|
fix (a refused message, a blocked user) is abandoned; `maxAttempts` (5) ends
|
|
16260
16423
|
the rest. Delivery is at least once: a handler that finished but could not be
|
|
@@ -16304,7 +16467,8 @@ in a `BotError`; the intake unwraps it, so `retry`, `onFailure` and the error
|
|
|
16304
16467
|
stored with the update are what the middleware threw — a `retry` that returns
|
|
16305
16468
|
`false` for the bot's own terminal error sees that error.
|
|
16306
16469
|
|
|
16307
|
-
The base store remains the six atomic steps of `TelegramUpdateStore
|
|
16470
|
+
The base store remains the six atomic steps of `TelegramUpdateStore`; `due` is
|
|
16471
|
+
paged, continuing strictly after `afterUpdateId`. A
|
|
16308
16472
|
`TelegramUpdateFencedStore` adds `claimOwned`, `renewOwned`, `owns` and
|
|
16309
16473
|
`settleOwned`; `TelegramUpdateDurableStore` adds the final-obligation methods.
|
|
16310
16474
|
Reference stores implement both, so the bot's own database holds the fence and
|
|
@@ -16789,12 +16953,171 @@ Download schedules, licenses, database paths, attribution persistence and
|
|
|
16789
16953
|
analytics policy belong to the application.
|
|
16790
16954
|
|
|
16791
16955
|
|
|
16956
|
+
==============================================================================
|
|
16957
|
+
# Guide: XLSX (docs/guide/xlsx.md)
|
|
16958
|
+
==============================================================================
|
|
16959
|
+
|
|
16960
|
+
# XLSX
|
|
16961
|
+
|
|
16962
|
+
`stitchkit/xlsx` turns rows into a workbook. It is evolving, it needs nothing beyond the `zod` the package
|
|
16963
|
+
already requires, and it runs wherever
|
|
16964
|
+
`CompressionStream` does: Bun, Node and a browser.
|
|
16965
|
+
|
|
16966
|
+
```ts
|
|
16967
|
+
import { defineMoney } from 'stitchkit/primitives'
|
|
16968
|
+
import { renderXlsx, XLSX_MEDIA_TYPE } from 'stitchkit/xlsx'
|
|
16969
|
+
|
|
16970
|
+
const rub = defineMoney('RUB')
|
|
16971
|
+
|
|
16972
|
+
const bytes = await renderXlsx({
|
|
16973
|
+
sheets: [
|
|
16974
|
+
{
|
|
16975
|
+
name: 'Orders',
|
|
16976
|
+
columns: [
|
|
16977
|
+
{ key: 'title', header: 'Title', type: 'text' },
|
|
16978
|
+
{ key: 'count', header: 'Count', type: 'number', format: '0.00' },
|
|
16979
|
+
{ key: 'day', header: 'Day', type: 'date' },
|
|
16980
|
+
{ key: 'at', header: 'Created', type: 'datetime', timeZone: 'Asia/Bangkok' },
|
|
16981
|
+
{ key: 'total', header: 'Total', type: 'money', currency: 'RUB', scale: 2 },
|
|
16982
|
+
{ key: 'paid', header: 'Paid', type: 'boolean' },
|
|
16983
|
+
],
|
|
16984
|
+
rows: [
|
|
16985
|
+
{
|
|
16986
|
+
title: 'First order',
|
|
16987
|
+
count: '2.5',
|
|
16988
|
+
day: '2026-11-03',
|
|
16989
|
+
at: new Date(),
|
|
16990
|
+
total: rub.create('504182'),
|
|
16991
|
+
paid: true,
|
|
16992
|
+
},
|
|
16993
|
+
],
|
|
16994
|
+
},
|
|
16995
|
+
],
|
|
16996
|
+
})
|
|
16997
|
+
|
|
16998
|
+
return new Response(bytes, {
|
|
16999
|
+
headers: {
|
|
17000
|
+
'content-type': XLSX_MEDIA_TYPE,
|
|
17001
|
+
'content-disposition': `attachment; filename*=UTF-8''${encodeURIComponent('Übersicht.xlsx')}`,
|
|
17002
|
+
},
|
|
17003
|
+
})
|
|
17004
|
+
```
|
|
17005
|
+
|
|
17006
|
+
A missing or `null` value leaves the cell empty. The first row holds the headers, stays frozen and carries a
|
|
17007
|
+
filter. The same input produces the same bytes on one runtime; Bun and Node compress differently.
|
|
17008
|
+
|
|
17009
|
+
## Column types
|
|
17010
|
+
|
|
17011
|
+
| `type` | Cell value | In the file |
|
|
17012
|
+
|---|---|---|
|
|
17013
|
+
| `text` | string | text, whatever it looks like: `007` keeps its zeros |
|
|
17014
|
+
| `number` | number, bigint or decimal string | a number, with an optional Excel `format` |
|
|
17015
|
+
| `date` | `YYYY-MM-DD` | a date serial; a calendar date has no time zone to get wrong |
|
|
17016
|
+
| `datetime` | `Date` or ISO instant with an offset | the wall clock of the column's `timeZone` to the second, since a cell stores no zone |
|
|
17017
|
+
| `money` | `Money` in the column's `currency` | a number with `scale` places and the currency in its format |
|
|
17018
|
+
| `boolean` | boolean | a boolean |
|
|
17019
|
+
|
|
17020
|
+
## What it refuses
|
|
17021
|
+
|
|
17022
|
+
A value of the wrong type throws `XlsxCellError` naming the cell, such as `sheet "Orders" B2: expected a
|
|
17023
|
+
number or a decimal string`, instead of landing as a wrong cell.
|
|
17024
|
+
|
|
17025
|
+
Excel keeps numbers as doubles, so 15 significant digits are what survives. A decimal string or `Money` with
|
|
17026
|
+
more refuses rather than turning into a different amount. Keep such a value in a `text` column if it must
|
|
17027
|
+
stay exact and needs no arithmetic. Dates before 1900-03-01 refuse too: Excel counts a leap day that never
|
|
17028
|
+
happened, so its serials before it are off by one.
|
|
17029
|
+
|
|
17030
|
+
A wall clock cannot tell the two hours of a daylight-saving change apart: 05:30Z and 06:30Z on a New York
|
|
17031
|
+
autumn night are the same cell. Use `UTC` for a column whose order must survive that hour.
|
|
17032
|
+
|
|
17033
|
+
## Text is never a formula
|
|
17034
|
+
|
|
17035
|
+
Cells are written as inline strings, so `=HYPERLINK("x")` from a user's input is text a reader shows,
|
|
17036
|
+
and the file has no formula element at all. A cell that starts with `=`, `+`, `-` or `@` also carries Excel's
|
|
17037
|
+
quote prefix, so it stays text when a person edits that cell.
|
|
17038
|
+
|
|
17039
|
+
## Limits
|
|
17040
|
+
|
|
17041
|
+
Everything is built in memory, up to Excel's own 1 048 576 rows per sheet. There is no reading, no
|
|
17042
|
+
charts, no merged cells and no streaming: an application that needs them takes a library.
|
|
17043
|
+
|
|
17044
|
+
|
|
16792
17045
|
==============================================================================
|
|
16793
17046
|
# Guide: Upgrading (docs/guide/upgrading.md)
|
|
16794
17047
|
==============================================================================
|
|
16795
17048
|
|
|
16796
17049
|
# Upgrading stitchkit
|
|
16797
17050
|
|
|
17051
|
+
## Released migration: 0.118.0
|
|
17052
|
+
|
|
17053
|
+
### telegram-due-cursor
|
|
17054
|
+
|
|
17055
|
+
**Who must act:** an application with its own `TelegramUpdateStore`. A bot on `memoryTelegramUpdateStore`,
|
|
17056
|
+
`sqliteTelegramUpdateStore` or `postgresTelegramUpdateStore` needs no change.
|
|
17057
|
+
|
|
17058
|
+
`due` returns one page of a queue whose rows stay due until claimed, and the intake reads the next page from
|
|
17059
|
+
`afterUpdateId`, until a page comes back empty. A store that ignores the cursor fails `start` and every sweep
|
|
17060
|
+
with a `TypeError`, reported to `onStoreError`, as soon as a row is due. Continue strictly after it, in
|
|
17061
|
+
`update_id` order:
|
|
17062
|
+
|
|
17063
|
+
```ts
|
|
17064
|
+
// before
|
|
17065
|
+
where: { OR: dueRows }
|
|
17066
|
+
// after
|
|
17067
|
+
where: { OR: dueRows, ...(query.afterUpdateId !== undefined && { updateId: { gt: query.afterUpdateId } }) }
|
|
17068
|
+
```
|
|
17069
|
+
|
|
17070
|
+
`checkTelegramUpdateStore` reports the rule as `due continues strictly after its cursor`.
|
|
17071
|
+
|
|
17072
|
+
Search pattern: an object with a `due(` method passed as `store` to `createTelegramUpdateIntake`.
|
|
17073
|
+
|
|
17074
|
+
## Released migration: 0.117.0
|
|
17075
|
+
|
|
17076
|
+
### telegram-chat-pause
|
|
17077
|
+
|
|
17078
|
+
**Who must act:** code that relied on a 429 to one chat to stop the token's other chats. A bot that
|
|
17079
|
+
only sends needs no change: its other chats stop waiting.
|
|
17080
|
+
|
|
17081
|
+
`run` pauses the `chat_id` of a refused send; the token pauses when `tokenPauseChats` chats are refused
|
|
17082
|
+
inside `tokenPauseWindowMs`, or when the call has no chat
|
|
17083
|
+
([ADR 0278](../decisions/0278-a-telegram-429-holds-the-chat-that-got-it.md)). A second budget kept under a
|
|
17084
|
+
derived key to isolate one group is no longer needed: remove it. Where one refusal must still stop everything,
|
|
17085
|
+
say so:
|
|
17086
|
+
|
|
17087
|
+
```ts
|
|
17088
|
+
// before
|
|
17089
|
+
await api.sendMessage(chatId, text)
|
|
17090
|
+
// after
|
|
17091
|
+
await api.sendMessage(chatId, text).catch((error) => {
|
|
17092
|
+
budget.pauseAfter(error)
|
|
17093
|
+
throw error
|
|
17094
|
+
})
|
|
17095
|
+
```
|
|
17096
|
+
|
|
17097
|
+
The catch belongs at the `Api` call, where grammY has turned a returned refusal into a thrown one. A raw
|
|
17098
|
+
`budget.run` around a client transformer's `send` gets that refusal as a value.
|
|
17099
|
+
|
|
17100
|
+
Search pattern: `budget.run`, and budgets created under a key derived from the token.
|
|
17101
|
+
|
|
17102
|
+
### tracking-contract-entry
|
|
17103
|
+
|
|
17104
|
+
**Who must act:** code that imports `createTrackingContract` or a tracking schema or wire type from
|
|
17105
|
+
`stitchkit/tracking`. Code that only uses the browser client needs no change.
|
|
17106
|
+
|
|
17107
|
+
The wire shapes moved to `stitchkit/tracking/contract`, so a page that sends events no longer carries `zod`
|
|
17108
|
+
([ADR 0280](../decisions/0280-real-visitor-speed-is-collected-after-the-page.md)):
|
|
17109
|
+
|
|
17110
|
+
```ts
|
|
17111
|
+
// before
|
|
17112
|
+
import { createTrackingContract, createTrackingSchemas } from 'stitchkit/tracking'
|
|
17113
|
+
// after
|
|
17114
|
+
import { createTrackingContract, createTrackingSchemas } from 'stitchkit/tracking/contract'
|
|
17115
|
+
```
|
|
17116
|
+
|
|
17117
|
+
Search pattern: imports from `stitchkit/tracking` naming `createTrackingContract`, `createTrackingSchemas`,
|
|
17118
|
+
`UtmData`, `AttributionData`, `TrackingEventEnvelope`, `TrackingDisposition`, `TrackEvents*`, `VisitEntryContext`,
|
|
17119
|
+
`VisitBootstrapResponse`, `TrackingOutboxState` or `DEFAULT_BUILD_ID_PATTERN`.
|
|
17120
|
+
|
|
16798
17121
|
## Released migration: 0.116.0
|
|
16799
17122
|
|
|
16800
17123
|
### send-only-telegram-pause
|
|
@@ -22167,6 +22490,10 @@ schedules, transports and file generation remain application-owned.
|
|
|
22167
22490
|
| `PermissionGrantMatrix` / `PermissionCheckResult` | _types_ | compile-time complete matrix and unknown/allowed/denied runtime result |
|
|
22168
22491
|
| `defineMoney` / `createMoneySchema` | functions | fixed-currency JSON-safe minor-unit value and Zod schema |
|
|
22169
22492
|
| `addMoney` / `subtractMoney` / `multiplyMoney` / `shareMoney` / `splitMoney` | functions | exact same-currency arithmetic with explicit indivisible remainder |
|
|
22493
|
+
| `moneyFromDecimal` / `moneyToDecimal` | functions | major units to minor ones and back, with the currency's scale as a parameter |
|
|
22494
|
+
| `multiplyMoneyByDecimal` / `roundMoney` | functions | an exact product rounded once, and an amount brought to a policy's steps |
|
|
22495
|
+
| `defineRoundingPolicy` / `roundDecimal` / `RoundingPolicySchema` / `RoundingPolicy` / `RoundingModeSchema` / `RoundingMode` | functions, schemas, _types_ | a rounding table as data, by magnitude, and its modes |
|
|
22496
|
+
| `DecimalStringSchema` / `DecimalInputSchema` | schemas | one canonical decimal spelling, and the input form that reaches it; a number is refused |
|
|
22170
22497
|
| `Money` / `MoneyShare` / `MoneySplit` | _types_ | currency-literal value and remainder-bearing operation results |
|
|
22171
22498
|
| `defineUnitSystem` / `createQuantitySchema` / `addQuantity` | functions | exact decimal quantities and caller-declared finite conversions |
|
|
22172
22499
|
| `Quantity` / `UnitConversion` / `QuantityProjection` | _types_ | unit-literal value, rational conversion and recorded/derived provenance |
|
|
@@ -22865,6 +23192,7 @@ Server-only optional application runtime. See the
|
|
|
22865
23192
|
| `AgentRuntimeRecoverOptions` | _type_ | bounded paged startup recovery with causal per-conversation scheduling, context resolver and explicit evidence policy |
|
|
22866
23193
|
| `AgentRuntimeAbandonInput` | _type_ | one known orphan identity, expected revision and mandatory stale-owner evidence for `runtime.abandon()` |
|
|
22867
23194
|
| `AgentRuntimeConflictError` | class | thrown when a store mutation loses to a concurrent writer — catchable by type from `stitchkit/agent-runtime` |
|
|
23195
|
+
| `AgentRunUnsettledError` | class | rejects `result` when the store never answered: `.run` is still active with no executor, close it with `runtime.abandon()` |
|
|
22868
23196
|
| `AgentSessionCloseOptions` | _type_ | `gracePeriodMs` for natural settlement, then abort, then `forceTimeoutMs` for bounded settlement after it |
|
|
22869
23197
|
| `AgentSessionCloseResult` | _type_ | what `close()` achieved: `settled`, or `timedOut` with `remaining` runs still in flight. Only omitting `forceTimeoutMs` guarantees nothing is in flight on return |
|
|
22870
23198
|
| `AgentHistoryProjectionOptions` | _type_ | storage-neutral file resolver, explicit unresolved-file behavior, and how an interrupted turn reaches the model (`interruptedAssistant`) |
|
|
@@ -23860,7 +24188,7 @@ injected grammY bot. → ADR 0143, ADR 0201, ADR 0274 — [guide](../guide/teleg
|
|
|
23860
24188
|
| `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) |
|
|
23861
24189
|
| `TelegramNotDispatchedError` / `TelegramNotDispatchedStage` | class / _type_ | a request that provably never left (`lookup`, `connect` or `request`), so repeating it cannot duplicate a message |
|
|
23862
24190
|
| `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 |
|
|
23863
|
-
| `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
|
|
24191
|
+
| `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 |
|
|
23864
24192
|
| `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 |
|
|
23865
24193
|
| `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` |
|
|
23866
24194
|
| `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 |
|
|
@@ -23884,7 +24212,7 @@ injected grammY bot. → ADR 0143, ADR 0201, ADR 0274 — [guide](../guide/teleg
|
|
|
23884
24212
|
| `TelegramUpdateIntakeConfig` / `TelegramUpdateAttemptIntakeConfig` / `TelegramUpdateIntakeOptions` / `TelegramUpdateIntake` / `TelegramUpdateEnvelope` / `TelegramUpdateFailure` / `TelegramUpdateStoreStep` | _type_ | `store`, unchanged `handle(update)` or attempt-aware `handleAttempt(update, context)` (a grammY `BotError` is unwrapped), shared `retry`, `maxAttempts` (5), `leaseMs` (120 000), `pendingGraceMs` (60 000), `sweepEveryMs` (30 000), `retainMs` (24 h), `maxConcurrent` (32), `onFailure`, durable `handleExhaustion`, `onExhaustionFailure`, `onStoreError`, `now`; `accept(body)`, `start()`, `sweep()`, `idle()`, `close()` |
|
|
23885
24213
|
| `TelegramUpdateAttemptContext` / `TelegramUpdateAttemptIdentity` / `TelegramUpdateOwnershipLostError` | _type_ / class | immutable `{ updateId, attempt, claimId }` fence plus `ownerLost`; the persisted opaque claim token prevents a stale capability from matching after prune/re-add, while a store check in the consumer's DB transaction fences a domain write |
|
|
23886
24214
|
| `TelegramUpdateExhaustion` / `TelegramUpdateExhaustionFailure` / `StoredTelegramUpdateExhaustion` / `TelegramUpdateExhaustionQuery` | _type_ | a terminal update/attempt/error retained in the update store until `handleExhaustion` resolves; ordered `{ limit, afterUpdateId? }` pages prevent a failing first batch from starving later rows; delivery failures are observational and leave it due |
|
|
23887
|
-
| `TelegramUpdateStore` / `StoredTelegramUpdate` / `TelegramUpdateState` / `TelegramUpdateSettlement` / `TelegramUpdateClaimOptions` / `TelegramUpdateDueQuery` | _type_ | the base store an intake runs on: `add`, `claim`, `renew`, `settle`, `due`, `prune`, each atomic on one record — a claim takes `pending`, a due `failed` or a lapsed `processing`; renew and settle only by the attempt holding it |
|
|
24215
|
+
| `TelegramUpdateStore` / `StoredTelegramUpdate` / `TelegramUpdateState` / `TelegramUpdateSettlement` / `TelegramUpdateClaimOptions` / `TelegramUpdateDueQuery` | _type_ | the base store an intake runs on: `add`, `claim`, `renew`, `settle`, `due`, `prune`, each atomic on one record — a claim takes `pending`, a due `failed` or a lapsed `processing`; renew and settle only by the attempt holding it; `due` returns one page and continues strictly after `afterUpdateId` |
|
|
23888
24216
|
| `TelegramUpdateFencedStore` / `TelegramUpdateDurableStore` | _type_ | reference-store capabilities: `claimOwned` creates and returns the persisted identity, `renewOwned`, `owns(identity, at)` and `settleOwned(identity, settlement)` act only on that exact unexpired claim; `exhaust`, `dueExhaustions`, `acknowledgeExhaustion` keep a final consumer obligation in the same row until exact acknowledgement |
|
|
23889
24217
|
| `memoryTelegramUpdateStore` | function | the store in this process's memory — tests, or a bot that accepts losing unhandled updates to a restart |
|
|
23890
24218
|
| `sqliteTelegramUpdateStore` / `SqliteTelegramUpdateStoreConfig` / `TelegramSqliteDatabase` | function / _type_ | the store in SQLite over the handle the application opened — `bun:sqlite` `Database` or `node:sqlite` `DatabaseSync`; `table` (default `telegram_updates`) created when missing |
|
|
@@ -23967,8 +24295,9 @@ the whole dependency. → ADR 0211 — [guide](../guide/telegram-screens.md)
|
|
|
23967
24295
|
|
|
23968
24296
|
Browser-safe visitor-tracking mechanics, with no event vocabulary of their own
|
|
23969
24297
|
and no React. The React wrapper (a provider and a hook, ~40 lines) is the
|
|
23970
|
-
application's — it owns the router and the session.
|
|
23971
|
-
`stitchkit/tracking/
|
|
24298
|
+
application's — it owns the router and the session. It imports no `zod`: the wire
|
|
24299
|
+
shapes are `stitchkit/tracking/contract`, the server half is
|
|
24300
|
+
`stitchkit/tracking/server`. → ADR 0166, ADR 0280 — [guide](../guide/tracking.md)
|
|
23972
24301
|
|
|
23973
24302
|
| Export | Kind | Summary |
|
|
23974
24303
|
|--------|------|---------|
|
|
@@ -23977,15 +24306,6 @@ application's — it owns the router and the session. The server half is
|
|
|
23977
24306
|
| `TrackFn` / `EventsWithMetadata` / `EventsWithoutMetadata` | _type_ | `track(type)` / `track(type, metadata)` typed by the application's metadata map, and the two halves of that map |
|
|
23978
24307
|
| `BuiltinTrackingEventTypes` / `CONVENTIONAL_TRACKING_EVENT_TYPES` | _type_ / const | the application's names for the events the client emits itself; the conventional `PAGE_VIEW` … `INTERACTION` set |
|
|
23979
24308
|
| `browserTrackingHost` / `TrackingHost` / `TrackingPageContext` | function / _type_ | everything the client takes from a browser tab behind one interface — page context, visibility, scroll depth, events, intervals, clocks, storage — so a test or a non-tab host can supply its own |
|
|
23980
|
-
| `createTrackingContract` / `TrackingContractConfig` / `TrackingContractEndpoints` | function / _type_ | `bootstrap` (`POST /visit`) and `track` (`POST /events`, `safelistedBody`) from the application's event types, scope and optional extras |
|
|
23981
|
-
| `createTrackingSchemas` / `TrackingSchemas` / `TrackingSchemasConfig` | function / _type_ | every schema of one surface — `event`, `request`, `response`, `disposition`, `entry`, `bootstrap` — from `eventTypes`, optional `eventExtras`, `buildIdPattern`, `maxEventsPerBatch` |
|
|
23982
|
-
| `TrackingEventEnvelope` / `TrackingEventShape` | _type_ | `eventId`, `visitId`, `browserStreamId`, `browserSequence`, `type`, `page`, `metadata`, `clientTimestamp` |
|
|
23983
|
-
| `TrackEventsRequest` / `TrackEventsResponse` / `TrackEventsResponseSchema` | _type_ / schema | a batch (`buildId`, `events`, `utm`) and its answer (`accepted`, `dispositions`) |
|
|
23984
|
-
| `TrackingDisposition` / `TrackingDispositionSchema` / `TrackingDispositionStatus` / `TrackingDispositionStatusSchema` | _type_ / schema | `accepted` / `duplicate` / `identity-invalid` / `excluded-bot` — every one terminal |
|
|
23985
|
-
| `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 |
|
|
23986
|
-
| `TrackingOutboxState` / `TrackingOutboxStateSchema` | _type_ / schema | `available` / `unavailable` |
|
|
23987
|
-
| `UtmData` / `UtmDataSchema` / `AttributionData` / `AttributionDataSchema` | _type_ / schema | campaign tags and a touch (UTM, referrer, landing page) |
|
|
23988
|
-
| `DEFAULT_BUILD_ID_PATTERN` | const | `dev` or a git SHA |
|
|
23989
24309
|
| `createTrackingOutbox` / `TrackingOutbox` / `TrackingOutboxOptions` / `TrackingOutboxHealth` | function / _type_ | the tab-shared outbox: `streamId`, `reserveSequences`, `enqueue`, `acquireLease` / `releaseLease` (short, released on leave), `readBatch`, `acknowledge`, `health`; bounded by count and age |
|
|
23990
24310
|
| `TrackingOutboxStorage` / `TrackingOutboxMeta` / `TrackingOutboxEvents` / `TrackingOutboxRecord` / `TrackingQueuedEvent` | _type_ | one atomic, all-or-nothing `transact` over a key/value store and an event store (`readonly` for pure reads) — the contract an adapter implements |
|
|
23991
24311
|
| `indexedDbOutboxStorage` / `memoryOutboxStorage` | function | the IndexedDB adapter (one `readwrite` transaction per `transact`) and the in-memory one for tests and degraded mode |
|
|
@@ -23997,10 +24317,38 @@ application's — it owns the router and the session. The server half is
|
|
|
23997
24317
|
| `createOncePerPage` / `OncePerPage` | function / _type_ | one fact per key per page within a window — the guard a twice-mounted component cannot keep itself |
|
|
23998
24318
|
| `resolveAttribution` / `ResolveAttributionInput` / `ResolvedAttribution` / `AttributionStorage` / `ReferrerRule` | function / _type_ | first-touch once, current-touch on every new UTM; the referrer → source/medium map is the application's, there is no built-in list |
|
|
23999
24319
|
| `parseUtmFromSearch` / `parseReferrer` | function | the two parsers `resolveAttribution` is built from |
|
|
24320
|
+
| `redactTrackingText` / `redactTrackingValue` | functions | mask passwords, sign-in credentials and signed launch data in text or a value of any shape; the key stays, and navigation and campaign parameters are untouched |
|
|
24000
24321
|
| `resolveTrackedClick` / `ResolveTrackedClickOptions` / `TrackedClick` / `TrackedClickAttributes` / `ClickTarget` | function / _type_ | `data-track` → click, `data-track-action` → interaction, a link to another origin → outbound; attribute names configurable; `hrefPolicy: 'full'` retains query/fragment (default `path-only` omits them), URL credentials excluded; `leavesPage` says which path to send on |
|
|
24001
24322
|
|
|
24002
24323
|
---
|
|
24003
24324
|
|
|
24325
|
+
## `stitchkit/tracking/contract`
|
|
24326
|
+
|
|
24327
|
+
The wire shapes of tracking, for a server and a shared contract. It brings `zod`, so
|
|
24328
|
+
browser code that only sends events does not import it. → ADR 0280
|
|
24329
|
+
|
|
24330
|
+
| Export | Kind | Summary |
|
|
24331
|
+
|--------|------|---------|
|
|
24332
|
+
| `createTrackingContract` / `TrackingContractConfig` / `TrackingContractEndpoints` | function / _type_ | `bootstrap` (`POST /visit`) and `track` (`POST /events`, `safelistedBody`) from the application's event types, scope and optional extras |
|
|
24333
|
+
| `createTrackingSchemas` / `TrackingSchemas` / `TrackingSchemasConfig` | function / _type_ | every schema of one surface — `event`, `request`, `response`, `disposition`, `entry`, `bootstrap` — from `eventTypes`, optional `eventExtras`, `buildIdPattern`, `maxEventsPerBatch` |
|
|
24334
|
+
| `TrackingEventEnvelope` / `TrackingEventShape` | _type_ | `eventId`, `visitId`, `browserStreamId`, `browserSequence`, `type`, `page`, `metadata`, `clientTimestamp` |
|
|
24335
|
+
| `TrackEventsRequest` / `TrackEventsResponse` / `TrackEventsResponseSchema` | _type_ / schema | a batch (`buildId`, `events`, `utm`) and its answer (`accepted`, `dispositions`) |
|
|
24336
|
+
| `TrackingDisposition` / `TrackingDispositionSchema` / `TrackingDispositionStatus` / `TrackingDispositionStatusSchema` | _type_ / schema | `accepted` / `duplicate` / `identity-invalid` / `excluded-bot` — every one terminal |
|
|
24337
|
+
| `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 |
|
|
24338
|
+
| `TrackingOutboxState` / `TrackingOutboxStateSchema` | _type_ / schema | `available` / `unavailable` |
|
|
24339
|
+
| `UtmData` / `UtmDataSchema` / `AttributionData` / `AttributionDataSchema` | _type_ / schema | campaign tags and a touch (UTM, referrer, landing page) |
|
|
24340
|
+
| `DEFAULT_BUILD_ID_PATTERN` | const | `dev` or a git SHA |
|
|
24341
|
+
| `PerformanceSampleSchema` / `PerformanceSample` / `PerformanceVitalsSchema` / `PerformanceVitals` | schemas / _types_ | one page load's wire shape; a metric that did not arrive is `null` |
|
|
24342
|
+
| `summarizePerformanceMetric` / `PerformanceMetricSummary` | function / _type_ | sample count, p75, and a p95 only from 100 samples |
|
|
24343
|
+
|
|
24344
|
+
## `stitchkit/tracking/performance`
|
|
24345
|
+
|
|
24346
|
+
| Export | Kind | Summary |
|
|
24347
|
+
|--------|------|---------|
|
|
24348
|
+
| `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 |
|
|
24349
|
+
| `PerformanceHost` / `VitalsLibrary` / `VitalsMetric` / `VitalsObserver` | _types_ | the seams of the collector: the page, and the part of `web-vitals` it uses |
|
|
24350
|
+
| `isLabUserAgent` | function | whether an agent admits to being a lab run or a crawler |
|
|
24351
|
+
|
|
24004
24352
|
## `stitchkit/tracking/server`
|
|
24005
24353
|
|
|
24006
24354
|
The decisions a tracking backend makes, without the storage it makes them
|
|
@@ -24016,6 +24364,7 @@ algorithm over a store the application implements. → ADR 0166
|
|
|
24016
24364
|
| `activeIntervalOf` / `ActiveTimeInterval` / `ActiveIntervalOptions` | function / _type_ | the visible-time interval an event carries, dated by the server clock; `null` for an unshaped or implausible one |
|
|
24017
24365
|
| `hashTrackingEvent` | function | `sha256(JSON.stringify(parsedEvent))` — the stored payload hash, unsorted on purpose so it matches what applications already hold |
|
|
24018
24366
|
| `isBotUserAgent` / `DEFAULT_BOT_USER_AGENT_PATTERN` | function / const | crawlers, monitors and `headlesschrome` are not visitors |
|
|
24367
|
+
| `trackingTelemetryHealth` / `TrackingOutboxReport` / `TrackingTelemetryHealth` | function / _types_ | `ok`, `degraded` or `unknown` from outbox reports; a lifetime `dropped` counts only by what it grew over `baselines` |
|
|
24019
24368
|
| `createPresenceRegistry` / `PresenceRegistry` / `PresenceEntry` | function / _type_ | who is here now, in this process: `touch` / `snapshot(filter)` / `presentVisitOf` with a 45 s TTL |
|
|
24020
24369
|
|
|
24021
24370
|
---
|
|
@@ -24054,6 +24403,15 @@ providers, the microphone and the player remain application-owned. See the
|
|
|
24054
24403
|
|
|
24055
24404
|
---
|
|
24056
24405
|
|
|
24406
|
+
## `stitchkit/xlsx`
|
|
24407
|
+
|
|
24408
|
+
| Export | Kind | Summary |
|
|
24409
|
+
|--------|------|---------|
|
|
24410
|
+
| `renderXlsx` | function | a workbook from rows and typed columns as XLSX bytes; deterministic, no formula in the file |
|
|
24411
|
+
| `XLSX_MEDIA_TYPE` | constant | the media type for `defineExportOperation` and a download response |
|
|
24412
|
+
| `XlsxCellError` | class | a value of the wrong type, or one Excel cannot hold exactly, with the cell's address |
|
|
24413
|
+
| `XlsxWorkbookSchema` / `XlsxWorkbook` / `XlsxSheetSchema` / `XlsxColumnSchema` / `XlsxColumn` | schemas / _types_ | the workbook, its sheets and the six column types |
|
|
24414
|
+
|
|
24057
24415
|
## `stitchkit/geo`
|
|
24058
24416
|
|
|
24059
24417
|
Server-only managed GeoIP generations. Applications own database acquisition,
|