pi-harness-runtime 1.1.507 → 1.1.509

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 (86) hide show
  1. package/CHANGELOG.md +171 -0
  2. package/harness/auto-resume-marker.ts +219 -0
  3. package/harness/scope-expansion-runtime.ts +464 -0
  4. package/harness/scope-expansion.ts +212 -23
  5. package/index.ts +502 -25
  6. package/package.json +1 -1
  7. package/packages/agent-policy/package.json +1 -1
  8. package/packages/auth/package.json +1 -1
  9. package/packages/autonomous-runtime/package.json +1 -1
  10. package/packages/checkpoint/package.json +1 -1
  11. package/packages/clipboard/package.json +1 -1
  12. package/packages/codex-watcher/package.json +1 -1
  13. package/packages/config-capture/package.json +1 -1
  14. package/packages/contracts/package.json +1 -1
  15. package/packages/cookie-sanitizer/package.json +1 -1
  16. package/packages/evaluation-engine/package.json +1 -1
  17. package/packages/event-bus/package.json +1 -1
  18. package/packages/event-store/package.json +1 -1
  19. package/packages/experience-replay/package.json +1 -1
  20. package/packages/file-copy-helper/package.json +1 -1
  21. package/packages/intent-analyzer/package.json +1 -1
  22. package/packages/jev-judge/package.json +1 -1
  23. package/packages/knowledge-retrieval/package.json +1 -1
  24. package/packages/learning-engine/package.json +1 -1
  25. package/packages/logging/package.json +1 -1
  26. package/packages/memory-engine/package.json +1 -1
  27. package/packages/notification/dist/adapters/detail-format.d.ts +1 -1
  28. package/packages/notification/dist/adapters/detail-format.d.ts.map +1 -1
  29. package/packages/notification/dist/adapters/detail-format.js +12 -0
  30. package/packages/notification/dist/adapters/detail-format.js.map +1 -1
  31. package/packages/notification/dist/adapters/email-adapter.d.ts.map +1 -1
  32. package/packages/notification/dist/adapters/email-adapter.js +2 -0
  33. package/packages/notification/dist/adapters/email-adapter.js.map +1 -1
  34. package/packages/notification/dist/adapters/line-adapter.d.ts.map +1 -1
  35. package/packages/notification/dist/adapters/line-adapter.js +2 -0
  36. package/packages/notification/dist/adapters/line-adapter.js.map +1 -1
  37. package/packages/notification/dist/adapters/ntfy-adapter.d.ts.map +1 -1
  38. package/packages/notification/dist/adapters/ntfy-adapter.js +2 -0
  39. package/packages/notification/dist/adapters/ntfy-adapter.js.map +1 -1
  40. package/packages/notification/dist/adapters/telegram-adapter.d.ts +0 -1
  41. package/packages/notification/dist/adapters/telegram-adapter.d.ts.map +1 -1
  42. package/packages/notification/dist/adapters/telegram-adapter.js +2 -3
  43. package/packages/notification/dist/adapters/telegram-adapter.js.map +1 -1
  44. package/packages/notification/dist/notification-center.d.ts +8 -4
  45. package/packages/notification/dist/notification-center.d.ts.map +1 -1
  46. package/packages/notification/dist/notification-center.js +32 -9
  47. package/packages/notification/dist/notification-center.js.map +1 -1
  48. package/packages/notification/dist/notification-policy.d.ts.map +1 -1
  49. package/packages/notification/dist/notification-policy.js +6 -0
  50. package/packages/notification/dist/notification-policy.js.map +1 -1
  51. package/packages/notification/dist/pending-question.d.ts +20 -1
  52. package/packages/notification/dist/pending-question.d.ts.map +1 -1
  53. package/packages/notification/dist/pending-question.js +9 -3
  54. package/packages/notification/dist/pending-question.js.map +1 -1
  55. package/packages/notification/dist/types.d.ts +10 -1
  56. package/packages/notification/dist/types.d.ts.map +1 -1
  57. package/packages/notification/package.json +1 -1
  58. package/packages/notification/src/adapters/detail-format.ts +17 -1
  59. package/packages/notification/src/adapters/email-adapter.ts +2 -0
  60. package/packages/notification/src/adapters/line-adapter.ts +2 -0
  61. package/packages/notification/src/adapters/ntfy-adapter.ts +2 -0
  62. package/packages/notification/src/adapters/telegram-adapter.ts +2 -4
  63. package/packages/notification/src/notification-center.ts +32 -9
  64. package/packages/notification/src/notification-policy.ts +6 -0
  65. package/packages/notification/src/pending-question.ts +28 -2
  66. package/packages/notification/src/types.ts +11 -0
  67. package/packages/paperclip-integration/package.json +1 -1
  68. package/packages/performance-optimizer/package.json +1 -1
  69. package/packages/privilege-broker/package.json +1 -1
  70. package/packages/prompt-compiler/package.json +1 -1
  71. package/packages/providers/package.json +1 -1
  72. package/packages/qdrant-skills/package.json +1 -1
  73. package/packages/quota-manager/package.json +1 -1
  74. package/packages/relay/package.json +1 -1
  75. package/packages/skill-mcp-client/package.json +1 -1
  76. package/packages/skills/package.json +1 -1
  77. package/packages/todo-bd-sync/package.json +1 -1
  78. package/packages/token-estimation/package.json +1 -1
  79. package/packages/tooling-preference/package.json +1 -1
  80. package/packages/trajectory/package.json +1 -1
  81. package/packages/tui/package.json +1 -1
  82. package/packages/two-phase-review/package.json +1 -1
  83. package/packages/types/package.json +1 -1
  84. package/packages/webmcp-tester/package.json +1 -1
  85. package/packages/wiki/package.json +1 -1
  86. package/packages/write-review/package.json +1 -1
