@crouton-kit/crouter 0.3.27 → 0.3.28

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 (62) hide show
  1. package/dist/builtin-personas/runtime-base.md +3 -0
  2. package/dist/clients/attach/__tests__/reconnect-giveup.test.d.ts +1 -0
  3. package/dist/clients/attach/__tests__/reconnect-giveup.test.js +30 -0
  4. package/dist/clients/attach/attach-cmd.js +187 -19
  5. package/dist/clients/attach/canvas-panels.d.ts +10 -0
  6. package/dist/clients/attach/canvas-panels.js +50 -0
  7. package/dist/clients/attach/graph-overlay.d.ts +34 -0
  8. package/dist/clients/attach/graph-overlay.js +266 -0
  9. package/dist/clients/attach/input-controller.d.ts +6 -0
  10. package/dist/clients/attach/input-controller.js +2 -0
  11. package/dist/clients/attach/slash-commands.d.ts +22 -1
  12. package/dist/clients/attach/slash-commands.js +160 -3
  13. package/dist/clients/attach/view-socket.d.ts +19 -1
  14. package/dist/clients/attach/view-socket.js +61 -6
  15. package/dist/commands/human/prompts.js +3 -3
  16. package/dist/commands/human/queue.d.ts +17 -0
  17. package/dist/commands/human/queue.js +111 -4
  18. package/dist/commands/memory/__tests__/lint-schema.test.js +24 -1
  19. package/dist/commands/memory/lint.d.ts +5 -4
  20. package/dist/commands/memory/lint.js +9 -5
  21. package/dist/commands/memory/write.js +12 -3
  22. package/dist/commands/sys/feedback.d.ts +1 -0
  23. package/dist/commands/sys/feedback.js +163 -0
  24. package/dist/commands/sys.js +3 -2
  25. package/dist/core/__tests__/broker-snapshot-history.test.d.ts +1 -0
  26. package/dist/core/__tests__/broker-snapshot-history.test.js +105 -0
  27. package/dist/core/__tests__/fixtures/fake-engine.d.ts +7 -0
  28. package/dist/core/__tests__/fixtures/fake-engine.js +10 -0
  29. package/dist/core/__tests__/full/placement-teardown.test.js +76 -0
  30. package/dist/core/__tests__/human-stranded-deliver.test.d.ts +1 -0
  31. package/dist/core/__tests__/human-stranded-deliver.test.js +108 -0
  32. package/dist/core/__tests__/on-read-dedup-resume.test.d.ts +1 -0
  33. package/dist/core/__tests__/on-read-dedup-resume.test.js +81 -0
  34. package/dist/core/canvas/nav-model.d.ts +162 -0
  35. package/dist/core/canvas/nav-model.js +486 -0
  36. package/dist/core/canvas/paths.d.ts +7 -0
  37. package/dist/core/canvas/paths.js +9 -0
  38. package/dist/core/runtime/broker-sdk.d.ts +0 -12
  39. package/dist/core/runtime/broker-sdk.js +77 -6
  40. package/dist/core/runtime/broker.d.ts +2 -1
  41. package/dist/core/runtime/broker.js +26 -1
  42. package/dist/core/runtime/front-door.js +23 -8
  43. package/dist/core/runtime/placement.d.ts +7 -6
  44. package/dist/core/runtime/placement.js +24 -12
  45. package/dist/core/runtime/revive.js +9 -0
  46. package/dist/core/runtime/spawn.d.ts +5 -0
  47. package/dist/core/runtime/spawn.js +62 -1
  48. package/dist/core/runtime/tmux.d.ts +9 -0
  49. package/dist/core/runtime/tmux.js +12 -0
  50. package/dist/core/spawn.d.ts +14 -0
  51. package/dist/core/spawn.js +29 -9
  52. package/dist/core/substrate/index.d.ts +1 -1
  53. package/dist/core/substrate/index.js +6 -6
  54. package/dist/core/substrate/injected-store.d.ts +10 -0
  55. package/dist/core/substrate/injected-store.js +55 -0
  56. package/dist/core/substrate/schema.d.ts +6 -8
  57. package/dist/core/substrate/schema.js +26 -28
  58. package/dist/pi-extensions/canvas-doc-substrate.js +16 -7
  59. package/dist/pi-extensions/canvas-nav.js +30 -385
  60. package/dist/pi-extensions/canvas-stophook.d.ts +1 -1
  61. package/dist/pi-extensions/canvas-stophook.js +32 -2
  62. package/package.json +1 -1
@@ -36,13 +36,24 @@ import { personaDrift, commitPersonaAck } from '../core/runtime/persona.js';
36
36
  import { reviveInPlace } from '../core/runtime/revive.js';
37
37
  import { handleNewSession, markCleanExitDone } from '../core/runtime/reset.js';
