stitchkit 0.136.4 → 0.136.5

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 (88) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/entrypoints/agent-executor/acp.js +5 -5
  3. package/dist/entrypoints/agent-executor/claude-sdk.js +7 -7
  4. package/dist/entrypoints/agent-executor/claude.js +7 -7
  5. package/dist/entrypoints/agent-executor/codex.js +9 -9
  6. package/dist/entrypoints/agent-executor/testing.js +9 -9
  7. package/dist/entrypoints/agent-executor.js +5 -5
  8. package/dist/entrypoints/agent-runtime/coding-tools.js +2 -2
  9. package/dist/entrypoints/agent-runtime/postgres.js +4 -4
  10. package/dist/entrypoints/agent-runtime/sandbox.js +7 -7
  11. package/dist/entrypoints/agent-runtime/sqlite/bun.js +5 -5
  12. package/dist/entrypoints/agent-runtime/sqlite/node.js +5 -5
  13. package/dist/entrypoints/agent-runtime/testing.js +4 -4
  14. package/dist/entrypoints/agent-runtime.js +4 -4
  15. package/dist/entrypoints/application/diagnostic-journal.js +3 -3
  16. package/dist/entrypoints/application/directory-inbox.js +7 -7
  17. package/dist/entrypoints/cli/publish.d.ts +14 -6
  18. package/dist/entrypoints/cli/publish.d.ts.map +1 -1
  19. package/dist/entrypoints/cli/publish.js +685 -30
  20. package/dist/entrypoints/cli.js +7 -124
  21. package/dist/entrypoints/files/packaging.js +2 -2
  22. package/dist/entrypoints/files.d.ts +1 -0
  23. package/dist/entrypoints/files.d.ts.map +1 -1
  24. package/dist/entrypoints/files.js +9 -9
  25. package/dist/entrypoints/node.js +3 -3
  26. package/dist/entrypoints/observability.js +1 -1
  27. package/dist/entrypoints/process.js +3 -3
  28. package/dist/entrypoints/server.js +6 -6
  29. package/dist/entrypoints/service-host/macos.js +7 -7
  30. package/dist/entrypoints/service-host/work.js +6 -6
  31. package/dist/entrypoints/service-host.js +9 -9
  32. package/dist/entrypoints/spend.js +1 -1
  33. package/dist/entrypoints/telegram.js +3 -3
  34. package/dist/entrypoints/tools.js +1 -1
  35. package/dist/{index-05b65gj4.js → index-0s75mjh7.js} +1 -1
  36. package/dist/{index-s2e3h616.js → index-150b1qyw.js} +10 -1
  37. package/dist/{index-tcv71frn.js → index-1fhbe4e4.js} +1 -1
  38. package/dist/{index-8cek82ar.js → index-1h0dtfz3.js} +1 -1
  39. package/dist/{index-jwtmw39p.js → index-2qnqvq11.js} +1 -1
  40. package/dist/index-2rs7ze0q.js +376 -0
  41. package/dist/{index-2wm9b9vs.js → index-3cwq5byx.js} +2 -2
  42. package/dist/{index-mtpcax6d.js → index-5md04mwc.js} +3 -3
  43. package/dist/{index-b0mh2t9x.js → index-67mzzkdv.js} +3 -3
  44. package/dist/{index-d5mhgx72.js → index-8tn10tp6.js} +1 -1
  45. package/dist/{index-0sxj3y45.js → index-afaq0nc4.js} +1 -1
  46. package/dist/{index-nfm15ej7.js → index-bbpygynk.js} +1 -1
  47. package/dist/{index-g04hszcm.js → index-chapre0y.js} +1 -1
  48. package/dist/{index-vh4291qh.js → index-ctaxjpa4.js} +1 -1
  49. package/dist/{index-x1r7kxzd.js → index-e4zt2x70.js} +3 -3
  50. package/dist/{index-s0n0nnz5.js → index-f103md2v.js} +122 -3
  51. package/dist/{index-2c5w2d1d.js → index-gyfsh29t.js} +1 -1
  52. package/dist/{index-kgkevngs.js → index-kadgaw1s.js} +4 -4
  53. package/dist/{index-ca1v40d3.js → index-kd48gk7d.js} +1 -1
  54. package/dist/{index-ke6jtxkd.js → index-mr3njw67.js} +1 -1
  55. package/dist/{index-cmqvf0dz.js → index-ppy23bd2.js} +1 -1
  56. package/dist/{index-43k180c2.js → index-rnhp7je8.js} +2 -2
  57. package/dist/{index-2tgmggcm.js → index-smvmnz5y.js} +1 -1
  58. package/dist/{index-9m1m92rg.js → index-tjhhsnjv.js} +1 -1
  59. package/dist/{index-64t6pheq.js → index-w161azza.js} +1 -1
  60. package/dist/{index-mttkdm5a.js → index-xqppqn97.js} +1 -1
  61. package/dist/{index-sjq4akrx.js → index-xsrma0jd.js} +2 -2
  62. package/dist/{index-zqc64g69.js → index-ypm85xwe.js} +1 -1
  63. package/dist/{index-zagc12j1.js → index-zcq3dby3.js} +1 -1
  64. package/dist/{index-29v1p1f4.js → index-zhngww7q.js} +1 -1
  65. package/dist/internal/atomic-file-owner.d.ts +91 -0
  66. package/dist/internal/atomic-file-owner.d.ts.map +1 -0
  67. package/dist/internal/atomic-file.d.ts +29 -7
  68. package/dist/internal/atomic-file.d.ts.map +1 -1
  69. package/dist/internal/bounded-file-read.d.ts +6 -2
  70. package/dist/internal/bounded-file-read.d.ts.map +1 -1
  71. package/dist/tools/cli/distribution-config.d.ts +56 -0
  72. package/dist/tools/cli/distribution-config.d.ts.map +1 -0
  73. package/dist/tools/cli/distribution-routes.d.ts +20 -0
  74. package/dist/tools/cli/distribution-routes.d.ts.map +1 -0
  75. package/dist/tools/cli/publication-source.d.ts +77 -0
  76. package/dist/tools/cli/publication-source.d.ts.map +1 -0
  77. package/llms/cli-publish.txt +15 -3
  78. package/llms/cli.2.txt +84 -63
  79. package/llms/cli.3.txt +67 -1
  80. package/llms/cli.txt +1 -1
  81. package/llms/files.txt +1 -1
  82. package/llms/process.txt +24 -4
  83. package/llms/stitchkit.txt +1 -1
  84. package/llms-full.txt +124 -9
  85. package/llms.txt +5 -5
  86. package/package.json +1 -1
  87. package/dist/index-pp97q86a.js +0 -221
  88. package/dist/{index-5c4m8zdf.js → index-tjakdpf2.js} +45 -45
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  isAbsoluteNormalPath,
3
3
  createBaseServiceHostAdapter
