stitchkit 0.119.0 → 0.120.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 (86) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +10 -7
  3. package/dist/entrypoints/agent-runtime/coding-tools.js +4 -4
  4. package/dist/entrypoints/agent-runtime/harness.js +4 -4
  5. package/dist/entrypoints/agent-runtime/realtime.js +3 -3
  6. package/dist/entrypoints/agent-runtime/sandbox.js +5 -5
  7. package/dist/entrypoints/agent-runtime/sqlite/bun.js +6 -6
  8. package/dist/entrypoints/agent-runtime/sqlite/node.js +6 -6
  9. package/dist/entrypoints/agent-runtime/testing.js +6 -6
  10. package/dist/entrypoints/agent-runtime.js +13 -11
  11. package/dist/entrypoints/application/diagnostic-journal.js +2 -2
  12. package/dist/entrypoints/application/directory-inbox.js +4 -4
  13. package/dist/entrypoints/application.js +6 -6
  14. package/dist/entrypoints/cli/publish.js +4 -4
  15. package/dist/entrypoints/cli.js +7 -7
  16. package/dist/entrypoints/contract.js +4 -4
  17. package/dist/entrypoints/files.js +3 -3
  18. package/dist/entrypoints/http.js +2 -2
  19. package/dist/entrypoints/index.js +2 -2
  20. package/dist/entrypoints/node.js +1 -1
  21. package/dist/entrypoints/process.js +1 -1
  22. package/dist/entrypoints/remote.js +1 -1
  23. package/dist/entrypoints/server.js +11 -11
  24. package/dist/entrypoints/telegram/screens.js +5 -5
  25. package/dist/entrypoints/telegram.js +7 -7
  26. package/dist/entrypoints/testing.js +2 -2
  27. package/dist/entrypoints/tools/agent.d.ts +9 -0
  28. package/dist/entrypoints/tools/agent.d.ts.map +1 -0
  29. package/dist/entrypoints/tools/agent.js +16 -0
  30. package/dist/entrypoints/tools/connections.js +4 -4
  31. package/dist/entrypoints/tools/mcp.js +104 -4
  32. package/dist/entrypoints/tools/toolkit.d.ts +9 -0
  33. package/dist/entrypoints/tools/toolkit.d.ts.map +1 -0
  34. package/dist/entrypoints/tools/toolkit.js +40 -0
  35. package/dist/entrypoints/tools.d.ts +0 -10
  36. package/dist/entrypoints/tools.d.ts.map +1 -1
  37. package/dist/entrypoints/tools.js +25 -69
  38. package/dist/{index-1k18qzqa.js → index-0qyrcjfs.js} +3 -3
  39. package/dist/index-1psbyyhj.js +21 -0
  40. package/dist/index-3prvb42w.js +30 -0
  41. package/dist/{index-ba7are04.js → index-3yb5kft5.js} +1 -1
  42. package/dist/index-568w258r.js +76 -0
  43. package/dist/{index-6a69xzrx.js → index-7zwtbak8.js} +5 -46
  44. package/dist/{index-fcqj44mb.js → index-8ryydawp.js} +4 -4
  45. package/dist/{index-fqd4yqwd.js → index-8xyf8h2k.js} +1 -1
  46. package/dist/{index-6f49krb5.js → index-aa50qwv4.js} +1 -1
  47. package/dist/{index-s20s2mad.js → index-bgcwxhxh.js} +16 -14
  48. package/dist/index-bph35vpy.js +77 -0
  49. package/dist/{index-ynrf908v.js → index-bz479f0x.js} +1 -1
  50. package/dist/{index-q968hy6y.js → index-e452syyh.js} +1 -1
  51. package/dist/index-h1j71dr1.js +48 -0
  52. package/dist/{index-mgb7r8b8.js → index-jswst0h3.js} +1 -1
  53. package/dist/{index-bbvc59gw.js → index-knmnj11j.js} +9 -180
  54. package/dist/{index-57gqaq8b.js → index-nyyam9ce.js} +1 -1
  55. package/dist/{index-s0qjs6ee.js → index-pq2m7t46.js} +9 -81
  56. package/dist/{index-yk4g8805.js → index-pq7rkwkk.js} +1 -30
  57. package/dist/{index-x8d9fdeg.js → index-qctbzmg9.js} +8 -4
  58. package/dist/{index-g444vfz2.js → index-r3db01kh.js} +1 -1
  59. package/dist/index-sb9dr3tq.js +14 -0
  60. package/dist/{index-rxcgp4b9.js → index-yb9n4pgj.js} +1 -1
  61. package/dist/{index-tvtacc9a.js → index-zyc64nbh.js} +1 -34
  62. package/llms/agent-runtime-harness.txt +4 -3
  63. package/llms/agent-runtime-sandbox.txt +1 -1
  64. package/llms/agent-runtime.2.txt +3 -2
  65. package/llms/agent-runtime.3.txt +4 -46
  66. package/llms/agent-runtime.4.txt +113 -0
  67. package/llms/agent-runtime.txt +11 -13
  68. package/llms/cli.txt +1 -1
  69. package/llms/stitchkit.txt +15 -9
  70. package/llms/testing.txt +4 -6
  71. package/llms/tools-agent.txt +24 -0
  72. package/llms/tools-mcp.txt +71 -6
  73. package/llms/tools-toolkit.txt +23 -0
  74. package/llms/tools.2.txt +6 -3
  75. package/llms/tools.3.txt +8 -77
  76. package/llms/tools.txt +8 -8
  77. package/llms/{upgrading-0.106.0-0.119.0.txt → upgrading-0.106.0-0.120.0.txt} +34 -3
  78. package/llms/upgrading.txt +1 -1
  79. package/llms-full.txt +231 -119
  80. package/llms.txt +9 -7
  81. package/package.json +10 -2
  82. package/dist/{index-arjmb6de.js → index-1jwsfkfz.js} +0 -0
  83. package/dist/{index-2dfvv1jg.js → index-2fc1k9k2.js} +0 -0
  84. package/dist/{index-qndsr7f0.js → index-5efrpfmj.js} +3 -3
  85. /package/dist/{index-cyxp8rbf.js → index-mtwh9hyp.js} +0 -0
  86. /package/dist/{index-f4njz9j0.js → index-qevqn3d3.js} +0 -0