38
38
  import { focusOf, handFocusToManager, tearDownNode, closeFocusToShell } from '../core/runtime/placement.js';
39
+ /** Condense a tool call into one short line for the activity cue. Picks the most
40
+ * identifying arg (command / path / pattern / description), collapses whitespace,
41
+ * and hard-caps the length so a giant bash command can't bloat telemetry.json. */
42
+ const ACTIVITY_CAP = 80;
43
+ function summarizeActivity(toolName, args) {
44
+ const a = (args ?? {});
45
+ const pick = (v) => (typeof v === 'string' ? v : '');
46
+ const detail = pick(a['command']) || pick(a['path']) || pick(a['file_path']) || pick(a['pattern']) || pick(a['description']) || pick(a['prompt']);
47
+ const line = (detail !== '' ? `${toolName}: ${detail}` : toolName).replace(/\s+/g, ' ').trim();
48
+ return line.length > ACTIVITY_CAP ? line.slice(0, ACTIVITY_CAP) : line;
49
+ }
39
50
  /**
40
51
  * Merge accumulated token counts into nodes/<nodeId>/job/telemetry.json.
41
52
  * Creates the directory when it doesn't yet exist. Best-effort; never throws.
42
53
  * `contextTokens` is the live window gauge for THIS turn; when null (pi can't
43
54
  * size the window yet) the last recorded value is preserved.
44
55
  */
45
- function flushTelemetry(jobDirPath, tokensIn, tokensOut, model, contextTokens) {
56
+ function flushTelemetry(jobDirPath, tokensIn, tokensOut, model, contextTokens, activity) {
46
57
  try {
47
58
  if (!existsSync(jobDirPath))
48
59
  mkdirSync(jobDirPath, { recursive: true });
@@ -62,6 +73,7 @@ function flushTelemetry(jobDirPath, tokensIn, tokensOut, model, contextTokens) {
62
73
  tokens_in: tokensIn,
63
74
  tokens_out: tokensOut,
64
75
  context_tokens: contextTokens ?? existing.context_tokens,
76
+ last_activity: activity ?? existing.last_activity,
65
77
  model: model !== '' ? model : (existing.model ?? ''),
66
78
  updated_at: new Date().toISOString(),
67
79
  };
@@ -205,6 +217,10 @@ export function registerCanvasStophook(pi) {
205
217
  let totalIn = 0;
206
218
  let totalOut = 0;
207
219
  let model = '';
220
+ // Last live context-window gauge + last tool summary, tracked across handlers so
221
+ // a tool_execution_start flush (activity-only) preserves the latest token figure.
222
+ let lastContext = null;
223
+ let lastActivity = null;
208
224
  // Context-size steering. As input context grows we nudge the node once per
209
225
  // band on an escalating, persona-specific schedule (see steerBand/steerNote).
210
226
  // The node's (lifecycle, mode) persona is read at fire time, since a terminal
@@ -294,6 +310,18 @@ export function registerCanvasStophook(pi) {
294
310
  catch { /* best-effort */ }
295
311
  });
296
312
  // ---------------------------------------------------------------------------
313
+ // tool_execution_start — capture the live "what is it doing" cue. Writes the
314
+ // one-line tool summary to telemetry.json so out-of-process readers (the nav
315
+ // chrome) show it inline without a second file or any extra read on their side.
316
+ // ---------------------------------------------------------------------------
317
+ pi.on('tool_execution_start', (event) => {
318
+ try {
319
+ lastActivity = summarizeActivity(String(event?.toolName ?? ''), event?.args);
320
+ flushTelemetry(jobDirPath, totalIn, totalOut, model, lastContext, lastActivity);
321
+ }
322
+ catch { /* best-effort */ }
323
+ });
324
+ // ---------------------------------------------------------------------------
297
325
  // session_shutdown — clean exit → done.
298
326
  //
299
327
  // pi hands us a reason as a session tears down. Only 'quit' is a node-ending
@@ -347,8 +375,10 @@ export function registerCanvasStophook(pi) {
347
375
  contextTokens = t;
348
376
  }
349
377
  catch { /* gauge unavailable this turn */ }
378
+ if (contextTokens !== null)
379
+ lastContext = contextTokens;
350
380
  // Fire-and-forget: flushTelemetry uses synchronous fs writes and never throws.
351
- flushTelemetry(jobDirPath, totalIn, totalOut, model, contextTokens);
381
+ flushTelemetry(jobDirPath, totalIn, totalOut, model, contextTokens, lastActivity);
352
382
  // Context-size steering: fire the current band once, with lifecycle-specific
353
383
  // guidance (lifecycle is read live — a terminal worker may have promoted to
354
384
  // resident since launch).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crouton-kit/crouter",
3
- "version": "0.3.27",
3
+ "version": "0.3.28",
4
4
  "description": "crtr — fast access to skills, plugins, and marketplaces",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",