@brimveyn/aimux 1.16.3 → 1.18.2

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 (61) hide show
  1. package/package.json +4 -2
  2. package/src/app-runtime/backend-runtime-events.ts +179 -0
  3. package/src/app-runtime/side-effects.ts +3 -1
  4. package/src/app.tsx +26 -0
  5. package/src/cli/chord.ts +77 -0
  6. package/src/cli/client/bootstrap.ts +76 -0
  7. package/src/cli/client/daemon-client.ts +228 -0
  8. package/src/cli/client/workspace-resolver.ts +57 -0
  9. package/src/cli/commands/tab/close.ts +33 -0
  10. package/src/cli/commands/tab/create.ts +109 -0
  11. package/src/cli/commands/tab/focus.ts +33 -0
  12. package/src/cli/commands/tab/list.ts +52 -0
  13. package/src/cli/commands/tab/send.ts +83 -0
  14. package/src/cli/commands/tab/snapshot.ts +127 -0
  15. package/src/cli/commands/tab/tail.ts +171 -0
  16. package/src/cli/commands/tab/wait.ts +86 -0
  17. package/src/cli/commands/workspace/close.ts +32 -0
  18. package/src/cli/commands/workspace/create.ts +92 -0
  19. package/src/cli/commands/workspace/list.ts +25 -0
  20. package/src/cli/commands/workspace/show.ts +32 -0
  21. package/src/cli/commands/workspace/switch.ts +75 -0
  22. package/src/cli/commands/worktree/create.ts +113 -0
  23. package/src/cli/commands/worktree/list.ts +44 -0
  24. package/src/cli/commands/worktree/remove.ts +59 -0
  25. package/src/cli/context.ts +16 -0
  26. package/src/cli/flags.ts +101 -0
  27. package/src/cli/index.ts +258 -0
  28. package/src/cli/output.ts +30 -0
  29. package/src/cli/registry.ts +54 -0
  30. package/src/cli/snapshot-render.ts +54 -0
  31. package/src/daemon/catalog-writer.ts +123 -0
  32. package/src/daemon/daemon.ts +566 -11
  33. package/src/daemon/reexec-client.ts +147 -0
  34. package/src/daemon/runtime-paths.ts +161 -1
  35. package/src/daemon/session-registry.ts +17 -0
  36. package/src/index.tsx +80 -2
  37. package/src/input/modes/bridge.ts +6 -0
  38. package/src/input/modes/transitions.ts +2 -0
  39. package/src/input/modes/types.ts +1 -0
  40. package/src/ipc/README.md +112 -0
  41. package/src/ipc/manager-protocol.ts +54 -4
  42. package/src/ipc/protocol.ts +466 -25
  43. package/src/platform/daemon-control.ts +14 -0
  44. package/src/restart-daemon.ts +36 -4
  45. package/src/session-backend/bootstrap.ts +110 -0
  46. package/src/session-backend/local-session-backend.ts +6 -0
  47. package/src/session-backend/remote-session-backend.ts +63 -0
  48. package/src/session-backend/types.ts +34 -0
  49. package/src/state/reducers/modal-state.ts +66 -1
  50. package/src/state/types.ts +40 -0
  51. package/src/state/validation.ts +1 -1
  52. package/src/terminal-manager/manager-client.ts +24 -7
  53. package/src/ui/components/flash/flash-label-badge.tsx +38 -0
  54. package/src/ui/components/layout/sidebar/tab-item.tsx +2 -0
  55. package/src/ui/components/layout/sidebar/workspace-list.tsx +4 -0
  56. package/src/ui/components/layout/sidebar/worktree-row.tsx +2 -0
  57. package/src/ui/components/layout/top-tab-bar.tsx +2 -0
  58. package/src/ui/flash/assign-labels.ts +126 -0
  59. package/src/ui/flash/build-labels.ts +78 -0
  60. package/src/ui/hooks/use-flash-label.ts +40 -0
  61. package/src/ui/root.tsx +3 -0
