@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.
Files changed (126) hide show
  1. package/dist/index.cjs +2340 -6832
  2. package/dist/index.mjs +2116 -6608
  3. package/dist/src/agent-roles.d.ts +8 -0
  4. package/dist/src/browser.d.ts +34 -4
  5. package/dist/src/browser.js +8 -1
  6. package/dist/src/capability-id.d.ts +22 -0
  7. package/dist/src/capability-id.js +8 -0
  8. package/dist/src/cli-output.d.ts +24 -0
  9. package/dist/src/cli-runner.d.ts +43 -0
  10. package/dist/src/cli-runner.js +13 -0
  11. package/dist/src/collab-session-viewer.d.ts +36 -0
  12. package/dist/src/collab-session-viewer.js +13 -0
  13. package/dist/src/config.d.ts +11 -0
  14. package/dist/src/config.js +279 -1098
  15. package/dist/src/control-plane-types.d.ts +41 -1
  16. package/dist/src/control-plane-types.js +9 -25
  17. package/dist/src/dependency-preflight.d.ts +43 -0
  18. package/dist/src/dependency-preflight.js +13 -0
  19. package/dist/src/doctor.d.ts +67 -4
  20. package/dist/src/doctor.js +8 -9
  21. package/dist/src/errors.d.ts +13 -0
  22. package/dist/src/errors.js +17 -0
  23. package/dist/src/github.d.ts +43 -0
  24. package/dist/src/github.js +12 -1
  25. package/dist/src/graph.d.ts +37 -0
  26. package/dist/src/graph.js +13 -0
  27. package/dist/src/guard.d.ts +111 -0
  28. package/dist/src/guard.js +6 -0
  29. package/dist/src/harness-events.d.ts +8 -0
  30. package/dist/src/harness-events.js +1 -0
  31. package/dist/src/help-catalog.d.ts +17 -10
  32. package/dist/src/help-catalog.js +9 -651
  33. package/dist/src/host.d.ts +41 -0
  34. package/dist/src/host.js +13 -0
  35. package/dist/src/identity.d.ts +44 -0
  36. package/dist/src/identity.js +1 -0
  37. package/dist/src/index.d.ts +27 -7
  38. package/dist/src/index.js +2116 -6608
  39. package/dist/src/isolation.d.ts +207 -15
  40. package/dist/src/isolation.js +8 -1
  41. package/dist/src/kernel.d.ts +11 -0
  42. package/dist/src/kernel.js +7 -0
  43. package/dist/src/layout.d.ts +49 -0
  44. package/dist/src/layout.js +10 -0
  45. package/dist/src/lifecycle-capabilities.d.ts +99 -0
  46. package/dist/src/lifecycle-capabilities.js +18 -1
  47. package/dist/src/managed-repos.d.ts +79 -16
  48. package/dist/src/managed-repos.js +12 -1
  49. package/dist/src/memory.d.ts +52 -4
  50. package/dist/src/memory.js +8 -1
  51. package/dist/src/notify.d.ts +46 -0
  52. package/dist/src/notify.js +13 -0
  53. package/dist/src/orchestration.d.ts +0 -3652
  54. package/dist/src/orchestration.js +28 -964
  55. package/dist/src/plugin-hooks.js +22 -3
  56. package/dist/src/plugin.d.ts +47 -0
  57. package/dist/src/plugin.js +24 -3
  58. package/dist/src/prompt.d.ts +29 -0
  59. package/dist/src/prompt.js +13 -0
  60. package/dist/src/provider-instructions.d.ts +26 -4
  61. package/dist/src/provider-instructions.js +8 -1
  62. package/dist/src/provider.js +1 -824
  63. package/dist/src/remote.d.ts +0 -8
  64. package/dist/src/remote.js +229 -1075
  65. package/dist/src/run-discovery.d.ts +79 -0
  66. package/dist/src/run-discovery.js +13 -0
  67. package/dist/src/run-dispatch.d.ts +34 -0
  68. package/dist/src/run-dispatch.js +13 -0
  69. package/dist/src/run-identity.d.ts +47 -0
  70. package/dist/src/run-identity.js +13 -0
  71. package/dist/src/run-journal.d.ts +0 -236
  72. package/dist/src/run-journal.js +249 -1321
  73. package/dist/src/run-read-model.d.ts +234 -0
  74. package/dist/src/run-read-model.js +13 -0
  75. package/dist/src/run-record.d.ts +0 -11
  76. package/dist/src/run-record.js +0 -16
  77. package/dist/src/run-registry-backbone.d.ts +56 -0
  78. package/dist/src/run-registry-backbone.js +13 -0
  79. package/dist/src/run-session-journal.d.ts +1 -25
  80. package/dist/src/run-session-journal.js +0 -1731
  81. package/dist/src/run-status.d.ts +0 -2
  82. package/dist/src/run-status.js +0 -11
  83. package/dist/src/run-timeline.d.ts +0 -3
  84. package/dist/src/run-timeline.js +0 -1498
  85. package/dist/src/runtime-task-context.d.ts +82 -0
  86. package/dist/src/runtime-task-context.js +1 -0
  87. package/dist/src/runtime.js +66 -904
  88. package/dist/src/session-asset-materializer.d.ts +35 -0
  89. package/dist/src/session-asset-materializer.js +13 -0
  90. package/dist/src/setup.d.ts +47 -0
  91. package/dist/src/setup.js +13 -0
  92. package/dist/src/supervisor-journal.js +117 -955
  93. package/dist/src/task-data.d.ts +239 -0
  94. package/dist/src/task-data.js +13 -0
  95. package/dist/src/task-graph-primitives.d.ts +0 -21
  96. package/dist/src/task-graph-primitives.js +0 -318
  97. package/dist/src/task-source.d.ts +65 -0
  98. package/dist/src/task-source.js +12 -0
  99. package/dist/src/task-state-metadata.d.ts +21 -0
  100. package/dist/src/task-state-metadata.js +1 -0
  101. package/dist/src/tool-materializer.d.ts +36 -0
  102. package/dist/src/tool-materializer.js +13 -0
  103. package/dist/src/tool-registry.d.ts +3 -0
  104. package/dist/src/tool-registry.js +58 -0
  105. package/dist/src/toolchain-sources.d.ts +54 -0
  106. package/dist/src/toolchain-sources.js +17 -0
  107. package/dist/src/workflow-journal.d.ts +0 -32
  108. package/dist/src/workflow-journal.js +0 -371
  109. package/dist/src/workspace-config.d.ts +18 -0
  110. package/dist/src/workspace-config.js +13 -0
  111. package/dist/src/workspace.js +73 -911
  112. package/package.json +1 -1
  113. package/dist/src/engine.d.ts +0 -2789
  114. package/dist/src/engine.js +0 -2392
  115. package/dist/src/ipc.d.ts +0 -248
  116. package/dist/src/providerRuntime.d.ts +0 -3949
  117. package/dist/src/providerRuntime.js +0 -1633
  118. package/dist/src/rig.d.ts +0 -783
  119. package/dist/src/rig.js +0 -2537
  120. package/dist/src/server.d.ts +0 -106
  121. package/dist/src/server.js +0 -1056
  122. package/dist/src/serviceFabric.d.ts +0 -62
  123. package/dist/src/serviceFabric.js +0 -1069
  124. package/dist/src/ws.d.ts +0 -747
  125. package/dist/src/ws.js +0 -3126
  126. /package/dist/src/{ipc.js → agent-roles.js} +0 -0
