stitchkit 0.119.0 → 0.121.0

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 (163) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/README.md +10 -7
  3. package/dist/agent-runtime/coding-discovery.d.ts +25 -0
  4. package/dist/agent-runtime/coding-discovery.d.ts.map +1 -0
  5. package/dist/agent-runtime/coding-search-automaton.d.ts +37 -0
  6. package/dist/agent-runtime/coding-search-automaton.d.ts.map +1 -0
  7. package/dist/agent-runtime/coding-search-case-fold.d.ts +4 -0
  8. package/dist/agent-runtime/coding-search-case-fold.d.ts.map +1 -0
  9. package/dist/agent-runtime/coding-search-class-ranges.d.ts +10 -0
  10. package/dist/agent-runtime/coding-search-class-ranges.d.ts.map +1 -0
  11. package/dist/agent-runtime/coding-search-contract.d.ts +86 -0
  12. package/dist/agent-runtime/coding-search-contract.d.ts.map +1 -0
  13. package/dist/agent-runtime/coding-search-limits.d.ts +13 -0
  14. package/dist/agent-runtime/coding-search-limits.d.ts.map +1 -0
  15. package/dist/agent-runtime/coding-search-matcher.d.ts +33 -0
  16. package/dist/agent-runtime/coding-search-matcher.d.ts.map +1 -0
  17. package/dist/agent-runtime/coding-search-output.d.ts +5 -0
  18. package/dist/agent-runtime/coding-search-output.d.ts.map +1 -0
  19. package/dist/agent-runtime/coding-search-regex-syntax.d.ts +39 -0
  20. package/dist/agent-runtime/coding-search-regex-syntax.d.ts.map +1 -0
  21. package/dist/agent-runtime/coding-search-unit-classes.d.ts +31 -0
  22. package/dist/agent-runtime/coding-search-unit-classes.d.ts.map +1 -0
  23. package/dist/agent-runtime/coding-shell-process.d.ts +1 -0
  24. package/dist/agent-runtime/coding-shell-process.d.ts.map +1 -1
  25. package/dist/agent-runtime/coding-tool-contract.d.ts +8 -3
  26. package/dist/agent-runtime/coding-tool-contract.d.ts.map +1 -1
  27. package/dist/agent-runtime/coding-tool-files.d.ts.map +1 -1
  28. package/dist/agent-runtime/coding-tool-listing.d.ts +1 -11
  29. package/dist/agent-runtime/coding-tool-listing.d.ts.map +1 -1
  30. package/dist/agent-runtime/coding-tool-paths.d.ts +6 -2
  31. package/dist/agent-runtime/coding-tool-paths.d.ts.map +1 -1
  32. package/dist/agent-runtime/coding-tool-refusals.d.ts +6 -0
  33. package/dist/agent-runtime/coding-tool-refusals.d.ts.map +1 -1
  34. package/dist/agent-runtime/coding-tool-search-patch.d.ts.map +1 -1
  35. package/dist/agent-runtime/coding-tool-search.d.ts +113 -0
  36. package/dist/agent-runtime/coding-tool-search.d.ts.map +1 -0
  37. package/dist/agent-runtime/coding-tool-shell.d.ts.map +1 -1
  38. package/dist/agent-runtime/contained-scan-budget.d.ts +32 -0
  39. package/dist/agent-runtime/contained-scan-budget.d.ts.map +1 -0
  40. package/dist/agent-runtime/contained-scan-contract.d.ts +52 -0
  41. package/dist/agent-runtime/contained-scan-contract.d.ts.map +1 -0
  42. package/dist/agent-runtime/contained-scan.d.ts +48 -13
  43. package/dist/agent-runtime/contained-scan.d.ts.map +1 -1
  44. package/dist/agent-runtime/sandbox.d.ts +5 -1
  45. package/dist/agent-runtime/sandbox.d.ts.map +1 -1
  46. package/dist/agent-runtime/workspace-glob.d.ts +6 -0
  47. package/dist/agent-runtime/workspace-glob.d.ts.map +1 -0
  48. package/dist/entrypoints/agent-runtime/coding-tools.js +7 -7
  49. package/dist/entrypoints/agent-runtime/harness.js +5 -5
  50. package/dist/entrypoints/agent-runtime/realtime.js +3 -3
  51. package/dist/entrypoints/agent-runtime/sandbox.js +8 -8
  52. package/dist/entrypoints/agent-runtime/sqlite/bun.js +9 -9
  53. package/dist/entrypoints/agent-runtime/sqlite/node.js +9 -9
  54. package/dist/entrypoints/agent-runtime/testing.js +9 -9
  55. package/dist/entrypoints/agent-runtime.js +16 -14
  56. package/dist/entrypoints/application/diagnostic-journal.js +3 -3
  57. package/dist/entrypoints/application/directory-inbox.js +5 -5
  58. package/dist/entrypoints/application.js +6 -6
  59. package/dist/entrypoints/cli/publish.js +5 -5
  60. package/dist/entrypoints/cli.js +8 -8
  61. package/dist/entrypoints/contract.js +4 -4
  62. package/dist/entrypoints/files.js +4 -4
  63. package/dist/entrypoints/http.js +2 -2
  64. package/dist/entrypoints/index.js +2 -2
  65. package/dist/entrypoints/node.js +1 -1
  66. package/dist/entrypoints/process/owner-loss.js +2 -1
  67. package/dist/entrypoints/process.js +4 -4
  68. package/dist/entrypoints/remote.js +1 -1
  69. package/dist/entrypoints/server.js +12 -12
  70. package/dist/entrypoints/telegram/screens.js +5 -5
  71. package/dist/entrypoints/telegram.js +8 -8
  72. package/dist/entrypoints/testing.js +2 -2
  73. package/dist/entrypoints/tools/agent.d.ts +9 -0
  74. package/dist/entrypoints/tools/agent.d.ts.map +1 -0
  75. package/dist/entrypoints/tools/agent.js +16 -0
  76. package/dist/entrypoints/tools/connections.js +4 -4
  77. package/dist/entrypoints/tools/mcp.js +104 -4
  78. package/dist/entrypoints/tools/toolkit.d.ts +9 -0
  79. package/dist/entrypoints/tools/toolkit.d.ts.map +1 -0
  80. package/dist/entrypoints/tools/toolkit.js +40 -0
  81. package/dist/entrypoints/tools.d.ts +0 -10
  82. package/dist/entrypoints/tools.d.ts.map +1 -1
  83. package/dist/entrypoints/tools.js +25 -69
  84. package/dist/{index-s0qjs6ee.js → index-0fra8xvy.js} +9 -81
  85. package/dist/{index-rxcgp4b9.js → index-10rg78vf.js} +1 -1
  86. package/dist/index-1psbyyhj.js +21 -0
  87. package/dist/index-3prvb42w.js +30 -0
  88. package/dist/{index-ba7are04.js → index-4tyt1qya.js} +1 -1
  89. package/dist/index-568w258r.js +76 -0
  90. package/dist/{index-fqd4yqwd.js → index-6j15ktag.js} +1 -1
  91. package/dist/{index-zrdcmg6j.js → index-72xtvcvr.js} +40 -6
  92. package/dist/{index-6a69xzrx.js → index-7zwtbak8.js} +5 -46
  93. package/dist/{index-fcqj44mb.js → index-8ryydawp.js} +4 -4
  94. package/dist/{index-q968hy6y.js → index-aqmadanx.js} +2 -2
  95. package/dist/{index-s20s2mad.js → index-bgcwxhxh.js} +16 -14
  96. package/dist/index-bph35vpy.js +77 -0
  97. package/dist/{index-arjmb6de.js → index-eeahxwvg.js} +60 -76
  98. package/dist/{index-57gqaq8b.js → index-f6pw75e1.js} +1 -1
  99. package/dist/{index-f4njz9j0.js → index-gq3fnq3f.js} +1 -1
  100. package/dist/{index-ynrf908v.js → index-gtx3eknx.js} +1 -1
  101. package/dist/index-h1j71dr1.js +48 -0
  102. package/dist/{index-nn9qvkww.js → index-j95jp7ee.js} +45 -9
  103. package/dist/{index-mgb7r8b8.js → index-jswst0h3.js} +1 -1
  104. package/dist/{index-bbvc59gw.js → index-knmnj11j.js} +9 -180
  105. package/dist/{index-2kbysk9s.js → index-m5m9rmvt.js} +2 -0
  106. package/dist/{index-g444vfz2.js → index-nwm3ww60.js} +1 -1
  107. package/dist/{index-yk4g8805.js → index-pq7rkwkk.js} +1 -30
  108. package/dist/index-qaqxdbxf.js +2857 -0
  109. package/dist/{index-x8d9fdeg.js → index-qctbzmg9.js} +8 -4
  110. package/dist/index-s9a0fjh3.js +305 -0
  111. package/dist/index-sb9dr3tq.js +14 -0
  112. package/dist/{index-tvtacc9a.js → index-zyc64nbh.js} +1 -34
  113. package/dist/internal/contained-directory.d.ts +1 -1
  114. package/dist/internal/contained-directory.d.ts.map +1 -1
  115. package/dist/internal/contained-files.d.ts +18 -51
  116. package/dist/internal/contained-files.d.ts.map +1 -1
  117. package/dist/internal/contained-read.d.ts +17 -0
  118. package/dist/internal/contained-read.d.ts.map +1 -0
  119. package/dist/internal/darwin-binding.d.ts +3 -1
  120. package/dist/internal/darwin-binding.d.ts.map +1 -1
  121. package/dist/process/bun-child.d.ts.map +1 -1
  122. package/dist/process/command-owner.d.ts.map +1 -1
  123. package/dist/process/group.d.ts +2 -0
  124. package/dist/process/group.d.ts.map +1 -1
  125. package/dist/process/launch.d.ts +1 -0
  126. package/dist/process/launch.d.ts.map +1 -1
  127. package/dist/process/owned-child.d.ts.map +1 -1
  128. package/dist/process/owner-loss-guard.d.ts.map +1 -1
  129. package/dist/process/owner-loss-protocol.d.ts +1 -0
  130. package/dist/process/owner-loss-protocol.d.ts.map +1 -1
  131. package/llms/agent-runtime-coding-tools.txt +9 -9
  132. package/llms/agent-runtime-harness.txt +4 -3
  133. package/llms/agent-runtime-sandbox.txt +1 -1
  134. package/llms/agent-runtime.2.txt +20 -2
  135. package/llms/agent-runtime.3.txt +4 -46
  136. package/llms/agent-runtime.4.txt +113 -0
  137. package/llms/agent-runtime.txt +70 -37
  138. package/llms/application.3.txt +5 -2
  139. package/llms/cli.txt +1 -1
  140. package/llms/contract.txt +1 -1
  141. package/llms/process.txt +3 -1
  142. package/llms/server.5.txt +2 -0
  143. package/llms/stitchkit.txt +15 -9
  144. package/llms/testing.txt +4 -6
  145. package/llms/tools-agent.txt +24 -0
  146. package/llms/tools-mcp.txt +71 -6
  147. package/llms/tools-toolkit.txt +23 -0
  148. package/llms/tools.2.txt +6 -3
  149. package/llms/tools.3.txt +8 -77
  150. package/llms/tools.txt +8 -8
  151. package/llms/{upgrading-0.106.0-0.119.0.txt → upgrading-0.106.0-0.121.0.txt} +84 -3
  152. package/llms/upgrading.txt +1 -1
  153. package/llms-full.txt +360 -139
  154. package/llms.txt +11 -9
  155. package/native/darwin-arm64.node +0 -0
  156. package/native/darwin-x64.node +0 -0
  157. package/native-assets.json +4 -4
  158. package/package.json +10 -2
  159. package/dist/index-1k18qzqa.js +0 -1478
  160. package/dist/index-6f49krb5.js +0 -107
  161. package/dist/{index-2dfvv1jg.js → index-2fc1k9k2.js} +0 -0
  162. package/dist/{index-qndsr7f0.js → index-5efrpfmj.js} +3 -3
  163. /package/dist/{index-cyxp8rbf.js → index-mtwh9hyp.js} +0 -0
