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.
- package/CHANGELOG.md +171 -0
- package/harness/auto-resume-marker.ts +219 -0
- package/harness/scope-expansion-runtime.ts +464 -0
- package/harness/scope-expansion.ts +212 -23
- package/index.ts +502 -25
- package/package.json +1 -1
- package/packages/agent-policy/package.json +1 -1
- package/packages/auth/package.json +1 -1
- package/packages/autonomous-runtime/package.json +1 -1
- package/packages/checkpoint/package.json +1 -1
- package/packages/clipboard/package.json +1 -1
- package/packages/codex-watcher/package.json +1 -1
- package/packages/config-capture/package.json +1 -1
- package/packages/contracts/package.json +1 -1
- package/packages/cookie-sanitizer/package.json +1 -1
- package/packages/evaluation-engine/package.json +1 -1
- package/packages/event-bus/package.json +1 -1
- package/packages/event-store/package.json +1 -1
- package/packages/experience-replay/package.json +1 -1
- package/packages/file-copy-helper/package.json +1 -1
- package/packages/intent-analyzer/package.json +1 -1
- package/packages/jev-judge/package.json +1 -1
- package/packages/knowledge-retrieval/package.json +1 -1
- package/packages/learning-engine/package.json +1 -1
- package/packages/logging/package.json +1 -1
- package/packages/memory-engine/package.json +1 -1
- package/packages/notification/dist/adapters/detail-format.d.ts +1 -1
- package/packages/notification/dist/adapters/detail-format.d.ts.map +1 -1
- package/packages/notification/dist/adapters/detail-format.js +12 -0
- package/packages/notification/dist/adapters/detail-format.js.map +1 -1
- package/packages/notification/dist/adapters/email-adapter.d.ts.map +1 -1
- package/packages/notification/dist/adapters/email-adapter.js +2 -0
- package/packages/notification/dist/adapters/email-adapter.js.map +1 -1
- package/packages/notification/dist/adapters/line-adapter.d.ts.map +1 -1
- package/packages/notification/dist/adapters/line-adapter.js +2 -0
- package/packages/notification/dist/adapters/line-adapter.js.map +1 -1
- package/packages/notification/dist/adapters/ntfy-adapter.d.ts.map +1 -1
- package/packages/notification/dist/adapters/ntfy-adapter.js +2 -0
- package/packages/notification/dist/adapters/ntfy-adapter.js.map +1 -1
- package/packages/notification/dist/adapters/telegram-adapter.d.ts +0 -1
- package/packages/notification/dist/adapters/telegram-adapter.d.ts.map +1 -1
- package/packages/notification/dist/adapters/telegram-adapter.js +2 -3
- package/packages/notification/dist/adapters/telegram-adapter.js.map +1 -1
- package/packages/notification/dist/notification-center.d.ts +8 -4
- package/packages/notification/dist/notification-center.d.ts.map +1 -1
- package/packages/notification/dist/notification-center.js +32 -9
- package/packages/notification/dist/notification-center.js.map +1 -1
- package/packages/notification/dist/notification-policy.d.ts.map +1 -1
- package/packages/notification/dist/notification-policy.js +6 -0
- package/packages/notification/dist/notification-policy.js.map +1 -1
- package/packages/notification/dist/pending-question.d.ts +20 -1
- package/packages/notification/dist/pending-question.d.ts.map +1 -1
- package/packages/notification/dist/pending-question.js +9 -3
- package/packages/notification/dist/pending-question.js.map +1 -1
- package/packages/notification/dist/types.d.ts +10 -1
- package/packages/notification/dist/types.d.ts.map +1 -1
- package/packages/notification/package.json +1 -1
- package/packages/notification/src/adapters/detail-format.ts +17 -1
- package/packages/notification/src/adapters/email-adapter.ts +2 -0
- package/packages/notification/src/adapters/line-adapter.ts +2 -0
- package/packages/notification/src/adapters/ntfy-adapter.ts +2 -0
- package/packages/notification/src/adapters/telegram-adapter.ts +2 -4
- package/packages/notification/src/notification-center.ts +32 -9
- package/packages/notification/src/notification-policy.ts +6 -0
- package/packages/notification/src/pending-question.ts +28 -2
- package/packages/notification/src/types.ts +11 -0
- package/packages/paperclip-integration/package.json +1 -1
- package/packages/performance-optimizer/package.json +1 -1
- package/packages/privilege-broker/package.json +1 -1
- package/packages/prompt-compiler/package.json +1 -1
- package/packages/providers/package.json +1 -1
- package/packages/qdrant-skills/package.json +1 -1
- package/packages/quota-manager/package.json +1 -1
- package/packages/relay/package.json +1 -1
- package/packages/skill-mcp-client/package.json +1 -1
- package/packages/skills/package.json +1 -1
- package/packages/todo-bd-sync/package.json +1 -1
- package/packages/token-estimation/package.json +1 -1
- package/packages/tooling-preference/package.json +1 -1
- package/packages/trajectory/package.json +1 -1
- package/packages/tui/package.json +1 -1
- package/packages/two-phase-review/package.json +1 -1
- package/packages/types/package.json +1 -1
- package/packages/webmcp-tester/package.json +1 -1
- package/packages/wiki/package.json +1 -1
- 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
|
-
|
|
149
|
+
questionId: string,
|
|
146
150
|
event: NotificationEvent,
|
|
147
151
|
context: NotificationContext,
|
|
148
152
|
): void {
|
|
149
|
-
this.pendingApprovals.set(
|
|
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
|
-
|
|
167
|
+
questionId: string,
|
|
164
168
|
result: "approved" | "rejected",
|
|
165
169
|
): boolean {
|
|
166
|
-
const pending = this.pendingApprovals.get(
|
|
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(
|
|
179
|
-
return this.pendingApprovals.get(
|
|
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(
|
|
186
|
-
const pending = this.pendingApprovals.get(
|
|
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({
|
|
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/two-phase-review",
|
|
3
|
-
"version": "1.1.
|
|
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",
|