pi-harness-runtime 1.1.493 → 1.1.495

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 (55) hide show
  1. package/CHANGELOG.md +143 -0
  2. package/harness/jev-wait-eligibility.ts +276 -0
  3. package/index.ts +274 -63
  4. package/package.json +1 -1
  5. package/packages/agent-policy/package.json +1 -1
  6. package/packages/auth/package.json +1 -1
  7. package/packages/autonomous-runtime/package.json +1 -1
  8. package/packages/checkpoint/package.json +1 -1
  9. package/packages/clipboard/package.json +1 -1
  10. package/packages/codex-watcher/package.json +1 -1
  11. package/packages/config-capture/package.json +1 -1
  12. package/packages/contracts/package.json +1 -1
  13. package/packages/cookie-sanitizer/package.json +1 -1
  14. package/packages/evaluation-engine/package.json +1 -1
  15. package/packages/event-bus/package.json +1 -1
  16. package/packages/event-store/package.json +1 -1
  17. package/packages/experience-replay/package.json +1 -1
  18. package/packages/file-copy-helper/package.json +1 -1
  19. package/packages/intent-analyzer/package.json +1 -1
  20. package/packages/jev-judge/dist/wait-lifecycle.d.ts +22 -1
  21. package/packages/jev-judge/dist/wait-lifecycle.d.ts.map +1 -1
  22. package/packages/jev-judge/dist/wait-lifecycle.js +31 -0
  23. package/packages/jev-judge/dist/wait-lifecycle.js.map +1 -1
  24. package/packages/jev-judge/package.json +1 -1
  25. package/packages/jev-judge/src/wait-lifecycle.ts +53 -0
  26. package/packages/knowledge-retrieval/package.json +1 -1
  27. package/packages/learning-engine/package.json +1 -1
  28. package/packages/logging/package.json +1 -1
  29. package/packages/memory-engine/package.json +1 -1
  30. package/packages/notification/dist/pending-question.d.ts +9 -0
  31. package/packages/notification/dist/pending-question.d.ts.map +1 -1
  32. package/packages/notification/dist/pending-question.js +1 -0
  33. package/packages/notification/dist/pending-question.js.map +1 -1
  34. package/packages/notification/package.json +1 -1
  35. package/packages/notification/src/pending-question.ts +10 -0
  36. package/packages/paperclip-integration/package.json +1 -1
  37. package/packages/performance-optimizer/package.json +1 -1
  38. package/packages/privilege-broker/package.json +1 -1
  39. package/packages/prompt-compiler/package.json +1 -1
  40. package/packages/providers/package.json +1 -1
  41. package/packages/qdrant-skills/package.json +1 -1
  42. package/packages/quota-manager/package.json +1 -1
  43. package/packages/relay/package.json +1 -1
  44. package/packages/skill-mcp-client/package.json +1 -1
  45. package/packages/skills/package.json +1 -1
  46. package/packages/todo-bd-sync/package.json +1 -1
  47. package/packages/token-estimation/package.json +1 -1
  48. package/packages/tooling-preference/package.json +1 -1
  49. package/packages/trajectory/package.json +1 -1
  50. package/packages/tui/package.json +1 -1
  51. package/packages/two-phase-review/package.json +1 -1
  52. package/packages/types/package.json +1 -1
  53. package/packages/webmcp-tester/package.json +1 -1
  54. package/packages/wiki/package.json +1 -1
  55. package/packages/write-review/package.json +1 -1
package/index.ts CHANGED
@@ -39,6 +39,15 @@ import {
39
39
  mayContinue,
40
40
  userReplyEffect,
41
41
  } from "./harness/pending-question-state.ts";
42
+ import {
43
+ clearObsoleteWait,
44
+ isObsoleteQuestion,
45
+ jevWaitEligibility,
46
+ questionRelevance,
47
+ workStateFromTodos,
48
+ type JevQuestionRelevance,
49
+ type JevWorkState,
50
+ } from "./harness/jev-wait-eligibility.ts";
42
51
  import { describeInboundAccess, getAllowedUserIds } from "./harness/telegram-auth.ts";
43
52
  import { buildTelegramCallbackUpdate, buildTelegramMessageUpdate } from "./harness/telegram-update.ts";
44
53
  import { installConsoleGuard } from "./harness/console-guard.ts";
