@h-rig/contracts 0.0.0-e2e-live.20260630085347

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (200) hide show
  1. package/README.md +14 -0
  2. package/dist/index.cjs +3442 -0
  3. package/dist/index.mjs +3401 -0
  4. package/dist/src/agent-roles.d.ts +8 -0
  5. package/dist/src/agent-roles.js +1 -0
  6. package/dist/src/artifact.d.ts +13 -0
  7. package/dist/src/artifact.js +56 -0
  8. package/dist/src/baseSchemas.d.ts +63 -0
  9. package/dist/src/baseSchemas.js +72 -0
  10. package/dist/src/blocker-classifier.d.ts +21 -0
  11. package/dist/src/blocker-classifier.js +13 -0
  12. package/dist/src/browser.d.ts +80 -0
  13. package/dist/src/browser.js +13 -0
  14. package/dist/src/capability-id.d.ts +22 -0
  15. package/dist/src/capability-id.js +8 -0
  16. package/dist/src/cli-output.d.ts +348 -0
  17. package/dist/src/cli-output.js +190 -0
  18. package/dist/src/cli-runner.d.ts +43 -0
  19. package/dist/src/cli-runner.js +13 -0
  20. package/dist/src/cockpit.d.ts +58 -0
  21. package/dist/src/cockpit.js +13 -0
  22. package/dist/src/collab-session-viewer.d.ts +36 -0
  23. package/dist/src/collab-session-viewer.js +13 -0
  24. package/dist/src/config.d.ts +553 -0
  25. package/dist/src/config.js +822 -0
  26. package/dist/src/control-plane-types.d.ts +323 -0
  27. package/dist/src/control-plane-types.js +13 -0
  28. package/dist/src/conversation.d.ts +50 -0
  29. package/dist/src/conversation.js +98 -0
  30. package/dist/src/dependency-preflight.d.ts +43 -0
  31. package/dist/src/dependency-preflight.js +13 -0
  32. package/dist/src/docs-drift.d.ts +10 -0
  33. package/dist/src/docs-drift.js +12 -0
  34. package/dist/src/doctor.d.ts +90 -0
  35. package/dist/src/doctor.js +13 -0
  36. package/dist/src/drift.d.ts +28 -0
  37. package/dist/src/drift.js +69 -0
  38. package/dist/src/editor.d.ts +25 -0
  39. package/dist/src/editor.js +58 -0
  40. package/dist/src/errors.d.ts +13 -0
  41. package/dist/src/errors.js +17 -0
  42. package/dist/src/git.d.ts +152 -0
  43. package/dist/src/git.js +196 -0
  44. package/dist/src/github.d.ts +295 -0
  45. package/dist/src/github.js +17 -0
  46. package/dist/src/graph.d.ts +360 -0
  47. package/dist/src/graph.js +229 -0
  48. package/dist/src/guard.d.ts +118 -0
  49. package/dist/src/guard.js +15 -0
  50. package/dist/src/harness-events.d.ts +8 -0
  51. package/dist/src/harness-events.js +1 -0
  52. package/dist/src/harness-profile-state.d.ts +10 -0
  53. package/dist/src/harness-profile-state.js +13 -0
  54. package/dist/src/help-catalog.d.ts +41 -0
  55. package/dist/src/help-catalog.js +13 -0
  56. package/dist/src/host.d.ts +41 -0
  57. package/dist/src/host.js +13 -0
  58. package/dist/src/identity.d.ts +44 -0
  59. package/dist/src/identity.js +1 -0
  60. package/dist/src/index.d.ts +98 -0
  61. package/dist/src/index.js +3401 -0
  62. package/dist/src/isolation.d.ts +213 -0
  63. package/dist/src/isolation.js +13 -0
  64. package/dist/src/kernel.d.ts +200 -0
  65. package/dist/src/kernel.js +261 -0
  66. package/dist/src/keybindings.d.ts +71 -0
  67. package/dist/src/keybindings.js +122 -0
  68. package/dist/src/layout.d.ts +44 -0
  69. package/dist/src/layout.js +8 -0
  70. package/dist/src/lifecycle-capabilities.d.ts +224 -0
  71. package/dist/src/lifecycle-capabilities.js +45 -0
  72. package/dist/src/managed-repos.d.ts +339 -0
  73. package/dist/src/managed-repos.js +37 -0
  74. package/dist/src/memory.d.ts +199 -0
  75. package/dist/src/memory.js +15 -0
  76. package/dist/src/model.d.ts +13 -0
  77. package/dist/src/model.js +9 -0
  78. package/dist/src/native-toolchain.d.ts +46 -0
  79. package/dist/src/native-toolchain.js +13 -0
  80. package/dist/src/notify.d.ts +46 -0
  81. package/dist/src/notify.js +13 -0
  82. package/dist/src/orchestration.d.ts +43 -0
  83. package/dist/src/orchestration.js +98 -0
  84. package/dist/src/panel-protocol.d.ts +17 -0
  85. package/dist/src/panel-protocol.js +10 -0
  86. package/dist/src/pi-session.d.ts +113 -0
  87. package/dist/src/pi-session.js +1 -0
  88. package/dist/src/placement.d.ts +47 -0
  89. package/dist/src/placement.js +13 -0
  90. package/dist/src/planning.d.ts +64 -0
  91. package/dist/src/planning.js +90 -0
  92. package/dist/src/plugin-hooks.d.ts +51 -0
  93. package/dist/src/plugin-hooks.js +386 -0
  94. package/dist/src/plugin.d.ts +476 -0
  95. package/dist/src/plugin.js +384 -0
  96. package/dist/src/policy.d.ts +16 -0
  97. package/dist/src/policy.js +59 -0
  98. package/dist/src/product-entrypoint.d.ts +22 -0
  99. package/dist/src/product-entrypoint.js +13 -0
  100. package/dist/src/project.d.ts +71 -0
  101. package/dist/src/project.js +110 -0
  102. package/dist/src/prompt.d.ts +29 -0
  103. package/dist/src/prompt.js +13 -0
  104. package/dist/src/protocol-version.d.ts +21 -0
  105. package/dist/src/protocol-version.js +6 -0
  106. package/dist/src/provider-instructions.d.ts +41 -0
  107. package/dist/src/provider-instructions.js +13 -0
  108. package/dist/src/provider.d.ts +105 -0
  109. package/dist/src/provider.js +194 -0
  110. package/dist/src/remote-control.d.ts +93 -0
  111. package/dist/src/remote-control.js +26 -0
  112. package/dist/src/remote.d.ts +318 -0
  113. package/dist/src/remote.js +634 -0
  114. package/dist/src/review.d.ts +18 -0
  115. package/dist/src/review.js +61 -0
  116. package/dist/src/rollups.d.ts +41 -0
  117. package/dist/src/rollups.js +70 -0
  118. package/dist/src/run-control.d.ts +164 -0
  119. package/dist/src/run-control.js +13 -0
  120. package/dist/src/run-discovery.d.ts +83 -0
  121. package/dist/src/run-discovery.js +13 -0
  122. package/dist/src/run-dispatch.d.ts +34 -0
  123. package/dist/src/run-dispatch.js +13 -0
  124. package/dist/src/run-identity.d.ts +47 -0
  125. package/dist/src/run-identity.js +13 -0
  126. package/dist/src/run-journal.d.ts +694 -0
  127. package/dist/src/run-journal.js +569 -0
  128. package/dist/src/run-queue.d.ts +36 -0
  129. package/dist/src/run-queue.js +13 -0
  130. package/dist/src/run-read-model.d.ts +200 -0
  131. package/dist/src/run-read-model.js +13 -0
  132. package/dist/src/run-record.d.ts +45 -0
  133. package/dist/src/run-record.js +1 -0
  134. package/dist/src/run-registry-backbone.d.ts +56 -0
  135. package/dist/src/run-registry-backbone.js +13 -0
  136. package/dist/src/run-session-journal.d.ts +154 -0
  137. package/dist/src/run-session-journal.js +87 -0
  138. package/dist/src/run-status.d.ts +10 -0
  139. package/dist/src/run-status.js +27 -0
  140. package/dist/src/run-timeline.d.ts +7 -0
  141. package/dist/src/run-timeline.js +1 -0
  142. package/dist/src/runtime-secrets.d.ts +10 -0
  143. package/dist/src/runtime-secrets.js +13 -0
  144. package/dist/src/runtime-task-context.d.ts +82 -0
  145. package/dist/src/runtime-task-context.js +1 -0
  146. package/dist/src/runtime.d.ts +103 -0
  147. package/dist/src/runtime.js +210 -0
  148. package/dist/src/session-asset-materializer.d.ts +35 -0
  149. package/dist/src/session-asset-materializer.js +13 -0
  150. package/dist/src/session-hook-materializer.d.ts +41 -0
  151. package/dist/src/session-hook-materializer.js +13 -0
  152. package/dist/src/setup.d.ts +154 -0
  153. package/dist/src/setup.js +13 -0
  154. package/dist/src/stage.d.ts +245 -0
  155. package/dist/src/stage.js +169 -0
  156. package/dist/src/supervisor-journal.d.ts +204 -0
  157. package/dist/src/supervisor-journal.js +336 -0
  158. package/dist/src/supervisor-loop.d.ts +40 -0
  159. package/dist/src/supervisor-loop.js +13 -0
  160. package/dist/src/task-artifacts.d.ts +53 -0
  161. package/dist/src/task-artifacts.js +13 -0
  162. package/dist/src/task-config.d.ts +22 -0
  163. package/dist/src/task-config.js +1 -0
  164. package/dist/src/task-context-renderer.d.ts +29 -0
  165. package/dist/src/task-context-renderer.js +13 -0
  166. package/dist/src/task-data.d.ts +196 -0
  167. package/dist/src/task-data.js +13 -0
  168. package/dist/src/task-graph-primitives.d.ts +47 -0
  169. package/dist/src/task-graph-primitives.js +1 -0
  170. package/dist/src/task-source.d.ts +167 -0
  171. package/dist/src/task-source.js +25 -0
  172. package/dist/src/task-state-metadata.d.ts +21 -0
  173. package/dist/src/task-state-metadata.js +1 -0
  174. package/dist/src/task-state-paths.d.ts +14 -0
  175. package/dist/src/task-state-paths.js +13 -0
  176. package/dist/src/task-state-store.d.ts +36 -0
  177. package/dist/src/task-state-store.js +17 -0
  178. package/dist/src/task-tracker-state.d.ts +101 -0
  179. package/dist/src/task-tracker-state.js +39 -0
  180. package/dist/src/terminal.d.ts +130 -0
  181. package/dist/src/terminal.js +161 -0
  182. package/dist/src/tool-materializer.d.ts +36 -0
  183. package/dist/src/tool-materializer.js +13 -0
  184. package/dist/src/tool-registry.d.ts +3 -0
  185. package/dist/src/tool-registry.js +58 -0
  186. package/dist/src/toolchain-sources.d.ts +54 -0
  187. package/dist/src/toolchain-sources.js +17 -0
  188. package/dist/src/transport-config.d.ts +161 -0
  189. package/dist/src/transport-config.js +15 -0
  190. package/dist/src/validation.d.ts +14 -0
  191. package/dist/src/validation.js +63 -0
  192. package/dist/src/workflow-journal.d.ts +125 -0
  193. package/dist/src/workflow-journal.js +27 -0
  194. package/dist/src/workspace-config.d.ts +18 -0
  195. package/dist/src/workspace-config.js +13 -0
  196. package/dist/src/workspace-service.d.ts +16 -0
  197. package/dist/src/workspace-service.js +13 -0
  198. package/dist/src/workspace.d.ts +204 -0
  199. package/dist/src/workspace.js +195 -0
  200. package/package.json +79 -0
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Pure runtime-task-context data shapes.
3
+ *
4
+ * These are behaviour-free data types describing the per-task runtime context
5
+ * the substrate materializes and threads to agents and capabilities. They carry
6
+ * no logic and import nothing but the sibling `RuntimeBrowserContext` contract,
7
+ * so they belong in the neutral contracts layer (exactly like `memory.ts` /
8
+ * `lifecycle-capabilities.ts`).
9
+ *
10
+ * The fs-backed loaders/serializers that PRODUCE and VALIDATE these shapes stay
11
+ * in `@rig/runtime/control-plane/runtime/context.ts`, which re-exports these
12
+ * types for back-compat so existing `import … from ".../runtime/context"` sites
13
+ * are unaffected.
14
+ */
15
+ import type { RuntimeBrowserContext } from "./browser";
16
+ /** Retrieval weighting for shared-memory recall; pure config data. */
17
+ export type RuntimeMemoryRetrievalConfig = {
18
+ topK: number;
19
+ lexicalWeight: number;
20
+ vectorWeight: number;
21
+ recencyWeight: number;
22
+ confidenceWeight: number;
23
+ };
24
+ /** The materialized shared-memory context handed to a runtime task. */
25
+ export type RuntimeMemoryContext = {
26
+ canonicalPath: string;
27
+ canonicalRef: string;
28
+ canonicalBaseOid?: string;
29
+ hydratedPath: string;
30
+ createdFresh: boolean;
31
+ retrieval: RuntimeMemoryRetrievalConfig;
32
+ };
33
+ /** The source-task contract fields a runtime task carries through. */
34
+ export type RuntimeSourceTaskContract = {
35
+ id: string;
36
+ title?: string;
37
+ description?: string;
38
+ body?: string;
39
+ acceptanceCriteria?: string;
40
+ acceptance_criteria?: string;
41
+ sourceIssueId?: string;
42
+ status?: string;
43
+ issueType?: string;
44
+ role?: string;
45
+ externalRef?: string;
46
+ scope?: string[];
47
+ validation?: string[];
48
+ validators?: string[];
49
+ labels?: string[];
50
+ };
51
+ /** The fully-resolved per-task runtime context. */
52
+ export type RuntimeTaskContext = {
53
+ runtimeId: string;
54
+ taskId: string;
55
+ role: string;
56
+ scopes: string[];
57
+ validation: string[];
58
+ sourceTask?: RuntimeSourceTaskContract;
59
+ browser?: RuntimeBrowserContext;
60
+ workspaceDir: string;
61
+ artifactRoot?: string;
62
+ hostProjectRoot?: string;
63
+ monorepoMainRoot?: string;
64
+ monorepoBaseRef?: string;
65
+ monorepoBaseCommit?: string;
66
+ initialHeadCommits?: {
67
+ project?: string;
68
+ monorepo?: string;
69
+ };
70
+ initialDirtyFiles?: {
71
+ project?: string[];
72
+ monorepo?: string[];
73
+ };
74
+ stateDir: string;
75
+ logsDir: string;
76
+ sessionDir: string;
77
+ sessionFile: string;
78
+ policyFile: string;
79
+ binDir: string;
80
+ createdAt: string;
81
+ memory?: RuntimeMemoryContext;
82
+ };
@@ -0,0 +1 @@
1
+ // @bun
@@ -0,0 +1,103 @@
1
+ import { Schema } from "effect";
2
+ export declare const RunKind: Schema.Literals<readonly ["adhoc", "task", "batch", "validation", "review"]>;
3
+ export type RunKind = typeof RunKind.Type;
4
+ export declare const RunMode: Schema.Literals<readonly ["interactive", "autonomous", "supervised"]>;
5
+ export type RunMode = typeof RunMode.Type;
6
+ export declare const RunStatus: Schema.Literals<readonly ["created", "queued", "preparing", "running", "waiting-approval", "waiting-user-input", "paused", "validating", "reviewing", "closing-out", "needs-attention", "completed", "failed", "stopped"]>;
7
+ export type RunStatus = typeof RunStatus.Type;
8
+ export declare const EngineSandboxMode: Schema.Literals<readonly ["read-only", "workspace-write", "danger-full-access"]>;
9
+ export type EngineSandboxMode = typeof EngineSandboxMode.Type;
10
+ export declare const IsolationMode: Schema.Literals<readonly ["none", "env", "worktree"]>;
11
+ export type IsolationMode = typeof IsolationMode.Type;
12
+ export declare const RuntimeStatus: Schema.Literals<readonly ["prepared", "starting", "running", "interrupted", "exited", "failed", "destroyed"]>;
13
+ export type RuntimeStatus = typeof RuntimeStatus.Type;
14
+ export declare const RunExecutionTarget: Schema.Literals<readonly ["local", "remote"]>;
15
+ export type RunExecutionTarget = typeof RunExecutionTarget.Type;
16
+ export declare const RunSummary: Schema.Struct<{
17
+ readonly id: Schema.brand<Schema.Trim, "RunId">;
18
+ readonly workspaceId: Schema.brand<Schema.Trim, "WorkspaceId">;
19
+ readonly taskId: Schema.NullOr<Schema.brand<Schema.Trim, "TaskId">>;
20
+ readonly title: Schema.Trim;
21
+ readonly runKind: Schema.Literals<readonly ["adhoc", "task", "batch", "validation", "review"]>;
22
+ readonly mode: Schema.Literals<readonly ["interactive", "autonomous", "supervised"]>;
23
+ readonly runtimeMode: Schema.Literals<readonly ["approval-required", "full-access"]>;
24
+ readonly interactionMode: Schema.Literals<readonly ["default", "plan"]>;
25
+ readonly status: Schema.Literals<readonly ["created", "queued", "preparing", "running", "waiting-approval", "waiting-user-input", "paused", "validating", "reviewing", "closing-out", "needs-attention", "completed", "failed", "stopped"]>;
26
+ readonly runtimeAdapter: Schema.Literal<"pi">;
27
+ readonly model: Schema.NullOr<Schema.Trim>;
28
+ readonly initialPrompt: Schema.NullOr<Schema.String>;
29
+ readonly executionTarget: Schema.optional<Schema.Literals<readonly ["local", "remote"]>>;
30
+ readonly remoteHostId: Schema.optional<Schema.NullOr<Schema.Trim>>;
31
+ readonly remoteLeaseId: Schema.optional<Schema.NullOr<Schema.Trim>>;
32
+ readonly remoteLeaseClaimedAt: Schema.optional<Schema.NullOr<Schema.String>>;
33
+ readonly activeRuntimeId: Schema.NullOr<Schema.brand<Schema.Trim, "EngineRuntimeId">>;
34
+ readonly latestMessageId: Schema.NullOr<Schema.Trim>;
35
+ readonly pendingApprovalCount: Schema.Int;
36
+ readonly pendingUserInputCount: Schema.Int;
37
+ readonly branch: Schema.NullOr<Schema.Trim>;
38
+ readonly worktreePath: Schema.NullOr<Schema.Trim>;
39
+ readonly errorText: Schema.NullOr<Schema.String>;
40
+ readonly createdAt: Schema.String;
41
+ readonly updatedAt: Schema.String;
42
+ readonly startedAt: Schema.NullOr<Schema.String>;
43
+ readonly completedAt: Schema.NullOr<Schema.String>;
44
+ }>;
45
+ export type RunSummary = typeof RunSummary.Type;
46
+ export declare const RuntimeSummary: Schema.Struct<{
47
+ readonly id: Schema.brand<Schema.Trim, "EngineRuntimeId">;
48
+ readonly workspaceId: Schema.brand<Schema.Trim, "WorkspaceId">;
49
+ readonly runId: Schema.brand<Schema.Trim, "RunId">;
50
+ readonly adapterKind: Schema.Literal<"pi">;
51
+ readonly executionTarget: Schema.optional<Schema.Literals<readonly ["local", "remote"]>>;
52
+ readonly remoteHostId: Schema.optional<Schema.NullOr<Schema.Trim>>;
53
+ readonly status: Schema.Literals<readonly ["prepared", "starting", "running", "interrupted", "exited", "failed", "destroyed"]>;
54
+ readonly sandboxMode: Schema.Literals<readonly ["read-only", "workspace-write", "danger-full-access"]>;
55
+ readonly isolationMode: Schema.Literals<readonly ["none", "env", "worktree"]>;
56
+ readonly workspaceDir: Schema.NullOr<Schema.Trim>;
57
+ readonly homeDir: Schema.NullOr<Schema.Trim>;
58
+ readonly tmpDir: Schema.NullOr<Schema.Trim>;
59
+ readonly cacheDir: Schema.NullOr<Schema.Trim>;
60
+ readonly logsDir: Schema.NullOr<Schema.Trim>;
61
+ readonly stateDir: Schema.NullOr<Schema.Trim>;
62
+ readonly sessionDir: Schema.NullOr<Schema.Trim>;
63
+ readonly sessionLogPath: Schema.NullOr<Schema.Trim>;
64
+ readonly pid: Schema.NullOr<Schema.Int>;
65
+ readonly startedAt: Schema.NullOr<Schema.String>;
66
+ readonly updatedAt: Schema.String;
67
+ readonly exitedAt: Schema.NullOr<Schema.String>;
68
+ }>;
69
+ export type RuntimeSummary = typeof RuntimeSummary.Type;
70
+ export declare const ApprovalStatus: Schema.Literals<readonly ["pending", "resolved"]>;
71
+ export type ApprovalStatus = typeof ApprovalStatus.Type;
72
+ export declare const ApprovalSummary: Schema.Struct<{
73
+ readonly id: Schema.Trim;
74
+ readonly runId: Schema.brand<Schema.Trim, "RunId">;
75
+ readonly actionId: Schema.NullOr<Schema.Trim>;
76
+ readonly requestKind: Schema.Trim;
77
+ readonly status: Schema.Literals<readonly ["pending", "resolved"]>;
78
+ readonly payload: Schema.Unknown;
79
+ readonly createdAt: Schema.String;
80
+ readonly resolvedAt: Schema.NullOr<Schema.String>;
81
+ }>;
82
+ export type ApprovalSummary = typeof ApprovalSummary.Type;
83
+ export declare const UserInputRequestSummary: Schema.Struct<{
84
+ readonly id: Schema.Trim;
85
+ readonly runId: Schema.brand<Schema.Trim, "RunId">;
86
+ readonly status: Schema.Literals<readonly ["pending", "resolved"]>;
87
+ readonly payload: Schema.Unknown;
88
+ readonly createdAt: Schema.String;
89
+ readonly resolvedAt: Schema.NullOr<Schema.String>;
90
+ }>;
91
+ export type UserInputRequestSummary = typeof UserInputRequestSummary.Type;
92
+ export declare const WorktreeSummary: Schema.Struct<{
93
+ readonly id: Schema.brand<Schema.Trim, "WorktreeId">;
94
+ readonly workspaceId: Schema.brand<Schema.Trim, "WorkspaceId">;
95
+ readonly runId: Schema.brand<Schema.Trim, "RunId">;
96
+ readonly taskId: Schema.NullOr<Schema.brand<Schema.Trim, "TaskId">>;
97
+ readonly branchName: Schema.Trim;
98
+ readonly path: Schema.Trim;
99
+ readonly status: Schema.Trim;
100
+ readonly createdAt: Schema.String;
101
+ readonly cleanedAt: Schema.NullOr<Schema.String>;
102
+ }>;
103
+ export type WorktreeSummary = typeof WorktreeSummary.Type;
@@ -0,0 +1,210 @@
1
+ // @bun
2
+ // packages/contracts/src/runtime.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/orchestration.ts
43
+ import { Schema as Schema2 } from "effect";
44
+ var ProviderKind = Schema2.Literals(["codex", "claude"]);
45
+ var ProviderApprovalPolicy = Schema2.Literals([
46
+ "untrusted",
47
+ "on-failure",
48
+ "on-request",
49
+ "never"
50
+ ]);
51
+ var ProviderSandboxMode = Schema2.Literals([
52
+ "read-only",
53
+ "workspace-write",
54
+ "danger-full-access"
55
+ ]);
56
+ var ProviderServiceTier = Schema2.Literals(["fast", "flex"]);
57
+ var RuntimeMode = Schema2.Literals(["approval-required", "full-access"]);
58
+ var ProviderInteractionMode = Schema2.Literals(["default", "plan"]);
59
+ var ProviderRequestKind = Schema2.Literals(["command", "file-read", "file-change"]);
60
+ var ProviderApprovalDecision = Schema2.Literals([
61
+ "accept",
62
+ "acceptForSession",
63
+ "decline",
64
+ "cancel"
65
+ ]);
66
+ var ProviderUserInputAnswers = Schema2.Record(Schema2.String, Schema2.Unknown);
67
+ var PROVIDER_SEND_TURN_MAX_IMAGE_BYTES = 10 * 1024 * 1024;
68
+ var CHAT_ATTACHMENT_ID_MAX_CHARS = 128;
69
+ var ChatAttachmentId = TrimmedNonEmptyString.check(Schema2.isMaxLength(CHAT_ATTACHMENT_ID_MAX_CHARS), Schema2.isPattern(/^[a-z0-9_-]+$/i));
70
+ var ChatImageAttachment = Schema2.Struct({
71
+ type: Schema2.Literal("image"),
72
+ id: ChatAttachmentId,
73
+ name: TrimmedNonEmptyString.check(Schema2.isMaxLength(255)),
74
+ mimeType: TrimmedNonEmptyString.check(Schema2.isMaxLength(100), Schema2.isPattern(/^image\//i)),
75
+ sizeBytes: NonNegativeInt.check(Schema2.isLessThanOrEqualTo(PROVIDER_SEND_TURN_MAX_IMAGE_BYTES))
76
+ });
77
+ var ChatAttachment = Schema2.Union([ChatImageAttachment]);
78
+
79
+ // packages/contracts/src/runtime.ts
80
+ var RunKind = Schema3.Literals(["adhoc", "task", "batch", "validation", "review"]);
81
+ var RunMode = Schema3.Literals(["interactive", "autonomous", "supervised"]);
82
+ var RunStatus = Schema3.Literals([
83
+ "created",
84
+ "queued",
85
+ "preparing",
86
+ "running",
87
+ "waiting-approval",
88
+ "waiting-user-input",
89
+ "paused",
90
+ "validating",
91
+ "reviewing",
92
+ "closing-out",
93
+ "needs-attention",
94
+ "completed",
95
+ "failed",
96
+ "stopped"
97
+ ]);
98
+ var EngineSandboxMode = Schema3.Literals([
99
+ "read-only",
100
+ "workspace-write",
101
+ "danger-full-access"
102
+ ]);
103
+ var IsolationMode = Schema3.Literals(["none", "env", "worktree"]);
104
+ var RuntimeStatus = Schema3.Literals([
105
+ "prepared",
106
+ "starting",
107
+ "running",
108
+ "interrupted",
109
+ "exited",
110
+ "failed",
111
+ "destroyed"
112
+ ]);
113
+ var RunExecutionTarget = Schema3.Literals(["local", "remote"]);
114
+ var RunSummary = Schema3.Struct({
115
+ id: RunId,
116
+ workspaceId: WorkspaceId,
117
+ taskId: Schema3.NullOr(TaskId),
118
+ title: TrimmedNonEmptyString,
119
+ runKind: RunKind,
120
+ mode: RunMode,
121
+ runtimeMode: RuntimeMode,
122
+ interactionMode: ProviderInteractionMode,
123
+ status: RunStatus,
124
+ runtimeAdapter: Schema3.Literal("pi"),
125
+ model: Schema3.NullOr(TrimmedNonEmptyString),
126
+ initialPrompt: Schema3.NullOr(Schema3.String),
127
+ executionTarget: Schema3.optional(RunExecutionTarget),
128
+ remoteHostId: Schema3.optional(Schema3.NullOr(TrimmedNonEmptyString)),
129
+ remoteLeaseId: Schema3.optional(Schema3.NullOr(TrimmedNonEmptyString)),
130
+ remoteLeaseClaimedAt: Schema3.optional(Schema3.NullOr(IsoDateTime)),
131
+ activeRuntimeId: Schema3.NullOr(EngineRuntimeId),
132
+ latestMessageId: Schema3.NullOr(TrimmedNonEmptyString),
133
+ pendingApprovalCount: NonNegativeInt,
134
+ pendingUserInputCount: NonNegativeInt,
135
+ branch: Schema3.NullOr(TrimmedNonEmptyString),
136
+ worktreePath: Schema3.NullOr(TrimmedNonEmptyString),
137
+ errorText: Schema3.NullOr(Schema3.String),
138
+ createdAt: IsoDateTime,
139
+ updatedAt: IsoDateTime,
140
+ startedAt: Schema3.NullOr(IsoDateTime),
141
+ completedAt: Schema3.NullOr(IsoDateTime)
142
+ });
143
+ var RuntimeSummary = Schema3.Struct({
144
+ id: EngineRuntimeId,
145
+ workspaceId: WorkspaceId,
146
+ runId: RunId,
147
+ adapterKind: Schema3.Literal("pi"),
148
+ executionTarget: Schema3.optional(RunExecutionTarget),
149
+ remoteHostId: Schema3.optional(Schema3.NullOr(TrimmedNonEmptyString)),
150
+ status: RuntimeStatus,
151
+ sandboxMode: EngineSandboxMode,
152
+ isolationMode: IsolationMode,
153
+ workspaceDir: Schema3.NullOr(TrimmedNonEmptyString),
154
+ homeDir: Schema3.NullOr(TrimmedNonEmptyString),
155
+ tmpDir: Schema3.NullOr(TrimmedNonEmptyString),
156
+ cacheDir: Schema3.NullOr(TrimmedNonEmptyString),
157
+ logsDir: Schema3.NullOr(TrimmedNonEmptyString),
158
+ stateDir: Schema3.NullOr(TrimmedNonEmptyString),
159
+ sessionDir: Schema3.NullOr(TrimmedNonEmptyString),
160
+ sessionLogPath: Schema3.NullOr(TrimmedNonEmptyString),
161
+ pid: Schema3.NullOr(NonNegativeInt),
162
+ startedAt: Schema3.NullOr(IsoDateTime),
163
+ updatedAt: IsoDateTime,
164
+ exitedAt: Schema3.NullOr(IsoDateTime)
165
+ });
166
+ var ApprovalStatus = Schema3.Literals(["pending", "resolved"]);
167
+ var ApprovalSummary = Schema3.Struct({
168
+ id: TrimmedNonEmptyString,
169
+ runId: RunId,
170
+ actionId: Schema3.NullOr(TrimmedNonEmptyString),
171
+ requestKind: TrimmedNonEmptyString,
172
+ status: ApprovalStatus,
173
+ payload: Schema3.Unknown,
174
+ createdAt: IsoDateTime,
175
+ resolvedAt: Schema3.NullOr(IsoDateTime)
176
+ });
177
+ var UserInputRequestSummary = Schema3.Struct({
178
+ id: TrimmedNonEmptyString,
179
+ runId: RunId,
180
+ status: ApprovalStatus,
181
+ payload: Schema3.Unknown,
182
+ createdAt: IsoDateTime,
183
+ resolvedAt: Schema3.NullOr(IsoDateTime)
184
+ });
185
+ var WorktreeSummary = Schema3.Struct({
186
+ id: WorktreeId,
187
+ workspaceId: WorkspaceId,
188
+ runId: RunId,
189
+ taskId: Schema3.NullOr(TaskId),
190
+ branchName: TrimmedNonEmptyString,
191
+ path: TrimmedNonEmptyString,
192
+ status: TrimmedNonEmptyString,
193
+ createdAt: IsoDateTime,
194
+ cleanedAt: Schema3.NullOr(IsoDateTime)
195
+ });
196
+ export {
197
+ WorktreeSummary,
198
+ UserInputRequestSummary,
199
+ RuntimeSummary,
200
+ RuntimeStatus,
201
+ RunSummary,
202
+ RunStatus,
203
+ RunMode,
204
+ RunKind,
205
+ RunExecutionTarget,
206
+ IsolationMode,
207
+ EngineSandboxMode,
208
+ ApprovalSummary,
209
+ ApprovalStatus
210
+ };
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Pure session-asset-materializer contract.
3
+ *
4
+ * Neutral home for the "materialize plugin-contributed session assets into the
5
+ * workspace" seam so the plugin-host assembler (@rig/core/plugin-host-context)
6
+ * can trigger Pi skill + package materialization without importing
7
+ * @rig/provider-plugin (a floor->plugin cycle). The provider plugin owns the
8
+ * concrete impl (it knows the `.pi/skills` + `.pi/settings.json` layout) and
9
+ * registers it under {@link SESSION_ASSET_MATERIALIZER}; the assembler resolves
10
+ * it by id off the project plugin host and calls it. When no provider plugin is
11
+ * loaded the capability is simply absent and materialization is skipped — the
12
+ * same non-fatal default the inline implementation had.
13
+ *
14
+ * Carries no behaviour and imports only sibling contract types.
15
+ */
16
+ import type { CapabilityId } from "./capability-id";
17
+ import type { RigConfig } from "./config";
18
+ /** Capability id the provider plugin registers its session-asset materializer under. */
19
+ export declare const SESSION_ASSET_MATERIALIZER_CAPABILITY_ID = "provider.session-asset-materializer";
20
+ /**
21
+ * Materializes the plugin-contributed session assets (Pi skills declared via
22
+ * `contributes.skills`, and the config-declared Pi extension packages in
23
+ * `runtime.pi.packages`) into the project workspace. Idempotent and non-fatal:
24
+ * implementations log-and-continue on individual write failures so a
25
+ * materialization error can never deadlock harness boot.
26
+ */
27
+ export interface SessionAssetMaterializerService {
28
+ materializeSessionAssets(projectRoot: string, config: RigConfig): Promise<void>;
29
+ }
30
+ /**
31
+ * Typed capability id the provider plugin provides and the plugin-host assembler
32
+ * requires. Phantom-typed with `SessionAssetMaterializerService` so `resolve(host)`
33
+ * returns the service with no cast leaking to callers.
34
+ */
35
+ export declare const SESSION_ASSET_MATERIALIZER: CapabilityId<SessionAssetMaterializerService>;
@@ -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/session-asset-materializer.ts
8
+ var SESSION_ASSET_MATERIALIZER_CAPABILITY_ID = "provider.session-asset-materializer";
9
+ var SESSION_ASSET_MATERIALIZER = makeCapabilityId(SESSION_ASSET_MATERIALIZER_CAPABILITY_ID);
10
+ export {
11
+ SESSION_ASSET_MATERIALIZER_CAPABILITY_ID,
12
+ SESSION_ASSET_MATERIALIZER
13
+ };
@@ -0,0 +1,41 @@
1
+ import type { CapabilityId } from "./capability-id";
2
+ import type { HookEvent, HookRegistration } from "./plugin";
3
+ /** Stable id string for provider/runtime-owned session hook materialization. */
4
+ export declare const SESSION_HOOK_MATERIALIZER_CAPABILITY_ID = "provider.session-hook-materializer";
5
+ /**
6
+ * A plugin hook contribution prepared for the active session host.
7
+ *
8
+ * `typed` means the hook has a runtime implementation attached to the authored
9
+ * plugin object. Concrete materializers decide how their session host invokes
10
+ * that implementation; metadata-only hooks (no command and not typed) can be
11
+ * skipped by implementations.
12
+ */
13
+ export interface PluginHookEntry {
14
+ readonly pluginName: string;
15
+ readonly hook: HookRegistration;
16
+ readonly typed?: boolean;
17
+ }
18
+ /** Alias naming the entries by the capability they are handed to. */
19
+ export type SessionHookEntry = PluginHookEntry;
20
+ /** Provider-owned materialization result; adapter ids are intentionally open. */
21
+ export type SessionHookMaterializerResult = {
22
+ readonly adapterId: string;
23
+ readonly status: "materialized";
24
+ readonly path?: string;
25
+ readonly events?: readonly HookEvent[];
26
+ } | {
27
+ readonly adapterId: string;
28
+ readonly status: "skipped";
29
+ readonly reason: string;
30
+ };
31
+ /**
32
+ * Materializes plugin-contributed hooks into whatever session host is active
33
+ * (Claude Code settings, Pi/OMP session integration, or another provider-owned
34
+ * substrate). The floor runtime resolves this capability and invokes it; it
35
+ * does not know adapter names, settings paths, or provider/session policy.
36
+ */
37
+ export interface SessionHookMaterializerService {
38
+ materializeSessionHooks(projectRoot: string, entries: readonly PluginHookEntry[]): Promise<readonly SessionHookMaterializerResult[]> | readonly SessionHookMaterializerResult[];
39
+ }
40
+ /** Branded capability id for the session-hook materializer service. */
41
+ export declare const SESSION_HOOK_MATERIALIZER: CapabilityId<SessionHookMaterializerService>;
@@ -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/session-hook-materializer.ts
8
+ var SESSION_HOOK_MATERIALIZER_CAPABILITY_ID = "provider.session-hook-materializer";
9
+ var SESSION_HOOK_MATERIALIZER = makeCapabilityId(SESSION_HOOK_MATERIALIZER_CAPABILITY_ID);
10
+ export {
11
+ SESSION_HOOK_MATERIALIZER_CAPABILITY_ID,
12
+ SESSION_HOOK_MATERIALIZER
13
+ };
@@ -0,0 +1,154 @@
1
+ /**
2
+ * cap:project-setup — cross-plugin seam.
3
+ *
4
+ * `@rig/cli-surface-plugin` (the `rig setup`/onboarding surface) runs project
5
+ * setup WITHOUT importing `@rig/init-plugin`: it requires this capability by id
6
+ * off the host. `@rig/init-plugin` OWNS the impl (`runSetup`) and registers it
7
+ * under this id. This file holds ONLY the pure seam vocabulary — no IO, no
8
+ * function-laden deps (those are the impl's concern, not the cross-plugin seam).
9
+ */
10
+ import type { CapabilityId } from "./capability-id";
11
+ import type { GitHubAuthStatus, GitHubProjectStatusField, GitHubProjectSummary } from "./github";
12
+ /** Capability id the init/setup plugin registers its setup runner under. */
13
+ export declare const PROJECT_SETUP_CAPABILITY_ID = "cap:project-setup";
14
+ /**
15
+ * Where runs execute for this project. `kind` is the placement discriminator
16
+ * (e.g. "local" | "remote"); kept as a plain string so contracts stays free of
17
+ * the placement-domain enum.
18
+ */
19
+ export type ProjectSetupPlacement = {
20
+ readonly alias: string;
21
+ readonly kind: "local" | "remote";
22
+ readonly host?: string;
23
+ readonly port?: number;
24
+ readonly token?: string | null;
25
+ };
26
+ /** Pure input to a project-setup pass. */
27
+ export type ProjectSetupInput = {
28
+ readonly projectRoot: string;
29
+ readonly slug: string;
30
+ readonly placement: ProjectSetupPlacement;
31
+ readonly rewriteConfig?: boolean;
32
+ readonly ensurePi?: boolean;
33
+ readonly ensureLabels?: boolean;
34
+ readonly githubToken?: string | null;
35
+ readonly importGhToken?: boolean;
36
+ };
37
+ export type ProjectInitAuthMethod = "gh" | "token" | "device" | "skip";
38
+ export type ProjectInitTaskSource = {
39
+ readonly kind: "github-issues";
40
+ readonly owner: string;
41
+ readonly repo: string;
42
+ readonly assignee?: string | undefined;
43
+ } | {
44
+ readonly kind: "files";
45
+ readonly path: string;
46
+ };
47
+ export type ProjectInitInput = {
48
+ readonly projectRoot: string;
49
+ readonly demo?: boolean | undefined;
50
+ readonly repoSlug?: string | undefined;
51
+ readonly taskSource?: ProjectInitTaskSource | undefined;
52
+ readonly githubToken?: string | undefined;
53
+ readonly githubAuthMethod?: ProjectInitAuthMethod | undefined;
54
+ readonly githubProject?: "off" | string | undefined;
55
+ readonly githubProjectStatusField?: string | undefined;
56
+ readonly githubProjectStatuses?: Readonly<Record<string, string>> | undefined;
57
+ readonly yes?: boolean | undefined;
58
+ readonly repair?: boolean | undefined;
59
+ readonly privateStateOnly?: boolean | undefined;
60
+ readonly server?: "local" | "remote" | undefined;
61
+ readonly remoteAlias?: string | undefined;
62
+ readonly remoteHost?: string | undefined;
63
+ readonly remotePort?: number | undefined;
64
+ readonly remoteCheckout?: string | undefined;
65
+ };
66
+ export type ProjectInitResult = {
67
+ readonly mode: "control-plane" | "local-files" | "demo" | "task-source";
68
+ readonly projectRoot: string;
69
+ readonly messages: readonly string[];
70
+ readonly details: Record<string, unknown>;
71
+ };
72
+ export type ProjectInitGitHubProjectsInput = {
73
+ readonly projectRoot: string;
74
+ readonly owner: string;
75
+ readonly token?: string | null | undefined;
76
+ };
77
+ export type ProjectInitGitHubProjectsResult = {
78
+ readonly ok: true;
79
+ readonly projects: readonly GitHubProjectSummary[];
80
+ } | {
81
+ readonly ok: false;
82
+ readonly error: string;
83
+ readonly projects: readonly [];
84
+ };
85
+ export type ProjectInitProjectStatusFieldInput = {
86
+ readonly projectRoot: string;
87
+ readonly projectId: string;
88
+ readonly token?: string | null | undefined;
89
+ };
90
+ export type ProjectInitProjectStatusFieldResult = {
91
+ readonly ok: true;
92
+ readonly field: GitHubProjectStatusField;
93
+ } | {
94
+ readonly ok: false;
95
+ readonly error: string;
96
+ };
97
+ export type ProjectRepoSlug = {
98
+ readonly owner: string;
99
+ readonly repo: string;
100
+ readonly slug: string;
101
+ };
102
+ export type RigConfigStatus = {
103
+ readonly exists: boolean;
104
+ readonly valid: boolean;
105
+ readonly path: string;
106
+ readonly slug: string | null;
107
+ readonly reason?: string;
108
+ };
109
+ export type RigStateStatus = {
110
+ readonly valid: boolean;
111
+ readonly selected: string | null;
112
+ readonly project: string | null;
113
+ readonly reason?: string;
114
+ };
115
+ export type RigAuthValidation = {
116
+ readonly ok: boolean;
117
+ readonly source: "stored-token" | "gh" | "missing";
118
+ readonly login?: string | null;
119
+ readonly detail: string;
120
+ readonly status?: GitHubAuthStatus;
121
+ };
122
+ export type RigSetupStatus = {
123
+ readonly configured: boolean;
124
+ readonly projectRoot: string;
125
+ readonly slug: string | null;
126
+ readonly config: RigConfigStatus;
127
+ readonly state: RigStateStatus;
128
+ readonly auth: RigAuthValidation;
129
+ readonly reasons: readonly string[];
130
+ };
131
+ export type ProjectSetupResult = {
132
+ readonly repoSlug: string;
133
+ readonly placement: string;
134
+ readonly configWritten: boolean;
135
+ readonly labels: unknown;
136
+ readonly pi: unknown;
137
+ readonly status: RigSetupStatus;
138
+ };
139
+ /** The cohesive project-setup operation the CLI surface depends on. Async methods do IO. */
140
+ export interface ProjectSetupService {
141
+ parseRepoSlug(value: string): ProjectRepoSlug;
142
+ detectOriginRepoSlug(input: {
143
+ readonly projectRoot: string;
144
+ }): string | null;
145
+ detectStartupStatus(input: {
146
+ readonly projectRoot: string;
147
+ }): Promise<RigSetupStatus>;
148
+ runSetup(input: ProjectSetupInput): Promise<ProjectSetupResult>;
149
+ listGitHubProjectsForInit(input: ProjectInitGitHubProjectsInput): Promise<ProjectInitGitHubProjectsResult>;
150
+ getGitHubProjectStatusFieldForInit(input: ProjectInitProjectStatusFieldInput): Promise<ProjectInitProjectStatusFieldResult>;
151
+ runInit(input: ProjectInitInput): Promise<ProjectInitResult>;
152
+ }
153
+ /** Typed capability id; string value is {@link PROJECT_SETUP_CAPABILITY_ID}. */
154
+ export declare const PROJECT_SETUP: CapabilityId<ProjectSetupService>;
@@ -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/setup.ts
8
+ var PROJECT_SETUP_CAPABILITY_ID = "cap:project-setup";
9
+ var PROJECT_SETUP = makeCapabilityId(PROJECT_SETUP_CAPABILITY_ID);
10
+ export {
11
+ PROJECT_SETUP_CAPABILITY_ID,
12
+ PROJECT_SETUP
13
+ };