@h-rig/contracts 0.0.6-alpha.17 → 0.0.6-alpha.170

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 (176) hide show
  1. package/dist/index.cjs +3373 -0
  2. package/dist/index.mjs +3332 -0
  3. package/dist/src/agent-roles.d.ts +8 -0
  4. package/dist/src/artifact.d.ts +13 -0
  5. package/dist/src/artifact.js +3 -0
  6. package/dist/src/baseSchemas.d.ts +63 -0
  7. package/dist/src/baseSchemas.js +6 -0
  8. package/dist/src/browser.d.ts +80 -0
  9. package/dist/src/browser.js +13 -0
  10. package/dist/src/capability-id.d.ts +22 -0
  11. package/dist/src/capability-id.js +8 -0
  12. package/dist/src/cli-output.d.ts +348 -0
  13. package/dist/src/cli-output.js +190 -0
  14. package/dist/src/cli-runner.d.ts +43 -0
  15. package/dist/src/cli-runner.js +13 -0
  16. package/dist/src/cockpit.d.ts +28 -0
  17. package/dist/src/cockpit.js +13 -0
  18. package/dist/src/collab-session-viewer.d.ts +36 -0
  19. package/dist/src/collab-session-viewer.js +13 -0
  20. package/dist/src/config.d.ts +551 -0
  21. package/dist/src/config.js +765 -162
  22. package/dist/src/control-plane-types.d.ts +323 -0
  23. package/dist/src/control-plane-types.js +13 -0
  24. package/dist/src/conversation.d.ts +50 -0
  25. package/dist/src/conversation.js +3 -0
  26. package/dist/src/dependency-preflight.d.ts +43 -0
  27. package/dist/src/dependency-preflight.js +13 -0
  28. package/dist/src/docs-drift.d.ts +10 -0
  29. package/dist/src/docs-drift.js +12 -0
  30. package/dist/src/doctor.d.ts +90 -0
  31. package/dist/src/doctor.js +13 -0
  32. package/dist/src/drift.d.ts +28 -0
  33. package/dist/src/drift.js +69 -0
  34. package/dist/src/editor.d.ts +25 -0
  35. package/dist/src/editor.js +3 -0
  36. package/dist/src/errors.d.ts +13 -0
  37. package/dist/src/errors.js +17 -0
  38. package/dist/src/git.d.ts +152 -0
  39. package/dist/src/git.js +3 -0
  40. package/dist/src/github.d.ts +285 -0
  41. package/dist/src/github.js +17 -0
  42. package/dist/src/graph.d.ts +360 -0
  43. package/dist/src/graph.js +137 -1
  44. package/dist/src/guard.d.ts +111 -0
  45. package/dist/src/guard.js +6 -0
  46. package/dist/src/harness-events.d.ts +8 -0
  47. package/dist/src/harness-events.js +1 -0
  48. package/dist/src/help-catalog.d.ts +41 -0
  49. package/dist/src/help-catalog.js +13 -0
  50. package/dist/src/host.d.ts +41 -0
  51. package/dist/src/host.js +13 -0
  52. package/dist/src/identity.d.ts +44 -0
  53. package/dist/src/identity.js +1 -0
  54. package/dist/src/index.d.ts +84 -0
  55. package/dist/src/index.js +2746 -3962
  56. package/dist/src/isolation.d.ts +213 -0
  57. package/dist/src/isolation.js +13 -0
  58. package/dist/src/kernel.d.ts +200 -0
  59. package/dist/src/kernel.js +261 -0
  60. package/dist/src/keybindings.d.ts +71 -0
  61. package/dist/src/keybindings.js +3 -0
  62. package/dist/src/layout.d.ts +49 -0
  63. package/dist/src/layout.js +10 -0
  64. package/dist/src/lifecycle-capabilities.d.ts +186 -0
  65. package/dist/src/lifecycle-capabilities.js +33 -0
  66. package/dist/src/managed-repos.d.ts +239 -0
  67. package/dist/src/managed-repos.js +33 -0
  68. package/dist/src/memory.d.ts +199 -0
  69. package/dist/src/memory.js +15 -0
  70. package/dist/src/model.d.ts +77 -0
  71. package/dist/src/native-toolchain.d.ts +46 -0
  72. package/dist/src/native-toolchain.js +13 -0
  73. package/dist/src/notify.d.ts +46 -0
  74. package/dist/src/notify.js +13 -0
  75. package/dist/src/orchestration.d.ts +43 -0
  76. package/dist/src/orchestration.js +28 -961
  77. package/dist/src/panel-protocol.d.ts +17 -0
  78. package/dist/src/panel-protocol.js +10 -0
  79. package/dist/src/pi-session.d.ts +113 -0
  80. package/dist/src/pi-session.js +1 -0
  81. package/dist/src/planning.d.ts +64 -0
  82. package/dist/src/planning.js +90 -0
  83. package/dist/src/plugin-hooks.d.ts +51 -0
  84. package/dist/src/plugin-hooks.js +386 -0
  85. package/dist/src/plugin.d.ts +476 -0
  86. package/dist/src/plugin.js +346 -64
  87. package/dist/src/policy.d.ts +16 -0
  88. package/dist/src/policy.js +3 -0
  89. package/dist/src/project.d.ts +71 -0
  90. package/dist/src/project.js +3 -0
  91. package/dist/src/prompt.d.ts +29 -0
  92. package/dist/src/prompt.js +13 -0
  93. package/dist/src/protocol-version.d.ts +21 -0
  94. package/dist/src/protocol-version.js +6 -0
  95. package/dist/src/provider-instructions.d.ts +41 -0
  96. package/dist/src/provider-instructions.js +13 -0
  97. package/dist/src/provider.d.ts +105 -0
  98. package/dist/src/provider.js +4 -824
  99. package/dist/src/remote.d.ts +318 -0
  100. package/dist/src/remote.js +238 -1078
  101. package/dist/src/review.d.ts +18 -0
  102. package/dist/src/review.js +3 -0
  103. package/dist/src/rollups.d.ts +41 -0
  104. package/dist/src/rollups.js +70 -0
  105. package/dist/src/run-discovery.d.ts +79 -0
  106. package/dist/src/run-discovery.js +13 -0
  107. package/dist/src/run-dispatch.d.ts +34 -0
  108. package/dist/src/run-dispatch.js +13 -0
  109. package/dist/src/run-identity.d.ts +47 -0
  110. package/dist/src/run-identity.js +13 -0
  111. package/dist/src/run-journal.d.ts +694 -0
  112. package/dist/src/run-journal.js +569 -0
  113. package/dist/src/run-read-model.d.ts +255 -0
  114. package/dist/src/run-read-model.js +13 -0
  115. package/dist/src/run-record.d.ts +45 -0
  116. package/dist/src/run-record.js +1 -0
  117. package/dist/src/run-registry-backbone.d.ts +56 -0
  118. package/dist/src/run-registry-backbone.js +13 -0
  119. package/dist/src/run-session-journal.d.ts +69 -0
  120. package/dist/src/run-session-journal.js +78 -0
  121. package/dist/src/run-status.d.ts +10 -0
  122. package/dist/src/run-status.js +27 -0
  123. package/dist/src/run-timeline.d.ts +7 -0
  124. package/dist/src/run-timeline.js +1 -0
  125. package/dist/src/runtime-task-context.d.ts +82 -0
  126. package/dist/src/runtime-task-context.js +1 -0
  127. package/dist/src/runtime.d.ts +103 -0
  128. package/dist/src/runtime.js +73 -906
  129. package/dist/src/session-asset-materializer.d.ts +35 -0
  130. package/dist/src/session-asset-materializer.js +13 -0
  131. package/dist/src/setup.d.ts +88 -0
  132. package/dist/src/setup.js +13 -0
  133. package/dist/src/stage.d.ts +245 -0
  134. package/dist/src/stage.js +169 -0
  135. package/dist/src/supervisor-journal.d.ts +204 -0
  136. package/dist/src/supervisor-journal.js +334 -0
  137. package/dist/src/task-artifacts.d.ts +33 -0
  138. package/dist/src/task-artifacts.js +13 -0
  139. package/dist/src/task-context-renderer.d.ts +29 -0
  140. package/dist/src/task-context-renderer.js +13 -0
  141. package/dist/src/task-data.d.ts +198 -0
  142. package/dist/src/task-data.js +13 -0
  143. package/dist/src/task-graph-primitives.d.ts +47 -0
  144. package/dist/src/task-graph-primitives.js +1 -0
  145. package/dist/src/task-source.d.ts +136 -0
  146. package/dist/src/task-source.js +16 -0
  147. package/dist/src/task-state-metadata.d.ts +21 -0
  148. package/dist/src/task-state-metadata.js +1 -0
  149. package/dist/src/task-state-store.d.ts +16 -0
  150. package/dist/src/task-state-store.js +13 -0
  151. package/dist/src/task-tracker-state.d.ts +106 -0
  152. package/dist/src/task-tracker-state.js +39 -0
  153. package/dist/src/terminal.d.ts +130 -0
  154. package/dist/src/terminal.js +3 -0
  155. package/dist/src/tool-materializer.d.ts +36 -0
  156. package/dist/src/tool-materializer.js +13 -0
  157. package/dist/src/tool-registry.d.ts +3 -0
  158. package/dist/src/tool-registry.js +58 -0
  159. package/dist/src/toolchain-sources.d.ts +54 -0
  160. package/dist/src/toolchain-sources.js +17 -0
  161. package/dist/src/validation.d.ts +14 -0
  162. package/dist/src/validation.js +3 -0
  163. package/dist/src/workflow-journal.d.ts +92 -0
  164. package/dist/src/workflow-journal.js +18 -0
  165. package/dist/src/workspace-config.d.ts +18 -0
  166. package/dist/src/workspace-config.js +13 -0
  167. package/dist/src/workspace.d.ts +204 -0
  168. package/dist/src/workspace.js +76 -911
  169. package/package.json +51 -4
  170. package/dist/src/engine.js +0 -2278
  171. package/dist/src/providerRuntime.js +0 -1630
  172. package/dist/src/rig.js +0 -2374
  173. package/dist/src/server.js +0 -1053
  174. package/dist/src/serviceFabric.js +0 -1066
  175. package/dist/src/ws.js +0 -2968
  176. /package/dist/src/{ipc.js → agent-roles.js} +0 -0
