stitchkit 0.99.0 → 0.100.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/CHANGELOG.md +124 -1
  2. package/dist/agent-runtime/contained-darwin.d.ts +0 -17
  3. package/dist/agent-runtime/contained-darwin.d.ts.map +1 -1
  4. package/dist/agent-runtime/contained-write.d.ts.map +1 -1
  5. package/dist/agent-runtime/invocation-attempt.d.ts +28 -0
  6. package/dist/agent-runtime/invocation-attempt.d.ts.map +1 -0
  7. package/dist/agent-runtime/invocation-failure.d.ts +6 -0
  8. package/dist/agent-runtime/invocation-failure.d.ts.map +1 -0
  9. package/dist/agent-runtime/invocation-payload.d.ts +20 -0
  10. package/dist/agent-runtime/invocation-payload.d.ts.map +1 -0
  11. package/dist/agent-runtime/invocation-read.d.ts +131 -0
  12. package/dist/agent-runtime/invocation-read.d.ts.map +1 -0
  13. package/dist/agent-runtime/invocation-schema.d.ts +378 -0
  14. package/dist/agent-runtime/invocation-schema.d.ts.map +1 -0
  15. package/dist/agent-runtime/invocations.d.ts +52 -0
  16. package/dist/agent-runtime/invocations.d.ts.map +1 -0
  17. package/dist/agent-runtime/projections.d.ts.map +1 -1
  18. package/dist/agent-runtime/run-acquisition.d.ts.map +1 -1
  19. package/dist/agent-runtime/run-execution-state.d.ts +4 -2
  20. package/dist/agent-runtime/run-execution-state.d.ts.map +1 -1
  21. package/dist/agent-runtime/run-execution.d.ts.map +1 -1
  22. package/dist/agent-runtime/run-failure.d.ts.map +1 -1
  23. package/dist/agent-runtime/run-model-attempts.d.ts.map +1 -1
  24. package/dist/agent-runtime/run-operation-lifecycle.d.ts +2 -2
  25. package/dist/agent-runtime/run-operation-lifecycle.d.ts.map +1 -1
  26. package/dist/agent-runtime/run-provider-ledger.d.ts +1 -0
  27. package/dist/agent-runtime/run-provider-ledger.d.ts.map +1 -1
  28. package/dist/agent-runtime/runtime.d.ts +11 -0
  29. package/dist/agent-runtime/runtime.d.ts.map +1 -1
  30. package/dist/agent-runtime/schedule-dispatch.d.ts +9 -2
  31. package/dist/agent-runtime/schedule-dispatch.d.ts.map +1 -1
  32. package/dist/agent-runtime/schedule-records.d.ts +8 -2
  33. package/dist/agent-runtime/schedule-records.d.ts.map +1 -1
  34. package/dist/agent-runtime/schedules.d.ts +5 -0
  35. package/dist/agent-runtime/schedules.d.ts.map +1 -1
  36. package/dist/agent-runtime/sqlite-events.d.ts.map +1 -1
  37. package/dist/agent-runtime/store-create.d.ts.map +1 -1
  38. package/dist/agent-runtime/store-driver-contract.d.ts +9 -0
  39. package/dist/agent-runtime/store-driver-contract.d.ts.map +1 -1
  40. package/dist/agent-runtime/store-event-once.d.ts +37 -0
  41. package/dist/agent-runtime/store-event-once.d.ts.map +1 -0
  42. package/dist/agent-runtime/store-memory.d.ts.map +1 -1
  43. package/dist/agent-runtime/store.d.ts +11 -0
  44. package/dist/agent-runtime/store.d.ts.map +1 -1
  45. package/dist/application/change-subscription.d.ts +36 -0
  46. package/dist/application/change-subscription.d.ts.map +1 -0
  47. package/dist/application/diagnostic-journal-contract.d.ts +3 -6
  48. package/dist/application/diagnostic-journal-contract.d.ts.map +1 -1
  49. package/dist/application/notification-delivery.d.ts +55 -0
  50. package/dist/application/notification-delivery.d.ts.map +1 -0
  51. package/dist/application/notification-outbox-state.d.ts +41 -0
  52. package/dist/application/notification-outbox-state.d.ts.map +1 -0
  53. package/dist/application/notification-outbox.d.ts +7 -1
  54. package/dist/application/notification-outbox.d.ts.map +1 -1
  55. package/dist/application/watch-hub-core.d.ts +14 -84
  56. package/dist/application/watch-hub-core.d.ts.map +1 -1
  57. package/dist/application/watch-hub-source.d.ts +98 -0
  58. package/dist/application/watch-hub-source.d.ts.map +1 -0
  59. package/dist/application/watch-hub.d.ts +10 -2
  60. package/dist/application/watch-hub.d.ts.map +1 -1
  61. package/dist/browser/session-credentials.d.ts +26 -0
  62. package/dist/browser/session-credentials.d.ts.map +1 -0
  63. package/dist/browser/session.d.ts +33 -0
  64. package/dist/browser/session.d.ts.map +1 -0
  65. package/dist/durability/events.d.ts +6 -0
  66. package/dist/durability/events.d.ts.map +1 -1
  67. package/dist/entrypoints/agent-runtime/coding-tools.js +3 -2
  68. package/dist/entrypoints/agent-runtime/harness.js +5 -3
  69. package/dist/entrypoints/agent-runtime/sandbox.js +3 -2
  70. package/dist/entrypoints/agent-runtime/sqlite/bun.js +3 -3
  71. package/dist/entrypoints/agent-runtime/sqlite/node.js +3 -3
  72. package/dist/entrypoints/agent-runtime/testing.js +3 -3
  73. package/dist/entrypoints/agent-runtime.d.ts +3 -0
  74. package/dist/entrypoints/agent-runtime.d.ts.map +1 -1
  75. package/dist/entrypoints/agent-runtime.js +65 -20
  76. package/dist/entrypoints/application/diagnostic-journal.js +2 -1
  77. package/dist/entrypoints/application.d.ts +3 -1
  78. package/dist/entrypoints/application.d.ts.map +1 -1
  79. package/dist/entrypoints/application.js +820 -294
  80. package/dist/entrypoints/files.js +9 -2
  81. package/dist/entrypoints/index.d.ts +2 -0
  82. package/dist/entrypoints/index.d.ts.map +1 -1
  83. package/dist/entrypoints/index.js +199 -0
  84. package/dist/entrypoints/live.js +78 -19
  85. package/dist/entrypoints/node.js +1 -1
  86. package/dist/entrypoints/react.d.ts +1 -1
  87. package/dist/entrypoints/react.d.ts.map +1 -1
  88. package/dist/entrypoints/react.js +59 -16
  89. package/dist/entrypoints/server.js +4 -4
  90. package/dist/{index-sp1tzwnb.js → index-10x2hbx0.js} +5 -2
  91. package/dist/{index-8p52kd5p.js → index-c6bxbsnc.js} +100 -14
  92. package/dist/{index-gxrt5h6v.js → index-cyktc4bp.js} +3 -0
  93. package/dist/{index-1m2thnq0.js → index-eaysmdtq.js} +11 -2
  94. package/dist/{index-jhx828hc.js → index-f4fx2tza.js} +948 -279
  95. package/dist/{index-px2gm2jp.js → index-fhwqwxe0.js} +17 -55
  96. package/dist/{index-e4hkgm5t.js → index-gw8bmyaj.js} +4 -2
  97. package/dist/{index-p3vsv1fb.js → index-hadmp193.js} +14 -5
  98. package/dist/{index-wt743f7f.js → index-k6gpggb9.js} +2 -1
  99. package/dist/index-q3pyb9n0.js +22 -0
  100. package/dist/{index-wsm5w4ee.js → index-vqr7f7v8.js} +51 -3
  101. package/dist/index-zjjyynm3.js +42 -0
  102. package/dist/internal/coalesced-task.d.ts +17 -0
  103. package/dist/internal/coalesced-task.d.ts.map +1 -0
  104. package/dist/internal/darwin-binding.d.ts +19 -0
  105. package/dist/internal/darwin-binding.d.ts.map +1 -0
  106. package/dist/internal/exclusive-lock.d.ts +20 -7
  107. package/dist/internal/exclusive-lock.d.ts.map +1 -1
  108. package/dist/internal/mutation-queue.d.ts +4 -0
  109. package/dist/internal/mutation-queue.d.ts.map +1 -0
  110. package/dist/internal/process-identity.d.ts +1 -1
  111. package/dist/internal/process-identity.d.ts.map +1 -1
  112. package/dist/internal/process-instance.d.ts +26 -0
  113. package/dist/internal/process-instance.d.ts.map +1 -0
  114. package/dist/internal/with-exclusive-lock.d.ts.map +1 -1
  115. package/dist/live/watch-client-state.d.ts +71 -0
  116. package/dist/live/watch-client-state.d.ts.map +1 -0
  117. package/dist/live/watch-client.d.ts +5 -1
  118. package/dist/live/watch-client.d.ts.map +1 -1
  119. package/dist/live/watch-contract.d.ts +12 -0
  120. package/dist/live/watch-contract.d.ts.map +1 -1
  121. package/dist/react/cache-bridge.d.ts +10 -0
  122. package/dist/react/cache-bridge.d.ts.map +1 -1
  123. package/dist/server/realtime.d.ts.map +1 -1
  124. package/llms/agent-runtime.2.txt +102 -0
  125. package/llms/agent-runtime.3.txt +30 -1
  126. package/llms/agent-runtime.txt +8 -3
  127. package/llms/application.2.txt +84 -2
  128. package/llms/application.txt +32 -2
  129. package/llms/files.txt +1 -1
  130. package/llms/live.txt +8 -0
  131. package/llms/react.txt +8 -0
  132. package/llms/server.3.txt +57 -0
  133. package/llms/stitchkit.2.txt +41 -0
  134. package/llms/stitchkit.3.txt +26 -0
  135. package/llms/stitchkit.txt +3 -3
  136. package/llms/upgrading-0.37.0.txt +176 -0
  137. package/llms/{upgrading-0.37.0-0.58.0.txt → upgrading-0.44.0-0.60.0.txt} +229 -169
  138. package/llms/{upgrading-0.59.0-0.71.0.txt → upgrading-0.61.0-0.73.0.txt} +122 -229
  139. package/llms/{upgrading-0.72.0-0.99.0.txt → upgrading-0.74.0-0.100.0.txt} +80 -123
  140. package/llms/upgrading.txt +4 -3
  141. package/llms-full.txt +471 -11
  142. package/llms.txt +10 -9
  143. package/native/darwin-arm64.node +0 -0
  144. package/native/darwin-x64.node +0 -0
  145. package/package.json +1 -1
  146. package/dist/agent-runtime/run-mutation-queue.d.ts +0 -21
  147. package/dist/agent-runtime/run-mutation-queue.d.ts.map +0 -1
