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