@h-rig/contracts 0.0.6-alpha.18 → 0.0.6-alpha.181

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 (205) hide show
  1. package/dist/index.cjs +3442 -0
  2. package/dist/index.mjs +3401 -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/blocker-classifier.d.ts +21 -0
  9. package/dist/src/blocker-classifier.js +13 -0
  10. package/dist/src/browser.d.ts +80 -0
  11. package/dist/src/browser.js +13 -0
  12. package/dist/src/capability-id.d.ts +22 -0
  13. package/dist/src/capability-id.js +8 -0
  14. package/dist/src/cli-output.d.ts +348 -0
  15. package/dist/src/cli-output.js +190 -0
  16. package/dist/src/cli-runner.d.ts +43 -0
  17. package/dist/src/cli-runner.js +13 -0
  18. package/dist/src/cockpit.d.ts +58 -0
  19. package/dist/src/cockpit.js +13 -0
  20. package/dist/src/collab-session-viewer.d.ts +36 -0
  21. package/dist/src/collab-session-viewer.js +13 -0
  22. package/dist/src/config.d.ts +553 -0
  23. package/dist/src/config.js +767 -162
  24. package/dist/src/control-plane-types.d.ts +323 -0
  25. package/dist/src/control-plane-types.js +13 -0
  26. package/dist/src/conversation.d.ts +50 -0
  27. package/dist/src/conversation.js +3 -0
  28. package/dist/src/dependency-preflight.d.ts +43 -0
  29. package/dist/src/dependency-preflight.js +13 -0
  30. package/dist/src/docs-drift.d.ts +10 -0
  31. package/dist/src/docs-drift.js +12 -0
  32. package/dist/src/doctor.d.ts +90 -0
  33. package/dist/src/doctor.js +13 -0
  34. package/dist/src/drift.d.ts +28 -0
  35. package/dist/src/drift.js +69 -0
  36. package/dist/src/editor.d.ts +25 -0
  37. package/dist/src/editor.js +3 -0
  38. package/dist/src/errors.d.ts +13 -0
  39. package/dist/src/errors.js +17 -0
  40. package/dist/src/git.d.ts +152 -0
  41. package/dist/src/git.js +3 -0
  42. package/dist/src/github.d.ts +295 -0
  43. package/dist/src/github.js +17 -0
  44. package/dist/src/graph.d.ts +360 -0
  45. package/dist/src/graph.js +137 -1
  46. package/dist/src/guard.d.ts +118 -0
  47. package/dist/src/guard.js +15 -0
  48. package/dist/src/harness-events.d.ts +8 -0
  49. package/dist/src/harness-events.js +1 -0
  50. package/dist/src/harness-profile-state.d.ts +10 -0
  51. package/dist/src/harness-profile-state.js +13 -0
  52. package/dist/src/help-catalog.d.ts +41 -0
  53. package/dist/src/help-catalog.js +13 -0
  54. package/dist/src/host.d.ts +41 -0
  55. package/dist/src/host.js +13 -0
  56. package/dist/src/identity.d.ts +44 -0
  57. package/dist/src/identity.js +1 -0
  58. package/dist/src/index.d.ts +98 -0
  59. package/dist/src/index.js +2605 -3752
  60. package/dist/src/isolation.d.ts +213 -0
  61. package/dist/src/isolation.js +13 -0
  62. package/dist/src/kernel.d.ts +200 -0
  63. package/dist/src/kernel.js +261 -0
  64. package/dist/src/keybindings.d.ts +71 -0
  65. package/dist/src/keybindings.js +3 -0
  66. package/dist/src/layout.d.ts +44 -0
  67. package/dist/src/layout.js +8 -0
  68. package/dist/src/lifecycle-capabilities.d.ts +224 -0
  69. package/dist/src/lifecycle-capabilities.js +45 -0
  70. package/dist/src/managed-repos.d.ts +339 -0
  71. package/dist/src/managed-repos.js +37 -0
  72. package/dist/src/memory.d.ts +199 -0
  73. package/dist/src/memory.js +15 -0
  74. package/dist/src/model.d.ts +13 -0
  75. package/dist/src/model.js +3 -58
  76. package/dist/src/native-toolchain.d.ts +46 -0
  77. package/dist/src/native-toolchain.js +13 -0
  78. package/dist/src/notify.d.ts +46 -0
  79. package/dist/src/notify.js +13 -0
  80. package/dist/src/orchestration.d.ts +43 -0
  81. package/dist/src/orchestration.js +28 -961
  82. package/dist/src/panel-protocol.d.ts +17 -0
  83. package/dist/src/panel-protocol.js +10 -0
  84. package/dist/src/pi-session.d.ts +113 -0
  85. package/dist/src/pi-session.js +1 -0
  86. package/dist/src/placement.d.ts +47 -0
  87. package/dist/src/placement.js +13 -0
  88. package/dist/src/planning.d.ts +64 -0
  89. package/dist/src/planning.js +90 -0
  90. package/dist/src/plugin-hooks.d.ts +51 -0
  91. package/dist/src/plugin-hooks.js +386 -0
  92. package/dist/src/plugin.d.ts +476 -0
  93. package/dist/src/plugin.js +346 -64
  94. package/dist/src/policy.d.ts +16 -0
  95. package/dist/src/policy.js +3 -0
  96. package/dist/src/product-entrypoint.d.ts +22 -0
  97. package/dist/src/product-entrypoint.js +13 -0
  98. package/dist/src/project.d.ts +71 -0
  99. package/dist/src/project.js +3 -0
  100. package/dist/src/prompt.d.ts +29 -0
  101. package/dist/src/prompt.js +13 -0
  102. package/dist/src/protocol-version.d.ts +21 -0
  103. package/dist/src/protocol-version.js +6 -0
  104. package/dist/src/provider-instructions.d.ts +41 -0
  105. package/dist/src/provider-instructions.js +13 -0
  106. package/dist/src/provider.d.ts +105 -0
  107. package/dist/src/provider.js +16 -835
  108. package/dist/src/remote-control.d.ts +93 -0
  109. package/dist/src/remote-control.js +26 -0
  110. package/dist/src/remote.d.ts +318 -0
  111. package/dist/src/remote.js +238 -1078
  112. package/dist/src/review.d.ts +18 -0
  113. package/dist/src/review.js +3 -0
  114. package/dist/src/rollups.d.ts +41 -0
  115. package/dist/src/rollups.js +70 -0
  116. package/dist/src/run-control.d.ts +164 -0
  117. package/dist/src/run-control.js +13 -0
  118. package/dist/src/run-discovery.d.ts +83 -0
  119. package/dist/src/run-discovery.js +13 -0
  120. package/dist/src/run-dispatch.d.ts +34 -0
  121. package/dist/src/run-dispatch.js +13 -0
  122. package/dist/src/run-identity.d.ts +47 -0
  123. package/dist/src/run-identity.js +13 -0
  124. package/dist/src/run-journal.d.ts +694 -0
  125. package/dist/src/run-journal.js +569 -0
  126. package/dist/src/run-queue.d.ts +36 -0
  127. package/dist/src/run-queue.js +13 -0
  128. package/dist/src/run-read-model.d.ts +200 -0
  129. package/dist/src/run-read-model.js +13 -0
  130. package/dist/src/run-record.d.ts +45 -0
  131. package/dist/src/run-record.js +1 -0
  132. package/dist/src/run-registry-backbone.d.ts +56 -0
  133. package/dist/src/run-registry-backbone.js +13 -0
  134. package/dist/src/run-session-journal.d.ts +154 -0
  135. package/dist/src/run-session-journal.js +87 -0
  136. package/dist/src/run-status.d.ts +10 -0
  137. package/dist/src/run-status.js +27 -0
  138. package/dist/src/run-timeline.d.ts +7 -0
  139. package/dist/src/run-timeline.js +1 -0
  140. package/dist/src/runtime-secrets.d.ts +10 -0
  141. package/dist/src/runtime-secrets.js +13 -0
  142. package/dist/src/runtime-task-context.d.ts +82 -0
  143. package/dist/src/runtime-task-context.js +1 -0
  144. package/dist/src/runtime.d.ts +103 -0
  145. package/dist/src/runtime.js +73 -906
  146. package/dist/src/session-asset-materializer.d.ts +35 -0
  147. package/dist/src/session-asset-materializer.js +13 -0
  148. package/dist/src/session-hook-materializer.d.ts +41 -0
  149. package/dist/src/session-hook-materializer.js +13 -0
  150. package/dist/src/setup.d.ts +154 -0
  151. package/dist/src/setup.js +13 -0
  152. package/dist/src/stage.d.ts +245 -0
  153. package/dist/src/stage.js +169 -0
  154. package/dist/src/supervisor-journal.d.ts +204 -0
  155. package/dist/src/supervisor-journal.js +336 -0
  156. package/dist/src/supervisor-loop.d.ts +40 -0
  157. package/dist/src/supervisor-loop.js +13 -0
  158. package/dist/src/task-artifacts.d.ts +53 -0
  159. package/dist/src/task-artifacts.js +13 -0
  160. package/dist/src/task-config.d.ts +22 -0
  161. package/dist/src/task-config.js +1 -0
  162. package/dist/src/task-context-renderer.d.ts +29 -0
  163. package/dist/src/task-context-renderer.js +13 -0
  164. package/dist/src/task-data.d.ts +196 -0
  165. package/dist/src/task-data.js +13 -0
  166. package/dist/src/task-graph-primitives.d.ts +47 -0
  167. package/dist/src/task-graph-primitives.js +1 -0
  168. package/dist/src/task-source.d.ts +167 -0
  169. package/dist/src/task-source.js +24 -0
  170. package/dist/src/task-state-metadata.d.ts +21 -0
  171. package/dist/src/task-state-metadata.js +1 -0
  172. package/dist/src/task-state-paths.d.ts +14 -0
  173. package/dist/src/task-state-paths.js +13 -0
  174. package/dist/src/task-state-store.d.ts +36 -0
  175. package/dist/src/task-state-store.js +17 -0
  176. package/dist/src/task-tracker-state.d.ts +101 -0
  177. package/dist/src/task-tracker-state.js +39 -0
  178. package/dist/src/terminal.d.ts +130 -0
  179. package/dist/src/terminal.js +3 -0
  180. package/dist/src/tool-materializer.d.ts +36 -0
  181. package/dist/src/tool-materializer.js +13 -0
  182. package/dist/src/tool-registry.d.ts +3 -0
  183. package/dist/src/tool-registry.js +58 -0
  184. package/dist/src/toolchain-sources.d.ts +54 -0
  185. package/dist/src/toolchain-sources.js +17 -0
  186. package/dist/src/transport-config.d.ts +161 -0
  187. package/dist/src/transport-config.js +15 -0
  188. package/dist/src/validation.d.ts +14 -0
  189. package/dist/src/validation.js +3 -0
  190. package/dist/src/workflow-journal.d.ts +125 -0
  191. package/dist/src/workflow-journal.js +27 -0
  192. package/dist/src/workspace-config.d.ts +18 -0
  193. package/dist/src/workspace-config.js +13 -0
  194. package/dist/src/workspace-service.d.ts +16 -0
  195. package/dist/src/workspace-service.js +13 -0
  196. package/dist/src/workspace.d.ts +204 -0
  197. package/dist/src/workspace.js +76 -911
  198. package/package.json +55 -4
  199. package/dist/src/engine.js +0 -2278
  200. package/dist/src/providerRuntime.js +0 -1630
  201. package/dist/src/rig.js +0 -2374
  202. package/dist/src/server.js +0 -1053
  203. package/dist/src/serviceFabric.js +0 -1066
  204. package/dist/src/ws.js +0 -2968
  205. /package/dist/src/{ipc.js → agent-roles.js} +0 -0