package/CHANGELOG.md CHANGED
@@ -15,6 +15,121 @@ additive**; the first breaking change landed in 0.10.0. Grep the file for
15
15
 
16
16
  ## [Unreleased]
17
17
 
18
+ ## [0.100.1] — 2026-09-28
19
+
20
+ ### Fixed
21
+
22
+ - `stitchkit/application` — an outbox action that succeeded is never sent again.
23
+ A `send` result that is not JSON (a `Date`, a `bigint`) or does not fit
24
+ `maxStateBytes` failed the checkpoint after the send, and the error was
25
+ classified and retried: the same message went out up to `maxAttempts` times.
26
+ The action is now confirmed with `receipt: null` and
27
+ `unrecorded: 'not-json' | 'too-large'`, and the cause goes to `onError`; any
28
+ other store failure while recording propagates as before.
29
+ - `stitchkit/application` — `delivery.retiredVersions` drains items queued under
30
+ an earlier plan version through that version's projection. A plan version with
31
+ no executor is no longer dropped: it is reported to `onError` as
32
+ `NotificationPlanVersionError` and waits, spending no attempt, for a process that
33
+ knows it — the other side of a rolling deploy or a rollback.
34
+ - `stitchkit/agent-runtime` — a schedule `dispatch` that returns a value other
35
+ than a `retry`/`terminal` outcome (e.g. `jobs.push(...)`'s length) delivered;
36
+ it was parsed as a failure and retried without end. Failed attempts of one
37
+ occurrence now stop at `maxAttempts` (default 1000): a one-off schedule becomes
38
+ `failed`, a recurring one skips to its next slot and keeps its cadence. A
39
+ recorded reason is kept to 1000 characters.
40
+ - `stitchkit/agent-runtime` — once-only admission (`appendEventOnce`, used by every
41
+ `complete()` and audited run) finds its event by identity instead of reading the
42
+ whole conversation log, payloads included, inside the write transaction. Measured
43
+ before on 1500 events of 100 KB: 223 ms and 770 MB RSS per admission. Drivers gain
44
+ an optional `events.find`, the store an optional `findEventOnce`; invocation payload
45
+ artifacts are keyed by artifact id, and ones written by 0.100.0 are still found.
46
+ - `stitchkit/files`, `stitchkit/application` — on a Linux kernel without time
47
+ namespaces (before 5.6) an exclusive lock records its owner's PID namespace
48
+ alone; since 0.100.0 it recorded no identity at all, so a lock left by a crashed
49
+ owner was never recovered there. A timeout now names the attribution, liveness
50
+ and identity evidence behind the refusal.
51
+ - `stitchkit/application` — a watch hub over `maxSubscribers` refuses through
52
+ `open` instead of throwing from `attach`, where the throw landed in a connection
53
+ handler. `bindRealtimeServer` catches a connection handler's failure, sync or
54
+ async: that connection is closed and the error logged, and the server goes on.
55
+ - `stitchkit/application` — an invalidation that arrived during `holdMs`, while
56
+ nobody watched, is read for the next subscriber; it received the old value as
57
+ `live`.
58
+ - `stitchkit/application` — one admission scope shares one source and one read
59
+ across client instances, as ADR 0208 states; each session-scoped tab opened its
60
+ own source and read.
61
+ - `stitchkit/live` — a watch handle takes its key on `subscribe`, not when it is
62
+ made, so handles that are never subscribed no longer hold keys or count against
63
+ `maxKeys`.
64
+ - `stitchkit/application` — a change subscription whose lost connection fails to
65
+ `close()` reconnects; it reported the failure and stayed disconnected for good.
66
+ - `stitchkit/agent-runtime` — audited streaming evidence no longer cuts the answer:
67
+ past half of `maxPayloadBytes` the evidence is truncated and fingerprinted
68
+ (`truncated: { parts, sha256 }`), where a fixed 1 MiB cap failed the run as
69
+ `provider_failure`.
70
+ - `stitchkit/agent-runtime` — `complete()` returns a paid answer when its
71
+ `invocation/finished` record cannot be written, with `receiptError`; it recorded
72
+ the answer as failed and dropped the text. A failure payload that cannot be
73
+ written — an error whose `cause` loops, which also no longer throws — keeps the
74
+ `invocation/finished` record and the outcome.
75
+ - `stitchkit/agent-runtime` — the summary projection's `lastModelId` follows audited
76
+ requests, which record the model under `sent`.
77
+ - `stitchkit` — `createSessionCredentials` bounds each storage call by
78
+ `storageTimeoutMs` (default 30 s): a hung `storage.write` held the queue, so
79
+ `logout()` never cleared persisted credentials. A call that lands after its
80
+ deadline, when memory has moved on, is followed by a write of the current
81
+ credentials or a clear. A refresh keeps the credentials the server issued in
82
+ memory even when storing them fails, so a slow store cannot restore a spent
83
+ pair. `SessionExpiredError` keeps the failure that stopped the work as `cause`.
84
+ - `stitchkit/application` — a failed watched read sends the browser the code and
85
+ message of an `AppError` only; any other error's code and message — a driver's,
86
+ with an address or a path in it — stay in the server log, and the frame says
87
+ `The watched read failed`.
88
+
89
+ ## [0.100.0] — 2026-09-28
90
+
91
+ ### ⚠️ Breaking changes
92
+
93
+ - `stitchkit/application`, `stitchkit/live` — watched reads now enforce finite
94
+ capacity by default: 1024 hub sources, 1024 hub subscribers, 1024 client keys
95
+ and 128 listeners per key. Excess admission is refused instead of retaining
96
+ unbounded state. Before: `createWatchHub({ read, watchable })` admitted an
97
+ unlimited number of hub sources/subscribers. After, for a larger workload:
98
+ `createWatchHub({ read, watchable, maxSources: 4096, maxSubscribers: 4096 })`.
99
+ Set `maxKeys` and `maxListenersPerKey` on `createWatchClient` when needed.
100
+ See ADR 0208 and the 0.100.0 migration in `docs/guide/upgrading.md`.
101
+
102
+ **Who must act:** watch consumers whose hub or client exceeds these defaults.
103
+ Choose explicit finite limits for the expected workload. Other consumers may
104
+ keep their existing configuration; new session and delivery APIs are opt-in.
105
+
106
+ ### Added
107
+
108
+ - `stitchkit` — `createSessionScope` fences requests and final delivery by login
109
+ lifetime; `createSessionCredentials` coordinates refresh and credential writes.
110
+ - `stitchkit/application` — managed change subscriptions with bounded keys,
111
+ reconnect and periodic reconciliation; watch admission scopes and capacity limits;
112
+ optional outbox action checkpoints and a separate projection receipt.
113
+ - `stitchkit/live`, `stitchkit/react` — session-scoped watch instances and explicit
114
+ watched-handle/cache bindings. Hub reconciliation can repair lost hints without
115
+ reconnect. Existing non-session watches and single-send outboxes remain supported.
116
+
117
+ - `stitchkit/agent-runtime` — public `createModelInvocationLedger` for plain text
118
+ completions and shared agent provider receipts, with atomic idempotent admission,
119
+ verified caller context, explicit fallback attempts, transport correlation IDs,
120
+ provenance-aware usage and encrypted payload artifacts in the existing store.
121
+ Opt in with the runtime `invocations` option. See ADR 0206 and the
122
+ [migration example](docs/guide/agent-runtime.md#plain-completions-and-shared-invocation-receipts).
123
+
124
+ ### Fixed
125
+
126
+ - `stitchkit/files`, `stitchkit/application` — exclusive locks and journal reclaim
127
+ guards identify the owning boot and process lifetime, so a PID reused after a
128
+ crash or reboot no longer impersonates an abandoned owner. Linux uses proc
129
+ start ticks and namespaces; macOS uses the packaged native kernel probe.
130
+ Unknown identity refuses takeover. Legacy records retain conservative PID
131
+ checks and require operator recovery when a live PID has been reused. See ADR 0210.
132
+
18
133
  ## [0.99.0] — 2026-09-27
19
134
 
20
135
  ### ⚠️ Breaking changes
@@ -23,7 +138,12 @@ additive**; the first breaking change landed in 0.10.0. Grep the file for
23
138
  array items when discriminated-union variants share a field with different
24
139
  structures. Flat mode no longer guarantees the absence of nested `anyOf`.
25
140
  Before: a collided object/array field was `{ type: ['object', 'array'] }`.
26
- After: `{ anyOf: [{ type: 'object', properties: ... }, { type: 'array', items: ... }] }`.
141
+ After: `{ anyOf: [{ type: 'array', items: ... }, { type: 'object', properties: ... }] }`
142
+ — alternatives in kind order, whatever the variant order. Every collision of
143
+ different kinds takes this shape, a scalar one too (`string` / `string[]` →
144
+ `{ anyOf: [{ type: 'array', items: { type: 'string' } }, { type: 'string' }] }`);
145
+ nullable kinds keep `null` in each alternative's `type`, and differing nested
146
+ object unions stay nested `anyOf` inside the alternatives.
27
147
  The containing union stays an object and the original contract still validates
28
148
  execution. Schema consumers must traverse these nested alternatives; no
29
149
  contract changes or global flatten opt-out are needed. This avoids provider
@@ -36,6 +156,9 @@ only update the dependency; runtime input validation is unchanged.
36
156
 
37
157
  ## [0.98.2] — 2026-09-27
38
158
 
159
+ The tag `v0.98.1` exists but was never published to npm: its publication failed.
160
+ Everything it carried is in this release.
161
+
39
162
  ### Fixed
40
163
 
41
164
  - `stitchkit/live` — prepending to a watched array preserves future copy bases,
@@ -5,27 +5,10 @@
5
5
  */
6
6
  import { type Stats } from 'node:fs';
7
7
  import type { ContainedFileHandle } from './contained-files.js';
8
- export interface DarwinEntry {
9
- name: string;
10
- mode: number;
11
- size: number;
12
- }
13
- export interface DarwinBinding {
14
- openDirectoryAt(directory: number, name: string): number;
15
- openFileAt(directory: number, name: string): number;
16
- createFileAt(directory: number, name: string, mode: number): number;
17
- createDirectoryAt(directory: number, name: string, mode: number): boolean;
18
- statAt(directory: number, name: string): Omit<DarwinEntry, 'name'> | null;
19
- listAt(directory: number): readonly DarwinEntry[];
20
- renameAt(directory: number, source: string, target: string): void;
21
- unlinkAt(directory: number, name: string): void;
22
- }
23
8
  export declare const FILE_TYPE_DIRECTORY = 16384;
24
9
  export declare const FILE_TYPE_REGULAR = 32768;
25
10
  export declare const FILE_TYPE_SYMLINK = 40960;
26
11
  export declare function modeIs(mode: number, type: number): boolean;
27
- export declare function hasFunctions(value: unknown, names: readonly string[]): boolean;
28
- export declare function loadDarwinBinding(): DarwinBinding;
29
12
  export declare class NumericFileHandle implements ContainedFileHandle {
30
13
  readonly fd: number;
31
14
  constructor(fd: number);
@@ -1 +1 @@
1
- {"version":3,"file":"contained-darwin.d.ts","sourceRoot":"","sources":["../../src/agent-runtime/contained-darwin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAKL,KAAK,KAAK,EACX,MAAM,SAAS,CAAC;AAKjB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE7D,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,aAAa;IAC5B,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACzD,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACpD,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACpE,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAC1E,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;IAC1E,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,WAAW,EAAE,CAAC;IAClD,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAClE,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACjD;AAGD,eAAO,MAAM,mBAAmB,QAAW,CAAC;AAC5C,eAAO,MAAM,iBAAiB,QAAW,CAAC;AAC1C,eAAO,MAAM,iBAAiB,QAAW,CAAC;AAE1C,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAM9E;AAID,wBAAgB,iBAAiB,IAAI,aAAa,CA+BjD;AAED,qBAAa,iBAAkB,YAAW,mBAAmB;IAC/C,QAAQ,CAAC,EAAE,EAAE,MAAM;IAA/B,YAAqB,EAAE,EAAE,MAAM,EAAI;IAEnC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAIrB;IAED,IAAI,CACF,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAMhC;IAED,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,CAIrB;CACF"}
1
+ {"version":3,"file":"contained-darwin.d.ts","sourceRoot":"","sources":["../../src/agent-runtime/contained-darwin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAA2D,KAAK,KAAK,EAAE,MAAM,SAAS,CAAC;AAE9F,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAG7D,eAAO,MAAM,mBAAmB,QAAW,CAAC;AAC5C,eAAO,MAAM,iBAAiB,QAAW,CAAC;AAC1C,eAAO,MAAM,iBAAiB,QAAW,CAAC;AAE1C,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAE1D;AAED,qBAAa,iBAAkB,YAAW,mBAAmB;IAC/C,QAAQ,CAAC,EAAE,EAAE,MAAM;IAA/B,YAAqB,EAAE,EAAE,MAAM,EAAI;IAEnC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAIrB;IAED,IAAI,CACF,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAMhC;IAED,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,CAIrB;CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"contained-write.d.ts","sourceRoot":"","sources":["../../src/agent-runtime/contained-write.ts"],"names":[],"mappings":"AAUA,OAAO,EAEL,KAAK,eAAe,EAErB,MAAM,mBAAmB,CAAC;AAsD3B,0FAA0F;AAC1F,wBAAsB,kBAAkB,CAAC,KAAK,EAAE;IAC9C,MAAM,EAAE,eAAe,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,OAAO,CAAC,IAAI,CAAC,CAsChB"}
1
+ {"version":3,"file":"contained-write.d.ts","sourceRoot":"","sources":["../../src/agent-runtime/contained-write.ts"],"names":[],"mappings":"AAWA,OAAO,EAEL,KAAK,eAAe,EAErB,MAAM,mBAAmB,CAAC;AAsD3B,0FAA0F;AAC1F,wBAAsB,kBAAkB,CAAC,KAAK,EAAE;IAC9C,MAAM,EAAE,eAAe,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,OAAO,CAAC,IAAI,CAAC,CAsChB"}
@@ -0,0 +1,28 @@
1
+ import { type LanguageModel } from 'ai';
2
+ import type { z } from 'zod';
3
+ import type { createInvocationPayloads } from './invocation-payload.js';
4
+ import type { InvocationProcessSchema, ModelInvocationAttemptContext, ModelInvocationRecord } from './invocation-schema.js';
5
+ import type { AgentResolvedModel } from './models.js';
6
+ /** Available inside the provider's fetch/transport; no time/model-name correlation. */
7
+ export declare function currentModelInvocationAttempt(): ModelInvocationAttemptContext | undefined;
8
+ export interface InvocationAttemptWriter {
9
+ identity: {
10
+ conversationId: string;
11
+ invocationId: string;
12
+ operationId: string;
13
+ runId?: string;
14
+ };
15
+ process: z.infer<typeof InvocationProcessSchema>;
16
+ payloads: ReturnType<typeof createInvocationPayloads>;
17
+ append(record: ModelInvocationRecord): Promise<void>;
18
+ onAttempt?(context: ModelInvocationAttemptContext): void | Promise<void>;
19
+ /**
20
+ * Where a provider attempt's own record could not be written. The provider
21
+ * has answered by then, so the failure is kept here instead of replacing
22
+ * the answer — or the provider's own error — with a receipt error.
23
+ */
24
+ readonly receiptErrors: unknown[];
25
+ }
26
+ /** The single audited provider boundary, used by completion and the existing agent loop. */
27
+ export declare function wrapInvocationModel(writer: InvocationAttemptWriter, selected: AgentResolvedModel, step: number, model?: LanguageModel): LanguageModel;
28
+ //# sourceMappingURL=invocation-attempt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invocation-attempt.d.ts","sourceRoot":"","sources":["../../src/agent-runtime/invocation-attempt.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,aAAa,EAAmD,MAAM,IAAI,CAAC;AACzF,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAErE,OAAO,KAAK,EACV,uBAAuB,EACvB,6BAA6B,EAC7B,qBAAqB,EACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AASnD,uFAAuF;AACvF,wBAAgB,6BAA6B,IAAI,6BAA6B,GAAG,SAAS,CAGzF;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE;QACR,cAAc,EAAE,MAAM,CAAC;QACvB,YAAY,EAAE,MAAM,CAAC;QACrB,WAAW,EAAE,MAAM,CAAC;QACpB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;IACjD,QAAQ,EAAE,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC;IACtD,MAAM,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,SAAS,CAAC,CAAC,OAAO,EAAE,6BAA6B,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzE;;;;OAIG;IACH,QAAQ,CAAC,aAAa,EAAE,OAAO,EAAE,CAAC;CACnC;AAED,4FAA4F;AAC5F,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,uBAAuB,EAC/B,QAAQ,EAAE,kBAAkB,EAC5B,IAAI,EAAE,MAAM,EACZ,KAAK,GAAE,aAA8B,GACpC,aAAa,CA8Kf"}
@@ -0,0 +1,6 @@
1
+ /** Receipt/storage/audit refusals belong to the runtime, never to the upstream provider. */
2
+ export declare class InvocationReceiptError extends Error {
3
+ constructor(cause: unknown);
4
+ }
5
+ export declare function invocationAudit<T>(work: () => Promise<T>): Promise<T>;
6
+ //# sourceMappingURL=invocation-failure.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invocation-failure.d.ts","sourceRoot":"","sources":["../../src/agent-runtime/invocation-failure.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,qBAAa,sBAAuB,SAAQ,KAAK;IAC/C,YAAY,KAAK,EAAE,OAAO,EAGzB;CACF;AACD,wBAAsB,eAAe,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAM3E"}
@@ -0,0 +1,20 @@
1
+ import { z } from 'zod';
2
+ import type { AgentRuntimeStore } from './store.js';
3
+ /** Serialize SDK payloads at the typed external boundary, retaining binary bytes privately. */
4
+ export declare function invocationJson(value: unknown): z.JSONType;
5
+ export declare function invocationHash(value: unknown): string;
6
+ export declare function createInvocationPayloads(store: AgentRuntimeStore, key: Uint8Array, maxBytes: number): {
7
+ /** The largest serialized payload one artifact may hold. */
8
+ maxBytes: number;
9
+ write(identity: {
10
+ conversationId: string;
11
+ invocationId: string;
12
+ operationId: string;
13
+ runId?: string;
14
+ }, value: unknown): Promise<{
15
+ artifactId: `${string}-${string}-${string}-${string}-${string}`;
16
+ sha256: string;
17
+ }>;
18
+ decrypt(conversationId: string, value: unknown): z.JSONType;
19
+ };
20
+ //# sourceMappingURL=invocation-payload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invocation-payload.d.ts","sourceRoot":"","sources":["../../src/agent-runtime/invocation-payload.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjD,+FAA+F;AAC/F,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,cAmB5C;AACD,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAIrD;AAED,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,iBAAiB,EACxB,GAAG,EAAE,UAAU,EACf,QAAQ,EAAE,MAAM;IAMd,4DAA4D;;oBAGhD;QACR,cAAc,EAAE,MAAM,CAAC;QACvB,YAAY,EAAE,MAAM,CAAC;QACrB,WAAW,EAAE,MAAM,CAAC;QACpB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,SACM,OAAO;;;;4BAsCQ,MAAM,SAAS,OAAO;EAgCjD"}
@@ -0,0 +1,131 @@
1
+ import { z } from 'zod';
2
+ import type { createInvocationPayloads } from './invocation-payload.js';
3
+ import type { AgentRuntimeStore } from './store.js';
4
+ export declare const InvocationReadInputSchema: z.ZodObject<{
5
+ conversationId: z.ZodString;
6
+ fromSeq: z.ZodOptional<z.ZodInt>;
7
+ limit: z.ZodInt;
8
+ }, z.core.$strict>;
9
+ export declare function readInvocationRecords(store: AgentRuntimeStore, input: z.infer<typeof InvocationReadInputSchema>): Promise<{
10
+ items: {
11
+ seq: number;
12
+ occurredAt: string;
13
+ record: {
14
+ conversationId: string;
15
+ invocationId: string;
16
+ operationId: string;
17
+ runId?: string | undefined;
18
+ type: "invocation/started";
19
+ mode: "agent" | "completion";
20
+ trace: {
21
+ operationId: string;
22
+ purpose: string;
23
+ project: string;
24
+ parent?: {
25
+ traceId: string;
26
+ invocationId?: string | undefined;
27
+ } | undefined;
28
+ experiment?: string | undefined;
29
+ case?: string | undefined;
30
+ profile?: string | undefined;
31
+ };
32
+ caller: {
33
+ subject: string;
34
+ };
35
+ executingProcess: {
36
+ instanceId: string;
37
+ pid: number;
38
+ hostname: string;
39
+ };
40
+ fingerprint: string;
41
+ requested: {
42
+ models: string[];
43
+ payloadSha256: string;
44
+ };
45
+ } | {
46
+ conversationId: string;
47
+ invocationId: string;
48
+ operationId: string;
49
+ runId?: string | undefined;
50
+ attemptId: string;
51
+ step: number;
52
+ type: "provider/request";
53
+ requested: {
54
+ modelId: string;
55
+ provider: string;
56
+ };
57
+ executingProcess: {
58
+ instanceId: string;
59
+ pid: number;
60
+ hostname: string;
61
+ };
62
+ sent: {
63
+ modelId: string;
64
+ provider: string;
65
+ payloadSha256: string;
66
+ artifactId: string;
67
+ tools: number;
68
+ };
69
+ } | {
70
+ conversationId: string;
71
+ invocationId: string;
72
+ operationId: string;
73
+ runId?: string | undefined;
74
+ attemptId: string;
75
+ step: number;
76
+ type: "provider/response";
77
+ status: "cancelled" | "failed" | "succeeded";
78
+ effective: {
79
+ provider: string | null;
80
+ modelId: string | null;
81
+ responseId: string | null;
82
+ };
83
+ usage: {
84
+ inputTokens: {
85
+ value?: number | undefined;
86
+ provenance: "computed" | "estimated" | "provider-reported" | "unavailable";
87
+ };
88
+ outputTokens: {
89
+ value?: number | undefined;
90
+ provenance: "computed" | "estimated" | "provider-reported" | "unavailable";
91
+ };
92
+ reasoningTokens?: {
93
+ value?: number | undefined;
94
+ provenance: "computed" | "estimated" | "provider-reported" | "unavailable";
95
+ } | undefined;
96
+ cacheReadTokens?: {
97
+ value?: number | undefined;
98
+ provenance: "computed" | "estimated" | "provider-reported" | "unavailable";
99
+ } | undefined;
100
+ cacheWriteTokens?: {
101
+ value?: number | undefined;
102
+ provenance: "computed" | "estimated" | "provider-reported" | "unavailable";
103
+ } | undefined;
104
+ cost?: {
105
+ value?: number | undefined;
106
+ currency?: string | undefined;
107
+ provenance: "computed" | "estimated" | "provider-reported" | "unavailable";
108
+ } | undefined;
109
+ };
110
+ artifactId: string;
111
+ payloadSha256: string;
112
+ } | {
113
+ conversationId: string;
114
+ invocationId: string;
115
+ operationId: string;
116
+ runId?: string | undefined;
117
+ type: "invocation/finished";
118
+ failure?: {
119
+ artifactId: string;
120
+ payloadSha256: string;
121
+ } | undefined;
122
+ status: "cancelled" | "failed" | "succeeded";
123
+ };
124
+ }[];
125
+ nextSeq?: number | undefined;
126
+ }>;
127
+ export declare function readInvocationPayload(store: AgentRuntimeStore, payloads: ReturnType<typeof createInvocationPayloads>, input: {
128
+ conversationId: string;
129
+ artifactId: string;
130
+ }): Promise<z.JSONType>;
131
+ //# sourceMappingURL=invocation-read.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invocation-read.d.ts","sourceRoot":"","sources":["../../src/agent-runtime/invocation-read.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAErE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEjD,eAAO,MAAM,yBAAyB;;;;kBAM3B,CAAC;AAEZ,wBAAsB,qBAAqB,CACzC,KAAK,EAAE,iBAAiB,EACxB,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BjD;AAED,wBAAsB,qBAAqB,CACzC,KAAK,EAAE,iBAAiB,EACxB,QAAQ,EAAE,UAAU,CAAC,OAAO,wBAAwB,CAAC,EACrD,KAAK,EAAE;IAAE,cAAc,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,uBAyBtD"}