@@ -1245,6 +1254,7 @@ async function initAutoContinue(pi: ExtensionAPI): Promise<void> {
1245
1254
  },
1246
1255
  currentSessionId: () => _sessionId,
1247
1256
  evaluate: (request, waitedMs) => evaluatePendingQuestion(request, waitedMs),
1257
+ eligibility: () => currentWaitEligibility(),
1248
1258
  onState: (state, detail) => {
1249
1259
  logToFile("[auto-continue]", `The wait is ${state}: ${detail.reason}`);
1250
1260
  },
@@ -1277,6 +1287,109 @@ async function initAutoContinue(pi: ExtensionAPI): Promise<void> {
1277
1287
  return isQuestionOpen(sharedState.pqController?.getCurrentQuestion?.());
1278
1288
  }
1279
1289
 
1290
+ /**
1291
+ * The last state of the work that was read.
1292
+ *
1293
+ * The countdown asks synchronously, so it reads the state that is
1294
+ * known instead of waiting for a new one.
1295
+ */
1296
+ let _lastWorkState: JevWorkState = "unknown";
1297
+
1298
+ /**
1299
+ * The state of the work of the current request.
1300
+ *
1301
+ * The task list is the only source. A list that could not be read
1302
+ * says nothing: an unreadable list is never an empty list, and an
1303
+ * empty list is never a finished request.
1304
+ */
1305
+ async function currentWorkState(): Promise<JevWorkState> {
1306
+ const controller = todoContinuationController;
1307
+ if (!controller) return "unknown";
1308
+ try {
1309
+ const snapshot = await controller.getSnapshot();
1310
+ // A todo that is marked complete while its final tier has not
1311
+ // passed is not done: the required validation is work that
1312
+ // remains, so the request is not finished.
1313
+ const validationPending = validationLedger
1314
+ ? snapshot.items.some((item) =>
1315
+ validationLedger?.isFinalTierPending(item),
1316
+ )
1317
+ : false;
1318
+ return workStateFromTodos(snapshot.items, {
1319
+ available: true,
1320
+ validationPending,
1321
+ });
1322
+ } catch {
1323
+ return "unknown";
1324
+ }
1325
+ }
1326
+
1327
+ /**
1328
+ * May the current question be decided automatically?
1329
+ *
1330
+ * One decision, shared by the creation of the wait, the
1331
+ * reconciliation with the finished work, the evaluation at the
1332
+ * deadline and the application of the result.
1333
+ */
1334
+ async function currentWaitEligibility(): Promise<{
1335
+ eligible: boolean;
1336
+ reason: string;
1337
+ }> {
1338
+ const question = sharedState.pqController?.getCurrentQuestion?.();
1339
+ if (!question) {
1340
+ return { eligible: false, reason: "there is no question" };
1341
+ }
1342
+ const relevance =
1343
+ (question.relevance as JevQuestionRelevance | undefined) ??
1344
+ "current-request";
1345
+ const work = await currentWorkState();
1346
+ _lastWorkState = work;
1347
+ return jevWaitEligibility({ relevance, work });
1348
+ }
1349
+
1350
+ /**
1351
+ * Cancel a question whose work is done.
1352
+ *
1353
+ * The question was asked while the work of the request remained.
1354
+ * That work is done now, so the question is obsolete: it blocks
1355
+ * nothing, and it keeps no countdown.
1356
+ *
1357
+ * Only the Jev owner is touched. A countdown of another owner keeps
1358
+ * its deadline and its state.
1359
+ */
1360
+ async function reconcileObsoleteQuestion(): Promise<void> {
1361
+ const question = sharedState.pqController?.getCurrentQuestion?.();
1362
+ if (!question || !isQuestionOpen(question)) return;
1363
+ const relevance =
1364
+ (question.relevance as JevQuestionRelevance | undefined) ??
1365
+ "current-request";
1366
+ const work = await currentWorkState();
1367
+ _lastWorkState = work;
1368
+ const obsolete = isObsoleteQuestion({ relevance, work });
1369
+ if (!obsolete.obsolete) return;
1370
+ logToFile(
1371
+ "[auto-continue]",
1372
+ "The work of the question is done - the question is obsolete:",
1373
+ question.requestId,
1374
+ );
1375
+ // The question is closed without an answer: nobody clicked
1376
+ // anything, so no answer is injected. Only the Jev owner is
1377
+ // touched: a countdown of another owner keeps its deadline.
1378
+ clearObsoleteWait({
1379
+ requestId: question.requestId,
1380
+ cancelQuestion: (reason) => {
1381
+ sharedState.pqController?.cancel(reason);
1382
+ },
1383
+ cancelWait: () => {
1384
+ waitLifecycle.cancel();
1385
+ },
1386
+ removeRow: (requestId) => {
1387
+ pendingActions.remove(jevDecisionActionId(requestId));
1388
+ },
1389
+ });
1390
+ updateAutoContinueStatus("IDLE");
1391
+ }
1392
+
1280
1393
  // A continuation was dispatched and its turn has not settled yet.
