@h-rig/contracts 0.0.6-alpha.157 → 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/task-source.js
CHANGED
|
@@ -1 +1,13 @@
|
|
|
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_IO_SERVICE_CAPABILITY_ID = "task-sources.task-io";
|
|
9
|
+
var TASK_IO_SERVICE_CAPABILITY = makeCapabilityId(TASK_IO_SERVICE_CAPABILITY_ID);
|
|
10
|
+
export {
|
|
11
|
+
TASK_IO_SERVICE_CAPABILITY_ID,
|
|
12
|
+
TASK_IO_SERVICE_CAPABILITY
|
|
13
|
+
};
|
|
@@ -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,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool-materializer capability seam.
|
|
3
|
+
*
|
|
4
|
+
* Defines the TOOL_MATERIALIZER service port that @rig/isolation-plugin
|
|
5
|
+
* consumes to build the runtime tool binaries (tool gateway, file tools,
|
|
6
|
+
* claude router, browser tools) without importing @rig/provider-plugin impl
|
|
7
|
+
* files directly. @rig/provider-plugin provides the capability; isolation-plugin
|
|
8
|
+
* resolves it via requireInstalledCapability — the SEAM-ONLY replacement for
|
|
9
|
+
* the four cross-plugin impl imports (§6.4).
|
|
10
|
+
*
|
|
11
|
+
* Pure: types + one branded id, no behaviour.
|
|
12
|
+
*/
|
|
13
|
+
import type { CapabilityId } from "./capability-id";
|
|
14
|
+
/**
|
|
15
|
+
* The tool-materializer service: builds provider-plugin-owned runtime tool
|
|
16
|
+
* binaries into the given bin directory.
|
|
17
|
+
*/
|
|
18
|
+
export interface ToolMaterializerService {
|
|
19
|
+
/** Materialize the runtime tool gateway binary. Returns the path. */
|
|
20
|
+
materializeRuntimeToolGateway(binDir: string): Promise<string>;
|
|
21
|
+
/** Materialize the runtime file-tools binary. Returns the path. */
|
|
22
|
+
materializeRuntimeFileTools(targetDir: string): Promise<string>;
|
|
23
|
+
/** Materialize the Claude tool-router binary. Returns the path. */
|
|
24
|
+
materializeClaudeToolRouterBinary(projectRoot: string, targetDir: string): Promise<string>;
|
|
25
|
+
/** Materialize the runtime browser-tools binary. Returns the path. */
|
|
26
|
+
materializeRuntimeBrowserTools(targetDir: string): Promise<string>;
|
|
27
|
+
/** Synchronously resolve the runtime browser-tool binary name. */
|
|
28
|
+
runtimeBrowserToolBinaryName(): string;
|
|
29
|
+
}
|
|
30
|
+
/** Stable id string for the tool-materializer service capability. */
|
|
31
|
+
export declare const TOOL_MATERIALIZER_CAPABILITY_ID = "provider.tool-materializer";
|
|
32
|
+
/**
|
|
33
|
+
* The branded tool-materializer capability id. `defineCapability(TOOL_MATERIALIZER)`
|
|
34
|
+
* (provider and consumers independently) resolves to a `ToolMaterializerService`.
|
|
35
|
+
*/
|
|
36
|
+
export declare const TOOL_MATERIALIZER: CapabilityId<ToolMaterializerService>;
|
|
@@ -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/tool-materializer.ts
|
|
8
|
+
var TOOL_MATERIALIZER_CAPABILITY_ID = "provider.tool-materializer";
|
|
9
|
+
var TOOL_MATERIALIZER = makeCapabilityId(TOOL_MATERIALIZER_CAPABILITY_ID);
|
|
10
|
+
export {
|
|
11
|
+
TOOL_MATERIALIZER_CAPABILITY_ID,
|
|
12
|
+
TOOL_MATERIALIZER
|
|
13
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// packages/contracts/src/tool-registry.ts
|
|
3
|
+
var RUNTIME_SHELL_TOOL_NAMES = [
|
|
4
|
+
"bash",
|
|
5
|
+
"sh",
|
|
6
|
+
"zsh",
|
|
7
|
+
"git",
|
|
8
|
+
"bun",
|
|
9
|
+
"node",
|
|
10
|
+
"python3",
|
|
11
|
+
"rg",
|
|
12
|
+
"grep",
|
|
13
|
+
"sed",
|
|
14
|
+
"cat",
|
|
15
|
+
"ls",
|
|
16
|
+
"find",
|
|
17
|
+
"tsc",
|
|
18
|
+
"gh",
|
|
19
|
+
"mkdir",
|
|
20
|
+
"rm",
|
|
21
|
+
"mv",
|
|
22
|
+
"cp",
|
|
23
|
+
"touch",
|
|
24
|
+
"pwd",
|
|
25
|
+
"head",
|
|
26
|
+
"tail",
|
|
27
|
+
"wc",
|
|
28
|
+
"sort",
|
|
29
|
+
"uniq",
|
|
30
|
+
"awk",
|
|
31
|
+
"xargs",
|
|
32
|
+
"dirname",
|
|
33
|
+
"basename",
|
|
34
|
+
"realpath",
|
|
35
|
+
"env",
|
|
36
|
+
"jq",
|
|
37
|
+
"tee",
|
|
38
|
+
"which"
|
|
39
|
+
];
|
|
40
|
+
var RUNTIME_FILE_TOOL_NAMES = [
|
|
41
|
+
"rig-read",
|
|
42
|
+
"rig-write",
|
|
43
|
+
"rig-edit",
|
|
44
|
+
"rig-glob",
|
|
45
|
+
"rig-grep"
|
|
46
|
+
];
|
|
47
|
+
var RUNTIME_BROWSER_TOOL_NAMES = [
|
|
48
|
+
"rig-browser-launch",
|
|
49
|
+
"rig-browser-check",
|
|
50
|
+
"rig-browser-attach-info",
|
|
51
|
+
"rig-browser-e2e",
|
|
52
|
+
"rig-browser-reset-profile"
|
|
53
|
+
];
|
|
54
|
+
export {
|
|
55
|
+
RUNTIME_SHELL_TOOL_NAMES,
|
|
56
|
+
RUNTIME_FILE_TOOL_NAMES,
|
|
57
|
+
RUNTIME_BROWSER_TOOL_NAMES
|
|
58
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Toolchain-source contribution seam.
|
|
3
|
+
*
|
|
4
|
+
* @rig/isolation-plugin's runtime toolchain materializes per-run hook binaries
|
|
5
|
+
* (guard hooks, lifecycle hooks) and standalone helper binaries (controlled-bash)
|
|
6
|
+
* by compiling SOURCE files owned by OTHER plugins. Hardcoding those sibling
|
|
7
|
+
* `packages/<plugin>/src/...` paths inside the toolchain couples it to every
|
|
8
|
+
* owning plugin's file layout (and trips the rule-8b arch invariant).
|
|
9
|
+
*
|
|
10
|
+
* Instead, each owning plugin CONTRIBUTES its build sources as DATA through a
|
|
11
|
+
* typed capability id, and the toolchain RESOLVES them off the project's plugin
|
|
12
|
+
* host. Each contributor owns a DISTINCT capability id (the plugin host enforces
|
|
13
|
+
* one-provider-per-id, so the two contributors cannot share a single id) — the
|
|
14
|
+
* toolchain merges the contributions it finds.
|
|
15
|
+
*
|
|
16
|
+
* Pure: types + branded ids, no behaviour.
|
|
17
|
+
*/
|
|
18
|
+
import type { CapabilityId } from "./capability-id";
|
|
19
|
+
/**
|
|
20
|
+
* One per-run hook binary build spec: the binary NAME (the basename the runtime
|
|
21
|
+
* dispatches by) and its `source` entrypoint, expressed RELATIVE to the rig
|
|
22
|
+
* source root (the same string the toolchain feeds to `buildBinary`).
|
|
23
|
+
*/
|
|
24
|
+
export interface ToolchainHookBinarySource {
|
|
25
|
+
readonly name: string;
|
|
26
|
+
readonly source: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* A plugin's contribution of runtime-toolchain build sources.
|
|
30
|
+
*
|
|
31
|
+
* - `hookBinaries` are compiled uniformly into the runtime `hooks/` directory
|
|
32
|
+
* with the shared hook defines.
|
|
33
|
+
* - `namedSources` are standalone source paths the toolchain compiles with its
|
|
34
|
+
* own per-binary defines, keyed by a stable build id (e.g. `"controlled-bash"`).
|
|
35
|
+
*
|
|
36
|
+
* All paths are RELATIVE to the rig source root (unchanged from the literals the
|
|
37
|
+
* toolchain previously embedded), so resolution behaviour is identical.
|
|
38
|
+
*/
|
|
39
|
+
export interface ToolchainSourceContribution {
|
|
40
|
+
readonly hookBinaries?: ReadonlyArray<ToolchainHookBinarySource>;
|
|
41
|
+
readonly namedSources?: Readonly<Record<string, string>>;
|
|
42
|
+
}
|
|
43
|
+
/** Stable id for @rig/guard-plugin's toolchain-source contribution. */
|
|
44
|
+
export declare const GUARD_TOOLCHAIN_SOURCES_CAPABILITY_ID = "rig.toolchain.sources.guard";
|
|
45
|
+
/** Stable id for @rig/bundle-default-lifecycle's toolchain-source contribution. */
|
|
46
|
+
export declare const LIFECYCLE_TOOLCHAIN_SOURCES_CAPABILITY_ID = "rig.toolchain.sources.lifecycle";
|
|
47
|
+
/**
|
|
48
|
+
* The guard-plugin toolchain-source capability id. `defineCapability(...)` (the
|
|
49
|
+
* provider and the isolation-plugin consumer construct it independently from the
|
|
50
|
+
* shared id) resolves to a `ToolchainSourceContribution`.
|
|
51
|
+
*/
|
|
52
|
+
export declare const GUARD_TOOLCHAIN_SOURCES: CapabilityId<ToolchainSourceContribution>;
|
|
53
|
+
/** The bundle-default-lifecycle toolchain-source capability id. */
|
|
54
|
+
export declare const LIFECYCLE_TOOLCHAIN_SOURCES: CapabilityId<ToolchainSourceContribution>;
|
|
@@ -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/toolchain-sources.ts
|
|
8
|
+
var GUARD_TOOLCHAIN_SOURCES_CAPABILITY_ID = "rig.toolchain.sources.guard";
|
|
9
|
+
var LIFECYCLE_TOOLCHAIN_SOURCES_CAPABILITY_ID = "rig.toolchain.sources.lifecycle";
|
|
10
|
+
var GUARD_TOOLCHAIN_SOURCES = makeCapabilityId(GUARD_TOOLCHAIN_SOURCES_CAPABILITY_ID);
|
|
11
|
+
var LIFECYCLE_TOOLCHAIN_SOURCES = makeCapabilityId(LIFECYCLE_TOOLCHAIN_SOURCES_CAPABILITY_ID);
|
|
12
|
+
export {
|
|
13
|
+
LIFECYCLE_TOOLCHAIN_SOURCES_CAPABILITY_ID,
|
|
14
|
+
LIFECYCLE_TOOLCHAIN_SOURCES,
|
|
15
|
+
GUARD_TOOLCHAIN_SOURCES_CAPABILITY_ID,
|
|
16
|
+
GUARD_TOOLCHAIN_SOURCES
|
|
17
|
+
};
|
|
@@ -76,36 +76,6 @@ export type RigWorkflowCustomEntry = {
|
|
|
76
76
|
customType?: string;
|
|
77
77
|
data?: unknown;
|
|
78
78
|
};
|
|
79
|
-
export declare function createWorkflowStarted(input: Omit<RigWorkflowStarted, "schemaVersion" | "createdAt"> & {
|
|
80
|
-
createdAt?: string;
|
|
81
|
-
}): RigWorkflowStarted;
|
|
82
|
-
export declare function createWorkflowTargetSelected(input: Omit<RigWorkflowTargetSelected, "schemaVersion" | "selectedAt"> & {
|
|
83
|
-
selectedAt?: string;
|
|
84
|
-
}): RigWorkflowTargetSelected;
|
|
85
|
-
export declare function createWorkflowTaskSelected(input: Omit<RigWorkflowTaskSelected, "schemaVersion" | "selectedAt"> & {
|
|
86
|
-
selectedAt?: string;
|
|
87
|
-
}): RigWorkflowTaskSelected;
|
|
88
|
-
export declare function createWorkflowStatusChanged(input: Omit<RigWorkflowStatusChanged, "schemaVersion" | "changedAt"> & {
|
|
89
|
-
changedAt?: string;
|
|
90
|
-
}): RigWorkflowStatusChanged;
|
|
91
|
-
export declare function createWorkflowOperatorNote(input: Omit<RigWorkflowOperatorNote, "schemaVersion" | "notedAt"> & {
|
|
92
|
-
notedAt?: string;
|
|
93
|
-
}): RigWorkflowOperatorNote;
|
|
94
|
-
export declare function createWorkflowInboxRequested(input: Omit<RigWorkflowInboxRequested, "schemaVersion" | "requestedAt"> & {
|
|
95
|
-
requestedAt?: string;
|
|
96
|
-
}): RigWorkflowInboxRequested;
|
|
97
|
-
export declare function createWorkflowInboxResolved(input: Omit<RigWorkflowInboxResolved, "schemaVersion" | "resolvedAt"> & {
|
|
98
|
-
resolvedAt?: string;
|
|
99
|
-
}): RigWorkflowInboxResolved;
|
|
100
|
-
export declare function parseWorkflowStarted(data: unknown): RigWorkflowStarted | null;
|
|
101
|
-
export declare function parseWorkflowTargetSelected(data: unknown): RigWorkflowTargetSelected | null;
|
|
102
|
-
export declare function parseWorkflowTaskSelected(data: unknown): RigWorkflowTaskSelected | null;
|
|
103
|
-
export declare function parseWorkflowStatusChanged(data: unknown): RigWorkflowStatusChanged | null;
|
|
104
|
-
export declare function parseWorkflowOperatorNote(data: unknown): RigWorkflowOperatorNote | null;
|
|
105
|
-
export declare function parseWorkflowInboxRequested(data: unknown): RigWorkflowInboxRequested | null;
|
|
106
|
-
export declare function parseWorkflowInboxResolved(data: unknown): RigWorkflowInboxResolved | null;
|
|
107
|
-
export declare function collectPendingInboxRequests(entries: readonly RigWorkflowCustomEntry[]): RigWorkflowInboxRequested[];
|
|
108
|
-
export declare function collectResolvedInboxRequests(entries: readonly RigWorkflowCustomEntry[]): RigWorkflowInboxResolved[];
|
|
109
79
|
export type RigCollabWorkflowMarkerInput = {
|
|
110
80
|
sessionId: string;
|
|
111
81
|
sessionPath: string;
|
|
@@ -120,5 +90,3 @@ export type RigCollabWorkflowMarkerInput = {
|
|
|
120
90
|
updatedAt: string;
|
|
121
91
|
stale: boolean;
|
|
122
92
|
};
|
|
123
|
-
export declare function projectCollabWorkflowMarker(collab: RigCollabWorkflowMarkerInput): RigWorkflowProjection;
|
|
124
|
-
export declare function projectWorkflowEntries(entries: readonly RigWorkflowCustomEntry[]): RigWorkflowProjection;
|
|
@@ -7,378 +7,7 @@ var RIG_WORKFLOW_STATUS_CHANGED = "rig.workflow.status.changed";
|
|
|
7
7
|
var RIG_WORKFLOW_OPERATOR_NOTE = "rig.workflow.operator.note";
|
|
8
8
|
var RIG_WORKFLOW_INBOX_REQUESTED = "rig.workflow.inbox.requested";
|
|
9
9
|
var RIG_WORKFLOW_INBOX_RESOLVED = "rig.workflow.inbox.resolved";
|
|
10
|
-
var EMPTY_PROJECTION = {
|
|
11
|
-
started: null,
|
|
12
|
-
target: null,
|
|
13
|
-
task: null,
|
|
14
|
-
status: null,
|
|
15
|
-
notes: [],
|
|
16
|
-
inbox: [],
|
|
17
|
-
resolvedInbox: [],
|
|
18
|
-
updatedAt: null
|
|
19
|
-
};
|
|
20
|
-
function asRecord(value) {
|
|
21
|
-
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
22
|
-
}
|
|
23
|
-
function optionalString(value) {
|
|
24
|
-
return typeof value === "string" && value.trim().length > 0 ? value.trim() : undefined;
|
|
25
|
-
}
|
|
26
|
-
function requiredString(value) {
|
|
27
|
-
const text = optionalString(value);
|
|
28
|
-
return text ?? null;
|
|
29
|
-
}
|
|
30
|
-
function timestamp(value) {
|
|
31
|
-
const text = requiredString(value);
|
|
32
|
-
if (!text)
|
|
33
|
-
return null;
|
|
34
|
-
const millis = Date.parse(text);
|
|
35
|
-
return Number.isFinite(millis) ? text : null;
|
|
36
|
-
}
|
|
37
|
-
function newer(left, right) {
|
|
38
|
-
if (!right)
|
|
39
|
-
return false;
|
|
40
|
-
if (!left)
|
|
41
|
-
return true;
|
|
42
|
-
return Date.parse(right) >= Date.parse(left);
|
|
43
|
-
}
|
|
44
|
-
function isWorkflowTarget(value) {
|
|
45
|
-
return value === "local" || value === "remote";
|
|
46
|
-
}
|
|
47
|
-
function isWorkflowStatus(value) {
|
|
48
|
-
return value === "starting" || value === "running" || value === "waiting-approval" || value === "waiting-input" || value === "completed" || value === "failed" || value === "stopped";
|
|
49
|
-
}
|
|
50
|
-
function isInboxKind(value) {
|
|
51
|
-
return value === "approval" || value === "input";
|
|
52
|
-
}
|
|
53
|
-
function isInboxDecision(value) {
|
|
54
|
-
return value === "approved" || value === "rejected" || value === "answered";
|
|
55
|
-
}
|
|
56
|
-
function parseOwner(value) {
|
|
57
|
-
const record = asRecord(value);
|
|
58
|
-
if (!record)
|
|
59
|
-
return null;
|
|
60
|
-
const githubUserId = requiredString(record.githubUserId);
|
|
61
|
-
const login = requiredString(record.login);
|
|
62
|
-
const namespaceKey = requiredString(record.namespaceKey);
|
|
63
|
-
return githubUserId && login && namespaceKey ? { githubUserId, login, namespaceKey } : null;
|
|
64
|
-
}
|
|
65
|
-
function parseStringArray(value) {
|
|
66
|
-
if (!Array.isArray(value))
|
|
67
|
-
return;
|
|
68
|
-
const options = value.map(optionalString).filter((option) => option !== undefined);
|
|
69
|
-
return options.length > 0 ? options : undefined;
|
|
70
|
-
}
|
|
71
|
-
function hasOwn(record, key) {
|
|
72
|
-
return Object.prototype.hasOwnProperty.call(record, key);
|
|
73
|
-
}
|
|
74
|
-
function entryUpdatedAt(entry) {
|
|
75
|
-
if ("createdAt" in entry)
|
|
76
|
-
return entry.createdAt;
|
|
77
|
-
if ("selectedAt" in entry)
|
|
78
|
-
return entry.selectedAt;
|
|
79
|
-
if ("changedAt" in entry)
|
|
80
|
-
return entry.changedAt;
|
|
81
|
-
if ("notedAt" in entry)
|
|
82
|
-
return entry.notedAt;
|
|
83
|
-
if ("requestedAt" in entry)
|
|
84
|
-
return entry.requestedAt;
|
|
85
|
-
return entry.resolvedAt;
|
|
86
|
-
}
|
|
87
|
-
function createWorkflowStarted(input) {
|
|
88
|
-
return {
|
|
89
|
-
schemaVersion: 1,
|
|
90
|
-
workflowId: input.workflowId,
|
|
91
|
-
target: input.target,
|
|
92
|
-
selectedRepo: input.selectedRepo,
|
|
93
|
-
owner: input.owner,
|
|
94
|
-
createdAt: input.createdAt ?? new Date().toISOString()
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
function createWorkflowTargetSelected(input) {
|
|
98
|
-
return {
|
|
99
|
-
schemaVersion: 1,
|
|
100
|
-
target: input.target,
|
|
101
|
-
...input.reason ? { reason: input.reason } : {},
|
|
102
|
-
selectedAt: input.selectedAt ?? new Date().toISOString()
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
function createWorkflowTaskSelected(input) {
|
|
106
|
-
return {
|
|
107
|
-
schemaVersion: 1,
|
|
108
|
-
taskId: input.taskId,
|
|
109
|
-
...input.title ? { title: input.title } : {},
|
|
110
|
-
selectedAt: input.selectedAt ?? new Date().toISOString()
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
function createWorkflowStatusChanged(input) {
|
|
114
|
-
return {
|
|
115
|
-
schemaVersion: 1,
|
|
116
|
-
status: input.status,
|
|
117
|
-
...input.detail ? { detail: input.detail } : {},
|
|
118
|
-
changedAt: input.changedAt ?? new Date().toISOString()
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
function createWorkflowOperatorNote(input) {
|
|
122
|
-
return {
|
|
123
|
-
schemaVersion: 1,
|
|
124
|
-
...input.noteId ? { noteId: input.noteId } : {},
|
|
125
|
-
note: input.note,
|
|
126
|
-
notedAt: input.notedAt ?? new Date().toISOString()
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
function createWorkflowInboxRequested(input) {
|
|
130
|
-
return {
|
|
131
|
-
schemaVersion: 1,
|
|
132
|
-
requestId: input.requestId,
|
|
133
|
-
kind: input.kind,
|
|
134
|
-
title: input.title,
|
|
135
|
-
...input.body ? { body: input.body } : {},
|
|
136
|
-
...input.options && input.options.length > 0 ? { options: input.options } : {},
|
|
137
|
-
requestedAt: input.requestedAt ?? new Date().toISOString()
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
function createWorkflowInboxResolved(input) {
|
|
141
|
-
const base = {
|
|
142
|
-
schemaVersion: 1,
|
|
143
|
-
requestId: input.requestId,
|
|
144
|
-
decision: input.decision,
|
|
145
|
-
resolvedAt: input.resolvedAt ?? new Date().toISOString()
|
|
146
|
-
};
|
|
147
|
-
return hasOwn(input, "answer") ? { ...base, answer: input.answer } : base;
|
|
148
|
-
}
|
|
149
|
-
function parseWorkflowStarted(data) {
|
|
150
|
-
const record = asRecord(data);
|
|
151
|
-
if (!record || record.schemaVersion !== 1)
|
|
152
|
-
return null;
|
|
153
|
-
const workflowId = requiredString(record.workflowId);
|
|
154
|
-
const target = optionalString(record.target);
|
|
155
|
-
const selectedRepo = requiredString(record.selectedRepo);
|
|
156
|
-
const owner = parseOwner(record.owner);
|
|
157
|
-
const createdAt = timestamp(record.createdAt);
|
|
158
|
-
if (!workflowId || !isWorkflowTarget(target) || !selectedRepo || !owner || !createdAt)
|
|
159
|
-
return null;
|
|
160
|
-
return {
|
|
161
|
-
schemaVersion: 1,
|
|
162
|
-
workflowId,
|
|
163
|
-
target,
|
|
164
|
-
selectedRepo,
|
|
165
|
-
owner,
|
|
166
|
-
createdAt
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
function parseWorkflowTargetSelected(data) {
|
|
170
|
-
const record = asRecord(data);
|
|
171
|
-
if (!record || record.schemaVersion !== 1)
|
|
172
|
-
return null;
|
|
173
|
-
const target = optionalString(record.target);
|
|
174
|
-
const selectedAt = timestamp(record.selectedAt);
|
|
175
|
-
if (!isWorkflowTarget(target) || !selectedAt)
|
|
176
|
-
return null;
|
|
177
|
-
const reason = optionalString(record.reason);
|
|
178
|
-
return {
|
|
179
|
-
schemaVersion: 1,
|
|
180
|
-
target,
|
|
181
|
-
...reason ? { reason } : {},
|
|
182
|
-
selectedAt
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
function parseWorkflowTaskSelected(data) {
|
|
186
|
-
const record = asRecord(data);
|
|
187
|
-
if (!record || record.schemaVersion !== 1)
|
|
188
|
-
return null;
|
|
189
|
-
const taskId = requiredString(record.taskId);
|
|
190
|
-
const selectedAt = timestamp(record.selectedAt);
|
|
191
|
-
if (!taskId || !selectedAt)
|
|
192
|
-
return null;
|
|
193
|
-
const title = optionalString(record.title);
|
|
194
|
-
return { schemaVersion: 1, taskId, ...title ? { title } : {}, selectedAt };
|
|
195
|
-
}
|
|
196
|
-
function parseWorkflowStatusChanged(data) {
|
|
197
|
-
const record = asRecord(data);
|
|
198
|
-
if (!record || record.schemaVersion !== 1)
|
|
199
|
-
return null;
|
|
200
|
-
const status = optionalString(record.status);
|
|
201
|
-
const changedAt = timestamp(record.changedAt);
|
|
202
|
-
if (!changedAt || !isWorkflowStatus(status))
|
|
203
|
-
return null;
|
|
204
|
-
const detail = optionalString(record.detail);
|
|
205
|
-
return { schemaVersion: 1, status, ...detail ? { detail } : {}, changedAt };
|
|
206
|
-
}
|
|
207
|
-
function parseWorkflowOperatorNote(data) {
|
|
208
|
-
const record = asRecord(data);
|
|
209
|
-
if (!record || record.schemaVersion !== 1)
|
|
210
|
-
return null;
|
|
211
|
-
const note = requiredString(record.note);
|
|
212
|
-
const notedAt = timestamp(record.notedAt);
|
|
213
|
-
if (!note || !notedAt)
|
|
214
|
-
return null;
|
|
215
|
-
const noteId = optionalString(record.noteId);
|
|
216
|
-
return { schemaVersion: 1, ...noteId ? { noteId } : {}, note, notedAt };
|
|
217
|
-
}
|
|
218
|
-
function parseWorkflowInboxRequested(data) {
|
|
219
|
-
const record = asRecord(data);
|
|
220
|
-
if (!record || record.schemaVersion !== 1)
|
|
221
|
-
return null;
|
|
222
|
-
const requestId = requiredString(record.requestId);
|
|
223
|
-
const kind = optionalString(record.kind);
|
|
224
|
-
const title = requiredString(record.title);
|
|
225
|
-
const requestedAt = timestamp(record.requestedAt);
|
|
226
|
-
if (!requestId || !isInboxKind(kind) || !title || !requestedAt)
|
|
227
|
-
return null;
|
|
228
|
-
const body = optionalString(record.body);
|
|
229
|
-
const options = parseStringArray(record.options);
|
|
230
|
-
return {
|
|
231
|
-
schemaVersion: 1,
|
|
232
|
-
requestId,
|
|
233
|
-
kind,
|
|
234
|
-
title,
|
|
235
|
-
...body ? { body } : {},
|
|
236
|
-
...options ? { options } : {},
|
|
237
|
-
requestedAt
|
|
238
|
-
};
|
|
239
|
-
}
|
|
240
|
-
function parseWorkflowInboxResolved(data) {
|
|
241
|
-
const record = asRecord(data);
|
|
242
|
-
if (!record || record.schemaVersion !== 1)
|
|
243
|
-
return null;
|
|
244
|
-
const requestId = requiredString(record.requestId);
|
|
245
|
-
const decision = optionalString(record.decision);
|
|
246
|
-
const resolvedAt = timestamp(record.resolvedAt);
|
|
247
|
-
if (!requestId || !isInboxDecision(decision) || !resolvedAt)
|
|
248
|
-
return null;
|
|
249
|
-
const base = { schemaVersion: 1, requestId, decision, resolvedAt };
|
|
250
|
-
return hasOwn(record, "answer") ? { ...base, answer: record.answer } : base;
|
|
251
|
-
}
|
|
252
|
-
function collectPendingInboxRequests(entries) {
|
|
253
|
-
const requested = new Map;
|
|
254
|
-
const resolved = new Map;
|
|
255
|
-
for (const entry of entries) {
|
|
256
|
-
if (entry.type !== "custom")
|
|
257
|
-
continue;
|
|
258
|
-
if (entry.customType === RIG_WORKFLOW_INBOX_REQUESTED) {
|
|
259
|
-
const request = parseWorkflowInboxRequested(entry.data);
|
|
260
|
-
if (request && newer(requested.get(request.requestId)?.requestedAt, request.requestedAt))
|
|
261
|
-
requested.set(request.requestId, request);
|
|
262
|
-
} else if (entry.customType === RIG_WORKFLOW_INBOX_RESOLVED) {
|
|
263
|
-
const resolution = parseWorkflowInboxResolved(entry.data);
|
|
264
|
-
if (resolution && newer(resolved.get(resolution.requestId), resolution.resolvedAt))
|
|
265
|
-
resolved.set(resolution.requestId, resolution.resolvedAt);
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
for (const [requestId, request] of requested) {
|
|
269
|
-
const resolvedAt = resolved.get(requestId);
|
|
270
|
-
if (resolvedAt && Date.parse(resolvedAt) >= Date.parse(request.requestedAt))
|
|
271
|
-
requested.delete(requestId);
|
|
272
|
-
}
|
|
273
|
-
return Array.from(requested.values()).sort((a, b) => Date.parse(b.requestedAt) - Date.parse(a.requestedAt));
|
|
274
|
-
}
|
|
275
|
-
function collectResolvedInboxRequests(entries) {
|
|
276
|
-
const requested = new Map;
|
|
277
|
-
const resolved = new Map;
|
|
278
|
-
for (const entry of entries) {
|
|
279
|
-
if (entry.type !== "custom")
|
|
280
|
-
continue;
|
|
281
|
-
if (entry.customType === RIG_WORKFLOW_INBOX_REQUESTED) {
|
|
282
|
-
const request = parseWorkflowInboxRequested(entry.data);
|
|
283
|
-
if (request && newer(requested.get(request.requestId), request.requestedAt))
|
|
284
|
-
requested.set(request.requestId, request.requestedAt);
|
|
285
|
-
} else if (entry.customType === RIG_WORKFLOW_INBOX_RESOLVED) {
|
|
286
|
-
const resolution = parseWorkflowInboxResolved(entry.data);
|
|
287
|
-
if (resolution && newer(resolved.get(resolution.requestId)?.resolvedAt, resolution.resolvedAt)) {
|
|
288
|
-
resolved.set(resolution.requestId, resolution);
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
for (const [requestId, resolution] of resolved) {
|
|
293
|
-
const requestedAt = requested.get(requestId);
|
|
294
|
-
if (requestedAt && Date.parse(requestedAt) > Date.parse(resolution.resolvedAt))
|
|
295
|
-
resolved.delete(requestId);
|
|
296
|
-
}
|
|
297
|
-
return Array.from(resolved.values()).sort((a, b) => Date.parse(b.resolvedAt) - Date.parse(a.resolvedAt));
|
|
298
|
-
}
|
|
299
|
-
function projectCollabWorkflowMarker(collab) {
|
|
300
|
-
const status = createWorkflowStatusChanged({
|
|
301
|
-
status: collab.stale ? "stopped" : "running",
|
|
302
|
-
detail: collab.stale ? "Stale OMP collab session discovered from the sanctioned collab registry." : "Live OMP collab session discovered from the sanctioned collab registry.",
|
|
303
|
-
changedAt: collab.updatedAt
|
|
304
|
-
});
|
|
305
|
-
return {
|
|
306
|
-
started: null,
|
|
307
|
-
target: null,
|
|
308
|
-
task: null,
|
|
309
|
-
status,
|
|
310
|
-
notes: [],
|
|
311
|
-
inbox: [],
|
|
312
|
-
resolvedInbox: [],
|
|
313
|
-
updatedAt: newer(collab.startedAt, collab.updatedAt) ? collab.updatedAt : collab.startedAt
|
|
314
|
-
};
|
|
315
|
-
}
|
|
316
|
-
function projectWorkflowEntries(entries) {
|
|
317
|
-
let started = null;
|
|
318
|
-
let target = null;
|
|
319
|
-
let task = null;
|
|
320
|
-
let status = null;
|
|
321
|
-
const notes = [];
|
|
322
|
-
let updatedAt = null;
|
|
323
|
-
for (const entry of entries) {
|
|
324
|
-
if (entry.type !== "custom")
|
|
325
|
-
continue;
|
|
326
|
-
if (entry.customType === RIG_WORKFLOW_STARTED) {
|
|
327
|
-
const parsed = parseWorkflowStarted(entry.data);
|
|
328
|
-
if (parsed && newer(started?.createdAt, parsed.createdAt))
|
|
329
|
-
started = parsed;
|
|
330
|
-
} else if (entry.customType === RIG_WORKFLOW_TARGET_SELECTED) {
|
|
331
|
-
const parsed = parseWorkflowTargetSelected(entry.data);
|
|
332
|
-
if (parsed && newer(target?.selectedAt, parsed.selectedAt))
|
|
333
|
-
target = parsed;
|
|
334
|
-
} else if (entry.customType === RIG_WORKFLOW_TASK_SELECTED) {
|
|
335
|
-
const parsed = parseWorkflowTaskSelected(entry.data);
|
|
336
|
-
if (parsed && newer(task?.selectedAt, parsed.selectedAt))
|
|
337
|
-
task = parsed;
|
|
338
|
-
} else if (entry.customType === RIG_WORKFLOW_STATUS_CHANGED) {
|
|
339
|
-
const parsed = parseWorkflowStatusChanged(entry.data);
|
|
340
|
-
if (parsed && newer(status?.changedAt, parsed.changedAt))
|
|
341
|
-
status = parsed;
|
|
342
|
-
} else if (entry.customType === RIG_WORKFLOW_OPERATOR_NOTE) {
|
|
343
|
-
const parsed = parseWorkflowOperatorNote(entry.data);
|
|
344
|
-
if (parsed)
|
|
345
|
-
notes.push(parsed);
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
notes.sort((a, b) => Date.parse(b.notedAt) - Date.parse(a.notedAt));
|
|
349
|
-
for (const value of [started, target, task, status, ...notes].map((entry) => entry ? entryUpdatedAt(entry) : null)) {
|
|
350
|
-
if (newer(updatedAt, value))
|
|
351
|
-
updatedAt = value;
|
|
352
|
-
}
|
|
353
|
-
const inbox = collectPendingInboxRequests(entries);
|
|
354
|
-
const resolvedInbox = collectResolvedInboxRequests(entries);
|
|
355
|
-
for (const entry of [...inbox, ...resolvedInbox]) {
|
|
356
|
-
if (newer(updatedAt, entryUpdatedAt(entry)))
|
|
357
|
-
updatedAt = entryUpdatedAt(entry);
|
|
358
|
-
}
|
|
359
|
-
if (!started && !target && !task && !status && notes.length === 0 && inbox.length === 0 && resolvedInbox.length === 0 && !updatedAt)
|
|
360
|
-
return EMPTY_PROJECTION;
|
|
361
|
-
return { started, target, task, status, notes, inbox, resolvedInbox, updatedAt };
|
|
362
|
-
}
|
|
363
10
|
export {
|
|
364
|
-
projectWorkflowEntries,
|
|
365
|
-
projectCollabWorkflowMarker,
|
|
366
|
-
parseWorkflowTaskSelected,
|
|
367
|
-
parseWorkflowTargetSelected,
|
|
368
|
-
parseWorkflowStatusChanged,
|
|
369
|
-
parseWorkflowStarted,
|
|
370
|
-
parseWorkflowOperatorNote,
|
|
371
|
-
parseWorkflowInboxResolved,
|
|
372
|
-
parseWorkflowInboxRequested,
|
|
373
|
-
createWorkflowTaskSelected,
|
|
374
|
-
createWorkflowTargetSelected,
|
|
375
|
-
createWorkflowStatusChanged,
|
|
376
|
-
createWorkflowStarted,
|
|
377
|
-
createWorkflowOperatorNote,
|
|
378
|
-
createWorkflowInboxResolved,
|
|
379
|
-
createWorkflowInboxRequested,
|
|
380
|
-
collectResolvedInboxRequests,
|
|
381
|
-
collectPendingInboxRequests,
|
|
382
11
|
RIG_WORKFLOW_TASK_SELECTED,
|
|
383
12
|
RIG_WORKFLOW_TARGET_SELECTED,
|
|
384
13
|
RIG_WORKFLOW_STATUS_CHANGED,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CapabilityId } from "./capability-id";
|
|
2
|
+
export type EnsureDeclarativeConfigInput = {
|
|
3
|
+
readonly projectRoot: string;
|
|
4
|
+
readonly repoSlug?: string;
|
|
5
|
+
};
|
|
6
|
+
export type EnsureDeclarativeConfigResult = {
|
|
7
|
+
/** True when this call wrote a new `.rig/rigfig.toml`. */
|
|
8
|
+
readonly created: boolean;
|
|
9
|
+
/** The rigfig path when one now exists (created or pre-existing), else null. */
|
|
10
|
+
readonly path: string | null;
|
|
11
|
+
/** Why nothing was created (code config present, no plugin produced a config, …). */
|
|
12
|
+
readonly reason?: string;
|
|
13
|
+
};
|
|
14
|
+
export interface WorkspaceConfigEnsureService {
|
|
15
|
+
ensureDeclarativeConfig(input: EnsureDeclarativeConfigInput): EnsureDeclarativeConfigResult;
|
|
16
|
+
}
|
|
17
|
+
export declare const WORKSPACE_CONFIG_ENSURE_CAPABILITY_ID = "workspace.config.ensure";
|
|
18
|
+
export declare const WORKSPACE_CONFIG_ENSURE: CapabilityId<WorkspaceConfigEnsureService>;
|
|
@@ -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/workspace-config.ts
|
|
8
|
+
var WORKSPACE_CONFIG_ENSURE_CAPABILITY_ID = "workspace.config.ensure";
|
|
9
|
+
var WORKSPACE_CONFIG_ENSURE = makeCapabilityId(WORKSPACE_CONFIG_ENSURE_CAPABILITY_ID);
|
|
10
|
+
export {
|
|
11
|
+
WORKSPACE_CONFIG_ENSURE_CAPABILITY_ID,
|
|
12
|
+
WORKSPACE_CONFIG_ENSURE
|
|
13
|
+
};
|