@timmyjl12/pi-subagents 0.20.0 → 0.21.0
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 +862 -827
- package/README.md +1125 -1080
- package/dist/active-agents-prompt.d.ts +31 -9
- package/dist/active-agents-prompt.js +73 -9
- package/dist/agent-color.js +9 -1
- package/dist/agent-file-toggle.d.ts +1 -1
- package/dist/agent-manager.d.ts +405 -18
- package/dist/agent-manager.js +1661 -131
- package/dist/agent-runner.d.ts +45 -6
- package/dist/agent-runner.js +109 -18
- package/dist/agent-types.d.ts +30 -7
- package/dist/agent-types.js +38 -9
- package/dist/awaited-result.d.ts +37 -0
- package/dist/awaited-result.js +150 -0
- package/dist/child-session-shutdown.d.ts +19 -1
- package/dist/child-session-shutdown.js +60 -11
- package/dist/cleanup-plans.d.ts +10 -0
- package/dist/cleanup-plans.js +112 -0
- package/dist/cross-extension-rpc.d.ts +8 -1
- package/dist/cross-extension-rpc.js +59 -5
- package/dist/custom-agents.d.ts +34 -9
- package/dist/custom-agents.js +308 -111
- package/dist/default-agents.d.ts +1 -1
- package/dist/env.d.ts +1 -1
- package/dist/error-log.d.ts +6 -0
- package/dist/error-log.js +8 -0
- package/dist/force-main-model.d.ts +21 -0
- package/dist/force-main-model.js +28 -0
- package/dist/goal-bridge.d.ts +155 -0
- package/dist/goal-bridge.js +305 -0
- package/dist/group-join.d.ts +5 -1
- package/dist/group-join.js +52 -7
- package/dist/index.d.ts +5 -5
- package/dist/index.js +2827 -333
- package/dist/invocation-config.d.ts +30 -3
- package/dist/invocation-config.js +30 -1
- package/dist/memory.d.ts +1 -1
- package/dist/mention-clone.d.ts +1 -1
- package/dist/model-scope.d.ts +1 -1
- package/dist/nested-tools.d.ts +22 -1
- package/dist/nested-tools.js +120 -26
- package/dist/output-file.d.ts +15 -4
- package/dist/output-file.js +146 -43
- package/dist/prompts.d.ts +1 -1
- package/dist/recovery.d.ts +1 -1
- package/dist/report-cleanup.d.ts +204 -0
- package/dist/report-cleanup.js +1632 -0
- package/dist/report-store.d.ts +738 -0
- package/dist/report-store.js +3612 -0
- package/dist/schedule-store.d.ts +14 -6
- package/dist/schedule-store.js +88 -58
- package/dist/schedule.d.ts +20 -8
- package/dist/schedule.js +135 -74
- package/dist/settings.d.ts +39 -11
- package/dist/settings.js +22 -5
- package/dist/status-note.d.ts +1 -1
- package/dist/structured-output.d.ts +1 -1
- package/dist/types.d.ts +32 -3
- package/dist/ui/agent-mention.d.ts +2 -2
- package/dist/ui/agent-widget.d.ts +82 -13
- package/dist/ui/agent-widget.js +155 -37
- package/dist/ui/cleanup-preview.d.ts +59 -0
- package/dist/ui/cleanup-preview.js +466 -0
- package/dist/ui/conversation-viewer.d.ts +4 -4
- package/dist/ui/conversation-viewer.js +10 -6
- package/dist/ui/fleet-list.d.ts +3 -3
- package/dist/ui/fleet-list.js +3 -3
- package/dist/ui/fleet-overlay.d.ts +37 -6
- package/dist/ui/fleet-overlay.js +214 -18
- package/dist/ui/hub-feed.d.ts +52 -0
- package/dist/ui/hub-feed.js +148 -0
- package/dist/ui/native-transcript.js +5 -1
- package/dist/ui/schedule-menu.d.ts +1 -1
- package/dist/ui/schedule-menu.js +1 -1
- package/dist/ui/workflow-card.d.ts +4 -4
- package/dist/ui/workflow-dialog.d.ts +4 -4
- package/dist/ui/workflow-dialog.js +8 -3
- package/dist/ui/workflow-menu.d.ts +2 -2
- package/dist/usage.d.ts +12 -0
- package/dist/usage.js +28 -1
- package/dist/workflow/entry.d.ts +3 -3
- package/dist/workflow/host.d.ts +7 -4
- package/dist/workflow/host.js +162 -48
- package/dist/workflow/journal.d.ts +23 -7
- package/dist/workflow/journal.js +80 -23
- package/dist/workflow/progress.d.ts +1 -1
- package/dist/workflow/runtime.d.ts +45 -6
- package/dist/workflow/runtime.js +105 -16
- package/dist/workflow/task.d.ts +13 -4
- package/dist/workflow/task.js +7 -1
- package/dist/workflow/tool-description.d.ts +7 -2
- package/dist/workflow/tool-description.js +10 -5
- package/docs/{FORK.md → DEVELOPMENT.md} +4 -4
- package/docs/artifacts.md +93 -0
- package/docs/rpc.md +252 -189
- package/docs/runtime-performance.md +53 -0
- package/docs/workflows.md +48 -18
- package/examples/agent-tool-description.md +2 -2
- package/examples/workflows/review-panel.js +6 -3
- package/package.json +5 -5
- package/src/active-agents-prompt.ts +115 -39
- package/src/agent-color.ts +10 -2
- package/src/agent-file-toggle.ts +2 -2
- package/src/agent-manager.ts +3312 -1601
- package/src/agent-runner.ts +164 -36
- package/src/agent-types.ts +56 -11
- package/src/awaited-result.ts +187 -0
- package/src/child-session-shutdown.ts +114 -46
- package/src/cleanup-plans.ts +112 -0
- package/src/cross-extension-rpc.ts +68 -9
- package/src/custom-agents.ts +384 -112
- package/src/default-agents.ts +1 -1
- package/src/enabled-models.ts +1 -1
- package/src/env.ts +1 -1
- package/src/error-log.ts +10 -1
- package/src/force-main-model.ts +29 -0
- package/src/goal-bridge.ts +468 -0
- package/src/group-join.ts +56 -9
- package/src/index.ts +2987 -349
- package/src/invocation-config.ts +50 -4
- package/src/memory.ts +1 -1
- package/src/mention-clone.ts +3 -3
- package/src/model-scope.ts +1 -1
- package/src/nested-tools.ts +164 -33
- package/src/output-file.ts +168 -46
- package/src/prompts.ts +1 -1
- package/src/recovery.ts +2 -2
- package/src/report-cleanup.ts +2044 -0
- package/src/report-store.ts +4130 -0
- package/src/schedule-store.ts +244 -201
- package/src/schedule.ts +144 -80
- package/src/settings.ts +61 -16
- package/src/skill-loader.ts +1 -1
- package/src/standalone-fallback.ts +2 -2
- package/src/status-note.ts +1 -1
- package/src/structured-output.ts +1 -1
- package/src/types.ts +33 -3
- package/src/ui/agent-mention.ts +3 -3
- package/src/ui/agent-widget.ts +179 -45
- package/src/ui/cleanup-preview.ts +518 -0
- package/src/ui/conversation-viewer.ts +19 -15
- package/src/ui/fleet-list.ts +7 -7
- package/src/ui/fleet-overlay.ts +1048 -847
- package/src/ui/hub-feed.ts +179 -0
- package/src/ui/native-transcript.ts +7 -3
- package/src/ui/schedule-menu.ts +4 -4
- package/src/ui/workflow-card.ts +4 -4
- package/src/ui/workflow-dialog.ts +10 -6
- package/src/ui/workflow-menu.ts +4 -4
- package/src/usage.ts +53 -3
- package/src/workflow/collisions.ts +1 -1
- package/src/workflow/entry.ts +3 -3
- package/src/workflow/host.ts +174 -54
- package/src/workflow/journal.ts +80 -23
- package/src/workflow/progress.ts +1 -1
- package/src/workflow/runtime.ts +146 -23
- package/src/workflow/saved.ts +3 -3
- package/src/workflow/task.ts +18 -7
- package/src/workflow/tool-description.ts +10 -5
package/dist/schedule-store.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* mutation acquires a PID-based exclusion lock, re-reads the latest state
|
|
10
10
|
* from disk, applies the change, atomic-writes via temp+rename, releases.
|
|
11
11
|
*/
|
|
12
|
-
import type { ScheduledSubagent } from "./types.
|
|
12
|
+
import type { ScheduledSubagent } from "./types.ts";
|
|
13
13
|
/**
|
|
14
14
|
* A lock older than this is stale whatever its PID says: Windows reuses PIDs
|
|
15
15
|
* aggressively, so "that process is alive" does not mean it holds the lock.
|
|
@@ -25,8 +25,14 @@ export declare class ScheduleStore {
|
|
|
25
25
|
constructor(filePath: string);
|
|
26
26
|
/** Create the backing directory lazily — only when we're about to persist. */
|
|
27
27
|
private ensureDir;
|
|
28
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* One cold synchronous read preserves the synchronous constructor and the
|
|
30
|
+
* list/get snapshot API. Every reload on a mutation path uses async I/O.
|
|
31
|
+
*/
|
|
32
|
+
private loadInitial;
|
|
33
|
+
/** Reload from disk into the in-memory cache. Silent on parse errors. */
|
|
29
34
|
private load;
|
|
35
|
+
private replaceJobs;
|
|
30
36
|
/** Atomic write via temp file + rename (POSIX-atomic). */
|
|
31
37
|
private save;
|
|
32
38
|
/** Acquire lock → reload → mutate → save → release. */
|
|
@@ -36,9 +42,11 @@ export declare class ScheduleStore {
|
|
|
36
42
|
/** Read-only check — uses the cache. */
|
|
37
43
|
hasName(name: string, exceptId?: string): boolean;
|
|
38
44
|
get(id: string): ScheduledSubagent | undefined;
|
|
39
|
-
add(job: ScheduledSubagent): void
|
|
40
|
-
|
|
41
|
-
|
|
45
|
+
add(job: ScheduledSubagent): Promise<void>;
|
|
46
|
+
/** Atomically re-check the latest committed names and insert only if unique. */
|
|
47
|
+
addUnlessNameExists(job: ScheduledSubagent): Promise<boolean>;
|
|
48
|
+
update(id: string, patch: Partial<ScheduledSubagent>): Promise<ScheduledSubagent | undefined>;
|
|
49
|
+
remove(id: string): Promise<boolean>;
|
|
42
50
|
/** Delete the backing file (used when no jobs remain, optional cleanup). */
|
|
43
|
-
deleteFileIfEmpty(): void
|
|
51
|
+
deleteFileIfEmpty(): Promise<void>;
|
|
44
52
|
}
|
package/dist/schedule-store.js
CHANGED
|
@@ -10,10 +10,12 @@
|
|
|
10
10
|
* from disk, applies the change, atomic-writes via temp+rename, releases.
|
|
11
11
|
*/
|
|
12
12
|
import { randomBytes } from "node:crypto";
|
|
13
|
-
import {
|
|
13
|
+
import { readFileSync } from "node:fs";
|
|
14
|
+
import { mkdir, readFile, rename, stat, unlink, writeFile } from "node:fs/promises";
|
|
14
15
|
import { dirname, join } from "node:path";
|
|
16
|
+
import { setTimeout as sleep } from "node:timers/promises";
|
|
15
17
|
const LOCK_RETRY_MS = 50;
|
|
16
|
-
/** Total
|
|
18
|
+
/** Total asynchronous wait for the lock. */
|
|
17
19
|
const LOCK_MAX_WAIT_MS = 1000;
|
|
18
20
|
/**
|
|
19
21
|
* A lock older than this is stale whatever its PID says: Windows reuses PIDs
|
|
@@ -23,10 +25,6 @@ const LOCK_MAX_WAIT_MS = 1000;
|
|
|
23
25
|
export const LOCK_STALE_MS = 30_000;
|
|
24
26
|
const RENAME_RETRIES = 5;
|
|
25
27
|
const RENAME_RETRY_MS = 20;
|
|
26
|
-
/** Block the thread without spinning the CPU. */
|
|
27
|
-
function sleepSync(ms) {
|
|
28
|
-
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
|
29
|
-
}
|
|
30
28
|
function isProcessRunning(pid) {
|
|
31
29
|
try {
|
|
32
30
|
process.kill(pid, 0);
|
|
@@ -41,11 +39,11 @@ function errorCode(e) {
|
|
|
41
39
|
return typeof code === "string" ? code : undefined;
|
|
42
40
|
}
|
|
43
41
|
/** True when the existing lock file can be broken: too old, or its owner is gone. */
|
|
44
|
-
function isLockStale(lockPath) {
|
|
42
|
+
async function isLockStale(lockPath) {
|
|
45
43
|
try {
|
|
46
|
-
if (Date.now() -
|
|
44
|
+
if (Date.now() - (await stat(lockPath)).mtimeMs > LOCK_STALE_MS)
|
|
47
45
|
return true;
|
|
48
|
-
const pid = parseInt(
|
|
46
|
+
const pid = parseInt(await readFile(lockPath, "utf-8"), 10);
|
|
49
47
|
return Number.isInteger(pid) && pid > 0 && !isProcessRunning(pid);
|
|
50
48
|
}
|
|
51
49
|
catch (e) {
|
|
@@ -53,20 +51,20 @@ function isLockStale(lockPath) {
|
|
|
53
51
|
return errorCode(e) === "ENOENT";
|
|
54
52
|
}
|
|
55
53
|
}
|
|
56
|
-
function acquireLock(lockPath) {
|
|
54
|
+
async function acquireLock(lockPath) {
|
|
57
55
|
const deadline = Date.now() + LOCK_MAX_WAIT_MS;
|
|
58
56
|
for (;;) {
|
|
59
57
|
try {
|
|
60
|
-
|
|
58
|
+
await writeFile(lockPath, `${process.pid}`, { flag: "wx" });
|
|
61
59
|
return;
|
|
62
60
|
}
|
|
63
61
|
catch (e) {
|
|
64
62
|
if (errorCode(e) !== "EEXIST")
|
|
65
63
|
throw e;
|
|
66
64
|
}
|
|
67
|
-
if (isLockStale(lockPath)) {
|
|
65
|
+
if (await isLockStale(lockPath)) {
|
|
68
66
|
try {
|
|
69
|
-
|
|
67
|
+
await unlink(lockPath);
|
|
70
68
|
}
|
|
71
69
|
catch (e) {
|
|
72
70
|
if (errorCode(e) !== "ENOENT")
|
|
@@ -76,41 +74,44 @@ function acquireLock(lockPath) {
|
|
|
76
74
|
}
|
|
77
75
|
if (Date.now() >= deadline)
|
|
78
76
|
break;
|
|
79
|
-
|
|
77
|
+
await sleep(LOCK_RETRY_MS);
|
|
80
78
|
}
|
|
81
79
|
throw new Error(`Failed to acquire schedule lock: ${lockPath}`);
|
|
82
80
|
}
|
|
83
81
|
/** rename with a bounded retry: Windows reports EPERM/EBUSY while AV or an indexer holds the target. */
|
|
84
|
-
function renameWithRetry(from, to) {
|
|
82
|
+
async function renameWithRetry(from, to) {
|
|
85
83
|
for (let attempt = 0;; attempt++) {
|
|
86
84
|
try {
|
|
87
|
-
|
|
85
|
+
await rename(from, to);
|
|
88
86
|
return;
|
|
89
87
|
}
|
|
90
88
|
catch (e) {
|
|
91
89
|
const code = errorCode(e);
|
|
92
90
|
const transient = code === "EPERM" || code === "EBUSY" || code === "EACCES";
|
|
93
91
|
if (!transient || attempt >= RENAME_RETRIES) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
catch { /* best effort: the rename error below is the one that matters */ }
|
|
92
|
+
// Best effort: the rename error below is the one that matters.
|
|
93
|
+
await unlink(from).catch(() => undefined);
|
|
98
94
|
throw e;
|
|
99
95
|
}
|
|
100
|
-
|
|
96
|
+
await sleep(RENAME_RETRY_MS * (attempt + 1));
|
|
101
97
|
}
|
|
102
98
|
}
|
|
103
99
|
}
|
|
104
|
-
function releaseLock(lockPath) {
|
|
105
|
-
|
|
106
|
-
unlinkSync(lockPath);
|
|
107
|
-
}
|
|
108
|
-
catch { /* ignore */ }
|
|
100
|
+
async function releaseLock(lockPath) {
|
|
101
|
+
await unlink(lockPath).catch(() => undefined);
|
|
109
102
|
}
|
|
110
103
|
/** Resolve the storage path for a session-scoped store. */
|
|
111
104
|
export function resolveStorePath(cwd, sessionId) {
|
|
112
105
|
return join(cwd, ".pi", "subagent-schedules", `${sessionId}.json`);
|
|
113
106
|
}
|
|
107
|
+
function parseStoreData(serialized) {
|
|
108
|
+
try {
|
|
109
|
+
return JSON.parse(serialized);
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
return undefined;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
114
115
|
export class ScheduleStore {
|
|
115
116
|
filePath;
|
|
116
117
|
lockPath;
|
|
@@ -118,44 +119,68 @@ export class ScheduleStore {
|
|
|
118
119
|
constructor(filePath) {
|
|
119
120
|
this.filePath = filePath;
|
|
120
121
|
this.lockPath = filePath + ".lock";
|
|
121
|
-
this.
|
|
122
|
+
this.loadInitial();
|
|
122
123
|
}
|
|
123
124
|
/** Create the backing directory lazily — only when we're about to persist. */
|
|
124
|
-
ensureDir() {
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
|
|
129
|
-
|
|
125
|
+
async ensureDir() {
|
|
126
|
+
await mkdir(dirname(this.filePath), { recursive: true });
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* One cold synchronous read preserves the synchronous constructor and the
|
|
130
|
+
* list/get snapshot API. Every reload on a mutation path uses async I/O.
|
|
131
|
+
*/
|
|
132
|
+
loadInitial() {
|
|
133
|
+
let serialized;
|
|
134
|
+
try {
|
|
135
|
+
serialized = readFileSync(this.filePath, "utf-8");
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
130
138
|
return;
|
|
139
|
+
}
|
|
140
|
+
const data = parseStoreData(serialized);
|
|
141
|
+
if (data)
|
|
142
|
+
this.replaceJobs(data);
|
|
143
|
+
}
|
|
144
|
+
/** Reload from disk into the in-memory cache. Silent on parse errors. */
|
|
145
|
+
async load() {
|
|
146
|
+
let serialized;
|
|
131
147
|
try {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
148
|
+
serialized = await readFile(this.filePath, "utf-8");
|
|
149
|
+
}
|
|
150
|
+
catch (e) {
|
|
151
|
+
if (errorCode(e) === "ENOENT")
|
|
152
|
+
return;
|
|
153
|
+
throw e;
|
|
136
154
|
}
|
|
137
|
-
|
|
155
|
+
const data = parseStoreData(serialized);
|
|
156
|
+
if (data)
|
|
157
|
+
this.replaceJobs(data);
|
|
158
|
+
}
|
|
159
|
+
replaceJobs(data) {
|
|
160
|
+
this.jobs.clear();
|
|
161
|
+
for (const j of data.jobs ?? [])
|
|
162
|
+
this.jobs.set(j.id, j);
|
|
138
163
|
}
|
|
139
164
|
/** Atomic write via temp file + rename (POSIX-atomic). */
|
|
140
|
-
save() {
|
|
165
|
+
async save() {
|
|
141
166
|
const data = { version: 1, jobs: [...this.jobs.values()] };
|
|
142
167
|
// Unique per write, so two writers can never clobber each other's temp file.
|
|
143
168
|
const tmp = `${this.filePath}.${process.pid}.${randomBytes(4).toString("hex")}.tmp`;
|
|
144
|
-
|
|
145
|
-
renameWithRetry(tmp, this.filePath);
|
|
169
|
+
await writeFile(tmp, JSON.stringify(data, null, 2));
|
|
170
|
+
await renameWithRetry(tmp, this.filePath);
|
|
146
171
|
}
|
|
147
172
|
/** Acquire lock → reload → mutate → save → release. */
|
|
148
|
-
withLock(fn) {
|
|
149
|
-
this.ensureDir();
|
|
150
|
-
acquireLock(this.lockPath);
|
|
173
|
+
async withLock(fn) {
|
|
174
|
+
await this.ensureDir();
|
|
175
|
+
await acquireLock(this.lockPath);
|
|
151
176
|
try {
|
|
152
|
-
this.load();
|
|
177
|
+
await this.load();
|
|
153
178
|
const result = fn();
|
|
154
|
-
this.save();
|
|
179
|
+
await this.save();
|
|
155
180
|
return result;
|
|
156
181
|
}
|
|
157
182
|
finally {
|
|
158
|
-
releaseLock(this.lockPath);
|
|
183
|
+
await releaseLock(this.lockPath);
|
|
159
184
|
}
|
|
160
185
|
}
|
|
161
186
|
/** Read-only — returns a snapshot of the in-memory cache. */
|
|
@@ -173,12 +198,21 @@ export class ScheduleStore {
|
|
|
173
198
|
get(id) {
|
|
174
199
|
return this.jobs.get(id);
|
|
175
200
|
}
|
|
176
|
-
add(job) {
|
|
177
|
-
this.withLock(() => {
|
|
201
|
+
async add(job) {
|
|
202
|
+
await this.withLock(() => {
|
|
203
|
+
this.jobs.set(job.id, job);
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
/** Atomically re-check the latest committed names and insert only if unique. */
|
|
207
|
+
async addUnlessNameExists(job) {
|
|
208
|
+
return this.withLock(() => {
|
|
209
|
+
if (this.hasName(job.name))
|
|
210
|
+
return false;
|
|
178
211
|
this.jobs.set(job.id, job);
|
|
212
|
+
return true;
|
|
179
213
|
});
|
|
180
214
|
}
|
|
181
|
-
update(id, patch) {
|
|
215
|
+
async update(id, patch) {
|
|
182
216
|
// No-op fast path — an unknown id changes nothing, so don't lock or touch
|
|
183
217
|
// disk (which would otherwise lazily create the backing directory).
|
|
184
218
|
if (!this.jobs.has(id))
|
|
@@ -192,19 +226,15 @@ export class ScheduleStore {
|
|
|
192
226
|
return updated;
|
|
193
227
|
});
|
|
194
228
|
}
|
|
195
|
-
remove(id) {
|
|
229
|
+
async remove(id) {
|
|
196
230
|
// No-op fast path — see update().
|
|
197
231
|
if (!this.jobs.has(id))
|
|
198
232
|
return false;
|
|
199
233
|
return this.withLock(() => this.jobs.delete(id));
|
|
200
234
|
}
|
|
201
235
|
/** Delete the backing file (used when no jobs remain, optional cleanup). */
|
|
202
|
-
deleteFileIfEmpty() {
|
|
203
|
-
if (this.jobs.size === 0
|
|
204
|
-
|
|
205
|
-
unlinkSync(this.filePath);
|
|
206
|
-
}
|
|
207
|
-
catch { /* ignore */ }
|
|
208
|
-
}
|
|
236
|
+
async deleteFileIfEmpty() {
|
|
237
|
+
if (this.jobs.size === 0)
|
|
238
|
+
await unlink(this.filePath).catch(() => undefined);
|
|
209
239
|
}
|
|
210
240
|
}
|
package/dist/schedule.d.ts
CHANGED
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
* `subagent-notification` followUp path. No new delivery code.
|
|
16
16
|
*/
|
|
17
17
|
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
18
|
-
import type { AgentManager } from "./agent-manager.
|
|
19
|
-
import type { ScheduleStore } from "./schedule-store.
|
|
20
|
-
import type { IsolationMode, ScheduledSubagent, SubagentType, ThinkingLevel } from "./types.
|
|
18
|
+
import type { AgentManager } from "./agent-manager.ts";
|
|
19
|
+
import type { ScheduleStore } from "./schedule-store.ts";
|
|
20
|
+
import type { IsolationMode, ScheduledSubagent, SubagentType, ThinkingLevel } from "./types.ts";
|
|
21
21
|
/** Event emitted on `pi.events` for cross-extension consumers. */
|
|
22
22
|
export type ScheduleChangeEvent = {
|
|
23
23
|
type: "added";
|
|
@@ -33,6 +33,11 @@ export type ScheduleChangeEvent = {
|
|
|
33
33
|
jobId: string;
|
|
34
34
|
agentId: string;
|
|
35
35
|
name: string;
|
|
36
|
+
} | {
|
|
37
|
+
type: "skipped";
|
|
38
|
+
jobId: string;
|
|
39
|
+
name: string;
|
|
40
|
+
reason: "overlap";
|
|
36
41
|
} | {
|
|
37
42
|
type: "error";
|
|
38
43
|
jobId: string;
|
|
@@ -54,6 +59,7 @@ export interface NewJobInput {
|
|
|
54
59
|
export declare class SubagentScheduler {
|
|
55
60
|
private jobs;
|
|
56
61
|
private intervals;
|
|
62
|
+
private activeRuns;
|
|
57
63
|
private store;
|
|
58
64
|
private pi;
|
|
59
65
|
private ctx;
|
|
@@ -71,20 +77,26 @@ export declare class SubagentScheduler {
|
|
|
71
77
|
*/
|
|
72
78
|
buildJob(input: NewJobInput): ScheduledSubagent;
|
|
73
79
|
/** Add a job, persist, and arm if enabled. Returns the stored job. */
|
|
74
|
-
addJob(input: NewJobInput): ScheduledSubagent
|
|
75
|
-
removeJob(id: string): boolean
|
|
80
|
+
addJob(input: NewJobInput): Promise<ScheduledSubagent>;
|
|
81
|
+
removeJob(id: string): Promise<boolean>;
|
|
76
82
|
/** Toggle / mutate a job. Re-arms based on the new `enabled` state. */
|
|
77
|
-
updateJob(id: string, patch: Partial<ScheduledSubagent>): ScheduledSubagent | undefined
|
|
83
|
+
updateJob(id: string, patch: Partial<ScheduledSubagent>): Promise<ScheduledSubagent | undefined>;
|
|
78
84
|
/** Next-run time as ISO, or undefined if not currently armed. */
|
|
79
85
|
getNextRun(jobId: string): string | undefined;
|
|
80
86
|
private scheduleJob;
|
|
87
|
+
private dispatchJob;
|
|
88
|
+
private executeOnce;
|
|
89
|
+
private disableJobWithError;
|
|
81
90
|
private unscheduleJob;
|
|
82
91
|
/**
|
|
83
92
|
* Fire a job: persist running state, spawn (bypassing the concurrency
|
|
84
|
-
* queue), persist completion.
|
|
85
|
-
*
|
|
93
|
+
* queue), persist completion. The in-memory guard covers the complete run,
|
|
94
|
+
* so persisted `running` state from a previous process never blocks recovery.
|
|
86
95
|
*/
|
|
87
96
|
private executeJob;
|
|
97
|
+
private finalizeRun;
|
|
98
|
+
private recordRunError;
|
|
99
|
+
private reportError;
|
|
88
100
|
private emit;
|
|
89
101
|
private requireStore;
|
|
90
102
|
/**
|