pi-harness-runtime 1.1.192 → 1.1.194
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 +4 -0
- 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/context-compiler/package.json +1 -1
- package/packages/context-discovery/package.json +1 -1
- package/packages/context-manager/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/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-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/dist/continuation-controller.d.ts +86 -0
- package/packages/jev-judge/dist/continuation-controller.d.ts.map +1 -0
- package/packages/jev-judge/dist/continuation-controller.js +245 -0
- package/packages/jev-judge/dist/continuation-controller.js.map +1 -0
- package/packages/jev-judge/dist/todo-provider.d.ts +103 -0
- package/packages/jev-judge/dist/todo-provider.d.ts.map +1 -0
- package/packages/jev-judge/dist/todo-provider.js +119 -0
- package/packages/jev-judge/dist/todo-provider.js.map +1 -0
- package/packages/jev-judge/package.json +1 -1
- package/packages/jev-judge/src/continuation-controller.ts +329 -0
- package/packages/jev-judge/src/todo-provider.ts +227 -0
- 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/conversation-bridge.d.ts +1 -1
- package/packages/notification/dist/conversation-bridge.d.ts.map +1 -1
- package/packages/notification/dist/conversation-bridge.js +60 -23
- package/packages/notification/dist/conversation-bridge.js.map +1 -1
- package/packages/notification/dist/notification-center.d.ts.map +1 -1
- package/packages/notification/dist/notification-center.js +8 -0
- package/packages/notification/dist/notification-center.js.map +1 -1
- package/packages/notification/dist/types.d.ts +1 -1
- package/packages/notification/dist/types.d.ts.map +1 -1
- package/packages/notification/package.json +1 -1
- package/packages/notification/src/conversation-bridge.ts +62 -24
- package/packages/notification/src/notification-center.ts +8 -0
- package/packages/notification/src/types.ts +2 -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/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/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/webmcp-tester/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,329 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Todo-Driven Continuation Controller
|
|
3
|
+
*
|
|
4
|
+
* Executes authorized todo items without repeated prompts.
|
|
5
|
+
* Uses deterministic rules + optional Jev for ambiguous cases.
|
|
6
|
+
*
|
|
7
|
+
* Architecture:
|
|
8
|
+
* A. Read real todo state (not bd)
|
|
9
|
+
* B. Deterministic continuation on agent_settled
|
|
10
|
+
* C. Jev for ambiguous classification only
|
|
11
|
+
* D. Single continuation controller
|
|
12
|
+
* E. Update prompts/Telegram/status together
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
16
|
+
import { createTodoProvider, type TodoItem, type TodoSnapshot } from "./todo-provider.js";
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Continuation state
|
|
21
|
+
*/
|
|
22
|
+
interface ContinuationState {
|
|
23
|
+
sessionId: string;
|
|
24
|
+
generation: number; // Incremented on edits/cancellation/switch
|
|
25
|
+
todoRevision: number;
|
|
26
|
+
currentItemId: number | null;
|
|
27
|
+
nextItemId: number | null;
|
|
28
|
+
lastMessageId: string | null;
|
|
29
|
+
continuationQueued: boolean;
|
|
30
|
+
userPaused: boolean;
|
|
31
|
+
lastSteerMessage: string | null;
|
|
32
|
+
steerAttempts: number;
|
|
33
|
+
lastEvaluationResult: ContinuationResult | null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Continuation result
|
|
38
|
+
*/
|
|
39
|
+
interface ContinuationResult {
|
|
40
|
+
action: "continue" | "stop" | "ask" | "blocked";
|
|
41
|
+
nextItemId?: number;
|
|
42
|
+
question?: string;
|
|
43
|
+
reason?: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Continuation controller configuration
|
|
48
|
+
*/
|
|
49
|
+
interface ContinuationConfig {
|
|
50
|
+
/** Minimum wait time before Jev fallback (ms) */
|
|
51
|
+
jevFallbackMinWaitMs?: number;
|
|
52
|
+
/** Jev probability threshold for routine continuation */
|
|
53
|
+
routineThreshold?: number;
|
|
54
|
+
/** Max steer attempts before reporting blocker */
|
|
55
|
+
maxSteerAttempts?: number;
|
|
56
|
+
/** Enable Jev classification for ambiguous cases */
|
|
57
|
+
enableJev?: boolean;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Todo-Driven Continuation Controller
|
|
62
|
+
*
|
|
63
|
+
* Evaluates todo state on agent_settled and determines next action.
|
|
64
|
+
*/
|
|
65
|
+
export class TodoContinuationController {
|
|
66
|
+
private pi: ExtensionAPI;
|
|
67
|
+
private config: Required<ContinuationConfig>;
|
|
68
|
+
private todoProvider = createTodoProvider();
|
|
69
|
+
|
|
70
|
+
private state: ContinuationState = {
|
|
71
|
+
sessionId: "",
|
|
72
|
+
generation: 0,
|
|
73
|
+
todoRevision: 0,
|
|
74
|
+
currentItemId: null,
|
|
75
|
+
nextItemId: null,
|
|
76
|
+
lastMessageId: null,
|
|
77
|
+
continuationQueued: false,
|
|
78
|
+
userPaused: false,
|
|
79
|
+
lastSteerMessage: null,
|
|
80
|
+
steerAttempts: 0,
|
|
81
|
+
lastEvaluationResult: null,
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
constructor(pi: ExtensionAPI, config?: ContinuationConfig) {
|
|
85
|
+
this.pi = pi;
|
|
86
|
+
this.config = {
|
|
87
|
+
jevFallbackMinWaitMs: 5 * 60 * 1000, // 5 minutes
|
|
88
|
+
routineThreshold: 0.7,
|
|
89
|
+
maxSteerAttempts: 3,
|
|
90
|
+
enableJev: true,
|
|
91
|
+
...config,
|
|
92
|
+
} as Required<ContinuationConfig>;
|
|
93
|
+
|
|
94
|
+
// Initialize Jev judge if enabled
|
|
95
|
+
if (this.config.enableJev) {
|
|
96
|
+
// Jev will be initialized with API key from environment
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Register lifecycle hooks
|
|
102
|
+
*/
|
|
103
|
+
register(): void {
|
|
104
|
+
console.log("[TodoContinuation] Registering lifecycle hooks...");
|
|
105
|
+
|
|
106
|
+
// Session start - reset state
|
|
107
|
+
this.pi.on("session_start", () => {
|
|
108
|
+
this.reset();
|
|
109
|
+
console.log("[TodoContinuation] Session started");
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
// Agent settled - evaluate continuation
|
|
113
|
+
this.pi.on("agent_settled", () => {
|
|
114
|
+
this.evaluateContinuation().catch((err) =>
|
|
115
|
+
console.error("[TodoContinuation] Evaluation failed:", err)
|
|
116
|
+
);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
// User input - reset pause state
|
|
120
|
+
this.pi.on("message_start", (event) => {
|
|
121
|
+
const msg = event.message as { role?: string };
|
|
122
|
+
if (msg?.role === "user") {
|
|
123
|
+
this.state.userPaused = false;
|
|
124
|
+
this.state.lastSteerMessage = null;
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
// Session shutdown - cleanup
|
|
129
|
+
this.pi.on("session_shutdown", () => {
|
|
130
|
+
this.cleanup();
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
// Tool call - track mutations that might invalidate state
|
|
134
|
+
this.pi.on("tool_call", (event) => {
|
|
135
|
+
// Increment generation on edits
|
|
136
|
+
if (["write", "edit", "bash"].includes(event.toolName)) {
|
|
137
|
+
this.state.generation++;
|
|
138
|
+
this.state.continuationQueued = false;
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
console.log("[TodoContinuation] Lifecycle hooks registered");
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Evaluate continuation decision and execute it
|
|
147
|
+
*/
|
|
148
|
+
private async evaluateContinuation(): Promise<void> {
|
|
149
|
+
// 1. Check user pause
|
|
150
|
+
if (this.state.userPaused) {
|
|
151
|
+
console.log("[TodoContinuation] User paused, stopping");
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// 2. Get current todo snapshot
|
|
156
|
+
const availability = await this.todoProvider.availability();
|
|
157
|
+
if (!availability.available) {
|
|
158
|
+
// No todo provider - don't auto-continue
|
|
159
|
+
console.log("[TodoContinuation] Todo provider unavailable:", availability.error);
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
try {
|
|
164
|
+
// Get snapshot for state tracking
|
|
165
|
+
await this.todoProvider.getSnapshot();
|
|
166
|
+
|
|
167
|
+
// 3. Get in-progress and pending items
|
|
168
|
+
const inProgressItems = await this.todoProvider.getByStatus("in_progress");
|
|
169
|
+
const pendingItems = await this.todoProvider.getPending();
|
|
170
|
+
const completedItems = await this.todoProvider.getCompleted();
|
|
171
|
+
|
|
172
|
+
// 4. If there's work in progress, continue it
|
|
173
|
+
if (inProgressItems.length > 0) {
|
|
174
|
+
const item = inProgressItems[0];
|
|
175
|
+
console.log(`[TodoContinuation] In-progress item: ${item.subject}`);
|
|
176
|
+
await this.continueItem(item);
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// 5. Determine action based on state
|
|
181
|
+
const totalItems = completedItems.length + pendingItems.length + inProgressItems.length;
|
|
182
|
+
const hasWork = pendingItems.length > 0 || inProgressItems.length > 0;
|
|
183
|
+
|
|
184
|
+
if (!hasWork && totalItems === 0) {
|
|
185
|
+
console.log("[TodoContinuation] All items complete");
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (pendingItems.length > 0) {
|
|
190
|
+
// Check if items are blocked
|
|
191
|
+
const blockedItems = await this.todoProvider.getBlocked();
|
|
192
|
+
if (blockedItems.length === pendingItems.length) {
|
|
193
|
+
// All pending items are blocked
|
|
194
|
+
const blocker = blockedItems[0];
|
|
195
|
+
console.log("[TodoContinuation] Items blocked:", blocker?.subject);
|
|
196
|
+
// Don't auto-continue when blocked
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// Continue the first non-blocked pending item
|
|
201
|
+
const readyItems = await this.todoProvider.getReady();
|
|
202
|
+
if (readyItems.length > 0) {
|
|
203
|
+
await this.continueItem(readyItems[0]);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
} catch (err) {
|
|
207
|
+
console.error("[TodoContinuation] Evaluation error:", err);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Continue a specific todo item
|
|
213
|
+
*/
|
|
214
|
+
private async continueItem(item: TodoItem): Promise<void> {
|
|
215
|
+
if (this.state.steerAttempts >= this.config.maxSteerAttempts) {
|
|
216
|
+
console.warn("[TodoContinuation] Max steer attempts reached");
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
this.state.steerAttempts++;
|
|
221
|
+
this.state.continuationQueued = true;
|
|
222
|
+
// Build continuation message
|
|
223
|
+
const message = item.description
|
|
224
|
+
? `Continue task: ${item.subject}\n\n${item.description}`
|
|
225
|
+
: `Continue task: ${item.subject}`;
|
|
226
|
+
|
|
227
|
+
this.state.lastSteerMessage = message;
|
|
228
|
+
console.log(`[TodoContinuation] Continuing: ${item.subject}`);
|
|
229
|
+
console.log(`[TodoContinuation] Message: ${message}`);
|
|
230
|
+
// Note: Pi does not expose sendUserMessage API.
|
|
231
|
+
// The Telegram notification system will prompt user for ambiguous cases.
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Steer to continue a todo item
|
|
238
|
+
*/
|
|
239
|
+
async steerToContinue(itemId: number): Promise<void> {
|
|
240
|
+
if (this.state.steerAttempts >= this.config.maxSteerAttempts) {
|
|
241
|
+
console.warn("[TodoContinuation] Max steer attempts reached");
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
this.state.steerAttempts++;
|
|
246
|
+
this.state.continuationQueued = true;
|
|
247
|
+
|
|
248
|
+
const snapshot = await this.todoProvider.getSnapshot();
|
|
249
|
+
const item = snapshot.items.find((i) => i.id === itemId);
|
|
250
|
+
|
|
251
|
+
const message = item
|
|
252
|
+
? `Continue todo item: "${item.subject}". ${item.description ?? ""}`
|
|
253
|
+
: `Continue work on the next ready task.`;
|
|
254
|
+
|
|
255
|
+
this.state.lastSteerMessage = message;
|
|
256
|
+
this.state.todoRevision = snapshot.revision;
|
|
257
|
+
|
|
258
|
+
console.log(`[TodoContinuation] Steering to continue item ${itemId}`);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Mark a todo item as complete
|
|
263
|
+
*/
|
|
264
|
+
async markComplete(itemId: number): Promise<void> {
|
|
265
|
+
console.log(`[TodoContinuation] Marking item ${itemId} complete`);
|
|
266
|
+
this.state.currentItemId = null;
|
|
267
|
+
this.state.generation++;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* User paused
|
|
272
|
+
*/
|
|
273
|
+
pause(): void {
|
|
274
|
+
this.state.userPaused = true;
|
|
275
|
+
this.state.continuationQueued = false;
|
|
276
|
+
console.log("[TodoContinuation] User paused");
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Reset state for new session
|
|
281
|
+
*/
|
|
282
|
+
private reset(): void {
|
|
283
|
+
this.state = {
|
|
284
|
+
sessionId: `session-${Date.now()}`,
|
|
285
|
+
generation: 0,
|
|
286
|
+
todoRevision: 0,
|
|
287
|
+
currentItemId: null,
|
|
288
|
+
nextItemId: null,
|
|
289
|
+
lastMessageId: null,
|
|
290
|
+
continuationQueued: false,
|
|
291
|
+
userPaused: false,
|
|
292
|
+
lastSteerMessage: null,
|
|
293
|
+
steerAttempts: 0,
|
|
294
|
+
lastEvaluationResult: null,
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Cleanup on shutdown
|
|
300
|
+
*/
|
|
301
|
+
private cleanup(): void {
|
|
302
|
+
console.log("[TodoContinuation] Cleaning up");
|
|
303
|
+
this.state.continuationQueued = false;
|
|
304
|
+
this.state.generation++;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Get current state summary
|
|
309
|
+
*/
|
|
310
|
+
getState(): { current: TodoItem | null; next: TodoItem | null; ready: number } {
|
|
311
|
+
return {
|
|
312
|
+
current: null, // Would need to fetch
|
|
313
|
+
next: null,
|
|
314
|
+
ready: 0,
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Create and register a todo continuation controller
|
|
321
|
+
*/
|
|
322
|
+
export function createTodoContinuation(
|
|
323
|
+
pi: ExtensionAPI,
|
|
324
|
+
config?: ContinuationConfig
|
|
325
|
+
): TodoContinuationController {
|
|
326
|
+
const controller = new TodoContinuationController(pi, config);
|
|
327
|
+
controller.register();
|
|
328
|
+
return controller;
|
|
329
|
+
}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Todo Provider - Read local todo state
|
|
3
|
+
*
|
|
4
|
+
* Provides typed access to the local todo list.
|
|
5
|
+
* Separates todo from bd (issue tracker).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Todo item status
|
|
12
|
+
*/
|
|
13
|
+
export type TodoStatus = "pending" | "in_progress" | "completed" | "deleted";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A single todo item
|
|
17
|
+
*/
|
|
18
|
+
export interface TodoItem {
|
|
19
|
+
id: number;
|
|
20
|
+
subject: string;
|
|
21
|
+
description?: string;
|
|
22
|
+
status: TodoStatus;
|
|
23
|
+
activeForm?: string;
|
|
24
|
+
blockedBy?: number[];
|
|
25
|
+
owner?: string;
|
|
26
|
+
metadata?: Record<string, unknown>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Snapshot of the todo list at a point in time
|
|
31
|
+
*/
|
|
32
|
+
export interface TodoSnapshot {
|
|
33
|
+
items: TodoItem[];
|
|
34
|
+
sessionId: string;
|
|
35
|
+
revision: number; // Monotonically increasing per-session version
|
|
36
|
+
createdAt: Date;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Availability result for todo provider
|
|
41
|
+
*/
|
|
42
|
+
export interface TodoAvailability {
|
|
43
|
+
available: boolean;
|
|
44
|
+
error?: string;
|
|
45
|
+
provider?: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Todo Provider interface
|
|
50
|
+
*/
|
|
51
|
+
export interface TodoProvider {
|
|
52
|
+
/**
|
|
53
|
+
* Check if todo is available
|
|
54
|
+
*/
|
|
55
|
+
availability(): Promise<TodoAvailability>;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Get current snapshot of todo list
|
|
59
|
+
*/
|
|
60
|
+
getSnapshot(): Promise<TodoSnapshot>;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Get items by status
|
|
64
|
+
*/
|
|
65
|
+
getByStatus(status: TodoStatus): Promise<TodoItem[]>;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Get in-progress items
|
|
69
|
+
*/
|
|
70
|
+
getInProgress(): Promise<TodoItem[]>;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Get pending items (not completed)
|
|
74
|
+
*/
|
|
75
|
+
getPending(): Promise<TodoItem[]>;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Get completed items
|
|
79
|
+
*/
|
|
80
|
+
getCompleted(): Promise<TodoItem[]>;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Get ready items (pending with satisfied dependencies)
|
|
84
|
+
*/
|
|
85
|
+
getReady(): Promise<TodoItem[]>;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Get blocked items (pending with unsatisfied dependencies)
|
|
89
|
+
*/
|
|
90
|
+
getBlocked(): Promise<TodoItem[]>;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Mock Todo Provider for testing
|
|
95
|
+
*/
|
|
96
|
+
export class MockTodoProvider implements TodoProvider {
|
|
97
|
+
private items: TodoItem[] = [];
|
|
98
|
+
private _sessionId: string;
|
|
99
|
+
private _revision = 0;
|
|
100
|
+
|
|
101
|
+
constructor(sessionId?: string) {
|
|
102
|
+
this._sessionId = sessionId ?? `mock-${Date.now()}`;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
async availability(): Promise<TodoAvailability> {
|
|
106
|
+
return { available: true, provider: "mock" };
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
async getSnapshot(): Promise<TodoSnapshot> {
|
|
110
|
+
this._revision++;
|
|
111
|
+
return {
|
|
112
|
+
items: [...this.items],
|
|
113
|
+
sessionId: this._sessionId,
|
|
114
|
+
revision: this._revision,
|
|
115
|
+
createdAt: new Date(),
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
async getByStatus(status: TodoStatus): Promise<TodoItem[]> {
|
|
120
|
+
return this.items.filter((item) => item.status === status);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
async getInProgress(): Promise<TodoItem[]> {
|
|
124
|
+
return this.getByStatus("in_progress");
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
async getPending(): Promise<TodoItem[]> {
|
|
128
|
+
return this.items.filter((item) => item.status === "pending");
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
async getCompleted(): Promise<TodoItem[]> {
|
|
132
|
+
return this.getByStatus("completed");
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
async getReady(): Promise<TodoItem[]> {
|
|
136
|
+
const pending = await this.getPending();
|
|
137
|
+
return pending.filter((item) => {
|
|
138
|
+
if (!item.blockedBy?.length) return true;
|
|
139
|
+
const blockedIds = new Set(item.blockedBy);
|
|
140
|
+
return !this.items.some(
|
|
141
|
+
(i) => blockedIds.has(i.id) && i.status !== "completed"
|
|
142
|
+
);
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
async getBlocked(): Promise<TodoItem[]> {
|
|
147
|
+
const pending = await this.getPending();
|
|
148
|
+
return pending.filter((item) => {
|
|
149
|
+
if (!item.blockedBy?.length) return false;
|
|
150
|
+
const blockedIds = new Set(item.blockedBy);
|
|
151
|
+
return this.items.some(
|
|
152
|
+
(i) => blockedIds.has(i.id) && i.status !== "completed"
|
|
153
|
+
);
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Test helpers
|
|
158
|
+
addItem(item: Omit<TodoItem, "id">): TodoItem {
|
|
159
|
+
const id = this.items.length + 1;
|
|
160
|
+
const newItem: TodoItem = { ...item, id };
|
|
161
|
+
this.items.push(newItem);
|
|
162
|
+
return newItem;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
setStatus(id: number, status: TodoStatus): void {
|
|
166
|
+
const item = this.items.find((i) => i.id === id);
|
|
167
|
+
if (item) {
|
|
168
|
+
item.status = status;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
clear(): void {
|
|
173
|
+
this.items = [];
|
|
174
|
+
this._revision++;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Create a todo provider based on available tools
|
|
180
|
+
*/
|
|
181
|
+
export function createTodoProvider(pi?: ExtensionAPI): TodoProvider {
|
|
182
|
+
// Check if Pi exposes a todo API
|
|
183
|
+
// For now, Pi does not expose a todo extension API
|
|
184
|
+
// Return a provider that reports unavailability
|
|
185
|
+
return new PiUnavailableTodoProvider();
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Provider that reports Pi todo extension is not available
|
|
190
|
+
*/
|
|
191
|
+
class PiUnavailableTodoProvider implements TodoProvider {
|
|
192
|
+
async availability(): Promise<TodoAvailability> {
|
|
193
|
+
return {
|
|
194
|
+
available: false,
|
|
195
|
+
error: "Pi does not expose a todo extension API. Todo state is not available.",
|
|
196
|
+
provider: "pi-todo",
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
async getSnapshot(): Promise<TodoSnapshot> {
|
|
201
|
+
throw new Error("Pi todo extension is not available");
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
async getByStatus(_status: TodoStatus): Promise<TodoItem[]> {
|
|
205
|
+
return [];
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
async getInProgress(): Promise<TodoItem[]> {
|
|
209
|
+
return [];
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
async getPending(): Promise<TodoItem[]> {
|
|
213
|
+
return [];
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
async getCompleted(): Promise<TodoItem[]> {
|
|
217
|
+
return [];
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
async getReady(): Promise<TodoItem[]> {
|
|
221
|
+
return [];
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
async getBlocked(): Promise<TodoItem[]> {
|
|
225
|
+
return [];
|
|
226
|
+
}
|
|
227
|
+
}
|
|
@@ -62,7 +62,7 @@ export declare class ConversationBridge {
|
|
|
62
62
|
*/
|
|
63
63
|
private finalizePendingMessages;
|
|
64
64
|
/**
|
|
65
|
-
* Flush pending messages
|
|
65
|
+
* Flush pending messages (on compaction) - send before clearing
|
|
66
66
|
*/
|
|
67
67
|
private flushPendingMessages;
|
|
68
68
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation-bridge.d.ts","sourceRoot":"","sources":["../src/conversation-bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAGnE;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACxC,gDAAgD;IAChD,sBAAsB,EAAE,OAAO,CAAC;IAChC,qCAAqC;IACrC,iBAAiB,EAAE,OAAO,CAAC;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