@@ -0,0 +1,196 @@
1
+ /**
2
+ * The TASK_DATA compatibility-facade seam.
3
+ *
4
+ * Floor-neutral vocab + a single `CapabilityId<TaskDataService>` for legacy
5
+ * task-data reads and task-command behaviours consumed by lifecycle, scheduler,
6
+ * isolation provisioning, repos, workspace, and CLI surfaces. Source adapters
7
+ * own real source IO through their dedicated seams; local task state, metadata,
8
+ * artifact IO, and tracker reads own their semantic capabilities in
9
+ * `@rig/task-state-plugin`.
10
+ *
11
+ * Ownership intent: `@rig/task-io-plugin` is the target owner for this legacy
12
+ * facade because it aggregates task/source IO for old consumers. The temporary
13
+ * provider shim remains in `@rig/task-state-plugin` only because capability
14
+ * provider factories run as `FeatureCapability.run(undefined)` with no
15
+ * `PluginHost`/resolver context; the narrower task-state/artifact/tracker
16
+ * capabilities are not boot-installed, and this facade still includes
17
+ * synchronous methods. Without a host-aware provider seam, task-io cannot compose
18
+ * `TASK_STATE_STORE`, `TASK_ARTIFACTS`, and `TASK_TRACKER_STATE` without a
19
+ * forbidden plugin-to-plugin implementation import.
20
+ *
21
+ * Consumers `resolve`/`require` task data off a built plugin host (or read the
22
+ * boot-installed singleton) WITHOUT importing the provider plugin. When provider
23
+ * execution becomes host-aware, move only the facade provider to task-io and keep
24
+ * the semantic state/artifact/tracker services in task-state.
25
+ *
26
+ * Pure: types + one branded legacy id, no behaviour.
27
+ */
28
+ import type { CapabilityId } from "./capability-id";
29
+ import type { TaskConfigEntry } from "./task-config";
30
+ import type { TaskRecord, RegisteredTaskSource, TaskSourceUpdate } from "./task-source";
31
+ import type { TaskRecordReader } from "./isolation";
32
+ import type { CanonicalTaskLifecycleStatus, TaskStateMetadataEnvelope } from "./task-state-metadata";
33
+ /** Result of a bounded artifact-file read (preview + truncation metadata). */
34
+ export type TaskArtifactReadResult = {
35
+ path: string;
36
+ sizeBytes: number;
37
+ contents: string;
38
+ truncated: boolean;
39
+ maxBytes: number;
40
+ };
41
+ /** One validation category outcome inside a {@link TaskValidationSummary}. */
42
+ export type TaskValidationCategoryResult = {
43
+ category: string;
44
+ status: "pass" | "fail";
45
+ exit_code?: number;
46
+ duration_seconds: number;
47
+ };
48
+ /**
49
+ * The aggregate task-validation outcome a task closeout reads/accepts (the
50
+ * category-rollup shape written to `validation-summary.json` by `taskValidate`).
51
+ * Distinct from the schema-typed run-level `ValidationSummary` in `./validation`.
52
+ */
53
+ export type TaskValidationSummary = {
54
+ status: "pass" | "fail" | "skipped";
55
+ total: number;
56
+ passed: number;
57
+ failed: number;
58
+ categories: TaskValidationCategoryResult[];
59
+ };
60
+ /** A `bd-`/source-id lifecycle status projected from the synced tracker. */
61
+ export type SyncedTrackerStatus = CanonicalTaskLifecycleStatus | "unknown";
62
+ export type SyncedTrackerDependency = {
63
+ issueId: string | null;
64
+ dependsOnId: string | null;
65
+ id?: string | null;
66
+ type: string | null;
67
+ };
68
+ export type SyncedTrackerIssue = {
69
+ id: string;
70
+ title: string | null;
71
+ description: string | null;
72
+ acceptanceCriteria: string | null;
73
+ issueType: string | null;
74
+ status: SyncedTrackerStatus;
75
+ rawStatus: string | null;
76
+ priority: number | null;
77
+ dependencies: SyncedTrackerDependency[];
78
+ };
79
+ export type SyncedTrackerSnapshot = {
80
+ source: "remote" | "local";
81
+ baseOid: string | null;
82
+ issues: SyncedTrackerIssue[];
83
+ taskState: TaskStateMetadataEnvelope;
84
+ };
85
+ /** Optional fallback toggle for synced-tracker reads. */
86
+ export type ReadSyncedTrackerOptions = {
87
+ allowLocalFallback?: boolean;
88
+ };
89
+ export type SourceAwareTaskConfigReadOptions = {
90
+ readonly configPath?: string;
91
+ readonly ghBinary?: string;
92
+ };
93
+ /** Result of resolving a single task through the configured task source. */
94
+ export type TaskSourceTaskReadResult = {
95
+ configured: boolean;
96
+ sourceKind: string | null;
97
+ task: TaskRecord | null;
98
+ };
99
+ /** Summary of a `task reopen` operation. */
100
+ export type TaskReopenSummary = {
101
+ mode: "all" | "single";
102
+ requestedTaskId: string | null;
103
+ dryRun: boolean;
104
+ closedFound: number;
105
+ reopened: string[];
106
+ failed: string[];
107
+ skipped: string[];
108
+ };
109
+ /** Identity fields used to resolve a task's source issue. */
110
+ export type SourceTaskIdentity = {
111
+ id?: unknown;
112
+ sourceIssueId?: unknown;
113
+ source_issue_id?: unknown;
114
+ };
115
+ /** Result of pushing an explicit source writeback through the configured source. */
116
+ export type TaskSourceWritebackResult = {
117
+ taskId: string;
118
+ updated: boolean;
119
+ source: "plugin" | "none";
120
+ sourceKind: string | null;
121
+ status: unknown;
122
+ };
123
+ /** Context for building a plugin-backed task-record reader. */
124
+ export type PluginTaskRecordReaderContext = {
125
+ taskSourceRegistry: {
126
+ list(): readonly RegisteredTaskSource[];
127
+ resolveById(id: string): RegisteredTaskSource;
128
+ resolveByKind(kind: string): RegisteredTaskSource;
129
+ };
130
+ };
131
+ /** Options selecting a source for a plugin-backed task-record reader. */
132
+ export type PluginTaskRecordReaderOptions = {
133
+ projectRoot: string;
134
+ sourceId?: string;
135
+ sourceKind?: string;
136
+ };
137
+ /**
138
+ * Legacy TASK_DATA compatibility facade.
139
+ *
140
+ * The shape intentionally remains broad while callers migrate to narrower
141
+ * semantic capabilities. Every method is keyed by `projectRoot` (the service is
142
+ * stateless), so the current provider can be installed as a boot singleton and
143
+ * read synchronously by substrate consumers.
144
+ */
145
+ export interface TaskDataService {
146
+ currentTaskId(projectRoot: string): string;
147
+ readTaskConfig(projectRoot: string): Record<string, TaskConfigEntry>;
148
+ readSourceTaskConfig(projectRoot: string): Record<string, TaskConfigEntry>;
149
+ readValidationDescriptions(projectRoot: string): Record<string, string>;
150
+ lookupTask(projectRoot: string, input: string): string;
151
+ artifactDirForId(projectRoot: string, id: string): string;
152
+ /** @deprecated Third argument is ignored; runtime/provider instruction ownership lives outside TASK_DATA. */
153
+ taskInfo(projectRoot: string, taskId?: string, deprecatedRuntimeProviderOverride?: unknown): Promise<void>;
154
+ taskDeps(projectRoot: string, taskId?: string): Promise<void>;
155
+ taskStatus(projectRoot: string): void;
156
+ taskScope(projectRoot: string, expandFiles: boolean, taskId?: string): Promise<void>;
157
+ taskReady(projectRoot: string): Promise<void>;
158
+ taskLookup(projectRoot: string, id: string): string;
159
+ taskRecord(projectRoot: string, type: "decision" | "failure", text: string, taskId?: string): void;
160
+ taskReopen(projectRoot: string, options: {
161
+ all: boolean;
162
+ taskId?: string;
163
+ dryRun?: boolean;
164
+ }): TaskReopenSummary;
165
+ taskArtifacts(projectRoot: string, taskId?: string): void;
166
+ taskArtifactDir(projectRoot: string, taskId?: string): string;
167
+ taskArtifactWrite(projectRoot: string, filename: string, content: string, taskId?: string): void;
168
+ taskArtifactRead(projectRoot: string, filename: string, options?: {
169
+ taskId?: string;
170
+ maxBytes?: number;
171
+ }): TaskArtifactReadResult;
172
+ taskDependencyIds(projectRoot: string, taskId: string): string[];
173
+ changedFilesForTask(projectRoot: string, taskId: string, scoped: boolean): string[];
174
+ pendingFilesForTask(projectRoot: string, taskId: string, scoped: boolean): string[];
175
+ readSourceAwareTaskStatus(projectRoot: string, taskId: string, options?: SourceAwareTaskConfigReadOptions): Promise<unknown>;
176
+ readConfiguredTaskSourceTask(projectRoot: string, taskId: string): Promise<TaskSourceTaskReadResult>;
177
+ updateConfiguredTaskSourceTask(projectRoot: string, input: {
178
+ taskId: string;
179
+ sourceTask?: SourceTaskIdentity | null;
180
+ update: TaskSourceUpdate;
181
+ }): Promise<TaskSourceWritebackResult>;
182
+ createLegacyTaskConfigRecordReader(projectRoot: string, options?: {
183
+ configPath?: string;
184
+ }): TaskRecordReader;
185
+ createSourceAwareTaskConfigRecordReader(projectRoot: string, options?: SourceAwareTaskConfigReadOptions): TaskRecordReader;
186
+ createPluginTaskRecordReader(context: PluginTaskRecordReaderContext, options: PluginTaskRecordReaderOptions): TaskRecordReader;
187
+ readSyncedTrackerState(projectRoot: string, deps?: unknown, options?: ReadSyncedTrackerOptions): SyncedTrackerSnapshot;
188
+ normalizeTaskLifecycleStatus(status: unknown): CanonicalTaskLifecycleStatus | null;
189
+ }
190
+ /** Stable legacy id string for the TASK_DATA compatibility facade. */
191
+ export declare const TASK_DATA_SERVICE_CAPABILITY_ID = "task-sources.task-data";
192
+ /**
193
+ * The branded task-data capability id. `defineCapability(TASK_DATA_SERVICE_CAPABILITY)`
194
+ * (provider and consumers, independently) resolves to a `TaskDataService`.
195
+ */
196
+ export declare const TASK_DATA_SERVICE_CAPABILITY: CapabilityId<TaskDataService>;
@@ -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/task-data.ts
8
+ var TASK_DATA_SERVICE_CAPABILITY_ID = "task-sources.task-data";
9
+ var TASK_DATA_SERVICE_CAPABILITY = makeCapabilityId(TASK_DATA_SERVICE_CAPABILITY_ID);
10
+ export {
11
+ TASK_DATA_SERVICE_CAPABILITY_ID,
12
+ TASK_DATA_SERVICE_CAPABILITY
13
+ };
@@ -0,0 +1,47 @@
1
+ import type { TaskSummary } from "./graph";
2
+ export type TaskDependencyProjection = Pick<TaskSummary, "id" | "status" | "priority" | "metadata"> & Partial<Pick<TaskSummary, "externalId" | "sourceIssueId" | "dependencies" | "parentChildDeps" | "createdAt" | "updatedAt" | "role" | "scope" | "validationKeys">> & {
3
+ readonly title?: string | null;
4
+ };
5
+ export type ClientTaskProjection = TaskDependencyProjection & {
6
+ readonly title?: string | null;
7
+ readonly assignees?: readonly string[] | null;
8
+ readonly assignedTo?: string | readonly string[] | null;
9
+ readonly labels?: readonly string[] | null;
10
+ };
11
+ export type TaskProjectionInput = {
12
+ readonly id: string;
13
+ readonly title?: string | null;
14
+ readonly status?: string | null;
15
+ readonly source?: string | null;
16
+ readonly url?: string | null;
17
+ readonly body?: string | null;
18
+ readonly priority?: number | string | null;
19
+ readonly assignedTo?: string | readonly string[] | null;
20
+ readonly assignees?: readonly string[] | null;
21
+ readonly dependencies?: readonly string[] | null;
22
+ readonly parentChildDeps?: readonly string[] | null;
23
+ readonly metadata?: Record<string, unknown> | null;
24
+ readonly [key: string]: unknown;
25
+ };
26
+ export type TaskDependencyBadgeKind = "blocked" | "ready" | "dependency";
27
+ export interface TaskDependencyBadge {
28
+ readonly kind: TaskDependencyBadgeKind;
29
+ readonly label: string;
30
+ readonly description: string;
31
+ readonly count?: number;
32
+ readonly taskIds?: readonly string[];
33
+ }
34
+ export interface TaskDependencyBadgeSummary {
35
+ readonly taskId: string;
36
+ readonly blockingDepth: number;
37
+ readonly dependencyIds: readonly string[];
38
+ readonly unresolvedDependencyRefs: readonly string[];
39
+ readonly blockedBy: readonly string[];
40
+ readonly blocks: readonly string[];
41
+ readonly blocked: boolean;
42
+ readonly ready: boolean;
43
+ readonly dependencyCount: number;
44
+ readonly dependentCount: number;
45
+ readonly badges: readonly TaskDependencyBadge[];
46
+ }
47
+ export type TaskScopeInput = readonly string[] | TaskDependencyProjection;
@@ -0,0 +1 @@
1
+ // @bun
@@ -0,0 +1,167 @@
1
+ import type { CapabilityId } from "./capability-id";
2
+ import type { TaskSourceRegistration } from "./plugin";
3
+ import type { TaskConfigEntry } from "./task-config";
4
+ export type { TaskConfigEntry } from "./task-config";
5
+ /**
6
+ * A single task record returned by a task source adapter.
7
+ * Open-ended to allow adapters to include source-specific fields.
8
+ */
9
+ export interface TaskRecord {
10
+ id: string;
11
+ deps: readonly string[];
12
+ status: "ready" | "in_progress" | "closed" | "blocked" | "open" | string;
13
+ [extra: string]: unknown;
14
+ }
15
+ /**
16
+ * The NORMALIZED, surface-facing task shape (the projection consumers read).
17
+ * The TYPE is floor-neutral vocab and lives here in contracts; the normalization
18
+ * implementation is provided by the task IO owner, not by the source-adapter
19
+ * plugin.
20
+ */
21
+ export type RigTask = {
22
+ readonly id: string;
23
+ readonly title?: string | null;
24
+ readonly status?: string | null;
25
+ readonly source?: string | null;
26
+ readonly url?: string | null;
27
+ readonly body?: string | null;
28
+ readonly priority?: number | string | null;
29
+ readonly assignedTo?: string | readonly string[] | null;
30
+ readonly assignees?: readonly string[] | null;
31
+ readonly dependencies?: readonly string[] | null;
32
+ readonly parentChildDeps?: readonly string[] | null;
33
+ readonly metadata?: Record<string, unknown> | null;
34
+ readonly [key: string]: unknown;
35
+ };
36
+ /** Alias retained for call sites that accept any task-like projection. */
37
+ export type TaskLike = RigTask;
38
+ export type TaskSourceLabelUpdate = {
39
+ readonly add?: readonly string[];
40
+ readonly remove?: readonly string[];
41
+ };
42
+ /**
43
+ * Explicit provider-owned source update payload. Reflection code should
44
+ * project intent into these concrete source write values before calling adapters.
45
+ */
46
+ export interface TaskSourceProjectedUpdate {
47
+ labels?: TaskSourceLabelUpdate;
48
+ sourceFields?: Record<string, string | null | undefined>;
49
+ close?: boolean;
50
+ assignToDefault?: boolean;
51
+ }
52
+ /** Generic provider-owned source update payload. */
53
+ export interface TaskSourceUpdate extends TaskSourceProjectedUpdate {
54
+ title?: string;
55
+ body?: string;
56
+ comment?: string;
57
+ metadata?: Record<string, unknown>;
58
+ }
59
+ export interface TaskSourceCreateInput {
60
+ title: string;
61
+ body: string;
62
+ deps?: readonly string[];
63
+ parents?: readonly string[];
64
+ metadata?: Record<string, unknown>;
65
+ }
66
+ export type TaskSourceCreateResult = TaskRecord;
67
+ export type TaskSourceUpdateRequest = {
68
+ readonly projectRoot: string;
69
+ readonly taskId: string;
70
+ readonly sourceId?: string | null;
71
+ readonly sourceKind?: string | null;
72
+ readonly update: TaskSourceUpdate;
73
+ };
74
+ export type TaskSourceUpdateWriteResult = "applied" | "not-configured" | "unsupported";
75
+ export type TaskSourceUpdateResult = {
76
+ readonly taskId: string;
77
+ readonly updated: boolean;
78
+ /** Authoritative source write outcome. `updated` is retained as a boolean compatibility projection. */
79
+ readonly writeResult: TaskSourceUpdateWriteResult;
80
+ readonly sourceId?: string | null;
81
+ readonly sourceKind?: string | null;
82
+ /** Best-effort status read back from the source after the write; absent/null when the adapter cannot read back. */
83
+ readonly sourceStatus?: unknown;
84
+ };
85
+ /**
86
+ * Generic source-adapter writeback port. The legacy id string is retained, but
87
+ * implementations should only dispatch to configured source adapters; local task
88
+ * state, normalized task IO, source reflection, and validation policy are
89
+ * owned by their respective plugins.
90
+ */
91
+ export interface TaskSourceUpdateService {
92
+ updateTask(input: TaskSourceUpdateRequest): Promise<TaskSourceUpdateResult>;
93
+ }
94
+ /**
95
+ * Synchronous projection seam for task-source-owned task config materialization.
96
+ *
97
+ * The service owns source adapter/config-path semantics (for example files-backed
98
+ * task directories and source task-config locations) while legacy sync state-store
99
+ * callers keep the existing `TaskStateStoreService` surface.
100
+ */
101
+ export interface TaskSourceConfigProjectionService {
102
+ /** Resolve the sync TaskStateStoreService readTaskConfig path, including source-owned fallback paths. */
103
+ resolveTaskConfigPath(projectRoot: string): string;
104
+ readSourceTaskConfig(projectRoot: string): Record<string, TaskConfigEntry>;
105
+ writeSourceTaskConfig(projectRoot: string, entries: Record<string, TaskConfigEntry>): void;
106
+ readSourceValidationDescriptions(projectRoot: string): Record<string, string>;
107
+ }
108
+ export declare const TASK_SOURCE_CONFIG_PROJECTION_CAPABILITY_ID = "task-sources.config-projection";
109
+ export declare const TASK_SOURCE_CONFIG_PROJECTION: CapabilityId<TaskSourceConfigProjectionService>;
110
+ export type TaskTerminalStateInput = {
111
+ readonly projectRoot: string;
112
+ readonly taskId: string;
113
+ };
114
+ /** Source-owned task terminal-state projection, including source config and Beads fallback. */
115
+ export interface TaskSourceTerminalStateService {
116
+ isTaskTerminal(input: TaskTerminalStateInput): Promise<boolean>;
117
+ }
118
+ export declare const TASK_SOURCE_TERMINAL_STATE_CAPABILITY_ID = "task-sources.terminal-state";
119
+ export declare const TASK_SOURCE_TERMINAL_STATE: CapabilityId<TaskSourceTerminalStateService>;
120
+ export declare const TASK_SOURCE_UPDATE_CAPABILITY_ID = "task-sources.update";
121
+ export declare const TASK_SOURCE_UPDATE: CapabilityId<TaskSourceUpdateService>;
122
+ export interface RegisteredTaskSource extends TaskSourceRegistration {
123
+ list(): Promise<readonly TaskRecord[]>;
124
+ get?(id: string): Promise<TaskRecord | undefined>;
125
+ updateTask?(id: string, update: TaskSourceUpdate): Promise<void>;
126
+ create?(input: TaskSourceCreateInput): Promise<TaskSourceCreateResult>;
127
+ }
128
+ export type TaskIoCreateResult = {
129
+ readonly taskId: string | null;
130
+ readonly source: string;
131
+ readonly result: unknown;
132
+ };
133
+ export type TaskFactRecordInput = {
134
+ readonly type: "decision" | "failure";
135
+ readonly text: string;
136
+ readonly taskId?: string;
137
+ };
138
+ export type TaskFactRecordResult = {
139
+ readonly taskId: string;
140
+ readonly message: string;
141
+ };
142
+ export type TaskArtifactsPrepareResult = {
143
+ readonly taskId: string;
144
+ readonly artifactDir: string;
145
+ readonly message: string;
146
+ };
147
+ export type TaskIoStateFilter = "open" | "closed";
148
+ export interface TaskIoListFilters {
149
+ readonly assignee?: string;
150
+ readonly state?: TaskIoStateFilter;
151
+ readonly limit?: number;
152
+ readonly search?: string;
153
+ }
154
+ /**
155
+ * Normalized task IO projection seam. The historical id string is retained for
156
+ * compatibility, but this capability is owned/provided by @rig/task-io-plugin;
157
+ * source-adapter plugins should contribute adapters and source writeback only.
158
+ */
159
+ export interface TaskIoService {
160
+ listTasks(projectRoot: string, filters?: TaskIoListFilters): Promise<readonly RigTask[]>;
161
+ getTask(projectRoot: string, taskId: string): Promise<RigTask | null>;
162
+ createTask(projectRoot: string, task: Record<string, unknown>): Promise<TaskIoCreateResult>;
163
+ recordTaskFact(projectRoot: string, input: TaskFactRecordInput): Promise<TaskFactRecordResult>;
164
+ prepareTaskArtifacts(projectRoot: string, taskId?: string): Promise<TaskArtifactsPrepareResult>;
165
+ }
166
+ export declare const TASK_IO_SERVICE_CAPABILITY_ID = "rig.tasks.io";
167
+ export declare const TASK_IO_SERVICE_CAPABILITY: CapabilityId<TaskIoService>;
@@ -1 +1,25 @@
1
1
  // @bun