@@ -0,0 +1,8 @@
1
+ import type { AgentRoleRegistration } from "./plugin";
2
+ export interface ResolvedAgentRole extends AgentRoleRegistration {
3
+ model: string;
4
+ }
5
+ export interface AgentRoleRegistry {
6
+ resolve(id: string): ResolvedAgentRole;
7
+ list(): readonly ResolvedAgentRole[];
8
+ }
@@ -8,11 +8,14 @@
8
8
  * no behaviour and import nothing — exactly like `memory.ts` /
9
9
  * `lifecycle-capabilities.ts`.
10
10
  *
11
- * The plugin registers its executable `BrowserContractService` impl under
12
- * {@link BROWSER_CONTRACT_SERVICE_CAPABILITY_ID} on `contributes.capabilities[].run`;
13
- * the runtime resolves it by id from `pluginHost.listExecutableCapabilities()`
14
- * via the typed port in `@rig/runtime/control-plane/browser-contract-port`.
11
+ * The plugin registers its executable `BrowserContractService` impl under the
12
+ * typed capability id {@link BROWSER_CONTRACT_SERVICE_CAPABILITY} (whose string
13
+ * value is {@link BROWSER_CONTRACT_SERVICE_CAPABILITY_ID}) via the
14
+ * `defineCapability` seam (`@rig/core/capability`); the runtime resolves it by id
15
+ * from `pluginHost.listExecutableCapabilities()` via the thin typed port in
16
+ * `@rig/runtime/control-plane/browser-contract-port`.
15
17
  */