@@ -0,0 +1,255 @@
1
+ /**
2
+ * Run read-model capability vocabulary.
3
+ *
4
+ * This file defines the contracts-only service seam that run-owner plugins can
5
+ * provide to CLI, cockpit, supervisor, and doctor surfaces. The OMP session is
6
+ * the journal source of truth: read-model implementations must key projections
7
+ * by the canonical run id/session id (`runId === sessionId`). Dispatch handles,
8
+ * worktree paths, and relay metadata are metadata only, never identity keys.
9
+ *
10
+ * Pure: types + one branded id, no folding, defaults, coercion, IO, or provider
11
+ * implementation.
12
+ */
13
+ import type { CapabilityId } from "./capability-id";
14
+ import type { RigStatsData } from "./cli-output";
15
+ import type { RunDiscoveryFilter } from "./run-discovery";
16
+ import type { RunJournalProjection } from "./run-journal";
17
+ import type { RunRegistryRunProjection } from "./run-registry-backbone";
18
+ import type { RigRunTimelineEntry } from "./run-timeline";
19
+ import type { RunRecord, UnifiedInboxRequest } from "./run-record";
20
+ import type { RunInboxResolutionInit, RunSessionCustomEntry } from "./run-session-journal";
21
+ import type { TaskRecord } from "./task-source";
22
+ export type RunReadModelSource = RunRecord["source"] | "all";
23
+ export type RunReadModelRunSelector = {
24
+ /** Exact run id/session id, task id, or unique run-id prefix chosen by the caller. */
25
+ readonly id: string;
26
+ /** Prefer interpreting `id` as this kind when the caller already knows it. */
27
+ readonly kind?: "run-id" | "task-id" | "run-id-prefix" | "any";
28
+ };
29
+ export interface RunReadModelListInput {
30
+ readonly projectRoot: string;
31
+ readonly taskId?: string | null;
32
+ readonly source?: RunReadModelSource;
33
+ readonly includeInactive?: boolean;
34
+ readonly discoveryFilter?: RunDiscoveryFilter;
35
+ }
36
+ export interface RunReadModelGetInput {
37
+ readonly projectRoot: string;
38
+ readonly selector: RunReadModelRunSelector;
39
+ readonly discoveryFilter?: RunDiscoveryFilter;
40
+ }
41
+ export interface RunReadModelProjectionInput {
42
+ readonly projectRoot: string;
43
+ /** Canonical run id/session id. */
44
+ readonly runId: string;
45
+ readonly sessionPath?: string | null;
46
+ readonly discoveryFilter?: RunDiscoveryFilter;
47
+ }
48
+ export interface RunReadModelRegistryProjectionInput {
49
+ /** Canonical run id/session id. */
50
+ readonly runId: string;
51
+ readonly folded: RunJournalProjection;
52
+ /** Raw run-session custom entries; providers own timeline extraction from them. */
53
+ readonly entries: readonly RunSessionCustomEntry[];
54
+ readonly title: string;
55
+ readonly joinLink?: string | null;
56
+ readonly webLink?: string | null;
57
+ readonly relayUrl?: string | null;
58
+ readonly sessionPath?: string | null;
59
+ readonly cwd?: string | null;
60
+ readonly collabCwd?: string | null;
61
+ readonly dispatchHandle?: string | null;
62
+ readonly timelineLimit?: number;
63
+ /** Optional caller-supplied timeline for compatibility; providers should prefer entries. */
64
+ readonly timeline?: readonly RigRunTimelineEntry[];
65
+ }
66
+ export interface RunReadModelDetailsInput extends RunReadModelGetInput {
67
+ readonly includeLogs?: boolean;
68
+ readonly includeSourceTask?: boolean;
69
+ }
70
+ export interface RunReadModelInboxInput {
71
+ readonly projectRoot: string;
72
+ readonly kind?: "approval" | "input" | "all";
73
+ readonly runId?: string | null;
74
+ readonly taskId?: string | null;
75
+ readonly discoveryFilter?: RunDiscoveryFilter;
76
+ }
77
+ export interface RunReadModelStatsInput {
78
+ readonly projectRoot: string;
79
+ /** ISO timestamp lower bound, or null for all-time. */
80
+ readonly since?: string | null;
81
+ /** Optional caller-supplied records, used when the surface already listed runs. */
82
+ readonly runs?: readonly RunRecord[];
83
+ readonly discoveryFilter?: RunDiscoveryFilter;
84
+ }
85
+ export interface RunReadModelInspectRowsInput {
86
+ readonly projectRoot: string;
87
+ readonly runs?: readonly RunRecord[];
88
+ readonly pendingInbox?: number | null;
89
+ readonly discoveryFilter?: RunDiscoveryFilter;
90
+ }
91
+ export interface RunReadModelControlTargetInput {
92
+ readonly projectRoot: string;
93
+ /** Canonical run id/session id. */
94
+ readonly runId: string;
95
+ readonly taskId?: string | null;
96
+ readonly purpose?: "attach" | "steer" | "stop" | "pause" | "resume" | "resolve-inbox";
97
+ readonly discoveryFilter?: RunDiscoveryFilter;
98
+ }
99
+ export type RunReadModelControl = {
100
+ readonly kind: "steer";
101
+ readonly message: string;
102
+ } | {
103
+ readonly kind: "stop";
104
+ readonly reason: string;
105
+ } | {
106
+ readonly kind: "pause";
107
+ } | {
108
+ readonly kind: "resume";
109
+ };
110
+ export interface RunReadModelControlInput {
111
+ readonly projectRoot: string;
112
+ /** Canonical run id/session id. */
113
+ readonly runId: string;
114
+ readonly control: RunReadModelControl;
115
+ readonly requestedBy?: string | null;
116
+ readonly discoveryFilter?: RunDiscoveryFilter;
117
+ }
118
+ export interface RunReadModelControlResult {
119
+ readonly runId: string;
120
+ readonly kind: RunReadModelControl["kind"];
121
+ readonly status: "delivered" | "not-found" | "not-live" | "unsupported";
122
+ readonly delivered: boolean;
123
+ readonly detail?: string | null;
124
+ }
125
+ export interface RunReadModelInboxResolutionInput {
126
+ readonly projectRoot: string;
127
+ /** Canonical run id/session id. */
128
+ readonly runId: string;
129
+ readonly resolution: RunInboxResolutionInit;
130
+ readonly requestedBy?: string | null;
131
+ readonly discoveryFilter?: RunDiscoveryFilter;
132
+ }
133
+ export interface RunReadModelRemoveRegistryEntryInput {
134
+ readonly projectRoot: string;
135
+ /** Canonical run id/session id. */
136
+ readonly runId: string;
137
+ }
138
+ export interface RunReadModelRemoveRegistryEntryResult {
139
+ /** Canonical run id/session id. */
140
+ readonly runId: string;
141
+ readonly removed: boolean;
142
+ }
143
+ export interface RunReadModelInboxCounts {
144
+ readonly approvals: number;
145
+ readonly inputs: number;
146
+ readonly total: number;
147
+ }
148
+ export interface RunReadModelInboxRecord {
149
+ readonly runId: string;
150
+ readonly taskId: string | null;
151
+ readonly requestId: string;
152
+ readonly kind: "approval" | "input";
153
+ readonly status: "pending";
154
+ readonly title: string;
155
+ readonly body?: string | null;
156
+ readonly prompt: string;
157
+ readonly requestedAt: string | null;
158
+ readonly payload: unknown;
159
+ readonly source: "run";
160
+ }
161
+ export interface RunReadModelInboxResolutionResult {
162
+ readonly runId: string;
163
+ readonly requestId: string;
164
+ readonly kind: "approval" | "input";
165
+ readonly status: "resolved" | "not-found" | "not-live" | "unsupported";
166
+ readonly delivered: boolean;
167
+ readonly detail?: string | null;
168
+ }
169
+ export interface RunReadModelControlTarget {
170
+ /** Canonical run id/session id. */
171
+ readonly runId: string;
172
+ readonly taskId: string | null;
173
+ readonly sessionId: string | null;
174
+ readonly sessionPath: string | null;
175
+ readonly joinLink: string | null;
176
+ readonly webLink: string | null;
177
+ readonly relayUrl: string | null;
178
+ readonly collabCwd: string | null;
179
+ readonly live: boolean;
180
+ readonly stale: boolean;
181
+ readonly canDeliver: boolean;
182
+ readonly reason?: string | null;
183
+ }
184
+ export type RunReadModelStats = RigStatsData;
185
+ export type RunReadModelStatusPhase = "starting" | "active" | "waiting" | "paused" | "needs-attention" | "completed" | "failed" | "stopped" | "unknown";
186
+ export type RunReadModelStatusRole = "success" | "action-yellow" | "active-cyan" | "failure" | "muted" | "neutral";
187
+ export interface RunReadModelRunClassification {
188
+ readonly status: string;
189
+ readonly phase: RunReadModelStatusPhase;
190
+ readonly role: RunReadModelStatusRole;
191
+ readonly rank: number;
192
+ readonly isActive: boolean;
193
+ readonly isTerminal: boolean;
194
+ readonly isNeedsAttention: boolean;
195
+ }
196
+ export interface RunReadModelInspectRow {
197
+ readonly id: string;
198
+ readonly label: string;
199
+ readonly currentValue: string;
200
+ readonly values?: readonly string[];
201
+ readonly heading?: boolean;
202
+ readonly description?: string;
203
+ }
204
+ export interface RunReadModelFailureSummary {
205
+ readonly kind: string;
206
+ readonly summary: string;
207
+ readonly detail?: string | null;
208
+ readonly retryable?: boolean | null;
209
+ }
210
+ export interface RunReadModelDetails {
211
+ readonly run: RunRecord;
212
+ readonly projection: RunJournalProjection;
213
+ readonly pendingInbox: readonly UnifiedInboxRequest[];
214
+ readonly inboxCounts: RunReadModelInboxCounts;
215
+ readonly sourceTask?: TaskRecord | null;
216
+ readonly sessionEntries?: readonly RunSessionCustomEntry[];
217
+ readonly failures: readonly RunReadModelFailureSummary[];
218
+ readonly logs: readonly string[];
219
+ }
220
+ export interface RunReadModelInspectResult {
221
+ readonly details: RunReadModelDetails;
222
+ readonly classification: RunReadModelRunClassification;
223
+ readonly rows: readonly RunReadModelInspectRow[];
224
+ }
225
+ /**
226
+ * Multi-method run read-model service capability.
227
+ *
228
+ * Providers own the executable discovery/folding/classification/control-target
229
+ * lookup. Consumers depend only on this contracts vocabulary and resolve the
230
+ * provider through the typed capability seam.
231
+ */
232
+ export interface RunReadModelService {
233
+ readonly listRuns: (input: RunReadModelListInput) => Promise<readonly RunRecord[]>;
234
+ readonly getRun: (input: RunReadModelGetInput) => Promise<RunRecord | null>;
235
+ readonly getRunProjection: (input: RunReadModelProjectionInput) => Promise<RunJournalProjection | null>;
236
+ readonly buildRegistryProjection: (input: RunReadModelRegistryProjectionInput) => RunRegistryRunProjection;
237
+ readonly getRunDetails: (input: RunReadModelDetailsInput) => Promise<RunReadModelDetails | null>;
238
+ readonly inspectRun: (input: RunReadModelDetailsInput) => Promise<RunReadModelInspectResult | null>;
239
+ readonly listInboxRecords: (input: RunReadModelInboxInput) => Promise<readonly RunReadModelInboxRecord[]>;
240
+ readonly getInboxCounts: (input: RunReadModelInboxInput) => Promise<RunReadModelInboxCounts>;
241
+ readonly resolveInboxRequest: (input: RunReadModelInboxResolutionInput) => Promise<RunReadModelInboxResolutionResult>;
242
+ readonly getStats: (input: RunReadModelStatsInput) => Promise<RunReadModelStats>;
243
+ readonly getInspectRows: (input: RunReadModelInspectRowsInput) => Promise<readonly RunReadModelInspectRow[]>;
244
+ readonly deliverControl: (input: RunReadModelControlInput) => Promise<RunReadModelControlResult>;
245
+ readonly classifyRun: (run: RunRecord) => RunReadModelRunClassification;
246
+ readonly resolveControlTarget: (input: RunReadModelControlTargetInput) => Promise<RunReadModelControlTarget | null>;
247
+ readonly removeRunRegistryEntry: (input: RunReadModelRemoveRegistryEntryInput) => Promise<RunReadModelRemoveRegistryEntryResult>;
248
+ }
249
+ /** Stable id string for the run read-model service capability. */
250
+ export declare const RUN_READ_MODEL_CAPABILITY_ID = "rig.runs.read-model";
251
+ /**
252
+ * Branded run read-model capability id. `defineCapability(RUN_READ_MODEL)`
253
+ * (provider and consumers independently) resolves to a `RunReadModelService`.
254
+ */
255
+ export declare const RUN_READ_MODEL: CapabilityId<RunReadModelService>;
@@ -0,0 +1,13 @@
1
+ // @bun
2
+ // packages/contracts/src/capability-id.ts
3
+ function makeCapabilityId(id) {
4
+ return id;
5
+ }
6
+
7
+ // packages/contracts/src/run-read-model.ts
8
+ var RUN_READ_MODEL_CAPABILITY_ID = "rig.runs.read-model";
9
+ var RUN_READ_MODEL = makeCapabilityId(RUN_READ_MODEL_CAPABILITY_ID);
10
+ export {
11
+ RUN_READ_MODEL_CAPABILITY_ID,
12
+ RUN_READ_MODEL
13
+ };
@@ -0,0 +1,45 @@
1
+ import type { RunJournalProjection } from "./run-journal";
2
+ import type { RigRunTimelineEntry } from "./run-timeline";
3
+ export type UnifiedInboxRequest = {
4
+ readonly requestId: string;
5
+ readonly kind: "approval" | "input";
6
+ readonly title: string;
7
+ readonly body?: string | null;
8
+ readonly options?: readonly string[];
9
+ readonly requestedAt: string | null;
10
+ readonly source: "run";
11
+ };
12
+ /** Unified operator-facing run record shared by CLI, cockpit, relay, and client projection logic. */
13
+ export interface RunRecord {
14
+ readonly runId: string;
15
+ readonly taskId: string | null;
16
+ readonly title: string;
17
+ /** RunStatus from the folded journal, or a liveness-derived fallback. */
18
+ readonly status: string;
19
+ readonly source: "local" | "remote";
20
+ /** True when the run is currently discoverable (registry heartbeat or local host). */
21
+ readonly live: boolean;
22
+ readonly stale: boolean;
23
+ readonly startedAt: string | null;
24
+ readonly updatedAt: string | null;
25
+ readonly completedAt: string | null;
26
+ readonly joinLink: string | null;
27
+ readonly webLink: string | null;
28
+ readonly relayUrl: string | null;
29
+ readonly sessionPath: string | null;
30
+ readonly prUrl: string | null;
31
+ readonly worktreePath: string | null;
32
+ readonly pendingApprovals: number;
33
+ readonly pendingInputs: number;
34
+ readonly steeringCount: number;
35
+ readonly stallCount: number;
36
+ readonly errorSummary?: string | null;
37
+ /** Timeline entries folded from the same OMP session custom entries as the journal. */
38
+ readonly timeline: RigRunTimelineEntry[];
39
+ /** Pending rig.run.* approvals/inputs only; rig.workflow.inbox.* is intentionally dead. */
40
+ readonly inbox: UnifiedInboxRequest[];
41
+ /** Live collab cwd when present in registry/discovery. */
42
+ readonly collabCwd: string | null;
43
+ /** The full folded journal (empty projection when no journal was readable). */
44
+ readonly projection: RunJournalProjection;
45
+ }
@@ -0,0 +1 @@
1
+ // @bun
@@ -0,0 +1,56 @@
1
+ import type { CapabilityId } from "./capability-id";
2
+ import type { RigWorkflowOwner } from "./workflow-journal";
3
+ import type { RunRecord } from "./run-record";
4
+ import type { RunStatus } from "./runtime";
5
+ /**
6
+ * cap:run-registry-backbone — transport-owned relay/registry room publication.
7
+ *
8
+ * The transport plugin owns the concrete @rig/relay-registry client. Run workers
9
+ * publish journal-derived projections through this structural seam so the worker
10
+ * lifecycle engine does not import the relay-registry implementation package.
11
+ */
12
+ export declare const RUN_REGISTRY_BACKBONE_CAPABILITY_ID = "transport.run-registry-backbone";
13
+ export type RunRegistryOwner = RigWorkflowOwner;
14
+ export type RunRegistryStatus = RunStatus | "starting" | "waiting-input";
15
+ export type RunRegistryRunProjection = Pick<RunRecord, "runId" | "taskId" | "title" | "status" | "source" | "startedAt" | "updatedAt" | "completedAt" | "joinLink" | "webLink" | "relayUrl" | "sessionPath" | "prUrl" | "worktreePath" | "pendingApprovals" | "pendingInputs" | "steeringCount" | "stallCount" | "errorSummary" | "timeline" | "collabCwd"> & {
16
+ readonly cwd?: string | null;
17
+ readonly dispatchHandle?: string | null;
18
+ };
19
+ export interface RunRegistryRegisterRoomInput {
20
+ readonly roomId: string;
21
+ readonly owner: RunRegistryOwner;
22
+ readonly repo: string;
23
+ readonly title: string;
24
+ readonly status: RunRegistryStatus;
25
+ readonly joinLink: string;
26
+ readonly webLink: string;
27
+ readonly relayUrl: string;
28
+ readonly startedAt: string;
29
+ readonly cwd?: string;
30
+ readonly sessionPath?: string;
31
+ readonly pid?: number;
32
+ readonly projection?: RunRegistryRunProjection;
33
+ }
34
+ export interface RunRegistryClient {
35
+ readonly registerRoom: (room: RunRegistryRegisterRoomInput) => Promise<unknown>;
36
+ readonly heartbeatRoom: (roomId: string, status: RunRegistryStatus, projection?: RunRegistryRunProjection) => Promise<unknown>;
37
+ readonly removeRoom: (roomId: string) => Promise<boolean>;
38
+ }
39
+ export interface RunWorkerProjectionConnection {
40
+ readonly ready: Promise<void>;
41
+ push(projection: RunRegistryRunProjection): void;
42
+ close(): void;
43
+ }
44
+ export interface RunRegistryBackboneService {
45
+ readonly createRegistryClient: (options: {
46
+ readonly baseUrl: string;
47
+ readonly namespaceKey: string;
48
+ }) => RunRegistryClient;
49
+ readonly connectWorkerProjection: (options: {
50
+ readonly baseUrl: string;
51
+ readonly namespaceKey: string;
52
+ readonly runId: string;
53
+ }) => RunWorkerProjectionConnection;
54
+ readonly coerceRegistryStatus: (value: unknown, fallback: RunRegistryStatus) => RunRegistryStatus;
55
+ }
56
+ export declare const RUN_REGISTRY_BACKBONE: CapabilityId<RunRegistryBackboneService>;
@@ -0,0 +1,13 @@
1
+ // @bun
2
+ // packages/contracts/src/capability-id.ts
3
+ function makeCapabilityId(id) {
4
+ return id;
5
+ }
6
+
7
+ // packages/contracts/src/run-registry-backbone.ts
8
+ var RUN_REGISTRY_BACKBONE_CAPABILITY_ID = "transport.run-registry-backbone";
9
+ var RUN_REGISTRY_BACKBONE = makeCapabilityId(RUN_REGISTRY_BACKBONE_CAPABILITY_ID);
10
+ export {
11
+ RUN_REGISTRY_BACKBONE_CAPABILITY_ID,
12
+ RUN_REGISTRY_BACKBONE
13
+ };
@@ -0,0 +1,69 @@
1
+ import { type RunJournalEvent } from "./run-journal";
2
+ type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
3
+ export type RunJournalEventInit = DistributiveOmit<RunJournalEvent, "v" | "seq" | "at" | "runId">;
4
+ export declare const RIG_RUN_STATUS_CHANGED = "rig.run.status-changed";
5
+ export declare const RIG_RUN_RECORD_PATCH = "rig.run.record-patch";
6
+ export declare const RIG_RUN_TIMELINE_ENTRY = "rig.run.timeline-entry";
7
+ export declare const RIG_RUN_LOG_ENTRY = "rig.run.log-entry";
8
+ export declare const RIG_RUN_APPROVAL_REQUESTED = "rig.run.approval-requested";
9
+ export declare const RIG_RUN_APPROVAL_RESOLVED = "rig.run.approval-resolved";
10
+ export declare const RIG_RUN_INPUT_REQUESTED = "rig.run.input-requested";
11
+ export declare const RIG_RUN_INPUT_RESOLVED = "rig.run.input-resolved";
12
+ export declare const RIG_RUN_STEERING = "rig.run.steering";
13
+ export declare const RIG_RUN_ADOPTED = "rig.run.adopted";
14
+ export declare const RIG_RUN_STALL_DETECTED = "rig.run.stall-detected";
15
+ export declare const RIG_RUN_CLOSEOUT_PHASE = "rig.run.closeout-phase";
16
+ export declare const RIG_RUN_PIPELINE_RESOLVED = "rig.run.pipeline-resolved";
17
+ export declare const RIG_RUN_STAGE_OUTCOME = "rig.run.stage-outcome";
18
+ export declare const RIG_STOP_SENTINEL = "<<RIG_STOP";
19
+ export declare const RIG_STOP_SENTINEL_END = ">>";
20
+ export declare const RIG_PAUSE_SENTINEL = "<<RIG_PAUSE";
21
+ export declare const RIG_RESUME_SENTINEL = "<<RIG_RESUME";
22
+ export declare const RIG_CONTROL_SENTINEL_END = ">>";
23
+ export type RunInboxResolutionSentinel = {
24
+ kind: "approval";
25
+ requestId: string;
26
+ decision: "approve" | "reject";
27
+ note?: string | null;
28
+ requestedBy: string | null;
29
+ } | {
30
+ kind: "input";
31
+ requestId: string;
32
+ answers: Record<string, string>;
33
+ requestedBy: string | null;
34
+ };
35
+ export declare const RIG_INBOX_RESOLUTION_SENTINEL = "<<RIG_INBOX_RESOLUTION";
36
+ export type RunInboxResolutionInit = {
37
+ kind: "approval";
38
+ requestId: string;
39
+ decision: "approve" | "reject";
40
+ note?: string | null;
41
+ } | {
42
+ kind: "input";
43
+ requestId: string;
44
+ answers: Record<string, string>;
45
+ };
46
+ export declare const CUSTOM_TYPE_FOR: {
47
+ readonly "status-changed": "rig.run.status-changed";
48
+ readonly "record-patch": "rig.run.record-patch";
49
+ readonly "timeline-entry": "rig.run.timeline-entry";
50
+ readonly "log-entry": "rig.run.log-entry";
51
+ readonly "approval-requested": "rig.run.approval-requested";
52
+ readonly "approval-resolved": "rig.run.approval-resolved";
53
+ readonly "input-requested": "rig.run.input-requested";
54
+ readonly "input-resolved": "rig.run.input-resolved";
55
+ readonly steering: "rig.run.steering";
56
+ readonly adopted: "rig.run.adopted";
57
+ readonly "stall-detected": "rig.run.stall-detected";
58
+ readonly "closeout-phase": "rig.run.closeout-phase";
59
+ readonly "pipeline-resolved": "rig.run.pipeline-resolved";
60
+ readonly "stage-outcome": "rig.run.stage-outcome";
61
+ };
62
+ export type RunSessionCustomType = (typeof CUSTOM_TYPE_FOR)[RunJournalEvent["type"]];
63
+ export declare const TYPE_FOR_CUSTOM: Readonly<Record<RunSessionCustomType, RunJournalEvent["type"]>>;
64
+ export type RunSessionCustomEntry = {
65
+ type: string;
66
+ customType?: string;
67
+ data?: unknown;
68
+ };
69
+ export {};
@@ -0,0 +1,78 @@
1
+ // @bun
2
+ // packages/contracts/src/run-session-journal.ts
3
+ var RIG_RUN_STATUS_CHANGED = "rig.run.status-changed";
4
+ var RIG_RUN_RECORD_PATCH = "rig.run.record-patch";
5
+ var RIG_RUN_TIMELINE_ENTRY = "rig.run.timeline-entry";
6
+ var RIG_RUN_LOG_ENTRY = "rig.run.log-entry";
7
+ var RIG_RUN_APPROVAL_REQUESTED = "rig.run.approval-requested";
8
+ var RIG_RUN_APPROVAL_RESOLVED = "rig.run.approval-resolved";
9
+ var RIG_RUN_INPUT_REQUESTED = "rig.run.input-requested";
10
+ var RIG_RUN_INPUT_RESOLVED = "rig.run.input-resolved";
11
+ var RIG_RUN_STEERING = "rig.run.steering";
12
+ var RIG_RUN_ADOPTED = "rig.run.adopted";
13
+ var RIG_RUN_STALL_DETECTED = "rig.run.stall-detected";
14
+ var RIG_RUN_CLOSEOUT_PHASE = "rig.run.closeout-phase";
15
+ var RIG_RUN_PIPELINE_RESOLVED = "rig.run.pipeline-resolved";
16
+ var RIG_RUN_STAGE_OUTCOME = "rig.run.stage-outcome";
17
+ var RIG_STOP_SENTINEL = "<<RIG_STOP";
18
+ var RIG_STOP_SENTINEL_END = ">>";
19
+ var RIG_PAUSE_SENTINEL = "<<RIG_PAUSE";
20
+ var RIG_RESUME_SENTINEL = "<<RIG_RESUME";
21
+ var RIG_CONTROL_SENTINEL_END = ">>";
22
+ var RIG_INBOX_RESOLUTION_SENTINEL = "<<RIG_INBOX_RESOLUTION";
23
+ var CUSTOM_TYPE_FOR = {
24
+ "status-changed": RIG_RUN_STATUS_CHANGED,
25
+ "record-patch": RIG_RUN_RECORD_PATCH,
26
+ "timeline-entry": RIG_RUN_TIMELINE_ENTRY,
27
+ "log-entry": RIG_RUN_LOG_ENTRY,
28
+ "approval-requested": RIG_RUN_APPROVAL_REQUESTED,
29
+ "approval-resolved": RIG_RUN_APPROVAL_RESOLVED,
30
+ "input-requested": RIG_RUN_INPUT_REQUESTED,
31
+ "input-resolved": RIG_RUN_INPUT_RESOLVED,
32
+ steering: RIG_RUN_STEERING,
33
+ adopted: RIG_RUN_ADOPTED,
34
+ "stall-detected": RIG_RUN_STALL_DETECTED,
35
+ "closeout-phase": RIG_RUN_CLOSEOUT_PHASE,
36
+ "pipeline-resolved": RIG_RUN_PIPELINE_RESOLVED,
37
+ "stage-outcome": RIG_RUN_STAGE_OUTCOME
38
+ };
39
+ var TYPE_FOR_CUSTOM = {
40
+ [RIG_RUN_STATUS_CHANGED]: "status-changed",
41
+ [RIG_RUN_RECORD_PATCH]: "record-patch",
42
+ [RIG_RUN_TIMELINE_ENTRY]: "timeline-entry",
43
+ [RIG_RUN_LOG_ENTRY]: "log-entry",
44
+ [RIG_RUN_APPROVAL_REQUESTED]: "approval-requested",
45
+ [RIG_RUN_APPROVAL_RESOLVED]: "approval-resolved",
46
+ [RIG_RUN_INPUT_REQUESTED]: "input-requested",
47
+ [RIG_RUN_INPUT_RESOLVED]: "input-resolved",
48
+ [RIG_RUN_STEERING]: "steering",
49
+ [RIG_RUN_ADOPTED]: "adopted",
50
+ [RIG_RUN_STALL_DETECTED]: "stall-detected",
51
+ [RIG_RUN_CLOSEOUT_PHASE]: "closeout-phase",
52
+ [RIG_RUN_PIPELINE_RESOLVED]: "pipeline-resolved",
53
+ [RIG_RUN_STAGE_OUTCOME]: "stage-outcome"
54
+ };
55
+ export {
56
+ TYPE_FOR_CUSTOM,
57
+ RIG_STOP_SENTINEL_END,
58
+ RIG_STOP_SENTINEL,
59
+ RIG_RUN_TIMELINE_ENTRY,
60
+ RIG_RUN_STEERING,
61
+ RIG_RUN_STATUS_CHANGED,
62
+ RIG_RUN_STALL_DETECTED,
63
+ RIG_RUN_STAGE_OUTCOME,
64
+ RIG_RUN_RECORD_PATCH,
65
+ RIG_RUN_PIPELINE_RESOLVED,
66
+ RIG_RUN_LOG_ENTRY,
67
+ RIG_RUN_INPUT_RESOLVED,
68
+ RIG_RUN_INPUT_REQUESTED,
69
+ RIG_RUN_CLOSEOUT_PHASE,
70
+ RIG_RUN_APPROVAL_RESOLVED,
71
+ RIG_RUN_APPROVAL_REQUESTED,
72
+ RIG_RUN_ADOPTED,
73
+ RIG_RESUME_SENTINEL,
74
+ RIG_PAUSE_SENTINEL,
75
+ RIG_INBOX_RESOLUTION_SENTINEL,
76
+ RIG_CONTROL_SENTINEL_END,
77
+ CUSTOM_TYPE_FOR
78
+ };
@@ -0,0 +1,10 @@
1
+ /** Operator-facing active-run classification.
2
+ *
3
+ * The canonical run-journal vocabulary intentionally keeps `needs-attention` as
4
+ * non-terminal so resume/steer/closeout state machines can still act on it.
5
+ * OpenTUI/task projections need a narrower meaning: only runs that are actively
6
+ * occupying a task slot should render as the task's active run. Legacy/closeout
7
+ * statuses from older authority files are treated conservatively as inactive so
8
+ * merged/closed runs do not pin task rows forever.
9
+ */
10
+ export declare const OPERATOR_INACTIVE_RUN_STATUSES: ReadonlySet<string>;
@@ -0,0 +1,27 @@
1
+ // @bun
2
+ // packages/contracts/src/run-status.ts
3
+ var OPERATOR_INACTIVE_RUN_STATUSES = new Set([
4
+ "completed",
5
+ "complete",
6
+ "done",
7
+ "success",
8
+ "succeeded",
9
+ "passed",
10
+ "failed",
11
+ "failure",
12
+ "error",
13
+ "errored",
14
+ "stopped",
15
+ "cancelled",
16
+ "canceled",
17
+ "aborted",
18
+ "abort",
19
+ "merged",
20
+ "closed",
21
+ "skipped",
22
+ "needs-attention",
23
+ "needs_attention"
24
+ ]);
25
+ export {
26
+ OPERATOR_INACTIVE_RUN_STATUSES
27
+ };
@@ -0,0 +1,7 @@
1
+ export type RigRunTimelineEntry = {
2
+ at: string | null;
3
+ type: string;
4
+ stage?: string | null;
5
+ status?: string | null;
6
+ detail?: string | null;
7
+ };
@@ -0,0 +1 @@
1
+ // @bun
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Pure runtime-task-context data shapes.
3
+ *
4
+ * These are behaviour-free data types describing the per-task runtime context
5
+ * the substrate materializes and threads to agents and capabilities. They carry
6
+ * no logic and import nothing but the sibling `RuntimeBrowserContext` contract,
7
+ * so they belong in the neutral contracts layer (exactly like `memory.ts` /
8
+ * `lifecycle-capabilities.ts`).
9
+ *
10
+ * The fs-backed loaders/serializers that PRODUCE and VALIDATE these shapes stay
11
+ * in `@rig/runtime/control-plane/runtime/context.ts`, which re-exports these
12
+ * types for back-compat so existing `import … from ".../runtime/context"` sites
13
+ * are unaffected.
14
+ */
15
+ import type { RuntimeBrowserContext } from "./browser";
16
+ /** Retrieval weighting for shared-memory recall; pure config data. */
17
+ export type RuntimeMemoryRetrievalConfig = {
18
+ topK: number;
19
+ lexicalWeight: number;
20
+ vectorWeight: number;
21
+ recencyWeight: number;
22
+ confidenceWeight: number;
23
+ };
24
+ /** The materialized shared-memory context handed to a runtime task. */
25
+ export type RuntimeMemoryContext = {
26
+ canonicalPath: string;
27
+ canonicalRef: string;
28
+ canonicalBaseOid?: string;
29
+ hydratedPath: string;
30
+ createdFresh: boolean;
31
+ retrieval: RuntimeMemoryRetrievalConfig;
32
+ };
33
+ /** The source-task contract fields a runtime task carries through. */
34
+ export type RuntimeSourceTaskContract = {
35
+ id: string;
36
+ title?: string;
37
+ description?: string;
38
+ body?: string;
39
+ acceptanceCriteria?: string;
40
+ acceptance_criteria?: string;
41
+ sourceIssueId?: string;
42
+ status?: string;
43
+ issueType?: string;
44
+ role?: string;
45
+ externalRef?: string;
46
+ scope?: string[];
47
+ validation?: string[];
48
+ validators?: string[];
49
+ labels?: string[];
50
+ };
51
+ /** The fully-resolved per-task runtime context. */
52
+ export type RuntimeTaskContext = {
53
+ runtimeId: string;
54
+ taskId: string;
55
+ role: string;
56
+ scopes: string[];
57
+ validation: string[];
58
+ sourceTask?: RuntimeSourceTaskContract;
59
+ browser?: RuntimeBrowserContext;
60
+ workspaceDir: string;
61
+ artifactRoot?: string;
62
+ hostProjectRoot?: string;
63
+ monorepoMainRoot?: string;
64
+ monorepoBaseRef?: string;
65
+ monorepoBaseCommit?: string;
66
+ initialHeadCommits?: {
67
+ project?: string;
68
+ monorepo?: string;
69
+ };
70
+ initialDirtyFiles?: {
71
+ project?: string[];
72
+ monorepo?: string[];
73
+ };
74
+ stateDir: string;
75
+ logsDir: string;
76
+ sessionDir: string;
77
+ sessionFile: string;
78
+ policyFile: string;
79
+ binDir: string;
80
+ createdAt: string;
81
+ memory?: RuntimeMemoryContext;
82
+ };
@@ -0,0 +1 @@
1
+ // @bun