@rigkit/sdk 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -8,7 +8,7 @@ Configs should import authoring helpers from this package:
8
8
  import { env, workflow } from "@rigkit/sdk";
9
9
  ```
10
10
 
11
- Task handlers receive `runtime.log(message, options)` for structured step logs.
11
+ Task handlers receive `step.log(message, options)` for structured step logs. Pass `step.log` to SDKs that accept a logger callback.
12
12
  Those events stream over the runtime run session and are rendered by interactive
13
13
  hosts such as the `rig` terminal run timeline.
14
14
  Provider VM commands can also report incremental stdout/stderr through
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rigkit/sdk",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -23,8 +23,8 @@
23
23
  "@effect/platform": "0.96.1",
24
24
  "@effect/platform-bun": "0.89.0",
25
25
  "effect": "^3.21.2",
26
- "@rigkit/engine": "0.2.3",
27
- "@rigkit/runtime-client": "0.2.3"
26
+ "@rigkit/engine": "0.2.4",
27
+ "@rigkit/runtime-client": "0.2.4"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@types/bun": "latest",
package/src/host.ts CHANGED
@@ -1,8 +1,17 @@
1
+ export type HostCapabilityLogOptions = {
2
+ stream?: "stdout" | "stderr" | "info";
3
+ label?: string;
4
+ };
5
+
6
+ export type HostCapabilityContext = {
7
+ log(data: string, options?: HostCapabilityLogOptions): void;
8
+ };
9
+
1
10
  export type HostCapabilityDefinition<Input = unknown, Result = unknown> = {
2
11
  readonly schemaHash?: string;
3
12
  readonly input?: unknown;
4
13
  readonly output?: unknown;
5
- readonly handle: (params: Input) => Result | Promise<Result>;
14
+ readonly handle: (params: Input, context?: HostCapabilityContext) => Result | Promise<Result>;
6
15
  };
7
16
 
8
17
  export type HostCapabilityHandler<Input = unknown, Result = unknown> =
package/src/index.test.ts CHANGED
@@ -16,7 +16,7 @@ import { defineHostCapabilities, defineHostCapability } from "./host.ts";
16
16
 
17
17
  describe("@rigkit/sdk package boundary", () => {
18
18
  test("exports authoring API and project runtime entrypoints", () => {
19
- expect(RIGKIT_SDK_VERSION).toBe("0.2.3");
19
+ expect(RIGKIT_SDK_VERSION).toBe("0.2.4");
20
20
  expect(env).toBeTypeOf("function");
21
21
  expect(env.secret).toBeTypeOf("function");
22
22
  expect(defineConfig).toBeTypeOf("function");
@@ -416,7 +416,7 @@ describe("runtime HTTP app", () => {
416
416
  `
417
417
  import { defineConfig, sequence } from "${import.meta.dir}/../../../engine/src/index.ts";
418
418
 
419
- const root = sequence("session-test").step("noop", async () => ({ ok: true }));
419
+ const root = sequence("session-test").step("noop", async () => ({ ctx: { ok: true } }));
420
420
 
