my-durable 0.0.38 → 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/projects.ts +587 -0
- package/apps/dpi-backend/src/routes.ts +27 -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 +304 -2
- 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 +8 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/NetworkSidebar.vue +23 -1
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/ProjectBar.vue +284 -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-fe/src/components/UsagePanel.vue +406 -0
- package/apps/dpi-playground/apps/dpi-playground-hub/src/main.ts +20 -1
- package/apps/dpi-sdk/src/api.ts +100 -0
- package/apps/dpi-sdk/src/client.ts +42 -0
- package/apps/dpi-sdk/src/protocol/rest-routes.ts +12 -0
- package/bin/dpi.mjs +15 -0
- package/docs/host-project-checklist.md +6 -6
- package/package.json +1 -1
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/assets/index-D4M8tCcs.js +0 -81
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/assets/index-xOvj8ub1.css +0 -1
|
@@ -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
|