@petriflow/gate 0.1.0 → 0.1.2
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/dist/index.cjs +411 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +209 -0
- package/dist/index.d.ts +209 -11
- package/dist/index.js +373 -10
- package/dist/index.js.map +1 -1
- package/package.json +8 -5
- package/dist/advance.d.ts +0 -11
- package/dist/advance.d.ts.map +0 -1
- package/dist/advance.js +0 -49
- package/dist/advance.js.map +0 -1
- package/dist/compose.d.ts +0 -37
- package/dist/compose.d.ts.map +0 -1
- package/dist/compose.js +0 -112
- package/dist/compose.js.map +0 -1
- package/dist/events.d.ts +0 -24
- package/dist/events.d.ts.map +0 -1
- package/dist/events.js +0 -2
- package/dist/events.js.map +0 -1
- package/dist/gate.d.ts +0 -39
- package/dist/gate.d.ts.map +0 -1
- package/dist/gate.js +0 -103
- package/dist/gate.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/manager.d.ts +0 -38
- package/dist/manager.d.ts.map +0 -1
- package/dist/manager.js +0 -128
- package/dist/manager.js.map +0 -1
- package/dist/types.d.ts +0 -71
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -5
- package/dist/types.js.map +0 -1
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { Marking } from '@petriflow/engine';
|
|
2
|
+
|
|
3
|
+
/** A transition that optionally gates tool access */
|
|
4
|
+
type GatedTransition<Place extends string> = {
|
|
5
|
+
name: string;
|
|
6
|
+
type: "auto" | "manual";
|
|
7
|
+
inputs: Place[];
|
|
8
|
+
outputs: Place[];
|
|
9
|
+
guard?: string | null;
|
|
10
|
+
tools?: string[];
|
|
11
|
+
/**
|
|
12
|
+
* When true, the transition allows the tool call immediately but
|
|
13
|
+
* only fires (consumes/produces tokens) when the tool_result
|
|
14
|
+
* comes back successfully (isError === false).
|
|
15
|
+
* Use this for transitions where the tool must succeed before
|
|
16
|
+
* the net advances (e.g. backup must succeed before delete unlocks).
|
|
17
|
+
*/
|
|
18
|
+
deferred?: boolean;
|
|
19
|
+
};
|
|
20
|
+
/** Minimal tool event shape for toolMapper */
|
|
21
|
+
type ToolEvent = {
|
|
22
|
+
toolName: string;
|
|
23
|
+
input: Record<string, unknown>;
|
|
24
|
+
};
|
|
25
|
+
/** A Petri net that gates a skill's tool access */
|
|
26
|
+
type SkillNet<Place extends string> = {
|
|
27
|
+
name: string;
|
|
28
|
+
places: Place[];
|
|
29
|
+
transitions: GatedTransition<Place>[];
|
|
30
|
+
initialMarking: Marking<Place>;
|
|
31
|
+
terminalPlaces: Place[];
|
|
32
|
+
freeTools: string[];
|
|
33
|
+
/**
|
|
34
|
+
* Maps a tool call to a virtual tool name before gating.
|
|
35
|
+
* Use this to split one tool (e.g. "bash") into multiple gated
|
|
36
|
+
* variants (e.g. "bash", "git-commit", "git-push") based on input.
|
|
37
|
+
* If not provided, event.toolName is used as-is.
|
|
38
|
+
*/
|
|
39
|
+
toolMapper?: (event: ToolEvent) => string;
|
|
40
|
+
/**
|
|
41
|
+
* Additional validation before a gated tool call is allowed.
|
|
42
|
+
* Called after the net confirms a matching transition exists.
|
|
43
|
+
* Return { block, reason } to reject, or void to allow.
|
|
44
|
+
* Use this for domain-specific checks (e.g. path coverage).
|
|
45
|
+
*
|
|
46
|
+
* Method syntax is intentional — bivariant so SkillNet<Place> widens to SkillNet<string>.
|
|
47
|
+
*/
|
|
48
|
+
validateToolCall?(event: ToolEvent, resolvedTool: string, transition: GatedTransition<Place>, state: {
|
|
49
|
+
marking: Marking<Place>;
|
|
50
|
+
meta: Record<string, unknown>;
|
|
51
|
+
}): {
|
|
52
|
+
block: true;
|
|
53
|
+
reason: string;
|
|
54
|
+
} | void;
|
|
55
|
+
/**
|
|
56
|
+
* Called when a deferred transition's tool_result arrives.
|
|
57
|
+
* Use this to record metadata (e.g. backed-up paths).
|
|
58
|
+
*
|
|
59
|
+
* Method syntax is intentional — bivariant so SkillNet<Place> widens to SkillNet<string>.
|
|
60
|
+
*/
|
|
61
|
+
onDeferredResult?(event: {
|
|
62
|
+
toolCallId: string;
|
|
63
|
+
input: Record<string, unknown>;
|
|
64
|
+
isError: boolean;
|
|
65
|
+
}, resolvedTool: string, transition: GatedTransition<Place>, state: {
|
|
66
|
+
marking: Marking<Place>;
|
|
67
|
+
meta: Record<string, unknown>;
|
|
68
|
+
}): void;
|
|
69
|
+
};
|
|
70
|
+
/** Type-safe helper — validates places/marking at the type level */
|
|
71
|
+
declare function defineSkillNet<Place extends string>(net: SkillNet<Place>): SkillNet<Place>;
|
|
72
|
+
|
|
73
|
+
/** Generic tool call event — framework-agnostic */
|
|
74
|
+
type GateToolCall = {
|
|
75
|
+
toolCallId: string;
|
|
76
|
+
toolName: string;
|
|
77
|
+
input: Record<string, unknown>;
|
|
78
|
+
};
|
|
79
|
+
/** Generic tool result event — framework-agnostic */
|
|
80
|
+
type GateToolResult = {
|
|
81
|
+
toolCallId: string;
|
|
82
|
+
toolName: string;
|
|
83
|
+
input: Record<string, unknown>;
|
|
84
|
+
isError: boolean;
|
|
85
|
+
};
|
|
86
|
+
/** Generic context for gating decisions */
|
|
87
|
+
type GateContext = {
|
|
88
|
+
hasUI: boolean;
|
|
89
|
+
confirm: (title: string, message: string) => Promise<boolean>;
|
|
90
|
+
};
|
|
91
|
+
/** A gating decision: block with reason, or undefined to allow */
|
|
92
|
+
type GateDecision = {
|
|
93
|
+
block: true;
|
|
94
|
+
reason: string;
|
|
95
|
+
} | undefined;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Auto-advance: fire all enabled structural transitions (type=auto,
|
|
99
|
+
* no tools) in a loop until quiescent.
|
|
100
|
+
*
|
|
101
|
+
* When multiple structural transitions compete for the same input
|
|
102
|
+
* token, none of them fire (avoids ambiguous choices).
|
|
103
|
+
*/
|
|
104
|
+
declare function autoAdvance<P extends string>(net: SkillNet<P>, marking: Marking<P>): Marking<P>;
|
|
105
|
+
|
|
106
|
+
/** Resolve the virtual tool name for a tool call event */
|
|
107
|
+
declare function resolveTool<P extends string>(net: SkillNet<P>, event: {
|
|
108
|
+
toolName: string;
|
|
109
|
+
input: Record<string, unknown>;
|
|
110
|
+
}): string;
|
|
111
|
+
/** Public: get tool transitions the agent can currently use */
|
|
112
|
+
declare function getEnabledToolTransitions<P extends string>(net: SkillNet<P>, marking: Marking<P>): GatedTransition<P>[];
|
|
113
|
+
/** Format marking for display */
|
|
114
|
+
declare function formatMarking<P extends string>(marking: Marking<P>): string;
|
|
115
|
+
/** A pending deferred transition awaiting tool_result */
|
|
116
|
+
type PendingDeferred<P extends string> = {
|
|
117
|
+
toolCallId: string;
|
|
118
|
+
transition: GatedTransition<P>;
|
|
119
|
+
resolvedTool: string;
|
|
120
|
+
};
|
|
121
|
+
type GateState<P extends string> = {
|
|
122
|
+
marking: Marking<P>;
|
|
123
|
+
/** Skill-specific metadata (e.g. backed-up paths) */
|
|
124
|
+
meta: Record<string, unknown>;
|
|
125
|
+
/** Deferred transitions waiting for tool_result */
|
|
126
|
+
pending: Map<string, PendingDeferred<P>>;
|
|
127
|
+
};
|
|
128
|
+
declare function createGateState<P extends string>(marking: Marking<P>): GateState<P>;
|
|
129
|
+
/**
|
|
130
|
+
* Core gating logic for a tool_call event.
|
|
131
|
+
* Mutates state.marking when a non-deferred transition fires.
|
|
132
|
+
* For deferred transitions, records pending and fires on tool_result.
|
|
133
|
+
*/
|
|
134
|
+
declare function handleToolCall<P extends string>(event: GateToolCall, ctx: GateContext, net: SkillNet<P>, state: GateState<P>): Promise<GateDecision>;
|
|
135
|
+
/**
|
|
136
|
+
* Handle a tool_result event. Fires deferred transitions on success.
|
|
137
|
+
* Returns void (tool_result handler doesn't block).
|
|
138
|
+
*/
|
|
139
|
+
declare function handleToolResult<P extends string>(event: GateToolResult, net: SkillNet<P>, state: GateState<P>): void;
|
|
140
|
+
|
|
141
|
+
/** Classification of a net's opinion on a tool call */
|
|
142
|
+
type NetVerdict<P extends string> = {
|
|
143
|
+
net: SkillNet<P>;
|
|
144
|
+
state: GateState<P>;
|
|
145
|
+
resolvedTool: string;
|
|
146
|
+
} & ({
|
|
147
|
+
kind: "free";
|
|
148
|
+
} | {
|
|
149
|
+
kind: "abstain";
|
|
150
|
+
} | {
|
|
151
|
+
kind: "blocked";
|
|
152
|
+
reason: string;
|
|
153
|
+
} | {
|
|
154
|
+
kind: "gated";
|
|
155
|
+
transition: SkillNet<P>["transitions"][number];
|
|
156
|
+
});
|
|
157
|
+
/** Registry-based config for dynamic net management */
|
|
158
|
+
type ComposeConfig = {
|
|
159
|
+
registry: Record<string, SkillNet<string>>;
|
|
160
|
+
active?: string[];
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* Phase 1 — Structural check (non-mutating).
|
|
164
|
+
* Classify each net as free, gated, blocked, or abstain.
|
|
165
|
+
*/
|
|
166
|
+
declare function classifyNets<P extends string>(nets: SkillNet<P>[], states: GateState<P>[], event: {
|
|
167
|
+
toolName: string;
|
|
168
|
+
input: Record<string, unknown>;
|
|
169
|
+
}): NetVerdict<P>[];
|
|
170
|
+
/**
|
|
171
|
+
* 4-phase tool call handler for composed nets.
|
|
172
|
+
*/
|
|
173
|
+
declare function composedToolCall(getNets: () => SkillNet<string>[], getStates: () => GateState<string>[], event: GateToolCall, ctx: GateContext): Promise<GateDecision>;
|
|
174
|
+
|
|
175
|
+
type GateManager = {
|
|
176
|
+
handleToolCall: (event: GateToolCall, ctx: GateContext) => Promise<GateDecision>;
|
|
177
|
+
handleToolResult: (event: GateToolResult) => void;
|
|
178
|
+
addNet: (name: string) => {
|
|
179
|
+
ok: boolean;
|
|
180
|
+
message: string;
|
|
181
|
+
};
|
|
182
|
+
removeNet: (name: string) => {
|
|
183
|
+
ok: boolean;
|
|
184
|
+
message: string;
|
|
185
|
+
};
|
|
186
|
+
getActiveNets: () => Array<{
|
|
187
|
+
name: string;
|
|
188
|
+
net: SkillNet<string>;
|
|
189
|
+
state: GateState<string>;
|
|
190
|
+
}>;
|
|
191
|
+
getAllNets: () => Array<{
|
|
192
|
+
name: string;
|
|
193
|
+
net: SkillNet<string>;
|
|
194
|
+
state: GateState<string>;
|
|
195
|
+
active: boolean;
|
|
196
|
+
}>;
|
|
197
|
+
formatStatus: () => string;
|
|
198
|
+
formatSystemPrompt: () => string;
|
|
199
|
+
isDynamic: boolean;
|
|
200
|
+
};
|
|
201
|
+
type GateManagerOptions = {
|
|
202
|
+
/** "enforce" blocks disallowed tools. "shadow" logs but never blocks. */
|
|
203
|
+
mode: "enforce" | "shadow";
|
|
204
|
+
/** Called after every gating decision. Use for logging, metrics, debugging. */
|
|
205
|
+
onDecision?: (event: GateToolCall, decision: GateDecision) => void;
|
|
206
|
+
};
|
|
207
|
+
declare function createGateManager(input: SkillNet<string>[] | ComposeConfig, opts?: GateManagerOptions): GateManager;
|
|
208
|
+
|
|
209
|
+
export { type ComposeConfig, type GateContext, type GateDecision, type GateManager, type GateManagerOptions, type GateState, type GateToolCall, type GateToolResult, type GatedTransition, type NetVerdict, type SkillNet, type ToolEvent, autoAdvance, classifyNets, composedToolCall, createGateManager, createGateState, defineSkillNet, formatMarking, getEnabledToolTransitions, handleToolCall, handleToolResult, resolveTool };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,209 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { Marking } from '@petriflow/engine';
|
|
2
|
+
|
|
3
|
+
/** A transition that optionally gates tool access */
|
|
4
|
+
type GatedTransition<Place extends string> = {
|
|
5
|
+
name: string;
|
|
6
|
+
type: "auto" | "manual";
|
|
7
|
+
inputs: Place[];
|
|
8
|
+
outputs: Place[];
|
|
9
|
+
guard?: string | null;
|
|
10
|
+
tools?: string[];
|
|
11
|
+
/**
|
|
12
|
+
* When true, the transition allows the tool call immediately but
|
|
13
|
+
* only fires (consumes/produces tokens) when the tool_result
|
|
14
|
+
* comes back successfully (isError === false).
|
|
15
|
+
* Use this for transitions where the tool must succeed before
|
|
16
|
+
* the net advances (e.g. backup must succeed before delete unlocks).
|
|
17
|
+
*/
|
|
18
|
+
deferred?: boolean;
|
|
19
|
+
};
|
|
20
|
+
/** Minimal tool event shape for toolMapper */
|
|
21
|
+
type ToolEvent = {
|
|
22
|
+
toolName: string;
|
|
23
|
+
input: Record<string, unknown>;
|
|
24
|
+
};
|
|
25
|
+
/** A Petri net that gates a skill's tool access */
|
|
26
|
+
type SkillNet<Place extends string> = {
|
|
27
|
+
name: string;
|
|
28
|
+
places: Place[];
|
|
29
|
+
transitions: GatedTransition<Place>[];
|
|
30
|
+
initialMarking: Marking<Place>;
|
|
31
|
+
terminalPlaces: Place[];
|
|
32
|
+
freeTools: string[];
|
|
33
|
+
/**
|
|
34
|
+
* Maps a tool call to a virtual tool name before gating.
|
|
35
|
+
* Use this to split one tool (e.g. "bash") into multiple gated
|
|
36
|
+
* variants (e.g. "bash", "git-commit", "git-push") based on input.
|
|
37
|
+
* If not provided, event.toolName is used as-is.
|
|
38
|
+
*/
|
|
39
|
+
toolMapper?: (event: ToolEvent) => string;
|
|
40
|
+
/**
|
|
41
|
+
* Additional validation before a gated tool call is allowed.
|
|
42
|
+
* Called after the net confirms a matching transition exists.
|
|
43
|
+
* Return { block, reason } to reject, or void to allow.
|
|
44
|
+
* Use this for domain-specific checks (e.g. path coverage).
|
|
45
|
+
*
|
|
46
|
+
* Method syntax is intentional — bivariant so SkillNet<Place> widens to SkillNet<string>.
|
|
47
|
+
*/
|
|
48
|
+
validateToolCall?(event: ToolEvent, resolvedTool: string, transition: GatedTransition<Place>, state: {
|
|
49
|
+
marking: Marking<Place>;
|
|
50
|
+
meta: Record<string, unknown>;
|
|
51
|
+
}): {
|
|
52
|
+
block: true;
|
|
53
|
+
reason: string;
|
|
54
|
+
} | void;
|
|
55
|
+
/**
|
|
56
|
+
* Called when a deferred transition's tool_result arrives.
|
|
57
|
+
* Use this to record metadata (e.g. backed-up paths).
|
|
58
|
+
*
|
|
59
|
+
* Method syntax is intentional — bivariant so SkillNet<Place> widens to SkillNet<string>.
|
|
60
|
+
*/
|
|
61
|
+
onDeferredResult?(event: {
|
|
62
|
+
toolCallId: string;
|
|
63
|
+
input: Record<string, unknown>;
|
|
64
|
+
isError: boolean;
|
|
65
|
+
}, resolvedTool: string, transition: GatedTransition<Place>, state: {
|
|
66
|
+
marking: Marking<Place>;
|
|
67
|
+
meta: Record<string, unknown>;
|
|
68
|
+
}): void;
|
|
69
|
+
};
|
|
70
|
+
/** Type-safe helper — validates places/marking at the type level */
|
|
71
|
+
declare function defineSkillNet<Place extends string>(net: SkillNet<Place>): SkillNet<Place>;
|
|
72
|
+
|
|
73
|
+
/** Generic tool call event — framework-agnostic */
|
|
74
|
+
type GateToolCall = {
|
|
75
|
+
toolCallId: string;
|
|
76
|
+
toolName: string;
|
|
77
|
+
input: Record<string, unknown>;
|
|
78
|
+
};
|
|
79
|
+
/** Generic tool result event — framework-agnostic */
|
|
80
|
+
type GateToolResult = {
|
|
81
|
+
toolCallId: string;
|
|
82
|
+
toolName: string;
|
|
83
|
+
input: Record<string, unknown>;
|
|
84
|
+
isError: boolean;
|
|
85
|
+
};
|
|
86
|
+
/** Generic context for gating decisions */
|
|
87
|
+
type GateContext = {
|
|
88
|
+
hasUI: boolean;
|
|
89
|
+
confirm: (title: string, message: string) => Promise<boolean>;
|
|
90
|
+
};
|
|
91
|
+
/** A gating decision: block with reason, or undefined to allow */
|
|
92
|
+
type GateDecision = {
|
|
93
|
+
block: true;
|
|
94
|
+
reason: string;
|
|
95
|
+
} | undefined;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Auto-advance: fire all enabled structural transitions (type=auto,
|
|
99
|
+
* no tools) in a loop until quiescent.
|
|
100
|
+
*
|
|
101
|
+
* When multiple structural transitions compete for the same input
|
|
102
|
+
* token, none of them fire (avoids ambiguous choices).
|
|
103
|
+
*/
|
|
104
|
+
declare function autoAdvance<P extends string>(net: SkillNet<P>, marking: Marking<P>): Marking<P>;
|
|
105
|
+
|
|
106
|
+
/** Resolve the virtual tool name for a tool call event */
|
|
107
|
+
declare function resolveTool<P extends string>(net: SkillNet<P>, event: {
|
|
108
|
+
toolName: string;
|
|
109
|
+
input: Record<string, unknown>;
|
|
110
|
+
}): string;
|
|
111
|
+
/** Public: get tool transitions the agent can currently use */
|
|
112
|
+
declare function getEnabledToolTransitions<P extends string>(net: SkillNet<P>, marking: Marking<P>): GatedTransition<P>[];
|
|
113
|
+
/** Format marking for display */
|
|
114
|
+
declare function formatMarking<P extends string>(marking: Marking<P>): string;
|
|
115
|
+
/** A pending deferred transition awaiting tool_result */
|
|
116
|
+
type PendingDeferred<P extends string> = {
|
|
117
|
+
toolCallId: string;
|
|
118
|
+
transition: GatedTransition<P>;
|
|
119
|
+
resolvedTool: string;
|
|
120
|
+
};
|
|
121
|
+
type GateState<P extends string> = {
|
|
122
|
+
marking: Marking<P>;
|
|
123
|
+
/** Skill-specific metadata (e.g. backed-up paths) */
|
|
124
|
+
meta: Record<string, unknown>;
|
|
125
|
+
/** Deferred transitions waiting for tool_result */
|
|
126
|
+
pending: Map<string, PendingDeferred<P>>;
|
|
127
|
+
};
|
|
128
|
+
declare function createGateState<P extends string>(marking: Marking<P>): GateState<P>;
|
|
129
|
+
/**
|
|
130
|
+
* Core gating logic for a tool_call event.
|
|
131
|
+
* Mutates state.marking when a non-deferred transition fires.
|
|
132
|
+
* For deferred transitions, records pending and fires on tool_result.
|
|
133
|
+
*/
|
|
134
|
+
declare function handleToolCall<P extends string>(event: GateToolCall, ctx: GateContext, net: SkillNet<P>, state: GateState<P>): Promise<GateDecision>;
|
|
135
|
+
/**
|
|
136
|
+
* Handle a tool_result event. Fires deferred transitions on success.
|
|
137
|
+
* Returns void (tool_result handler doesn't block).
|
|
138
|
+
*/
|
|
139
|
+
declare function handleToolResult<P extends string>(event: GateToolResult, net: SkillNet<P>, state: GateState<P>): void;
|
|
140
|
+
|
|
141
|
+
/** Classification of a net's opinion on a tool call */
|
|
142
|
+
type NetVerdict<P extends string> = {
|
|
143
|
+
net: SkillNet<P>;
|
|
144
|
+
state: GateState<P>;
|
|
145
|
+
resolvedTool: string;
|
|
146
|
+
} & ({
|
|
147
|
+
kind: "free";
|
|
148
|
+
} | {
|
|
149
|
+
kind: "abstain";
|
|
150
|
+
} | {
|
|
151
|
+
kind: "blocked";
|
|
152
|
+
reason: string;
|
|
153
|
+
} | {
|
|
154
|
+
kind: "gated";
|
|
155
|
+
transition: SkillNet<P>["transitions"][number];
|
|
156
|
+
});
|
|
157
|
+
/** Registry-based config for dynamic net management */
|
|
158
|
+
type ComposeConfig = {
|
|
159
|
+
registry: Record<string, SkillNet<string>>;
|
|
160
|
+
active?: string[];
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* Phase 1 — Structural check (non-mutating).
|
|
164
|
+
* Classify each net as free, gated, blocked, or abstain.
|
|
165
|
+
*/
|
|
166
|
+
declare function classifyNets<P extends string>(nets: SkillNet<P>[], states: GateState<P>[], event: {
|
|
167
|
+
toolName: string;
|
|
168
|
+
input: Record<string, unknown>;
|
|
169
|
+
}): NetVerdict<P>[];
|
|
170
|
+
/**
|
|
171
|
+
* 4-phase tool call handler for composed nets.
|
|
172
|
+
*/
|
|
173
|
+
declare function composedToolCall(getNets: () => SkillNet<string>[], getStates: () => GateState<string>[], event: GateToolCall, ctx: GateContext): Promise<GateDecision>;
|
|
174
|
+
|
|
175
|
+
type GateManager = {
|
|
176
|
+
handleToolCall: (event: GateToolCall, ctx: GateContext) => Promise<GateDecision>;
|
|
177
|
+
handleToolResult: (event: GateToolResult) => void;
|
|
178
|
+
addNet: (name: string) => {
|
|
179
|
+
ok: boolean;
|
|
180
|
+
message: string;
|
|
181
|
+
};
|
|
182
|
+
removeNet: (name: string) => {
|
|
183
|
+
ok: boolean;
|
|
184
|
+
message: string;
|
|
185
|
+
};
|
|
186
|
+
getActiveNets: () => Array<{
|
|
187
|
+
name: string;
|
|
188
|
+
net: SkillNet<string>;
|
|
189
|
+
state: GateState<string>;
|
|
190
|
+
}>;
|
|
191
|
+
getAllNets: () => Array<{
|
|
192
|
+
name: string;
|
|
193
|
+
net: SkillNet<string>;
|
|
194
|
+
state: GateState<string>;
|
|
195
|
+
active: boolean;
|
|
196
|
+
}>;
|
|
197
|
+
formatStatus: () => string;
|
|
198
|
+
formatSystemPrompt: () => string;
|
|
199
|
+
isDynamic: boolean;
|
|
200
|
+
};
|
|
201
|
+
type GateManagerOptions = {
|
|
202
|
+
/** "enforce" blocks disallowed tools. "shadow" logs but never blocks. */
|
|
203
|
+
mode: "enforce" | "shadow";
|
|
204
|
+
/** Called after every gating decision. Use for logging, metrics, debugging. */
|
|
205
|
+
onDecision?: (event: GateToolCall, decision: GateDecision) => void;
|
|
206
|
+
};
|
|
207
|
+
declare function createGateManager(input: SkillNet<string>[] | ComposeConfig, opts?: GateManagerOptions): GateManager;
|
|
208
|
+
|
|
209
|
+
export { type ComposeConfig, type GateContext, type GateDecision, type GateManager, type GateManagerOptions, type GateState, type GateToolCall, type GateToolResult, type GatedTransition, type NetVerdict, type SkillNet, type ToolEvent, autoAdvance, classifyNets, composedToolCall, createGateManager, createGateState, defineSkillNet, formatMarking, getEnabledToolTransitions, handleToolCall, handleToolResult, resolveTool };
|