stitchkit 0.83.1 → 0.83.2

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 CHANGED
@@ -15,6 +15,19 @@ additive**; the first breaking change landed in 0.10.0. Grep the file for
15
15
 
16
16
  ## [Unreleased]
17
17
 
18
+ ## [0.83.2] — 2026-09-07
19
+
20
+ ### Added
21
+
22
+ - **Agent coding tools can enforce one path policy before disclosure or content reads.**
23
+ `createAgentCodingTools({ authorizePath })` accepts an async or synchronous callback shared by
24
+ direct read/write/edit, `list_directory`, `glob` and both `search_files` modes. Direct access to a
25
+ denied path returns `FORBIDDEN`; discovery omits it. The contained walker applies the decision
26
+ before descending into a directory or opening a file, and `search_files.include` now filters
27
+ before reading instead of after the whole scan. This lets a host protect `.env` or credential
28
+ paths without copying the framework scanner. Shell remains explicitly outside the guarantee: an
29
+ executable requires process isolation, not path filtering. → ADR 0172.
30
+
18
31
  ## [0.83.1] — 2026-09-07
19
32
 
20
33
  ### Fixed
@@ -58,9 +58,20 @@ export declare const AgentCodingToolAuthorizationSchema: z.ZodDiscriminatedUnion
58
58
  }, z.core.$strict>], "operation">;
59
59
  export type AgentCodingToolLimits = z.infer<typeof AgentCodingToolLimitsSchema>;
60
60
  export type AgentCodingToolAuthorization = z.infer<typeof AgentCodingToolAuthorizationSchema>;
