stitchkit 0.103.11 → 0.103.13

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 +36 -0
  2. package/darwin-native.cjs +12 -0
  3. package/darwin-native.d.cts +2 -0
  4. package/dist/agent-runtime/coding-shell-process.d.ts.map +1 -1
  5. package/dist/agent-runtime/sandbox-process-owner.d.ts +1 -1
  6. package/dist/agent-runtime/sandbox-process-owner.d.ts.map +1 -1
  7. package/dist/agent-runtime/store-conformance-support.d.ts +5 -5
  8. package/dist/durability/json.d.ts.map +1 -1
  9. package/dist/entrypoints/agent-runtime/coding-tools.js +4 -2
  10. package/dist/entrypoints/agent-runtime/harness.js +4 -3
  11. package/dist/entrypoints/agent-runtime/sandbox.js +22 -16
  12. package/dist/entrypoints/agent-runtime.js +2 -2
  13. package/dist/entrypoints/application/diagnostic-journal.js +3 -2
  14. package/dist/entrypoints/cli.js +1 -1
  15. package/dist/entrypoints/files.js +3 -2
  16. package/dist/entrypoints/primitives.js +4 -3
  17. package/dist/entrypoints/process.js +3 -2
  18. package/dist/entrypoints/tools.js +2 -2
  19. package/dist/{index-nybn2err.js → index-5csmzesf.js} +1 -1
  20. package/dist/{index-ary5s7k0.js → index-69nvze1q.js} +1 -2
  21. package/dist/{index-ahtnte39.js → index-8zfsgar0.js} +35 -30
  22. package/dist/{index-ttf0y7b8.js → index-9853ymwb.js} +38 -19
  23. package/dist/{index-g4jxe7ve.js → index-db2spkv1.js} +7 -6
  24. package/dist/{index-32jkwkdm.js → index-f330qqyg.js} +253 -165
  25. package/dist/index-fm1c1a08.js +138 -0
  26. package/dist/{index-ej331hah.js → index-gxm9rc97.js} +1 -1
  27. package/dist/index-v5ee8ath.js +88 -0
  28. package/dist/{index-9jb61j5a.js → index-zp4jpkp0.js} +1 -1
  29. package/dist/internal/darwin-binding-error.d.ts +24 -0
  30. package/dist/internal/darwin-binding-error.d.ts.map +1 -0
  31. package/dist/internal/darwin-binding.d.ts.map +1 -1
  32. package/dist/internal/exclusive-lock.d.ts +1 -1
  33. package/dist/internal/exclusive-lock.d.ts.map +1 -1
  34. package/dist/internal/json-data.d.ts +8 -2
  35. package/dist/internal/json-data.d.ts.map +1 -1
  36. package/dist/internal/json-string-size.d.ts +3 -0
  37. package/dist/internal/json-string-size.d.ts.map +1 -0
  38. package/dist/primitives/canonical-json.d.ts.map +1 -1
  39. package/dist/process/cleanup.d.ts +12 -0
  40. package/dist/process/cleanup.d.ts.map +1 -0
  41. package/dist/process/command-lifetime.d.ts +19 -0
  42. package/dist/process/command-lifetime.d.ts.map +1 -0
  43. package/dist/process/command-owner.d.ts +0 -3
  44. package/dist/process/command-owner.d.ts.map +1 -1
  45. package/dist/process/group.d.ts.map +1 -1
  46. package/dist/process/launch.d.ts +15 -6
  47. package/dist/process/launch.d.ts.map +1 -1
  48. package/dist/process/owned-child.d.ts +10 -0
  49. package/dist/process/owned-child.d.ts.map +1 -0
  50. package/dist/process/start-failure.d.ts +2 -5
  51. package/dist/process/start-failure.d.ts.map +1 -1
  52. package/dist/process/transport.d.ts +30 -0
  53. package/dist/process/transport.d.ts.map +1 -0
  54. package/dist/tools/cli/args-fields.d.ts +2 -0
  55. package/dist/tools/cli/args-fields.d.ts.map +1 -1
  56. package/dist/tools/cli/args.d.ts.map +1 -1
  57. package/llms/agent-runtime-sandbox.txt +9 -1
  58. package/llms/cli.txt +10 -0
  59. package/llms/process.txt +62 -8
  60. package/llms-full.txt +81 -9
  61. package/llms.txt +3 -3
  62. package/package.json +6 -1
  63. package/dist/index-c1jmtxa0.js +0 -74
  64. package/dist/index-d4pa2bgs.js +0 -42
