@groeponline/pi-missions 0.2.0 → 0.3.0

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/CHANGELOG.md CHANGED
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.3.0] - 2026-08-22
11
+
12
+ ## [0.2.1] - 2026-08-22
13
+
10
14
  ## [0.2.0] - 2026-08-22
11
15
 
12
16
  ### Added
package/dist/index.d.ts CHANGED
@@ -2,4 +2,27 @@ import { ExtensionAPI } from '@earendil-works/pi-coding-agent';
2
2
 
3
3
  declare function piMissions(pi: ExtensionAPI): void;
4
4
 
5
- export { piMissions as default };
5
+ declare const ORCHESTRA_EXECUTION_CONTRACT_VERSION: 1;
6
+ interface MissionOrchestraExecutionIdentity {
7
+ missionId: string;
8
+ taskId: string;
9
+ attemptId: string;
10
+ }
11
+ interface MissionOrchestraExecutionCorrelation extends MissionOrchestraExecutionIdentity {
12
+ caller: "pi-missions";
13
+ idempotencyKey: string;
14
+ }
15
+ /**
16
+ * Must stay byte-for-byte compatible with
17
+ * @groeponline/pi-agent-orchestrator's CHE-142 v1 contract.
18
+ */
19
+ declare function buildOrchestraExecutionIdempotencyKey(identity: MissionOrchestraExecutionIdentity): string;
20
+ /** Build the correlation envelope for one logical mission execution attempt. */
21
+ declare function buildMissionOrchestraExecutionCorrelation(identity: MissionOrchestraExecutionIdentity): MissionOrchestraExecutionCorrelation;
22
+ /**
23
+ * Propagate correlation through a child Pi process without making environment
24
+ * variables the canonical durable state. They are transport metadata only.
25
+ */
26
+ declare function orchestraCorrelationEnv(correlation: MissionOrchestraExecutionCorrelation): Record<string, string>;
27
+
28
+ export { type MissionOrchestraExecutionCorrelation, type MissionOrchestraExecutionIdentity, ORCHESTRA_EXECUTION_CONTRACT_VERSION, buildMissionOrchestraExecutionCorrelation, buildOrchestraExecutionIdempotencyKey, piMissions as default, orchestraCorrelationEnv };
package/dist/index.js CHANGED
@@ -2003,6 +2003,37 @@ async function processAgentEndForAutopilot(pi, ctx, event, runtime) {
2003
2003
 
2004
2004
  // src/engines/worker.ts
2005
2005
  import { spawn } from "child_process";
2006
+
2007
+ // src/integrations/orchestra-execution.ts
2008
+ var ORCHESTRA_EXECUTION_CONTRACT_VERSION = 1;
2009
+ function keyPart(value) {
2010
+ if (value.length === 0) {
2011
+ throw new Error("Orchestra execution identity parts must be non-empty");
2012
+ }
2013
+ return encodeURIComponent(value);
2014
+ }
2015
+ function buildOrchestraExecutionIdempotencyKey(identity) {
2016
+ return `orchestra:v${ORCHESTRA_EXECUTION_CONTRACT_VERSION}:mission:${keyPart(identity.missionId)}:task:${keyPart(identity.taskId)}:attempt:${keyPart(identity.attemptId)}`;
2017
+ }
2018
+ function buildMissionOrchestraExecutionCorrelation(identity) {
2019
+ return {
2020
+ caller: "pi-missions",
2021
+ ...identity,
2022
+ idempotencyKey: buildOrchestraExecutionIdempotencyKey(identity)
2023
+ };
2024
+ }
2025
+ function orchestraCorrelationEnv(correlation) {
2026
+ return {
2027
+ PI_ORCHESTRA_CONTRACT_VERSION: String(ORCHESTRA_EXECUTION_CONTRACT_VERSION),
2028
+ PI_ORCHESTRA_CALLER: correlation.caller,
2029
+ PI_MISSION_ID: correlation.missionId,
2030
+ PI_MISSION_TASK_ID: correlation.taskId,
2031
+ PI_MISSION_ATTEMPT_ID: correlation.attemptId,
2032
+ PI_ORCHESTRA_IDEMPOTENCY_KEY: correlation.idempotencyKey
2033
+ };
2034
+ }
2035
+
2036
+ // src/engines/worker.ts
2006
2037
  var activeWorker = null;
2007
2038
  function getActiveWorker() {
2008
2039
  return activeWorker;
@@ -2062,9 +2093,21 @@ function spawnWorker(mission, config) {
2062
2093
  args.push("-e", extPath);
2063
2094
  }
2064
2095
  args.push(prompt);
2096
+ const correlationEnv = config.orchestraCorrelation ? orchestraCorrelationEnv(config.orchestraCorrelation) : {};
2065
2097
  const child = spawn(piPath, args, {
2066
2098
  stdio: ["ignore", "pipe", "pipe"],
2067
- env: { ...process.env, PI_NO_COLOR: "1" }
2099
+ env: (() => {
2100
+ const childEnv = { ...process.env, ...correlationEnv, PI_NO_COLOR: "1" };
2101
+ if (!config.orchestraCorrelation) {
2102
+ delete childEnv.PI_ORCHESTRA_CONTRACT_VERSION;
2103
+ delete childEnv.PI_ORCHESTRA_CALLER;
2104
+ delete childEnv.PI_MISSION_ID;
2105
+ delete childEnv.PI_MISSION_TASK_ID;
2106
+ delete childEnv.PI_MISSION_ATTEMPT_ID;
2107
+ delete childEnv.PI_ORCHESTRA_IDEMPOTENCY_KEY;
2108
+ }
2109
+ return childEnv;
2110
+ })()
2068
2111
  });
2069
2112
  let stdout = "";
2070
2113
  let stderr = "";
@@ -2084,7 +2127,8 @@ function spawnWorker(mission, config) {
2084
2127
  process: child,
2085
2128
  featureId: config.featureId,
2086
2129
  startedAt,
2087
- status: "running"
2130
+ status: "running",
2131
+ orchestraCorrelation: config.orchestraCorrelation
2088
2132
  };
2089
2133
  const timeout = setTimeout(() => {
2090
2134
  killed = true;
@@ -2105,7 +2149,8 @@ function spawnWorker(mission, config) {
2105
2149
  stdout,
2106
2150
  stderr,
2107
2151
  durationMs,
2108
- killed
2152
+ killed,
2153
+ orchestraCorrelation: config.orchestraCorrelation
2109
2154
  };
2110
2155
  if (activeWorker) {
2111
2156
  activeWorker.result = result;
@@ -2125,7 +2170,8 @@ function spawnWorker(mission, config) {
2125
2170
  missionId,
2126
2171
  stdoutLen: stdout.length,
2127
2172
  stderrLen: stderr.length,
2128
- model
2173
+ model,
2174
+ orchestraCorrelation: config.orchestraCorrelation
2129
2175
  }
2130
2176
  });
2131
2177
  saveMissionSafe(mission).catch(() => {
@@ -3965,6 +4011,10 @@ ${detection.signals.map((s) => `- ${s.type}: ${s.evidence}`).join("\n")}`,
3965
4011
  });
3966
4012
  }
3967
4013
  export {
3968
- piMissions as default
4014
+ ORCHESTRA_EXECUTION_CONTRACT_VERSION,
4015
+ buildMissionOrchestraExecutionCorrelation,
4016
+ buildOrchestraExecutionIdempotencyKey,
4017
+ piMissions as default,
4018
+ orchestraCorrelationEnv
3969
4019
  };
3970
4020
  //# sourceMappingURL=index.js.map