1281
1394
  // The gate owns that state: the status stays "RUN" until the turn
1282
1395
  // settles, and no timer may clear it in the meantime.
@@ -1466,6 +1579,14 @@ async function initAutoContinue(pi: ExtensionAPI): Promise<void> {
1466
1579
  if (_countdownSessionId !== _piSessionId) return false;
1467
1580
  const current = sharedState.pqController?.getCurrentQuestion?.();
1468
1581
  if (!current) return false;
1582
+ // A wait that is no longer eligible draws no row: an
1583
+ // obsolete question must not keep a countdown on the screen.
1584
+ const relevance =
1585
+ (current.relevance as JevQuestionRelevance | undefined) ??
1586
+ "current-request";
1587
+ if (!jevWaitEligibility({ relevance, work: _lastWorkState }).eligible) {
1588
+ return false;
1589
+ }
1469
1590
  return (
1470
1591
  current.requestId === requestId &&
1471
1592
  (current.state === "pending" || current.state === "evaluating")
@@ -1767,6 +1888,31 @@ async function initAutoContinue(pi: ExtensionAPI): Promise<void> {
1767
1888
  proposedAction,
1768
1889
  questionAction,
1769
1890
  });
1891
+ // The state of the work decides whether the question belongs
1892
+ // to the request. It is read before the wait starts, because
1893
+ // the wait is the thing that must not start for a question
1894
+ // that nobody may answer by silence.
1895
+ const workState = await currentWorkState();
1896
+ _lastWorkState = workState;
1897
+ const relevance = questionRelevance({
1898
+ text: result.questionText,
1899
+ work: workState,
1900
+ });
1901
+ const eligibility = jevWaitEligibility({
1902
+ relevance,
1903
+ work: workState,
1904
+ });
1905
+ if (!eligibility.eligible) {
1906
+ // The question is not answered by silence: it waits for
1907
+ // the user, and no countdown, no row and no notification
1908
+ // claim that the agent is waiting.
1909
+ logToFile(
1910
+ "[auto-continue]",
1911
+ "The question does not wait for an automatic decision:",
1912
+ eligibility.reason,
1913
+ );
1914
+ return;
1915
+ }
1770
1916
  const question = pqController.createQuestion({
1771
1917
  text: result.questionText,
1772
1918
  sessionId: _sessionId,
@@ -1775,6 +1921,7 @@ async function initAutoContinue(pi: ExtensionAPI): Promise<void> {
1775
1921
  askType: result.askType,
1776
1922
  alternatives: result.alternatives,
1777
1923
  contextText: result.contextText,
1924
+ relevance,
1778
1925
  risk: {
1779
1926
  requiresExplicitAuthorization: riskFacts.requiresExplicitAuthorization,
1780
1927
  destructive: riskFacts.destructive,
@@ -1805,6 +1952,7 @@ async function initAutoContinue(pi: ExtensionAPI): Promise<void> {
1805
1952
  text: result.questionText,
1806
1953
  contextText: result.contextText,
1807
1954
  alternatives: result.alternatives,
1955
+ relevance,
1808
1956
  });
1809
1957
 
1810
1958
  // Get task context for additional info
@@ -2267,6 +2415,19 @@ async function initAutoContinue(pi: ExtensionAPI): Promise<void> {
2267
2415
  );
2268
2416
  return;
2269
2417
  }
2418
+ // The decision is checked once more: the work of the question can
2419
+ // be done while the judge was thinking. A decision about an
2420
+ // obsolete question steers nothing, pauses nothing and resolves
2421
+ // nothing.
2422
+ const eligibility = await currentWaitEligibility();
2423
+ if (!eligibility.eligible) {
2424
+ logToFile(
2425
+ "[auto-continue]",
2426
+ "The question is no longer eligible - discarding the decision:",
2427
+ eligibility.reason,
2428
+ );
2429
+ return;
2430
+ }
2270
2431
  const outcome = evaluation.outcome;
2271
2432
  const requestId = evaluation.requestId;
2272
2433
  const waitMinutes = waitLifecycle.waitedMinutes();
@@ -2438,6 +2599,12 @@ async function initAutoContinue(pi: ExtensionAPI): Promise<void> {
2438
2599
  waitLifecycle.cancel();
2439
2600
  updateAutoContinueStatus("IDLE");
2440
2601
  }
2602
+ if (result.discardReason === "not-eligible") {
2603
+ // The question became obsolete while it waited: it is
2604
+ // closed without an answer and the work is idle.
2605
+ sharedState.pqController?.cancel("the question is obsolete");
2606
+ updateAutoContinueStatus("IDLE");
2607
+ }
2441
2608
  return;
2442
2609
  }
2443
2610
 
@@ -2728,6 +2895,11 @@ async function initAutoContinue(pi: ExtensionAPI): Promise<void> {
2728
2895
  updateAutoContinueStatus("IDLE");
2729
2896
  }
2730
2897
 
2898
+ // A question whose work is done is obsolete. It must not block
2899
+ // the completion of the request, and the code that discovers it
2900
+ // is stale must run before the open question stops the handler.
2901
+ await reconcileObsoleteQuestion();
2902
+
2731
2903
  // Don't continue if user is waiting for response, and do not
2732
2904
  // continue behind a question that is still open: the work waits
2733
2905
  // for the answer, also when the wait itself is over.
@@ -5971,6 +6143,93 @@ export default async function (pi: ExtensionAPI) {
5971
6143
  }
5972
6144
  }
5973
6145
 
6146
+ /**
6147
+ * The settle timer of a plan message.
6148
+ *
6149
+ * A review has no file to watch, so only a plan starts the
6150
+ * timer. The candidate of the plan is remembered, so the settle
6151
+ * timer can find the message again.
6152
+ */
6153
+ const startPlanSettleTimer = (msg: {
6154
+ ordinal: number;
6155
+ text: string;
6156
+ }): void => {
6157
+ if (!codexSessionState.currentProjectRoot) return;
6158
+ const planPath = findPlanFile(codexSessionState.currentProjectRoot);
6159
+ if (!planPath) {
6160
+ // No wiki/plan.md found yet - wait for file to appear
6161
+ logToFile(
6162
+ "[codex-trigger]",
6163
+ "Plan message but no wiki/plan.md yet, waiting...",
6164
+ );
6165
+ return;
6166
+ }
6167
+ // Track plan candidate
6168
+ codexSessionState.currentPlanCandidate = {
6169
+ ordinal: msg.ordinal,
6170
+ text: msg.text,
6171
+ timestamp: Date.now(),
6172
+ };
6173
+ logToFile("[codex-trigger]", "Plan message + wiki file detected:", planPath);
6174
+ startSettleTimer(planPath, msg.ordinal);
6175
+ };
6176
+
6177
+ /**
6178
+ * The alert of a plan or a review message.
6179
+ *
6180
+ * The buttons are the actions of the stage: a plan can be
6181
+ * coded, a review can be coded again. Both stages can be
6182
+ * closed.
6183
+ */
6184
+ const notifyCodexStage = (
6185
+ msg: { ordinal: number; text: string },
6186
+ hasReviewMarker: boolean,
6187
+ sessionId: string,
6188
+ projectRoot: string,
6189
+ planPath: string | undefined,
6190
+ ): void => {
6191
+ // Create tokens for each action
6192
+ const codeToken = _createPendingAction(sessionId, "code", projectRoot, "plan");
6193
+ const doneToken = _createPendingAction(sessionId, "done", projectRoot, "plan");
6194
+
6195
+ // Use event type based on stage
6196
+ if (hasReviewMarker) {
6197
+ // Review stage: buttons are Code again and Done
6198
+ const codeAgainToken = _createPendingAction(sessionId, "code_again", projectRoot, "review");
6199
+ // SAFETY: _nc.center is always an object with notifyWithButtons in our usage
6200
+ void (_nc as unknown as { center: { notifyWithButtons: Function } }).center.notifyWithButtons("CodexReviewDetected", {
6201
+ requirement: msg.text,
6202
+ taskTitle: sessionId,
6203
+ details: {
6204
+ ordinal: msg.ordinal,
6205
+ stage: "review",
6206
+ projectRoot,
6207
+ messageLength: msg.text.length,
6208
+ },
6209
+ }, [
6210
+ { text: "Code again", action: PING_PONG_ACTIONS.CODE_AGAIN, targetId: codeAgainToken },
6211
+ { text: "Done", action: PING_PONG_ACTIONS.DONE, targetId: doneToken },
6212
+ ]);
6213
+ return;
6214
+ }
6215
+ // Plan stage: buttons are Code and Done
6216
+ // SAFETY: _nc.center is always an object with notifyWithButtons in our usage
6217
+ void (_nc as unknown as { center: { notifyWithButtons: Function } }).center.notifyWithButtons("CodexPlanDetected", {
6218
+ requirement: msg.text, // Full text, no truncation
6219
+ taskTitle: sessionId,
6220
+ details: {
6221
+ ordinal: msg.ordinal,
6222
+ stage: "plan",
6223
+ projectRoot,
6224
+ planPath: planPath || undefined,
6225
+ messageLength: msg.text.length,
6226
+ },
6227
+ }, [
6228
+ { text: "Code", action: PING_PONG_ACTIONS.CODE, targetId: codeToken },
6229
+ { text: "Done", action: PING_PONG_ACTIONS.DONE, targetId: doneToken },
6230
+ ]);
6231
+ };
6232
+
5974
6233
  const codexHandle = startWatcher({
5975
6234
  pollIntervalMs: 5000,
5976
6235
  maxIdlePolls: Infinity,
@@ -6047,7 +6306,7 @@ export default async function (pi: ExtensionAPI) {
6047
6306
  }
6048
6307
  },
6049
6308
  onMessages: (msgs) => {
6050
- if (!codexSessionState.currentCodexSessionId) return;
6309
+ if (!codexSessionState.currentCodexSessionId) return;
6051
6310
 
6052
6311
  for (const msg of msgs) {
6053
6312
  lastActivityTime = Date.now();
@@ -6055,79 +6314,31 @@ export default async function (pi: ExtensionAPI) {
6055
6314
  if (msg.role !== "assistant") continue;
6056
6315
 
6057
6316
  const classification = classifyMessage(msg.text);
6058
-
6317
+
6059
6318
  // Check for review markers in unknown messages
6060
6319
  const hasReviewMarker = classification === "unknown" && detectReviewMarker(msg.text);
6061
6320
  if (classification !== "plan" && classification !== "mixed" && !hasReviewMarker) continue;
6062
-
6321
+
6063
6322
  // Determine stage (for future use in event metadata)
6064
6323
  void classification; // used for classification only
6065
6324
 
6066
6325
  // Only start settle timer for plans (not reviews)
6067
6326
  // Reviews don't have a file to watch
6068
- if (!hasReviewMarker && codexSessionState.currentProjectRoot) {
6069
- const planPath = findPlanFile(codexSessionState.currentProjectRoot);
6070
- if (planPath) {
6071
- // Track plan candidate
6072
- codexSessionState.currentPlanCandidate = { ordinal: msg.ordinal, text: msg.text, timestamp: Date.now() };
6073
- logToFile("[codex-trigger]", "Plan message + wiki file detected:", planPath);
6074
- startSettleTimer(planPath, msg.ordinal);
6075
- } else {
6076
- // No wiki/plan.md found yet - wait for file to appear
6077
- logToFile("[codex-trigger]", "Plan message but no wiki/plan.md yet, waiting...");
6078
- }
6079
- }
6327
+ if (!hasReviewMarker) {
6328
+ startPlanSettleTimer(msg);
6329
+ }
6080
6330
 
6081
- // Emit Telegram alert with full content (async, non-blocking)
6082
- const planPath = codexSessionState.currentProjectRoot ? findPlanFile(codexSessionState.currentProjectRoot) : undefined;
6331
+ // Emit Telegram alert with full content (async, non-blocking)
6332
+ const planPath = codexSessionState.currentProjectRoot ? findPlanFile(codexSessionState.currentProjectRoot) : undefined;
6083
6333
 
6084
- // Create pending actions for PING_PONG buttons
6085
- const sessionId = codexSessionState.currentCodexSessionId || "unknown";
6086
- const projectRoot = codexSessionState.currentProjectRoot || "";
6087
-
6088
- // Create tokens for each action
6089
- const codeToken = _createPendingAction(sessionId, "code", projectRoot, "plan");
6090
- const doneToken = _createPendingAction(sessionId, "done", projectRoot, "plan");
6334
+ // Create pending actions for PING_PONG buttons
6335
+ const sessionId = codexSessionState.currentCodexSessionId || "unknown";
6336
+ const projectRoot = codexSessionState.currentProjectRoot || "";
6091
6337
 
6092
- // Use event type based on stage
6093
- if (hasReviewMarker) {
6094
- // Review stage: buttons are Code again and Done
6095
- const codeAgainToken = _createPendingAction(sessionId, "code_again", projectRoot, "review");
6096
- // SAFETY: _nc.center is always an object with notifyWithButtons in our usage
6097
- void (_nc as unknown as { center: { notifyWithButtons: Function } }).center.notifyWithButtons("CodexReviewDetected", {
6098
- requirement: msg.text,
6099
- taskTitle: sessionId,
6100
- details: {
6101
- ordinal: msg.ordinal,
6102
- stage: "review",
6103
- projectRoot,
6104
- messageLength: msg.text.length,
6105
- },
6106
- }, [
6107
- { text: "Code again", action: PING_PONG_ACTIONS.CODE_AGAIN, targetId: codeAgainToken },
6108
- { text: "Done", action: PING_PONG_ACTIONS.DONE, targetId: doneToken },
6109
- ]);
6110
- } else {
6111
- // Plan stage: buttons are Code and Done
6112
- // SAFETY: _nc.center is always an object with notifyWithButtons in our usage
6113
- void (_nc as unknown as { center: { notifyWithButtons: Function } }).center.notifyWithButtons("CodexPlanDetected", {
6114
- requirement: msg.text, // Full text, no truncation
6115
- taskTitle: sessionId,
6116
- details: {
6117
- ordinal: msg.ordinal,
6118
- stage: "plan",
6119
- projectRoot,
6120
- planPath: planPath || undefined,
6121
- messageLength: msg.text.length,
6122
- },
6123
- }, [
6124
- { text: "Code", action: PING_PONG_ACTIONS.CODE, targetId: codeToken },
6125
- { text: "Done", action: PING_PONG_ACTIONS.DONE, targetId: doneToken },
6126
- ]);
6127
- }
6128
- }
6129
- },
6130
- });
6338
+ notifyCodexStage(msg, hasReviewMarker, sessionId, projectRoot, planPath);
6339
+ }
6340
+ },
6341
+ });
6131
6342
 