package/llms/process.txt CHANGED
@@ -15,7 +15,7 @@ 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-02 16:28 +07:00
18
+ updated: 2026-10-04 09:40 +07:00
19
19
  participants:
20
20
  - role: authored
21
21
  harness: Codex
@@ -25,6 +25,14 @@ participants:
25
25
  harness: Codex
26
26
  model: GPT-6
27
27
  at: 2026-10-02 00:08 +07:00
28
+ - role: implemented
29
+ harness: Codex
30
+ model: GPT-6
31
+ at: 2026-10-03 13:36 +07:00
32
+ - role: implemented
33
+ harness: Codex
34
+ model: GPT-6
35
+ at: 2026-10-04 09:21 +07:00
28
36
  ---
29
37
 
30
38
  # Native IO
@@ -227,9 +235,10 @@ independent of umask. Default `0600` stays private. Shared `0640` requires a com
227
235
  traversable directories; another UID also needs directory write permission to reclaim a
228
236
  proven-dead owner's file. Set `ownerlessGraceMs: null` to refuse every age-only reclaim,
229
237
  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 остаются отказом.
238
+ Stale reclaim guards use the same lock owner and a child guard for the inode check and
239
+ unlink. Recovery depth is capped at 16; a deeper stale chain refuses recovery with a depth diagnosis retained as the cause of
240
+ the bounded `LOCK_TIMEOUT`. Live owners, unknown process-lifetime evidence and unsafe records are never
241
+ reclaimed. Concurrent writers cannot bypass a guard while a prior unlink is paused.
233
242
 
234
243
  ## Libraries with a Zod-only runtime
235
244
 
@@ -251,14 +260,59 @@ version: carry their reachable relative `.d.ts` closure, rather than emitting re
251
260
  instead emit declarations for only that DTO contract. Keep the library's manifest at runtime
252
261
  `dependencies: {}` and `peerDependencies: { zod: ... }` when that is its declared promise.
253
262
 
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.
263
+ The packaged Darwin loader has static references to both architecture addons. Bun compilation
264
+ embeds the matching `.node` asset; ordinary Bun bundling emits native assets alongside its JS
265
+ output. Publish **every output returned by `Bun.build`**, preserving relative paths. Copying only
266
+ the JS file drops its native dependency. No runtime Stitchkit installation or manually chosen
267
+ native path is required for these bundled artifacts.
268
+
269
+ ```sh
270
+ bun build src/native.ts --target=bun --minify --outdir=dist
271
+ bun build src/native.ts --compile --bytecode --format=esm --outfile=dist/native
272
+ ```
273
+
274
+ For a JS build that previously used `--outfile=dist/native.js`, use
275
+ `--outdir=dist --entry-naming=native.js` instead: the output can now include native assets.
276
+ The standalone executable still uses `--outfile` because those assets are embedded inside it.
277
+
278
+ Qualify the complete output outside its build tree and installed dependency graph. Test process
279
+ identity, live-owner refusal, dead-owner recovery and contained file operations in the resulting
280
+ JS bundle and standalone executable. Bun and Node package imports retain the same lazy loader;
281
+ importing a portable leaf does not load a Darwin addon on another OS. Test declarations too,
282
+ and check that importing an unbundled Stitchkit leaf fails in a deliberately isolated library
283
+ distribution. A separate schema-only entry must not import the native entry.
284
+
285
+ If the Darwin backend cannot load, `observeProcessInstance` still returns `unavailable`.
286
+ Its backend `Error` preserves the original `cause`; JSON serialization carries only the stable
287
+ `DARWIN_BACKEND_UNAVAILABLE` code, architecture, safe message and failure stage
288
+ (`architecture`, `resolve`, `load` or `surface`), plus a recognized native error code when present.
289
+ It excludes stack, paths and nested cause. This backend diagnosis does not reclassify kernel
290
+ failures or turn unavailable identity into proof that an owner is dead. If a runtime provides
291
+ no recognized native error code, the stage stays `load`; the loader never infers errno from text.
258
292
 
259
293
  This delivery removes a runtime kernel installation; it does not remove the build-time
260
294
  Stitchkit installation or create an independent lightweight npm package.
