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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) hide show
  1. package/dist/index.cjs +3442 -0
  2. package/dist/index.mjs +3401 -0
  3. package/dist/src/agent-roles.d.ts +8 -0
  4. package/dist/src/artifact.d.ts +13 -0
  5. package/dist/src/artifact.js +3 -0
  6. package/dist/src/baseSchemas.d.ts +63 -0
  7. package/dist/src/baseSchemas.js +6 -0
  8. package/dist/src/blocker-classifier.d.ts +21 -0
  9. package/dist/src/blocker-classifier.js +13 -0
  10. package/dist/src/browser.d.ts +80 -0
  11. package/dist/src/browser.js +13 -0
  12. package/dist/src/capability-id.d.ts +22 -0
  13. package/dist/src/capability-id.js +8 -0
  14. package/dist/src/cli-output.d.ts +348 -0
  15. package/dist/src/cli-output.js +190 -0
  16. package/dist/src/cli-runner.d.ts +43 -0
  17. package/dist/src/cli-runner.js +13 -0
  18. package/dist/src/cockpit.d.ts +58 -0
  19. package/dist/src/cockpit.js +13 -0
  20. package/dist/src/collab-session-viewer.d.ts +36 -0
  21. package/dist/src/collab-session-viewer.js +13 -0
  22. package/dist/src/config.d.ts +553 -0
  23. package/dist/src/config.js +767 -162
  24. package/dist/src/control-plane-types.d.ts +323 -0
  25. package/dist/src/control-plane-types.js +13 -0
  26. package/dist/src/conversation.d.ts +50 -0
  27. package/dist/src/conversation.js +3 -0
  28. package/dist/src/dependency-preflight.d.ts +43 -0
  29. package/dist/src/dependency-preflight.js +13 -0
  30. package/dist/src/docs-drift.d.ts +10 -0
  31. package/dist/src/docs-drift.js +12 -0
  32. package/dist/src/doctor.d.ts +90 -0
  33. package/dist/src/doctor.js +13 -0
  34. package/dist/src/drift.d.ts +28 -0
  35. package/dist/src/drift.js +69 -0
  36. package/dist/src/editor.d.ts +25 -0
  37. package/dist/src/editor.js +3 -0
  38. package/dist/src/errors.d.ts +13 -0
  39. package/dist/src/errors.js +17 -0
  40. package/dist/src/git.d.ts +152 -0
  41. package/dist/src/git.js +3 -0
  42. package/dist/src/github.d.ts +295 -0
  43. package/dist/src/github.js +17 -0
  44. package/dist/src/graph.d.ts +360 -0
  45. package/dist/src/graph.js +137 -1
  46. package/dist/src/guard.d.ts +118 -0
  47. package/dist/src/guard.js +15 -0
  48. package/dist/src/harness-events.d.ts +8 -0
  49. package/dist/src/harness-events.js +1 -0
  50. package/dist/src/harness-profile-state.d.ts +10 -0
  51. package/dist/src/harness-profile-state.js +13 -0
  52. package/dist/src/help-catalog.d.ts +41 -0
  53. package/dist/src/help-catalog.js +13 -0
  54. package/dist/src/host.d.ts +41 -0
  55. package/dist/src/host.js +13 -0
  56. package/dist/src/identity.d.ts +44 -0
  57. package/dist/src/identity.js +1 -0
  58. package/dist/src/index.d.ts +98 -0
  59. package/dist/src/index.js +2605 -3752
  60. package/dist/src/isolation.d.ts +213 -0
  61. package/dist/src/isolation.js +13 -0
  62. package/dist/src/kernel.d.ts +200 -0
  63. package/dist/src/kernel.js +261 -0
  64. package/dist/src/keybindings.d.ts +71 -0
  65. package/dist/src/keybindings.js +3 -0
  66. package/dist/src/layout.d.ts +44 -0
  67. package/dist/src/layout.js +8 -0
  68. package/dist/src/lifecycle-capabilities.d.ts +224 -0
  69. package/dist/src/lifecycle-capabilities.js +45 -0
  70. package/dist/src/managed-repos.d.ts +339 -0
  71. package/dist/src/managed-repos.js +37 -0
  72. package/dist/src/memory.d.ts +199 -0
  73. package/dist/src/memory.js +15 -0
  74. package/dist/src/model.d.ts +13 -0
  75. package/dist/src/model.js +3 -58
  76. package/dist/src/native-toolchain.d.ts +46 -0
  77. package/dist/src/native-toolchain.js +13 -0
  78. package/dist/src/notify.d.ts +46 -0
  79. package/dist/src/notify.js +13 -0
  80. package/dist/src/orchestration.d.ts +43 -0
  81. package/dist/src/orchestration.js +28 -961
  82. package/dist/src/panel-protocol.d.ts +17 -0
  83. package/dist/src/panel-protocol.js +10 -0
  84. package/dist/src/pi-session.d.ts +113 -0
  85. package/dist/src/pi-session.js +1 -0
  86. package/dist/src/placement.d.ts +47 -0
  87. package/dist/src/placement.js +13 -0
  88. package/dist/src/planning.d.ts +64 -0
  89. package/dist/src/planning.js +90 -0
  90. package/dist/src/plugin-hooks.d.ts +51 -0
  91. package/dist/src/plugin-hooks.js +386 -0
  92. package/dist/src/plugin.d.ts +476 -0
  93. package/dist/src/plugin.js +346 -64
  94. package/dist/src/policy.d.ts +16 -0
  95. package/dist/src/policy.js +3 -0
  96. package/dist/src/product-entrypoint.d.ts +22 -0
  97. package/dist/src/product-entrypoint.js +13 -0
  98. package/dist/src/project.d.ts +71 -0
  99. package/dist/src/project.js +3 -0
  100. package/dist/src/prompt.d.ts +29 -0
  101. package/dist/src/prompt.js +13 -0
  102. package/dist/src/protocol-version.d.ts +21 -0
  103. package/dist/src/protocol-version.js +6 -0
  104. package/dist/src/provider-instructions.d.ts +41 -0
  105. package/dist/src/provider-instructions.js +13 -0
  106. package/dist/src/provider.d.ts +105 -0
  107. package/dist/src/provider.js +16 -835
  108. package/dist/src/remote-control.d.ts +93 -0
  109. package/dist/src/remote-control.js +26 -0
  110. package/dist/src/remote.d.ts +318 -0
  111. package/dist/src/remote.js +238 -1078
  112. package/dist/src/review.d.ts +18 -0
  113. package/dist/src/review.js +3 -0
  114. package/dist/src/rollups.d.ts +41 -0
  115. package/dist/src/rollups.js +70 -0
  116. package/dist/src/run-control.d.ts +164 -0
  117. package/dist/src/run-control.js +13 -0
  118. package/dist/src/run-discovery.d.ts +83 -0
  119. package/dist/src/run-discovery.js +13 -0
  120. package/dist/src/run-dispatch.d.ts +34 -0
  121. package/dist/src/run-dispatch.js +13 -0
  122. package/dist/src/run-identity.d.ts +47 -0
  123. package/dist/src/run-identity.js +13 -0
  124. package/dist/src/run-journal.d.ts +694 -0
  125. package/dist/src/run-journal.js +569 -0
  126. package/dist/src/run-queue.d.ts +36 -0
  127. package/dist/src/run-queue.js +13 -0
  128. package/dist/src/run-read-model.d.ts +200 -0
  129. package/dist/src/run-read-model.js +13 -0
  130. package/dist/src/run-record.d.ts +45 -0
  131. package/dist/src/run-record.js +1 -0
  132. package/dist/src/run-registry-backbone.d.ts +56 -0
  133. package/dist/src/run-registry-backbone.js +13 -0
  134. package/dist/src/run-session-journal.d.ts +154 -0
  135. package/dist/src/run-session-journal.js +87 -0
  136. package/dist/src/run-status.d.ts +10 -0
  137. package/dist/src/run-status.js +27 -0
  138. package/dist/src/run-timeline.d.ts +7 -0
  139. package/dist/src/run-timeline.js +1 -0
  140. package/dist/src/runtime-secrets.d.ts +10 -0
  141. package/dist/src/runtime-secrets.js +13 -0
  142. package/dist/src/runtime-task-context.d.ts +82 -0
  143. package/dist/src/runtime-task-context.js +1 -0
  144. package/dist/src/runtime.d.ts +103 -0
  145. package/dist/src/runtime.js +73 -906
  146. package/dist/src/session-asset-materializer.d.ts +35 -0
  147. package/dist/src/session-asset-materializer.js +13 -0
  148. package/dist/src/session-hook-materializer.d.ts +41 -0
  149. package/dist/src/session-hook-materializer.js +13 -0
  150. package/dist/src/setup.d.ts +154 -0
  151. package/dist/src/setup.js +13 -0
  152. package/dist/src/stage.d.ts +245 -0
  153. package/dist/src/stage.js +169 -0
  154. package/dist/src/supervisor-journal.d.ts +204 -0
  155. package/dist/src/supervisor-journal.js +336 -0
  156. package/dist/src/supervisor-loop.d.ts +40 -0
  157. package/dist/src/supervisor-loop.js +13 -0
  158. package/dist/src/task-artifacts.d.ts +53 -0
  159. package/dist/src/task-artifacts.js +13 -0
  160. package/dist/src/task-config.d.ts +22 -0
  161. package/dist/src/task-config.js +1 -0
  162. package/dist/src/task-context-renderer.d.ts +29 -0
  163. package/dist/src/task-context-renderer.js +13 -0
  164. package/dist/src/task-data.d.ts +196 -0
  165. package/dist/src/task-data.js +13 -0
  166. package/dist/src/task-graph-primitives.d.ts +47 -0
  167. package/dist/src/task-graph-primitives.js +1 -0
  168. package/dist/src/task-source.d.ts +167 -0
  169. package/dist/src/task-source.js +24 -0
  170. package/dist/src/task-state-metadata.d.ts +21 -0
  171. package/dist/src/task-state-metadata.js +1 -0
  172. package/dist/src/task-state-paths.d.ts +14 -0
  173. package/dist/src/task-state-paths.js +13 -0
  174. package/dist/src/task-state-store.d.ts +36 -0
  175. package/dist/src/task-state-store.js +17 -0
  176. package/dist/src/task-tracker-state.d.ts +101 -0
  177. package/dist/src/task-tracker-state.js +39 -0
  178. package/dist/src/terminal.d.ts +130 -0
  179. package/dist/src/terminal.js +3 -0
  180. package/dist/src/tool-materializer.d.ts +36 -0
  181. package/dist/src/tool-materializer.js +13 -0
  182. package/dist/src/tool-registry.d.ts +3 -0
  183. package/dist/src/tool-registry.js +58 -0
  184. package/dist/src/toolchain-sources.d.ts +54 -0
  185. package/dist/src/toolchain-sources.js +17 -0
  186. package/dist/src/transport-config.d.ts +161 -0
  187. package/dist/src/transport-config.js +15 -0
  188. package/dist/src/validation.d.ts +14 -0
  189. package/dist/src/validation.js +3 -0
  190. package/dist/src/workflow-journal.d.ts +125 -0
  191. package/dist/src/workflow-journal.js +27 -0
  192. package/dist/src/workspace-config.d.ts +18 -0
  193. package/dist/src/workspace-config.js +13 -0
  194. package/dist/src/workspace-service.d.ts +16 -0
  195. package/dist/src/workspace-service.js +13 -0
  196. package/dist/src/workspace.d.ts +204 -0
  197. package/dist/src/workspace.js +76 -911
  198. package/package.json +55 -4
  199. package/dist/src/engine.js +0 -2278
  200. package/dist/src/providerRuntime.js +0 -1630
  201. package/dist/src/rig.js +0 -2374
  202. package/dist/src/server.js +0 -1053
  203. package/dist/src/serviceFabric.js +0 -1066
  204. package/dist/src/ws.js +0 -2968
  205. /package/dist/src/{ipc.js → agent-roles.js} +0 -0
