stitchkit 0.105.2 → 0.106.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 (35) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/dist/agent-runtime/coding-shell-process.d.ts.map +1 -1
  3. package/dist/agent-runtime/store-conformance-lifecycle.d.ts +10 -10
  4. package/dist/agent-runtime/store-conformance-support.d.ts +5 -5
  5. package/dist/entrypoints/agent-runtime/coding-tools.js +2 -2
  6. package/dist/entrypoints/agent-runtime/sandbox.js +2 -2
  7. package/dist/entrypoints/process.js +1 -1
  8. package/dist/{index-3s86a7kf.js → index-4q9jvqg7.js} +216 -51
  9. package/dist/{index-sevbwsnn.js → index-9bskshe3.js} +2 -4
  10. package/dist/process/cleanup.d.ts.map +1 -1
  11. package/dist/process/command-owner.d.ts.map +1 -1
  12. package/dist/process/contract.d.ts +84 -9
  13. package/dist/process/contract.d.ts.map +1 -1
  14. package/dist/process/group.d.ts +12 -0
  15. package/dist/process/group.d.ts.map +1 -1
  16. package/dist/process/launch.d.ts +5 -0
  17. package/dist/process/launch.d.ts.map +1 -1
  18. package/dist/process/output-drain.d.ts +14 -0
  19. package/dist/process/output-drain.d.ts.map +1 -0
  20. package/dist/process/owned-child.d.ts +9 -0
  21. package/dist/process/owned-child.d.ts.map +1 -1
  22. package/dist/process/terminate.d.ts +2 -0
  23. package/dist/process/terminate.d.ts.map +1 -1
  24. package/dist/process/transport.d.ts +5 -0
  25. package/dist/process/transport.d.ts.map +1 -1
  26. package/llms/process.txt +69 -22
  27. package/llms/stitchkit.txt +3 -3
  28. package/llms/{upgrading-0.37.0-0.50.0.txt → upgrading-0.37.0-0.53.0.txt} +25 -3
  29. package/llms/{upgrading-0.53.0-0.67.0.txt → upgrading-0.55.0-0.68.0.txt} +53 -25
  30. package/llms/{upgrading-0.68.0-0.94.0.txt → upgrading-0.69.0-0.95.0.txt} +45 -53
  31. package/llms/{upgrading-0.95.0-0.105.0.txt → upgrading-0.96.0-0.106.0.txt} +40 -45
  32. package/llms/upgrading.txt +4 -4
  33. package/llms-full.txt +109 -25
  34. package/llms.txt +5 -5
  35. package/package.json +3 -3
@@ -3,13 +3,21 @@ declare const NativeCommandSettlementSchema: z.ZodDiscriminatedUnion<[z.ZodObjec
3
3
  kind: z.ZodLiteral<"exit">;
4
4
  exitCode: z.ZodNullable<z.ZodNumber>;
5
5
  signal: z.ZodNullable<z.ZodString>;
6
+ }, z.core.$strip>, z.ZodObject<{
7
+ kind: z.ZodLiteral<"stopped">;
8
+ cause: z.ZodUnknown;
9
+ exitCode: z.ZodNullable<z.ZodNumber>;
10
+ signal: z.ZodNullable<z.ZodString>;
6
11
  }, z.core.$strip>, z.ZodObject<{
7
12
  kind: z.ZodLiteral<"error">;
8
13
  cause: z.ZodUnknown;
9
14
  }, z.core.$strip>], "kind">;
10
15
  /**
11
- * How a command's main process ended: `exit` with code and signal, or `error` with the cause;
12
- * `onLeaderSettled` receives it before inherited pipes finish draining.
16
+ * How a command's main process ended: `exit` with code and signal when it ended on its own;
17
+ * `stopped` when the command was stopped (abort, deadline, output budget, failing sink) and the
18
+ * kernel then reported how the leader ended, with the stop's `cause`; `error` when no exit of the
19
+ * leader was observed (it could not start, or its exit never arrived). A leader that ends on its
20
+ * own settles before inherited pipes finish draining, a stopped one after the stop signals.
13
21
  */
14
22
  export type NativeCommandSettlement = z.infer<typeof NativeCommandSettlementSchema>;
15
23
  /**
@@ -37,11 +45,12 @@ declare const NativeCommandStopPolicySchema: z.ZodObject<{
37
45
  /**
38
46
  * How a cancelled command is stopped: `signal` goes to the whole group (`target: 'group'`) or
39
47
  * only to the leader (`'leader'`), the group gets KILL once the grace ends (for `'leader'`, as
40
- * soon as the leader has exited), and an abort of `killOn` stops at once with KILL.
48
+ * soon as the leader has exited), and an abort of `killOn` stops at once with KILL. A command in
49
+ * the caller's group (`group: 'caller'`) takes `'leader'` only, and KILL reaches its leader alone.
41
50
  */
42
51
  export type NativeCommandStopPolicy = z.input<typeof NativeCommandStopPolicySchema>;
43
52
  export type ParsedNativeCommandStopPolicy = z.output<typeof NativeCommandStopPolicySchema>;
