@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.
- package/extensions/pi/index.ts +11 -11
- package/package.json +1 -1
package/extensions/pi/index.ts
CHANGED
|
@@ -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 =
|
|
371
|
-
const 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",
|
|
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 =
|
|
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 =
|
|
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:
|
|
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 =
|
|
453
|
-
const herdrSession =
|
|
454
|
-
const 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:
|
|
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?.());
|