@matamt-dbg/dsh-studio 0.2.8 → 0.3.0
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 +5 -5
- package/client.js +3406 -402
- package/index.js +2561 -214
- package/package.json +1 -1
- package/policy.js +14 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@matamt-dbg/dsh-studio",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "DSH Studio: build, edit and apply DeepSeek Harness agent presets — tools, prompts, Configs and role-based subagents — from the web GUI.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"deepseek-harness",
|
package/policy.js
CHANGED
|
@@ -127,23 +127,27 @@ function patchParameter(parameters, path, description) {
|
|
|
127
127
|
}
|
|
128
128
|
node.description = description;
|
|
129
129
|
}
|
|
130
|
-
function installPolicy(ctx, scopeKey, config) {
|
|
130
|
+
function installPolicy(ctx, scopeKey, config, warn = () => {
|
|
131
|
+
}) {
|
|
131
132
|
validatePolicy(config);
|
|
132
133
|
if (scopeOf(ctx) !== scopeKey) throw new Error("Studio policy requires its owning scoped context");
|
|
133
134
|
if (config.tools.includes("run_code") || ctx.tools.get("run_code", scopeKey) !== void 0) {
|
|
134
135
|
throw new Error("Studio policy does not support PTC presentation or the reserved run_code tool; configure this preset with native tool presentation");
|
|
135
136
|
}
|
|
136
137
|
const missing = config.tools.filter((name2) => ctx.tools.get(name2, scopeKey) === void 0);
|
|
137
|
-
if (missing.length)
|
|
138
|
+
if (missing.length) warn(`Studio policy selected tools unavailable: ${missing.join(", ")}`);
|
|
138
139
|
const restoreProbe = ctx.tools.restrict({ allow: [] });
|
|
140
|
+
let local;
|
|
139
141
|
try {
|
|
140
|
-
|
|
141
|
-
if (local.length) throw new Error(`Studio policy does not support own-scope tools: ${local.map((tool) => tool.name).join(", ")}; register providers in an ancestor preset scope. Public API cannot hide late own-scope schemas; dynamic own-scope providers are unsupported`);
|
|
142
|
+
local = new Set(ctx.tools.schemas(scopeKey).map((tool) => tool.name));
|
|
142
143
|
} finally {
|
|
143
144
|
restoreProbe();
|
|
144
145
|
}
|
|
145
146
|
const selected = new Set(config.tools);
|
|
146
|
-
const
|
|
147
|
+
const deny = ctx.tools.schemas(scopeKey).map((tool) => tool.name).filter((name2) => !selected.has(name2) && !local.has(name2));
|
|
148
|
+
const unpatchable = config.tools.filter((name2) => local.has(name2) && (config.toolOverrides[name2] || config.execution?.defaults[name2] || config.execution?.batch?.tool === name2));
|
|
149
|
+
if (unpatchable.length) warn(`Studio policy cannot apply overrides to agent-scope tools: ${unpatchable.join(", ")}`);
|
|
150
|
+
const definitions = config.tools.filter((name2) => !local.has(name2) && !missing.includes(name2)).map((name2) => {
|
|
147
151
|
const definition = ctx.tools.get(name2, scopeKey);
|
|
148
152
|
const override = config.toolOverrides[name2];
|
|
149
153
|
const defaults = config.execution?.defaults[name2];
|
|
@@ -177,8 +181,7 @@ function installPolicy(ctx, scopeKey, config) {
|
|
|
177
181
|
for (const release of disposers.splice(0).reverse()) release();
|
|
178
182
|
};
|
|
179
183
|
try {
|
|
180
|
-
disposers.push(ctx.tools.restrict({
|
|
181
|
-
disposers.push(ctx.tools.guard((execution) => selected.has(execution.name) ? void 0 : "Tool excluded by Studio preset policy"));
|
|
184
|
+
if (deny.length) disposers.push(ctx.tools.restrict({ deny }));
|
|
182
185
|
for (const definition of definitions) disposers.push(ctx.tools.register(definition));
|
|
183
186
|
for (const [name2, text] of Object.entries(config.sections)) disposers.push(ctx.systemPrompt.section({ name: name2, order: ctx.systemPrompt.getSectionOrder(POLICY_SECTION_ORDERS[name2]), text, interpolate: false }));
|
|
184
187
|
disposers.push(ctx.systemPrompt.section({ name: "studio:additional", order: Number.MAX_SAFE_INTEGER, text: config.prompt, interpolate: false }));
|
|
@@ -200,13 +203,16 @@ function apply(ctx, config) {
|
|
|
200
203
|
const hidden = hideable.filter((name2) => agent.ctx.tools.get(name2, agent) === void 0 && provided(name2));
|
|
201
204
|
return hidden.length ? childPolicy(config, hidden) : config;
|
|
202
205
|
};
|
|
206
|
+
const warn = (message) => {
|
|
207
|
+
ctx.logger?.warn?.(message);
|
|
208
|
+
};
|
|
203
209
|
const installed = /* @__PURE__ */ new Map();
|
|
204
210
|
const installing = /* @__PURE__ */ new Set();
|
|
205
211
|
const install = (agent) => {
|
|
206
212
|
if (installed.has(agent) || installing.has(agent)) return;
|
|
207
213
|
installing.add(agent);
|
|
208
214
|
try {
|
|
209
|
-
installed.set(agent, installPolicy(agent.ctx, agent, policyFor(agent)));
|
|
215
|
+
installed.set(agent, installPolicy(agent.ctx, agent, policyFor(agent), warn));
|
|
210
216
|
} finally {
|
|
211
217
|
installing.delete(agent);
|
|
212
218
|
}
|