@rigkit/sdk 0.2.1 → 0.2.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rigkit/sdk",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
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.1",
27
- "@rigkit/runtime-client": "0.2.1"
26
+ "@rigkit/engine": "0.2.2",
27
+ "@rigkit/runtime-client": "0.2.2"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@types/bun": "latest",
package/src/cli.ts CHANGED
@@ -4,6 +4,7 @@ import { serveRuntime } from "./runtime/server.ts";
4
4
 
5
5
  type ServeArgs = {
6
6
  projectId?: string;
7
+ runtimeFingerprint?: string;
7
8
  projectDir?: string;
8
9
  configPath?: string;
9
10
  statePath?: string;
@@ -37,6 +38,7 @@ if (missing.length > 0) {
37
38
 
38
39
  const runtime = await serveRuntime({
39
40
  projectId: options.projectId!,
41
+ runtimeFingerprint: options.runtimeFingerprint,
40
42
  projectDir: resolve(options.projectDir!),
41
43
  configPath: resolve(options.configPath!),
42
44
  statePath: options.statePath ? resolve(options.statePath) : undefined,
@@ -79,6 +81,9 @@ function parseServeArgs(args: string[]): ServeArgs {
79
81
  case "--project-id":
80
82
  parsed.projectId = readValue();
81
83
  break;
84
+ case "--runtime-fingerprint":
85
+ parsed.runtimeFingerprint = readValue();
86
+ break;
82
87
  case "--project-dir":
83
88
  case "--project":
84
89
  parsed.projectDir = readValue();
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.1");
19
+ expect(RIGKIT_SDK_VERSION).toBe("0.2.2");
20
20
  expect(env).toBeTypeOf("function");
21
21
  expect(env.secret).toBeTypeOf("function");
22
22
  expect(defineConfig).toBeTypeOf("function");
@@ -111,6 +111,7 @@ describe("runtime HTTP app", () => {
111
111
  let closed: Promise<void> | undefined;
112
112
 
113
113
  try {
114
+ writeNoopConfig(root);
114
115
  await Effect.runPromise(Effect.scoped(
115
116
  Effect.flatMap(
116
117
  serveRuntimeEffect({
@@ -146,6 +147,7 @@ describe("runtime HTTP app", () => {
146
147
  const root = mkdtempSync(join(tmpdir(), "rigkit-runtime-shutdown-"));
147
148
 
148
149
  try {
150
+ writeNoopConfig(root);
149
151
  const server = await serveRuntime({
150
152
  projectId: "test-project",
151
153
  projectDir: root,
@@ -167,6 +169,26 @@ describe("runtime HTTP app", () => {
167
169
  }
168
170
  });
169
171
 
172
+ test("loads config before reporting runtime readiness", async () => {
173
+ const root = mkdtempSync(join(tmpdir(), "rigkit-runtime-startup-config-"));
174
+ const configPath = join(root, "rig.config.ts");
175
+ writeFileSync(configPath, "throw new Error('startup config failed');\n");
176
+
177
+ try {
178
+ await expect(serveRuntime({
179
+ projectId: "test-project",
180
+ projectDir: root,
181
+ configPath,
182
+ handlePath: join(root, "runtime.json"),
183
+ tokenPath: join(root, "runtime.token"),
184
+ token: "test-token",
185
+ idleMs: 60_000,
186
+ })).rejects.toThrow("startup config failed");
187
+ } finally {
188
+ rmSync(root, { recursive: true, force: true });
189
+ }
190
+ });
191
+
170
192
  test("returns structured validation errors", async () => {
171
193
  const app = createRuntimeApp(testContext(), createRunStore());
172
194
 
@@ -806,6 +828,22 @@ describe("runtime HTTP app", () => {
806
828
  });
807
829
  });
808
830
 
831
+ function writeNoopConfig(projectDir: string): void {
832
+ writeFileSync(
833
+ join(projectDir, "rig.config.ts"),
834
+ `
835
+ import { defineConfig, sequence } from "${import.meta.dir}/../../../engine/src/index.ts";
836
+
837
+ const root = sequence("noop").step("ready", async () => ({ ready: true }));
838
+
839
+ export default defineConfig({
840
+ providers: {},
841
+ workflows: { root },
842
+ });
843
+ `,
844
+ );
845
+ }
846
+
809
847
  async function serveRuntimeFixture(prefix: string, configBody: string) {
810
848
  const projectDir = mkdtempSync(join(tmpdir(), prefix));
811
849
  const configPath = join(projectDir, "rig.config.ts");
@@ -4,6 +4,7 @@ import { serveRuntime } from "./server.ts";
4
4
 
5
5
  type ServeArgs = {
6
6
  projectId?: string;
7
+ runtimeFingerprint?: string;
7
8
  projectDir?: string;
8
9
  configPath?: string;
9
10
  statePath?: string;
@@ -37,6 +38,7 @@ if (missing.length > 0) {
37
38
 
38
39
  const runtime = await serveRuntime({
39
40
  projectId: options.projectId!,
41
+ runtimeFingerprint: options.runtimeFingerprint,
40
42
  projectDir: resolve(options.projectDir!),
41
43
  configPath: resolve(options.configPath!),
42
44
  statePath: options.statePath ? resolve(options.statePath) : undefined,
@@ -78,6 +80,9 @@ function parseServeArgs(args: string[]): ServeArgs {
78
80
  case "--project-id":
79
81
  parsed.projectId = readValue();
80
82
  break;
83
+ case "--runtime-fingerprint":
84
+ parsed.runtimeFingerprint = readValue();
85
+ break;
81
86
  case "--project-dir":
82
87
  case "--project":
83
88
  parsed.projectDir = readValue();
@@ -34,6 +34,7 @@ export function runtimeHealth(context: RuntimeContext) {
34
34
  return {
35
35
  ok: true,
36
36
  projectId: context.projectId,
37
+ runtimeFingerprint: context.runtimeFingerprint,
37
38
  projectDir: context.projectDir,
38
39
  configPath: context.configPath,
39
40
  statePath: context.statePath,
@@ -13,6 +13,7 @@ import { RIGKIT_RUNTIME_VERSION } from "./version.ts";
13
13
  import { runtimeJsonError, sessionRunIdFor } from "./app.ts";
14
14
  import { createRuntimeControlApiHandler } from "./api-handlers.ts";
15
15
  import type { RuntimeAppState } from "./control.ts";
16
+ import { loadEngine } from "./operations.ts";
16
17
  import { runSessionSocketEffect } from "./sessions.ts";
17
18
  import { DEFAULT_IDLE_MS } from "./protocol.ts";
18
19
  import { createRunStore } from "./runs.ts";
@@ -60,6 +61,7 @@ export async function serveRuntime(options: ServeRuntimeOptions): Promise<Runtim
60
61
  options.handlePath,
61
62
  `${JSON.stringify({
62
63
  projectId: options.projectId,
64
+ runtimeFingerprint: options.runtimeFingerprint,
63
65
  projectDir,
64
66
  configPath,
65
67
  statePath,
@@ -76,6 +78,7 @@ export async function serveRuntime(options: ServeRuntimeOptions): Promise<Runtim
76
78
 
77
79
  const context: RuntimeContext = {
78
80
  projectId: options.projectId,
81
+ runtimeFingerprint: options.runtimeFingerprint,
79
82
  projectDir,
80
83
  configPath,
81
84
  statePath,
@@ -90,6 +93,8 @@ export async function serveRuntime(options: ServeRuntimeOptions): Promise<Runtim
90
93
  stop: () => stopServer(),
91
94
  };
92
95
  const state: RuntimeAppState = { context, store };
96
+ await loadEngine(context);
97
+
93
98
  const controlApi = createRuntimeControlApiHandler(context, store);
94
99
  const app = createRuntimeHttpApp(state, controlApi);
95
100
  const scope = Effect.runSync(Scope.make());
@@ -2,6 +2,7 @@ import type { JsonValue } from "@rigkit/engine";
2
2
 
3
3
  export type ServeRuntimeOptions = {
4
4
  projectId: string;
5
+ runtimeFingerprint?: string;
5
6
  projectDir: string;
6
7
  configPath: string;
7
8
  statePath?: string;
@@ -23,6 +24,7 @@ export type RuntimeServer = {
23
24
 
24
25
  export type RuntimeContext = {
25
26
  readonly projectId: string;
27
+ readonly runtimeFingerprint?: string;
26
28
  readonly projectDir: string;
27
29
  readonly configPath: string;
28
30
  readonly statePath?: string;
@@ -1 +1 @@
1
- export const RIGKIT_RUNTIME_VERSION = "0.2.1";
1
+ export const RIGKIT_RUNTIME_VERSION = "0.2.2";
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const RIGKIT_SDK_VERSION = "0.2.1";
1
+ export const RIGKIT_SDK_VERSION = "0.2.2";