@crouton-kit/crouter 0.3.70 → 0.3.79

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 (193) hide show
  1. package/README.md +1 -1
  2. package/dist/build-root.d.ts +12 -4
  3. package/dist/build-root.js +25 -6
  4. package/dist/builtin-memory/00-runtime-base.md +3 -10
  5. package/dist/builtin-memory/04-base-worker.md +18 -0
  6. package/dist/builtin-memory/04-orchestration-kernel.md +1 -1
  7. package/dist/builtin-memory/crouter-development/plugins.md +82 -5
  8. package/dist/builtin-pi-packages/pi-crtr-extensions/README.md +13 -34
  9. package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/__tests__/provider-rotation.test.ts +1115 -1
  10. package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/provider-rotation.ts +234 -71
  11. package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/statusline.ts +2 -9
  12. package/dist/builtin-pi-packages/pi-crtr-extensions/lib/subscription-state.ts +2 -516
  13. package/dist/builtin-pi-packages/pi-crtr-extensions/package-lock.json +2 -2
  14. package/dist/builtin-pi-packages/pi-mode-switch/README.md +11 -39
  15. package/dist/builtin-pi-packages/pi-mode-switch/extensions/index.ts +20 -15
  16. package/dist/builtin-pi-packages/pi-mode-switch/package.json +1 -1
  17. package/dist/builtin-views/canvas/tui.mjs +8 -9
  18. package/dist/builtin-views/chat/tui.mjs +12 -12
  19. package/dist/builtin-views/git-pr/tui.mjs +7 -8
  20. package/dist/builtin-views/inbox/tui.mjs +27 -41
  21. package/dist/builtin-views/linkedin/tui.mjs +23 -37
  22. package/dist/builtin-views/prompt-review/tui.mjs +11 -11
  23. package/dist/builtin-views/settings/tui.mjs +11 -11
  24. package/dist/builtin-views/workspace-sidebar/tui.mjs +8 -9
  25. package/dist/clients/attach/__tests__/attach-chrome-remote.test.js +11 -6
  26. package/dist/clients/attach/__tests__/attach-keybindings.test.d.ts +1 -0
  27. package/dist/clients/attach/__tests__/attach-keybindings.test.js +113 -0
  28. package/dist/clients/attach/__tests__/crtr-output-render.test.js +1 -1
  29. package/dist/clients/attach/__tests__/mermaid-render.test.d.ts +1 -0
  30. package/dist/clients/attach/__tests__/mermaid-render.test.js +28 -0
  31. package/dist/clients/attach/__tests__/oauth-dialog-lifecycle.test.d.ts +1 -0
  32. package/dist/clients/attach/__tests__/oauth-dialog-lifecycle.test.js +110 -0
  33. package/dist/clients/attach/attach-cmd.d.ts +9 -1
  34. package/dist/clients/attach/attach-cmd.js +841 -792
  35. package/dist/clients/attach/auth-pickers.d.ts +0 -12
  36. package/dist/clients/attach/auth-pickers.js +64 -15
  37. package/dist/clients/attach/canvas-panels.js +2 -3
  38. package/dist/clients/attach/chat-view.d.ts +7 -8
  39. package/dist/clients/attach/chat-view.js +119 -79
  40. package/dist/clients/attach/edit-diff-render.d.ts +6 -0
  41. package/dist/clients/attach/edit-diff-render.js +263 -0
  42. package/dist/clients/attach/graph-overlay.d.ts +12 -2
  43. package/dist/clients/attach/graph-overlay.js +83 -33
  44. package/dist/clients/attach/input-controller.d.ts +28 -2
  45. package/dist/clients/attach/input-controller.js +38 -5
  46. package/dist/clients/attach/mermaid-render.js +5 -2
  47. package/dist/clients/attach/pickers.d.ts +8 -7
  48. package/dist/clients/attach/pickers.js +11 -17
  49. package/dist/clients/attach/slash-commands.d.ts +9 -0
  50. package/dist/clients/attach/slash-commands.js +127 -7
  51. package/dist/clients/attach/titled-editor.d.ts +12 -1
  52. package/dist/clients/attach/titled-editor.js +103 -8
  53. package/dist/commands/canvas-browse.js +2 -2
  54. package/dist/commands/human/queue.js +3 -4
  55. package/dist/commands/memory/lint.js +39 -5
  56. package/dist/commands/memory/write.js +1 -0
  57. package/dist/commands/node.js +9 -2
  58. package/dist/commands/pkg/plugin-inspect.js +22 -1
  59. package/dist/commands/pkg/plugin-manage.js +31 -9
  60. package/dist/commands/surface-tmux-spread.js +1 -3
  61. package/dist/commands/sys/__tests__/config-keybindings.test.d.ts +1 -0
  62. package/dist/commands/sys/__tests__/config-keybindings.test.js +55 -0
  63. package/dist/commands/sys/__tests__/config-model-ladders.test.d.ts +1 -0
  64. package/dist/commands/sys/__tests__/config-model-ladders.test.js +121 -0
  65. package/dist/commands/sys/__tests__/setup-core.test.js +158 -1
  66. package/dist/commands/sys/config.js +18 -21
  67. package/dist/commands/sys/doctor.js +42 -4
  68. package/dist/commands/sys/setup-core.d.ts +49 -1
  69. package/dist/commands/sys/setup-core.js +161 -4
  70. package/dist/commands/sys/setup.d.ts +88 -0
  71. package/dist/commands/sys/setup.js +943 -169
  72. package/dist/commands/view-pick.d.ts +4 -0
  73. package/dist/commands/view-pick.js +17 -7
  74. package/dist/core/__tests__/base-worker-prompt.test.d.ts +1 -0
  75. package/dist/core/__tests__/base-worker-prompt.test.js +24 -0
  76. package/dist/core/__tests__/canvas-inbox-watcher-hold.test.js +232 -1
  77. package/dist/core/__tests__/canvas-inbox-watcher.test.js +34 -9
  78. package/dist/core/__tests__/command-plugins-surfaces.test.d.ts +1 -0
  79. package/dist/core/__tests__/command-plugins-surfaces.test.js +298 -0
  80. package/dist/core/__tests__/command-plugins.test.d.ts +1 -0
  81. package/dist/core/__tests__/command-plugins.test.js +444 -0
  82. package/dist/core/__tests__/fault-classifier.test.js +15 -0
  83. package/dist/core/__tests__/fixtures/fake-engine.d.ts +6 -0
  84. package/dist/core/__tests__/fixtures/fake-engine.js +9 -1
  85. package/dist/core/__tests__/full/broker-dialogs.test.js +7 -2
  86. package/dist/core/__tests__/host-teardown-process-group.test.js +15 -4
  87. package/dist/core/__tests__/preview-registry-sync.test.js +30 -1
  88. package/dist/core/__tests__/scope-crouter-home-fence.test.d.ts +1 -0
  89. package/dist/core/__tests__/scope-crouter-home-fence.test.js +55 -0
  90. package/dist/core/__tests__/stream-watchdog.test.d.ts +1 -0
  91. package/dist/core/__tests__/stream-watchdog.test.js +70 -0
  92. package/dist/core/__tests__/tmux-surface.test.js +72 -0
  93. package/dist/core/canvas/browse/__tests__/model.test.js +23 -5
  94. package/dist/core/canvas/browse/__tests__/render.test.js +1 -0
  95. package/dist/core/canvas/browse/app.d.ts +6 -0
  96. package/dist/core/canvas/browse/app.js +230 -41
  97. package/dist/core/canvas/browse/model.d.ts +10 -6
  98. package/dist/core/canvas/browse/model.js +20 -12
  99. package/dist/core/canvas/browse/pins.d.ts +4 -0
  100. package/dist/core/canvas/browse/pins.js +29 -0
  101. package/dist/core/canvas/browse/render.d.ts +13 -1
  102. package/dist/core/canvas/browse/render.js +72 -15
  103. package/dist/core/canvas/nav-model.js +5 -11
  104. package/dist/core/canvas/paths.d.ts +5 -0
  105. package/dist/core/canvas/paths.js +7 -0
  106. package/dist/core/command-plugins/adapter.d.ts +15 -0
  107. package/dist/core/command-plugins/adapter.js +145 -0
  108. package/dist/core/command-plugins/compose.d.ts +5 -0
  109. package/dist/core/command-plugins/compose.js +56 -0
  110. package/dist/core/command-plugins/discovery.d.ts +104 -0
  111. package/dist/core/command-plugins/discovery.js +565 -0
  112. package/dist/core/config.d.ts +48 -0
  113. package/dist/core/config.js +228 -110
  114. package/dist/core/fault-classifier.js +1 -1
  115. package/dist/core/fs-utils.d.ts +1 -0
  116. package/dist/core/fs-utils.js +15 -1
  117. package/dist/core/keybindings/__tests__/bespoke-consumers.test.d.ts +1 -0
  118. package/dist/core/keybindings/__tests__/bespoke-consumers.test.js +40 -0
  119. package/dist/core/keybindings/__tests__/resolve.test.d.ts +1 -0
  120. package/dist/core/keybindings/__tests__/resolve.test.js +224 -0
  121. package/dist/core/keybindings/catalog.d.ts +14 -0
  122. package/dist/core/keybindings/catalog.js +257 -0
  123. package/dist/core/keybindings/index.d.ts +5 -0
  124. package/dist/core/keybindings/index.js +4 -0
  125. package/dist/core/keybindings/match.d.ts +29 -0
  126. package/dist/core/keybindings/match.js +99 -0
  127. package/dist/core/keybindings/persistence.d.ts +14 -0
  128. package/dist/core/keybindings/persistence.js +31 -0
  129. package/dist/core/keybindings/resolve.d.ts +14 -0
  130. package/dist/core/keybindings/resolve.js +305 -0
  131. package/dist/core/keybindings/types.d.ts +37 -0
  132. package/dist/core/keybindings/types.js +1 -0
  133. package/dist/core/memory-resolver.d.ts +1 -1
  134. package/dist/core/memory-resolver.js +10 -3
  135. package/dist/core/predicate.d.ts +5 -3
  136. package/dist/core/predicate.js +5 -3
  137. package/dist/core/profiles/select.d.ts +6 -0
  138. package/dist/core/profiles/select.js +86 -52
  139. package/dist/core/provider-management.d.ts +12 -0
  140. package/dist/core/provider-management.js +24 -0
  141. package/dist/core/runtime/broker-protocol.d.ts +33 -5
  142. package/dist/core/runtime/broker.js +164 -14
  143. package/dist/core/runtime/launch.d.ts +39 -6
  144. package/dist/core/runtime/launch.js +78 -20
  145. package/dist/core/runtime/naming.js +3 -3
  146. package/dist/core/runtime/pi-cli.d.ts +6 -0
  147. package/dist/core/runtime/pi-cli.js +16 -2
  148. package/dist/core/runtime/pi-vendored.d.ts +8 -0
  149. package/dist/core/runtime/pi-vendored.js +14 -0
  150. package/dist/core/runtime/placement.d.ts +2 -2
  151. package/dist/core/runtime/placement.js +4 -1
  152. package/dist/core/runtime/promote.js +4 -0
  153. package/dist/core/runtime/recap.d.ts +3 -3
  154. package/dist/core/runtime/recap.js +75 -47
  155. package/dist/core/runtime/recycle.js +6 -1
  156. package/dist/core/runtime/reset.js +5 -0
  157. package/dist/core/runtime/session-list-cache.d.ts +33 -0
  158. package/dist/core/runtime/session-list-cache.js +338 -0
  159. package/dist/core/runtime/spawn.js +52 -45
  160. package/dist/core/runtime/stream-watchdog.d.ts +26 -0
  161. package/dist/core/runtime/stream-watchdog.js +75 -0
  162. package/dist/core/runtime/tmux-chrome.d.ts +1 -1
  163. package/dist/core/runtime/tmux-chrome.js +2 -2
  164. package/dist/core/runtime/tmux.d.ts +18 -15
  165. package/dist/core/runtime/tmux.js +217 -110
  166. package/dist/core/scope.js +27 -4
  167. package/dist/core/subscription-state.d.ts +90 -0
  168. package/dist/core/subscription-state.js +762 -0
  169. package/dist/core/tui/__tests__/host-keybindings.test.d.ts +1 -0
  170. package/dist/core/tui/__tests__/host-keybindings.test.js +112 -0
  171. package/dist/core/tui/host.d.ts +30 -1
  172. package/dist/core/tui/host.js +148 -34
  173. package/dist/core/view/contract.d.ts +17 -3
  174. package/dist/daemon/crtrd.js +253 -12
  175. package/dist/pi-extensions/__tests__/canvas-stophook-agentend.test.js +41 -0
  176. package/dist/pi-extensions/__tests__/canvas-stophook-context-nudge.test.d.ts +1 -0
  177. package/dist/pi-extensions/__tests__/canvas-stophook-context-nudge.test.js +121 -0
  178. package/dist/pi-extensions/canvas-inbox-watcher.d.ts +1 -1
  179. package/dist/pi-extensions/canvas-inbox-watcher.js +203 -25
  180. package/dist/pi-extensions/canvas-recap.d.ts +4 -0
  181. package/dist/pi-extensions/canvas-recap.js +73 -46
  182. package/dist/pi-extensions/canvas-stophook.d.ts +11 -0
  183. package/dist/pi-extensions/canvas-stophook.js +33 -4
  184. package/dist/types.d.ts +9 -26
  185. package/dist/types.js +1 -28
  186. package/dist/web-client/assets/{index-DiFuLcp6.js → index--md2ylfi.js} +1 -1
  187. package/dist/web-client/index.html +1 -1
  188. package/dist/web-client/sw.js +1 -1
  189. package/package.json +8 -4
  190. package/dist/pi-extensions/canvas-nav.d.ts +0 -43
  191. package/dist/pi-extensions/canvas-nav.js +0 -640
  192. package/dist/pi-extensions/widget-order-bus.d.ts +0 -6
  193. package/dist/pi-extensions/widget-order-bus.js +0 -34
