@sleep2agi/dsh-anet 0.1.0-preview.26 → 0.1.0-preview.27
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 -1
- package/README.zh.md +1 -1
- package/package.json +1 -1
- package/src/client.js +33 -5
- package/src/plugin.mjs +6 -2
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ A [DSH (DeepSeek Harness)](https://www.npmjs.com/package/@deepseek-ai/dsh) plugi
|
|
|
13
13
|
## Install
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
-
dsh plugin --profile web add /
|
|
16
|
+
dsh plugin --profile web add @sleep2agi/dsh-anet
|
|
17
17
|
# restart DSH
|
|
18
18
|
```
|
|
19
19
|
|
package/README.zh.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sleep2agi/dsh-anet",
|
|
3
|
-
"version": "0.1.0-preview.
|
|
3
|
+
"version": "0.1.0-preview.27",
|
|
4
4
|
"description": "DSH (DeepSeek Harness) plugin: expose one or more DSH sessions as Agent Network (anet.sh / CommHub) nodes.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/plugin.mjs",
|
package/src/client.js
CHANGED
|
@@ -22,6 +22,7 @@ window.__ModuleLoader__.load({
|
|
|
22
22
|
loggedIn: "已登录", createTitle: "创建节点", createHint: "节点 token 会由当前账号自动创建",
|
|
23
23
|
create: "创建节点", creating: "创建中…", created: "节点已创建并接入",
|
|
24
24
|
delete: "删除", confirmDelete: "删除这个节点?", switchSession: "切换会话", switched: "已切换会话",
|
|
25
|
+
switchProject: "切换项目", switchProjectHint: "切换项目会为该节点新建 session", projectSwitched: "已切换项目",
|
|
25
26
|
loading: "正在加载…", offline: "本地服务不可用(127.0.0.1:9460)", failed: "操作失败",
|
|
26
27
|
note: "配置保存在 ~/.anet/dsh/nodes.json(0600)",
|
|
27
28
|
running: "已连接", starting: "连接中", stopped: "未连接", error: "异常",
|
|
@@ -38,6 +39,7 @@ window.__ModuleLoader__.load({
|
|
|
38
39
|
loggedIn: "Logged in", createTitle: "Create node", createHint: "The node token is minted with the current account",
|
|
39
40
|
create: "Create node", creating: "Creating…", created: "Node created and connected",
|
|
40
41
|
delete: "Delete", confirmDelete: "Delete this node?", switchSession: "Switch session", switched: "Session switched",
|
|
42
|
+
switchProject: "Switch project", switchProjectHint: "Switching project creates a new session for this node", projectSwitched: "Project switched",
|
|
41
43
|
loading: "Loading…", offline: "Local service unavailable (127.0.0.1:9460)", failed: "Failed",
|
|
42
44
|
note: "Stored in ~/.anet/dsh/nodes.json (0600)",
|
|
43
45
|
running: "Connected", starting: "Connecting", stopped: "Disconnected", error: "Error",
|
|
@@ -97,20 +99,30 @@ window.__ModuleLoader__.load({
|
|
|
97
99
|
}
|
|
98
100
|
|
|
99
101
|
function NodeRow(props) {
|
|
100
|
-
const { node, t, onDelete, sessions, onSwitch } = props;
|
|
102
|
+
const { node, t, onDelete, sessions, onSwitch, projects, onSwitchProject } = props;
|
|
101
103
|
return h("div", { style: { ...cardStyle, padding: "14px 16px", marginBottom: 10 } },
|
|
102
104
|
h("div", { style: { display: "flex", alignItems: "center", gap: 10 } },
|
|
103
105
|
h("div", { style: { fontSize: 14, fontWeight: 650, color: T.text, flex: 1, minWidth: 0, overflowWrap: "anywhere" } }, node.name),
|
|
104
106
|
h(StatusPill, { status: node.status, t }),
|
|
105
107
|
h("button", { type: "button", style: ghostButton(false), onClick: () => onDelete(node) }, t("delete")),
|
|
106
108
|
),
|
|
107
|
-
h("div", { style: { display: "grid", gridTemplateColumns: "1.2fr 1fr
|
|
109
|
+
h("div", { style: { display: "grid", gridTemplateColumns: "1.2fr 1fr", gap: 12, marginTop: 10 } },
|
|
108
110
|
h(Meta, { label: "Hub", value: node.hub }),
|
|
109
111
|
h(Meta, { label: "NETWORK", value: node.networkId || t("noNetwork") }),
|
|
110
|
-
h(Meta, { label: "PROJECT", value: node.projectDir }),
|
|
111
112
|
),
|
|
112
113
|
h("div", { style: { display: "flex", alignItems: "center", gap: 8, marginTop: 10, paddingTop: 10, borderTop: `1px solid ${T.border}` } },
|
|
113
|
-
h("span", { style: { fontSize: 11.5, color: T.muted, flex: "none" } }, t("
|
|
114
|
+
h("span", { style: { fontSize: 11.5, color: T.muted, flex: "none", width: 44 } }, t("projectLabel")),
|
|
115
|
+
h("select", {
|
|
116
|
+
value: node.projectDir,
|
|
117
|
+
onChange: (event) => onSwitchProject(node, event.target.value),
|
|
118
|
+
style: { ...inputStyle, height: 30, padding: "0 8px", fontSize: 12, flex: 1, minWidth: 0 },
|
|
119
|
+
},
|
|
120
|
+
(projects ?? []).some((project) => project.path === node.projectDir) ? null : h("option", { value: node.projectDir }, node.projectDir),
|
|
121
|
+
(projects ?? []).map((project) => h("option", { key: project.path, value: project.path }, `${project.label} — ${project.path}`)),
|
|
122
|
+
),
|
|
123
|
+
),
|
|
124
|
+
h("div", { style: { display: "flex", alignItems: "center", gap: 8, marginTop: 8 } },
|
|
125
|
+
h("span", { style: { fontSize: 11.5, color: T.muted, flex: "none", width: 44 } }, t("sessionPick")),
|
|
114
126
|
h("select", {
|
|
115
127
|
value: node.sessionId,
|
|
116
128
|
disabled: !sessions || sessions.length === 0,
|
|
@@ -296,6 +308,22 @@ window.__ModuleLoader__.load({
|
|
|
296
308
|
}
|
|
297
309
|
};
|
|
298
310
|
|
|
311
|
+
const onSwitchProject = async (node, projectDir) => {
|
|
312
|
+
if (!projectDir || projectDir === node.projectDir) return;
|
|
313
|
+
if (!window.confirm(`${t("switchProjectHint")}?`)) return;
|
|
314
|
+
try {
|
|
315
|
+
const res = await fetch(`${ENDPOINT}/nodes/${encodeURIComponent(node.id)}`, {
|
|
316
|
+
method: "PATCH", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ projectDir }),
|
|
317
|
+
});
|
|
318
|
+
const body = await res.json();
|
|
319
|
+
if (!res.ok || body.ok === false) throw new Error(body.error ?? `HTTP ${res.status}`);
|
|
320
|
+
setMessage(t("projectSwitched"));
|
|
321
|
+
await refresh();
|
|
322
|
+
} catch (error) {
|
|
323
|
+
setFailed(true); setMessage(`${t("failed")}: ${error?.message ?? error}`);
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
|
|
299
327
|
const onSwitch = async (node, sessionId) => {
|
|
300
328
|
if (!sessionId || sessionId === node.sessionId) return;
|
|
301
329
|
if (!window.confirm(t("confirmDelete").replace(/.*/, t("switchSession") + "?"))) return;
|
|
@@ -333,7 +361,7 @@ window.__ModuleLoader__.load({
|
|
|
333
361
|
state.nodes.length === 0
|
|
334
362
|
? h("p", { style: { fontSize: 12, color: T.muted, margin: "10px 0 2px" } }, t("noNodes"))
|
|
335
363
|
: h("div", { style: { marginTop: 12 } }, state.nodes.map((node) =>
|
|
336
|
-
h(NodeRow, { key: node.id, node, t, onDelete, sessions, onSwitch }))),
|
|
364
|
+
h(NodeRow, { key: node.id, node, t, onDelete, sessions, onSwitch, projects, onSwitchProject }))),
|
|
337
365
|
),
|
|
338
366
|
|
|
339
367
|
session
|
package/src/plugin.mjs
CHANGED
|
@@ -13,7 +13,7 @@ import { createLedger } from "./ledger.mjs";
|
|
|
13
13
|
import { createCommhubNode } from "./node-loop.mjs";
|
|
14
14
|
import { commhubToolSpecs } from "./tools.mjs";
|
|
15
15
|
import { summarizeTurn, turnFailure } from "./turn.mjs";
|
|
16
|
-
import { findNodeBySession, loadNodes, normalizeNode, registryPath, saveNodes, validateNode } from "./nodes.mjs";
|
|
16
|
+
import { findNodeBySession, loadNodes, newSessionId, normalizeNode, registryPath, saveNodes, validateNode } from "./nodes.mjs";
|
|
17
17
|
import { startConfigServer } from "./ui-server.mjs";
|
|
18
18
|
|
|
19
19
|
export { summarizeTurn } from "./turn.mjs";
|
|
@@ -21,7 +21,7 @@ export { summarizeTurn } from "./turn.mjs";
|
|
|
21
21
|
export const name = "anet";
|
|
22
22
|
export const inject = ["agents", "agentDefaultModel", "sessions", "tools"];
|
|
23
23
|
|
|
24
|
-
const VERSION = "dsh-anet@0.1.0-preview.
|
|
24
|
+
const VERSION = "dsh-anet@0.1.0-preview.27";
|
|
25
25
|
|
|
26
26
|
function agentSetup(ctx) {
|
|
27
27
|
const selection = ctx.agentDefaultModel.currentSelection();
|
|
@@ -242,6 +242,10 @@ export function apply(ctx, config) {
|
|
|
242
242
|
const node = requireNode(id);
|
|
243
243
|
let sessionId = node.sessionId;
|
|
244
244
|
let projectDir = String(draft.projectDir ?? node.projectDir);
|
|
245
|
+
if (draft.projectDir !== undefined && String(draft.projectDir) !== node.projectDir && draft.sessionId === undefined) {
|
|
246
|
+
projectDir = String(draft.projectDir);
|
|
247
|
+
sessionId = newSessionId(node.name);
|
|
248
|
+
}
|
|
245
249
|
if (draft.sessionId !== undefined && String(draft.sessionId) !== node.sessionId) {
|
|
246
250
|
const session = await sessionById(String(draft.sessionId));
|
|
247
251
|
if (!session) throw new Error(`session 不存在: ${draft.sessionId}`);
|