4
- } from "./index-b0mh2t9x.js";
4
+ } from "./index-67mzzkdv.js";
5
5
  import {
6
6
  errnoOf
7
7
  } from "./index-jj9228tt.js";
@@ -5,7 +5,7 @@ import {
5
5
  assertUnixSocketPathLength,
6
6
  assertExpectedOwnerUid,
7
7
  assertUnixSocketClientTarget
8
- } from "./index-ca1v40d3.js";
8
+ } from "./index-kd48gk7d.js";
9
9
  import {
10
10
  DEFAULT_REQUEST_BODY_BYTES
11
11
  } from "./index-qqd979f7.js";
@@ -9,11 +9,11 @@ import {
9
9
  reclaimable,
10
10
  LockRecordError,
11
11
  readLockRecord
12
- } from "./index-jwtmw39p.js";
12
+ } from "./index-2qnqvq11.js";
13
13
  import {
14
14
  AtomicFilePublicationError2,
15
15
  publishAtomicFile
16
- } from "./index-2c5w2d1d.js";
16
+ } from "./index-gyfsh29t.js";
17
17
  import {
18
18
  errnoOf
19
19
  } from "./index-jj9228tt.js";
@@ -2,7 +2,7 @@ import {
2
2
  assertUnixSocketPathLength,
3
3
  assertExpectedOwnerUid,
4
4
  unixSocketDirectoryViolation
5
- } from "./index-ca1v40d3.js";
5
+ } from "./index-kd48gk7d.js";
6
6
  import {
7
7
  errnoOf
8
8
  } from "./index-jj9228tt.js";
@@ -2,7 +2,7 @@ import {
2
2
  PlanWindowSchema2,
3
3
  PlanLimitsSchema2,
4
4
  clampPlanName
5
- } from "./index-sjq4akrx.js";
5
+ } from "./index-xsrma0jd.js";
6
6
  import {
7
7
  isPositiveSafeInteger
8
8
  } from "./index-gr0kxymw.js";
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  CommandStopped,
6
6
  startNativeCommand
7
- } from "./index-5c4m8zdf.js";
7
+ } from "./index-tjakdpf2.js";
8
8
  import {
9
9
  ScanStopped,
10
10
  ContainedScanBudget,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  writeFileAtomic2
3
- } from "./index-pp97q86a.js";
3
+ } from "./index-2rs7ze0q.js";
4
4
  import {
5
5
  errnoOf
6
6
  } from "./index-jj9228tt.js";
@@ -9,10 +9,10 @@ import {
9
9
  } from "./index-02kdtrcd.js";
10
10
  import {
11
11
  streamNativeCommand2
12
- } from "./index-8cek82ar.js";
12
+ } from "./index-1h0dtfz3.js";
13
13
  import {
14
14
  runNativeCommand2
15
- } from "./index-0sxj3y45.js";
15
+ } from "./index-afaq0nc4.js";
16
16
  import {
17
17
  jsonDataRefusal
18
18
  } from "./index-m6w6jtda.js";
@@ -23,7 +23,7 @@ import {
23
23
  replaceMessage,
24
24
  ArchiveSpillSchema,
25
25
  createAgentRuntimeStore2
26
- } from "./index-d5mhgx72.js";
26
+ } from "./index-8tn10tp6.js";
27
27
 
28
28
  // src/agent-runtime/stores/store-memory.ts
29
29
  import { z as z2 } from "zod";
@@ -26,7 +26,7 @@ import {
26
26
  isRuntimeSnapshotEntry,
27
27
  appendEventIn,
28
28
  ArchiveSpillSchema
29
- } from "./index-d5mhgx72.js";
29
+ } from "./index-8tn10tp6.js";
30
30
  import {
31
31
  InvocationExpiredPayloadSchema,
32
32
  parsePayloadPurgeCutoff,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  attemptExclusiveLock
3
- } from "./index-43k180c2.js";
3
+ } from "./index-rnhp7je8.js";
4
4
  import {
5
5
  sleep
6
6
  } from "./index-h20qcyh5.js";
