@deathbeam/pi-delegate 0.0.17 → 0.0.19
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/README.md +5 -3
- package/agents.ts +115 -0
- package/child.ts +37 -8
- package/format.ts +23 -14
- package/index.ts +123 -456
- package/inspector.ts +235 -0
- package/package.json +5 -2
- package/store.ts +163 -0
package/inspector.ts
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { type ExtensionAPI, getMarkdownTheme, keyHint, rawKeyHint } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { HStack, Markdown, matchesKey, truncateToWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
|
|
3
|
+
import type { ChildActivity } from "./child.ts";
|
|
4
|
+
import { formatTools, jobIdentity, STATUS_COLORS, statusText, usageStats } from "./format.ts";
|
|
5
|
+
import type { InspectJob, JobStore } from "./store.ts";
|
|
6
|
+
|
|
7
|
+
/** The /delegate command: a full-screen inspector over the job store. */
|
|
8
|
+
export function registerInspector(pi: ExtensionAPI, store: JobStore) {
|
|
9
|
+
pi.registerCommand("delegate", {
|
|
10
|
+
description: "Inspect live and recent delegate activity",
|
|
11
|
+
handler: async (_args, ctx) => {
|
|
12
|
+
if (ctx.mode !== "tui") return;
|
|
13
|
+
if (!store.all().length) {
|
|
14
|
+
ctx.ui.notify("No delegates in this session yet.", "info");
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const screen = {
|
|
18
|
+
overlay: true,
|
|
19
|
+
overlayOptions: { width: "100%", maxHeight: "100%", row: 0, col: 0 },
|
|
20
|
+
} as const;
|
|
21
|
+
let stopRedraw: (() => void) | undefined;
|
|
22
|
+
try {
|
|
23
|
+
await ctx.ui.custom((tui, theme, keys, done) => {
|
|
24
|
+
let selectedId = store.all()[0]!.id;
|
|
25
|
+
let focus: "list" | "history" = "list";
|
|
26
|
+
let top: number | undefined;
|
|
27
|
+
let historyWidth = 1;
|
|
28
|
+
let markdown = new WeakMap<ChildActivity, Markdown>();
|
|
29
|
+
const jobs = () => store.all();
|
|
30
|
+
// Fixed rows: title, top rule, bottom rule, footer.
|
|
31
|
+
const bodyHeight = () => Math.max(0, tui.terminal.rows - 4);
|
|
32
|
+
const toolsLines = (job: InspectJob, width: number) =>
|
|
33
|
+
wrapTextWithAnsi(formatTools(job.tools), Math.max(1, width)).map((line) =>
|
|
34
|
+
theme.fg("dim", line),
|
|
35
|
+
);
|
|
36
|
+
// Fixed rows: header, model, description, rule, counter.
|
|
37
|
+
const historyHeight = (job: InspectJob, width: number) =>
|
|
38
|
+
Math.max(0, bodyHeight() - 5 - toolsLines(job, width).length);
|
|
39
|
+
// ScrollView needs fullscreen layout; window the history in regular TUI too.
|
|
40
|
+
const renderJobs = (width: number, items: InspectJob[], selectedIndex: number): string[] => {
|
|
41
|
+
const row = (text: string) =>
|
|
42
|
+
truncateToWidth(text, Math.max(0, width - 1), "…", true) + theme.fg("borderMuted", "│");
|
|
43
|
+
const visible = Math.max(1, Math.floor((bodyHeight() - 1) / 3));
|
|
44
|
+
const start = Math.max(
|
|
45
|
+
0,
|
|
46
|
+
Math.min(selectedIndex - Math.floor(visible / 2), items.length - visible),
|
|
47
|
+
);
|
|
48
|
+
const lines = items
|
|
49
|
+
.slice(start, start + visible)
|
|
50
|
+
.flatMap((item, index) => [
|
|
51
|
+
row(
|
|
52
|
+
`${theme.fg(start + index === selectedIndex && focus === "list" ? "accent" : "text", start + index === selectedIndex ? "›" : " ")} ${statusText(theme, item.status)} ${jobIdentity(theme, item)}`,
|
|
53
|
+
),
|
|
54
|
+
row(theme.fg("muted", ` ${item.description}`)),
|
|
55
|
+
row(
|
|
56
|
+
theme.fg(
|
|
57
|
+
"muted",
|
|
58
|
+
` ${usageStats(item, (item.endedAt ?? Date.now()) - item.startedAt)}`,
|
|
59
|
+
),
|
|
60
|
+
),
|
|
61
|
+
]);
|
|
62
|
+
return [
|
|
63
|
+
...lines,
|
|
64
|
+
...Array(Math.max(0, bodyHeight() - 1 - lines.length)).fill(row("")),
|
|
65
|
+
row(theme.fg("dim", `${selectedIndex + 1}/${items.length}`)),
|
|
66
|
+
].slice(0, bodyHeight());
|
|
67
|
+
};
|
|
68
|
+
const renderEntry = (entry: ChildActivity, width: number): string[] => {
|
|
69
|
+
if (entry.kind === "assistant" || entry.kind === "user") {
|
|
70
|
+
let md = markdown.get(entry);
|
|
71
|
+
if (!md) {
|
|
72
|
+
md = new Markdown(entry.text, 0, 0, getMarkdownTheme());
|
|
73
|
+
markdown.set(entry, md);
|
|
74
|
+
}
|
|
75
|
+
return [theme.fg("accent", entry.kind), ...md.render(width), ""];
|
|
76
|
+
}
|
|
77
|
+
if (entry.kind === "tool")
|
|
78
|
+
return [
|
|
79
|
+
truncateToWidth(
|
|
80
|
+
theme.fg("toolTitle", entry.text) +
|
|
81
|
+
(entry.detail ? ` ${theme.fg("accent", entry.detail)}` : ""),
|
|
82
|
+
width,
|
|
83
|
+
),
|
|
84
|
+
];
|
|
85
|
+
if (entry.kind === "result") return [truncateToWidth(theme.fg("text", entry.text), width)];
|
|
86
|
+
// Only failure detail still says anything; the header icon carries the status.
|
|
87
|
+
if (!entry.text) return [];
|
|
88
|
+
return [truncateToWidth(theme.fg(STATUS_COLORS.failed, entry.text), width)];
|
|
89
|
+
};
|
|
90
|
+
const renderHistory = (width: number, job: InspectJob): string[] => {
|
|
91
|
+
historyWidth = width;
|
|
92
|
+
const tools = toolsLines(job, width);
|
|
93
|
+
const height = historyHeight(job, width);
|
|
94
|
+
const history = job.activity.flatMap((entry) => renderEntry(entry, width));
|
|
95
|
+
const maxTop = Math.max(0, history.length - height);
|
|
96
|
+
const start = Math.min(top ?? maxTop, maxTop);
|
|
97
|
+
const visible = history.slice(start, start + height);
|
|
98
|
+
const shown = visible.length
|
|
99
|
+
? visible
|
|
100
|
+
: height
|
|
101
|
+
? [
|
|
102
|
+
theme.fg(
|
|
103
|
+
"muted",
|
|
104
|
+
job.status === "interrupted"
|
|
105
|
+
? "Interrupted by a crash before activity was recorded."
|
|
106
|
+
: "Waiting for activity…",
|
|
107
|
+
),
|
|
108
|
+
]
|
|
109
|
+
: [];
|
|
110
|
+
return [
|
|
111
|
+
truncateToWidth(`${statusText(theme, job.status)} ${jobIdentity(theme, job)}`, width),
|
|
112
|
+
truncateToWidth(theme.fg("dim", job.model), width),
|
|
113
|
+
...tools,
|
|
114
|
+
truncateToWidth(theme.fg("text", theme.bold(job.description)), width),
|
|
115
|
+
theme.fg("borderMuted", "─".repeat(Math.max(0, width))),
|
|
116
|
+
...shown,
|
|
117
|
+
...Array(Math.max(0, height - shown.length)).fill(""),
|
|
118
|
+
truncateToWidth(
|
|
119
|
+
theme.fg(
|
|
120
|
+
"dim",
|
|
121
|
+
`${visible.length ? `${start + 1}–${start + visible.length}` : "0"}/${history.length}`,
|
|
122
|
+
),
|
|
123
|
+
width,
|
|
124
|
+
),
|
|
125
|
+
].slice(0, bodyHeight());
|
|
126
|
+
};
|
|
127
|
+
stopRedraw = store.subscribe(() => tui.requestRender());
|
|
128
|
+
return {
|
|
129
|
+
render(width: number) {
|
|
130
|
+
const items = jobs();
|
|
131
|
+
const selectedIndex = Math.max(
|
|
132
|
+
0,
|
|
133
|
+
items.findIndex((item) => item.id === selectedId),
|
|
134
|
+
);
|
|
135
|
+
const selected = items[selectedIndex];
|
|
136
|
+
const title = truncateToWidth(
|
|
137
|
+
`${theme.fg(focus === "list" ? "accent" : "muted", focus === "list" ? "[Jobs]" : "Jobs")} ` +
|
|
138
|
+
`${theme.fg(focus === "history" ? "accent" : "muted", focus === "history" ? "[Activity]" : "Activity")}` +
|
|
139
|
+
theme.fg("dim", ` · ${store.live().length} running · ${items.length} total`),
|
|
140
|
+
width,
|
|
141
|
+
);
|
|
142
|
+
const footer = truncateToWidth(
|
|
143
|
+
theme.fg(
|
|
144
|
+
"dim",
|
|
145
|
+
`${keyHint("tui.select.up", "up")} · ${keyHint("tui.select.down", "down")} · ${rawKeyHint("←/→", "switch pane")} · ${keyHint("tui.select.cancel", "close")}`,
|
|
146
|
+
),
|
|
147
|
+
width,
|
|
148
|
+
);
|
|
149
|
+
if (!selected)
|
|
150
|
+
return [
|
|
151
|
+
title,
|
|
152
|
+
theme.fg("muted", "No delegates in this session."),
|
|
153
|
+
// Fixed rows: title, top rule, bottom rule, footer.
|
|
154
|
+
...Array(Math.max(0, tui.terminal.rows - 4)).fill(""),
|
|
155
|
+
footer,
|
|
156
|
+
].slice(0, tui.terminal.rows);
|
|
157
|
+
const sidebarWidth = Math.min(
|
|
158
|
+
40,
|
|
159
|
+
Math.max(16, Math.floor(width * 0.35)),
|
|
160
|
+
Math.max(1, width - 2),
|
|
161
|
+
);
|
|
162
|
+
const body = new HStack(
|
|
163
|
+
[
|
|
164
|
+
{
|
|
165
|
+
component: {
|
|
166
|
+
render: (w) => renderJobs(w, items, selectedIndex),
|
|
167
|
+
invalidate() {},
|
|
168
|
+
},
|
|
169
|
+
basis: sidebarWidth,
|
|
170
|
+
shrink: 0,
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
component: { render: (w) => renderHistory(w, selected), invalidate() {} },
|
|
174
|
+
basis: 0,
|
|
175
|
+
grow: 1,
|
|
176
|
+
},
|
|
177
|
+
],
|
|
178
|
+
{ gap: 1 },
|
|
179
|
+
).render(width);
|
|
180
|
+
return [
|
|
181
|
+
title,
|
|
182
|
+
theme.fg("borderMuted", "─".repeat(Math.max(0, width))),
|
|
183
|
+
...body,
|
|
184
|
+
theme.fg("borderMuted", "─".repeat(Math.max(0, width))),
|
|
185
|
+
footer,
|
|
186
|
+
].slice(0, tui.terminal.rows);
|
|
187
|
+
},
|
|
188
|
+
invalidate() {
|
|
189
|
+
markdown = new WeakMap();
|
|
190
|
+
},
|
|
191
|
+
handleInput(data: string) {
|
|
192
|
+
if (keys.matches(data, "tui.select.cancel")) done(undefined);
|
|
193
|
+
else if (matchesKey(data, "left")) focus = "list";
|
|
194
|
+
else if (
|
|
195
|
+
matchesKey(data, "right") ||
|
|
196
|
+
(focus === "list" && keys.matches(data, "tui.select.confirm"))
|
|
197
|
+
)
|
|
198
|
+
focus = "history";
|
|
199
|
+
else if (keys.matches(data, "tui.select.up") || keys.matches(data, "tui.select.down")) {
|
|
200
|
+
const up = keys.matches(data, "tui.select.up");
|
|
201
|
+
const items = jobs();
|
|
202
|
+
if (focus === "list") {
|
|
203
|
+
const index = Math.max(
|
|
204
|
+
0,
|
|
205
|
+
items.findIndex((item) => item.id === selectedId),
|
|
206
|
+
);
|
|
207
|
+
selectedId =
|
|
208
|
+
items[Math.max(0, Math.min(items.length - 1, index + (up ? -1 : 1)))]?.id ??
|
|
209
|
+
selectedId;
|
|
210
|
+
top = undefined;
|
|
211
|
+
} else {
|
|
212
|
+
const selected = items.find((item) => item.id === selectedId) ?? items[0];
|
|
213
|
+
const length =
|
|
214
|
+
selected?.activity.reduce(
|
|
215
|
+
(sum, entry) => sum + renderEntry(entry, historyWidth).length,
|
|
216
|
+
0,
|
|
217
|
+
) ?? 0;
|
|
218
|
+
const maxTop = Math.max(
|
|
219
|
+
0,
|
|
220
|
+
length - (selected ? historyHeight(selected, historyWidth) : 0),
|
|
221
|
+
);
|
|
222
|
+
const position = Math.max(0, Math.min(maxTop, top ?? maxTop) + (up ? -1 : 1));
|
|
223
|
+
top = position >= maxTop ? undefined : position;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
tui.requestRender();
|
|
227
|
+
},
|
|
228
|
+
};
|
|
229
|
+
}, screen);
|
|
230
|
+
} finally {
|
|
231
|
+
stopRedraw?.();
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
});
|
|
235
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deathbeam/pi-delegate",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.0.19",
|
|
4
|
+
"description": "Minimal extension for delegating tasks to subagents.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -18,6 +18,9 @@
|
|
|
18
18
|
},
|
|
19
19
|
"files": [
|
|
20
20
|
"index.ts",
|
|
21
|
+
"store.ts",
|
|
22
|
+
"inspector.ts",
|
|
23
|
+
"agents.ts",
|
|
21
24
|
"child.ts",
|
|
22
25
|
"format.ts",
|
|
23
26
|
"agents",
|
package/store.ts
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import type { ChildActivity, ChildUpdate } from "./child.ts";
|
|
2
|
+
|
|
3
|
+
export type JobStatus = "running" | "done" | "failed" | "cancelled" | "interrupted";
|
|
4
|
+
export type InspectJob = {
|
|
5
|
+
id: string;
|
|
6
|
+
agent: string;
|
|
7
|
+
description: string;
|
|
8
|
+
task: string;
|
|
9
|
+
model: string;
|
|
10
|
+
tools: string[];
|
|
11
|
+
toolCalls: number;
|
|
12
|
+
contextTokens?: number;
|
|
13
|
+
contextWindow?: number;
|
|
14
|
+
startedAt: number;
|
|
15
|
+
endedAt?: number;
|
|
16
|
+
status: JobStatus;
|
|
17
|
+
activity: ChildActivity[];
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type DelegateJob = InspectJob & {
|
|
21
|
+
lastTool?: string;
|
|
22
|
+
lastDetail?: string;
|
|
23
|
+
lastResult?: string;
|
|
24
|
+
controller: AbortController;
|
|
25
|
+
steer?: (message: string) => Promise<void>;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const JOB_ENTRY = "delegate-job";
|
|
29
|
+
|
|
30
|
+
/** The latest delegate-job entry per id, newest first: the append-only log's current view. */
|
|
31
|
+
function restoredJobs(entries: readonly unknown[]): InspectJob[] {
|
|
32
|
+
const seen = new Set<string>();
|
|
33
|
+
const jobs: InspectJob[] = [];
|
|
34
|
+
for (let i = entries.length - 1; i >= 0; i--) {
|
|
35
|
+
const entry = entries[i] as { type?: string; customType?: string; data?: unknown } | null;
|
|
36
|
+
if (entry?.type !== "custom" || entry.customType !== JOB_ENTRY || !entry.data) continue;
|
|
37
|
+
const job = entry.data as InspectJob;
|
|
38
|
+
if (typeof job?.id !== "string" || seen.has(job.id)) continue;
|
|
39
|
+
seen.add(job.id);
|
|
40
|
+
jobs.push(job);
|
|
41
|
+
}
|
|
42
|
+
return jobs;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Whether and how a delegate call may resume an interrupted, failed, or cancelled job. */
|
|
46
|
+
export function resumeDecision(
|
|
47
|
+
id: string,
|
|
48
|
+
jobs: readonly InspectJob[],
|
|
49
|
+
live: ReadonlySet<string>,
|
|
50
|
+
): { job?: InspectJob; error?: string } {
|
|
51
|
+
if (!id) return { error: "No job id given for resume." };
|
|
52
|
+
if (live.has(id))
|
|
53
|
+
return { error: `Delegate job "${id}" is still running; steer or cancel it instead of resuming.` };
|
|
54
|
+
const job = jobs.find((candidate) => candidate.id === id);
|
|
55
|
+
if (!job) return { error: `Unknown delegate job "${id}".` };
|
|
56
|
+
if (job.status === "interrupted" || job.status === "failed" || job.status === "cancelled") return { job };
|
|
57
|
+
if (job.status === "done")
|
|
58
|
+
return { error: `Delegate job "${id}" is already done; its report is in this session, no resume needed.` };
|
|
59
|
+
return {
|
|
60
|
+
error: `Delegate job "${id}" is ${job.status}; only interrupted, failed or cancelled jobs can be resumed.`,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** One owner for live jobs, history, and the delegate-job session entries they write. */
|
|
65
|
+
export function createJobStore(append: (customType: string, data: InspectJob) => void) {
|
|
66
|
+
const running = new Map<string, DelegateJob>();
|
|
67
|
+
const history: InspectJob[] = [];
|
|
68
|
+
const listeners = new Set<() => void>();
|
|
69
|
+
const notify = () => {
|
|
70
|
+
for (const redraw of listeners) redraw();
|
|
71
|
+
};
|
|
72
|
+
// A session_tree rebuild restores old entries; the history keeps one row per id across finish and relaunch.
|
|
73
|
+
const drop = (id: string) => {
|
|
74
|
+
const stale = history.findIndex((item) => item.id === id);
|
|
75
|
+
if (stale >= 0) history.splice(stale, 1);
|
|
76
|
+
};
|
|
77
|
+
const entryData = (job: DelegateJob): InspectJob => {
|
|
78
|
+
const { controller, steer, lastTool, lastDetail, lastResult, ...snapshot } = job;
|
|
79
|
+
// Copy activity: the live job keeps appending to its own array after the launch snapshot.
|
|
80
|
+
return { ...snapshot, activity: [...snapshot.activity] };
|
|
81
|
+
};
|
|
82
|
+
const addActivity = (job: DelegateJob, activity: ChildActivity) => {
|
|
83
|
+
const normalize = (text: string) => text.replace(/\s+/g, " ").trim();
|
|
84
|
+
job.activity.push(
|
|
85
|
+
activity.kind === "assistant" || activity.kind === "user"
|
|
86
|
+
? activity
|
|
87
|
+
: {
|
|
88
|
+
...activity,
|
|
89
|
+
text: normalize(activity.text),
|
|
90
|
+
detail: activity.detail && normalize(activity.detail),
|
|
91
|
+
},
|
|
92
|
+
);
|
|
93
|
+
notify();
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
return {
|
|
97
|
+
/** Every job a view can show: live first, then history. */
|
|
98
|
+
all: (): InspectJob[] => [...running.values(), ...history],
|
|
99
|
+
live: (): DelegateJob[] => [...running.values()],
|
|
100
|
+
find: (id: string) => running.get(id) ?? history.find((item) => item.id === id),
|
|
101
|
+
/** Writes the launch entry a restarted parent restores from; background jobs join the live set. */
|
|
102
|
+
launch: (job: DelegateJob, background: boolean) => {
|
|
103
|
+
append(JOB_ENTRY, entryData(job));
|
|
104
|
+
drop(job.id);
|
|
105
|
+
if (background) running.set(job.id, job);
|
|
106
|
+
},
|
|
107
|
+
record: (job: DelegateJob, update: ChildUpdate) => {
|
|
108
|
+
if (job.status !== "running") return;
|
|
109
|
+
if (update.toolCalls !== undefined) job.toolCalls = update.toolCalls;
|
|
110
|
+
if (update.lastTool !== undefined) job.lastTool = update.lastTool;
|
|
111
|
+
if (update.lastDetail !== undefined) job.lastDetail = update.lastDetail;
|
|
112
|
+
if (update.lastResult !== undefined) job.lastResult = update.lastResult;
|
|
113
|
+
if (update.contextTokens !== undefined) job.contextTokens = update.contextTokens;
|
|
114
|
+
// Activity feeds the live views; a foreground run reports through its tool result instead.
|
|
115
|
+
if (update.activity && running.has(job.id)) addActivity(job, update.activity);
|
|
116
|
+
},
|
|
117
|
+
/** Leaves the live set and writes the completion entry; false when the job was cancelled. */
|
|
118
|
+
finish: (job: DelegateJob, status: JobStatus, detail?: string): boolean => {
|
|
119
|
+
// Cancellation was already acknowledged; shutdown has no UI to report into.
|
|
120
|
+
if (job.controller.signal.aborted) return false;
|
|
121
|
+
running.delete(job.id);
|
|
122
|
+
job.status = status;
|
|
123
|
+
if (detail) addActivity(job, { kind: "status", text: detail });
|
|
124
|
+
const entry: InspectJob = { ...entryData(job), endedAt: Date.now() };
|
|
125
|
+
drop(entry.id);
|
|
126
|
+
history.unshift(entry);
|
|
127
|
+
append(JOB_ENTRY, entry);
|
|
128
|
+
notify();
|
|
129
|
+
return true;
|
|
130
|
+
},
|
|
131
|
+
/** Rebuilds history from the branch and returns the jobs it marked interrupted. */
|
|
132
|
+
restore: (branch: readonly unknown[]): InspectJob[] => {
|
|
133
|
+
history.length = 0;
|
|
134
|
+
// Skip live jobs' launch entries (the live set renders them); copy so session entries stay append-only.
|
|
135
|
+
const restored = restoredJobs(branch)
|
|
136
|
+
.filter((job) => !running.has(job.id))
|
|
137
|
+
.map((job) => ({ ...job }));
|
|
138
|
+
// A restored running job no live job owns means the parent crashed; the child exits on its own when
|
|
139
|
+
// the parent's stdin pipe closes, so only the job state needs fixing.
|
|
140
|
+
const interrupted = restored.filter((job) => job.status === "running");
|
|
141
|
+
for (const job of interrupted) {
|
|
142
|
+
job.status = "interrupted";
|
|
143
|
+
job.endedAt = Date.now();
|
|
144
|
+
append(JOB_ENTRY, job);
|
|
145
|
+
}
|
|
146
|
+
history.push(...restored);
|
|
147
|
+
return interrupted;
|
|
148
|
+
},
|
|
149
|
+
/** Drops all jobs and view subscriptions; called on session shutdown. */
|
|
150
|
+
clear: () => {
|
|
151
|
+
running.clear();
|
|
152
|
+
history.length = 0;
|
|
153
|
+
listeners.clear();
|
|
154
|
+
},
|
|
155
|
+
subscribe: (listener: () => void) => {
|
|
156
|
+
listeners.add(listener);
|
|
157
|
+
return () => listeners.delete(listener);
|
|
158
|
+
},
|
|
159
|
+
notify,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export type JobStore = ReturnType<typeof createJobStore>;
|