44
- export declare const NativeCommandOptionsSchema: z.ZodObject<{
53
+ export declare const NativeCommandOptionsSchema: z.ZodPipe<z.ZodObject<{
45
54
  executable: z.ZodString;
46
55
  args: z.ZodDefault<z.ZodArray<z.ZodString>>;
47
56
  cwd: z.ZodOptional<z.ZodString>;
@@ -64,7 +73,15 @@ export declare const NativeCommandOptionsSchema: z.ZodObject<{
64
73
  pid: number;
65
74
  }) => void>>;
66
75
  drainTimeoutMs: z.ZodOptional<z.ZodNumber>;
67
- stop: z.ZodDefault<z.ZodObject<{
76
+ group: z.ZodDefault<z.ZodEnum<{
77
+ caller: "caller";
78
+ own: "own";
79
+ }>>;
80
+ stdio: z.ZodDefault<z.ZodEnum<{
81
+ inherit: "inherit";
82
+ pipe: "pipe";
83
+ }>>;
84
+ stop: z.ZodOptional<z.ZodObject<{
68
85
  target: z.ZodEnum<{
69
86
  group: "group";
70
87
  leader: "leader";
@@ -80,12 +97,68 @@ export declare const NativeCommandOptionsSchema: z.ZodObject<{
80
97
  graceMs: z.ZodNumber;
81
98
  killOn: z.ZodOptional<z.ZodCustom<AbortSignal, AbortSignal>>;
82
99
  }, z.core.$strict>>;
83
- descendants: z.ZodDefault<z.ZodEnum<{
100
+ descendants: z.ZodOptional<z.ZodEnum<{
84
101
  leave: "leave";
85
102
  "terminate-after-leader": "terminate-after-leader";
86
103
  }>>;
87
104
  cleanupTimeoutMs: z.ZodDefault<z.ZodNumber>;
88
- }, z.core.$strict>;
105
+ }, z.core.$strict>, z.ZodTransform<{
106
+ executable: string;
107
+ args: string[];
108
+ cwd?: string | undefined;
109
+ env?: Record<string, string> | undefined;
110
+ envPolicy: "ambient" | "declared-only";
111
+ signal?: AbortSignal | undefined;
112
+ timeoutMs?: number | undefined;
113
+ maxOutputBytes?: number | undefined;
114
+ capture: boolean;
115
+ stdin?: Uint8Array<ArrayBufferLike> | undefined;
116
+ maxStdinBytes: number;
117
+ onOutput?: ((bytes: Uint8Array, channel: 'stdout' | 'stderr', signal: AbortSignal) => void | Promise<void>) | undefined;
118
+ onLeaderSettled?: ((event: NativeCommandSettlement, signal: AbortSignal) => void | Promise<void>) | undefined;
119
+ onLeaderStarted?: ((event: {
120
+ pid: number;
121
+ }) => void) | undefined;
122
+ drainTimeoutMs?: number | undefined;
123
+ group: "caller" | "own";
124
+ stdio: "inherit" | "pipe";
125
+ cleanupTimeoutMs: number;
126
+ stop: {
127
+ target: "group" | "leader";
128
+ signal: "SIGHUP" | "SIGINT" | "SIGQUIT" | "SIGTERM" | "SIGUSR1" | "SIGUSR2";
129
+ graceMs: number;
130
+ killOn?: AbortSignal | undefined;
131
+ };
132
+ descendants: "leave" | "terminate-after-leader";
133
+ }, {
134
+ executable: string;
135
+ args: string[];
136
+ cwd?: string | undefined;
137
+ env?: Record<string, string> | undefined;
138
+ envPolicy: "ambient" | "declared-only";
139
+ signal?: AbortSignal | undefined;
140
+ timeoutMs?: number | undefined;
141
+ maxOutputBytes?: number | undefined;
142
+ capture: boolean;
143
+ stdin?: Uint8Array<ArrayBufferLike> | undefined;
144
+ maxStdinBytes: number;
145
+ onOutput?: ((bytes: Uint8Array, channel: 'stdout' | 'stderr', signal: AbortSignal) => void | Promise<void>) | undefined;
146
+ onLeaderSettled?: ((event: NativeCommandSettlement, signal: AbortSignal) => void | Promise<void>) | undefined;
147
+ onLeaderStarted?: ((event: {
148
+ pid: number;
149
+ }) => void) | undefined;
150
+ drainTimeoutMs?: number | undefined;
151
+ group: "caller" | "own";
152
+ stdio: "inherit" | "pipe";
153
+ stop?: {
154
+ target: "group" | "leader";
155
+ signal: "SIGHUP" | "SIGINT" | "SIGQUIT" | "SIGTERM" | "SIGUSR1" | "SIGUSR2";
156
+ graceMs: number;
157
+ killOn?: AbortSignal | undefined;
158
+ } | undefined;
159
+ descendants?: "leave" | "terminate-after-leader" | undefined;
160
+ cleanupTimeoutMs: number;
161
+ }>>;
89
162
  /**
90
163
  * Input to `runNativeCommand`: the executable and args, plus a caller signal or finite
91
164
  * timeout; capturing output also requires `maxOutputBytes`.
@@ -110,8 +183,10 @@ declare const NativeCommandLimitReasonSchema: z.ZodEnum<{
110
183
  }>;
111
184
  /**
112
185
  * Thrown by `runNativeCommand`; `code` is `COMMAND_LIMIT` (see `reason`),
113
- * `COMMAND_UNAVAILABLE` (could not start) or `COMMAND_CLEANUP` (handles stayed open past
114
- * `cleanupTimeoutMs`).
186
+ * `COMMAND_UNAVAILABLE` (could not start) or `COMMAND_CLEANUP` (the command's resources were not
187
+ * proven closed): handles stayed open past `cleanupTimeoutMs` after a stop, or the output pipes
188
+ * stayed open past `drainTimeoutMs` after the leader exited. `cause` holds the failure of the
189
+ * bound that tripped.
115
190
  */
116
191
  export declare class NativeCommandError extends Error {
117
192
  readonly code: 'COMMAND_LIMIT' | 'COMMAND_UNAVAILABLE' | 'COMMAND_CLEANUP';
@@ -1 +1 @@
1
- {"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../src/process/contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,QAAA,MAAM,6BAA6B;;;;;;;2BAOjC,CAAC;AACH;;;GAGG;AACH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC;AAEpF;;GAEG;AACH,eAAO,MAAM,0BAA0B,OAAO,CAAC;AAE/C,gGAAgG;AAChG,eAAO,MAAM,yBAAyB,UAAY,CAAC;AAEnD,QAAA,MAAM,6BAA6B;;;;;;;;;;;;;;;kBAOjC,CAAC;AACH;;;;GAIG;AACH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC;AACpF,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,6BAA6B,CAAC,CAAC;AAqB3F,eAA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G;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E,QAAA,MAAM,8BAA8B;;;EAAwC,CAAC;AAE7E;;;;;;GAMG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;aAezB,IAAI,EAAE,eAAe,GAAG,qBAAqB,GAAG,iBAAiB;IAdnF,2GAA2G;IAC3G,SAAgB,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,GAAG,SAAS,CAAC;IAEnF,YACE,IAAI,EAAE,eAAe,EACrB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,YAAY,GAAG;QAAE,MAAM,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAA;KAAE,EACpF;IACF,YACE,IAAI,EAAE,eAAe,GAAG,qBAAqB,GAAG,iBAAiB,EACjE,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,YAAY,GAAG;QAAE,MAAM,CAAC,EAAE,KAAK,CAAA;KAAE,EAC3C;CAgBH"}
@@ -45,6 +45,18 @@ export declare function stopCommandLeader(stop: CommandGroupStop & {
45
45
  leader: CommandLeader;
46
46
  leaderExit: Promise<unknown>;
47
47
  }): Promise<boolean>;
48
+ /**
49
+ * Stop a command that is no group leader of its own (it joined the caller's group): the
50
+ * policy's signal to the leader alone, a grace its exit ends, then KILL to the leader alone.
51
+ * Its group is the caller's and is never signalled; a leader that has already exited is never
52
+ * signalled again. Resolves `true` when a signal reached the leader.
53
+ */
54
+ export declare function stopLeaderAlone(stop: {
55
+ leader: CommandLeader;
56
+ policy: ParsedNativeCommandStopPolicy;
57
+ leaderExit: Promise<unknown>;
58
+ force: boolean;
59
+ }): Promise<boolean>;
48
60
  export declare function commandCleanupError(cause: unknown): NativeCommandError;
49
61
  export declare function waitForCommandClose<T>(closed: Promise<T>, timeoutMs: number): Promise<T>;
50
62
  //# sourceMappingURL=group.d.ts.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AC,CAAA;CAAE,GAC/E,OAAO,CAAC,OAAO,CAAC,CAsBlB;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,IAAI,EAAE;IAC1C,MAAM,EAAE,aAAa,CAAC;IACtB,MAAM,EAAE,6BAA6B,CAAC;IACtC,UAAU,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAC7B,KAAK,EAAE,OAAO,CAAC;CAChB,GAAG,OAAO,CAAC,OAAO,CAAC,CAyBnB;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,kBAAkB,CAItE;AAED,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAMxF"}
@@ -62,6 +62,11 @@ export declare function launchNativeCommand({ options, driver, onSpawn, onFailur
62
62
  kind: "exit";
63
63
  exitCode: number | null;
64
64
  signal: string | null;
65
+ } | {
66
+ kind: "stopped";
67
+ cause: unknown;
68
+ exitCode: number | null;
69
+ signal: string | null;
65
70
  } | {
66
71
  kind: "error";
67
72
  cause: unknown;
@@ -1 +1 @@
1
- {"version":3,"file":"launch.d.ts","sourceRoot":"","sources":["../../src/process/launch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAsB,KAAK,0BAA0B,EAAE,MAAM,YAAY,CAAC;AAEjF,OAAO,EAA0B,KAAK,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAElF,wFAAwF;AACxF,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;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S,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B;AAGD,uFAAuF;AACvF,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,kBAAkB,GAAG,IAAI,CAEzF;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS,CAEhF;AAwED,yFAAyF;AACzF,wBAAgB,mBAAmB,CAAC,EAClC,OAAO,EACP,MAAM,EACN,OAAO,EACP,SAAS,EACT,cAAc,EACd,UAAU,GACX,EAAE;IACD,OAAO,EAAE,0BAA0B,CAAC;IACpC,MAAM,EAAE,yBAAyB,GAAG,SAAS,CAAC;IAC9C,kEAAkE;IAClE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,8BAA8B,KAAK,IAAI,CAAC;IAC1D,wDAAwD;IACxD,SAAS,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAClC,kEAAkE;IAClE,cAAc,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACvC,yEAAyE;IACzE,UAAU,EAAE,CAAC,SAAS,EAAE,sBAAsB,KAAK,IAAI,CAAC;CACzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoDA"}
@@ -0,0 +1,14 @@
1
+ import { type ParsedNativeCommandOptions } from './contract.js';
2
+ /**
3
+ * The reader of a command's two output channels: one combined `maxOutputBytes` budget, the
4
+ * captured bytes per channel and the `onOutput` sink, all under the command's lifetime signal.
5
+ */
6
+ export declare function createOutputDrain(options: ParsedNativeCommandOptions, signal: AbortSignal): {
7
+ drain: (stream: AsyncIterable<Uint8Array>, channel: 'stdout' | 'stderr') => Promise<void>;
8
+ /** The captured bytes of each channel; empty unless `capture` was set. */
9
+ captured: () => {
10
+ stdout: Buffer<ArrayBuffer>;
11
+ stderr: Buffer<ArrayBuffer>;
12
+ };
13
+ };
14
+ //# sourceMappingURL=output-drain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output-drain.d.ts","sourceRoot":"","sources":["../../src/process/output-drain.ts"],"names":[],"mappings":"AACA,OAAO,EAAsB,KAAK,0BAA0B,EAAE,MAAM,YAAY,CAAC;AAEjF;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,0BAA0B,EAAE,MAAM,EAAE,WAAW;oBAG3D,aAAa,CAAC,UAAU,CAAC,WAAW,QAAQ,GAAG,QAAQ;IA+BlF,0EAA0E;;QAExE,MAAM;QACN,MAAM;;EAGX"}
@@ -1,3 +1,4 @@
1
+ import type { NativeCommandLaunchedProcess } from './launch.js';
1
2
  /** Only this native spawn can establish group ownership; structural PIDs cannot. */
2
3
  export declare function spawnOwnedCommand(input: {
3
4
  executable: string;
@@ -6,5 +7,13 @@ export declare function spawnOwnedCommand(input: {
6
7
  env?: NodeJS.ProcessEnv;
7
8
  group: boolean;
8
9
  }): import("node:child_process").ChildProcessWithoutNullStreams;
10
+ /** The same ownership rule as {@link spawnOwnedCommand}, for a child that inherits stdio. */
11
+ export declare function spawnInheritedCommand(input: {
12
+ executable: string;
13
+ args: readonly string[];
14
+ cwd?: string;
15
+ env?: NodeJS.ProcessEnv;
16
+ group: boolean;
17
+ }): NativeCommandLaunchedProcess;
9
18
  export declare function ownsCommandGroup(child: object): boolean;
10
19
  //# sourceMappingURL=owned-child.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"owned-child.d.ts","sourceRoot":"","sources":["../../src/process/owned-child.ts"],"names":[],"mappings":"AAIA,oFAAoF;AACpF,wBAAgB,iBAAiB,CAAC,KAAK,EAAE;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACxB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,KAAK,EAAE,OAAO,CAAC;CAChB,+DASA;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEvD"}
1
+ {"version":3,"file":"owned-child.d.ts","sourceRoot":"","sources":["../../src/process/owned-child.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAA+B,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAI1F,oFAAoF;AACpF,wBAAgB,iBAAiB,CAAC,KAAK,EAAE;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACxB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,KAAK,EAAE,OAAO,CAAC;CAChB,+DASA;AAmDD,6FAA6F;AAC7F,wBAAgB,qBAAqB,CAAC,KAAK,EAAE;IAC3C,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACxB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,KAAK,EAAE,OAAO,CAAC;CAChB,GAAG,4BAA4B,CAW/B;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEvD"}
@@ -17,6 +17,8 @@ export declare function signalCommandChild(child: SignalableChild, input: {
17
17
  leaderExit: Promise<unknown>;
18
18
  cleanupTimeoutMs: number;
19
19
  force: boolean;
20
+ /** The child joined the caller's group (`group: 'caller'`): only its leader is stopped. */
21
+ callerGroup?: boolean;
20
22
  }): Promise<boolean>;
21
23
  interface ClosableChild extends SignalableChild {
22
24
  readonly stdin: {
@@ -1 +1 @@
1
- {"version":3,"file":"terminate.d.ts","sourceRoot":"","sources":["../../src/process/terminate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EACL,KAAK,aAAa,EAKnB,MAAM,SAAS,CAAC;AAGjB,mFAAmF;AACnF,UAAU,eAAgB,SAAQ,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AC;IACtC,mFAAmF;IACnF,UAAU,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAC7B,gBAAgB,EAAE,MAAM,CAAC;IACzB,KAAK,EAAE,OAAO,CAAC;IACf,2FAA2F;IAC3F,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,GACA,OAAO,CAAC,OAAO,CAAC,CA0BlB;AAED,UAAU,aAAc,SAAQ,eAAe;IAC7C,QAAQ,CAAC,KAAK,EAAE;QAAE,OAAO,IAAI,OAAO,CAAA;KAAE,CAAC;IACvC,QAAQ,CAAC,MAAM,EAAE;QAAE,OAAO,IAAI,OAAO,CAAA;KAAE,CAAC;IACxC,QAAQ,CAAC,MAAM,EAAE;QAAE,OAAO,IAAI,OAAO,CAAA;KAAE,CAAC;CACzC;AAED;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACvC,KAAK,EAAE,aAAa,EACpB,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,EACxB,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC,IAAI,CAAC,CAcf"}
@@ -7,6 +7,11 @@ export declare function createCommandTransport(child: NativeCommandLaunchedProce
7
7
  kind: "exit";
8
8
  exitCode: number | null;
9
9
  signal: string | null;
10
+ } | {
11
+ kind: "stopped";
12
+ cause: unknown;
13
+ exitCode: number | null;
14
+ signal: string | null;
10
15
  } | {
11
16
  kind: "error";
12
17
  cause: unknown;
@@ -1 +1 @@
1
- {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/process/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,KAAK,EAAE,2BAA2B,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAE1F,6FAA6F;AAC7F,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,4BAA4B;;;;;;;;;;;kBAEvB,MAAM,GAAG,IAAI;gBAAU,MAAM,GAAG,IAAI;;;;;uBA6BhE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI;;;;;yBAkCpB,QAAQ,GAAG,QAAQ,WAAW,MAAM,OAAO;;EAmBnE;AAED,MAAM,MAAM,sBAAsB,GAAG,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC"}
1
+ {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/process/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,KAAK,EAAE,2BAA2B,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAE1F,6FAA6F;AAC7F,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,4BAA4B;;;;;;;;;;;;;;;;kBAEvB,MAAM,GAAG,IAAI;gBAAU,MAAM,GAAG,IAAI;;;;;uBA6BhE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI;;;;;yBAkCpB,QAAQ,GAAG,QAAQ,WAAW,MAAM,OAAO;;EAmBnE;AAED,MAAM,MAAM,sBAAsB,GAAG,UAAU,CAAC,OAAO,sBAAsB,CAAC,CAAC"}
package/llms/process.txt CHANGED
@@ -213,7 +213,9 @@ command the same way, by its `stop` policy:
213
213
  | `graceMs` | How long the leader (or the group) has to leave before the whole group gets KILL. 0 to 3 600 000 (one hour). Required. |
214
214
  | `killOn` | Optional `AbortSignal`. Its abort stops the command with KILL to the whole group at once, also in the middle of a grace. |
215
215
 
216
- Omitting `stop` means `{ target: 'group', signal: 'SIGTERM', graceMs: 100 }`.
216
+ Omitting `stop` means `{ target: 'group', signal: 'SIGTERM', graceMs: 100 }`; a command in the
217
+ caller's group (`group: 'caller'`) stops its leader alone, so its default is `target: 'leader'`
218
+ and a group target is refused (see [Terminal commands](#terminal-commands-inherited-stdio-and-the-callers-group)).
217
219
 
218
220
  ```ts
219
221
  // Cooperative cancellation: the leader rolls its work back, its helpers are not asked.
@@ -268,13 +270,15 @@ so a helper started in the background races the leader:
268
270
 
269
271
  | launched by the leader as | after the leader exits |
270
272
  |---|---|
271
- | `setsid -f helper` (returns once the new session exists) | survives |
273
+ | `setsid -f helper` | usually survives: `setsid -f` forks and returns at once, and the child calls `setsid()` a moment later, so a leader that exits immediately can still catch it in the group (13 of 300 launches under CPU load) |
272
274
  | `setsid helper &`, `(setsid helper &)`, `nohup helper &` | stopped: the leader usually exits before the background job has left the group |
275
+ | a launch the leader waits on until the helper reports it has left the group | survives |
273
276
  | any of these under `descendants: 'leave'` | survives |
274
277
 
275
- Start a daemon so that the session exists before the leader returns (`setsid -f`, or the
276
- daemon's own double fork followed by the leader waiting for it), or declare `'leave'`. Declare
277
- `'leave'` only for a helper that has to outlive the command while staying in its group:
278
+ Start a daemon so that the leader waits for the session to exist before it returns: the helper
279
+ writes its pid, or prints a line, only after its own `setsid()`, and the leader waits for that.
280
+ Or declare `'leave'`. Declare `'leave'` only for a helper that has to outlive the command while
281
+ staying in its group:
278
282
 
279
283
  ```ts
280
284
  await runNativeCommand({
@@ -284,7 +288,8 @@ await runNativeCommand({
284
288
  })
285
289
  ```
286
290
 
287
- A command whose group this package did not create (a structural
291
+ A command in the caller's group (`group: 'caller'`) has no group of its own: `descendants` is
292
+ refused there and nothing is stopped after its leader exits. A command whose group this package did not create (a structural
288
293
  launcher supplied by a host) has no group to stop, and `descendants` has nothing to act on there.
289
294
 
290
295
 
@@ -300,26 +305,68 @@ bounded tar or capture commands get their own explicit limits.
300
305
  A child the caller holds until it exits is the same call. A guardian that forwards its own SIGTERM
301
306
  passes an abort signal and `stop: { target: 'leader', signal: 'SIGTERM', graceMs }`. It records the
302
307
  pid in `onLeaderStarted({ pid })`, which runs once right after the leader exists (a throw stops the
303
- command with that error), reads the exit code and signal in `onLeaderSettled` before the pipes
304
- drain, and reads stderr through `onOutput` or `capture` with `maxOutputBytes`. `drainTimeoutMs`
305
- bounds how long the output pipes may stay open after the leader exited: a holder that left the
306
- group with `setsid` keeps them open, and without the option the command waits for it until
307
- `timeoutMs` or the signal; with it the command ends with `COMMAND_CLEANUP` (a holder inside the
308
- group is already stopped by `descendants`). A worker whose whole group must stop on abort is the
309
- default `target: 'group'`. A child that inherits the caller's terminal is outside this
310
- capability: every command runs in a group of its own, and a background group that reads the
311
- terminal is stopped by the kernel (`SIGTTIN`), so an interactive re-execution stays a plain
312
- spawn in the caller's group. Importing one leaf does not make
308
+ command with that error), and the leader's exit code and signal in `onLeaderSettled`: `'exit'`
309
+ when the leader ended on its own, `'stopped'` with the same fields when the guardian stopped it.
310
+ It reads stderr through `onOutput` or `capture` with `maxOutputBytes`. `drainTimeoutMs` bounds how
311
+ long the output pipes may stay open after the leader exited: a holder that left the group with
312
+ `setsid` keeps them open, and without the option the command waits for it until `timeoutMs` or
313
+ the signal; with it the command ends with `COMMAND_CLEANUP` (a holder inside the group is already
314
+ stopped by `descendants`). A worker whose whole group must stop on abort is the default
315
+ `target: 'group'`. A command that uses the caller's terminal is the next section. Importing one leaf does not make
313
316
  installing the whole npm package smaller; choose a dependency after measuring packed size and its
314
317
  dependency closure.
315
318
 
319
+ ## Terminal commands: inherited stdio and the caller's group
320
+
321
+ An operator CLI that re-runs itself, or any command that prompts or prints in colour, needs the
322
+ caller's terminal itself rather than pipes. Two options give it that:
323
+
324
+ ```ts
325
+ const { exitCode } = await runNativeCommand({
326
+ executable: process.execPath, args: [cliPath, ...argv], envPolicy: 'ambient',
327
+ signal: shutdown.signal,
328
+ stdio: 'inherit', // the command's stdin, stdout and stderr are the caller's: a TTY stays a TTY
329
+ group: 'caller', // it joins the caller's process group, so a Ctrl-C at the terminal reaches it
330
+ })
331
+ process.exitCode = exitCode ?? 1
332
+ ```
333
+
334
+ `stdio: 'inherit'` hands the caller's three descriptors to the command; its bytes never pass
335
+ through this package, so `capture`, `onOutput`, `stdin`, `maxOutputBytes` and `drainTimeoutMs` are
336
+ refused by name with it, and the result's buffers stay empty.
337
+
338
+ `group: 'caller'` keeps the command in the caller's process group instead of a group of its own.
339
+ That is what an interactive command needs: the terminal sends Ctrl-C to its foreground group,
340
+ and a command in a group of its own is a background group there, which the kernel stops
341
+ (`SIGTTIN`) as soon as it reads the terminal. In the caller's group the command has no group of
342
+ its own, so:
343
+
344
+ - a stop signals the leader alone: `stop.target` is `'leader'` (the default here is
345
+ `{ target: 'leader', signal: 'SIGTERM', graceMs: 100 }`), and `target: 'group'` is refused,
346
+ because a group signal would reach the caller;
347
+ - `descendants` does not apply and is refused: what the leader leaves behind belongs to the
348
+ caller's group, and `descendantsStopped` is always `false`;
349
+ - a Ctrl-C reaches the caller too; handle `SIGINT` in the caller when it must outlive the command.
350
+
351
+ The two options are independent: `stdio: 'inherit'` alone keeps colour and `isatty` for a command
352
+ that never reads the terminal, and `group: 'caller'` alone forwards Ctrl-C to a piped command.
353
+
316
354
  ## Resource-scoped launchers and shared owners
317
355
 
318
356
  `onLeaderSettled(event, signal)` observes leader exit before inherited stdout/stderr pipes
319
357
  close. A resource owner can stop its external scope there, allowing pipe drain to complete.
320
- The callback runs once: `event.kind === 'exit'` carries observed `exitCode`/`signal`; a terminal
321
- failure uses `kind: 'error'` and preserves its cause. Unavailable executables, output sink
322
- failure and caller cancellation settle through the same owner. Synchronous native launch
358
+ The callback runs once, with one of three events:
359
+
360
+ | `event.kind` | when | carries |
361
+ |---|---|---|
362
+ | `'exit'` | the leader ended on its own | `exitCode`, `signal` as the kernel reported them |
363
+ | `'stopped'` | the command was stopped (caller abort, `timeoutMs`, output budget, failing sink) and the leader's exit after the stop signals was observed | the stop's `cause`, and the leader's `exitCode` and `signal` (for example `SIGTERM`, or `SIGKILL` once the grace ended) |
364
+ | `'error'` | no exit of the leader was observed: it could not start, or its exit did not arrive within `cleanupTimeoutMs` | the `cause` |
365
+
366
+ A leader that ended on its own settles before the pipes drain; a stopped one settles after the
367
+ stop sequence, once its exit is known. A stop that comes after the leader already exited (a
368
+ deadline while a helper holds the pipe) does not change its `'exit'` event. Unavailable
369
+ executables, output sink failure and caller cancellation settle through the same owner. Synchronous native launch
323
370
  failures such as `E2BIG` also return a rejected result after this bounded settlement;
324
371
  schema-invalid and already-aborted inputs refuse before native ownership and do not invoke
325
372
  the hook. A failing hook preserves both the initial launch error and cleanup cause.
@@ -574,12 +621,12 @@ Native POSIX Bun/Node one-shot command execution. See [native IO](../guide/nativ
574
621
  | Export | Kind | Purpose |
575
622
  |---|---|---|
576
623
  | `runNativeCommand` | function | caller-lifetime streaming or explicitly bounded binary capture |
577
- | `NativeCommandOptions` | type | executable/args, env policy, signal/deadline, bytes sink, finite cleanup limits, the `stop` policy and `descendants` (`'terminate-after-leader'`, the default: stop the group after the leader exits, or `'leave'`); `onLeaderStarted({ pid })` (once, after the leader exists), `drainTimeoutMs` (bound on the pipes staying open after the leader exited, `COMMAND_CLEANUP`); an unknown key is refused by name, a removed one (`killGraceMs`) with its replacement |
624
+ | `NativeCommandOptions` | type | executable/args, env policy, signal/deadline, bytes sink, finite cleanup limits, the `stop` policy and `descendants` (`'terminate-after-leader'`, the default: stop the group after the leader exits, or `'leave'`); `stdio` (`'pipe'`, or `'inherit'` for the caller's descriptors, refusing the pipe-only options) and `group` (`'own'`, or `'caller'`: joins the caller's process group, stops only the leader, refuses `descendants` and a group stop); `onLeaderStarted({ pid })` (once, after the leader exists), `drainTimeoutMs` (bound on the pipes staying open after the leader exited, `COMMAND_CLEANUP`); an unknown key is refused by name, a removed one (`killGraceMs`) with its replacement |
578
625
  | `NativeCommandStopPolicy` | type | how a cancelled command stops: `target` `'group'` (signal every member) or `'leader'` (signal only the leader; its exit ends the grace), `signal` (default `SIGTERM`), `graceMs` (at most one hour) before KILL to the group, and `killOn`, an `AbortSignal` that skips the grace; default `{ target: 'group', signal: 'SIGTERM', graceMs: 100 }` |
579
626
  | `NativeCommandResult` | type | observed nullable exit code/signal, `descendantsStopped` (members left in the group after the leader exited were stopped) and captured stdout/stderr bytes |
580
- | `NativeCommandError` | class | COMMAND_LIMIT with machine reason `deadline` or `output-budget`; COMMAND_UNAVAILABLE / COMMAND_CLEANUP have no limit reason. Preserves internal cause and existing constructor; caller-created limits without supplied reason remain unclassified |
627
+ | `NativeCommandError` | class | COMMAND_LIMIT with machine reason `deadline` or `output-budget`; COMMAND_UNAVAILABLE / COMMAND_CLEANUP have no limit reason; COMMAND_CLEANUP means the command's resources were not proven closed, either past `cleanupTimeoutMs` after a stop or past `drainTimeoutMs` after the leader exited, and `cause` holds that bound's failure. Preserves internal cause and existing constructor; caller-created limits without supplied reason remain unclassified |
581
628
 
582
- | `NativeCommandSettlement` | type | observed leader `exit` or terminal `error`, including synchronous native launch failure; `onLeaderSettled` runs once before drain, bounded by cleanupTimeoutMs, with a cancellable settlement signal; schema/pre-abort refusal creates no settlement obligation |
629
+ | `NativeCommandSettlement` | type | `exit` (the leader ended on its own), `stopped` (the command was stopped and the leader's exit after the stop observed: the stop's `cause` with `exitCode`/`signal`) or `error` (no exit observed), including synchronous native launch failure; `onLeaderSettled` runs once before drain, bounded by cleanupTimeoutMs, with a cancellable settlement signal; schema/pre-abort refusal creates no settlement obligation |
583
630
  | `observeProcessInstance` / `ProcessInstanceObservation` | function / type | Linux/Darwin lifetime observation; observed identity or unavailable with its original cause, never guessed absence |
584
631
  | `ProcessInstanceSchema` / `ProcessInstance` | schema / type | platform, boot ID, namespace and process start identity from the shared native reader |
585
632
  | `probeProcessOwner` / `ProcessOwnerEvidence` | function / type | compare lifetimes on one caller-established machine; matched, boot change, reused PID, gone, legacy or unavailable with cause |
@@ -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 50 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 51 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, plus the managed-resource conformance kit |
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 50 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 51 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 50 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 51 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 |
@@ -1,14 +1,36 @@
1
- # Upgrading 0.37.0 → 0.50.0 — stitchkit docs slice
1
+ # Upgrading 0.37.0 → 0.53.0 — stitchkit docs slice
2
2
 
3
3
  > Generated from the `docs/` tree by `bun run gen:llms`. The index of all slices is
4
4
  > `llms.txt` in this package.
5
5
 
6
- Contains: Guide: Upgrading, 0.37.0 → 0.50.0 (docs/guide/upgrading.md)
6
+ Contains: Guide: Upgrading, 0.37.0 → 0.53.0 (docs/guide/upgrading.md)
7
7
 
8
8
  ==============================================================================
9
- # Guide: Upgrading, 0.37.0 → 0.50.0 (docs/guide/upgrading.md)
9
+ # Guide: Upgrading, 0.37.0 → 0.53.0 (docs/guide/upgrading.md)
10
10
  ==============================================================================
11
11
 
12
+ ## Released migration: 0.53.0
13
+
14
+ ### Realtime `emit` returns `boolean` instead of `void`
15
+
16
+ Every **call site** compiles and behaves exactly as before — the return value
17
+ is new information (`true` = accepted by the transport, `false` = dropped
18
+ while the browser client was disconnected), not a behavior change. What breaks
19
+ is **implementing** the interfaces: a test mock or app-side adapter of
20
+ `SocketIOClient` / `RealtimeClient` / `ValidatedRealtimeSocket` /
21
+ `RealtimeServer` whose `emit` returns `void` no longer typechecks.
22
+
23
+ ```ts
24
+ // before — a void mock satisfied the interface
25
+ const mock: Pick<RealtimeClient<S, C>, 'emit'> = { emit: () => {} }
26
+ // after — report acceptance (true is what a live server-side emit reports)
27
+ const mock: Pick<RealtimeClient<S, C>, 'emit'> = { emit: () => true }
28
+ ```
29
+
30
+ While migrating, consider replacing hand-rolled `if (client.connected)` guards
31
+ with the new honest surface: check `client.emit(...) === false`, or observe
32
+ drops centrally with `onDroppedEmit`.
33
+
12
34
  ## Released migration: 0.50.0
13
35
 
14
36
  ### The factory's scope union now covers per-endpoint overrides
@@ -1,14 +1,64 @@
1
- # Upgrading 0.53.0 → 0.67.0 — stitchkit docs slice
1
+ # Upgrading 0.55.0 → 0.68.0 — stitchkit docs slice
2
2
 
3
3
  > Generated from the `docs/` tree by `bun run gen:llms`. The index of all slices is
4
4
  > `llms.txt` in this package.
5
5
 
6
- Contains: Guide: Upgrading, 0.53.0 → 0.67.0 (docs/guide/upgrading.md)
6
+ Contains: Guide: Upgrading, 0.55.0 → 0.68.0 (docs/guide/upgrading.md)
7
7
 
8
8
  ==============================================================================
9
- # Guide: Upgrading, 0.53.0 → 0.67.0 (docs/guide/upgrading.md)
9
+ # Guide: Upgrading, 0.55.0 → 0.68.0 (docs/guide/upgrading.md)
10
10
  ==============================================================================
11
11
 
12
+ ## Released migration: 0.68.0
13
+
14
+ ### Make Unix transport selection explicit outside Bun
15
+
16
+ The legacy `unix` option remains a Bun convenience, but on Node or another
17
+ runtime it now fails before dispatch. Replace it with the owned adapter and close
18
+ that adapter with the application:
19
+
20
+ ```ts
21
+ // before — unsafe outside Bun: an unsupported fetch could dial baseUrl over TCP
22
+ const http = createHttpClient({ baseUrl, unix: '/run/service.sock' })
23
+
24
+ // after — Bun and Node; every dispatch and redirect stays on the socket
25
+ import { createUnixClientTransport } from 'stitchkit/server' // or stitchkit/node
26
+ const transport = createUnixClientTransport({ socketPath: '/run/service.sock' })
27
+ const http = createHttpClient({ baseUrl, fetch: transport.fetch })
28
+ // during shutdown
29
+ await transport.close()
30
+ ```
31
+
32
+ Do not automatically replay `possibly-dispatched`: a timeout or connection loss
33
+ after bytes left the process does not prove that a write did not happen.
34
+
35
+ ### Choose tolerant stream parsing explicitly
36
+
37
+ `parseNDJSON` and `parseSSE` now throw on malformed JSON, invalid UTF-8 and an
38
+ over-limit line. The default line ceiling is 1 MiB. If a feed deliberately skips
39
+ bad records, retain that policy explicitly:
40
+
41
+ ```ts
42
+ // before — malformed input disappeared implicitly
43
+ parseNDJSON(response)
44
+
45
+ // after — ordinary fail-closed path
46
+ parseNDJSON(response, { maxLineBytes: 256 * 1024 })
47
+
48
+ // after — deliberately tolerant path
49
+ parseNDJSON(response, { onParseError: (raw, error) => report(raw, error) })
50
+ ```
51
+
52
+ ### Extend exhaustive framework-error handling
53
+
54
+ If a switch makes `StitchErrorCode` exhaustive, add
55
+ `STREAM_ITEM_INVALID`, `STREAM_FRAME_TOO_LARGE`,
56
+ `STREAM_TERMINAL_MISSING` and `STREAM_LIFETIME_EXCEEDED`. A partial application
57
+ status map needs no change (ADR 0105).
58
+
59
+ The admission/channel APIs and endpoint `stream` descriptor are additive; raw
60
+ responses and raw `streamingRoute` remain supported.
61
+
12
62
  ## Released migration: 0.67.0
13
63
 
14
64
  Three application-kernel changes. Two of them fix silent failures, so the most
@@ -1150,25 +1200,3 @@ Downloaded `path` is now relative to the boundary and MIME metadata is named
1150
1200
  same way. Auth predicates must explicitly return `true`, `false`, or a plain
1151
1201
  object of context fields; replace accidental `undefined` fallthroughs with the
1152
1202
  intended boolean.
1153
-
1154
- ## Released migration: 0.53.0
1155
-
1156
- ### Realtime `emit` returns `boolean` instead of `void`
1157
-
1158
- Every **call site** compiles and behaves exactly as before — the return value
1159
- is new information (`true` = accepted by the transport, `false` = dropped
1160
- while the browser client was disconnected), not a behavior change. What breaks
1161
- is **implementing** the interfaces: a test mock or app-side adapter of
1162
- `SocketIOClient` / `RealtimeClient` / `ValidatedRealtimeSocket` /
1163
- `RealtimeServer` whose `emit` returns `void` no longer typechecks.
1164
-
1165
- ```ts
1166
- // before — a void mock satisfied the interface
1167
- const mock: Pick<RealtimeClient<S, C>, 'emit'> = { emit: () => {} }
1168
- // after — report acceptance (true is what a live server-side emit reports)
1169
- const mock: Pick<RealtimeClient<S, C>, 'emit'> = { emit: () => true }
1170
- ```
1171
-
1172
- While migrating, consider replacing hand-rolled `if (client.connected)` guards
1173
- with the new honest surface: check `client.emit(...) === false`, or observe
1174
- drops centrally with `onDroppedEmit`.