stitchkit 0.103.9 → 0.103.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/dist/agent-runtime/coding-shell-process.d.ts.map +1 -1
- package/dist/agent-runtime/sandbox-process-owner.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/coding-tools.js +2 -1
- package/dist/entrypoints/agent-runtime/sandbox.js +28 -14
- package/dist/entrypoints/application/diagnostic-journal.js +2 -1
- package/dist/entrypoints/files.js +14 -4
- package/dist/entrypoints/process.d.ts +2 -1
- package/dist/entrypoints/process.d.ts.map +1 -1
- package/dist/entrypoints/process.js +9 -2
- package/dist/index-32jkwkdm.js +565 -0
- package/dist/{index-a4ajxwmb.js → index-g4jxe7ve.js} +113 -131
- package/dist/index-nybn2err.js +213 -0
- package/dist/index-ttf0y7b8.js +246 -0
- package/dist/internal/exclusive-lock-read.d.ts +20 -0
- package/dist/internal/exclusive-lock-read.d.ts.map +1 -0
- package/dist/internal/exclusive-lock.d.ts +3 -1
- package/dist/internal/exclusive-lock.d.ts.map +1 -1
- package/dist/internal/process-instance.d.ts +46 -9
- package/dist/internal/process-instance.d.ts.map +1 -1
- package/dist/internal/with-exclusive-lock.d.ts +4 -3
- package/dist/internal/with-exclusive-lock.d.ts.map +1 -1
- package/dist/process/command-owner.d.ts +7 -2
- package/dist/process/command-owner.d.ts.map +1 -1
- package/dist/process/contract.d.ts +22 -1
- package/dist/process/contract.d.ts.map +1 -1
- package/dist/process/group.d.ts +6 -1
- package/dist/process/group.d.ts.map +1 -1
- package/dist/process/launch.d.ts +65 -0
- package/dist/process/launch.d.ts.map +1 -0
- package/dist/process/leader-settlement.d.ts +6 -0
- package/dist/process/leader-settlement.d.ts.map +1 -0
- package/dist/process/start-failure.d.ts +7 -0
- package/dist/process/start-failure.d.ts.map +1 -0
- package/llms/agent-runtime.txt +7 -1
- package/llms/files.txt +1 -1
- package/llms/process.txt +115 -2
- package/llms-full.txt +123 -4
- package/llms.txt +3 -3
- package/native/darwin-arm64.node +0 -0
- package/native/darwin-x64.node +0 -0
- package/package.json +2 -2
- package/dist/index-7kxw1awn.js +0 -328
- package/dist/index-eeqmg7qm.js +0 -202
package/llms/files.txt
CHANGED
|
@@ -30,7 +30,7 @@ available from `stitchkit/contract`.
|
|
|
30
30
|
| `ManagedFileInspector` | _type_ | bounded-prefix read/write inspection callback with a finite cancellation signal that cannot own path or size |
|
|
31
31
|
| `ManagedFileInspectionInput` / `ManagedFileInspection` | _type_ | inspector prefix/name/declared media/signal input and validated metadata-only result |
|
|
32
32
|
| `writeFileAtomic` / `writeFileAtomicSync` / `WriteFileAtomicOptions` | function / _type_ | replace a file atomically: a random staging name created exclusively (never through a planted link), the mode set on the descriptor before the file is visible (default `0o600`, not masked by the umask), `fsync`, rename; a failure leaves the target and no staging file. The asynchronous form keeps the event loop running |
|
|
33
|
-
| `withExclusiveLock` / `ExclusiveLockOptions` / `ExclusiveLock` / `ExclusiveLockOwner` | function / _type_ | run work under an exclusive lock between processes — a file recording its owner (pid, host, machine identity, time and nullable kernel process identity); waits up to `timeoutMs` (default 10 s) and stops on `signal`; a dead owner on this machine is taken over, a live, slow or foreign one never is; an ownerless lock only after `ownerlessGraceMs` |
|
|
33
|
+
| `withExclusiveLock` / `ExclusiveLockOptions` / `ExclusiveLock` / `ExclusiveLockOwner` | function / _type_ | run work under an exclusive lock between processes — a file recording its owner (pid, host, machine identity, time and nullable kernel process identity); waits up to `timeoutMs` (default 10 s) and stops on `signal`; a dead owner on this machine is taken over, a live, slow or foreign one never is; an ownerless lock only after `ownerlessGraceMs` (default 5000 ms, `null` disables age-based reclaim including guards); exact `mode` is independent of umask; shared readers need a common group and traversable directories |
|
|
34
34
|
| `ExclusiveLockError` | class | `LOCK_TIMEOUT` naming the resource and its holder, or `LOCK_ABORTED` with the signal's reason |
|
|
35
35
|
| `createChunkSpool` | function | the server half of a chunked upload: parts on disk under `owner` + client-minted `uploadId`, each with a size+sha256 receipt; idempotent `open` and `put`, the first writer of a part wins across processes, `assemble` in order once every part is in, `sweep` of untouched uploads — [guide](../guide/client.md#chunked-uploads) |
|
|
36
36
|
| `ChunkSpool` / `ChunkSpoolConfig` / `ChunkSpoolKey` / `ChunkSpoolOpen` / `ChunkSpoolPart` / `ChunkSpoolAssembly` | _type_ | the spool, its directory, part size, file limit, meta schema and age; an upload's key; its declaration; one part; the assembled parts with a concatenating `stream()` |
|
package/llms/process.txt
CHANGED
|
@@ -15,12 +15,16 @@ description: Native IO для Bun и Node, с явно выбранной durabi
|
|
|
15
15
|
type: guide
|
|
16
16
|
status: active
|
|
17
17
|
created: 2026-10-01 20:44 +07:00
|
|
18
|
-
updated: 2026-10-
|
|
18
|
+
updated: 2026-10-02 16:28 +07:00
|
|
19
19
|
participants:
|
|
20
20
|
- role: authored
|
|
21
21
|
harness: Codex
|
|
22
22
|
model: GPT-6
|
|
23
23
|
at: 2026-10-01 20:44 +07:00
|
|
24
|
+
- role: implemented
|
|
25
|
+
harness: Codex
|
|
26
|
+
model: GPT-6
|
|
27
|
+
at: 2026-10-02 00:08 +07:00
|
|
24
28
|
---
|
|
25
29
|
|
|
26
30
|
# Native IO
|
|
@@ -127,6 +131,32 @@ await runNativeCommand({
|
|
|
127
131
|
означает пустой environment; `ambient` явно разрешает наследование. Cwd/executable policy остаётся
|
|
128
132
|
приложению; этот primitive запускает native executable и сам не создаёт shell.
|
|
129
133
|
|
|
134
|
+
Машинная классификация limit error использует `NativeCommandError.reason`: `deadline` при
|
|
135
|
+
истечении собственного `timeoutMs`, `output-budget` при превышении суммарных bytes stdout+stderr
|
|
136
|
+
в capture или streaming. Оба случая сохраняют `code: 'COMMAND_LIMIT'`; `message` служит
|
|
137
|
+
диагностике, не протоколу. У `COMMAND_UNAVAILABLE` и `COMMAND_CLEANUP` reason отсутствует;
|
|
138
|
+
caller abort и sink failure сохраняют исходную ошибку. При cleanup failure первоначальный
|
|
139
|
+
limit вместе с reason остаётся внутри `AggregateError` cause.
|
|
140
|
+
|
|
141
|
+
```ts
|
|
142
|
+
import { NativeCommandError } from 'stitchkit/process'
|
|
143
|
+
|
|
144
|
+
try {
|
|
145
|
+
await runNativeCommand({ executable: '/usr/bin/git', args: ['status'], timeoutMs: 5000 })
|
|
146
|
+
} catch (error) {
|
|
147
|
+
if (error instanceof NativeCommandError && error.code === 'COMMAND_LIMIT') {
|
|
148
|
+
if (error.reason === 'deadline') console.error('Command timed out')
|
|
149
|
+
if (error.reason === 'output-budget') console.error('Command produced too many bytes')
|
|
150
|
+
}
|
|
151
|
+
throw error
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Конструктор сохраняет вызов `new NativeCommandError(code, message, { cause })` и принимает
|
|
156
|
+
`{ cause, reason: 'deadline' | 'output-budget' }` только для `COMMAND_LIMIT`. Owner всегда
|
|
157
|
+
заполняет reason для собственных limits. Созданная вызывающей стороной ошибка без reason
|
|
158
|
+
не получает выдуманную причину из текста; её reason остаётся `undefined`.
|
|
159
|
+
|
|
130
160
|
Вывод читается с backpressure отдельно для stdout/stderr: один выполняющийся sink на канал плюс
|
|
131
161
|
bounded native Readable buffer; накопления всей истории при streaming нет. Callback получает
|
|
132
162
|
lifetime signal. Abort освобождает ожидание даже игнорирующего signal callback, но не способен
|
|
@@ -136,6 +166,10 @@ callbacks owner не запускает. Normal completion ждёт всех byt
|
|
|
136
166
|
|
|
137
167
|
Cleanup: POSIX process group, TERM, `killGraceMs` (default 100, maximum 10 000), затем KILL;
|
|
138
168
|
`cleanupTimeoutMs` (default 2000, maximum 30 000) ограничивает ожидание close после сигналов.
|
|
169
|
+
На Darwin временный `EPERM` при сигнале группе может означать zombies, ещё не убранные
|
|
170
|
+
OS reaper. Повтор ограничен `cleanupTimeoutMs`; успех требует доставленного сигнала или
|
|
171
|
+
`ESRCH`, постоянный отказ сохраняется в cause. Закрытие каждого owned pipe и выход leader
|
|
172
|
+
наблюдаются отдельно, включая отсутствие общего `child.close` при teardown.
|
|
139
173
|
Сохраняется caller/sink причина; failure cleanup — `NativeCommandError` с `COMMAND_CLEANUP` и
|
|
140
174
|
AggregateError cause. Даже вышедший parent не исключает helper, удерживающий pipe. Windows
|
|
141
175
|
отказывает с `COMMAND_UNAVAILABLE`; потомок, самостоятельно покинувший группу через setsid,
|
|
@@ -150,6 +184,80 @@ shell policy, command admission, логирование, redaction, bytes→text
|
|
|
150
184
|
Длительные signal-only команды остаются streaming; bounded tar/capture получают свои явные limits.
|
|
151
185
|
Импорт leaf не делает установку всего npm package маленькой; выбирайте dependency после измерения
|
|
152
186
|
packed размера и dependency closure.
|
|
187
|
+
## Resource-scoped launchers and shared owners
|
|
188
|
+
|
|
189
|
+
`onLeaderSettled(event, signal)` observes leader exit before inherited stdout/stderr pipes
|
|
190
|
+
close. A resource owner can stop its external scope there, allowing pipe drain to complete.
|
|
191
|
+
The callback runs once: `event.kind === 'exit'` carries observed `exitCode`/`signal`; a terminal
|
|
192
|
+
failure uses `kind: 'error'` and preserves its cause. Unavailable executables, output sink
|
|
193
|
+
failure and caller cancellation settle through the same owner. Synchronous native launch
|
|
194
|
+
failures such as `E2BIG` also return a rejected result after this bounded settlement;
|
|
195
|
+
schema-invalid and already-aborted inputs refuse before native ownership and do not invoke
|
|
196
|
+
the hook. A failing hook preserves both the initial launch error and cleanup cause.
|
|
197
|
+
`cleanupTimeoutMs` bounds
|
|
198
|
+
the callback after settlement starts; it never becomes a deadline for signal-only execution.
|
|
199
|
+
Honor the settlement signal; arbitrary user promises cannot be forcibly cancelled.
|
|
200
|
+
|
|
201
|
+
```ts
|
|
202
|
+
await runNativeCommand({
|
|
203
|
+
executable: launcher,
|
|
204
|
+
args,
|
|
205
|
+
signal: scope.signal,
|
|
206
|
+
onOutput: (bytes, channel, signal) => scope.write(bytes, channel, signal),
|
|
207
|
+
onLeaderSettled: (event, signal) => scope.settle(event, signal),
|
|
208
|
+
});
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
`observeProcessInstance(pid)` returns `observed` with a `ProcessInstance`, or `unavailable`
|
|
212
|
+
with its cause. `probeProcessOwner(pid, recorded)` compares that evidence on the machine the
|
|
213
|
+
caller established: `matched`, `different-boot`, `reused-pid`, `pid-gone`, `legacy` or
|
|
214
|
+
`unavailable`. Missing/partial/denied evidence is not death. Supervisor tree fencing remains
|
|
215
|
+
the caller's job; a PID lifetime is not proof that its whole workload stopped.
|
|
216
|
+
|
|
217
|
+
Exclusive acquisition checks cancellation again before invoking the protected callback;
|
|
218
|
+
an aborted acquisition releases its newly owned lock without starting the callback.
|
|
219
|
+
Existing lock and reclaim-guard records are opened with nonblocking/no-follow flags,
|
|
220
|
+
must be regular files with one link, and are capped at 16 KiB. Descriptor metadata must
|
|
221
|
+
remain stable during the read. Unsafe records are not evidence of absence or permission
|
|
222
|
+
to reclaim. This bounds local record reads; it does not make a hung remote-filesystem
|
|
223
|
+
syscall interruptible or provide a snapshot against a hostile writer.
|
|
224
|
+
|
|
225
|
+
An exclusive lock applies exact requested permissions through its creating descriptor,
|
|
226
|
+
independent of umask. Default `0600` stays private. Shared `0640` requires a common group and
|
|
227
|
+
traversable directories; another UID also needs directory write permission to reclaim a
|
|
228
|
+
proven-dead owner's file. Set `ownerlessGraceMs: null` to refuse every age-only reclaim,
|
|
229
|
+
including ownerless reclaim guards. The default remains 5000 ms for existing clients.
|
|
230
|
+
Восстановление stale reclaim guard использует тот же lock owner и следующий guard:
|
|
231
|
+
проверка inode и удаление выполняются под ним. Конкурирующий writer не обходит guard,
|
|
232
|
+
пока прежнее удаление приостановлено; live и unknown lifetime evidence остаются отказом.
|
|
233
|
+
|
|
234
|
+
## Libraries with a Zod-only runtime
|
|
235
|
+
|
|
236
|
+
Public leaves keep optional peers out of their import closure. Installing `stitchkit` still
|
|
237
|
+
installs the complete package and ky; selective imports alone do not avoid that installation.
|
|
238
|
+
A library can use Stitchkit as a build dependency, bundle its selected public native imports,
|
|
239
|
+
keep Zod external, and publish the resulting implementation with its library artifact.
|
|
240
|
+
|
|
241
|
+
```ts
|
|
242
|
+
// The library's build entry; all mechanisms remain owned by Stitchkit.
|
|
243
|
+
export { canonicalJson } from 'stitchkit/primitives';
|
|
244
|
+
export { writeFileAtomic, withExclusiveLock } from 'stitchkit/files';
|
|
245
|
+
export { observeProcessInstance, probeProcessOwner, runNativeCommand } from 'stitchkit/process';
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
Bundle for Node-compatible execution with Zod external. Publish declarations from the same
|
|
249
|
+
version: carry their reachable relative `.d.ts` closure, rather than emitting references to
|
|
250
|
+
`stitchkit` that force clients to install it for types. A library exposing its own DTOs may
|
|
251
|
+
instead emit declarations for only that DTO contract. Keep the library's manifest at runtime
|
|
252
|
+
`dependencies: {}` and `peerDependencies: { zod: ... }` when that is its declared promise.
|
|
253
|
+
|
|
254
|
+
Darwin consumers need the published native binaries at the bundled loader's relative native
|
|
255
|
+
directory. A JS-only bundle is not portable evidence. Qualify the packed library outside its
|
|
256
|
+
build tree in Bun and Node, test its declarations, and check that importing an unbundled
|
|
257
|
+
Stitchkit leaf fails there. A separate schema-only entry must not import the native entry.
|
|
258
|
+
|
|
259
|
+
This delivery removes a runtime kernel installation; it does not remove the build-time
|
|
260
|
+
Stitchkit installation or create an independent lightweight npm package.
|
|
153
261
|
|
|
154
262
|
==============================================================================
|
|
155
263
|
# API reference: `stitchkit/process` (docs/api/reference.md)
|
|
@@ -164,4 +272,9 @@ Native POSIX Bun/Node one-shot command execution. See [native IO](../guide/nativ
|
|
|
164
272
|
| `runNativeCommand` | function | caller-lifetime streaming or explicitly bounded binary capture |
|
|
165
273
|
| `NativeCommandOptions` | type | executable/args, env policy, signal/deadline, bytes sink and finite cleanup limits |
|
|
166
274
|
| `NativeCommandResult` | type | observed nullable exit code/signal and captured stdout/stderr bytes |
|
|
167
|
-
| `NativeCommandError` | class | COMMAND_LIMIT
|
|
275
|
+
| `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 |
|
|
276
|
+
|
|
277
|
+
| `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 |
|
|
278
|
+
| `observeProcessInstance` / `ProcessInstanceObservation` | function / type | Linux/Darwin lifetime observation; observed identity or unavailable with its original cause, never guessed absence |
|
|
279
|
+
| `ProcessInstanceSchema` / `ProcessInstance` | schema / type | platform, boot ID, namespace and process start identity from the shared native reader |
|
|
280
|
+
| `probeProcessOwner` / `ProcessOwnerEvidence` | function / type | compare lifetimes on one caller-established machine; matched, boot change, reused PID, gone, legacy or unavailable with cause |
|
package/llms-full.txt
CHANGED
|
@@ -5119,7 +5119,7 @@ description: Configure Stitchkit's optional durable history, stream loop, run co
|
|
|
5119
5119
|
type: architecture
|
|
5120
5120
|
status: active
|
|
5121
5121
|
created: 2026-08-22
|
|
5122
|
-
updated: 2026-
|
|
5122
|
+
updated: 2026-10-02 16:28 +07:00
|
|
5123
5123
|
---
|
|
5124
5124
|
|
|
5125
5125
|
# Agent application runtime
|
|
@@ -5476,6 +5476,12 @@ second host executable, so Windows kills the direct child, destroys retained pip
|
|
|
5476
5476
|
deadline and makes no descendant-cleanup claim. A signal already aborted before execution returns
|
|
5477
5477
|
`cancelled` without spawning.
|
|
5478
5478
|
|
|
5479
|
+
Coding commands compose the shared native execution owner. Artifact retention and UTF-8
|
|
5480
|
+
previews remain coding-tool policy; normal leader exit still forcibly stops remaining POSIX
|
|
5481
|
+
group members before draining. A structural sandbox launcher uses the same settlement owner
|
|
5482
|
+
with a finite output queue. Sandbox shutdown waits for actual owned completion and surfaces
|
|
5483
|
+
cleanup refusal rather than treating it as successful teardown.
|
|
5484
|
+
|
|
5479
5485
|
One `createAgentHarnessFileResources` instance represents one immutable discovery generation:
|
|
5480
5486
|
concurrent and repeated `load()` calls share it, so a direct resource read cannot cross into a
|
|
5481
5487
|
new catalog unexpectedly. Discovery uses the same descriptor-anchored traversal as coding search;
|
|
@@ -8031,12 +8037,16 @@ description: Native IO для Bun и Node, с явно выбранной durabi
|
|
|
8031
8037
|
type: guide
|
|
8032
8038
|
status: active
|
|
8033
8039
|
created: 2026-10-01 20:44 +07:00
|
|
8034
|
-
updated: 2026-10-
|
|
8040
|
+
updated: 2026-10-02 16:28 +07:00
|
|
8035
8041
|
participants:
|
|
8036
8042
|
- role: authored
|
|
8037
8043
|
harness: Codex
|
|
8038
8044
|
model: GPT-6
|
|
8039
8045
|
at: 2026-10-01 20:44 +07:00
|
|
8046
|
+
- role: implemented
|
|
8047
|
+
harness: Codex
|
|
8048
|
+
model: GPT-6
|
|
8049
|
+
at: 2026-10-02 00:08 +07:00
|
|
8040
8050
|
---
|
|
8041
8051
|
|
|
8042
8052
|
# Native IO
|
|
@@ -8143,6 +8153,32 @@ await runNativeCommand({
|
|
|
8143
8153
|
означает пустой environment; `ambient` явно разрешает наследование. Cwd/executable policy остаётся
|
|
8144
8154
|
приложению; этот primitive запускает native executable и сам не создаёт shell.
|
|
8145
8155
|
|
|
8156
|
+
Машинная классификация limit error использует `NativeCommandError.reason`: `deadline` при
|
|
8157
|
+
истечении собственного `timeoutMs`, `output-budget` при превышении суммарных bytes stdout+stderr
|
|
8158
|
+
в capture или streaming. Оба случая сохраняют `code: 'COMMAND_LIMIT'`; `message` служит
|
|
8159
|
+
диагностике, не протоколу. У `COMMAND_UNAVAILABLE` и `COMMAND_CLEANUP` reason отсутствует;
|
|
8160
|
+
caller abort и sink failure сохраняют исходную ошибку. При cleanup failure первоначальный
|
|
8161
|
+
limit вместе с reason остаётся внутри `AggregateError` cause.
|
|
8162
|
+
|
|
8163
|
+
```ts
|
|
8164
|
+
import { NativeCommandError } from 'stitchkit/process'
|
|
8165
|
+
|
|
8166
|
+
try {
|
|
8167
|
+
await runNativeCommand({ executable: '/usr/bin/git', args: ['status'], timeoutMs: 5000 })
|
|
8168
|
+
} catch (error) {
|
|
8169
|
+
if (error instanceof NativeCommandError && error.code === 'COMMAND_LIMIT') {
|
|
8170
|
+
if (error.reason === 'deadline') console.error('Command timed out')
|
|
8171
|
+
if (error.reason === 'output-budget') console.error('Command produced too many bytes')
|
|
8172
|
+
}
|
|
8173
|
+
throw error
|
|
8174
|
+
}
|
|
8175
|
+
```
|
|
8176
|
+
|
|
8177
|
+
Конструктор сохраняет вызов `new NativeCommandError(code, message, { cause })` и принимает
|
|
8178
|
+
`{ cause, reason: 'deadline' | 'output-budget' }` только для `COMMAND_LIMIT`. Owner всегда
|
|
8179
|
+
заполняет reason для собственных limits. Созданная вызывающей стороной ошибка без reason
|
|
8180
|
+
не получает выдуманную причину из текста; её reason остаётся `undefined`.
|
|
8181
|
+
|
|
8146
8182
|
Вывод читается с backpressure отдельно для stdout/stderr: один выполняющийся sink на канал плюс
|
|
8147
8183
|
bounded native Readable buffer; накопления всей истории при streaming нет. Callback получает
|
|
8148
8184
|
lifetime signal. Abort освобождает ожидание даже игнорирующего signal callback, но не способен
|
|
@@ -8152,6 +8188,10 @@ callbacks owner не запускает. Normal completion ждёт всех byt
|
|
|
8152
8188
|
|
|
8153
8189
|
Cleanup: POSIX process group, TERM, `killGraceMs` (default 100, maximum 10 000), затем KILL;
|
|
8154
8190
|
`cleanupTimeoutMs` (default 2000, maximum 30 000) ограничивает ожидание close после сигналов.
|
|
8191
|
+
На Darwin временный `EPERM` при сигнале группе может означать zombies, ещё не убранные
|
|
8192
|
+
OS reaper. Повтор ограничен `cleanupTimeoutMs`; успех требует доставленного сигнала или
|
|
8193
|
+
`ESRCH`, постоянный отказ сохраняется в cause. Закрытие каждого owned pipe и выход leader
|
|
8194
|
+
наблюдаются отдельно, включая отсутствие общего `child.close` при teardown.
|
|
8155
8195
|
Сохраняется caller/sink причина; failure cleanup — `NativeCommandError` с `COMMAND_CLEANUP` и
|
|
8156
8196
|
AggregateError cause. Даже вышедший parent не исключает helper, удерживающий pipe. Windows
|
|
8157
8197
|
отказывает с `COMMAND_UNAVAILABLE`; потомок, самостоятельно покинувший группу через setsid,
|
|
@@ -8166,6 +8206,80 @@ shell policy, command admission, логирование, redaction, bytes→text
|
|
|
8166
8206
|
Длительные signal-only команды остаются streaming; bounded tar/capture получают свои явные limits.
|
|
8167
8207
|
Импорт leaf не делает установку всего npm package маленькой; выбирайте dependency после измерения
|
|
8168
8208
|
packed размера и dependency closure.
|
|
8209
|
+
## Resource-scoped launchers and shared owners
|
|
8210
|
+
|
|
8211
|
+
`onLeaderSettled(event, signal)` observes leader exit before inherited stdout/stderr pipes
|
|
8212
|
+
close. A resource owner can stop its external scope there, allowing pipe drain to complete.
|
|
8213
|
+
The callback runs once: `event.kind === 'exit'` carries observed `exitCode`/`signal`; a terminal
|
|
8214
|
+
failure uses `kind: 'error'` and preserves its cause. Unavailable executables, output sink
|
|
8215
|
+
failure and caller cancellation settle through the same owner. Synchronous native launch
|
|
8216
|
+
failures such as `E2BIG` also return a rejected result after this bounded settlement;
|
|
8217
|
+
schema-invalid and already-aborted inputs refuse before native ownership and do not invoke
|
|
8218
|
+
the hook. A failing hook preserves both the initial launch error and cleanup cause.
|
|
8219
|
+
`cleanupTimeoutMs` bounds
|
|
8220
|
+
the callback after settlement starts; it never becomes a deadline for signal-only execution.
|
|
8221
|
+
Honor the settlement signal; arbitrary user promises cannot be forcibly cancelled.
|
|
8222
|
+
|
|
8223
|
+
```ts
|
|
8224
|
+
await runNativeCommand({
|
|
8225
|
+
executable: launcher,
|
|
8226
|
+
args,
|
|
8227
|
+
signal: scope.signal,
|
|
8228
|
+
onOutput: (bytes, channel, signal) => scope.write(bytes, channel, signal),
|
|
8229
|
+
onLeaderSettled: (event, signal) => scope.settle(event, signal),
|
|
8230
|
+
});
|
|
8231
|
+
```
|
|
8232
|
+
|
|
8233
|
+
`observeProcessInstance(pid)` returns `observed` with a `ProcessInstance`, or `unavailable`
|
|
8234
|
+
with its cause. `probeProcessOwner(pid, recorded)` compares that evidence on the machine the
|
|
8235
|
+
caller established: `matched`, `different-boot`, `reused-pid`, `pid-gone`, `legacy` or
|
|
8236
|
+
`unavailable`. Missing/partial/denied evidence is not death. Supervisor tree fencing remains
|
|
8237
|
+
the caller's job; a PID lifetime is not proof that its whole workload stopped.
|
|
8238
|
+
|
|
8239
|
+
Exclusive acquisition checks cancellation again before invoking the protected callback;
|
|
8240
|
+
an aborted acquisition releases its newly owned lock without starting the callback.
|
|
8241
|
+
Existing lock and reclaim-guard records are opened with nonblocking/no-follow flags,
|
|
8242
|
+
must be regular files with one link, and are capped at 16 KiB. Descriptor metadata must
|
|
8243
|
+
remain stable during the read. Unsafe records are not evidence of absence or permission
|
|
8244
|
+
to reclaim. This bounds local record reads; it does not make a hung remote-filesystem
|
|
8245
|
+
syscall interruptible or provide a snapshot against a hostile writer.
|
|
8246
|
+
|
|
8247
|
+
An exclusive lock applies exact requested permissions through its creating descriptor,
|
|
8248
|
+
independent of umask. Default `0600` stays private. Shared `0640` requires a common group and
|
|
8249
|
+
traversable directories; another UID also needs directory write permission to reclaim a
|
|
8250
|
+
proven-dead owner's file. Set `ownerlessGraceMs: null` to refuse every age-only reclaim,
|
|
8251
|
+
including ownerless reclaim guards. The default remains 5000 ms for existing clients.
|
|
8252
|
+
Восстановление stale reclaim guard использует тот же lock owner и следующий guard:
|
|
8253
|
+
проверка inode и удаление выполняются под ним. Конкурирующий writer не обходит guard,
|
|
8254
|
+
пока прежнее удаление приостановлено; live и unknown lifetime evidence остаются отказом.
|
|
8255
|
+
|
|
8256
|
+
## Libraries with a Zod-only runtime
|
|
8257
|
+
|
|
8258
|
+
Public leaves keep optional peers out of their import closure. Installing `stitchkit` still
|
|
8259
|
+
installs the complete package and ky; selective imports alone do not avoid that installation.
|
|
8260
|
+
A library can use Stitchkit as a build dependency, bundle its selected public native imports,
|
|
8261
|
+
keep Zod external, and publish the resulting implementation with its library artifact.
|
|
8262
|
+
|
|
8263
|
+
```ts
|
|
8264
|
+
// The library's build entry; all mechanisms remain owned by Stitchkit.
|
|
8265
|
+
export { canonicalJson } from 'stitchkit/primitives';
|
|
8266
|
+
export { writeFileAtomic, withExclusiveLock } from 'stitchkit/files';
|
|
8267
|
+
export { observeProcessInstance, probeProcessOwner, runNativeCommand } from 'stitchkit/process';
|
|
8268
|
+
```
|
|
8269
|
+
|
|
8270
|
+
Bundle for Node-compatible execution with Zod external. Publish declarations from the same
|
|
8271
|
+
version: carry their reachable relative `.d.ts` closure, rather than emitting references to
|
|
8272
|
+
`stitchkit` that force clients to install it for types. A library exposing its own DTOs may
|
|
8273
|
+
instead emit declarations for only that DTO contract. Keep the library's manifest at runtime
|
|
8274
|
+
`dependencies: {}` and `peerDependencies: { zod: ... }` when that is its declared promise.
|
|
8275
|
+
|
|
8276
|
+
Darwin consumers need the published native binaries at the bundled loader's relative native
|
|
8277
|
+
directory. A JS-only bundle is not portable evidence. Qualify the packed library outside its
|
|
8278
|
+
build tree in Bun and Node, test its declarations, and check that importing an unbundled
|
|
8279
|
+
Stitchkit leaf fails there. A separate schema-only entry must not import the native entry.
|
|
8280
|
+
|
|
8281
|
+
This delivery removes a runtime kernel installation; it does not remove the build-time
|
|
8282
|
+
Stitchkit installation or create an independent lightweight npm package.
|
|
8169
8283
|
|
|
8170
8284
|
|
|
8171
8285
|
==============================================================================
|
|
@@ -20568,7 +20682,7 @@ available from `stitchkit/contract`.
|
|
|
20568
20682
|
| `ManagedFileInspector` | _type_ | bounded-prefix read/write inspection callback with a finite cancellation signal that cannot own path or size |
|
|
20569
20683
|
| `ManagedFileInspectionInput` / `ManagedFileInspection` | _type_ | inspector prefix/name/declared media/signal input and validated metadata-only result |
|
|
20570
20684
|
| `writeFileAtomic` / `writeFileAtomicSync` / `WriteFileAtomicOptions` | function / _type_ | replace a file atomically: a random staging name created exclusively (never through a planted link), the mode set on the descriptor before the file is visible (default `0o600`, not masked by the umask), `fsync`, rename; a failure leaves the target and no staging file. The asynchronous form keeps the event loop running |
|
|
20571
|
-
| `withExclusiveLock` / `ExclusiveLockOptions` / `ExclusiveLock` / `ExclusiveLockOwner` | function / _type_ | run work under an exclusive lock between processes — a file recording its owner (pid, host, machine identity, time and nullable kernel process identity); waits up to `timeoutMs` (default 10 s) and stops on `signal`; a dead owner on this machine is taken over, a live, slow or foreign one never is; an ownerless lock only after `ownerlessGraceMs` |
|
|
20685
|
+
| `withExclusiveLock` / `ExclusiveLockOptions` / `ExclusiveLock` / `ExclusiveLockOwner` | function / _type_ | run work under an exclusive lock between processes — a file recording its owner (pid, host, machine identity, time and nullable kernel process identity); waits up to `timeoutMs` (default 10 s) and stops on `signal`; a dead owner on this machine is taken over, a live, slow or foreign one never is; an ownerless lock only after `ownerlessGraceMs` (default 5000 ms, `null` disables age-based reclaim including guards); exact `mode` is independent of umask; shared readers need a common group and traversable directories |
|
|
20572
20686
|
| `ExclusiveLockError` | class | `LOCK_TIMEOUT` naming the resource and its holder, or `LOCK_ABORTED` with the signal's reason |
|
|
20573
20687
|
| `createChunkSpool` | function | the server half of a chunked upload: parts on disk under `owner` + client-minted `uploadId`, each with a size+sha256 receipt; idempotent `open` and `put`, the first writer of a part wins across processes, `assemble` in order once every part is in, `sweep` of untouched uploads — [guide](../guide/client.md#chunked-uploads) |
|
|
20574
20688
|
| `ChunkSpool` / `ChunkSpoolConfig` / `ChunkSpoolKey` / `ChunkSpoolOpen` / `ChunkSpoolPart` / `ChunkSpoolAssembly` | _type_ | the spool, its directory, part size, file limit, meta schema and age; an upload's key; its declaration; one part; the assembled parts with a concatenating `stream()` |
|
|
@@ -21121,4 +21235,9 @@ Native POSIX Bun/Node one-shot command execution. See [native IO](../guide/nativ
|
|
|
21121
21235
|
| `runNativeCommand` | function | caller-lifetime streaming or explicitly bounded binary capture |
|
|
21122
21236
|
| `NativeCommandOptions` | type | executable/args, env policy, signal/deadline, bytes sink and finite cleanup limits |
|
|
21123
21237
|
| `NativeCommandResult` | type | observed nullable exit code/signal and captured stdout/stderr bytes |
|
|
21124
|
-
| `NativeCommandError` | class | COMMAND_LIMIT
|
|
21238
|
+
| `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 |
|
|
21239
|
+
|
|
21240
|
+
| `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 |
|
|
21241
|
+
| `observeProcessInstance` / `ProcessInstanceObservation` | function / type | Linux/Darwin lifetime observation; observed identity or unavailable with its original cause, never guessed absence |
|
|
21242
|
+
| `ProcessInstanceSchema` / `ProcessInstance` | schema / type | platform, boot ID, namespace and process start identity from the shared native reader |
|
|
21243
|
+
| `probeProcessOwner` / `ProcessOwnerEvidence` | function / type | compare lifetimes on one caller-established machine; matched, boot change, reused PID, gone, legacy or unavailable with cause |
|
package/llms.txt
CHANGED
|
@@ -23,7 +23,7 @@ Load the slice for each entrypoint your code imports — `import … from 'stitc
|
|
|
23
23
|
- **stitchkit/primitives**: [llms/primitives.txt](llms/primitives.txt) 11.2 KB
|
|
24
24
|
- **stitchkit/server**: [llms/server.txt](llms/server.txt) 45.3 KB → [llms/server.2.txt](llms/server.2.txt) 14.6 KB → [llms/server.3.txt](llms/server.3.txt) 45.6 KB → [llms/server.4.txt](llms/server.4.txt) 38.1 KB → [llms/server.5.txt](llms/server.5.txt) 21.8 KB
|
|
25
25
|
- **stitchkit/observability**: [llms/observability.txt](llms/observability.txt) 44.8 KB
|
|
26
|
-
- **stitchkit/agent-runtime**: [llms/agent-runtime.txt](llms/agent-runtime.txt)
|
|
26
|
+
- **stitchkit/agent-runtime**: [llms/agent-runtime.txt](llms/agent-runtime.txt) 37.2 KB → [llms/agent-runtime.2.txt](llms/agent-runtime.2.txt) 46.7 KB → [llms/agent-runtime.3.txt](llms/agent-runtime.3.txt) 34.3 KB
|
|
27
27
|
- **stitchkit/agent-runtime/testing**: [llms/agent-runtime-testing.txt](llms/agent-runtime-testing.txt) 2.6 KB
|
|
28
28
|
- **stitchkit/agent-runtime/harness**: [llms/agent-runtime-harness.txt](llms/agent-runtime-harness.txt) 10.1 KB
|
|
29
29
|
- **stitchkit/agent-runtime/coding-tools**: [llms/agent-runtime-coding-tools.txt](llms/agent-runtime-coding-tools.txt) 4.9 KB
|
|
@@ -39,7 +39,7 @@ Load the slice for each entrypoint your code imports — `import … from 'stitc
|
|
|
39
39
|
- **stitchkit/application/schemas**: [llms/application-schemas.txt](llms/application-schemas.txt) 1.8 KB
|
|
40
40
|
- **stitchkit/testing**: [llms/testing.txt](llms/testing.txt) 30.8 KB
|
|
41
41
|
- **stitchkit/agent-runtime/sandbox**: [llms/agent-runtime-sandbox.txt](llms/agent-runtime-sandbox.txt) 8.1 KB
|
|
42
|
-
- **stitchkit/files**: [llms/files.txt](llms/files.txt) 4.
|
|
42
|
+
- **stitchkit/files**: [llms/files.txt](llms/files.txt) 4.5 KB
|
|
43
43
|
- **stitchkit/telegram**: [llms/telegram.txt](llms/telegram.txt) 26.9 KB
|
|
44
44
|
- **stitchkit/telegram/html**: [llms/telegram-html.txt](llms/telegram-html.txt) 2.7 KB
|
|
45
45
|
- **stitchkit/telegram/screens**: [llms/telegram-screens.txt](llms/telegram-screens.txt) 21.2 KB
|
|
@@ -55,7 +55,7 @@ Load the slice for each entrypoint your code imports — `import … from 'stitc
|
|
|
55
55
|
- **stitchkit/agent-runtime/react**: [llms/agent-runtime-react.txt](llms/agent-runtime-react.txt) 1.0 KB
|
|
56
56
|
- **stitchkit/agent-runtime/realtime**: [llms/agent-runtime-realtime.txt](llms/agent-runtime-realtime.txt) 1.8 KB
|
|
57
57
|
- **stitchkit/agent-runtime/harness-tools**: [llms/agent-runtime-harness-tools.txt](llms/agent-runtime-harness-tools.txt) 1.3 KB
|
|
58
|
-
- **stitchkit/process**: [llms/process.txt](llms/process.txt)
|
|
58
|
+
- **stitchkit/process**: [llms/process.txt](llms/process.txt) 18.6 KB
|
|
59
59
|
|
|
60
60
|
## Upgrading slices
|
|
61
61
|
- **Upgrading — how to move across versions**: [llms/upgrading.txt](llms/upgrading.txt) 10.3 KB
|
package/native/darwin-arm64.node
CHANGED
|
Binary file
|
package/native/darwin-x64.node
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stitchkit",
|
|
3
|
-
"version": "0.103.
|
|
3
|
+
"version": "0.103.11",
|
|
4
4
|
"description": "Contract-first backend framework — one defineContract() into an HTTP API, MCP tools, AI-agent tools and a typed client. Bun and Node.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bun",
|
|
@@ -250,7 +250,7 @@
|
|
|
250
250
|
"build": "bun ../../scripts/package-build-lock.ts -- bun run build:unlocked",
|
|
251
251
|
"build:unlocked": "rm -rf dist && cp ../../CHANGELOG.md ./CHANGELOG.md && bun run build:js && chmod +x dist/entrypoints/bin/upgrade-cli.js && bun run build:types && bun scripts/check-browser-clean.mjs && bun scripts/check-browser-executes.mjs && bun scripts/check-env-live.mjs && bun scripts/check-public-types.mjs && bun scripts/check-durability-port-standalone.mjs && bun scripts/check-declarations-strict.mjs",
|
|
252
252
|
"dev": "bun run build:entrypoints -- --watch",
|
|
253
|
-
"prepack": "
|
|
253
|
+
"prepack": "bun ../../scripts/sync-package-readme.ts && bun ../../scripts/gen-llms.ts && bun run build",
|
|
254
254
|
"test": "bun test",
|
|
255
255
|
"smoke:node": "node scripts/node-smoke.mjs",
|
|
256
256
|
"smoke:next-ssr": "node scripts/next-ssr-retry-smoke.mjs",
|