@h-rig/cli 0.0.6-alpha.8 → 0.0.6-alpha.81

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 (198) hide show
  1. package/README.md +1 -1
  2. package/dist/bin/build-rig-binaries.d.ts +2 -0
  3. package/dist/bin/rig.d.ts +2 -0
  4. package/dist/bin/rig.js +18374 -8205
  5. package/dist/src/app/board.d.ts +23 -0
  6. package/dist/src/app/board.js +1815 -0
  7. package/dist/src/app/drone-ui.d.ts +37 -0
  8. package/dist/src/app/drone-ui.js +294 -0
  9. package/dist/src/app/theme.d.ts +47 -0
  10. package/dist/src/app/theme.js +151 -0
  11. package/dist/src/app-opentui/adapters/common.d.ts +53 -0
  12. package/dist/src/app-opentui/adapters/common.js +149 -0
  13. package/dist/src/app-opentui/adapters/doctor.d.ts +11 -0
  14. package/dist/src/app-opentui/adapters/doctor.js +780 -0
  15. package/dist/src/app-opentui/adapters/fleet.d.ts +16 -0
  16. package/dist/src/app-opentui/adapters/fleet.js +874 -0
  17. package/dist/src/app-opentui/adapters/inbox.d.ts +33 -0
  18. package/dist/src/app-opentui/adapters/inbox.js +1454 -0
  19. package/dist/src/app-opentui/adapters/init.d.ts +13 -0
  20. package/dist/src/app-opentui/adapters/init.js +2357 -0
  21. package/dist/src/app-opentui/adapters/pi-attach.d.ts +16 -0
  22. package/dist/src/app-opentui/adapters/pi-attach.js +1295 -0
  23. package/dist/src/app-opentui/adapters/run-detail.d.ts +20 -0
  24. package/dist/src/app-opentui/adapters/run-detail.js +893 -0
  25. package/dist/src/app-opentui/adapters/server.d.ts +14 -0
  26. package/dist/src/app-opentui/adapters/server.js +798 -0
  27. package/dist/src/app-opentui/adapters/tasks.d.ts +55 -0
  28. package/dist/src/app-opentui/adapters/tasks.js +3472 -0
  29. package/dist/src/app-opentui/bootstrap.d.ts +16 -0
  30. package/dist/src/app-opentui/bootstrap.js +19509 -0
  31. package/dist/src/app-opentui/drone.d.ts +12 -0
  32. package/dist/src/app-opentui/drone.js +227 -0
  33. package/dist/src/app-opentui/events.d.ts +7 -0
  34. package/dist/src/app-opentui/events.js +28 -0
  35. package/dist/src/app-opentui/index.d.ts +8 -0
  36. package/dist/src/app-opentui/index.js +3477 -0
  37. package/dist/src/app-opentui/intent.d.ts +3 -0
  38. package/dist/src/app-opentui/intent.js +211 -0
  39. package/dist/src/app-opentui/layout.d.ts +15 -0
  40. package/dist/src/app-opentui/layout.js +44 -0
  41. package/dist/src/app-opentui/list-search.d.ts +8 -0
  42. package/dist/src/app-opentui/list-search.js +43 -0
  43. package/dist/src/app-opentui/pi-host-child.d.ts +2 -0
  44. package/dist/src/app-opentui/pi-host-child.js +778 -0
  45. package/dist/src/app-opentui/pi-pty-host.d.ts +64 -0
  46. package/dist/src/app-opentui/pi-pty-host.js +384 -0
  47. package/dist/src/app-opentui/registry.d.ts +4 -0
  48. package/dist/src/app-opentui/registry.js +6835 -0
  49. package/dist/src/app-opentui/render/graphics.d.ts +39 -0
  50. package/dist/src/app-opentui/render/graphics.js +537 -0
  51. package/dist/src/app-opentui/render/image-visual-layer-native-canvas.d.ts +2 -0
  52. package/dist/src/app-opentui/render/image-visual-layer-native-canvas.js +1480 -0
  53. package/dist/src/app-opentui/render/image-visual-layer-worker.d.ts +1 -0
  54. package/dist/src/app-opentui/render/image-visual-layer-worker.js +1541 -0
  55. package/dist/src/app-opentui/render/image-visual-layer.d.ts +93 -0
  56. package/dist/src/app-opentui/render/image-visual-layer.js +945 -0
  57. package/dist/src/app-opentui/render/panels.d.ts +10 -0
  58. package/dist/src/app-opentui/render/panels.js +201 -0
  59. package/dist/src/app-opentui/render/scene.d.ts +16 -0
  60. package/dist/src/app-opentui/render/scene.js +110 -0
  61. package/dist/src/app-opentui/render/text.d.ts +10 -0
  62. package/dist/src/app-opentui/render/text.js +121 -0
  63. package/dist/src/app-opentui/render/type-bar.d.ts +14 -0
  64. package/dist/src/app-opentui/render/type-bar.js +137 -0
  65. package/dist/src/app-opentui/runtime.d.ts +2 -0
  66. package/dist/src/app-opentui/runtime.js +3406 -0
  67. package/dist/src/app-opentui/scenes/doctor.d.ts +2 -0
  68. package/dist/src/app-opentui/scenes/doctor.js +91 -0
  69. package/dist/src/app-opentui/scenes/error.d.ts +2 -0
  70. package/dist/src/app-opentui/scenes/error.js +190 -0
  71. package/dist/src/app-opentui/scenes/fleet.d.ts +3 -0
  72. package/dist/src/app-opentui/scenes/fleet.js +207 -0
  73. package/dist/src/app-opentui/scenes/handoff.d.ts +2 -0
  74. package/dist/src/app-opentui/scenes/handoff.js +147 -0
  75. package/dist/src/app-opentui/scenes/help.d.ts +3 -0
  76. package/dist/src/app-opentui/scenes/help.js +138 -0
  77. package/dist/src/app-opentui/scenes/inbox.d.ts +2 -0
  78. package/dist/src/app-opentui/scenes/inbox.js +118 -0
  79. package/dist/src/app-opentui/scenes/init.d.ts +2 -0
  80. package/dist/src/app-opentui/scenes/init.js +94 -0
  81. package/dist/src/app-opentui/scenes/main.d.ts +2 -0
  82. package/dist/src/app-opentui/scenes/main.js +96 -0
  83. package/dist/src/app-opentui/scenes/run-detail.d.ts +2 -0
  84. package/dist/src/app-opentui/scenes/run-detail.js +139 -0
  85. package/dist/src/app-opentui/scenes/server.d.ts +2 -0
  86. package/dist/src/app-opentui/scenes/server.js +88 -0
  87. package/dist/src/app-opentui/scenes/tasks.d.ts +3 -0
  88. package/dist/src/app-opentui/scenes/tasks.js +230 -0
  89. package/dist/src/app-opentui/state.d.ts +4 -0
  90. package/dist/src/app-opentui/state.js +286 -0
  91. package/dist/src/app-opentui/theme.d.ts +36 -0
  92. package/dist/src/app-opentui/theme.js +88 -0
  93. package/dist/src/app-opentui/types.d.ts +188 -0
  94. package/dist/src/app-opentui/types.js +1 -0
  95. package/dist/src/commands/_async-ui.d.ts +13 -0
  96. package/dist/src/commands/_async-ui.js +223 -0
  97. package/dist/src/commands/_authority-runs.d.ts +22 -0
  98. package/dist/src/commands/_authority-runs.js +2 -3
  99. package/dist/src/commands/_cli-format.d.ts +49 -0
  100. package/dist/src/commands/_cli-format.js +447 -0
  101. package/dist/src/commands/_connection-state.d.ts +44 -0
  102. package/dist/src/commands/_connection-state.js +30 -11
  103. package/dist/src/commands/_doctor-checks.d.ts +52 -0
  104. package/dist/src/commands/_doctor-checks.js +180 -44
  105. package/dist/src/commands/_help-catalog.d.ts +51 -0
  106. package/dist/src/commands/_help-catalog.js +442 -0
  107. package/dist/src/commands/_json-output.d.ts +11 -0
  108. package/dist/src/commands/_json-output.js +56 -0
  109. package/dist/src/commands/_operator-surface.d.ts +34 -0
  110. package/dist/src/commands/_operator-surface.js +220 -0
  111. package/dist/src/commands/_operator-view.d.ts +30 -0
  112. package/dist/src/commands/_operator-view.js +803 -73
  113. package/dist/src/commands/_parsers.d.ts +15 -0
  114. package/dist/src/commands/_parsers.js +18 -11
  115. package/dist/src/commands/_paths.d.ts +11 -0
  116. package/dist/src/commands/_pi-frontend.d.ts +27 -0
  117. package/dist/src/commands/_pi-frontend.js +742 -0
  118. package/dist/src/commands/_pi-install.d.ts +42 -0
  119. package/dist/src/commands/_pi-install.js +5 -4
  120. package/dist/src/commands/_policy.d.ts +8 -0
  121. package/dist/src/commands/_policy.js +12 -5
  122. package/dist/src/commands/_preflight.d.ts +22 -0
  123. package/dist/src/commands/_preflight.js +190 -128
  124. package/dist/src/commands/_probes.d.ts +1 -0
  125. package/dist/src/commands/_run-driver-helpers.d.ts +99 -0
  126. package/dist/src/commands/_run-driver-helpers.js +75 -22
  127. package/dist/src/commands/_run-replay.d.ts +24 -0
  128. package/dist/src/commands/_run-replay.js +142 -0
  129. package/dist/src/commands/_server-client.d.ts +186 -0
  130. package/dist/src/commands/_server-client.js +360 -61
  131. package/dist/src/commands/_snapshot-upload.d.ts +39 -0
  132. package/dist/src/commands/_snapshot-upload.js +163 -39
  133. package/dist/src/commands/_spinner.d.ts +25 -0
  134. package/dist/src/commands/_spinner.js +65 -0
  135. package/dist/src/commands/_task-picker.d.ts +9 -0
  136. package/dist/src/commands/_task-picker.js +172 -19
  137. package/dist/src/commands/agent.d.ts +3 -0
  138. package/dist/src/commands/agent.js +39 -20
  139. package/dist/src/commands/browser.d.ts +65 -0
  140. package/dist/src/commands/browser.js +334 -51
  141. package/dist/src/commands/connect.d.ts +7 -0
  142. package/dist/src/commands/connect.js +272 -33
  143. package/dist/src/commands/dist.d.ts +28 -0
  144. package/dist/src/commands/dist.js +19 -12
  145. package/dist/src/commands/doctor.d.ts +3 -0
  146. package/dist/src/commands/doctor.js +378 -45
  147. package/dist/src/commands/github.d.ts +3 -0
  148. package/dist/src/commands/github.js +375 -53
  149. package/dist/src/commands/inbox.d.ts +30 -0
  150. package/dist/src/commands/inbox.js +760 -70
  151. package/dist/src/commands/init.d.ts +74 -0
  152. package/dist/src/commands/init.js +963 -119
  153. package/dist/src/commands/inspect.d.ts +3 -0
  154. package/dist/src/commands/inspect.js +588 -32
  155. package/dist/src/commands/inspector.d.ts +3 -0
  156. package/dist/src/commands/inspector.js +20 -13
  157. package/dist/src/commands/pi.d.ts +3 -0
  158. package/dist/src/commands/pi.js +177 -0
  159. package/dist/src/commands/plugin.d.ts +16 -0
  160. package/dist/src/commands/plugin.js +95 -27
  161. package/dist/src/commands/profile-and-review.d.ts +4 -0
  162. package/dist/src/commands/profile-and-review.js +26 -19
  163. package/dist/src/commands/queue.d.ts +3 -0
  164. package/dist/src/commands/queue.js +32 -12
  165. package/dist/src/commands/remote.d.ts +3 -0
  166. package/dist/src/commands/remote.js +43 -36
  167. package/dist/src/commands/repo-git-harness.d.ts +5 -0
  168. package/dist/src/commands/repo-git-harness.js +22 -15
  169. package/dist/src/commands/run.d.ts +3 -0
  170. package/dist/src/commands/run.js +1379 -159
  171. package/dist/src/commands/server.d.ts +7 -0
  172. package/dist/src/commands/server.js +502 -57
  173. package/dist/src/commands/setup.d.ts +16 -0
  174. package/dist/src/commands/setup.js +390 -63
  175. package/dist/src/commands/stats.d.ts +12 -0
  176. package/dist/src/commands/stats.js +1051 -0
  177. package/dist/src/commands/task-report-bug.d.ts +19 -0
  178. package/dist/src/commands/task-report-bug.js +260 -62
  179. package/dist/src/commands/task-run-driver.d.ts +132 -0
  180. package/dist/src/commands/task-run-driver.js +886 -130
  181. package/dist/src/commands/task.d.ts +14 -0
  182. package/dist/src/commands/task.js +1644 -314
  183. package/dist/src/commands/test.d.ts +3 -0
  184. package/dist/src/commands/test.js +15 -8
  185. package/dist/src/commands/workspace.d.ts +3 -0
  186. package/dist/src/commands/workspace.js +18 -11
  187. package/dist/src/commands.d.ts +29 -0
  188. package/dist/src/commands.js +10996 -6637
  189. package/dist/src/index.d.ts +4 -0
  190. package/dist/src/index.js +10197 -5787
  191. package/dist/src/launcher.d.ts +61 -0
  192. package/dist/src/launcher.js +77 -13
  193. package/dist/src/report-bug.d.ts +44 -0
  194. package/dist/src/report-bug.js +3 -3
  195. package/dist/src/runner.d.ts +47 -0
  196. package/dist/src/runner.js +16 -22
  197. package/dist/src/withMutedConsole.d.ts +2 -0
  198. package/package.json +16 -6