18
+ import type { CapabilityId } from "./capability-id";
16
19
  /** Capability id the browser plugin registers its `BrowserContractService` factory under. */
17
20
  export declare const BROWSER_CONTRACT_SERVICE_CAPABILITY_ID = "browser.contract";
18
21
  /** Author-facing browser config attached to a task entry (rig.config / task source). */
@@ -48,3 +51,30 @@ export type RuntimeBrowserContext = {
48
51
  e2eHelper: string;
49
52
  resetProfileHelper: string;
50
53
  };
54
+ /** Options for deriving the runtime-effective browser context. */
55
+ export type ResolveTaskBrowserContextOptions = {
56
+ hostProjectRoot?: string;
57
+ runtimeId?: string;
58
+ };
59
+ /**
60
+ * The cohesive set of browser-contract operations the runtime consumers depend
61
+ * on. This is pure capability VOCAB: the `@rig/browser-plugin` provides a
62
+ * concrete impl (statically checked against this interface via
63
+ * `BrowserContractCap.provide`), and the substrate only ever sees this contract —
64
+ * resolved by id off a plugin host with no `as unknown as` at any call site.
65
+ */
66
+ export interface BrowserContractService {
67
+ /** Resolve an author-facing `TaskBrowserConfig` into the runtime-effective context. */
68
+ resolveTaskBrowserContext(browser: TaskBrowserConfig | undefined, options?: ResolveTaskBrowserContextOptions): RuntimeBrowserContext | undefined;
69
+ /** Render the `task info` guidance lines for a resolved browser context. */
70
+ buildBrowserGuidanceLines(browser: RuntimeBrowserContext): string[];
71
+ }
72
+ /**
73
+ * The typed capability id the browser plugin provides and consumers require.
74
+ * Phantom-typed with {@link BrowserContractService} so
75
+ * `BrowserContractCap.require(host)` returns a `BrowserContractService` with no
76
+ * cast leaking to callers. Its string value is
77
+ * {@link BROWSER_CONTRACT_SERVICE_CAPABILITY_ID}, so it indexes the same host
78
+ * entry.
79
+ */
80
+ export declare const BROWSER_CONTRACT_SERVICE_CAPABILITY: CapabilityId<BrowserContractService>;
@@ -1,6 +1,13 @@
1
1
  // @bun
2
+ // packages/contracts/src/capability-id.ts
3
+ function makeCapabilityId(id) {
4
+ return id;
5
+ }
6
+
2
7
  // packages/contracts/src/browser.ts
3
8
  var BROWSER_CONTRACT_SERVICE_CAPABILITY_ID = "browser.contract";
9
+ var BROWSER_CONTRACT_SERVICE_CAPABILITY = makeCapabilityId(BROWSER_CONTRACT_SERVICE_CAPABILITY_ID);
4
10
  export {
5
- BROWSER_CONTRACT_SERVICE_CAPABILITY_ID
11
+ BROWSER_CONTRACT_SERVICE_CAPABILITY_ID,
12
+ BROWSER_CONTRACT_SERVICE_CAPABILITY
6
13
  };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Capability-seam vocabulary.
3
+ *
4
+ * A `CapabilityId<T>` is a plain id string branded (phantom-typed) with the
5
+ * service type `T` it resolves to. `defineCapability<T>` (in `@rig/core`) reads
6
+ * this brand so `resolve`/`require` are typed as `T` with the `unknown → T` cast
7
+ * contained ONCE inside the helper — callers never cast.
8
+ *
9
+ * Pure: no imports, no behaviour. The brand lives only in an OPTIONAL phantom
10
+ * property so a plain `string` is still assignable to `CapabilityId<T>` via the
11
+ * `makeCapabilityId` cast, and a `CapabilityId<T>` is usable anywhere a `string`
12
+ * is (equality checks against `host` capability ids, `.toString()`, etc.).
13
+ */
14
+ declare const CapabilityIdBrand: unique symbol;
15
+ /** A capability id string branded with the service type `T` it resolves to. */
16
+ export type CapabilityId<T> = string & {
17
+ /** Phantom — never present at runtime; carries `T` for `defineCapability<T>`. */
18
+ readonly [CapabilityIdBrand]?: T;
19
+ };
20
+ /** Brand a plain id string as a `CapabilityId<T>`. */
21
+ export declare function makeCapabilityId<T>(id: string): CapabilityId<T>;
22
+ export {};
@@ -0,0 +1,8 @@
1
+ // @bun
2
+ // packages/contracts/src/capability-id.ts
3
+ function makeCapabilityId(id) {
4
+ return id;
5
+ }
6
+ export {
7
+ makeCapabilityId
8
+ };
@@ -322,3 +322,27 @@ export declare const RigStatsOutput: Schema.Struct<{
322
322
  }>;