2
+ // packages/contracts/src/capability-id.ts
3
+ function makeCapabilityId(id) {
4
+ return id;
5
+ }
6
+
7
+ // packages/contracts/src/task-source.ts
8
+ var TASK_SOURCE_CONFIG_PROJECTION_CAPABILITY_ID = "task-sources.config-projection";
9
+ var TASK_SOURCE_CONFIG_PROJECTION = makeCapabilityId(TASK_SOURCE_CONFIG_PROJECTION_CAPABILITY_ID);
10
+ var TASK_SOURCE_TERMINAL_STATE_CAPABILITY_ID = "task-sources.terminal-state";
11
+ var TASK_SOURCE_TERMINAL_STATE = makeCapabilityId(TASK_SOURCE_TERMINAL_STATE_CAPABILITY_ID);
12
+ var TASK_SOURCE_UPDATE_CAPABILITY_ID = "task-sources.update";
13
+ var TASK_SOURCE_UPDATE = makeCapabilityId(TASK_SOURCE_UPDATE_CAPABILITY_ID);
14
+ var TASK_IO_SERVICE_CAPABILITY_ID = "rig.tasks.io";
15
+ var TASK_IO_SERVICE_CAPABILITY = makeCapabilityId(TASK_IO_SERVICE_CAPABILITY_ID);
16
+ export {
17
+ TASK_SOURCE_UPDATE_CAPABILITY_ID,
18
+ TASK_SOURCE_UPDATE,
19
+ TASK_SOURCE_TERMINAL_STATE_CAPABILITY_ID,
20
+ TASK_SOURCE_TERMINAL_STATE,
21
+ TASK_SOURCE_CONFIG_PROJECTION_CAPABILITY_ID,
22
+ TASK_SOURCE_CONFIG_PROJECTION,
23
+ TASK_IO_SERVICE_CAPABILITY_ID,
24
+ TASK_IO_SERVICE_CAPABILITY
25
+ };
@@ -0,0 +1,21 @@
1
+ export type CanonicalTaskLifecycleStatus = "draft" | "open" | "ready" | "queued" | "in_progress" | "under_review" | "blocked" | "completed" | "cancelled";
2
+ export type TaskStateMetadata = {
3
+ claimId?: string;
4
+ status: CanonicalTaskLifecycleStatus;
5
+ ownerId?: string;
6
+ claimedAt?: string;
7
+ lastEvidenceAt?: string;
8
+ runId?: string;
9
+ branchName?: string;
10
+ prNumber?: number;
11
+ prUrl?: string;
12
+ reviewState?: string;
13
+ blockerReason?: string;
14
+ sourceCommit?: string;
15
+ };
16
+ export type TaskStateMetadataEnvelope = {
17
+ schemaVersion: number;
18
+ supported: boolean;
19
+ baseTrackerCommit: string | null;
20
+ tasks: Record<string, TaskStateMetadata>;
21
+ };
@@ -0,0 +1 @@
1
+ // @bun
@@ -0,0 +1,14 @@
1
+ import type { CapabilityId } from "./capability-id";
2
+ /** Task-state-owned local path layout for task config/session/artifacts/metadata files. */
3
+ export interface TaskStatePaths {
4
+ readonly stateDir: string;
5
+ readonly artifactsDir: string;
6
+ readonly taskConfigPath: string;
7
+ readonly sessionPath: string;
8
+ readonly failedApproachesPath: string;
9
+ }
10
+ export interface TaskStatePathsService {
11
+ resolvePaths(projectRoot: string): TaskStatePaths;
12
+ }
13
+ export declare const TASK_STATE_PATHS_CAPABILITY_ID = "task-state.paths";
14
+ export declare const TASK_STATE_PATHS: CapabilityId<TaskStatePathsService>;
@@ -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/task-state-paths.ts
8
+ var TASK_STATE_PATHS_CAPABILITY_ID = "task-state.paths";
9
+ var TASK_STATE_PATHS = makeCapabilityId(TASK_STATE_PATHS_CAPABILITY_ID);
10
+ export {
11
+ TASK_STATE_PATHS_CAPABILITY_ID,
12
+ TASK_STATE_PATHS
13
+ };
@@ -0,0 +1,36 @@
1
+ import type { CapabilityId } from "./capability-id";
2
+ import type { TaskConfigEntry } from "./task-config";
3
+ import type { TaskTerminalStateInput } from "./task-source";
4
+ import type { TaskStateMetadataEnvelope } from "./task-state-metadata";
5
+ export type TaskFailedApproachRecordInput = {
6
+ readonly projectRoot: string;
7
+ readonly taskId?: string;
8
+ readonly text: string;
9
+ readonly timestamp?: string;
10
+ };
11
+ export type TaskFailedApproachRecordResult = {
12
+ readonly taskId: string;
13
+ readonly attempts: number;
14
+ readonly path: string;
15
+ readonly message: string;
16
+ };
17
+ /** Local `.rig` task state/config/metadata only; no runtime/provider guidance. */
18
+ export interface TaskStateStoreService {
19
+ readCurrentTaskId(projectRoot: string): string | null;
20
+ writeCurrentTaskId(projectRoot: string, taskId: string | null): void;
21
+ readTaskConfig(projectRoot: string): Record<string, TaskConfigEntry>;
22
+ writeTaskConfig(projectRoot: string, entries: Record<string, TaskConfigEntry>): void;
23
+ readSourceTaskConfig(projectRoot: string): Record<string, TaskConfigEntry>;
24
+ writeSourceTaskConfig(projectRoot: string, entries: Record<string, TaskConfigEntry>): void;
25
+ readTaskStateMetadata(projectRoot: string): TaskStateMetadataEnvelope | null;
26
+ writeTaskStateMetadata(projectRoot: string, envelope: TaskStateMetadataEnvelope): void;
27
+ recordFailedApproach(input: TaskFailedApproachRecordInput): TaskFailedApproachRecordResult;
28
+ }
29
+ export declare const TASK_STATE_STORE_CAPABILITY_ID = "task-state.store";
30
+ export declare const TASK_STATE_STORE: CapabilityId<TaskStateStoreService>;
31
+ /** Local task-state-owned terminal-state check over `.rig/task-config.json`. */
32
+ export interface TaskStateTerminalStateService {
33
+ isTaskTerminal(input: TaskTerminalStateInput): Promise<boolean>;
34
+ }
35
+ export declare const TASK_STATE_TERMINAL_STATE_CAPABILITY_ID = "task-state.terminal-state";
36
+ export declare const TASK_STATE_TERMINAL_STATE: CapabilityId<TaskStateTerminalStateService>;
@@ -0,0 +1,17 @@
1
+ // @bun
2
+ // packages/contracts/src/capability-id.ts
3
+ function makeCapabilityId(id) {
4
+ return id;
5
+ }
6
+
7
+ // packages/contracts/src/task-state-store.ts
8
+ var TASK_STATE_STORE_CAPABILITY_ID = "task-state.store";
9
+ var TASK_STATE_STORE = makeCapabilityId(TASK_STATE_STORE_CAPABILITY_ID);
10
+ var TASK_STATE_TERMINAL_STATE_CAPABILITY_ID = "task-state.terminal-state";
11
+ var TASK_STATE_TERMINAL_STATE = makeCapabilityId(TASK_STATE_TERMINAL_STATE_CAPABILITY_ID);
12
+ export {
13
+ TASK_STATE_TERMINAL_STATE_CAPABILITY_ID,
14
+ TASK_STATE_TERMINAL_STATE,
15
+ TASK_STATE_STORE_CAPABILITY_ID,
16
+ TASK_STATE_STORE
17
+ };
@@ -0,0 +1,101 @@
1
+ import type { CapabilityId } from "./capability-id";
2
+ import type { CanonicalTaskLifecycleStatus, TaskStateMetadata, TaskStateMetadataEnvelope } from "./task-state-metadata";
3
+ import type { SyncedTrackerSnapshot, ReadSyncedTrackerOptions } from "./task-data";
4
+ export declare const TASK_TRACKER_LIFECYCLE_STATUSES: readonly ["draft", "open", "ready", "queued", "in_progress", "under_review", "blocked", "completed", "cancelled"];
5
+ export declare const TASK_TRACKER_STALE_CLAIM_MS: number;
6
+ export type TaskTrackerPolicyDecision = {
7
+ readonly allowed: boolean;
8
+ readonly code?: "claim-conflict" | "status-conflict";
9
+ readonly reason?: string;
10
+ /** Owner-supplied compare-and-set precondition for tracker persistence. */
11
+ readonly expectedLifecycleStatus?: CanonicalTaskLifecycleStatus | readonly CanonicalTaskLifecycleStatus[];
12
+ };
13
+ export type TrackerPullRequestEvidence = {
14
+ readonly branchName?: string | null;
15
+ readonly prNumber?: number | null;
16
+ readonly prUrl?: string | null;
17
+ readonly isOpen?: boolean;
18
+ readonly isMerged?: boolean;
19
+ readonly reviewState?: string | null;
20
+ };
21
+ export type TrackerReconcileEvidence = {
22
+ readonly now?: string;
23
+ readonly closeoutPassed?: boolean;
24
+ readonly pr?: TrackerPullRequestEvidence | null;
25
+ readonly activeOwnerIds?: readonly string[];
26
+ };
27
+ export type TaskReconciliationProjection = {
28
+ readonly valid: boolean;
29
+ readonly reasons: readonly string[];
30
+ readonly isStale: boolean;
31
+ readonly wouldReconcileTo: CanonicalTaskLifecycleStatus | null;
32
+ readonly nextMetadata: TaskStateMetadata | null;
33
+ };
34
+ export type TaskTrackerReconciliationPolicyInput = {
35
+ readonly lifecycleStatus: CanonicalTaskLifecycleStatus;
36
+ readonly metadata: TaskStateMetadata | null;
37
+ readonly evidence?: TrackerReconcileEvidence;
38
+ /**
39
+ * Explicit clock input keeps the lifecycle-owned projection deterministic.
40
+ */
41
+ readonly nowIso: string;
42
+ };
43
+ export type TaskTrackerClaimTransitionPolicyInput = {
44
+ readonly taskId: string;
45
+ readonly lifecycleStatus: CanonicalTaskLifecycleStatus;
46
+ readonly expectedStatus?: CanonicalTaskLifecycleStatus;
47
+ };
48
+ export type TaskTrackerLifecycleTransitionPolicyInput = {
49
+ readonly taskId: string;
50
+ readonly lifecycleStatus: CanonicalTaskLifecycleStatus;
51
+ readonly allowedFrom?: readonly CanonicalTaskLifecycleStatus[];
52
+ };
53
+ export interface TaskTrackerReconciliationPolicyService {
54
+ projectReconciliation(input: TaskTrackerReconciliationPolicyInput): TaskReconciliationProjection;
55
+ canUpdateLifecycle(input: TaskTrackerLifecycleTransitionPolicyInput): TaskTrackerPolicyDecision;
56
+ }
57
+ export declare const TASK_TRACKER_RECONCILIATION_POLICY_CAPABILITY_ID = "lifecycle.task-tracker-reconciliation-policy";
58
+ export declare const TASK_TRACKER_RECONCILIATION_POLICY: CapabilityId<TaskTrackerReconciliationPolicyService>;
59
+ export interface TaskTrackerReadinessPolicyService {
60
+ listReadyTaskIds(snapshot: SyncedTrackerSnapshot): readonly string[];
61
+ canClaimTask(input: TaskTrackerClaimTransitionPolicyInput): TaskTrackerPolicyDecision;
62
+ }
63
+ export declare const TASK_TRACKER_READINESS_POLICY_CAPABILITY_ID = "scheduler.task-tracker-readiness-policy";
64
+ export declare const TASK_TRACKER_READINESS_POLICY: CapabilityId<TaskTrackerReadinessPolicyService>;
65
+ export type TaskTrackerStateUpdateInput = {
66
+ readonly projectRoot: string;
67
+ readonly taskId: string;
68
+ readonly lifecycleStatus: CanonicalTaskLifecycleStatus;
69
+ readonly metadata?: TaskStateMetadata | null;
70
+ /** Lifecycle-owner supplied transition precondition. Required by the legacy task-state wrapper. */
71
+ readonly allowedFrom?: readonly CanonicalTaskLifecycleStatus[];
72
+ readonly reason?: string;
73
+ };
74
+ export type TaskTrackerStateClaimInput = {
75
+ readonly projectRoot: string;
76
+ readonly taskId: string;
77
+ readonly ownerId: string;
78
+ readonly runId?: string | null;
79
+ readonly now?: string;
80
+ };
81
+ /**
82
+ * Tracker repository locator seam.
83
+ *
84
+ * Task-state owns tracker persistence and metadata storage only. Lifecycle and
85
+ * scheduler policy capabilities own reconciliation, stale-claim, readiness, and
86
+ * transition decisions; contracts provides the pure vocabulary/capability ids.
87
+ */
88
+ export interface TaskTrackerRepoLocatorService {
89
+ resolveTrackerRepoPath(projectRoot: string): string;
90
+ }
91
+ export declare const TASK_TRACKER_REPO_LOCATOR_CAPABILITY_ID = "task-state.tracker-repo-locator";
92
+ export declare const TASK_TRACKER_REPO_LOCATOR: CapabilityId<TaskTrackerRepoLocatorService>;
93
+ /** Tracker snapshot/persistence API. Keep this shape stable for legacy callers. */
94
+ export interface TaskTrackerStateService {
95
+ readSnapshot(projectRoot: string, options?: ReadSyncedTrackerOptions): SyncedTrackerSnapshot;
96
+ normalizeStatus(status: unknown): CanonicalTaskLifecycleStatus | null;
97
+ claimTask(input: TaskTrackerStateClaimInput): TaskStateMetadataEnvelope | Promise<TaskStateMetadataEnvelope>;
98
+ updateLifecycle(input: TaskTrackerStateUpdateInput): TaskStateMetadataEnvelope | Promise<TaskStateMetadataEnvelope>;
99
+ }
100
+ export declare const TASK_TRACKER_STATE_CAPABILITY_ID = "task-state.tracker-state";
101
+ export declare const TASK_TRACKER_STATE: CapabilityId<TaskTrackerStateService>;