stitchkit 0.108.4 → 0.109.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/dist/browser/cancellation.d.ts +4 -5
  3. package/dist/browser/cancellation.d.ts.map +1 -1
  4. package/dist/browser/client-executors.d.ts.map +1 -1
  5. package/dist/browser/http.d.ts.map +1 -1
  6. package/dist/entrypoints/agent-runtime/harness.js +4 -3
  7. package/dist/entrypoints/agent-runtime.js +7 -6
  8. package/dist/entrypoints/cli.js +6 -5
  9. package/dist/entrypoints/index.js +2 -2
  10. package/dist/entrypoints/react.js +1 -1
  11. package/dist/entrypoints/remote.js +2 -2
  12. package/dist/entrypoints/telegram.d.ts +2 -2
  13. package/dist/entrypoints/telegram.d.ts.map +1 -1
  14. package/dist/entrypoints/telegram.js +868 -137
  15. package/dist/entrypoints/testing.js +2 -2
  16. package/dist/entrypoints/tools/connections.js +6 -1
  17. package/dist/entrypoints/tools/contract.js +2 -1
  18. package/dist/entrypoints/tools/invoker.js +5 -4
  19. package/dist/entrypoints/tools/mcp.js +6 -5
  20. package/dist/entrypoints/tools.js +9 -8
  21. package/dist/{index-7jvwrjqa.js → index-00v1qz76.js} +20 -17
  22. package/dist/{index-cx2nh595.js → index-3wm2xp2a.js} +1 -1
  23. package/dist/{index-fgq4w9bf.js → index-5cw390s6.js} +100 -20
  24. package/dist/{index-h7qms8f9.js → index-68y3n9j3.js} +3 -3
  25. package/dist/{index-6yxhe58g.js → index-cykxpxz5.js} +7 -0
  26. package/dist/{index-p5kx5vqd.js → index-e32vy8jw.js} +22 -11
  27. package/dist/{index-dm2fv45z.js → index-k4v2kq4q.js} +1 -1
  28. package/dist/{index-6y9t2fwz.js → index-kvvpw1kq.js} +2 -2
  29. package/dist/{index-2s6fpehp.js → index-ryv32myz.js} +1 -1
  30. package/dist/index-t5sjh517.js +100 -0
  31. package/dist/{index-yz8x0hbx.js → index-tpk71wqn.js} +1 -1
  32. package/dist/{index-mep4sb48.js → index-x5xs71dw.js} +3 -3
  33. package/dist/telegram/update-intake-work.d.ts +39 -0
  34. package/dist/telegram/update-intake-work.d.ts.map +1 -0
  35. package/dist/telegram/update-intake.d.ts +47 -9
  36. package/dist/telegram/update-intake.d.ts.map +1 -1
  37. package/dist/telegram/update-store-check.d.ts.map +1 -1
  38. package/dist/telegram/update-store-postgres.d.ts +2 -2
  39. package/dist/telegram/update-store-postgres.d.ts.map +1 -1
  40. package/dist/telegram/update-store-sqlite.d.ts +2 -2
  41. package/dist/telegram/update-store-sqlite.d.ts.map +1 -1
  42. package/dist/telegram/update-store.d.ts +52 -3
  43. package/dist/telegram/update-store.d.ts.map +1 -1
  44. package/dist/tools/cli/args-fields.d.ts +7 -1
  45. package/dist/tools/cli/args-fields.d.ts.map +1 -1
  46. package/dist/tools/cli/args.d.ts.map +1 -1
  47. package/dist/tools/connections/runtime.d.ts.map +1 -1
  48. package/dist/tools/schema/coerce.d.ts.map +1 -1
  49. package/dist/tools/schema/json-schema-origin.d.ts +14 -0
  50. package/dist/tools/schema/json-schema-origin.d.ts.map +1 -0
  51. package/llms/cli.2.txt +1 -1
  52. package/llms/cli.txt +12 -0
  53. package/llms/stitchkit.txt +10 -3
  54. package/llms/telegram.txt +59 -8
  55. package/llms/tools.3.txt +1 -1
  56. package/llms/{upgrading-0.100.0-0.108.0.txt → upgrading-0.101.0-0.109.0.txt} +70 -72
  57. package/llms/upgrading-0.37.0.txt +176 -0
  58. package/llms/{upgrading-0.37.0-0.58.0.txt → upgrading-0.44.0-0.60.0.txt} +229 -169
  59. package/llms/{upgrading-0.59.0-0.71.0.txt → upgrading-0.61.0-0.73.0.txt} +122 -229
  60. package/llms/{upgrading-0.72.0-0.99.0.txt → upgrading-0.74.0-0.100.0.txt} +72 -122
  61. package/llms/upgrading.txt +5 -4
  62. package/llms-full.txt +150 -13
  63. package/llms.txt +9 -8
  64. package/package.json +1 -1