@@ -0,0 +1,188 @@
1
+ import type { StyledText } from "@opentui/core";
2
+ import type { RunnerContext } from "../runner";
3
+ import type { StageLayout } from "./layout";
4
+ export type AppSceneId = "main" | "fleet" | "tasks" | "inbox" | "server" | "init" | "doctor" | "run-detail" | "handoff" | "help" | "error";
5
+ export type AppActionKind = "none" | "refresh" | "navigate" | "task-run-next" | "task-run-id" | "run-stop" | "run-attach" | "run-steer" | "inbox-approve" | "inbox-reject" | "inbox-answer" | "init-start" | "doctor-run";
6
+ export type AppIntent = {
7
+ readonly scene: AppSceneId;
8
+ readonly argv: readonly string[];
9
+ readonly raw?: string;
10
+ readonly action: {
11
+ readonly kind: AppActionKind;
12
+ readonly label?: string;
13
+ readonly payload?: Record<string, unknown>;
14
+ };
15
+ };
16
+ export type AppStatus = "idle" | "loading" | "action" | "success" | "error";
17
+ export type AppFooterState = {
18
+ readonly project?: string;
19
+ readonly server?: string;
20
+ readonly auth?: string;
21
+ readonly run?: string;
22
+ readonly message?: string;
23
+ readonly [key: string]: string | undefined;
24
+ };
25
+ export type AppTypeBarState = {
26
+ readonly value: string;
27
+ readonly placeholder: string;
28
+ readonly message?: string;
29
+ };
30
+ export type AppErrorState = {
31
+ readonly message: string;
32
+ readonly hint?: string;
33
+ readonly cause?: unknown;
34
+ };
35
+ export type AppSelectionState = {
36
+ readonly index: number;
37
+ readonly count: number;
38
+ };
39
+ export type AppState = {
40
+ readonly projectRoot: string;
41
+ readonly scene: AppSceneId;
42
+ readonly status: AppStatus;
43
+ readonly tick: number;
44
+ readonly argv: readonly string[];
45
+ readonly intent: AppIntent;
46
+ readonly typeBar: AppTypeBarState;
47
+ readonly footer: AppFooterState;
48
+ readonly selection: AppSelectionState;
49
+ readonly data: Record<string, unknown>;
50
+ readonly runtimeReady: boolean;
51
+ readonly actionLabel?: string;
52
+ readonly error?: AppErrorState;
53
+ };
54
+ export type AppStatePatch = Omit<Partial<AppState>, "typeBar" | "footer" | "selection" | "data"> & {
55
+ readonly typeBar?: Partial<AppTypeBarState>;
56
+ readonly footer?: Partial<AppFooterState>;
57
+ readonly selection?: Partial<AppSelectionState>;
58
+ readonly data?: Record<string, unknown>;
59
+ };
60
+ export type AppEvent = {
61
+ readonly type: "scene.change";
62
+ readonly scene: AppSceneId;
63
+ readonly intent?: AppIntent;
64
+ } | {
65
+ readonly type: "action.started";
66
+ readonly label: string;
67
+ readonly optimistic?: Record<string, unknown>;
68
+ } | {
69
+ readonly type: "action.progress";
70
+ readonly label: string;
71
+ readonly detail?: string;
72
+ readonly data?: Record<string, unknown>;
73
+ } | {
74
+ readonly type: "action.completed";
75
+ readonly label: string;
76
+ readonly data?: Record<string, unknown>;
77
+ } | {
78
+ readonly type: "action.failed";
79
+ readonly label: string;
80
+ readonly message: string;
81
+ readonly hint?: string;
82
+ readonly cause?: unknown;
83
+ } | {
84
+ readonly type: "data.patch";
85
+ readonly data: Record<string, unknown>;
86
+ } | {
87
+ readonly type: "footer.patch";
88
+ readonly footer: Partial<AppFooterState>;
89
+ } | {
90
+ readonly type: "typebar.patch";
91
+ readonly typeBar: Partial<AppTypeBarState>;
92
+ } | {
93
+ readonly type: "runtime.ready";
94
+ readonly runner: RunnerContext;
95
+ } | {
96
+ readonly type: "runtime.failed";
97
+ readonly message: string;
98
+ readonly hint?: string;
99
+ readonly cause?: unknown;
100
+ };
101
+ export type AppStore = {
102
+ getState(): AppState;
103
+ setState(next: AppState): void;
104
+ patch(patch: AppStatePatch): void;
105
+ subscribe(listener: (state: AppState) => void): () => void;
106
+ };
107
+ export type AppEventBus = {
108
+ emit(event: AppEvent): void;
109
+ subscribe(listener: (event: AppEvent) => void): () => void;
110
+ };
111
+ export type AppSceneLine = {
112
+ readonly text: string;
113
+ readonly styledText?: StyledText;
114
+ readonly fg?: string;
115
+ readonly bold?: boolean;
116
+ readonly dim?: boolean;
117
+ readonly align?: "left" | "center" | "right";
118
+ /** Zero-based selectable item index for keyboard/mouse navigation. */
119
+ readonly selectableIndex?: number;
120
+ /** Activate on single click instead of only selecting/double-clicking. */
121
+ readonly activateOnClick?: boolean;
122
+ };
123
+ export type AppScenePanel = {
124
+ readonly id: string;
125
+ readonly top: number;
126
+ readonly left?: number;
127
+ readonly width?: number;
128
+ readonly height: number;
129
+ readonly lines: readonly AppSceneLine[];
130
+ readonly backgroundColor?: string;
131
+ readonly backgroundAlpha?: number;
132
+ readonly border?: boolean;
133
+ readonly borderColor?: string;
134
+ readonly borderAlpha?: number;
135
+ readonly opacity?: number;
136
+ readonly zIndex?: number;
137
+ readonly stickyScroll?: boolean;
138
+ readonly stickyStart?: "bottom" | "top" | "left" | "right";
139
+ readonly chrome?: "ad-terminal" | "none";
140
+ readonly headerText?: string;
141
+ readonly headerHeight?: number;
142
+ readonly paddingX?: number;
143
+ readonly paddingY?: number;
144
+ };
145
+ export type AppSceneFrame = {
146
+ readonly scene: AppSceneId;
147
+ readonly title?: string;
148
+ readonly lines: readonly AppSceneLine[];
149
+ readonly panels?: readonly AppScenePanel[];
150
+ readonly footer?: Partial<AppFooterState>;
151
+ readonly typeBarPlaceholder?: string;
152
+ readonly live?: boolean;
153
+ /** Use the full terminal canvas instead of the centered app layout. */
154
+ readonly fullScreen?: boolean;
155
+ /** Hide and blur the command typebar while another terminal app owns input. */
156
+ readonly hideTypeBar?: boolean;
157
+ /** Raw keypresses should be forwarded to the embedded terminal host. */
158
+ readonly terminalActive?: boolean;
159
+ };
160
+ export type AppSceneRenderer = (state: AppState, layout?: StageLayout) => AppSceneFrame;
161
+ export type AppRuntime = {
162
+ getState(): AppState;
163
+ patchState(patch: AppStatePatch): void;
164
+ emit(event: AppEvent): void;
165
+ setScene(scene: AppSceneId, intent?: AppIntent): void;
166
+ runIntent(intent: AppIntent): Promise<void>;
167
+ getRunnerContext(): Promise<RunnerContext>;
168
+ suspend(): void;
169
+ resume(): void;
170
+ destroy(): void;
171
+ };
172
+ export type AppAdapter = {
173
+ readonly id: string;
174
+ start?(runtime: AppRuntime): void | Promise<void>;
175
+ handleIntent?(runtime: AppRuntime, intent: AppIntent): boolean | void | Promise<boolean | void>;
176
+ };
177
+ export type AppLaunchOptions = {
178
+ readonly projectRoot: string;
179
+ readonly argv: readonly string[];
180
+ readonly dryRun?: boolean;
181
+ readonly runId?: string;
182
+ readonly policyMode?: "off" | "observe" | "enforce";
183
+ readonly projectConfigured?: boolean;
184
+ readonly initialFooter?: AppFooterState;
185
+ readonly initializeRuntime?: () => Promise<RunnerContext>;
186
+ readonly adapters?: readonly AppAdapter[];
187
+ readonly sceneRenderers?: Partial<Record<AppSceneId, AppSceneRenderer>>;
188
+ };
@@ -0,0 +1 @@
1
+ // @bun
@@ -0,0 +1,13 @@
1
+ import type { OutputMode } from "@rig/runtime/control-plane/runtime/types";
2
+ export type SpinnerOutput = Pick<NodeJS.WriteStream, "write"> & {
3
+ readonly isTTY?: boolean;
4
+ };
5
+ export type WithSpinnerOptions = {
6
+ /** Final line left behind on success. Default: the spinner line is erased. */
7
+ readonly doneLabel?: string;
8
+ /** Pass context.outputMode; "json" suppresses all spinner output. */
9
+ readonly outputMode?: OutputMode;
10
+ /** Stream override for tests. Defaults to process.stderr. */
11
+ readonly output?: SpinnerOutput;
12
+ };
13
+ export declare function withSpinner<T>(label: string, work: (update: (label: string) => void) => Promise<T>, options?: WithSpinnerOptions): Promise<T>;
@@ -0,0 +1,223 @@
1
+ // @bun
2
+ // packages/cli/src/commands/_async-ui.ts
3
+ import pc from "picocolors";
4
+
5
+ // packages/cli/src/commands/_spinner.ts
6
+ var SPINNER_FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
7
+ function createTtySpinner(input) {
8
+ const output = input.output ?? process.stdout;
9
+ const isTty = output.isTTY === true;
10
+ const frames = input.frames && input.frames.length > 0 ? input.frames : SPINNER_FRAMES;
11
+ let label = input.label;
12
+ let frame = 0;
13
+ let paused = false;
14
+ let stopped = false;
15
+ let lastPrintedLabel = "";
16
+ const render = () => {
17
+ if (stopped || paused)
18
+ return;
19
+ if (!isTty) {
20
+ if (label !== lastPrintedLabel) {
21
+ output.write(`${label}
22
+ `);
23
+ lastPrintedLabel = label;
24
+ }
25
+ return;
26
+ }
27
+ frame = (frame + 1) % frames.length;
28
+ const glyph = frames[frame] ?? frames[0] ?? "";
29
+ output.write(`\r\x1B[2K${input.styleFrame ? input.styleFrame(glyph) : glyph} ${label}`);
30
+ };
31
+ const clearLine = () => {
32
+ if (isTty)
33
+ output.write("\r\x1B[2K");
34
+ };
35
+ render();
36
+ const timer = isTty ? setInterval(render, input.intervalMs ?? 16) : null;
37
+ return {
38
+ setLabel(next) {
39
+ label = next;
40
+ render();
41
+ },
42
+ pause() {
43
+ paused = true;
44
+ clearLine();
45
+ },
46
+ resume() {
47
+ if (stopped)
48
+ return;
49
+ paused = false;
50
+ render();
51
+ },
52
+ stop(finalLine) {
53
+ if (stopped)
54
+ return;
55
+ stopped = true;
56
+ if (timer)
57
+ clearInterval(timer);
58
+ clearLine();
59
+ if (finalLine)
60
+ output.write(`${finalLine}
61
+ `);
62
+ }
63
+ };
64
+ }
65
+
66
+ // packages/cli/src/runner.ts
67
+ import { EventBus } from "@rig/runtime/control-plane/runtime/events";
68
+ import { CliError as RuntimeCliError } from "@rig/runtime/control-plane/errors";
69
+ import { evaluate, loadPolicy, resolveAction } from "@rig/runtime/control-plane/runtime/guard";
70
+ import { buildBinary } from "@rig/runtime/control-plane/runtime/isolation";
71
+
72
+ // packages/cli/src/commands/_server-client.ts
73
+ import { ensureLocalRigServerConnection } from "@rig/runtime/local-server";
74
+ var scopedGitHubBearerTokens = new Map;
75
+ var serverPhaseListener = null;
76
+ function setServerPhaseListener(listener) {
77
+ const previous = serverPhaseListener;
78
+ serverPhaseListener = listener;
79
+ return previous;
80
+ }
81
+ var serverReachabilityCache = new Map;
82
+ var RESUMABLE_RUN_STATUSES = new Set([
83
+ "created",
84
+ "preparing",
85
+ "running",
86
+ "validating",
87
+ "reviewing",
88
+ "stopped",
89
+ "failed",
90
+ "needs-attention",
91
+ "needs_attention"
92
+ ]);
93
+
94
+ // packages/cli/src/app/theme.ts
95
+ var RIG_PALETTE = {
96
+ ink: "#f2f3f6",
97
+ ink2: "#aeb0ba",
98
+ ink3: "#6c6e79",
99
+ ink4: "#44464f",
100
+ accent: "#ccff4d",
101
+ accentDim: "#a9d63f",
102
+ cyan: "#56d8ff",
103
+ red: "#ff5d5d",
104
+ yellow: "#ffd24d"
105
+ };
106
+ function hexToRgb(hex) {
107
+ const value = hex.replace("#", "");
108
+ return [
109
+ Number.parseInt(value.slice(0, 2), 16),
110
+ Number.parseInt(value.slice(2, 4), 16),
111
+ Number.parseInt(value.slice(4, 6), 16)
112
+ ];
113
+ }
114
+ function fg(hex) {
115
+ const [r, g, b] = hexToRgb(hex);
116
+ return (text) => `\x1B[38;2;${r};${g};${b}m${text}\x1B[39m`;
117
+ }
118
+ var ink = fg(RIG_PALETTE.ink);
119
+ var ink2 = fg(RIG_PALETTE.ink2);
120
+ var ink3 = fg(RIG_PALETTE.ink3);
121
+ var ink4 = fg(RIG_PALETTE.ink4);
122
+ var accent = fg(RIG_PALETTE.accent);
123
+ var accentDim = fg(RIG_PALETTE.accentDim);
124
+ var cyan = fg(RIG_PALETTE.cyan);
125
+ var red = fg(RIG_PALETTE.red);
126
+ var yellow = fg(RIG_PALETTE.yellow);
127
+ function bold(text) {
128
+ return `\x1B[1m${text}\x1B[22m`;
129
+ }
130
+ var DRONE_ART = [
131
+ " .-=-. .-=-. ",
132
+ " ( !!! ) ( !!! ) ",
133
+ " '-=-'._ _.'-=-' ",
134
+ " '._ _.' ",
135
+ " '=$$$$$$$=.' ",
136
+ " =$$$$$$$$$$$= ",
137
+ " $$$@@@@@@@@@@$$$ ",
138
+ " $$$@@ @@$$$ ",
139
+ " $$@ ? @$$$ ",
140
+ " $$$@ '-' @$$$ ",
141
+ " $$$@@ @@$$$ ",
142
+ " $$$@@@@@@@@@@$$$ ",
143
+ " =$$$$$$$$$$$= ",
144
+ " '=$$$$$$$=.' ",
145
+ " _.' '._ ",
146
+ " .-=-.' '.-=-. ",
147
+ " ( !!! ) ( !!! ) ",
148
+ " '-=-' '-=-' "
149
+ ];
150
+ var EYE_FRAMES = ["@", "o", "."];
151
+ var DRONE_WIDTH = DRONE_ART[0].length;
152
+ var DRONE_HEIGHT = DRONE_ART.length;
153
+ var MICRO_BLADES = ["---", "\\\\\\", "|||", "///"];
154
+ function microDroneFrame(tick) {
155
+ const blade = MICRO_BLADES[tick % MICRO_BLADES.length];
156
+ const eye = EYE_FRAMES[Math.floor(tick / 2) % EYE_FRAMES.length];
157
+ return `(${blade})${eye}(${blade})`;
158
+ }
159
+ var MICRO_DRONE_FRAMES = Array.from({ length: 12 }, (_, index) => microDroneFrame(index));
160
+ function renderMicroDroneFrame(tick) {
161
+ const blade = MICRO_BLADES[tick % MICRO_BLADES.length];
162
+ const eye = EYE_FRAMES[Math.floor(tick / 2) % EYE_FRAMES.length];
163
+ return `${ink4("(")}${cyan(blade)}${ink4(")")}${bold(accent(eye))}${ink4("(")}${cyan(blade)}${ink4(")")}`;
164
+ }
165
+
166
+ // packages/cli/src/commands/_async-ui.ts
167
+ var DONE_SYMBOL = pc.green("\u25C7");
168
+ var FAIL_SYMBOL = pc.red("\u25A0");
169
+ var activeUpdate = null;
170
+ async function withSpinner(label, work, options = {}) {
171
+ if (options.outputMode === "json") {
172
+ return work(() => {});
173
+ }
174
+ if (activeUpdate) {
175
+ const outer = activeUpdate;
176
+ outer(label);
177
+ return work(outer);
178
+ }
179
+ const output = options.output ?? process.stderr;
180
+ const isTty = output.isTTY === true;
181
+ let lastLabel = label;
182
+ if (!isTty) {
183
+ output.write(`${label}
184
+ `);
185
+ const update2 = (next) => {
186
+ lastLabel = next;
187
+ };
188
+ activeUpdate = update2;
189
+ const previousListener2 = setServerPhaseListener(update2);
190
+ try {
191
+ return await work(update2);
192
+ } finally {
193
+ activeUpdate = null;
194
+ setServerPhaseListener(previousListener2);
195
+ }
196
+ }
197
+ const spinner = createTtySpinner({
198
+ label,
199
+ output,
200
+ frames: MICRO_DRONE_FRAMES,
201
+ styleFrame: (frame) => renderMicroDroneFrame(Math.max(0, MICRO_DRONE_FRAMES.indexOf(frame)))
202
+ });
203
+ const update = (next) => {
204
+ lastLabel = next;
205
+ spinner.setLabel(next);
206
+ };
207
+ activeUpdate = update;
208
+ const previousListener = setServerPhaseListener(update);
209
+ try {
210
+ const result = await work(update);
211
+ spinner.stop(options.doneLabel ? `${DONE_SYMBOL} ${options.doneLabel}` : undefined);
212
+ return result;
213
+ } catch (error) {
214
+ spinner.stop(`${FAIL_SYMBOL} ${lastLabel}`);
215
+ throw error;
216
+ } finally {
217
+ activeUpdate = null;
218
+ setServerPhaseListener(previousListener);
219
+ }
220
+ }
221
+ export {
222
+ withSpinner
223
+ };
@@ -0,0 +1,22 @@
1
+ import { type AuthorityRunRecord } from "@rig/runtime/control-plane/authority-files";
2
+ import type { RunStatus } from "@rig/contracts";
3
+ export declare const RIG_WORKSPACE_ID = "rig-local-workspace";
4
+ export type RuntimeAdapter = "claude-code" | "codex" | "pi";
5
+ export declare function normalizeRuntimeAdapter(value: string | undefined): RuntimeAdapter;
6
+ export declare function readLatestBeadRecord(projectRoot: string, taskId: string): Record<string, unknown> | null;
7
+ export declare function upsertAgentAuthorityRun(projectRoot: string, input: {
8
+ runId: string;
9
+ taskId: string;
10
+ createdAt: string;
11
+ runtimeAdapter?: string;
12
+ status: RunStatus;
13
+ startedAt?: string | null;
14
+ completedAt?: string | null;
15
+ worktreePath?: string | null;
16
+ artifactRoot?: string | null;
17
+ logRoot?: string | null;
18
+ sessionPath?: string | null;
19
+ sessionLogPath?: string | null;
20
+ pid?: number | null;
21
+ errorText?: string | null;
22
+ }): AuthorityRunRecord & Record<string, unknown>;
@@ -5,8 +5,7 @@ import { resolve } from "path";
5
5
  import {
6
6
  readAuthorityRun,
7
7
  readJsonlFile,
8
- resolveAuthorityRunDir,
9
- writeJsonFile
8
+ writeAuthorityRunRecord
10
9
  } from "@rig/runtime/control-plane/authority-files";
