@matamt-dbg/dsh-studio 0.2.1 → 0.2.7
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 +9 -4
- package/client.js +281 -174
- package/index.js +192 -57
- package/package.json +1 -1
- package/policy.js +134 -9
- package/roles.js +25 -3
package/roles.js
CHANGED
|
@@ -50,11 +50,27 @@ function parseRoles(input) {
|
|
|
50
50
|
if (!/^[a-zA-Z0-9_-]+$/.test(reasoning)) throw new Error("Role reasoning must be inherit or an effort identifier");
|
|
51
51
|
if (spawn !== "fresh" && spawn !== "fork") throw new Error("Role spawn must be fresh or fork");
|
|
52
52
|
seen.add(role);
|
|
53
|
-
|
|
53
|
+
const filter = value.toolFilter;
|
|
54
|
+
if (filter !== void 0 && (!object(filter) || !Array.isArray(filter.deny) || filter.deny.some((name3) => typeof name3 !== "string" || !name3) || filter.mode !== void 0 && filter.mode !== "extend" && filter.mode !== "replace")) throw new Error("Invalid role tool filter");
|
|
55
|
+
return {
|
|
56
|
+
name: name2,
|
|
57
|
+
role,
|
|
58
|
+
model,
|
|
59
|
+
reasoning,
|
|
60
|
+
spawn,
|
|
61
|
+
persona,
|
|
62
|
+
...filter !== void 0 ? { toolFilter: { mode: filter.mode ?? "replace", deny: [...new Set(filter.deny)] } } : {},
|
|
63
|
+
..."overrides" in value ? { overrides: structuredClone(value.overrides) } : {}
|
|
64
|
+
};
|
|
54
65
|
});
|
|
55
66
|
}
|
|
56
67
|
function executableRoles(roles) {
|
|
57
|
-
return roles.map(({ name: name2, role, model, reasoning, spawn, persona }) => ({ name: name2, role, model, reasoning, spawn, persona }));
|
|
68
|
+
return roles.map(({ name: name2, role, model, reasoning, spawn, persona, toolFilter }) => ({ name: name2, role, model, reasoning, spawn, persona, ...toolFilter ? { toolFilter } : {} }));
|
|
69
|
+
}
|
|
70
|
+
function roleToolFilter(role, presetDefault = []) {
|
|
71
|
+
const own = role?.toolFilter;
|
|
72
|
+
if (!own) return [...presetDefault];
|
|
73
|
+
return own.mode === "replace" ? [...own.deny] : [.../* @__PURE__ */ new Set([...presetDefault, ...own.deny])];
|
|
58
74
|
}
|
|
59
75
|
|
|
60
76
|
// src/package-name.ts
|
|
@@ -72,6 +88,9 @@ var inject = ["tools", "subagents", "llm"];
|
|
|
72
88
|
var PARENT_ROLE = { name: "Subagent", role: "subagent", model: "inherit", reasoning: "inherit", spawn: "fresh", persona: "" };
|
|
73
89
|
function apply(ctx, config) {
|
|
74
90
|
const roles = executableRoles(parseRoles(config.roles));
|
|
91
|
+
const deny = config.toolFilter?.deny;
|
|
92
|
+
if (deny !== void 0 && (!Array.isArray(deny) || deny.some((name2) => typeof name2 !== "string" || !name2))) throw new Error("Invalid subagent tool filter");
|
|
93
|
+
const presetDefault = deny ?? [];
|
|
75
94
|
ctx.tools.register(defineTool({
|
|
76
95
|
name: ROLE_TOOL,
|
|
77
96
|
description: roles.length ? "Discover saved specialist roles or delegate a task to one. Calls return a native child agent id; the child reports back through normal subagent delivery." : "Delegate a self-contained task to a subagent that starts with the same model and settings as you. Calls return a native child agent id; the child reports back through normal subagent delivery.",
|
|
@@ -102,6 +121,8 @@ function apply(ctx, config) {
|
|
|
102
121
|
}
|
|
103
122
|
if (role.reasoning !== "inherit") agentOptions.reasoningEffort = ReasoningEffortId2(role.reasoning);
|
|
104
123
|
const maxDepth = ctx.subagents.resolveMaxDepth();
|
|
124
|
+
const hidden = roleToolFilter(roles.length ? role : void 0, presetDefault);
|
|
125
|
+
const toolFilter = hidden.length ? { deny: hidden } : void 0;
|
|
105
126
|
const spec = {
|
|
106
127
|
provider: role.spawn === "fork" ? "fork" : "spawn",
|
|
107
128
|
label: role.name,
|
|
@@ -110,7 +131,8 @@ function apply(ctx, config) {
|
|
|
110
131
|
prompt: [{ type: "text", text: args.task }],
|
|
111
132
|
...Object.keys(agentOptions).length ? { agentOptions } : {},
|
|
112
133
|
...role.persona ? { persona: role.persona } : {},
|
|
113
|
-
...maxDepth === void 0 ? {} : { maxDepth }
|
|
134
|
+
...maxDepth === void 0 ? {} : { maxDepth },
|
|
135
|
+
...toolFilter ? { toolFilter } : {}
|
|
114
136
|
},
|
|
115
137
|
signal: exec.signal
|
|
116
138
|
};
|