@@ -25,25 +25,25 @@ import {
25
25
  } from "./index-ycqhyars.js";
26
26
  import {
27
27
  writeContainedFile
28
- } from "./index-q968hy6y.js";
28
+ } from "./index-e452syyh.js";
29
29
  import {
30
30
  openPinnedDirectory,
31
31
  isSafeEntryName,
32
32
  containedEntryMetadata
33
- } from "./index-arjmb6de.js";
33
+ } from "./index-1jwsfkfz.js";
34
+ import {
35
+ pollUntil
36
+ } from "./index-bph35vpy.js";
34
37
  import {
35
38
  collectToolSurface
36
39
  } from "./index-ff39f9dr.js";
37
40
  import {
38
41
  fetchGuarded,
39
42
  readCapped
40
- } from "./index-mgb7r8b8.js";
43
+ } from "./index-jswst0h3.js";
41
44
  import {
42
45
  errnoOf
43
46
  } from "./index-jj9228tt.js";
44
- import {
45
- sleep
46
- } from "./index-eemvahkc.js";
47
47
  import {
48
48
  isUnsafeKey,
49
49
  safeJsonParse
@@ -59,78 +59,6 @@ import {
59
59
  isRecord
60
60
  } from "./index-9jfdm5tg.js";
61
61
 
62
- // src/tools/operations/wait-core.ts
63
- var DEFAULT_BACKOFF = [2, 3, 5, 5, 8, 10];
64
- var DEFAULT_TIMEOUT = 600;
65
-
66
- class WaitTimeoutError extends Error {
67
- constructor() {
68
- super("wait deadline elapsed before the first snapshot");
69
- this.name = "WaitTimeoutError";
70
- }
71
- }
72
- async function pollUntil(params) {
73
- const backoff = params.backoff?.length ? params.backoff : DEFAULT_BACKOFF;
74
- const lastBackoff = backoff[backoff.length - 1] ?? 5;
75
- const timeoutSec = params.timeoutSec ?? DEFAULT_TIMEOUT;
76
- const pause = params.sleepFn ?? sleep;
77
- const now = params.nowFn ?? (() => performance.now());
78
- const startedAt = now();
79
- const deadline = startedAt + timeoutSec * 1000;
80
- let last;
81
- for (let attempt = 0;; attempt++) {
82
- params.signal?.throwIfAborted();
83
- const remainingBeforePoll = Math.max(0, deadline - now());
84
- if (remainingBeforePoll === 0 && last) {
85
- return { state: last.state, timedOut: true };
86
- }
87
- const deadlineController = new AbortController;
88
- const onCallerAbort = () => deadlineController.abort(params.signal?.reason);
89
- params.signal?.addEventListener("abort", onCallerAbort, { once: true });
90
- const deadlineTimer = setTimeout(() => deadlineController.abort(new WaitTimeoutError), remainingBeforePoll);
91
- deadlineTimer.unref?.();
92
- let state;
93
- try {
94
- state = await params.poll(deadlineController.signal);
95
- } catch (error) {
96
- if (params.signal?.aborted)
97
- throw params.signal.reason ?? error;
98
- if (deadlineController.signal.aborted && now() >= deadline) {
99
- if (last)
100
- return { state: last.state, timedOut: true };
101
- throw new WaitTimeoutError;
102
- }
103
- throw error;
104
- } finally {
105
- clearTimeout(deadlineTimer);
106
- params.signal?.removeEventListener("abort", onCallerAbort);
107
- }
108
- params.signal?.throwIfAborted();
109
- last = { state };
110
- if (params.done(state))
111
- return { state, timedOut: false };
112
- const elapsedMs = now() - startedAt;
113
- const elapsedSec = elapsedMs / 1000;
114
- params.onTick?.(attempt + 1, elapsedSec);
115
- if (elapsedSec >= timeoutSec)
116
- return { state, timedOut: true };
117
- const waitSec = backoff[Math.min(attempt, backoff.length - 1)] ?? lastBackoff;
118
- await pause(Math.min(waitSec * 1000, Math.max(0, deadline - now())), params.signal);
119
- }
120
- }
121
- function runWaitOperation(params) {
122
- return pollUntil({
123
- poll: (signal) => params.poll(params.input, signal),
124
- done: params.done,
125
- backoff: params.backoff,
126
- timeoutSec: params.timeoutSec,
127
- sleepFn: params.sleepFn,
128
- onTick: params.onTick,
129
- signal: params.signal,
130
- nowFn: params.nowFn
131
- });
132
- }
133
-
134
62
  // src/tools/cli/command.ts
135
63
  function defineCliCommand2(definition) {
136
64
  return definition;
@@ -2151,7 +2079,7 @@ function renderCliView2(data, view) {
2151
2079
  }
2152
2080
 
2153
2081
  // src/tools/cli/wait.ts
2154
- var DEFAULT_TIMEOUT2 = 600;
2082
+ var DEFAULT_TIMEOUT = 600;
2155
2083
  function waitFailure(tool, result) {
2156
2084
  return {
2157
2085
  ok: false,
@@ -2173,7 +2101,7 @@ async function pollUntilDone2(params) {
2173
2101
  const pollArgs = wait.poll(initial.data);
2174
2102
  if (!pollArgs)
2175
2103
  return initial;
2176
- const timeoutSec = params.timeoutSec ?? wait.timeout ?? DEFAULT_TIMEOUT2;
2104
+ const timeoutSec = params.timeoutSec ?? wait.timeout ?? DEFAULT_TIMEOUT;
2177
2105
  let failedState;
2178
2106
  const { state, timedOut } = await pollUntil({
2179
2107
  poll: () => call(wait.tool, pollArgs),
@@ -2455,4 +2383,4 @@ async function createCli2(config) {
2455
2383
  return runManagedInvocation(session, route);
2456
2384
  }
2457
2385
 
2458
- export { WaitTimeoutError, runWaitOperation, defineCliCommand2, DEFAULT_EXIT_CODES2, cliExitCode2, emitResult2, CliArgumentError2, cliInvocationResult2, createCliInvoker2, routeCliArgv2, parseCliArgs2, extractCliGlobalOptions2, renderCliView2, pollUntilDone2, createCli2 };
2386
+ export { defineCliCommand2, DEFAULT_EXIT_CODES2, cliExitCode2, emitResult2, CliArgumentError2, cliInvocationResult2, createCliInvoker2, routeCliArgv2, parseCliArgs2, extractCliGlobalOptions2, renderCliView2, pollUntilDone2, createCli2 };
@@ -101,33 +101,4 @@ function setCorsHeader(headers, key, value) {
101
101
  headers.set("Vary", `${existing}, ${value}`);
102
102
  }
103
103
 
104
- // src/server/process-signal-common.ts
105
- var DEFAULT_PROCESS_SIGNALS = ["SIGINT", "SIGTERM"];
106
- var defaultSignalSource = {
107
- on: (signal, handler) => {
108
- process.on(signal, handler);
109
- },
110
- off: (signal, handler) => {
111
- process.off(signal, handler);
112
- },
113
- raiseDefault: (signal) => {
114
- if (process.listenerCount(signal) > 0)
115
- return false;
116
- process.kill(process.pid, signal);
117
- return true;
118
- }
119
- };
120
- function reportSignalError(phase, error, onError) {
121
- try {
122
- onError?.(phase, error);
123
- } catch {}
124
- }
125
- function guardSignalCallback(run, phase, onError) {
126
- try {
127
- run();
128
- } catch (error) {
129
- reportSignalError(phase, error, onError);
130
- }
131
- }
132
-
133
- export { DEFAULT_CORS_ALLOW_HEADERS2, DEFAULT_CORS_EXPOSE_HEADERS2, assertCorsConfig, isOriginAllowed, corsHeaders2, corsPreflightResponse2, requestCorsHeaders, applyCors, DEFAULT_PROCESS_SIGNALS, defaultSignalSource, reportSignalError, guardSignalCallback };
104
+ export { DEFAULT_CORS_ALLOW_HEADERS2, DEFAULT_CORS_EXPOSE_HEADERS2, assertCorsConfig, isOriginAllowed, corsHeaders2, corsPreflightResponse2, requestCorsHeaders, applyCors };
@@ -19,10 +19,8 @@ import {
19
19
  agentDurableEventId2
20
20
  } from "./index-mnkk1ffz.js";
21
21
  import {
22
- createLocalStepDurability2,
23
- isAgentToolError2,
24
- createToolDurabilityContext
25
- } from "./index-tvtacc9a.js";
22
+ createLocalStepDurability2
23
+ } from "./index-zyc64nbh.js";
26
24
  import {
27
25
  canonicalAgentJson2,
28
26
  createToolChronology,
@@ -39,9 +37,15 @@ import {
39
37
  import {
40
38
  messageOf
41
39
  } from "./index-g149e9pk.js";
40
+ import {
41
+ createToolDurabilityContext
42
+ } from "./index-sb9dr3tq.js";
42
43
  import {
43
44
  createMutationQueue
44
45
  } from "./index-sykb5ag7.js";
46
+ import {
47
+ isAgentToolError2
48
+ } from "./index-1psbyyhj.js";
45
49
  import {
46
50
  assertPositiveSafeInteger
47
51
  } from "./index-0s4xebbg.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  attemptExclusiveLock
3
- } from "./index-ynrf908v.js";
3
+ } from "./index-bz479f0x.js";
4
4
  import {
5
5
  sleep
6
6
  } from "./index-eemvahkc.js";
@@ -0,0 +1,14 @@
1
+ // src/tools/durability-context.ts
2
+ var contexts = new WeakMap;
3
+ function createToolDurabilityContext(factory) {
4
+ const context = {};
5
+ contexts.set(context, factory);
6
+ return context;
7
+ }
8
+ function resolveToolDurability(context, callId, signal) {
9
+ if (typeof context !== "object" || context === null)
10
+ return;
11
+ return contexts.get(context)?.(callId, signal);
12
+ }
13
+
14
+ export { createToolDurabilityContext, resolveToolDurability };
@@ -4,7 +4,7 @@ import {
4
4
  AgentSandboxRestrictionSchema2,
5
5
  AgentSandboxGradeSchema2,
6
6
  AGENT_CODING_TOOL_NAMES
7
- } from "./index-1k18qzqa.js";
7
+ } from "./index-0qyrcjfs.js";
8
8
  import {
9
9
  AgentRecordIdSchema2,
10
10
  AgentRecordVersionSchema2,
@@ -543,37 +543,4 @@ function createLocalStepDurability2(options) {
543
543
  };
544
544
  }
545
545
 
546
- // src/tools/agent-tool-error.ts
547
- var AGENT_TOOL_ERROR_BRAND = Symbol.for("stitchkit.AgentToolError");
548
-
549
- class AgentToolError2 extends Error {
550
- output;
551
- constructor(output, cause) {
552
- let message = "Tool execution failed";
553
- try {
554
- message = JSON.stringify(output);
555
- } catch {}
556
- super(message, cause === undefined ? undefined : { cause });
557
- this.name = "AgentToolError";
558
- this.output = output;
559
- Object.defineProperty(this, AGENT_TOOL_ERROR_BRAND, { value: true });
560
- }
561
- }
562
- function isAgentToolError2(value) {
563
- return typeof value === "object" && value !== null && AGENT_TOOL_ERROR_BRAND in value;
564
- }
565
-
566
- // src/tools/durability-context.ts
567
- var contexts = new WeakMap;
568
- function createToolDurabilityContext(factory) {
569
- const context = {};
570
- contexts.set(context, factory);
571
- return context;
572
- }
573
- function resolveToolDurability(context, callId, signal) {
574
- if (typeof context !== "object" || context === null)
575
- return;
576
- return contexts.get(context)?.(callId, signal);
577
- }
578
-
579
- export { createLocalStepDurability2, AgentToolError2, isAgentToolError2, createToolDurabilityContext, resolveToolDurability };
546
+ export { createLocalStepDurability2 };
@@ -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,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) (continued)
@@ -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() }),
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