@lyteboat/tool-policy 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +4 -2
- package/lib/index.d.ts +120 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +279 -0
- package/lib/index.js.map +1 -0
- package/lib/state.d.ts +35 -0
- package/lib/state.d.ts.map +1 -0
- package/lib/state.js +107 -0
- package/lib/state.js.map +1 -0
- package/package.json +45 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 lyteboat
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @lyteboat/tool-policy
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
lyteboat's tool policy over the dsh tool registry: visibility (always/auto + activation, and whether an agent's undeclared inherited tools stay visible) and tool-result state deltas folded into the lyteboatState projection.
|
|
4
|
+
|
|
5
|
+
Part of [lyteboat](https://github.com/lyteboat/lyteboat), an agent harness for business agents built on DeepSeek Harness. Its source is [`lyteboat/plugins/tool-policy`](https://github.com/lyteboat/lyteboat/tree/master/lyteboat/plugins/tool-policy); the repository README explains how the packages fit together and how a project outside the repository installs them.
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @lyteboat/tool-policy — lyteboat's tool policy over the dsh tool registry. One host
|
|
3
|
+
* service, `ctx.toolPolicy`, holds lyteboat-side metadata for tools registered in
|
|
4
|
+
* the global layer or a preset's standing layer, and enforces it at two dsh
|
|
5
|
+
* seams:
|
|
6
|
+
*
|
|
7
|
+
* - visibility: an `auto` tool stays out of the model's schemas until a
|
|
8
|
+
* plugin activates it for the agent (`activate`); a scope can hide every
|
|
9
|
+
* inherited tool its policy does not declare (`declareInherited('hidden')`),
|
|
10
|
+
* and such a tool stays hidden: only declared tools are activated. The
|
|
11
|
+
* agent's restriction is recomputed after every `lyteboat/pre-assemble` and
|
|
12
|
+
* reissued only when the denied set changed;
|
|
13
|
+
* - state: a tool registered with `stateDelta` carries its delta on the
|
|
14
|
+
* result's presentation meta (`meta.lyteboat.stateDelta`), and a delta the
|
|
15
|
+
* state cannot hold fails the call instead; the `lyteboatState` projection
|
|
16
|
+
* folds it straight from the `tool/result` node (successful, top-level calls
|
|
17
|
+
* only) and renders it to the model as the `lyteboat:state` runtime context.
|
|
18
|
+
* No lyteboat node is written: dsh's persistence refuses logs with event
|
|
19
|
+
* types it does not know.
|
|
20
|
+
*
|
|
21
|
+
* Only inherited tools can be hidden — dsh's `restrict` never filters an
|
|
22
|
+
* agent's own layer — so register and declare through the host or a preset
|
|
23
|
+
* row, never through `agent.ctx`.
|
|
24
|
+
* @module @lyteboat/tool-policy
|
|
25
|
+
*/
|
|
26
|
+
import { Context, Service } from '@deepseek-ai/cordis';
|
|
27
|
+
import type { Agent } from '@deepseek-ai/dsh-agent';
|
|
28
|
+
import type { ScopeKey } from '@deepseek-ai/dsh-scope';
|
|
29
|
+
import type { ToolDefinition } from '@deepseek-ai/dsh-tools';
|
|
30
|
+
import type { LyteboatInheritedToolVisibility, LyteboatToolMeta } from '@lyteboat/contracts';
|
|
31
|
+
declare module '@deepseek-ai/cordis' {
|
|
32
|
+
interface Context {
|
|
33
|
+
toolPolicy: ToolPolicyService;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/** Metadata a composition file can declare for a tool registered elsewhere: everything but the code-only delta. */
|
|
37
|
+
export type LyteboatToolPolicy = Omit<LyteboatToolMeta, 'stateDelta'>;
|
|
38
|
+
/** Host service: lyteboat tool metadata plus its enforcement at the dsh tool seams. */
|
|
39
|
+
export declare class ToolPolicyService extends Service {
|
|
40
|
+
static inject: string[];
|
|
41
|
+
private readonly layers;
|
|
42
|
+
private readonly agents;
|
|
43
|
+
constructor(ctx: Context);
|
|
44
|
+
/**
|
|
45
|
+
* Register a tool in the calling scope's layer together with its lyteboat
|
|
46
|
+
* metadata. A `stateDelta` is folded into the tool's presentation meta.
|
|
47
|
+
* @param definition - the dsh tool definition.
|
|
48
|
+
* @param meta - lyteboat-side metadata; `visibility` defaults to `always`.
|
|
49
|
+
* @returns the exact disposer that unregisters both.
|
|
50
|
+
*/
|
|
51
|
+
register(definition: ToolDefinition, meta?: LyteboatToolMeta): () => void;
|
|
52
|
+
/**
|
|
53
|
+
* Declare metadata for a tool registered elsewhere (an official dsh tool, a
|
|
54
|
+
* agent row's tool), in the calling scope's layer. Nearest scope wins.
|
|
55
|
+
* @param name - the tool name as registered.
|
|
56
|
+
* @param meta - lyteboat-side metadata.
|
|
57
|
+
* @returns the exact disposer that withdraws the declaration.
|
|
58
|
+
*/
|
|
59
|
+
declare(name: string, meta: LyteboatToolMeta): () => void;
|
|
60
|
+
/**
|
|
61
|
+
* Declare, in the calling scope's layer, whether the tools its agents
|
|
62
|
+
* inherit and no declaration on their chain names reach the model. Nearest
|
|
63
|
+
* scope wins; without one they are `visible`. A hidden inherited tool stays
|
|
64
|
+
* hidden: `activate` names declared tools only.
|
|
65
|
+
* @param visibility - `visible` or `hidden`.
|
|
66
|
+
* @returns the exact disposer that withdraws the declaration.
|
|
67
|
+
* @throws when the scope already declared it.
|
|
68
|
+
*/
|
|
69
|
+
declareInherited(visibility: LyteboatInheritedToolVisibility): () => void;
|
|
70
|
+
/**
|
|
71
|
+
* The metadata a scope resolves for a tool: its own chain, nearest scope last.
|
|
72
|
+
* An agent is its own scope key (the agent loop keys each agent's scope by
|
|
73
|
+
* the agent), so an agent and a preset's standing scope resolve alike.
|
|
74
|
+
* @param name - the tool name.
|
|
75
|
+
* @param scope - the viewing agent or scope; omitted for the global view.
|
|
76
|
+
*/
|
|
77
|
+
metaOf(name: string, scope?: ScopeKey): LyteboatToolMeta | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* Make `auto` tools visible to one agent from its next assembly on (or this
|
|
80
|
+
* step's, when called inside `lyteboat/pre-assemble`). Names must be declared.
|
|
81
|
+
* @param agent - the agent whose visibility changes.
|
|
82
|
+
* @param names - declared tool names.
|
|
83
|
+
*/
|
|
84
|
+
activate(agent: Agent, names: readonly string[]): void;
|
|
85
|
+
/**
|
|
86
|
+
* Withdraw every activation of one agent; its `auto` tools hide again.
|
|
87
|
+
* @param agent - the agent to reset.
|
|
88
|
+
*/
|
|
89
|
+
clear(agent: Agent): void;
|
|
90
|
+
/** The names one agent activated, sorted. */
|
|
91
|
+
activated(agent: Agent): string[];
|
|
92
|
+
/**
|
|
93
|
+
* The tool names an agent started under a scope (a preset's standing scope)
|
|
94
|
+
* sees before anything is activated, in registry order: its `auto` tools and,
|
|
95
|
+
* with inherited tools hidden, every undeclared inherited tool, are left out.
|
|
96
|
+
* A running agent's current view is `ctx.tools.schemas(agent)`.
|
|
97
|
+
* @param scope - the standing scope a new agent inherits from.
|
|
98
|
+
*/
|
|
99
|
+
visible(scope: ScopeKey): string[];
|
|
100
|
+
private stateOf;
|
|
101
|
+
/** Whether one scope's undeclared inherited tools reach the model: the nearest declaration on its chain, `visible` without one. */
|
|
102
|
+
private inheritedOf;
|
|
103
|
+
/**
|
|
104
|
+
* The names an agent of `scope`, inheriting `inheritedView`, is denied: every
|
|
105
|
+
* declared `auto` tool not activated and, with inherited tools `hidden`, every
|
|
106
|
+
* inherited tool no declaration names. Sorted.
|
|
107
|
+
*/
|
|
108
|
+
private deniedFor;
|
|
109
|
+
/**
|
|
110
|
+
* Recompute one agent's restriction: every `auto` tool it inherits and has
|
|
111
|
+
* not activated is denied, and with inherited tools `hidden` every inherited
|
|
112
|
+
* tool no declaration names. Reissued only when the set changed.
|
|
113
|
+
* @throws when a declared name reaches the agent registered by no row, or
|
|
114
|
+
* an `auto` tool sits in the agent's own layer, where `restrict` cannot hide
|
|
115
|
+
* it: both are composition mistakes and never silently pass.
|
|
116
|
+
*/
|
|
117
|
+
private reconcile;
|
|
118
|
+
}
|
|
119
|
+
export default ToolPolicyService;
|
|
120
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAEnD,OAAO,KAAK,EAAE,QAAQ,EAAc,MAAM,wBAAwB,CAAA;AAElE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAI5D,O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G;IACH,OAAO,CAAC,SAAS;IAejB;;;;;;;OAOG;IACH,OAAO,CAAC,SAAS;CA2BlB;AAED,eAAe,iBAAiB,CAAA"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @lyteboat/tool-policy — lyteboat's tool policy over the dsh tool registry. One host
|
|
3
|
+
* service, `ctx.toolPolicy`, holds lyteboat-side metadata for tools registered in
|
|
4
|
+
* the global layer or a preset's standing layer, and enforces it at two dsh
|
|
5
|
+
* seams:
|
|
6
|
+
*
|
|
7
|
+
* - visibility: an `auto` tool stays out of the model's schemas until a
|
|
8
|
+
* plugin activates it for the agent (`activate`); a scope can hide every
|
|
9
|
+
* inherited tool its policy does not declare (`declareInherited('hidden')`),
|
|
10
|
+
* and such a tool stays hidden: only declared tools are activated. The
|
|
11
|
+
* agent's restriction is recomputed after every `lyteboat/pre-assemble` and
|
|
12
|
+
* reissued only when the denied set changed;
|
|
13
|
+
* - state: a tool registered with `stateDelta` carries its delta on the
|
|
14
|
+
* result's presentation meta (`meta.lyteboat.stateDelta`), and a delta the
|
|
15
|
+
* state cannot hold fails the call instead; the `lyteboatState` projection
|
|
16
|
+
* folds it straight from the `tool/result` node (successful, top-level calls
|
|
17
|
+
* only) and renders it to the model as the `lyteboat:state` runtime context.
|
|
18
|
+
* No lyteboat node is written: dsh's persistence refuses logs with event
|
|
19
|
+
* types it does not know.
|
|
20
|
+
*
|
|
21
|
+
* Only inherited tools can be hidden — dsh's `restrict` never filters an
|
|
22
|
+
* agent's own layer — so register and declare through the host or a preset
|
|
23
|
+
* row, never through `agent.ctx`.
|
|
24
|
+
* @module @lyteboat/tool-policy
|
|
25
|
+
*/
|
|
26
|
+
import { Service } from '@deepseek-ai/cordis';
|
|
27
|
+
import { NamedEntries, ScopedLayers, scopeOf, scopeParentOf } from '@deepseek-ai/dsh-scope';
|
|
28
|
+
import { RUN_CODE_NAME } from '@deepseek-ai/dsh-tools';
|
|
29
|
+
import { LYTEBOAT_STATE_CONTEXT_ORDER } from '@lyteboat/contracts';
|
|
30
|
+
import { lyteboatStateProjectionDefinition, isJsonObject, mergeStateDelta, renderLyteboatState } from "./state.js";
|
|
31
|
+
/** One scope's policy contribution. */
|
|
32
|
+
class PolicyLayer {
|
|
33
|
+
metas;
|
|
34
|
+
/** The visibility of the inherited tools no declaration on the chain names; one cell, since two answers contradict. */
|
|
35
|
+
inherited;
|
|
36
|
+
constructor(scope) {
|
|
37
|
+
this.metas = new NamedEntries(name => new Error(scope === undefined
|
|
38
|
+
? `lyteboat tool policy for "${name}" is already declared globally`
|
|
39
|
+
: `lyteboat tool policy for "${name}" is already declared in this scope`));
|
|
40
|
+
}
|
|
41
|
+
isEmpty() {
|
|
42
|
+
return this.metas.isEmpty() && this.inherited === undefined;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/** Wrap a definition so its presentation meta carries the lyteboat state delta beside the tool's own meta. */
|
|
46
|
+
function withStateDelta(definition, stateDelta) {
|
|
47
|
+
const output = definition.output;
|
|
48
|
+
const inner = output.presentationMeta?.bind(output);
|
|
49
|
+
return {
|
|
50
|
+
...definition,
|
|
51
|
+
output: {
|
|
52
|
+
...output,
|
|
53
|
+
presentationMeta(args, value) {
|
|
54
|
+
const base = inner?.(args, value);
|
|
55
|
+
const delta = stateDelta(args, value);
|
|
56
|
+
// dsh refuses an undefined presentation meta, so a call with neither a delta
|
|
57
|
+
// nor a meta of the tool's own records an empty object.
|
|
58
|
+
if (delta === undefined)
|
|
59
|
+
return base ?? {};
|
|
60
|
+
// The lyteboatState fold refuses a delta it cannot merge, and a refused result
|
|
61
|
+
// stops every projection of the session; thrown here, dsh fails the call instead.
|
|
62
|
+
mergeStateDelta({}, delta);
|
|
63
|
+
if (base === undefined)
|
|
64
|
+
return { lyteboat: { stateDelta: delta } };
|
|
65
|
+
// A tool's own `lyteboat` object (a rendered card) merges with the delta instead of losing it.
|
|
66
|
+
if (isJsonObject(base))
|
|
67
|
+
return { ...base, lyteboat: { ...isJsonObject(base['lyteboat']) ? base['lyteboat'] : {}, stateDelta: delta } };
|
|
68
|
+
return { presentation: base, lyteboat: { stateDelta: delta } };
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function sameNames(left, right) {
|
|
74
|
+
return left.length === right.length && left.every((name, index) => name === right[index]);
|
|
75
|
+
}
|
|
76
|
+
/** Host service: lyteboat tool metadata plus its enforcement at the dsh tool seams. */
|
|
77
|
+
export class ToolPolicyService extends Service {
|
|
78
|
+
// lyteboatDistro: visibility is reconciled in the kernel extension agent-loop-pre-assemble.
|
|
79
|
+
static inject = ['tools', 'sessionProjections', 'systemPrompt', 'lyteboatDistro'];
|
|
80
|
+
layers = new ScopedLayers(scope => new PolicyLayer(scope), () => { });
|
|
81
|
+
agents = new WeakMap();
|
|
82
|
+
constructor(ctx) {
|
|
83
|
+
super(ctx, 'toolPolicy');
|
|
84
|
+
ctx.sessionProjections.register(lyteboatStateProjectionDefinition);
|
|
85
|
+
ctx.systemPrompt.context({
|
|
86
|
+
name: 'lyteboat:state',
|
|
87
|
+
order: LYTEBOAT_STATE_CONTEXT_ORDER,
|
|
88
|
+
text: (context) => {
|
|
89
|
+
const agent = context.agent;
|
|
90
|
+
if (agent === undefined)
|
|
91
|
+
return '';
|
|
92
|
+
return renderLyteboatState(ctx.sessionProjections.stateOf(agent.session, 'lyteboatState'));
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
// After `next()`: listeners registered later (a `--plugin` row, a preset
|
|
96
|
+
// row) activate inside the same waterfall, and the restriction they need
|
|
97
|
+
// is computed once they returned.
|
|
98
|
+
ctx.on('lyteboat/pre-assemble', async (payload, next) => {
|
|
99
|
+
await next();
|
|
100
|
+
this.reconcile(payload.agent);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Register a tool in the calling scope's layer together with its lyteboat
|
|
105
|
+
* metadata. A `stateDelta` is folded into the tool's presentation meta.
|
|
106
|
+
* @param definition - the dsh tool definition.
|
|
107
|
+
* @param meta - lyteboat-side metadata; `visibility` defaults to `always`.
|
|
108
|
+
* @returns the exact disposer that unregisters both.
|
|
109
|
+
*/
|
|
110
|
+
register(definition, meta = {}) {
|
|
111
|
+
const wrapped = meta.stateDelta === undefined ? definition : withStateDelta(definition, meta.stateDelta);
|
|
112
|
+
const disposeTool = this.ctx.tools.register(wrapped);
|
|
113
|
+
let disposeMeta;
|
|
114
|
+
try {
|
|
115
|
+
disposeMeta = this.declare(definition.name, meta);
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
disposeTool();
|
|
119
|
+
throw error;
|
|
120
|
+
}
|
|
121
|
+
return () => {
|
|
122
|
+
disposeMeta();
|
|
123
|
+
disposeTool();
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Declare metadata for a tool registered elsewhere (an official dsh tool, a
|
|
128
|
+
* agent row's tool), in the calling scope's layer. Nearest scope wins.
|
|
129
|
+
* @param name - the tool name as registered.
|
|
130
|
+
* @param meta - lyteboat-side metadata.
|
|
131
|
+
* @returns the exact disposer that withdraws the declaration.
|
|
132
|
+
*/
|
|
133
|
+
declare(name, meta) {
|
|
134
|
+
return this.layers.effect(this.ctx, layer => layer.metas.insert(name, meta), { label: 'toolPolicy.declare()', notify: false });
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Declare, in the calling scope's layer, whether the tools its agents
|
|
138
|
+
* inherit and no declaration on their chain names reach the model. Nearest
|
|
139
|
+
* scope wins; without one they are `visible`. A hidden inherited tool stays
|
|
140
|
+
* hidden: `activate` names declared tools only.
|
|
141
|
+
* @param visibility - `visible` or `hidden`.
|
|
142
|
+
* @returns the exact disposer that withdraws the declaration.
|
|
143
|
+
* @throws when the scope already declared it.
|
|
144
|
+
*/
|
|
145
|
+
declareInherited(visibility) {
|
|
146
|
+
return this.layers.effect(this.ctx, (layer) => {
|
|
147
|
+
if (layer.inherited !== undefined)
|
|
148
|
+
throw new Error(`lyteboat tool policy: the visibility of inherited tools is already declared in this scope (${layer.inherited})`);
|
|
149
|
+
layer.inherited = visibility;
|
|
150
|
+
return () => { layer.inherited = undefined; };
|
|
151
|
+
}, { label: 'toolPolicy.declareInherited()', notify: false });
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* The metadata a scope resolves for a tool: its own chain, nearest scope last.
|
|
155
|
+
* An agent is its own scope key (the agent loop keys each agent's scope by
|
|
156
|
+
* the agent), so an agent and a preset's standing scope resolve alike.
|
|
157
|
+
* @param name - the tool name.
|
|
158
|
+
* @param scope - the viewing agent or scope; omitted for the global view.
|
|
159
|
+
*/
|
|
160
|
+
metaOf(name, scope) {
|
|
161
|
+
return this.layers.merge(scope, layer => layer.metas).get(name);
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Make `auto` tools visible to one agent from its next assembly on (or this
|
|
165
|
+
* step's, when called inside `lyteboat/pre-assemble`). Names must be declared.
|
|
166
|
+
* @param agent - the agent whose visibility changes.
|
|
167
|
+
* @param names - declared tool names.
|
|
168
|
+
*/
|
|
169
|
+
activate(agent, names) {
|
|
170
|
+
const known = this.layers.merge(scopeOf(agent.ctx), layer => layer.metas);
|
|
171
|
+
const unknown = names.filter(name => !known.has(name));
|
|
172
|
+
if (unknown.length > 0) {
|
|
173
|
+
throw new Error(`lyteboat tool policy: cannot activate undeclared tool${unknown.length > 1 ? 's' : ''} ${unknown.map(name => JSON.stringify(name)).join(', ')}; declared: ${[...known.keys()].sort().join(', ') || '(none)'}`);
|
|
174
|
+
}
|
|
175
|
+
const state = this.stateOf(agent);
|
|
176
|
+
for (const name of names)
|
|
177
|
+
state.activated.add(name);
|
|
178
|
+
this.reconcile(agent);
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Withdraw every activation of one agent; its `auto` tools hide again.
|
|
182
|
+
* @param agent - the agent to reset.
|
|
183
|
+
*/
|
|
184
|
+
clear(agent) {
|
|
185
|
+
const state = this.agents.get(agent);
|
|
186
|
+
if (state === undefined)
|
|
187
|
+
return;
|
|
188
|
+
state.activated.clear();
|
|
189
|
+
this.reconcile(agent);
|
|
190
|
+
}
|
|
191
|
+
/** The names one agent activated, sorted. */
|
|
192
|
+
activated(agent) {
|
|
193
|
+
return [...this.agents.get(agent)?.activated ?? []].sort();
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* The tool names an agent started under a scope (a preset's standing scope)
|
|
197
|
+
* sees before anything is activated, in registry order: its `auto` tools and,
|
|
198
|
+
* with inherited tools hidden, every undeclared inherited tool, are left out.
|
|
199
|
+
* A running agent's current view is `ctx.tools.schemas(agent)`.
|
|
200
|
+
* @param scope - the standing scope a new agent inherits from.
|
|
201
|
+
*/
|
|
202
|
+
visible(scope) {
|
|
203
|
+
const denied = new Set(this.deniedFor(scope, scope, new Set()));
|
|
204
|
+
return this.ctx.tools.schemas(scope).map(schema => schema.name).filter(name => !denied.has(name));
|
|
205
|
+
}
|
|
206
|
+
stateOf(agent) {
|
|
207
|
+
let state = this.agents.get(agent);
|
|
208
|
+
if (state === undefined) {
|
|
209
|
+
state = { activated: new Set(), deny: [], dispose: undefined };
|
|
210
|
+
this.agents.set(agent, state);
|
|
211
|
+
}
|
|
212
|
+
return state;
|
|
213
|
+
}
|
|
214
|
+
/** Whether one scope's undeclared inherited tools reach the model: the nearest declaration on its chain, `visible` without one. */
|
|
215
|
+
inheritedOf(key) {
|
|
216
|
+
let visibility = 'visible';
|
|
217
|
+
for (const layer of [this.layers.global, ...this.layers.chainLayers(key)])
|
|
218
|
+
visibility = layer.inherited ?? visibility;
|
|
219
|
+
return visibility;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* The names an agent of `scope`, inheriting `inheritedView`, is denied: every
|
|
223
|
+
* declared `auto` tool not activated and, with inherited tools `hidden`, every
|
|
224
|
+
* inherited tool no declaration names. Sorted.
|
|
225
|
+
*/
|
|
226
|
+
deniedFor(scope, inheritedView, activated) {
|
|
227
|
+
const declared = [...this.layers.merge(scope, layer => layer.metas)];
|
|
228
|
+
const declaredNames = new Set(declared.map(([name]) => name));
|
|
229
|
+
// The parent's view is what the agent inherits before its own restriction;
|
|
230
|
+
// the PTC transport sits outside every restriction and is never named.
|
|
231
|
+
const hiddenInherited = this.inheritedOf(scope) === 'hidden'
|
|
232
|
+
? this.ctx.tools.schemas(inheritedView).map(schema => schema.name).filter(name => name !== RUN_CODE_NAME && !declaredNames.has(name))
|
|
233
|
+
: [];
|
|
234
|
+
return declared
|
|
235
|
+
.filter(([name, meta]) => meta.visibility === 'auto' && !activated.has(name))
|
|
236
|
+
.map(([name]) => name)
|
|
237
|
+
.concat(hiddenInherited)
|
|
238
|
+
.sort();
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Recompute one agent's restriction: every `auto` tool it inherits and has
|
|
242
|
+
* not activated is denied, and with inherited tools `hidden` every inherited
|
|
243
|
+
* tool no declaration names. Reissued only when the set changed.
|
|
244
|
+
* @throws when a declared name reaches the agent registered by no row, or
|
|
245
|
+
* an `auto` tool sits in the agent's own layer, where `restrict` cannot hide
|
|
246
|
+
* it: both are composition mistakes and never silently pass.
|
|
247
|
+
*/
|
|
248
|
+
reconcile(agent) {
|
|
249
|
+
const key = scopeOf(agent.ctx);
|
|
250
|
+
if (key === undefined)
|
|
251
|
+
return;
|
|
252
|
+
const state = this.stateOf(agent);
|
|
253
|
+
const inheritedView = scopeParentOf(key);
|
|
254
|
+
const declared = [...this.layers.merge(key, layer => layer.metas)];
|
|
255
|
+
// `get` answers from the visible view, which the agent's own restriction
|
|
256
|
+
// filters; the parent's view is unrestricted, and an own-layer tool is
|
|
257
|
+
// never restricted, so between the two every registered name shows.
|
|
258
|
+
const unregistered = declared
|
|
259
|
+
.filter(([name]) => this.ctx.tools.get(name, inheritedView) === undefined && this.ctx.tools.get(name, key) === undefined)
|
|
260
|
+
.map(([name]) => name);
|
|
261
|
+
if (unregistered.length > 0) {
|
|
262
|
+
throw new Error(`lyteboat tool policy: declared tool${unregistered.length > 1 ? 's' : ''} ${unregistered.map(name => JSON.stringify(name)).join(', ')} registered by no row reachable from agent "${agent.id}"`);
|
|
263
|
+
}
|
|
264
|
+
const unrestrictable = declared
|
|
265
|
+
.filter(([name, meta]) => meta.visibility === 'auto' && this.ctx.tools.get(name, inheritedView) === undefined)
|
|
266
|
+
.map(([name]) => name);
|
|
267
|
+
if (unrestrictable.length > 0) {
|
|
268
|
+
throw new Error(`lyteboat tool policy: auto tool${unrestrictable.length > 1 ? 's' : ''} ${unrestrictable.map(name => JSON.stringify(name)).join(', ')} registered in agent "${agent.id}"'s own layer, which restrict() cannot hide; register through the host or an agent row`);
|
|
269
|
+
}
|
|
270
|
+
const deny = this.deniedFor(key, inheritedView, state.activated);
|
|
271
|
+
if (sameNames(deny, state.deny))
|
|
272
|
+
return;
|
|
273
|
+
state.dispose?.();
|
|
274
|
+
state.dispose = deny.length === 0 ? undefined : agent.ctx.tools.restrict({ deny });
|
|
275
|
+
state.deny = deny;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
export default ToolPolicyService;
|
|
279
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAW,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAEtD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAE3F,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAItD,OAAO,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAA;AAElE,OAAO,EAAE,iCAAiC,EAAE,YAAY,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;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I,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,yBAAyB,KAAK,CAAC,EAAE,wFAAwF,CAAC,CAAA;QACjR,CAAC;QACD,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,aAAa,EAAE,KAAK,CAAC,SAAS,CAAC,CAAA;QAChE,IAAI,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC;YAAE,OAAM;QACvC,KAAK,CAAC,OAAO,EAAE,EAAE,CAAA;QACjB,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAA;QAClF,KAAK,CAAC,IAAI,GAAG,IAAI,CAAA;IACnB,CAAC;;AAGH,eAAe,iBAAiB,CAAA"}
|
package/lib/state.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `lyteboatState` projection: the session's accumulated tool state, folded
|
|
3
|
+
* from the `stateDelta` a successful `tool/result` carries on
|
|
4
|
+
* `meta.lyteboat.stateDelta`. A delta is a JSON object whose top-level keys are
|
|
5
|
+
* dot paths (`assets.total`); each path is assigned into the state, nested
|
|
6
|
+
* plain objects deep-merge (the reference `apply_state_delta` overwrites the leaf
|
|
7
|
+
* instead; lyteboat keeps sibling fields a partial refresh did not mention),
|
|
8
|
+
* every other value replaces. The fold is immutable and returns the same
|
|
9
|
+
* reference when nothing changed.
|
|
10
|
+
* @module @lyteboat/tool-policy/state
|
|
11
|
+
*/
|
|
12
|
+
import type { JsonValue, LyteboatStateValue } from '@lyteboat/contracts';
|
|
13
|
+
/** Whether a JSON value is a plain object (the only shape that merges). */
|
|
14
|
+
export declare function isJsonObject(value: JsonValue | undefined): value is LyteboatStateValue;
|
|
15
|
+
/**
|
|
16
|
+
* Fold one delta into the state.
|
|
17
|
+
* @param state - the state before the delta.
|
|
18
|
+
* @param delta - a JSON object keyed by dot paths.
|
|
19
|
+
* @returns the next state, or `state` itself when the delta changed nothing.
|
|
20
|
+
*/
|
|
21
|
+
export declare function mergeStateDelta(state: LyteboatStateValue, delta: JsonValue): LyteboatStateValue;
|
|
22
|
+
export declare const lyteboatStateProjectionDefinition: {
|
|
23
|
+
key: "lyteboatState";
|
|
24
|
+
stateSchema: import("zod").ZodType<LyteboatStateValue, unknown, import("zod/v4/core").$ZodTypeInternals<LyteboatStateValue, unknown>>;
|
|
25
|
+
init: () => LyteboatStateValue;
|
|
26
|
+
apply(state: LyteboatStateValue, event: import("@deepseek-ai/dsh-session").SessionEvent): LyteboatStateValue;
|
|
27
|
+
wire: {
|
|
28
|
+
viewSchema: import("zod").ZodType<LyteboatStateValue, unknown, import("zod/v4/core").$ZodTypeInternals<LyteboatStateValue, unknown>>;
|
|
29
|
+
view: (state: LyteboatStateValue) => LyteboatStateValue;
|
|
30
|
+
};
|
|
31
|
+
stateVersion: number;
|
|
32
|
+
};
|
|
33
|
+
/** The model-facing rendering of the current state; empty when there is none. */
|
|
34
|
+
export declare function renderLyteboatState(state: LyteboatStateValue | undefined): string;
|
|
35
|
+
//# sourceMappingURL=state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAsB,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAE5F,2EAA2E;AAC3E,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,GAAG,KAAK,IAAI,kBAAkB,CAEtF;AA2BD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,SAAS,GAAG,kBAAkB,CAS/F;AAaD,eAAO,MAAM,iCAAiC;;;gBAGlC,kBAAkB;iBACf,kBAAkB;;;sBAgB6B,kBAAkB;;;CAEX,CAAA;AAErE,iFAAiF;AACjF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,kBAAkB,GAAG,SAAS,GAAG,MAAM,CAGjF"}
|
package/lib/state.js
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `lyteboatState` projection: the session's accumulated tool state, folded
|
|
3
|
+
* from the `stateDelta` a successful `tool/result` carries on
|
|
4
|
+
* `meta.lyteboat.stateDelta`. A delta is a JSON object whose top-level keys are
|
|
5
|
+
* dot paths (`assets.total`); each path is assigned into the state, nested
|
|
6
|
+
* plain objects deep-merge (the reference `apply_state_delta` overwrites the leaf
|
|
7
|
+
* instead; lyteboat keeps sibling fields a partial refresh did not mention),
|
|
8
|
+
* every other value replaces. The fold is immutable and returns the same
|
|
9
|
+
* reference when nothing changed.
|
|
10
|
+
* @module @lyteboat/tool-policy/state
|
|
11
|
+
*/
|
|
12
|
+
import { lyteboatResultMetaSchema, lyteboatStateValueSchema } from '@lyteboat/contracts';
|
|
13
|
+
/** Whether a JSON value is a plain object (the only shape that merges). */
|
|
14
|
+
export function isJsonObject(value) {
|
|
15
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
16
|
+
}
|
|
17
|
+
/** Deep-merge two plain objects without splitting keys; returns `target` when nothing changed. */
|
|
18
|
+
function deepMerge(target, source) {
|
|
19
|
+
let next = target;
|
|
20
|
+
for (const [key, value] of Object.entries(source)) {
|
|
21
|
+
const current = next[key];
|
|
22
|
+
const replacement = isJsonObject(value) && isJsonObject(current) ? deepMerge(current, value) : value;
|
|
23
|
+
if (Object.is(replacement, current))
|
|
24
|
+
continue;
|
|
25
|
+
next = { ...next, [key]: replacement };
|
|
26
|
+
}
|
|
27
|
+
return next;
|
|
28
|
+
}
|
|
29
|
+
function assignPath(target, path, value) {
|
|
30
|
+
const [head, ...rest] = path;
|
|
31
|
+
/* v8 ignore next -- mergeStateDelta rejects an empty path before descending */
|
|
32
|
+
if (head === undefined)
|
|
33
|
+
throw new Error('state delta path must not be empty');
|
|
34
|
+
const current = target[head];
|
|
35
|
+
let replacement;
|
|
36
|
+
if (rest.length > 0)
|
|
37
|
+
replacement = assignPath(isJsonObject(current) ? current : {}, rest, value);
|
|
38
|
+
else if (isJsonObject(value) && isJsonObject(current))
|
|
39
|
+
replacement = deepMerge(current, value);
|
|
40
|
+
else
|
|
41
|
+
replacement = value;
|
|
42
|
+
if (Object.is(replacement, current))
|
|
43
|
+
return target;
|
|
44
|
+
return { ...target, [head]: replacement };
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Fold one delta into the state.
|
|
48
|
+
* @param state - the state before the delta.
|
|
49
|
+
* @param delta - a JSON object keyed by dot paths.
|
|
50
|
+
* @returns the next state, or `state` itself when the delta changed nothing.
|
|
51
|
+
*/
|
|
52
|
+
export function mergeStateDelta(state, delta) {
|
|
53
|
+
if (!isJsonObject(delta))
|
|
54
|
+
throw new Error('state delta must be a JSON object keyed by dot paths');
|
|
55
|
+
let next = state;
|
|
56
|
+
for (const [path, value] of Object.entries(delta)) {
|
|
57
|
+
const segments = path.split('.');
|
|
58
|
+
if (segments.some(segment => segment === ''))
|
|
59
|
+
throw new Error(`state delta path ${JSON.stringify(path)} has an empty segment`);
|
|
60
|
+
next = assignPath(next, segments, value);
|
|
61
|
+
}
|
|
62
|
+
return next;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The delta a result's presentation meta carries under `lyteboat.stateDelta`.
|
|
66
|
+
* @param meta - a tool result's presentation meta.
|
|
67
|
+
* @returns the delta; undefined when the meta carries no `lyteboat` envelope or it has no delta.
|
|
68
|
+
* @throws when the `lyteboat` envelope fails its schema.
|
|
69
|
+
*/
|
|
70
|
+
function stateDeltaOfMeta(meta) {
|
|
71
|
+
if (!isJsonObject(meta) || meta['lyteboat'] === undefined)
|
|
72
|
+
return undefined;
|
|
73
|
+
return lyteboatResultMetaSchema.parse(meta['lyteboat']).stateDelta;
|
|
74
|
+
}
|
|
75
|
+
export const lyteboatStateProjectionDefinition = {
|
|
76
|
+
key: 'lyteboatState',
|
|
77
|
+
stateSchema: lyteboatStateValueSchema,
|
|
78
|
+
init: () => ({}),
|
|
79
|
+
apply(state, event) {
|
|
80
|
+
// dsh computes no presentation meta for a PTC sub-dispatch (a tool the
|
|
81
|
+
// `run_code` SDK calls, `exec.parent` set), so only model-direct calls carry
|
|
82
|
+
// a delta; an errored result carries no delta worth folding.
|
|
83
|
+
// A surface replacement (compaction pruning, an agent shortening an old
|
|
84
|
+
// result) must keep the original meta, so folding it would apply an old delta
|
|
85
|
+
// over newer state: only the appended result counts.
|
|
86
|
+
if (event.type !== 'tool/result' || event.surfaceOp !== 'append')
|
|
87
|
+
return state;
|
|
88
|
+
if (event.data.message.isError === true)
|
|
89
|
+
return state;
|
|
90
|
+
try {
|
|
91
|
+
const delta = stateDeltaOfMeta(event.data.meta);
|
|
92
|
+
return delta === undefined ? state : mergeStateDelta(state, delta);
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
throw new Error(`tool result at session seq ${String(event.seq)} carries an invalid meta.lyteboat`, { cause: error });
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
wire: { viewSchema: lyteboatStateValueSchema, view: (state) => state },
|
|
99
|
+
stateVersion: 1,
|
|
100
|
+
};
|
|
101
|
+
/** The model-facing rendering of the current state; empty when there is none. */
|
|
102
|
+
export function renderLyteboatState(state) {
|
|
103
|
+
if (state === undefined || Object.keys(state).length === 0)
|
|
104
|
+
return '';
|
|
105
|
+
return `Session state, accumulated from tool results (JSON):\n${JSON.stringify(state)}`;
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=state.js.map
|
package/lib/state.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.js","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OA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AAS,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAA;IACrE,OAAO,yDAAyD,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAA;AACzF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,48 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lyteboat/tool-policy",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"description": "lyteboat's tool policy over the dsh tool registry: visibility (always/auto + activation, and whether an agent's undeclared inherited tools stay visible) and tool-result state deltas folded into the lyteboatState projection",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/lyteboat/lyteboat.git",
|
|
9
|
+
"directory": "lyteboat/plugins/tool-policy"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/lyteboat/lyteboat#readme",
|
|
12
|
+
"type": "module",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"@lyteboat/source": "./src/index.ts",
|
|
16
|
+
"types": "./lib/index.d.ts",
|
|
17
|
+
"default": "./lib/index.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"lib"
|
|
22
|
+
],
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@deepseek-ai/dsh-scope": "0.2.0-rc.2",
|
|
25
|
+
"@lyteboat/contracts": "0.1.0"
|
|
26
|
+
},
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"@deepseek-ai/cordis": "4.0.4",
|
|
29
|
+
"@deepseek-ai/dsh-agent": "0.2.0-rc.2",
|
|
30
|
+
"@deepseek-ai/dsh-session": "0.2.0-rc.2",
|
|
31
|
+
"@deepseek-ai/dsh-system-prompt": "0.2.0-rc.2",
|
|
32
|
+
"@deepseek-ai/dsh-session-projection": "0.2.0-rc.2",
|
|
33
|
+
"@deepseek-ai/dsh-tools": "0.2.0-rc.2"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@deepseek-ai/cordis": "4.0.4",
|
|
37
|
+
"@lyteboat/testkit": "0.1.0",
|
|
38
|
+
"@deepseek-ai/dsh-agent": "0.2.0-rc.2",
|
|
39
|
+
"@deepseek-ai/dsh-session": "0.2.0-rc.2",
|
|
40
|
+
"@lyteboat/distro": "0.1.0",
|
|
41
|
+
"@deepseek-ai/dsh-session-projection": "0.2.0-rc.2",
|
|
42
|
+
"@deepseek-ai/dsh-system-prompt": "0.2.0-rc.2",
|
|
43
|
+
"@deepseek-ai/dsh-tools": "0.2.0-rc.2"
|
|
44
|
+
},
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public"
|
|
47
|
+
}
|
|
6
48
|
}
|