my-durable 0.0.39 → 0.0.40
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/apps/dpi-backend/src/doctor.ts +10 -8
- package/apps/dpi-backend/src/gc-cli.ts +113 -0
- package/apps/dpi-backend/src/gc.ts +142 -0
- package/apps/dpi-backend/src/routes.ts +9 -0
- package/apps/dpi-backend/src/schedule-cli.ts +211 -0
- package/apps/dpi-backend/src/schedules.ts +676 -0
- package/apps/dpi-backend/src/store.ts +151 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/assets/index-DMJMesxP.css +1 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/assets/index-jDhVa5sg.js +81 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/index.html +2 -2
- package/apps/dpi-playground/apps/dpi-playground-fe/src/client/hub.ts +2 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/client/store.ts +4 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/Inspector.vue +4 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/SchedulesPanel.vue +289 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/TreeRow.vue +13 -1
- package/apps/dpi-playground/apps/dpi-playground-hub/src/main.ts +20 -1
- package/apps/dpi-sdk/src/api.ts +46 -0
- package/apps/dpi-sdk/src/client.ts +18 -0
- package/apps/dpi-sdk/src/protocol/rest-routes.ts +6 -0
- package/bin/dpi.mjs +15 -0
- package/docs/host-project-checklist.md +4 -4
- package/package.json +1 -1
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/assets/index-CYZxCPDU.js +0 -81
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/assets/index-v7IQ7Jg5.css +0 -1
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
<meta name="referrer" content="no-referrer" />
|
|
8
8
|
<link rel="icon" type="image/svg+xml" href="/icons/durable-pi.svg" />
|
|
9
9
|
<title>Durable Pi | Network</title>
|
|
10
|
-
<script type="module" crossorigin src="/assets/index-
|
|
11
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
10
|
+
<script type="module" crossorigin src="/assets/index-jDhVa5sg.js"></script>
|
|
11
|
+
<link rel="stylesheet" crossorigin href="/assets/index-DMJMesxP.css">
|
|
12
12
|
</head>
|
|
13
13
|
<body>
|
|
14
14
|
<div id="app"></div>
|
|
@@ -26,6 +26,8 @@ async function call<T>(method: string, path: string, body?: unknown): Promise<T>
|
|
|
26
26
|
|
|
27
27
|
export const hub = {
|
|
28
28
|
network: () => call<{ configFile?: string; devices: NetworkDevice[] }>("GET", "/network"),
|
|
29
|
+
/** The hub's own version, for the "device is behind" badge. */
|
|
30
|
+
version: () => call<{ version: string; node: string }>("GET", "/version"),
|
|
29
31
|
/** Probe a device now. Devices themselves are configured in dpi-network.yaml, not here. */
|
|
30
32
|
check: (id: string) =>
|
|
31
33
|
call<NetworkDevice>("POST", `/devices/${encodeURIComponent(id)}/check`, {}),
|
|
@@ -15,6 +15,9 @@ export const streamState = ref(stream.state);
|
|
|
15
15
|
stream.onState((s) => (streamState.value = s));
|
|
16
16
|
export const network = useNetwork(stream);
|
|
17
17
|
export const configFile = ref<string>();
|
|
18
|
+
/** The hub's own version. A device reporting another one is behind (badge only:
|
|
19
|
+
* the hub never pushes code, devices self-update). */
|
|
20
|
+
export const hubVersion = ref<string>();
|
|
18
21
|
|
|
19
22
|
// ------------------------------------------------------------------ selection + persisted UI state
|
|
20
23
|
|
|
@@ -122,6 +125,7 @@ export async function boot() {
|
|
|
122
125
|
hub.uiGet<{ tree: boolean; inspector: boolean }>("layout.panels"),
|
|
123
126
|
]);
|
|
124
127
|
if (panels) Object.assign(layout, panels);
|
|
128
|
+
void hub.version().then((v) => (hubVersion.value = v.version)).catch(() => {});
|
|
125
129
|
configFile.value = net.configFile;
|
|
126
130
|
if (!network.model.devices.length)
|
|
127
131
|
network.model.apply({ type: "network", devices: net.devices });
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
Download,
|
|
7
7
|
PackageOpen,
|
|
8
8
|
PiggyBank,
|
|
9
|
+
CalendarClock,
|
|
9
10
|
GitBranch,
|
|
10
11
|
ChevronDown,
|
|
11
12
|
FolderOpen,
|
|
@@ -26,6 +27,7 @@ import TasksPanel from "./TasksPanel.vue";
|
|
|
26
27
|
import GitPanel from "./GitPanel.vue";
|
|
27
28
|
import HostPanel from "./HostPanel.vue";
|
|
28
29
|
import UsagePanel from "./UsagePanel.vue";
|
|
30
|
+
import SchedulesPanel from "./SchedulesPanel.vue";
|
|
29
31
|
import ExtensionsPanel from "./ExtensionsPanel.vue";
|
|
30
32
|
import ContextBar from "./ContextBar.vue";
|
|
31
33
|
import { deviceClient, message } from "../client/hub";
|
|
@@ -67,6 +69,7 @@ const tabs = [
|
|
|
67
69
|
{ id: "git", label: "Git", icon: GitBranch },
|
|
68
70
|
{ id: "host", label: "Host", icon: Activity },
|
|
69
71
|
{ id: "usage", label: "Usage", icon: PiggyBank },
|
|
72
|
+
{ id: "auto", label: "Auto", icon: CalendarClock },
|
|
70
73
|
{ id: "state", label: "State", icon: Braces },
|
|
71
74
|
{ id: "tasks", label: "Tasks", icon: Activity },
|
|
72
75
|
{ id: "tools", label: "Tools", icon: Wrench },
|
|
@@ -437,6 +440,7 @@ const offeredTools = computed(() => detail.value?.tools.filter((t) => t.offered)
|
|
|
437
440
|
<GitPanel v-if="ui.tab === 'git'" />
|
|
438
441
|
<HostPanel v-if="ui.tab === 'host'" />
|
|
439
442
|
<UsagePanel v-if="ui.tab === 'usage'" />
|
|
443
|
+
<SchedulesPanel v-if="ui.tab === 'auto'" />
|
|
440
444
|
<ExtensionsPanel v-if="ui.tab === 'extensions'" />
|
|
441
445
|
<template v-if="ui.tab === 'tools'"
|
|
442
446
|
><div class="panel-heading">
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
// Scheduled sessions (Wave 2): the DEVICE owns the clock — this panel only
|
|
3
|
+
// reads and edits the records over the tunnel, so the daemon runs them whether
|
|
4
|
+
// or not a browser is open. A run creates a fresh session per trigger.
|
|
5
|
+
import { computed, ref, watch } from "vue";
|
|
6
|
+
import { CalendarClock, Play, Plus, RefreshCw, Trash2, Power } from "lucide-vue-next";
|
|
7
|
+
import type { ScheduleView } from "@sdk/api";
|
|
8
|
+
import { deviceClient, message } from "../client/hub";
|
|
9
|
+
import { notify, selected, ui } from "../client/store";
|
|
10
|
+
|
|
11
|
+
const schedules = ref<ScheduleView[]>([]);
|
|
12
|
+
const busy = ref("");
|
|
13
|
+
const error = ref("");
|
|
14
|
+
const loading = ref(false);
|
|
15
|
+
const deviceId = computed(() => selected.value?.deviceId);
|
|
16
|
+
const client = () => deviceClient(deviceId.value ?? "");
|
|
17
|
+
|
|
18
|
+
const every = ref("60");
|
|
19
|
+
const daily = ref("");
|
|
20
|
+
const adding = ref(false);
|
|
21
|
+
const draft = ref({ name: "", cwd: "", prompt: "", model: "" });
|
|
22
|
+
|
|
23
|
+
async function load() {
|
|
24
|
+
if (!deviceId.value) return void (schedules.value = []);
|
|
25
|
+
loading.value = true;
|
|
26
|
+
error.value = "";
|
|
27
|
+
try {
|
|
28
|
+
schedules.value = (await client().schedules()).schedules;
|
|
29
|
+
} catch (e) {
|
|
30
|
+
const code = (e as { code?: string }).code;
|
|
31
|
+
error.value =
|
|
32
|
+
code === "not_found" || /allowlist/i.test(message(e))
|
|
33
|
+
? "This device runs an older build: update it (`dpi update`) to use schedules."
|
|
34
|
+
: message(e).slice(0, 160);
|
|
35
|
+
} finally {
|
|
36
|
+
loading.value = false;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
watch(deviceId, load, { immediate: true });
|
|
40
|
+
|
|
41
|
+
const when = (at: number | null) => {
|
|
42
|
+
if (!at) return "—";
|
|
43
|
+
const delta = at - Date.now();
|
|
44
|
+
const mins = Math.round(Math.abs(delta) / 60_000);
|
|
45
|
+
const human = mins < 60 ? `${mins}m` : mins < 1440 ? `${Math.round(mins / 60)}h` : `${Math.round(mins / 1440)}d`;
|
|
46
|
+
return delta >= 0 ? `in ${human}` : `${human} ago`;
|
|
47
|
+
};
|
|
48
|
+
const trigger = (s: ScheduleView) => (s.everyMinutes ? `every ${s.everyMinutes}m` : `daily ${s.dailyAt}`);
|
|
49
|
+
|
|
50
|
+
async function withBusy(id: string, fn: () => Promise<unknown>, done: string) {
|
|
51
|
+
busy.value = id;
|
|
52
|
+
try {
|
|
53
|
+
await fn();
|
|
54
|
+
await load();
|
|
55
|
+
notify(done);
|
|
56
|
+
} catch (e) {
|
|
57
|
+
notify(message(e).slice(0, 140));
|
|
58
|
+
} finally {
|
|
59
|
+
busy.value = "";
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const toggle = (s: ScheduleView) =>
|
|
64
|
+
withBusy(s.id, () => client().updateSchedule(s.id, { enabled: !s.enabled }), s.enabled ? "Schedule paused." : "Schedule resumed.");
|
|
65
|
+
|
|
66
|
+
const runNow = (s: ScheduleView) =>
|
|
67
|
+
withBusy(s.id, () => client().runSchedule(s.id), `${s.name}: run finished.`);
|
|
68
|
+
|
|
69
|
+
const remove = (s: ScheduleView) =>
|
|
70
|
+
(ui.dialog = {
|
|
71
|
+
kind: "prompt",
|
|
72
|
+
title: `Remove ${s.name}?`,
|
|
73
|
+
hint: "The schedule stops being run. Sessions it already created are untouched.",
|
|
74
|
+
submit: "Remove schedule",
|
|
75
|
+
danger: true,
|
|
76
|
+
run: () => withBusy(s.id, () => client().removeSchedule(s.id), "Schedule removed."),
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
/** The model is picked from the device's own catalog, not typed from memory. */
|
|
80
|
+
const models = ref<{ key: string }[]>([]);
|
|
81
|
+
async function openAdd() {
|
|
82
|
+
adding.value = true;
|
|
83
|
+
draft.value = { name: "", cwd: selected.value?.sessionId ? "" : "", prompt: "", model: "" };
|
|
84
|
+
try {
|
|
85
|
+
const device = await client().device();
|
|
86
|
+
models.value = device.models.map((m) => ({ key: `${m.provider}/${m.id}` }));
|
|
87
|
+
draft.value.model = device.defaultModel;
|
|
88
|
+
} catch {
|
|
89
|
+
models.value = [];
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
async function save() {
|
|
94
|
+
const d = draft.value;
|
|
95
|
+
const [provider, ...rest] = d.model.split("/");
|
|
96
|
+
const modelId = rest.join("/");
|
|
97
|
+
if (!d.name.trim() || !d.cwd.trim() || !d.prompt.trim() || !provider || !modelId) return;
|
|
98
|
+
busy.value = "new";
|
|
99
|
+
try {
|
|
100
|
+
await client().createSchedule({
|
|
101
|
+
name: d.name.trim(),
|
|
102
|
+
cwd: d.cwd.trim(),
|
|
103
|
+
prompt: d.prompt,
|
|
104
|
+
model: { provider, modelId },
|
|
105
|
+
// One trigger only: exactly what the registry demands.
|
|
106
|
+
...(daily.value.trim() ? { dailyAt: daily.value.trim() } : { everyMinutes: Number(every.value) || 60 }),
|
|
107
|
+
});
|
|
108
|
+
adding.value = false;
|
|
109
|
+
await load();
|
|
110
|
+
notify("Schedule created. The device runs it on its own clock.");
|
|
111
|
+
} catch (e) {
|
|
112
|
+
notify(message(e).slice(0, 160));
|
|
113
|
+
} finally {
|
|
114
|
+
busy.value = "";
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
</script>
|
|
118
|
+
|
|
119
|
+
<template>
|
|
120
|
+
<section class="schedules-panel" aria-label="Scheduled sessions">
|
|
121
|
+
<header class="panel-heading">
|
|
122
|
+
<span><CalendarClock :size="16" />SCHEDULES</span>
|
|
123
|
+
<button class="icon-button" :disabled="loading || !deviceId" aria-label="Refresh schedules" title="Refresh schedules" @click="load">
|
|
124
|
+
<RefreshCw :size="15" :class="{ spin: loading }" />
|
|
125
|
+
</button>
|
|
126
|
+
<button class="icon-button" :disabled="!deviceId" aria-label="Add schedule" title="Add schedule" @click="openAdd">
|
|
127
|
+
<Plus :size="15" />
|
|
128
|
+
</button>
|
|
129
|
+
</header>
|
|
130
|
+
|
|
131
|
+
<p class="hint">Runs on the device's own clock — no browser needs to be open.</p>
|
|
132
|
+
<p v-if="!deviceId" class="hint">Select a session to see its device.</p>
|
|
133
|
+
<p v-else-if="error" class="message-error">{{ error }}</p>
|
|
134
|
+
|
|
135
|
+
<form v-if="adding" class="add-form" @submit.prevent="save">
|
|
136
|
+
<label>Name<input v-model="draft.name" placeholder="Nightly smoke" required /></label>
|
|
137
|
+
<label>Directory<input v-model="draft.cwd" placeholder="/home/me/project" required /></label>
|
|
138
|
+
<label>Prompt<textarea v-model="draft.prompt" rows="3" placeholder="Run the tests and summarise failures" required /></label>
|
|
139
|
+
<label
|
|
140
|
+
>Model
|
|
141
|
+
<select v-model="draft.model">
|
|
142
|
+
<option v-for="m in models" :key="m.key" :value="m.key">{{ m.key }}</option>
|
|
143
|
+
</select>
|
|
144
|
+
</label>
|
|
145
|
+
<div class="trigger-row">
|
|
146
|
+
<label class="inline">Every <input v-model="every" class="num" :disabled="!!daily.trim()" /> min</label>
|
|
147
|
+
<span class="muted">or</span>
|
|
148
|
+
<label class="inline">daily at <input v-model="daily" class="num time" placeholder="03:00" :disabled="!!every" /></label>
|
|
149
|
+
</div>
|
|
150
|
+
<div class="row">
|
|
151
|
+
<button class="primary small" type="submit" :disabled="busy === 'new'">
|
|
152
|
+
{{ busy === "new" ? "creating…" : "Create schedule" }}
|
|
153
|
+
</button>
|
|
154
|
+
<button class="small" type="button" @click="adding = false">Cancel</button>
|
|
155
|
+
</div>
|
|
156
|
+
</form>
|
|
157
|
+
|
|
158
|
+
<p v-if="!adding && !schedules.length && deviceId && !error" class="hint">
|
|
159
|
+
No schedules yet. Press + to add one.
|
|
160
|
+
</p>
|
|
161
|
+
|
|
162
|
+
<ul v-if="schedules.length" class="schedule-list">
|
|
163
|
+
<li v-for="s in schedules" :key="s.id" class="schedule" :class="{ off: !s.enabled }">
|
|
164
|
+
<div class="head">
|
|
165
|
+
<b>{{ s.name }}</b>
|
|
166
|
+
<span class="tag">{{ trigger(s) }}</span>
|
|
167
|
+
<span v-if="s.running" class="tag running">running</span>
|
|
168
|
+
<span v-else-if="s.lastOutcome === 'failed'" class="tag bad" :title="s.lastError">last run failed</span>
|
|
169
|
+
<span class="next">{{ s.enabled ? `next ${when(s.nextRunAt)}` : "paused" }}</span>
|
|
170
|
+
</div>
|
|
171
|
+
<code class="cwd">{{ s.cwd }}</code>
|
|
172
|
+
<p v-if="s.lastError" class="message-error">{{ s.lastError.slice(0, 160) }}</p>
|
|
173
|
+
<div class="row">
|
|
174
|
+
<button class="small" :disabled="busy === s.id" @click="runNow(s)"><Play :size="12" />run now</button>
|
|
175
|
+
<button class="small" :disabled="busy === s.id" @click="toggle(s)">
|
|
176
|
+
<Power :size="12" />{{ s.enabled ? "pause" : "resume" }}
|
|
177
|
+
</button>
|
|
178
|
+
<button class="small danger" :disabled="busy === s.id" @click="remove(s)"><Trash2 :size="12" />remove</button>
|
|
179
|
+
</div>
|
|
180
|
+
</li>
|
|
181
|
+
</ul>
|
|
182
|
+
</section>
|
|
183
|
+
</template>
|
|
184
|
+
|
|
185
|
+
<style scoped>
|
|
186
|
+
.schedules-panel {
|
|
187
|
+
display: flex;
|
|
188
|
+
flex-direction: column;
|
|
189
|
+
gap: 10px;
|
|
190
|
+
padding: 4px 2px 12px;
|
|
191
|
+
font-size: 16px;
|
|
192
|
+
}
|
|
193
|
+
.schedule-list {
|
|
194
|
+
display: flex;
|
|
195
|
+
flex-direction: column;
|
|
196
|
+
gap: 8px;
|
|
197
|
+
margin: 0;
|
|
198
|
+
padding: 0;
|
|
199
|
+
list-style: none;
|
|
200
|
+
}
|
|
201
|
+
.schedule {
|
|
202
|
+
display: flex;
|
|
203
|
+
flex-direction: column;
|
|
204
|
+
gap: 4px;
|
|
205
|
+
padding: 8px 10px;
|
|
206
|
+
border: 1px solid var(--line);
|
|
207
|
+
border-radius: 10px;
|
|
208
|
+
}
|
|
209
|
+
.schedule.off {
|
|
210
|
+
opacity: 0.6;
|
|
211
|
+
}
|
|
212
|
+
.schedule .head {
|
|
213
|
+
display: flex;
|
|
214
|
+
align-items: center;
|
|
215
|
+
gap: 6px;
|
|
216
|
+
flex-wrap: wrap;
|
|
217
|
+
}
|
|
218
|
+
.schedule .next {
|
|
219
|
+
margin-left: auto;
|
|
220
|
+
font-size: 13px;
|
|
221
|
+
opacity: 0.7;
|
|
222
|
+
}
|
|
223
|
+
.schedule .tag.running {
|
|
224
|
+
border-color: var(--accent);
|
|
225
|
+
color: var(--accent);
|
|
226
|
+
}
|
|
227
|
+
.schedule .tag.bad {
|
|
228
|
+
border-color: var(--warn, #e5a50a);
|
|
229
|
+
}
|
|
230
|
+
.schedule .cwd {
|
|
231
|
+
font-size: 13px;
|
|
232
|
+
opacity: 0.7;
|
|
233
|
+
word-break: break-all;
|
|
234
|
+
}
|
|
235
|
+
.schedule .row,
|
|
236
|
+
.trigger-row {
|
|
237
|
+
display: flex;
|
|
238
|
+
gap: 6px;
|
|
239
|
+
align-items: center;
|
|
240
|
+
flex-wrap: wrap;
|
|
241
|
+
}
|
|
242
|
+
.add-form {
|
|
243
|
+
display: flex;
|
|
244
|
+
flex-direction: column;
|
|
245
|
+
gap: 8px;
|
|
246
|
+
padding: 10px;
|
|
247
|
+
border: 1px solid var(--line);
|
|
248
|
+
border-radius: 10px;
|
|
249
|
+
}
|
|
250
|
+
.add-form label {
|
|
251
|
+
display: flex;
|
|
252
|
+
flex-direction: column;
|
|
253
|
+
gap: 3px;
|
|
254
|
+
font-size: 13px;
|
|
255
|
+
opacity: 0.85;
|
|
256
|
+
}
|
|
257
|
+
.add-form input,
|
|
258
|
+
.add-form textarea,
|
|
259
|
+
.add-form select {
|
|
260
|
+
font: inherit;
|
|
261
|
+
font-size: 15px;
|
|
262
|
+
padding: 5px 8px;
|
|
263
|
+
color: var(--fg);
|
|
264
|
+
background: transparent;
|
|
265
|
+
border: 1px solid var(--line);
|
|
266
|
+
border-radius: 8px;
|
|
267
|
+
}
|
|
268
|
+
.add-form .inline {
|
|
269
|
+
flex-direction: row;
|
|
270
|
+
align-items: center;
|
|
271
|
+
gap: 5px;
|
|
272
|
+
opacity: 1;
|
|
273
|
+
}
|
|
274
|
+
.add-form input.num {
|
|
275
|
+
width: 72px;
|
|
276
|
+
}
|
|
277
|
+
.add-form .muted {
|
|
278
|
+
font-size: 13px;
|
|
279
|
+
opacity: 0.6;
|
|
280
|
+
}
|
|
281
|
+
.spin {
|
|
282
|
+
animation: spin 1s linear infinite;
|
|
283
|
+
}
|
|
284
|
+
@keyframes spin {
|
|
285
|
+
to {
|
|
286
|
+
transform: rotate(360deg);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
</style>
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
} from "lucide-vue-next";
|
|
16
16
|
import DeviceIcon from "./DeviceIcon.vue";
|
|
17
17
|
import type { TreeNode } from "@sdk/models";
|
|
18
|
-
import { ago } from "../client/store";
|
|
18
|
+
import { ago, hubVersion } from "../client/store";
|
|
19
19
|
import { branchOf } from "../client/session-git";
|
|
20
20
|
|
|
21
21
|
const props = defineProps<{
|
|
@@ -42,6 +42,12 @@ const background = computed(() =>
|
|
|
42
42
|
: (agent.value?.background ?? 0),
|
|
43
43
|
);
|
|
44
44
|
const busy = computed(() => session.value?.busy || agent.value?.busy);
|
|
45
|
+
/** Behind the hub's build: devices self-update, this is only a hint. */
|
|
46
|
+
const behind = computed(() => {
|
|
47
|
+
const theirs = device.value?.info?.packageVersion;
|
|
48
|
+
const ours = hubVersion.value;
|
|
49
|
+
return Boolean(theirs && ours && ours !== "unknown" && theirs !== ours);
|
|
50
|
+
});
|
|
45
51
|
const statusText = computed(() => {
|
|
46
52
|
const d = device.value;
|
|
47
53
|
if (!d) return "";
|
|
@@ -113,6 +119,12 @@ const title = computed(() => {
|
|
|
113
119
|
<DeviceIcon :device="device" :size="16" />
|
|
114
120
|
<b class="name">{{ label }}</b>
|
|
115
121
|
<span class="badge">{{ device.kind }}</span>
|
|
122
|
+
<span
|
|
123
|
+
v-if="behind"
|
|
124
|
+
class="tag update"
|
|
125
|
+
:title="`device runs ${device?.info?.packageVersion ?? '?'}; hub runs ${hubVersion}. Devices self-update: dpi update`"
|
|
126
|
+
>update</span
|
|
127
|
+
>
|
|
116
128
|
<span class="meta" :class="{ err: dot === 'err' }">{{ statusText }}</span>
|
|
117
129
|
<span class="acts" @click.stop>
|
|
118
130
|
<button
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
import express from "express";
|
|
5
5
|
import { createServer } from "node:http";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
|
-
import {
|
|
7
|
+
import { readFileSync } from "node:fs";
|
|
8
|
+
import { extname, join, resolve } from "node:path";
|
|
8
9
|
import { hostname, networkInterfaces } from "node:os";
|
|
9
10
|
import { NetworkRegistry, UI_STATE_MAX_CHARS } from "../../../../dpi-sdk/src/node/registry.js";
|
|
10
11
|
import { ByteBudget } from "../../../../dpi-sdk/src/node/chunk.js";
|
|
@@ -112,6 +113,24 @@ app.use((req, res, next) => {
|
|
|
112
113
|
next();
|
|
113
114
|
});
|
|
114
115
|
app.get("/healthz", (_req, res) => res.json({ ok: true }));
|
|
116
|
+
// The hub's own version, so a UI can flag devices that are behind it (the hub
|
|
117
|
+
// never pushes code — this is a badge, not an update channel).
|
|
118
|
+
const HUB_VERSION = (() => {
|
|
119
|
+
// Walk up to the package that owns this build: the checkout and the published
|
|
120
|
+
// layout nest the hub at different depths, so a fixed "../.." would lie.
|
|
121
|
+
let dir = fileURLToPath(new URL(".", import.meta.url));
|
|
122
|
+
for (let i = 0; i < 8; i += 1) {
|
|
123
|
+
try {
|
|
124
|
+
const pkg = JSON.parse(readFileSync(join(dir, "package.json"), "utf8")) as { name?: string; version?: string };
|
|
125
|
+
if (pkg.name === "my-durable" && pkg.version) return pkg.version;
|
|
126
|
+
} catch {
|
|
127
|
+
/* keep walking */
|
|
128
|
+
}
|
|
129
|
+
dir = resolve(dir, "..");
|
|
130
|
+
}
|
|
131
|
+
return "unknown";
|
|
132
|
+
})();
|
|
133
|
+
app.get("/api/version", (_req, res) => res.json({ version: HUB_VERSION, node: process.version }));
|
|
115
134
|
// All CANON limits must be sane or the hub refuses to start (P2-22: fail startup, not per-request).
|
|
116
135
|
assertLimitsConfig();
|
|
117
136
|
/** Operator floor for free space on the registry volume (bytes); below it audited changes are refused with 503. */
|
package/apps/dpi-sdk/src/api.ts
CHANGED
|
@@ -89,6 +89,8 @@ export interface DeviceInfo {
|
|
|
89
89
|
platform: string;
|
|
90
90
|
apiVersion: typeof API_VERSION;
|
|
91
91
|
durableVersion: string;
|
|
92
|
+
/** The my-durable build this device runs (what `dpi update` replaces). */
|
|
93
|
+
packageVersion?: string;
|
|
92
94
|
startedAt: number;
|
|
93
95
|
/** Where new sessions start: the directory browser opens here, relative cwds resolve against the first. */
|
|
94
96
|
startDirs: string[];
|
|
@@ -213,6 +215,50 @@ export interface ProjectPatchBody {
|
|
|
213
215
|
labels?: string[];
|
|
214
216
|
}
|
|
215
217
|
|
|
218
|
+
/** A scheduled session: the device owns the clock, the hub only displays it. */
|
|
219
|
+
export interface ScheduleModelRef {
|
|
220
|
+
provider: string;
|
|
221
|
+
modelId: string;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export interface ScheduleRecord {
|
|
225
|
+
id: string;
|
|
226
|
+
name: string;
|
|
227
|
+
/** Directory each run's session starts in. */
|
|
228
|
+
cwd: string;
|
|
229
|
+
model: ScheduleModelRef;
|
|
230
|
+
/** Message sent to the new session's root agent. */
|
|
231
|
+
prompt: string;
|
|
232
|
+
/** Interval trigger in minutes (5–1440). Exactly one trigger is set. */
|
|
233
|
+
everyMinutes?: number;
|
|
234
|
+
/** Daily trigger, local time "HH:MM". Exactly one trigger is set. */
|
|
235
|
+
dailyAt?: string;
|
|
236
|
+
enabled: boolean;
|
|
237
|
+
lastRunAt?: number;
|
|
238
|
+
lastSessionId?: string;
|
|
239
|
+
lastOutcome?: "ok" | "failed";
|
|
240
|
+
lastError?: string;
|
|
241
|
+
createdAt: number;
|
|
242
|
+
updatedAt: number;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/** What a UI shows: the record plus the clock the device computed and live state. */
|
|
246
|
+
export interface ScheduleView extends ScheduleRecord {
|
|
247
|
+
nextRunAt: number | null;
|
|
248
|
+
/** A turn is in flight for this schedule right now. */
|
|
249
|
+
running: boolean;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export interface SchedulePatchBody {
|
|
253
|
+
name?: string;
|
|
254
|
+
cwd?: string;
|
|
255
|
+
model?: ScheduleModelRef;
|
|
256
|
+
prompt?: string;
|
|
257
|
+
everyMinutes?: number;
|
|
258
|
+
dailyAt?: string;
|
|
259
|
+
enabled?: boolean;
|
|
260
|
+
}
|
|
261
|
+
|
|
216
262
|
/** Device usage rollup over the sessions it still holds (archived are closed). */
|
|
217
263
|
export interface DeviceUsageReport {
|
|
218
264
|
at: number;
|
|
@@ -17,6 +17,8 @@ import type {
|
|
|
17
17
|
Page,
|
|
18
18
|
ProjectPatchBody,
|
|
19
19
|
ProjectRecord,
|
|
20
|
+
SchedulePatchBody,
|
|
21
|
+
ScheduleView,
|
|
20
22
|
SendResult,
|
|
21
23
|
SessionSearchResult,
|
|
22
24
|
SessionSummary,
|
|
@@ -224,6 +226,22 @@ export class DpiClient {
|
|
|
224
226
|
unarchiveProject(id: string) {
|
|
225
227
|
return this.request<ProjectRecord>("POST", `/v1/projects/${enc(id)}/unarchive`, {});
|
|
226
228
|
}
|
|
229
|
+
/** Scheduled sessions on this device (device-owned clock). */
|
|
230
|
+
schedules() {
|
|
231
|
+
return this.request<{ schedules: ScheduleView[] }>("GET", "/v1/schedules");
|
|
232
|
+
}
|
|
233
|
+
createSchedule(input: SchedulePatchBody & { name: string; cwd: string; prompt: string }) {
|
|
234
|
+
return this.request<ScheduleView>("POST", "/v1/schedules", input);
|
|
235
|
+
}
|
|
236
|
+
updateSchedule(id: string, patch: SchedulePatchBody) {
|
|
237
|
+
return this.request<ScheduleView>("PATCH", `/v1/schedules/${enc(id)}`, patch);
|
|
238
|
+
}
|
|
239
|
+
removeSchedule(id: string) {
|
|
240
|
+
return this.request<{ removed: boolean }>("DELETE", `/v1/schedules/${enc(id)}`);
|
|
241
|
+
}
|
|
242
|
+
runSchedule(id: string) {
|
|
243
|
+
return this.request<ScheduleView>("POST", `/v1/schedules/${enc(id)}/run`, {});
|
|
244
|
+
}
|
|
227
245
|
/** Usage rollup over the sessions this device still holds. */
|
|
228
246
|
deviceUsage() {
|
|
229
247
|
return this.request<DeviceUsageReport>("GET", "/v1/device/usage");
|
|
@@ -25,6 +25,12 @@ const ROUTES: readonly (readonly [method: string, pattern: string])[] = [
|
|
|
25
25
|
["POST", "/projects/:id/archive"],
|
|
26
26
|
["POST", "/projects/:id/unarchive"],
|
|
27
27
|
|
|
28
|
+
["GET", "/schedules"],
|
|
29
|
+
["POST", "/schedules"],
|
|
30
|
+
["PATCH", "/schedules/:id"],
|
|
31
|
+
["DELETE", "/schedules/:id"],
|
|
32
|
+
["POST", "/schedules/:id/run"],
|
|
33
|
+
|
|
28
34
|
["GET", "/sessions"],
|
|
29
35
|
["POST", "/sessions"],
|
|
30
36
|
["GET", "/sessions/search"],
|
package/bin/dpi.mjs
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
// dpi hub [--port N] [--host H] [--public-host H] web UI + device tunnel server
|
|
4
4
|
// dpi device [start|stop|status|install|uninstall] device-side daemon
|
|
5
5
|
// dpi tui terminal admin client
|
|
6
|
+
// dpi schedule [list|add|enable|disable|run|remove] scheduled sessions
|
|
7
|
+
// dpi gc --closed-before 30d [--dry-run|--yes] retention (dry-run default)
|
|
6
8
|
// dpi doctor [--json] [--quiet] one-shot device health check
|
|
7
9
|
// Every subcommand runs the TypeScript entry through tsx, so no build step is needed.
|
|
8
10
|
import { access } from "node:fs/promises";
|
|
@@ -138,6 +140,19 @@ if (command === "update" || command === "upgrade") {
|
|
|
138
140
|
register();
|
|
139
141
|
const { runPairCommand } = await import("../apps/dpi-backend/src/pair-cli.ts");
|
|
140
142
|
process.exit(await runPairCommand(commandRest));
|
|
143
|
+
} else if (command === "schedule") {
|
|
144
|
+
// Scheduled sessions: the CLI only edits the device's records over its own API,
|
|
145
|
+
// so a running daemon picks changes up without a restart.
|
|
146
|
+
const { register } = await loadTsx();
|
|
147
|
+
register();
|
|
148
|
+
const { scheduleCli } = await import("../apps/dpi-backend/src/schedule-cli.ts");
|
|
149
|
+
process.exit(await scheduleCli(commandRest));
|
|
150
|
+
} else if (command === "gc") {
|
|
151
|
+
// Retention: dry-run unless --yes. Never runs on its own (policy gate #3).
|
|
152
|
+
const { register } = await loadTsx();
|
|
153
|
+
register();
|
|
154
|
+
const { gcCli } = await import("../apps/dpi-backend/src/gc-cli.ts");
|
|
155
|
+
process.exit(await gcCli({ argv: commandRest }));
|
|
141
156
|
} else if (command === "doctor") {
|
|
142
157
|
// One-shot health check. The logic lives in the backend as TS (testable with
|
|
143
158
|
// injected fakes); this is only the tsx loader + the exit code.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Host / Project / Device / Session Management Feature Checklist — orca / paseo / zcode / herdr / piggery → durable-pi
|
|
2
2
|
|
|
3
3
|
Run: `team_20261024143910_47d06fe8b77400d4` · Steps: 01_explore (inventory) → 02_analyze (verify/correct) → 03_write (this file)
|
|
4
|
-
Status: **Waves 1a+1b+2
|
|
4
|
+
Status: **Waves 1a+1b+2 ADOPTED (0.0.40 — live-verified in production Chrome: bell+panel, usage chip+total row, transcript download, prompt library, bulk select bar, recent-cwds chips; Host vitals with real uptime/load/memory/disk, tunnel-routed session search, and a bundle zip that real `unzip` opens).** Remaining: notification fan-out, env UI, backup/restore, rate-limit surfacing, per-project settings (Wave 2 SHOULDs) and Wave 3. Policy gates #1/#2/#4 are still open; #3 is implemented as manual-only GC (no defaults, no timer). Companion to `docs/git-ui-checklist.md` (CLOSED): that file covered the git panel; this one covers everything **around** the agent runtime — projects/workspaces, host/device management, session lifecycle, config/credentials, diagnostics, maintenance. Git-panel features are deliberately absent here. Every load-bearing citation below was re-read in the actual files during this run (see [Verification log](#verification-log)).
|
|
5
5
|
|
|
6
6
|
## Why this doc exists
|
|
7
7
|
|
|
@@ -134,12 +134,12 @@ None of them blocks Wave 1.
|
|
|
134
134
|
| Tier | Feature | Source (path:line) | Ours | Adoption suggestion |
|
|
135
135
|
|---|---|---|---|---|
|
|
136
136
|
| MUST | Project entity + labels + archive | paseo `workspace-registry.ts:22-40` (`PersistedProjectRecord`: projectId/rootPath/kind/displayName/projectKey with COMPAT migration, customName; atomic writes via `atomic-file.ts`); zcode `packages/services/src/project/CONTRACT.md` + `autoArchiveScheduler.ts` | ✅ (`0.0.39`) | `projects.ts`: atomic 0600 registry with `.bak` + v0→v1 COMPAT migration, customName/labels/archive; seeded from every session cwd on boot and on create. FE `ProjectBar.vue` chips filter the tree, name/labels/archive through the app-styled prompt |
|
|
137
|
-
| MUST | Scheduled sessions (device-side) | orca `automations/service.ts:186-211` (scheduled trigger, precheck, completion watcher; separate drift report) |
|
|
137
|
+
| MUST | Scheduled sessions (device-side) | orca `automations/service.ts:186-211` (scheduled trigger, precheck, completion watcher; separate drift report) | ✅ (`0.0.40`) | `schedules.ts` registry + a 30 s unref'd device loop (`store.ts`): a run creates a **fresh session** (`<name> · <time>`), sends the prompt, records the outcome. `dpi schedule list/add/enable/disable/run/remove`; Inspector **Auto** tab. Live: run → `ok`, next run computed |
|
|
138
138
|
| MUST | Usage dashboard | orca `usage/agent-token-usage.ts` + `usage-calendar-range.ts` (46-file suite incl. per-provider parsers) | ✅ (`0.0.39`) | GET `/device/usage` sums each harness's usage per session/model/project; Inspector **Usage** tab. Live: 4,307 tok → `opencode-go/claude-haiku-5-5`, attributed to its project. No calendar/persistence yet (archived sessions are closed stores) |
|
|
139
139
|
| SHOULD | Notification delivery fan-out | orca `notification-delivery-service.ts:15-49` (tray→mobile→desktop, burst cooldown); piggery notify hooks desktop/herdr/ntfy (`docs/reference.md:15`) | ❌ | webhook + ntfy targets driven from existing events; per-device cooldown like orca's |
|
|
140
140
|
| SHOULD | Env-var management UI | orca `settings/HostAgentEnvironmentEditor.tsx` + `agent-default-env-draft.ts` | ❌ | edit the `env`/`env_keys` blocks of `dpi-network.yaml` (the file that generates `backend.env`, `dpi-network.example.yaml:23-30`) |
|
|
141
|
-
| MUST | Retention / auto-GC — **policy #3** | orca `terminal-history-gc.ts`; piggery `gc --closed-before DURATION [--dry-run]` (`docs/reference.md:31`) |
|
|
142
|
-
| SHOULD | Remote update badge — **policy #4** | orca `ssh/managed-server-update-check.ts` + `orcad-update-plan.ts` |
|
|
141
|
+
| MUST | Retention / auto-GC — **policy #3** | orca `terminal-history-gc.ts`; piggery `gc --closed-before DURATION [--dry-run]` (`docs/reference.md:31`) | ✅ manual-only (`0.0.40`) | `gc.ts` + `dpi gc --closed-before 30d [--yes]`: **dry-run is the default and nothing schedules itself** — the retention policy stays the operator's call (gate #3 remains open for defaults) |
|
|
142
|
+
| SHOULD | Remote update badge — **policy #4** | orca `ssh/managed-server-update-check.ts` + `orcad-update-plan.ts` | ✅ (`0.0.40`) | `GET /api/version` (hub walks up to the `my-durable` package.json) + device `packageVersion` in `/v1/device` → tree badge "update". Hint only: devices self-update, the hub never pushes code. Verified 0 badges when versions match, and the 1.3.0-vs-0.0.39 trap (pi-durable's version) is fixed by reporting both |
|
|
143
143
|
| SHOULD | Backup/restore of session data | orca `rolling-file-backup.ts`; paseo `migrations/` (schema side) | ❌ | rolling copies of registry + device store ahead of schema migrations |
|
|
144
144
|
| SHOULD | Rate-limit surfacing | orca `rate-limits/` | ❌ | parse provider 429/limit info at probe/send time → hint in model picker |
|
|
145
145
|
| SHOULD | Per-project settings/instructions | orca `settings/RepositoryPane.tsx` | ❌ | after the project entity: per-project model/env defaults |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "my-durable",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.40",
|
|
4
4
|
"description": "Durable Pi — the durable agent network: hub web UI, device backend daemon, TUI admin and the shared SDK, packaged as one runnable monorepo install",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|