@senpi-ai/runtime 1.0.74 → 1.0.76

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 (61) hide show
  1. package/dist/cli/guide-commands.js +9 -9
  2. package/dist/cli/senpi-commands.js +20 -20
  3. package/dist/cli/senpi-commands.js.map +1 -1
  4. package/dist/dsl/events/handlers.d.ts +1 -0
  5. package/dist/dsl/events/handlers.d.ts.map +1 -1
  6. package/dist/dsl/events/handlers.js +59 -48
  7. package/dist/dsl/events/handlers.js.map +1 -1
  8. package/dist/dsl/monitor/create-monitor.d.ts +1 -0
  9. package/dist/dsl/monitor/create-monitor.d.ts.map +1 -1
  10. package/dist/dsl/monitor/create-monitor.js +2 -1
  11. package/dist/dsl/monitor/create-monitor.js.map +1 -1
  12. package/dist/dsl/monitor/process-one-position.d.ts +2 -0
  13. package/dist/dsl/monitor/process-one-position.d.ts.map +1 -1
  14. package/dist/dsl/monitor/process-one-position.js +9 -1
  15. package/dist/dsl/monitor/process-one-position.js.map +1 -1
  16. package/dist/dsl/plugin/index.d.ts +2 -1
  17. package/dist/dsl/plugin/index.d.ts.map +1 -1
  18. package/dist/dsl/plugin/index.js +6 -3
  19. package/dist/dsl/plugin/index.js.map +1 -1
  20. package/dist/health/index.d.ts +2 -2
  21. package/dist/health/index.d.ts.map +1 -1
  22. package/dist/health/index.js +4 -4
  23. package/dist/health/index.js.map +1 -1
  24. package/dist/health/types.d.ts +4 -4
  25. package/dist/health/types.d.ts.map +1 -1
  26. package/dist/index.d.ts +4 -4
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +98 -98
  29. package/dist/index.js.map +1 -1
  30. package/dist/runtime/load-runtime-config.js +4 -4
  31. package/dist/runtime/load-runtime-config.js.map +1 -1
  32. package/dist/runtime/recipe-version.d.ts +2 -14
  33. package/dist/runtime/recipe-version.d.ts.map +1 -1
  34. package/dist/runtime/recipe-version.js +2 -24
  35. package/dist/runtime/recipe-version.js.map +1 -1
  36. package/dist/runtime/run.d.ts +2 -2
  37. package/dist/runtime/run.d.ts.map +1 -1
  38. package/dist/runtime/run.js +2 -2
  39. package/dist/runtime/run.js.map +1 -1
  40. package/dist/runtime/runtime-schema.d.ts +1 -1
  41. package/dist/runtime/runtime-schema.js +1 -1
  42. package/dist/runtime/runtime-version.d.ts +19 -0
  43. package/dist/runtime/runtime-version.d.ts.map +1 -0
  44. package/dist/runtime/runtime-version.js +29 -0
  45. package/dist/runtime/runtime-version.js.map +1 -0
  46. package/dist/runtime/runtime.d.ts +2 -2
  47. package/dist/runtime/runtime.d.ts.map +1 -1
  48. package/dist/runtime/runtime.js +4 -4
  49. package/dist/runtime/runtime.js.map +1 -1
  50. package/dist/runtime/state-layout.d.ts +16 -14
  51. package/dist/runtime/state-layout.d.ts.map +1 -1
  52. package/dist/runtime/state-layout.js +24 -22
  53. package/dist/runtime/state-layout.js.map +1 -1
  54. package/dist/runtime/strategy-registry.d.ts +29 -23
  55. package/dist/runtime/strategy-registry.d.ts.map +1 -1
  56. package/dist/runtime/strategy-registry.js +60 -38
  57. package/dist/runtime/strategy-registry.js.map +1 -1
  58. package/dist/types/dsl/index.d.ts +2 -2
  59. package/dist/types/dsl/index.d.ts.map +1 -1
  60. package/openclaw.plugin.json +1 -1
  61. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@
5
5
  * Named export run(): programmatic/standalone entry.
6
6
  */
7
7
  import { join } from "node:path";
8
- import { buildRecipeStateDir, archiveStateDir } from "./runtime/state-layout.js";
8
+ import { buildRuntimeStateDir, archiveStateDir } from "./runtime/state-layout.js";
9
9
  import { registerSenpiCli } from "./cli/senpi-commands.js";
10
10
  import { readSenpiCliStore, resolveSenpiApiKeyFromStore, resolveSenpiBaseStateDir, resolveTelegramChatIdFromStore, } from "./cli/senpi-cli-config.js";