323
323
  }>;
324
324
  export type RigStatsOutput = typeof RigStatsOutput.Type;
325
+ export type OutputMode = "text" | "json";
326
+ export type CommandExecutionResult = {
327
+ command: string[];
328
+ formattedCommand: string;
329
+ exitCode: number;
330
+ durationMs: number;
331
+ startedAt: string;
332
+ finishedAt: string;
333
+ stdout?: string;
334
+ stderr?: string;
335
+ };
336
+ /** Structured outcome a `rig <group> <command>` handler returns to the runner. */
337
+ export type CommandOutcome = {
338
+ readonly ok: boolean;
339
+ readonly group: string;
340
+ readonly command: string;
341
+ readonly details?: Record<string, unknown>;
342
+ };
343
+ export type PluginValidatorResult = {
344
+ id: string;
345
+ passed: boolean;
346
+ summary: string;
347
+ details?: string;
348
+ };
@@ -0,0 +1,43 @@
1
+ import type { CapabilityId } from "./capability-id";
2
+ import type { CommandExecutionResult, OutputMode } from "./cli-output";
3
+ import type { HarnessEvent, HarnessEventType } from "./harness-events";
4
+ import type { PolicyConfig, PolicyMode } from "./guard";
5
+ export type CliRuntimeInitializeOptions = {
6
+ readonly projectRoot: string;
7
+ readonly dryRun: boolean;
8
+ readonly outputMode: OutputMode;
9
+ readonly runId?: string;
10
+ readonly policyMode?: PolicyMode;
11
+ };
12
+ export type CliRuntimeContext = {
13
+ readonly projectRoot: string;
14
+ readonly dryRun: boolean;
15
+ readonly outputMode: OutputMode;
16
+ readonly runId: string;
17
+ readonly policyMode?: PolicyMode;
18
+ readonly eventBus: {
19
+ getRunId(): string;
20
+ getEventsFile(): string;
21
+ getMemoryEvents(): HarnessEvent[];
22
+ emit<TPayload extends Record<string, unknown>>(type: HarnessEventType, payload: TPayload): Promise<HarnessEvent<TPayload>>;
23
+ };
24
+ readonly emitEvent: <TPayload extends Record<string, unknown>>(type: HarnessEventType, payload: TPayload) => Promise<void>;
25
+ readonly runCommand: (parts: string[]) => Promise<CommandExecutionResult>;
26
+ };
27
+ export type AgentShellMaterializationOptions = {
28
+ readonly env?: Record<string, string | undefined>;
29
+ readonly cwd?: string;
30
+ readonly moduleDir?: string;
31
+ readonly build?: (entrypoint: string, output: string, cwd: string, define?: Record<string, string>) => Promise<void>;
32
+ };
33
+ export interface CliRunnerService {
34
+ initializeRuntime(options: CliRuntimeInitializeOptions): Promise<CliRuntimeContext>;
35
+ runCommand(context: CliRuntimeContext, parts: string[]): Promise<CommandExecutionResult>;
36
+ ensureAgentShellBinary(projectRoot: string, options?: AgentShellMaterializationOptions): Promise<string>;
37
+ resolveAgentMaterializationSourceRoot(projectRoot: string, options?: AgentShellMaterializationOptions): string;
38
+ withProjectRoot(projectRoot: string): void;
39
+ formatCommand(parts: string[]): string;
40
+ loadPolicy(projectRoot: string): PolicyConfig;
41
+ }
42
+ export declare const CLI_RUNNER_CAPABILITY_ID = "rig.cli.runner";
43
+ export declare const CLI_RUNNER: CapabilityId<CliRunnerService>;
@@ -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/cli-runner.ts
8
+ var CLI_RUNNER_CAPABILITY_ID = "rig.cli.runner";
9
+ var CLI_RUNNER = makeCapabilityId(CLI_RUNNER_CAPABILITY_ID);
10
+ export {
11
+ CLI_RUNNER_CAPABILITY_ID,
12
+ CLI_RUNNER
13
+ };
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Pure collab-session-viewer surface vocab.
3
+ *
4
+ * The neutral seam for the browser collab-session viewer SPA (the `collab-web`
5
+ * client, owned by `@rig/collab-session-browser-plugin`). Consumers resolve the
6
+ * surface off a plugin host without importing the plugin or the SPA. Carries no
7
+ * behaviour — like `browser.ts` / `notify.ts`.
8
+ *
9
+ * The plugin provides the concrete impl (built `dist/` location + the pi-wire
10
+ * link grammar) under {@link COLLAB_SESSION_VIEWER_CAPABILITY} via the
11
+ * `defineCapability` seam.
12
+ */
13
+ import type { CapabilityId } from "./capability-id";
14
+ /** Inputs to format a shareable collab-session viewer link (pi-wire grammar). */
15
+ export interface CollabSessionViewerLinkInput {
16
+ relayUrl: string;
17
+ roomId: string;
18
+ key: Uint8Array;
19
+ writeToken?: Uint8Array;
20
+ }
21
+ /** Capability id the collab-session-browser plugin registers its surface under. */
22
+ export declare const COLLAB_SESSION_VIEWER_CAPABILITY_ID = "collab.session-viewer";
23
+ /**
24
+ * The browser collab-session viewer surface. `distDir()` is the built SPA static
25
+ * root (serve it to hand a browser the live transcript viewer); `formatViewerLink`
26
+ * preserves the exact `@oh-my-pi/pi-wire` link grammar so a `roomId.key` link
27
+ * opens the streaming session.
28
+ */
29
+ export interface CollabSessionViewerSurface {
30
+ /** Absolute path to the built browser SPA dist directory (static assets). */
31
+ distDir(): string;
32
+ /** Format the shareable viewer link using the preserved pi-wire link grammar. */
33
+ formatViewerLink(input: CollabSessionViewerLinkInput): string;
34
+ }
35
+ /** Typed capability id the plugin provides and consumers require. */
36
+ export declare const COLLAB_SESSION_VIEWER_CAPABILITY: CapabilityId<CollabSessionViewerSurface>;
@@ -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/collab-session-viewer.ts
8
+ var COLLAB_SESSION_VIEWER_CAPABILITY_ID = "collab.session-viewer";
9
+ var COLLAB_SESSION_VIEWER_CAPABILITY = makeCapabilityId(COLLAB_SESSION_VIEWER_CAPABILITY_ID);
10
+ export {
11
+ COLLAB_SESSION_VIEWER_CAPABILITY_ID,
12
+ COLLAB_SESSION_VIEWER_CAPABILITY
13
+ };
@@ -316,6 +316,9 @@ export declare const RigConfig: Schema.Struct<{
316
316
  readonly usage: Schema.optional<Schema.String>;
317
317
  readonly aliases: Schema.optional<Schema.$Array<Schema.String>>;
318
318
  readonly projectRequired: Schema.optional<Schema.Boolean>;
319
+ readonly rootDefault: Schema.optional<Schema.Boolean>;
320
+ readonly productRoot: Schema.optional<Schema.Boolean>;
321
+ readonly subcommands: Schema.optional<Schema.$Array<Schema.String>>;
319
322
  }>>>;
