dsh-tool-manager 1.2.10 → 1.2.12
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/CHANGELOG.md +29 -0
- package/DESIGN.md +62 -1
- package/README.md +8 -2
- package/dist/catalog.d.ts +2 -1
- package/dist/catalog.d.ts.map +1 -1
- package/dist/catalog.js +2 -1
- package/dist/catalog.js.map +1 -1
- package/dist/client.js +71 -3
- package/dist/composition-watch.d.ts +17 -2
- package/dist/composition-watch.d.ts.map +1 -1
- package/dist/composition-watch.js +40 -13
- package/dist/composition-watch.js.map +1 -1
- package/dist/dsh.d.ts +41 -2
- package/dist/dsh.d.ts.map +1 -1
- package/dist/dsh.js +30 -0
- package/dist/dsh.js.map +1 -1
- package/dist/index.d.ts +16 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +251 -40
- package/dist/index.js.map +1 -1
- package/dist/notices.d.ts +74 -0
- package/dist/notices.d.ts.map +1 -0
- package/dist/notices.js +99 -0
- package/dist/notices.js.map +1 -0
- package/dist/preset-repair.d.ts +128 -0
- package/dist/preset-repair.d.ts.map +1 -0
- package/dist/preset-repair.js +279 -0
- package/dist/preset-repair.js.map +1 -0
- package/dist/runtime.d.ts +133 -2
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +615 -20
- package/dist/runtime.js.map +1 -1
- package/dist/snapshot.d.ts.map +1 -1
- package/dist/snapshot.js +0 -1
- package/dist/snapshot.js.map +1 -1
- package/dist/types.d.ts +0 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/runtime.d.ts
CHANGED
|
@@ -1,20 +1,70 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AgentPresetsSource, ContextLike, ToolSchemaLike } from "./dsh.js";
|
|
2
|
+
import { type RepairAgentDiagnostics, type RepairDiagnostics } from "./preset-repair.js";
|
|
3
|
+
import type { UserNoticeInput } from "./notices.js";
|
|
2
4
|
import { type ToolManagerSettings } from "./types.js";
|
|
3
5
|
export declare class ToolPolicyRuntime {
|
|
4
6
|
private readonly ctx;
|
|
7
|
+
/** The live registry, or a resolver: DSH replaces the instance on reload. */
|
|
5
8
|
private readonly presets;
|
|
9
|
+
/** The reader's inbox: what the model cannot fix and the person must see. */
|
|
10
|
+
private readonly onUserNotice?;
|
|
11
|
+
/** Called when a repair succeeds, so its transient notice can be withdrawn. */
|
|
12
|
+
private readonly onBindingHealed?;
|
|
6
13
|
private settings;
|
|
7
14
|
private readonly states;
|
|
8
15
|
private readonly observedSchemas;
|
|
16
|
+
/** Re-attaches Sessions to a registry instance that replaced their own. */
|
|
17
|
+
private readonly repairs;
|
|
18
|
+
/** Sessions whose re-attach already failed once, so the log stays readable. */
|
|
19
|
+
private readonly healFailures;
|
|
9
20
|
private mutating;
|
|
10
21
|
private refreshQueued;
|
|
11
22
|
private discoveryDisposer?;
|
|
12
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Whether `system-prompt/assemble` still owns the tool declarations.
|
|
25
|
+
* DSH < 0.2.2 hands over a PromptAssembly (declarations included);
|
|
26
|
+
* DSH >= 0.2.2 hands over a PromptPresentation and re-attaches the
|
|
27
|
+
* provider's declarations after the waterfall. Undefined until the first
|
|
28
|
+
* assembly with something to hide is observed.
|
|
29
|
+
*/
|
|
30
|
+
private declarationFiltering;
|
|
31
|
+
/** Names `restrict()` refused because they are not global tools. */
|
|
32
|
+
private readonly unrestrictable;
|
|
33
|
+
private warnedUnrestrictable;
|
|
34
|
+
/**
|
|
35
|
+
* Whether this Host filters the per-step admitted set.
|
|
36
|
+
* DSH >= 0.2.2 derives declarations, PTC bindings, and execution lookup from
|
|
37
|
+
* `tools.resolve()`, which is the only seam that can hide a registration made
|
|
38
|
+
* in the Agent's own scope. `undefined` on older Hosts (no `resolve`).
|
|
39
|
+
*/
|
|
40
|
+
private stepFilter;
|
|
41
|
+
private restoreStepFilter?;
|
|
42
|
+
/** The registry instance the observed schemas belong to. */
|
|
43
|
+
private presetsInstance?;
|
|
44
|
+
constructor(ctx: ContextLike,
|
|
45
|
+
/** The live registry, or a resolver: DSH replaces the instance on reload. */
|
|
46
|
+
presets: AgentPresetsSource, initial: ToolManagerSettings,
|
|
47
|
+
/** The reader's inbox: what the model cannot fix and the person must see. */
|
|
48
|
+
onUserNotice?: ((notice: UserNoticeInput) => void) | undefined,
|
|
49
|
+
/** Called when a repair succeeds, so its transient notice can be withdrawn. */
|
|
50
|
+
onBindingHealed?: ((sessionId: string | undefined, presetId: string | undefined) => void) | undefined);
|
|
13
51
|
start(): void;
|
|
14
52
|
update(next: ToolManagerSettings): void;
|
|
15
53
|
private install;
|
|
16
54
|
private uninstall;
|
|
17
55
|
private presetId;
|
|
56
|
+
/** The preset a Session runs, per the Session log, when the live registry has no binding. */
|
|
57
|
+
private declaredPreset;
|
|
58
|
+
/** Whether the live registry lost this Agent's preset binding to a reload. */
|
|
59
|
+
private lostBinding;
|
|
60
|
+
/**
|
|
61
|
+
* Drop observations taken through a registry instance DSH has replaced.
|
|
62
|
+
*
|
|
63
|
+
* A preset id identifies a composition of ONE registry instance. After a
|
|
64
|
+
* reload the same id is a different composition, so schemas observed under
|
|
65
|
+
* the retired instance would describe tools no live preset owns.
|
|
66
|
+
*/
|
|
67
|
+
private retain;
|
|
18
68
|
private policy;
|
|
19
69
|
private hostTools;
|
|
20
70
|
private inheritedSchemas;
|
|
@@ -24,8 +74,60 @@ export declare class ToolPolicyRuntime {
|
|
|
24
74
|
private installLocalPolicy;
|
|
25
75
|
private queueBaselineRefresh;
|
|
26
76
|
private refreshAllBaselines;
|
|
77
|
+
/**
|
|
78
|
+
* Adopt names the live inherited surface gained since the snapshot.
|
|
79
|
+
*
|
|
80
|
+
* The baseline is a snapshot, and a snapshot can miss a registration that
|
|
81
|
+
* lands outside a `tools/change` edge: a plugin installed while the runtime
|
|
82
|
+
* was still starting, a standing Preset re-mounting, or a composition reload
|
|
83
|
+
* that re-registers tools without emitting a change. A stale baseline makes a
|
|
84
|
+
* saved on-demand group resolve to zero tools, so the group silently drops
|
|
85
|
+
* out of the catalog and its tools stay visible — the "the group only works
|
|
86
|
+
* after restarting DSH" report. One live `schemas(agent)` read per step is a
|
|
87
|
+
* map walk and keeps the policy, the catalog and the step on one tool set.
|
|
88
|
+
*
|
|
89
|
+
* The visible surface is read first: this Agent's own restriction only ever
|
|
90
|
+
* removes names, so a name it shows that the snapshot lacks is proof of a new
|
|
91
|
+
* registration. Only then is the restriction lifted for a full read — adopting
|
|
92
|
+
* the restricted view would drop every grouped tool from the snapshot and
|
|
93
|
+
* `reconcile()` would then un-hide them. A surface that merely shrank can be
|
|
94
|
+
* the transient gap of a composition swap, which the debounced `tools/change`
|
|
95
|
+
* refresh in `refreshAllBaselines()` settles.
|
|
96
|
+
* @param state - the Agent whose baseline may have drifted.
|
|
97
|
+
* @returns whether the baseline changed.
|
|
98
|
+
*/
|
|
99
|
+
private syncBaseline;
|
|
100
|
+
/** Refresh the baseline of the Agent a `tools.resolve()` call belongs to. */
|
|
101
|
+
private syncStepBaseline;
|
|
27
102
|
private openGroup;
|
|
28
103
|
private onPreStep;
|
|
104
|
+
/**
|
|
105
|
+
* Re-attach this Session to a registry instance that replaced its own.
|
|
106
|
+
*
|
|
107
|
+
* A registry reload disposes the standing composition the Agent's scope
|
|
108
|
+
* points at, so the Session silently drops to root-bundle tools. Re-linking
|
|
109
|
+
* the Agent's ancestry to the live instance's revision restores them before
|
|
110
|
+
* this step resolves its tool set, which is the only point where it can
|
|
111
|
+
* happen without rebuilding the Agent (and therefore without a restart).
|
|
112
|
+
* @param state - the Agent whose preset binding may have been retired.
|
|
113
|
+
*/
|
|
114
|
+
/** What the registry re-attach can see, for the diagnostic endpoint. */
|
|
115
|
+
repairDiagnostics(): RepairDiagnostics & {
|
|
116
|
+
agents: RepairAgentDiagnostics[];
|
|
117
|
+
};
|
|
118
|
+
/** One row per live Agent: what it resolves now, and what it should resolve. */
|
|
119
|
+
private diagnoseAgents;
|
|
120
|
+
private healBinding;
|
|
121
|
+
/**
|
|
122
|
+
* Tell the person that a Session lost its tools and cannot get them back.
|
|
123
|
+
*
|
|
124
|
+
* `healBinding` runs first and is the preferred outcome; this is the residual
|
|
125
|
+
* case (the handles died with the replaced instance, or the preset no longer
|
|
126
|
+
* exists). Then only a rebuilt Agent helps, and the reader is the one who has
|
|
127
|
+
* to act, so the notice goes to the banner — never into the transcript: a
|
|
128
|
+
* model-side reminder cannot restore a tool set and is easy to miss.
|
|
129
|
+
*/
|
|
130
|
+
private reportLostBinding;
|
|
29
131
|
/**
|
|
30
132
|
* Register `tool_list` on the host/global tools layer, not per agent.
|
|
31
133
|
*
|
|
@@ -38,8 +140,37 @@ export declare class ToolPolicyRuntime {
|
|
|
38
140
|
*/
|
|
39
141
|
private registerDiscovery;
|
|
40
142
|
private discoveryDefinition;
|
|
143
|
+
/**
|
|
144
|
+
* Hide the policy's names from every per-step tool set.
|
|
145
|
+
*
|
|
146
|
+
* DSH 0.2.2 builds each step's admitted set from `tools.resolve()`, then
|
|
147
|
+
* derives the model-facing declarations, the PTC bindings, and execution
|
|
148
|
+
* lookup from it. Unlike `restrict()`, that set is NOT exempting the Agent's
|
|
149
|
+
* own registrations, so this is the only seam able to hide a tool another
|
|
150
|
+
* plugin registered into `agent.ctx` — the exact behaviour the prompt
|
|
151
|
+
* waterfall provided before 0.2.2.
|
|
152
|
+
*
|
|
153
|
+
* The seam is a method on the shared `ToolsService` prototype, so one patch
|
|
154
|
+
* covers the host service and every Agent-scoped derivation of it. Every
|
|
155
|
+
* failure path returns the untouched set: a wrong guess here must degrade to
|
|
156
|
+
* "visible but still blocked by the guard", never to a broken step.
|
|
157
|
+
*/
|
|
158
|
+
private installStepFilter;
|
|
159
|
+
/** Remove this Agent's hidden names from one resolved step set. */
|
|
160
|
+
private filterStepToolSet;
|
|
41
161
|
private reconcile;
|
|
42
162
|
private applyDeny;
|
|
163
|
+
/**
|
|
164
|
+
* Remember names `restrict()` refused because they are not global tools.
|
|
165
|
+
*
|
|
166
|
+
* These are registrations owned by the Agent's own scope (delegation and
|
|
167
|
+
* scheduled-task tools are the common ones). DSH < 0.2.2 still hid them by
|
|
168
|
+
* filtering the prompt assembly; DSH >= 0.2.2 cannot, so the call guard is
|
|
169
|
+
* the only remaining enforcement and the model keeps seeing the name.
|
|
170
|
+
*/
|
|
171
|
+
private noteUnrestrictable;
|
|
172
|
+
/** Explain the remaining limitation once, and only when it actually bites. */
|
|
173
|
+
private warnUnrestrictable;
|
|
43
174
|
private warn;
|
|
44
175
|
dispose(): Promise<void>;
|
|
45
176
|
}
|
package/dist/runtime.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,kBAAkB,EAClB,WAAW,EAEX,cAAc,EACf,MAAM,UAAU,CAAC;AASlB,OAAO,EAAuB,KAAK,sBAAsB,EAAE,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC9G,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAUpD,OAAO,EAML,KAAK,mBAAmB,EACzB,MAAM,YAAY,CAAC;AAwBpB,qBAAa,iBAAiB;IAkC1B,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,6EAA6E;IAC7E,OAAO,CAAC,QAAQ,CAAC,OAAO;IAExB,6EAA6E;IAC7E,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC;IAC9B,+EAA+E;IAC/E,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC;IAxCnC,OAAO,CAAC,QAAQ,CAAsB;IACtC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoC;IAC3D,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAkD;IAClF,2EAA2E;IAC3E,OAAO,CAAC,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