261
295
 
296
+ ## Qualification boundaries
297
+
298
+ Native command cleanup owns the child before launch subscriptions are installed. Setup
299
+ refusal still settles leader closure and teardown within the cleanup budget; failure to
300
+ prove closure reports `COMMAND_CLEANUP` with the original failure retained. Process-group
301
+ signaling requires evidence from the actual detached launcher, not a structural PID field.
302
+ The built-in sandbox transport carries that ownership across the package's split entrypoints.
303
+ Internal finite deadlines and Darwin retry admission use monotonic elapsed time.
304
+
305
+ Linux UID-refusal qualification is a separate privileged installed-package proof in Bun
306
+ and real Node; an unsupported platform or insufficient UID reports an explicit skip.
307
+ A generic native-owner marker does not certify the privileged case. Real Darwin CI remains
308
+ the qualification for native Darwin behavior.
309
+
310
+ Local filesystem tests do not attest delayed NFS visibility, shared-volume microVM or gVisor
311
+ ownership, actual PGID reuse, power-loss durability or macOS full-sync behavior. Those
312
+ require their actual topology or failure environment. The default ownerless grace remains
313
+ 5000 ms; stricter callers can retain `ownerlessGraceMs: null`. No age-only observation
314
+ proves a partially published owner's process dead.
315
+
262
316
  ==============================================================================
263
317
  # API reference: `stitchkit/process` (docs/api/reference.md)
264
318
  ==============================================================================
package/llms-full.txt CHANGED
@@ -7900,6 +7900,12 @@ boundary is required. Send and projection callbacks own their external deadlines
7900
7900
  ---
7901
7901
  title: Optional process sandbox
7902
7902
  description: Linux namespace isolation, durable workspaces and a host credential gateway.
7903
+ updated: 2026-10-03 14:47 +07:00
7904
+ participants:
7905
+ - role: implemented
7906
+ harness: Codex
7907
+ model: GPT-6
7908
+ at: 2026-10-03 14:47 +07:00
7903
7909
  ---
7904
7910
 
7905
7911
  # Optional process sandbox
@@ -7969,7 +7975,9 @@ Unsupported backends omit the binding and the factory refuses explicitly.
7969
7975
  Stop also kills coding commands. Both launch paths share the configured
7970
7976
  `maxConcurrentCommands` admission limit (default 8); an occupied slot gives
7971
7977
  `SANDBOX_BUSY` before another process starts. This counts direct commands, not
7972
- guest descendants. Required restrictions are checked again during preparation;
7978
+ guest descendants. A direct launch retains its slot through terminal group cleanup,
7979
+ including descendants that outlive the leader. Required restrictions are checked again
7980
+ during preparation;
7973
7981
  a network-policy change invalidates an outstanding prepared launch. After
7974
7982
  reconnect, create the coding profile from the new handle; old tools remain stopped.
7975
7983
 
@@ -8037,7 +8045,7 @@ description: Native IO для Bun и Node, с явно выбранной durabi
8037
8045
  type: guide
8038
8046
  status: active
8039
8047
  created: 2026-10-01 20:44 +07:00
8040
- updated: 2026-10-02 16:28 +07:00
8048
+ updated: 2026-10-04 09:40 +07:00
8041
8049
  participants:
8042
8050
  - role: authored
8043
8051
  harness: Codex
@@ -8047,6 +8055,14 @@ participants:
8047
8055
  harness: Codex
8048
8056
  model: GPT-6
8049
8057
  at: 2026-10-02 00:08 +07:00
8058
+ - role: implemented
8059
+ harness: Codex
8060
+ model: GPT-6
8061
+ at: 2026-10-03 13:36 +07:00
8062
+ - role: implemented
8063
+ harness: Codex
8064
+ model: GPT-6
8065
+ at: 2026-10-04 09:21 +07:00
8050
8066
  ---
8051
8067
 
8052
8068
  # Native IO
@@ -8249,9 +8265,10 @@ independent of umask. Default `0600` stays private. Shared `0640` requires a com
8249
8265
  traversable directories; another UID also needs directory write permission to reclaim a
8250
8266
  proven-dead owner's file. Set `ownerlessGraceMs: null` to refuse every age-only reclaim,
8251
8267
  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 остаются отказом.
