orchestrar 0.3.0 → 0.3.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.
Files changed (2) hide show
  1. package/orchestrator.js +27 -5
  2. package/package.json +1 -1
package/orchestrator.js CHANGED
@@ -446,13 +446,31 @@ async function fileExists(filePath) {
446
446
  }
447
447
  }
448
448
 
449
- function unwrap(result, label) {
450
- if (result && typeof result === "object" && "data" in result) {
451
- if (result.error) {
452
- throw new Error(`${label} failed: ${formatError(result.error)}`);
449
+ async function unwrap(result, label) {
450
+ if (result && typeof result.then === "function") {
451
+ result = await result;
452
+ }
453
+
454
+ if (!result || typeof result !== "object") {
455
+ return result;
456
+ }
457
+
458
+ const hasWrapperFields =
459
+ "request" in result ||
460
+ "response" in result ||
461
+ "error" in result ||
462
+ Object.prototype.hasOwnProperty.call(result, "data");
463
+
464
+ if (result.error) {
465
+ throw new Error(`${label} failed: ${formatError(result.error)}`);
466
+ }
467
+
468
+ if (hasWrapperFields) {
469
+ if ("data" in result || result.data !== undefined) {
470
+ return result.data;
453
471
  }
454
- return result.data;
455
472
  }
473
+
456
474
  return result;
457
475
  }
458
476
 
@@ -464,8 +482,12 @@ function extractSessionID(session, context) {
464
482
  const candidates = [
465
483
  session.id,
466
484
  session.sessionID,
485
+ session.data?.id,
486
+ session.data?.sessionID,
467
487
  session.info?.id,
468
488
  session.info?.sessionID,
489
+ session.data?.info?.id,
490
+ session.data?.info?.sessionID,
469
491
  session.properties?.id,
470
492
  session.properties?.sessionID,
471
493
  session.properties?.info?.id,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orchestrar",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "OpenCode milestone orchestrator",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",