61
+ export declare const AgentCodingToolPathAuthorizationSchema: z.ZodObject<{
62
+ path: z.ZodString;
63
+ }, z.core.$strict>;
64
+ export type AgentCodingToolPathAuthorization = z.infer<typeof AgentCodingToolPathAuthorizationSchema>;
61
65
  export interface AgentCodingToolConfig {
62
66
  root: string;
63
67
  authorize(input: AgentCodingToolAuthorization): boolean | Promise<boolean>;
68
+ /**
69
+ * One operation-independent admission policy for workspace paths.
70
+ *
71
+ * A denied path is refused by direct file tools and omitted from discovery.
72
+ * The callback runs before a file is opened or its content is read.
73
+ */
74
+ authorizePath?(input: AgentCodingToolPathAuthorization): boolean | Promise<boolean>;
64
75
  executables?: Readonly<Record<string, string>>;
65
76
  environment?: Readonly<Record<string, string>>;
66
77
  artifacts?: AgentCodingArtifactStore;
@@ -1 +1 @@
1
- {"version":3,"file":"coding-tool-contract.d.ts","sourceRoot":"","sources":["../../src/agent-runtime/coding-tool-contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;kBAgB7B,CAAC;AAEZ,eAAO,MAAM,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iCAsD7C,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAChF,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kCAAkC,CAAC,CAAC;AAE9F,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,KAAK,EAAE,4BAA4B,GAAG,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3E,WAAW,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC/C,WAAW,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC/C,SAAS,CAAC,EAAE,wBAAwB,CAAC;IACrC,MAAM,CAAC,EAAE;QACP,wEAAwE;QACxE,kBAAkB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;KACxC,CAAC;IACF,MAAM,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,CAAC;CACzC;AAED,MAAM,WAAW,wBAAwB;IACvC,KAAK,CAAC,KAAK,EAAE;QACX,SAAS,EAAE,MAAM,CAAC;QAClB,IAAI,EAAE,UAAU,CAAC;KAClB,GAAG;QAAE,SAAS,EAAE,MAAM,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E,CAAC;IAClD,OAAO,CAAC,OAAO,EAAE;QACf,MAAM,EAAE,SAAS,CAAC;QAClB,KAAK,EAAE,OAAO,CAAC;QACf,MAAM,CAAC,EAAE,WAAW,CAAC;QACrB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,GAAG,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAChC;AAED,eAAO,MAAM,mBAAmB;;;;kBAMrB,CAAC;AAEZ,eAAO,MAAM,oBAAoB;;;;;;;kBAStB,CAAC;AAEZ,eAAO,MAAM,oBAAoB;;;;kBAMtB,CAAC;AAEZ,eAAO,MAAM,qBAAqB;;;;kBAcvB,CAAC;AAEZ,wBAAgB,sBAAsB,CAAC,eAAe,EAAE,SAAS,MAAM,EAAE;;;;;;mBAWxE;AAED,eAAO,MAAM,gBAAgB;;;;kBAMlB,CAAC;AAEZ,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;kBAiBnB,CAAC;AAkBZ,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,OAAO,CAAC,qBAAqB,CAAC,GAAG,SAAS,GAChD,qBAAqB,CAEvB"}
@@ -1 +1 @@
1
- {"version":3,"file":"coding-tool-files.d.ts","sourceRoot":"","sources":["../../src/agent-runtime/coding-tool-files.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,EAC9B,KAAK,qBAAqB,EAK3B,MAAM,wBAAwB,CAAC;AA2BhC,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,qBAAqB,EAC7B,MAAM,EAAE,qBAAqB,GAC5B,SAAS,yBAAyB,EAAE,CAsJtC"}
1
+ {"version":3,"file":"coding-tool-files.d.ts","sourceRoot":"","sources":["../../src/agent-runtime/coding-tool-files.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,EAC9B,KAAK,qBAAqB,EAK3B,MAAM,wBAAwB,CAAC;AA+BhC,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,qBAAqB,EAC7B,MAAM,EAAE,qBAAqB,GAC5B,SAAS,yBAAyB,EAAE,CAwJtC"}
@@ -1 +1 @@
1
- {"version":3,"file":"coding-tool-listing.d.ts","sourceRoot":"","sources":["../../src/agent-runtime/coding-tool-listing.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,qBAAqB,EACrB,yBAAyB,EACzB,qBAAqB,EACtB,MAAM,wBAAwB,CAAC;AAShC,iFAAiF;AACjF,eAAO,MAAM,4BAA4B,UAQxC,CAAC;AAoCF;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CA2B5D;AAED,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,qBAAqB,EAC7B,MAAM,EAAE,qBAAqB,GAC5B,SAAS,yBAAyB,EAAE,CAmGtC"}
1
+ {"version":3,"file":"coding-tool-listing.d.ts","sourceRoot":"","sources":["../../src/agent-runtime/coding-tool-listing.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,qBAAqB,EACrB,yBAAyB,EACzB,qBAAqB,EACtB,MAAM,wBAAwB,CAAC;AAchC,iFAAiF;AACjF,eAAO,MAAM,4BAA4B,UAQxC,CAAC;AAoCF;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CA2B5D;AAED,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,qBAAqB,EAC7B,MAAM,EAAE,qBAAqB,GAC5B,SAAS,yBAAyB,EAAE,CAuGtC"}
@@ -13,6 +13,8 @@ export declare function editableCodingPath(root: string, requested: string, maxP
13
13
  relative: string;
14
14
  }>;
15
15
  export declare function authorizeCodingTool(config: AgentCodingToolConfig, request: AgentCodingToolAuthorization): Promise<void>;
16
+ export declare function isCodingPathAuthorized(config: AgentCodingToolConfig, path: string): Promise<boolean>;
17
+ export declare function authorizeCodingPath(config: AgentCodingToolConfig, path: string): Promise<void>;
16
18
  /** Serialize framework-owned compare-and-replace transactions for one canonical target. */
17
19
  export declare function withCodingPathLock<T>(target: string, work: () => Promise<T>): Promise<T>;
18
20
  export declare function textOccurrences(source: string, search: string): number;
@@ -1 +1 @@
1
- {"version":3,"file":"coding-tool-paths.d.ts","sourceRoot":"","sources":["../../src/agent-runtime/coding-tool-paths.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,4BAA4B,EAEjC,KAAK,qBAAqB,EAC3B,MAAM,wBAAwB,CAAC;AAkChC,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAezF;AAED,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM;;;GAKrB;AAED,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM;;;GAarB;AAED,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM;;;GAQrB;AAED,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,qBAAqB,EAC7B,OAAO,EAAE,4BAA4B,GACpC,OAAO,CAAC,IAAI,CAAC,CAGf;AAID,2FAA2F;AAC3F,wBAAsB,kBAAkB,CAAC,CAAC,EACxC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACrB,OAAO,CAAC,CAAC,CAAC,CAeZ;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAUtE"}
1
+ {"version":3,"file":"coding-tool-paths.d.ts","sourceRoot":"","sources":["../../src/agent-runtime/coding-tool-paths.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,4BAA4B,EAEjC,KAAK,qBAAqB,EAE3B,MAAM,wBAAwB,CAAC;AAkChC,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAezF;AAED,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM;;;GAKrB;AAED,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM;;;GAarB;AAED,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM;;;GAQrB;AAED,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,qBAAqB,EAC7B,OAAO,EAAE,4BAA4B,GACpC,OAAO,CAAC,IAAI,CAAC,CAGf;AAED,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,qBAAqB,EAC7B,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,OAAO,CAAC,CAIlB;AAED,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,qBAAqB,EAC7B,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,IAAI,CAAC,CAIf;AAID,2FAA2F;AAC3F,wBAAsB,kBAAkB,CAAC,CAAC,EACxC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACrB,OAAO,CAAC,CAAC,CAAC,CAeZ;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAUtE"}
@@ -1 +1 @@
1
- {"version":3,"file":"coding-tool-search-patch.d.ts","sourceRoot":"","sources":["../../src/agent-runtime/coding-tool-search-patch.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,qBAAqB,EACrB,yBAAyB,EACzB,qBAAqB,EACtB,MAAM,wBAAwB,CAAC;AAuHhC,wBAAgB,+BAA+B,CAC7C,MAAM,EAAE,qBAAqB,EAC7B,MAAM,EAAE,qBAAqB,GAC5B,SAAS,yBAAyB,EAAE,CAkMtC"}
1
+ {"version":3,"file":"coding-tool-search-patch.d.ts","sourceRoot":"","sources":["../../src/agent-runtime/coding-tool-search-patch.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,qBAAqB,EACrB,yBAAyB,EACzB,qBAAqB,EACtB,MAAM,wBAAwB,CAAC;AAyHhC,wBAAgB,+BAA+B,CAC7C,MAAM,EAAE,qBAAqB,EAC7B,MAAM,EAAE,qBAAqB,GAC5B,SAAS,yBAAyB,EAAE,CAuMtC"}
@@ -31,7 +31,7 @@ interface ContainedEntryMetadata {
31
31
  isSymbolicLink(): boolean;
32
32
  }
33
33
  /** One directory's direct children, read through pinned descriptors. */
34
- export declare function listContainedDirectory(root: string, relative: string, maxEntries: number): Promise<{
34
+ export declare function listContainedDirectory(root: string, relative: string, maxEntries: number, authorizePath?: (relative: string) => boolean | Promise<boolean>): Promise<{
35
35
  entries: {
36
36
  name: string;
37
37
  kind: 'file' | 'directory' | 'symlink' | 'other';
@@ -93,6 +93,7 @@ export declare function scanContainedFiles(input: {
93
93
  readMaxBytes?: number;
94
94
  skipUnreadable?: boolean;
95
95
  excludeDirectory?: (relative: string) => boolean;
96
+ authorizePath?: (relative: string, kind: 'file' | 'directory' | 'symlink' | 'other') => boolean | Promise<boolean>;
96
97
  }): Promise<ContainedFileScan>;
97
98
  export {};
98
99
  //# sourceMappingURL=contained-files.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"contained-files.d.ts","sourceRoot":"","sources":["../../src/agent-runtime/contained-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,KAAK,EAEX,MAAM,SAAS,CAAC;AAejB,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK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izationSchema, type AgentCodingToolConfig, type AgentCodingToolDefinition, type AgentCodingToolLimits, AgentCodingToolLimitsSchema, createAgentCodingTools, } from './agent-runtime/coding-tools.js';
1
+ export { type AgentCodingArtifactStore, type AgentCodingToolAuthorization, AgentCodingToolAuthorizationSchema, type AgentCodingToolConfig, type AgentCodingToolDefinition, type AgentCodingToolLimits, AgentCodingToolLimitsSchema, type AgentCodingToolPathAuthorization, AgentCodingToolPathAuthorizationSchema, createAgentCodingTools, } from './agent-runtime/coding-tools.js';
2
2
  //# sourceMappingURL=agent-runtime-coding-tools.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"agent-runtime-coding-tools.d.ts","sourceRoot":"","sources":["../src/agent-runtime-coding-tools.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,4BAA4B,EACjC,kCAAkC,EAClC,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,EAC9B,KAAK,qBAAqB,EAC1B,2BAA2B,EAC3B,sBAAsB,GACvB,MAAM,8BAA8B,CAAC"}
1
+ {"version":3,"file":"agent-runtime-coding-tools.d.ts","sourceRoot":"","sources":["../src/agent-runtime-coding-tools.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,4BAA4B,EACjC,kCAAkC,EAClC,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,EAC9B,KAAK,qBAAqB,EAC1B,2BAA2B,EAC3B,KAAK,gCAAgC,EACrC,sCAAsC,EACtC,sBAAsB,GACvB,MAAM,8BAA8B,CAAC"}
@@ -10,7 +10,7 @@ import {
10
10
  readContainedUtf8Handle,
11
11
  scanContainedFiles,
12
12
  writeContainedFile
13
- } from "./index-rqpdar1e.js";
13
+ } from "./index-t7gh5w3v.js";
14
14
  import {
15
15
  defineRuntimeTool
16
16
  } from "./index-dx9xehwt.js";
@@ -89,6 +89,7 @@ var AgentCodingToolAuthorizationSchema = z.discriminatedUnion("operation", [
89
89
  cwd: z.string().min(1)
90
90
  }).strict()
91
91
  ]);
92
+ var AgentCodingToolPathAuthorizationSchema = z.object({ path: z.string().min(1) }).strict();
92
93
  var FileReadInputSchema = z.object({
93
94
  path: z.string().min(1),
94
95
  offset: z.int().nonnegative().default(0),
@@ -262,6 +263,17 @@ async function authorizeCodingTool(config, request) {
262
263
  if (!await config.authorize(parsed))
263
264
  forbidden("Coding tool permission denied");
264
265
  }
266
+ async function isCodingPathAuthorized(config, path2) {
267
+ if (!config.authorizePath)
268
+ return true;
269
+ const parsed = AgentCodingToolPathAuthorizationSchema.parse({ path: path2 });
270
+ return await config.authorizePath(parsed);
271
+ }
272
+ async function authorizeCodingPath(config, path2) {
273
+ if (!await isCodingPathAuthorized(config, path2)) {
274
+ forbidden("Coding tool path permission denied");
275
+ }
276
+ }
265
277
  var codingPathLocks = new Map;
266
278
  async function withCodingPathLock(target, work) {
267
279
  const previous = codingPathLocks.get(target) ?? Promise.resolve();
@@ -320,6 +332,7 @@ function createFileCodingTools(config, limits) {
320
332
  handler: async ({ input }) => {
321
333
  const root = await realpath2(config.root);
322
334
  const relative = boundedCodingRelativePath(input.path, limits.maxPathBytes);
335
+ await authorizeCodingPath(config, relative);
323
336
  const handle = await openContainedFile(root, relative).catch((error) => refuseMissingCodingPath(error, relative));
324
337
  const maximum = Math.min(input.maxBytes ?? limits.maxReadBytes, limits.maxReadBytes);
325
338
  let selected;
@@ -366,6 +379,7 @@ function createFileCodingTools(config, limits) {
366
379
  handler: async ({ input }) => {
367
380
  const root = await realpath2(config.root);
368
381
  const relative = boundedCodingRelativePath(input.path, limits.maxPathBytes);
382
+ await authorizeCodingPath(config, relative);
369
383
  const bytes = Buffer.byteLength(input.content);
370
384
  if (bytes > limits.maxWriteBytes) {
371
385
  codingPathRefusal("BAD_REQUEST", `The content is ${bytes} bytes, over the ${limits.maxWriteBytes}-byte limit`, relative, {
@@ -500,8 +514,9 @@ function createListingCodingTools(config, limits) {
500
514
  handler: async ({ input }) => {
501
515
  const root = await realpath3(config.root);
502
516
  const relative = input.path === "." ? "." : boundedCodingRelativePath(input.path, limits.maxPathBytes);
517
+ await authorizeCodingPath(config, relative);
503
518
  await authorizeCodingTool(config, { operation: "list", path: relative });
504
- const listing = await listContainedDirectory(root, relative, limits.maxListEntries).catch((error) => {
519
+ const listing = await listContainedDirectory(root, relative, limits.maxListEntries, (candidate) => isCodingPathAuthorized(config, candidate)).catch((error) => {
505
520
  if (error instanceof Error && error.message.includes("ancestor is not a directory")) {
506
521
  codingPathRefusal("BAD_REQUEST", "This path is not a directory", relative, {
507
522
  hint: "Pass a directory; use read_file for a file."
@@ -533,6 +548,7 @@ function createListingCodingTools(config, limits) {
533
548
  transports: ["AGENT"],
534
549
  handler: async ({ input }) => {
535
550
  const relative = input.path === "." ? "." : boundedCodingRelativePath(input.path, limits.maxPathBytes);
551
+ await authorizeCodingPath(config, relative);
536
552
  await authorizeCodingTool(config, {
537
553
  operation: "glob",
538
554
  pattern: input.pattern,
@@ -553,7 +569,8 @@ function createListingCodingTools(config, limits) {
553
569
  maxDepth: limits.maxSearchDepth,
554
570
  maxFiles: limits.maxSearchFiles,
555
571
  symlinks: "skip",
556
- excludeDirectory: (directory) => directory.split(path2.sep).some((segment) => excluded.has(segment))
572
+ excludeDirectory: (directory) => directory.split(path2.sep).some((segment) => excluded.has(segment)),
573
+ authorizePath: (candidate) => isCodingPathAuthorized(config, candidate)
557
574
  });
558
575
  const prefix = relative === "." ? "" : `${relative}${path2.sep}`;
559
576
  const matched = scan.files.filter((file) => file.relative.startsWith(prefix)).map((file) => file.relative).filter((candidate) => matcher.test(candidate.slice(prefix.length))).sort();
@@ -646,7 +663,9 @@ function createSearchAndPatchCodingTools(config, limits) {
646
663
  mode: input.mode
647
664
  });
648
665
  const root = await realpath4(config.root);
666
+ await authorizeCodingPath(config, ".");
649
667
  const excluded = new Set(config.search?.excludeDirectories ?? DEFAULT_EXCLUDED_DIRECTORIES);
668
+ const included = input.include ? compileWorkspaceGlob(input.include) : null;
650
669
  const scan = await scanContainedFiles({
651
670
  root,
652
671
  maxDepth: limits.maxSearchDepth,
@@ -656,10 +675,14 @@ function createSearchAndPatchCodingTools(config, limits) {
656
675
  readMaxBytes: limits.maxReadBytes,
657
676
  skipUnreadable: true
658
677
  },
659
- excludeDirectory: (relative) => relative.split(path3.sep).some((segment) => excluded.has(segment))
678
+ excludeDirectory: (relative) => relative.split(path3.sep).some((segment) => excluded.has(segment)),
679
+ authorizePath: async (candidate, kind) => {
680
+ if (kind === "file" && included && !included.test(candidate))
681
+ return false;
682
+ return await isCodingPathAuthorized(config, candidate);
683
+ }
660
684
  });
661
685
  const matcher = input.regex ? compileSearchRegex(input.query) : null;
662
- const included = input.include ? compileWorkspaceGlob(input.include) : null;
663
686
  const hit = (line) => {
664
687
  if (line.length > MAX_SEARCHED_LINE_BYTES)
665
688
  return false;
@@ -672,8 +695,6 @@ function createSearchAndPatchCodingTools(config, limits) {
672
695
  const matches = [];
673
696
  let truncated = false;
674
697
  for (const file of scan.files) {
675
- if (included && !included.test(file.relative))
676
- continue;
677
698
  if (input.mode === "path") {
678
699
  if (hit(file.relative))
679
700
  matches.push({ path: file.relative });
@@ -724,6 +745,7 @@ function createSearchAndPatchCodingTools(config, limits) {
724
745
  handler: async ({ input }) => {
725
746
  const root = await realpath4(config.root);
726
747
  const relative = boundedCodingRelativePath(input.path, limits.maxPathBytes);
748
+ await authorizeCodingPath(config, relative);
727
749
  const parent = await openContainedParent(root, relative).catch((error) => refuseMissingCodingPath(error, relative));
728
750
  try {
729
751
  return await withCodingPathLock(`${root}:${relative}`, async () => {
@@ -1073,6 +1095,7 @@ function createAgentCodingTools(config) {
1073
1095
  }
1074
1096
  export {
1075
1097
  createAgentCodingTools,
1098
+ AgentCodingToolPathAuthorizationSchema,
1076
1099
  AgentCodingToolLimitsSchema,
1077
1100
  AgentCodingToolAuthorizationSchema
1078
1101
  };
@@ -10,7 +10,7 @@ import"./index-y2s6h5bf.js";
10
10
  import"./index-wnfk50r0.js";
11
11
  import {
12
12
  walkContainedFiles
13
- } from "./index-rqpdar1e.js";
13
+ } from "./index-t7gh5w3v.js";
14
14
  import {
15
15
  AgentControlRequestSchema,
16
16
  AgentControlResponseSchema
@@ -156,7 +156,7 @@ async function listAt(directory) {
156
156
  }
157
157
  return readdir(descriptorPath(directory), { withFileTypes: true });
158
158
  }
159
- async function listContainedDirectory(root, relative, maxEntries) {
159
+ async function listContainedDirectory(root, relative, maxEntries, authorizePath) {
160
160
  let current = await openPinnedDirectory(root);
161
161
  try {
162
162
  if (relative !== ".") {
@@ -173,8 +173,14 @@ async function listContainedDirectory(root, relative, maxEntries) {
173
173
  }
174
174
  const raw = [...await listAt(current)];
175
175
  raw.sort((left, right) => left.name.localeCompare(right.name));
176
+ const admitted = [];
177
+ for (const entry of raw) {
178
+ const entryPath = relative === "." ? entry.name : path.join(relative, entry.name);
179
+ if (!authorizePath || await authorizePath(entryPath))
180
+ admitted.push(entry);
181
+ }
176
182
  const entries = [];
177
- for (const entry of raw.slice(0, maxEntries)) {
183
+ for (const entry of admitted.slice(0, maxEntries)) {
178
184
  const kind = entry.isDirectory() ? "directory" : entry.isSymbolicLink() ? "symlink" : entry.isFile() ? "file" : "other";
179
185
  if (kind !== "file") {
180
186
  entries.push({ name: entry.name, kind });
@@ -192,7 +198,7 @@ async function listContainedDirectory(root, relative, maxEntries) {
192
198
  return left.name.localeCompare(right.name);
193
199
  return left.kind === "directory" ? -1 : right.kind === "directory" ? 1 : 0;
194
200
  });
195
- return { entries, truncated: raw.length > maxEntries };
201
+ return { entries, truncated: admitted.length > maxEntries };
196
202
  } finally {
197
203
  await current.close();
198
204
  }
@@ -430,6 +436,9 @@ async function scanContainedFiles(input) {
430
436
  entries.sort((left, right) => left.name.localeCompare(right.name));
431
437
  for (const entry of entries) {
432
438
  const relative = relativeDirectory ? path.join(relativeDirectory, entry.name) : entry.name;
439
+ const kind = entry.isDirectory() ? "directory" : entry.isSymbolicLink() ? "symlink" : entry.isFile() ? "file" : "other";
440
+ if (input.authorizePath && !await input.authorizePath(relative, kind))
441
+ continue;
433
442
  if (entry.isSymbolicLink()) {
434
443
  if (input.symlinks === "refuse") {
435
444
  throw new Error(`Contained file traversal refuses symlink: ${relative}`);
package/llms-full.txt CHANGED
@@ -4716,8 +4716,11 @@ approval input fails the run with a private diagnostic rather than starting a fr
4716
4716
 
4717
4717
  `stitchkit/agent-runtime/coding-tools` returns ordinary direct runtime tools named `read_file`,
4718
4718
  `write_file`, `edit_file`, `list_directory`, `glob`, `search_files`, `run_command` and optional
4719
- `read_output`. Every call passes a
4720
- required host authorization callback. File paths are relative, bounded and contained after
4719
+ `read_output`. Every call passes a required host authorization callback. An optional async/sync
4720
+ `authorizePath({ path })` is the one operation-independent policy for direct file access and
4721
+ discovery: direct read/write/edit refuses a denied path, while listing, glob and search omit it.
4722
+ Directory decisions happen before descent; file decisions and `search_files.include` happen before
4723
+ opening content. File paths are relative, bounded and contained after
4721
4724
  descriptor-relative resolution: each ancestor is opened without following symlinks and remains
4722
4725
  pinned through authorization and the filesystem effect. Reads revalidate the pinned file identity;
4723
4726
  writes and patches revalidate the pinned parent identity; search and resource discovery descend
@@ -4730,7 +4733,8 @@ UTF-8 and retained bytes are finite. Shell accepts a finite alias mapped by the
4730
4733
  argument array — never a shell command string — and uses only the explicitly supplied environment.
4731
4734
  Arguments, output and time are bounded, while cancellation terminates the child. The configured
4732
4735
  root and cwd are path boundaries, not a security sandbox: isolate the process when an executable
4733
- must not access the rest of the machine.
4736
+ must not access the rest of the machine. Path admission does not constrain `run_command`; an
4737
+ executable requires process isolation for that guarantee. → ADR 0172
4734
4738
 
4735
4739
  `edit_file` replaces one exact snippet. `oldText` is itself the freshness guard for the region it
4736
4740
  changes, so the digest is the optional `expectedSha256` and an edit is one call; pass the digest
@@ -15253,8 +15257,9 @@ artifact store is supplied, `read_output`.
15253
15257
  | `createAgentCodingTools` | function | construct direct host-authorized bounded file, listing, glob, search, exact-snippet edit, shell and artifact runtime-tool definitions; every ordinary refusal is a typed code with an instructive `hint`, and filesystem operations use Linux `/proc/self/fd` or the packaged macOS Node-API backend and otherwise fail closed |
15254
15258
  | `AGENT_CODING_TOOL_NAMES` | const | the mounted tool names — `read_file`, `write_file`, `edit_file`, `list_directory`, `glob`, `search_files`, `run_command`, `read_output` |
15255
15259
  | `AgentCodingToolDefinition` | _type_ | peer-free structural direct-tool shape accepted by the canonical runtime-tool surface |
15256
- | `AgentCodingToolConfig` | _type_ | absolute root, required authorization callback, finite executable alias map, exact child environment and optional limits |
15260
+ | `AgentCodingToolConfig` | _type_ | absolute root, required operation authorization, optional async/sync `authorizePath({ path })` shared by direct file effects and discovery, finite executable alias map, exact child environment and optional limits |
15257
15261
  | `AgentCodingToolAuthorizationSchema` / `AgentCodingToolAuthorization` | schema / _type_ | discriminated read/write/search/patch/shell/artifact decision presented to host policy before effect |
15262
+ | `AgentCodingToolPathAuthorizationSchema` / `AgentCodingToolPathAuthorization` | schema / _type_ | strict workspace-relative path presented to the shared path policy before disclosure, opening or mutation |
15258
15263
  | `AgentCodingToolLimitsSchema` / `AgentCodingToolLimits` | schema / _type_ | explicit path/read/write/argument-count/argument-byte/output/artifact/timeout/termination-grace ceilings |
15259
15264
  | `AgentCodingArtifactStore` | _type_ | host-owned opaque artifact write and bounded read boundary |
15260
15265
  | `FileReadInputSchema` / `FileReadOutputSchema` | schema | bounded strict-UTF-8 byte slice; offsets must align with UTF-8 code-point boundaries |
@@ -15268,6 +15273,12 @@ of aggregate argument text, 4 MiB per artifact and 30 seconds. The root is a pat
15268
15273
  boundary, not an OS sandbox; executable behavior, process
15269
15274
  isolation, credentials and external-effect idempotency remain host responsibilities.
15270
15275
 
15276
+ When `authorizePath` denies a path, direct read/write/edit returns `FORBIDDEN`, while
15277
+ `list_directory`, `glob` and `search_files` omit it. Directory admission happens before descent and
15278
+ file admission before opening; `search_files.include` is also applied before content is read.
15279
+ `run_command` is intentionally outside this guarantee because an executable needs process isolation,
15280
+ not path filtering, to constrain its filesystem access. → ADR 0172.
15281
+
15271
15282
  ## `stitchkit/agent-runtime/browser`
15272
15283
 
15273
15284
  Browser-safe canonical agent data. It re-exports the run, message, part, usage,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stitchkit",
3
- "version": "0.83.1",
3
+ "version": "0.83.2",
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",