@@ -0,0 +1,339 @@
1
+ /**
2
+ * Pure managed-repo, repo-operation, and repo-native git contract types + capability ids.
3
+ *
4
+ * `@rig/repos-plugin` owns the concrete implementations. It contributes:
5
+ * - `ManagedRepoService` under {@link MANAGED_REPO_SERVICE_CAPABILITY_ID} for
6
+ * registry/layout/mirror state,
7
+ * - `RepoOperationsService` under {@link REPO_OPERATIONS_CAPABILITY_ID} for
8
+ * task repo pinning, baseline reset, and project-main pre-run sync,
9
+ * - `RepoNativeGitService` under {@link REPO_NATIVE_GIT_CAPABILITY_ID} for
10
+ * repo-native git command wrappers,
11
+ * - `RepoGitBinaryService` under {@link REPO_GIT_BINARY_CAPABILITY_ID} for
12
+ * the repo-owned rig-git helper binary, and
13
+ * - `RepoTrackerPersistenceService` under {@link REPO_TRACKER_PERSISTENCE_CAPABILITY_ID}
14
+ * for mechanical tracker snapshot reads and owner-supplied mutation persistence.
15
+ *
16
+ * This module carries no behaviour and imports only pure sibling types, so
17
+ * consumers resolve typed ids through `@rig/core` without importing the provider
18
+ * plugin or the old kernel repo-ops facades.
19
+ */
20
+ import type { CapabilityId } from "./capability-id";
21
+ import type { RepoSourceRegistration } from "./plugin";
22
+ import type { GitWorkingTreeFileChange } from "./git";
23
+ import type { NativeToolchainBinaryArtifact, NativeToolchainTarget } from "./native-toolchain";
24
+ import type { SyncedTrackerSnapshot, ReadSyncedTrackerOptions } from "./task-data";
25
+ import type { CanonicalTaskLifecycleStatus, TaskStateMetadata } from "./task-state-metadata";
26
+ export type ManagedRepoId = string;
27
+ export type ManagedRepoAlias = string;
28
+ export type ManagedRepoHealth = "missing" | "ready" | "stale" | "misconfigured";
29
+ export type ManagedRepoRegistryEntry = {
30
+ id: ManagedRepoId;
31
+ alias: ManagedRepoAlias;
32
+ defaultBranch: string;
33
+ defaultRemoteUrl: string;
34
+ remoteEnvVar?: string;
35
+ checkoutEnvVar?: string;
36
+ };
37
+ export type ManagedRepoLayout = {
38
+ projectRoot: string;
39
+ repoId: ManagedRepoId;
40
+ alias: ManagedRepoAlias;
41
+ defaultBranch: string;
42
+ remoteUrl: string;
43
+ checkoutRoot: string;
44
+ worktreesRoot: string;
45
+ stateDir: string;
46
+ metadataRoot: string;
47
+ metadataRelativePath: string;
48
+ mirrorRoot: string;
49
+ mirrorStatePath: string;
50
+ mirrorStateRelativePath: string;
51
+ };
52
+ export type ManagedRepoMirrorState = {
53
+ version: 1;
54
+ repoId: ManagedRepoId;
55
+ remoteUrl: string;
56
+ defaultBranch: string;
57
+ initializedAt?: string;
58
+ lastSyncedAt?: string;
59
+ headRef?: string;
60
+ headCommit?: string;
61
+ };
62
+ export type ManagedRepoSyncResult = {
63
+ layout: ManagedRepoLayout;
64
+ headCommit: string;
65
+ };
66
+ /** A repo registration plus an optional computed local checkout path. */
67
+ export interface RepoEntry extends RepoSourceRegistration {
68
+ /** Optional computed local checkout path (runtime-specific, may be set by caller). */
69
+ localPath?: string;
70
+ }
71
+ /** An immutable, id-indexed view over plugin-contributed repo sources. */
72
+ export interface RepoRegistry {
73
+ getById(id: string): RepoEntry | undefined;
74
+ list(): readonly RepoEntry[];
75
+ }
76
+ /**
77
+ * The cohesive set of managed-repo operations the runtime substrate depends on.
78
+ * The plugin provides a concrete impl (statically checked against this interface
79
+ * via `defineCapability(MANAGED_REPO_SERVICE_CAPABILITY).provide`); the substrate
80
+ * only ever sees this port, resolved by id off a plugin host with no cast.
81
+ */
82
+ export interface ManagedRepoService {
83
+ /** Replace the managed-repo singleton with the given entries (boot wiring). */
84
+ setManagedRepos(entries: readonly ManagedRepoRegistryEntry[]): void;
85
+ /** List the currently registered managed-repo entries. */
86
+ listManagedRepoEntries(): ManagedRepoRegistryEntry[];
87
+ /** Resolve a managed-repo id from its alias, or null when unknown. */
88
+ resolveManagedRepoIdByAlias(alias: string): ManagedRepoId | null;
89
+ /**
90
+ * Convert a plugin-contributed RepoSourceRegistration into the managed-repo
91
+ * entry shape; null for pure-listing registrations (no defaultBranch).
92
+ */
93
+ repoRegistrationToManagedEntry(reg: RepoSourceRegistration): ManagedRepoRegistryEntry | null;
94
+ /** Build an immutable id-indexed registry from repo source registrations. */
95
+ createRepoRegistry(entries: readonly RepoSourceRegistration[]): RepoRegistry;
96
+ /** Resolve a managed repo's on-disk layout by alias, or null when unknown. */
97
+ resolveManagedRepoLayoutByAlias(projectRoot: string, alias: string): ManagedRepoLayout | null;
98
+ /** Resolve the primary monorepo layout; throws when no managed repos exist. */
99
+ resolveMonorepoRepoLayout(projectRoot: string): ManagedRepoLayout;
100
+ /** Refresh + sync a managed repo's mirror, returning the resulting head. */
101
+ syncManagedRepo(projectRoot: string, repoId: ManagedRepoId): ManagedRepoSyncResult;
102
+ }
103
+ export type RepoPins = Record<string, string>;
104
+ export type RepoNativeGitTreeCommitUpdate = {
105
+ readonly path: string;
106
+ readonly content: string;
107
+ readonly executable?: boolean;
108
+ } | {
109
+ readonly path: string;
110
+ readonly sourceFilePath: string;
111
+ readonly executable?: boolean;
112
+ } | {
113
+ readonly path: string;
114
+ readonly delete: true;
115
+ };
116
+ export type RepoNativeGitPendingFile = {
117
+ readonly path: string;
118
+ readonly status: string;
119
+ };
120
+ export type RepoNativeGitCommandResult = {
121
+ readonly exitCode: number;
122
+ readonly stdout: string;
123
+ readonly stderr: string;
124
+ };
125
+ export type RepoNativeGitRunOptions = {
126
+ /** Project root used to derive runtime git environment/secrets when different from repoPath. */
127
+ readonly projectRoot?: string;
128
+ readonly input?: string;
129
+ readonly env?: Readonly<Record<string, string | undefined>>;
130
+ };
131
+ export type RepoNativeGitCommitOptions = {
132
+ readonly message: string;
133
+ readonly allowEmpty?: boolean;
134
+ /** Explicit repo-relative paths to stage. Provider may use pathspec files to avoid argv limits. */
135
+ readonly paths?: readonly string[];
136
+ /** Stage all repo changes except excludes when no explicit paths are provided. */
137
+ readonly stageAll?: boolean;
138
+ readonly excludePathspecs?: readonly string[];
139
+ readonly projectRoot?: string;
140
+ };
141
+ export type RepoNativeGitCommitResult = {
142
+ readonly committed: boolean;
143
+ readonly status: string;
144
+ readonly stagedChangeCount: number;
145
+ readonly stagedPathCount: number;
146
+ };
147
+ export type RepoNativeGitCheckoutOptions = {
148
+ readonly createIfMissing?: boolean;
149
+ readonly resetIfDetachedExisting?: boolean;
150
+ readonly projectRoot?: string;
151
+ };
152
+ export type RepoNativeGitPushBranchOptions = {
153
+ readonly remote?: string;
154
+ readonly setUpstream?: boolean;
155
+ readonly forceWithLease?: boolean;
156
+ readonly projectRoot?: string;
157
+ };
158
+ export type RepoNativeGitRemoteDispatchCheckoutInput = {
159
+ /**
160
+ * Shell expression for the checkout path, e.g. "$CHECKOUT" or "$HOME/.rig/checkouts/repo".
161
+ * The caller owns quoting this path expression before passing it across the seam.
162
+ */
163
+ readonly checkoutExpression: string;
164
+ /** Shell expression that points at the materialized github-auth.json temp file. */
165
+ readonly authStateFileExpression: string;
166
+ /** Shell expression that points at a temp executable credential-helper file. */
167
+ readonly credentialHelperFileExpression: string;
168
+ readonly originUrl?: string | null;
169
+ readonly operatorHead: string;
170
+ };
171
+ /**
172
+ * Repo-owned native git command seam. Implementations live in `@rig/repos-plugin`;
173
+ * native-toolchain only builds/materializes binaries and does not own repo or git
174
+ * workflow semantics. Lifecycle and other consumers keep policy decisions but
175
+ * delegate checkout/stage/commit/fetch/push mechanics through this capability.
176
+ */
177
+ export interface RepoNativeGitService {
178
+ run(repoPath: string, args: readonly string[], options?: RepoNativeGitRunOptions): RepoNativeGitCommandResult;
179
+ branchName(repoPath: string, projectRoot?: string): string | null;
180
+ headOid(repoPath: string, projectRoot?: string): string | null;
181
+ githubOriginSlug(repoPath: string, projectRoot?: string): string | null;
182
+ changeCount(repoPath: string, projectRoot?: string): number | null;
183
+ pendingFiles(repoPath: string, projectRoot?: string): readonly RepoNativeGitPendingFile[] | null;
184
+ fileHasChanges(repoPath: string, filePath: string, projectRoot?: string): boolean | null;
185
+ checkoutBranch(repoPath: string, branch: string, options?: RepoNativeGitCheckoutOptions): RepoNativeGitCommandResult;
186
+ commit(repoPath: string, options: RepoNativeGitCommitOptions): RepoNativeGitCommitResult;
187
+ pushBranch(repoPath: string, branch: string, options?: RepoNativeGitPushBranchOptions): RepoNativeGitCommandResult;
188
+ remoteDispatchCheckoutShell(input: RepoNativeGitRemoteDispatchCheckoutInput): readonly string[];
189
+ fetchRef(repoPath: string, remote: string, branch: string): string;
190
+ readBlobAtRef(repoPath: string, ref: string, path: string): string;
191
+ readBlobBytesAtRef(repoPath: string, ref: string, path: string): Uint8Array;
192
+ writeTreeCommit(repoPath: string, baseRef: string, updates: readonly RepoNativeGitTreeCommitUpdate[], message: string): string;
193
+ pushRefWithLease(repoPath: string, localOid: string, remoteRef: string, expectedOldOid: string, remote?: string): string;
194
+ }
195
+ /**
196
+ * Repo-native git is intentionally named from repos contracts. The capability id
197
+ * remains `native-toolchain.git` for compatibility with already published
198
+ * providers/consumers; treat that string as a legacy wire id, not ownership.
199
+ */
200
+ export declare const REPO_NATIVE_GIT_CAPABILITY_ID = "native-toolchain.git";
201
+ export declare const REPO_NATIVE_GIT: CapabilityId<RepoNativeGitService>;
202
+ /** @deprecated Use RepoNativeGitTreeCommitUpdate. */
203
+ export type NativeGitTreeCommitUpdate = RepoNativeGitTreeCommitUpdate;
204
+ /** @deprecated Use RepoNativeGitService. */
205
+ export type NativeGitService = RepoNativeGitService;
206
+ /** @deprecated Use REPO_NATIVE_GIT_CAPABILITY_ID; this is the legacy wire id. */
207
+ export declare const NATIVE_TOOLCHAIN_GIT_CAPABILITY_ID = "native-toolchain.git";
208
+ /** @deprecated Use REPO_NATIVE_GIT. */
209
+ export declare const NATIVE_TOOLCHAIN_GIT: CapabilityId<RepoNativeGitService>;
210
+ export interface RepoGitBinaryResolveInput {
211
+ readonly projectRoot?: string;
212
+ readonly target?: NativeToolchainTarget;
213
+ }
214
+ export interface RepoGitBinaryMaterializeInput {
215
+ readonly projectRoot: string;
216
+ readonly targetDir: string;
217
+ readonly target?: NativeToolchainTarget;
218
+ }
219
+ export interface RepoGitBinaryArtifact extends NativeToolchainBinaryArtifact {
220
+ readonly name: "rig-git";
221
+ readonly kind: "executable";
222
+ readonly commandName: string;
223
+ }
224
+ export interface RepoGitBinaryService {
225
+ gitHelperBinaryName(input?: RepoGitBinaryResolveInput): string;
226
+ resolveGitHelperBinary(input?: RepoGitBinaryResolveInput): RepoGitBinaryArtifact | null | Promise<RepoGitBinaryArtifact | null>;
227
+ materializeGitHelperBinary(input: RepoGitBinaryMaterializeInput): Promise<RepoGitBinaryArtifact>;
228
+ }
229
+ export declare const REPO_GIT_BINARY_CAPABILITY_ID = "repos.git-binary";
230
+ export declare const REPO_GIT_BINARY: CapabilityId<RepoGitBinaryService>;
231
+ export type ProjectMainPreRunSyncResult = {
232
+ status: "disabled";
233
+ } | {
234
+ status: "skipped_not_main";
235
+ branch: string;
236
+ } | {
237
+ status: "up_to_date";
238
+ } | {
239
+ status: "local_ahead";
240
+ localAhead: number;
241
+ } | {
242
+ status: "updated";
243
+ remoteAhead: number;
244
+ };
245
+ export type ProjectMainPreRunSyncOptions = {
246
+ projectRoot: string;
247
+ disabled?: boolean;
248
+ runBootstrap: () => Promise<void>;
249
+ syncMonorepo?: (projectRoot: string) => void | Promise<void>;
250
+ };
251
+ export type RepoChangeSetSelector = {
252
+ readonly kind: "task";
253
+ readonly taskId: string;
254
+ readonly scoped: boolean;
255
+ } | {
256
+ readonly kind: "scope";
257
+ readonly paths: readonly string[];
258
+ } | {
259
+ readonly kind: "workspace";
260
+ };
261
+ export type RepoChangeSetTarget = {
262
+ readonly kind: "project";
263
+ readonly projectRoot: string;
264
+ } | {
265
+ readonly kind: "managed-repo";
266
+ readonly projectRoot: string;
267
+ readonly repoId: ManagedRepoId;
268
+ } | {
269
+ readonly kind: "repo-root";
270
+ readonly repoRoot: string;
271
+ readonly projectRoot?: string;
272
+ };
273
+ export interface RepoChangeSetInput {
274
+ readonly projectRoot: string;
275
+ readonly selector: RepoChangeSetSelector;
276
+ readonly target?: RepoChangeSetTarget;
277
+ }
278
+ export interface RepoChangeSetFile extends GitWorkingTreeFileChange {
279
+ readonly repoRoot: string;
280
+ readonly repoId?: ManagedRepoId;
281
+ }
282
+ export interface RepoChangeSet {
283
+ readonly changedFiles: readonly RepoChangeSetFile[];
284
+ readonly pendingFiles: readonly RepoChangeSetFile[];
285
+ }
286
+ export interface RepoChangeSetService {
287
+ collectChangeSet(input: RepoChangeSetInput): RepoChangeSet | Promise<RepoChangeSet>;
288
+ changedFiles(input: RepoChangeSetInput): readonly RepoChangeSetFile[] | Promise<readonly RepoChangeSetFile[]>;
289
+ pendingFiles(input: RepoChangeSetInput): readonly RepoChangeSetFile[] | Promise<readonly RepoChangeSetFile[]>;
290
+ }
291
+ export declare const REPO_CHANGE_SET_CAPABILITY_ID = "repos.change-set";
292
+ export declare const REPO_CHANGE_SET: CapabilityId<RepoChangeSetService>;
293
+ export interface RepoOperationsService {
294
+ repoEnsure(projectRoot: string, taskId?: string): void;
295
+ repoPins(projectRoot: string, taskId?: string): RepoPins;
296
+ repoVerify(projectRoot: string, taskId?: string): boolean;
297
+ repoDiscover(projectRoot: string, taskId?: string): RepoPins;
298
+ repoBaseline(projectRoot: string, refresh?: boolean): RepoPins;
299
+ recordTaskRepoCommits(projectRoot: string, taskId: string): void;
300
+ resetBaseline(projectRoot: string, keepTaskStatus: boolean): void;
301
+ ensureProjectMainFreshBeforeRun(options: ProjectMainPreRunSyncOptions): Promise<ProjectMainPreRunSyncResult>;
302
+ }
303
+ export declare const REPO_OPERATIONS_CAPABILITY_ID = "repos.operations";
304
+ export declare const REPO_OPERATIONS_CAPABILITY: CapabilityId<RepoOperationsService>;
305
+ export type RepoTrackerPersistenceMutationResult = {
306
+ readonly outcome: "applied" | "noop";
307
+ readonly snapshot: SyncedTrackerSnapshot;
308
+ readonly commitOid: string | null;
309
+ };
310
+ export type RepoTrackerPersistenceMutation = {
311
+ readonly taskId: string;
312
+ readonly lifecycleStatus: CanonicalTaskLifecycleStatus;
313
+ readonly metadata?: TaskStateMetadata | null;
314
+ /** Mechanical owner-supplied compare-and-set precondition. */
315
+ readonly expectedLifecycleStatus?: CanonicalTaskLifecycleStatus | readonly CanonicalTaskLifecycleStatus[];
316
+ };
317
+ export type RepoTrackerPersistenceMutationsInput = {
318
+ readonly projectRoot: string;
319
+ readonly mutations: readonly RepoTrackerPersistenceMutation[];
320
+ readonly reason?: string;
321
+ };
322
+ export interface RepoTrackerPersistenceService {
323
+ readSnapshot(projectRoot: string, options?: ReadSyncedTrackerOptions): SyncedTrackerSnapshot;
324
+ persistMutations(input: RepoTrackerPersistenceMutationsInput): RepoTrackerPersistenceMutationResult;
325
+ }
326
+ export declare const REPO_TRACKER_PERSISTENCE_CAPABILITY_ID = "repos.tracker-persistence";
327
+ export declare const REPO_TRACKER_PERSISTENCE: CapabilityId<RepoTrackerPersistenceService>;
328
+ /** The capability `run` shape the plugin registers: a (lazy) service factory. */
329
+ export type ManagedRepoServiceCapabilityRun = () => ManagedRepoService | Promise<ManagedRepoService>;
330
+ /** Capability id the managed-repo service plugin registers its factory under. */
331
+ export declare const MANAGED_REPO_SERVICE_CAPABILITY_ID = "managed-repos.service";
332
+ /**
333
+ * The typed capability id the repos plugin provides and consumers require.
334
+ * Phantom-typed with {@link ManagedRepoService} so
335
+ * `defineCapability(MANAGED_REPO_SERVICE_CAPABILITY).resolve(host)` returns a
336
+ * `ManagedRepoService` with no cast leaking to callers. Its string value is
337
+ * {@link MANAGED_REPO_SERVICE_CAPABILITY_ID}, so it indexes the same host entry.
338
+ */
339
+ export declare const MANAGED_REPO_SERVICE_CAPABILITY: CapabilityId<ManagedRepoService>;
@@ -0,0 +1,37 @@
1
+ // @bun
2
+ // packages/contracts/src/capability-id.ts
3
+ function makeCapabilityId(id) {
4
+ return id;
5
+ }
6
+
7
+ // packages/contracts/src/managed-repos.ts
8
+ var REPO_NATIVE_GIT_CAPABILITY_ID = "native-toolchain.git";
9
+ var REPO_NATIVE_GIT = makeCapabilityId(REPO_NATIVE_GIT_CAPABILITY_ID);
10
+ var NATIVE_TOOLCHAIN_GIT_CAPABILITY_ID = REPO_NATIVE_GIT_CAPABILITY_ID;
11
+ var NATIVE_TOOLCHAIN_GIT = REPO_NATIVE_GIT;
12
+ var REPO_GIT_BINARY_CAPABILITY_ID = "repos.git-binary";
13
+ var REPO_GIT_BINARY = makeCapabilityId(REPO_GIT_BINARY_CAPABILITY_ID);
14
+ var REPO_CHANGE_SET_CAPABILITY_ID = "repos.change-set";
15
+ var REPO_CHANGE_SET = makeCapabilityId(REPO_CHANGE_SET_CAPABILITY_ID);
16
+ var REPO_OPERATIONS_CAPABILITY_ID = "repos.operations";
17
+ var REPO_OPERATIONS_CAPABILITY = makeCapabilityId(REPO_OPERATIONS_CAPABILITY_ID);
18
+ var REPO_TRACKER_PERSISTENCE_CAPABILITY_ID = "repos.tracker-persistence";
19
+ var REPO_TRACKER_PERSISTENCE = makeCapabilityId(REPO_TRACKER_PERSISTENCE_CAPABILITY_ID);
20
+ var MANAGED_REPO_SERVICE_CAPABILITY_ID = "managed-repos.service";
21
+ var MANAGED_REPO_SERVICE_CAPABILITY = makeCapabilityId(MANAGED_REPO_SERVICE_CAPABILITY_ID);
22
+ export {
23
+ REPO_TRACKER_PERSISTENCE_CAPABILITY_ID,
24
+ REPO_TRACKER_PERSISTENCE,
25
+ REPO_OPERATIONS_CAPABILITY_ID,
26
+ REPO_OPERATIONS_CAPABILITY,
27
+ REPO_NATIVE_GIT_CAPABILITY_ID,
28
+ REPO_NATIVE_GIT,
29
+ REPO_GIT_BINARY_CAPABILITY_ID,
30
+ REPO_GIT_BINARY,
31
+ REPO_CHANGE_SET_CAPABILITY_ID,
32
+ REPO_CHANGE_SET,
33
+ NATIVE_TOOLCHAIN_GIT_CAPABILITY_ID,
34
+ NATIVE_TOOLCHAIN_GIT,
35
+ MANAGED_REPO_SERVICE_CAPABILITY_ID,
36
+ MANAGED_REPO_SERVICE_CAPABILITY
37
+ };
@@ -0,0 +1,199 @@
1
+ /**
2
+ * Pure memory-service contract types.
3
+ *
4
+ * These types are the neutral home for the shared-memory data model so that the
5
+ * dumb runtime substrate (hooks, harness-cli, isolation, rig-agent) and the
6
+ * @rig/memory-plugin that owns the implementation can both reference them
7
+ * without a substrate->plugin import cycle. They carry no behaviour and import
8
+ * nothing — exactly like `lifecycle-capabilities.ts`.
9
+ *
10
+ * The plugin registers its executable `MemoryService` impl under the typed
11
+ * capability id {@link MEMORY} (whose string value is
12
+ * {@link MEMORY_SERVICE_CAPABILITY_ID}); the runtime resolves it by id from
13
+ * `pluginHost.listExecutableCapabilities()` via the `defineCapability` seam
14
+ * (`@rig/core/capability`), re-exported from the thin
15
+ * `@rig/runtime/control-plane/memory-service-port`.
16
+ */
17
+ import type { CapabilityId } from "./capability-id";
18
+ import type { RuntimeMemoryRetrievalConfig, RuntimeTaskContext } from "./runtime-task-context";
19
+ /** Capability id the memory plugin registers its `MemoryService` factory under. */
20
+ export declare const MEMORY_SERVICE_CAPABILITY_ID = "memory.service";
21
+ export declare const NO_MATCH_RETRIEVAL_CANONICAL_KEY = "__memory_recall__:none";
22
+ export type MemoryDbStatement = {
23
+ sql: string;
24
+ args?: unknown[];
25
+ };
26
+ export type MemoryDbExecuteResult = {
27
+ rows: Array<Record<string, unknown>>;
28
+ rowsAffected?: number;
29
+ };
30
+ export type MemoryDbTransaction = {
31
+ execute(statement: MemoryDbStatement | string, args?: unknown[]): Promise<MemoryDbExecuteResult>;
32
+ commit(): Promise<void>;
33
+ rollback(): Promise<void>;
34
+ close(): void;
35
+ };
36
+ export type MemoryDbClient = {
37
+ execute(statement: MemoryDbStatement | string, args?: unknown[]): Promise<MemoryDbExecuteResult>;
38
+ transaction(mode: "write"): Promise<MemoryDbTransaction>;
39
+ close(): void;
40
+ };
41
+ export type MemoryEventType = "observed" | "promoted" | "corrected" | "superseded" | "retracted" | "reinforced" | "retrieved" | "feedback_recorded";
42
+ export type MemoryStatus = "active" | "superseded" | "retracted";
43
+ export type RetrievalFeedbackOutcome = "helpful" | "ignored" | "incorrect";
44
+ type MemoryEventBase = {
45
+ eventId: string;
46
+ canonicalKey: string;
47
+ sourceRunId?: string | null;
48
+ sourceTaskId?: string | null;
49
+ branch?: string | null;
50
+ createdAt: string;
51
+ };
52
+ type MemoryProjectionSeed = {
53
+ summary: string;
54
+ kind: string;
55
+ category?: string | null;
56
+ confidence: number;
57
+ details?: Record<string, unknown> | null;
58
+ };
59
+ export type MemoryEventInput = (MemoryEventBase & MemoryProjectionSeed & {
60
+ eventType: "observed";
61
+ }) | (MemoryEventBase & MemoryProjectionSeed & {
62
+ eventType: "promoted";
63
+ sourceCanonicalKey: string;
64
+ }) | (MemoryEventBase & MemoryProjectionSeed & {
65
+ eventType: "corrected";
66
+ sourceCanonicalKey: string;
67
+ }) | (MemoryEventBase & {
68
+ eventType: "superseded";
69
+ replacementCanonicalKey: string;
70
+ }) | (MemoryEventBase & {
71
+ eventType: "retracted";
72
+ }) | (MemoryEventBase & {
73
+ eventType: "reinforced";
74
+ confidence: number;
75
+ }) | (MemoryEventBase & {
76
+ eventType: "retrieved";
77
+ retrievalQuery: string;
78
+ retrievalRank: number;
79
+ }) | (MemoryEventBase & {
80
+ eventType: "feedback_recorded";
81
+ feedbackOutcome: RetrievalFeedbackOutcome;
82
+ retrievalRank: number;
83
+ retrievalQuery?: string | null;
84
+ });
85
+ export type MemoryEventMetadata = {
86
+ sourceCanonicalKey?: string | null;
87
+ replacementCanonicalKey?: string | null;
88
+ retrievalQuery?: string | null;
89
+ retrievalRank?: number | null;
90
+ feedbackOutcome?: RetrievalFeedbackOutcome | null;
91
+ summary?: string | null;
92
+ kind?: string | null;
93
+ category?: string | null;
94
+ confidence?: number | null;
95
+ details?: Record<string, unknown> | null;
96
+ };
97
+ export type MemoryEventRow = {
98
+ eventId: string;
99
+ eventType: MemoryEventType;
100
+ canonicalKey: string;
101
+ summary: string;
102
+ createdAt: string;
103
+ };
104
+ export type MemoryItemRow = {
105
+ canonicalKey: string;
106
+ summary: string;
107
+ kind: string | null;
108
+ category: string | null;
109
+ status: MemoryStatus;
110
+ confidence: number;
111
+ sourceRunId: string | null;
112
+ sourceTaskId: string | null;
113
+ branch: string | null;
114
+ details: Record<string, unknown> | null;
115
+ createdAt: string;
116
+ updatedAt: string;
117
+ lastEventId: string;
118
+ supersededBy: string | null;
119
+ embedding: number[] | null;
120
+ };
121
+ export type MemoryQueryOptions = {
122
+ canonicalKey?: string;
123
+ includeInactive?: boolean;
124
+ };
125
+ export type MemoryDb = {
126
+ path: string;
127
+ client: MemoryDbClient;
128
+ close(): Promise<void>;
129
+ };
130
+ /** A scored, ranked shared-memory item returned by the retrieval query. */
131
+ export type MemoryQueryResult = {
132
+ canonicalKey: string;
133
+ summary: string;
134
+ kind: string | null;
135
+ category: string | null;
136
+ confidence: number;
137
+ updatedAt: string;
138
+ score: number;
139
+ lexicalScore: number;
140
+ vectorScore: number;
141
+ recencyScore: number;
142
+ };
143
+ /** Embeds text into vectors for memory retrieval; provider-agnostic. */
144
+ export type MemoryEmbedder = {
145
+ embed(texts: string[]): Promise<number[][]>;
146
+ };
147
+ /** A materialized read-only snapshot of the canonical project-memory database. */
148
+ export type CanonicalMemorySnapshot = {
149
+ repoPath: string;
150
+ baseOid: string;
151
+ dbPath: string;
152
+ createdFresh: boolean;
153
+ cleanup(): Promise<void>;
154
+ };
155
+ /**
156
+ * Minimal telemetry sink the memory command emits run events through. The
157
+ * substrate's concrete event bus (`@rig/runtime` `EventBusLike`) is a superset
158
+ * and is structurally assignable to this; the memory contract only depends on
159
+ * `emit`, so the pure contract stays free of any runtime/behaviour import.
160
+ */
161
+ export interface MemoryCommandEventSink {
162
+ emit<TPayload extends Record<string, unknown>>(type: string, payload: TPayload): Promise<unknown>;
163
+ }
164
+ /** Options for the agent-facing `rig-agent memory <verb>` command dispatch. */
165
+ export type ExecuteMemoryCommandOptions = {
166
+ projectRoot: string;
167
+ taskId: string;
168
+ runtimeContext: RuntimeTaskContext | null;
169
+ args: string[];
170
+ eventBus?: MemoryCommandEventSink;
171
+ };
172
+ /** The retrieval-query shape the substrate passes through to the impl. */
173
+ export type MemoryQueryPortInput = {
174
+ query: string;
175
+ limit?: number;
176
+ retrieval?: RuntimeMemoryRetrievalConfig;
177
+ };
178
+ /**
179
+ * The cohesive set of shared-memory operations the runtime consumers depend on.
180
+ * This is pure capability VOCAB: the `@rig/memory-plugin` provides a concrete
181
+ * impl (statically checked against this interface via `MemoryCap.provide`), and
182
+ * the substrate only ever sees this contract — resolved by id off a plugin host
183
+ * with no `as unknown as` at any call site.
184
+ */
185
+ export interface MemoryService {
186
+ executeMemoryCommand(options: ExecuteMemoryCommandOptions): Promise<string>;
187
+ readCanonicalMemoryDb(projectRoot: string): Promise<CanonicalMemorySnapshot>;
188
+ openMemoryDb(dbPath: string): Promise<MemoryDb>;
189
+ queryRelevantMemory(db: MemoryDb, input: MemoryQueryPortInput): Promise<MemoryQueryResult[]>;
190
+ formatMemoryQueryResults(results: MemoryQueryResult[]): string;
191
+ }
192
+ /**
193
+ * The typed capability id the memory plugin provides and consumers require.
194
+ * Phantom-typed with `MemoryService` so `MemoryCap.require(host)` returns a
195
+ * `MemoryService` with no cast leaking to callers. Its string value is
196
+ * {@link MEMORY_SERVICE_CAPABILITY_ID}, so it indexes the same host entry.
197
+ */
198
+ export declare const MEMORY: CapabilityId<MemoryService>;
199
+ export {};
@@ -0,0 +1,15 @@
1
+ // @bun
2
+ // packages/contracts/src/capability-id.ts
3
+ function makeCapabilityId(id) {
4
+ return id;
5
+ }
6
+
7
+ // packages/contracts/src/memory.ts
8
+ var MEMORY_SERVICE_CAPABILITY_ID = "memory.service";
9
+ var NO_MATCH_RETRIEVAL_CANONICAL_KEY = "__memory_recall__:none";
10
+ var MEMORY = makeCapabilityId(MEMORY_SERVICE_CAPABILITY_ID);
11
+ export {
12
+ NO_MATCH_RETRIEVAL_CANONICAL_KEY,
13
+ MEMORY_SERVICE_CAPABILITY_ID,
14
+ MEMORY
15
+ };
@@ -0,0 +1,13 @@
1
+ import { Schema } from "effect";
2
+ /**
3
+ * Provider model vocabulary shared by the transport contract.
4
+ *
5
+ * Concrete model catalogs, aliases, defaults, and reasoning-effort policy are
6
+ * runtime/provider ownership concerns and live in `@rig/provider-plugin/model`.
7
+ * The contract layer intentionally accepts opaque model slugs/options so new
8
+ * provider packages can evolve without changing the floor package.
9
+ */
10
+ export declare const ModelSlug: Schema.String;
11
+ export type ModelSlug = typeof ModelSlug.Type;
12
+ export declare const ProviderModelOptions: Schema.$Record<Schema.String, Schema.Unknown>;
13
+ export type ProviderModelOptions = typeof ProviderModelOptions.Type;
package/dist/src/model.js CHANGED
@@ -1,64 +1,9 @@
1
1
  // @bun