6132
6343
  // Clean up when pi session ends
6133
6344
  pi.on("session_shutdown", () => codexHandle.stop());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-harness-runtime",
3
- "version": "1.1.493",
3
+ "version": "1.1.495",
4
4
  "description": "[BETA] Codex-style /usage status + autonomous coding harness for pi. Not production ready — expect breaking changes.",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/agent-policy",
3
- "version": "1.1.493",
3
+ "version": "1.1.495",
4
4
  "description": "Agent policy runtime for pi-harness - enforces mandatory rule delivery and mutation gating",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/auth",
3
- "version": "1.1.493",
3
+ "version": "1.1.495",
4
4
  "description": "pi-harness-runtime — auth",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/autonomous-runtime",
3
- "version": "1.1.493",
3
+ "version": "1.1.495",
4
4
  "description": "Autonomous Operations Runtime — task inbox, lease management, and worker lifecycle (RFC-0101)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/checkpoint",
3
- "version": "1.1.493",
3
+ "version": "1.1.495",
4
4
  "description": "Enhanced checkpoint system with incremental snapshots, diff-based storage, and recovery strategies",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/clipboard",
3
- "version": "1.1.493",
3
+ "version": "1.1.495",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "exports": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/codex-watcher",
3
- "version": "1.1.493",
3
+ "version": "1.1.495",
4
4
  "description": "Watches Codex CLI sessions and emits visible messages for PING-PONG monitoring",
