@crouter/api 0.3.386 → 0.3.388

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 (130) hide show
  1. package/dist/api/__tests__/integration/client.test.js +97 -0
  2. package/dist/api/client.d.ts +7 -0
  3. package/dist/api/client.js +40 -21
  4. package/dist/core/asset-root.d.ts +7 -0
  5. package/dist/core/asset-root.js +18 -0
  6. package/dist/core/canvas/boot-id.d.ts +6 -0
  7. package/dist/core/canvas/boot-id.js +26 -0
  8. package/dist/core/canvas/paths.d.ts +72 -0
  9. package/dist/core/canvas/paths.js +163 -0
  10. package/dist/core/canvas/pid.d.ts +391 -0
  11. package/dist/core/canvas/pid.js +948 -0
  12. package/dist/core/command-plugins/bundle.d.ts +149 -0
  13. package/dist/core/command-plugins/bundle.js +588 -0
  14. package/dist/core/command-plugins/endpoint.d.ts +24 -0
  15. package/dist/core/command-plugins/endpoint.js +51 -0
  16. package/dist/core/config.d.ts +233 -0
  17. package/dist/core/config.js +1120 -0
  18. package/dist/core/env-name.d.ts +6 -0
  19. package/dist/core/env-name.js +9 -0
  20. package/dist/core/errors.d.ts +38 -0
  21. package/dist/core/errors.js +90 -0
  22. package/dist/core/events/emit.d.ts +6 -0
  23. package/dist/core/events/emit.js +42 -0
  24. package/dist/core/events/envelope.d.ts +2 -0
  25. package/dist/core/events/envelope.js +84 -0
  26. package/dist/core/events/errors.d.ts +4 -0
  27. package/dist/core/events/errors.js +69 -0
  28. package/dist/core/events/operation-id.d.ts +4 -0
  29. package/dist/core/events/operation-id.js +24 -0
  30. package/dist/core/events/serialize.d.ts +4 -0
  31. package/dist/core/events/serialize.js +199 -0
  32. package/dist/core/events/source.d.ts +16 -0
  33. package/dist/core/events/source.js +31 -0
  34. package/dist/core/events/types.d.ts +68 -0
  35. package/dist/core/events/types.js +11 -0
  36. package/dist/core/exclusive-lock.d.ts +34 -0
  37. package/dist/core/exclusive-lock.js +197 -0
  38. package/dist/core/fs-utils.d.ts +44 -0
  39. package/dist/core/fs-utils.js +208 -0
  40. package/dist/core/help.d.ts +309 -0
  41. package/dist/core/help.js +406 -0
  42. package/dist/core/human/page-catalog.d.ts +57 -0
  43. package/dist/core/human/page-catalog.js +172 -0
  44. package/dist/core/installed-plugins.d.ts +2 -0
  45. package/dist/core/installed-plugins.js +79 -0
  46. package/dist/core/io.d.ts +122 -0
  47. package/dist/core/io.js +373 -0
  48. package/dist/core/keybindings/attach-control.d.ts +49 -0
  49. package/dist/core/keybindings/attach-control.js +42 -0
  50. package/dist/core/keybindings/catalog.d.ts +18 -0
  51. package/dist/core/keybindings/catalog.js +257 -0
  52. package/dist/core/keybindings/types.d.ts +42 -0
  53. package/dist/core/keybindings/types.js +1 -0
  54. package/dist/core/layout.d.ts +26 -0
  55. package/dist/core/layout.js +94 -0
  56. package/dist/core/locked-file.d.ts +27 -0
  57. package/dist/core/locked-file.js +118 -0
  58. package/dist/core/log.d.ts +9 -0
  59. package/dist/core/log.js +89 -0
  60. package/dist/core/manifest.d.ts +5 -0
  61. package/dist/core/manifest.js +15 -0
  62. package/dist/core/plugin-env.d.ts +8 -0
  63. package/dist/core/plugin-env.js +31 -0
  64. package/dist/core/plugin-extensions.d.ts +29 -0
  65. package/dist/core/plugin-extensions.js +191 -0
  66. package/dist/core/plugin-swap-lock.d.ts +9 -0
  67. package/dist/core/plugin-swap-lock.js +31 -0
  68. package/dist/core/preview-result-path.d.ts +4 -0
  69. package/dist/core/preview-result-path.js +26 -0
  70. package/dist/core/profiles/env-store.d.ts +22 -0
  71. package/dist/core/profiles/env-store.js +163 -0
  72. package/dist/core/profiles/fuzzy-match.d.ts +19 -0
  73. package/dist/core/profiles/fuzzy-match.js +92 -0
  74. package/dist/core/profiles/manifest.d.ts +120 -0
  75. package/dist/core/profiles/manifest.js +529 -0
  76. package/dist/core/rate-limit-scope.d.ts +25 -0
  77. package/dist/core/rate-limit-scope.js +64 -0
  78. package/dist/core/render.d.ts +12 -0
  79. package/dist/core/render.js +138 -0
  80. package/dist/core/resolver.d.ts +14 -0
  81. package/dist/core/resolver.js +111 -0
  82. package/dist/core/runtime/branded-host.d.ts +25 -0
  83. package/dist/core/runtime/branded-host.js +264 -0
  84. package/dist/core/runtime/broker/daemon-ops.d.ts +65 -0
  85. package/dist/core/runtime/broker/daemon-ops.js +177 -0
  86. package/dist/core/runtime/broker/signal-stream.d.ts +30 -0
  87. package/dist/core/runtime/broker/signal-stream.js +149 -0
  88. package/dist/core/scope.d.ts +32 -0
  89. package/dist/core/scope.js +184 -0
  90. package/dist/core/scoped-state/db.d.ts +17 -0
  91. package/dist/core/scoped-state/db.js +247 -0
  92. package/dist/core/scoped-state/migrate.d.ts +8 -0
  93. package/dist/core/scoped-state/migrate.js +187 -0
  94. package/dist/core/scoped-state/paths.d.ts +9 -0
  95. package/dist/core/scoped-state/paths.js +27 -0
  96. package/dist/core/scoped-state/profiles.d.ts +27 -0
  97. package/dist/core/scoped-state/profiles.js +93 -0
  98. package/dist/core/scoped-state/providers.d.ts +24 -0
  99. package/dist/core/scoped-state/providers.js +19 -0
  100. package/dist/core/scoped-state/schema.d.ts +6 -0
  101. package/dist/core/scoped-state/schema.js +43 -0
  102. package/dist/core/scoped-state/settings.d.ts +28 -0
  103. package/dist/core/scoped-state/settings.js +83 -0
  104. package/dist/core/spaces/open-beneath.d.ts +71 -0
  105. package/dist/core/spaces/open-beneath.js +581 -0
  106. package/dist/core/sqlite-statements.d.ts +4 -0
  107. package/dist/core/sqlite-statements.js +17 -0
  108. package/dist/core/subscription-state.d.ts +121 -0
  109. package/dist/core/subscription-state.js +287 -0
  110. package/dist/core/user-settings.d.ts +377 -0
  111. package/dist/core/user-settings.js +458 -0
  112. package/dist/daemon/broker-signals/bus.d.ts +30 -0
  113. package/dist/daemon/broker-signals/bus.js +87 -0
  114. package/dist/daemon/manage.d.ts +176 -0
  115. package/dist/daemon/manage.js +664 -0
  116. package/dist/daemon/pidfile.d.ts +8 -0
  117. package/dist/daemon/pidfile.js +37 -0
  118. package/dist/daemon/startup-policy.d.ts +1 -0
  119. package/dist/daemon/startup-policy.js +1 -0
  120. package/dist/native/linux.d.ts +29 -0
  121. package/dist/native/linux.js +20 -0
  122. package/dist/shared/env.d.ts +116 -0
  123. package/dist/shared/env.js +271 -0
  124. package/dist/shared/inbox-entry-body.d.ts +22 -0
  125. package/dist/shared/inbox-entry-body.js +116 -0
  126. package/dist/shared/working-activity.d.ts +9 -0
  127. package/dist/shared/working-activity.js +27 -0
  128. package/dist/types.d.ts +562 -0
  129. package/dist/types.js +186 -0
  130. package/package.json +1 -1
