my-durable 0.0.49 → 0.0.51

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.
@@ -6,6 +6,7 @@ import { computed, ref, watch } from "vue";
6
6
  import { CalendarClock, Play, Plus, RefreshCw, Trash2, Power } from "lucide-vue-next";
7
7
  import type { ScheduleView } from "@sdk/api";
8
8
  import { deviceClient, message } from "../client/hub";
9
+ import { isStaleDeviceError, staleDeviceHint } from "../client/stale";
9
10
  import { notify, selected, ui } from "../client/store";
10
11
 
11
12
  const schedules = ref<ScheduleView[]>([]);
@@ -27,11 +28,9 @@ async function load() {
27
28
  try {
28
29
  schedules.value = (await client().schedules()).schedules;
29
30
  } 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);
31
+ error.value = isStaleDeviceError(e)
32
+ ? staleDeviceHint(deviceId.value, "schedules")
33
+ : message(e).slice(0, 220);
35
34
  } finally {
36
35
  loading.value = false;
37
36
  }
@@ -7,6 +7,7 @@ import { computed, ref, watch } from "vue";
7
7
  import { Activity, Cpu, FolderGit2, RefreshCw } from "lucide-vue-next";
8
8
  import type { DeviceUsageReport } from "@sdk/api";
9
9
  import { deviceClient, message } from "../client/hub";
10
+ import { isStaleDeviceError, staleDeviceHint } from "../client/stale";
10
11
  import { notify, selected } from "../client/store";
11
12
 
12
13
  const usage = ref<DeviceUsageReport>();