@@ -0,0 +1,91 @@
1
+ /**
2
+ * POSIX ownership policy, validation and descriptor application for atomic file writes.
3
+ *
4
+ * Ownership is either left to the kernel (`'none'`), preserved from an existing regular file at
5
+ * `target` via `lstat` (`'preserve'`), or set explicitly (`{ uid, gid }`). Before calling `fchown`,
6
+ * the descriptor's actual `(uid, gid)` is read with `fstat(fd)` — never guessed from
7
+ * `process.getuid()`/`process.getgid()`, which disagree with the inode in setgid or BSD directories.
8
+ */
9
+ /** Explicit POSIX numeric user and group IDs (`0`..`4294967294`) applied to an atomically written file. */
10
+ export interface WriteFileAtomicOwner {
11
+ /** Numeric POSIX user ID (`0`..`4294967294`; `0xffff_ffff` is refused as POSIX `(uid_t)-1` no-op). */
12
+ readonly uid: number;
13
+ /** Numeric POSIX group ID (`0`..`4294967294`; `0xffff_ffff` is refused as POSIX `(gid_t)-1` no-op). */
14
+ readonly gid: number;
15
+ }
16
+ /** Normalized ownership policy resolved once up front from `WriteFileAtomicOptions`. */
17
+ export type AtomicOwnerPolicy = {
18
+ readonly kind: 'none';
19
+ } | {
20
+ readonly kind: 'preserve';
21
+ } | {
22
+ readonly kind: 'explicit';
23
+ readonly owner: WriteFileAtomicOwner;
24
+ };
25
+ /** Minimal `lstat` view needed to inspect an existing target's file kind and ownership. */
26
+ export interface TargetLstatView {
27
+ isFile(): boolean;
28
+ uid: number;
29
+ gid: number;
30
+ }
31
+ /** Minimal `fstat(fd)` view needed to compare a staged descriptor's real `(uid, gid)`. */
32
+ export interface DescriptorOwnerView {
33
+ uid: number;
34
+ gid: number;
35
+ }
36
+ /** Maximum valid POSIX `uid`/`gid` for `fchown`; `0xffff_ffff` is the `(uid_t)-1` no-op sentinel. */
37
+ export declare const MAX_POSIX_OWNER_ID = 4294967294;
38
+ /** Exclusive create flags for staging files: refuses existing files and symbolic links. */
39
+ export declare function stagingOpenFlags(): number;
40
+ /** Validate `options.mode` eagerly before opening any staging file or narrowing bits. */
41
+ export declare function assertWriteMode(mode: unknown, defaultMode: number): number;
42
+ /**
43
+ * Validate and snapshot the ownership policy once up front. Option types and combinations throw
44
+ * `TypeError` before the Windows platform refusal so malformed inputs fail uniformly everywhere.
45
+ */
46
+ export declare function resolveAtomicOwnerPolicy(options: {
47
+ readonly replace?: boolean;
48
+ readonly owner?: unknown;
49
+ }, platform?: string): AtomicOwnerPolicy;
50
+ /**
51
+ * When ownership will be adjusted before publication, strip group/other bits at `open` time so
52
+ * the staging file is never readable by the process's prior group before `fchown` and `fchmod`.
53
+ */
54
+ export declare function initialCreateMode(mode: number, policy: AtomicOwnerPolicy): number;
55
+ /** Resolve the target `(uid, gid)` asynchronously; missing or non-regular targets yield `undefined`. */
56
+ export declare function resolveDesiredOwner(target: string, policy: AtomicOwnerPolicy, lstatTarget: (path: string) => Promise<TargetLstatView>): Promise<WriteFileAtomicOwner | undefined>;
57
+ /** Synchronous counterpart of {@link resolveDesiredOwner}. */
58
+ export declare function resolveDesiredOwnerSync(target: string, policy: AtomicOwnerPolicy, lstatTarget: (path: string) => TargetLstatView): WriteFileAtomicOwner | undefined;
59
+ /**
60
+ * Apply `desired` to an open staged descriptor after inspecting its real `fstat(fd)`. Skips
61
+ * `fchown` when the inode already matches, and refuses unchangeable sentinel IDs instead of
62
+ * letting POSIX `fchown` silently ignore `(uid_t)-1`.
63
+ */
64
+ export declare function applyAtomicFileOwner(file: {
65
+ stat(): Promise<DescriptorOwnerView>;
66
+ chown(uid: number, gid: number): Promise<void>;
67
+ }, desired: WriteFileAtomicOwner | undefined): Promise<void>;
68
+ /** Synchronous counterpart of {@link applyAtomicFileOwner}. */
69
+ export declare function applyAtomicFileOwnerSync(file: {
70
+ stat(): DescriptorOwnerView;
71
+ chown(uid: number, gid: number): void;
72
+ }, desired: WriteFileAtomicOwner | undefined): void;
73
+ /** Normalized write options resolved once up front for both async and sync atomic writes. */
74
+ export interface ResolvedAtomicWriteOptions {
75
+ readonly mode: number;
76
+ readonly replace: boolean;
77
+ readonly idempotent: boolean;
78
+ readonly durability: 'none' | 'file' | 'directory';
79
+ readonly ownerPolicy: AtomicOwnerPolicy;
80
+ }
81
+ /** Validate and snapshot every atomic-write option once up front before touching the filesystem. */
82
+ export declare function resolveAtomicWriteOptions(options: {
83
+ readonly mode?: unknown;
84
+ readonly replace?: boolean;
85
+ readonly idempotent?: boolean;
86
+ readonly durability?: 'none' | 'file' | 'directory';
87
+ readonly owner?: unknown;
88
+ }, defaultMode: number, platform?: string): ResolvedAtomicWriteOptions;
89
+ /** Check whether an existing target's `(uid, gid)` satisfies an explicit `owner` for `idempotent: true`. */
90
+ export declare function ownerMatches(actualUid: number | undefined, actualGid: number | undefined, policy: AtomicOwnerPolicy): boolean;
91
+ //# sourceMappingURL=atomic-file-owner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"atomic-file-owner.d.ts","sourceRoot":"","sources":["../../src/internal/atomic-file-owner.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,2GAA2G;AAC3G,MAAM,WAAW,oBAAoB;IACnC,sGAAsG;IACtG,QAAQ,CAAC,GAAG,EAAE,MAAM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,CAAC,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,WAAW,CAAC;IACpD,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;CAC1B,EACD,WAAW,EAAE,MAAM,EACnB,QAAQ,GAAE,MAAyB,GAClC,0BAA0B,CAU5B;AAED,4GAA4G;AAC5G,wBAAgB,YAAY,CAC1B,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAGT"}
@@ -20,6 +20,7 @@
20
20
  * synchronous `rename` on a loaded machine was measured holding a consumer's
