@deathbeam/pi-delegate 0.0.15 → 0.0.16
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 +15 -1
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -100,6 +100,7 @@ const MODEL_TIERS = new Set(["cheap", "balanced", "strong"]);
|
|
|
100
100
|
const WIDGET_KEY = "delegate";
|
|
101
101
|
const RESULT_MESSAGE = "delegate-result";
|
|
102
102
|
const REMINDER_MESSAGE = "delegate-reminder";
|
|
103
|
+
const JOB_ENTRY = "delegate-job";
|
|
103
104
|
const EXPLORATION_TOOLS = new Set(["read", "grep", "find", "ls", "bash", "powershell", "web_search", "web_fetch"]);
|
|
104
105
|
const FIRST_REMINDER_AT = 5;
|
|
105
106
|
const TASK_PREVIEW_LINES = 5;
|
|
@@ -270,7 +271,9 @@ export default function (pi: ExtensionAPI) {
|
|
|
270
271
|
job.status = status;
|
|
271
272
|
if (detail) addActivity(job, { kind: "status", text: detail });
|
|
272
273
|
const { controller, steer, lastTool, lastDetail, lastResult, ...snapshot } = job;
|
|
273
|
-
|
|
274
|
+
const entry: InspectJob = { ...snapshot, endedAt: Date.now() };
|
|
275
|
+
recent.unshift(entry);
|
|
276
|
+
pi.appendEntry(JOB_ENTRY, entry);
|
|
274
277
|
};
|
|
275
278
|
|
|
276
279
|
const jobSnapshot = (job: DelegateJob) => ({
|
|
@@ -356,6 +359,17 @@ export default function (pi: ExtensionAPI) {
|
|
|
356
359
|
viewing = undefined;
|
|
357
360
|
});
|
|
358
361
|
|
|
362
|
+
// Rebuilt from the active branch, like pi's todo example; abandoned branches are alternative histories.
|
|
363
|
+
const restoreJobs = (ctx: ExtensionContext) => {
|
|
364
|
+
recent.length = 0;
|
|
365
|
+
for (const entry of ctx.sessionManager.getBranch()) {
|
|
366
|
+
if (entry.type !== "custom" || entry.customType !== JOB_ENTRY || !entry.data) continue;
|
|
367
|
+
recent.unshift(entry.data as InspectJob);
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
pi.on("session_start", (_event, ctx) => restoreJobs(ctx));
|
|
371
|
+
pi.on("session_tree", (_event, ctx) => restoreJobs(ctx));
|
|
372
|
+
|
|
359
373
|
pi.on("before_agent_start", () => {
|
|
360
374
|
directCalls = 0;
|
|
361
375
|
nextReminder = FIRST_REMINDER_AT;
|