@@ -0,0 +1,18 @@
1
+ import type { BindingDefinition, SafetyRequirement } from './types.js';
2
+ import type { AttachBindingId, AttachMenuBindingId } from './attach-control.js';
3
+ type TmuxMenuAction = 'open' | 'attach' | 'show' | 'view-settings' | 'provider-options' | 'fold-tools' | 'metadata' | 'promote' | 'demote-mode' | 'resume' | 'fork' | 'demote' | 'make-resident' | 'detach' | 'close-subtree' | 'background-bash' | 'file-review' | 'pin' | 'reload-viewer' | 'recap' | 'context' | 'context-admin' | 'providers' | 'plugins' | 'analytics' | 'graph' | 'focus-manager' | 'copy-id' | 'issues';
4
+ type TmuxMenuEntryAction = Exclude<TmuxMenuAction, 'open' | 'attach'> | `issue.${'idea' | 'bug'}`;
5
+ type GraphAction = 'down' | 'up' | 'first' | 'last' | 'collapse-or-manager' | 'expand-or-child' | 'focus' | 'revive' | 'focus-manager' | 'close-subtree' | 'dismiss';
6
+ type BrowseAction = 'quit' | 'down' | 'up' | 'first' | 'last' | 'expand-or-child' | 'collapse-or-parent' | 'toggle-fold' | 'tab-next' | 'tab-previous' | `tab.${1 | 2 | 3 | 4 | 5}` | 'close-subtree' | 'confirm-close' | 'sort' | 'scope' | 'profile' | 'residents' | 'preview' | 'report' | 'pin' | 'search' | 'revive-now' | 'focus' | 'focus-background' | 'yank-id';
7
+ type ProfileMenuAction = 'up' | 'down' | 'select' | 'accept-default' | 'abort' | `slot.${1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9}` | 'create' | 'search-existing' | 'use-root' | 'set-default' | 'add-directory' | 'unpin' | 'manage';
8
+ type SetupAction = 'cancel' | 'tab-next' | 'tab-previous' | 'open' | 'list-down' | 'list-up' | 'toggle' | 'details' | 'advance' | 'cell-previous' | 'cell-next';
9
+ type SetupKeybindingAction = 'edit' | 'commit-edit' | 'cancel-edit' | 'unbind' | 'reset-row' | 'reset-all' | 'save' | 'discard' | 'page-up' | 'page-down' | 'filter' | 'filter-delete' | 'filter-clear';
10
+ type SetupModelsAction = 'open' | 'commit' | 'cancel' | 'scope-next';
11
+ export type BindingId = `crtr.tmux.menu.${TmuxMenuAction}` | `crtr.tmux.menu.issue.${'idea' | 'bug'}` | AttachMenuBindingId | `crtr.tmux.menu-global.${TmuxMenuEntryAction}` | `crtr.tmux.node.${'next' | 'previous'}` | 'crtr.tmux.inbox.toggle' | `crtr.attach.scroll.${'up' | 'down' | 'page-up' | 'page-down' | 'live'}` | 'crtr.attach.mouse.toggle' | 'crtr.attach.copy.message' | 'crtr.attach.help.toggle' | `crtr.attach.search.${'next' | 'previous' | 'edit' | 'close'}` | AttachBindingId | `crtr.graph.${GraphAction}` | `crtr.graph.confirm.${'accept' | 'cancel'}` | `crtr.inspector.${'force-quit' | 'down' | 'up' | 'section-next' | 'section-prev' | 'page-down' | 'page-up' | 'toggle-detail' | 'cancel-item' | 'open-log' | 'confirm' | 'dismiss' | 'retarget' | 'refresh' | 'quit'}` | `crtr.browse.${BrowseAction}` | `crtr.browse.search.${'cancel' | 'commit' | 'delete' | 'quit'}` | `crtr.profile.menu.${ProfileMenuAction}` | `crtr.profile.search.${'up' | 'down' | 'pick' | 'back' | 'delete' | 'abort'}` | `crtr.setup.${SetupAction}` | `crtr.setup.confirm.${'accept' | 'back'}` | `crtr.setup.keybindings.${SetupKeybindingAction}` | `crtr.setup.models.${SetupModelsAction}`;
12
+ export declare const BINDING_CATALOG: readonly [BindingDefinition<"crtr.tmux.menu.open">, BindingDefinition<"crtr.tmux.menu.attach">, ...(BindingDefinition<BindingId> | BindingDefinition<"crtr.tmux.node.next"> | BindingDefinition<"crtr.tmux.node.previous"> | BindingDefinition<"crtr.tmux.inbox.toggle"> | BindingDefinition<"crtr.attach.scroll.up"> | BindingDefinition<"crtr.attach.scroll.down"> | BindingDefinition<"crtr.attach.scroll.page-up"> | BindingDefinition<"crtr.attach.scroll.page-down"> | BindingDefinition<"crtr.attach.scroll.live"> | BindingDefinition<"crtr.attach.mouse.toggle"> | BindingDefinition<"crtr.attach.copy.message"> | BindingDefinition<"crtr.attach.search.next"> | BindingDefinition<"crtr.attach.search.previous"> | BindingDefinition<"crtr.attach.search.edit"> | BindingDefinition<"crtr.attach.search.close"> | BindingDefinition<"crtr.graph.down"> | BindingDefinition<"crtr.graph.up"> | BindingDefinition<"crtr.graph.first"> | BindingDefinition<"crtr.graph.last"> | BindingDefinition<"crtr.graph.collapse-or-manager"> | BindingDefinition<"crtr.graph.expand-or-child"> | BindingDefinition<"crtr.graph.focus"> | BindingDefinition<"crtr.graph.revive"> | BindingDefinition<"crtr.graph.focus-manager"> | BindingDefinition<"crtr.graph.close-subtree"> | BindingDefinition<"crtr.graph.dismiss"> | BindingDefinition<"crtr.graph.confirm.accept"> | BindingDefinition<"crtr.graph.confirm.cancel"> | BindingDefinition<"crtr.inspector.force-quit"> | BindingDefinition<"crtr.inspector.down"> | BindingDefinition<"crtr.inspector.up"> | BindingDefinition<"crtr.inspector.section-next"> | BindingDefinition<"crtr.inspector.section-prev"> | BindingDefinition<"crtr.inspector.page-down"> | BindingDefinition<"crtr.inspector.page-up"> | BindingDefinition<"crtr.inspector.toggle-detail"> | BindingDefinition<"crtr.inspector.cancel-item"> | BindingDefinition<"crtr.inspector.open-log"> | BindingDefinition<"crtr.inspector.confirm"> | BindingDefinition<"crtr.inspector.dismiss"> | BindingDefinition<"crtr.inspector.retarget"> | BindingDefinition<"crtr.inspector.refresh"> | BindingDefinition<"crtr.inspector.quit"> | BindingDefinition<"crtr.browse.quit"> | BindingDefinition<"crtr.browse.down"> | BindingDefinition<"crtr.browse.up"> | BindingDefinition<"crtr.browse.first"> | BindingDefinition<"crtr.browse.last"> | BindingDefinition<"crtr.browse.expand-or-child"> | BindingDefinition<"crtr.browse.collapse-or-parent"> | BindingDefinition<"crtr.browse.toggle-fold"> | BindingDefinition<"crtr.browse.tab-next"> | BindingDefinition<"crtr.browse.tab-previous"> | BindingDefinition<"crtr.browse.tab.2" | "crtr.browse.tab.5" | "crtr.browse.tab.4" | "crtr.browse.tab.3" | "crtr.browse.tab.1"> | BindingDefinition<"crtr.browse.close-subtree"> | BindingDefinition<"crtr.browse.confirm-close"> | BindingDefinition<"crtr.browse.sort"> | BindingDefinition<"crtr.browse.scope"> | BindingDefinition<"crtr.browse.profile"> | BindingDefinition<"crtr.browse.residents"> | BindingDefinition<"crtr.browse.preview"> | BindingDefinition<"crtr.browse.report"> | BindingDefinition<"crtr.browse.pin"> | BindingDefinition<"crtr.browse.search"> | BindingDefinition<"crtr.browse.revive-now"> | BindingDefinition<"crtr.browse.focus"> | BindingDefinition<"crtr.browse.focus-background"> | BindingDefinition<"crtr.browse.yank-id"> | BindingDefinition<"crtr.browse.search.cancel"> | BindingDefinition<"crtr.browse.search.commit"> | BindingDefinition<"crtr.browse.search.delete"> | BindingDefinition<"crtr.browse.search.quit"> | BindingDefinition<"crtr.profile.menu.up"> | BindingDefinition<"crtr.profile.menu.down"> | BindingDefinition<"crtr.profile.menu.select"> | BindingDefinition<"crtr.profile.menu.accept-default"> | BindingDefinition<"crtr.profile.menu.abort"> | BindingDefinition<"crtr.profile.menu.slot.2" | "crtr.profile.menu.slot.5" | "crtr.profile.menu.slot.4" | "crtr.profile.menu.slot.7" | "crtr.profile.menu.slot.3" | "crtr.profile.menu.slot.6" | "crtr.profile.menu.slot.1" | "crtr.profile.menu.slot.8" | "crtr.profile.menu.slot.9">)[], BindingDefinition<"crtr.profile.menu.create">, BindingDefinition<"crtr.profile.menu.search-existing">, BindingDefinition<"crtr.profile.menu.use-root">, BindingDefinition<"crtr.profile.menu.set-default">, BindingDefinition<"crtr.profile.menu.add-directory">, BindingDefinition<"crtr.profile.menu.unpin">, BindingDefinition<"crtr.profile.menu.manage">, BindingDefinition<"crtr.profile.search.up">, BindingDefinition<"crtr.profile.search.down">, BindingDefinition<"crtr.profile.search.pick">, BindingDefinition<"crtr.profile.search.back">, BindingDefinition<"crtr.profile.search.delete">, BindingDefinition<"crtr.profile.search.abort">, BindingDefinition<"crtr.setup.cancel">, BindingDefinition<"crtr.setup.tab-next">, BindingDefinition<"crtr.setup.tab-previous">, BindingDefinition<"crtr.setup.open">, BindingDefinition<"crtr.setup.list-down">, BindingDefinition<"crtr.setup.list-up">, BindingDefinition<"crtr.setup.toggle">, BindingDefinition<"crtr.setup.details">, BindingDefinition<"crtr.setup.advance">, BindingDefinition<"crtr.setup.confirm.accept">, BindingDefinition<"crtr.setup.confirm.back">, BindingDefinition<"crtr.setup.keybindings.edit">, BindingDefinition<"crtr.setup.keybindings.commit-edit">, BindingDefinition<"crtr.setup.keybindings.cancel-edit">, BindingDefinition<"crtr.setup.keybindings.unbind">, BindingDefinition<"crtr.setup.keybindings.reset-row">, BindingDefinition<"crtr.setup.keybindings.reset-all">, BindingDefinition<"crtr.setup.keybindings.save">, BindingDefinition<"crtr.setup.keybindings.discard">, BindingDefinition<"crtr.setup.keybindings.page-up">, BindingDefinition<"crtr.setup.keybindings.page-down">, BindingDefinition<"crtr.setup.keybindings.filter">, BindingDefinition<"crtr.setup.keybindings.filter-delete">, BindingDefinition<"crtr.setup.keybindings.filter-clear">, BindingDefinition<"crtr.setup.cell-previous">, BindingDefinition<"crtr.setup.cell-next">, BindingDefinition<"crtr.setup.models.open">, BindingDefinition<"crtr.setup.models.scope-next">, BindingDefinition<"crtr.setup.models.commit">, BindingDefinition<"crtr.setup.models.cancel">];
13
+ export declare const BINDING_IDS: ReadonlySet<string>;
14
+ /** True for an action whose direct gesture is handled inside an attach viewer.
15
+ * Tmux menu selectors and root shortcuts are chrome, not pane input. */
16
+ export declare function isAttachPaneBinding(definition: BindingDefinition): boolean;
17
+ export declare const SAFETY_REQUIREMENTS: readonly SafetyRequirement[];
18
+ export {};
@@ -0,0 +1,257 @@
1
+ function binding(id, group, name, description, defaults, inputKind, contexts, safety, pair) {
2
+ return Object.freeze({
3
+ id,
4
+ group,
5
+ name,
6
+ description,
7
+ defaults: Object.freeze([...defaults]),
8
+ inputKind,
9
+ contexts: Object.freeze([...contexts]),
10
+ ...(safety === undefined ? {} : { safety }),
11
+ ...(pair === undefined ? {} : { pair: Object.freeze({ ...pair }) }),
12
+ });
13
+ }
14
+ const b = binding;
15
+ function menuEntry(action, name, description, defaults, contexts) {
16
+ const menuId = `crtr.tmux.menu.${action}`;
17
+ const globalId = `crtr.tmux.menu-global.${action}`;
18
+ return [
19
+ b(menuId, 'Global tmux', name, description, defaults, 'tmux-menu-selector', contexts, undefined, { field: 'menu', pairedId: globalId }),
20
+ b(globalId, 'Global tmux', name, description, [], 'tmux-global-action', ['tmux.root'], undefined, { field: 'global', pairedId: menuId }),
21
+ ];
22
+ }
23
+ function attachEntry(menuId, actionId, name, description,
24
+ // Empty hides the row from the attach submenu while the action stays bindable
25
+ // and reachable by its direct gesture — file review lives on the top-level menu.
26
+ menuDefaults, directDefaults) {
27
+ return [
28
+ b(menuId, 'Attach', name, description, menuDefaults, 'tmux-menu-selector', ['tmux.menu.attach'], undefined, { field: 'menu', pairedId: actionId }),
29
+ b(actionId, 'Attach', name, description, directDefaults, 'host-global', ATTACH_CONTEXTS, undefined, { field: 'direct', pairedId: menuId }),
30
+ ];
31
+ }
32
+ const ATTACH_CONTEXTS = ['attach', 'graph', 'graph.confirm'];
33
+ const SETUP_CANCEL_CONTEXTS = [
34
+ 'setup.login', 'setup.list', 'setup.input', 'setup.keybindings',
35
+ 'setup.keybindings.edit', 'setup.keybindings.filter', 'setup.models',
36
+ ];
37
+ const SETUP_TAB_CONTEXTS = ['setup.login', 'setup.list', 'setup.keybindings', 'setup.models'];
38
+ export const BINDING_CATALOG = Object.freeze([
39
+ b('crtr.tmux.menu.open', 'Global tmux', 'Open crouter menu', 'Open the crouter action menu.', ['alt+c'], 'host-global', ['tmux.root']),
40
+ b('crtr.tmux.menu.attach', 'Global tmux', 'Attach actions', 'Open the attach-viewer action submenu.', ['a'], 'tmux-menu-selector', ['tmux.menu']),
41
+ ...menuEntry('promote', 'Promote to orchestrator', 'Promote the focused node to orchestrator — it holds a roadmap and delegates.', ['o'], ['tmux.menu']),
42
+ ...menuEntry('demote-mode', 'Demote to base node', 'Demote the focused orchestrator back to a base node — hands-on again in its own window, no roadmap to drive.', ['shift+o'], ['tmux.menu']),
43
+ ...menuEntry('resume', 'Find node', 'Open the canvas navigator and go to the chosen node.', ['/'], ['tmux.menu']),
44
+ ...menuEntry('fork', 'Fork node', 'Fork the focused node into an independent idle root.', ['f'], ['tmux.menu']),
45
+ ...menuEntry('demote', 'Demote to terminal', 'Demote the focused node to terminal — it keeps running, owes a final up the spine, and reaps when done.', ['d'], ['tmux.menu']),
46
+ ...menuEntry('make-resident', 'Make resident', 'Flip the focused node to resident — interactable, never forced to submit a final, and wakeable while attached or awaiting something live.', ['shift+r'], ['tmux.menu']),
47
+ ...menuEntry('detach', 'Demote and close viewer', 'Demote the focused node and close its viewer; its broker keeps running off-screen.', ['shift+d'], ['tmux.menu']),
48
+ ...menuEntry('close-subtree', 'Close subtree', 'Close the focused node and its subtree.', ['x'], ['tmux.menu']),
49
+ ...menuEntry('background-bash', 'Background running bash', 'Hand the focused node’s running bash command to its background job system.', ['b'], ['tmux.menu']),
50
+ ...menuEntry('file-review', 'Review a file', 'Open a line-anchored review of a file named in the transcript.', ['v'], ['tmux.menu']),
51
+ ...menuEntry('pin', 'Pin conversation', 'Pin or unpin this conversation in the canvas navigator.', ['p'], ['tmux.menu']),
52
+ ...menuEntry('show', 'Inspect node', 'Open the focused node’s inspection menu.', ['i'], ['tmux.menu']),
53
+ ...menuEntry('view-settings', 'Display settings', 'Open the viewer display-settings menu.', ['z'], ['tmux.menu']),
54
+ ...menuEntry('fold-tools', 'Fold finished tool calls', 'Fold every finished tool call in the transcript to its single call line.', ['f'], ['tmux.menu.view-settings']),
55
+ ...menuEntry('metadata', 'Show metadata', 'Show the focused node’s metadata dossier.', ['m'], ['tmux.menu.show']),
56
+ ...menuEntry('context', 'Browse context', 'Browse the focused node context.', ['c'], ['tmux.menu.show']),
57
+ ...menuEntry('providers', 'Open settings', 'Open the crouter settings panel.', [','], ['tmux.menu']),
58
+ // Next to the settings comma: the same page, opened on its provider-options
59
+ // destination.
60
+ ...menuEntry('provider-options', 'Provider options', 'Open provider options — how an authenticated provider serves your turns, including Codex fast mode.', ['.'], ['tmux.menu']),
61
+ // j and k steer the menu cursor, so no selector may claim either.
62
+ ...menuEntry('plugins', 'Browse plugins', 'Open the crouter plugin browser.', ['l'], ['tmux.menu']),
63
+ ...menuEntry('analytics', 'Analytics', 'Open the Analytics page: how agents worked in the last 24 hours or 7 days.', ['shift+a'], ['tmux.menu']),
64
+ // Lowercase c opens the create submenu, so the context surface takes the
65
+ // shifted form of the word its command tree already uses.
66
+ ...menuEntry('context-admin', 'Context surface', 'Open the context surface: which documents each event delivers, and the surfaces, gates, and caps that decide it.', ['shift+c'], ['tmux.menu']),
67
+ ...menuEntry('graph', 'Canvas graph', 'Open the canvas graph.', ['g'], ['tmux.menu']),
68
+ ...menuEntry('focus-manager', 'Go to manager', 'Focus this node’s manager.', ['h'], ['tmux.menu']),
69
+ ...menuEntry('copy-id', 'Copy node id', 'Copy the focused node id to the system clipboard.', ['y'], ['tmux.menu']),
70
+ ...menuEntry('reload-viewer', 'Reload viewer', 'Respawn this pane’s viewer onto the current runtime generation.', ['r'], ['tmux.menu']),
71
+ ...menuEntry('recap', 'Generate recap', 'Generate the focused node’s Goal and State recap and refresh its generated title.', ['s'], ['tmux.menu']),
72
+ ...menuEntry('issues', 'Open create menu', 'Open the create submenu.', ['c'], ['tmux.menu']),
73
+ ...menuEntry('issue.idea', 'Create idea', 'Create an idea issue.', ['i'], ['tmux.menu.issue']),
74
+ ...menuEntry('issue.bug', 'Create bug', 'Create a bug issue.', ['b'], ['tmux.menu.issue']),
75
+ b('crtr.tmux.node.next', 'Global tmux', 'Next node', 'Focus the next canvas node.', ['alt+]'], 'host-global', ['tmux.root']),
76
+ b('crtr.tmux.node.previous', 'Global tmux', 'Previous node', 'Focus the previous canvas node.', ['alt+['], 'host-global', ['tmux.root']),
77
+ b('crtr.tmux.inbox.toggle', 'Global tmux', 'Toggle inbox', 'Open or close the human inbox in the focused viewer.', ['alt+i'], 'host-global', ['tmux.root']),
78
+ ...attachEntry('crtr.tmux.menu.attach.detach', 'crtr.attach.detach', 'Detach', 'Detach from the node.', ['d'], ['ctrl+d']),
79
+ ...attachEntry('crtr.tmux.menu.attach.clear-or-detach', 'crtr.attach.clear-or-detach', 'Clear input (cancel agent on repeat)', 'Clear the input; press again within a second to cancel the running agent turn. Detach lives on its own binding.', ['c'], ['ctrl+c']),
80
+ ...attachEntry('crtr.tmux.menu.attach.graph.toggle', 'crtr.attach.graph.toggle', 'Toggle graph', 'Open or close the graph overlay.', ['g'], ['alt+g']),
81
+ ...attachEntry('crtr.tmux.menu.attach.help.toggle', 'crtr.attach.help.toggle', 'Help', 'Open the attach help overlay.', ['?'], ['alt+shift+k']),
82
+ ...attachEntry('crtr.tmux.menu.attach.inbox.toggle', 'crtr.attach.inbox.toggle', 'Toggle inbox', 'Open or close the human inbox surface in this viewer.', ['i'], []),
83
+ ...attachEntry('crtr.tmux.menu.attach.inbox-strip', 'crtr.attach.inbox-strip', 'Pending requests', 'Jump to the pending human-request strip at the top of the pane.', ['u'], ['alt+u']),
84
+ ...attachEntry('crtr.tmux.menu.attach.model-ladder.next', 'crtr.attach.model-ladder.next', 'Next model', 'Move to the next model ladder rung.', [']'], ['alt+m']),
85
+ ...attachEntry('crtr.tmux.menu.attach.model-ladder.previous', 'crtr.attach.model-ladder.previous', 'Previous model', 'Move to the previous model ladder rung.', ['['], ['alt+shift+m']),
86
+ ...attachEntry('crtr.tmux.menu.attach.command.inspect', 'crtr.attach.command.inspect', 'Inspect loaded command', 'Open the loaded slash command’s expanded prompt.', ['h'], ['alt+shift+h']),
87
+ ...attachEntry('crtr.tmux.menu.attach.file-review', 'crtr.attach.file-review', 'Review a file', 'Open a line-anchored review of a file named in the transcript.', [], ['alt+shift+r']),
88
+ ...attachEntry('crtr.tmux.menu.attach.profile-files', 'crtr.attach.profile-files', 'Search profile files', 'Fuzzy-match path segments across the node family’s working directories, their context directories (files), profile projects and the profile’s own directory; Ctrl+Y copies a selected path.', ['f'], ['ctrl+f']),
89
+ ...attachEntry('crtr.tmux.menu.attach.search', 'crtr.attach.search', 'Search transcript', 'Search the transcript as it is currently displayed — folded tool output is not searched until it is unfolded.', ['/'], ['alt+/']),
90
+ ...attachEntry('crtr.tmux.menu.attach.whip', 'crtr.attach.whip', 'Whip agent', 'Interrupt the agent and send a playful command.', ['w'], []),
91
+ b('crtr.attach.scroll.up', 'Attach', 'Scroll up', 'Scroll the transcript one line up.', ['shift+up'], 'terminal', ATTACH_CONTEXTS),
92
+ b('crtr.attach.scroll.down', 'Attach', 'Scroll down', 'Scroll the transcript one line down.', ['shift+down'], 'terminal', ATTACH_CONTEXTS),
93
+ b('crtr.attach.scroll.page-up', 'Attach', 'Scroll page up', 'Scroll the transcript one page up.', ['pageup'], 'terminal', ATTACH_CONTEXTS),
94
+ b('crtr.attach.scroll.page-down', 'Attach', 'Scroll page down', 'Scroll the transcript one page down.', ['pagedown'], 'terminal', ATTACH_CONTEXTS),
95
+ b('crtr.attach.scroll.live', 'Attach', 'Return to live', 'Return the transcript to the live bottom.', ['shift+end'], 'terminal', ATTACH_CONTEXTS),
96
+ b('crtr.attach.mouse.toggle', 'Attach', 'Toggle mouse wheel scrolling', 'Toggle mouse wheel scrolling on or off.', ['alt+shift+o'], 'terminal', ATTACH_CONTEXTS),
97
+ b('crtr.attach.copy.message', 'Attach', 'Copy visible message', 'Copy the newest message visible in the transcript viewport.', ['alt+shift+y'], 'terminal', ATTACH_CONTEXTS),
98
+ b('crtr.attach.search.next', 'Attach', 'Next match', 'Move to the next transcript search match.', ['n'], 'terminal', ['attach.search']),
99
+ b('crtr.attach.search.previous', 'Attach', 'Previous match', 'Move to the previous transcript search match.', ['shift+n'], 'terminal', ['attach.search']),
100
+ b('crtr.attach.search.edit', 'Attach', 'Edit query', 'Return to editing the transcript search query.', ['/'], 'terminal', ['attach.search']),
101
+ b('crtr.attach.search.close', 'Attach', 'Close search', 'Leave transcript search and clear its highlights.', ['escape'], 'terminal', ['attach.search'], 'dismiss-modal'),
102
+ b('crtr.graph.down', 'GRAPH', 'Move down', 'Move to the next graph row.', ['j', 'down'], 'terminal', ['graph']),
103
+ b('crtr.graph.up', 'GRAPH', 'Move up', 'Move to the previous graph row.', ['k', 'up'], 'terminal', ['graph']),
104
+ b('crtr.graph.first', 'GRAPH', 'First row', 'Move to the first graph row.', ['g'], 'terminal', ['graph']),
105
+ b('crtr.graph.last', 'GRAPH', 'Last row', 'Move to the last graph row.', ['shift+g'], 'terminal', ['graph']),
106
+ b('crtr.graph.collapse-or-manager', 'GRAPH', 'Collapse or manager', 'Collapse a node or move to its manager.', ['h', 'left'], 'terminal', ['graph']),
107
+ b('crtr.graph.expand-or-child', 'GRAPH', 'Expand or child', 'Expand a node or move to its child.', ['l', 'right'], 'terminal', ['graph']),
108
+ b('crtr.graph.focus', 'GRAPH', 'Focus node', 'Focus the selected node.', ['enter'], 'terminal', ['graph']),
109
+ b('crtr.graph.revive', 'GRAPH', 'Revive node', 'Revive and open the selected dormant node.', ['r'], 'terminal', ['graph']),
110
+ b('crtr.graph.focus-manager', 'GRAPH', 'Focus manager', 'Focus the selected node manager.', ['m'], 'terminal', ['graph']),
111
+ b('crtr.graph.close-subtree', 'GRAPH', 'Close subtree', 'Ask to close the selected subtree.', ['x'], 'terminal', ['graph']),
112
+ b('crtr.graph.dismiss', 'GRAPH', 'Dismiss graph', 'Close the graph overlay.', ['escape'], 'terminal', ['graph'], 'dismiss-modal'),
113
+ b('crtr.graph.confirm.accept', 'GRAPH', 'Confirm close', 'Confirm closing the selected subtree.', ['y'], 'terminal', ['graph.confirm']),
114
+ b('crtr.graph.confirm.cancel', 'GRAPH', 'Cancel close', 'Cancel closing the selected subtree.', ['n', 'escape'], 'terminal', ['graph.confirm'], 'dismiss-modal'),
115
+ b('crtr.inspector.force-quit', 'Inspector', 'Force quit Inspector', 'Immediately leave the Inspector.', ['ctrl+c'], 'host-global', ['inspector'], 'leave-screen'),
116
+ b('crtr.inspector.down', 'Inspector', 'Move down', 'Move the Inspector selection or scroll cursor down.', ['j', 'down'], 'terminal', ['inspector']),
117
+ b('crtr.inspector.up', 'Inspector', 'Move up', 'Move the Inspector selection or scroll cursor up.', ['k', 'up'], 'terminal', ['inspector']),
118
+ b('crtr.inspector.section-next', 'Inspector', 'Next section', 'Move to the next Inspector section.', ['tab'], 'terminal', ['inspector']),
119
+ b('crtr.inspector.section-prev', 'Inspector', 'Previous section', 'Move to the previous Inspector section.', ['shift+tab'], 'terminal', ['inspector']),
120
+ b('crtr.inspector.page-down', 'Inspector', 'Page down', 'Scroll the Inspector detail body down.', ['ctrl+d', 'pagedown'], 'terminal', ['inspector']),
121
+ b('crtr.inspector.page-up', 'Inspector', 'Page up', 'Scroll the Inspector detail body up.', ['ctrl+u', 'pageup'], 'terminal', ['inspector']),
122
+ b('crtr.inspector.toggle-detail', 'Inspector', 'Toggle item detail', 'Expand or collapse the selected cron or background job.', ['enter'], 'terminal', ['inspector']),
123
+ b('crtr.inspector.cancel-item', 'Inspector', 'Cancel selected item', 'Arm cancellation for the selected cron, or stopping for the selected background job.', ['x'], 'terminal', ['inspector']),
124
+ b('crtr.inspector.open-log', 'Inspector', 'Open job log', 'Follow the selected background job’s log in a new tmux window.', ['o'], 'terminal', ['inspector']),
125
+ b('crtr.inspector.confirm', 'Inspector', 'Confirm action', 'Confirm the armed Inspector action.', ['y'], 'terminal', ['inspector']),
126
+ b('crtr.inspector.dismiss', 'Inspector', 'Dismiss action', 'Dismiss an Inspector confirmation or banner.', ['escape'], 'terminal', ['inspector'], 'dismiss-modal'),
127
+ b('crtr.inspector.retarget', 'Inspector', 'Retarget', 'Inspect the selected cron anchor or creator node.', ['t'], 'terminal', ['inspector']),
128
+ b('crtr.inspector.refresh', 'Inspector', 'Refresh', 'Refresh the Inspector now.', ['g', 'r'], 'terminal', ['inspector']),
129
+ b('crtr.inspector.quit', 'Inspector', 'Quit', 'Leave the Inspector.', ['q'], 'terminal', ['inspector'], 'leave-screen'),
130
+ ...browseBindings(),
131
+ ...profileBindings(),
132
+ ...setupBindings(),
133
+ ]);
134
+ function browseBindings() {
135
+ const nav = 'browse';
136
+ return [
137
+ b('crtr.browse.quit', 'Browse and pickers', 'Quit browse', 'Leave canvas browse.', ['q', 'escape', 'ctrl+c'], 'terminal', [nav], 'leave-screen'),
138
+ b('crtr.browse.down', 'Browse and pickers', 'Move down', 'Move to the next row.', ['j', 'down'], 'terminal', [nav]),
139
+ b('crtr.browse.up', 'Browse and pickers', 'Move up', 'Move to the previous row.', ['k', 'up'], 'terminal', [nav]),
140
+ b('crtr.browse.first', 'Browse and pickers', 'First row', 'Move to the first row.', ['g'], 'terminal', [nav]),
141
+ b('crtr.browse.last', 'Browse and pickers', 'Last row', 'Move to the last row.', ['shift+g'], 'terminal', [nav]),
142
+ b('crtr.browse.expand-or-child', 'Browse and pickers', 'Expand or child', 'Expand a row or move to its child.', ['l', 'right'], 'terminal', [nav]),
143
+ b('crtr.browse.collapse-or-parent', 'Browse and pickers', 'Collapse or parent', 'Collapse a row or move to its parent.', ['h', 'left'], 'terminal', [nav]),
144
+ b('crtr.browse.toggle-fold', 'Browse and pickers', 'Toggle fold', 'Toggle the selected fold.', ['space'], 'terminal', [nav]),
145
+ b('crtr.browse.tab-next', 'Browse and pickers', 'Next tab', 'Select the next browse tab.', ['tab', ']'], 'terminal', [nav]),
146
+ b('crtr.browse.tab-previous', 'Browse and pickers', 'Previous tab', 'Select the previous browse tab.', ['shift+tab', '['], 'terminal', [nav]),
147
+ ...[1, 2, 3, 4, 5].map((slot) => b(`crtr.browse.tab.${slot}`, 'Browse and pickers', `Tab ${slot}`, `Select browse tab ${slot}.`, [`${slot}`], 'terminal', [nav])),
148
+ b('crtr.browse.close-subtree', 'Browse and pickers', 'Close subtree', 'Ask to close the selected subtree.', ['x'], 'terminal', [nav]),
149
+ b('crtr.browse.confirm-close', 'Browse and pickers', 'Confirm close', 'Confirm closing the selected subtree.', ['y'], 'terminal', ['browse.confirm']),
150
+ b('crtr.browse.sort', 'Browse and pickers', 'Change sort', 'Change the browse sort.', ['s'], 'terminal', [nav]),
151
+ b('crtr.browse.scope', 'Browse and pickers', 'Change scope', 'Toggle the browse cwd scope.', ['c'], 'terminal', [nav]),
152
+ b('crtr.browse.profile', 'Browse and pickers', 'Toggle profile', 'Toggle the browse profile scope.', ['shift+p'], 'terminal', [nav]),
153
+ b('crtr.browse.residents', 'Browse and pickers', 'Toggle residents', 'Toggle resident display.', ['r'], 'terminal', [nav]),
154
+ b('crtr.browse.preview', 'Browse and pickers', 'Toggle preview', 'Toggle the preview panel.', ['v'], 'terminal', [nav]),
155
+ b('crtr.browse.report', 'Browse and pickers', 'Toggle report', 'Swap the preview panel between the conversation and the node\'s newest report.', ['shift+v'], 'terminal', [nav]),
156
+ b('crtr.browse.pin', 'Browse and pickers', 'Pin node', 'Star or unstar the selected node.', ['p'], 'terminal', [nav]),
157
+ b('crtr.browse.search', 'Browse and pickers', 'Search', 'Open browse search.', ['/'], 'terminal', [nav]),
158
+ b('crtr.browse.revive-now', 'Browse and pickers', 'Revive now', 'Revive the selected node now.', ['shift+k'], 'terminal', [nav]),
159
+ b('crtr.browse.focus', 'Browse and pickers', 'Focus node', 'Focus the selected node.', ['enter', 'o'], 'terminal', [nav]),
160
+ b('crtr.browse.focus-background', 'Browse and pickers', 'Focus node (keep browsing)', 'Focus the selected node without leaving the navigator.', ['shift+o'], 'terminal', [nav]),
161
+ b('crtr.browse.yank-id', 'Browse and pickers', 'Yank node id', 'Copy the selected node id to the system clipboard.', ['y'], 'terminal', [nav]),
162
+ b('crtr.browse.search.cancel', 'Browse and pickers', 'Cancel search', 'Cancel browse search.', ['escape'], 'terminal', ['browse.search'], 'dismiss-modal'),
163
+ b('crtr.browse.search.commit', 'Browse and pickers', 'Commit search', 'Apply browse search.', ['enter'], 'terminal', ['browse.search']),
164
+ b('crtr.browse.search.delete', 'Browse and pickers', 'Delete search text', 'Delete the previous search character.', ['backspace'], 'terminal', ['browse.search']),
165
+ b('crtr.browse.search.quit', 'Browse and pickers', 'Quit browse', 'Leave canvas browse from search.', ['ctrl+c'], 'terminal', ['browse.search'], 'leave-screen'),
166
+ ];
167
+ }
168
+ function profileBindings() {
169
+ const menu = 'profile.menu';
170
+ const search = 'profile.search';
171
+ return [
172
+ b('crtr.profile.menu.up', 'Profiles', 'Move up', 'Move to the previous profile.', ['k', 'up'], 'terminal', [menu]),
173
+ b('crtr.profile.menu.down', 'Profiles', 'Move down', 'Move to the next profile.', ['j', 'down'], 'terminal', [menu]),
174
+ b('crtr.profile.menu.select', 'Profiles', 'Select profile', 'Select the highlighted profile.', ['enter'], 'terminal', [menu]),
175
+ b('crtr.profile.menu.accept-default', 'Profiles', 'Accept default', 'Accept the default profile.', ['escape'], 'terminal', [menu], 'leave-screen'),
176
+ b('crtr.profile.menu.abort', 'Profiles', 'Abort', 'Leave profile selection.', ['ctrl+c'], 'terminal', [menu], 'leave-screen'),
177
+ ...[1, 2, 3, 4, 5, 6, 7, 8, 9].map((slot) => b(`crtr.profile.menu.slot.${slot}`, 'Profiles', `Profile slot ${slot}`, `Select profile slot ${slot}.`, [`${slot}`], 'terminal', [menu])),
178
+ b('crtr.profile.menu.create', 'Profiles', 'Create profile', 'Create a profile.', ['c'], 'terminal', [menu]),
179
+ b('crtr.profile.menu.search-existing', 'Profiles', 'Search profiles', 'Search existing profiles.', ['s'], 'terminal', [menu]),
180
+ b('crtr.profile.menu.use-root', 'Profiles', 'Use root profile', 'Use the root profile.', ['r'], 'terminal', [menu]),
181
+ b('crtr.profile.menu.set-default', 'Profiles', 'Set default', 'Set the selected profile as default.', ['d'], 'terminal', [menu]),
182
+ b('crtr.profile.menu.add-directory', 'Profiles', 'Add directory', 'Add a directory to the profile.', ['a'], 'terminal', [menu]),
183
+ b('crtr.profile.menu.unpin', 'Profiles', 'Unpin directory', 'Unpin the selected directory.', ['u'], 'terminal', [menu]),
184
+ b('crtr.profile.menu.manage', 'Profiles', 'Manage profiles', 'Open the profiles settings page in a popup.', ['v'], 'terminal', [menu]),
185
+ b('crtr.profile.search.up', 'Profiles', 'Move up', 'Move to the previous search result.', ['up', 'ctrl+p'], 'terminal', [search]),
186
+ b('crtr.profile.search.down', 'Profiles', 'Move down', 'Move to the next search result.', ['down', 'ctrl+n'], 'terminal', [search]),
187
+ b('crtr.profile.search.pick', 'Profiles', 'Pick profile', 'Pick the highlighted profile.', ['enter'], 'terminal', [search]),
188
+ b('crtr.profile.search.back', 'Profiles', 'Back', 'Return to profile selection.', ['escape'], 'terminal', [search], 'leave-screen'),
189
+ b('crtr.profile.search.delete', 'Profiles', 'Delete filter text', 'Delete the previous filter character.', ['backspace'], 'terminal', [search]),
190
+ b('crtr.profile.search.abort', 'Profiles', 'Abort', 'Leave profile search.', ['ctrl+c'], 'terminal', [search], 'leave-screen'),
191
+ ];
192
+ }
193
+ function setupBindings() {
194
+ return [
195
+ b('crtr.setup.cancel', 'Setup', 'Cancel setup', 'Leave the setup wizard.', ['q', 'ctrl+c', 'ctrl+d'], 'terminal', SETUP_CANCEL_CONTEXTS, 'leave-screen'),
196
+ b('crtr.setup.tab-next', 'Setup', 'Next tab', 'Select the next setup tab.', ['tab', 'right'], 'terminal', SETUP_TAB_CONTEXTS),
197
+ b('crtr.setup.tab-previous', 'Setup', 'Previous tab', 'Select the previous setup tab.', ['shift+tab', 'left'], 'terminal', SETUP_TAB_CONTEXTS),
198
+ b('crtr.setup.open', 'Setup', 'Open', 'Open the selected setup item.', ['enter'], 'terminal', ['setup.login']),
199
+ b('crtr.setup.list-down', 'Setup', 'Move down', 'Move to the next setup item.', ['j', 'down'], 'terminal', ['setup.list', 'setup.models', 'setup.models.dimension-picker', 'setup.models.route-form']),
200
+ b('crtr.setup.list-up', 'Setup', 'Move up', 'Move to the previous setup item.', ['k', 'up'], 'terminal', ['setup.list', 'setup.models', 'setup.models.dimension-picker', 'setup.models.route-form']),
201
+ b('crtr.setup.toggle', 'Setup', 'Toggle', 'Toggle the selected setup item.', ['space'], 'terminal', ['setup.list', 'setup.keybindings']),
202
+ b('crtr.setup.details', 'Setup', 'Show details', 'Show details for the selected item.', ['?'], 'terminal', ['setup.list']),
203
+ b('crtr.setup.advance', 'Setup', 'Advance', 'Advance the setup flow.', ['enter'], 'terminal', ['setup.list']),
204
+ b('crtr.setup.confirm.accept', 'Setup', 'Confirm', 'Accept the setup confirmation.', ['y', 'enter'], 'terminal', ['setup.confirm', 'setup.models.confirm']),
205
+ b('crtr.setup.confirm.back', 'Setup', 'Go back', 'Cancel the setup confirmation.', ['n', 'escape', 'q'], 'terminal', ['setup.confirm', 'setup.models.confirm'], 'dismiss-modal'),
206
+ b('crtr.setup.keybindings.edit', 'Setup', 'Edit binding', 'Edit the selected binding.', ['enter'], 'terminal', ['setup.keybindings']),
207
+ b('crtr.setup.keybindings.commit-edit', 'Setup', 'Commit edit', 'Commit the active binding edit.', ['enter'], 'terminal', ['setup.keybindings.edit']),
208
+ b('crtr.setup.keybindings.cancel-edit', 'Setup', 'Cancel edit', 'Cancel the active binding edit.', ['escape'], 'terminal', ['setup.keybindings.edit'], 'dismiss-modal'),
209
+ b('crtr.setup.keybindings.unbind', 'Setup', 'Unbind', 'Disable the selected binding.', ['delete'], 'terminal', ['setup.keybindings']),
210
+ b('crtr.setup.keybindings.reset-row', 'Setup', 'Reset binding', 'Reset the selected binding.', ['r'], 'terminal', ['setup.keybindings']),
211
+ b('crtr.setup.keybindings.reset-all', 'Setup', 'Reset all bindings', 'Reset all bindings to defaults.', ['shift+r'], 'terminal', ['setup.keybindings']),
212
+ b('crtr.setup.keybindings.save', 'Setup', 'Save bindings', 'Save keybinding changes.', ['s'], 'terminal', ['setup.keybindings'], 'save-keybindings'),
213
+ b('crtr.setup.keybindings.discard', 'Setup', 'Discard changes', 'Discard keybinding changes.', ['escape'], 'terminal', ['setup.keybindings'], 'leave-screen'),
214
+ b('crtr.setup.keybindings.page-up', 'Setup', 'Page up', 'Move up one keybinding page.', ['pageup'], 'terminal', ['setup.keybindings', 'setup.keybindings.edit']),
215
+ b('crtr.setup.keybindings.page-down', 'Setup', 'Page down', 'Move down one keybinding page.', ['pagedown'], 'terminal', ['setup.keybindings', 'setup.keybindings.edit']),
216
+ b('crtr.setup.keybindings.filter', 'Setup', 'Filter bindings', 'Open the keybinding filter.', ['/'], 'terminal', ['setup.keybindings']),
217
+ b('crtr.setup.keybindings.filter-delete', 'Setup', 'Delete filter text', 'Delete the previous filter character.', ['backspace'], 'terminal', ['setup.keybindings.filter']),
218
+ b('crtr.setup.keybindings.filter-clear', 'Setup', 'Clear filter', 'Clear the keybinding filter.', ['escape'], 'terminal', ['setup.keybindings.filter'], 'dismiss-modal'),
219
+ b('crtr.setup.cell-previous', 'Setup', 'Previous field', 'Select the previous field or setup table cell.', ['h'], 'terminal', ['setup.models', 'setup.keybindings']),
220
+ b('crtr.setup.cell-next', 'Setup', 'Next field', 'Select the next field or setup table cell.', ['l'], 'terminal', ['setup.models', 'setup.keybindings']),
221
+ b('crtr.setup.models.open', 'Setup', 'Edit model', 'Edit the selected model cell or route field.', ['enter'], 'terminal', ['setup.models', 'setup.models.route-form']),
222
+ b('crtr.setup.models.scope-next', 'Setup', 'Next model config scope', 'Edit the next applicable user, profile, or project config.', ['s'], 'terminal', ['setup.models']),
223
+ b('crtr.setup.models.commit', 'Setup', 'Commit pick', 'Commit the provider, strength, model, or thinking-level pick.', ['enter'], 'terminal', ['setup.models.picker', 'setup.models.dimension-picker']),
224
+ b('crtr.setup.models.cancel', 'Setup', 'Cancel pick', 'Cancel the model picker or route form.', ['escape'], 'terminal', ['setup.models.picker', 'setup.models.dimension-picker', 'setup.models.route-form'], 'dismiss-modal'),
225
+ ];
226
+ }
227
+ export const BINDING_IDS = new Set(BINDING_CATALOG.map((definition) => definition.id));
228
+ /** True for an action whose direct gesture is handled inside an attach viewer.
229
+ * Tmux menu selectors and root shortcuts are chrome, not pane input. */
230
+ export function isAttachPaneBinding(definition) {
231
+ return definition.contexts.includes('attach')
232
+ && (definition.inputKind === 'terminal' || definition.inputKind === 'host-global');
233
+ }
234
+ export const SAFETY_REQUIREMENTS = Object.freeze([
235
+ { context: 'graph', capability: 'dismiss-modal' },
236
+ { context: 'graph.confirm', capability: 'dismiss-modal' },
237
+ { context: 'inspector', capability: 'leave-screen' },
238
+ { context: 'inspector', capability: 'dismiss-modal' },
239
+ { context: 'attach.search', capability: 'dismiss-modal' },
240
+ { context: 'browse', capability: 'leave-screen' },
241
+ { context: 'browse.search', capability: 'dismiss-modal' },
242
+ { context: 'profile.menu', capability: 'leave-screen' },
243
+ { context: 'profile.search', capability: 'leave-screen' },
244
+ { context: 'setup.login', capability: 'leave-screen' },
245
+ { context: 'setup.list', capability: 'leave-screen' },
246
+ { context: 'setup.input', capability: 'leave-screen' },
247
+ { context: 'setup.confirm', capability: 'dismiss-modal' },
248
+ { context: 'setup.keybindings', capability: 'leave-screen' },
249
+ { context: 'setup.keybindings', capability: 'save-keybindings' },
250
+ { context: 'setup.keybindings.edit', capability: 'dismiss-modal' },
251
+ { context: 'setup.keybindings.filter', capability: 'dismiss-modal' },
252
+ { context: 'setup.models', capability: 'leave-screen' },
253
+ { context: 'setup.models.picker', capability: 'dismiss-modal' },
254
+ { context: 'setup.models.dimension-picker', capability: 'dismiss-modal' },
255
+ { context: 'setup.models.route-form', capability: 'dismiss-modal' },
256
+ { context: 'setup.models.confirm', capability: 'dismiss-modal' },
257
+ ]);
@@ -0,0 +1,42 @@
1
+ export type BindingInputKind = 'terminal' | 'tmux-sequence' | 'tmux-menu-selector' | 'tmux-global-action' | 'host-global';
2
+ export interface BindingPair {
3
+ readonly field: 'menu' | 'global' | 'direct';
4
+ readonly pairedId: string;
5
+ }
6
+ export type BindingSafetyCapability = 'dismiss-modal' | 'leave-screen' | 'save-keybindings';
7
+ export interface BindingDefinition<Id extends string = string> {
8
+ readonly id: Id;
9
+ readonly group: string;
10
+ readonly name: string;
11
+ readonly description: string;
12
+ readonly defaults: readonly string[];
13
+ readonly inputKind: BindingInputKind;
14
+ readonly contexts: readonly string[];
15
+ readonly safety?: BindingSafetyCapability;
16
+ readonly pair?: BindingPair;
17
+ }
18
+ export interface EffectiveBinding<Id extends string = string> {
19
+ readonly definition: BindingDefinition<Id>;
20
+ readonly gestures: readonly string[];
21
+ readonly source: 'default' | 'user';
22
+ }
23
+ export type KeybindingDiagnosticCode = 'invalid-keybindings' | 'unknown-binding' | 'invalid-override' | 'collision' | 'unreachable';
24
+ export interface KeybindingDiagnostic {
25
+ readonly severity: 'error';
26
+ readonly code: KeybindingDiagnosticCode;
27
+ readonly bindingId?: string;
28
+ readonly relatedBindingIds?: readonly string[];
29
+ readonly offendingValue: unknown;
30
+ readonly message: string;
31
+ }
32
+ export interface SafetyRequirement {
33
+ readonly context: string;
34
+ readonly capability: BindingSafetyCapability;
35
+ }
36
+ export interface BindingResolution<Id extends string = string> {
37
+ readonly bindings: ReadonlyMap<Id, EffectiveBinding<Id>>;
38
+ readonly diagnostics: readonly KeybindingDiagnostic[];
39
+ get(id: Id): EffectiveBinding<Id>;
40
+ gestures(id: Id): readonly string[];
41
+ }
42
+ export type SparseKeybindingOverrides<Id extends string = string> = Partial<Record<Id, string[]>>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,26 @@
1
+ export declare const LAYOUT_VERSION = "1";
2
+ /** CRTR_HOME names the volume root, not the canvas records directory. */
3
+ export declare function layoutRoot(): string;
4
+ export declare function runtimeRoot(): string;
5
+ export declare function userRoot(): string;
6
+ export declare function appsRoot(): string;
7
+ export declare function secretsDir(): string;
8
+ export declare function profileSpace(app: string, id: string): {
9
+ memory: string;
10
+ env: string;
11
+ home: string;
12
+ };
13
+ export declare function socketDir(): string;
14
+ export declare function layoutVersionFile(): string;
15
+ export declare function userFilesRoot(): string;
16
+ export declare function appSpace(app: string): {
17
+ root: string;
18
+ memory: string;
19
+ conversations: string;
20
+ nodes: string;
21
+ files: string;
22
+ home: string;
23
+ };
24
+ /** A missing version on an occupied volume is never initialized by daemon startup. */
25
+ export declare function layoutNeedsMigration(): boolean;
26
+ export declare function initializeEmptyLayout(): void;
@@ -0,0 +1,94 @@
1
+ import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
2
+ import { homedir, userInfo } from 'node:os';
3
+ import { basename, dirname, isAbsolute, join, resolve } from 'node:path';
4
+ import { envHomeOverride } from '../shared/env.js';
5
+ import { readConfig } from './config.js';
6
+ export const LAYOUT_VERSION = '1';
7
+ /** CRTR_HOME names the volume root, not the canvas records directory. */
8
+ export function layoutRoot() {
9
+ const root = resolve(envHomeOverride() || (process.platform === 'linux' ? '/' : join(homedir(), '.crouter')));
10
+ if (runningUnderNodeTest() && root === accountLayoutRoot()) {
11
+ throw new Error(`refusing to use the account's real crouter root ${root} from a node --test process; point CRTR_HOME (not only HOME) at a temporary directory`);
12
+ }
13
+ return root;
14
+ }
15
+ /** `node --test` marks each isolated test child with NODE_TEST_CONTEXT and runs
16
+ * `--test-isolation=none` files with `--test` in execArgv. Production crtr
17
+ * processes carry neither. */
18
+ function runningUnderNodeTest() {
19
+ return process.env['NODE_TEST_CONTEXT'] !== undefined || process.execArgv.includes('--test');
20
+ }
21
+ /** The real account's `~/.crouter`, resolved from the passwd entry so a test
22
+ * that relocates HOME still names the root it must not touch. A node's shell
23
+ * inherits CRTR_HOME pointing here, so relocating HOME alone leaves every
24
+ * scoped-state write aimed at the person's live settings. */
25
+ let accountLayoutRootCache;
26
+ function accountLayoutRoot() {
27
+ if (accountLayoutRootCache === undefined) {
28
+ try {
29
+ accountLayoutRootCache = resolve(userInfo().homedir, '.crouter');
30
+ }
31
+ catch {
32
+ accountLayoutRootCache = null;
33
+ }
34
+ }
35
+ return accountLayoutRootCache;
36
+ }
37
+ export function runtimeRoot() { return join(layoutRoot(), 'runtime'); }
38
+ export function userRoot() { return join(layoutRoot(), 'user'); }
39
+ export function appsRoot() { return join(layoutRoot(), 'apps'); }
40
+ export function secretsDir() { return join(runtimeRoot(), 'secrets'); }
41
+ export function profileSpace(app, id) {
42
+ if (!/^[a-z0-9]+(?:-[a-z0-9]+)*-[0-9a-f]{8}$/.test(id))
43
+ throw new Error(`invalid profile id: ${id}`);
44
+ const space = appSpace(app);
45
+ return {
46
+ memory: join(space.memory, 'profiles', id),
47
+ env: join(secretsDir(), 'env', basename(space.root), id),
48
+ home: space.home,
49
+ };
50
+ }
51
+ export function socketDir() { return process.platform === 'linux' ? '/run/crtr' : runtimeRoot(); }
52
+ export function layoutVersionFile() { return join(runtimeRoot(), 'layout'); }
53
+ export function userFilesRoot() {
54
+ const path = readConfig('user').paths?.user_files ?? (process.platform === 'linux' ? join(userRoot(), 'files') : dirname(layoutRoot()));
55
+ if (!isAbsolute(path))
56
+ throw new Error('paths.user_files must be absolute');
57
+ return resolve(path);
58
+ }
59
+ export function appSpace(app) {
60
+ const id = app.startsWith('app:') ? app.slice(4) : app;
61
+ if (!/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(id) || id === '.' || id === '..')
62
+ throw new Error(`invalid app id: ${app}`);
63
+ const root = join(appsRoot(), id);
64
+ return { root, memory: join(root, 'memory'), conversations: join(root, 'conversations'), nodes: join(root, 'nodes'), files: join(root, 'files'), home: join(root, 'home') };
65
+ }
66
+ /** A missing version on an occupied volume is never initialized by daemon startup. */
67
+ export function layoutNeedsMigration() {
68
+ if (process.env['CRTR_LAYOUT_REFUSE'] === '1')
69
+ return true;
70
+ if (existsSync(layoutVersionFile())) {
71
+ if (readFileSync(layoutVersionFile(), 'utf8').trim() !== LAYOUT_VERSION)
72
+ throw new Error('unsupported runtime layout version');
73
+ return false;
74
+ }
75
+ const root = layoutRoot();
76
+ const volume = process.platform === 'linux' && root === '/' && existsSync('/volume') ? '/volume' : root;
77
+ if (existsSync(join(volume, 'canvas')) || existsSync(join(volume, 'canvas.db')))
78
+ return true;
79
+ // A moved canvas.db without a layout version is an unfinished offline
80
+ // migration. Node records move before the DB, so the old or moved DB always
81
+ // accompanies them; entrypoint-created directories are a fresh volume.
82
+ return existsSync(join(runtimeRoot(), 'canvas.db'));
83
+ }
84
+ export function initializeEmptyLayout() {
85
+ if (layoutNeedsMigration())
86
+ throw new Error('layout_migration_required');
87
+ for (const dir of [runtimeRoot(), userRoot(), appsRoot(), secretsDir()])
88
+ mkdirSync(dir, { recursive: true, mode: 0o700 });
89
+ mkdirSync(socketDir(), { recursive: true, mode: 0o755 });
90
+ if (process.platform === 'linux' && (statSync(socketDir()).mode & 0o777) !== 0o755)
91
+ throw new Error('launcher socket directory must be mode 0755');
92
+ if (!existsSync(layoutVersionFile()))
93
+ writeFileSync(layoutVersionFile(), `${LAYOUT_VERSION}\n`, { flag: 'wx', mode: 0o600 });
94
+ }
@@ -0,0 +1,27 @@
1
+ export type LockResult<T> = {
2
+ result: T;
3
+ next?: string;
4
+ };
5
+ /** Throws if this lock was compromised (stolen/expired) since acquisition. Callers that write
6
+ * from INSIDE the critical section must call it immediately before that write, because the
7
+ * post-`fn` check cannot un-write a file the callback already replaced. */
8
+ export type LockHeldGuard = () => void;
9
+ export type LockedFilePublish = (next: string) => void;
10
+ export interface LockedFileBackend {
11
+ withLockAsync<T>(fn: (current: string | undefined, assertLockHeld: LockHeldGuard, publish: LockedFilePublish) => Promise<LockResult<T>>): Promise<T>;
12
+ /** The current whole-file contents, or undefined when the file does not exist yet.
13
+ * Lock-free: every writer replaces the file by atomic rename. */
14
+ readUnlocked(): string | undefined;
15
+ }
16
+ /** A 0600 JSON file guarded by a cross-process `proper-lockfile` lock on its own path. */
17
+ export declare class LockedJsonFile implements LockedFileBackend {
18
+ private readonly path;
19
+ private readonly durable;
20
+ private readonly initialContent;
21
+ constructor(path: string, durable?: boolean, initialContent?: string);
22
+ readUnlocked(): string | undefined;
23
+ private ensureFile;
24
+ /** Acquire the lock without blocking the event loop, keeping every read-modify-write
25
+ * callback on the same asynchronous path. */
26
+ withLockAsync<T>(fn: (current: string | undefined, assertLockHeld: LockHeldGuard, publish: LockedFilePublish) => Promise<LockResult<T>>): Promise<T>;
27
+ }