dsh-tool-manager 1.1.1

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.
Files changed (47) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/DESIGN.md +228 -0
  3. package/LICENSE +21 -0
  4. package/README.md +201 -0
  5. package/cordis.patch.yml +4 -0
  6. package/dist/catalog.d.ts +44 -0
  7. package/dist/catalog.d.ts.map +1 -0
  8. package/dist/catalog.js +166 -0
  9. package/dist/catalog.js.map +1 -0
  10. package/dist/client.js +581 -0
  11. package/dist/config.d.ts +16 -0
  12. package/dist/config.d.ts.map +1 -0
  13. package/dist/config.js +107 -0
  14. package/dist/config.js.map +1 -0
  15. package/dist/dsh.d.ts +108 -0
  16. package/dist/dsh.d.ts.map +1 -0
  17. package/dist/dsh.js +7 -0
  18. package/dist/dsh.js.map +1 -0
  19. package/dist/index.d.ts +5 -0
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/index.js +140 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/policy.d.ts +23 -0
  24. package/dist/policy.d.ts.map +1 -0
  25. package/dist/policy.js +167 -0
  26. package/dist/policy.js.map +1 -0
  27. package/dist/runtime.d.ts +29 -0
  28. package/dist/runtime.d.ts.map +1 -0
  29. package/dist/runtime.js +276 -0
  30. package/dist/runtime.js.map +1 -0
  31. package/dist/snapshot.d.ts +4 -0
  32. package/dist/snapshot.d.ts.map +1 -0
  33. package/dist/snapshot.js +48 -0
  34. package/dist/snapshot.js.map +1 -0
  35. package/dist/stats.d.ts +10 -0
  36. package/dist/stats.d.ts.map +1 -0
  37. package/dist/stats.js +29 -0
  38. package/dist/stats.js.map +1 -0
  39. package/dist/suggest.d.ts +34 -0
  40. package/dist/suggest.d.ts.map +1 -0
  41. package/dist/suggest.js +290 -0
  42. package/dist/suggest.js.map +1 -0
  43. package/dist/types.d.ts +63 -0
  44. package/dist/types.d.ts.map +1 -0
  45. package/dist/types.js +3 -0
  46. package/dist/types.js.map +1 -0
  47. package/package.json +67 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,gBAAgB,EAChB,WAAW,EAEZ,MAAM,UAAU,CAAC;AAclB,OAAO,EAKL,KAAK,mBAAmB,EACzB,MAAM,YAAY,CAAC;AAWpB,qBAAa,iBAAiB;IAO1B,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAP1B,OAAO,CAAC,QAAQ,CAAsB;IACtC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoC;IAC3D,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,aAAa,CAAS;gBAGX,GAAG,EAAE,WAAW,EAChB,OAAO,EAAE,gBAAgB,EAC1C,OAAO,EAAE,mBAAmB;IAK9B,KAAK,IAAI,IAAI;IAgBb,MAAM,CAAC,IAAI,EAAE,mBAAmB,GAAG,IAAI;IAYvC,OAAO,CAAC,OAAO;IAcf,OAAO,CAAC,SAAS;IAajB,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,MAAM;IAId,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,oBAAoB;IAS5B,OAAO,CAAC,mBAAmB;IAe3B,OAAO,CAAC,SAAS;YAqBH,SAAS;IAkBvB,OAAO,CAAC,aAAa;IAkDrB,OAAO,CAAC,aAAa;IAMrB,OAAO,CAAC,SAAS;IAiBjB,OAAO,CAAC,SAAS;IAsBjB,OAAO,CAAC,IAAI;IAKN,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAG/B"}