11
11
  import { getDefaultStateDir } from "./runtime/default-state-dir.js";
@@ -42,7 +42,7 @@ export { ClosePositionAction, closePositionFactory, closePositionManifest, } fro
42
42
  export { SenpiClient } from './senpi/index.js';
43
43
  // Scanner runtime module
44
44
  export { createScannerRuntimeModule, createSenpiScannerProviders, emergingMoversScanner, momentumScanner, oiTrackerScanner, providerInput, prescreenerScanner, PersistencePolicy, RetentionPolicy, ScanStatus as ScannerScanStatus, SkipScan, } from './scanners/index.js';
45
- // Runtime (trading recipe loader) — programmatic API and OpenClaw plugin entry
45
+ // Runtime loader — programmatic API and OpenClaw plugin entry
46
46
  export { run } from "./runtime/run.js";
47
47
  export { loadRuntimeConfig } from "./runtime/load-runtime-config.js";
48
48
  export { Runtime } from "./runtime/runtime.js";
@@ -132,13 +132,13 @@ function fireAndForgetErrorNotification(notifications, message) {
132
132
  }
133
133
  /**
134
134
  * OpenClaw plugin entry.
135
- * Boots from internal registry (installed_recipes.json) in stateDir; does not read recipe list from config.
135
+ * Boots from internal registry (installed_runtimes.json) in stateDir; does not read runtime list from config.
136
136
  */