@@ -0,0 +1,100 @@
1
+ // src/tools/schema/json-schema-origin.ts
2
+ import { z } from "zod";
3
+ var JSON_SCHEMA_OBJECT_GUARD = Symbol.for("stitchkit.tools.json-schema-object-guard-origin.v1");
4
+ function mark(schema) {
5
+ if (Reflect.get(schema, JSON_SCHEMA_OBJECT_GUARD) === true)
6
+ return;
7
+ const marked = Reflect.defineProperty(schema, JSON_SCHEMA_OBJECT_GUARD, {
8
+ configurable: false,
9
+ enumerable: false,
10
+ value: true,
11
+ writable: false
12
+ });
13
+ if (!marked)
14
+ throw new Error("Cannot mark a restored JSON Schema object guard");
15
+ }
16
+ function markObjectGuard(schema) {
17
+ if (schema.in instanceof z.ZodTransform && schema.out instanceof z.ZodObject && schema.in.def.checks?.length) {
18
+ mark(schema);
19
+ return true;
20
+ }
21
+ return false;
22
+ }
23
+ function markJsonSchemaObjectGuards(schema) {
24
+ const visited = new WeakMap;
25
+ const visit = (current) => {
26
+ const known = visited.get(current);
27
+ if (known !== undefined)
28
+ return known;
29
+ visited.set(current, false);
30
+ if (current instanceof z.ZodPipe) {
31
+ const guarded = markObjectGuard(current);
32
+ visit(current.out);
33
+ visited.set(current, guarded);
34
+ return guarded;
35
+ }
36
+ if (current instanceof z.ZodObject) {
37
+ for (const field of Object.values(current.shape))
38
+ visit(field);
39
+ const catchall = current.def.catchall;
40
+ if (catchall)
41
+ visit(catchall);
42
+ return false;
43
+ }
44
+ if (current instanceof z.ZodArray) {
45
+ visit(current.element);
46
+ return false;
47
+ }
48
+ if (current instanceof z.ZodTuple) {
49
+ for (const item of current.def.items)
50
+ visit(item);
51
+ if (current.def.rest)
52
+ visit(current.def.rest);
53
+ return false;
54
+ }
55
+ if (current instanceof z.ZodRecord) {
56
+ visit(current.keyType);
57
+ visit(current.valueType);
58
+ return false;
59
+ }
60
+ if (current instanceof z.ZodUnion) {
61
+ for (const option of current.def.options)
62
+ visit(option);
63
+ return false;
64
+ }
65
+ if (current instanceof z.ZodIntersection) {
66
+ const leftGuarded = visit(current.def.left);
67
+ const rightGuarded = visit(current.def.right);
68
+ const guarded = leftGuarded || rightGuarded;
69
+ if (guarded)
70
+ mark(current);
71
+ visited.set(current, guarded);
72
+ return guarded;
73
+ }
74
+ if (current instanceof z.ZodOptional || current instanceof z.ZodExactOptional || current instanceof z.ZodNullable || current instanceof z.ZodDefault || current instanceof z.ZodPrefault || current instanceof z.ZodNonOptional || current instanceof z.ZodCatch || current instanceof z.ZodReadonly || current instanceof z.ZodLazy) {
75
+ const guarded = visit(current.unwrap());
76
+ if (guarded)
77
+ mark(current);
78
+ visited.set(current, guarded);
79
+ return guarded;
80
+ }
81
+ return false;
82
+ };
83
+ visit(schema);
84
+ }
85
+ function jsonSchemaObjectCoercionMembers(schema) {
86
+ if (Reflect.get(schema, JSON_SCHEMA_OBJECT_GUARD) !== true)
87
+ return;
88
+ if (schema instanceof z.ZodPipe && schema.out instanceof z.ZodObject) {
89
+ return [schema.out];
90
+ }
91
+ if (schema instanceof z.ZodIntersection) {
92
+ return [schema.def.left, schema.def.right];
93
+ }
94
+ if (schema instanceof z.ZodOptional || schema instanceof z.ZodExactOptional || schema instanceof z.ZodNullable || schema instanceof z.ZodDefault || schema instanceof z.ZodPrefault || schema instanceof z.ZodNonOptional || schema instanceof z.ZodCatch || schema instanceof z.ZodReadonly || schema instanceof z.ZodLazy) {
95
+ return [schema.unwrap()];
96
+ }
97
+ return;
98
+ }
99
+
100
+ export { markJsonSchemaObjectGuards, jsonSchemaObjectCoercionMembers };
@@ -14,7 +14,7 @@ import {
14
14
  import {
15
15
  ToolExecutionControlError2,
16
16
  isToolExecutionControlError2
17
- } from "./index-dm2fv45z.js";
17
+ } from "./index-k4v2kq4q.js";
18
18
  import {
19
19
  agentDurableEventId2
20
20
  } from "./index-mnkk1ffz.js";
