my-durable 0.0.44 → 0.0.46
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/config.ts +7 -1
- package/apps/dpi-backend/src/crash.ts +338 -0
- package/apps/dpi-backend/src/doctor.ts +16 -1
- package/apps/dpi-backend/src/graph-cli.ts +446 -0
- package/apps/dpi-backend/src/graphs.ts +960 -0
- package/apps/dpi-backend/src/main.ts +33 -2
- package/apps/dpi-backend/src/notify-cli.ts +8 -1
- package/apps/dpi-backend/src/pi-config.ts +102 -1
- package/apps/dpi-backend/src/routes.ts +29 -1
- package/apps/dpi-backend/src/store.ts +173 -1
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/assets/index-B5d1JP_j.css +1 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/assets/{index-BDY9dgTQ.js → index-CAtBlkjt.js} +4 -4
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/index.html +2 -2
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/EnvPanel.vue +136 -2
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/GraphPanel.vue +309 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/Inspector.vue +4 -0
- package/apps/dpi-sdk/src/api.ts +56 -0
- package/apps/dpi-sdk/src/client.ts +34 -0
- package/apps/dpi-sdk/src/protocol/rest-routes.ts +10 -0
- package/bin/dpi.mjs +7 -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-CraiQho0.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-CAtBlkjt.js"></script>
|
|
11
|
+
<link rel="stylesheet" crossorigin href="/assets/index-B5d1JP_j.css">
|
|
12
12
|
</head>
|
|
13
13
|
<body>
|
|
14
14
|
<div id="app"></div>
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
// change needs a daemon restart to apply — the panel says so, it does not
|
|
8
8
|
// pretend otherwise.
|
|
9
9
|
import { computed, ref, watch } from "vue";
|
|
10
|
-
import { RefreshCw, Plus, Pencil, Trash2, FileCog } from "lucide-vue-next";
|
|
11
|
-
import type { EnvFileView, EnvVarView } from "@sdk/api";
|
|
10
|
+
import { RefreshCw, Plus, Pencil, Trash2, FileCog, KeyRound } from "lucide-vue-next";
|
|
11
|
+
import type { EnvFileView, EnvVarView, PiAuthView } from "@sdk/api";
|
|
12
12
|
import { deviceClient, message } from "../client/hub";
|
|
13
13
|
import { notify, selected, ui } from "../client/store";
|
|
14
14
|
|
|
@@ -37,9 +37,65 @@ async function load() {
|
|
|
37
37
|
} finally {
|
|
38
38
|
loading.value = false;
|
|
39
39
|
}
|
|
40
|
+
void loadKeys();
|
|
40
41
|
}
|
|
41
42
|
watch(deviceId, load, { immediate: true });
|
|
42
43
|
|
|
44
|
+
// ---------------------------------------------------------------- pi keys
|
|
45
|
+
// Gate #2: WRITE-ONLY provider keys in pi's own auth.json. Values are never
|
|
46
|
+
// shown — the list carries masked tails only — and the input is a password
|
|
47
|
+
// field that is cleared the moment a save lands.
|
|
48
|
+
const keys = ref<PiAuthView | null>(null);
|
|
49
|
+
const keysError = ref("");
|
|
50
|
+
const addingKey = ref(false);
|
|
51
|
+
const keyDraft = ref({ providerId: "", key: "" });
|
|
52
|
+
|
|
53
|
+
async function loadKeys() {
|
|
54
|
+
if (!deviceId.value) return void (keys.value = null);
|
|
55
|
+
try {
|
|
56
|
+
keys.value = await client().piAuth();
|
|
57
|
+
keysError.value = "";
|
|
58
|
+
} catch (e) {
|
|
59
|
+
const text = message(e);
|
|
60
|
+
keysError.value =
|
|
61
|
+
(e as { code?: string }).code === "not_found" || /allowlist/i.test(text)
|
|
62
|
+
? "This device runs an older build: update it (`dpi update`) to manage pi keys."
|
|
63
|
+
: text.slice(0, 160);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async function addKey() {
|
|
68
|
+
const providerId = keyDraft.value.providerId.trim();
|
|
69
|
+
if (!providerId || !keyDraft.value.key) return;
|
|
70
|
+
busy.value = "pi-key";
|
|
71
|
+
try {
|
|
72
|
+
const r = await client().setPiApiKey(providerId, keyDraft.value.key);
|
|
73
|
+
keyDraft.value = { providerId: "", key: "" };
|
|
74
|
+
addingKey.value = false;
|
|
75
|
+
await loadKeys();
|
|
76
|
+
notify(`${providerId} saved (now ${r.masked}) — restart the device to apply it.`);
|
|
77
|
+
} catch (e) {
|
|
78
|
+
notify(message(e).slice(0, 160));
|
|
79
|
+
} finally {
|
|
80
|
+
busy.value = "";
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function removeKey(providerId: string) {
|
|
85
|
+
ui.dialog = {
|
|
86
|
+
kind: "prompt",
|
|
87
|
+
title: `Remove the ${providerId} key?`,
|
|
88
|
+
hint: "The entry is deleted from pi's auth.json. pi's own logins are never touched. Restart the device to apply.",
|
|
89
|
+
submit: "Remove",
|
|
90
|
+
danger: true,
|
|
91
|
+
run: async () => {
|
|
92
|
+
await client().removePiApiKey(providerId);
|
|
93
|
+
await loadKeys();
|
|
94
|
+
notify(`${providerId} removed — restart the device to apply it.`);
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
43
99
|
const editable = (v: EnvVarView) => v.source === "file" && !v.managed;
|
|
44
100
|
|
|
45
101
|
async function add() {
|
|
@@ -173,6 +229,81 @@ function remove(v: EnvVarView) {
|
|
|
173
229
|
</ul>
|
|
174
230
|
|
|
175
231
|
<p v-if="view" class="hint path">{{ view.envFile }}</p>
|
|
232
|
+
|
|
233
|
+
<header class="panel-heading keys-heading">
|
|
234
|
+
<span><KeyRound :size="16" />PI KEYS</span>
|
|
235
|
+
<button
|
|
236
|
+
class="icon-button"
|
|
237
|
+
:disabled="loading || !deviceId"
|
|
238
|
+
aria-label="Refresh pi keys"
|
|
239
|
+
title="Refresh"
|
|
240
|
+
@click="loadKeys"
|
|
241
|
+
>
|
|
242
|
+
<RefreshCw :size="15" />
|
|
243
|
+
</button>
|
|
244
|
+
<button
|
|
245
|
+
class="icon-button"
|
|
246
|
+
:disabled="!deviceId || !!keysError"
|
|
247
|
+
aria-label="Add a pi provider key"
|
|
248
|
+
title="Add a provider key to pi's auth.json"
|
|
249
|
+
@click="addingKey = !addingKey"
|
|
250
|
+
>
|
|
251
|
+
<Plus :size="15" />
|
|
252
|
+
</button>
|
|
253
|
+
</header>
|
|
254
|
+
|
|
255
|
+
<p class="hint">
|
|
256
|
+
Provider keys in pi's own <code>auth.json</code> — write-only: values are never shown, pi's interactive
|
|
257
|
+
logins (oauth) are never touched.
|
|
258
|
+
</p>
|
|
259
|
+
<p v-if="keysError" class="message-error">{{ keysError }}</p>
|
|
260
|
+
|
|
261
|
+
<form v-if="addingKey" class="add-form" @submit.prevent="addKey">
|
|
262
|
+
<label
|
|
263
|
+
>Provider id<input v-model="keyDraft.providerId" placeholder="zai" required />
|
|
264
|
+
</label>
|
|
265
|
+
<label
|
|
266
|
+
>Key<input
|
|
267
|
+
v-model="keyDraft.key"
|
|
268
|
+
type="password"
|
|
269
|
+
autocomplete="off"
|
|
270
|
+
placeholder="paste the api key"
|
|
271
|
+
required
|
|
272
|
+
/>
|
|
273
|
+
</label>
|
|
274
|
+
<div class="row">
|
|
275
|
+
<button class="primary small" type="submit" :disabled="busy === 'pi-key'">
|
|
276
|
+
{{ busy === 'pi-key' ? "saving…" : "Save to auth.json" }}
|
|
277
|
+
</button>
|
|
278
|
+
<button class="small" type="button" @click="addingKey = false">Cancel</button>
|
|
279
|
+
</div>
|
|
280
|
+
<p class="hint">Applies after the next device restart. Existing keys for other providers stay as they are.</p>
|
|
281
|
+
</form>
|
|
282
|
+
|
|
283
|
+
<p v-if="!addingKey && keys && !keys.entries.length && !keysError" class="hint">
|
|
284
|
+
No provider keys found.
|
|
285
|
+
</p>
|
|
286
|
+
|
|
287
|
+
<ul v-if="keys?.entries.length" class="var-list">
|
|
288
|
+
<li v-for="k in keys.entries" :key="k.providerId" class="var">
|
|
289
|
+
<div class="head">
|
|
290
|
+
<code class="key">{{ k.providerId }}</code>
|
|
291
|
+
<span class="tag">{{ k.source }}</span>
|
|
292
|
+
<span v-if="k.type !== 'api_key'" class="tag" title="Set by pi /login — read-only here">{{ k.type }}</span>
|
|
293
|
+
<span class="spacer" />
|
|
294
|
+
<button
|
|
295
|
+
v-if="k.type === 'api_key'"
|
|
296
|
+
class="icon-button"
|
|
297
|
+
:aria-label="`Remove ${k.providerId} key`"
|
|
298
|
+
title="Remove from auth.json"
|
|
299
|
+
@click="removeKey(k.providerId)"
|
|
300
|
+
>
|
|
301
|
+
<Trash2 :size="13" />
|
|
302
|
+
</button>
|
|
303
|
+
</div>
|
|
304
|
+
<code class="value" title="write-only — masked tail">{{ k.masked }}</code>
|
|
305
|
+
</li>
|
|
306
|
+
</ul>
|
|
176
307
|
</section>
|
|
177
308
|
</template>
|
|
178
309
|
|
|
@@ -257,6 +388,9 @@ function remove(v: EnvVarView) {
|
|
|
257
388
|
opacity: 0.55;
|
|
258
389
|
word-break: break-all;
|
|
259
390
|
}
|
|
391
|
+
.keys-heading {
|
|
392
|
+
margin-top: 14px;
|
|
393
|
+
}
|
|
260
394
|
.spin {
|
|
261
395
|
animation: spin 1s linear infinite;
|
|
262
396
|
}
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
// Task-graphs (Wave 3): a DAG of prompt-tasks the DEVICE runs sequentially —
|
|
3
|
+
// each task that has all dependencies ok starts a fresh session. This panel
|
|
4
|
+
// reads and starts; statuses stream in with the tree (no polling).
|
|
5
|
+
import { computed, ref, watch } from "vue";
|
|
6
|
+
import { RefreshCw, Play, Plus, Trash2, Waypoints } from "lucide-vue-next";
|
|
7
|
+
import type { GraphRecord, GraphRunRecord } from "@sdk/api";
|
|
8
|
+
import { deviceClient, message } from "../client/hub";
|
|
9
|
+
import { notify, selected, ui } from "../client/store";
|
|
10
|
+
|
|
11
|
+
interface Listed extends GraphRecord {
|
|
12
|
+
lastRun?: GraphRunRecord;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const graphs = ref<Listed[]>([]);
|
|
16
|
+
const runs = ref<Record<string, GraphRunRecord>>({});
|
|
17
|
+
const loading = ref(false);
|
|
18
|
+
const error = ref("");
|
|
19
|
+
const busy = ref("");
|
|
20
|
+
const adding = ref(false);
|
|
21
|
+
const draft = ref("");
|
|
22
|
+
const deviceId = computed(() => selected.value?.deviceId);
|
|
23
|
+
const client = () => deviceClient(deviceId.value ?? "");
|
|
24
|
+
|
|
25
|
+
async function load() {
|
|
26
|
+
if (!deviceId.value) return void (graphs.value = []);
|
|
27
|
+
loading.value = true;
|
|
28
|
+
error.value = "";
|
|
29
|
+
try {
|
|
30
|
+
const result = await client().graphs();
|
|
31
|
+
graphs.value = result.graphs;
|
|
32
|
+
runs.value = {};
|
|
33
|
+
} catch (e) {
|
|
34
|
+
const code = (e as { code?: string }).code;
|
|
35
|
+
error.value =
|
|
36
|
+
code === "not_found" || /allowlist/i.test(message(e))
|
|
37
|
+
? "This device runs an older build: update it (`dpi update`) to run task-graphs."
|
|
38
|
+
: message(e).slice(0, 160);
|
|
39
|
+
} finally {
|
|
40
|
+
loading.value = false;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
watch(deviceId, load, { immediate: true });
|
|
44
|
+
|
|
45
|
+
const STATUS_CLASS: Record<string, string> = {
|
|
46
|
+
ok: "ok",
|
|
47
|
+
failed: "bad",
|
|
48
|
+
running: "run",
|
|
49
|
+
pending: "",
|
|
50
|
+
skipped: "skip",
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
function statusOf(g: Listed, taskId: string): string {
|
|
54
|
+
return runs.value[g.id]?.tasks[taskId]?.status ?? g.lastRun?.tasks[taskId]?.status ?? "pending";
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async function openRuns(g: Listed) {
|
|
58
|
+
try {
|
|
59
|
+
const detail = await client().graph(g.id);
|
|
60
|
+
runs.value = { ...runs.value, [g.id]: detail.runs[0] ?? g.lastRun! };
|
|
61
|
+
if (!detail.runs.length) notify("This graph has not run yet.");
|
|
62
|
+
} catch (e) {
|
|
63
|
+
notify(message(e).slice(0, 140));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async function run(g: Listed) {
|
|
68
|
+
busy.value = g.id;
|
|
69
|
+
try {
|
|
70
|
+
const { run } = await client().runGraph(g.id);
|
|
71
|
+
runs.value = { ...runs.value, [g.id]: run };
|
|
72
|
+
notify(`Run started: ${Object.keys(run.tasks).length} tasks.`);
|
|
73
|
+
void openRuns(g);
|
|
74
|
+
} catch (e) {
|
|
75
|
+
notify(message(e).slice(0, 140));
|
|
76
|
+
} finally {
|
|
77
|
+
busy.value = "";
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function remove(g: Listed) {
|
|
82
|
+
ui.dialog = {
|
|
83
|
+
kind: "prompt",
|
|
84
|
+
title: `Remove the graph "${g.name}"?`,
|
|
85
|
+
hint: "The registry record goes. Sessions the graph created are never touched.",
|
|
86
|
+
submit: "Remove graph",
|
|
87
|
+
danger: true,
|
|
88
|
+
run: async () => {
|
|
89
|
+
await client().removeGraph(g.id);
|
|
90
|
+
await load();
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** The same JSON document `dpi graph add --file` takes. */
|
|
96
|
+
async function add() {
|
|
97
|
+
const text = draft.value.trim();
|
|
98
|
+
if (!text) return;
|
|
99
|
+
busy.value = "new";
|
|
100
|
+
try {
|
|
101
|
+
const doc = JSON.parse(text) as { name?: string; cwd?: string; tasks?: unknown };
|
|
102
|
+
const created = await client().createGraph({
|
|
103
|
+
name: String(doc.name ?? ""),
|
|
104
|
+
cwd: String(doc.cwd ?? ""),
|
|
105
|
+
tasks: doc.tasks as never,
|
|
106
|
+
});
|
|
107
|
+
adding.value = false;
|
|
108
|
+
draft.value = "";
|
|
109
|
+
notify(`Graph "${created.name}" added (${created.tasks.length} tasks).`);
|
|
110
|
+
await load();
|
|
111
|
+
} catch (e) {
|
|
112
|
+
notify(message(e).slice(0, 200));
|
|
113
|
+
} finally {
|
|
114
|
+
busy.value = "";
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
</script>
|
|
118
|
+
|
|
119
|
+
<template>
|
|
120
|
+
<section class="graph-panel" aria-label="Task graphs">
|
|
121
|
+
<header class="panel-heading">
|
|
122
|
+
<span><Waypoints :size="16" />DAG</span>
|
|
123
|
+
<button class="icon-button" :disabled="loading || !deviceId" aria-label="Refresh graphs" title="Refresh" @click="load">
|
|
124
|
+
<RefreshCw :size="15" :class="{ spin: loading }" />
|
|
125
|
+
</button>
|
|
126
|
+
<button
|
|
127
|
+
class="icon-button"
|
|
128
|
+
:disabled="!deviceId || !!error"
|
|
129
|
+
aria-label="Add a graph"
|
|
130
|
+
title="Add a graph from JSON"
|
|
131
|
+
@click="adding = !adding"
|
|
132
|
+
>
|
|
133
|
+
<Plus :size="15" />
|
|
134
|
+
</button>
|
|
135
|
+
</header>
|
|
136
|
+
|
|
137
|
+
<p class="hint">Tasks run on the device, in dependency order — one fresh session each.</p>
|
|
138
|
+
<p v-if="!deviceId" class="hint">Select a session to see its device.</p>
|
|
139
|
+
<p v-else-if="error" class="message-error">{{ error }}</p>
|
|
140
|
+
<p v-else-if="!graphs.length && !adding" class="hint">
|
|
141
|
+
No graphs yet. Press + and paste a graph JSON ({ name, cwd, tasks: [{ id, name, prompt, dependsOn }] }).
|
|
142
|
+
</p>
|
|
143
|
+
|
|
144
|
+
<form v-if="adding" class="add-form" @submit.prevent="add">
|
|
145
|
+
<label
|
|
146
|
+
>Graph JSON
|
|
147
|
+
<textarea
|
|
148
|
+
v-model="draft"
|
|
149
|
+
rows="8"
|
|
150
|
+
placeholder='{ "name": "nightly", "cwd": "~/work/app", "tasks": [{ "id": "build", "name": "Build", "prompt": "run the build", "dependsOn": [] }, { "id": "report", "name": "Report", "prompt": "summarise", "dependsOn": ["build"] }] }'
|
|
151
|
+
/> </label
|
|
152
|
+
>
|
|
153
|
+
<div class="row">
|
|
154
|
+
<button class="primary small" type="submit" :disabled="busy === 'new'">
|
|
155
|
+
{{ busy === "new" ? "adding…" : "Add graph" }}
|
|
156
|
+
</button>
|
|
157
|
+
<button class="small" type="button" @click="adding = false">Cancel</button>
|
|
158
|
+
</div>
|
|
159
|
+
</form>
|
|
160
|
+
|
|
161
|
+
<div v-for="g in graphs" :key="g.id" class="graph">
|
|
162
|
+
<div class="head">
|
|
163
|
+
<b>{{ g.name }}</b>
|
|
164
|
+
<code class="cwd" :title="g.cwd">{{ g.cwd.split("/").filter(Boolean).at(-1) || g.cwd }}</code>
|
|
165
|
+
<span class="tag" :class="STATUS_CLASS[g.lastRun?.status ?? 'pending'] ?? ''">{{
|
|
166
|
+
g.lastRun ? g.lastRun.status : "never run"
|
|
167
|
+
}}</span>
|
|
168
|
+
<span class="spacer" />
|
|
169
|
+
<button class="icon-button" :aria-label="`Run ${g.name}`" title="Run now" :disabled="busy === g.id" @click="run(g)">
|
|
170
|
+
<Play :size="14" />
|
|
171
|
+
</button>
|
|
172
|
+
<button class="icon-button" :aria-label="`Remove ${g.name}`" title="Remove graph" @click="remove(g)">
|
|
173
|
+
<Trash2 :size="14" />
|
|
174
|
+
</button>
|
|
175
|
+
</div>
|
|
176
|
+
<ul class="tasks">
|
|
177
|
+
<li v-for="t in g.tasks" :key="t.id" :class="STATUS_CLASS[statusOf(g, t.id)]">
|
|
178
|
+
<span class="dot" aria-hidden="true" />
|
|
179
|
+
<span class="name" :title="t.prompt">{{ t.name }}</span>
|
|
180
|
+
<code v-if="t.dependsOn.length" class="deps">← {{ t.dependsOn.join(", ") }}</code>
|
|
181
|
+
<span class="tag">{{ statusOf(g, t.id) }}</span>
|
|
182
|
+
<em v-if="runs[g.id]?.tasks[t.id]?.error" class="err">{{ runs[g.id].tasks[t.id]!.error!.slice(0, 120) }}</em>
|
|
183
|
+
</li>
|
|
184
|
+
</ul>
|
|
185
|
+
</div>
|
|
186
|
+
</section>
|
|
187
|
+
</template>
|
|
188
|
+
|
|
189
|
+
<style scoped>
|
|
190
|
+
.graph-panel {
|
|
191
|
+
display: flex;
|
|
192
|
+
flex-direction: column;
|
|
193
|
+
gap: 10px;
|
|
194
|
+
padding: 4px 2px 12px;
|
|
195
|
+
font-size: 16px;
|
|
196
|
+
}
|
|
197
|
+
.graph {
|
|
198
|
+
display: flex;
|
|
199
|
+
flex-direction: column;
|
|
200
|
+
gap: 6px;
|
|
201
|
+
padding: 8px 10px;
|
|
202
|
+
border: 1px solid var(--line);
|
|
203
|
+
border-radius: 10px;
|
|
204
|
+
}
|
|
205
|
+
.graph .head {
|
|
206
|
+
display: flex;
|
|
207
|
+
align-items: center;
|
|
208
|
+
gap: 6px;
|
|
209
|
+
flex-wrap: wrap;
|
|
210
|
+
}
|
|
211
|
+
.graph .spacer {
|
|
212
|
+
margin-left: auto;
|
|
213
|
+
}
|
|
214
|
+
.graph .cwd {
|
|
215
|
+
font-size: 13px;
|
|
216
|
+
opacity: 0.7;
|
|
217
|
+
}
|
|
218
|
+
.tasks {
|
|
219
|
+
display: flex;
|
|
220
|
+
flex-direction: column;
|
|
221
|
+
gap: 3px;
|
|
222
|
+
margin: 0;
|
|
223
|
+
padding: 0;
|
|
224
|
+
list-style: none;
|
|
225
|
+
}
|
|
226
|
+
.tasks li {
|
|
227
|
+
display: flex;
|
|
228
|
+
align-items: baseline;
|
|
229
|
+
gap: 6px;
|
|
230
|
+
flex-wrap: wrap;
|
|
231
|
+
font-size: 15px;
|
|
232
|
+
}
|
|
233
|
+
.tasks .dot {
|
|
234
|
+
width: 8px;
|
|
235
|
+
height: 8px;
|
|
236
|
+
border-radius: 50%;
|
|
237
|
+
background: var(--line);
|
|
238
|
+
align-self: center;
|
|
239
|
+
}
|
|
240
|
+
.tasks li.ok .dot {
|
|
241
|
+
background: var(--accent, #4f8cc9);
|
|
242
|
+
}
|
|
243
|
+
.tasks li.bad .dot {
|
|
244
|
+
background: var(--warn, #e5a50a);
|
|
245
|
+
}
|
|
246
|
+
.tasks li.run .dot {
|
|
247
|
+
animation: pulse 1.2s ease-in-out infinite;
|
|
248
|
+
}
|
|
249
|
+
.tasks .name {
|
|
250
|
+
font-weight: 600;
|
|
251
|
+
}
|
|
252
|
+
.tasks .deps {
|
|
253
|
+
font-size: 12px;
|
|
254
|
+
opacity: 0.6;
|
|
255
|
+
}
|
|
256
|
+
.tasks .err {
|
|
257
|
+
font-style: normal;
|
|
258
|
+
font-size: 13px;
|
|
259
|
+
color: var(--warn, #e5a50a);
|
|
260
|
+
}
|
|
261
|
+
.tag.ok {
|
|
262
|
+
color: var(--accent, #4f8cc9);
|
|
263
|
+
}
|
|
264
|
+
.tag.bad,
|
|
265
|
+
.tag.skip {
|
|
266
|
+
opacity: 0.7;
|
|
267
|
+
}
|
|
268
|
+
.add-form {
|
|
269
|
+
display: flex;
|
|
270
|
+
flex-direction: column;
|
|
271
|
+
gap: 8px;
|
|
272
|
+
padding: 10px;
|
|
273
|
+
border: 1px solid var(--line);
|
|
274
|
+
border-radius: 10px;
|
|
275
|
+
}
|
|
276
|
+
.add-form label {
|
|
277
|
+
display: flex;
|
|
278
|
+
flex-direction: column;
|
|
279
|
+
gap: 4px;
|
|
280
|
+
font-size: 13px;
|
|
281
|
+
opacity: 0.85;
|
|
282
|
+
}
|
|
283
|
+
.add-form textarea {
|
|
284
|
+
font: 12.5px/1.5 ui-monospace, monospace;
|
|
285
|
+
padding: 6px 8px;
|
|
286
|
+
color: var(--fg);
|
|
287
|
+
background: transparent;
|
|
288
|
+
border: 1px solid var(--line);
|
|
289
|
+
border-radius: 8px;
|
|
290
|
+
resize: vertical;
|
|
291
|
+
}
|
|
292
|
+
.add-form .row {
|
|
293
|
+
display: flex;
|
|
294
|
+
gap: 6px;
|
|
295
|
+
}
|
|
296
|
+
.spin {
|
|
297
|
+
animation: spin 1s linear infinite;
|
|
298
|
+
}
|
|
299
|
+
@keyframes spin {
|
|
300
|
+
to {
|
|
301
|
+
transform: rotate(360deg);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
@keyframes pulse {
|
|
305
|
+
50% {
|
|
306
|
+
opacity: 0.3;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
</style>
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
PackageOpen,
|
|
8
8
|
PiggyBank,
|
|
9
9
|
CalendarClock,
|
|
10
|
+
Waypoints,
|
|
10
11
|
Bell,
|
|
11
12
|
FileCog,
|
|
12
13
|
GitBranch,
|
|
@@ -30,6 +31,7 @@ import GitPanel from "./GitPanel.vue";
|
|
|
30
31
|
import HostPanel from "./HostPanel.vue";
|
|
31
32
|
import UsagePanel from "./UsagePanel.vue";
|
|
32
33
|
import SchedulesPanel from "./SchedulesPanel.vue";
|
|
34
|
+
import GraphPanel from "./GraphPanel.vue";
|
|
33
35
|
import NotifyPanel from "./NotifyPanel.vue";
|
|
34
36
|
import EnvPanel from "./EnvPanel.vue";
|
|
35
37
|
import ExtensionsPanel from "./ExtensionsPanel.vue";
|
|
@@ -74,6 +76,7 @@ const tabs = [
|
|
|
74
76
|
{ id: "host", label: "Host", icon: Activity },
|
|
75
77
|
{ id: "usage", label: "Usage", icon: PiggyBank },
|
|
76
78
|
{ id: "auto", label: "Auto", icon: CalendarClock },
|
|
79
|
+
{ id: "dag", label: "DAG", icon: Waypoints },
|
|
77
80
|
{ id: "notify", label: "Notify", icon: Bell },
|
|
78
81
|
{ id: "env", label: "Env", icon: FileCog },
|
|
79
82
|
{ id: "state", label: "State", icon: Braces },
|
|
@@ -495,6 +498,7 @@ const offeredTools = computed(() => detail.value?.tools.filter((t) => t.offered)
|
|
|
495
498
|
<HostPanel v-if="ui.tab === 'host'" />
|
|
496
499
|
<UsagePanel v-if="ui.tab === 'usage'" />
|
|
497
500
|
<SchedulesPanel v-if="ui.tab === 'auto'" />
|
|
501
|
+
<GraphPanel v-if="ui.tab === 'dag'" />
|
|
498
502
|
<NotifyPanel v-if="ui.tab === 'notify'" />
|
|
499
503
|
<EnvPanel v-if="ui.tab === 'env'" />
|
|
500
504
|
<ExtensionsPanel v-if="ui.tab === 'extensions'" />
|
package/apps/dpi-sdk/src/api.ts
CHANGED
|
@@ -233,6 +233,24 @@ export interface EnvVarView {
|
|
|
233
233
|
managed: boolean;
|
|
234
234
|
}
|
|
235
235
|
|
|
236
|
+
/** One provider credential in pi's auth.json — masked tail only, never the value. */
|
|
237
|
+
export interface PiAuthEntry {
|
|
238
|
+
providerId: string;
|
|
239
|
+
type: string;
|
|
240
|
+
source: "auth.json" | "models.json" | "both";
|
|
241
|
+
masked: string;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export interface PiAuthView {
|
|
245
|
+
entries: PiAuthEntry[];
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export interface PiAuthWriteResult {
|
|
249
|
+
providerId: string;
|
|
250
|
+
masked: string;
|
|
251
|
+
restartRequired: true;
|
|
252
|
+
}
|
|
253
|
+
|
|
236
254
|
export interface EnvFileView {
|
|
237
255
|
envFile: string;
|
|
238
256
|
exists: boolean;
|
|
@@ -251,6 +269,44 @@ export interface ModelProbe {
|
|
|
251
269
|
retryAfterMs?: number;
|
|
252
270
|
}
|
|
253
271
|
|
|
272
|
+
/** One node of a task-graph: runs as a fresh session once every dep finished ok. */
|
|
273
|
+
export interface GraphTask {
|
|
274
|
+
id: string;
|
|
275
|
+
name: string;
|
|
276
|
+
prompt: string;
|
|
277
|
+
dependsOn: string[];
|
|
278
|
+
model?: { provider: string; modelId: string };
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
export interface GraphRecord {
|
|
282
|
+
id: string;
|
|
283
|
+
name: string;
|
|
284
|
+
cwd: string;
|
|
285
|
+
tasks: GraphTask[];
|
|
286
|
+
createdAt: string;
|
|
287
|
+
updatedAt: string;
|
|
288
|
+
archivedAt: string | null;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
export type TaskRunStatus = "pending" | "running" | "ok" | "failed" | "skipped";
|
|
292
|
+
|
|
293
|
+
export interface TaskRunState {
|
|
294
|
+
status: TaskRunStatus;
|
|
295
|
+
sessionId?: string;
|
|
296
|
+
error?: string;
|
|
297
|
+
startedAt?: string;
|
|
298
|
+
endedAt?: string;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
export interface GraphRunRecord {
|
|
302
|
+
id: string;
|
|
303
|
+
graphId: string;
|
|
304
|
+
startedAt: string;
|
|
305
|
+
finishedAt: string | null;
|
|
306
|
+
status: "running" | "ok" | "failed" | "interrupted";
|
|
307
|
+
tasks: Record<string, TaskRunState>;
|
|
308
|
+
}
|
|
309
|
+
|
|
254
310
|
/** One outbound notification target on the device (webhook or ntfy). */
|
|
255
311
|
export type NotifySinkKind = "webhook" | "ntfy";
|
|
256
312
|
|
|
@@ -5,6 +5,11 @@ import type {
|
|
|
5
5
|
AgentSummary,
|
|
6
6
|
CompactionSettings,
|
|
7
7
|
EnvFileView,
|
|
8
|
+
PiAuthView,
|
|
9
|
+
PiAuthWriteResult,
|
|
10
|
+
GraphRecord,
|
|
11
|
+
GraphRunRecord,
|
|
12
|
+
GraphTask,
|
|
8
13
|
EnvVarView,
|
|
9
14
|
CreateAgentBody,
|
|
10
15
|
CreateSessionBody,
|
|
@@ -258,6 +263,35 @@ export class DpiClient {
|
|
|
258
263
|
removeEnvVar(key: string) {
|
|
259
264
|
return this.request<{ removed: boolean }>("DELETE", `/v1/device/env/${enc(key)}`);
|
|
260
265
|
}
|
|
266
|
+
/** pi provider keys — WRITE-ONLY: the view carries masked tails, never values. */
|
|
267
|
+
piAuth() {
|
|
268
|
+
return this.request<PiAuthView>("GET", "/v1/device/pi-auth");
|
|
269
|
+
}
|
|
270
|
+
setPiApiKey(providerId: string, key: string) {
|
|
271
|
+
return this.request<PiAuthWriteResult>("PUT", `/v1/device/pi-auth/${enc(providerId)}`, { key });
|
|
272
|
+
}
|
|
273
|
+
removePiApiKey(providerId: string) {
|
|
274
|
+
return this.request<{ removed: boolean; restartRequired: true }>(
|
|
275
|
+
"DELETE",
|
|
276
|
+
`/v1/device/pi-auth/${enc(providerId)}`,
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
/** Task-graphs: a DAG of prompt-tasks the device runs sequentially. */
|
|
280
|
+
graphs() {
|
|
281
|
+
return this.request<{ graphs: Array<GraphRecord & { lastRun?: GraphRunRecord }> }>("GET", "/v1/graphs");
|
|
282
|
+
}
|
|
283
|
+
graph(id: string) {
|
|
284
|
+
return this.request<{ graph: GraphRecord; runs: GraphRunRecord[] }>("GET", `/v1/graphs/${enc(id)}`);
|
|
285
|
+
}
|
|
286
|
+
createGraph(input: { name: string; cwd: string; tasks: GraphTask[] }) {
|
|
287
|
+
return this.request<GraphRecord>("POST", "/v1/graphs", input);
|
|
288
|
+
}
|
|
289
|
+
runGraph(id: string) {
|
|
290
|
+
return this.request<{ run: GraphRunRecord }>("POST", `/v1/graphs/${enc(id)}/run`, {});
|
|
291
|
+
}
|
|
292
|
+
removeGraph(id: string) {
|
|
293
|
+
return this.request<{ removed: boolean }>("DELETE", `/v1/graphs/${enc(id)}`);
|
|
294
|
+
}
|
|
261
295
|
/** Scheduled sessions on this device (device-owned clock). */
|
|
262
296
|
schedules() {
|
|
263
297
|
return this.request<{ schedules: ScheduleView[] }>("GET", "/v1/schedules");
|
|
@@ -15,6 +15,9 @@ const ROUTES: readonly (readonly [method: string, pattern: string])[] = [
|
|
|
15
15
|
["GET", "/device/env"],
|
|
16
16
|
["POST", "/device/env"],
|
|
17
17
|
["DELETE", "/device/env/:key"],
|
|
18
|
+
["GET", "/device/pi-auth"],
|
|
19
|
+
["PUT", "/device/pi-auth/:provider"],
|
|
20
|
+
["DELETE", "/device/pi-auth/:provider"],
|
|
18
21
|
["GET", "/device/usage"],
|
|
19
22
|
["GET", "/tree"],
|
|
20
23
|
["GET", "/fs/dirs"],
|
|
@@ -40,6 +43,13 @@ const ROUTES: readonly (readonly [method: string, pattern: string])[] = [
|
|
|
40
43
|
["DELETE", "/schedules/:id"],
|
|
41
44
|
["POST", "/schedules/:id/run"],
|
|
42
45
|
|
|
46
|
+
["GET", "/graphs"],
|
|
47
|
+
["POST", "/graphs"],
|
|
48
|
+
["GET", "/graphs/:id"],
|
|
49
|
+
["PATCH", "/graphs/:id"],
|
|
50
|
+
["DELETE", "/graphs/:id"],
|
|
51
|
+
["POST", "/graphs/:id/run"],
|
|
52
|
+
|
|
43
53
|
["GET", "/sessions"],
|
|
44
54
|
["POST", "/sessions"],
|
|
45
55
|
["GET", "/sessions/search"],
|
package/bin/dpi.mjs
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
// dpi backup [create|list|restore] whole-home snapshots
|
|
10
10
|
// dpi diagnostics [--out F] redacted bug-report bundle
|
|
11
11
|
// telegram status|bind|unbind|sessions Telegram chat bridge
|
|
12
|
+
// graph list|show|add|run|remove|archive|unarchive task-graph DAG
|
|
12
13
|
// dpi doctor [--json] [--quiet] one-shot device health check
|
|
13
14
|
// Every subcommand runs the TypeScript entry through tsx, so no build step is needed.
|
|
14
15
|
import { access } from "node:fs/promises";
|
|
@@ -177,6 +178,12 @@ if (command === "update" || command === "upgrade") {
|
|
|
177
178
|
register();
|
|
178
179
|
const { diagnosticsCli } = await import("../apps/dpi-backend/src/diagnostics-cli.ts");
|
|
179
180
|
process.exit(await diagnosticsCli({ argv: commandRest }));
|
|
181
|
+
} else if (command === "graph") {
|
|
182
|
+
// Task-graphs: a DAG of prompt-tasks, each run as a fresh session.
|
|
183
|
+
const { register } = await loadTsx();
|
|
184
|
+
register();
|
|
185
|
+
const { graphCli } = await import("../apps/dpi-backend/src/graph-cli.ts");
|
|
186
|
+
process.exit(await graphCli({ argv: commandRest }));
|
|
180
187
|
} else if (command === "backup") {
|
|
181
188
|
// Whole-home snapshots: create/list, restore is plan-first and refuses while
|
|
182
189
|
// the daemon runs. Nothing is ever deleted — the old home becomes a .bak.
|