137
- const senpiRecipePlugin = {
137
+ const senpiRuntimePlugin = {
138
138
  id: "@senpi-ai/runtime",
139
- name: "Senpi Trading Recipe",
139
+ name: "Senpi Trading Runtime",
140
140
  version: VERSION,
141
- description: "Trading recipe plugin for OpenClaw — orchestrates scanners, actions, and DSL exit engine",
141
+ description: "Senpi trading runtime plugin for OpenClaw — orchestrates scanners, actions, and DSL exit engine",
142
142
  configSchema: {
143
143
  parse(value) {
144
144
  if (value && typeof value === "object" && !Array.isArray(value)) {
@@ -153,10 +153,10 @@ const senpiRecipePlugin = {
153
153
  warn: (...args) => api.logger.warn(...args),
154
154
  error: (message, meta) => api.logger.error(message, meta),
155
155
  };
156
- pluginLogger.info("[senpi-recipe] register(api) invoked");
156
+ pluginLogger.info("[senpi-runtime] register(api) invoked");
157
157
  const config = api.pluginConfig;
158
158
  if (!config) {
159
- pluginLogger.warn("[senpi-recipe] No plugin config found — skipping registration");
159
+ pluginLogger.warn("[senpi-runtime] No plugin config found — skipping registration");
160
160
  return;
161
161
  }
162
162
  const senpiCliStore = readSenpiCliStore();
@@ -171,7 +171,7 @@ const senpiRecipePlugin = {
171
171
  const mcpTransport = api.mcpTransport;
172
172
  const apiKey = resolveSenpiApiKeyFromStore(senpiCliStore, typeof config.apiKey === "string" && config.apiKey.length > 0 ? config.apiKey : undefined);
173
173
  if (!mcpTransport && !apiKey) {
174
- pluginLogger.error("[senpi-recipe] mcpTransport or apiKey is required (provide via gateway, api, or config)");
174
+ pluginLogger.error("[senpi-runtime] mcpTransport or apiKey is required (provide via gateway, api, or config)");
175
175
  return;
176
176
  }
177
177
  const runtimeHandles = new Map();
@@ -193,7 +193,7 @@ const senpiRecipePlugin = {
193
193
  fireAndForgetErrorNotification(lifecycleNotifications, formatApiLoggerErrorNotification(message, meta));
194
194
  };
195
195
  api.registerService({
196
- id: "senpi-recipe",
196
+ id: "senpi-runtime",
197
197
  async start() {
198
198
  const { readRegistry } = await import("./runtime/strategy-registry.js");
199
199
  const registry = await readRegistry(baseStateDir);
@@ -203,7 +203,7 @@ const senpiRecipePlugin = {
203
203
  });
204
204
  const started = [];
205
205
  try {
206
- for (const entry of registry.recipes) {
206
+ for (const entry of registry.runtimes) {
207
207
  const hasPath = typeof entry.runtimeYamlPath === "string" && entry.runtimeYamlPath.length > 0;
208
208
  const hasContent = typeof entry.runtimeYamlContent === "string";
209
209
  if (hasPath && hasContent)
@@ -211,7 +211,7 @@ const senpiRecipePlugin = {
211
211
  if (!hasPath && !hasContent)
212
212
  continue;
213
213
  const pathOrContent = entry.runtimeYamlPath ?? entry.runtimeYamlContent;
214
- const entryStateDir = buildRecipeStateDir(baseStateDir, entry.id, entry.wallet ?? "");
214
+ const entryStateDir = buildRuntimeStateDir(baseStateDir, entry.id, entry.wallet ?? "");
215
215
  const handle = await run(pathOrContent, {
216
216
  fromPath: hasPath,
217
217
  stateDir: entryStateDir,
@@ -232,15 +232,15 @@ const senpiRecipePlugin = {
232
232
  }
233
233
  throw err;
234
234
  }
235
- pluginLogger.info(`[senpi-recipe] Started ${started.length} recipe${started.length === 1 ? "" : "s"}`);
235
+ pluginLogger.info(`[senpi-runtime] Started ${started.length} runtime${started.length === 1 ? "" : "s"}`);
236
236
  if (lifecycleNotifications) {
237
237
  const n = started.length;
238
238
  lifecycleNotifications
239
- .notify(`Senpi started. ${n} recipe${n === 1 ? "" : "s"} running.`)
239
+ .notify(`Senpi started. ${n} runtime${n === 1 ? "" : "s"} running.`)
240
240
  .catch(() => { });
241
241
  }
242
242
  else if (started.length > 0) {
243
- pluginLogger.info("[senpi-recipe] Lifecycle notification skipped (set telegram-chat-id via `openclaw senpi config set-chat-id` or TELEGRAM_CHAT_ID / SENPI_LIFECYCLE_TELEGRAM_CHAT_ID)");
243
+ pluginLogger.info("[senpi-runtime] Lifecycle notification skipped (set telegram-chat-id via `openclaw senpi config set-chat-id` or TELEGRAM_CHAT_ID / SENPI_LIFECYCLE_TELEGRAM_CHAT_ID)");
244
244
  }
245
245
  },
246
246
  async stop() {
@@ -254,28 +254,28 @@ const senpiRecipePlugin = {
254
254
  await h.stop();
255
255
  runtimeHandles.delete(ids[i]);
256
256
  }
257
- pluginLogger.info("[senpi-recipe] All recipes stopped");
257
+ pluginLogger.info("[senpi-runtime] All runtimes stopped");
258
258
  },
259
259
  });
260
- pluginLogger.info("[senpi-recipe] calling api.registerCli(..., { commands: ['senpi'] })");
260
+ pluginLogger.info("[senpi-runtime] calling api.registerCli(..., { commands: ['senpi'] })");
261
261
  api.registerCli((ctx) => {
262
- pluginLogger.info("[senpi-recipe] CLI registrar callback invoked — attaching senpi subcommands to program");
262
+ pluginLogger.info("[senpi-runtime] CLI registrar callback invoked — attaching senpi subcommands to program");
263
263
  registerSenpiCli(ctx.program);
264
264
  }, { commands: ["senpi"] });
265
265
  /** Gateway respond accepts (ok, payload?, error?) with error as { code, message }; plugin SDK types may omit the third arg. */
266
- api.registerGatewayMethod("senpi.installRecipe", async (ctx) => {
266
+ api.registerGatewayMethod("senpi.installRuntime", async (ctx) => {
267
267
  const { params } = ctx;
268
268
  const respond = ctx.respond;
269
269
  const toError = (message) => ({ code: "INVALID_REQUEST", message });
270
270
  const toUnavailable = (message) => ({ code: "UNAVAILABLE", message });
271
- const { readRegistry, writeRegistry, validateEntry, hasId, deriveRecipeId, sanitizeId } = await import("./runtime/strategy-registry.js");
271
+ const { readRegistry, writeRegistry, validateEntry, hasId, deriveRuntimeId, sanitizeId } = await import("./runtime/strategy-registry.js");
272
272
  const id = typeof params?.id === "string" ? params.id : undefined;
273
273
  const runtimeYamlPath = typeof params?.runtimeYamlPath === "string" ? params.runtimeYamlPath : undefined;
274
274
  const runtimeYamlContent = typeof params?.runtimeYamlContent === "string" ? params.runtimeYamlContent : undefined;
275
275
  const hasPath = runtimeYamlPath !== undefined && runtimeYamlPath.length > 0;
276
276
  const hasContent = runtimeYamlContent !== undefined;
277
277
  if (!hasPath && !hasContent) {
278
- respond(false, undefined, toError("Please provide your recipe YAML: use the create command with --path <file> or --content \"<yaml text>\"."));
278
+ respond(false, undefined, toError("Please provide your runtime YAML: use the create command with --path <file> or --content \"<yaml text>\"."));
279
279
  return;
280
280
  }
281
281
  if (hasPath && hasContent) {
@@ -285,34 +285,34 @@ const senpiRecipePlugin = {
285
285
  const pathOrContent = runtimeYamlPath ?? runtimeYamlContent;
286
286
  // Parse YAML first to extract name, version, and wallet for ID derivation.
287
287
  let parsedSchemaVersion;
288
- let recipeName = "";
288
+ let runtimeName = "";
289
289
  let wallet = "";
290
290
  try {
291
291
  const { loadRuntimeConfig } = await import("./runtime/load-runtime-config.js");
292
- const { extractMajorVersion } = await import("./runtime/recipe-version.js");
292
+ const { extractMajorVersion } = await import("./runtime/runtime-version.js");
293
293
  const parsedConfig = await loadRuntimeConfig(pathOrContent, { fromPath: hasPath });
294
294
  parsedSchemaVersion = extractMajorVersion(parsedConfig.version);
295
- recipeName = parsedConfig.name;
295
+ runtimeName = parsedConfig.name;
296
296
  wallet = parsedConfig.strategy?.wallet ?? "";
297
297
  }
298
298
  catch (err) {
299
299
  const msg = err instanceof Error ? err.message : String(err);
300
- respond(false, undefined, toUnavailable(`Could not start the recipe. This is usually due to invalid or incomplete YAML.\n\n${msg}`));
300
+ respond(false, undefined, toUnavailable(`Could not start the runtime. This is usually due to invalid or incomplete YAML.\n\n${msg}`));
301
301
  return;
302
302
  }
303
303
  const registry = await readRegistry(baseStateDir);
304
304
  const resolvedId = id && id.length > 0
305
- ? (sanitizeId(id) || "recipe")
306
- : deriveRecipeId(recipeName, wallet);
305
+ ? (sanitizeId(id) || "runtime")
306
+ : deriveRuntimeId(runtimeName, wallet);
307
307
  if (hasId(registry, resolvedId)) {
308
- respond(false, undefined, toError(`A recipe with id "${resolvedId}" already exists. Use a different id (e.g. --recipe-id another-name) or remove the existing one first: openclaw senpi runtime delete ${resolvedId}`));
308
+ respond(false, undefined, toError(`A runtime with id "${resolvedId}" already exists. Use a different id (e.g. --runtime-id another-name) or remove the existing one first: openclaw senpi runtime delete ${resolvedId}`));
309
309
  return;
310
310
  }
311
- // Enforce one running recipe per wallet address
311
+ // Enforce one running runtime per wallet address
312
312
  if (wallet) {
313
313
  for (const [existingId, existingHandle] of runtimeHandles) {
314
314
  if (existingHandle.wallet === wallet) {
315
- respond(false, undefined, toError(`A recipe for wallet "${wallet}" is already running (recipe "${existingId}"). ` +
315
+ respond(false, undefined, toError(`A runtime for wallet "${wallet}" is already running (runtime "${existingId}"). ` +
316
316
  `Stop it first: openclaw senpi runtime delete --id ${existingId}`));
317
317
  return;
318
318
  }
@@ -326,14 +326,14 @@ const senpiRecipePlugin = {
326
326
  respond(false, undefined, toError(valid.error));
327
327
  return;
328
328
  }
329
- registry.recipes.push(entry);
329
+ registry.runtimes.push(entry);
330
330
  await writeRegistry(baseStateDir, registry);
331
331
  try {
332
332
  const scannerProviders = await createScannerProvidersForRun({
333
333
  mcpTransport,
334
334
  apiKey,
335
335
  });
336
- const entryStateDir = buildRecipeStateDir(baseStateDir, resolvedId, wallet);
336
+ const entryStateDir = buildRuntimeStateDir(baseStateDir, resolvedId, wallet);
337
337
  const handle = await run(pathOrContent, {
338
338
  fromPath: hasPath,
339
339
  stateDir: entryStateDir,
@@ -342,28 +342,28 @@ const senpiRecipePlugin = {
342
342
  scannerProviders,
343
343
  });
344
344
  runtimeHandles.set(resolvedId, handle);
345
- respond(true, { id: resolvedId, name: recipeName, wallet });
345
+ respond(true, { id: resolvedId, name: runtimeName, wallet });
346
346
  }
347
347
  catch (err) {
348
- const next = registry.recipes.filter((e) => e.id !== resolvedId);
349
- await writeRegistry(baseStateDir, { ...registry, recipes: next });
348
+ const next = registry.runtimes.filter((e) => e.id !== resolvedId);
349
+ await writeRegistry(baseStateDir, { ...registry, runtimes: next });
350
350
  const msg = err instanceof Error ? err.message : String(err);
351
- respond(false, undefined, toUnavailable(`Could not start the recipe. This is usually due to invalid or incomplete YAML.\n\n${msg}`));
351
+ respond(false, undefined, toUnavailable(`Could not start the runtime. This is usually due to invalid or incomplete YAML.\n\n${msg}`));
352
352
  }
353
353
  });
354
- api.registerGatewayMethod("senpi.listRecipes", async (ctx) => {
354
+ api.registerGatewayMethod("senpi.listRuntimes", async (ctx) => {
355
355
  const respond = ctx.respond;
356
356
  const { readRegistry } = await import("./runtime/strategy-registry.js");
357
357
  const registry = await readRegistry(baseStateDir);
358
- const recipes = registry.recipes.map((e) => ({
358
+ const runtimes = registry.runtimes.map((e) => ({
359
359
  id: e.id,
360
360
  wallet: e.wallet ?? "",
361
361
  source: typeof e.runtimeYamlPath === "string" && e.runtimeYamlPath.length > 0 ? e.runtimeYamlPath : "(inline)",
362
362
  status: runtimeHandles.has(e.id) ? "running" : "stopped",
363
363
  }));
364
- respond(true, { recipes });
364
+ respond(true, { runtimes });
365
365
  });
366
- api.registerGatewayMethod("senpi.deleteRecipe", async (ctx) => {
366
+ api.registerGatewayMethod("senpi.deleteRuntime", async (ctx) => {
367
367
  const { params } = ctx;
368
368
  const respond = ctx.respond;
369
369
  const { readRegistry, writeRegistry } = await import("./runtime/strategy-registry.js");
@@ -372,11 +372,11 @@ const senpiRecipePlugin = {
372
372
  const targetAddress = typeof params?.address === "string" ? params.address : undefined;
373
373
  // Resolve target by address if id not provided
374
374
  if (!targetId && targetAddress) {
375
- const entry = registry.recipes.find((e) => e.wallet === targetAddress);
375
+ const entry = registry.runtimes.find((e) => e.wallet === targetAddress);
376
376
  if (!entry) {
377
377
  respond(false, undefined, {
378
378
  code: "NOT_FOUND",
379
- message: `No recipe found for wallet address "${targetAddress}".`,
379
+ message: `No runtime found for wallet address "${targetAddress}".`,
380
380
  });
381
381
  return;
382
382
  }
@@ -385,41 +385,41 @@ const senpiRecipePlugin = {
385
385
  if (!targetId) {
386
386
  respond(false, undefined, {
387
387
  code: "INVALID_REQUEST",
388
- message: "Please provide the recipe id or wallet address. Example: openclaw senpi runtime delete --id my-recipe",
388
+ message: "Please provide the runtime id or wallet address. Example: openclaw senpi runtime delete --id my-runtime",
389
389
  });
390
390
  return;
391
391
  }
392
392
  const handle = runtimeHandles.get(targetId);
393
393
  if (handle) {
394
- await handle.teardownDslForRecipeDeletion();
394
+ await handle.teardownDslForRuntimeDeletion();
395
395
  await handle.stop();
396
396
  runtimeHandles.delete(targetId);
397
397
  }
398
398
  // Archive state directory before removing from registry
399
- const deletedEntry = registry.recipes.find((e) => e.id === targetId);
399
+ const deletedEntry = registry.runtimes.find((e) => e.id === targetId);
400
400
  if (deletedEntry) {
401
- const recipeStateDir = buildRecipeStateDir(baseStateDir, targetId, deletedEntry.wallet ?? "");
401
+ const runtimeStateDir = buildRuntimeStateDir(baseStateDir, targetId, deletedEntry.wallet ?? "");
402
402
  const archivesDir = join(baseStateDir, "archives");
403
403
  try {
404
- const archivePath = await archiveStateDir(recipeStateDir, archivesDir, targetId, deletedEntry.wallet ?? "");
405
- api.logger.info(`[senpi-recipe] Archived state to ${archivePath}`);
404
+ const archivePath = await archiveStateDir(runtimeStateDir, archivesDir, targetId, deletedEntry.wallet ?? "");
405
+ api.logger.info(`[senpi-runtime] Archived state to ${archivePath}`);
406
406
  }
407
407
  catch (err) {
408
- api.logger.warn("[senpi-recipe] Failed to archive state dir", { err });
408
+ api.logger.warn("[senpi-runtime] Failed to archive state dir", { err });
409
409
  }
410
410
  }
411
- const next = registry.recipes.filter((e) => e.id !== targetId);
412
- await writeRegistry(baseStateDir, { ...registry, recipes: next });
411
+ const next = registry.runtimes.filter((e) => e.id !== targetId);
412
+ await writeRegistry(baseStateDir, { ...registry, runtimes: next });
413
413
  respond(true, { id: targetId });
414
414
  });
415
415
  api.registerGatewayMethod("senpi.listDslPositions", async (ctx) => {
416
416
  const respond = ctx.respond;
417
- const recipeId = typeof ctx.params?.recipeId === "string" ? ctx.params.recipeId : undefined;
417
+ const runtimeId = typeof ctx.params?.runtimeId === "string" ? ctx.params.runtimeId : undefined;
418
418
  const address = typeof ctx.params?.address === "string" ? ctx.params.address : undefined;
419
- pluginLogger.info("[senpi-recipe] senpi.listDslPositions", { recipeId, address });
419
+ pluginLogger.info("[senpi-runtime] senpi.listDslPositions", { runtimeId, address });
420
420
  const positions = [];
421
421
  for (const [id, handle] of runtimeHandles) {
422
- if (recipeId && id !== recipeId)
422
+ if (runtimeId && id !== runtimeId)
423
423
  continue;
424
424
  if (!handle.dsl)
425
425
  continue;
@@ -428,11 +428,11 @@ const senpiRecipePlugin = {
428
428
  for (const s of items) {
429
429
  if (address && s.address !== address)
430
430
  continue;
431
- positions.push({ ...s, recipeId: id });
431
+ positions.push({ ...s, runtimeId: id });
432
432
  }
433
433
  }
434
434
  catch (err) {
435
- pluginLogger.warn("[senpi-recipe] listDslPositions error", { recipeId: id, err });
435
+ pluginLogger.warn("[senpi-runtime] listDslPositions error", { runtimeId: id, err });
436
436
  }
437
437
  }
438
438
  respond(true, { positions });
@@ -444,12 +444,12 @@ const senpiRecipePlugin = {
444
444
  respond(false, undefined, { code: "INVALID_REQUEST", message: "asset is required" });
445
445
  return;
446
446
  }
447
- const recipeId = typeof ctx.params?.recipeId === "string" ? ctx.params.recipeId : undefined;
447
+ const runtimeId = typeof ctx.params?.runtimeId === "string" ? ctx.params.runtimeId : undefined;
448
448
  const address = typeof ctx.params?.address === "string" ? ctx.params.address : undefined;
449
- pluginLogger.info("[senpi-recipe] senpi.getDslPositionState", { asset, recipeId, address });
449
+ pluginLogger.info("[senpi-runtime] senpi.getDslPositionState", { asset, runtimeId, address });
450
450
  const matches = [];
451
451
  for (const [id, handle] of runtimeHandles) {
452
- if (recipeId && id !== recipeId)
452
+ if (runtimeId && id !== runtimeId)
453
453
  continue;
454
454
  if (!handle.dsl)
455
455
  continue;
@@ -457,16 +457,16 @@ const senpiRecipePlugin = {
457
457
  if (address) {
458
458
  const state = handle.dsl.getPositionState(address, asset);
459
459
  if (state)
460
- matches.push({ recipeId: id, address, state });
460
+ matches.push({ runtimeId: id, address, state });
461
461
  }
462
462
  else {
463
463
  const found = handle.dsl.findPositionByAsset(asset);
464
464
  if (found)
465
- matches.push({ recipeId: id, address: found.address, state: found.state });
465
+ matches.push({ runtimeId: id, address: found.address, state: found.state });
466
466
  }
467
467
  }
468
468
  catch (err) {
469
- pluginLogger.warn("[senpi-recipe] getDslPositionState error", { recipeId: id, err });
469
+ pluginLogger.warn("[senpi-runtime] getDslPositionState error", { runtimeId: id, err });
470
470
  }
471
471
  }
472
472
  if (matches.length === 0) {
@@ -480,23 +480,23 @@ const senpiRecipePlugin = {
480
480
  });
481
481
  api.registerGatewayMethod("senpi.listDslArchives", async (ctx) => {
482
482
  const respond = ctx.respond;
483
- const recipeId = typeof ctx.params?.recipeId === "string" ? ctx.params.recipeId : undefined;
483
+ const runtimeId = typeof ctx.params?.runtimeId === "string" ? ctx.params.runtimeId : undefined;
484
484
  const address = typeof ctx.params?.address === "string" ? ctx.params.address : undefined;
485
485
  const limit = typeof ctx.params?.limit === "number" ? ctx.params.limit : undefined;
486
- pluginLogger.info("[senpi-recipe] senpi.listDslArchives", { recipeId, address, limit });
486
+ pluginLogger.info("[senpi-runtime] senpi.listDslArchives", { runtimeId, address, limit });
487
487
  let closes = [];
488
488
  for (const [id, handle] of runtimeHandles) {
489
- if (recipeId && id !== recipeId)
489
+ if (runtimeId && id !== runtimeId)
490
490
  continue;
491
491
  if (!handle.dsl)
492
492
  continue;
493
493
  try {
494
494
  const items = await handle.dsl.listArchivedCloses({ address });
495
495
  for (const c of items)
496
- closes.push({ ...c, recipeId: id });
496
+ closes.push({ ...c, runtimeId: id });
497
497
  }
498
498
  catch (err) {
499
- pluginLogger.warn("[senpi-recipe] listDslArchives error", { recipeId: id, err });
499
+ pluginLogger.warn("[senpi-runtime] listDslArchives error", { runtimeId: id, err });
500
500
  }
501
501
  }
502
502
  closes.sort((a, b) => (b.closedAt ?? "").localeCompare(a.closedAt ?? ""));
@@ -506,23 +506,23 @@ const senpiRecipePlugin = {
506
506
  });
507
507
  api.registerGatewayMethod("senpi.getHealthStatus", async (ctx) => {
508
508
  const respond = ctx.respond;
509
- const recipeId = typeof ctx.params?.recipeId === "string" ? ctx.params.recipeId : undefined;
510
- if (recipeId) {
511
- const handle = getRuntimeHandleOrRespond(runtimeHandles, recipeId, respond);
509
+ const runtimeId = typeof ctx.params?.runtimeId === "string" ? ctx.params.runtimeId : undefined;
510
+ if (runtimeId) {
511
+ const handle = getRuntimeHandleOrRespond(runtimeHandles, runtimeId, respond);
512
512
  if (!handle) {
513
513
  return;
514
514
  }
515
515
  try {
516
516
  const status = await handle.getHealthStatus();
517
517
  respond(true, {
518
- status: status ? { ...status, recipeId } : null,
518
+ status: status ? { ...status, runtimeId } : null,
519
519
  });
520
520
  }
521
521
  catch (err) {
522
- api.logger.warn("[senpi-recipe] getHealthStatus error", { recipeId, err });
522
+ api.logger.warn("[senpi-runtime] getHealthStatus error", { runtimeId, err });
523
523
  respond(false, undefined, {
524
524
  code: "INTERNAL_ERROR",
525
- message: `Failed to get health status for recipe ${recipeId}: ${formatGatewayError(err)}`,
525
+ message: `Failed to get health status for runtime ${runtimeId}: ${formatGatewayError(err)}`,
526
526
  });
527
527
  }
528
528
  return;
@@ -532,23 +532,23 @@ const senpiRecipePlugin = {
532
532
  });
533
533
  api.registerGatewayMethod("senpi.getSystemState", async (ctx) => {
534
534
  const respond = ctx.respond;
535
- const recipeId = typeof ctx.params?.recipeId === "string" ? ctx.params.recipeId : undefined;
536
- if (recipeId) {
537
- const handle = getRuntimeHandleOrRespond(runtimeHandles, recipeId, respond);
535
+ const runtimeId = typeof ctx.params?.runtimeId === "string" ? ctx.params.runtimeId : undefined;
536
+ if (runtimeId) {
537
+ const handle = getRuntimeHandleOrRespond(runtimeHandles, runtimeId, respond);
538
538
  if (!handle) {
539
539
  return;
540
540
  }
541
541
  try {
542
542
  const state = await handle.getSystemState();
543
543
  respond(true, {
544
- state: state ? { ...state, recipeId } : null,
544
+ state: state ? { ...state, runtimeId } : null,
545
545
  });
546
546
  }
547
547
  catch (err) {
548
- api.logger.warn("[senpi-recipe] getSystemState error", { recipeId, err });
548
+ api.logger.warn("[senpi-runtime] getSystemState error", { runtimeId, err });
549
549
  respond(false, undefined, {
550
550
  code: "INTERNAL_ERROR",
551
- message: `Failed to get system state for recipe ${recipeId}: ${formatGatewayError(err)}`,
551
+ message: `Failed to get system state for runtime ${runtimeId}: ${formatGatewayError(err)}`,
552
552
  });
553
553
  }
554
554
  return;
@@ -556,50 +556,50 @@ const senpiRecipePlugin = {
556
556
  const states = await collectRuntimeSystemStates(runtimeHandles, api.logger, baseStateDir);
557
557
  respond(true, { states });
558
558
  });
559
- api.logger.info(`[senpi-recipe] v${VERSION} plugin registered — stateDir: ${baseStateDir}`);
559
+ api.logger.info(`[senpi-runtime] v${VERSION} plugin registered — stateDir: ${baseStateDir}`);
560
560
  },
561
561
  };
562
- function getRuntimeHandleOrRespond(runtimeHandles, recipeId, respond) {
563
- const handle = runtimeHandles.get(recipeId);
562
+ function getRuntimeHandleOrRespond(runtimeHandles, runtimeId, respond) {
563
+ const handle = runtimeHandles.get(runtimeId);
564
564
  if (handle) {
565
565
  return handle;
566
566
  }
567
567
  respond(false, undefined, {
568
568
  code: "NOT_FOUND",
569
- message: `No running recipe found for id ${recipeId}`,
569
+ message: `No running runtime found for id ${runtimeId}`,
570
570
  });
571
571
  return null;
572
572
  }
573
573
  async function collectRuntimeHealthStatuses(runtimeHandles, logger) {
574
- return (await Promise.all(Array.from(runtimeHandles, async ([recipeId, handle]) => {
574
+ return (await Promise.all(Array.from(runtimeHandles, async ([runtimeId, handle]) => {
575
575
  try {
576
576
  const status = await handle.getHealthStatus();
577
- return status ? { ...status, recipeId } : null;
577
+ return status ? { ...status, runtimeId } : null;
578
578
  }
579
579
  catch (err) {
580
- logger.warn("[senpi-recipe] getHealthStatus error", { recipeId, err });
581
- return createGatewayHealthErrorStatus(recipeId, err);
580
+ logger.warn("[senpi-runtime] getHealthStatus error", { runtimeId, err });
581
+ return createGatewayHealthErrorStatus(runtimeId, err);
582
582
  }
583
583
  }))).filter((status) => status !== null);
584
584
  }
585
585
  async function collectRuntimeSystemStates(runtimeHandles, logger, baseStateDir) {
586
- return (await Promise.all(Array.from(runtimeHandles, async ([recipeId, handle]) => {
586
+ return (await Promise.all(Array.from(runtimeHandles, async ([runtimeId, handle]) => {
587
587
  try {
588
588
  const state = await handle.getSystemState();
589
- return state ? { ...state, recipeId } : null;
589
+ return state ? { ...state, runtimeId } : null;
590
590
  }
591
591
  catch (err) {
592
- logger.warn("[senpi-recipe] getSystemState error", { recipeId, err });
593
- return createGatewaySystemStateError(recipeId, join(baseStateDir, recipeId), err);
592
+ logger.warn("[senpi-runtime] getSystemState error", { runtimeId, err });
593
+ return createGatewaySystemStateError(runtimeId, join(baseStateDir, runtimeId), err);
594
594
  }
595
595
  }))).filter((state) => state !== null);
596
596
  }
597
- function createGatewayHealthErrorStatus(recipeId, error) {
597
+ function createGatewayHealthErrorStatus(runtimeId, error) {
598
598
  const now = new Date().toISOString();
599
599
  const message = formatGatewayError(error);
600
600
  return {
601
- recipeId,
602
- recipeName: recipeId,
601
+ runtimeId,
602
+ runtimeName: runtimeId,
603
603
  startedAt: now,
604
604
  generatedAt: now,
605
605
  health: "unhealthy",
@@ -622,12 +622,12 @@ function createGatewayHealthErrorStatus(recipeId, error) {
622
622
  },
623
623
  };
624
624
  }
625
- function createGatewaySystemStateError(recipeId, stateDir, error) {
625
+ function createGatewaySystemStateError(runtimeId, stateDir, error) {
626
626
  const now = new Date().toISOString();
627
627
  const message = formatGatewayError(error);
628
628
  return {
629
- recipeId,
630
- recipeName: recipeId,
629
+ runtimeId,
630
+ runtimeName: runtimeId,
631
631
  stateDir,
632
632
  startedAt: now,
633
633
  generatedAt: now,
@@ -650,5 +650,5 @@ function createGatewaySystemStateError(recipeId, stateDir, error) {
650
650
  function formatGatewayError(error) {
651
651
  return error instanceof Error ? error.message : String(error);
652
652
  }
653
- export default senpiRecipePlugin;
653
+ export default senpiRuntimePlugin;
654
654
  //# sourceMappingURL=index.js.map