@h-rig/contracts 0.0.6-alpha.156 → 0.0.6-alpha.158
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.
- package/dist/index.cjs +2340 -6832
- package/dist/index.mjs +2116 -6608
- package/dist/src/agent-roles.d.ts +8 -0
- package/dist/src/browser.d.ts +34 -4
- package/dist/src/browser.js +8 -1
- package/dist/src/capability-id.d.ts +22 -0
- package/dist/src/capability-id.js +8 -0
- package/dist/src/cli-output.d.ts +24 -0
- package/dist/src/cli-runner.d.ts +43 -0
- package/dist/src/cli-runner.js +13 -0
- package/dist/src/collab-session-viewer.d.ts +36 -0
- package/dist/src/collab-session-viewer.js +13 -0
- package/dist/src/config.d.ts +11 -0
- package/dist/src/config.js +279 -1098
- package/dist/src/control-plane-types.d.ts +41 -1
- package/dist/src/control-plane-types.js +9 -25
- package/dist/src/dependency-preflight.d.ts +43 -0
- package/dist/src/dependency-preflight.js +13 -0
- package/dist/src/doctor.d.ts +67 -4
- package/dist/src/doctor.js +8 -9
- package/dist/src/errors.d.ts +13 -0
- package/dist/src/errors.js +17 -0
- package/dist/src/github.d.ts +43 -0
- package/dist/src/github.js +12 -1
- package/dist/src/graph.d.ts +37 -0
- package/dist/src/graph.js +13 -0
- package/dist/src/guard.d.ts +111 -0
- package/dist/src/guard.js +6 -0
- package/dist/src/harness-events.d.ts +8 -0
- package/dist/src/harness-events.js +1 -0
- package/dist/src/help-catalog.d.ts +17 -10
- package/dist/src/help-catalog.js +9 -651
- package/dist/src/host.d.ts +41 -0
- package/dist/src/host.js +13 -0
- package/dist/src/identity.d.ts +44 -0
- package/dist/src/identity.js +1 -0
- package/dist/src/index.d.ts +27 -7
- package/dist/src/index.js +2116 -6608
- package/dist/src/isolation.d.ts +207 -15
- package/dist/src/isolation.js +8 -1
- package/dist/src/kernel.d.ts +11 -0
- package/dist/src/kernel.js +7 -0
- package/dist/src/layout.d.ts +49 -0
- package/dist/src/layout.js +10 -0
- package/dist/src/lifecycle-capabilities.d.ts +99 -0
- package/dist/src/lifecycle-capabilities.js +18 -1
- package/dist/src/managed-repos.d.ts +79 -16
- package/dist/src/managed-repos.js +12 -1
- package/dist/src/memory.d.ts +52 -4
- package/dist/src/memory.js +8 -1
- package/dist/src/notify.d.ts +46 -0
- package/dist/src/notify.js +13 -0
- package/dist/src/orchestration.d.ts +0 -3652
- package/dist/src/orchestration.js +28 -964
- package/dist/src/plugin-hooks.js +22 -3
- package/dist/src/plugin.d.ts +47 -0
- package/dist/src/plugin.js +24 -3
- package/dist/src/prompt.d.ts +29 -0
- package/dist/src/prompt.js +13 -0
- package/dist/src/provider-instructions.d.ts +26 -4
- package/dist/src/provider-instructions.js +8 -1
- package/dist/src/provider.js +1 -824
- package/dist/src/remote.d.ts +0 -8
- package/dist/src/remote.js +229 -1075
- package/dist/src/run-discovery.d.ts +79 -0
- package/dist/src/run-discovery.js +13 -0
- package/dist/src/run-dispatch.d.ts +34 -0
- package/dist/src/run-dispatch.js +13 -0
- package/dist/src/run-identity.d.ts +47 -0
- package/dist/src/run-identity.js +13 -0
- package/dist/src/run-journal.d.ts +0 -236
- package/dist/src/run-journal.js +249 -1321
- package/dist/src/run-read-model.d.ts +234 -0
- package/dist/src/run-read-model.js +13 -0
- package/dist/src/run-record.d.ts +0 -11
- package/dist/src/run-record.js +0 -16
- package/dist/src/run-registry-backbone.d.ts +56 -0
- package/dist/src/run-registry-backbone.js +13 -0
- package/dist/src/run-session-journal.d.ts +1 -25
- package/dist/src/run-session-journal.js +0 -1731
- package/dist/src/run-status.d.ts +0 -2
- package/dist/src/run-status.js +0 -11
- package/dist/src/run-timeline.d.ts +0 -3
- package/dist/src/run-timeline.js +0 -1498
- package/dist/src/runtime-task-context.d.ts +82 -0
- package/dist/src/runtime-task-context.js +1 -0
- package/dist/src/runtime.js +66 -904
- package/dist/src/session-asset-materializer.d.ts +35 -0
- package/dist/src/session-asset-materializer.js +13 -0
- package/dist/src/setup.d.ts +47 -0
- package/dist/src/setup.js +13 -0
- package/dist/src/supervisor-journal.js +117 -955
- package/dist/src/task-data.d.ts +239 -0
- package/dist/src/task-data.js +13 -0
- package/dist/src/task-graph-primitives.d.ts +0 -21
- package/dist/src/task-graph-primitives.js +0 -318
- package/dist/src/task-source.d.ts +65 -0
- package/dist/src/task-source.js +12 -0
- package/dist/src/task-state-metadata.d.ts +21 -0
- package/dist/src/task-state-metadata.js +1 -0
- package/dist/src/tool-materializer.d.ts +36 -0
- package/dist/src/tool-materializer.js +13 -0
- package/dist/src/tool-registry.d.ts +3 -0
- package/dist/src/tool-registry.js +58 -0
- package/dist/src/toolchain-sources.d.ts +54 -0
- package/dist/src/toolchain-sources.js +17 -0
- package/dist/src/workflow-journal.d.ts +0 -32
- package/dist/src/workflow-journal.js +0 -371
- package/dist/src/workspace-config.d.ts +18 -0
- package/dist/src/workspace-config.js +13 -0
- package/dist/src/workspace.js +73 -911
- package/package.json +1 -1
- package/dist/src/engine.d.ts +0 -2789
- package/dist/src/engine.js +0 -2392
- package/dist/src/ipc.d.ts +0 -248
- package/dist/src/providerRuntime.d.ts +0 -3949
- package/dist/src/providerRuntime.js +0 -1633
- package/dist/src/rig.d.ts +0 -783
- package/dist/src/rig.js +0 -2537
- package/dist/src/server.d.ts +0 -106
- package/dist/src/server.js +0 -1056
- package/dist/src/serviceFabric.d.ts +0 -62
- package/dist/src/serviceFabric.js +0 -1069
- package/dist/src/ws.d.ts +0 -747
- package/dist/src/ws.js +0 -3126
- /package/dist/src/{ipc.js → agent-roles.js} +0 -0
package/dist/src/isolation.d.ts
CHANGED
|
@@ -1,21 +1,213 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Pure isolation-backend contract
|
|
2
|
+
* Pure isolation-backend contract vocab.
|
|
3
3
|
*
|
|
4
|
-
* The neutral home for the
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
4
|
+
* The neutral home for the runtime-isolation backend seam: the capability id, the
|
|
5
|
+
* `IsolationBackend` service interface, and its provisioning option/data types. A
|
|
6
|
+
* backend plugin (e.g. @rig/isolation-plugin: worktree/sandbox provisioning)
|
|
7
|
+
* registers its executable `IsolationBackend` factory under {@link ISOLATION_BACKEND}
|
|
8
|
+
* (string value {@link ISOLATION_BACKEND_CAPABILITY_ID}); the dumb runtime
|
|
9
|
+
* substrate (the task-runtime-start hook, the default-lifecycle isolation stage)
|
|
10
|
+
* resolves it by id from a plugin host built off the project's rig.config via the
|
|
11
|
+
* `defineCapability` seam — exactly the seam shape of {@link MEMORY} and the
|
|
12
|
+
* lifecycle capabilities. This module carries no behaviour and imports only pure
|
|
13
|
+
* contract types, so both the substrate and the plugin can reference it without a
|
|
14
|
+
* substrate->plugin import cycle.
|
|
13
15
|
*
|
|
14
|
-
* The
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* runtime-owned types — mirroring how `MemoryService` lives in the runtime port
|
|
18
|
-
* module while only the pure data types live here.
|
|
16
|
+
* The provisioning data types (`AgentRuntime`, `IsolationMode`, `TaskRecordReader`)
|
|
17
|
+
* are pure data/structural shapes mirrored here so the option type is contracts-
|
|
18
|
+
* pure; the runtime re-exports them from its own modules for back-compat.
|
|
19
19
|
*/
|
|
20
|
+
import type { CapabilityId } from "./capability-id";
|
|
21
|
+
import type { TaskRecord } from "./task-source";
|
|
22
|
+
import type { IsolationMode } from "./runtime";
|
|
20
23
|
/** Capability id the isolation backend plugin registers its factory under. */
|
|
21
24
|
export declare const ISOLATION_BACKEND_CAPABILITY_ID = "isolation.backend";
|
|
25
|
+
/**
|
|
26
|
+
* A provisioned, isolated agent runtime: the resolved filesystem layout a backend
|
|
27
|
+
* hands back. Pure data (all paths/ids), so it lives in contracts as seam vocab;
|
|
28
|
+
* the runtime re-exports this from `runtime/isolation` for its internal callers.
|
|
29
|
+
*/
|
|
30
|
+
export type AgentRuntime = {
|
|
31
|
+
id: string;
|
|
32
|
+
taskId: string;
|
|
33
|
+
mode: IsolationMode;
|
|
34
|
+
rootDir: string;
|
|
35
|
+
workspaceDir: string;
|
|
36
|
+
homeDir: string;
|
|
37
|
+
tmpDir: string;
|
|
38
|
+
cacheDir: string;
|
|
39
|
+
logsDir: string;
|
|
40
|
+
stateDir: string;
|
|
41
|
+
sessionDir: string;
|
|
42
|
+
claudeHomeDir: string;
|
|
43
|
+
contextFile: string;
|
|
44
|
+
binDir: string;
|
|
45
|
+
createdAt: string;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* The control surface over a running task-run snapshot sidecar. Pure data/handle
|
|
49
|
+
* type (no impl), so it lives in contracts as seam vocab; both the isolation
|
|
50
|
+
* plugin (which starts it) and the runtime substrate (agent-wrapper, which holds
|
|
51
|
+
* the handle) reference it from here without coupling to the impl.
|
|
52
|
+
*/
|
|
53
|
+
export type RuntimeSnapshotSidecar = {
|
|
54
|
+
cancel: () => Promise<void>;
|
|
55
|
+
finalize: (command: string[], exitCode: number) => Promise<void>;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* The minimal read surface over task records the provisioner consumes. Structural
|
|
59
|
+
* contract (only depends on the pure {@link TaskRecord}); the runtime's concrete
|
|
60
|
+
* reader is assignable to this, mirroring how `MemoryCommandEventSink` keeps the
|
|
61
|
+
* memory contract free of any runtime/behaviour import.
|
|
62
|
+
*/
|
|
63
|
+
export interface TaskRecordReader {
|
|
64
|
+
listTasks(): Promise<readonly TaskRecord[]>;
|
|
65
|
+
getTask(id: string): Promise<TaskRecord | null>;
|
|
66
|
+
}
|
|
67
|
+
/** Options the substrate passes through to provision an isolated runtime. */
|
|
68
|
+
export type EnsureAgentRuntimeOptions = {
|
|
69
|
+
projectRoot: string;
|
|
70
|
+
id: string;
|
|
71
|
+
taskId: string;
|
|
72
|
+
mode: IsolationMode;
|
|
73
|
+
provider?: "pi";
|
|
74
|
+
taskRecordReader?: TaskRecordReader;
|
|
75
|
+
preserveTaskArtifacts?: boolean;
|
|
76
|
+
};
|
|
77
|
+
/** Options to execute a command inside an already-provisioned agent runtime. */
|
|
78
|
+
export type RunInAgentRuntimeOptions = {
|
|
79
|
+
projectRoot: string;
|
|
80
|
+
runtime: AgentRuntime;
|
|
81
|
+
command: string[];
|
|
82
|
+
inheritStdio?: boolean;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* The pure filesystem-layout subset a sandbox wrap consumes. Structural data
|
|
86
|
+
* (all paths/ids), so it lives in contracts as seam vocab; agent-wrapper builds
|
|
87
|
+
* this from an {@link AgentRuntime} and the backend's wrap impl consumes it. The
|
|
88
|
+
* provisioned runtime is always `worktree`, but `mode` is the wider
|
|
89
|
+
* {@link IsolationMode} here so the seam stays assignable from `AgentRuntime`.
|
|
90
|
+
*/
|
|
91
|
+
export type SandboxRuntimeDescriptor = {
|
|
92
|
+
id: string;
|
|
93
|
+
mode: IsolationMode;
|
|
94
|
+
rootDir: string;
|
|
95
|
+
workspaceDir: string;
|
|
96
|
+
homeDir: string;
|
|
97
|
+
tmpDir: string;
|
|
98
|
+
cacheDir: string;
|
|
99
|
+
stateDir: string;
|
|
100
|
+
sessionDir: string;
|
|
101
|
+
claudeHomeDir: string;
|
|
102
|
+
binDir: string;
|
|
103
|
+
};
|
|
104
|
+
/** Options the substrate passes to wrap a provider command for sandboxed launch. */
|
|
105
|
+
export type WrapRuntimeSandboxOptions = {
|
|
106
|
+
projectRoot: string;
|
|
107
|
+
runtime: SandboxRuntimeDescriptor;
|
|
108
|
+
command: string[];
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* The plan a sandbox-wrap returns: the (possibly rewritten) command plus the
|
|
112
|
+
* resolved backend metadata. `backend` is an open string union (none/seatbelt/
|
|
113
|
+
* bwrap/docker/…) kept as `string` so contracts carry no impl-coupled literals.
|
|
114
|
+
*/
|
|
115
|
+
export type RuntimeSandboxPlan = {
|
|
116
|
+
command: string[];
|
|
117
|
+
enabled: boolean;
|
|
118
|
+
backend: string;
|
|
119
|
+
profilePath?: string;
|
|
120
|
+
reason?: string;
|
|
121
|
+
metadata?: Record<string, unknown>;
|
|
122
|
+
};
|
|
123
|
+
/** Result of executing a command inside an isolated agent runtime. */
|
|
124
|
+
export type RunInAgentRuntimeResult = {
|
|
125
|
+
exitCode: number;
|
|
126
|
+
stdout?: string;
|
|
127
|
+
stderr?: string;
|
|
128
|
+
sandboxBackend: string;
|
|
129
|
+
sandboxEnabled: boolean;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* A deterministic fingerprint of the runtime image build inputs. Pure data,
|
|
133
|
+
* lives in contracts so both isolation-plugin (which computes it) and
|
|
134
|
+
* cli-surface-plugin (which reads image ops through the ISOLATION_BACKEND
|
|
135
|
+
* seam) can reference the type without a cross-plugin import.
|
|
136
|
+
*/
|
|
137
|
+
export type RuntimeImageFingerprint = {
|
|
138
|
+
platform: string;
|
|
139
|
+
bunVersion: string;
|
|
140
|
+
nodeVersion: string;
|
|
141
|
+
claudeVersion: string;
|
|
142
|
+
runtimeCodeHash: string;
|
|
143
|
+
policyHash: string;
|
|
144
|
+
pluginsHash: string;
|
|
145
|
+
lockfileHashes: Record<string, string>;
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* The cohesive isolation surface the runtime substrate depends on: provisioning
|
|
149
|
+
* (`ensureAgentRuntime`) plus the execution helpers (`runInAgentRuntime`,
|
|
150
|
+
* `runtimeEnv`, `startRuntimeSnapshotSidecar`) the substrate's queue/agent
|
|
151
|
+
* executor still invokes. A backend plugin provides a concrete impl (worktree,
|
|
152
|
+
* sandbox, container, …); the substrate only ever sees this port — it resolves the
|
|
153
|
+
* port off the plugin host and never imports the backend package, so there is no
|
|
154
|
+
* substrate->plugin cycle even though the impls now live in @rig/isolation-plugin.
|
|
155
|
+
*/
|
|
156
|
+
export interface IsolationBackend {
|
|
157
|
+
ensureAgentRuntime(options: EnsureAgentRuntimeOptions): Promise<AgentRuntime>;
|
|
158
|
+
runInAgentRuntime(options: RunInAgentRuntimeOptions): Promise<RunInAgentRuntimeResult>;
|
|
159
|
+
runtimeEnv(projectRoot: string, runtime: AgentRuntime): Promise<Record<string, string>>;
|
|
160
|
+
/**
|
|
161
|
+
* Enumerate the provisioned runtimes for a project root. Backend-specific
|
|
162
|
+
* (worktree dirs vs. containers vs. sandboxes), so it belongs on the port —
|
|
163
|
+
* the `rig agent` group and the host run-loader resolve it here rather than
|
|
164
|
+
* importing the backend impl.
|
|
165
|
+
*/
|
|
166
|
+
listAgentRuntimes(projectRoot: string): Promise<AgentRuntime[]>;
|
|
167
|
+
/**
|
|
168
|
+
* Tear down a single provisioned runtime by id. Backend-specific cleanup
|
|
169
|
+
* (remove worktree / kill container), reached through the port.
|
|
170
|
+
*/
|
|
171
|
+
cleanupAgentRuntime(options: {
|
|
172
|
+
projectRoot: string;
|
|
173
|
+
id: string;
|
|
174
|
+
}): Promise<void>;
|
|
175
|
+
/**
|
|
176
|
+
* Persist operator-forwarded secrets beside the runtime so a detached run
|
|
177
|
+
* process recovers them via {@link runtimeEnv}. Backend-specific because the
|
|
178
|
+
* secret location is part of the runtime's on-disk/instance layout.
|
|
179
|
+
*/
|
|
180
|
+
persistRuntimeSecrets(runtimeRoot: string, env: Record<string, string>): void;
|
|
181
|
+
startRuntimeSnapshotSidecar(runtime: AgentRuntime, options?: {
|
|
182
|
+
instanceId?: string;
|
|
183
|
+
}): Promise<RuntimeSnapshotSidecar>;
|
|
184
|
+
/**
|
|
185
|
+
* Wrap a provider command for sandboxed launch (seatbelt/bwrap/none). The
|
|
186
|
+
* substrate's agent-wrapper resolves this through the port and spawns the
|
|
187
|
+
* returned `command` itself, so the sandbox impl stays plugin-owned.
|
|
188
|
+
*/
|
|
189
|
+
wrapRuntimeSandbox(options: WrapRuntimeSandboxOptions): Promise<RuntimeSandboxPlan>;
|
|
190
|
+
/**
|
|
191
|
+
* Compute the deterministic fingerprint of this project's runtime image build
|
|
192
|
+
* inputs (Bun/Node/Claude versions, code hashes, policy hash, lockfile hashes).
|
|
193
|
+
* Exposed on the port so build-time CLI commands (e.g. `rig dist rebuild-agent`)
|
|
194
|
+
* resolve it through the seam instead of importing isolation-plugin impl directly.
|
|
195
|
+
*/
|
|
196
|
+
computeRuntimeImageFingerprint(projectRoot: string): Promise<RuntimeImageFingerprint>;
|
|
197
|
+
/**
|
|
198
|
+
* Derive a short deterministic image id string from a fingerprint.
|
|
199
|
+
* Pure function; lives on the port alongside `computeRuntimeImageFingerprint`
|
|
200
|
+
* so callers only need the seam, not the impl.
|
|
201
|
+
*/
|
|
202
|
+
computeRuntimeImageId(fp: RuntimeImageFingerprint): string;
|
|
203
|
+
}
|
|
204
|
+
/** The capability `run` shape the plugin registers: a (lazy) backend factory. */
|
|
205
|
+
export type IsolationBackendCapabilityRun = () => IsolationBackend | Promise<IsolationBackend>;
|
|
206
|
+
/**
|
|
207
|
+
* The typed capability id the isolation backend plugin provides and the substrate
|
|
208
|
+
* requires. Phantom-typed with {@link IsolationBackend} so
|
|
209
|
+
* `defineCapability(ISOLATION_BACKEND)` resolves to the backend with no cast
|
|
210
|
+
* leaking to callers. Its string value is {@link ISOLATION_BACKEND_CAPABILITY_ID},
|
|
211
|
+
* so it indexes the same host entry.
|
|
212
|
+
*/
|
|
213
|
+
export declare const ISOLATION_BACKEND: CapabilityId<IsolationBackend>;
|
package/dist/src/isolation.js
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
// @bun
|
|
2
|
+
// packages/contracts/src/capability-id.ts
|
|
3
|
+
function makeCapabilityId(id) {
|
|
4
|
+
return id;
|
|
5
|
+
}
|
|
6
|
+
|
|
2
7
|
// packages/contracts/src/isolation.ts
|
|
3
8
|
var ISOLATION_BACKEND_CAPABILITY_ID = "isolation.backend";
|
|
9
|
+
var ISOLATION_BACKEND = makeCapabilityId(ISOLATION_BACKEND_CAPABILITY_ID);
|
|
4
10
|
export {
|
|
5
|
-
ISOLATION_BACKEND_CAPABILITY_ID
|
|
11
|
+
ISOLATION_BACKEND_CAPABILITY_ID,
|
|
12
|
+
ISOLATION_BACKEND
|
|
6
13
|
};
|
package/dist/src/kernel.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
2
|
import type { RigPlugin } from "./plugin";
|
|
3
|
+
import type { CapabilityId } from "./capability-id";
|
|
3
4
|
import { ResolvedPipeline, StageContext, StageDescriptor, StageMutation, StageResult, StageRunOutcome } from "./stage";
|
|
4
5
|
export declare const CapabilityTag: Schema.Literals<readonly ["kernel", "journal", "stage-runner", "transport", "loader-policy"]>;
|
|
5
6
|
export type CapabilityTag = typeof CapabilityTag.Type;
|
|
@@ -187,3 +188,13 @@ export interface BootResult {
|
|
|
187
188
|
capabilityProviderIds: Readonly<Record<CapabilityTag, string>>;
|
|
188
189
|
}
|
|
189
190
|
export type StageExecutor = (ctx: StageContext) => Promise<StageResult> | StageResult;
|
|
191
|
+
/**
|
|
192
|
+
* The placement-aware run transport capability id.
|
|
193
|
+
*
|
|
194
|
+
* @rig/transport-plugin provides this as a host-service capability (its impl
|
|
195
|
+
* wraps `createPlacementRunTransport`). @rig/run-exec resolves it via
|
|
196
|
+
* `loadCapabilityForRoot` and passes the result to `adopt()` — the SEAM-ONLY
|
|
197
|
+
* replacement for importing `createPlacementRunTransport` directly from
|
|
198
|
+
* @rig/transport-plugin impl (§6.4).
|
|
199
|
+
*/
|
|
200
|
+
export declare const PLACEMENT_RUN_TRANSPORT: CapabilityId<TransportCapability>;
|
package/dist/src/kernel.js
CHANGED
|
@@ -39,6 +39,11 @@ var ApprovalRequestId = makeEntityId("ApprovalRequestId");
|
|
|
39
39
|
var CheckpointRef = makeEntityId("CheckpointRef");
|
|
40
40
|
var RemoteEndpointId = makeEntityId("RemoteEndpointId");
|
|
41
41
|
|
|
42
|
+
// packages/contracts/src/capability-id.ts
|
|
43
|
+
function makeCapabilityId(id) {
|
|
44
|
+
return id;
|
|
45
|
+
}
|
|
46
|
+
|
|
42
47
|
// packages/contracts/src/stage.ts
|
|
43
48
|
import { Schema as Schema2 } from "effect";
|
|
44
49
|
var StageKind = Schema2.Literals(["transform", "gate", "observe"]);
|
|
@@ -232,8 +237,10 @@ var JournalEvent = Schema3.Struct({
|
|
|
232
237
|
at: IsoDateTime,
|
|
233
238
|
payload: Schema3.Unknown
|
|
234
239
|
});
|
|
240
|
+
var PLACEMENT_RUN_TRANSPORT = makeCapabilityId("transport.placement-run");
|
|
235
241
|
export {
|
|
236
242
|
PipelineUnresolvable,
|
|
243
|
+
PLACEMENT_RUN_TRANSPORT,
|
|
237
244
|
MissingCapability,
|
|
238
245
|
KernelResolutionRecord,
|
|
239
246
|
KernelReplacementGrant,
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/** Directory name for a project's checked-in rig definition (`<root>/rig`). */
|
|
2
|
+
export declare const RIG_DEFINITION_DIRNAME = "rig";
|
|
3
|
+
/** Directory name for rig's per-project state (`<root>/.rig`). */
|
|
4
|
+
export declare const RIG_STATE_DIRNAME = ".rig";
|
|
5
|
+
/** Directory name for run artifacts (`<workspace>/artifacts`). */
|
|
6
|
+
export declare const RIG_ARTIFACTS_DIRNAME = "artifacts";
|
|
7
|
+
export type RigLayout = {
|
|
8
|
+
projectRoot: string;
|
|
9
|
+
monorepoRoot: string;
|
|
10
|
+
definitionRoot: string;
|
|
11
|
+
runtimeWorkspaceRoot: string;
|
|
12
|
+
stateRoot: string;
|
|
13
|
+
artifactsRoot: string;
|
|
14
|
+
configPath: string;
|
|
15
|
+
taskConfigPath: string;
|
|
16
|
+
policyDir: string;
|
|
17
|
+
policyFile: string;
|
|
18
|
+
pluginsDir: string;
|
|
19
|
+
hooksDir: string;
|
|
20
|
+
toolsDir: string;
|
|
21
|
+
templatesDir: string;
|
|
22
|
+
validationDir: string;
|
|
23
|
+
stateDir: string;
|
|
24
|
+
logsDir: string;
|
|
25
|
+
notificationsDir: string;
|
|
26
|
+
runtimeDir: string;
|
|
27
|
+
distDir: string;
|
|
28
|
+
binDir: string;
|
|
29
|
+
pluginBinDir: string;
|
|
30
|
+
keybindingsPath: string;
|
|
31
|
+
controlPlaneEventsFile: string;
|
|
32
|
+
};
|
|
33
|
+
export type RuntimeWorkspaceLayout = {
|
|
34
|
+
workspaceDir: string;
|
|
35
|
+
rigRoot: string;
|
|
36
|
+
stateDir: string;
|
|
37
|
+
logsDir: string;
|
|
38
|
+
artifactsRoot: string;
|
|
39
|
+
runtimeDir: string;
|
|
40
|
+
homeDir: string;
|
|
41
|
+
tmpDir: string;
|
|
42
|
+
cacheDir: string;
|
|
43
|
+
sessionDir: string;
|
|
44
|
+
binDir: string;
|
|
45
|
+
distDir: string;
|
|
46
|
+
pluginBinDir: string;
|
|
47
|
+
contextPath: string;
|
|
48
|
+
controlPlaneEventsFile: string;
|
|
49
|
+
};
|
|
@@ -8,16 +8,31 @@
|
|
|
8
8
|
* `pluginHost.listExecutableCapabilities()`. These pure types are the shared
|
|
9
9
|
* contract for that seam — they carry no behaviour and import nothing.
|
|
10
10
|
*/
|
|
11
|
+
import type { CapabilityId } from "./capability-id";
|
|
12
|
+
import type { JournalCapability } from "./kernel";
|
|
13
|
+
import type { RigAutomationConfig, StrictPrGreptileApiOptions } from "./control-plane-types";
|
|
14
|
+
import type { RunCloseoutPhase, RunCloseoutPhaseOutcome } from "./run-journal";
|
|
11
15
|
/** Capability id the bundle registers its `taskVerify` orchestration under. */
|
|
12
16
|
export declare const TASK_VERIFY_CAPABILITY_ID = "default-lifecycle.task-verify";
|
|
13
17
|
/** Capability id the bundle registers the completion-verification gate under. */
|
|
14
18
|
export declare const COMPLETION_VERIFICATION_CAPABILITY_ID = "default-lifecycle.completion-verification";
|
|
19
|
+
/** Capability id the bundle registers its run-worker closeout driver under. */
|
|
20
|
+
export declare const RUN_CLOSEOUT_CAPABILITY_ID = "default-lifecycle.run-closeout";
|
|
21
|
+
/** Capability id the bundle registers its agent-facing git helper surface under. */
|
|
22
|
+
export declare const LIFECYCLE_GIT_AGENT_CAPABILITY_ID = "default-lifecycle.git-agent";
|
|
15
23
|
export interface TaskVerifyCapabilityInput {
|
|
16
24
|
readonly projectRoot: string;
|
|
17
25
|
readonly taskId?: string;
|
|
18
26
|
}
|
|
19
27
|
/** Resolves true when the task is approved, false when verification rejects. */
|
|
20
28
|
export type TaskVerifyCapabilityRun = (input: TaskVerifyCapabilityInput) => Promise<boolean>;
|
|
29
|
+
/**
|
|
30
|
+
* The typed capability id the bundle provides its task-verify run under, phantom-
|
|
31
|
+
* typed with {@link TaskVerifyCapabilityRun} so `defineCapability(TASK_VERIFY_CAPABILITY)`
|
|
32
|
+
* resolves to the run function with no cast leaking to callers. Its string value
|
|
33
|
+
* is {@link TASK_VERIFY_CAPABILITY_ID}, so it indexes the same host entry.
|
|
34
|
+
*/
|
|
35
|
+
export declare const TASK_VERIFY_CAPABILITY: CapabilityId<TaskVerifyCapabilityRun>;
|
|
21
36
|
export interface CompletionVerificationCapabilityInput {
|
|
22
37
|
readonly projectRoot: string;
|
|
23
38
|
readonly taskId?: string;
|
|
@@ -27,3 +42,87 @@ export interface CompletionVerificationCapabilityResult {
|
|
|
27
42
|
readonly ok: boolean;
|
|
28
43
|
}
|
|
29
44
|
export type CompletionVerificationCapabilityRun = (input: CompletionVerificationCapabilityInput) => Promise<CompletionVerificationCapabilityResult>;
|
|
45
|
+
/**
|
|
46
|
+
* The typed capability id the bundle provides its completion-verification gate
|
|
47
|
+
* under, phantom-typed with {@link CompletionVerificationCapabilityRun}. Its
|
|
48
|
+
* string value is {@link COMPLETION_VERIFICATION_CAPABILITY_ID}, so it indexes
|
|
49
|
+
* the same host entry.
|
|
50
|
+
*/
|
|
51
|
+
export declare const COMPLETION_VERIFICATION_CAPABILITY: CapabilityId<CompletionVerificationCapabilityRun>;
|
|
52
|
+
export type LifecycleGitCommitOptions = {
|
|
53
|
+
projectRoot: string;
|
|
54
|
+
taskId?: string;
|
|
55
|
+
target: "monorepo" | "project" | "both";
|
|
56
|
+
message?: string;
|
|
57
|
+
allowEmpty: boolean;
|
|
58
|
+
scoped?: boolean;
|
|
59
|
+
};
|
|
60
|
+
export type LifecycleGitOpenPrOptions = {
|
|
61
|
+
projectRoot: string;
|
|
62
|
+
taskId?: string;
|
|
63
|
+
target?: "monorepo" | "project";
|
|
64
|
+
reviewer?: string;
|
|
65
|
+
base?: string;
|
|
66
|
+
title?: string;
|
|
67
|
+
body?: string;
|
|
68
|
+
draft?: boolean;
|
|
69
|
+
};
|
|
70
|
+
export type LifecycleGitOpenPrResult = {
|
|
71
|
+
url: string;
|
|
72
|
+
reviewer?: string;
|
|
73
|
+
reviewerSource?: "flag" | "task-config" | "changed-files" | "env";
|
|
74
|
+
target: "monorepo" | "project";
|
|
75
|
+
repoLabel: string;
|
|
76
|
+
branch: string;
|
|
77
|
+
base: string;
|
|
78
|
+
};
|
|
79
|
+
export type LifecycleGitAgentService = {
|
|
80
|
+
shouldScopeGitCommit(args: string[], hasTaskContext: boolean): boolean;
|
|
81
|
+
gitStatus(projectRoot: string, taskId?: string): void;
|
|
82
|
+
gitChanged(projectRoot: string, taskId: string | undefined, scoped: boolean): string[];
|
|
83
|
+
gitPreflight(projectRoot: string, taskId: string | undefined, strict: boolean): boolean;
|
|
84
|
+
gitSyncBranch(projectRoot: string, taskId?: string, targetRepo?: "monorepo" | "project"): void;
|
|
85
|
+
gitCommit(options: LifecycleGitCommitOptions): void;
|
|
86
|
+
gitSnapshot(projectRoot: string, taskId?: string, outputPath?: string): string;
|
|
87
|
+
gitOpenPr(options: LifecycleGitOpenPrOptions): LifecycleGitOpenPrResult;
|
|
88
|
+
};
|
|
89
|
+
export declare const LIFECYCLE_GIT_AGENT: CapabilityId<LifecycleGitAgentService>;
|
|
90
|
+
export type RunTaskSourceReflectStatus = "under_review" | "ci_fixing" | "merging" | "closed" | "needs_attention";
|
|
91
|
+
export type RunCloseoutResultStatus = "merged" | "opened" | "skipped" | "needs-attention";
|
|
92
|
+
export type RunCloseoutResult = {
|
|
93
|
+
status: RunCloseoutResultStatus;
|
|
94
|
+
prUrl?: string;
|
|
95
|
+
iterations: number;
|
|
96
|
+
feedback: readonly string[];
|
|
97
|
+
};
|
|
98
|
+
export type RunCloseoutValidationInput = {
|
|
99
|
+
projectRoot: string;
|
|
100
|
+
taskId: string;
|
|
101
|
+
};
|
|
102
|
+
export type RunCloseoutValidationRunner = (input: RunCloseoutValidationInput) => Promise<boolean> | boolean;
|
|
103
|
+
export type RunCloseoutInput = {
|
|
104
|
+
projectRoot: string;
|
|
105
|
+
runId: string;
|
|
106
|
+
taskId: string;
|
|
107
|
+
branch: string;
|
|
108
|
+
workspace: string;
|
|
109
|
+
artifactRoot?: string | null;
|
|
110
|
+
config?: RigAutomationConfig | null;
|
|
111
|
+
sourceTask?: Record<string, unknown> | null;
|
|
112
|
+
steerPi: (message: string) => Promise<void>;
|
|
113
|
+
greptileApi?: StrictPrGreptileApiOptions;
|
|
114
|
+
runValidation?: RunCloseoutValidationRunner;
|
|
115
|
+
onValidationStart?: () => Promise<void> | void;
|
|
116
|
+
kernelJournal?: JournalCapability | null;
|
|
117
|
+
journalPhase: (phase: RunCloseoutPhase, outcome: RunCloseoutPhaseOutcome, detail?: string | null) => Promise<void> | void;
|
|
118
|
+
reflect: (status: RunTaskSourceReflectStatus, summary: string, options?: {
|
|
119
|
+
errorText?: string | null;
|
|
120
|
+
}) => Promise<void> | void;
|
|
121
|
+
};
|
|
122
|
+
export type RunCloseoutCapabilityRun = (input: RunCloseoutInput) => Promise<RunCloseoutResult>;
|
|
123
|
+
/**
|
|
124
|
+
* The typed capability id the bundle provides its run-worker closeout driver
|
|
125
|
+
* under, so @rig/run-worker can close out by resolving the lifecycle capability
|
|
126
|
+
* instead of importing the lifecycle plugin implementation.
|
|
127
|
+
*/
|
|
128
|
+
export declare const RUN_CLOSEOUT_CAPABILITY: CapabilityId<RunCloseoutCapabilityRun>;
|
|
@@ -1,8 +1,25 @@
|
|
|
1
1
|
// @bun
|
|
2
|
+
// packages/contracts/src/capability-id.ts
|
|
3
|
+
function makeCapabilityId(id) {
|
|
4
|
+
return id;
|
|
5
|
+
}
|
|
6
|
+
|
|
2
7
|
// packages/contracts/src/lifecycle-capabilities.ts
|
|
3
8
|
var TASK_VERIFY_CAPABILITY_ID = "default-lifecycle.task-verify";
|
|
4
9
|
var COMPLETION_VERIFICATION_CAPABILITY_ID = "default-lifecycle.completion-verification";
|
|
10
|
+
var RUN_CLOSEOUT_CAPABILITY_ID = "default-lifecycle.run-closeout";
|
|
11
|
+
var LIFECYCLE_GIT_AGENT_CAPABILITY_ID = "default-lifecycle.git-agent";
|
|
12
|
+
var TASK_VERIFY_CAPABILITY = makeCapabilityId(TASK_VERIFY_CAPABILITY_ID);
|
|
13
|
+
var COMPLETION_VERIFICATION_CAPABILITY = makeCapabilityId(COMPLETION_VERIFICATION_CAPABILITY_ID);
|
|
14
|
+
var LIFECYCLE_GIT_AGENT = makeCapabilityId(LIFECYCLE_GIT_AGENT_CAPABILITY_ID);
|
|
15
|
+
var RUN_CLOSEOUT_CAPABILITY = makeCapabilityId(RUN_CLOSEOUT_CAPABILITY_ID);
|
|
5
16
|
export {
|
|
6
17
|
TASK_VERIFY_CAPABILITY_ID,
|
|
7
|
-
|
|
18
|
+
TASK_VERIFY_CAPABILITY,
|
|
19
|
+
RUN_CLOSEOUT_CAPABILITY_ID,
|
|
20
|
+
RUN_CLOSEOUT_CAPABILITY,
|
|
21
|
+
LIFECYCLE_GIT_AGENT_CAPABILITY_ID,
|
|
22
|
+
LIFECYCLE_GIT_AGENT,
|
|
23
|
+
COMPLETION_VERIFICATION_CAPABILITY_ID,
|
|
24
|
+
COMPLETION_VERIFICATION_CAPABILITY
|
|
8
25
|
};
|
|
@@ -1,23 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Pure managed-repo contract types +
|
|
2
|
+
* Pure managed-repo and repo-operation contract types + capability ids.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* state-sync tracker-path resolver) resolves the service by this id from a
|
|
10
|
-
* plugin host built off the project's rig.config — exactly the seam shape of
|
|
11
|
-
* {@link MEMORY_SERVICE_CAPABILITY_ID} / ISOLATION_BACKEND_CAPABILITY_ID. This
|
|
12
|
-
* module carries no behaviour and imports only pure sibling types, so both the
|
|
13
|
-
* substrate and the plugin can reference these without a substrate->plugin
|
|
14
|
-
* import cycle.
|
|
4
|
+
* `@rig/repos-plugin` owns the concrete implementations. It contributes:
|
|
5
|
+
* - `ManagedRepoService` under {@link MANAGED_REPO_SERVICE_CAPABILITY_ID} for
|
|
6
|
+
* registry/layout/mirror state, and
|
|
7
|
+
* - `RepoOperationsService` under {@link REPO_OPERATIONS_CAPABILITY_ID} for
|
|
8
|
+
* task repo pinning, baseline reset, and project-main pre-run sync.
|
|
15
9
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* here.
|
|
10
|
+
* This module carries no behaviour and imports only pure sibling types, so
|
|
11
|
+
* consumers resolve typed ids through `@rig/core` without importing the provider
|
|
12
|
+
* plugin or the old kernel repo-ops facades.
|
|
20
13
|
*/
|
|
14
|
+
import type { CapabilityId } from "./capability-id";
|
|
21
15
|
import type { RepoSourceRegistration } from "./plugin";
|
|
22
16
|
export type ManagedRepoId = string;
|
|
23
17
|
export type ManagedRepoAlias = string;
|
|
@@ -69,5 +63,74 @@ export interface RepoRegistry {
|
|
|
69
63
|
getById(id: string): RepoEntry | undefined;
|
|
70
64
|
list(): readonly RepoEntry[];
|
|
71
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* The cohesive set of managed-repo operations the runtime substrate depends on.
|
|
68
|
+
* The plugin provides a concrete impl (statically checked against this interface
|
|
69
|
+
* via `defineCapability(MANAGED_REPO_SERVICE_CAPABILITY).provide`); the substrate
|
|
70
|
+
* only ever sees this port, resolved by id off a plugin host with no cast.
|
|
71
|
+
*/
|
|
72
|
+
export interface ManagedRepoService {
|
|
73
|
+
/** Replace the managed-repo singleton with the given entries (boot wiring). */
|
|
74
|
+
setManagedRepos(entries: readonly ManagedRepoRegistryEntry[]): void;
|
|
75
|
+
/** List the currently registered managed-repo entries. */
|
|
76
|
+
listManagedRepoEntries(): ManagedRepoRegistryEntry[];
|
|
77
|
+
/** Resolve a managed-repo id from its alias, or null when unknown. */
|
|
78
|
+
resolveManagedRepoIdByAlias(alias: string): ManagedRepoId | null;
|
|
79
|
+
/**
|
|
80
|
+
* Convert a plugin-contributed RepoSourceRegistration into the managed-repo
|
|
81
|
+
* entry shape; null for pure-listing registrations (no defaultBranch).
|
|
82
|
+
*/
|
|
83
|
+
repoRegistrationToManagedEntry(reg: RepoSourceRegistration): ManagedRepoRegistryEntry | null;
|
|
84
|
+
/** Build an immutable id-indexed registry from repo source registrations. */
|
|
85
|
+
createRepoRegistry(entries: readonly RepoSourceRegistration[]): RepoRegistry;
|
|
86
|
+
/** Resolve a managed repo's on-disk layout by alias, or null when unknown. */
|
|
87
|
+
resolveManagedRepoLayoutByAlias(projectRoot: string, alias: string): ManagedRepoLayout | null;
|
|
88
|
+
/** Resolve the primary monorepo layout; throws when no managed repos exist. */
|
|
89
|
+
resolveMonorepoRepoLayout(projectRoot: string): ManagedRepoLayout;
|
|
90
|
+
/** Refresh + sync a managed repo's mirror, returning the resulting head. */
|
|
91
|
+
syncManagedRepo(projectRoot: string, repoId: ManagedRepoId): ManagedRepoSyncResult;
|
|
92
|
+
}
|
|
93
|
+
export type RepoPins = Record<string, string>;
|
|
94
|
+
export type ProjectMainPreRunSyncResult = {
|
|
95
|
+
status: "disabled";
|
|
96
|
+
} | {
|
|
97
|
+
status: "skipped_not_main";
|
|
98
|
+
branch: string;
|
|
99
|
+
} | {
|
|
100
|
+
status: "up_to_date";
|
|
101
|
+
} | {
|
|
102
|
+
status: "local_ahead";
|
|
103
|
+
localAhead: number;
|
|
104
|
+
} | {
|
|
105
|
+
status: "updated";
|
|
106
|
+
remoteAhead: number;
|
|
107
|
+
};
|
|
108
|
+
export type ProjectMainPreRunSyncOptions = {
|
|
109
|
+
projectRoot: string;
|
|
110
|
+
disabled?: boolean;
|
|
111
|
+
runBootstrap: () => Promise<void>;
|
|
112
|
+
syncMonorepo?: (projectRoot: string) => void | Promise<void>;
|
|
113
|
+
};
|
|
114
|
+
export interface RepoOperationsService {
|
|
115
|
+
repoEnsure(projectRoot: string, taskId?: string): void;
|
|
116
|
+
repoPins(projectRoot: string, taskId?: string): RepoPins;
|
|
117
|
+
repoVerify(projectRoot: string, taskId?: string): boolean;
|
|
118
|
+
repoDiscover(projectRoot: string, taskId?: string): RepoPins;
|
|
119
|
+
repoBaseline(projectRoot: string, refresh?: boolean): RepoPins;
|
|
120
|
+
resetBaseline(projectRoot: string, keepTaskStatus: boolean): void;
|
|
121
|
+
ensureProjectMainFreshBeforeRun(options: ProjectMainPreRunSyncOptions): Promise<ProjectMainPreRunSyncResult>;
|
|
122
|
+
}
|
|
123
|
+
export declare const REPO_OPERATIONS_CAPABILITY_ID = "repos.operations";
|
|
124
|
+
export declare const REPO_OPERATIONS_CAPABILITY: CapabilityId<RepoOperationsService>;
|
|
125
|
+
/** The capability `run` shape the plugin registers: a (lazy) service factory. */
|
|
126
|
+
export type ManagedRepoServiceCapabilityRun = () => ManagedRepoService | Promise<ManagedRepoService>;
|
|
72
127
|
/** Capability id the managed-repo service plugin registers its factory under. */
|
|
73
128
|
export declare const MANAGED_REPO_SERVICE_CAPABILITY_ID = "managed-repos.service";
|
|
129
|
+
/**
|
|
130
|
+
* The typed capability id the repos plugin provides and consumers require.
|
|
131
|
+
* Phantom-typed with {@link ManagedRepoService} so
|
|
132
|
+
* `defineCapability(MANAGED_REPO_SERVICE_CAPABILITY).resolve(host)` returns a
|
|
133
|
+
* `ManagedRepoService` with no cast leaking to callers. Its string value is
|
|
134
|
+
* {@link MANAGED_REPO_SERVICE_CAPABILITY_ID}, so it indexes the same host entry.
|
|
135
|
+
*/
|
|
136
|
+
export declare const MANAGED_REPO_SERVICE_CAPABILITY: CapabilityId<ManagedRepoService>;
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
// @bun
|
|
2
|
+
// packages/contracts/src/capability-id.ts
|
|
3
|
+
function makeCapabilityId(id) {
|
|
4
|
+
return id;
|
|
5
|
+
}
|
|
6
|
+
|
|
2
7
|
// packages/contracts/src/managed-repos.ts
|
|
8
|
+
var REPO_OPERATIONS_CAPABILITY_ID = "repos.operations";
|
|
9
|
+
var REPO_OPERATIONS_CAPABILITY = makeCapabilityId(REPO_OPERATIONS_CAPABILITY_ID);
|
|
3
10
|
var MANAGED_REPO_SERVICE_CAPABILITY_ID = "managed-repos.service";
|
|
11
|
+
var MANAGED_REPO_SERVICE_CAPABILITY = makeCapabilityId(MANAGED_REPO_SERVICE_CAPABILITY_ID);
|
|
4
12
|
export {
|
|
5
|
-
|
|
13
|
+
REPO_OPERATIONS_CAPABILITY_ID,
|
|
14
|
+
REPO_OPERATIONS_CAPABILITY,
|
|
15
|
+
MANAGED_REPO_SERVICE_CAPABILITY_ID,
|
|
16
|
+
MANAGED_REPO_SERVICE_CAPABILITY
|
|
6
17
|
};
|