8268
+ Stale reclaim guards use the same lock owner and a child guard for the inode check and
8269
+ unlink. Recovery depth is capped at 16; a deeper stale chain refuses recovery with a depth diagnosis retained as the cause of
8270
+ the bounded `LOCK_TIMEOUT`. Live owners, unknown process-lifetime evidence and unsafe records are never
8271
+ reclaimed. Concurrent writers cannot bypass a guard while a prior unlink is paused.
8255
8272
 
8256
8273
  ## Libraries with a Zod-only runtime
8257
8274
 
@@ -8273,14 +8290,59 @@ version: carry their reachable relative `.d.ts` closure, rather than emitting re
8273
8290
  instead emit declarations for only that DTO contract. Keep the library's manifest at runtime
8274
8291
  `dependencies: {}` and `peerDependencies: { zod: ... }` when that is its declared promise.
8275
8292
 
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.
8293
+ The packaged Darwin loader has static references to both architecture addons. Bun compilation
8294
+ embeds the matching `.node` asset; ordinary Bun bundling emits native assets alongside its JS
8295
+ output. Publish **every output returned by `Bun.build`**, preserving relative paths. Copying only
8296
+ the JS file drops its native dependency. No runtime Stitchkit installation or manually chosen
8297
+ native path is required for these bundled artifacts.
8298
+
8299
+ ```sh
8300
+ bun build src/native.ts --target=bun --minify --outdir=dist
8301
+ bun build src/native.ts --compile --bytecode --format=esm --outfile=dist/native
8302
+ ```
8303
+
8304
+ For a JS build that previously used `--outfile=dist/native.js`, use
8305
+ `--outdir=dist --entry-naming=native.js` instead: the output can now include native assets.
8306
+ The standalone executable still uses `--outfile` because those assets are embedded inside it.
8307
+
8308
+ Qualify the complete output outside its build tree and installed dependency graph. Test process
8309
+ identity, live-owner refusal, dead-owner recovery and contained file operations in the resulting
8310
+ JS bundle and standalone executable. Bun and Node package imports retain the same lazy loader;
8311
+ importing a portable leaf does not load a Darwin addon on another OS. Test declarations too,
8312
+ and check that importing an unbundled Stitchkit leaf fails in a deliberately isolated library
8313
+ distribution. A separate schema-only entry must not import the native entry.
8314
+
8315
+ If the Darwin backend cannot load, `observeProcessInstance` still returns `unavailable`.
8316
+ Its backend `Error` preserves the original `cause`; JSON serialization carries only the stable
8317
+ `DARWIN_BACKEND_UNAVAILABLE` code, architecture, safe message and failure stage
8318
+ (`architecture`, `resolve`, `load` or `surface`), plus a recognized native error code when present.
8319
+ It excludes stack, paths and nested cause. This backend diagnosis does not reclassify kernel
8320
+ failures or turn unavailable identity into proof that an owner is dead. If a runtime provides
8321
+ no recognized native error code, the stage stays `load`; the loader never infers errno from text.
8280
8322
 
8281
8323
  This delivery removes a runtime kernel installation; it does not remove the build-time
8282
8324
  Stitchkit installation or create an independent lightweight npm package.
8283
8325
 
8326
+ ## Qualification boundaries
8327
+
8328
+ Native command cleanup owns the child before launch subscriptions are installed. Setup
8329
+ refusal still settles leader closure and teardown within the cleanup budget; failure to
8330
+ prove closure reports `COMMAND_CLEANUP` with the original failure retained. Process-group
8331
+ signaling requires evidence from the actual detached launcher, not a structural PID field.
8332
+ The built-in sandbox transport carries that ownership across the package's split entrypoints.
8333
+ Internal finite deadlines and Darwin retry admission use monotonic elapsed time.
8334
+
8335
+ Linux UID-refusal qualification is a separate privileged installed-package proof in Bun
8336
+ and real Node; an unsupported platform or insufficient UID reports an explicit skip.
8337
+ A generic native-owner marker does not certify the privileged case. Real Darwin CI remains
8338
+ the qualification for native Darwin behavior.
8339
+
8340
+ Local filesystem tests do not attest delayed NFS visibility, shared-volume microVM or gVisor
8341
+ ownership, actual PGID reuse, power-loss durability or macOS full-sync behavior. Those
8342
+ require their actual topology or failure environment. The default ownerless grace remains
8343
+ 5000 ms; stricter callers can retain `ownerlessGraceMs: null`. No age-only observation
8344
+ proves a partially published owner's process dead.
8345
+
8284
8346
 
