stitchkit 0.71.0 → 0.72.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/README.md +1 -1
- package/dist/application/admission.d.ts +22 -2
- package/dist/application/admission.d.ts.map +1 -1
- package/dist/application/channel.d.ts +28 -0
- package/dist/application/channel.d.ts.map +1 -1
- package/dist/application/diagnostic-journal-contract.d.ts +20 -0
- package/dist/application/diagnostic-journal-contract.d.ts.map +1 -1
- package/dist/application/diagnostic-journal-lock.d.ts +17 -0
- package/dist/application/diagnostic-journal-lock.d.ts.map +1 -0
- package/dist/application/diagnostic-journal-manager.d.ts +2 -1
- package/dist/application/diagnostic-journal-manager.d.ts.map +1 -1
- package/dist/application/diagnostic-journal-storage.d.ts +4 -1
- package/dist/application/diagnostic-journal-storage.d.ts.map +1 -1
- package/dist/application/diagnostic-journal.d.ts +4 -2
- package/dist/application/diagnostic-journal.d.ts.map +1 -1
- package/dist/application-opentelemetry.js +1 -1
- package/dist/application.d.ts +3 -3
- package/dist/application.d.ts.map +1 -1
- package/dist/application.js +134 -21
- package/dist/browser/resumable.d.ts +56 -0
- package/dist/browser/resumable.d.ts.map +1 -0
- package/dist/{index-zpyj7hsv.js → index-3cwck0rm.js} +98 -33
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +103 -14
- package/dist/primitives/audit.d.ts +52 -0
- package/dist/primitives/audit.d.ts.map +1 -0
- package/dist/primitives/deadline.d.ts +39 -0
- package/dist/primitives/deadline.d.ts.map +1 -0
- package/dist/primitives/decimal.d.ts +10 -0
- package/dist/primitives/decimal.d.ts.map +1 -0
- package/dist/primitives/delivery.d.ts +96 -0
- package/dist/primitives/delivery.d.ts.map +1 -0
- package/dist/primitives/event.d.ts +42 -0
- package/dist/primitives/event.d.ts.map +1 -0
- package/dist/primitives/export-operation.d.ts +89 -0
- package/dist/primitives/export-operation.d.ts.map +1 -0
- package/dist/primitives/index.d.ts +12 -0
- package/dist/primitives/index.d.ts.map +1 -0
- package/dist/primitives/lifecycle.d.ts +90 -0
- package/dist/primitives/lifecycle.d.ts.map +1 -0
- package/dist/primitives/migration-checks.d.ts +15 -0
- package/dist/primitives/migration-checks.d.ts.map +1 -0
- package/dist/primitives/money.d.ts +43 -0
- package/dist/primitives/money.d.ts.map +1 -0
- package/dist/primitives/owner-scope.d.ts +30 -0
- package/dist/primitives/owner-scope.d.ts.map +1 -0
- package/dist/primitives/permission.d.ts +28 -0
- package/dist/primitives/permission.d.ts.map +1 -0
- package/dist/primitives/quantity.d.ts +57 -0
- package/dist/primitives/quantity.d.ts.map +1 -0
- package/dist/primitives.d.ts +3 -0
- package/dist/primitives.d.ts.map +1 -0
- package/dist/primitives.js +750 -0
- package/llms-full.txt +246 -3
- package/llms.txt +1 -0
- package/package.json +6 -2
package/llms-full.txt
CHANGED
|
@@ -48,6 +48,7 @@ own, recorded as an ADR.
|
|
|
48
48
|
|--------|--------|----------|-------|
|
|
49
49
|
| `stitchkit` | browser **and** server | stable | `defineContract`, `createClient`, `createHttpClient`, `createSocketIOClient`, `parseSSE`, the error model |
|
|
50
50
|
| `stitchkit/contract` | browser **and** server | stable | the contract layer alone — `defineContract`, errors, pagination |
|
|
51
|
+
| `stitchkit/primitives` | browser **and** server | evolving | generic values and declarations for lifecycle, access, audit, delivery and exports |
|
|
51
52
|
| `stitchkit/server` | server (Bun) | stable | `createServer`, `implement`, hooks, auth, Socket.IO server, server primitives |
|
|
52
53
|
| `stitchkit/node` | server (Node ≥ 22) | stable | `serveNode` + the runtime-agnostic core — the Node mirror of `/server` |
|
|
53
54
|
| `stitchkit/tools` | server | stable | `createMcpHandler`, `mountMcp`, `mountAgent`, the OAuth provider, native tools |
|
|
@@ -60,7 +61,7 @@ own, recorded as an ADR.
|
|
|
60
61
|
| `stitchkit/testing` | tests on Bun or Node | stable | in-process generated clients over a real Fetch handler, plus the store and managed-resource conformance kits |
|
|
61
62
|
| `stitchkit/declaration` | build and deployment tooling (Bun or Node) | evolving | `ProjectDeclarationSchema` — the one machine-readable statement a repository makes about itself |
|
|
62
63
|
| `stitchkit/react` | browser | stable | `createCursorQuery`, `createCacheBridge` |
|
|
63
|
-
| `stitchkit/agent-runtime` | server | evolving<br>_redefined in 10 of the
|
|
64
|
+
| `stitchkit/agent-runtime` | server | evolving<br>_redefined in 10 of the 17 minors since 0.56.2, most recently 0.69.0_ | optional durable conversation/run loop, history, models, prompts, fencing and events |
|
|
64
65
|
| `stitchkit/agent-runtime/harness` | server | evolving | resource-aware process-local facade over the canonical Agent runtime; supervision stays outside |
|
|
65
66
|
| `stitchkit/agent-runtime/coding-tools` | server (Bun or Node) | evolving | bounded host-authorized direct file and shell tools; a root boundary, not an OS sandbox |
|
|
66
67
|
| `stitchkit/agent-runtime/openrouter` | server | evolving | isolated OpenRouter language-model adapter |
|
|
@@ -68,7 +69,7 @@ own, recorded as an ADR.
|
|
|
68
69
|
| `stitchkit/agent-runtime/sqlite/bun` | server (Bun) | evolving | durable built-in SQLite store for the agent runtime |
|
|
69
70
|
| `stitchkit/agent-runtime/sqlite/node` | server (Node ≥ 22.5) | evolving | durable built-in SQLite store for the agent runtime |
|
|
70
71
|
| `stitchkit-tui` | terminal (Bun) | evolving | optional official OpenTUI host over a caller-composed headless runtime |
|
|
71
|
-
| `stitchkit/application` | server | evolving<br>_redefined in
|
|
72
|
+
| `stitchkit/application` | server | evolving<br>_redefined in 4 of the 17 minors since 0.56.2, most recently 0.72.0_ | managed resource graph, readiness, admission, schedules and bounded shutdown |
|
|
72
73
|
| `stitchkit/application/grammy` | server | evolving | isolated grammY polling and webhook lifecycle adapters |
|
|
73
74
|
| `stitchkit/application/opentelemetry` | server | evolving | maps application snapshots onto an injected OpenTelemetry `Meter` |
|
|
74
75
|
|
|
@@ -2565,6 +2566,49 @@ Set `finalLine: 'require-newline'` when the final newline is part of the
|
|
|
2565
2566
|
protocol's truncation proof. The default `allow` continues to accept one valid
|
|
2566
2567
|
final JSON document without a newline.
|
|
2567
2568
|
|
|
2569
|
+
## Resumable streams
|
|
2570
|
+
|
|
2571
|
+
A stream that survives a dropped connection needs four things beyond opening it:
|
|
2572
|
+
re-open, back off before retrying, resume from where it stopped rather than
|
|
2573
|
+
restart, and stop for good on a terminal item. `resumableIterator` owns those
|
|
2574
|
+
four; your code keeps every decision that is about your data.
|
|
2575
|
+
|
|
2576
|
+
```ts
|
|
2577
|
+
import { resumableIterator } from 'stitchkit'
|
|
2578
|
+
|
|
2579
|
+
for await (const event of resumableIterator<Event, string>({
|
|
2580
|
+
async open(cursor) {
|
|
2581
|
+
const url = cursor ? `/api/events?after=${cursor}` : '/api/events'
|
|
2582
|
+
return parseNDJSON(await fetch(url, { signal }))
|
|
2583
|
+
},
|
|
2584
|
+
advance: (event) => event.id, // what "where it stopped" means
|
|
2585
|
+
isTerminal: (event) => event.done, // which item ends the stream
|
|
2586
|
+
retry: { minDelayMs: 500, maxDelayMs: 30_000, jitter: 0.5 },
|
|
2587
|
+
signal,
|
|
2588
|
+
onAttempt: ({ number, delayMs, error }) => log.warn({ number, delayMs, error }),
|
|
2589
|
+
})) {
|
|
2590
|
+
render(event)
|
|
2591
|
+
}
|
|
2592
|
+
```
|
|
2593
|
+
|
|
2594
|
+
`open` receives the cursor produced by the last **delivered** item, so a source
|
|
2595
|
+
that fails after three items re-opens after the third, not from the beginning.
|
|
2596
|
+
A source that simply ends without a terminal item is treated as a dropped
|
|
2597
|
+
connection — that is the case a hand-written loop usually mistakes for
|
|
2598
|
+
completion, and it is why the stream stops resuming.
|
|
2599
|
+
|
|
2600
|
+
**Jitter is not a detail.** Without it every consumer that lost the same server
|
|
2601
|
+
retries at the same instant and the fleet arrives together on a server that has
|
|
2602
|
+
just come back. The randomisation only ever *shortens* a delay, so `maxDelayMs`
|
|
2603
|
+
stays a real ceiling. `createBackoff({ minDelayMs, maxDelayMs, jitter })` is the
|
|
2604
|
+
same policy as a standalone value — `next()` and `reset()` — when you need the
|
|
2605
|
+
delays without the iterator.
|
|
2606
|
+
|
|
2607
|
+
A delivered item resets the backoff, so a stream that reconnects, works for an
|
|
2608
|
+
hour and drops again starts its next retry at `minDelayMs` rather than the
|
|
2609
|
+
ceiling it reached last time. Aborting the signal ends the iteration promptly,
|
|
2610
|
+
including in the middle of a wait.
|
|
2611
|
+
|
|
2568
2612
|
|
|
2569
2613
|
==============================================================================
|
|
2570
2614
|
# Guide: MCP & agents (docs/guide/mcp-and-agents.md)
|
|
@@ -5609,6 +5653,110 @@ retry rules do **not** disappear. They were never process-local glue and remain
|
|
|
5609
5653
|
application-owned.
|
|
5610
5654
|
|
|
5611
5655
|
|
|
5656
|
+
==============================================================================
|
|
5657
|
+
# Guide: Generic application primitives (docs/guide/primitives.md)
|
|
5658
|
+
==============================================================================
|
|
5659
|
+
|
|
5660
|
+
---
|
|
5661
|
+
title: Generic application primitives
|
|
5662
|
+
description: Declare lifecycle, access, exact values, audit, delivery and exports without moving application infrastructure into Stitchkit.
|
|
5663
|
+
type: guide
|
|
5664
|
+
status: active
|
|
5665
|
+
created: 2026-09-01
|
|
5666
|
+
updated: 2026-09-01
|
|
5667
|
+
---
|
|
5668
|
+
|
|
5669
|
+
# Generic application primitives
|
|
5670
|
+
|
|
5671
|
+
`stitchkit/primitives` is an optional browser-safe leaf. It declares values and policies; it does
|
|
5672
|
+
not own a database, transaction, scheduler, durable queue, transport or document generator.
|
|
5673
|
+
|
|
5674
|
+
## Lifecycle and access
|
|
5675
|
+
|
|
5676
|
+
```ts
|
|
5677
|
+
import { defineLifecycle, defineOwnerScope, definePermissionMatrix } from 'stitchkit/primitives';
|
|
5678
|
+
import { z } from 'zod';
|
|
5679
|
+
|
|
5680
|
+
const lifecycle = defineLifecycle({
|
|
5681
|
+
name: 'document',
|
|
5682
|
+
states: ['draft', 'published'],
|
|
5683
|
+
roles: ['author'],
|
|
5684
|
+
transitions: {
|
|
5685
|
+
publish: {
|
|
5686
|
+
from: 'draft',
|
|
5687
|
+
to: 'published',
|
|
5688
|
+
by: ['author'],
|
|
5689
|
+
payload: z.object({ note: z.string() }),
|
|
5690
|
+
},
|
|
5691
|
+
},
|
|
5692
|
+
});
|
|
5693
|
+
|
|
5694
|
+
const permissions = definePermissionMatrix({
|
|
5695
|
+
roles: ['reader', 'author'],
|
|
5696
|
+
operations: ['read', 'publish'],
|
|
5697
|
+
grants: {
|
|
5698
|
+
reader: { read: true, publish: false },
|
|
5699
|
+
author: { read: true, publish: true },
|
|
5700
|
+
},
|
|
5701
|
+
});
|
|
5702
|
+
```
|
|
5703
|
+
|
|
5704
|
+
Persist `transition(...).event` in the same application transaction as the next state. A state is
|
|
5705
|
+
an immutable branded value; `transition()` produces the next one. `availableTransitions()` and
|
|
5706
|
+
`transition()` read the same declaration.
|
|
5707
|
+
|
|
5708
|
+
`defineOwnerScope` resolves one owner from authenticated identity. Reading across owners is a
|
|
5709
|
+
separate `acrossAllOwners(identity)` call and permission. Pass the resulting branded `OwnerScope`
|
|
5710
|
+
to the data adapter. This proves the scope was explicit; Stitchkit cannot prove what SQL an
|
|
5711
|
+
arbitrary adapter emits. `scanOwnerFilterRisks` maps existing caller-named manual filters before a
|
|
5712
|
+
migration.
|
|
5713
|
+
|
|
5714
|
+
## Exact values and deadlines
|
|
5715
|
+
|
|
5716
|
+
`defineMoney(currency)` stores integer minor units as a JSON string. Arithmetic keeps the currency
|
|
5717
|
+
literal in the type; division and rational shares return an explicit remainder. It does not own
|
|
5718
|
+
exchange rates.
|
|
5719
|
+
|
|
5720
|
+
`defineUnitSystem` stores exact canonical decimal strings. Every conversion is an application
|
|
5721
|
+
rational with an id. A converted `QuantityProjection` is `derived` and carries both its source and
|
|
5722
|
+
conversion id; a form/database value can be marked `recorded`. Whether a derived projection is
|
|
5723
|
+
persisted or recomputed is an application decision.
|
|
5724
|
+
|
|
5725
|
+
`defineDeadlinePolicy` requires an explicit `now`, IANA timezone and elapsed/calendar-day boundary.
|
|
5726
|
+
It returns the due instant, signed remaining days, overdue days and caller-owned category key.
|
|
5727
|
+
`queryBoundary(now)` returns instants suitable for a data-adapter predicate; reminders and
|
|
5728
|
+
escalations are not included.
|
|
5729
|
+
|
|
5730
|
+
## Audit and delivery
|
|
5731
|
+
|
|
5732
|
+
Put an audit decision beside each operation:
|
|
5733
|
+
|
|
5734
|
+
```ts
|
|
5735
|
+
meta: { audit: audit.record(z.object({ changed: z.array(z.string()) })) }
|
|
5736
|
+
// or
|
|
5737
|
+
meta: { audit: audit.omit('read-only projection') }
|
|
5738
|
+
```
|
|
5739
|
+
|
|
5740
|
+
`assertAuditDeclared(contract)` refuses silence. `createAuditRecord()` validates the change and
|
|
5741
|
+
returns a `DomainEvent`; the same id/value can feed both the journal and delivery.
|
|
5742
|
+
|
|
5743
|
+
`defineDomainEventDelivery().plan(event)` is pure. Save that event and its destinations in the
|
|
5744
|
+
application's transaction. After commit, call `dispatch(event.id)`: the dispatcher accepts only an
|
|
5745
|
+
id and obtains actual work from `DomainEventOutbox.claim`. A transport returns `delivered`,
|
|
5746
|
+
`retryable`, `terminal` or `unknown`; the dispatcher calls the matching outbox transition. Only
|
|
5747
|
+
`retry` may schedule another claim, while `unknown` is held for inspection instead of guessed into
|
|
5748
|
+
a retry. The application owns retention and scheduling. There is deliberately no scheduler or
|
|
5749
|
+
distributed lease.
|
|
5750
|
+
|
|
5751
|
+
## Exports
|
|
5752
|
+
|
|
5753
|
+
`defineExportOperation` supplies one input and one result schema to an ordinary contract endpoint.
|
|
5754
|
+
A small result can be `ready` with a `ManagedFileRef`; a larger result can be `pending` with the id
|
|
5755
|
+
of the application's existing async operation. The input, scope, metadata and tool identity do not
|
|
5756
|
+
change. The application creates bytes and owns operation persistence; the managed-file boundary
|
|
5757
|
+
streams them.
|
|
5758
|
+
|
|
5759
|
+
|
|
5612
5760
|
==============================================================================
|
|
5613
5761
|
# Guide: Application migration recipes (docs/guide/application-migration-recipes.md)
|
|
5614
5762
|
==============================================================================
|
|
@@ -9293,6 +9441,45 @@ additive** — adopting it changes nothing in your code. (See
|
|
|
9293
9441
|
So upgrading is: read the `### ⚠️ Breaking changes` of every version *above* your
|
|
9294
9442
|
current one *up to* your target, and apply each snippet.
|
|
9295
9443
|
|
|
9444
|
+
## Released migration: 0.72.0
|
|
9445
|
+
|
|
9446
|
+
Nothing you *pass* changed. Both items are about types you read or build, and
|
|
9447
|
+
both stop the compiler rather than surprising you at runtime.
|
|
9448
|
+
|
|
9449
|
+
### If you read `perKey` off `BoundedAdmissionPolicy`
|
|
9450
|
+
|
|
9451
|
+
`perKey` is now a union: the flat ceiling it always was, or `{ maxKeys, limits }`
|
|
9452
|
+
where the ceiling is resolved from the key. Declaring one is unchanged; reading
|
|
9453
|
+
one needs a narrowing.
|
|
9454
|
+
|
|
9455
|
+
```ts
|
|
9456
|
+
// before
|
|
9457
|
+
const ceiling = policy.perKey?.maxConcurrent
|
|
9458
|
+
|
|
9459
|
+
// after
|
|
9460
|
+
const ceiling =
|
|
9461
|
+
policy.perKey && !('limits' in policy.perKey) ? policy.perKey.maxConcurrent : undefined
|
|
9462
|
+
```
|
|
9463
|
+
|
|
9464
|
+
A shape carrying members of both branches — `{ maxKeys, maxConcurrent, limits }` —
|
|
9465
|
+
is refused at construction. It does *not* fail to typecheck: an excess-property
|
|
9466
|
+
check against a union admits any property some member declares, so this one is
|
|
9467
|
+
caught by `createBoundedAdmission`, not by `tsc`.
|
|
9468
|
+
|
|
9469
|
+
### If you build a snapshot or a status by hand
|
|
9470
|
+
|
|
9471
|
+
`CreditWindowSnapshot` gained `waiting` (producers parked in the new waiting
|
|
9472
|
+
`acquire`) and `DiagnosticJournalStatus` gained `lock`. Both are produced by the
|
|
9473
|
+
framework, so reading them is unaffected — but a test double stops compiling:
|
|
9474
|
+
|
|
9475
|
+
```ts
|
|
9476
|
+
// before
|
|
9477
|
+
const snapshot: CreditWindowSnapshot = { state: 'open', capacityBytes: 100, /* … */ }
|
|
9478
|
+
|
|
9479
|
+
// after
|
|
9480
|
+
const snapshot: CreditWindowSnapshot = { state: 'open', capacityBytes: 100, /* … */ waiting: 0 }
|
|
9481
|
+
```
|
|
9482
|
+
|
|
9296
9483
|
## Released migration: 0.71.0
|
|
9297
9484
|
|
|
9298
9485
|
The Agent coding tools. Two of the three changes are visible to the compiler;
|
|
@@ -12020,6 +12207,8 @@ The browser-and-server entrypoint. Re-exports everything from
|
|
|
12020
12207
|
| `createRetainedTopics` | function | retained last-value store for sticky events — [guide](../guide/realtime.md#sticky-events) |
|
|
12021
12208
|
| `parseSSE` | function | parse an SSE `Response` into an async generator — [guide](../guide/client.md#sse) |
|
|
12022
12209
|
| `parseNDJSON` | function | parse bounded fatal-UTF-8 NDJSON; blank keep-alives are skipped and `finalLine: 'require-newline'` can make the delimiter mandatory — [guide](../guide/client.md#ndjson) |
|
|
12210
|
+
| `resumableIterator` | function | re-open a long-lived stream from the last delivered cursor, with jittered backoff, a caller-owned terminal item and prompt abort — [guide](../guide/client.md#resumable-streams) |
|
|
12211
|
+
| `createBackoff` | function | exponential backoff with subtractive jitter as a value: `next()` / `reset()` |
|
|
12023
12212
|
| `ContractStreamFrameSchema` / `ContractStreamFrame` | schema / _type_ | default on-the-wire `data` / safe `error` / `end` envelope of a contract-first stream |
|
|
12024
12213
|
| `ContractStreamFraming` / `ContractStreamCompletion` | _types_ | opt-in item-vs-envelope framing and terminal-vs-stream-end completion policies |
|
|
12025
12214
|
| `StreamFinalLinePolicy` | _type_ | permissive or newline-required final NDJSON line policy |
|
|
@@ -12063,6 +12252,10 @@ The browser-and-server entrypoint. Re-exports everything from
|
|
|
12063
12252
|
| `RetainedTopics` | _type_ | the `createRetainedTopics` handle |
|
|
12064
12253
|
| `ParseSSEOptions` | _type_ | options for `parseSSE` |
|
|
12065
12254
|
| `ParseNDJSONOptions` | _type_ | options for `parseNDJSON` |
|
|
12255
|
+
| `BackoffPolicySchema` / `BackoffPolicy` | schema / _type_ | `minDelayMs`, `maxDelayMs` and a `0`–`1` jitter fraction; a ceiling below the floor is refused |
|
|
12256
|
+
| `Backoff` | _type_ | the backoff handle returned by `createBackoff` |
|
|
12257
|
+
| `ResumableIteratorConfig` | _type_ | caller-owned `open` / `advance` / `isTerminal`, retry policy, abort signal and `onAttempt` observer |
|
|
12258
|
+
| `ResumableAttempt` | _type_ | attempt number, the delay about to be waited and the error that caused it |
|
|
12066
12259
|
|
|
12067
12260
|
### Trace (client)
|
|
12068
12261
|
|
|
@@ -12174,6 +12367,51 @@ from the root `stitchkit`.
|
|
|
12174
12367
|
|
|
12175
12368
|
---
|
|
12176
12369
|
|
|
12370
|
+
## `stitchkit/primitives`
|
|
12371
|
+
|
|
12372
|
+
Browser-and-server-safe declarations for facts an application wants to define once. See the
|
|
12373
|
+
[primitives guide](../guide/primitives.md). Storage, transactions, data-adapter predicates,
|
|
12374
|
+
schedules, transports and file generation remain application-owned.
|
|
12375
|
+
|
|
12376
|
+
| Export | Kind | Summary |
|
|
12377
|
+
|--------|------|---------|
|
|
12378
|
+
| `defineLifecycle` | function | immutable finite-state transition declaration, role/payload validation, available-action projection and transition event |
|
|
12379
|
+
| `LifecycleState` / `LifecycleTransitionDefinition` / `LifecycleDefinition` | _types_ | branded state value and the declaration inferred from application strings |
|
|
12380
|
+
| `LifecycleTransitionInput` / `LifecycleTransitionResult` / `LifecycleTransitionSuccess` / `LifecycleTransitionFailure` | _types_ | typed execution input and distinct transition/state, role and payload outcomes |
|
|
12381
|
+
| `LifecycleTransitionEventSchema` / `LifecycleTransitionEvent` | schema / _type_ | canonical event returned for application-atomic persistence |
|
|
12382
|
+
| `defineOwnerScope` | function | resolve one owner from identity or require the explicit `acrossAllOwners` capability |
|
|
12383
|
+
| `OwnerScope` / `OwnerScopeDefinition` / `OwnerScopeResolution` | _types_ | branded adapter input and its resolved/refused outcomes |
|
|
12384
|
+
| `definePermissionMatrix` | function | exhaustive role × operation decisions with server check and client capability projection |
|
|
12385
|
+
| `PermissionGrantMatrix` / `PermissionCheckResult` | _types_ | compile-time complete matrix and unknown/allowed/denied runtime result |
|
|
12386
|
+
| `defineMoney` / `createMoneySchema` | functions | fixed-currency JSON-safe minor-unit value and Zod schema |
|
|
12387
|
+
| `addMoney` / `subtractMoney` / `multiplyMoney` / `shareMoney` / `splitMoney` | functions | exact same-currency arithmetic with explicit indivisible remainder |
|
|
12388
|
+
| `Money` / `MoneyShare` / `MoneySplit` | _types_ | currency-literal value and remainder-bearing operation results |
|
|
12389
|
+
| `defineUnitSystem` / `createQuantitySchema` / `addQuantity` | functions | exact decimal quantities and caller-declared finite conversions |
|
|
12390
|
+
| `Quantity` / `UnitConversion` / `QuantityProjection` | _types_ | unit-literal value, rational conversion and recorded/derived provenance |
|
|
12391
|
+
| `QuantityProjectionSchema` | schema | transport-safe recorded/derived quantity union |
|
|
12392
|
+
| `defineDeadlinePolicy` | function | elapsed- or calendar-day projection with explicit timezone, threshold, current time and caller category keys |
|
|
12393
|
+
| `DeadlineResultSchema` / `DeadlineResult` | schema / _type_ | due instant, remaining/overdue days and projected category |
|
|
12394
|
+
| `audit` | constant | constructors for explicit `record(changeSchema)` or `omit(reason)` endpoint metadata |
|
|
12395
|
+
| `assertAuditDeclared` | function | refuse a contract operation with no audit decision |
|
|
12396
|
+
| `createAuditRecord` | function | validate one declared change and return the canonical event value |
|
|
12397
|
+
| `AuditPolicy` / `AuditRecordPolicy` / `AuditOmitPolicy` / `CreateAuditRecordInput` | _types_ | audit declaration and record input contracts |
|
|
12398
|
+
| `AuditRecordSchema` / `AuditRecord` | schema / _type_ | domain-event-shaped audit record |
|
|
12399
|
+
| `createDomainEventSchema` | function | wrap a typed payload in the canonical event envelope |
|
|
12400
|
+
| `DomainEventSchema` / `DomainEvent` | schema / _type_ | generic event with stable id, time, subject and optional actor |
|
|
12401
|
+
| `DomainEventActorSchema` / `DomainEventActor` | schema / _type_ | structured actor identity and application role |
|
|
12402
|
+
| `DomainEventSubjectSchema` / `DomainEventSubject` | schema / _type_ | generic subject type/id pair |
|
|
12403
|
+
| `defineDomainEventDelivery` | function | plan routes and dispatch only application-outbox claims by committed event id |
|
|
12404
|
+
| `DomainEventDestinationSchema` / `DomainEventDestination` | schema / _type_ | transport-neutral destination identity |
|
|
12405
|
+
| `DomainEventDeliveryOutcomeSchema` / `DomainEventDeliveryOutcome` | schema / _type_ | delivered, retryable, terminal or unknown transport result |
|
|
12406
|
+
| `DomainEventDeliveryClaimSchema` / `DomainEventDeliveryClaim` | schema / _type_ | application-owned atomic outbox claim |
|
|
12407
|
+
| `DomainEventOutbox` / `DomainEventRoute` / `DomainEventTransport` | _types_ | host capabilities composed by process-local delivery |
|
|
12408
|
+
| `DomainEventDeliveryPlan` / `DomainEventDispatchResult` | _types_ | transaction input and bounded dispatch summary |
|
|
12409
|
+
| `defineExportOperation` / `createExportResultSchema` | functions | one typed contract operation returning a ready managed file or pending operation id |
|
|
12410
|
+
| `scanMoneyNumberRisks` / `scanOwnerFilterRisks` | functions | source-text migration diagnostics with caller-owned identifiers |
|
|
12411
|
+
| `SourceText` / `SourceRisk` | _types_ | migration scanner input and exact path/line evidence |
|
|
12412
|
+
|
|
12413
|
+
---
|
|
12414
|
+
|
|
12177
12415
|
## `stitchkit/server`
|
|
12178
12416
|
|
|
12179
12417
|
Server-only. Builds and runs the HTTP server, and carries the server primitives.
|
|
@@ -12423,7 +12661,9 @@ cutovers are covered by the executable
|
|
|
12423
12661
|
| Export | Kind | Summary |
|
|
12424
12662
|
|--------|------|---------|
|
|
12425
12663
|
| `createBoundedAdmission` | function | process-local no-queue global/per-key concurrency and rate leases, optionally composed with application admission |
|
|
12426
|
-
| `BoundedAdmissionPolicySchema` / `BoundedAdmissionPolicy` | schema / _type_ | finite global budget and optional finite per-key budget with `maxKeys
|
|
12664
|
+
| `BoundedAdmissionPolicySchema` / `BoundedAdmissionPolicy` | schema / _type_ | finite global budget and optional finite per-key budget with `maxKeys`, declared either as one flat ceiling or as a resolver — never both |
|
|
12665
|
+
| `BoundedAdmissionPerKeyLimitsSchema` / `BoundedAdmissionPerKeyLimits` | schema / _type_ | one key's resolved ceiling: `maxConcurrent` and optional `rate` |
|
|
12666
|
+
| `BoundedAdmissionPerKeyLimitResolver` | _type_ | `(key) => limits`, resolved on a key's first admission and cached until the key is evicted |
|
|
12427
12667
|
| `BoundedRateBudgetSchema` / `BoundedRateBudget` | schema / _type_ | `{ limit, intervalMs }` monotonic sliding-window budget |
|
|
12428
12668
|
| `BoundedAdmissionStateSchema` / `BoundedAdmissionState` | schema / _type_ | `accepting \| draining \| closed` |
|
|
12429
12669
|
| `BoundedAdmissionRefusalReasonSchema` / `BoundedAdmissionRefusalReason` | schema / _type_ | exact local/upstream refusal vocabulary |
|
|
@@ -12450,6 +12690,8 @@ cutovers are covered by the executable
|
|
|
12450
12690
|
| `createCreditWindow` | function | finite byte-credit lease window with exact once-only replenishment |
|
|
12451
12691
|
| `CreditWindow` / `CreditWindowSnapshot` / `CreditWindowSnapshotSchema` | _type_ / schema | byte-credit handle and absolute accounting record |
|
|
12452
12692
|
| `CreditAcquireResult` / `CreditLease` | _type_ | reasoned refusal or idempotently releasable byte-credit lease |
|
|
12693
|
+
| `CreditAcquireWaitOptions` | _type_ | `signal` / `timeoutMs` for the waiting `acquire` overload; absent budget waits until credit, close or abort |
|
|
12694
|
+
| `CreditWaitResult` / `CreditWaitRefusalReason` | _type_ | waiting-acquire outcome; `insufficient-credit` is absent by construction, `timed-out` and `aborted` replace it |
|
|
12453
12695
|
|
|
12454
12696
|
### Bounded diagnostic journal
|
|
12455
12697
|
|
|
@@ -12458,6 +12700,7 @@ cutovers are covered by the executable
|
|
|
12458
12700
|
| `createDiagnosticJournal` | function | create one schema-owned FIFO JSONL writer with bounded retained memory, exclusive local path ownership and finite rotation |
|
|
12459
12701
|
| `DiagnosticJournalConfig` / `DiagnosticJournal` | _type_ | owner schema/path/limits/failure observer and the synchronous `submit`, bounded-wait `flush`/`close`, status handle |
|
|
12460
12702
|
| `DiagnosticJournalLimitsSchema` / `DiagnosticJournalLimits` | schema / _type_ | positive event, pending-item, pending-byte, file-byte and retained-file limits |
|
|
12703
|
+
| `DiagnosticJournalLockPolicySchema` / `DiagnosticJournalLockPolicy` | schema / _type_ | `refuse` (default) or `reclaim-stale`, which reclaims only a lock whose recorded owner is provably gone |
|
|
12461
12704
|
| `DiagnosticJournalSubmitResultSchema` / `DiagnosticJournalSubmitResult` | schema / _type_ | accepted epoch/sequence or explicit invalid, oversized, capacity, closed or failed refusal |
|
|
12462
12705
|
| `DiagnosticJournalStatusSchema` / `DiagnosticJournalStatus` | schema / _type_ | state, limits, exact admission/write/failure counters, pending ownership, rotations, partial tails and last safe sequences |
|
|
12463
12706
|
| `DiagnosticJournalFrameSchema` / `DiagnosticJournalFrame` | schema / _type_ | version-1 JSONL frame carrying process epoch, contiguous accepted sequence and schema-validated JSON event |
|
package/llms.txt
CHANGED
|
@@ -12,6 +12,7 @@ Build with stitchkit: define a contract once, then `implement` it and serve it (
|
|
|
12
12
|
- [MCP & agents](https://github.com/max-listov/stitchkit/blob/master/docs/guide/mcp-and-agents.md): contracts as MCP tools (createMcpHandler) and AI-agent tools (mountAgent); tool lifecycle, extend, identity
|
|
13
13
|
- [Agent application runtime](https://github.com/max-listov/stitchkit/blob/master/docs/guide/agent-runtime.md): optional durable history, prompt/model composition, stream loop, coordination, fencing and events
|
|
14
14
|
- [Managed application kernel](https://github.com/max-listov/stitchkit/blob/master/docs/guide/application-kernel.md): process-local resources, readiness, admission, schedules, projections and optional provider adapters
|
|
15
|
+
- [Generic application primitives](https://github.com/max-listov/stitchkit/blob/master/docs/guide/primitives.md): lifecycle transitions, owner scope, permissions, exact money and quantities, deadlines, audit, delivery and exports — declared, not persisted
|
|
15
16
|
- [Application migration recipes](https://github.com/max-listov/stitchkit/blob/master/docs/guide/application-migration-recipes.md): executable database, poller, queue-consumer and operational publishing cutovers
|
|
16
17
|
- [CLI](https://github.com/max-listov/stitchkit/blob/master/docs/guide/cli.md): contracts as a command-line program
|
|
17
18
|
- [Realtime](https://github.com/max-listov/stitchkit/blob/master/docs/guide/realtime.md): Socket.IO server/client wrappers, handshake auth, the cache bridge, a raw WebSocket lane
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stitchkit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.72.0",
|
|
4
4
|
"description": "Contract-first backend framework — one defineContract() into an HTTP API, MCP tools, AI-agent tools and a typed client. Bun and Node.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bun",
|
|
@@ -73,6 +73,10 @@
|
|
|
73
73
|
"types": "./dist/contract/index.d.ts",
|
|
74
74
|
"import": "./dist/contract/index.js"
|
|
75
75
|
},
|
|
76
|
+
"./primitives": {
|
|
77
|
+
"types": "./dist/primitives.d.ts",
|
|
78
|
+
"import": "./dist/primitives.js"
|
|
79
|
+
},
|
|
76
80
|
"./server": {
|
|
77
81
|
"types": "./dist/server/index.d.ts",
|
|
78
82
|
"import": "./dist/server/index.js"
|
|
@@ -148,7 +152,7 @@
|
|
|
148
152
|
"scripts": {
|
|
149
153
|
"build:native-contained-files": "node scripts/build-contained-files-native.mjs",
|
|
150
154
|
"check": "bun x tsc --noEmit",
|
|
151
|
-
"build:browser": "bun build src/index.ts src/react.ts src/contract/index.ts src/declaration.ts src/agent-runtime-browser.ts --outdir dist --target node --packages external --splitting --root src",
|
|
155
|
+
"build:browser": "bun build src/index.ts src/react.ts src/contract/index.ts src/primitives.ts src/declaration.ts src/agent-runtime-browser.ts --outdir dist --target node --packages external --splitting --root src",
|
|
152
156
|
"build:server": "bun build src/server/index.ts src/node.ts src/tools.ts src/tool-invoker.ts src/cli.ts src/remote.ts src/files.ts src/testing.ts src/observability/index.ts src/agent-runtime.ts src/agent-runtime-harness.ts src/agent-runtime-coding-tools.ts src/agent-runtime-openrouter.ts src/agent-runtime-sqlite-bun.ts src/agent-runtime-sqlite-node.ts src/application.ts src/application-grammy.ts src/application-opentelemetry.ts src/telegram.ts --outdir dist --target node --packages external --splitting --root src",
|
|
153
157
|
"build:js": "bun run build:browser && bun run build:server && bun scripts/preserve-webpack-ignore.mjs",
|
|
154
158
|
"build:types": "bun x tsc -p tsconfig.build.json --emitDeclarationOnly && bun scripts/rewrite-declaration-specifiers.mjs",
|