pi-harness-runtime 1.1.346 → 1.1.348
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/index.ts +71 -75
- package/package.json +1 -1
- package/packages/a2a-adapter/package.json +1 -1
- package/packages/agent-policy/package.json +1 -1
- package/packages/architecture-generator/package.json +1 -1
- package/packages/auth/package.json +1 -1
- package/packages/autonomous-refactor/package.json +1 -1
- package/packages/autonomous-runtime/package.json +1 -1
- package/packages/cache-strategy/package.json +1 -1
- package/packages/capability-registry/package.json +1 -1
- package/packages/checkpoint/package.json +1 -1
- package/packages/cli-plugin-sdk/package.json +1 -1
- package/packages/clipboard/package.json +1 -1
- package/packages/clipboard-plugin/package.json +1 -1
- package/packages/code-generation/package.json +1 -1
- package/packages/code-review/package.json +1 -1
- package/packages/codex-adapter/package.json +1 -1
- package/packages/codex-watcher/package.json +1 -1
- package/packages/config-capture/package.json +1 -1
- package/packages/connection-runtime/package.json +1 -1
- package/packages/context-compiler/package.json +1 -1
- package/packages/context-discovery/package.json +1 -1
- package/packages/context-manager/package.json +1 -1
- package/packages/contracts/package.json +1 -1
- package/packages/cookie-sanitizer/package.json +1 -1
- package/packages/cost-optimizer/package.json +1 -1
- package/packages/dependency-analyzer/package.json +1 -1
- package/packages/django-plugin/package.json +1 -1
- package/packages/doc-generator/package.json +1 -1
- package/packages/durable-review/package.json +1 -1
- package/packages/e2e-tester/package.json +1 -1
- package/packages/evaluation-engine/package.json +1 -1
- package/packages/evaluation-runner/package.json +1 -1
- package/packages/event-bus/package.json +1 -1
- package/packages/event-sink/package.json +1 -1
- package/packages/event-store/package.json +1 -1
- package/packages/experience-replay/package.json +1 -1
- package/packages/feedback-collector/package.json +1 -1
- package/packages/file-copy-helper/package.json +1 -1
- package/packages/framework-detector/package.json +1 -1
- package/packages/framework-plugin-sdk/package.json +1 -1
- package/packages/frappe-plugin/package.json +1 -1
- package/packages/generic-web-plugin/package.json +1 -1
- package/packages/health-monitor/package.json +1 -1
- package/packages/intent-analyzer/package.json +1 -1
- package/packages/jev-judge/package.json +1 -1
- package/packages/knowledge-graph/package.json +1 -1
- package/packages/knowledge-retrieval/package.json +1 -1
- package/packages/laravel-plugin/package.json +1 -1
- package/packages/learning-engine/package.json +1 -1
- package/packages/mcp-adapter/package.json +1 -1
- package/packages/memory-engine/package.json +1 -1
- package/packages/milestone-manager/package.json +1 -1
- package/packages/model-registry/package.json +1 -1
- package/packages/nextjs-plugin/package.json +1 -1
- package/packages/notification/dist/index.d.ts +1 -0
- package/packages/notification/dist/index.d.ts.map +1 -1
- package/packages/notification/dist/index.js +1 -0
- package/packages/notification/dist/index.js.map +1 -1
- package/packages/notification/dist/notification-center.d.ts +13 -0
- package/packages/notification/dist/notification-center.d.ts.map +1 -1
- package/packages/notification/dist/notification-center.js +91 -1
- package/packages/notification/dist/notification-center.js.map +1 -1
- package/packages/notification/dist/pending-question.d.ts +198 -0
- package/packages/notification/dist/pending-question.d.ts.map +1 -0
- package/packages/notification/dist/pending-question.js +410 -0
- package/packages/notification/dist/pending-question.js.map +1 -0
- package/packages/notification/package.json +1 -1
- package/packages/notification/src/index.ts +1 -0
- package/packages/notification/src/notification-center.ts +92 -1
- package/packages/notification/src/pending-question.ts +594 -0
- package/packages/notification/test/pending-question.test.ts +331 -0
- package/packages/observability/package.json +1 -1
- package/packages/okf-indexer/package.json +1 -1
- package/packages/paperclip-integration/package.json +1 -1
- package/packages/performance-optimizer/package.json +1 -1
- package/packages/permission-mode/package.json +1 -1
- package/packages/privilege-broker/package.json +1 -1
- package/packages/project-analyzer/package.json +1 -1
- package/packages/project-bootstrap/package.json +1 -1
- package/packages/projection-engine/package.json +1 -1
- package/packages/prompt-compiler/package.json +1 -1
- package/packages/prompt-versioning/package.json +1 -1
- package/packages/provider-adapter-sdk/package.json +1 -1
- package/packages/provider-router/package.json +1 -1
- package/packages/provider-selector/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/rate-limiter/package.json +1 -1
- package/packages/react-vite-plugin/package.json +1 -1
- package/packages/relay/package.json +1 -1
- package/packages/release-manager/package.json +1 -1
- package/packages/requirement-compiler/package.json +1 -1
- package/packages/runtime/package.json +1 -1
- package/packages/scheduler/package.json +1 -1
- package/packages/scheduler-adapter/package.json +1 -1
- package/packages/session/package.json +1 -1
- package/packages/session-api/package.json +1 -1
- package/packages/session-export/package.json +1 -1
- package/packages/shared-context/package.json +1 -1
- package/packages/skill-mcp-client/package.json +1 -1
- package/packages/skill-registry/package.json +1 -1
- package/packages/skills/package.json +1 -1
- package/packages/sprint-planner/package.json +1 -1
- package/packages/subscription-engine/package.json +1 -1
- package/packages/task-compiler/package.json +1 -1
- package/packages/telegram/package.json +1 -1
- package/packages/tencentdb-memory/package.json +1 -1
- package/packages/tencentdb-sync/package.json +1 -1
- package/packages/test-data-generator/package.json +1 -1
- package/packages/test-generator/package.json +1 -1
- package/packages/todo-bd-sync/package.json +1 -1
- package/packages/token-estimation/package.json +1 -1
- package/packages/token-optimizer/package.json +1 -1
- package/packages/trajectory/package.json +1 -1
- package/packages/tui/package.json +1 -1
- package/packages/types/package.json +1 -1
- package/packages/voice-api/package.json +1 -1
- package/packages/webmcp-tester/package.json +1 -1
- package/packages/wiki/package.json +1 -1
- package/packages/workflow-events/package.json +1 -1
- package/packages/workspace-scanner/package.json +1 -1
- package/packages/worktree/package.json +1 -1
- package/packages/write-review/package.json +1 -1
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pending Question Controller Tests
|
|
3
|
+
*
|
|
4
|
+
* Tests for the pending question detection, state management,
|
|
5
|
+
* and channel delivery logic.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { describe, it, expect, beforeEach } from "bun:test";
|
|
9
|
+
import {
|
|
10
|
+
PendingQuestionController,
|
|
11
|
+
createPendingQuestionController,
|
|
12
|
+
type QuestionKind,
|
|
13
|
+
} from "../src/pending-question.js";
|
|
14
|
+
|
|
15
|
+
describe("PendingQuestionController", () => {
|
|
16
|
+
let controller: PendingQuestionController;
|
|
17
|
+
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
controller = createPendingQuestionController({
|
|
20
|
+
evaluationDelayMs: 5 * 60 * 1000,
|
|
21
|
+
jevEnabled: false,
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
describe("detectQuestion", () => {
|
|
26
|
+
it("should detect 'Want me to implement X?' pattern", () => {
|
|
27
|
+
const result = controller.detectQuestion(
|
|
28
|
+
"I've finished the toggle implementation. Want me to implement the toggle buttons now?"
|
|
29
|
+
);
|
|
30
|
+
expect(result.detected).toBe(true);
|
|
31
|
+
expect(result.questionText).toContain("Want me to implement");
|
|
32
|
+
expect(result.kind).toBe("approval");
|
|
33
|
+
expect(result.isRoutine).toBe(false);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("should detect 'Would you like me to add X?' pattern", () => {
|
|
37
|
+
const result = controller.detectQuestion(
|
|
38
|
+
"Would you like me to add the persistence layer next?"
|
|
39
|
+
);
|
|
40
|
+
expect(result.detected).toBe(true);
|
|
41
|
+
expect(result.questionText).toContain("Would you like me to add");
|
|
42
|
+
expect(result.kind).toBe("approval");
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("should detect 'Shall I start X?' pattern", () => {
|
|
46
|
+
const result = controller.detectQuestion(
|
|
47
|
+
"Shall I start with the database schema?"
|
|
48
|
+
);
|
|
49
|
+
expect(result.detected).toBe(true);
|
|
50
|
+
expect(result.kind).toBe("approval");
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it("should detect 'Should I implement X?' pattern", () => {
|
|
54
|
+
const result = controller.detectQuestion(
|
|
55
|
+
"Should I implement the SQLite persistence now?"
|
|
56
|
+
);
|
|
57
|
+
expect(result.detected).toBe(true);
|
|
58
|
+
expect(result.kind).toBe("approval");
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("should detect question ending with ? with request + intent words", () => {
|
|
62
|
+
const result = controller.detectQuestion(
|
|
63
|
+
"Should I continue with the next task?"
|
|
64
|
+
);
|
|
65
|
+
expect(result.detected).toBe(true);
|
|
66
|
+
expect(result.kind).toBe("routine");
|
|
67
|
+
expect(result.isRoutine).toBe(true);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("should detect 'Should I continue?' as routine", () => {
|
|
71
|
+
const result = controller.detectQuestion("Should I continue?");
|
|
72
|
+
expect(result.detected).toBe(true);
|
|
73
|
+
expect(result.isRoutine).toBe(true);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("should NOT detect quoted questions", () => {
|
|
77
|
+
const result = controller.detectQuestion(
|
|
78
|
+
`Here's an example: "Want me to implement this?" - that's what I might ask.`
|
|
79
|
+
);
|
|
80
|
+
// The quoted question should not be detected
|
|
81
|
+
expect(result.detected).toBe(false);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it("should NOT detect rhetorical questions in code blocks", () => {
|
|
85
|
+
const result = controller.detectQuestion(
|
|
86
|
+
`\`\`\`\n// Want me to implement this?\n\`\`\`\nThe code above shows what we need.`
|
|
87
|
+
);
|
|
88
|
+
expect(result.detected).toBe(false);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it("should detect clarification questions", () => {
|
|
92
|
+
const result = controller.detectQuestion(
|
|
93
|
+
"Do you mean the SQLite or the file-based approach?"
|
|
94
|
+
);
|
|
95
|
+
expect(result.detected).toBe(true);
|
|
96
|
+
expect(result.kind).toBe("clarification");
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it("should NOT detect plain progress statements", () => {
|
|
100
|
+
const result = controller.detectQuestion(
|
|
101
|
+
"I've implemented the toggle buttons and they work correctly."
|
|
102
|
+
);
|
|
103
|
+
expect(result.detected).toBe(false);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it("should detect 'Can I proceed?' as routine", () => {
|
|
107
|
+
const result = controller.detectQuestion("Can I proceed with the next step?");
|
|
108
|
+
expect(result.detected).toBe(true);
|
|
109
|
+
expect(result.isRoutine).toBe(true);
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
describe("question lifecycle", () => {
|
|
114
|
+
it("should create and track a pending question", () => {
|
|
115
|
+
const question = controller.createQuestion({
|
|
116
|
+
text: "Want me to implement the toggle buttons now?",
|
|
117
|
+
sessionId: "test-session",
|
|
118
|
+
workspacePath: "/test",
|
|
119
|
+
kind: "approval",
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
expect(question.requestId).toBeDefined();
|
|
123
|
+
expect(question.state).toBe("pending");
|
|
124
|
+
expect(question.kind).toBe("approval");
|
|
125
|
+
expect(controller.hasPendingQuestion()).toBe(true);
|
|
126
|
+
expect(controller.getCurrentQuestion()).toEqual(question);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it("should resolve a question with 'yes'", () => {
|
|
130
|
+
controller.createQuestion({
|
|
131
|
+
text: "Want me to implement X?",
|
|
132
|
+
sessionId: "test-session",
|
|
133
|
+
workspacePath: "/test",
|
|
134
|
+
kind: "approval",
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
controller.resolve({ resolution: "yes", by: "user" });
|
|
138
|
+
|
|
139
|
+
expect(controller.isResolved()).toBe(true);
|
|
140
|
+
expect(controller.getResolution()).toBe("yes");
|
|
141
|
+
expect(controller.getCurrentQuestion()?.state).toBe("resolved");
|
|
142
|
+
expect(controller.getCurrentQuestion()?.resolvedBy).toBe("user");
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it("should resolve a question with 'no'", () => {
|
|
146
|
+
controller.createQuestion({
|
|
147
|
+
text: "Want me to implement X?",
|
|
148
|
+
sessionId: "test-session",
|
|
149
|
+
workspacePath: "/test",
|
|
150
|
+
kind: "approval",
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
controller.resolve({ resolution: "no", by: "user" });
|
|
154
|
+
|
|
155
|
+
expect(controller.getResolution()).toBe("no");
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it("should cancel a question", () => {
|
|
159
|
+
controller.createQuestion({
|
|
160
|
+
text: "Want me to implement X?",
|
|
161
|
+
sessionId: "test-session",
|
|
162
|
+
workspacePath: "/test",
|
|
163
|
+
kind: "approval",
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
controller.cancel("Session switched");
|
|
167
|
+
|
|
168
|
+
expect(controller.hasPendingQuestion()).toBe(false);
|
|
169
|
+
expect(controller.getCurrentQuestion()).toBe(null);
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it("should start evaluation", () => {
|
|
173
|
+
controller.createQuestion({
|
|
174
|
+
text: "Want me to implement X?",
|
|
175
|
+
sessionId: "test-session",
|
|
176
|
+
workspacePath: "/test",
|
|
177
|
+
kind: "approval",
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
controller.startEvaluation();
|
|
181
|
+
|
|
182
|
+
expect(controller.getCurrentQuestion()?.state).toBe("evaluating");
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
describe("channel delivery state", () => {
|
|
187
|
+
it("should update Telegram delivery state", () => {
|
|
188
|
+
controller.createQuestion({
|
|
189
|
+
text: "Want me to implement X?",
|
|
190
|
+
sessionId: "test-session",
|
|
191
|
+
workspacePath: "/test",
|
|
192
|
+
kind: "approval",
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
controller.updateDeliveryState("telegram", true);
|
|
196
|
+
|
|
197
|
+
const question = controller.getCurrentQuestion();
|
|
198
|
+
expect(question?.deliveryState.telegram?.delivered).toBe(true);
|
|
199
|
+
expect(question?.deliveryState.telegram?.deliveredAt).toBeDefined();
|
|
200
|
+
expect(question?.userNotified).toBe(true);
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
it("should update LINE delivery state", () => {
|
|
204
|
+
controller.createQuestion({
|
|
205
|
+
text: "Want me to implement X?",
|
|
206
|
+
sessionId: "test-session",
|
|
207
|
+
workspacePath: "/test",
|
|
208
|
+
kind: "approval",
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
controller.updateDeliveryState("line", true);
|
|
212
|
+
|
|
213
|
+
const question = controller.getCurrentQuestion();
|
|
214
|
+
expect(question?.deliveryState.line?.delivered).toBe(true);
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it("should track delivery errors", () => {
|
|
218
|
+
controller.createQuestion({
|
|
219
|
+
text: "Want me to implement X?",
|
|
220
|
+
sessionId: "test-session",
|
|
221
|
+
workspacePath: "/test",
|
|
222
|
+
kind: "approval",
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
controller.updateDeliveryState("telegram", false, "Network error");
|
|
226
|
+
|
|
227
|
+
const question = controller.getCurrentQuestion();
|
|
228
|
+
expect(question?.deliveryState.telegram?.delivered).toBe(false);
|
|
229
|
+
expect(question?.deliveryState.telegram?.error).toBe("Network error");
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
describe("suppress completion", () => {
|
|
234
|
+
it("should suppress completion when pending question exists", () => {
|
|
235
|
+
controller.createQuestion({
|
|
236
|
+
text: "Want me to implement X?",
|
|
237
|
+
sessionId: "test-session",
|
|
238
|
+
workspacePath: "/test",
|
|
239
|
+
kind: "approval",
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
expect(controller.shouldSuppressCompletion()).toBe(true);
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
it("should NOT suppress completion when no pending question", () => {
|
|
246
|
+
expect(controller.shouldSuppressCompletion()).toBe(false);
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
it("should NOT suppress completion when question is resolved", () => {
|
|
250
|
+
controller.createQuestion({
|
|
251
|
+
text: "Want me to implement X?",
|
|
252
|
+
sessionId: "test-session",
|
|
253
|
+
workspacePath: "/test",
|
|
254
|
+
kind: "approval",
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
controller.resolve({ resolution: "yes", by: "user" });
|
|
258
|
+
|
|
259
|
+
expect(controller.shouldSuppressCompletion()).toBe(false);
|
|
260
|
+
});
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
describe("callbacks", () => {
|
|
264
|
+
it("should call user answer callback on resolution", () => {
|
|
265
|
+
let callbackCalled = false;
|
|
266
|
+
let callbackResolution = "";
|
|
267
|
+
|
|
268
|
+
controller.onUserAnswer((question, answer) => {
|
|
269
|
+
callbackCalled = true;
|
|
270
|
+
callbackResolution = answer;
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
controller.createQuestion({
|
|
274
|
+
text: "Want me to implement X?",
|
|
275
|
+
sessionId: "test-session",
|
|
276
|
+
workspacePath: "/test",
|
|
277
|
+
kind: "approval",
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
controller.resolve({ resolution: "yes", by: "user" });
|
|
281
|
+
|
|
282
|
+
expect(callbackCalled).toBe(true);
|
|
283
|
+
expect(callbackResolution).toBe("yes");
|
|
284
|
+
});
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
describe("cleanup", () => {
|
|
288
|
+
it("should clean up old resolved questions", () => {
|
|
289
|
+
controller.createQuestion({
|
|
290
|
+
text: "Want me to implement X?",
|
|
291
|
+
sessionId: "test-session",
|
|
292
|
+
workspacePath: "/test",
|
|
293
|
+
kind: "approval",
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
controller.resolve({ resolution: "yes", by: "user" });
|
|
297
|
+
|
|
298
|
+
// Wait a tiny bit then cleanup with 0ms max age
|
|
299
|
+
setTimeout(() => {
|
|
300
|
+
controller.cleanup(0);
|
|
301
|
+
const questions = controller.getAllQuestions();
|
|
302
|
+
expect(questions.length).toBe(0);
|
|
303
|
+
}, 10);
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
describe("Question detection edge cases", () => {
|
|
309
|
+
let controller: PendingQuestionController;
|
|
310
|
+
|
|
311
|
+
beforeEach(() => {
|
|
312
|
+
controller = createPendingQuestionController();
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
it("should handle multiple questions in one message", () => {
|
|
316
|
+
const result = controller.detectQuestion(
|
|
317
|
+
"I've finished task 1. Want me to implement the toggle buttons now? Should I continue with the next task?"
|
|
318
|
+
);
|
|
319
|
+
// Should detect the approval question, not the routine continuation
|
|
320
|
+
expect(result.detected).toBe(true);
|
|
321
|
+
expect(result.kind).toBe("approval");
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
it("should handle mixed content with questions", () => {
|
|
325
|
+
const result = controller.detectQuestion(
|
|
326
|
+
`Here's what I did:\n1. Implemented toggle state\n2. Added persistence\n\nWant me to continue with the UI?`
|
|
327
|
+
);
|
|
328
|
+
expect(result.detected).toBe(true);
|
|
329
|
+
expect(result.kind).toBe("approval");
|
|
330
|
+
});
|
|
331
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-harness/provider-router",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.348",
|
|
4
4
|
"description": "Enhanced Provider Router for pi-harness-runtime — intelligent routing with capabilities, costs, and quotas",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/provider-router.js",
|