my-durable 0.0.54 → 0.0.56
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/API.md +1 -1
- package/apps/dpi-backend/src/store.ts +27 -3
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/assets/{index-_rDvatx4.css → index-C8I93zWz.css} +1 -1
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/assets/index-C9ulm0b-.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/worktree.ts +110 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/GitPanel.vue +9 -11
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/Inspector.vue +53 -1
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/NetworkSidebar.vue +24 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/NewSessionDialog.vue +10 -1
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/TreeRow.vue +15 -0
- package/apps/dpi-playground/wt-cleanup.tmp.mjs +22 -0
- package/apps/dpi-playground/wt-live-repro.tmp.mjs +53 -0
- package/apps/dpi-playground/wt-live-repro2.tmp.mjs +30 -0
- package/apps/dpi-playground/wt-live-repro3.tmp.mjs +47 -0
- package/apps/dpi-sdk/src/api.ts +4 -1
- package/apps/dpi-tui/src/app.ts +1 -1
- package/apps/dpi-tui/src/pickers.ts +33 -1
- package/apps/dpi-tui/src/views.ts +6 -1
- package/package.json +1 -1
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/assets/index-CBxu8tMi.js +0 -81
|
@@ -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-C9ulm0b-.js"></script>
|
|
11
|
+
<link rel="stylesheet" crossorigin href="/assets/index-C8I93zWz.css">
|
|
12
12
|
</head>
|
|
13
13
|
<body>
|
|
14
14
|
<div id="app"></div>
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// Worktree sessions, shared by the Git tab and the session tree (F3): the
|
|
2
|
+
// sibling-target rule (<parent>/<base>-<branch>) lives here once so the two
|
|
3
|
+
// entry points cannot drift. GitPanel keeps its own busy/notify chrome around
|
|
4
|
+
// the same calls; the session list gets the whole flow in one function.
|
|
5
|
+
import type { DpiClient, GitStatus } from "@sdk/client";
|
|
6
|
+
import type { SessionSummary } from "@sdk/api";
|
|
7
|
+
|
|
8
|
+
/** What the flow needs from a device client — structural, so a stub (tests,
|
|
9
|
+
* other transports) can stand in without constructing a real DpiClient. */
|
|
10
|
+
export interface WorktreeApi {
|
|
11
|
+
gitStatus: DpiClient["gitStatus"];
|
|
12
|
+
gitOp: DpiClient["gitOp"];
|
|
13
|
+
createSession: DpiClient["createSession"];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Sibling checkout target: <parent>/<base>-<branch>. Path separators in the
|
|
17
|
+
* branch are flattened to dashes — a branch may contain them, a folder may not. */
|
|
18
|
+
export function worktreeTarget(root: string, branch: string): string {
|
|
19
|
+
const parent = root.slice(0, root.lastIndexOf("/"));
|
|
20
|
+
const base = root.slice(root.lastIndexOf("/") + 1);
|
|
21
|
+
return `${parent}/${base}-${branch.replace(/[/\\]+/g, "-")}`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** `git worktree add` into the sibling target — the extracted half of the old
|
|
25
|
+
* GitPanel.addWorktree. Returns the target plus the op's first line (notify). */
|
|
26
|
+
export async function addWorktree(
|
|
27
|
+
deviceApi: Pick<WorktreeApi, "gitOp">,
|
|
28
|
+
cwd: string,
|
|
29
|
+
root: string,
|
|
30
|
+
branch: string,
|
|
31
|
+
): Promise<{ target: string; text: string }> {
|
|
32
|
+
const target = worktreeTarget(root, branch);
|
|
33
|
+
const r = await deviceApi.gitOp(cwd, "worktree-add", { branch, target });
|
|
34
|
+
return { target, text: r.text.split("\n")[0] ?? `worktree ${target}` };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Open a session in an existing folder — the extracted half of the old
|
|
38
|
+
* GitPanel.sessionOn. Model optional: absent = the device's (or the
|
|
39
|
+
* project's) default, the same rule as every other create call. */
|
|
40
|
+
export async function createSessionOn(
|
|
41
|
+
deviceApi: Pick<WorktreeApi, "createSession">,
|
|
42
|
+
path: string,
|
|
43
|
+
name: string,
|
|
44
|
+
model?: { provider: string; modelId: string },
|
|
45
|
+
): Promise<SessionSummary> {
|
|
46
|
+
return deviceApi.createSession(model ? { name, cwd: path, model } : { name, cwd: path });
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface CreateWorktreeSessionArgs {
|
|
50
|
+
deviceApi: WorktreeApi;
|
|
51
|
+
cwd: string;
|
|
52
|
+
sessionName: string;
|
|
53
|
+
branch: string;
|
|
54
|
+
/** Repo root when the caller already has it (GitPanel's cached status);
|
|
55
|
+
* resolved from the device otherwise. */
|
|
56
|
+
root?: string;
|
|
57
|
+
/** The session this one is branched from (session tree, F3). Its model rides
|
|
58
|
+
* along ONLY in the object shape the create route requires — SessionSummary
|
|
59
|
+
* stores `model` as a bare modelId string, so it is rewrapped as
|
|
60
|
+
* `{ provider, modelId }`; a bare string is a 400 ("model must be
|
|
61
|
+
* { provider, modelId }"). A field missing — or a pair the device no
|
|
62
|
+
* longer serves (seen live: sessions outliving a curated-model removal) —
|
|
63
|
+
* falls to the catalog default, NOT to omitting: the worktree is a sibling
|
|
64
|
+
* folder, its brand-new project has no default, and the create route has
|
|
65
|
+
* no device-default fallback for an absent model (both proven live). */
|
|
66
|
+
source?: Pick<SessionSummary, "model" | "provider">;
|
|
67
|
+
/** The device's served catalog (the tree's device.info.models) and its
|
|
68
|
+
* default (device.info.defaultModel, "provider/id"). With a catalog the
|
|
69
|
+
* resolution is: source pair if served → catalog default → catalog[0]
|
|
70
|
+
* (NewSessionDialog's rule). Without one, any { model, provider } pair is
|
|
71
|
+
* forwarded as-is and a missing pair omits `model` (the documented
|
|
72
|
+
* create-body contract: absent or { provider, modelId }, never a string). */
|
|
73
|
+
catalog?: ReadonlyArray<{ provider: string; id: string }>;
|
|
74
|
+
defaultModel?: string;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Worktree + session in one call (session tree, F3): add the sibling
|
|
78
|
+
* checkout, then open the session right in it. worktree-add runs first, so a
|
|
79
|
+
* rejected add never leaves a session behind, and the session's cwd is
|
|
80
|
+
* exactly the folder git just made. */
|
|
81
|
+
export async function createWorktreeSession({
|
|
82
|
+
deviceApi,
|
|
83
|
+
cwd,
|
|
84
|
+
sessionName,
|
|
85
|
+
branch,
|
|
86
|
+
root,
|
|
87
|
+
source,
|
|
88
|
+
catalog,
|
|
89
|
+
defaultModel,
|
|
90
|
+
}: CreateWorktreeSessionArgs): Promise<SessionSummary> {
|
|
91
|
+
let repoRoot = root;
|
|
92
|
+
if (!repoRoot) {
|
|
93
|
+
const status: GitStatus = await deviceApi.gitStatus(cwd);
|
|
94
|
+
if (!status.repo || !status.root) throw Error(`${cwd} is not a git repository`);
|
|
95
|
+
repoRoot = status.root;
|
|
96
|
+
}
|
|
97
|
+
const { target } = await addWorktree(deviceApi, cwd, repoRoot, branch);
|
|
98
|
+
// Wire shape, not a passthrough: SessionSummary.model is a modelId string,
|
|
99
|
+
// CreateSessionBody.model is { provider, modelId } — never a bare string.
|
|
100
|
+
const { model: srcModel, provider: srcProvider } = source ?? {};
|
|
101
|
+
const served =
|
|
102
|
+
srcModel && srcProvider && (!catalog || catalog.some((m) => m.provider === srcProvider && m.id === srcModel))
|
|
103
|
+
? { provider: srcProvider, modelId: srcModel }
|
|
104
|
+
: undefined;
|
|
105
|
+
const fallback = catalog?.length
|
|
106
|
+
? (catalog.find((m) => `${m.provider}/${m.id}` === defaultModel) ?? catalog[0])
|
|
107
|
+
: undefined;
|
|
108
|
+
const model = served ?? (fallback ? { provider: fallback.provider, modelId: fallback.id } : undefined);
|
|
109
|
+
return createSessionOn(deviceApi, target, sessionName, model);
|
|
110
|
+
}
|
|
@@ -35,6 +35,7 @@ import {
|
|
|
35
35
|
import { deviceId, network, sessionSummary, notify, select } from "../client/store";
|
|
36
36
|
import { deviceClient } from "../client/hub";
|
|
37
37
|
import { ensureGit, gitEntry, wireGitAutoRefresh } from "../client/git-store";
|
|
38
|
+
import { addWorktree as gitAddWorktree, createSessionOn } from "../client/worktree";
|
|
38
39
|
import type { GitStatus } from "@sdk/client";
|
|
39
40
|
|
|
40
41
|
const props = defineProps<{ deviceId?: string; cwd?: string }>();
|
|
@@ -717,14 +718,10 @@ watch(cpsOpen, (open) => {
|
|
|
717
718
|
async function addWorktree(branch: string) {
|
|
718
719
|
wtMenu.value = false;
|
|
719
720
|
if (!devId.value || !cwd.value || !status.value?.root) return;
|
|
720
|
-
const root = status.value.root;
|
|
721
|
-
const parent = root.slice(0, root.lastIndexOf("/"));
|
|
722
|
-
const base = root.slice(root.lastIndexOf("/") + 1);
|
|
723
|
-
const target = `${parent}/${base}-${branch.replace(/[/\\]+/g, "-")}`;
|
|
724
721
|
busy.value = "wt";
|
|
725
722
|
try {
|
|
726
|
-
const r = await deviceClient(devId.value)
|
|
727
|
-
notify(r.text
|
|
723
|
+
const r = await gitAddWorktree(deviceClient(devId.value), cwd.value, status.value.root, branch);
|
|
724
|
+
notify(r.text);
|
|
728
725
|
newBranch.value = "";
|
|
729
726
|
await refresh();
|
|
730
727
|
} catch (e) {
|
|
@@ -741,11 +738,12 @@ async function sessionOn(path: string, branch: string | null) {
|
|
|
741
738
|
const info = network.devices.value.find((d) => d.id === devId.value)?.info;
|
|
742
739
|
const model = modelCandidates(info)[0];
|
|
743
740
|
if (!model) return notify(`no model available on ${devId.value} — cannot create a session`);
|
|
744
|
-
const s = await
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
741
|
+
const s = await createSessionOn(
|
|
742
|
+
deviceClient(devId.value),
|
|
743
|
+
path,
|
|
744
|
+
branch ?? path.slice(path.lastIndexOf("/") + 1),
|
|
745
|
+
{ provider: model.provider, modelId: model.id },
|
|
746
|
+
);
|
|
749
747
|
select({ deviceId: devId.value, sessionId: s.id, agentId: 1 });
|
|
750
748
|
notify(`session "${s.name}" on ${path}`);
|
|
751
749
|
} catch (e) {
|
|
@@ -204,6 +204,57 @@ function renameSession() {
|
|
|
204
204
|
};
|
|
205
205
|
}
|
|
206
206
|
|
|
207
|
+
/** Per-project default models (same fetch as NewSessionDialog): they decide
|
|
208
|
+
* what "(default)" means for the current session — the project's model when
|
|
209
|
+
* the cwd names a registered root, the device's otherwise. */
|
|
210
|
+
const projectModels = ref<Record<string, { provider: string; modelId: string }>>({});
|
|
211
|
+
watch(
|
|
212
|
+
device,
|
|
213
|
+
async (d) => {
|
|
214
|
+
projectModels.value = {};
|
|
215
|
+
if (!d) return;
|
|
216
|
+
try {
|
|
217
|
+
const { projects } = await deviceClient(d.id).projects(true);
|
|
218
|
+
projectModels.value = Object.fromEntries(
|
|
219
|
+
projects.filter((p) => p.model).map((p) => [p.rootPath, p.model!]),
|
|
220
|
+
);
|
|
221
|
+
} catch {
|
|
222
|
+
/* older device: no project defaults, the device default stays */
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
{ immediate: true },
|
|
226
|
+
);
|
|
227
|
+
/** The current model with provenance: the agent's configured model when set,
|
|
228
|
+
* else the model the session was created with (SessionSummary). */
|
|
229
|
+
const sessionModel = computed(() => {
|
|
230
|
+
const m = agentState.value.agent.model;
|
|
231
|
+
if (m?.modelId) return m;
|
|
232
|
+
const s = sessionSummary.value;
|
|
233
|
+
return s?.model ? { provider: s.provider ?? "", modelId: s.model } : undefined;
|
|
234
|
+
});
|
|
235
|
+
/** Longest registered root wins — the same rule the device applies on create. */
|
|
236
|
+
const modelIsDefault = computed(() => {
|
|
237
|
+
const m = sessionModel.value;
|
|
238
|
+
if (!m) return false;
|
|
239
|
+
const cwd = sessionSummary.value?.cwd;
|
|
240
|
+
const roots = Object.keys(projectModels.value)
|
|
241
|
+
.filter((root) => cwd === root || (cwd ?? "").startsWith(`${root}/`))
|
|
242
|
+
.sort((a, b) => b.length - a.length);
|
|
243
|
+
const projectDefault = roots.length ? projectModels.value[roots[0]] : undefined;
|
|
244
|
+
const key = projectDefault
|
|
245
|
+
? `${projectDefault.provider}/${projectDefault.modelId}`
|
|
246
|
+
: (device.value?.info?.defaultModel ?? "");
|
|
247
|
+
return Boolean(key) && key === `${m.provider}/${m.modelId}`;
|
|
248
|
+
});
|
|
249
|
+
/** "model: <id> (<provider>)" + " (default)" when it is the effective default. */
|
|
250
|
+
const modelLine = computed(
|
|
251
|
+
() =>
|
|
252
|
+
sessionModel.value &&
|
|
253
|
+
`model: ${sessionModel.value.modelId} (${sessionModel.value.provider})${
|
|
254
|
+
modelIsDefault.value ? " (default)" : ""
|
|
255
|
+
}`,
|
|
256
|
+
);
|
|
257
|
+
|
|
207
258
|
// ------------------------------------------------------------ App State (device-wide document)
|
|
208
259
|
|
|
209
260
|
const shared = deviceFeed.sharedState;
|
|
@@ -396,11 +447,12 @@ const offeredTools = computed(() => detail.value?.tools.filter((t) => t.offered)
|
|
|
396
447
|
</div>
|
|
397
448
|
<ChevronDown :size="18" />
|
|
398
449
|
</button>
|
|
450
|
+
<p v-if="modelLine" class="hint model-provenance">{{ modelLine }}</p>
|
|
399
451
|
<div class="thinking-row">
|
|
400
452
|
<span>Thinking</span
|
|
401
453
|
><select
|
|
402
454
|
aria-label="Thinking level"
|
|
403
|
-
:value="agentState.agent.thinkingLevel ?? '
|
|
455
|
+
:value="agentState.agent.thinkingLevel ?? 'medium'"
|
|
404
456
|
@change="
|
|
405
457
|
configure(
|
|
406
458
|
{ thinkingLevel: ($event.target as HTMLSelectElement).value as ThinkingLevel },
|
|
@@ -6,6 +6,7 @@ import type { TreeNode } from "@sdk/models";
|
|
|
6
6
|
import TreeRow from "./TreeRow.vue";
|
|
7
7
|
import ProjectBar from "./ProjectBar.vue";
|
|
8
8
|
import { deviceClient, hub } from "../client/hub";
|
|
9
|
+
import { createWorktreeSession } from "../client/worktree";
|
|
9
10
|
import {
|
|
10
11
|
attempt,
|
|
11
12
|
expanded,
|
|
@@ -208,6 +209,29 @@ async function action(node: TreeNode, name: string) {
|
|
|
208
209
|
submit: "Save name",
|
|
209
210
|
run: (value) => client.session(s.id).rename(value),
|
|
210
211
|
};
|
|
212
|
+
else if (name === "worktree")
|
|
213
|
+
ui.dialog = {
|
|
214
|
+
kind: "prompt",
|
|
215
|
+
title: "New worktree session",
|
|
216
|
+
label: "Branch name",
|
|
217
|
+
value: s.name.replace(/[/\\]+/g, "-"),
|
|
218
|
+
hint: `Adds a sibling checkout of ${s.cwd} on the branch (git worktree add) and opens a session in it.`,
|
|
219
|
+
submit: "Create worktree session",
|
|
220
|
+
run: async (branch) => {
|
|
221
|
+
const created = await createWorktreeSession({
|
|
222
|
+
deviceApi: client,
|
|
223
|
+
cwd: s.cwd,
|
|
224
|
+
sessionName: branch,
|
|
225
|
+
branch,
|
|
226
|
+
source: s,
|
|
227
|
+
catalog: device.info?.models,
|
|
228
|
+
defaultModel: device.info?.defaultModel,
|
|
229
|
+
});
|
|
230
|
+
const root = created.agents.find((a) => a.kind === "root") ?? created.agents[0];
|
|
231
|
+
select({ deviceId: device.id, sessionId: created.id, agentId: root?.id ?? 1 });
|
|
232
|
+
notify(`session "${created.name}" on ${created.cwd}`);
|
|
233
|
+
},
|
|
234
|
+
};
|
|
211
235
|
else if (name === "archive")
|
|
212
236
|
ui.dialog = {
|
|
213
237
|
kind: "prompt",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed, ref, watch } from "vue";
|
|
3
3
|
import { Plus, X } from "lucide-vue-next";
|
|
4
|
+
import { THINKING_LEVELS, type ThinkingLevel } from "@sdk/api";
|
|
4
5
|
import DirBrowser from "./DirBrowser.vue";
|
|
5
6
|
import { deviceClient, message } from "../client/hub";
|
|
6
7
|
import { network, notify, select } from "../client/store";
|
|
@@ -41,7 +42,7 @@ const catalogEmpty = computed(
|
|
|
41
42
|
/** The device lists its built-in catalog but chat needs the key (0.0.12+ devices). */
|
|
42
43
|
const keyless = computed(() => !!(device.value?.info as { providerKeyMissing?: boolean } | undefined)?.providerKeyMissing);
|
|
43
44
|
const key = (m: { provider: string; id: string }) => `${m.provider}/${m.id}`;
|
|
44
|
-
const draft = ref({ name: "", cwd: "", model: "" });
|
|
45
|
+
const draft = ref({ name: "", cwd: "", model: "", thinking: "medium" as ThinkingLevel });
|
|
45
46
|
/** orca new-workspace composer: the last N working dirs per device, one click
|
|
46
47
|
* away. localStorage only — the device never learns about recents. */
|
|
47
48
|
const RECENT_KEY = "dpi-recent-cwds";
|
|
@@ -123,6 +124,7 @@ async function create() {
|
|
|
123
124
|
name: draft.value.name.trim() || "New session",
|
|
124
125
|
cwd: draft.value.cwd.trim(),
|
|
125
126
|
model: { provider: model.provider, modelId: model.id },
|
|
127
|
+
thinkingLevel: draft.value.thinking,
|
|
126
128
|
});
|
|
127
129
|
rememberCwd(device.value.id, created.cwd);
|
|
128
130
|
const root = created.agents.find((a) => a.kind === "root") ?? created.agents[0];
|
|
@@ -202,6 +204,13 @@ async function create() {
|
|
|
202
204
|
</option>
|
|
203
205
|
</select></label
|
|
204
206
|
>
|
|
207
|
+
<label
|
|
208
|
+
>Thinking<select v-model="draft.thinking" aria-label="New session thinking level">
|
|
209
|
+
<option v-for="level in THINKING_LEVELS" :key="level" :value="level">
|
|
210
|
+
{{ level }}
|
|
211
|
+
</option>
|
|
212
|
+
</select></label
|
|
213
|
+
>
|
|
205
214
|
</template>
|
|
206
215
|
<p v-if="error" class="message-error" role="alert">{{ error }}</p>
|
|
207
216
|
<footer>
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
RefreshCw,
|
|
13
13
|
Archive,
|
|
14
14
|
KeyRound,
|
|
15
|
+
Split,
|
|
15
16
|
} from "lucide-vue-next";
|
|
16
17
|
import DeviceIcon from "./DeviceIcon.vue";
|
|
17
18
|
import type { TreeNode } from "@sdk/models";
|
|
@@ -176,6 +177,12 @@ const title = computed(() => {
|
|
|
176
177
|
<b class="name">{{ label }}</b>
|
|
177
178
|
<span class="path">…/{{ session.cwd.split("/").filter(Boolean).at(-1) }}</span>
|
|
178
179
|
<span v-if="branch" class="branch" :title="`git branch of ${session.cwd}`">⎇ {{ branch }}</span>
|
|
180
|
+
<span
|
|
181
|
+
v-if="session.model"
|
|
182
|
+
class="tag"
|
|
183
|
+
:title="session.provider ? `${session.provider} / ${session.model}` : session.model"
|
|
184
|
+
>{{ session.model }}</span
|
|
185
|
+
>
|
|
179
186
|
<i v-if="busy" class="dot work" title="Working" />
|
|
180
187
|
<span v-if="background" class="bg-count" :title="`${background} background task(s)`"
|
|
181
188
|
><i class="dot bg" />{{ background }} bg</span
|
|
@@ -197,6 +204,14 @@ const title = computed(() => {
|
|
|
197
204
|
@click="emit('action', 'rename')"
|
|
198
205
|
>
|
|
199
206
|
<Pencil :size="16" /></button
|
|
207
|
+
><button
|
|
208
|
+
class="icon-button"
|
|
209
|
+
:disabled="!online"
|
|
210
|
+
:aria-label="`New worktree session from ${label}`"
|
|
211
|
+
title="New worktree session: branch this folder's repo and open a session in the sibling checkout"
|
|
212
|
+
@click="emit('action', 'worktree')"
|
|
213
|
+
>
|
|
214
|
+
<Split :size="16" /></button
|
|
200
215
|
><button
|
|
201
216
|
class="icon-button"
|
|
202
217
|
:disabled="!online"
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { chromium } from "@playwright/test";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
const TOKEN = readFileSync(`${process.env.HOME}/.local/share/durable-pi/admin.token`, "utf8").trim();
|
|
4
|
+
const browser = await chromium.launch({ executablePath: "/usr/bin/google-chrome", headless: true });
|
|
5
|
+
const page = await browser.newPage({ viewport: { width: 1600, height: 1000 } });
|
|
6
|
+
page.on("response", (r) => r.url().endsWith("/v1/sessions/" ) === false && r.request().method() === "DELETE" && console.log(`[net] DELETE ${r.url().split("/api/")[1]} -> ${r.status()}`));
|
|
7
|
+
await page.goto("https://my-durable.phuongnb.io.vn/");
|
|
8
|
+
await page.locator(".login-veil input").fill(TOKEN);
|
|
9
|
+
await page.locator(".login-veil input").press("Enter");
|
|
10
|
+
await page.waitForTimeout(4000);
|
|
11
|
+
await page.evaluate(() => {
|
|
12
|
+
const hit = [...document.querySelectorAll(".tree-row")].find((r) => r.querySelector(".name")?.textContent?.trim() === "wt-fixcheck");
|
|
13
|
+
if (!hit) throw Error("wt-fixcheck row not found");
|
|
14
|
+
hit.classList.add("probe-target");
|
|
15
|
+
});
|
|
16
|
+
await page.locator(".probe-target").hover();
|
|
17
|
+
await page.click(`.probe-target button[aria-label^="Archive session"]`);
|
|
18
|
+
await page.click("text=Archive session"); // the dialog's submit button
|
|
19
|
+
await page.waitForTimeout(3000);
|
|
20
|
+
const still = await page.evaluate(() => [...document.querySelectorAll(".tree-row .name")].some((n) => n.textContent?.trim() === "wt-fixcheck"));
|
|
21
|
+
console.log("wt-fixcheck still in live tree:", still);
|
|
22
|
+
await browser.close();
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// Live repro of the worktree-from-session flow against https://my-durable.phuongnb.io.vn
|
|
2
|
+
// using the NEW fixed bundle (index-6a3ATkAn.js).
|
|
3
|
+
import { chromium } from "@playwright/test";
|
|
4
|
+
import { readFileSync } from "node:fs";
|
|
5
|
+
|
|
6
|
+
const TOKEN = readFileSync(`${process.env.HOME}/.local/share/durable-pi/admin.token`, "utf8").trim();
|
|
7
|
+
const errors = [];
|
|
8
|
+
|
|
9
|
+
const browser = await chromium.launch({ executablePath: "/usr/bin/google-chrome", headless: true });
|
|
10
|
+
const page = await browser.newPage({ viewport: { width: 1600, height: 1000 } });
|
|
11
|
+
page.on("response", (r) => {
|
|
12
|
+
if (r.url().includes("/v1/sessions") && r.request().method() === "POST")
|
|
13
|
+
console.log(`[net] POST ${r.url().replace("https://my-durable.phuongnb.io.vn", "")} -> ${r.status()}`);
|
|
14
|
+
});
|
|
15
|
+
page.on("console", (m) => m.type() === "error" && errors.push(m.text()));
|
|
16
|
+
|
|
17
|
+
await page.goto("https://my-durable.phuongnb.io.vn/");
|
|
18
|
+
await page.locator(".login-veil input").fill(TOKEN);
|
|
19
|
+
await page.locator(".login-veil input").press("Enter");
|
|
20
|
+
await page.waitForTimeout(4000);
|
|
21
|
+
|
|
22
|
+
// Mark the 'usage-probe' row (walk up to .tree-row, add class probe-target)
|
|
23
|
+
await page.evaluate(() => {
|
|
24
|
+
const rows = [...document.querySelectorAll(".tree-row")];
|
|
25
|
+
const hit = rows.find((r) => r.querySelector(".name")?.textContent?.trim() === "usage-probe");
|
|
26
|
+
if (!hit) throw Error("usage-probe row not found; rows=" + rows.length);
|
|
27
|
+
hit.classList.add("probe-target");
|
|
28
|
+
return true;
|
|
29
|
+
});
|
|
30
|
+
const row = page.locator(".probe-target");
|
|
31
|
+
await row.hover();
|
|
32
|
+
await page.click(`.probe-target button[aria-label^="New worktree session from"]`);
|
|
33
|
+
await page.locator("input").last().fill("wt-fixcheck");
|
|
34
|
+
await page.click("text=Create worktree session");
|
|
35
|
+
await page.waitForTimeout(12000);
|
|
36
|
+
|
|
37
|
+
// Assert: a session with cwd containing gitdemo-wt-fixcheck exists + no 'model must be' error
|
|
38
|
+
const bodyText = await page.evaluate(() => document.body.textContent ?? "");
|
|
39
|
+
const net = await page.evaluate(async () => {
|
|
40
|
+
const r = await fetch("/api/devices/1e2e23fcd30b49c4ba1ffa2151816bd3/v1/sessions", {
|
|
41
|
+
headers: { authorization: `Bearer ${localStorage.getItem("dpi.admin.token") ?? ""}` },
|
|
42
|
+
});
|
|
43
|
+
return { status: r.status, sessions: (await r.json()).sessions?.map((s) => `${s.name}|${s.cwd}`) };
|
|
44
|
+
});
|
|
45
|
+
const created = (net.sessions ?? []).filter((s) => s.includes("gitdemo-wt-fixcheck"));
|
|
46
|
+
console.log("bundle:", await page.evaluate(() => [...document.scripts].map((s) => s.src).join(" ")));
|
|
47
|
+
console.log("sidebar has wt-fixcheck:", bodyText.includes("wt-fixcheck"));
|
|
48
|
+
console.log("message-error 'model must be':", /model must be/.test(bodyText) ? "PRESENT (FAIL)" : "absent (PASS)");
|
|
49
|
+
console.log("created session(s):", JSON.stringify(created, null, 2));
|
|
50
|
+
console.log("console errors:", errors.length ? errors.slice(0, 3) : "none");
|
|
51
|
+
await page.screenshot({ path: "/tmp/wt-fixcheck-live.png", fullPage: false });
|
|
52
|
+
await browser.close();
|
|
53
|
+
if (!created.length) process.exit(1);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { chromium } from "@playwright/test";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
const TOKEN = readFileSync(`${process.env.HOME}/.local/share/durable-pi/admin.token`, "utf8").trim();
|
|
4
|
+
const browser = await chromium.launch({ executablePath: "/usr/bin/google-chrome", headless: true });
|
|
5
|
+
const page = await browser.newPage({ viewport: { width: 1600, height: 1000 } });
|
|
6
|
+
page.on("response", async (r) => {
|
|
7
|
+
const m = r.request().method();
|
|
8
|
+
if ((r.url().includes("/v1/sessions") && m === "POST") || (r.url().includes("/v1/git") && m === "POST")) {
|
|
9
|
+
let body = "";
|
|
10
|
+
try { body = (await r.json()).error?.message ?? ""; } catch {}
|
|
11
|
+
console.log(`[net] ${m} ${r.url().split("/api/")[1]} -> ${r.status()} ${body}`);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
await page.goto("https://my-durable.phuongnb.io.vn/");
|
|
15
|
+
await page.locator(".login-veil input").fill(TOKEN);
|
|
16
|
+
await page.locator(".login-veil input").press("Enter");
|
|
17
|
+
await page.waitForTimeout(4000);
|
|
18
|
+
await page.evaluate(() => {
|
|
19
|
+
const hit = [...document.querySelectorAll(".tree-row")].find((r) => r.querySelector(".name")?.textContent?.trim() === "usage-probe");
|
|
20
|
+
if (!hit) throw Error("usage-probe row not found");
|
|
21
|
+
hit.classList.add("probe-target");
|
|
22
|
+
});
|
|
23
|
+
await page.locator(".probe-target").hover();
|
|
24
|
+
await page.click(`.probe-target button[aria-label^="New worktree session from"]`);
|
|
25
|
+
await page.locator("input").last().fill("wt-fixcheck2");
|
|
26
|
+
await page.click("text=Create worktree session");
|
|
27
|
+
await page.waitForTimeout(12000);
|
|
28
|
+
const bodyText = await page.evaluate(() => document.body.textContent ?? "");
|
|
29
|
+
console.log("err shown:", (bodyText.match(/model must be[^.]*|Unknown model[^.]*/) ?? ["none"])[0]);
|
|
30
|
+
await browser.close();
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { chromium } from "@playwright/test";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
const TOKEN = readFileSync(`${process.env.HOME}/.local/share/durable-pi/admin.token`, "utf8").trim();
|
|
4
|
+
const errors = [];
|
|
5
|
+
const browser = await chromium.launch({ executablePath: "/usr/bin/google-chrome", headless: true });
|
|
6
|
+
const page = await browser.newPage({ viewport: { width: 1600, height: 1000 } });
|
|
7
|
+
page.on("response", async (r) => {
|
|
8
|
+
const m = r.request().method();
|
|
9
|
+
if ((r.url().includes("/v1/sessions") && m === "POST") || (r.url().includes("/v1/git") && m === "POST")) {
|
|
10
|
+
let body = "";
|
|
11
|
+
try { body = (await r.json()).error?.message ?? ""; } catch {}
|
|
12
|
+
console.log(`[net] ${m} ${r.url().split("/api/")[1]} -> ${r.status()} ${body}`);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
page.on("console", (m) => m.type() === "error" && !/cloudflare|beacon/.test(m.text()) && errors.push(m.text().slice(0, 120)));
|
|
16
|
+
|
|
17
|
+
await page.goto("https://my-durable.phuongnb.io.vn/");
|
|
18
|
+
await page.locator(".login-veil input").fill(TOKEN);
|
|
19
|
+
await page.locator(".login-veil input").press("Enter");
|
|
20
|
+
await page.waitForTimeout(4000);
|
|
21
|
+
|
|
22
|
+
await page.evaluate(() => {
|
|
23
|
+
const hit = [...document.querySelectorAll(".tree-row")].find((r) => r.querySelector(".name")?.textContent?.trim() === "usage-probe");
|
|
24
|
+
if (!hit) throw Error("usage-probe row not found");
|
|
25
|
+
hit.classList.add("probe-target");
|
|
26
|
+
});
|
|
27
|
+
await page.locator(".probe-target").hover();
|
|
28
|
+
await page.click(`.probe-target button[aria-label^="New worktree session from"]`);
|
|
29
|
+
await page.locator("input").last().fill("wt-fixcheck");
|
|
30
|
+
await page.click("text=Create worktree session");
|
|
31
|
+
await page.waitForTimeout(12000);
|
|
32
|
+
|
|
33
|
+
const bodyText = await page.evaluate(() => document.body.textContent ?? "");
|
|
34
|
+
const net = await page.evaluate(async (tok) => {
|
|
35
|
+
const r = await fetch("/api/devices/1e2e23fcd30b49c4ba1ffa2151816bd3/v1/sessions", { headers: { authorization: `Bearer ${tok}` } });
|
|
36
|
+
return (await r.json()).sessions?.map((s) => `${s.name}|${s.cwd}|${s.provider}/${s.model}`);
|
|
37
|
+
}, TOKEN);
|
|
38
|
+
const created = (net ?? []).filter((s) => s.includes("gitdemo-wt-fixcheck"));
|
|
39
|
+
console.log("bundle:", await page.evaluate(() => [...document.scripts].map((s) => s.src).find((s) => s.includes("index-"))));
|
|
40
|
+
console.log("sidebar contains wt-fixcheck:", bodyText.includes("wt-fixcheck"));
|
|
41
|
+
console.log("message-error 'model must be':", /model must be/.test(bodyText) ? "PRESENT (FAIL)" : "absent (PASS)");
|
|
42
|
+
console.log("message-error 'Unknown model':", /Unknown model/.test(bodyText) ? "PRESENT (FAIL)" : "absent (PASS)");
|
|
43
|
+
console.log("created session(s):", JSON.stringify(created, null, 2));
|
|
44
|
+
console.log("app console errors:", errors.length ? errors : "none");
|
|
45
|
+
await page.screenshot({ path: "/tmp/wt-fixcheck-live.png" });
|
|
46
|
+
await browser.close();
|
|
47
|
+
if (!created.length) process.exit(1);
|
package/apps/dpi-sdk/src/api.ts
CHANGED
|
@@ -54,7 +54,7 @@ export type ErrorCode =
|
|
|
54
54
|
| "offline"
|
|
55
55
|
| "rate_limited"
|
|
56
56
|
| "timeout";
|
|
57
|
-
export type ThinkingLevel = "off" | "minimal" | "low" | "medium" | "high" | "xhigh";
|
|
57
|
+
export type ThinkingLevel = "off" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
|
|
58
58
|
export const THINKING_LEVELS: readonly ThinkingLevel[] = [
|
|
59
59
|
"off",
|
|
60
60
|
"minimal",
|
|
@@ -62,6 +62,7 @@ export const THINKING_LEVELS: readonly ThinkingLevel[] = [
|
|
|
62
62
|
"medium",
|
|
63
63
|
"high",
|
|
64
64
|
"xhigh",
|
|
65
|
+
"max",
|
|
65
66
|
];
|
|
66
67
|
export type WhenBusy = "followUp" | "steer" | "reject";
|
|
67
68
|
|
|
@@ -146,6 +147,8 @@ export interface SessionSummary {
|
|
|
146
147
|
name: string;
|
|
147
148
|
cwd: string;
|
|
148
149
|
model: string;
|
|
150
|
+
/** Provider id of the session's model ("faux" offline; same column the catalog stores). */
|
|
151
|
+
provider: string;
|
|
149
152
|
createdAt: number;
|
|
150
153
|
dbPath: string;
|
|
151
154
|
busy: boolean;
|
package/apps/dpi-tui/src/app.ts
CHANGED
|
@@ -1062,7 +1062,7 @@ export class App {
|
|
|
1062
1062
|
if (!wide) return table;
|
|
1063
1063
|
const selected = this.sessions.find((s) => s.id === (this.selectedId ?? this.sessionId));
|
|
1064
1064
|
if (selected?.cwd) this.refreshGit(selected.cwd);
|
|
1065
|
-
const panel = renderHerdPanel(panelW, h, selected, this.contextLeft(), this.device.name, this.gitOf(selected?.cwd));
|
|
1065
|
+
const panel = renderHerdPanel(panelW, h, selected, this.contextLeft(), this.device.name, this.gitOf(selected?.cwd), this.info.defaultModel);
|
|
1066
1066
|
return joinPanel(table, panel, tableW, w, h);
|
|
1067
1067
|
}
|
|
1068
1068
|
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
type Focusable,
|
|
12
12
|
type SelectItem,
|
|
13
13
|
} from "@earendil-works/pi-tui";
|
|
14
|
+
import { THINKING_LEVELS, type ThinkingLevel } from "../../dpi-sdk/src/api.ts";
|
|
14
15
|
import { agentTree, type TreeNode } from "../../dpi-sdk/src/models.ts";
|
|
15
16
|
import type { App } from "./app.ts";
|
|
16
17
|
import { c, selectTheme } from "./theme.ts";
|
|
@@ -286,8 +287,17 @@ export async function newSession(app: App, presetName?: string) {
|
|
|
286
287
|
? await chooseModel(app, app.info.defaultModel)
|
|
287
288
|
: { provider: (app.info as { provider?: string }).provider ?? "openrouter", id: app.info.defaultModel, name: "(device default)" };
|
|
288
289
|
if (!model) return;
|
|
290
|
+
// Thinking rides the create call: pick a level up front instead of paying
|
|
291
|
+
// for "high" on a scratch session the device default never asked for.
|
|
292
|
+
const thinking = await chooseThinking(app);
|
|
293
|
+
if (!thinking) return;
|
|
289
294
|
await app.run(async () => {
|
|
290
|
-
const s = await app.client.createSession({
|
|
295
|
+
const s = await app.client.createSession({
|
|
296
|
+
name: name || "New session",
|
|
297
|
+
cwd,
|
|
298
|
+
model: { provider: model.provider, modelId: model.id },
|
|
299
|
+
thinkingLevel: thinking,
|
|
300
|
+
});
|
|
291
301
|
await app.attach(s.id, s.agents.find((a) => a.kind === "root")?.id ?? 1);
|
|
292
302
|
app.flash(`Session created in ${cwd}`);
|
|
293
303
|
if (!models.length) app.flash(`no model catalog on the device — using its default (${app.info.defaultModel})`);
|
|
@@ -346,6 +356,28 @@ function chooseModel(app: App, current?: string) {
|
|
|
346
356
|
});
|
|
347
357
|
}
|
|
348
358
|
|
|
359
|
+
/** The new-session thinking step: the same levels `y` cycles in-session. */
|
|
360
|
+
function chooseThinking(app: App) {
|
|
361
|
+
return new Promise<ThinkingLevel | undefined>((done) => {
|
|
362
|
+
const picker = new Picker(
|
|
363
|
+
"Thinking level",
|
|
364
|
+
THINKING_LEVELS.map((level) => ({ value: level, label: level })),
|
|
365
|
+
(item) => {
|
|
366
|
+
app.closeOverlay();
|
|
367
|
+
done(item.value as ThinkingLevel);
|
|
368
|
+
},
|
|
369
|
+
() => {
|
|
370
|
+
app.closeOverlay();
|
|
371
|
+
done(undefined);
|
|
372
|
+
},
|
|
373
|
+
);
|
|
374
|
+
// Preselect the backend's create default, so a bare enter keeps "medium".
|
|
375
|
+
const index = THINKING_LEVELS.indexOf("medium");
|
|
376
|
+
if (index >= 0) picker.list.setSelectedIndex(index);
|
|
377
|
+
app.overlay(picker);
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
|
|
349
381
|
export async function pickModel(app: App) {
|
|
350
382
|
if (!app.handle) return;
|
|
351
383
|
const model = await chooseModel(app, app.model.state.agent.model?.modelId);
|
|
@@ -302,6 +302,8 @@ export function renderHerdPanel(
|
|
|
302
302
|
ctxLeft?: number,
|
|
303
303
|
device?: string,
|
|
304
304
|
git?: { repo: boolean; branch?: string; head?: string; staged?: number; unstaged?: number; untracked?: number; ahead?: number; behind?: number; worktreeOf?: string },
|
|
305
|
+
/** The device's advertised default model id — a session on it is "(default)". */
|
|
306
|
+
defaultModel?: string,
|
|
305
307
|
): string[] {
|
|
306
308
|
// No session selected: a blank panel next to the divider is what made the
|
|
307
309
|
// wide layout look broken — herdr's panel always carries a device header.
|
|
@@ -321,10 +323,13 @@ export function renderHerdPanel(
|
|
|
321
323
|
const agents = s.agents.map((a) =>
|
|
322
324
|
a.kind === "fork" ? `⑂ ${a.name}` : a.kind === "subagent" ? `↳ ${a.name}` : `● ${a.name}`,
|
|
323
325
|
);
|
|
326
|
+
// A session on exactly the device's default model says so, muted — the same
|
|
327
|
+
// signal the web dialog's "(device default)" row carries.
|
|
328
|
+
const onDefault = defaultModel !== undefined && s.model === defaultModel;
|
|
324
329
|
const lines = [
|
|
325
330
|
c.muted(" OVERVIEW"),
|
|
326
331
|
` ${c.bold(s.name)}`,
|
|
327
|
-
` ${c.muted(basename(s.cwd))} ${c.muted("·")} ${c.text(basename(s.model) || s.model)}`,
|
|
332
|
+
` ${c.muted(basename(s.cwd))} ${c.muted("·")} ${c.text(basename(s.model) || s.model)}${onDefault ? c.muted(" (default)") : ""}`,
|
|
328
333
|
git?.repo
|
|
329
334
|
? ` ${c.muted("⎇")} ${c.text(git.branch ?? git.head ?? "?")}${c.muted("±")}${c.text(String((git.staged ?? 0) + (git.unstaged ?? 0) + (git.untracked ?? 0)))}${git.ahead ? c.text(` ↑${git.ahead}`) : ""}${git.behind ? c.text(` ↓${git.behind}`) : ""}${git.worktreeOf ? c.muted(" · worktree") : ""}`
|
|
330
335
|
: "",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "my-durable",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.56",
|
|
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": {
|