421
421
  export default defineConfig({
422
422
  providers: {},
@@ -473,7 +473,7 @@ describe("runtime HTTP app", () => {
473
473
  import { defineConfig, sequence } from "${import.meta.dir}/../../../engine/src/index.ts";
474
474
 
475
475
  const root = sequence("workspace-ctx")
476
- .step("prepare", async () => ({ repoPath: "/workspace/repo" }))
476
+ .step("prepare", async () => ({ ctx: { repoPath: "/workspace/repo" } }))
477
477
  .workspace({
478
478
  create: async ({ workflow, workspace }) => ({
479
479
  name: workspace.name,
@@ -536,7 +536,7 @@ describe("runtime HTTP app", () => {
536
536
  import { defineConfig, sequence } from "${import.meta.dir}/../../../engine/src/index.ts";
537
537
 
538
538
  const root = sequence("validation")
539
- .step("prepare", async () => ({ ok: true }))
539
+ .step("prepare", async () => ({ ctx: { ok: true } }))
540
540
  .workspace({
541
541
  create: async ({ workspace }) => ({ name: workspace.name, vmId: "vm-" + workspace.name }),
542
542
  remove: async () => {},
@@ -806,7 +806,7 @@ function writeNoopConfig(projectDir: string): void {
806
806
  `
807
807
  import { defineConfig, sequence } from "${import.meta.dir}/../../../engine/src/index.ts";
808
808
 
809
- const root = sequence("noop").step("ready", async () => ({ ready: true }));
809
+ const root = sequence("noop").step("ready", async () => ({ ctx: { ready: true } }));
810
810
 
811
811
  export default defineConfig({
812
812
  providers: {},
@@ -3,6 +3,7 @@ import {
3
3
  type DevMachineEngine,
4
4
  type EngineOperationSummary,
5
5
  type JsonValue,
6
+ type LocalHostCapabilityRequestOptions,
6
7
  } from "@rigkit/engine";
7
8
  import { normalizeRuntimeRunError } from "./errors.ts";
8
9
  import {
@@ -83,10 +84,18 @@ async function executeOperation(run: RunRecord, store: RunStore, options: Engine
83
84
  const result = await requestHost(store, run, "host.command.run", command);
84
85
  return HostCommandResultSchema.parse(result);
85
86
  },
86
- requestCapability: async <Result = unknown>(capability: string, params: unknown) =>
87
- await requestHostCapability(store, run, capability, params) as Result,
88
- requestCapabilitySession: async <Result = unknown>(capability: string, params: unknown) =>
89
- await requestHostCapabilitySession<Result>(store, run, capability, params),
87
+ requestCapability: async <Result = unknown>(
88
+ capability: string,
89
+ params: unknown,
90
+ requestOptions?: LocalHostCapabilityRequestOptions,
91
+ ) =>
92
+ await requestHostCapability(store, run, capability, params, requestOptions) as Result,
93
+ requestCapabilitySession: async <Result = unknown>(
94
+ capability: string,
95
+ params: unknown,
96
+ requestOptions?: LocalHostCapabilityRequestOptions,
97
+ ) =>
98
+ await requestHostCapabilitySession<Result>(store, run, capability, params, requestOptions),
90
99
  },
91
100
  });
92
101
  engine.onEvent((event) => emitRunEvent(run, event));
@@ -99,6 +99,7 @@ export type HostCapabilityRequestEvent = {
99
99
  type: "host.capability.request";
100
100
  requestId: string;
101
101
  id: string;
102
+ nodePath?: string;
102
103
  capability: string;
103
104
  params: unknown;
104
105
  };
@@ -21,6 +21,10 @@ export type HostCapabilitySessionResult<Result = unknown> = {
21
21
  closed: Promise<void>;
22
22
  };
23
23
 
24
+ export type HostCapabilityRequestOptions = {
25
+ nodePath?: string;
26
+ };
27
+
24
28
  export type RunRecord = {
25
29
  id: string;
26
30
  operation: string;
@@ -197,8 +201,9 @@ export function requestHostCapability(
197
201
  run: RunRecord,
198
202
  capability: string,
199
203
  params: unknown,
204
+ options: HostCapabilityRequestOptions = {},
200
205
  ): Promise<unknown> {
201
- const { requestId } = emitHostCapabilityRequest(run, capability, params);
206
+ const { requestId } = emitHostCapabilityRequest(run, capability, params, options);
202
207
  return waitForHostResponse(store, requestId);
203
208
  }
204
209
 
@@ -207,8 +212,9 @@ export async function requestHostCapabilitySession<Result = unknown>(
207
212
  run: RunRecord,
208
213
  capability: string,
209
214
  params: unknown,
215
+ options: HostCapabilityRequestOptions = {},
210
216
  ): Promise<HostCapabilitySessionResult<Result>> {
211
- const { requestId } = emitHostCapabilityRequest(run, capability, params);
217
+ const { requestId } = emitHostCapabilityRequest(run, capability, params, options);
212
218
  const closed = new Promise<void>((resolveClosed, rejectClosed) => {
213
219
  store.hostCapabilityResources.set(requestId, { resolveClosed, rejectClosed });
214
220
  run.pendingHostCapabilityResourceIds.add(requestId);
@@ -234,6 +240,7 @@ function emitHostCapabilityRequest(
234
240
  run: RunRecord,
235
241
  capability: string,
236
242
  params: unknown,
243
+ options: HostCapabilityRequestOptions = {},
237
244
  ): { requestId: string } {
238
245
  if (run.status !== "running") {
239
246
  throw new RuntimeHostRequestError({
@@ -243,7 +250,14 @@ function emitHostCapabilityRequest(
243
250
  }
244
251
  const requestId = `cap_req_${crypto.randomUUID()}`;
245
252
  run.pendingHostRequestIds.add(requestId);
246
- emitRunEvent(run, { type: "host.capability.request", requestId, id: requestId, capability, params });
253
+ emitRunEvent(run, {
254
+ type: "host.capability.request",
255
+ requestId,
256
+ id: requestId,
257
+ ...(options.nodePath ? { nodePath: options.nodePath } : {}),
258
+ capability,
259
+ params,
260
+ });
247
261
  return { requestId };
248
262
  }
249
263
 
@@ -164,6 +164,7 @@ function sessionEvent(event: unknown): Record<string, unknown> {
164
164
  return {
165
165
  type: "host.capability.request",
166
166
  id: typeof event.id === "string" ? event.id : event.requestId,
167
+ ...(typeof event.nodePath === "string" ? { nodePath: event.nodePath } : {}),
167
168
  capability: event.capability,
168
169
  params: event.params,
169
170
  };
@@ -1 +1 @@
1
- export const RIGKIT_RUNTIME_VERSION = "0.2.3";
1
+ export const RIGKIT_RUNTIME_VERSION = "0.2.4";
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const RIGKIT_SDK_VERSION = "0.2.3";
1
+ export const RIGKIT_SDK_VERSION = "0.2.4";