2
2
  // packages/contracts/src/model.ts
3
3
  import { Schema } from "effect";
4
- var CODEX_REASONING_EFFORT_OPTIONS = ["xhigh", "high", "medium", "low"];
5
- var CodexModelOptions = Schema.Struct({
6
- reasoningEffort: Schema.optional(Schema.Literals(CODEX_REASONING_EFFORT_OPTIONS)),
7
- fastMode: Schema.optional(Schema.Boolean)
8
- });
9
- var ClaudeModelOptions = Schema.Struct({});
10
- var ProviderModelOptions = Schema.Struct({
11
- codex: Schema.optional(CodexModelOptions),
12
- claude: Schema.optional(ClaudeModelOptions)
13
- });
14
- var MODEL_OPTIONS_BY_PROVIDER = {
15
- codex: [
16
- { slug: "gpt-5.4", name: "GPT-5.4" },
17
- { slug: "gpt-5.3-codex", name: "GPT-5.3 Codex" },
18
- { slug: "gpt-5.3-codex-spark", name: "GPT-5.3 Codex Spark" },
19
- { slug: "gpt-5.2-codex", name: "GPT-5.2 Codex" },
20
- { slug: "gpt-5.2", name: "GPT-5.2" }
21
- ],
22
- claude: [
23
- { slug: "claude-sonnet-4-6", name: "Claude Sonnet 4.6" },
24
- { slug: "claude-opus-4-1", name: "Claude Opus 4.1" },
25
- { slug: "claude-3-7-sonnet-latest", name: "Claude 3.7 Sonnet" }
26
- ]
27
- };
28
- var DEFAULT_MODEL_BY_PROVIDER = {
29
- codex: "gpt-5.4",
30
- claude: "claude-sonnet-4-6"
31
- };
32
- var MODEL_SLUG_ALIASES_BY_PROVIDER = {
33
- codex: {
34
- "5.4": "gpt-5.4",
35
- "5.3": "gpt-5.3-codex",
36
- "gpt-5.3": "gpt-5.3-codex",
37
- "5.3-spark": "gpt-5.3-codex-spark",
38
- "gpt-5.3-spark": "gpt-5.3-codex-spark"
39
- },
40
- claude: {
41
- sonnet: "claude-sonnet-4-6",
42
- opus: "claude-opus-4-1",
43
- "3.7-sonnet": "claude-3-7-sonnet-latest"
44
- }
45
- };
46
- var REASONING_EFFORT_OPTIONS_BY_PROVIDER = {
47
- codex: CODEX_REASONING_EFFORT_OPTIONS,
48
- claude: []
49
- };
50
- var DEFAULT_REASONING_EFFORT_BY_PROVIDER = {
51
- codex: "high",
52
- claude: null
53
- };
4
+ var ModelSlug = Schema.String;
5
+ var ProviderModelOptions = Schema.Record(Schema.String, Schema.Unknown);
54
6
  export {
55
- REASONING_EFFORT_OPTIONS_BY_PROVIDER,
56
7
  ProviderModelOptions,
57
- MODEL_SLUG_ALIASES_BY_PROVIDER,
58
- MODEL_OPTIONS_BY_PROVIDER,
59
- DEFAULT_REASONING_EFFORT_BY_PROVIDER,
60
- DEFAULT_MODEL_BY_PROVIDER,
61
- CodexModelOptions,
62
- ClaudeModelOptions,
63
- CODEX_REASONING_EFFORT_OPTIONS
8
+ ModelSlug
64
9
  };