my-durable 0.0.36 → 0.0.38
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 +1 -0
- package/apps/dpi-backend/src/doctor.ts +426 -0
- package/apps/dpi-backend/src/routes.ts +7 -0
- package/apps/dpi-backend/src/store.ts +121 -0
- package/apps/dpi-backend/src/vitals.ts +94 -0
- package/apps/dpi-backend/src/zip.ts +117 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/assets/index-D4M8tCcs.js +81 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/assets/{index-BxJGBCW9.css → index-xOvj8ub1.css} +1 -1
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/index.html +2 -2
- package/apps/dpi-playground/apps/dpi-playground-fe/src/client/store.ts +12 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/Composer.vue +74 -1
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/HostPanel.vue +224 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/Inspector.vue +74 -1
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/NetworkSidebar.vue +184 -4
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/NewSessionDialog.vue +41 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/TopBar.vue +68 -1
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/TreeRow.vue +17 -1
- package/apps/dpi-sdk/src/api.ts +41 -0
- package/apps/dpi-sdk/src/client.ts +17 -0
- package/apps/dpi-sdk/src/protocol/rest-routes.ts +3 -0
- package/bin/dpi.mjs +11 -0
- package/docs/host-project-checklist.md +214 -0
- package/package.json +2 -2
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/assets/index-DKJspajj.js +0 -81
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
// Host vitals for the device behind the current selection (Wave 1b): uptime,
|
|
3
|
+
// load, memory, and the free space on the volume that holds the device's data
|
|
4
|
+
// dir. Asked for when the tab is opened — no polling, matching the lazy store.
|
|
5
|
+
import { computed, ref, watch } from "vue";
|
|
6
|
+
import { Activity, RefreshCw, Server } from "lucide-vue-next";
|
|
7
|
+
import type { DeviceVitals } from "@sdk/api";
|
|
8
|
+
import { deviceClient, message } from "../client/hub";
|
|
9
|
+
import { notify, selected } from "../client/store";
|
|
10
|
+
|
|
11
|
+
const vitals = ref<DeviceVitals>();
|
|
12
|
+
const busy = ref(false);
|
|
13
|
+
const error = ref("");
|
|
14
|
+
|
|
15
|
+
const deviceId = computed(() => selected.value?.deviceId);
|
|
16
|
+
|
|
17
|
+
const kib = (bytes: number) => {
|
|
18
|
+
if (!Number.isFinite(bytes) || bytes <= 0) return "0";
|
|
19
|
+
const units = ["B", "KiB", "MiB", "GiB", "TiB"];
|
|
20
|
+
let value = bytes;
|
|
21
|
+
let unit = 0;
|
|
22
|
+
while (value >= 1024 && unit < units.length - 1) {
|
|
23
|
+
value /= 1024;
|
|
24
|
+
unit += 1;
|
|
25
|
+
}
|
|
26
|
+
return `${value >= 100 || unit === 0 ? Math.round(value) : value.toFixed(1)} ${units[unit]}`;
|
|
27
|
+
};
|
|
28
|
+
const duration = (seconds: number) => {
|
|
29
|
+
const s = Math.max(0, Math.floor(seconds));
|
|
30
|
+
if (s < 60) return `${s}s`;
|
|
31
|
+
const m = Math.floor(s / 60);
|
|
32
|
+
if (m < 60) return `${m}m`;
|
|
33
|
+
const h = Math.floor(m / 60);
|
|
34
|
+
if (h < 24) return `${h}h ${m % 60}m`;
|
|
35
|
+
return `${Math.floor(h / 24)}d ${h % 24}h`;
|
|
36
|
+
};
|
|
37
|
+
const percent = (part: number, whole: number) =>
|
|
38
|
+
whole > 0 ? Math.max(0, Math.min(100, Math.round((part / whole) * 100))) : 0;
|
|
39
|
+
|
|
40
|
+
const memUsed = computed(() => (vitals.value ? percent(vitals.value.memory.usedBytes, vitals.value.memory.totalBytes) : 0));
|
|
41
|
+
const diskUsed = computed(() =>
|
|
42
|
+
vitals.value?.disk.known ? percent(vitals.value.disk.totalBytes - vitals.value.disk.freeBytes, vitals.value.disk.totalBytes) : 0,
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
async function load() {
|
|
46
|
+
const id = deviceId.value;
|
|
47
|
+
vitals.value = undefined;
|
|
48
|
+
error.value = "";
|
|
49
|
+
if (!id) return;
|
|
50
|
+
busy.value = true;
|
|
51
|
+
try {
|
|
52
|
+
vitals.value = await deviceClient(id).vitals();
|
|
53
|
+
} catch (e) {
|
|
54
|
+
error.value = message(e).slice(0, 160);
|
|
55
|
+
} finally {
|
|
56
|
+
busy.value = false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
watch(deviceId, load, { immediate: true });
|
|
61
|
+
|
|
62
|
+
async function refresh() {
|
|
63
|
+
await load();
|
|
64
|
+
if (!error.value) notify("Vitals refreshed.");
|
|
65
|
+
}
|
|
66
|
+
</script>
|
|
67
|
+
|
|
68
|
+
<template>
|
|
69
|
+
<section class="host-panel" aria-label="Device vitals">
|
|
70
|
+
<header class="panel-heading">
|
|
71
|
+
<span><Server :size="16" />HOST</span>
|
|
72
|
+
<button
|
|
73
|
+
class="icon-button"
|
|
74
|
+
:disabled="busy || !deviceId"
|
|
75
|
+
aria-label="Refresh vitals"
|
|
76
|
+
title="Refresh vitals"
|
|
77
|
+
@click="refresh"
|
|
78
|
+
>
|
|
79
|
+
<RefreshCw :size="15" :class="{ spin: busy }" />
|
|
80
|
+
</button>
|
|
81
|
+
</header>
|
|
82
|
+
|
|
83
|
+
<p v-if="!deviceId" class="hint">Select a session to see its device.</p>
|
|
84
|
+
<p v-else-if="error" class="message-error">{{ error }}</p>
|
|
85
|
+
<p v-else-if="!vitals" class="hint">{{ busy ? "Reading host…" : "No vitals." }}</p>
|
|
86
|
+
|
|
87
|
+
<template v-else>
|
|
88
|
+
<div class="vitals-grid">
|
|
89
|
+
<div class="vital">
|
|
90
|
+
<span class="label">Host uptime</span>
|
|
91
|
+
<strong>{{ duration(vitals.uptime) }}</strong>
|
|
92
|
+
</div>
|
|
93
|
+
<div class="vital">
|
|
94
|
+
<span class="label">Device process</span>
|
|
95
|
+
<strong>{{ duration(vitals.processUptime) }}</strong>
|
|
96
|
+
<em>pid {{ vitals.pid }}</em>
|
|
97
|
+
</div>
|
|
98
|
+
<div class="vital">
|
|
99
|
+
<span class="label">Load (1/5/15m)</span>
|
|
100
|
+
<strong>{{ vitals.loadavg.map((n) => n.toFixed(2)).join(" · ") }}</strong>
|
|
101
|
+
<em>{{ vitals.cpuCount }} CPU{{ vitals.cpuCount === 1 ? "" : "s" }}</em>
|
|
102
|
+
</div>
|
|
103
|
+
<div class="vital">
|
|
104
|
+
<span class="label">Sessions</span>
|
|
105
|
+
<strong>{{ vitals.counts?.sessions ?? 0 }}</strong>
|
|
106
|
+
<em>{{ vitals.counts?.archived ?? 0 }} archived</em>
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
109
|
+
|
|
110
|
+
<div class="meter">
|
|
111
|
+
<div class="meter-head">
|
|
112
|
+
<span class="label">Memory</span>
|
|
113
|
+
<span class="hint">
|
|
114
|
+
{{ kib(vitals.memory.usedBytes) }} / {{ kib(vitals.memory.totalBytes) }} · device
|
|
115
|
+
{{ kib(vitals.memory.processRssBytes) }}
|
|
116
|
+
</span>
|
|
117
|
+
</div>
|
|
118
|
+
<div class="bar" role="meter" :aria-valuenow="memUsed" aria-valuemin="0" aria-valuemax="100" aria-label="Memory used">
|
|
119
|
+
<i :style="{ width: `${memUsed}%` }" :class="{ high: memUsed >= 90 }" />
|
|
120
|
+
</div>
|
|
121
|
+
</div>
|
|
122
|
+
|
|
123
|
+
<div class="meter">
|
|
124
|
+
<div class="meter-head">
|
|
125
|
+
<span class="label">Disk · data dir</span>
|
|
126
|
+
<span class="hint">
|
|
127
|
+
<template v-if="vitals.disk.known">
|
|
128
|
+
{{ kib(vitals.disk.totalBytes - vitals.disk.freeBytes) }} used ·
|
|
129
|
+
{{ kib(vitals.disk.freeBytes) }} free
|
|
130
|
+
</template>
|
|
131
|
+
<template v-else>unknown on this volume</template>
|
|
132
|
+
</span>
|
|
133
|
+
</div>
|
|
134
|
+
<div class="bar" role="meter" :aria-valuenow="diskUsed" aria-valuemin="0" aria-valuemax="100" aria-label="Disk used">
|
|
135
|
+
<i :style="{ width: `${diskUsed}%` }" :class="{ high: diskUsed >= 90 }" />
|
|
136
|
+
</div>
|
|
137
|
+
<code class="path">{{ vitals.disk.path }}</code>
|
|
138
|
+
</div>
|
|
139
|
+
|
|
140
|
+
<p class="hint">
|
|
141
|
+
<Activity :size="13" /> Read on demand — open this tab or press refresh. Nothing polls the device.
|
|
142
|
+
</p>
|
|
143
|
+
</template>
|
|
144
|
+
</section>
|
|
145
|
+
</template>
|
|
146
|
+
|
|
147
|
+
<style scoped>
|
|
148
|
+
.host-panel {
|
|
149
|
+
display: flex;
|
|
150
|
+
flex-direction: column;
|
|
151
|
+
gap: 12px;
|
|
152
|
+
padding: 4px 2px 12px;
|
|
153
|
+
font-size: 16px;
|
|
154
|
+
}
|
|
155
|
+
.vitals-grid {
|
|
156
|
+
display: grid;
|
|
157
|
+
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
|
|
158
|
+
gap: 10px;
|
|
159
|
+
}
|
|
160
|
+
.vital {
|
|
161
|
+
display: flex;
|
|
162
|
+
flex-direction: column;
|
|
163
|
+
gap: 2px;
|
|
164
|
+
padding: 10px 12px;
|
|
165
|
+
border: 1px solid var(--line);
|
|
166
|
+
border-radius: 10px;
|
|
167
|
+
}
|
|
168
|
+
.vital .label,
|
|
169
|
+
.meter .label {
|
|
170
|
+
color: var(--fg-dim, var(--fg));
|
|
171
|
+
opacity: 0.72;
|
|
172
|
+
font-size: 13px;
|
|
173
|
+
text-transform: uppercase;
|
|
174
|
+
letter-spacing: 0.04em;
|
|
175
|
+
}
|
|
176
|
+
.vital strong {
|
|
177
|
+
font-size: 18px;
|
|
178
|
+
font-variant-numeric: tabular-nums;
|
|
179
|
+
}
|
|
180
|
+
.vital em {
|
|
181
|
+
font-style: normal;
|
|
182
|
+
font-size: 13px;
|
|
183
|
+
opacity: 0.7;
|
|
184
|
+
}
|
|
185
|
+
.meter {
|
|
186
|
+
display: flex;
|
|
187
|
+
flex-direction: column;
|
|
188
|
+
gap: 6px;
|
|
189
|
+
}
|
|
190
|
+
.meter-head {
|
|
191
|
+
display: flex;
|
|
192
|
+
justify-content: space-between;
|
|
193
|
+
align-items: baseline;
|
|
194
|
+
gap: 12px;
|
|
195
|
+
}
|
|
196
|
+
.bar {
|
|
197
|
+
height: 8px;
|
|
198
|
+
border-radius: 999px;
|
|
199
|
+
background: var(--line);
|
|
200
|
+
overflow: hidden;
|
|
201
|
+
}
|
|
202
|
+
.bar i {
|
|
203
|
+
display: block;
|
|
204
|
+
height: 100%;
|
|
205
|
+
background: var(--accent);
|
|
206
|
+
transition: width 0.3s ease;
|
|
207
|
+
}
|
|
208
|
+
.bar i.high {
|
|
209
|
+
background: var(--warn, #e5a50a);
|
|
210
|
+
}
|
|
211
|
+
.path {
|
|
212
|
+
font-size: 13px;
|
|
213
|
+
opacity: 0.7;
|
|
214
|
+
word-break: break-all;
|
|
215
|
+
}
|
|
216
|
+
.spin {
|
|
217
|
+
animation: spin 1s linear infinite;
|
|
218
|
+
}
|
|
219
|
+
@keyframes spin {
|
|
220
|
+
to {
|
|
221
|
+
transform: rotate(360deg);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
</style>
|
|
@@ -3,6 +3,8 @@ import { computed, ref, watch } from "vue";
|
|
|
3
3
|
import {
|
|
4
4
|
Activity,
|
|
5
5
|
Braces,
|
|
6
|
+
Download,
|
|
7
|
+
PackageOpen,
|
|
6
8
|
GitBranch,
|
|
7
9
|
ChevronDown,
|
|
8
10
|
FolderOpen,
|
|
@@ -21,9 +23,10 @@ import TunnelStatusBar from "./TunnelStatusBar.vue";
|
|
|
21
23
|
import TokenManager from "./TokenManager.vue";
|
|
22
24
|
import TasksPanel from "./TasksPanel.vue";
|
|
23
25
|
import GitPanel from "./GitPanel.vue";
|
|
26
|
+
import HostPanel from "./HostPanel.vue";
|
|
24
27
|
import ExtensionsPanel from "./ExtensionsPanel.vue";
|
|
25
28
|
import ContextBar from "./ContextBar.vue";
|
|
26
|
-
import { message } from "../client/hub";
|
|
29
|
+
import { deviceClient, message } from "../client/hub";
|
|
27
30
|
import { toolSignature } from "../client/signature";
|
|
28
31
|
import {
|
|
29
32
|
agentHandle,
|
|
@@ -41,6 +44,7 @@ import {
|
|
|
41
44
|
notify,
|
|
42
45
|
number,
|
|
43
46
|
refreshDetail,
|
|
47
|
+
selected,
|
|
44
48
|
session,
|
|
45
49
|
sessionHandle,
|
|
46
50
|
sessionSummary,
|
|
@@ -59,6 +63,7 @@ const signatures = computed(
|
|
|
59
63
|
const tabs = [
|
|
60
64
|
{ id: "session", label: "Session", icon: FolderOpen },
|
|
61
65
|
{ id: "git", label: "Git", icon: GitBranch },
|
|
66
|
+
{ id: "host", label: "Host", icon: Activity },
|
|
62
67
|
{ id: "state", label: "State", icon: Braces },
|
|
63
68
|
{ id: "tasks", label: "Tasks", icon: Activity },
|
|
64
69
|
{ id: "tools", label: "Tools", icon: Wrench },
|
|
@@ -71,6 +76,7 @@ const usageRows = computed(() => [
|
|
|
71
76
|
{ label: "Cache write", tokens: usage.value.cacheWrite, cost: usage.value.cacheWriteCost },
|
|
72
77
|
]);
|
|
73
78
|
const background = computed(() => tasks.value.filter((t) => t.background).length);
|
|
79
|
+
const exporting = ref(false);
|
|
74
80
|
|
|
75
81
|
function configure(
|
|
76
82
|
patch: Parameters<NonNullable<typeof agentHandle.value>["configure"]>[0],
|
|
@@ -83,6 +89,50 @@ function configure(
|
|
|
83
89
|
});
|
|
84
90
|
}
|
|
85
91
|
|
|
92
|
+
/** Transcript download (API existed since v1; the FE button is the checklist's
|
|
93
|
+
* Wave 1a). Markdown straight from the device into a file. */
|
|
94
|
+
async function downloadTranscript() {
|
|
95
|
+
const dev = device.value;
|
|
96
|
+
const summary = sessionSummary.value;
|
|
97
|
+
if (!dev || !summary) return;
|
|
98
|
+
try {
|
|
99
|
+
const r = await deviceClient(dev.id).agent(summary.id, selected.value?.agentId ?? 1).transcript("markdown");
|
|
100
|
+
const blob = new Blob([typeof r === "string" ? r : JSON.stringify(r)], { type: "text/markdown" });
|
|
101
|
+
const a = document.createElement("a");
|
|
102
|
+
a.href = URL.createObjectURL(blob);
|
|
103
|
+
a.download = `${summary.name.replace(/[^\w.-]+/g, "_") || "session"}-${summary.id.slice(0, 8)}.md`;
|
|
104
|
+
a.click();
|
|
105
|
+
URL.revokeObjectURL(a.href);
|
|
106
|
+
notify("Transcript downloaded.");
|
|
107
|
+
} catch (e) {
|
|
108
|
+
notify(`transcript download failed: ${message(e).slice(0, 120)}`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** Whole-session bundle (Wave 1b): manifest + record + every agent's
|
|
113
|
+
* transcript and config, zipped on the device (base64 over the tunnel). */
|
|
114
|
+
async function downloadBundle() {
|
|
115
|
+
const dev = device.value;
|
|
116
|
+
const summary = sessionSummary.value;
|
|
117
|
+
if (!dev || !summary) return;
|
|
118
|
+
exporting.value = true;
|
|
119
|
+
try {
|
|
120
|
+
const r = await deviceClient(dev.id).exportSession(summary.id);
|
|
121
|
+
const bytes = Uint8Array.from(atob(r.base64), (c) => c.charCodeAt(0));
|
|
122
|
+
const online = URL.createObjectURL(new Blob([bytes], { type: r.mime || "application/zip" }));
|
|
123
|
+
const a = document.createElement("a");
|
|
124
|
+
a.href = online;
|
|
125
|
+
a.download = r.filename;
|
|
126
|
+
a.click();
|
|
127
|
+
URL.revokeObjectURL(online);
|
|
128
|
+
notify(`Bundle downloaded (${Math.max(1, Math.round(r.bytes / 1024))} KiB).`);
|
|
129
|
+
} catch (e) {
|
|
130
|
+
notify(`bundle export failed: ${message(e).slice(0, 120)}`);
|
|
131
|
+
} finally {
|
|
132
|
+
exporting.value = false;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
86
136
|
function renameSession() {
|
|
87
137
|
const handle = sessionHandle.value;
|
|
88
138
|
if (!handle) return;
|
|
@@ -226,6 +276,21 @@ const offeredTools = computed(() => detail.value?.tools.filter((t) => t.offered)
|
|
|
226
276
|
@click="renameSession"
|
|
227
277
|
>
|
|
228
278
|
<Pencil :size="18" />
|
|
279
|
+
</button><button
|
|
280
|
+
class="icon-button"
|
|
281
|
+
title="Download transcript (markdown)"
|
|
282
|
+
aria-label="Download transcript"
|
|
283
|
+
@click="downloadTranscript"
|
|
284
|
+
>
|
|
285
|
+
<Download :size="18" />
|
|
286
|
+
</button><button
|
|
287
|
+
class="icon-button"
|
|
288
|
+
title="Download session bundle (.zip: manifest, transcripts, configs)"
|
|
289
|
+
aria-label="Download session bundle"
|
|
290
|
+
:disabled="exporting"
|
|
291
|
+
@click="downloadBundle"
|
|
292
|
+
>
|
|
293
|
+
<PackageOpen :size="18" />
|
|
229
294
|
</button>
|
|
230
295
|
</h1>
|
|
231
296
|
<button
|
|
@@ -310,6 +375,11 @@ const offeredTools = computed(() => detail.value?.tools.filter((t) => t.offered)
|
|
|
310
375
|
<td>{{ row.tokens.toLocaleString("en-US") }}</td>
|
|
311
376
|
<td>${{ row.cost.toFixed(4) }}</td>
|
|
312
377
|
</tr>
|
|
378
|
+
<tr class="usage-total">
|
|
379
|
+
<th scope="row">Total</th>
|
|
380
|
+
<td>{{ usage.tokens.toLocaleString("en-US") }}</td>
|
|
381
|
+
<td>${{ usage.cost.toFixed(4) }}</td>
|
|
382
|
+
</tr>
|
|
313
383
|
</tbody>
|
|
314
384
|
</table>
|
|
315
385
|
</section>
|
|
@@ -362,6 +432,7 @@ const offeredTools = computed(() => detail.value?.tools.filter((t) => t.offered)
|
|
|
362
432
|
</template>
|
|
363
433
|
<TasksPanel v-if="ui.tab === 'tasks'" />
|
|
364
434
|
<GitPanel v-if="ui.tab === 'git'" />
|
|
435
|
+
<HostPanel v-if="ui.tab === 'host'" />
|
|
365
436
|
<ExtensionsPanel v-if="ui.tab === 'extensions'" />
|
|
366
437
|
<template v-if="ui.tab === 'tools'"
|
|
367
438
|
><div class="panel-heading">
|
|
@@ -427,3 +498,5 @@ const offeredTools = computed(() => detail.value?.tools.filter((t) => t.offered)
|
|
|
427
498
|
</template>
|
|
428
499
|
</aside>
|
|
429
500
|
</template>
|
|
501
|
+
|
|
502
|
+
<style scoped>.usage-total th, .usage-total td { border-top: 1px solid var(--line); font-weight: 650; }</style>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { computed, nextTick, ref } from "vue";
|
|
3
|
-
import { Link2, Network, PanelLeftClose, PanelLeftOpen } from "lucide-vue-next";
|
|
2
|
+
import { computed, nextTick, ref, watch } from "vue";
|
|
3
|
+
import { Link2, ListChecks, Network, PanelLeftClose, PanelLeftOpen, Search, X } from "lucide-vue-next";
|
|
4
4
|
import DeviceIcon from "./DeviceIcon.vue";
|
|
5
5
|
import type { TreeNode } from "@sdk/models";
|
|
6
6
|
import TreeRow from "./TreeRow.vue";
|
|
@@ -39,6 +39,104 @@ const rows = computed(() => {
|
|
|
39
39
|
const focusKey = ref<string>();
|
|
40
40
|
const list = ref<HTMLElement>();
|
|
41
41
|
|
|
42
|
+
/** Session search (paseo `agent-history-search`, cheap v1). The local pass
|
|
43
|
+
* filters the tree instantly; the device pass asks each online device for its
|
|
44
|
+
* own matches (names/cwds/models) so results do not depend on how fresh the
|
|
45
|
+
* hub's tree is. Transcripts are not scanned — that needs an FTS index. */
|
|
46
|
+
const query = ref("");
|
|
47
|
+
const deviceHits = ref<{ deviceId: string; name: string; cwd: string; id: string; where: string[] }[]>([]);
|
|
48
|
+
const searching = ref(false);
|
|
49
|
+
const needle = computed(() => query.value.trim().toLowerCase());
|
|
50
|
+
const filtering = computed(() => needle.value.length >= 2);
|
|
51
|
+
|
|
52
|
+
/** Sessions whose name/cwd matches — the anchor a filter keeps the tree around. */
|
|
53
|
+
const matchedSessions = computed(() => {
|
|
54
|
+
const ids = new Set<string>();
|
|
55
|
+
if (!filtering.value) return ids;
|
|
56
|
+
for (const device of network.devices.value)
|
|
57
|
+
for (const session of device.tree?.sessions ?? [])
|
|
58
|
+
if (`${session.name}\n${session.cwd}`.toLowerCase().includes(needle.value)) ids.add(session.id);
|
|
59
|
+
return ids;
|
|
60
|
+
});
|
|
61
|
+
/** A filter keeps the matched sessions, their agents, and the devices holding
|
|
62
|
+
* them — a hit you cannot locate in the tree is a riddle, not a result. */
|
|
63
|
+
const localRows = computed(() => {
|
|
64
|
+
if (!filtering.value) return rows.value;
|
|
65
|
+
const keep = (node: TreeNode): boolean => {
|
|
66
|
+
if (node.type === "session") return matchedSessions.value.has(node.session.id);
|
|
67
|
+
if (node.type === "agent")
|
|
68
|
+
return matchedSessions.value.has(node.sessionId) || node.agent.name.toLowerCase().includes(needle.value);
|
|
69
|
+
return (node.device.tree?.sessions ?? []).some((s) => matchedSessions.value.has(s.id));
|
|
70
|
+
};
|
|
71
|
+
const visible = new Set(rows.value.filter((row) => keep(row.node)).map((row) => row.node.key));
|
|
72
|
+
return rows.value.filter((row) => visible.has(row.node.key));
|
|
73
|
+
});
|
|
74
|
+
/** Device hits the tree already shows are dropped: one row per session. */
|
|
75
|
+
const extraHits = computed(() =>
|
|
76
|
+
deviceHits.value.filter((hit) => !rows.value.some((r) => r.node.type === "session" && r.node.session.id === hit.id)),
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
let searchTimer: ReturnType<typeof setTimeout> | undefined;
|
|
80
|
+
watch(query, (value) => {
|
|
81
|
+
clearTimeout(searchTimer);
|
|
82
|
+
const q = value.trim();
|
|
83
|
+
if (q.length < 2) {
|
|
84
|
+
deviceHits.value = [];
|
|
85
|
+
searching.value = false;
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
searchTimer = setTimeout(async () => {
|
|
89
|
+
searching.value = true;
|
|
90
|
+
const found: typeof deviceHits.value = [];
|
|
91
|
+
for (const device of network.devices.value.filter((d) => d.status === "online")) {
|
|
92
|
+
const result = await deviceClient(device.id)
|
|
93
|
+
.searchSessions(q)
|
|
94
|
+
.catch(() => undefined);
|
|
95
|
+
for (const match of result?.matches ?? [])
|
|
96
|
+
found.push({ deviceId: device.id, id: match.id, name: match.name, cwd: match.cwd, where: match.where });
|
|
97
|
+
}
|
|
98
|
+
deviceHits.value = found;
|
|
99
|
+
searching.value = false;
|
|
100
|
+
}, 250);
|
|
101
|
+
});
|
|
102
|
+
const clearSearch = () => ((query.value = ""), (deviceHits.value = []));
|
|
103
|
+
|
|
104
|
+
/** Bulk session manage (orca ManageSessionsSection): select many, then
|
|
105
|
+
* archive/abort each with a per-row result. Client-side loop over the
|
|
106
|
+
* existing APIs — no new backend surface. */
|
|
107
|
+
const bulkMode = ref(false);
|
|
108
|
+
const bulkSel = ref(new Set<string>());
|
|
109
|
+
const bulkBusy = ref("");
|
|
110
|
+
const bulkToggle = (node: TreeNode) => {
|
|
111
|
+
if (node.type !== "session") return;
|
|
112
|
+
const next = new Set(bulkSel.value);
|
|
113
|
+
if (next.has(node.session.id)) next.delete(node.session.id);
|
|
114
|
+
else next.add(node.session.id);
|
|
115
|
+
bulkSel.value = next;
|
|
116
|
+
};
|
|
117
|
+
const bulkRun = async (op: "archive" | "abort") => {
|
|
118
|
+
bulkBusy.value = op;
|
|
119
|
+
let ok = 0;
|
|
120
|
+
const failed: string[] = [];
|
|
121
|
+
for (const node of rows.value.map((r) => r.node)) {
|
|
122
|
+
if (node.type !== "session" || !bulkSel.value.has(node.session.id)) continue;
|
|
123
|
+
const device = deviceOf(node);
|
|
124
|
+
if (!device) continue;
|
|
125
|
+
const client = deviceClient(device.id);
|
|
126
|
+
try {
|
|
127
|
+
if (op === "archive") await client.session(node.session.id).archive();
|
|
128
|
+
else await client.agent(node.session.id, 1).abort(true);
|
|
129
|
+
ok++;
|
|
130
|
+
if (op === "archive" && selected.value?.sessionId === node.session.id) select(undefined);
|
|
131
|
+
} catch {
|
|
132
|
+
failed.push(node.session.name);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
notify(`${op}: ${ok} done${failed.length ? `, ${failed.length} failed (${failed.slice(0, 3).join(", ")})` : ""}`);
|
|
136
|
+
bulkSel.value = new Set();
|
|
137
|
+
bulkBusy.value = "";
|
|
138
|
+
};
|
|
139
|
+
|
|
42
140
|
const deviceOf = (node: TreeNode) =>
|
|
43
141
|
network.devices.value.find(
|
|
44
142
|
(d) => d.id === (node.type === "device" ? node.device.id : node.deviceId),
|
|
@@ -52,6 +150,7 @@ const isSelected = (node: TreeNode) =>
|
|
|
52
150
|
|
|
53
151
|
function activate(node: TreeNode) {
|
|
54
152
|
focusKey.value = node.key;
|
|
153
|
+
if (bulkMode.value && node.type === "session") return bulkToggle(node);
|
|
55
154
|
if (node.type === "device") return toggle(node.key);
|
|
56
155
|
if (node.type === "agent")
|
|
57
156
|
return select({ deviceId: node.deviceId, sessionId: node.sessionId, agentId: node.agent.id });
|
|
@@ -156,6 +255,15 @@ function keydown(e: KeyboardEvent) {
|
|
|
156
255
|
<template v-if="layout.tree || ui.drawer">
|
|
157
256
|
<header class="tree-head">
|
|
158
257
|
<span><Network :size="16" />NETWORK</span>
|
|
258
|
+
<button
|
|
259
|
+
class="icon-button"
|
|
260
|
+
:aria-label="bulkMode ? 'Exit bulk select' : 'Bulk manage sessions'"
|
|
261
|
+
:title="bulkMode ? 'Exit bulk select' : 'Bulk manage sessions (select → archive / abort)'"
|
|
262
|
+
:class="{ on: bulkMode }"
|
|
263
|
+
@click="((bulkMode = !bulkMode), (bulkSel = new Set()))"
|
|
264
|
+
>
|
|
265
|
+
<ListChecks :size="15" />
|
|
266
|
+
</button>
|
|
159
267
|
<button
|
|
160
268
|
class="icon-button"
|
|
161
269
|
aria-label="Pair a device"
|
|
@@ -173,6 +281,21 @@ function keydown(e: KeyboardEvent) {
|
|
|
173
281
|
<PanelLeftClose :size="18" />
|
|
174
282
|
</button>
|
|
175
283
|
</header>
|
|
284
|
+
<div class="tree-search">
|
|
285
|
+
<Search :size="14" class="search-icon" />
|
|
286
|
+
<input
|
|
287
|
+
v-model="query"
|
|
288
|
+
type="search"
|
|
289
|
+
class="search-input"
|
|
290
|
+
placeholder="Search sessions…"
|
|
291
|
+
aria-label="Search sessions"
|
|
292
|
+
spellcheck="false"
|
|
293
|
+
/>
|
|
294
|
+
<button v-if="query" class="icon-button clear" aria-label="Clear search" @click="clearSearch">
|
|
295
|
+
<X :size="13" />
|
|
296
|
+
</button>
|
|
297
|
+
<span v-if="searching" class="searching" aria-label="Searching devices">…</span>
|
|
298
|
+
</div>
|
|
176
299
|
<div
|
|
177
300
|
ref="list"
|
|
178
301
|
class="tree-list"
|
|
@@ -182,8 +305,15 @@ function keydown(e: KeyboardEvent) {
|
|
|
182
305
|
@keydown="keydown"
|
|
183
306
|
@focus="focusFirst"
|
|
184
307
|
>
|
|
308
|
+
<div v-if="bulkMode && bulkSel.size" class="bulk-bar">
|
|
309
|
+
<span>{{ bulkSel.size }} selected</span>
|
|
310
|
+
<button class="small" :disabled="!!bulkBusy" @click="bulkRun('abort')">abort work</button>
|
|
311
|
+
<button class="small danger" :disabled="!!bulkBusy" @click="bulkRun('archive')">
|
|
312
|
+
{{ bulkBusy === "archive" ? "archiving…" : "archive" }}
|
|
313
|
+
</button>
|
|
314
|
+
</div>
|
|
185
315
|
<TreeRow
|
|
186
|
-
v-for="row in
|
|
316
|
+
v-for="row in localRows"
|
|
187
317
|
:key="row.node.key"
|
|
188
318
|
:node="row.node"
|
|
189
319
|
:depth="row.depth"
|
|
@@ -191,11 +321,31 @@ function keydown(e: KeyboardEvent) {
|
|
|
191
321
|
:selected="isSelected(row.node)"
|
|
192
322
|
:focused="focusKey === row.node.key"
|
|
193
323
|
:online="isOnline(row.node)"
|
|
324
|
+
:checkbox="bulkMode && row.node.type === 'session'"
|
|
325
|
+
:checked="row.node.type === 'session' && bulkSel.has(row.node.session.id)"
|
|
194
326
|
@toggle="toggle(row.node.key)"
|
|
195
327
|
@activate="activate(row.node)"
|
|
196
328
|
@action="action(row.node, $event)"
|
|
329
|
+
@check="bulkToggle(row.node)"
|
|
197
330
|
/>
|
|
198
|
-
<
|
|
331
|
+
<template v-if="filtering && extraHits.length">
|
|
332
|
+
<div class="hit-head hint">{{ extraHits.length }} more on device</div>
|
|
333
|
+
<button
|
|
334
|
+
v-for="hit in extraHits"
|
|
335
|
+
:key="`${hit.deviceId}-${hit.id}`"
|
|
336
|
+
class="hit"
|
|
337
|
+
:title="hit.cwd"
|
|
338
|
+
@click="select({ deviceId: hit.deviceId, sessionId: hit.id, agentId: 1 })"
|
|
339
|
+
>
|
|
340
|
+
<span class="hit-name">{{ hit.name }}</span>
|
|
341
|
+
<code class="hit-cwd">{{ hit.cwd }}</code>
|
|
342
|
+
<em v-if="hit.where.length" class="hit-where">{{ hit.where.join(" · ") }}</em>
|
|
343
|
+
</button>
|
|
344
|
+
</template>
|
|
345
|
+
<p v-if="filtering && !localRows.length && !extraHits.length" class="hint tree-empty">
|
|
346
|
+
No session matches “{{ query.trim() }}”.
|
|
347
|
+
</p>
|
|
348
|
+
<p v-if="!rows.length && !filtering" class="hint tree-empty" data-testid="tree-empty">
|
|
199
349
|
No devices yet. Declare them in <code>dpi-network.yaml</code> (start from
|
|
200
350
|
<code>dpi-network.example.yaml</code>), then run <code>just net up <id></code>.
|
|
201
351
|
</p>
|
|
@@ -234,3 +384,33 @@ function keydown(e: KeyboardEvent) {
|
|
|
234
384
|
</div>
|
|
235
385
|
</aside>
|
|
236
386
|
</template>
|
|
387
|
+
|
|
388
|
+
<style scoped>
|
|
389
|
+
.tree-search {
|
|
390
|
+
display: flex; align-items: center; gap: 6px; margin: 4px 6px 2px;
|
|
391
|
+
padding: 0 8px; border: 1px solid var(--line); border-radius: 8px;
|
|
392
|
+
}
|
|
393
|
+
.tree-search:focus-within { border-color: var(--accent); }
|
|
394
|
+
.tree-search .search-icon { opacity: 0.6; flex: none; }
|
|
395
|
+
.search-input {
|
|
396
|
+
flex: 1; min-width: 0; border: 0; background: transparent; color: var(--fg);
|
|
397
|
+
font-size: 14px; padding: 6px 0; outline: none;
|
|
398
|
+
}
|
|
399
|
+
.search-input::-webkit-search-cancel-button { display: none; }
|
|
400
|
+
.tree-search .clear { padding: 2px; }
|
|
401
|
+
.searching { opacity: 0.6; font-size: 13px; }
|
|
402
|
+
.hit-head { margin: 6px 2px 2px; }
|
|
403
|
+
.hit {
|
|
404
|
+
display: flex; flex-direction: column; gap: 1px; width: 100%; text-align: left;
|
|
405
|
+
background: none; border: 1px solid transparent; border-radius: 8px;
|
|
406
|
+
padding: 5px 8px; color: var(--fg); font-size: 15px; cursor: pointer;
|
|
407
|
+
}
|
|
408
|
+
.hit:hover { border-color: var(--line); background: var(--hover, rgba(127,127,127,0.08)); }
|
|
409
|
+
.hit-cwd { font-size: 12px; opacity: 0.65; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
410
|
+
.hit-where { font-style: normal; font-size: 11px; opacity: 0.5; text-transform: uppercase; letter-spacing: 0.04em; }
|
|
411
|
+
.bulk-bar {
|
|
412
|
+
display: flex; gap: 8px; align-items: center; padding: 6px 10px; margin: 4px 0;
|
|
413
|
+
border: 1px solid var(--line); border-radius: 8px; font-size: 14px;
|
|
414
|
+
}
|
|
415
|
+
.bulk-bar .danger { border-color: var(--warn, #e5a50a); }
|
|
416
|
+
</style>
|
|
@@ -42,6 +42,24 @@ const catalogEmpty = computed(
|
|
|
42
42
|
const keyless = computed(() => !!(device.value?.info as { providerKeyMissing?: boolean } | undefined)?.providerKeyMissing);
|
|
43
43
|
const key = (m: { provider: string; id: string }) => `${m.provider}/${m.id}`;
|
|
44
44
|
const draft = ref({ name: "", cwd: "", model: "" });
|
|
45
|
+
/** orca new-workspace composer: the last N working dirs per device, one click
|
|
46
|
+
* away. localStorage only — the device never learns about recents. */
|
|
47
|
+
const RECENT_KEY = "dpi-recent-cwds";
|
|
48
|
+
type Recents = Record<string, string[]>;
|
|
49
|
+
const recentCwds = computed(() => {
|
|
50
|
+
try {
|
|
51
|
+
return (JSON.parse(localStorage.getItem(RECENT_KEY) ?? "{}") as Recents)[deviceId.value] ?? [];
|
|
52
|
+
} catch {
|
|
53
|
+
return [];
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
const rememberCwd = (devId: string, cwd: string) => {
|
|
57
|
+
try {
|
|
58
|
+
const all = JSON.parse(localStorage.getItem(RECENT_KEY) ?? "{}") as Recents;
|
|
59
|
+
const kept = [cwd, ...(all[devId] ?? []).filter((c) => c !== cwd)].slice(0, 6);
|
|
60
|
+
localStorage.setItem(RECENT_KEY, JSON.stringify({ ...all, [devId]: kept }));
|
|
61
|
+
} catch {}
|
|
62
|
+
};
|
|
45
63
|
const pending = ref(false);
|
|
46
64
|
const error = ref("");
|
|
47
65
|
|
|
@@ -69,6 +87,7 @@ async function create() {
|
|
|
69
87
|
cwd: draft.value.cwd.trim(),
|
|
70
88
|
model: { provider: model.provider, modelId: model.id },
|
|
71
89
|
});
|
|
90
|
+
rememberCwd(device.value.id, created.cwd);
|
|
72
91
|
const root = created.agents.find((a) => a.kind === "root") ?? created.agents[0];
|
|
73
92
|
select({ deviceId: device.value.id, sessionId: created.id, agentId: root?.id ?? 1 });
|
|
74
93
|
notify(`Session created on ${device.value.id}.`);
|
|
@@ -119,6 +138,19 @@ async function create() {
|
|
|
119
138
|
/></label>
|
|
120
139
|
<div class="field">
|
|
121
140
|
<span>Working directory on {{ devices.find((d) => d.id === deviceId)?.name ?? deviceId }}</span>
|
|
141
|
+
<div v-if="recentCwds.length" class="recent-cwds">
|
|
142
|
+
<button
|
|
143
|
+
v-for="c in recentCwds"
|
|
144
|
+
:key="c"
|
|
145
|
+
type="button"
|
|
146
|
+
class="chip"
|
|
147
|
+
:class="{ on: c === draft.cwd }"
|
|
148
|
+
:title="c"
|
|
149
|
+
@click="draft.cwd = c"
|
|
150
|
+
>
|
|
151
|
+
{{ c.split("/").filter(Boolean).at(-1) || c }}
|
|
152
|
+
</button>
|
|
153
|
+
</div>
|
|
122
154
|
<DirBrowser v-model="draft.cwd" :device-id="deviceId" />
|
|
123
155
|
</div>
|
|
124
156
|
<label
|
|
@@ -144,3 +176,12 @@ async function create() {
|
|
|
144
176
|
</form>
|
|
145
177
|
</div>
|
|
146
178
|
</template>
|
|
179
|
+
|
|
180
|
+
<style scoped>
|
|
181
|
+
.recent-cwds { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
|
|
182
|
+
.recent-cwds .chip {
|
|
183
|
+
font-size: 13px; padding: 3px 10px; border: 1px solid var(--line); border-radius: 12px;
|
|
184
|
+
background: none; cursor: pointer; color: inherit;
|
|
185
|
+
}
|
|
186
|
+
.recent-cwds .chip.on { border-color: var(--accent); font-weight: 550; }
|
|
187
|
+
</style>
|