@dougbots/avenor-core 0.10.2 → 0.10.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/dist/index.d.ts CHANGED
@@ -407,6 +407,13 @@ declare class Supervisor {
407
407
  private static start;
408
408
  private startProcess;
409
409
  get supervisorId(): string;
410
+ /**
411
+ * Look up a run by its public run ID first, then by its label alias.
412
+ * Public run IDs are canonical; labels are lookup-only aliases.
413
+ */
414
+ getRunByReference(reference: string): RunInfo | undefined;
415
+ /** Match a stored run by its broker runtime ID. */
416
+ getRunByRuntimeId(runtimeId: string): RunInfo | undefined;
410
417
  static isCurrentInstance(supervisorId: string): boolean;
411
418
  static currentInstance(): Supervisor | null;
412
419
  getClient(): Client;
package/dist/index.js CHANGED
@@ -1496,6 +1496,18 @@ var Supervisor = class Supervisor {
1496
1496
  get supervisorId() {
1497
1497
  return this.socketPath;
1498
1498
  }
1499
+ /**
1500
+ * Look up a run by its public run ID first, then by its label alias.
1501
+ * Public run IDs are canonical; labels are lookup-only aliases.
1502
+ */
1503
+ getRunByReference(reference) {
1504
+ return this.runs.get(reference) ?? this.aliases.get(reference);
1505
+ }
1506
+ /** Match a stored run by its broker runtime ID. */
1507
+ getRunByRuntimeId(runtimeId) {
1508
+ if (!runtimeId) return void 0;
1509
+ for (const runInfo of this.runs.values()) if (runInfo.runtimeId === runtimeId) return runInfo;
1510
+ }
1499
1511
  static isCurrentInstance(supervisorId) {
1500
1512
  return Supervisor.instance !== null && Supervisor.instance.supervisorId === supervisorId;
1501
1513
  }
@@ -2105,14 +2117,11 @@ function validateThinkingForBackendResume(backend, value) {
2105
2117
  //#region src/tools/run-resolution.ts
2106
2118
  /** Resolve a local public run ID before considering a label alias. */
2107
2119
  function findLocalRunByReference(sup, reference) {
2108
- const { runs, aliases } = sup;
2109
- return runs.get(reference) ?? aliases.get(reference);
2120
+ return sup.getRunByReference(reference);
2110
2121
  }
2111
2122
  /** Match a supervisor list entry to its stored runtime identity. */
2112
2123
  function findLocalRunByRuntimeId(sup, runtimeId) {
2113
- if (!runtimeId) return void 0;
2114
- const { runs } = sup;
2115
- for (const runInfo of runs.values()) if (runInfo.runtimeId === runtimeId) return runInfo;
2124
+ return sup.getRunByRuntimeId(runtimeId);
2116
2125
  }
2117
2126
  //#endregion
2118
2127
  //#region src/tools/status.ts
@@ -3025,9 +3034,10 @@ function extractReplyMessage(result) {
3025
3034
  return JSON.stringify(result);
3026
3035
  }
3027
3036
  async function executeAskTool(args, getSupervisorClient) {
3028
- const { client, isSingleton } = await getSupervisorClient(args.supervisorId);
3037
+ const { client, isSingleton, sup, supervisorId } = await getSupervisorClient(args.supervisorId);
3029
3038
  try {
3030
- const result = await client.brokerAsk(args.toRunId, args.message);
3039
+ const target = (isSingleton && sup ? findLocalRunByReference(sup, args.toRunId) : findExternalRun(supervisorId, args.toRunId))?.runtimeId ?? args.toRunId;
3040
+ const result = await client.brokerAsk(target, args.message);
3031
3041
  return {
3032
3042
  reply: extractReplyMessage(result),
3033
3043
  from_run_id: result.from_run_id ?? ""
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dougbots/avenor-core",
3
- "version": "0.10.2",
3
+ "version": "0.10.4",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",