11
10
 
12
11
  // packages/cli/src/commands/_paths.ts
@@ -100,7 +99,7 @@ function upsertAgentAuthorityRun(projectRoot, input) {
100
99
  } else if ("errorText" in next) {
101
100
  delete next.errorText;
102
101
  }
103
- writeJsonFile(resolve(resolveAuthorityRunDir(projectRoot, input.runId), "run.json"), next);
102
+ writeAuthorityRunRecord(projectRoot, input.runId, next);
104
103
  return next;
105
104
  }
106
105
  export {
@@ -0,0 +1,49 @@
1
+ export type CliTaskLike = Record<string, unknown>;
2
+ export type CliRunLike = Record<string, unknown>;
3
+ export declare function printFormattedOutput(message: string, options?: {
4
+ title?: string;
5
+ }): void;
6
+ export declare function formatStatusPill(status: string): string;
7
+ export declare function formatSection(title: string, subtitle?: string): string;
8
+ export declare function formatSuccessCard(title: string, rows?: Array<[string, string | number | null | undefined]>): string;
9
+ export declare function formatNextSteps(steps: readonly string[]): string[];
10
+ export declare function formatTaskList(tasks: readonly CliTaskLike[], options?: {
11
+ raw?: boolean;
12
+ }): string;
13
+ export declare function formatTaskCard(task: CliTaskLike, options?: {
14
+ title?: string;
15
+ selected?: boolean;
16
+ }): string;
17
+ export declare function formatTaskDetails(task: CliTaskLike): string;
18
+ export declare function formatRunList(runs: readonly CliRunLike[], options?: {
19
+ source?: "local" | "server";
20
+ }): string;
21
+ export declare function formatSubmittedRun(input: {
22
+ runId: string;
23
+ task?: CliTaskLike | null;
24
+ runtimeAdapter?: string | null;
25
+ runtimeMode?: string | null;
26
+ interactionMode?: string | null;
27
+ detached?: boolean;
28
+ }): string;
29
+ export declare function formatRunCard(run: CliRunLike, options?: {
30
+ title?: string;
31
+ }): string;
32
+ export declare function formatRunStatus(summary: {
33
+ activeRuns?: CliRunLike[];
34
+ recentRuns?: CliRunLike[];
35
+ runs?: CliRunLike[];
36
+ }, options?: {
37
+ source?: "local" | "server";
38
+ }): string;
39
+ export declare function formatInboxList(kind: "approvals" | "inputs", entries: readonly Record<string, unknown>[]): string;
40
+ export declare function formatConnectionList(connections: Record<string, {
41
+ kind: string;
42
+ baseUrl?: string;
43
+ mode?: string;
44
+ }>): string;
45
+ export declare function formatConnectionStatus(selected: string, connections: Record<string, {
46
+ kind: string;
47
+ baseUrl?: string;
48
+ mode?: string;
49
+ }>): string;