@@ -34,10 +34,32 @@ import {
34
34
  // is raised in lockstep to force matching binaries.
35
35
  export const MANAGER_PROTOCOL_MIN_VERSION = 8
36
36
  export const MANAGER_PROTOCOL_VERSION = 8
37
+
38
+ /**
39
+ * Capability strings advertised by *this* process in its `helloResult`. New
40
+ * additive TM features should be introduced here rather than via a MIN bump
41
+ * — bumping MIN forces a fresh TM and kills every PTY. See
42
+ * `src/ipc/README.md`.
43
+ */
44
+ export const MANAGER_PROTOCOL_CAPABILITIES: readonly string[] = [
45
+ 'setBroadcastEnabled',
46
+ 'createTabWorktreeId',
47
+ ]
48
+
49
+ /**
50
+ * Capability name a daemon must observe on the TM's helloResult before
51
+ * sending `setBroadcastEnabled`.
52
+ */
53
+ export const MANAGER_CAPABILITY_SET_BROADCAST_ENABLED = 'setBroadcastEnabled'
54
+
37
55
  /**
38
- * Minimum version required to send `setBroadcastEnabled`. Older TMs (v3) will
39
- * not understand the message; the daemon must check the negotiated version
40
- * before sending and fall back to always-on broadcast.
56
+ * Version-based fallback for `setBroadcastEnabled`. TM binaries that predate
57
+ * the capability field (built before the additive-contract migration) don't
58
+ * advertise capabilities, but any TM at v4+ speaks the request. Callers gate
59
+ * on `capabilities.has('setBroadcastEnabled') || selectedVersion >= this`.
60
+ *
61
+ * Rolling-upgrade window: new daemon + old TM (still v4+) would otherwise
62
+ * silently regress to always-broadcasting, spiking CPU and IPC traffic.
41
63
  */
42
64
  export const MANAGER_PROTOCOL_BROADCAST_GATE_VERSION = 4
43
65
 
@@ -51,6 +73,11 @@ export interface ManagerHelloResult {
51
73
  maxVersion: number
52
74
  processVersion: string
53
75
  selectedVersion: number
76
+ /**
77
+ * Feature flags. Always present on the typed shape; older peers that did
78
+ * not yet advertise capabilities are normalised to `[]` at parse time.
79
+ */
80
+ capabilities: string[]
54
81
  }
55
82
 
56
83
  export interface ManagerAttachRequest {
@@ -85,6 +112,13 @@ export type ManagerRequest =
85
112
  cwd?: string
86
113
  /** Extra env vars merged into the spawned PTY's environment. */
87
114
  env?: Record<string, string>
115
+ /**
116
+ * Worktree this tab belongs to (UI grouping). Capability-gated on
117
+ * `createTabWorktreeId`. Pre-cap TMs silently drop the field, which
118
+ * matches the previous behaviour where every new tab had
119
+ * `worktreeId = undefined`.
120
+ */
121
+ worktreeId?: string
88
122
  }
89
123
  }
90
124
  | { id: string; type: 'write'; payload: { sessionId: string; tabId: string; data: string } }
@@ -240,7 +274,10 @@ function isHelloResult(value: unknown): value is ManagerHelloResult {
240
274
  isFiniteNumber(value.minVersion) &&
241
275
  isFiniteNumber(value.maxVersion) &&
242
276
  isFiniteNumber(value.selectedVersion) &&
243
- isString(value.processVersion)
277
+ isString(value.processVersion) &&
278
+ // Wire-back-compat: legacy peers omit capabilities entirely. The parser
279
+ // normalises that to `[]` before returning the typed shape.
280
+ (value.capabilities === undefined || isStringArray(value.capabilities))
244
281
  )
245
282
  }
246
283
 
@@ -250,6 +287,12 @@ function assert(condition: boolean, message: string): asserts condition {
250
287
  }
251
288
  }
252
289
 
290
+ function normaliseManagerCapabilities(payload: Record<string, unknown>): void {
291
+ if (!Array.isArray(payload.capabilities)) {
292
+ payload.capabilities = []
293
+ }
294
+ }
295
+
253
296
  export function selectManagerProtocolVersion(payload: ManagerHelloRequest): number | null {
254
297
  return negotiateProtocolVersion(
255
298
  payload.minVersion,
@@ -261,6 +304,7 @@ export function selectManagerProtocolVersion(payload: ManagerHelloRequest): numb
261
304
 
262
305
  export function createManagerHelloResult(selectedVersion: number): ManagerHelloResult {
263
306
  return {
307
+ capabilities: [...MANAGER_PROTOCOL_CAPABILITIES],
264
308
  maxVersion: MANAGER_PROTOCOL_VERSION,
265
309
  minVersion: MANAGER_PROTOCOL_MIN_VERSION,
266
310
  processVersion: getProcessVersion(),
@@ -316,6 +360,10 @@ export function parseManagerRequest(value: unknown): ManagerRequest {
316
360
  value.payload.env === undefined || isStringRecord(value.payload.env),
317
361
  'createTab.env must be a string-keyed string record'
318
362
  )
363
+ assert(
364
+ value.payload.worktreeId === undefined || isString(value.payload.worktreeId),
365
+ 'createTab.worktreeId must be a string when present'
366
+ )
319
367
  return value as ManagerRequest
320
368
  case 'write':
321
369
  assert(isString(value.payload.sessionId), 'write.sessionId must be a string')
@@ -375,6 +423,8 @@ export function parseManagerMessage(value: unknown): ManagerResponse | ManagerEv
375
423
  case 'helloResult':
376
424
  assert(isString(value.id), 'helloResult.id must be a string')
377
425
  assert(isHelloResult(value.payload), 'helloResult.payload is invalid')
426
+ // Normalise wire-back-compat: pre-capability TMs omit the field.
427
+ normaliseManagerCapabilities(value.payload)
378
428
  return value as ManagerResponse
379
429
  case 'ok':
380
430
  assert(isString(value.id), 'ok.id must be a string')