8285
8347
  ==============================================================================
8286
8348
  # Guide: Generic application primitives (docs/guide/primitives.md)
@@ -8874,6 +8936,16 @@ there stays a positional, and `--` makes a literal `false` one too. The same
8874
8936
  holds for a short alias, a framework flag such as `--json false` and an
8875
8937
  application option.
8876
8938
 
8939
+ Every declared non-array option is single-use, including framework and
8940
+ application globals. Bare, separate-value, inline, negative and short-alias
8941
+ forms of a command option count as the same name: `--active=false --active`,
8942
+ `--active false --no-active` and `-f --active` are argument errors even when
8943
+ the values agree. Duplicates are refused before command execution. Array
8944
+ options accumulate across long and short forms; unknown non-dotted passthrough
8945
+ options retain their raw-list grammar. Tokens after `--` are literal data.
8946
+ Command `--help` and `-h` keep their diagnostic precedence over malformed
8947
+ operation arguments; application globals are validated before routing.
8948
+
8877
8949
  Without presentation configuration, positional arguments fill non-boolean
8878
8950
  fields in declaration order, so `myapp generate "a fox"` is
8879
8951
  `--prompt "a fox"`. A piped value fills the first required unset field:
package/llms.txt CHANGED
@@ -17,7 +17,7 @@ Load the slice for each entrypoint your code imports — `import … from 'stitc
17
17
  - **stitchkit/tools/contract**: [llms/tools-contract.txt](llms/tools-contract.txt) 0.2 KB
18
18
  - **stitchkit/tools/invoker**: [llms/tools-invoker.txt](llms/tools-invoker.txt) 0.2 KB
19
19
  - **stitchkit/tools/connections**: [llms/tools-connections.txt](llms/tools-connections.txt) 3.1 KB
20
- - **stitchkit/cli**: [llms/cli.txt](llms/cli.txt) 43.6 KB → [llms/cli.2.txt](llms/cli.2.txt) 8.1 KB
20
+ - **stitchkit/cli**: [llms/cli.txt](llms/cli.txt) 44.2 KB → [llms/cli.2.txt](llms/cli.2.txt) 8.1 KB
21
21
  - **stitchkit/remote**: [llms/remote.txt](llms/remote.txt) 1.0 KB
22
22
  - **stitchkit/contract**: [llms/contract.txt](llms/contract.txt) 31.9 KB
23
23
  - **stitchkit/primitives**: [llms/primitives.txt](llms/primitives.txt) 11.2 KB
@@ -38,7 +38,7 @@ Load the slice for each entrypoint your code imports — `import … from 'stitc
38
38
  - **stitchkit/application/diagnostic-journal**: [llms/application-diagnostic-journal.txt](llms/application-diagnostic-journal.txt) 1.8 KB
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
- - **stitchkit/agent-runtime/sandbox**: [llms/agent-runtime-sandbox.txt](llms/agent-runtime-sandbox.txt) 8.1 KB
41
+ - **stitchkit/agent-runtime/sandbox**: [llms/agent-runtime-sandbox.txt](llms/agent-runtime-sandbox.txt) 8.3 KB
42
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
@@ -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) 18.6 KB
58
+ - **stitchkit/process**: [llms/process.txt](llms/process.txt) 21.7 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stitchkit",
3
- "version": "0.103.11",
3
+ "version": "0.103.13",
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",
@@ -42,6 +42,8 @@
42
42
  "files": [
43
43
  "dist",
44
44
  "native/*.node",
45
+ "darwin-native.cjs",
46
+ "darwin-native.d.cts",
45
47
  "llms.txt",
46
48
  "llms-full.txt",
47
49
  "llms",
@@ -49,6 +51,9 @@
49
51
  "CHANGELOG.md",
50
52
  "LICENSE"
51
53
  ],