@@ -54,11 +55,9 @@ async function load() {
54
55
  try {
55
56
  usage.value = await deviceClient(id).deviceUsage();
56
57
  } catch (e) {
57
- const text = message(e);
58
- error.value =
59
- (e as { code?: string }).code === "not_found" || /allowlist|not found/i.test(text)
60
- ? "This device runs an older build: update it (`dpi update`) to see usage."
61
- : text.slice(0, 160);
58
+ error.value = isStaleDeviceError(e)
59
+ ? staleDeviceHint(deviceId.value, "usage")
60
+ : message(e).slice(0, 220);
62
61
  } finally {
63
62
  busy.value = false;
64
63
  }
@@ -130,6 +130,10 @@ export class App {
130
130
  private suggIndex = 0;
131
131
  /** Hub feed (multi-host display parity with the web sidebar). */
132
132
  private hub?: { url: string; token: string };
133
+ /** Public read for the welcome screen: is hub mode on? */
134
+ get hubUrl(): string | undefined {
135
+ return this.hub?.url;
136
+ }
133
137
  /** The hub's /api/stream mux — tunnel-device attach (same transport as the web). */
134
138
  private mux?: HubMux;
135
139
  /** True while the current device is reached through the hub proxy. */
@@ -122,13 +122,31 @@ function isLoopbackUrl(url: string): boolean {
122
122
  }
123
123
  }
124
124
 
125
+ // Hub credentials, resolved once: every startup path (welcome included) can
126
+ // offer the hub network.
127
+ const hubEnv = (() => {
128
+ const u = values["hub-url"] ?? process.env.DPI_HUB_URL;
129
+ const t = values["hub-token"] ?? process.env.DPI_HUB_TOKEN;
130
+ return u && t ? { url: u, token: t } : undefined;
131
+ })();
132
+
125
133
  // The app opens first; connection is a state, not a precondition. With no explicit
126
134
  // device/url/pair: one saved device opens it directly, several open on the first
127
135
  // with the device picker on top, none open the welcome screen.
128
136
  const startup = resolveStartupAction({ devices: registry.list(), env: process.env, args: { deviceRef, url, pair: values.pair } });
129
137
 
130
138
  if (startup.kind === "welcome") {
131
- showWelcome(new App(WELCOME_DEVICE, new DpiClient(WELCOME_DEVICE.url, WELCOME_DEVICE.token), emptyDeviceInfo(), registry));
139
+ // Hub credentials ride along so the welcome offers the hub network — the
140
+ // feed is one key away instead of invisible behind the overlay.
141
+ showWelcome(
142
+ new App(
143
+ WELCOME_DEVICE,
144
+ new DpiClient(WELCOME_DEVICE.url, WELCOME_DEVICE.token),
145
+ emptyDeviceInfo(),
146
+ registry,
147
+ hubEnv,
148
+ ),
149
+ );
132
150
  } else if (startup.kind === "auto-open" || startup.kind === "picker") {
133
151
  const row = startup.kind === "auto-open" ? startup.device : startup.devices[0]!;
134
152
  const device: DeviceRef = { id: row.id, name: row.name, url: row.url!, token: row.token! };
@@ -152,12 +170,21 @@ if (startup.kind === "welcome") {
152
170
  } else {
153
171
  // An auto-connected device that is unreachable falls back to a screen that says
154
172
  // so and offers the picker + welcome actions — never back to usage text.
155
- showWelcome(new App(WELCOME_DEVICE, new DpiClient(WELCOME_DEVICE.url, WELCOME_DEVICE.token), emptyDeviceInfo(), registry), {
173
+ showWelcome(
174
+ new App(
175
+ WELCOME_DEVICE,
176
+ new DpiClient(WELCOME_DEVICE.url, WELCOME_DEVICE.token),
177
+ emptyDeviceInfo(),
178
+ registry,
179
+ hubEnv,
180
+ ),
181
+ {
156
182
  notice:
157
183
  isDpiError(e) && e.code === "unauthorized"
158
184
  ? `${device.id}: token rejected by ${device.url}`
159
185
  : `${device.id} is offline at ${device.url} (${(e as Error).message})`,
160
- });
186
+ },
187
+ );
161
188
  }
162
189
  }
163
190
  } else if (url) {
@@ -228,7 +228,7 @@ export function validateDeviceInput(urlAnswer: string, tokenAnswer: string): { u
228
228
 
229
229
  // ------------------------------------------------------------------ the welcome screen
230
230
 
231
- export function welcomeItems(deviceCount: number, port: number): SelectItem[] {
231
+ export function welcomeItems(deviceCount: number, port: number, hub = false): SelectItem[] {
232
232
  // The bracket letter is a real shortcut (see WelcomePicker) — typing it runs
233
233
  // the action instead of relying on filter order.
234
234
  const items: SelectItem[] = [
@@ -236,6 +236,15 @@ export function welcomeItems(deviceCount: number, port: number): SelectItem[] {
236
236
  { value: "add-url", label: "[a] Add a device by URL", description: "http://host:port + its DPI_TOKEN" },
237
237
  { value: "detect-local", label: "[d] Detect the local backend", description: `probe 127.0.0.1:${port} (DPI_TOKEN or ~/.dpi/backend.env)` },
238
238
  ];
239
+ // Hub mode (live-caught): the network is one key away — before this the
240
+ // welcome offered only local pairing and quit, with the hub feed invisible
241
+ // behind the overlay and no way to browse it.
242
+ if (hub)
243
+ items.unshift({
244
+ value: "hub-network",
245
+ label: "[h] Browse the hub network",
246
+ description: "devices and sessions the hub can see",
247
+ });
239
248
  if (deviceCount > 0)
240
249
  items.push({
241
250
  value: "switch-device",
@@ -273,7 +282,7 @@ export function showWelcome(app: App, opts: { notice?: string } = {}) {
273
282
  let picked = false; // an action was chosen: closing the overlay is a step, not a quit
274
283
  app.overlay(
275
284
  new WelcomePicker(
276
- welcomeItems(devices.length, applyBackendEnv().port),
285
+ welcomeItems(devices.length, applyBackendEnv().port, Boolean(app.hubUrl)),
277
286
  (item) => {
278
287
  picked = true;
279
288
  app.closeOverlay();
@@ -325,6 +334,12 @@ async function runWelcomeAction(app: App, action: string) {
325
334
  if (action === "add-url") return welcomeAddUrl(app);
326
335
  if (action === "detect-local") return welcomeLocal(app);
327
336
  if (action === "switch-device") return welcomeSwitch(app);
337
+ if (action === "hub-network") {
338
+ // Close into the network view; the hub feed keeps it current.
339
+ app.closeOverlay();
340
+ app.setView("network");
341
+ return;
342
+ }
328
343
  }
329
344
 
330
345
  /** [p] Pair this machine — the same LocalPairing path as `--pair` and /pair. */
@@ -365,7 +380,9 @@ async function welcomeAddUrl(app: App) {
365
380
  app.flash(`Connecting to ${input.url}…`);
366
381
  let info;
367
382
  try {
368
- info = await new DpiClient(input.url, input.token).device({ timeoutMs: 8000 });
383
+ // 20s, not 8: a HUB-proxied device URL pays the tunnel's first-hit cost
384
+ // (15s observed live) — 8s reported "cannot reach" on a healthy device.
385
+ info = await new DpiClient(input.url, input.token).device({ timeoutMs: 20000 });
369
386
  } catch (e) {
370
387
  app.flash(
371
388
  isDpiError(e) && e.code === "unauthorized"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "my-durable",
3
- "version": "0.0.49",
3
+ "version": "0.0.51",
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": {