5
5
  "type": "module",
6
6
  "main": "./dist/src/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moocoding/config-capture",
3
- "version": "1.1.493",
3
+ "version": "1.1.495",
4
4
  "description": "Auto-capture API-fetched configuration values to AGENTS.md",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/contracts",
3
- "version": "1.1.493",
3
+ "version": "1.1.495",
4
4
  "type": "module",
5
5
  "description": "RPC schema definitions for pi-harness runtime",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/cookie-sanitizer",
3
- "version": "1.1.493",
3
+ "version": "1.1.495",
4
4
  "description": "pi-harness-runtime — cookie sanitizer (provider-quota cookie file normaliser)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/evaluation-engine",
3
- "version": "1.1.493",
3
+ "version": "1.1.495",
4
4
  "description": "Evaluation engine for pi-harness runtime (RFC-0057)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/event-bus",
3
- "version": "1.1.493",
3
+ "version": "1.1.495",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "exports": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/event-store",
3
- "version": "1.1.493",
3
+ "version": "1.1.495",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "exports": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/experience-replay",
3
- "version": "1.1.493",
3
+ "version": "1.1.495",
4
4
  "description": "Experience replay for debugging and reproducibility (RFC-0059)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moocoding/file-copy-helper",
3
- "version": "1.1.493",
3
+ "version": "1.1.495",
4
4
  "description": "Injects cp/sudo cp rule when user asks to mimic/copy files",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/intent-analyzer",
