@zgeoff/atc 0.1.11 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/README.md +54 -15
  2. package/package.json +7 -2
  3. package/src/{agent-adapter.ts → agents/agent-adapter.ts} +31 -14
  4. package/src/{build-cli-command.ts → agents/build-cli-command.ts} +1 -1
  5. package/src/agents/build-hook-settings.ts +59 -0
  6. package/src/{claude-adapter.ts → agents/claude-adapter.ts} +41 -80
  7. package/src/{codex-adapter.ts → agents/codex-adapter.ts} +41 -30
  8. package/src/agents/gateway-adapter.ts +106 -0
  9. package/src/{grok-adapter.ts → agents/grok-adapter.ts} +83 -46
  10. package/src/agents/resolve-agent-home.ts +13 -0
  11. package/src/agents/truncate-detail.ts +7 -0
  12. package/src/agents/write-hook-settings.ts +37 -0
  13. package/src/cli.ts +25 -14
  14. package/src/{boot-daemon.ts → client/boot-daemon.ts} +8 -7
  15. package/src/client/build-client-machine.ts +119 -0
  16. package/src/client/collect-agent-picks.ts +31 -0
  17. package/src/{daemon-client.ts → client/daemon-client.ts} +4 -4
  18. package/src/{dirs.ts → client/dirs.ts} +8 -0
  19. package/src/client/format-overlay-agent-mark.ts +15 -0
  20. package/src/{index.ts → client/index.ts} +181 -550
  21. package/src/client/keys.ts +111 -0
  22. package/src/client/parse-daemon-event.ts +114 -0
  23. package/src/{pick-tab-target.ts → client/pick-tab-target.ts} +2 -2
  24. package/src/client/spawn-picker.ts +305 -0
  25. package/src/client/to-mirror-session.ts +65 -0
  26. package/src/{ui.ts → client/ui.ts} +13 -8
  27. package/src/{attach-registry.ts → daemon/attach-registry.ts} +12 -10
  28. package/src/daemon/build-session-event.ts +43 -0
  29. package/src/{daemon-connection.ts → daemon/daemon-connection.ts} +194 -108
  30. package/src/{daemon.ts → daemon/daemon.ts} +142 -301
  31. package/src/{hooks.ts → daemon/hooks.ts} +6 -4
  32. package/src/daemon/mint-session-id.ts +12 -0
  33. package/src/{permission-registry.ts → daemon/permission-registry.ts} +5 -3
  34. package/src/daemon/restore-fleet.ts +141 -0
  35. package/src/daemon/run-eject-handoff.ts +33 -0
  36. package/src/{screen-model.ts → daemon/screen-model.ts} +1 -1
  37. package/src/daemon/session-runtime.ts +64 -0
  38. package/src/{sessions.ts → daemon/sessions.ts} +98 -144
  39. package/src/{start-headless-run.ts → daemon/start-headless-run.ts} +9 -3
  40. package/src/daemon/start-headless-turn.ts +57 -0
  41. package/src/hook-report.ts +2 -2
  42. package/src/mcp-server.ts +33 -44
  43. package/src/protocol/parse-request-params.ts +31 -0
  44. package/src/{protocol.ts → protocol/protocol.ts} +1 -1
  45. package/src/protocol/request-param-schemas.ts +109 -0
  46. package/src/shared/agent-session-id.ts +8 -0
  47. package/src/shared/build-optional-boolean.ts +10 -0
  48. package/src/shared/build-optional-string-array.ts +14 -0
  49. package/src/shared/build-optional-string.ts +10 -0
  50. package/src/shared/collect-gateways.ts +113 -0
  51. package/src/{config.ts → shared/config.ts} +47 -31
  52. package/src/{get-build.ts → shared/get-build.ts} +21 -6
  53. package/src/shared/get-record.ts +20 -0
  54. package/src/shared/session-id.ts +8 -0
  55. package/src/shared/to-agent-session-id.ts +12 -0
  56. package/src/shared/to-session-id.ts +11 -0
  57. package/src/shared/to-shell-arg.ts +7 -0
  58. package/src/statusline.ts +2 -2
  59. package/src/store/bun-sqlite-driver.ts +96 -0
  60. package/src/store/fleet-entry.ts +72 -0
  61. package/src/store/run-migrations.ts +242 -0
  62. package/src/store/state-store.ts +226 -0
  63. package/src/format-overlay-agent-mark.ts +0 -17
  64. package/src/state-store.ts +0 -227
  65. /package/src/{normalize-hook-event.ts → agents/normalize-hook-event.ts} +0 -0
  66. /package/src/{print-codex-hook-file.ts → agents/print-codex-hook-file.ts} +0 -0
  67. /package/src/{print-grok-hook-file.ts → agents/print-grok-hook-file.ts} +0 -0
  68. /package/src/{build-leader-chords.ts → client/build-leader-chords.ts} +0 -0
  69. /package/src/{daemon-error.ts → protocol/daemon-error.ts} +0 -0
  70. /package/src/{outbound-queue.ts → protocol/outbound-queue.ts} +0 -0
  71. /package/src/{collect-clean-env.ts → shared/collect-clean-env.ts} +0 -0
  72. /package/src/{report.ts → shared/report.ts} +0 -0
  73. /package/src/{reset-input-modes.ts → shared/reset-input-modes.ts} +0 -0
  74. /package/src/{resolve-repo-root.ts → shared/resolve-repo-root.ts} +0 -0
