@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.
- package/dist/index.cjs +3442 -0
- package/dist/index.mjs +3401 -0
- package/dist/src/agent-roles.d.ts +8 -0
- package/dist/src/artifact.d.ts +13 -0
- package/dist/src/artifact.js +3 -0
- package/dist/src/baseSchemas.d.ts +63 -0
- package/dist/src/baseSchemas.js +6 -0
- package/dist/src/blocker-classifier.d.ts +21 -0
- package/dist/src/blocker-classifier.js +13 -0
- package/dist/src/browser.d.ts +80 -0
- package/dist/src/browser.js +13 -0
- package/dist/src/capability-id.d.ts +22 -0
- package/dist/src/capability-id.js +8 -0
- package/dist/src/cli-output.d.ts +348 -0
- package/dist/src/cli-output.js +190 -0
- package/dist/src/cli-runner.d.ts +43 -0
- package/dist/src/cli-runner.js +13 -0
- package/dist/src/cockpit.d.ts +58 -0
- package/dist/src/cockpit.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 +553 -0
- package/dist/src/config.js +767 -162
- package/dist/src/control-plane-types.d.ts +323 -0
- package/dist/src/control-plane-types.js +13 -0
- package/dist/src/conversation.d.ts +50 -0
- package/dist/src/conversation.js +3 -0
- package/dist/src/dependency-preflight.d.ts +43 -0
- package/dist/src/dependency-preflight.js +13 -0
- package/dist/src/docs-drift.d.ts +10 -0
- package/dist/src/docs-drift.js +12 -0
- package/dist/src/doctor.d.ts +90 -0
- package/dist/src/doctor.js +13 -0
- package/dist/src/drift.d.ts +28 -0
- package/dist/src/drift.js +69 -0
- package/dist/src/editor.d.ts +25 -0
- package/dist/src/editor.js +3 -0
- package/dist/src/errors.d.ts +13 -0
- package/dist/src/errors.js +17 -0
- package/dist/src/git.d.ts +152 -0
- package/dist/src/git.js +3 -0
- package/dist/src/github.d.ts +295 -0
- package/dist/src/github.js +17 -0
- package/dist/src/graph.d.ts +360 -0
- package/dist/src/graph.js +137 -1
- package/dist/src/guard.d.ts +118 -0
- package/dist/src/guard.js +15 -0
- package/dist/src/harness-events.d.ts +8 -0
- package/dist/src/harness-events.js +1 -0
- package/dist/src/harness-profile-state.d.ts +10 -0
- package/dist/src/harness-profile-state.js +13 -0
- package/dist/src/help-catalog.d.ts +41 -0
- package/dist/src/help-catalog.js +13 -0
- 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 +98 -0
- package/dist/src/index.js +2605 -3752
- package/dist/src/isolation.d.ts +213 -0
- package/dist/src/isolation.js +13 -0
- package/dist/src/kernel.d.ts +200 -0
- package/dist/src/kernel.js +261 -0
- package/dist/src/keybindings.d.ts +71 -0
- package/dist/src/keybindings.js +3 -0
- package/dist/src/layout.d.ts +44 -0
- package/dist/src/layout.js +8 -0
- package/dist/src/lifecycle-capabilities.d.ts +224 -0
- package/dist/src/lifecycle-capabilities.js +45 -0
- package/dist/src/managed-repos.d.ts +339 -0
- package/dist/src/managed-repos.js +37 -0
- package/dist/src/memory.d.ts +199 -0
- package/dist/src/memory.js +15 -0
- package/dist/src/model.d.ts +13 -0
- package/dist/src/model.js +3 -58
- package/dist/src/native-toolchain.d.ts +46 -0
- package/dist/src/native-toolchain.js +13 -0
- package/dist/src/notify.d.ts +46 -0
- package/dist/src/notify.js +13 -0
- package/dist/src/orchestration.d.ts +43 -0
- package/dist/src/orchestration.js +28 -961
- package/dist/src/panel-protocol.d.ts +17 -0
- package/dist/src/panel-protocol.js +10 -0
- package/dist/src/pi-session.d.ts +113 -0
- package/dist/src/pi-session.js +1 -0
- package/dist/src/placement.d.ts +47 -0
- package/dist/src/placement.js +13 -0
- package/dist/src/planning.d.ts +64 -0
- package/dist/src/planning.js +90 -0
- package/dist/src/plugin-hooks.d.ts +51 -0
- package/dist/src/plugin-hooks.js +386 -0
- package/dist/src/plugin.d.ts +476 -0
- package/dist/src/plugin.js +346 -64
- package/dist/src/policy.d.ts +16 -0
- package/dist/src/policy.js +3 -0
- package/dist/src/product-entrypoint.d.ts +22 -0
- package/dist/src/product-entrypoint.js +13 -0
- package/dist/src/project.d.ts +71 -0
- package/dist/src/project.js +3 -0
- package/dist/src/prompt.d.ts +29 -0
- package/dist/src/prompt.js +13 -0
- package/dist/src/protocol-version.d.ts +21 -0
- package/dist/src/protocol-version.js +6 -0
- package/dist/src/provider-instructions.d.ts +41 -0
- package/dist/src/provider-instructions.js +13 -0
- package/dist/src/provider.d.ts +105 -0
- package/dist/src/provider.js +16 -835
- package/dist/src/remote-control.d.ts +93 -0
- package/dist/src/remote-control.js +26 -0
- package/dist/src/remote.d.ts +318 -0
- package/dist/src/remote.js +238 -1078
- package/dist/src/review.d.ts +18 -0
- package/dist/src/review.js +3 -0
- package/dist/src/rollups.d.ts +41 -0
- package/dist/src/rollups.js +70 -0
- package/dist/src/run-control.d.ts +164 -0
- package/dist/src/run-control.js +13 -0
- package/dist/src/run-discovery.d.ts +83 -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 +694 -0
- package/dist/src/run-journal.js +569 -0
- package/dist/src/run-queue.d.ts +36 -0
- package/dist/src/run-queue.js +13 -0
- package/dist/src/run-read-model.d.ts +200 -0
- package/dist/src/run-read-model.js +13 -0
- package/dist/src/run-record.d.ts +45 -0
- package/dist/src/run-record.js +1 -0
- 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 +154 -0
- package/dist/src/run-session-journal.js +87 -0
- package/dist/src/run-status.d.ts +10 -0
- package/dist/src/run-status.js +27 -0
- package/dist/src/run-timeline.d.ts +7 -0
- package/dist/src/run-timeline.js +1 -0
- package/dist/src/runtime-secrets.d.ts +10 -0
- package/dist/src/runtime-secrets.js +13 -0
- package/dist/src/runtime-task-context.d.ts +82 -0
- package/dist/src/runtime-task-context.js +1 -0
- package/dist/src/runtime.d.ts +103 -0
- package/dist/src/runtime.js +73 -906
- package/dist/src/session-asset-materializer.d.ts +35 -0
- package/dist/src/session-asset-materializer.js +13 -0
- package/dist/src/session-hook-materializer.d.ts +41 -0
- package/dist/src/session-hook-materializer.js +13 -0
- package/dist/src/setup.d.ts +154 -0
- package/dist/src/setup.js +13 -0
- package/dist/src/stage.d.ts +245 -0
- package/dist/src/stage.js +169 -0
- package/dist/src/supervisor-journal.d.ts +204 -0
- package/dist/src/supervisor-journal.js +336 -0
- package/dist/src/supervisor-loop.d.ts +40 -0
- package/dist/src/supervisor-loop.js +13 -0
- package/dist/src/task-artifacts.d.ts +53 -0
- package/dist/src/task-artifacts.js +13 -0
- package/dist/src/task-config.d.ts +22 -0
- package/dist/src/task-config.js +1 -0
- package/dist/src/task-context-renderer.d.ts +29 -0
- package/dist/src/task-context-renderer.js +13 -0
- package/dist/src/task-data.d.ts +196 -0
- package/dist/src/task-data.js +13 -0
- package/dist/src/task-graph-primitives.d.ts +47 -0
- package/dist/src/task-graph-primitives.js +1 -0
- package/dist/src/task-source.d.ts +167 -0
- package/dist/src/task-source.js +24 -0
- package/dist/src/task-state-metadata.d.ts +21 -0
- package/dist/src/task-state-metadata.js +1 -0
- package/dist/src/task-state-paths.d.ts +14 -0
- package/dist/src/task-state-paths.js +13 -0
- package/dist/src/task-state-store.d.ts +36 -0
- package/dist/src/task-state-store.js +17 -0
- package/dist/src/task-tracker-state.d.ts +101 -0
- package/dist/src/task-tracker-state.js +39 -0
- package/dist/src/terminal.d.ts +130 -0
- package/dist/src/terminal.js +3 -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/transport-config.d.ts +161 -0
- package/dist/src/transport-config.js +15 -0
- package/dist/src/validation.d.ts +14 -0
- package/dist/src/validation.js +3 -0
- package/dist/src/workflow-journal.d.ts +125 -0
- package/dist/src/workflow-journal.js +27 -0
- package/dist/src/workspace-config.d.ts +18 -0
- package/dist/src/workspace-config.js +13 -0
- package/dist/src/workspace-service.d.ts +16 -0
- package/dist/src/workspace-service.js +13 -0
- package/dist/src/workspace.d.ts +204 -0
- package/dist/src/workspace.js +76 -911
- package/package.json +55 -4
- package/dist/src/engine.js +0 -2278
- package/dist/src/providerRuntime.js +0 -1630
- package/dist/src/rig.js +0 -2374
- package/dist/src/server.js +0 -1053
- package/dist/src/serviceFabric.js +0 -1066
- package/dist/src/ws.js +0 -2968
- /package/dist/src/{ipc.js → agent-roles.js} +0 -0
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure isolation-backend contract vocab.
|
|
3
|
+
*
|
|
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.
|
|
15
|
+
*
|
|
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
|
+
*/
|
|
20
|
+
import type { CapabilityId } from "./capability-id";
|
|
21
|
+
import type { TaskRecord } from "./task-source";
|
|
22
|
+
import type { IsolationMode } from "./runtime";
|
|
23
|
+
/** Capability id the isolation backend plugin registers its factory under. */
|
|
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>;
|
|
@@ -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/isolation.ts
|
|
8
|
+
var ISOLATION_BACKEND_CAPABILITY_ID = "isolation.backend";
|
|
9
|
+
var ISOLATION_BACKEND = makeCapabilityId(ISOLATION_BACKEND_CAPABILITY_ID);
|
|
10
|
+
export {
|
|
11
|
+
ISOLATION_BACKEND_CAPABILITY_ID,
|
|
12
|
+
ISOLATION_BACKEND
|
|
13
|
+
};
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import type { RigPlugin } from "./plugin";
|
|
3
|
+
import type { CapabilityId } from "./capability-id";
|
|
4
|
+
import { ResolvedPipeline, StageContext, StageDescriptor, StageMutation, StageResult, StageRunOutcome } from "./stage";
|
|
5
|
+
export declare const CapabilityTag: Schema.Literals<readonly ["kernel", "journal", "stage-runner", "transport", "loader-policy"]>;
|
|
6
|
+
export type CapabilityTag = typeof CapabilityTag.Type;
|
|
7
|
+
export declare const CapabilityProviderRef: Schema.Struct<{
|
|
8
|
+
readonly capability: Schema.Literals<readonly ["kernel", "journal", "stage-runner", "transport", "loader-policy"]>;
|
|
9
|
+
readonly pluginId: Schema.Trim;
|
|
10
|
+
}>;
|
|
11
|
+
export type CapabilityProviderRef = typeof CapabilityProviderRef.Type;
|
|
12
|
+
export declare const CapabilityReplacement: Schema.Struct<{
|
|
13
|
+
readonly capability: Schema.Literals<readonly ["kernel", "journal", "stage-runner", "transport", "loader-policy"]>;
|
|
14
|
+
readonly providerPluginId: Schema.Trim;
|
|
15
|
+
}>;
|
|
16
|
+
export type CapabilityReplacement = typeof CapabilityReplacement.Type;
|
|
17
|
+
export declare const CapabilityReplacementSpec: Schema.Union<readonly [Schema.Struct<{
|
|
18
|
+
readonly capability: Schema.Literals<readonly ["kernel", "journal", "stage-runner", "transport", "loader-policy"]>;
|
|
19
|
+
readonly providerPluginId: Schema.Trim;
|
|
20
|
+
}>, Schema.Trim]>;
|
|
21
|
+
export type CapabilityReplacementSpec = typeof CapabilityReplacementSpec.Type;
|
|
22
|
+
export declare const KernelReplacementGrant: Schema.Struct<{
|
|
23
|
+
readonly pluginId: Schema.Trim;
|
|
24
|
+
readonly grantedBy: Schema.optional<Schema.Trim>;
|
|
25
|
+
readonly reason: Schema.optional<Schema.String>;
|
|
26
|
+
}>;
|
|
27
|
+
export type KernelReplacementGrant = typeof KernelReplacementGrant.Type;
|
|
28
|
+
export declare const CapabilityGrants: Schema.Struct<{
|
|
29
|
+
readonly capabilityPrecedence: Schema.optional<Schema.$Record<Schema.String, Schema.$Array<Schema.Trim>>>;
|
|
30
|
+
readonly kernelReplacementGrants: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
31
|
+
readonly pluginId: Schema.Trim;
|
|
32
|
+
readonly grantedBy: Schema.optional<Schema.Trim>;
|
|
33
|
+
readonly reason: Schema.optional<Schema.String>;
|
|
34
|
+
}>>>;
|
|
35
|
+
}>;
|
|
36
|
+
export type CapabilityGrants = typeof CapabilityGrants.Type;
|
|
37
|
+
export declare const KernelBootErrorCode: Schema.Literals<readonly ["BootIncoherent", "AmbiguousCapability", "MissingCapability", "KernelReplacementDenied", "PipelineUnresolvable"]>;
|
|
38
|
+
export type KernelBootErrorCode = typeof KernelBootErrorCode.Type;
|
|
39
|
+
export declare const KernelBootError: Schema.Struct<{
|
|
40
|
+
readonly code: Schema.Literals<readonly ["BootIncoherent", "AmbiguousCapability", "MissingCapability", "KernelReplacementDenied", "PipelineUnresolvable"]>;
|
|
41
|
+
readonly message: Schema.Trim;
|
|
42
|
+
readonly capability: Schema.optional<Schema.Literals<readonly ["kernel", "journal", "stage-runner", "transport", "loader-policy"]>>;
|
|
43
|
+
readonly stageId: Schema.optional<Schema.Trim>;
|
|
44
|
+
readonly pluginIds: Schema.optional<Schema.$Array<Schema.Trim>>;
|
|
45
|
+
}>;
|
|
46
|
+
export type KernelBootError = typeof KernelBootError.Type;
|
|
47
|
+
export declare class BootIncoherent extends Error {
|
|
48
|
+
readonly code = "BootIncoherent";
|
|
49
|
+
}
|
|
50
|
+
export declare class AmbiguousCapability extends Error {
|
|
51
|
+
readonly code = "AmbiguousCapability";
|
|
52
|
+
}
|
|
53
|
+
export declare class MissingCapability extends Error {
|
|
54
|
+
readonly code = "MissingCapability";
|
|
55
|
+
}
|
|
56
|
+
export declare class KernelReplacementDenied extends Error {
|
|
57
|
+
readonly code = "KernelReplacementDenied";
|
|
58
|
+
}
|
|
59
|
+
export declare class PipelineUnresolvable extends Error {
|
|
60
|
+
readonly code = "PipelineUnresolvable";
|
|
61
|
+
}
|
|
62
|
+
export declare const CapabilityResolutionStatus: Schema.Literals<readonly ["resolved", "ambiguous", "missing", "replaced"]>;
|
|
63
|
+
export type CapabilityResolutionStatus = typeof CapabilityResolutionStatus.Type;
|
|
64
|
+
export declare const CapabilityResolutionRecord: Schema.Struct<{
|
|
65
|
+
readonly capability: Schema.Literals<readonly ["kernel", "journal", "stage-runner", "transport", "loader-policy"]>;
|
|
66
|
+
readonly status: Schema.Literals<readonly ["resolved", "ambiguous", "missing", "replaced"]>;
|
|
67
|
+
readonly selectedPluginId: Schema.NullOr<Schema.Trim>;
|
|
68
|
+
readonly candidatePluginIds: Schema.$Array<Schema.Trim>;
|
|
69
|
+
readonly precedenceUsed: Schema.Boolean;
|
|
70
|
+
readonly replacementUsed: Schema.optional<Schema.Struct<{
|
|
71
|
+
readonly capability: Schema.Literals<readonly ["kernel", "journal", "stage-runner", "transport", "loader-policy"]>;
|
|
72
|
+
readonly providerPluginId: Schema.Trim;
|
|
73
|
+
}>>;
|
|
74
|
+
readonly error: Schema.optional<Schema.String>;
|
|
75
|
+
}>;
|
|
76
|
+
export type CapabilityResolutionRecord = typeof CapabilityResolutionRecord.Type;
|
|
77
|
+
export declare const KernelResolutionRecord: Schema.Struct<{
|
|
78
|
+
readonly resolvedAt: Schema.String;
|
|
79
|
+
readonly capabilities: Schema.$Array<Schema.Struct<{
|
|
80
|
+
readonly capability: Schema.Literals<readonly ["kernel", "journal", "stage-runner", "transport", "loader-policy"]>;
|
|
81
|
+
readonly status: Schema.Literals<readonly ["resolved", "ambiguous", "missing", "replaced"]>;
|
|
82
|
+
readonly selectedPluginId: Schema.NullOr<Schema.Trim>;
|
|
83
|
+
readonly candidatePluginIds: Schema.$Array<Schema.Trim>;
|
|
84
|
+
readonly precedenceUsed: Schema.Boolean;
|
|
85
|
+
readonly replacementUsed: Schema.optional<Schema.Struct<{
|
|
86
|
+
readonly capability: Schema.Literals<readonly ["kernel", "journal", "stage-runner", "transport", "loader-policy"]>;
|
|
87
|
+
readonly providerPluginId: Schema.Trim;
|
|
88
|
+
}>>;
|
|
89
|
+
readonly error: Schema.optional<Schema.String>;
|
|
90
|
+
}>>;
|
|
91
|
+
readonly pipeline: Schema.optional<Schema.Struct<{
|
|
92
|
+
readonly runId: Schema.optional<Schema.brand<Schema.Trim, "RunId">>;
|
|
93
|
+
readonly order: Schema.$Array<Schema.brand<Schema.Trim, "StageId">>;
|
|
94
|
+
readonly record: Schema.$Array<Schema.Struct<{
|
|
95
|
+
readonly stageId: Schema.brand<Schema.Trim, "StageId">;
|
|
96
|
+
readonly contributedBy: Schema.Trim;
|
|
97
|
+
readonly removedBy: Schema.optional<Schema.Trim>;
|
|
98
|
+
readonly replacedBy: Schema.optional<Schema.Trim>;
|
|
99
|
+
readonly wrappedBy: Schema.optional<Schema.$Array<Schema.Trim>>;
|
|
100
|
+
readonly droppedAnchors: Schema.optional<Schema.$Array<Schema.brand<Schema.Trim, "StageId">>>;
|
|
101
|
+
readonly isProtected: Schema.Boolean;
|
|
102
|
+
}>>;
|
|
103
|
+
readonly cycles: Schema.$Array<Schema.$Array<Schema.brand<Schema.Trim, "StageId">>>;
|
|
104
|
+
readonly grantUses: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
105
|
+
readonly kind: Schema.Literal<"kernel-replacement">;
|
|
106
|
+
readonly target: Schema.Trim;
|
|
107
|
+
readonly pluginId: Schema.Trim;
|
|
108
|
+
}>>>;
|
|
109
|
+
readonly resolvedAt: Schema.optional<Schema.String>;
|
|
110
|
+
}>>;
|
|
111
|
+
}>;
|
|
112
|
+
export type KernelResolutionRecord = typeof KernelResolutionRecord.Type;
|
|
113
|
+
export declare const BootResultDescriptor: Schema.Struct<{
|
|
114
|
+
readonly kernelPluginId: Schema.Trim;
|
|
115
|
+
readonly pluginIds: Schema.$Array<Schema.Trim>;
|
|
116
|
+
readonly resolution: Schema.Struct<{
|
|
117
|
+
readonly resolvedAt: Schema.String;
|
|
118
|
+
readonly capabilities: Schema.$Array<Schema.Struct<{
|
|
119
|
+
readonly capability: Schema.Literals<readonly ["kernel", "journal", "stage-runner", "transport", "loader-policy"]>;
|
|
120
|
+
readonly status: Schema.Literals<readonly ["resolved", "ambiguous", "missing", "replaced"]>;
|
|
121
|
+
readonly selectedPluginId: Schema.NullOr<Schema.Trim>;
|
|
122
|
+
readonly candidatePluginIds: Schema.$Array<Schema.Trim>;
|
|
123
|
+
readonly precedenceUsed: Schema.Boolean;
|
|
124
|
+
readonly replacementUsed: Schema.optional<Schema.Struct<{
|
|
125
|
+
readonly capability: Schema.Literals<readonly ["kernel", "journal", "stage-runner", "transport", "loader-policy"]>;
|
|
126
|
+
readonly providerPluginId: Schema.Trim;
|
|
127
|
+
}>>;
|
|
128
|
+
readonly error: Schema.optional<Schema.String>;
|
|
129
|
+
}>>;
|
|
130
|
+
readonly pipeline: Schema.optional<Schema.Struct<{
|
|
131
|
+
readonly runId: Schema.optional<Schema.brand<Schema.Trim, "RunId">>;
|
|
132
|
+
readonly order: Schema.$Array<Schema.brand<Schema.Trim, "StageId">>;
|
|
133
|
+
readonly record: Schema.$Array<Schema.Struct<{
|
|
134
|
+
readonly stageId: Schema.brand<Schema.Trim, "StageId">;
|
|
135
|
+
readonly contributedBy: Schema.Trim;
|
|
136
|
+
readonly removedBy: Schema.optional<Schema.Trim>;
|
|
137
|
+
readonly replacedBy: Schema.optional<Schema.Trim>;
|
|
138
|
+
readonly wrappedBy: Schema.optional<Schema.$Array<Schema.Trim>>;
|
|
139
|
+
readonly droppedAnchors: Schema.optional<Schema.$Array<Schema.brand<Schema.Trim, "StageId">>>;
|
|
140
|
+
readonly isProtected: Schema.Boolean;
|
|
141
|
+
}>>;
|
|
142
|
+
readonly cycles: Schema.$Array<Schema.$Array<Schema.brand<Schema.Trim, "StageId">>>;
|
|
143
|
+
readonly grantUses: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
144
|
+
readonly kind: Schema.Literal<"kernel-replacement">;
|
|
145
|
+
readonly target: Schema.Trim;
|
|
146
|
+
readonly pluginId: Schema.Trim;
|
|
147
|
+
}>>>;
|
|
148
|
+
readonly resolvedAt: Schema.optional<Schema.String>;
|
|
149
|
+
}>>;
|
|
150
|
+
}>;
|
|
151
|
+
}>;
|
|
152
|
+
export type BootResultDescriptor = typeof BootResultDescriptor.Type;
|
|
153
|
+
export declare const JournalEvent: Schema.Struct<{
|
|
154
|
+
readonly type: Schema.Trim;
|
|
155
|
+
readonly runId: Schema.optional<Schema.brand<Schema.Trim, "RunId">>;
|
|
156
|
+
readonly at: Schema.String;
|
|
157
|
+
readonly payload: Schema.Unknown;
|
|
158
|
+
}>;
|
|
159
|
+
export type JournalEvent = typeof JournalEvent.Type;
|
|
160
|
+
export interface JournalCapability {
|
|
161
|
+
append(event: unknown): Promise<void>;
|
|
162
|
+
recordPipeline(runId: string, pipeline: ResolvedPipeline): Promise<void>;
|
|
163
|
+
recordStageOutcome?(runId: string, outcome: StageRunOutcome): Promise<void>;
|
|
164
|
+
read(runId: string): Promise<readonly unknown[]>;
|
|
165
|
+
}
|
|
166
|
+
export interface StageRunnerCapability {
|
|
167
|
+
resolve(defaultStages: readonly StageDescriptor[], mutations: readonly StageMutation[], grants?: CapabilityGrants): ResolvedPipeline;
|
|
168
|
+
runPipeline(runId: string, resolved: ResolvedPipeline, ctx: StageContext): Promise<readonly StageRunOutcome[]>;
|
|
169
|
+
}
|
|
170
|
+
export interface TransportCapability {
|
|
171
|
+
dispatch(task: unknown, options?: unknown): Promise<string>;
|
|
172
|
+
attach?(runId: string): Promise<unknown>;
|
|
173
|
+
serve?(): Promise<void>;
|
|
174
|
+
}
|
|
175
|
+
export interface LoaderPolicyCapability {
|
|
176
|
+
resolveCapability(plugins: readonly RigPlugin[], capability: CapabilityTag, grants?: CapabilityGrants): CapabilityResolutionRecord;
|
|
177
|
+
}
|
|
178
|
+
export interface KernelCapability {
|
|
179
|
+
journal: JournalCapability;
|
|
180
|
+
stageRunner: StageRunnerCapability;
|
|
181
|
+
transport: TransportCapability;
|
|
182
|
+
loaderPolicy: LoaderPolicyCapability;
|
|
183
|
+
start(plugins: readonly unknown[]): Promise<void>;
|
|
184
|
+
}
|
|
185
|
+
export interface BootResult {
|
|
186
|
+
kernel: KernelCapability;
|
|
187
|
+
plugins: readonly RigPlugin[];
|
|
188
|
+
capabilityProviderIds: Readonly<Record<CapabilityTag, string>>;
|
|
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>;
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// packages/contracts/src/kernel.ts
|
|
3
|
+
import { Schema as Schema3 } from "effect";
|
|
4
|
+
|
|
5
|
+
// packages/contracts/src/baseSchemas.ts
|
|
6
|
+
import { Schema } from "effect";
|
|
7
|
+
var TrimmedString = Schema.Trim;
|
|
8
|
+
var TrimmedNonEmptyString = TrimmedString.check(Schema.isNonEmpty());
|
|
9
|
+
var NonNegativeInt = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));
|
|
10
|
+
var PositiveInt = Schema.Int.check(Schema.isGreaterThanOrEqualTo(1));
|
|
11
|
+
var IsoDateTime = Schema.String;
|
|
12
|
+
var makeEntityId = (brand) => TrimmedNonEmptyString.pipe(Schema.brand(brand));
|
|
13
|
+
var ThreadId = makeEntityId("ThreadId");
|
|
14
|
+
var ProjectId = makeEntityId("ProjectId");
|
|
15
|
+
var WorkspaceId = makeEntityId("WorkspaceId");
|
|
16
|
+
var GraphId = makeEntityId("GraphId");
|
|
17
|
+
var TaskId = makeEntityId("TaskId");
|
|
18
|
+
var RunId = makeEntityId("RunId");
|
|
19
|
+
var SafePathSegment = TrimmedNonEmptyString.check(Schema.isPattern(/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/)).pipe(Schema.brand("SafePathSegment"));
|
|
20
|
+
var SafeRunId = TrimmedNonEmptyString.check(Schema.isPattern(/^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/)).pipe(Schema.brand("SafeRunId"));
|
|
21
|
+
var SafeGitRefComponent = TrimmedNonEmptyString.check(Schema.isPattern(/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/)).pipe(Schema.brand("SafeGitRefComponent"));
|
|
22
|
+
var EngineRuntimeId = makeEntityId("EngineRuntimeId");
|
|
23
|
+
var ConversationId = makeEntityId("ConversationId");
|
|
24
|
+
var ActionId = makeEntityId("ActionId");
|
|
25
|
+
var ArtifactId = makeEntityId("ArtifactId");
|
|
26
|
+
var WorktreeId = makeEntityId("WorktreeId");
|
|
27
|
+
var ValidationResultId = makeEntityId("ValidationResultId");
|
|
28
|
+
var ReviewResultId = makeEntityId("ReviewResultId");
|
|
29
|
+
var CommandId = makeEntityId("CommandId");
|
|
30
|
+
var EventId = makeEntityId("EventId");
|
|
31
|
+
var MessageId = makeEntityId("MessageId");
|
|
32
|
+
var TurnId = makeEntityId("TurnId");
|
|
33
|
+
var ProviderItemId = makeEntityId("ProviderItemId");
|
|
34
|
+
var RuntimeSessionId = makeEntityId("RuntimeSessionId");
|
|
35
|
+
var RuntimeItemId = makeEntityId("RuntimeItemId");
|
|
36
|
+
var RuntimeRequestId = makeEntityId("RuntimeRequestId");
|
|
37
|
+
var RuntimeTaskId = makeEntityId("RuntimeTaskId");
|
|
38
|
+
var ApprovalRequestId = makeEntityId("ApprovalRequestId");
|
|
39
|
+
var CheckpointRef = makeEntityId("CheckpointRef");
|
|
40
|
+
var RemoteEndpointId = makeEntityId("RemoteEndpointId");
|
|
41
|
+
|
|
42
|
+
// packages/contracts/src/capability-id.ts
|
|
43
|
+
function makeCapabilityId(id) {
|
|
44
|
+
return id;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// packages/contracts/src/stage.ts
|
|
48
|
+
import { Schema as Schema2 } from "effect";
|
|
49
|
+
var StageKind = Schema2.Literals(["transform", "gate", "observe"]);
|
|
50
|
+
var StageId = TrimmedNonEmptyString.pipe(Schema2.brand("StageId"));
|
|
51
|
+
var StageContext = Schema2.Struct({
|
|
52
|
+
runId: RunId,
|
|
53
|
+
taskId: Schema2.optional(Schema2.NullOr(TaskId)),
|
|
54
|
+
state: Schema2.Unknown,
|
|
55
|
+
metadata: Schema2.optional(Schema2.Record(Schema2.String, Schema2.Unknown))
|
|
56
|
+
});
|
|
57
|
+
var StageDescriptor = Schema2.Struct({
|
|
58
|
+
id: StageId,
|
|
59
|
+
kind: StageKind,
|
|
60
|
+
before: Schema2.optional(Schema2.Array(StageId)),
|
|
61
|
+
after: Schema2.optional(Schema2.Array(StageId)),
|
|
62
|
+
priority: Schema2.Number.pipe(Schema2.withDecodingDefault(() => 0)),
|
|
63
|
+
protected: Schema2.Boolean.pipe(Schema2.withDecodingDefault(() => false))
|
|
64
|
+
});
|
|
65
|
+
var StageContinueResult = Schema2.Struct({
|
|
66
|
+
kind: Schema2.Literal("continue"),
|
|
67
|
+
ctx: StageContext
|
|
68
|
+
});
|
|
69
|
+
var StageAllowResult = Schema2.Struct({
|
|
70
|
+
kind: Schema2.Literal("allow")
|
|
71
|
+
});
|
|
72
|
+
var StageBlockResult = Schema2.Struct({
|
|
73
|
+
kind: Schema2.Literal("block"),
|
|
74
|
+
reason: TrimmedNonEmptyString
|
|
75
|
+
});
|
|
76
|
+
var StageResult = Schema2.Union([
|
|
77
|
+
StageContinueResult,
|
|
78
|
+
StageAllowResult,
|
|
79
|
+
StageBlockResult
|
|
80
|
+
]);
|
|
81
|
+
var StageWrapperDescriptor = Schema2.Struct({
|
|
82
|
+
id: TrimmedNonEmptyString,
|
|
83
|
+
priority: Schema2.Number.pipe(Schema2.withDecodingDefault(() => 0))
|
|
84
|
+
});
|
|
85
|
+
var StageMutationOp = Schema2.Literals(["insert", "remove", "replace", "wrap", "reorder"]);
|
|
86
|
+
var InsertStageMutation = Schema2.Struct({
|
|
87
|
+
op: Schema2.Literal("insert"),
|
|
88
|
+
stage: StageDescriptor,
|
|
89
|
+
contributedBy: Schema2.optional(TrimmedNonEmptyString)
|
|
90
|
+
});
|
|
91
|
+
var RemoveStageMutation = Schema2.Struct({
|
|
92
|
+
op: Schema2.Literal("remove"),
|
|
93
|
+
id: StageId,
|
|
94
|
+
contributedBy: Schema2.optional(TrimmedNonEmptyString)
|
|
95
|
+
});
|
|
96
|
+
var ReplaceStageMutation = Schema2.Struct({
|
|
97
|
+
op: Schema2.Literal("replace"),
|
|
98
|
+
id: StageId,
|
|
99
|
+
stage: StageDescriptor,
|
|
100
|
+
contributedBy: Schema2.optional(TrimmedNonEmptyString)
|
|
101
|
+
});
|
|
102
|
+
var WrapStageMutation = Schema2.Struct({
|
|
103
|
+
op: Schema2.Literal("wrap"),
|
|
104
|
+
id: StageId,
|
|
105
|
+
around: StageWrapperDescriptor,
|
|
106
|
+
contributedBy: Schema2.optional(TrimmedNonEmptyString)
|
|
107
|
+
});
|
|
108
|
+
var ReorderStageMutation = Schema2.Struct({
|
|
109
|
+
op: Schema2.Literal("reorder"),
|
|
110
|
+
id: StageId,
|
|
111
|
+
before: Schema2.optional(Schema2.Array(StageId)),
|
|
112
|
+
after: Schema2.optional(Schema2.Array(StageId)),
|
|
113
|
+
contributedBy: Schema2.optional(TrimmedNonEmptyString)
|
|
114
|
+
});
|
|
115
|
+
var StageMutation = Schema2.Union([
|
|
116
|
+
InsertStageMutation,
|
|
117
|
+
RemoveStageMutation,
|
|
118
|
+
ReplaceStageMutation,
|
|
119
|
+
WrapStageMutation,
|
|
120
|
+
ReorderStageMutation
|
|
121
|
+
]);
|
|
122
|
+
var ResolutionGrantUse = Schema2.Struct({
|
|
123
|
+
kind: Schema2.Literal("kernel-replacement"),
|
|
124
|
+
target: TrimmedNonEmptyString,
|
|
125
|
+
pluginId: TrimmedNonEmptyString
|
|
126
|
+
});
|
|
127
|
+
var ResolutionRecordEntry = Schema2.Struct({
|
|
128
|
+
stageId: StageId,
|
|
129
|
+
contributedBy: TrimmedNonEmptyString,
|
|
130
|
+
removedBy: Schema2.optional(TrimmedNonEmptyString),
|
|
131
|
+
replacedBy: Schema2.optional(TrimmedNonEmptyString),
|
|
132
|
+
wrappedBy: Schema2.optional(Schema2.Array(TrimmedNonEmptyString)),
|
|
133
|
+
droppedAnchors: Schema2.optional(Schema2.Array(StageId)),
|
|
134
|
+
isProtected: Schema2.Boolean
|
|
135
|
+
});
|
|
136
|
+
var ResolvedPipeline = Schema2.Struct({
|
|
137
|
+
runId: Schema2.optional(RunId),
|
|
138
|
+
order: Schema2.Array(StageId),
|
|
139
|
+
record: Schema2.Array(ResolutionRecordEntry),
|
|
140
|
+
cycles: Schema2.Array(Schema2.Array(StageId)),
|
|
141
|
+
grantUses: Schema2.optional(Schema2.Array(ResolutionGrantUse)),
|
|
142
|
+
resolvedAt: Schema2.optional(IsoDateTime)
|
|
143
|
+
});
|
|
144
|
+
var StageRunOutcome = Schema2.Struct({
|
|
145
|
+
stageId: StageId,
|
|
146
|
+
result: StageResult,
|
|
147
|
+
startedAt: IsoDateTime,
|
|
148
|
+
finishedAt: IsoDateTime
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
// packages/contracts/src/kernel.ts
|
|
152
|
+
var CapabilityTag = Schema3.Literals([
|
|
153
|
+
"kernel",
|
|
154
|
+
"journal",
|
|
155
|
+
"stage-runner",
|
|
156
|
+
"transport",
|
|
157
|
+
"loader-policy"
|
|
158
|
+
]);
|
|
159
|
+
var CapabilityProviderRef = Schema3.Struct({
|
|
160
|
+
capability: CapabilityTag,
|
|
161
|
+
pluginId: TrimmedNonEmptyString
|
|
162
|
+
});
|
|
163
|
+
var CapabilityReplacement = Schema3.Struct({
|
|
164
|
+
capability: CapabilityTag,
|
|
165
|
+
providerPluginId: TrimmedNonEmptyString
|
|
166
|
+
});
|
|
167
|
+
var CapabilityReplacementSpec = Schema3.Union([
|
|
168
|
+
CapabilityReplacement,
|
|
169
|
+
TrimmedNonEmptyString
|
|
170
|
+
]);
|
|
171
|
+
var KernelReplacementGrant = Schema3.Struct({
|
|
172
|
+
pluginId: TrimmedNonEmptyString,
|
|
173
|
+
grantedBy: Schema3.optional(TrimmedNonEmptyString),
|
|
174
|
+
reason: Schema3.optional(Schema3.String)
|
|
175
|
+
});
|
|
176
|
+
var CapabilityGrants = Schema3.Struct({
|
|
177
|
+
capabilityPrecedence: Schema3.optional(Schema3.Record(Schema3.String, Schema3.Array(TrimmedNonEmptyString))),
|
|
178
|
+
kernelReplacementGrants: Schema3.optional(Schema3.Array(KernelReplacementGrant))
|
|
179
|
+
});
|
|
180
|
+
var KernelBootErrorCode = Schema3.Literals([
|
|
181
|
+
"BootIncoherent",
|
|
182
|
+
"AmbiguousCapability",
|
|
183
|
+
"MissingCapability",
|
|
184
|
+
"KernelReplacementDenied",
|
|
185
|
+
"PipelineUnresolvable"
|
|
186
|
+
]);
|
|
187
|
+
var KernelBootError = Schema3.Struct({
|
|
188
|
+
code: KernelBootErrorCode,
|
|
189
|
+
message: TrimmedNonEmptyString,
|
|
190
|
+
capability: Schema3.optional(CapabilityTag),
|
|
191
|
+
stageId: Schema3.optional(TrimmedNonEmptyString),
|
|
192
|
+
pluginIds: Schema3.optional(Schema3.Array(TrimmedNonEmptyString))
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
class BootIncoherent extends Error {
|
|
196
|
+
code = "BootIncoherent";
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
class AmbiguousCapability extends Error {
|
|
200
|
+
code = "AmbiguousCapability";
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
class MissingCapability extends Error {
|
|
204
|
+
code = "MissingCapability";
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
class KernelReplacementDenied extends Error {
|
|
208
|
+
code = "KernelReplacementDenied";
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
class PipelineUnresolvable extends Error {
|
|
212
|
+
code = "PipelineUnresolvable";
|
|
213
|
+
}
|
|
214
|
+
var CapabilityResolutionStatus = Schema3.Literals(["resolved", "ambiguous", "missing", "replaced"]);
|
|
215
|
+
var CapabilityResolutionRecord = Schema3.Struct({
|
|
216
|
+
capability: CapabilityTag,
|
|
217
|
+
status: CapabilityResolutionStatus,
|
|
218
|
+
selectedPluginId: Schema3.NullOr(TrimmedNonEmptyString),
|
|
219
|
+
candidatePluginIds: Schema3.Array(TrimmedNonEmptyString),
|
|
220
|
+
precedenceUsed: Schema3.Boolean,
|
|
221
|
+
replacementUsed: Schema3.optional(CapabilityReplacement),
|
|
222
|
+
error: Schema3.optional(Schema3.String)
|
|
223
|
+
});
|
|
224
|
+
var KernelResolutionRecord = Schema3.Struct({
|
|
225
|
+
resolvedAt: IsoDateTime,
|
|
226
|
+
capabilities: Schema3.Array(CapabilityResolutionRecord),
|
|
227
|
+
pipeline: Schema3.optional(ResolvedPipeline)
|
|
228
|
+
});
|
|
229
|
+
var BootResultDescriptor = Schema3.Struct({
|
|
230
|
+
kernelPluginId: TrimmedNonEmptyString,
|
|
231
|
+
pluginIds: Schema3.Array(TrimmedNonEmptyString),
|
|
232
|
+
resolution: KernelResolutionRecord
|
|
233
|
+
});
|
|
234
|
+
var JournalEvent = Schema3.Struct({
|
|
235
|
+
type: TrimmedNonEmptyString,
|
|
236
|
+
runId: Schema3.optional(RunId),
|
|
237
|
+
at: IsoDateTime,
|
|
238
|
+
payload: Schema3.Unknown
|
|
239
|
+
});
|
|
240
|
+
var PLACEMENT_RUN_TRANSPORT = makeCapabilityId("transport.placement-run");
|
|
241
|
+
export {
|
|
242
|
+
PipelineUnresolvable,
|
|
243
|
+
PLACEMENT_RUN_TRANSPORT,
|
|
244
|
+
MissingCapability,
|
|
245
|
+
KernelResolutionRecord,
|
|
246
|
+
KernelReplacementGrant,
|
|
247
|
+
KernelReplacementDenied,
|
|
248
|
+
KernelBootErrorCode,
|
|
249
|
+
KernelBootError,
|
|
250
|
+
JournalEvent,
|
|
251
|
+
CapabilityTag,
|
|
252
|
+
CapabilityResolutionStatus,
|
|
253
|
+
CapabilityResolutionRecord,
|
|
254
|
+
CapabilityReplacementSpec,
|
|
255
|
+
CapabilityReplacement,
|
|
256
|
+
CapabilityProviderRef,
|
|
257
|
+
CapabilityGrants,
|
|
258
|
+
BootResultDescriptor,
|
|
259
|
+
BootIncoherent,
|
|
260
|
+
AmbiguousCapability
|
|
261
|
+
};
|