54
+ "imports": {
55
+ "#stitchkit-darwin-native": "./darwin-native.cjs"
56
+ },
52
57
  "exports": {
53
58
  ".": {
54
59
  "types": "./dist/entrypoints/index.d.ts",
@@ -1,74 +0,0 @@
1
- // src/internal/json-data.ts
2
- function isJsonData(value, limits) {
3
- const ancestors = new Set;
4
- let nodes = 0;
5
- let bytes = 0;
6
- const charge = (amount) => {
7
- bytes += amount;
8
- return bytes <= limits.maxBytes;
9
- };
10
- const textSize = (text) => {
11
- if (text.length > limits.maxBytes)
12
- return limits.maxBytes + 1;
13
- return new TextEncoder().encode(JSON.stringify(text)).byteLength;
14
- };
15
- const visit = (item, depth) => {
16
- if (++nodes > limits.maxNodes || depth > limits.maxDepth)
17
- return false;
18
- if (item === null)
19
- return charge(4);
20
- if (typeof item === "string")
21
- return charge(textSize(item));
22
- if (typeof item === "boolean")
23
- return charge(item ? 4 : 5);
24
- if (typeof item === "number")
25
- return Number.isFinite(item) && !Object.is(item, -0) && charge(String(item).length);
26
- if (typeof item !== "object" || ancestors.has(item))
27
- return false;
28
- const array = Array.isArray(item);
29
- const prototype = Object.getPrototypeOf(item);
30
- if (array ? prototype !== Array.prototype : prototype !== Object.prototype && prototype !== null)
31
- return false;
32
- if (array && item.length > limits.maxNodes - nodes)
33
- return false;
34
- const keys = Reflect.ownKeys(item);
35
- if (keys.length > limits.maxNodes - nodes + (array ? 1 : 0))
36
- return false;
37
- if (array && keys.length !== item.length + 1)
38
- return false;
39
- ancestors.add(item);
40
- try {
41
- if (!charge(2))
42
- return false;
43
- let members = 0;
44
- for (const key of keys) {
45
- if (array && key === "length")
46
- continue;
47
- if (typeof key !== "string")
48
- return false;
49
- if (array && (!/^(0|[1-9][0-9]*)$/.test(key) || Number(key) >= item.length))
50
- return false;
51
- const descriptor = Object.getOwnPropertyDescriptor(item, key);
52
- if (!descriptor?.enumerable || !("value" in descriptor))
53
- return false;
54
- if (!array && limits.omitObjectUndefined && descriptor.value === undefined) {
55
- if (++nodes > limits.maxNodes)
56
- return false;
57
- continue;
58
- }
59
- if (members++ > 0 && !charge(1))
60
- return false;
61
- if (!array && !charge(textSize(key) + 1))
62
- return false;
63
- if (!visit(descriptor.value, depth + 1))
64
- return false;
65
- }
66
- return true;
67
- } finally {
68
- ancestors.delete(item);
69
- }
70
- };
71
- return visit(value, 0);
72
- }
73
-
74
- export { isJsonData };
@@ -1,42 +0,0 @@
1
- // src/internal/darwin-binding.ts
2
- import { existsSync } from "node:fs";
3
- import { createRequire } from "node:module";
4
- import path from "node:path";
5
- import { fileURLToPath } from "node:url";
6
- function hasFunctions(value, names) {
7
- return typeof value === "object" && value !== null && names.every((name) => typeof Reflect.get(value, name) === "function");
8
- }
9
- var darwinBinding;
10
- function loadDarwinBinding() {
11
- if (darwinBinding)
12
- return darwinBinding;
13
- const directory = path.dirname(fileURLToPath(import.meta.url));
14
- const binary = `darwin-${process.arch}.node`;
15
- const candidates = [
16
- path.resolve(directory, "../native", binary),
17
- path.resolve(directory, "../../native", binary)
18
- ];
19
- const selected = candidates.find((candidate) => existsSync(candidate));
20
- if (!selected) {
21
- throw new Error(`Contained filesystem operations need the packaged Darwin ${process.arch} backend`);
22
- }
23
- const loaded = createRequire(import.meta.url)(selected);
24
- const methods = [
25
- "openDirectoryAt",
26
- "openFileAt",
27
- "createFileAt",
28
- "createDirectoryAt",
29
- "statAt",
30
- "listAt",
31
- "renameAt",
32
- "unlinkAt",
33
- "processIdentity"
34
- ];
35
- if (!hasFunctions(loaded, methods)) {
36
- throw new Error("The packaged Darwin contained-files backend has an invalid surface");
37
- }
38
- darwinBinding = loaded;
39
- return darwinBinding;
40
- }
41
-
42
- export { loadDarwinBinding };