@@ -2,6 +2,7 @@ export declare const OWNER_LOSS_GUARD_FLAG = "--stitchkit-owner-loss-guard-v1";
2
2
  export interface OwnerLossGuardInvocation {
3
3
  readonly entry: string;
4
4
  readonly signalTarget: 'group' | 'leader';
5
+ readonly cwdDescriptor?: number;
5
6
  }
6
7
  /** The owner-loss guard is certified only on the two POSIX kernels exercised by release CI. */
7
8
  export declare function ownerLossAvailable(platform: NodeJS.Platform): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"owner-loss-protocol.d.ts","sourceRoot":"","sources":["../../src/process/owner-loss-protocol.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,oCAAoC,CAAC;AAEvE,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,YAAY,EAAE,OAAO,GAAG,QAAQ,CAAC;CAC3C;AAED,+FAA+F;AAC/F,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,GAAG,OAAO,CAErE;AAED,mGAAmG;AACnG,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,wBAAwB,EAC/B,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,SAAS,MAAM,EAAE,GACtB,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CASvB"}
1
+ {"version":3,"file":"owner-loss-protocol.d.ts","sourceRoot":"","sources":["../../src/process/owner-loss-protocol.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,oCAAoC,CAAC;AAEvE,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,YAAY,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC1C,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;CACjC;AAED,+FAA+F;AAC/F,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,GAAG,OAAO,CAErE;AAED,mGAAmG;AACnG,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,wBAAwB,EAC/B,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,SAAS,MAAM,EAAE,GACtB,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CAUvB"}
@@ -22,28 +22,28 @@ artifact store is supplied, `read_output`.
22
22
  | Export | Kind | Summary |
23
23
  |--------|------|---------|
24
24
  | `createAgentCodingTools` | function | construct direct host-authorized bounded file, listing, glob, search, exact-snippet edit, shell and artifact runtime-tool definitions; `edit_file` inserts `newText` literally in both single and `replaceAll` modes; 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 |
25
- | `AGENT_CODING_TOOL_NAMES` | const | the mounted tool names — `read_file`, `write_file`, `edit_file`, `list_directory`, `glob`, `search_files`, `run_command`, `read_output` |
26
25
  | `AgentCodingToolDefinition` | _type_ | peer-free structural direct-tool shape accepted by the canonical runtime-tool surface |
27
26
  | `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 |
28
27
  | `AgentCodingToolAuthorizationSchema` / `AgentCodingToolAuthorization` | schema / _type_ | discriminated read/write/search/patch/shell/artifact decision presented to host policy before effect |
29
28
  | `AgentCodingToolPathAuthorizationSchema` / `AgentCodingToolPathAuthorization` | schema / _type_ | strict workspace-relative path presented to the shared path policy before disclosure, opening or mutation |
30
- | `AgentCodingToolLimitsSchema` / `AgentCodingToolLimits` | schema / _type_ | explicit path/read/write/argument-count/argument-byte/output/artifact/timeout/termination-grace ceilings |
29
+ | `AgentCodingToolLimitsSchema` / `AgentCodingToolLimits` | schema / _type_ | explicit path/read/write/argument-count/argument-byte/output/artifact/timeout/termination-grace ceilings; shared discovery directory/entry/serialized-output/deadline ceilings, aggregate search-read ceiling and measured coverage |
31
30
  | `AgentCodingArtifactStore` | _type_ | host-owned opaque artifact write and bounded read boundary |
32
- | `FileReadInputSchema` / `FileReadOutputSchema` | schema | bounded strict-UTF-8 byte slice; offsets must align with UTF-8 code-point boundaries |
33
- | `FileWriteInputSchema` / `FileWriteOutputSchema` | schema | create-only by default or explicit atomic replacement; symlink targets fail closed |
34
- | `createShellInputSchema` / `ShellOutputSchema` | schema | enumerated executable alias plus arguments and concrete relative cwd; explicit exited/timeout/output-limit/cancelled outcome |
35
31
 
36
- File/search operations pin directory descriptors across authorization and the actual effect;
32
+ File/search operations select a root descriptor before both policy callback kinds and pin directory descriptors across authorization and the actual effect;
37
33
  resource discovery uses the same ancestor-safe traversal. This closes parent rename/symlink races
38
- without claiming an executable sandbox. The default ceilings are 4,096 path bytes, 256 KiB read/write/output, 128 shell arguments, 64 KiB
34
+ without claiming an executable sandbox. The ordinary command launcher passes a pinned cwd to its
35
+ isolated guard (inherited fd 4); a custom sandbox launcher owns atomic capture of its pathname cwd. List/glob/search report coverage; canonical spelling work consumes the same budget. List raw entries
36
+ are capped by maxListEntries and maxSearchEntries, and glob patterns by 4,096 UTF-16 units.
37
+ The default ceilings are 4,096 path bytes, 256 KiB read/write/output, 128 shell arguments, 64 KiB
39
38
  of aggregate argument text, 4 MiB per artifact and 30 seconds. The root is a path-resolution
40
39
  boundary, not an OS sandbox; executable behavior, process
41
40
  isolation, credentials and external-effect idempotency remain host responsibilities.
42
41
 
43
42
  When `authorizePath` denies a path, direct read/write/edit returns `FORBIDDEN`, while
44
43
  `list_directory`, `glob` and `search_files` omit it. Denial is recursive: direct access and
45
- discovery base paths are checked against `.` and every ancestor, outermost first and segment-wise,
46
- so denying `credentials` denies `credentials/token.txt` but not `credentials-backup`. Directory
44
+ discovery base paths check every named ancestor, outermost first and segment-wise; `.` is
45
+ checked only when the requested base itself is `.`, so subtree allowlists remain usable. Thus
46
+ denying `credentials` denies `credentials/token.txt` but not `credentials-backup`. Directory
47
47
  admission happens before descent and file admission before opening; `search_files.include` is also
48
48
  applied before content is read. Requested paths must use `/` — a backslash is refused, because the
49
49
  containment walk reads it as a separator while a callback would read it as one name.
@@ -27,7 +27,8 @@ import {
27
27
  createAgentHarnessFileResources,
28
28
  createHeadlessAgentHarness,
29
29
  } from 'stitchkit/agent-runtime/harness';
30
- import { composeToolLifecycle, mountAgent } from 'stitchkit/tools';
30
+ import { composeToolLifecycle } from 'stitchkit/tools';
31
+ import { mountAgent } from 'stitchkit/tools/agent';
31
32
 
32
33
  const resources = createAgentHarnessFileResources({
33
34
  roots: [{ id: 'guide', kind: 'instruction', path: instructionRoot }],
@@ -51,8 +52,8 @@ compose your authorization with the run's `toolFenceLifecycle` by `composeToolLi
51
52
  fence rejects a call from a run that no longer owns the conversation, and it must run exactly
52
53
  once. Every mount option remains available, including registry, runtime tools, extension,
53
54
  coercion, output stripping, hooks and durability, and the callback may be async. The same callback
54
- still accepts arbitrary typed AI SDK tools and prepareStep. `stitchkit/tools` needs the same `ai` and
55
- `@modelcontextprotocol/server` peers as any `mountAgent` use; the base harness stays AI-only.
55
+ still accepts arbitrary typed AI SDK tools and prepareStep. `mountAgent` comes from `stitchkit/tools/agent`, which needs only the `ai` peer the
56
+ harness already has; the base harness stays AI-only.
56
57
  The resource reader is explicitly selected: filtered allowlists do not gain tools merely
57
58
  because a loader exists. Root IDs, kinds, provenance and limits are unchanged.
58
59
 
@@ -57,7 +57,7 @@ Storage is process-durable, without a power-loss/fsync guarantee.
57
57
 
58
58
  ```ts
59
59
  import { createSandboxCodingTools } from 'stitchkit/agent-runtime/sandbox';
60
- import { mountAgent } from 'stitchkit/tools';
60
+ import { mountAgent } from 'stitchkit/tools/agent';
61
61
 
62
62
  const tools = mountAgent([], {
63
63
  runtimeTools: createSandboxCodingTools(handle, {
@@ -1,4 +1,4 @@
1
- # stitchkit/agent-runtime — stitchkit docs slice, part 2 of 3
1
+ # stitchkit/agent-runtime — stitchkit docs slice, part 2 of 4
2
2
 
3
3
  > Generated from the `docs/` tree by `bun run gen:llms`. The index of all slices is
4
4
  > `llms.txt` in this package.
@@ -7,12 +7,30 @@
7
7
  Parts of this slice:
8
8
  - `llms/agent-runtime.txt`: Guide: Agent application runtime (docs/guide/agent-runtime.md)
9
9
  - `llms/agent-runtime.2.txt`: Guide: Agent application runtime (docs/guide/agent-runtime.md)
10
- - `llms/agent-runtime.3.txt`: Guide: Agent application runtime (docs/guide/agent-runtime.md) · API reference: `stitchkit/agent-runtime` (docs/api/reference.md) · API reference: `stitchkit-tui` (docs/api/reference.md)
10
+ - `llms/agent-runtime.3.txt`: Guide: Agent application runtime (docs/guide/agent-runtime.md) · API reference: `stitchkit/agent-runtime` (docs/api/reference.md)
11
+ - `llms/agent-runtime.4.txt`: API reference: `stitchkit-tui` (docs/api/reference.md)
11
12
 
12
13
  ==============================================================================
13
14
  # Guide: Agent application runtime (docs/guide/agent-runtime.md) (continued)
14
15
  ==============================================================================
15
16
 
17
+ ## Durable order
18
+
19
+ `acceptInputAndAssignRun` is one atomic operation. It is followed by ownership
20
+ acquisition, revision-checked assistant checkpoints and one terminal CAS. The
21
+ process-local coordinator releases its lane only after terminal commit.
22
+
23
+ A queued admission is durable immediately, even if its predecessor is still awaiting ownership
24
+ or its first checkpoint. Snapshots expose causal turn order rather than physical append order:
25
+ the predecessor's assigned input(s) and assistant come before the successor input(s). Execution
26
+ uses the same run boundary, so neither `prompt({ snapshot })` nor default/custom history
27
+ projection can see inputs assigned to a later run. `inject` remains the explicit path that moves
28
+ a successor input into the run already in flight.
29
+
30
+ ```text
31
+ input + queued run → running → execution settled → terminal CAS → successor
32
+ ```
33
+
16
34
  ## What happens to a run when new input arrives
17
35
 
18
36
  `runs.inputPolicy` decides. It takes five values, or a function returning one:
@@ -1,12 +1,14 @@
1
- # stitchkit/agent-runtime — stitchkit docs slice, part 3 of 3
1
+ # stitchkit/agent-runtime — stitchkit docs slice, part 3 of 4
2
2
 
3
3
  > Generated from the `docs/` tree by `bun run gen:llms`. The index of all slices is
4
4
  > `llms.txt` in this package.
5
+ > Continues in `llms/agent-runtime.4.txt`.
5
6
 
6
7
  Parts of this slice:
7
8
  - `llms/agent-runtime.txt`: Guide: Agent application runtime (docs/guide/agent-runtime.md)
8
9
  - `llms/agent-runtime.2.txt`: Guide: Agent application runtime (docs/guide/agent-runtime.md)
9
- - `llms/agent-runtime.3.txt`: Guide: Agent application runtime (docs/guide/agent-runtime.md) · API reference: `stitchkit/agent-runtime` (docs/api/reference.md) · API reference: `stitchkit-tui` (docs/api/reference.md)
10
+ - `llms/agent-runtime.3.txt`: Guide: Agent application runtime (docs/guide/agent-runtime.md) · API reference: `stitchkit/agent-runtime` (docs/api/reference.md)
11
+ - `llms/agent-runtime.4.txt`: API reference: `stitchkit-tui` (docs/api/reference.md)
10
12
 
11
13
  ==============================================================================
12
14
  # Guide: Agent application runtime (docs/guide/agent-runtime.md) (continued)
@@ -431,47 +433,3 @@ is an optional atomic capability required by receipt admission, and
431
433
  stores supply both; custom adapters must honor the once-only transaction contract.
432
434
  A driver's optional `events.find(transaction, { conversationId, eventId })` makes
433
435
  both one lookup instead of a scan of the conversation log.
434
-
435
- ==============================================================================
436
- # API reference: `stitchkit-tui` (docs/api/reference.md)
437
- ==============================================================================
438
-
439
- ## `stitchkit-tui`
440
-
441
- Separate optional evolving Bun/OpenTUI package over a caller-composed headless harness.
442
-
443
- | Export | Kind | Summary |
444
- |--------|------|---------|
445
- | `defineAgentTui` | function | typed config for title/theme/status rows, model catalog, context, commands, runtime bundle and optional host-evidenced recovery policy; the default never requeues acquired effects |
446
- | `runAgentTui` | function | start one fresh durable conversation and terminal controller, recover durable work and publish its authenticated local session; `initialConversationId` is an explicit resume override |
447
- | `defineTuiCommand` / `resolveTuiCommand` | function | typed composable slash-command registry; unknown slash input remains an ordinary model prompt |
448
- | `createAgentTuiController` | function | single admission, selection, approval, interruption and conversation-switch owner over the harness |
449
- | `startAgentTuiSessionHost` / `createAgentTuiClient` | function | authenticated mode-`0600` Unix-socket host/client for status, submit and interrupt through that controller |
450
- | `listAgentTuiSessions` | function | discover live local terminal session IDs and their current conversation |
451
- | `createAgentTuiComposer` / `navigateAgentTuiHistory` | function | multiline draft and reversible prompt-history state |
452
- | `defaultAgentTuiStatusLine` / `AgentTuiStatusLineFormatter` | function / _type_ | terminal-native default rows and a host formatter over model capacity, durable snapshot, activity, workspace and local identities; `statusLine: false` hides the rows |
453
- | `createAgentTuiDiagnosticRecorder` / `AgentTuiDiagnosticEventSchema` | function / schema | bounded per-session metadata journal that rejects prompt, reasoning, tool-input and provider-cause payloads before disk admission |
454
-
455
- The `stitchkit-agent` binary loads `stitchkit.agent.ts` by default and also exposes `sessions`,
456
- `status`, `send` and `interrupt`. `--workspace` addresses a host outside the caller's cwd,
457
- `send --idempotency-key` accepts caller-owned retry identity, and `interrupt` defaults to the
458
- active run returned by `status`. Session descriptors and sockets are local control credentials,
459
- not a remote API.
460
- Interactive `/resume` and `/sessions` open the durable conversation picker. `/clear` creates a new
461
- conversation and keeps the previous one available there; it is not a viewport-only operation.
462
- The slash palette owns its highlighted selection: Up/Down move it, Tab completes it, Enter runs
463
- the exact command and Escape dismisses it. Partial input is never submitted while the palette is
464
- active; unknown slash text with no match remains an ordinary model prompt.
465
-
466
- ### `stitchkit-tui/core`
467
-
468
- Renderer-neutral state only. This entrypoint imports neither React/OpenTUI nor the agent runtime.
469
-
470
- | Export | Kind | Summary |
471
- |--------|------|---------|
472
- | `createTerminalCollection` / `reduceTerminalCollection` | function | identity-stable live collection selection, reconciliation, windowing and resize |
473
- | `createTerminalFeedViewport` / `reduceTerminalFeedViewport` | function | generic follow-tail, history anchoring, unseen and bounded visible-range state |
474
- | `createTerminalPaneState` / `reduceTerminalPaneState` | function | bounded split-pane focus, resize and single-pane collapse |
475
- | `createTerminalCommandPalette` / `terminalCommandMatches` | function | bounded command filtering and keyboard selection over a collision-validated registry |
476
- | `resolveExactTerminalCommand` / `validateTerminalCommands` | function | exact dispatch and fail-closed name/alias validation |
477
- | `createTerminalOperationState` / `reduceTerminalOperationState` | function | confirmation and single-pending-operation lifecycle |
@@ -0,0 +1,113 @@
1
+ # stitchkit/agent-runtime — stitchkit docs slice, part 4 of 4
2
+
3
+ > Generated from the `docs/` tree by `bun run gen:llms`. The index of all slices is
4
+ > `llms.txt` in this package.
5
+
6
+ Parts of this slice:
7
+ - `llms/agent-runtime.txt`: Guide: Agent application runtime (docs/guide/agent-runtime.md)
8
+ - `llms/agent-runtime.2.txt`: Guide: Agent application runtime (docs/guide/agent-runtime.md)
9
+ - `llms/agent-runtime.3.txt`: Guide: Agent application runtime (docs/guide/agent-runtime.md) · API reference: `stitchkit/agent-runtime` (docs/api/reference.md)
10
+ - `llms/agent-runtime.4.txt`: API reference: `stitchkit-tui` (docs/api/reference.md)
11
+
12
+ ==============================================================================
13
+ # API reference: `stitchkit-tui` (docs/api/reference.md)
14
+ ==============================================================================
15
+
16
+ ## `stitchkit-tui`
17
+
18
+ Separate optional evolving Bun/OpenTUI package over a caller-composed headless harness.
19
+
20
+ | Export | Kind | Summary |
21
+ |--------|------|---------|
22
+ | `defineAgentTui` | function | typed config for title, `theme` (a `TerminalPalette` override) and `themeMode`, status rows, model catalog, context, commands, runtime bundle and optional host-evidenced recovery policy; the default never requeues acquired effects |
23
+ | `runAgentTui` | function | start one fresh durable conversation and terminal controller, recover durable work and publish its authenticated local session; `initialConversationId` is an explicit resume override; it closes the session and exits the process on Ctrl-C and every signal OpenTUI catches unless `exitSignals: []` |
24
+ | `defineTuiCommand` / `resolveTuiCommand` | function | typed composable slash-command registry; unknown slash input remains an ordinary model prompt |
25
+ | `createAgentTuiController` | function | single admission, selection, approval, interruption and conversation-switch owner over the harness |
26
+ | `startAgentTuiSessionHost` / `createAgentTuiClient` | function | authenticated mode-`0600` Unix-socket host/client for status, submit and interrupt through that controller |
27
+ | `listAgentTuiSessions` | function | discover live local terminal session IDs and their current conversation |
28
+ | `createAgentTuiComposer` / `navigateAgentTuiHistory` | function | multiline draft and reversible prompt-history state |
29
+ | `defaultAgentTuiStatusLine` / `AgentTuiStatusLineFormatter` | function / _type_ | terminal-native default rows and a host formatter over model capacity, durable snapshot, activity, workspace and local identities; `statusLine: false` hides the rows |
30
+ | `createAgentTuiDiagnosticRecorder` / `AgentTuiDiagnosticEventSchema` | function / schema | bounded per-session metadata journal that rejects prompt, reasoning, tool-input and provider-cause payloads before disk admission |
31
+
32
+ The `stitchkit-agent` binary runs React's production build unless `NODE_ENV` says otherwise and loads `stitchkit.agent.ts` by default and also exposes `sessions`,
33
+ `status`, `send` and `interrupt`. `--workspace` addresses a host outside the caller's cwd,
34
+ `send --idempotency-key` accepts caller-owned retry identity, and `interrupt` defaults to the
35
+ active run returned by `status`. Session descriptors and sockets are local control credentials,
36
+ not a remote API.
37
+ Interactive `/resume` and `/sessions` open the durable conversation picker. `/clear` creates a new
38
+ conversation and keeps the previous one available there; it is not a viewport-only operation.
39
+ The slash palette owns its highlighted selection: Up/Down move it, Tab completes it, Enter runs
40
+ the exact command and Escape dismisses it. Partial input is never submitted while the palette is
41
+ active; unknown slash text with no match remains an ordinary model prompt.
42
+
43
+ ### `stitchkit-tui/core`
44
+
45
+ Renderer-neutral state only. This entrypoint imports neither React/OpenTUI nor the agent runtime.
46
+
47
+ | Export | Kind | Summary |
48
+ |--------|------|---------|
49
+ | `createTerminalCollection` / `reduceTerminalCollection` | function | identity-stable live collection selection, reconciliation, windowing and resize |
50
+ | `createTerminalFeedViewport` / `reduceTerminalFeedViewport` | function | generic follow-tail, history anchoring, unseen and bounded visible-range state |
51
+ | `createTerminalPaneState` / `reduceTerminalPaneState` | function | bounded split-pane focus, resize and single-pane collapse |
52
+ | `createTerminalCommandPalette` / `terminalCommandMatches` | function | bounded command filtering and keyboard selection over a collision-validated registry |
53
+ | `resolveExactTerminalCommand` / `validateTerminalCommands` | function | exact dispatch and fail-closed name/alias validation |
54
+ | `createTerminalOperationState` / `reduceTerminalOperationState` | function | confirmation and single-pending-operation lifecycle |
55
+ | `createTerminalTable` / `reduceTerminalTable` / `projectTerminalTable` | function | live table: typed columns, rows validated on entry, sort with key tie-break and missing values last, tree expansion pruned to present rows, filter on displayed text, selection kept across data; a row's `tone` and a column's `tone(value, row)` colour state |
56
+ | `layoutTerminalTableColumns` / `formatTerminalTableCell` / `visibleTerminalTableRows` / `terminalTableTreePrefix` | function | fixed and flexible column widths, `—` for missing values, the virtualized window, tree indentation |
57
+ | `createTerminalList` / `reduceTerminalList` / `visibleTerminalListLines` | function | picker with sections, fuzzy query with title highlight ranges, multi-select, disabled items and "more above/below" counts |
58
+ | `createTerminalForm` / `reduceTerminalForm` / `readTerminalForm` / `terminalFormFieldsFromJsonSchema` | function | typed fields (text, secret, number, integer, boolean, choice, JSON) from a JSON Schema, relative text edits, validation on leave and submit |
59
+ | `createTerminalTabs` / `reduceTerminalTabs` | function | tabs with badges, wrap-around movement, digit selection and reconcile that keeps the selected tab |
60
+ | `createTerminalNavigation` / `reduceTerminalNavigation` / `terminalBreadcrumbs` | function | screen stack keeping each level's state, root never popped |
61
+ | `createTerminalFocus` / `reduceTerminalFocus` | function | focus ring plus layers that take the keyboard and give it back |
62
+ | `createTerminalNotices` / `reduceTerminalNotices` / `nextTerminalNoticeExpiry` | function | bounded toasts on a caller clock, replaced by id |
63
+ | `createTerminalTimeSeries` / `appendTerminalSample` / `sampleTerminalTimeSeries` | function | time window bounded by duration and sample count, value-in-force sampling with explicit gaps |
64
+ | `terminalBrailleChart` / `terminalSparkline` / `terminalTimeAxis` / `terminalChartScale` | function | multi-series braille line or area chart as toned runs, sparkline, time axis |
65
+ | `terminalMeter` / `layoutTerminalMeterGrid` | function | eighth-block bar toned by thresholds, unmeasured as muted; column-major core grid |
66
+ | `terminalProgress` / `terminalSpinnerFrame` / `terminalIndeterminateBlock` / `formatTerminalDuration` | function | ratio, rate and ETA only when knowable; spinner frames; indeterminate bar; elapsed time |
67
+ | `defineTerminalKeymap` / `matchTerminalKey` / `fitTerminalKeyHints` | function | conflict-checked bindings that both answer keys and draw a footer fitted to the width |
68
+ | `terminalTableKeymap` / `terminalTableKey` / `terminalTabsKeymap` / `terminalTabsKey` | function | htop-style table bindings and tab bindings as keymaps |
69
+ | `matchTerminalSearch` / `searchTerminalItems` / `terminalHighlightRuns` | function | multi-word fuzzy match with ranges, stable ranking, highlight runs |
70
+ | `sanitizeTerminalText` / `terminalTextWidth` / `truncateTerminalText` / `fitTerminalText` / `wrapTerminalText` | function | strip escape and control sequences; measure, cut, pad and wrap by terminal cells |
71
+ | `terminalTextEdit` / `applyTerminalTextEdit` | function | one-line edits as relative actions, so fast input is never lost |
72
+ | `terminalJsonLines` / `layoutTerminalDetails` | function | toned, sanitized JSON lines; aligned key/value pairs |
73
+ | `terminalPalettes` / `resolveTerminalPalette` / `TerminalPalette` / `TerminalTone` | value / function / _type_ | one semantic palette (surfaces plus `primary`, `muted`, `accent`, `success`, `warning`, `danger`) for dark and light terminals |
74
+ | `terminalLabelsEn` / `terminalLabelsRu` / `TerminalLabels` | value / _type_ | every word the widgets draw |
75
+
76
+ ### `stitchkit-tui/widgets`
77
+
78
+ OpenTUI React widgets over the core state. React, `@opentui/core` and `@opentui/react` are peers;
79
+ this entrypoint never loads `stitchkit`.
80
+
81
+ | Export | Kind | Summary |
82
+ |--------|------|---------|
83
+ | `TerminalAppShell` / `TerminalPanel` / `TerminalStatusBar` / `TerminalKeyHints` | component | breadcrumbs, status lines, body, fitted key hints and toast overlay; titled rounded panels with a focus frame |
84
+ | `TerminalTable` | component | virtualized live table with header sort marks, tree, filter line and htop keys; row and cell tones in the palette, bold or dim where colour is missing |
85
+ | `terminalToneAttributes` | function | the text attribute that carries a tone without colour: `danger` and `warning` bold, `muted` dim |
86
+ | `TerminalList` | component | sections, fuzzy search line with highlights, `›` cursor, meta, badges, multi-select, description |
87
+ | `runTerminalApp` / `RunTerminalAppOptions` / `RunningTerminalApp` | function / _type_ | start an application: renderer, theme and labels providers, the error boundary, and an exit with 128 + signal after `onClose` on Ctrl-C and every signal OpenTUI catches — a closed window leaves no orphan |
88
+ | `TerminalErrorBoundary` / `TERMINAL_EXIT_SIGNALS` / `TerminalExitSignal` | component / value / _type_ | draws a render error and its stack in place of the screen, where OpenTUI's own boundary renders nothing under production React |
89
+ | `TerminalForm` | component | fields edited in place, cycling choices, masked secrets, inline errors; a form without fields says so and submits `{}` on Enter |
90
+ | `TerminalTextView` / `TerminalJsonView` | component | pager over sanitized wrapped text or toned JSON |
91
+ | `TerminalMeter` / `TerminalMeterGrid` / `TerminalChart` / `TerminalSparkline` | component | htop meters and core grid; btop braille charts with axis |
92
+ | `TerminalTabs` / `TerminalDialog` / `TerminalSpinner` / `TerminalProgressBar` / `TerminalAsyncView` / `TerminalDetails` / `TerminalNotices` / `TerminalHelp` | component | views, confirmation, loading, progress, async states, details, toasts, key help |
93
+ | `TerminalThemeProvider` / `useTerminalPalette` / `useTerminalThemeMode` | component / hook | palette from the terminal's reported background (`auto`) or a fixed mode |
94
+ | `TerminalLabelsProvider` / `TerminalFocusProvider` / `useTerminalFocused` | component / hook | product language and shared focus |
95
+
96
+ The `stitchkit-tui-gallery` binary shows every widget live.
97
+
98
+ ### `stitchkit-tui/build`
99
+
100
+ Build-time only; imports Bun and no React.
101
+
102
+ | Export | Kind | Summary |
103
+ |--------|------|---------|
104
+ | `compileTerminalApp` / `CompileTerminalAppOptions` | function / _type_ | one standalone executable for any Bun compile target, from any machine, with React's production build defined |
105
+ | `terminalNativePlugin` / `TerminalNativePluginOptions` | function / _type_ | the `Bun.build` plugin behind it: the target's `@opentui/core-<os>-<arch>` at the pinned version from the registry, verified against `bun.lock`; other platforms' packages throw; musl refused |
106
+ | `terminalNativeTarget` / `TerminalNativeTarget` | function / _type_ | the native package a compile target needs |
107
+
108
+ ### `stitchkit-tui/testing`
109
+
110
+ | Export | Kind | Summary |
111
+ |--------|------|---------|
112
+ | `renderTerminalTest` / `TerminalTestScreen` / `TerminalTestOptions` | function / _type_ | a screen inside the kit's providers on a test terminal; `press`, `type`, `burst`, `advance`, `waitForText`, `resize` run inside React's `act` and wait out a lone Esc |
113
+ | `TerminalTestKey` / `TerminalTestModifiers` | _type_ | the mock input's key names and modifiers |
@@ -1,4 +1,4 @@
1
- # stitchkit/agent-runtime — stitchkit docs slice, part 1 of 3
1
+ # stitchkit/agent-runtime — stitchkit docs slice, part 1 of 4
2
2
 
3
3
  > Generated from the `docs/` tree by `bun run gen:llms`. The index of all slices is
4
4
  > `llms.txt` in this package.
@@ -7,7 +7,8 @@
7
7
  Parts of this slice:
8
8
  - `llms/agent-runtime.txt`: Guide: Agent application runtime (docs/guide/agent-runtime.md)
9
9
  - `llms/agent-runtime.2.txt`: Guide: Agent application runtime (docs/guide/agent-runtime.md)
10
- - `llms/agent-runtime.3.txt`: Guide: Agent application runtime (docs/guide/agent-runtime.md) · API reference: `stitchkit/agent-runtime` (docs/api/reference.md) · API reference: `stitchkit-tui` (docs/api/reference.md)
10
+ - `llms/agent-runtime.3.txt`: Guide: Agent application runtime (docs/guide/agent-runtime.md) · API reference: `stitchkit/agent-runtime` (docs/api/reference.md)
11
+ - `llms/agent-runtime.4.txt`: API reference: `stitchkit-tui` (docs/api/reference.md)
11
12
 
12
13
  ==============================================================================
13
14
  # Guide: Agent application runtime (docs/guide/agent-runtime.md)
@@ -18,16 +19,16 @@ Parts of this slice:
18
19
  > **Maturity: evolving.** This surface is still finding its shape and may be
19
20
  > redefined in any minor release — always with a `### ⚠️ Breaking changes` entry
20
21
  > and a migration section, never silently. If your application already owns the
21
- > conversation loop, `mountAgent` from `stitchkit/tools` is the stable path.
22
+ > conversation loop, `mountAgent` from `stitchkit/tools/agent` is the direct path.
22
23
 
23
24
  `stitchkit/agent-runtime` is the server-only, opinionated layer above
24
25
  `mountAgent`. Use it when the application wants Stitchkit to own conversation
25
26
  mechanics: durable acceptance, history projection, the AI SDK stream loop,
26
27
  checkpoints, keyed interruption, terminal commit and stable application events.
27
28
 
28
- If the application already owns that loop, continue importing `mountAgent` from
29
- `stitchkit/tools`. `stitchkit/tools` does not depend on this entrypoint at all;
30
- this entrypoint uses the tool executor from it, but pulls no MCP peer, so
29
+ If the application already owns that loop, import `mountAgent` from
30
+ `stitchkit/tools/agent`. Neither `stitchkit/tools` nor `stitchkit/tools/agent` depends on
31
+ this entrypoint; this entrypoint uses the tool executor, but pulls no MCP peer, so
31
32
  choosing `mountAgent` alone costs you nothing from here.
32
33
 
33
34
  UI and shared DTO code must import canonical records and delivery validation from
@@ -51,12 +52,8 @@ persistence, event sinks and every Node context dependency.
51
52
  bun add stitchkit ai zod
52
53
  ```
53
54
 
54
- `mountAgent` from `stitchkit/tools` — used in the composition below — additionally
55
- needs the MCP peer, which that entrypoint imports statically:
56
-
57
- ```sh
58
- bun add @modelcontextprotocol/server
59
- ```
55
+ `mountAgent` from `stitchkit/tools/agent` — used in the composition below — needs no
56
+ peer beyond `ai`.
60
57
 
61
58
  OpenRouter is isolated so other runtime users do not resolve its package:
62
59
 
@@ -77,7 +74,8 @@ import {
77
74
  defineModelRegistry,
78
75
  } from 'stitchkit/agent-runtime'
79
76
  import { openRouterProvider } from 'stitchkit/agent-runtime/openrouter'
80
- import { composeToolLifecycle, mountAgent } from 'stitchkit/tools'
77
+ import { composeToolLifecycle } from 'stitchkit/tools'
78
+ import { mountAgent } from 'stitchkit/tools/agent'
81
79
 
82
80
  const protocol = defineAgentProtocol({
83
81
  context: z.object({ userId: z.string() }),
@@ -306,14 +304,26 @@ outermost first, stopping at the first refusal; discovery rooted at `.` also ask
306
304
  Thus denying `credentials` denies everything
307
305
  under it. The comparison is segment-wise, so it does not deny `credentials-backup`, and a path of
308
306
  depth N costs N questions for direct access. Directory decisions happen before descent; file decisions and
309
- `search_files.include` happen before opening content. Requested paths use `/`: a backslash is
307
+ `search_files.include` happen before opening content. Incompatible glob directory prefixes are
308
+ pruned before policy or directory opens. Requested paths use `/`: a backslash is
310
309
  refused rather than normalised, because the workspace walk reads it as a separator and every
311
310
  authorization callback would otherwise be asked about a different decomposition than the one opened. File paths are relative, bounded and contained after
312
311
  descriptor-relative resolution: each ancestor is opened without following symlinks. Reads and edits
313
312
  stay pinned through authorization; `write_file` plans before it and opens the parent after, because
314
313
  the parent it creates does not exist yet. Reads revalidate the pinned file identity;
315
314
  writes and patches revalidate the pinned parent identity; search and resource discovery descend
316
- only through opened directories. A path that changed during authorization refuses with `CONFLICT`.
315
+ only through opened directories. Every filesystem tool selects its root capability before operation or path authorization and retains
316
+ that identity if a callback replaces the root path or configured alias. On Linux the ordinary
317
+ command launcher spawns the command with the pinned directory's `/proc` descriptor link as its cwd;
318
+ on macOS it inherits the pinned cwd through an isolated guard — one short-lived guard process per
319
+ command, tens of milliseconds, outside `shellTimeoutMs`, which counts from the command's start. The
320
+ application process never changes cwd. Where
321
+ contained descriptors are unavailable (Windows), `run_command` accepts a cwd whose realpath is
322
+ that same name under the root — a symlink segment refuses there too — and checks the directory's
323
+ identity again immediately before launch, after every host decision.
324
+ A custom sandbox launcher owns atomic cwd capture at its pathname handoff; the SDK refuses a
325
+ changed identity after policy/prepare and immediately before that handoff. A path that changed
326
+ during direct-access authorization refuses with `CONFLICT`.
317
327
  A path spelled differently from the name stored on disk refuses before any policy reads it, so on a
318
328
  case-insensitive volume a rule on `credentials` cannot be passed by asking for `CREDENTIALS`.
319
329
  NUL bytes are refused before either host policy sees a path.
@@ -367,11 +377,51 @@ crosses a process boundary and is rebuilt from the wire.
367
377
  excluded directory is not "no files", and a model told only "nothing found" concludes the wrong
368
378
  thing. `search_files` takes `regex`, `context` lines and an anchored `include` pattern matched
369
379
  against the whole workspace-relative path. `*` does not cross `/`, so files in subdirectories need
370
- `**/`; `scannedFiles` counts files admitted by both that filter and host authorization. A `hint`
371
- explains the zero only when the filter produced it, rejecting every file the scan reached; an empty
372
- tree and a host refusal return the same empty result without blaming the pattern. Regex is bounded by
373
- refusing backreferences and lookaround and capping line length rather than by a timeout, because a
374
- JavaScript `RegExp` cannot be interrupted once it starts backtracking. With an optional `AgentCodingArtifactStore`, shell output beyond the inline
380
+ `**/`; `scannedFiles` counts files admitted by both that filter and host authorization that reached
381
+ comparison. One finite glob automaton matches files and prunes incompatible directory prefixes;
382
+ `glob` also confines its walk to the requested path. A `hint` can explain include filtering or
383
+ pruning, without counting files below unopened directories.
384
+
385
+ Search processes one file at a time. List, glob and search share directory, entry, serialized-output,
386
+ timeout and cancellation budgets, including canonical spelling checks before path authorization.
387
+ `list_directory` caps raw enumeration at the smaller of `maxListEntries` and `maxSearchEntries`;
388
+ its coverage scope lists symlinks while glob/search skip them. Glob patterns are limited to 4,096
389
+ UTF-16 units. A scoped glob measures depth from its requested base directory. In addition to `maxSearchFiles` (10,000), `maxSearchDepth`
390
+ (32), `maxSearchResults` (100) and `maxReadBytes` (262,144), hosts can configure
391
+ `maxSearchDirectories` (1,000 directory-open attempts, root included), `maxSearchEntries`
392
+ (20,000 entries observed by bounded readers), `maxSearchBytes` (16,777,216 aggregate content
393
+ bytes, including rejected UTF-8), `maxSearchOutputBytes` (65,536 bytes for the entire serialized
394
+ UTF-8 JSON, minimum 1,024) and `searchTimeoutMs` (5,000). An input whose minimum coverage
395
+ envelope cannot fit the output ceiling refuses before filesystem access. Directory readers cap
396
+ enumeration before materialization and sorting; reaching an entry or result ceiling is
397
+ conservatively partial, without reading a lookahead entry or match.
398
+
399
+ `list_directory`, `glob` and `search_files` return `coverage.complete` and `coverage.reasons`
400
+ to distinguish full empty results from partial work. Glob `resultTruncated` conservatively marks
401
+ the result ceiling even when no extra match was read.
402
+ Coverage names the include/exclusion/symlink scope, directory and entry counters, actual content
403
+ bytes and elapsed milliseconds. Limits, cancellation, denial, unreadable files and oversized
404
+ lines are explicit reasons. `errors` names only a workspace-relative path, operation and safe code;
405
+ `errorsTruncated` and `deniedTruncated` report shortened diagnostics. Excluded directories and
406
+ symlinks are outside the declared search scope. The caller's signal and deadline reach host
407
+ authorization, file reads and traversal; CPU checkpoints and asynchronous races stop further work.
408
+ Late opened handles are closed, while already-running kernel calls may finish later. Directory
409
+ enumeration and glob matching have internal checkpoints; cancellation stops their producer loops.
410
+ Host policy and visitor exceptions propagate to error hooks with their original cause, rather
411
+ than becoming filesystem diagnostics. Diagnostic byte admission is linear and checks the deadline
412
+ even for an empty result.
413
+
414
+ Regex searches use JavaScript `RegExp` syntax without flags — groups, alternation, classes,
415
+ anchors, `\b`, quantifiers and `(?ims-ims:…)` modifiers — with bounded cost per line. A line
416
+ whose backtracking work (paths × longest path × line length × (number of groups + 1), every
417
+ repetition capped at the line length beyond the iterations it requires) stays within 2^24 steps runs on the native engine, so ordinary `.*` searches over code
418
+ lines keep native speed and the deadline is observed between lines; any other line runs on a
419
+ cached linear automaton, so `(a+)+$` on a long line costs the same as `a+` and the deadline is
420
+ observed inside the line. Backreferences and
421
+ lookaround refuse before I/O; lines over 8,192 UTF-8 bytes are skipped with incomplete coverage.
422
+ Literal queries allow up to 8,192 UTF-16 units and include patterns up to 4,096.
423
+
424
+ With an optional `AgentCodingArtifactStore`, shell output beyond the inline
375
425
  preview continues into an opaque bounded artifact and `read_output` reads slices without
376
426
  exposing a host path. Without a store, the previous finite output-limit behavior is unchanged.
377
427
 
@@ -770,20 +820,3 @@ as `lost`, not misreported as a provider failure.
770
820
  `createAgentChildTools` adds `subagent`, `subagent_fork`, `list_agents`,
771
821
  `send_message` and `interrupt_agent`; final output stays behind its bounded
772
822
  result locator.
773
-
774
- ## Durable order
775
-
776
- `acceptInputAndAssignRun` is one atomic operation. It is followed by ownership
777
- acquisition, revision-checked assistant checkpoints and one terminal CAS. The
778
- process-local coordinator releases its lane only after terminal commit.
779
-
780
- A queued admission is durable immediately, even if its predecessor is still awaiting ownership
781
- or its first checkpoint. Snapshots expose causal turn order rather than physical append order:
782
- the predecessor's assigned input(s) and assistant come before the successor input(s). Execution
783
- uses the same run boundary, so neither `prompt({ snapshot })` nor default/custom history
784
- projection can see inputs assigned to a later run. `inject` remains the explicit path that moves
785
- a successor input into the run already in flight.
786
-
787
- ```text
788
- input + queued run → running → execution settled → terminal CAS → successor
789
- ```
@@ -14,6 +14,8 @@ Parts of this slice:
14
14
 
15
15
  ## `stitchkit/application`
16
16
 
17
+ Construct a directory inbox with `createDirectoryInbox` from `stitchkit/application/directory-inbox`.
18
+
17
19
  `StartFact` also carries `previousDrainUpperBoundMs`: the time from a predecessor's recorded admission stop to this start when its exit is `interrupted`, otherwise `null`. This is an upper bound, and does not identify a kill signal or supervisor deadline.
18
20
 
19
21
 
@@ -39,7 +41,7 @@ cutovers are covered by the executable
39
41
  | `NotificationOutboxItem` / `NotificationOutboxReceipt` / `NotificationOutboxState` / `NotificationSend` / `NotificationFailureClassification` / `DroppedNotification` / `EnqueueNotification` | _type_ | versioned queue records, stable send identity and delivery decisions |
40
42
  | `notificationOutboxStateSchema` | function | strict persisted-state schema over an application payload schema |
41
43
  | `notificationOutboxResource` / `NotificationOutboxResource` / `NotificationOutboxResourceConfig` | function / _type_ | thin managed-resource scheduler over an outbox handle |
42
- | `createDirectoryInbox` (from `stitchkit/application/directory-inbox`) / `DirectoryInbox` / `DirectoryInboxConfig` / `DirectoryInboxDelivery` / `DirectoryInboxResource` | function / _type_ | one managed directory inbox for files or durable `accept({ source, key, entry })` (`entry` is the schema's input, stored as given); a hard-linked file is set aside as `invalid`; first payload wins, bounded capacity/bytes/receipts and renewable fenced leases; delivery begins after readiness and effects remain at least once |
44
+ | `DirectoryInbox` / `DirectoryInboxConfig` / `DirectoryInboxDelivery` / `DirectoryInboxResource` | _type_ | one managed directory inbox for files or durable `accept({ source, key, entry })` (`entry` is the schema's input, stored as given); a hard-linked file is set aside as `invalid`; first payload wins, bounded capacity/bytes/receipts and renewable fenced leases; delivery begins after readiness and effects remain at least once |
43
45
  | `DirectoryInboxIdentitySchema` / `DirectoryInboxIdentity` / `DirectoryInboxAccept` / `DirectoryInboxAcceptResultSchema` / `DirectoryInboxAcceptResult` | schema / _type_ | validated source/key, typed entry and durable accepted/duplicate result with filename; duplicates do not replace the first payload |
44
46
  | `StateStoreUpdateContext` | _type_ | real active protected transaction: `assertHeld()` refuses after ownership loss or completion; custom adapters supply this context to their transition |
45
47
  | `DirectoryInboxStateSchema` / `DirectoryInboxState` / `DirectoryInboxRejection` / `DirectoryInboxRejectionReasonSchema` / `DirectoryInboxRejectionReason` | schema / _type_ | the inbox's claims, receipts and rejections (`invalid`, `too-large`, `attempt-limit`) |
@@ -122,9 +124,10 @@ cutovers are covered by the executable
122
124
 
123
125
  ### Bounded diagnostic journal
124
126
 
127
+ Construct the writer with `createDiagnosticJournal` from `stitchkit/application/diagnostic-journal`.
128
+
125
129
  | Export | Kind | Summary |
126
130
  |--------|------|---------|
127
- | `createDiagnosticJournal` | function | create one schema-owned FIFO JSONL writer with bounded retained memory, exclusive local path ownership and finite rotation |
128
131
  | `DiagnosticJournalConfig` / `DiagnosticJournal` | _type_ | owner schema/path/limits/failure observer, `startupScan` (`tails` by default, or `full`), `onStartupRefusal` (`quarantine` by default, or `fail`) and the synchronous `submit`, bounded-wait `flush`/`close`, status handle |
129
132
  | `DiagnosticJournalLimitsSchema` / `DiagnosticJournalLimits` | schema / _type_ | positive event, pending-item, pending-byte, file-byte and retained-file limits |
130
133
  | `DiagnosticJournalLockPolicySchema` / `DiagnosticJournalLockPolicy` | schema / _type_ | `refuse` (default) or `reclaim-stale`, which reclaims only a lock whose recorded owner is provably gone |
package/llms/cli.txt CHANGED
@@ -36,7 +36,7 @@ types; the package keeps its required dependencies separate from optional SDKs.
36
36
  CLI runtime tools use the one runtime-tool declaration: identity, input and output
37
37
  schemas, handler, and explicit CLI exposure. SDK presenters are the adapter's extension
38
38
  of that declaration (the fourth type argument of `RuntimeToolDefinitionWithOutput`, or
39
- `defineRuntimeTool` in `stitchkit/tools`), which requires the corresponding peers. A typed
39
+ `defineRuntimeTool` in `stitchkit/tools`), whose presenter types name the corresponding SDKs. A typed
40
40
  definition returned by `defineRuntimeTool` or `createRuntimeToolFactory` can be
41
41
  passed directly to both CLI and SDK mounts.
42
42
 
package/llms/contract.txt CHANGED
@@ -567,7 +567,7 @@ from the root `stitchkit`.
567
567
  | `McpProgressUpdate` | _type_ | one mid-call progress update — `message`, and `progress`/`total` when the operation knows a scale |
568
568
  | `McpReportProgress` | _type_ | `ctx.reportProgress` — sends one update to the host that asked for progress; a no-op when none did, and never throws |
569
569
  | `McpRoundOutcome` | _type_ | managed multi-round attempt outcome |
570
- | `EndpointHandlerContext` | _type_ | one endpoint handler's fully inferred params, input, files and runtime context |
570
+ | `HandlerContext` | _type_ | contract handler's fully inferred params, input, files and runtime context |
571
571
  | `EndpointFn` | _type_ | the call signature of one client method |
572
572
  | `TypedClient` | _type_ | the full typed client for a contract |
573
573
  | `TypedHttpClient` | _type_ | the typed client, HTTP endpoints only (`= ScopedHttpClient<C, unknown>`) |
package/llms/process.txt CHANGED
@@ -172,7 +172,9 @@ concurrently or cancel the stream you ignore. Cancelling a stream drops its late
172
172
  command fails or is stopped, both streams error and the bytes still queued are dropped.
173
173
 
174
174
  A command needs a caller `signal` or a finite `timeoutMs` (1 to 2147483647 ms, the native timer
175
- range; a larger value is refused, never turned into 1 ms). Streaming runs for the caller's lifetime,
175
+ range; a larger value is refused, never turned into 1 ms). `timeoutMs` counts from the moment the
176
+ command started. A guarded command (`ownerLoss: 'terminate'`) first starts its guard; that start is
177
+ bounded by `timeoutMs` or 5 seconds, whichever is longer, and does not use the command's budget. Streaming runs for the caller's lifetime,
176
178
  with no hidden 60-second timeout or 1 MiB output limit. `capture` defaults to false; `true` requires
177
179
  `maxOutputBytes` for the combined stdout and stderr. The limit counts source bytes; the API returns
178
180
  `Uint8Array` and does not decode invalid UTF-8. The result holds the observed `exitCode: number | null`
package/llms/server.5.txt CHANGED
@@ -19,6 +19,8 @@ Also read:
19
19
 
20
20
  ## `stitchkit/server`
21
21
 
22
+ `EndpointHandlerContext` is the server endpoint handler’s inferred params, input, files and runtime context.
23
+
22
24
  Server-only. Builds and runs the HTTP server, and carries the server primitives.
23
25
  Also re-exports the error helpers from `stitchkit/contract`.
24
26