320
323
  readonly stages: Schema.optional<Schema.$Array<Schema.Struct<{
321
324
  readonly id: Schema.brand<Schema.Trim, "StageId">;
@@ -373,6 +376,7 @@ export declare const RigConfig: Schema.Struct<{
373
376
  readonly description: Schema.optional<Schema.String>;
374
377
  readonly commandId: Schema.optional<Schema.String>;
375
378
  readonly panelId: Schema.optional<Schema.String>;
379
+ readonly run: Schema.optional<Schema.declare<import("./plugin").CapabilityRun, import("./plugin").CapabilityRun>>;
376
380
  }>>>;
377
381
  readonly panels: Schema.optional<Schema.$Array<Schema.Struct<{
378
382
  readonly id: Schema.String;
@@ -392,6 +396,13 @@ export declare const RigConfig: Schema.Struct<{
392
396
  readonly id: Schema.String;
393
397
  readonly description: Schema.optional<Schema.String>;
394
398
  }>>>;
399
+ readonly seedEntrypoints: Schema.optional<Schema.$Array<Schema.Struct<{
400
+ readonly id: Schema.String;
401
+ readonly description: Schema.optional<Schema.String>;
402
+ readonly basename: Schema.optional<Schema.String>;
403
+ readonly workerArg: Schema.optional<Schema.String>;
404
+ readonly insidePty: Schema.optional<Schema.Boolean>;
405
+ }>>>;
395
406
  }>>;
396
407
  }>>;
397
408
  readonly taskSource: Schema.Struct<{