@afokapu/atdd-flow 0.3.69 → 0.3.70

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.
@@ -366,9 +366,9 @@ const sessionUnsetOrEqual = (runtime: Seat["runtime"], piSession?: string, piSes
366
366
  const recovery = (root: string, seat: string, mode: RecoveryMode, session?: string) => recoveryFor(root, seat, mode, session).catch(() => undefined);
367
367
 
368
368
  /** Desk mail is authoritative; the queue is a bounded delivery index and fs.watch only shortens latency. */
369
- export default function (pi: ExtensionAPI) {
370
- const root = process.env.ATDD_WORKFLOW_ROOT;
371
- const seat = process.env.ATDD_WORKFLOW_SEAT;
369
+ export default function (pi: ExtensionAPI, environment: NodeJS.ProcessEnv = process.env) {
370
+ const root = environment.ATDD_WORKFLOW_ROOT;
371
+ const seat = environment.ATDD_WORKFLOW_SEAT;
372
372
  if (!root || !seat) return;
373
373
  let runtime: ReturnType<typeof createPiRuntime> | undefined;
374
374
  let handoverPrompted = false;
@@ -395,7 +395,7 @@ export default function (pi: ExtensionAPI) {
395
395
  const threshold = await contextHandoverThreshold(root);
396
396
  if (percent < threshold) return;
397
397
  handoverPrompted = true;
398
- const bundle = await recovery(root, seat, "threshold", process.env.ATDD_FLOW_PI_SESSION);
398
+ const bundle = await recovery(root, seat, "threshold", environment.ATDD_FLOW_PI_SESSION);
399
399
  pi.sendMessage({
400
400
  customType: "atdd-flow-context-handover-replacement",
401
401
  content: handoverThresholdInstruction(percent, threshold, bundle),
@@ -404,7 +404,7 @@ export default function (pi: ExtensionAPI) {
404
404
  } catch { /* Desk policy is re-read on the next safe boundary. */ }
405
405
  });
406
406
  pi.on("turn_end", async (_event, ctx) => {
407
- const sourceSession = process.env.ATDD_FLOW_PI_SESSION;
407
+ const sourceSession = environment.ATDD_FLOW_PI_SESSION;
408
408
  if (!sourceSession) return;
409
409
  try {
410
410
  const request = await readHandoverReplacement(root, seat);
@@ -419,13 +419,13 @@ export default function (pi: ExtensionAPI) {
419
419
  });
420
420
  pi.on("session_start", async (_event, ctx) => {
421
421
  const sessionManager = (ctx as { sessionManager?: { getSessionId?: () => string; getSessionFile?: () => string | undefined } }).sessionManager;
422
- const liveSession = process.env.ATDD_FLOW_PI_SESSION ?? sessionManager?.getSessionId?.();
422
+ const liveSession = environment.ATDD_FLOW_PI_SESSION ?? sessionManager?.getSessionId?.();
423
423
  // One display-only notice per session: a refused, timed-out or failed activation must never be silent, and never wakes the agent.
424
424
  let noticed = false;
425
425
  const noticeActivation = async (transport: "active" | "inactive", error?: string) => {
426
426
  if (noticed) return;
427
427
  noticed = true;
428
- const live = { pi_session: liveSession, herdr_session: process.env.ATDD_FLOW_HERDR_SESSION ?? process.env.HERDR_SESSION, pane: process.env.ATDD_FLOW_HERDR_PANE ?? process.env.HERDR_PANE_ID };
428
+ const live = { pi_session: liveSession, herdr_session: environment.ATDD_FLOW_HERDR_SESSION ?? environment.HERDR_SESSION, pane: environment.ATDD_FLOW_HERDR_PANE ?? environment.HERDR_PANE_ID };
429
429
  const activation = await diagnoseMailActivation(root, seat, live, transport, error).catch(() => undefined);
430
430
  if (!activation) return;
431
431
  if (runtime) await recordMailActivation(root, seat, runtime.ownerToken, activation).catch(() => undefined);
@@ -449,11 +449,11 @@ export default function (pi: ExtensionAPI) {
449
449
  });
450
450
  } });
451
451
  await runtime.start();
452
- const piSession = process.env.ATDD_FLOW_PI_SESSION;
453
- const herdrSession = process.env.ATDD_FLOW_HERDR_SESSION;
454
- const pane = process.env.ATDD_FLOW_HERDR_PANE;
452
+ const piSession = environment.ATDD_FLOW_PI_SESSION;
453
+ const herdrSession = environment.ATDD_FLOW_HERDR_SESSION;
454
+ const pane = environment.ATDD_FLOW_HERDR_PANE;
455
455
  if (!piSession && !herdrSession && !pane) {
456
- if (await hostAttachedActivation({ root, seat, herdrSession: process.env.HERDR_SESSION, pane: process.env.HERDR_PANE_ID, piSession: sessionManager?.getSessionId?.(), piSessionPath: sessionManager?.getSessionFile?.() })) {
456
+ if (await hostAttachedActivation({ root, seat, herdrSession: environment.HERDR_SESSION, pane: environment.HERDR_PANE_ID, piSession: sessionManager?.getSessionId?.(), piSessionPath: sessionManager?.getSessionFile?.() })) {
457
457
  hostActivatedAt = Date.now();
458
458
  if (await runtime.activate()) {
459
459
  const bundle = await recovery(root, seat, "start", sessionManager?.getSessionId?.());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@afokapu/atdd-flow",
3
- "version": "0.3.69",
3
+ "version": "0.3.70",
4
4
  "description": "Filesystem-first Desk registry for projects, seats, tasks, threads, and handoffs.",
5
5
  "type": "module",
6
6
  "bin": {