@@ -0,0 +1,31 @@
1
+ import type { AgentID } from '../agents/agent-adapter';
2
+ import type { Config } from '../shared/config';
3
+
4
+ export interface AgentPick {
5
+ readonly agent: AgentID;
6
+ readonly label: string;
7
+ }
8
+
9
+ /**
10
+ * The agent choices the spawn and adopt flows offer, in menu order. An agent
11
+ * whose configured binary does not resolve is left out, so every row in the
12
+ * menu is a session that can start. Resolution follows the rule a spawn
13
+ * follows: a bare name comes off PATH, a name carrying a separator is taken
14
+ * as a path, and either way it has to be executable.
15
+ */
16
+ export function collectAgentPicks(config: Config): AgentPick[] {
17
+ // Spawns inherit this process's PATH, so the search list is read live
18
+ // rather than left to the snapshot Bun.which defaults to.
19
+ const opts = { PATH: process.env['PATH'] ?? '' };
20
+
21
+ const candidates: readonly (AgentPick & { readonly bin: string })[] = [
22
+ { agent: 'claude', label: 'Claude', bin: config.claudeBin },
23
+ { agent: 'grok', label: 'Grok', bin: config.grokBin },
24
+ { agent: 'codex', label: 'Codex', bin: config.codexBin },
25
+ ...config.gateways.map((g) => ({ agent: g.id, label: g.label, bin: g.bin })),
26
+ ];
27
+
28
+ return candidates
29
+ .filter((c) => Bun.which(c.bin, opts) !== null)
30
+ .map((c) => ({ agent: c.agent, label: c.label }));
31
+ }
@@ -1,7 +1,7 @@
1
- import { DaemonError } from './daemon-error';
2
- import { OutboundQueue } from './outbound-queue';
3
- import { PROTOCOL_V, decodeMessage, encodeMessage } from './protocol';
4
- import type { EventMsg, ResponseMsg } from './protocol';
1
+ import { DaemonError } from '../protocol/daemon-error';
2
+ import { OutboundQueue } from '../protocol/outbound-queue';
3
+ import { PROTOCOL_V, decodeMessage, encodeMessage } from '../protocol/protocol';
4
+ import type { EventMsg, ResponseMsg } from '../protocol/protocol';
5
5
 
6
6
  interface Pending {
7
7
  readonly resolve: (ok: Readonly<Record<string, unknown>>) => void;
@@ -61,6 +61,14 @@ export function formatDir(d: string): string {
61
61
  return d.startsWith(home) ? `~${d.slice(home.length)}` : d;
62
62
  }
63
63
 
64
+ /**
65
+ * The short display name for a directory: its leaf, which is the name a
66
+ * session spawned there takes when its own name is left blank.
67
+ */
68
+ export function formatDirName(d: string): string {
69
+ return basename(d);
70
+ }
71
+
64
72
  const SEPARATORS = new Set(['/', '-', '_', '.', ' ']);
65
73
 
66
74
  /**
@@ -0,0 +1,15 @@
1
+ import type { AgentID } from '../agents/agent-adapter';
2
+
3
+ const BUILT_IN_MARKS: Readonly<Record<AgentID, string>> = { grok: 'g', codex: 'x' };
4
+
5
+ /**
6
+ * The reserved overlay column after unread: one character per agent, a space
7
+ * for Claude, so session names stay aligned across a mixed fleet. A
8
+ * configured mark wins, so a backend added by the user gets its own letter.
9
+ */
10
+ export function formatOverlayAgentMark(
11
+ agent: AgentID,
12
+ marks: Readonly<Record<AgentID, string>> = {},
13
+ ): string {
14
+ return marks[agent] ?? BUILT_IN_MARKS[agent] ?? ' ';
15
+ }