3
- "version": "1.1.493",
3
+ "version": "1.1.495",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "exports": {
@@ -53,6 +53,13 @@ export interface WaitRequest {
53
53
  contextText?: string;
54
54
  /** The concrete alternatives of a choice question. */
55
55
  alternatives?: string[];
56
+ /**
57
+ * What the question is about.
58
+ *
59
+ * The relevance decides whether the wait may reach the judge at all: an
60
+ * offer of work that was not asked for is never decided by silence.
61
+ */
62
+ relevance?: string;
56
63
  }
57
64
  /** The result of one evaluation. */
58
65
  export interface WaitEvaluation {
@@ -136,11 +143,25 @@ export interface WaitLifecycleDeps {
136
143
  evaluate: (request: WaitRequest, waitedMs: number) => Promise<WaitEvaluation>;
137
144
  /** The state of the wait changed. */
138
145
  onState?: (state: WaitLifecycleState, detail: WaitStateDetail) => void;
146
+ /**
147
+ * Is the wait still eligible for an automatic decision?
148
+ *
149
+ * The owner of the wait answers: it knows the state of the work and the
150
+ * relevance of the question. The controller asks before it evaluates,
151
+ * so an obsolete wait never reaches the judge.
152
+ */
153
+ eligibility?: () => Promise<{
154
+ eligible: boolean;
155
+ reason: string;
156
+ }> | {
157
+ eligible: boolean;
158
+ reason: string;
159
+ };
139
160
  /** A failure of the controller itself. */
140
161
  onError?: (error: unknown) => void;
141
162
  }
142
163
  /** Why an evaluation was not applied. */
143
- export type WaitDiscardReason = "no-request" | "not-waiting" | "not-due" | "stale" | "other-session";
164
+ export type WaitDiscardReason = "no-request" | "not-waiting" | "not-due" | "not-eligible" | "stale" | "other-session";
144
165
  /** What the controller did with an evaluation. */
145
166
  export interface WaitLifecycleResult {
146
167
  /** Did the evaluation change the state? */
@@ -1 +1 @@
1
- {"version":3,"file":"wait-lifecycle.d.ts","sourceRoot":"","sources":["../src/wait-lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEzE;;;;;;;;;GASG;AACH,MAAM,MAAM,kBAAkB,GAC3B,MAAM,GACN,SAAS,GACT,YAAY,GACZ,SAAS,GACT,gBAAgB,GAChB,kBAAkB,CAAC;AAEtB,oCAAoC;AACpC,MAAM,WAAW,WAAW;IAC3B,gDAAgD;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB,6CAA6C;IAC7C,SAAS,EAAE,MAAM,CAAC;IAClB,4DAA4D;IAC5D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qCAAqC;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gCAAgC;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sDAAs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