@@ -0,0 +1,276 @@
1
+ import { applyCatalogDecision, catalogEntriesFromGroups, catalogHistory, } from "./catalog.js";
2
+ import { denyNames, findGroup, parseKnownRestrictable, policyFor, resolveGroups, sameNames, } from "./policy.js";
3
+ import { DISCOVERY_TOOL_NAME, PTC_TRANSPORT_NAME, } from "./types.js";
4
+ export class ToolPolicyRuntime {
5
+ ctx;
6
+ presets;
7
+ settings;
8
+ states = new Map();
9
+ mutating = false;
10
+ refreshQueued = false;
11
+ constructor(ctx, presets, initial) {
12
+ this.ctx = ctx;
13
+ this.presets = presets;
14
+ this.settings = initial;
15
+ }
16
+ start() {
17
+ const agents = this.ctx.get("agents");
18
+ for (const agent of agents?.list() ?? [])
19
+ this.install(agent);
20
+ this.ctx.on("agent/created", (...args) => {
21
+ const payload = asCreated(args[0]);
22
+ if (payload)
23
+ this.install(payload.agent);
24
+ });
25
+ this.ctx.on("agent/disposed", (...args) => {
26
+ const payload = asCreated(args[0]);
27
+ if (payload)
28
+ this.uninstall(payload.agent);
29
+ });
30
+ this.ctx.on("tools/change", () => this.queueBaselineRefresh());
31
+ this.ctx.on("agent/pre-step", (...args) => this.onPreStep(args[0], args[1]));
32
+ }
33
+ update(next) {
34
+ this.settings = next;
35
+ for (const state of this.states.values()) {
36
+ const known = new Set(this.policy(state.agent).groups.map((group) => group.name.toLowerCase()));
37
+ for (const name of [...state.exposures]) {
38
+ if (!known.has(name.toLowerCase()))
39
+ state.exposures.delete(name);
40
+ }
41
+ this.syncDiscovery(state);
42
+ this.reconcile(state);
43
+ }
44
+ }
45
+ install(agent) {
46
+ if (this.states.has(agent))
47
+ return;
48
+ if (!agent.ctx.get("tools"))
49
+ return;
50
+ const state = {
51
+ agent,
52
+ baseline: this.inheritedNames(agent),
53
+ exposures: new Set(),
54
+ };
55
+ this.states.set(agent, state);
56
+ this.syncDiscovery(state);
57
+ this.reconcile(state);
58
+ }
59
+ uninstall(agent) {
60
+ const state = this.states.get(agent);
61
+ if (!state)
62
+ return;
63
+ this.states.delete(agent);
64
+ this.mutating = true;
65
+ try {
66
+ this.dropDiscovery(state);
67
+ state.restriction?.();
68
+ }
69
+ finally {
70
+ this.mutating = false;
71
+ }
72
+ }
73
+ presetId(agent) {
74
+ return this.presets.composedPreset(agent.ctx);
75
+ }
76
+ policy(agent) {
77
+ return policyFor(this.settings, this.presetId(agent));
78
+ }
79
+ inheritedNames(agent) {
80
+ const scopedTools = agent.ctx.get("tools");
81
+ if (!scopedTools)
82
+ return [];
83
+ return scopedTools
84
+ .schemas(agent)
85
+ .map((schema) => schema.name)
86
+ .filter((name) => name !== DISCOVERY_TOOL_NAME && name !== PTC_TRANSPORT_NAME);
87
+ }
88
+ queueBaselineRefresh() {
89
+ if (this.mutating || this.refreshQueued)
90
+ return;
91
+ this.refreshQueued = true;
92
+ queueMicrotask(() => {
93
+ this.refreshQueued = false;
94
+ this.refreshAllBaselines();
95
+ });
96
+ }
97
+ refreshAllBaselines() {
98
+ this.mutating = true;
99
+ try {
100
+ for (const state of this.states.values()) {
101
+ state.restriction?.();
102
+ state.restriction = undefined;
103
+ const next = this.inheritedNames(state.agent);
104
+ if (!sameNames(state.baseline, next))
105
+ state.baseline = next;
106
+ }
107
+ }
108
+ finally {
109
+ this.mutating = false;
110
+ }
111
+ for (const state of this.states.values())
112
+ this.reconcile(state);
113
+ }
114
+ openGroup(agent, requestedGroup) {
115
+ const state = this.states.get(agent);
116
+ if (!state)
117
+ throw new Error("tool manager is not attached to this Agent");
118
+ const groups = resolveGroups(this.policy(agent), state.baseline);
119
+ const known = groups.map((item) => item.name).join(", ") || "(none)";
120
+ if (requestedGroup === undefined || requestedGroup.trim() === "") {
121
+ throw new Error(`group is required; known groups: ${known}`);
122
+ }
123
+ const group = findGroup(groups, requestedGroup);
124
+ if (!group) {
125
+ throw new Error(`unknown tool group ${JSON.stringify(requestedGroup)}; known groups: ${known}`);
126
+ }
127
+ state.exposures.add(group.name);
128
+ this.reconcile(state);
129
+ return {
130
+ name: group.name,
131
+ ...(group.description ? { description: group.description } : {}),
132
+ tools: group.tools,
133
+ };
134
+ }
135
+ async onPreStep(payload, next) {
136
+ const decision = typeof next === "function"
137
+ ? await next()
138
+ : payload;
139
+ if (!isEnterDecision(decision))
140
+ return decision;
141
+ const agent = asCreated(payload)?.agent;
142
+ if (!agent)
143
+ return decision;
144
+ if (!this.states.has(agent))
145
+ this.install(agent);
146
+ const state = this.states.get(agent);
147
+ if (!state)
148
+ return decision;
149
+ const groups = resolveGroups(this.policy(agent), state.baseline);
150
+ return applyCatalogDecision(decision, catalogEntriesFromGroups(groups), catalogHistory(agent));
151
+ }
152
+ syncDiscovery(state) {
153
+ const policy = this.policy(state.agent);
154
+ const wantsDiscovery = policy.groups.length > 0;
155
+ const signature = discoverySignature(policy);
156
+ this.mutating = true;
157
+ try {
158
+ if (wantsDiscovery && state.toolListDisposer && state.discoverySignature !== signature) {
159
+ state.toolListDisposer();
160
+ state.toolListDisposer = undefined;
161
+ }
162
+ if (wantsDiscovery && !state.toolListDisposer) {
163
+ const scopedTools = state.agent.ctx.get("tools");
164
+ if (scopedTools) {
165
+ const known = policy.groups.map((group) => group.name).join(", ") || "(none)";
166
+ state.toolListDisposer = scopedTools.register({
167
+ name: DISCOVERY_TOOL_NAME,
168
+ description: `Open one on-demand tool group by name. All tools in that group become available for the rest of this session. Known groups: ${known}.`,
169
+ parameters: {
170
+ type: "object",
171
+ properties: {
172
+ group: {
173
+ type: "string",
174
+ description: `Group name to open. Known groups: ${known}.`,
175
+ },
176
+ },
177
+ required: ["group"],
178
+ },
179
+ output: {
180
+ schema: { type: "object", additionalProperties: true },
181
+ render: (_args, value) => [
182
+ { type: "text", text: JSON.stringify(value, null, 2) },
183
+ ],
184
+ },
185
+ execute: async (args) => this.openGroup(state.agent, args.group),
186
+ });
187
+ state.discoverySignature = signature;
188
+ }
189
+ }
190
+ if (!wantsDiscovery && state.toolListDisposer) {
191
+ state.toolListDisposer();
192
+ state.toolListDisposer = undefined;
193
+ state.discoverySignature = undefined;
194
+ state.exposures.clear();
195
+ }
196
+ }
197
+ finally {
198
+ this.mutating = false;
199
+ }
200
+ }
201
+ dropDiscovery(state) {
202
+ state.toolListDisposer?.();
203
+ state.toolListDisposer = undefined;
204
+ state.discoverySignature = undefined;
205
+ }
206
+ reconcile(state) {
207
+ const deny = denyNames(this.policy(state.agent), state.baseline, state.exposures);
208
+ this.mutating = true;
209
+ try {
210
+ state.restriction?.();
211
+ state.restriction = undefined;
212
+ if (deny.length === 0)
213
+ return;
214
+ state.restriction = this.applyDeny(state.agent, deny);
215
+ }
216
+ finally {
217
+ this.mutating = false;
218
+ }
219
+ }
220
+ applyDeny(agent, deny) {
221
+ const scopedTools = agent.ctx.get("tools");
222
+ if (!scopedTools)
223
+ return undefined;
224
+ try {
225
+ return scopedTools.restrict({ deny });
226
+ }
227
+ catch (error) {
228
+ const known = parseKnownRestrictable(error);
229
+ if (!known) {
230
+ this.warn(`tool-manager restrict failed: ${errorMessage(error)}`);
231
+ return undefined;
232
+ }
233
+ const next = deny.filter((name) => known.has(name));
234
+ if (next.length === 0)
235
+ return undefined;
236
+ try {
237
+ return scopedTools.restrict({ deny: next });
238
+ }
239
+ catch (retryError) {
240
+ this.warn(`tool-manager restrict retry failed: ${errorMessage(retryError)}`);
241
+ return undefined;
242
+ }
243
+ }
244
+ }
245
+ warn(message) {
246
+ const logger = this.ctx.get("logger");
247
+ logger?.warn?.(message);
248
+ }
249
+ async dispose() {
250
+ for (const agent of [...this.states.keys()])
251
+ this.uninstall(agent);
252
+ }
253
+ }
254
+ function asCreated(value) {
255
+ if (value === null || typeof value !== "object")
256
+ return undefined;
257
+ const agent = value.agent;
258
+ if (!agent || typeof agent !== "object" || !("ctx" in agent))
259
+ return undefined;
260
+ return { agent };
261
+ }
262
+ function isEnterDecision(value) {
263
+ if (value === null || typeof value !== "object")
264
+ return false;
265
+ const record = value;
266
+ return record.kind === "enter" && Array.isArray(record.messages);
267
+ }
268
+ function discoverySignature(policy) {
269
+ return policy.groups
270
+ .map((group) => `${group.name}\0${group.description ?? ""}`)
271
+ .join("\n");
272
+ }
273
+ function errorMessage(error) {
274
+ return error instanceof Error ? error.message : String(error);
275
+ }
276
+ //# sourceMappingURL=runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.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D,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,CAAC,KAAK,IAAI,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAC/E,OAAO,EAAE,KAAK,EAAE,CAAC;AACnB,CAAC;AAED,SAAS,eAAe,CAAC,KAAc;IACrC,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC9D,MAAM,MAAM,GAAG,KAA+C,CAAC;IAC/D,OAAO,MAAM,CAAC,IAAI,KAAK,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AACnE,CAAC;AAED,SAAS,kBAAkB,CAAC,MAAwB;IAClD,OAAO,MAAM,CAAC,MAAM;SACjB,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,WAAW,IAAI,EAAE,EAAE,CAAC;SAC3D,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC;AAED,SAAS,YAAY,CAAC,KAAc;IAClC,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChE,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { AgentPresetsLike, ToolRuntimeLike } from "./dsh.js";
2
+ import { type ToolManagerSettings, type ToolManagerSnapshot } from "./types.js";
3
+ export declare function buildSnapshot(presets: AgentPresetsLike, tools: ToolRuntimeLike, settings: ToolManagerSettings, revision: number, configPath: string): Promise<ToolManagerSnapshot>;
4
+ //# sourceMappingURL=snapshot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../src/snapshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAElE,OAAO,EAIL,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EAEzB,MAAM,YAAY,CAAC;AAEpB,wBAAsB,aAAa,CACjC,OAAO,EAAE,gBAAgB,EACzB,KAAK,EAAE,eAAe,EACtB,QAAQ,EAAE,mBAAmB,EAC7B,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,mBAAmB,CAAC,CAsC9B"}
@@ -0,0 +1,48 @@
1
+ import { policyFor, policyOrphans, resolveGroups } from "./policy.js";
2
+ import { DISCOVERY_TOOL_NAME, PTC_TRANSPORT_NAME, } from "./types.js";
3
+ export async function buildSnapshot(presets, tools, settings, revision, configPath) {
4
+ const compositions = await presets.compositionInventory();
5
+ const views = [];
6
+ for (const composition of compositions) {
7
+ let schemas = [];
8
+ let broken = composition.broken;
9
+ if (!broken) {
10
+ try {
11
+ const key = await presets.standingKeyFor(composition.id);
12
+ schemas = tools.schemas(key)
13
+ .filter((schema) => schema.name !== DISCOVERY_TOOL_NAME && schema.name !== PTC_TRANSPORT_NAME)
14
+ .map(projectSchema);
15
+ }
16
+ catch (error) {
17
+ broken = error instanceof Error ? error.message : String(error);
18
+ }
19
+ }
20
+ const policy = policyFor(settings, composition.id);
21
+ const names = schemas.map((item) => item.name);
22
+ views.push({
23
+ id: composition.id,
24
+ ...(composition.name ? { name: composition.name } : {}),
25
+ trust: composition.trust,
26
+ isDefault: composition.isDefault,
27
+ ...(broken ? { broken } : {}),
28
+ tools: schemas,
29
+ policy,
30
+ groups: resolveGroups(policy, names),
31
+ orphans: policyOrphans(policy, names),
32
+ });
33
+ }
34
+ return {
35
+ writable: true,
36
+ revision,
37
+ configPath,
38
+ presets: views,
39
+ };
40
+ }
41
+ function projectSchema(schema) {
42
+ return {
43
+ name: schema.name,
44
+ description: schema.description,
45
+ parameters: schema.parameters,
46
+ };
47
+ }
48
+ //# sourceMappingURL=snapshot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapshot.js","sour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AI,CAAC,CAAC;QAC/C,KAAK,CAAC,IAAI,CAAC;YACT,EAAE,EAAE,WAAW,CAAC,EAAE;YAClB,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACvD,KAAK,EAAE,WAAW,CAAC,KAAK;YACxB,SAAS,EAAE,WAAW,CAAC,SAAS;YAChC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC7B,KAAK,EAAE,OAAO;YACd,MAAM;YACN,MAAM,EAAE,aAAa,CAAC,MAAM,EAAE,KAAK,CAAC;YACpC,OAAO,EAAE,aAAa,CAAC,MAAM,EAAE,KAAK,CAAC;SACtC,CAAC,CAAC;IACL,CAAC;IAED,OAAO;QACL,QAAQ,EAAE,IAAI;QACd,QAAQ;QACR,UAAU;QACV,OAAO,EAAE,KAAK;KACf,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,MAItB;IACC,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,UAAU,EAAE,MAAM,CAAC,UAAU;KAC9B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { PresetToolPolicy, ToolSchemaView } from "./types.js";
2
+ export interface ToolCatalogStats {
3
+ totalTools: number;
4
+ groupCount: number;
5
+ ungroupedTools: number;
6
+ onDemandTools: number;
7
+ disabledTools: number;
8
+ }
9
+ export declare function toolCatalogStats(tools: readonly Pick<ToolSchemaView, "name">[], policy: PresetToolPolicy): ToolCatalogStats;
10
+ //# sourceMappingURL=stats.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stats.d.ts","sourceRoot":"","sources":["../src/stats.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEnE,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,SAAS,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,EAAE,EAC9C,MAAM,EAAE,gBAAgB,GACvB,gBAAgB,CAyBlB"}
package/dist/stats.js ADDED
@@ -0,0 +1,29 @@
1
+ import { matchesPattern } from "./policy.js";
2
+ export function toolCatalogStats(tools, policy) {
3
+ const disabled = new Set(policy.disabled);
4
+ const grouped = new Set();
5
+ for (const tool of tools) {
6
+ if (policy.groups.some((group) => group.patterns.some((pattern) => matchesPattern(tool.name, pattern)))) {
7
+ grouped.add(tool.name);
8
+ }
9
+ }
10
+ let ungroupedTools = 0;
11
+ let onDemandTools = 0;
12
+ let disabledTools = 0;
13
+ for (const tool of tools) {
14
+ if (disabled.has(tool.name))
15
+ disabledTools += 1;
16
+ else if (grouped.has(tool.name))
17
+ onDemandTools += 1;
18
+ else
19
+ ungroupedTools += 1;
20
+ }
21
+ return {
22
+ totalTools: tools.length,
23
+ groupCount: policy.groups.length,
24
+ ungroupedTools,
25
+ onDemandTools,
26
+ disabledTools,
27
+ };
28
+ }
29
+ //# sourceMappingURL=stats.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stats.js","sourceRoot":"","sources":["../src/stats.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAW7C,MAAM,UAAU,gBAAgB,CAC9B,KAA8C,EAC9C,MAAwB;IAExB,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC1C,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAClC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;YACxG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzB,CAAC;IACH,CAAC;IAED,IAAI,cAAc,GAAG,CAAC,CAAC;IACvB,IAAI,aAAa,GAAG,CAAC,CAAC;IACtB,IAAI,aAAa,GAAG,CAAC,CAAC;IACtB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;YAAE,aAAa,IAAI,CAAC,CAAC;aAC3C,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;YAAE,aAAa,IAAI,CAAC,CAAC;;YAC/C,cAAc,IAAI,CAAC,CAAC;IAC3B,CAAC;IAED,OAAO;QACL,UAAU,EAAE,KAAK,CAAC,MAAM;QACxB,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM;QAChC,cAAc;QACd,aAAa;QACb,aAAa;KACd,CAAC;AACJ,CAAC"}
@@ -0,0 +1,34 @@
1
+ import type { AgentDefaultModelLike, LlmRuntimeLike, ToolSchemaLike } from "./dsh.js";
2
+ export declare const MAX_SUGGESTION_TOOLS = 64;
3
+ export declare const MAX_AUTO_GROUP_TOOLS = 120;
4
+ export declare const MAX_AUTO_GROUPS = 32;
5
+ export declare const MAX_GROUP_NAME_LENGTH = 40;
6
+ export declare const MAX_GROUP_DESCRIPTION_LENGTH = 240;
7
+ export interface GroupSuggestion {
8
+ name: string;
9
+ description: string;
10
+ }
11
+ export interface GroupSuggestionRequest {
12
+ tools: ToolSchemaLike[];
13
+ otherGroupNames: string[];
14
+ }
15
+ export interface AutoGroupSuggestion extends GroupSuggestion {
16
+ tools: string[];
17
+ }
18
+ export interface AutoGroupResult {
19
+ groups: AutoGroupSuggestion[];
20
+ ungrouped: string[];
21
+ }
22
+ export interface AutoGroupRequest {
23
+ tools: ToolSchemaLike[];
24
+ otherGroupNames: string[];
25
+ }
26
+ export declare function generateGroupSuggestion(llm: LlmRuntimeLike, defaultModel: AgentDefaultModelLike, request: GroupSuggestionRequest): Promise<GroupSuggestion>;
27
+ export declare function selectSuggestionTools(schemas: ToolSchemaLike[], requestedNames: unknown, limit?: number): ToolSchemaLike[];
28
+ export declare function normalizeGroupNames(value: unknown): string[];
29
+ export declare function generateAutoGroups(llm: LlmRuntimeLike, defaultModel: AgentDefaultModelLike, request: AutoGroupRequest): Promise<AutoGroupResult>;
30
+ export declare function buildSuggestionPrompt(request: GroupSuggestionRequest): string;
31
+ export declare function buildAutoGroupPrompt(request: AutoGroupRequest): string;
32
+ export declare function parseAutoGroupResult(output: string, candidateNames: string[], otherGroupNames: string[]): AutoGroupResult;
33
+ export declare function parseGroupSuggestion(output: string): GroupSuggestion;
34
+ //# sourceMappingURL=suggest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"suggest.d.ts","sourceRoot":"","sources":["../src/suggest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,cAAc,EAGd,cAAc,EACf,MAAM,UAAU,CAAC;AAElB,eAAO,MAAM,oBAAoB,KAAK,CAAC;AACvC,eAAO,MAAM,oBAAoB,MAAM,CAAC;AACxC,eAAO,MAAM,eAAe,KAAK,CAAC;AAClC,eAAO,MAAM,qBAAqB,KAAK,CAAC;AACxC,eAAO,MAAM,4BAA4B,MAAM,CAAC;AAMhD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,sBAAsB;IACrC,KAAK,E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