@@ -140,14 +140,18 @@ export class NotificationCenter {
140
140
 
141
141
  /**
142
142
  * Track a new pending approval request
143
+ *
144
+ * The key is the canonical question id: the buttons of the notification
145
+ * carry it, and it is what a callback looks the approval up with. A
146
+ * notification without a question id is keyed by its job id.
143
147
  */
144
148
  trackPendingApproval(
145
- jobId: string,
149
+ questionId: string,
146
150
  event: NotificationEvent,
147
151
  context: NotificationContext,
148
152
  ): void {
149
- this.pendingApprovals.set(jobId, {
150
- jobId,
153
+ this.pendingApprovals.set(questionId, {
154
+ jobId: context.jobId,
151
155
  event,
152
156
  context,
153
157
  createdAt: new Date(),
@@ -160,10 +164,10 @@ export class NotificationCenter {
160
164
  * @returns true if the request was found and resolved, false otherwise
161
165
  */
162
166
  resolvePendingApproval(
163
- jobId: string,
167
+ questionId: string,
164
168
  result: "approved" | "rejected",
165
169
  ): boolean {
166
- const pending = this.pendingApprovals.get(jobId);
170
+ const pending = this.pendingApprovals.get(questionId);
167
171
  if (!pending || pending.resolved) {
168
172
  return false;
169
173
  }
@@ -175,15 +179,15 @@ export class NotificationCenter {
175
179
  /**
176
180
  * Get a pending approval request
177
181
  */
178
- getPendingApproval(jobId: string): PendingApproval | undefined {
179
- return this.pendingApprovals.get(jobId);
182
+ getPendingApproval(questionId: string): PendingApproval | undefined {
183
+ return this.pendingApprovals.get(questionId);
180
184
  }
181
185
 
182
186
  /**
183
187
  * Check if a pending approval exists and is unresolved
184
188
  */
185
- isPendingApproval(jobId: string): boolean {
186
- const pending = this.pendingApprovals.get(jobId);
189
+ isPendingApproval(questionId: string): boolean {
190
+ const pending = this.pendingApprovals.get(questionId);
187
191
  return !!pending && !pending.resolved;
188
192
  }
189
193
 
@@ -605,6 +609,11 @@ export class NotificationCenter {
605
609
  jobId: context.jobId,
606
610
  ...(context.questionId && { questionId: context.questionId }),
607
611
  ...(context.questionKind && { questionKind: context.questionKind }),
612
+ // The shared detail format renders the named issues
613
+ // and the deadline of a scope proposal: LINE shows the
614
+ // same facts as every other channel.
615
+ ...(context.scopeIds && { scopeIds: context.scopeIds }),
616
+ ...(context.scopeDeadline && { scopeDeadline: context.scopeDeadline }),
608
617
  _actionButtons: buttons,
609
618
  ...options?.additionalDetails,
610
619
  },
@@ -802,6 +811,8 @@ export class NotificationCenter {
802
811
  }),
803
812
  ...(context.resetAt && { resetAt: context.resetAt }),
804
813
  ...(context.quotaWindow && { quotaWindow: context.quotaWindow }),
814
+ ...(context.scopeIds && { scopeIds: context.scopeIds }),
815
+ ...(context.scopeDeadline && { scopeDeadline: context.scopeDeadline }),
805
816
  // Pass inline keyboard options to Telegram adapter
806
817
  ...(options?.enableInlineKeyboard && { _enableInlineKeyboard: true }),
807
818
  ...(options?.actionButtons && { _actionButtons: options.actionButtons }),
@@ -906,6 +917,18 @@ export class NotificationCenter {
906
917
  // proposal the user can answer.
907
918
  message: fullRequirement,
908
919
  },
920
+ ScopeProposal: {
921
+ title: "Scope Proposal",
922
+ // The full proposal travels: the exact ids, the scope and
923
+ // the deadline are what the human answers about.
924
+ message: fullRequirement,
925
+ },
926
+ ScopeDecision: {
927
+ title: "Scope Decision",
928
+ // The decision and its reasoning travel: the human has to
929
+ // know what was decided before the work starts.
930
+ message: fullRequirement,
931
+ },
909
932
  Error: {
910
933
  title: "Runtime Error",
911
934
  message: `An error occurred${context.error ? `: ${context.error}` : ""}`,
@@ -59,6 +59,9 @@ const APPROVAL_REQUIRED_EVENTS = new Set([
59
59
  "ConfirmDeploy",
60
60
  "ConfirmDelete",
61
61
  "ConfirmCriticalAction",
62
+ // A proposal of a new scope needs an answer: the backlog is not work of
63
+ // the request that finished, and it does not become work by silence.
64
+ "ScopeProposal",
62
65
  ]);
63
66
 
64
67
  /**
@@ -71,6 +74,9 @@ const HIGH_PRIORITY_EVENTS = new Set([
71
74
  "WaitingForUserInput",
72
75
  "JobFailed",
73
76
  "SystemAlert",
77
+ // A proposal of a new scope is a question that waits for an answer: the
78
+ // policy of the package may not drop it.
79
+ "ScopeProposal",
74
80
  ]);
75
81
 
76
82
  /**
@@ -844,6 +844,15 @@ export class PendingQuestionController {
844
844
  requestId?: string;
845
845
  /** The channel a human answer came from. */
846
846
  channel?: ResolutionChannel;
847
+ /**
848
+ * Notify the callback of the user answer.
849
+ *
850
+ * A question that is not a question of the work - a proposal of the
851
+ * backlog, for example - is answered by the human without becoming an
852
+ * answer of the request: the callback would clear the wait of the
853
+ * request and steer an answer into the conversation.
854
+ */
855
+ notifyUser?: boolean;
847
856
  }): boolean {
848
857
  if (!this.currentQuestion) {
849
858
  logWarn("[PendingQuestion]", "No question to resolve - no pending question");
@@ -896,7 +905,7 @@ export class PendingQuestionController {
896
905
  eligible: true,
897
906
  });
898
907
  }
899
- } else if (this.userAnswerCallback) {
908
+ } else if (this.userAnswerCallback && params.notifyUser !== false) {
900
909
  this.userAnswerCallback(this.currentQuestion, params.resolution);
901
910
  }
902
911
 
@@ -1049,13 +1058,30 @@ export class PendingQuestionController {
1049
1058
  action: string,
1050
1059
  requestId: string,
1051
1060
  channel: ResolutionChannel,
1061
+ options?: {
1062
+ /**
1063
+ * Notify the callback of the user answer.
1064
+ *
1065
+ * A question that is not a question of the work of the request - a
1066
+ * proposal of the backlog - is answered without an answer of the
1067
+ * request: the callback would clear the wait of the request and steer
1068
+ * an answer into the conversation.
1069
+ */
1070
+ notifyUser?: boolean;
1071
+ },
1052
1072
  ): { applied: boolean; resolution?: "yes" | "no"; reason?: string } {
1053
1073
  if (action !== "approve" && action !== "reject") {
1054
1074
  return { applied: false, reason: `unknown action '${action}'` };
1055
1075
  }
1056
1076
 
1057
1077
  const resolution = action === "approve" ? "yes" : "no";
1058
- const applied = this.resolve({ resolution, by: "user", requestId, channel });
1078
+ const applied = this.resolve({
1079
+ resolution,
1080
+ by: "user",
1081
+ requestId,
1082
+ channel,
1083
+ ...(options?.notifyUser === false && { notifyUser: false }),
1084
+ });
1059
1085
 
1060
1086
  return applied
1061
1087
  ? { applied: true, resolution }
@@ -22,6 +22,8 @@ export type NotificationEvent =
22
22
  | "CodexPlanDetected"
23
23
  | "CodexReviewDetected"
24
24
  | "ToolingPreferenceProposal"
25
+ | "ScopeProposal"
26
+ | "ScopeDecision"
25
27
  | "AssistantResponse"
26
28
  | "ToolSummary"
27
29
  | "Error"
@@ -185,4 +187,13 @@ export interface NotificationContext {
185
187
  resetAt?: string;
186
188
  /** The quota window the event is about ("5h", "weekly"). */
187
189
  quotaWindow?: string;
190
+ /**
191
+ * The exact ids of the issues that a scope proposal names.
192
+ *
193
+ * A proposal names ids, not titles: the ids are what the decision
194
+ * authorizes.
195
+ */
196
+ scopeIds?: string[];
197
+ /** The absolute moment the decision of a scope proposal has to be made. */
198
+ scopeDeadline?: string;
188
199
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/paperclip-integration",
3
- "version": "1.1.507",
3
+ "version": "1.1.509",
4
4
  "description": "Paperclip API integration: poll agent inbox, route tasks to pi.dev, Telegram alerts",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/performance-optimizer",
3
- "version": "1.1.507",
3
+ "version": "1.1.509",
4
4
  "description": "Performance optimization analyzer for pi-harness runtime (RFC-0056)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/privilege-broker",
3
- "version": "1.1.507",
3
+ "version": "1.1.509",
4
4
  "description": "Privilege Broker — capability registry and command executor for autonomous runtime (RFC-0101 §7)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/prompt-compiler",
3
- "version": "1.1.507",
3
+ "version": "1.1.509",
4
4
  "description": "Deterministic prompt compiler for pi-harness-runtime",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/providers",
3
- "version": "1.1.507",
3
+ "version": "1.1.509",
4
4
  "description": "pi-harness-runtime — providers",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/qdrant-skills",
3
- "version": "1.1.507",
3
+ "version": "1.1.509",
4
4
  "description": "Qdrant vector search integration for Hermes-style skill system",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/quota-manager",
3
- "version": "1.1.507",
3
+ "version": "1.1.509",
4
4
  "description": "pi-harness-runtime — quota-manager",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/relay",
3
- "version": "1.1.507",
3
+ "version": "1.1.509",
4
4
  "type": "module",
5
5
  "description": "Cloud relay for remote access - T3 Connect style for pi-harness",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/skill-mcp-client",
3
- "version": "1.1.507",
3
+ "version": "1.1.509",
4
4
  "description": "MCP client for Skills SaaS backend",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/skills",
3
- "version": "1.1.507",
3
+ "version": "1.1.509",
4
4
  "description": "File-based skill system with pi.dev compatibility and Hermes self-improvement",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moocoding/todo-bd-sync",
3
- "version": "1.1.507",
3
+ "version": "1.1.509",
4
4
  "description": "Two-way sync between rpiv-todo overlay and bd issue tracker",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/token-estimation",
3
- "version": "1.1.507",
3
+ "version": "1.1.509",
4
4
  "description": "pi-harness-runtime — token-estimation",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/tooling-preference",
3
- "version": "1.1.507",
3
+ "version": "1.1.509",
4
4
  "description": "pi-harness-runtime — JS/TS tooling preference (Biome vs ESLint/Prettier) proposal",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/trajectory",
3
- "version": "1.1.507",
3
+ "version": "1.1.509",
4
4
  "description": "Trajectory capture for the write-review loop — persists cycle records for learning",
5
5
  "type": "module",
6
6
  "main": "./dist/src/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/tui",
3
- "version": "1.1.507",
3
+ "version": "1.1.509",
4
4
  "description": "pi-harness-runtime — tui",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/two-phase-review",
3
- "version": "1.1.507",
3
+ "version": "1.1.509",
4
4
  "description": "pi-harness-runtime — two-phase implementation and review workflow (queue review signals, gate the phase, scope the diff)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/types",
3
- "version": "1.1.507",
3
+ "version": "1.1.509",
4
4
  "description": "Shared TypeScript types for pi-harness-runtime packages",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/webmcp-tester",
3
- "version": "1.1.507",
3
+ "version": "1.1.509",
4
4
  "description": "WebMCP-powered E2E testing for pi-harness - natural language test scenarios",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/wiki",
3
- "version": "1.1.507",
3
+ "version": "1.1.509",
4
4
  "description": "LLM Wiki integration for pi-harness-runtime",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moocoding/write-review",
3
- "version": "1.1.507",
3
+ "version": "1.1.509",
4
4
  "description": "Two-agent write-review loop with blackboard coordination",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",