@dsmm/dsmm 0.3.32 → 0.3.33
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/dsh-plugin.json +1 -1
- package/lib/client/RoleToolView.js +9 -8
- package/lib/client.js +5 -5
- package/lib/native-admission.js +16 -8
- package/lib/resident-root.d.ts +1 -1
- package/lib/resident-root.js +39 -6
- package/package.json +1 -1
package/dsh-plugin.json
CHANGED
|
@@ -57,17 +57,18 @@ export function RoleToolView(props) {
|
|
|
57
57
|
const actual = persisted?.phase === "settled" ? persisted : observed ?? inactivePersisted;
|
|
58
58
|
const comparison = actual?.routeComparison;
|
|
59
59
|
const target = actual?.role ?? requested.target;
|
|
60
|
-
const
|
|
60
|
+
const observedStop = actual?.phase === "settled" ? actual.stopReason : undefined;
|
|
61
|
+
const state = result?.error?.code === "interrupted" || observedStop === "aborted" ? "stopped"
|
|
62
|
+
: failed || observedStop !== undefined && observedStop !== "completed" ? "error"
|
|
63
|
+
: result !== undefined && actual?.delivery === "parent" && actual.phase !== "settled" ? "background"
|
|
64
|
+
: actual?.phase === "settled" || result !== undefined ? "result"
|
|
65
|
+
: props.phase === "preparing" ? "preparing" : "running";
|
|
66
|
+
const isOngoing = state === "running" || state === "preparing";
|
|
67
|
+
const action = state === "preparing" ? t("calling") : t("call");
|
|
61
68
|
const targetLabel = target === undefined ? t("unknownTarget") : roleToolDisplay(target);
|
|
62
69
|
const rawDesc = requested.description?.trim();
|
|
63
70
|
const singleLineDesc = rawDesc ? rawDesc.replace(/\s+/gu, " ") : undefined;
|
|
64
71
|
const title = `${action} ${targetLabel}`;
|
|
65
|
-
const observedStop = actual?.phase === "settled" ? actual.stopReason : undefined;
|
|
66
|
-
const state = result?.error?.code === "interrupted" || observedStop === "aborted" ? "stopped"
|
|
67
|
-
: failed || observedStop !== undefined && observedStop !== "completed" ? "error"
|
|
68
|
-
: result === undefined ? props.phase === "preparing" ? "preparing" : "running"
|
|
69
|
-
: actual?.delivery === "parent" && actual.phase !== "settled" ? "background" : "result";
|
|
70
|
-
const isOngoing = state === "running" || props.phase === "preparing";
|
|
71
72
|
const code = (value) => _jsx(CodeBlock, { code: value, copyLabel: t("copy"), copiedLabel: t("copied") });
|
|
72
73
|
const [viewMode, setViewMode] = useState("table");
|
|
73
74
|
const controlId = `dsmm-tech-${props.callId || "call"}`;
|
|
@@ -84,7 +85,7 @@ export function RoleToolView(props) {
|
|
|
84
85
|
const actualRoute = comparison?.liveRoute;
|
|
85
86
|
const routeLabel = (route, missingEffort = false) => `${route.provider}/${route.model}${route.reasoningEffort === undefined ? missingEffort ? ` · ${t("effortUnreported")}` : "" : ` · ${route.reasoningEffort}`}`;
|
|
86
87
|
const collapsedContent = singleLineDesc ? _jsxs(_Fragment, { children: [_jsx("span", { className: "dsmm-role-sep", "aria-hidden": "true" }), _jsx("span", { className: "dsmm-role-summary", children: _jsx(TextShimmer, { active: isOngoing, children: singleLineDesc }) })] }) : undefined;
|
|
87
|
-
const stateDotState = state === "error" ? "error" : state === "stopped" ? "warning" :
|
|
88
|
+
const stateDotState = state === "error" ? "error" : state === "stopped" ? "warning" : state === "background" ? "idle" : state === "result" ? "done" : "ongoing";
|
|
88
89
|
return _jsxs("div", { className: "dsmm-role-tool", "data-dsmm-role-tool": props.toolName, "data-identity": actual === undefined ? "requested" : "actual", "data-state": state, "data-delivery": actual?.delivery, "data-phase": actual?.phase, "data-expanded": expanded ? "true" : "false", children: [_jsx(DisclosureRow, { title: title, titleClassName: "dsmm-role-title", rowClassName: "dsmm-role-heading", contentClassName: "dsmm-role-text", icon: _jsx(IconAgentPresetOutlineRegular, { size: 14, className: "dsmm-role-icon" }), collapsedContent: collapsedContent, keepContentWhenOpen: true, running: isOngoing, open: expanded, expandable: true, onToggle: toggle, expandOnRowClick: true, children: _jsxs("div", { className: "dsmm-role-body", children: [_jsxs("p", { className: "dsmm-role-identity", children: [showRequestedVsActual ? _jsxs(_Fragment, { children: [_jsxs("span", { className: "dsmm-role-dim", children: [t("requested"), ": "] }), _jsxs("span", { children: [requested.target === undefined ? t("unknown") : roleToolDisplay(requested.target), requested.level ? ` (${requested.level})` : ""] }), _jsx("span", { className: "dsmm-role-dim", children: " \u2192 " }), _jsxs("span", { className: "dsmm-role-dim", children: [t("actual"), ": "] }), _jsxs("span", { children: [roleToolDisplay(actual.role), " (", actual.level, ")"] })] }) : _jsxs("span", { children: [actual === undefined && _jsxs("span", { className: "dsmm-role-dim", children: [t("requested"), ": "] }), actual !== undefined ? roleToolDisplay(actual.role) : requested.target === undefined ? t("unknownTarget") : roleToolDisplay(requested.target), (actual?.level ?? requested.level) !== undefined && ` · ${actual?.level ?? requested.level}`, props.phase !== "preparing" && actual === undefined && _jsxs("span", { className: "dsmm-role-dim", children: [" \u00B7 ", t("actualUnknown")] })] }), initialRoute !== undefined && _jsxs("span", { className: "dsmm-role-model", children: [" · ", t("initialRoute"), ": ", initialRoute.status === "known" ? routeLabel(initialRoute.route) : t("routeUnknown")] }), actualRoute !== undefined ? _jsxs("span", { className: "dsmm-role-model", children: [" · ", t("actualRoute"), ": ", actualRoute.status === "known" ? routeLabel(actualRoute.route, true) : t("routeUnknown")] }) : props.phase !== "preparing" && _jsxs("span", { className: "dsmm-role-model", children: [" · ", t("actualRoute"), ": ", t("routeUnknown")] })] }), _jsxs("p", { className: "dsmm-role-identity", "data-observation-status": observationStatus, children: [t("observation"), ": ", t({ unavailable: "observationUnavailable", connecting: "observationConnecting", live: "observationLive", stale: "observationStale" }[observationStatus]), observationIssue !== undefined && ` · ${observationIssue.kind}/${observationIssue.code}`] }), requested.description !== undefined && _jsx("p", { className: "dsmm-role-task", children: requested.description }), result?.error != null && _jsxs("div", { className: "dsmm-role-failure", children: [_jsx("p", { className: "dsmm-role-section-title", children: t("failure") }), code(JSON.stringify(result.error, null, 2))] }), _jsxs("details", { className: "dsmm-role-details", children: [_jsx("summary", { children: t("technicalDetails") }), _jsxs("div", { className: "dsmm-role-details-body", children: [_jsx("div", { className: "dsmm-role-details-header", children: _jsx(SegmentedControl, { id: controlId, value: viewMode, options: viewOptions, onChange: setViewMode, label: t("viewMode"), className: "dsmm-role-view-switch" }) }), _jsx("div", { id: `${controlId}-table-panel`, role: "tabpanel", "aria-labelledby": `${controlId}-table`, hidden: viewMode !== "table", tabIndex: 0, children: viewMode === "table" && _jsxs("table", { className: "dsmm-role-table", children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { scope: "col", children: t("property") }), _jsx("th", { scope: "col", children: t("value") })] }) }), _jsx("tbody", { children: tableRows.map(row => _jsxs("tr", { children: [_jsx("td", { className: "dsmm-role-prop-cell", children: row.property }), _jsx("td", { className: "dsmm-role-val-cell", children: row.isComplex ? _jsx("pre", { className: "dsmm-role-cell-code", children: JSON.stringify(row.value, null, 2) })
|
|
89
90
|
: typeof row.value === "string" ? _jsx("span", { className: "dsmm-role-cell-text", children: row.value })
|
|
90
91
|
: _jsx("span", { children: row.value === null ? "null" : row.value === undefined ? "undefined" : String(row.value) }) })] }, row.property)) })] }) }), _jsx("div", { id: `${controlId}-json-panel`, role: "tabpanel", "aria-labelledby": `${controlId}-json`, hidden: viewMode !== "json", tabIndex: 0, children: viewMode === "json" && code(JSON.stringify(jsonData, null, 2)) })] })] })] }) }), _jsxs("div", { className: "dsmm-role-actions", children: [_jsx(StateDot, { state: stateDotState }), _jsx("p", { className: "dsmm-role-status", role: "status", children: t(state) }), props.inspect !== undefined && _jsx(Button, { variant: "ghost", size: "sm", onClick: props.inspect, children: t("inspect") })] })] });
|
package/lib/client.js
CHANGED
|
@@ -9659,14 +9659,14 @@ function RoleToolView(props) {
|
|
|
9659
9659
|
const actual = persisted?.phase === "settled" ? persisted : observed ?? inactivePersisted;
|
|
9660
9660
|
const comparison = actual?.routeComparison;
|
|
9661
9661
|
const target = actual?.role ?? requested.target;
|
|
9662
|
-
const
|
|
9662
|
+
const observedStop = actual?.phase === "settled" ? actual.stopReason : void 0;
|
|
9663
|
+
const state = result?.error?.code === "interrupted" || observedStop === "aborted" ? "stopped" : failed || observedStop !== void 0 && observedStop !== "completed" ? "error" : result !== void 0 && actual?.delivery === "parent" && actual.phase !== "settled" ? "background" : actual?.phase === "settled" || result !== void 0 ? "result" : props.phase === "preparing" ? "preparing" : "running";
|
|
9664
|
+
const isOngoing = state === "running" || state === "preparing";
|
|
9665
|
+
const action2 = state === "preparing" ? t("calling") : t("call");
|
|
9663
9666
|
const targetLabel = target === void 0 ? t("unknownTarget") : roleToolDisplay(target);
|
|
9664
9667
|
const rawDesc = requested.description?.trim();
|
|
9665
9668
|
const singleLineDesc = rawDesc ? rawDesc.replace(/\s+/gu, " ") : void 0;
|
|
9666
9669
|
const title = `${action2} ${targetLabel}`;
|
|
9667
|
-
const observedStop = actual?.phase === "settled" ? actual.stopReason : void 0;
|
|
9668
|
-
const state = result?.error?.code === "interrupted" || observedStop === "aborted" ? "stopped" : failed || observedStop !== void 0 && observedStop !== "completed" ? "error" : result === void 0 ? props.phase === "preparing" ? "preparing" : "running" : actual?.delivery === "parent" && actual.phase !== "settled" ? "background" : "result";
|
|
9669
|
-
const isOngoing = state === "running" || props.phase === "preparing";
|
|
9670
9670
|
const code = (value) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_dsh_client_ui_primitives12.CodeBlock, { code: value, copyLabel: t("copy"), copiedLabel: t("copied") });
|
|
9671
9671
|
const [viewMode, setViewMode] = (0, import_react11.useState)("table");
|
|
9672
9672
|
const controlId = `dsmm-tech-${props.callId || "call"}`;
|
|
@@ -9686,7 +9686,7 @@ function RoleToolView(props) {
|
|
|
9686
9686
|
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "dsmm-role-sep", "aria-hidden": "true" }),
|
|
9687
9687
|
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "dsmm-role-summary", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_dsh_client_ui_primitives12.TextShimmer, { active: isOngoing, children: singleLineDesc }) })
|
|
9688
9688
|
] }) : void 0;
|
|
9689
|
-
const stateDotState = state === "error" ? "error" : state === "stopped" ? "warning" :
|
|
9689
|
+
const stateDotState = state === "error" ? "error" : state === "stopped" ? "warning" : state === "background" ? "idle" : state === "result" ? "done" : "ongoing";
|
|
9690
9690
|
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
9691
9691
|
"div",
|
|
9692
9692
|
{
|
package/lib/native-admission.js
CHANGED
|
@@ -198,6 +198,9 @@ export class NativeAdmission {
|
|
|
198
198
|
}, { global: true, prepend: true });
|
|
199
199
|
ctx.on("tools/pre-execute", async (exec, next) => {
|
|
200
200
|
if (exec.agent) {
|
|
201
|
+
const publication = !this.live.has(exec.agent) && this.awaitingPublication.get(exec.agent);
|
|
202
|
+
if (publication)
|
|
203
|
+
await publication.promise;
|
|
201
204
|
captureResidentTool(exec.agent, this, exec.token);
|
|
202
205
|
this.trackExecution(exec);
|
|
203
206
|
await this.guardExecution(exec.agent);
|
|
@@ -616,8 +619,10 @@ export class NativeAdmission {
|
|
|
616
619
|
/** Exact process-local capture, retained after retirement so stale objects never become native. */
|
|
617
620
|
owns(agent) { return this.agentLifetimes.has(agent); }
|
|
618
621
|
async guardExecution(agent) {
|
|
622
|
+
const publication = this.awaitingPublication.get(agent);
|
|
623
|
+
if (publication)
|
|
624
|
+
await publication.promise;
|
|
619
625
|
assertResidentRootCurrent(agent, this);
|
|
620
|
-
await this.awaitingPublication.get(agent)?.promise;
|
|
621
626
|
if (!this.owns(agent)) {
|
|
622
627
|
const registry = agent.ctx.get("agents");
|
|
623
628
|
if (registry && original(registry) === original(this.ctx.agents) && scopeOf(agent.ctx) === agent && registry.get(agent.id) !== agent
|
|
@@ -1091,7 +1096,7 @@ export class NativeAdmission {
|
|
|
1091
1096
|
if (restoring)
|
|
1092
1097
|
guardResidentRealm(agent);
|
|
1093
1098
|
else
|
|
1094
|
-
markResidentAgent(agent, this, isRoot);
|
|
1099
|
+
markResidentAgent(agent, this, isRoot, this.awaitingPublication.get(agent)?.promise);
|
|
1095
1100
|
const scope = agent.ctx.plugin(function dsmmAgentGeneration() { }).ctx;
|
|
1096
1101
|
this.scopes.set(agent, scope);
|
|
1097
1102
|
this.agentLifetimes.set(agent, new AbortController());
|
|
@@ -1253,15 +1258,12 @@ export class NativeAdmission {
|
|
|
1253
1258
|
}
|
|
1254
1259
|
await this.install(agent, this.getter(agent), scope);
|
|
1255
1260
|
check();
|
|
1256
|
-
await this.profiles.revalidateActivation(admission);
|
|
1257
|
-
check();
|
|
1258
|
-
if (pending)
|
|
1259
|
-
this.check(pending);
|
|
1260
|
-
if (continuationProvider && this.ctx.get("subagents").getProvider(continuationProvider.name) !== continuationProvider)
|
|
1261
|
-
throw new SubagentError("Role provider changed", "UNAUTHORIZED");
|
|
1262
1261
|
// Occupancy precedes the installed guards' async policy and approval work.
|
|
1263
1262
|
scope.on("tools/pre-execute", async (exec, next) => {
|
|
1264
1263
|
if (exec.agent === agent) {
|
|
1264
|
+
const publication = !this.live.has(agent) && this.awaitingPublication.get(agent);
|
|
1265
|
+
if (publication)
|
|
1266
|
+
await publication.promise;
|
|
1265
1267
|
captureResidentTool(agent, this, exec.token);
|
|
1266
1268
|
this.trackExecution(exec);
|
|
1267
1269
|
await this.ensure(agent);
|
|
@@ -1271,6 +1273,12 @@ export class NativeAdmission {
|
|
|
1271
1273
|
}
|
|
1272
1274
|
return next();
|
|
1273
1275
|
}, { prepend: true });
|
|
1276
|
+
await this.profiles.revalidateActivation(admission);
|
|
1277
|
+
check();
|
|
1278
|
+
if (pending)
|
|
1279
|
+
this.check(pending);
|
|
1280
|
+
if (continuationProvider && this.ctx.get("subagents").getProvider(continuationProvider.name) !== continuationProvider)
|
|
1281
|
+
throw new SubagentError("Role provider changed", "UNAUTHORIZED");
|
|
1274
1282
|
const routeCandidate = await this.admissionModelSelection?.(agent, {
|
|
1275
1283
|
settings: admission.settings, epoch: admission.epoch, admission, signal, assertCurrent: check,
|
|
1276
1284
|
});
|
package/lib/resident-root.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { Agent } from "@deepseek-ai/dsh-agent";
|
|
|
2
2
|
import type { ToolExecution } from "@deepseek-ai/dsh-tools";
|
|
3
3
|
import type { NativeAdmission } from "./native-admission.js";
|
|
4
4
|
export declare function assertResidentRootCurrent(agent: Agent, owner: NativeAdmission | undefined): void;
|
|
5
|
-
export declare function markResidentAgent(agent: Agent, owner: NativeAdmission, root: boolean): void;
|
|
5
|
+
export declare function markResidentAgent(agent: Agent, owner: NativeAdmission, root: boolean, publication?: Promise<void>): void;
|
|
6
6
|
export declare function captureResidentTool(agent: Agent, owner: NativeAdmission, token: ToolExecution["token"]): void;
|
|
7
7
|
export declare function guardResidentRealm(agent: Agent): void;
|
|
8
8
|
export declare function publishResidentAgent(agent: Agent, owner: NativeAdmission): void;
|
package/lib/resident-root.js
CHANGED
|
@@ -32,7 +32,7 @@ function claim(record, owner) {
|
|
|
32
32
|
owner.lifetime.signal.addEventListener("abort", revoke, { once: true });
|
|
33
33
|
record.detachOwner = () => owner.lifetime.signal.removeEventListener("abort", revoke);
|
|
34
34
|
}
|
|
35
|
-
export function markResidentAgent(agent, owner, root) {
|
|
35
|
+
export function markResidentAgent(agent, owner, root, publication) {
|
|
36
36
|
if (records.has(agent))
|
|
37
37
|
deny();
|
|
38
38
|
const deployment = owner.ctx.get("dsmmDeploymentConfig");
|
|
@@ -50,12 +50,26 @@ export function markResidentAgent(agent, owner, root) {
|
|
|
50
50
|
record.owner = undefined;
|
|
51
51
|
record.afterDrain = undefined;
|
|
52
52
|
});
|
|
53
|
-
agent.ctx.on("agent/pre-step", async (frame, next) => {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
agent.ctx.on("agent/pre-step", async (frame, next) => {
|
|
54
|
+
if (frame.agent === agent) {
|
|
55
|
+
if (!record.published && publication)
|
|
56
|
+
await publication;
|
|
57
|
+
await current(record).ensure(agent);
|
|
58
|
+
}
|
|
59
|
+
return next();
|
|
60
|
+
}, { prepend: true });
|
|
61
|
+
agent.ctx.on("agent/request", async (frame, next) => {
|
|
62
|
+
if (frame.agent === agent) {
|
|
63
|
+
if (!record.published && publication)
|
|
64
|
+
await publication;
|
|
65
|
+
await current(record).ensure(agent);
|
|
66
|
+
}
|
|
67
|
+
return next();
|
|
68
|
+
}, { prepend: true });
|
|
57
69
|
agent.ctx.on("tools/pre-execute", async (exec, next) => {
|
|
58
70
|
if (exec.agent === agent) {
|
|
71
|
+
if (!record.published && publication)
|
|
72
|
+
await publication;
|
|
59
73
|
const owner = current(record);
|
|
60
74
|
record.tokens.add(exec.token);
|
|
61
75
|
await owner.ensure(agent);
|
|
@@ -101,10 +115,29 @@ export function guardResidentRealm(agent) {
|
|
|
101
115
|
});
|
|
102
116
|
record.tools.add(realm);
|
|
103
117
|
}
|
|
118
|
+
function loaderEntry(owner) {
|
|
119
|
+
const entry = owner.ctx.fiber.entry, profileDir = owner.ctx.get("profileContext")?.dir;
|
|
120
|
+
return entry && profileDir ? { name: entry.options.name, profileDir } : null;
|
|
121
|
+
}
|
|
122
|
+
function sameDeployment(record, owner) {
|
|
123
|
+
const deployment = owner.ctx.get("dsmmDeploymentConfig");
|
|
124
|
+
if (!deployment || record.home !== deployment.home)
|
|
125
|
+
return false;
|
|
126
|
+
const entry = loaderEntry(owner);
|
|
127
|
+
if (record.loaderEntry && entry) {
|
|
128
|
+
// Reinstalling a plugin mints a new Loader entry ID within the same physical profile.
|
|
129
|
+
return record.loaderEntry.name === entry.name && record.loaderEntry.profileDir === entry.profileDir;
|
|
130
|
+
}
|
|
131
|
+
if (record.loaderEntry === undefined && record.profile && entry)
|
|
132
|
+
return true;
|
|
133
|
+
return record.deploymentKey === deployment.hostProfileKey && (record.loaderEntry === undefined || record.loaderEntry === entry);
|
|
134
|
+
}
|
|
104
135
|
export function publishResidentAgent(agent, owner) {
|
|
105
136
|
const record = records.get(agent);
|
|
106
137
|
if (record.disposed || original(record.owner) !== original(owner) || !owner.isReady)
|
|
107
138
|
deny();
|
|
139
|
+
record.loaderEntry = loaderEntry(owner);
|
|
140
|
+
record.deploymentKey = owner.ctx.get("dsmmDeploymentConfig")?.hostProfileKey;
|
|
108
141
|
record.scopeParent = scopeParentOf(agent);
|
|
109
142
|
record.preset = agent.ctx.get("agentPresets")?.composedPreset(agent.ctx);
|
|
110
143
|
record.published = record.active = true;
|
|
@@ -114,7 +147,7 @@ export function restoreResidentRoot(agent, owner, install) {
|
|
|
114
147
|
if (!record || record.version !== 1 || !record.root || record.disposed || !record.published || record.owner)
|
|
115
148
|
return;
|
|
116
149
|
const valid = () => record.profile === original(owner.ctx.get("profileContext")) && record.registry === original(owner.ctx.agents) && record.registry === original(agent.ctx.get("agents"))
|
|
117
|
-
&&
|
|
150
|
+
&& sameDeployment(record, owner)
|
|
118
151
|
&& record.sessions === original(owner.ctx.get("sessions")) && record.session === agent.session && owner.ctx.get("sessions")?.get(agent.id) === record.session
|
|
119
152
|
&& record.presets === original(agent.ctx.get("agentPresets")) && record.preset === agent.ctx.get("agentPresets")?.composedPreset(agent.ctx)
|
|
120
153
|
&& record.scopeParent === scopeParentOf(agent) && scopeOf(agent.ctx) === agent && owner.ctx.agents.get(agent.id) === agent;
|