21
21
  * main thread for ~15 s — every timer and request of a daemon stood still.
22
22
  */
23
+ import { type DescriptorOwnerView, type TargetLstatView, type WriteFileAtomicOwner } from './atomic-file-owner.js';
23
24
  import { type AtomicPublishOptions } from './atomic-publication.js';
24
25
  /** Options of {@link writeFileAtomic} and {@link writeFileAtomicSync}. */
25
26
  export interface WriteFileAtomicOptions {
@@ -35,8 +36,9 @@ export interface WriteFileAtomicOptions {
35
36
  /**
36
37
  * Only valid with `replace: false` (throws `TypeError` otherwise). When `true`
37
38
  * and `target` already exists, succeed without replacing it if the existing
38
- * regular file (not a symlink, FIFO, or directory) already has identical bytes
39
- * and matching permission bits (`mode`, on POSIX).
39
+ * regular file (not a symlink, FIFO, or directory) already has identical bytes,
40
+ * matching permission bits (`mode`, on POSIX), and matching `(uid, gid)` when an
41
+ * explicit `owner` is requested.
40
42
  */
41
43
  idempotent?: boolean;
42
44
  /**
@@ -44,12 +46,22 @@ export interface WriteFileAtomicOptions {
44
46
  * also fsyncs the parent after it; `'none'` does neither.
45
47
  */
46
48
  durability?: 'none' | 'file' | 'directory';
49
+ /**
50
+ * POSIX file ownership applied via `fchown` before `fchmod`, `fsync` and
51
+ * publication: `'preserve'` copies `(uid, gid)` from an existing regular file
52
+ * at `target` via `lstat` (requires `replace !== false`; missing or non-regular
53
+ * targets keep the kernel default), and `{ uid, gid }` sets an explicit owner.
54
+ * Compared against the staged descriptor's real `fstat(fd)`; unsupported on Windows.
55
+ */
56
+ owner?: 'preserve' | WriteFileAtomicOwner;
47
57
  }
48
58
  /** The staged file as a writer sees it; a `FileHandle` satisfies it. */
49
59
  export interface StagedFile {
50
60
  write(bytes: Uint8Array, offset: number, length: number): Promise<{
51
61
  bytesWritten: number;
52
62
  }>;
63
+ stat(): Promise<DescriptorOwnerView>;
64
+ chown(uid: number, gid: number): Promise<void>;
53
65
  chmod(mode: number): Promise<void>;
54
66
  sync(): Promise<void>;
55
67
  close(): Promise<void>;
@@ -70,14 +82,18 @@ export declare function writeAllBytes(file: StagedFile, bytes: Uint8Array): Prom
70
82
  */
71
83
  export declare function writeFileAtomic(target: string, data: Uint8Array | string, options?: WriteFileAtomicOptions): Promise<void>;
72
84
  interface AtomicFileWriteIO {
73
- open(path: string, flags: 'wx', mode: number): Promise<StagedFile>;
85
+ open(path: string, flags: number, mode: number): Promise<StagedFile>;
74
86
  unlink(path: string): Promise<void>;
75
87
  publish(staged: string, target: string, options: AtomicPublishOptions): Promise<void>;
88
+ lstat?(path: string): Promise<TargetLstatView>;
76
89
  readExisting?(target: string, maxBytes: number): Promise<{
77
90
  bytes: Uint8Array;
78
91
  mode: number | undefined;
92
+ uid?: number | undefined;
93
+ gid?: number | undefined;
79
94
  }>;
80
95
  syncDir?(dir: string): Promise<void>;
96
+ platform?: string;
81
97
  }
82
98
  /** How the staged bytes of one atomic write are produced and vetted. */
83
99
  export interface AtomicFileStage<T> {
@@ -90,9 +106,9 @@ export interface AtomicFileStage<T> {
90
106
  }
91
107
  /**
92
108
  * The one staging sequence behind every asynchronous atomic write: exclusive
93
- * create, fill, chmod, fsync, publication, and removal of the
94
- * staging file on any failure. Also the internal syscall seam for
95
- * publication-order and precommit fault controls.
109
+ * create with `O_NOFOLLOW`, fill, optional `fstat`/`fchown`, `fchmod`, `fsync`,
110
+ * publication, and removal of the staging file on any failure. Also the internal
111
+ * syscall seam for publication-order and precommit fault controls.
96
112
  */
97
113
  export declare function writeAtomicFileStaged<T>(target: string, stage: AtomicFileStage<T>, options: WriteFileAtomicOptions, io?: AtomicFileWriteIO): Promise<T>;
98
114
  /** {@link writeAtomicFileStaged} for bytes already in memory. */
@@ -100,19 +116,25 @@ export declare function writeAtomicFileData(target: string, data: Uint8Array | s
100
116
  /** The staged file of the synchronous form. */
101
117
  interface StagedFileSync {
102
118
  write(bytes: Uint8Array, offset: number, length: number): number;
119
+ stat(): DescriptorOwnerView;
120
+ chown(uid: number, gid: number): void;
103
121
  chmod(mode: number): void;
104
122
  sync(): void;
105
123
  close(): void;
106
124
  }
107
125
  interface AtomicFileWriteSyncIO {
108
- open(path: string, flags: 'wx', mode: number): StagedFileSync;
126
+ open(path: string, flags: number, mode: number): StagedFileSync;
109
127
  unlink(path: string): void;
110
128
  publish(staged: string, target: string, options: AtomicPublishOptions): void;
129
+ lstat?(path: string): TargetLstatView;
111
130
  readExisting?(target: string, maxBytes: number): {
112
131
  bytes: Uint8Array;
113
132
  mode: number;
133
+ uid?: number | undefined;
134
+ gid?: number | undefined;
114
135
  };
115
136
  syncDir?(dir: string): void;
137
+ platform?: string;
116
138
  }
117
139
  /**
118
140
  * The synchronous form of {@link writeFileAtomic}, with the same guarantees in
@@ -1 +1 @@
1
- {"version":3,"file":"atomic-file.d.ts","sourceRoot":"","sources":["../../src/internal/atomic-file.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAKH,OAAO,EAEL,KAAK,oBAAoB,EAK1B,MAAM,sBAAsB,CAAC;AAM9B,0EAA0E;AAC1E,MAAM,WAAW,sBAAsB;IACrC;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,8EAA8E;IAC9E,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;I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
+ uid?: number | undefined;
40
+ gid?: number | undefined;
39
41
  /** Exact nanosecond post-read stat when the open descriptor supports `{ bigint: true }`. */
40
42
  after?: NanosecondFileStats;
41
43
  }
@@ -51,13 +53,15 @@ export interface BoundedFileReadSyncOptions extends FileOpenOptions {
51
53
  /**
52
54
  * Synchronous counterpart of {@link readBoundedFile}: opens with `O_RDONLY | O_NONBLOCK`
53
55
  * (plus `O_NOFOLLOW` when `rejectSymlinks` is true), validates `fstat` regular file and
54
- * link/size caps (including `maxBytes === 0`), and returns bytes, observation, mode and
55
- * the nanosecond `fstat` taken after the read (`after`) for an exact identity.
56
+ * link/size caps (including `maxBytes === 0`), and returns bytes, observation, mode, uid,
57
+ * gid and the nanosecond `fstat` taken after the read (`after`) for an exact identity.
56
58
  */
57
59
  export declare function readBoundedFileSync(target: string, maxBytes: number, options?: BoundedFileReadSyncOptions, openFd?: (path: string, flags: number) => number, snapshot?: BoundedFileSnapshotSyncHooks): {
58
60
  bytes: Uint8Array;
59
61
  observation: FileObservation;
60
62
  mode: number;
63
+ uid: number;
64
+ gid: number;
61
65
  after: BigIntStats;
62
66
  };
63
67
  export declare function readHandle(handle: {
@@ -1 +1 @@
1
- {"version":3,"file":"bounded-file-read.d.ts","sourceRoot":"","sources":["../../src/internal/bounded-file-read.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAMjB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,KAAK,UAAU,EAAQ,MAAM,kBAAkB,CAAC;AACzD,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,4BAA4B,EAYlC,MAAM,wBAAwB,CAAC;AAGhC,OAAO,KAAK,EACV,eAAe,EACf,kBAAkB,EAClB,YAAY,EACZ,aAAa,EACb,mBAAmB,EACpB,MAAM,oBAAoB,CAAC;AAE5B,qBAAa,oBAAqB,SAAQ,KAAK;IAE3C,QAAQ,CAAC,IAAI,EACT,kBAAkB,GAClB,kBAAkB,GAClB,kBAAkB,GAClB,gBAA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AAM,EAChB,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,UAAU,CAAC,CAgCrB"}
1
+ {"version":3,"file":"bounded-file-read.d.ts","sourceRoot":"","sources":["../../src/internal/bounded-file-read.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAMjB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,KAAK,UAAU,EAAQ,MAAM,kBAAkB,CAAC;AACzD,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,4BAA4B,EAYlC,MAAM,wBAAwB,CAAC;AAGhC,OAAO,KAAK,EACV,eAAe,EACf,kBAAkB,EAClB,YAAY,EACZ,aAAa,EACb,mBAAmB,EACpB,MAAM,oBAAoB,CAAC;AAE5B,qBAAa,oBAAqB,SAAQ,KAAK;IAE3C,QAAQ,CAAC,IAAI,EACT,kBAAkB,GAClB,kBAAkB,GAClB,kBAAkB,GAClB,gBAAgB,GAChB,cAAc;IAElB,QAAQ,CAAC,WAAW,CAAC,EAAE,eAAe;IARxC,YACW,IAAI,EACT,kBAAkB,GAClB,kBAAkB,GAClB,kBAAkB,GAClB,gBAAgB,GAChB,cAAc,EAClB,OAAO,EAAE,MAAM,EACN,WAAW,CAAC,EAAE,eAAe,YAAA,EACtC,OAAO,CAAC,EAAE,YAAY,EAIvB;CACF;AAED,MAAM,WAAW,eAAe;IAC9B,0GAA0G;IAC1G,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,kFAAkF;IAClF,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,sBAAsB,CAAC,CAAC,SAAS,YAAY,GAAG,YAAY,CAC3E,SAAQ,eAAe;IACvB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,iGAAiG;IACjG,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,GAAG,aAAa,KAAK,IAAI,CAAC;CAC/C;AAED,wBAAgB,qBAAqB,CAA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,CAAC;IACjB,gGAAgG;IAChG,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;CAC1C;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,0BAA+B,EACxC,MAAM,GAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAiB,EAC1D,QAAQ,GAAE,4BAAiC,GAC1C;IACD,KAAK,EAAE,UAAU,CAAC;IAClB,WAAW,EAAE,eAAe,CAAC;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,WAAW,CAAC;CACpB,CAuFA;AAED,wBAAsB,UAAU,CAC9B,MAAM,EAAE;IACN,IAAI,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC1F,EACD,QAAQ,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,UAAU,CAAC,CAgCrB"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Configuration validation and safe path matching for `createCliDistributionRoutes`.
3
+ */
4
+ import type { CliSignatureVerdict, CliTrustRoot } from './signature.js';
5
+ export declare const SAFE_ASSET_SEGMENT: RegExp;
6
+ /** Diagnostic event emitted when a CLI distribution route responds with 503 or 404. */
7
+ export interface CliDistributionUnavailableEvent {
8
+ readonly route: 'manifest' | 'version-manifest' | 'asset' | 'installer';
9
+ readonly channel: string;
10
+ readonly version?: string;
11
+ readonly asset?: string;
12
+ readonly reason: 'unconfigured-root' | 'empty-trust-root' | 'missing' | 'unsafe-path' | 'too-large' | 'invalid-manifest' | 'identity-mismatch' | 'untrusted-signature' | 'unlisted-asset' | 'io-error';
13
+ readonly verdict?: CliSignatureVerdict;
14
+ readonly error?: unknown;
15
+ }
16
+ /** Configuration for {@link createCliDistributionRoutes}. */
17
+ export interface CliDistributionRoutesOptions {
18
+ /** Absolute path to the CLI distribution root directory, or `undefined` to serve 503 fail-closed. */
19
+ readonly root: string | undefined;
20
+ /** Expected `manifest.name` verified against the signed manifest on every request. */
21
+ readonly name: string;
22
+ /** Trust root whose Ed25519 public keys verify manifest signatures; empty `keys` fails closed with 503. */
23
+ readonly trust: CliTrustRoot;
24
+ /** Release channels mounted under `${basePath}/channels/<channel>/...` (default `['stable', 'beta']`). */
25
+ readonly channels?: readonly string[];
26
+ /** Channel served by `${basePath}/install.sh` (defaults to the first entry of `channels`). */
27
+ readonly installerChannel?: string;
28
+ /** URL path prefix for the routes (default `'/cli'`; `'/'` mounts at root). */
29
+ readonly basePath?: string;
30
+ /** Binary filename written into `install.sh` (defaults to `name`). */
31
+ readonly binaryName?: string;
32
+ /** Default `INSTALL_DIR` in `install.sh` (default `'$HOME/.local/bin'`). */
33
+ readonly installDir?: string;
34
+ /** Maximum byte size read for any manifest file (default `256 * 1024`). */
35
+ readonly maxManifestBytes?: number;
36
+ /** Optional `RawRoute.serviceName` attached to every returned route for observability. */
37
+ readonly serviceName?: string;
38
+ /** Optional observer invoked when a manifest or asset is unavailable or refused; throws are isolated. */
39
+ readonly onUnavailable?: (event: CliDistributionUnavailableEvent) => void;
40
+ }
41
+ export interface ResolvedDistributionConfig {
42
+ readonly root: string | undefined;
43
+ readonly name: string;
44
+ readonly trust: CliTrustRoot;
45
+ readonly channels: readonly string[];
46
+ readonly installerChannel: string;
47
+ readonly basePath: string;
48
+ readonly binaryName: string;
49
+ readonly installDir: string;
50
+ readonly maxManifestBytes: number;
51
+ readonly serviceName: string | undefined;
52
+ readonly onUnavailable: ((event: CliDistributionUnavailableEvent) => void) | undefined;
53
+ }
54
+ export declare function resolveDistributionConfig(options: CliDistributionRoutesOptions): ResolvedDistributionConfig;
55
+ export declare function assetMatchesUrl(entryUrl: string, asset: string): boolean;
56
+ //# sourceMappingURL=distribution-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"distribution-config.d.ts","sourceRoot":"","sources":["../../../src/tools/cli/distribution-config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,KAAK,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AASrE,eAAO,MAAM,kBAAkB,QAAiC,CAAC;AAKjE,uFAAuF;AACvF,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,CAAC,KAAK,EAAE,UAAU,GAAG,kBAAkB,GAAG,OAAO,GAAG,WAAW,CAAC;IACxE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EACX,mBAAmB,GACnB,kBAAkB,GAClB,SAAS,GACT,aAAa,GACb,WAAW,GACX,kBAAkB,GAClB,mBAAmB,GACnB,qBAAqB,GACrB,gBAAgB,GAChB,UAAU,CAAC;IACf,QAAQ,CAAC,OAAO,CAAC,EAAE,mBAAmB,CAAC;IACvC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,6DAA6D;AAC7D,MAAM,WAAW,4BAA4B;IAC3C,qGAAqG;IACrG,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,sFAAsF;IACtF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,2GAA2G;IAC3G,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,0GAA0G;IAC1G,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,8FAA8F;IAC9F,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACnC,+EAA+E;I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HTTP distribution routes for a published CLI channel (`stitchkit/cli/publish`).
3
+ *
4
+ * Serves signed channel manifests, immutable versioned manifests and binary assets, and the
5
+ * generated shell installer as portable `RawRoute[]` (compatible with `stitchkit/handler`,
6
+ * `stitchkit/server` and `stitchkit/node`). Every read verifies
7
+ * ancestor directory containment (`realpath` + `isWithinDir`), leaf `O_NOFOLLOW`, strict UTF-8
8
+ * JSON without `__proto__`, exact manifest identity and Ed25519 signature (`verdict === 'valid'`),
9
+ * and streams binaries directly from an open descriptor without `Bun.file`.
10
+ */
11
+ import type { RawRoute } from '../../server/types.js';
12
+ import { type CliDistributionRoutesOptions } from './distribution-config.js';
13
+ /**
14
+ * Create portable `RawRoute[]` handlers serving signed CLI channel manifests, immutable
15
+ * versioned manifests and binary assets, and `install.sh` (`GET` only, full-body descriptor
16
+ * streaming). Fails closed with `503 No verified CLI build is published` when unconfigured,
17
+ * missing, unsigned, or untrusted.
18
+ */
19
+ export declare function createCliDistributionRoutes(options: CliDistributionRoutesOptions): RawRoute[];
20
+ //# sourceMappingURL=distribution-routes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"distribution-routes.d.ts","sourceRoot":"","sources":["../../../src/tools/cli/distribution-routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAQH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAEL,KAAK,4BAA4B,EAKlC,MAAM,uBAAuB,CAAC;AAuS/B;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,4BAA4B,GACpC,QAAQ,EAAE,CAwCZ"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Git-backed CLI source verification and shipping-input versioning for `stitchkit/cli/publish`.
3
+ *
4
+ * Versions derived from shipping inputs pair the declared `major.minor` series in the CLI package
5
+ * manifest at `<commit>` with the full commit count touching `shippingPaths` up to `<commit>`.
6
+ * Every git invocation runs through `runNativeCommand` with a declared-only environment so parent
7
+ * hook variables (`GIT_DIR`, `GIT_WORK_TREE`, `GIT_INDEX_FILE`) cannot silently redirect checks.
8
+ */
9
+ /** Options for {@link deriveCliVersionFromShippingInputs}. */
10
+ export interface CliShippingVersionOptions {
11
+ /** Absolute path to the git repository root (worktree root or bare repository root). */
12
+ readonly repository: string;
13
+ /** Exact 40-lowercase-hex commit SHA whose shipping inputs determine the version. */
14
+ readonly commit: string;
15
+ /** Repository-relative POSIX path to the package manifest declaring `major.minor` (e.g. `'packages/cli/package.json'`). */
16
+ readonly packageJsonPath: string;
17
+ /** Non-empty list of repository-relative paths whose history determines the patch number. */
18
+ readonly shippingPaths: readonly string[];
19
+ /** End-to-end deadline across all git checks in milliseconds (default `30_000`). */
20
+ readonly timeoutMs?: number;
21
+ /** Optional cancellation signal bound to the git checks. */
22
+ readonly signal?: AbortSignal;
23
+ }
24
+ /** Options for {@link cliShippingInputsChanged}. */
25
+ export interface CliShippingInputsChangedOptions {
26
+ /** Absolute path to the git repository root (worktree root or bare repository root). */
27
+ readonly repository: string;
28
+ /** Earlier 40-lowercase-hex commit SHA. */
29
+ readonly previousCommit: string;
30
+ /** Later 40-lowercase-hex commit SHA. */
31
+ readonly nextCommit: string;
32
+ /** Non-empty list of repository-relative paths to compare between the two commits. */
33
+ readonly shippingPaths: readonly string[];
34
+ /** End-to-end deadline across all git checks in milliseconds (default `30_000`). */
35
+ readonly timeoutMs?: number;
36
+ /** Optional cancellation signal bound to the git checks. */
37
+ readonly signal?: AbortSignal;
38
+ }
39
+ /** Options for {@link assertCleanCliSource}. */
40
+ export interface CleanCliSourceOptions {
41
+ /** Absolute path to the git working tree root directory (bare repositories are refused). */
42
+ readonly repository: string;
43
+ /** When set, `HEAD` must resolve to this exact 40-lowercase-hex commit SHA. */
44
+ readonly expectedCommit?: string;
45
+ /**
46
+ * When omitted, any untracked file in the worktree is refused. When set to a non-empty list
47
+ * of repository-relative paths or `*` globs, untracked files are refused only under those
48
+ * paths (allowing sibling runtime state outside shipping inputs).
49
+ */
50
+ readonly untrackedPaths?: readonly string[];
51
+ /** When set, verifies `realpath(servingSource) === realpath(repository)`. */
52
+ readonly servingSource?: string;
53
+ /** End-to-end deadline across all git checks in milliseconds (default `30_000`). */
54
+ readonly timeoutMs?: number;
55
+ /** Optional cancellation signal bound to the git checks. */
56
+ readonly signal?: AbortSignal;
57
+ }
58
+ /**
59
+ * Derive a CLI semver string from `<commit>`: `major.minor` from `packageJsonPath` at `<commit>`
60
+ * paired with the full commit count touching `shippingPaths` up to `<commit>`. Accepts a git
61
+ * worktree root or bare repository root; refuses shallow repositories, non-commit SHAs,
62
+ * subdirectories and non-bare `.git` directories.
63
+ */
64
+ export declare function deriveCliVersionFromShippingInputs(options: CliShippingVersionOptions): Promise<string>;
65
+ /**
66
+ * Return `true` when any path in `shippingPaths` differs between `previousCommit` and
67
+ * `nextCommit`. Accepts a git worktree root or bare repository root, refuses non-commit SHAs,
68
+ * and uses `git diff --no-ext-diff --quiet`.
69
+ */
70
+ export declare function cliShippingInputsChanged(options: CliShippingInputsChangedOptions): Promise<boolean>;
71
+ /**
72
+ * Verify that `repository` is a clean git root matching `expectedCommit` (when set), with no
73
+ * tracked changes, no disallowed untracked files, and optional `servingSource` realpath identity.
74
+ * Returns the verified 40-lowercase-hex `HEAD` commit SHA.
75
+ */
76
+ export declare function assertCleanCliSource(options: CleanCliSourceOptions): Promise<string>;
77
+ //# sourceMappingURL=publication-source.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"publication-source.d.ts","sourceRoot":"","sources":["../../../src/tools/cli/publication-source.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAwBH,8DAA8D;AAC9D,MAAM,WAAW,yBAAyB;IACxC,wFAAwF;IACxF,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,qFAAqF;IACrF,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,2HAA2H;IAC3H,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,6FAA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A+B,GACvC,OAAO,CAAC,OAAO,CAAC,CA2BlB;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,MAAM,CAAC,CAmE1F"}
@@ -14,9 +14,12 @@ Also read:
14
14
 
15
15
  ## `stitchkit/cli/publish`
16
16
 
17
- Build and release tooling, evolving. Publishes a CLI distribution into a local
18
- application-owned directory; the manifest, signatures, installer and updater it
19
- writes for stay in `stitchkit/cli` — [guide](../guide/cli.md#publishing-a-complete-version),
17
+ Build, source verification and distribution-route tooling, evolving. Publishes a
18
+ CLI distribution into a local application-owned directory, derives deterministic
19
+ versions from git shipping-input history, verifies clean source roots, and
20
+ serves verified channel manifests, immutable assets and `install.sh` over
21
+ `RawRoute[]`; the manifest, signatures, installer and updater it writes for stay
22
+ in `stitchkit/cli` — [guide](../guide/cli.md#publishing-a-complete-version),
20
23
  [ADR 0245](../decisions/0245-cli-publication-is-an-evolving-leaf.md).
21
24
 
22
25
  | Export | Kind | Summary |
@@ -25,5 +28,14 @@ writes for stay in `stitchkit/cli` — [guide](../guide/cli.md#publishing-a-comp
25
28
  | `CliPublicationOptions` | _type_ | identity, storage root, base URL, targets, limits, retention, the `admit` and `build` callbacks, optional signing and trust |
26
29
  | `CliPublicationPhase` | _type_ | the step `admit` is asked about — `prepare`, `build`, `commit` or `promote` |
27
30
  | `CliPublicationResult` | _type_ | `published` or `existing`, with the manifest ready to serve |
31
+ | `deriveCliVersionFromShippingInputs` | function | derive `major.minor.<count>` from `packageJsonPath` at `<commit>` and the full git commit count touching `shippingPaths`; accepts worktree or bare repository roots and refuses shallow clones, subdirectories, non-bare `.git` dirs and non-commit SHAs |
32
+ | `CliShippingVersionOptions` | _type_ | options for `deriveCliVersionFromShippingInputs` (`repository`, `commit`, `packageJsonPath`, `shippingPaths`, `timeoutMs`, `signal`) |
33
+ | `cliShippingInputsChanged` | function | return `true` when any path in `shippingPaths` differs between `previousCommit` and `nextCommit` using `git diff --no-ext-diff --quiet` |
34
+ | `CliShippingInputsChangedOptions` | _type_ | options for `cliShippingInputsChanged` (`repository`, `previousCommit`, `nextCommit`, `shippingPaths`, `timeoutMs`, `signal`) |
35
+ | `assertCleanCliSource` | function | verify a clean git root matching optional `expectedCommit`, optional `untrackedPaths` globs and optional `servingSource` realpath; returns verified 40-hex `HEAD` |
36
+ | `CleanCliSourceOptions` | _type_ | options for `assertCleanCliSource` (`repository`, `expectedCommit`, `untrackedPaths`, `servingSource`, `timeoutMs`, `signal`) |
37
+ | `createCliDistributionRoutes` | function | portable `RawRoute[]` (`GET` only) serving verified signed channel manifests (`no-store`), immutable versioned manifests and descriptor-streamed binary assets, and `install.sh`, failing closed with `503 No verified CLI build is published` |
38
+ | `CliDistributionRoutesOptions` | _type_ | options for `createCliDistributionRoutes` (`root`, `name`, `trust`, `channels`, `installerChannel`, `basePath`, `binaryName`, `installDir`, `maxManifestBytes`, `serviceName`, `onUnavailable`) |
39
+ | `CliDistributionUnavailableEvent` | _type_ | diagnostic event passed to `onUnavailable` with `route`, `channel`, optional `version`/`asset`, inline `reason`, optional `verdict` and `error` |
28
40
 
29
41
  ---