@@ -481,12 +481,35 @@ export function registerCanvasStophook(pi) {
481
481
  flushTelemetry(jobDirPath, totalIn, totalOut, model, contextTokens, lastActivity);
482
482
  touchBusy(nodeId); // wedge heartbeat: a turn ending is a sign of life
483
483
  clearFault(nodeId, { link: 'daemon→node' }); // reaching turn_end proves this turn wasn't wedged
484
+ clearFault(nodeId, { link: 'pi→provider' }); // a completed provider round-trip proves this episode is over
485
+ // Will the agent run CONTINUE past this turn? Deterministic at turn_end:
486
+ // the loop keeps going exactly when this assistant message carried tool
487
+ // calls and the run wasn't aborted/errored (those end unconditionally,
488
+ // before tools execute). A tool-calling turn ends with stopReason
489
+ // 'toolUse' — or 'length' when truncation failed the calls, which still
490
+ // continues the loop — NEVER 'stop', so gate on the abort/error reasons,
491
+ // not on an allowlist that excludes 'toolUse'.
492
+ // This handler runs BEFORE the loop drains the steering queue, so the read
493
+ // is race-free: zero tool calls ⇒ this is the run's FINAL message, and a
494
+ // steer sent now would not redirect at a boundary — it would EXTEND the run
495
+ // past the agent's closing reply, burying the summary the human comes back
496
+ // to read once the conversation goes quiet.
497
+ const turnContent = Array.isArray(event?.message?.content) ? event.message.content : [];
498
+ const turnStopReason = event?.message?.stopReason ?? '';
499
+ const runContinues = turnStopReason !== 'error' &&
500
+ turnStopReason !== 'aborted' &&
501
+ turnContent.some((c) => c?.type === 'toolCall');
484
502
  // Context-size steering: fire the current band once, with lifecycle-specific
485
503
  // guidance (lifecycle is read live — a terminal worker may have promoted to
486
504
  // resident since launch).
487
- // Delivered as a STEER, not a followUp: guidance to become an orchestrator /
488
- // delegate / yield must redirect the node at the turn boundary, not queue
489
- // behind whatever it does next (where it rides along, easy to ignore).
505
+ // Delivery splits on runContinues:
506
+ // mid-run STEER, not a followUp: guidance to become an orchestrator /
507
+ // delegate / yield must redirect the node at the turn boundary, not queue
508
+ // behind whatever it does next (where it rides along, easy to ignore).
509
+ // • final message → HOLD via pi's 'nextTurn' queue: it injects alongside
510
+ // the next user message without triggering a turn, so the nudge is read
511
+ // at the start of the next engagement instead of spawning a phantom
512
+ // continuation after the agent already said its piece.
490
513
  // Never the cumulative totalIn: under prompt caching that never grows (input
491
514
  // is a ~2-token uncached delta each turn), so the bands were unreachable and
492
515
  // the nudge never fired.
@@ -497,7 +520,13 @@ export function registerCanvasStophook(pi) {
497
520
  const at = contextTokens !== null ? steerBand(contextTokens) : null;
498
521
  if (at !== null && !firedBands.has(at)) {
499
522
  firedBands.add(at);
500
- pi.sendUserMessage(`[crtr] ${steerNote(at, lifecycle, mode)}`, { deliverAs: 'steer' });
523
+ const note = `[crtr] ${steerNote(at, lifecycle, mode)}`;
524
+ if (runContinues) {
525
+ pi.sendUserMessage(note, { deliverAs: 'steer' });
526
+ }
527
+ else {
528
+ pi.sendMessage({ customType: 'crtr-context-nudge', content: note, display: true }, { deliverAs: 'nextTurn' });
529
+ }
501
530
  }
502
531
  }
503
532
  catch {
package/dist/types.d.ts CHANGED
@@ -20,6 +20,12 @@ export interface PluginManifest {
20
20
  source?: string;
21
21
  owner?: OwnerRef;
22
22
  kinds?: string[];
23
+ /** Plugin-root-relative path to one declarative command manifest
24
+ * (`commands.json`). When present on an installed, enabled plugin, that
25
+ * manifest contributes top-level command branches to the `crtr` tree —
26
+ * crtr owns parse/help/render/errors and direct-spawns the plugin's one
27
+ * executable per leaf invocation. See `src/core/command-plugins/`. */
28
+ commands?: string;
23
29
  }
24
30
  export interface MarketplacePluginEntry {
25
31
  name: string;
@@ -50,6 +56,8 @@ export interface AutoUpdateConfig {
50
56
  content: AutoUpdateMode;
51
57
  interval_hours: number;
52
58
  }
59
+ export type KeybindingOverrides = Record<string, string[]>;
60
+ /** Compile-time seam for runtime consumers migrating to semantic binding IDs. */
53
61
  export type CanvasAction = {
54
62
  kind?: 'crtr';
55
63
  run: string;
@@ -70,27 +78,6 @@ export interface CanvasMenuItem {
70
78
  action: CanvasAction;
71
79
  confirm?: boolean;
72
80
  }
73
- /** Legacy GRAPH bind shape; retained for graphBinds only. */
74
- export interface CanvasBind {
75
- run: string;
76
- confirm?: boolean;
77
- desc?: string;
78
- }
79
- /** Canvas-nav config (`canvasNav` in config.json). `prefixBinds` are consumed
80
- * at the tmux alt+c menu layer; `graphBinds` are consumed in-process by the
81
- * canvas-nav pi extension while in GRAPH. Built-in GRAPH keys
82
- * (j/k/h/l/g/G/enter/m/e/x/esc) are reserved — `graphBinds` is strictly
83
- * additive. */
84
- export interface CanvasNavConfig {
85
- /** Fallback pi shortcut for GRAPH toggle when NOT in tmux. Default 'alt+g'. */
86
- prefixKey?: string;
87
- /** chord key (after alt+c) → action; tmux-menu layer. */
88
- prefixBinds: Record<string, CanvasAction & {
89
- desc?: string;
90
- }>;
91
- /** extra raw key in GRAPH → action; pi-extension layer (additive only). */
92
- graphBinds: Record<string, CanvasBind>;
93
- }
94
81
  export type ModelStrength = 'ultra' | 'strong' | 'medium' | 'light';
95
82
  export type ModelProvider = 'anthropic' | 'openai';
96
83
  export interface ModelLaddersConfig {
@@ -129,7 +116,7 @@ export interface ScopeConfig {
129
116
  plugins: Record<string, ConfigPluginEntry>;
130
117
  auto_update: AutoUpdateConfig;
131
118
  max_panes_per_window: number;
132
- canvasNav: CanvasNavConfig;
119
+ keybindings: KeybindingOverrides;
133
120
  modelLadders: ModelLaddersConfig;
134
121
  /** The kind registry (spec §1.5): kind existence + launch knobs, keyed by
135
122
  * full kind string (top-level e.g. `developer`, or sub-kind e.g.
@@ -264,9 +251,5 @@ export declare function defaultRemoteCanvasConfig(): RemoteCanvasConfig;
264
251
  * ancestor) — `product/teardown` is included explicitly below for parity
265
252
  * even though its value equals the default. */
266
253
  export declare function defaultKindsConfig(): Record<string, KindConfig>;
267
- /** Built-in canvas-nav binds so an absent config still gives the intended UX.
268
- * prefixBinds restate the current menu defaults; graphBinds stay empty.
269
- */
270
- export declare function defaultCanvasNavConfig(): CanvasNavConfig;
271
254
  export declare function defaultModelLaddersConfig(): ModelLaddersConfig;
272
255
  export declare function defaultScopeState(): ScopeState;
package/dist/types.js CHANGED
@@ -28,7 +28,7 @@ export function defaultScopeConfig() {
28
28
  plugins: {},
29
29
  auto_update: { crtr: 'notify', content: 'notify', interval_hours: 24 },
30
30
  max_panes_per_window: DEFAULT_MAX_PANES_PER_WINDOW,
31
- canvasNav: defaultCanvasNavConfig(),
31
+ keybindings: {},
32
32
  modelLadders: defaultModelLaddersConfig(),
33
33
  kinds: defaultKindsConfig(),
34
34
  remoteCanvas: defaultRemoteCanvasConfig(),
@@ -119,33 +119,6 @@ export function defaultKindsConfig() {
119
119
  },
120
120
  };
121
121
  }
122
- /** Built-in canvas-nav binds so an absent config still gives the intended UX.
123
- * prefixBinds restate the current menu defaults; graphBinds stay empty.
124
- */
125
- export function defaultCanvasNavConfig() {
126
- return {
127
- prefixKey: 'alt+g',
128
- prefixBinds: {
129
- o: { kind: 'keys', keys: '/promote', desc: 'promote to orchestrator' },
130
- r: { kind: 'keys', keys: '/resume-node', desc: 'resume node' },
131
- d: { kind: 'crtr', run: 'node lifecycle demote --pane {pane}', desc: 'demote to terminal' },
132
- D: { kind: 'crtr', run: 'node lifecycle demote --pane {pane} --detach', desc: 'detach to background' },
133
- x: { kind: 'crtr', run: 'node lifecycle close --pane {pane}', desc: 'close agent + subtree' },
134
- c: { kind: 'keys', keys: '/context', desc: 'browse context dirs' },
135
- g: { kind: 'keys', keys: '/graph', desc: 'graph view' },
136
- m: { kind: 'crtr', run: 'node focus {manager}', desc: 'focus manager' },
137
- i: {
138
- kind: 'menu',
139
- desc: 'new issue / todo',
140
- items: [
141
- { key: 'i', desc: 'idea', action: { kind: 'popup', run: 'canvas issue new --type idea' } },
142
- { key: 'b', desc: 'bug', action: { kind: 'popup', run: 'canvas issue new --type bug' } },
143
- ],
144
- },
145
- },
146
- graphBinds: {},
147
- };
148
- }
149
122
  export function defaultModelLaddersConfig() {
150
123
  return {
151
124
  anthropic: {