@@ -13,15 +13,15 @@ import {
13
13
  parseToolCallArguments,
14
14
  toolResultFromError,
15
15
  observed
16
- } from "./index-dm2fv45z.js";
16
+ } from "./index-k4v2kq4q.js";
17
17
  import {
18
18
  collectTools2,
19
19
  createToolRunner,
20
20
  formatToolError
21
- } from "./index-2s6fpehp.js";
21
+ } from "./index-ryv32myz.js";
22
22
  import {
23
23
  collectToolSurface
24
- } from "./index-cx2nh595.js";
24
+ } from "./index-3wm2xp2a.js";
25
25
  import {
26
26
  DEFAULT_CORS_ALLOW_HEADERS2,
27
27
  DEFAULT_PROCESS_SIGNALS,
@@ -0,0 +1,39 @@
1
+ import type { TelegramUpdateAttemptIntakeConfig, TelegramUpdateEnvelope, TelegramUpdateIntakeConfig, TelegramUpdateStoreStep } from './update-intake.js';
2
+ import type { StoredTelegramUpdateExhaustion, TelegramUpdateAttemptIdentity, TelegramUpdateDurableStore, TelegramUpdateFencedStore, TelegramUpdateStore } from './update-store.js';
3
+ type TelegramUpdateAnyIntakeConfig<TUpdate extends TelegramUpdateEnvelope> = TelegramUpdateIntakeConfig<TUpdate> | TelegramUpdateAttemptIntakeConfig<TUpdate>;
4
+ export type TelegramUpdateStoreErrorReporter = (error: unknown, step: TelegramUpdateStoreStep) => void;
5
+ /** One shared concurrency budget for ordinary attempts and exhaustion delivery. */
6
+ export interface TelegramUpdateWorkSlots {
7
+ take(): Promise<void>;
8
+ release(): void;
9
+ }
10
+ export declare function createTelegramUpdateWorkSlots(maxConcurrent: number): TelegramUpdateWorkSlots;
11
+ export interface TelegramUpdateExhaustionScheduler {
12
+ schedule(row: StoredTelegramUpdateExhaustion, active: boolean): boolean;
13
+ pending(): readonly Promise<void>[];
14
+ }
15
+ /** Deliver recoverable terminal obligations without creating another durable queue. */
16
+ export declare function createTelegramUpdateExhaustionScheduler<TUpdate extends TelegramUpdateEnvelope>(options: {
17
+ readonly config: TelegramUpdateAnyIntakeConfig<TUpdate>;
18
+ readonly store: TelegramUpdateDurableStore | undefined;
19
+ readonly now: () => number;
20
+ readonly slots: TelegramUpdateWorkSlots;
21
+ readonly parse: (body: string) => Record<string, unknown> | undefined;
22
+ readonly reportStoreError: TelegramUpdateStoreErrorReporter;
23
+ }): TelegramUpdateExhaustionScheduler;
24
+ /** Build the claim/renew/settle state machine for one update attempt. */
25
+ export declare function createTelegramUpdateAttemptRunner<TUpdate extends TelegramUpdateEnvelope>(options: {
26
+ readonly config: TelegramUpdateAnyIntakeConfig<TUpdate>;
27
+ readonly store: TelegramUpdateStore;
28
+ readonly fenced: TelegramUpdateFencedStore | undefined;
29
+ readonly durable: TelegramUpdateDurableStore | undefined;
30
+ readonly now: () => number;
31
+ readonly retry: (error: unknown, attempt: number) => number | false;
32
+ readonly maxAttempts: number;
33
+ readonly leaseMs: number;
34
+ readonly reportStoreError: TelegramUpdateStoreErrorReporter;
35
+ readonly scheduleExhaustion: (row: StoredTelegramUpdateExhaustion) => void;
36
+ readonly ownershipLostReason: (identity: TelegramUpdateAttemptIdentity) => unknown;
37
+ }): (update: Record<string, unknown>, updateId: number) => Promise<void>;
38
+ export {};
39
+ //# sourceMappingURL=update-intake-work.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-intake-work.d.ts","sourceRoot":"","sources":["../../src/telegram/update-intake-work.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,iCAAiC,EACjC,sBAAsB,EAEtB,0BAA0B,EAC1B,uBAAuB,EACxB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EACV,8BAA8B,EAC9B,6BAA6B,EAC7B,0BAA0B,EAC1B,yBAAyB,EACzB,mBAAmB,EACpB,MAAM,gBAAgB,CAAC;AAExB,KAAK,6BAA6B,CAAC,OAAO,SAAS,sBAAsB,IACrE,0BAA0B,CAAC,OAAO,CAAC,GACnC,iCAAiC,CAAC,OAAO,CAAC,CAAC;AAE/C,MAAM,MAAM,gCAAgC,GAAG,CAC7C,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,uBAAuB,KAC1B,IAAI,CAAC;AAEV,mFAAmF;AACnF,MAAM,WAAW,uBAAuB;IACtC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,OAAO,IAAI,IAAI,CAAC;CACjB;AA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M,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,gBAAgB,EAAE,gCAAgC,CAAC;IAC5D,QAAQ,CAAC,kBAAkB,EAAE,CAAC,GAAG,EAAE,8BAA8B,KAAK,IAAI,CAAC;IAC3E,QAAQ,CAAC,mBAAmB,EAAE,CAAC,QAAQ,EAAE,6BAA6B,KAAK,OAAO,CAAC;CACpF,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CA+JvE"}
@@ -18,7 +18,7 @@
18
18
  * `processing` whose lease nobody renewed. Delivery is at least once: a
19
19
  * handler that finished but could not be recorded as finished runs again.
20
20
  */
21
- import type { TelegramUpdateStore } from './update-store.js';
21
+ import type { TelegramUpdateAttemptIdentity, TelegramUpdateFencedStore, TelegramUpdateStore } from './update-store.js';
22
22
  import type { TelegramUpdateAcceptance } from './webhook.js';
23
23
  /** An update as Telegram sends it; name grammY's `Update` to get its full type. */
24
24
  export interface TelegramUpdateEnvelope {
@@ -31,15 +31,32 @@ export interface TelegramUpdateFailure {
31
31
  /** `false` when the update was abandoned — no attempt follows. */
32
32
  readonly retrying: boolean;
33
33
  }
34
+ /** One handler invocation under one immutable store claim. */
35
+ export interface TelegramUpdateAttemptContext extends TelegramUpdateAttemptIdentity {
36
+ /** Pass this exact identity to a fenced store check inside the consumer's DB transaction. */
37
+ readonly fence: TelegramUpdateAttemptIdentity;
38
+ /** Aborted once renewal proves the attempt lost ownership or its last proven lease expires. */
39
+ readonly ownerLost: AbortSignal;
40
+ }
41
+ /** A terminal update failure recovered from the same durable update store. */
42
+ export interface TelegramUpdateExhaustion<TUpdate extends TelegramUpdateEnvelope> extends TelegramUpdateAttemptIdentity {
43
+ readonly update: TUpdate;
44
+ readonly exhaustedAt: number;
45
+ readonly error: string;
46
+ }
47
+ /** A failed delivery of a durable terminal-update obligation. */
48
+ export interface TelegramUpdateExhaustionFailure<TUpdate extends TelegramUpdateEnvelope> {
49
+ readonly exhaustion: TelegramUpdateExhaustion<TUpdate>;
50
+ readonly error: unknown;
51
+ }
52
+ /** The reason carried by `ownerLost` when an attempt no longer owns its lease. */
53
+ export declare class TelegramUpdateOwnershipLostError extends Error {
54
+ readonly identity: TelegramUpdateAttemptIdentity;
55
+ constructor(identity: TelegramUpdateAttemptIdentity);
56
+ }
34
57
  export type TelegramUpdateStoreStep = 'claim' | 'renew' | 'settle' | 'sweep';
35
- export interface TelegramUpdateIntakeConfig<TUpdate extends TelegramUpdateEnvelope> {
36
- readonly store: TelegramUpdateStore;
37
- /**
38
- * Handle one update — with grammY, `(update) => bot.handleUpdate(update)`.
39
- * A grammY `BotError` is unwrapped: `retry`, `onFailure` and the stored
40
- * error see what the middleware threw.
41
- */
42
- readonly handle: (update: TUpdate) => unknown;
58
+ /** Retry, lease, scheduling and observation options shared by both handler forms. */
59
+ export interface TelegramUpdateIntakeOptions<TUpdate extends TelegramUpdateEnvelope> {
43
60
  /**
44
61
  * After a failed attempt: milliseconds until the next, or `false` to
45
62
  * abandon the update. Default: abandon what Telegram said repeating cannot
@@ -61,11 +78,31 @@ export interface TelegramUpdateIntakeConfig<TUpdate extends TelegramUpdateEnvelo
61
78
  readonly maxConcurrent?: number;
62
79
  /** Every failed attempt. */
63
80
  readonly onFailure?: (failure: TelegramUpdateFailure) => void;
81
+ /**
82
+ * A durable final obligation. Resolving acknowledges it; throwing leaves it
83
+ * in the same store for a later sweep. Requires a `TelegramUpdateDurableStore`.
84
+ * Delivery is at least once, so persist by the supplied update/attempt identity.
85
+ */
86
+ readonly handleExhaustion?: (exhaustion: TelegramUpdateExhaustion<TUpdate>) => unknown;
87
+ /** An observational report that `handleExhaustion` threw; it never acknowledges the row. */
88
+ readonly onExhaustionFailure?: (failure: TelegramUpdateExhaustionFailure<TUpdate>) => void;
64
89
  /** The store refused a step; the update is retried when its lease lapses. */
65
90
  readonly onStoreError?: (error: unknown, step: TelegramUpdateStoreStep) => void;
66
91
  /** Default `Date.now`. */
67
92
  readonly now?: () => number;
68
93
  }
94
+ /** Existing one-argument intake configuration. */
95
+ export interface TelegramUpdateIntakeConfig<TUpdate extends TelegramUpdateEnvelope> extends TelegramUpdateIntakeOptions<TUpdate> {
96
+ readonly store: TelegramUpdateStore;
97
+ /** Direct grammY handlers keep their optional second argument private. */
98
+ readonly handle: (update: TUpdate) => unknown;
99
+ }
100
+ /** Intake configuration for a handler that needs attempt ownership metadata. */
101
+ export interface TelegramUpdateAttemptIntakeConfig<TUpdate extends TelegramUpdateEnvelope> extends TelegramUpdateIntakeOptions<TUpdate> {
102
+ readonly store: TelegramUpdateFencedStore;
103
+ /** Handle an update with its immutable attempt fence and ownership-loss signal. */
104
+ readonly handleAttempt: (update: TUpdate, context: TelegramUpdateAttemptContext) => unknown;
105
+ }
69
106
  export interface TelegramUpdateIntake {
70
107
  /** Record one webhook body; handling starts after, once the intake is started. */
71
108
  accept(body: string): Promise<TelegramUpdateAcceptance>;
@@ -79,4 +116,5 @@ export interface TelegramUpdateIntake {
79
116
  close(): Promise<void>;
80
117
  }
81
118
  export declare function createTelegramUpdateIntake<TUpdate extends TelegramUpdateEnvelope>(config: TelegramUpdateIntakeConfig<TUpdate>): TelegramUpdateIntake;
119
+ export declare function createTelegramUpdateIntake<TUpdate extends TelegramUpdateEnvelope>(config: TelegramUpdateAttemptIntakeConfig<TUpdate>): TelegramUpdateIntake;
82
120
  //# sourceMappingURL=update-intake.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"update-intake.d.ts","sourceRoot":"","sources":["../../src/telegram/update-intake.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAIH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAE1D,mFAAmF;AACnF,MAAM,WAAW,sBAAsB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,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;IACxD,iEAAiE;IACjE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,kEAAkE;IAClE,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACzB,0CAA0C;IAC1C,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACtB,2DAA2D;IAC3D,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAmFD,wBAAgB,0BAA0B,CAAC,OAAO,SAAS,sBAAsB,EAC/E,MAAM,EAAE,0BAA0B,CAAC,OAAO,CAAC,GAC1C,oBAAoB,CAAC;AACxB,wBAAgB,0BAA0B,CAAC,OAAO,SAAS,sBAAsB,EAC/E,MAAM,EAAE,iCAAiC,CAAC,OAAO,CAAC,GACjD,oBAAoB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"update-store-check.d.ts","sourceRoot":"","sources":["../../src/telegram/update-store-check.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAqG1D;;;;GAIG;AACH,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,MAAM,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,CAAC,GAC7D,OAAO,CAAC,MAAM,EAAE,CAAC,CAYnB"}
1
+ {"version":3,"file":"update-store-check.d.ts","sourceRoot":"","sources":["../../src/telegram/update-store-check.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAGV,mBAAmB,EACpB,MAAM,gBAAgB,CAAC;AAiXxB;;;;GAIG;AACH,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,MAAM,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,CAAC,GAC7D,OAAO,CAAC,MAAM,EAAE,CAAC,CAYnB"}
@@ -13,7 +13,7 @@
13
13
  * Parameters carry explicit casts: a driver that sends a JS number as a
14
14
  * double still lands in a `bigint` column.
15
15
  */
16
- import type { TelegramUpdateStore } from './update-store.js';
16
+ import type { TelegramUpdateDurableStore } from './update-store.js';
17
17
  /** Run one statement with `$1…$n` parameters; resolve with the rows it returned. */
18
18
  export type TelegramPostgresQuery = (text: string, parameters: readonly (string | number | null)[]) => Promise<readonly unknown[]>;
19
19
  export interface PostgresTelegramUpdateStoreConfig {
@@ -29,5 +29,5 @@ export interface PostgresTelegramUpdateStoreConfig {
29
29
  }
30
30
  /** The table and its index, for a migration. Safe to run twice. */
31
31
  export declare function postgresTelegramUpdateStoreSchema(table?: string): string;
32
- export declare function postgresTelegramUpdateStore(config: PostgresTelegramUpdateStoreConfig): TelegramUpdateStore;
32
+ export declare function postgresTelegramUpdateStore(config: PostgresTelegramUpdateStoreConfig): TelegramUpdateDurableStore;
33
33
  //# sourceMappingURL=update-store-postgres.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"update-store-postgres.d.ts","sourceRoot":"","sources":["../../src/telegram/update-store-postgres.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAA4B,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAEpF,oFAAoF;AACpF,MAAM,MAAM,qBAAqB,GAAG,CAClC,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,SAAS,CAAC,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC,EAAE,KAC5C,OAAO,CAAC,SAAS,OAAO,EAAE,CAAC,CAAC;AAEjC,MAAM,WAAW,iCAAiC;IAChD,QAAQ,CAAC,KAAK,EAAE,qBAAqB,CAAC;IACtC,kCAAkC;IAClC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;CAChC;AAaD,mEAAmE;AACnE,wBAAgB,iCAAiC,CAAC,KAAK,SAAqB,GAAG,MAAM,CAapF;AAqBD,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,iCAAiC,GACxC,mBAAmB,CAyGrB"}
1
+ {"version":3,"file":"update-store-postgres.d.ts","sourceRoot":"","sources":["../../src/telegram/update-store-postgres.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EAIV,0BAA0B,EAE3B,MAAM,gBAAgB,CAAC;AAExB,oFAAoF;AACpF,MAAM,MAAM,qBAAqB,GAAG,CAClC,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,SAAS,CAAC,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC,EAAE,KAC5C,OAAO,CAAC,SAAS,OAAO,EAAE,CAAC,CAAC;AAEjC,MAAM,WAAW,iCAAiC;IAChD,QAAQ,CAAC,KAAK,EAAE,qBAAqB,CAAC;IACtC,kCAAkC;IAClC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;CAChC;AAaD,mEAAmE;AACnE,wBAAgB,iCAAiC,CAAC,KAAK,SAAqB,GAAG,MAAM,CAepF;AA4HD,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,iCAAiC,GACxC,0BAA0B,CAmK5B"}
@@ -6,7 +6,7 @@
6
6
  * Each rule of `TelegramUpdateStore` is one conditional statement, so a claim
7
7
  * is atomic across processes sharing the file.
8
8
  */
9
- import type { TelegramUpdateStore } from './update-store.js';
9
+ import type { TelegramUpdateDurableStore } from './update-store.js';
10
10
  /** What this store needs of a SQLite handle; both runtimes' handles have it. */
11
11
  export interface TelegramSqliteDatabase {
12
12
  exec(sql: string): unknown;
@@ -22,5 +22,5 @@ export interface SqliteTelegramUpdateStoreConfig {
22
22
  /** Default `telegram_updates`. Created when missing. */
23
23
  readonly table?: string;
24
24
  }
25
- export declare function sqliteTelegramUpdateStore(config: SqliteTelegramUpdateStoreConfig): TelegramUpdateStore;
25
+ export declare function sqliteTelegramUpdateStore(config: SqliteTelegramUpdateStoreConfig): TelegramUpdateDurableStore;
26
26
  //# sourceMappingURL=update-store-sqlite.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"update-store-sqlite.d.ts","sourceRoot":"","sources":["../../src/telegram/update-store-sqlite.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAGV,mBAAmB,EACpB,MAAM,gBAAgB,CAAC;AAExB,gFAAgF;AAChF,MAAM,WAAW,sBAAsB;IACrC,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAC3B,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG;QACpB,GAAG,CAAC,GAAG,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC,EAAE,GAAG;YAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAA;SAAE,CAAC;QACtF,GAAG,CAAC,GAAG,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC,EAAE,GAAG,OAAO,EAAE,CAAC;KAC3D,CAAC;CACH;AAED,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,CAAC,QAAQ,EAAE,sBAAsB,CAAC;IAC1C,wDAAwD;IACxD,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAiBD,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,+BAA+B,GACtC,mBAAmB,CAkFrB"}
1
+ {"version":3,"file":"update-store-sqlite.d.ts","sourceRoot":"","sources":["../../src/telegram/update-store-sqlite.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAKV,0BAA0B,EAE3B,MAAM,gBAAgB,CAAC;AAExB,gFAAgF;AAChF,MAAM,WAAW,sBAAsB;IACrC,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAC3B,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG;QACpB,GAAG,CAAC,GAAG,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC,EAAE,GAAG;YAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAA;SAAE,CAAC;QACtF,GAAG,CAAC,GAAG,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC,EAAE,GAAG,OAAO,EAAE,CAAC;KAC3D,CAAC;CACH;AAED,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,CAAC,QAAQ,EAAE,sBAAsB,CAAC;IAC1C,wDAAwD;IACxD,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AA+ID,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,+BAA+B,GACtC,0BAA0B,CAyI5B"}
@@ -12,7 +12,10 @@
12
12
  * whose attempts are spent as `abandoned`;
13
13
  * - `renew` and `settle` act only while the record is still `processing` under
14
14
  * the same attempt, so a process that lost its lease cannot overwrite the
15
- * one that took it over.
15
+ * one that took it over;
16
+ * - a durable abandonment keeps `settledAt` empty until the consumer has
17
+ * handled its final obligation. It stays in this record and is never pruned
18
+ * while it is pending.
16
19
  */
17
20
  export type TelegramUpdateState = 'pending' | 'processing' | 'failed' | 'completed' | 'abandoned';
18
21
  export type TelegramUpdateSettlement = {
@@ -32,6 +35,8 @@ export interface TelegramUpdateClaimOptions {
32
35
  readonly now: number;
33
36
  readonly leaseUntil: number;
34
37
  readonly maxAttempts: number;
38
+ /** Keep an attempts-spent abandonment pending until the consumer acknowledges it. */
39
+ readonly durableExhaustion?: boolean;
35
40
  }
36
41
  export interface TelegramUpdateDueQuery {
37
42
  readonly now: number;
@@ -43,6 +48,23 @@ export interface StoredTelegramUpdate {
43
48
  readonly updateId: number;
44
49
  readonly body: string;
45
50
  }
51
+ /** The immutable identity of one claim, including a token that never repeats after pruning. */
52
+ export interface TelegramUpdateAttemptIdentity {
53
+ readonly updateId: number;
54
+ readonly attempt: number;
55
+ readonly claimId: string;
56
+ }
57
+ /** A final failure waiting for the consumer's durable obligation. */
58
+ export interface StoredTelegramUpdateExhaustion extends StoredTelegramUpdate, TelegramUpdateAttemptIdentity {
59
+ readonly exhaustedAt: number;
60
+ readonly error: string;
61
+ }
62
+ /** One ordered page of final failures still waiting for acknowledgement. */
63
+ export interface TelegramUpdateExhaustionQuery {
64
+ readonly limit: number;
65
+ /** Continue strictly after this `update_id`; omit to begin at the first row. */
66
+ readonly afterUpdateId?: number;
67
+ }
46
68
  export interface TelegramUpdateStore {
47
69
  /** Record a received update as `pending`; `false` when this `update_id` is already recorded. */
48
70
  add(update: StoredTelegramUpdate & {
@@ -51,7 +73,9 @@ export interface TelegramUpdateStore {
51
73
  /** Take a claimable update for one attempt; its number, or `undefined` when not taken. */
52
74
  claim(updateId: number, options: TelegramUpdateClaimOptions): Promise<number | undefined>;
53
75
  /** Extend the lease of this attempt; `false` when the attempt no longer holds the update. */
54
- renew(updateId: number, attempt: number, leaseUntil: number): Promise<boolean>;
76
+ renew(updateId: number, attempt: number, leaseUntil: number,
77
+ /** When supplied, a lease that already expired cannot be resurrected. */
78
+ now?: number): Promise<boolean>;
55
79
  /** End this attempt; ignored when the attempt no longer holds the update. */
56
80
  settle(updateId: number, attempt: number, settlement: TelegramUpdateSettlement): Promise<void>;
57
81
  /** Claimable updates in `update_id` order. */
@@ -59,9 +83,34 @@ export interface TelegramUpdateStore {
59
83
  /** Forget `completed` and `abandoned` updates settled before `before`; how many were forgotten. */
60
84
  prune(before: number): Promise<number>;
61
85
  }
86
+ /** A store able to verify an immutable attempt fence inside the caller's transaction. */
87
+ export interface TelegramUpdateFencedStore extends TelegramUpdateStore {
88
+ /** Atomically take one claim and return its persisted, globally unique identity. */
89
+ claimOwned(updateId: number, options: TelegramUpdateClaimOptions): Promise<TelegramUpdateAttemptIdentity | undefined>;
90
+ /** Extend only this exact claim's live lease. */
91
+ renewOwned(identity: TelegramUpdateAttemptIdentity, leaseUntil: number, now?: number): Promise<boolean>;
92
+ /** `true` only while this exact attempt still owns an unexpired lease. */
93
+ owns(identity: TelegramUpdateAttemptIdentity, at: number): Promise<boolean>;
94
+ /** Atomically settle only while this exact attempt still owns an unexpired lease. */
95
+ settleOwned(identity: TelegramUpdateAttemptIdentity, settlement: TelegramUpdateSettlement): Promise<boolean>;
96
+ }
97
+ /**
98
+ * The same update store with recoverable final-failure delivery.
99
+ *
100
+ * `exhaust` leaves the abandonment pending, `dueExhaustions` reads it after a
101
+ * restart, and `acknowledgeExhaustion` makes it eligible for ordinary pruning.
102
+ */
103
+ export interface TelegramUpdateDurableStore extends TelegramUpdateFencedStore {
104
+ exhaust(identity: TelegramUpdateAttemptIdentity, exhaustion: {
105
+ readonly at: number;
106
+ readonly error: string;
107
+ }): Promise<boolean>;
108
+ dueExhaustions(query: TelegramUpdateExhaustionQuery): Promise<readonly StoredTelegramUpdateExhaustion[]>;
109
+ acknowledgeExhaustion(identity: TelegramUpdateAttemptIdentity, at: number): Promise<boolean>;
110
+ }
62
111
  /**
63
112
  * A store in this process's memory — for tests, and for a bot that accepts
64
113
  * losing what was received but not handled when it restarts.
65
114
  */
66
- export declare function memoryTelegramUpdateStore(): TelegramUpdateStore;
115
+ export declare function memoryTelegramUpdateStore(): TelegramUpdateDurableStore;
67
116
  //# sourceMappingURL=update-store.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"update-store.d.ts","sourceRoot":"","sources":["../../src/telegram/update-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,MAAM,mBAAmB,GAC3B,SAAS,GACT,YAAY,GACZ,QAAQ,GACR,WAAW,GACX,WAAW,CAAC;AAEhB,MAAM,MAAM,wBAAwB,GAChC;IAAE,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CAAE,GACpD;IACE,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IACzB,QAAQ,CAA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AC,SAAS,8BAA8B,EAAE,CAAC,CAAC;IACtD,qBAAqB,CAAC,QAAQ,EAAE,6BAA6B,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC9F;AAuBD;;;GAGG;AACH,wBAAgB,yBAAyB,IAAI,0BAA0B,CAmKtE"}
@@ -21,6 +21,12 @@ export declare function appendCliOptionValue(raw: Map<string, string[]>, name: s
21
21
  * scalar schema yields an empty map and every value is left as a string.
22
22
  */
23
23
  export declare function describeSchemaFields(schema: z.ZodType | undefined): Map<string, FieldInfo>;
24
+ /**
25
+ * Resolve the declared leaf of a dotted option. An intersection's concrete
26
+ * constraint can refine a free member; a union with a free member stays raw,
27
+ * because coercion must not choose one accepted branch for the caller.
28
+ */
29
+ export declare function describeSchemaPath(schema: z.ZodType | undefined, path: readonly string[]): FieldInfo | undefined;
24
30
  /** Strict boolean for a RESERVED option — an unrecognised value is a usage error, never a silent `true`. */
25
31
  /**
26
32
  * The token after a bare boolean flag, when it is the flag's value: exactly
@@ -33,7 +39,7 @@ export declare function separateBoolValue(next: string | undefined): boolean | u
33
39
  /** True for a value the reserved-boolean grammar already claims. */
34
40
  export declare function isReservedBoolWord(value: string): boolean;
35
41
  export declare function parseReservedBool(name: string, value: string): boolean;
36
- /** Best-effort coercion for a dotted-path leaf, where the schema type is unknown. */
42
+ /** Preserve the legacy best-effort grammar for a wholly unknown passthrough option. */
37
43
  export declare function looseCoerce(value: string): unknown;
38
44
  /** Coerce the collected raw string value(s) for one field to its typed form. */
39
45
  export declare function coerceField(info: FieldInfo | undefined, values: string[], label: string): unknown;
@@ -1 +1 @@
1
- {"version":3,"file":"args-fields.d.ts","sourceRoot":"","sources":["../../../src/tools/cli/args-fields.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,MAAM,MAAM,SAAS,GACjB,SAAS,GACT,QAAQ,GACR,QAAQ,GACR,MAAM,GAC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AIhF;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EACzC,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,EACjC,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,qBAAqB,EAC/C,SAAS,EAAE,0BAA0B,GACpC,qBAAqB,EAAE,CAczB"}
@@ -1 +1 @@
1
- {"version":3,"file":"coerce.d.ts","sourceRoot":"","sources":["../../../src/tools/schema/coerce.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA2KxB;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,MAAM,EAAE,CAAC,CAAC,OAAO,GAAG,SAAS,GAC5B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAGzB"}
1
+ {"version":3,"file":"coerce.d.ts","sourceRoot":"","sources":["../../../src/tools/schema/coerce.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAoLxB;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,MAAM,EAAE,CAAC,CAAC,OAAO,GAAG,SAAS,GAC5B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAGzB"}
@@ -0,0 +1,14 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Record which structural pipes came from the one foreign JSON Schema boundary.
4
+ * The walk runs once after `z.fromJSONSchema`; coercion later reads only this
5
+ * provenance and never guesses from a transform's public shape or metadata.
6
+ */
7
+ export declare function markJsonSchemaObjectGuards(schema: z.core.$ZodType): void;
8
+ /**
9
+ * Schemas that can guide coercion at a proven foreign object boundary.
10
+ * Intersections need both branches: one carries the key guard, while another
11
+ * can carry nested object fields that also need recursive coercion.
12
+ */
13
+ export declare function jsonSchemaObjectCoercionMembers(schema: z.core.$ZodType): readonly z.core.$ZodType[] | undefined;
14
+ //# sourceMappingURL=json-schema-origin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-schema-origin.d.ts","sourceRoot":"","sources":["../../../src/tools/schema/json-schema-origin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAgCxB;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAiExE;AAED;;;;GAIG;AACH,wBAAgB,+BAA+B,CAC7C,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,GACtB,SAAS,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,SAAS,CAsBxC"}
package/llms/cli.2.txt CHANGED
@@ -269,7 +269,7 @@ SDK nor the `ai` peer.
269
269
  | `parseCliArgs` | function | argv → typed tool args against a schema (advanced) |
270
270
  | `routeCliArgv` | function | select the command out of argv without duplicating the global-option grammar (advanced) |
271
271
  | `extractCliGlobalOptions` | function | lift the application's own global options out of argv before routing (advanced) |
272
- | `coerceJsonArgs` | function | the second half of `parseCliArgs` — parse array/object values a consumer sends itself, without the `stitchkit/tools` barrel |
272
+ | `coerceJsonArgs` | function | the second half of `parseCliArgs` — parse array/object values a consumer sends itself, including discovered MCP object guards restored from JSON Schema, without the `stitchkit/tools` barrel |
273
273
  | `CliArgumentError` | class | the refusal `parseCliArgs` and the view flags raise; a CLI reports it and exits `2` |
274
274
  | `renderCliView` | function | compute an aggregate over a result (`--count-by`, `--sum`, `--top`, `--table`) — [guide](../guide/cli.md#aggregate-views) |
275
275
  | `createCliProfileStore` | function | named `0600` credential profiles resolved by name, with the never-substitute rule built in — [guide](../guide/cli.md#named-profiles) |
package/llms/cli.txt CHANGED
@@ -244,12 +244,24 @@ string, the schema says what it should be:
244
244
  | `z.enum([...])` | `--size large` |
245
245
  | `z.array(z.string())`| `--tag a --tag b` → `["a","b"]` |
246
246
  | `z.object({...})` | `--opts '{"k":"v"}'` (JSON) or `--opts.k v` |
247
+ | `z.record(z.string(), z.unknown())` | `--data '{"code":"007"}'` or `--data.code=007` → `"007"` |
247
248
  | `.optional()` / `.default()` | not required |
248
249
 
249
250
  Primitive literals use the same coercion through optional, nullable and default wrappers and as
250
251
  array elements. A literal set whose members have different primitive types stays lexical because
251
252
  argv has no type tag: for `z.literal([7, '007'])`, `--value 007` remains the string `"007"` rather
252
253
  than being guessed as the number `7`. The unchanged Zod schema makes the final admission decision.
254
+ Object and record JSON keeps the same behavior when a CLI discovers a tool through MCP. Restored
255
+ `propertyNames`, `minProperties` and `maxProperties` constraints still run before dispatch; CLI
256
+ coercion does not execute application transforms.
257
+
258
+ A dotted leaf follows the leaf schema, including through optional/nullable wrappers and restored
259
+ MCP object guards. A declared number or boolean is coerced; a string stays byte-for-byte lexical.
260
+ For a free `z.record(z.string(), z.unknown())`, argv provides no JSON type tag, so the dotted
261
+ value also stays a string: `007`, `+007`, `1e3`, `true` and `false` keep those spellings.
262
+ Use the whole-object JSON form when a free record value must be a JSON number or boolean. This
263
+ avoids silently changing identifiers while keeping `z.record(..., z.number())` and
264
+ `z.record(..., z.boolean())` explicitly typed.
253
265
 
254
266
  After a bare boolean flag, the next token is its value when it is exactly
255
267
  `true` or `false` — `--active false` turns it off, as it reads. Any other word
@@ -83,12 +83,12 @@ own, recorded as an ADR.
83
83
  | `stitchkit/geo` | server (Bun or Node) | evolving | managed GeoIP reader generations, last-known-good reload and the optional MaxMind adapter |
84
84
  | `stitchkit/oauth` | browser **and** server | evolving | provider-neutral Authorization Code + PKCE request and one-shot callback transaction mechanics |
85
85
  | `stitchkit/google` | server (Bun or Node) | evolving | optional Google code exchange and verified OIDC identity adapter |
86
- | `stitchkit/observability` | server | stable<br>_redefined in 2 of the 53 minors since 0.56.2, most recently 0.92.0_ | request/tool event projections — `createObservability`, trace context, sanitisation |
86
+ | `stitchkit/observability` | server | stable<br>_redefined in 2 of the 54 minors since 0.56.2, most recently 0.92.0_ | request/tool event projections — `createObservability`, trace context, sanitisation |
87
87
  | `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 |
88
88
  | `stitchkit/declaration` | browser + build and deployment tooling (Bun or Node) | evolving | `ProjectDeclarationSchema` — the one machine-readable statement a repository makes about itself |
89
89
  | `stitchkit/react` | browser + server rendering | stable | `createCursorQuery`, `createCacheBridge`, QueryClient and `ApiError` retry policy |
90
90
  | `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) |
91
- | `stitchkit/agent-runtime` | server | evolving<br>_redefined in 23 of the 53 minors since 0.56.2, most recently 0.105.0_ | optional durable conversation/run loop, history, models, prompts, fencing and events |
91
+ | `stitchkit/agent-runtime` | server | evolving<br>_redefined in 23 of the 54 minors since 0.56.2, most recently 0.105.0_ | optional durable conversation/run loop, history, models, prompts, fencing and events |
92
92
  | `stitchkit/agent-runtime/sandbox` | server | evolving | optional Linux Bubblewrap sessions, durable workspaces and a host HTTP credential gateway; see [sandbox guide](sandbox.md) |
93
93
  | `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 |
94
94
  | `stitchkit/agent-runtime/harness` | server | evolving | resource-aware process-local facade over the canonical Agent runtime; supervision stays outside |
@@ -100,7 +100,7 @@ own, recorded as an ADR.
100
100
  | `stitchkit/agent-runtime/sqlite/bun` | server (Bun) | evolving | durable built-in SQLite store for the agent runtime |
101
101
  | `stitchkit/agent-runtime/sqlite/node` | server (Node ≥ 22.5) | evolving | durable built-in SQLite store for the agent runtime |
102
102
  | `stitchkit-tui` | terminal (Bun) | evolving | optional official OpenTUI host over a caller-composed headless runtime |
103
- | `stitchkit/application` | browser + server | evolving<br>_redefined in 13 of the 53 minors since 0.56.2, most recently 0.105.0_ | managed resource graph, readiness, admission, schedules, subtree restart and bounded shutdown |
103
+ | `stitchkit/application` | browser + server | evolving<br>_redefined in 13 of the 54 minors since 0.56.2, most recently 0.105.0_ | managed resource graph, readiness, admission, schedules, subtree restart and bounded shutdown |
104
104
  | `stitchkit/application/grammy` | server | evolving | a grammY bot as application resources — configuration, then polling with updates admitted by batch — and the webhook adapter |
105
105
  | `stitchkit/application/opentelemetry` | server | evolving | maps application snapshots onto an injected OpenTelemetry `Meter` |
106
106
  | `stitchkit/application/schemas` | browser + server | evolving | the application's snapshot, health and shutdown schemas alone, without the kernel |
@@ -621,6 +621,13 @@ preserve facts the generic client cannot invent — for example a Unix transport
621
621
  an effect from `UNKNOWN_ERROR` alone; inspect the owned adapter's cause and retry
622
622
  only when it proves that dispatch did not happen.
623
623
 
624
+ The same evidence survives when caller abort or the request deadline wins the
625
+ race: the public code remains `REQUEST_ABORTED` or `REQUEST_TIMEOUT`, while
626
+ the exact rejection produced by the transport remains in `ApiError.cause`.
627
+ That cause is internal diagnostic data — it is not included by JSON/string
628
+ rendering — so delivery state and trace metadata remain available without
629
+ putting transport payloads or credentials in a client-facing error.
630
+
624
631
  For an endpoint without contract arguments, pass only the options object:
625
632
 
626
633
  ```ts