@method-ai-hq/sdk 0.15.0 → 0.15.1

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
@@ -3,7 +3,7 @@
3
3
  MIT-licensed JavaScript API and the `method` CLI. Source and releases: https://github.com/method-ai-hq/method-sdk
4
4
 
5
5
  ```sh
6
- npm install https://github.com/method-ai-hq/method-sdk/releases/download/v0.15.0/method-ai-hq-sdk-0.15.0.tgz
6
+ npm install https://github.com/method-ai-hq/method-sdk/releases/download/v0.15.1/method-ai-hq-sdk-0.15.1.tgz
7
7
  npx method --version
8
8
  ```
9
9
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@method-ai-hq/sdk",
3
- "version": "0.15.0",
3
+ "version": "0.15.1",
4
4
  "description": "Build and run reusable .method files with checked steps and saved results.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,4 +1,5 @@
1
1
  import { runCurrentFile } from "./current-runtime.js";
2
+ import { workerRunId } from "./run-worker.js";
2
3
  import { existsSync, readFileSync } from "node:fs";
3
4
  import { resolve } from "node:path";
4
5
  import { parseArgs } from "node:util";
@@ -93,8 +94,7 @@ async function accountSync(path, flags) {
93
94
  }
94
95
  const version = await prepareVersion(client, outbox, path);
95
96
  // A run started by the run worker keeps the ID that its start line linked to.
96
- const identity = join(runDir, "run-id.json"), runId = existsSync(identity) ? JSON.parse(readFileSync(identity, "utf8")).id : undefined;
97
- return { client, outbox, version, sync: () => new Sync(client, runDir, version.method_id, version.version_id, runId, method.run_data === "device", outbox) };
97
+ return { client, outbox, version, sync: () => new Sync(client, runDir, version.method_id, version.version_id, workerRunId(runDir), method.run_data === "device", outbox) };
98
98
  }
99
99
  catch (error) {
100
100
  // A copy of a Method that is saved from another file must not run: the change belongs in that file.
@@ -9,6 +9,7 @@ import { runCurrentFile } from './current-runtime.js';
9
9
  import { MethodSync } from './method-sync.js';
10
10
  import { recordKnownVersion } from './outbox.js';
11
11
  import { writePrivateJson } from './files.js';
12
+ import { workerRunId } from './run-worker.js';
12
13
  import { readDocument } from './authoring.js';
13
14
  import { withInputsFrom } from './inputs-from.js';
14
15
  // Older versions are listed only after their saved-package tests pass.
@@ -23,7 +24,8 @@ export async function runSaved(saved, flags, client) {
23
24
  const prior = existsSync(requestFile) ? JSON.parse(readFileSync(requestFile, 'utf8')) : null;
24
25
  if (prior && (prior.workflow_id !== saved.workflow_id || prior.version_id !== saved.version_id))
25
26
  throw Error('This run belongs to another saved version.');
26
- const request = prior ?? { run_id: randomUUID(), workflow_id: saved.workflow_id, version_id: saved.version_id, server: client.server };
27
+ // A run started by the run worker keeps the ID that its start line linked to.
28
+ const request = prior ?? { run_id: workerRunId(directory) ?? randomUUID(), workflow_id: saved.workflow_id, version_id: saved.version_id, server: client.server };
27
29
  if (prior && !flags.resume)
28
30
  throw Error('This run already exists. Use --resume.');
29
31
  writePrivateJson(requestFile, request);
@@ -1,5 +1,7 @@
1
1
  /** server: the signed-in Method server, so that the start line links to the run's dashboard page. */
2
2
  export declare function startRunWorker(args: string[], directory: string, background?: boolean, server?: string): Promise<void>;
3
+ /** The run ID that the worker's start line links to, when a run worker started this run. */
4
+ export declare function workerRunId(directory: string): string | undefined;
3
5
  export declare function workerAlive(directory: string): boolean;
4
6
  export declare function waitForRun(directory: string): Promise<any>;
5
7
  export declare function cancelRun(directory: string): {
@@ -65,6 +65,11 @@ export async function startRunWorker(args, directory, background = false, server
65
65
  if (!background)
66
66
  await waitForRun(directory);
67
67
  }
68
+ /** The run ID that the worker's start line links to, when a run worker started this run. */
69
+ export function workerRunId(directory) {
70
+ const identity = join(resolve(directory), 'run-id.json');
71
+ return existsSync(identity) ? JSON.parse(readFileSync(identity, 'utf8')).id : undefined;
72
+ }
68
73
  export function workerAlive(directory) {
69
74
  const path = join(resolve(directory), 'worker.json');
70
75
  if (!existsSync(path))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@method-ai-hq/sdk",
3
- "version": "0.15.0",
3
+ "version": "0.15.1",
4
4
  "description": "Build and run reusable .method files with checked steps and saved results.",
5
5
  "license": "MIT",
6
6
  "type": "module",