@intutic/gate 1.10.1 → 2.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/README.md +18 -10
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +2 -0
- package/dist/actions.js.map +1 -1
- package/dist/dsh.d.ts +27 -2
- package/dist/dsh.d.ts.map +1 -1
- package/dist/dsh.js +23 -1
- package/dist/dsh.js.map +1 -1
- package/dist/eve.d.ts +81 -14
- package/dist/eve.d.ts.map +1 -1
- package/dist/eve.js +93 -10
- package/dist/eve.js.map +1 -1
- package/dist/gate.d.ts +1 -3
- package/dist/gate.d.ts.map +1 -1
- package/dist/gate.js +3 -9
- package/dist/gate.js.map +1 -1
- package/dist/harness.d.ts +86 -31
- package/dist/harness.d.ts.map +1 -1
- package/dist/harness.js +103 -28
- package/dist/harness.js.map +1 -1
- package/dist/managedAgents.d.ts +35 -6
- package/dist/managedAgents.d.ts.map +1 -1
- package/dist/managedAgents.js +26 -6
- package/dist/managedAgents.js.map +1 -1
- package/dist/mastra.d.ts +5 -2
- package/dist/mastra.d.ts.map +1 -1
- package/dist/mastra.js +3 -1
- package/dist/mastra.js.map +1 -1
- package/dist/openai.d.ts +5 -3
- package/dist/openai.d.ts.map +1 -1
- package/dist/openai.js +5 -3
- package/dist/openai.js.map +1 -1
- package/dist/registry.d.ts +18 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +24 -0
- package/dist/registry.js.map +1 -0
- package/dist/vercel.d.ts +3 -3
- package/dist/vercel.d.ts.map +1 -1
- package/dist/vercel.js +1 -1
- package/dist/vercel.js.map +1 -1
- package/dist/workflow.d.ts +153 -39
- package/dist/workflow.d.ts.map +1 -1
- package/dist/workflow.js +162 -49
- package/dist/workflow.js.map +1 -1
- package/dist/wrapTools.d.ts +1 -1
- package/dist/wrapTools.d.ts.map +1 -1
- package/dist/wrapTools.js +1 -1
- package/dist/wrapTools.js.map +1 -1
- package/package.json +11 -10
package/dist/workflow.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `@ai-sdk/workflow` adapter: `
|
|
3
|
-
* `wrapWorkflowTools()`, and the FatalError-compatible
|
|
2
|
+
* `@ai-sdk/workflow` adapter: `withIntuticApproval()`, `intuticNeedsApproval()`,
|
|
3
|
+
* `intuticApprovalStep()`, `wrapWorkflowTools()`, and the FatalError-compatible
|
|
4
|
+
* `IntuticWorkflowRefusal`.
|
|
4
5
|
*
|
|
5
6
|
* `@intutic/gate/workflow` — the same idea `vercel.ts` implements for the base
|
|
6
7
|
* `ai` package (wrap the framework's own veto point around this package's
|
|
@@ -9,10 +10,11 @@
|
|
|
9
10
|
*
|
|
10
11
|
* ## 1. The veto surface is per-tool `needsApproval`, not an agent option
|
|
11
12
|
*
|
|
12
|
-
* Confirmed against a real install (`@ai-sdk/workflow@1.0.69
|
|
13
|
-
* `WorkflowAgent`/`WorkflowAgentOptions` carry
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* Confirmed against a real install (`@ai-sdk/workflow@1.0.69`, re-read on
|
|
14
|
+
* 2.0.58): `WorkflowAgent`/`WorkflowAgentOptions` carry NO approval-policy
|
|
15
|
+
* field — 1.x's shipped `.d.ts` never mentions `toolApproval`, and 2.x adds
|
|
16
|
+
* only `experimental_toolApprovalSecret`, an HMAC secret that signs approval
|
|
17
|
+
* requests so a replayed approval can be verified, not a veto. The veto surface is `needsApproval` (boolean | function) on the
|
|
16
18
|
* TOOL definition, exactly as the framework's own workflow-agent docs
|
|
17
19
|
* describe under "Tool Approval". The compiled agent loop confirms the
|
|
18
20
|
* semantics (dist/index.js): `needsApproval == null` → no approval; a
|
|
@@ -22,9 +24,9 @@
|
|
|
22
24
|
* later — so this framework, uniquely in this package, has a real
|
|
23
25
|
* human-in-the-loop lane for the gate to route into.
|
|
24
26
|
*
|
|
25
|
-
* (`ai@7.0.
|
|
26
|
-
* generateText-level `toolApproval` — but `@ai-sdk/workflow`'s
|
|
27
|
-
* reads the tool-level field and exposes no other veto surface, so it is the
|
|
27
|
+
* (`ai@7` — still in 7.0.127 — marks tool-level `needsApproval` `@deprecated`
|
|
28
|
+
* in favour of generateText-level `toolApproval` — but `@ai-sdk/workflow`'s
|
|
29
|
+
* OWN agent loop (1.x and 2.0.58 alike) reads the tool-level field and exposes no other veto surface, so it is the
|
|
28
30
|
* correct — indeed the only — integration point here. Noted in the TD entry
|
|
29
31
|
* this phase filed, so a future @ai-sdk/workflow release moving to the
|
|
30
32
|
* generateText-shaped surface gets caught rather than silently ungated.)
|
|
@@ -33,11 +35,13 @@
|
|
|
33
35
|
*
|
|
34
36
|
* A durable workflow retries failed steps. Confirmed against real installs
|
|
35
37
|
* (`workflow@4.8.3` re-exporting `@workflow/errors@4.2.1` via
|
|
36
|
-
* `@workflow/core
|
|
37
|
-
* `FatalError.is(err)`
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
38
|
+
* `@workflow/core`; re-read on `workflow@5.0.1` / `@workflow/errors@5.0.1`):
|
|
39
|
+
* the runtime's retry/abort decision consults `FatalError.is(err)`
|
|
40
|
+
* (`@workflow/core`'s `runtime/step-handler.js` in 4.x,
|
|
41
|
+
* `runtime/step-executor.js` in 5.x — a fatal error "bubbl[es] up to parent
|
|
42
|
+
* workflow"; anything else is retried toward `maxAttempts`), and
|
|
43
|
+
* `FatalError.is()` DUCK-TYPES: it checks `err.name === 'FatalError'` (5.x
|
|
44
|
+
* also accepts `err.fatal === true`) on any Error-shaped object, precisely because
|
|
41
45
|
* workflows execute in a separate `vm` realm where `instanceof` fails across
|
|
42
46
|
* the boundary. A plain `IntuticGateRefusal` thrown from `needsApproval` or a
|
|
43
47
|
* tool body would therefore be RETRIED — a governance denial replayed on a
|
|
@@ -56,9 +60,44 @@
|
|
|
56
60
|
* "no gate configured" case, which is deterministic and would fail every
|
|
57
61
|
* retry identically) is made fatal.
|
|
58
62
|
*
|
|
63
|
+
* ## 3. `needsApproval` runs in the workflow VM — the gate must run in a step
|
|
64
|
+
*
|
|
65
|
+
* Observed in a live run on the Workflow DevKit's local world (TD-498):
|
|
66
|
+
* `WorkflowAgent`'s loop runs inside the `"use workflow"` function, so it
|
|
67
|
+
* calls `needsApproval` in the workflow VM, which has no Node.js modules.
|
|
68
|
+
* `Gate` reads its policy snapshot with `node:fs`, so evaluating it there
|
|
69
|
+
* fails with `require is not defined` — and when the workflow bundle pulls
|
|
70
|
+
* `node:fs` in at module level, EVERY workflow sharing that bundle fails at
|
|
71
|
+
* load (observed with `workflow/nitro`).
|
|
72
|
+
*
|
|
73
|
+
* So the gate runs in a STEP, which has full Node.js and is durable. The
|
|
74
|
+
* caller declares one `"use step"` function in their own module — the
|
|
75
|
+
* directive must sit in a module the workflow bundler transforms, and the
|
|
76
|
+
* step's body must build/receive the `Gate` itself, because step arguments
|
|
77
|
+
* are serialized and a `Gate` instance is not serializable — whose body is
|
|
78
|
+
* {@link intuticApprovalStep}, and passes it as `{ step }`:
|
|
79
|
+
*
|
|
80
|
+
* ```ts
|
|
81
|
+
* export async function intuticGate(toolName: string, input: unknown) {
|
|
82
|
+
* 'use step'
|
|
83
|
+
* return intuticApprovalStep(toolName, input, { gate: new Gate({ ... }) })
|
|
84
|
+
* }
|
|
85
|
+
* // in the workflow: tools: withIntuticApproval(tools, { step: intuticGate })
|
|
86
|
+
* ```
|
|
87
|
+
*
|
|
88
|
+
* With `{ step }`, the `needsApproval` this module builds only calls the step
|
|
89
|
+
* (a durable step invocation from the VM's point of view) and maps its
|
|
90
|
+
* boolean; nothing Node-only runs in the VM. This module itself is safe to
|
|
91
|
+
* import into workflow code: it imports nothing that touches Node.js
|
|
92
|
+
* (`errors.ts`, `registry.ts`, `wrapTools.ts`; `Gate` is a type-only
|
|
93
|
+
* import). Without `{ step }`, the gate is evaluated in-process, which still
|
|
94
|
+
* works wherever Node.js is available (inside a step, or any plain `ai`
|
|
95
|
+
* loop); called in the workflow VM it throws an {@link IntuticWorkflowRefusal}
|
|
96
|
+
* naming this fix instead of failing with `require is not defined`.
|
|
97
|
+
*
|
|
59
98
|
* @module
|
|
60
99
|
*/
|
|
61
|
-
import {
|
|
100
|
+
import type { Gate } from './gate.js';
|
|
62
101
|
import { IntuticGateRefusal } from './errors.js';
|
|
63
102
|
import { type AnyFn, type ExecutableTool } from './wrapTools.js';
|
|
64
103
|
/**
|
|
@@ -99,9 +138,15 @@ export interface WorkflowNeedsApprovalOptions {
|
|
|
99
138
|
* `ai`'s tool-level `needsApproval` (the surface `@ai-sdk/workflow`'s agent
|
|
100
139
|
* loop actually consults). */
|
|
101
140
|
export type WorkflowNeedsApproval = (input: unknown, options: WorkflowNeedsApprovalOptions) => Promise<boolean>;
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
141
|
+
/**
|
|
142
|
+
* The `"use step"` function the caller declares to run the gate (see module
|
|
143
|
+
* doc, section 3): called with the tool name and the call's input — both
|
|
144
|
+
* serializable — it resolves `true` when a human should approve the call and
|
|
145
|
+
* throws {@link IntuticWorkflowRefusal} when the gate blocks it. Its body is
|
|
146
|
+
* {@link intuticApprovalStep}.
|
|
147
|
+
*/
|
|
148
|
+
export type IntuticGateStep = (toolName: string, input: unknown) => Promise<boolean>;
|
|
149
|
+
interface OnAllowOption {
|
|
105
150
|
/**
|
|
106
151
|
* What an ALLOWED call maps to. `needsApproval` answers "does a human need
|
|
107
152
|
* to approve this?", which is a different question from "may this run?" —
|
|
@@ -119,30 +164,74 @@ export interface IntuticNeedsApprovalOptions {
|
|
|
119
164
|
* the decision to a human approver as though the gate had no verdict, and
|
|
120
165
|
* returning `false` would RUN the tool — the one thing a block must never
|
|
121
166
|
* do.
|
|
167
|
+
*
|
|
168
|
+
* With `{ step }`, `'human'` here and the step's own answer are OR-ed:
|
|
169
|
+
* either one asking for a human is enough.
|
|
122
170
|
*/
|
|
123
171
|
onAllow?: 'auto' | 'human';
|
|
124
172
|
}
|
|
173
|
+
export type IntuticNeedsApprovalOptions = (OnAllowOption & {
|
|
174
|
+
/**
|
|
175
|
+
* Evaluate the gate in this `"use step"` function — required when the
|
|
176
|
+
* `needsApproval` runs in the workflow VM, i.e. on a `WorkflowAgent`
|
|
177
|
+
* (see module doc, section 3). The step builds or receives its own
|
|
178
|
+
* `Gate`; a `gate` cannot be passed here, since the VM cannot hold one.
|
|
179
|
+
*/
|
|
180
|
+
step: IntuticGateStep;
|
|
181
|
+
gate?: never;
|
|
182
|
+
}) | (OnAllowOption & {
|
|
183
|
+
/** Evaluate in-process, Node.js only. Overrides the process-wide
|
|
184
|
+
* installed gate (`install(new Gate(...))`). */
|
|
185
|
+
gate?: Gate;
|
|
186
|
+
step?: undefined;
|
|
187
|
+
});
|
|
188
|
+
/** Options for {@link intuticApprovalStep} — the in-process evaluation, so no
|
|
189
|
+
* `step`. */
|
|
190
|
+
export type IntuticApprovalStepOptions = OnAllowOption & {
|
|
191
|
+
gate?: Gate;
|
|
192
|
+
};
|
|
125
193
|
/**
|
|
126
|
-
*
|
|
194
|
+
* The gate evaluation for ONE call, written to be the body of the caller's
|
|
195
|
+
* `"use step"` function (see module doc, section 3):
|
|
127
196
|
*
|
|
128
197
|
* ```ts
|
|
129
|
-
*
|
|
130
|
-
* import { Gate
|
|
131
|
-
* import {
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
* }
|
|
198
|
+
* // workflows/intutic-gate.ts
|
|
199
|
+
* import { Gate } from '@intutic/gate'
|
|
200
|
+
* import { intuticApprovalStep } from '@intutic/gate/workflow'
|
|
201
|
+
*
|
|
202
|
+
* export async function intuticGate(toolName: string, input: unknown): Promise<boolean> {
|
|
203
|
+
* 'use step'
|
|
204
|
+
* return intuticApprovalStep(toolName, input, {
|
|
205
|
+
* gate: new Gate({ workspaceId: process.env.INTUTIC_WORKSPACE_ID }),
|
|
206
|
+
* })
|
|
207
|
+
* }
|
|
208
|
+
* ```
|
|
209
|
+
*
|
|
210
|
+
* Reference `@intutic/gate` only inside step bodies in that module: the
|
|
211
|
+
* workflow bundler also bundles it into the VM with the step bodies
|
|
212
|
+
* replaced, and a module-level use would keep the Node-only gate there.
|
|
213
|
+
*
|
|
214
|
+
* Verdict mapping: BLOCK → throws {@link IntuticWorkflowRefusal} (fatal — the
|
|
215
|
+
* step runs once and the run fails instead of retry-looping; see module doc);
|
|
216
|
+
* ALLOW → `false`, or `true` with `onAllow: 'human'`. A non-refusal crash in
|
|
217
|
+
* the gate is re-thrown untouched (the step retries — correct for
|
|
218
|
+
* transients). Requires a gate (`{ gate }` or `install()` in the process
|
|
219
|
+
* that runs steps); called in the workflow VM itself, it throws naming the
|
|
220
|
+
* fix.
|
|
221
|
+
*/
|
|
222
|
+
export declare function intuticApprovalStep(toolName: string, input: unknown, opts?: IntuticApprovalStepOptions): Promise<boolean>;
|
|
223
|
+
/**
|
|
224
|
+
* Build an async `needsApproval` function for ONE workflow tool. On a
|
|
225
|
+
* `WorkflowAgent`, pass the caller's gate step (see
|
|
226
|
+
* {@link intuticApprovalStep}):
|
|
227
|
+
*
|
|
228
|
+
* ```ts
|
|
229
|
+
* deployService: {
|
|
230
|
+
* description: '...',
|
|
231
|
+
* inputSchema,
|
|
232
|
+
* execute: deployStep,
|
|
233
|
+
* needsApproval: intuticNeedsApproval('deployService', { step: intuticGate }),
|
|
234
|
+
* },
|
|
146
235
|
* ```
|
|
147
236
|
*
|
|
148
237
|
* The tool name is a parameter because the framework's `needsApproval`
|
|
@@ -151,6 +240,12 @@ export interface IntuticNeedsApprovalOptions {
|
|
|
151
240
|
* {@link withIntuticApproval} to attach this to a whole tools record without
|
|
152
241
|
* hand-repeating each name.
|
|
153
242
|
*
|
|
243
|
+
* With `{ step }`, the returned function only calls the step and maps its
|
|
244
|
+
* answer — safe in the workflow VM. Without it, the gate is evaluated
|
|
245
|
+
* in-process (`{ gate }` or the installed gate), which needs Node.js: fine in
|
|
246
|
+
* a plain `ai` loop or inside a step, and in the workflow VM it throws an
|
|
247
|
+
* {@link IntuticWorkflowRefusal} naming the `{ step }` fix.
|
|
248
|
+
*
|
|
154
249
|
* Verdict mapping: BLOCK → throws {@link IntuticWorkflowRefusal} (fatal —
|
|
155
250
|
* aborts instead of retry-looping; see module doc); ALLOW → `false` or `true`
|
|
156
251
|
* per `onAllow`. A non-refusal crash in the gate is re-thrown untouched
|
|
@@ -169,13 +264,29 @@ export interface WorkflowToolLike {
|
|
|
169
264
|
* `needsApproval` the tool already declares:
|
|
170
265
|
*
|
|
171
266
|
* ```ts
|
|
172
|
-
*
|
|
267
|
+
* import { WorkflowAgent } from '@ai-sdk/workflow'
|
|
268
|
+
* import { withIntuticApproval } from '@intutic/gate/workflow'
|
|
269
|
+
* import { intuticGate } from './intutic-gate' // the "use step" function
|
|
270
|
+
*
|
|
271
|
+
* export async function deployAgent(messages: ModelMessage[]) {
|
|
272
|
+
* 'use workflow'
|
|
273
|
+
* const agent = new WorkflowAgent({
|
|
274
|
+
* model,
|
|
275
|
+
* tools: withIntuticApproval(tools, { step: intuticGate }),
|
|
276
|
+
* })
|
|
277
|
+
* // ...
|
|
278
|
+
* }
|
|
173
279
|
* ```
|
|
174
280
|
*
|
|
281
|
+
* (`{ step }` is what makes this work on a `WorkflowAgent`, whose
|
|
282
|
+
* `needsApproval` runs in the workflow VM — see {@link intuticApprovalStep}
|
|
283
|
+
* and the module doc, section 3. Without it the gate is evaluated
|
|
284
|
+
* in-process, which needs Node.js.)
|
|
285
|
+
*
|
|
175
286
|
* For each tool (the record KEY is the tool name reported to the gate — the
|
|
176
287
|
* same identity the framework itself dispatches on):
|
|
177
288
|
*
|
|
178
|
-
* 1.
|
|
289
|
+
* 1. The gate runs first. BLOCK throws {@link IntuticWorkflowRefusal}.
|
|
179
290
|
* 2. On allow, the tool's OWN prior `needsApproval` still applies: a
|
|
180
291
|
* boolean is returned as-is; a function is awaited with the original
|
|
181
292
|
* arguments; a tool with none falls back to `onAllow` ('auto' → false).
|
|
@@ -198,7 +309,9 @@ export declare function withIntuticApproval<T extends Record<string, WorkflowToo
|
|
|
198
309
|
* "no gate configured" handling and the record-key-is-tool-name convention —
|
|
199
310
|
* is `wrapTools`'s own behaviour, reused rather than reimplemented.
|
|
200
311
|
*
|
|
201
|
-
*
|
|
312
|
+
* Call it inside the tool's `"use step"` body (it evaluates the gate
|
|
313
|
+
* in-process, so it needs Node.js). Prefer {@link withIntuticApproval} as the
|
|
314
|
+
* primary integration: it uses the
|
|
202
315
|
* framework's own pre-execution veto surface, refuses BEFORE the durable
|
|
203
316
|
* step ever starts, and keeps the human-approval lane available. This
|
|
204
317
|
* execute-level wrapper is defense in depth (or the option for callers whose
|
|
@@ -206,4 +319,5 @@ export declare function withIntuticApproval<T extends Record<string, WorkflowToo
|
|
|
206
319
|
* the call, which is harmless but emits duplicate gate telemetry.
|
|
207
320
|
*/
|
|
208
321
|
export declare function wrapWorkflowTools<T extends AnyFn | ExecutableTool>(tools: Record<string, T>, gate?: Gate): Record<string, T>;
|
|
322
|
+
export {};
|
|
209
323
|
//# sourceMappingURL=workflow.d.ts.map
|
package/dist/workflow.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../src/workflow.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../src/workflow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkGG;AAKH,OAAO,KAAK,EAAE,IAAI,EAAa,MAAM,WAAW,CAAA;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAEhD,OAAO,E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,IAAI,CAAC,EAAE,IAAI,CAAA;CAAE,CAAA;AAiDxE;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,OAAO,EACd,IAAI,GAAE,0BAA+B,GACpC,OAAO,CAAC,OAAO,CAAC,CAYlB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,MAAM,EAChB,IAAI,GAAE,2BAAgC,GACrC,qBAAqB,CAYvB;AAED;;mDAEmD;AACnD,MAAM,WAAW,gBAAgB;IAC/B,aAAa,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,KAAK,OAAO,CAAC,CAAA;IACrE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,EAC5E,KAAK,EAAE,CAAC,EACR,IAAI,GAAE,2BAAgC,GACrC,CAAC,CAiBH;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,KAAK,GAAG,cAAc,EAChE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,EACxB,IAAI,CAAC,EAAE,IAAI,GACV,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAWnB"}
|
package/dist/workflow.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `@ai-sdk/workflow` adapter: `
|
|
3
|
-
* `wrapWorkflowTools()`, and the FatalError-compatible
|
|
2
|
+
* `@ai-sdk/workflow` adapter: `withIntuticApproval()`, `intuticNeedsApproval()`,
|
|
3
|
+
* `intuticApprovalStep()`, `wrapWorkflowTools()`, and the FatalError-compatible
|
|
4
|
+
* `IntuticWorkflowRefusal`.
|
|
4
5
|
*
|
|
5
6
|
* `@intutic/gate/workflow` — the same idea `vercel.ts` implements for the base
|
|
6
7
|
* `ai` package (wrap the framework's own veto point around this package's
|
|
@@ -9,10 +10,11 @@
|
|
|
9
10
|
*
|
|
10
11
|
* ## 1. The veto surface is per-tool `needsApproval`, not an agent option
|
|
11
12
|
*
|
|
12
|
-
* Confirmed against a real install (`@ai-sdk/workflow@1.0.69
|
|
13
|
-
* `WorkflowAgent`/`WorkflowAgentOptions` carry
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* Confirmed against a real install (`@ai-sdk/workflow@1.0.69`, re-read on
|
|
14
|
+
* 2.0.58): `WorkflowAgent`/`WorkflowAgentOptions` carry NO approval-policy
|
|
15
|
+
* field — 1.x's shipped `.d.ts` never mentions `toolApproval`, and 2.x adds
|
|
16
|
+
* only `experimental_toolApprovalSecret`, an HMAC secret that signs approval
|
|
17
|
+
* requests so a replayed approval can be verified, not a veto. The veto surface is `needsApproval` (boolean | function) on the
|
|
16
18
|
* TOOL definition, exactly as the framework's own workflow-agent docs
|
|
17
19
|
* describe under "Tool Approval". The compiled agent loop confirms the
|
|
18
20
|
* semantics (dist/index.js): `needsApproval == null` → no approval; a
|
|
@@ -22,9 +24,9 @@
|
|
|
22
24
|
* later — so this framework, uniquely in this package, has a real
|
|
23
25
|
* human-in-the-loop lane for the gate to route into.
|
|
24
26
|
*
|
|
25
|
-
* (`ai@7.0.
|
|
26
|
-
* generateText-level `toolApproval` — but `@ai-sdk/workflow`'s
|
|
27
|
-
* reads the tool-level field and exposes no other veto surface, so it is the
|
|
27
|
+
* (`ai@7` — still in 7.0.127 — marks tool-level `needsApproval` `@deprecated`
|
|
28
|
+
* in favour of generateText-level `toolApproval` — but `@ai-sdk/workflow`'s
|
|
29
|
+
* OWN agent loop (1.x and 2.0.58 alike) reads the tool-level field and exposes no other veto surface, so it is the
|
|
28
30
|
* correct — indeed the only — integration point here. Noted in the TD entry
|
|
29
31
|
* this phase filed, so a future @ai-sdk/workflow release moving to the
|
|
30
32
|
* generateText-shaped surface gets caught rather than silently ungated.)
|
|
@@ -33,11 +35,13 @@
|
|
|
33
35
|
*
|
|
34
36
|
* A durable workflow retries failed steps. Confirmed against real installs
|
|
35
37
|
* (`workflow@4.8.3` re-exporting `@workflow/errors@4.2.1` via
|
|
36
|
-
* `@workflow/core
|
|
37
|
-
* `FatalError.is(err)`
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
38
|
+
* `@workflow/core`; re-read on `workflow@5.0.1` / `@workflow/errors@5.0.1`):
|
|
39
|
+
* the runtime's retry/abort decision consults `FatalError.is(err)`
|
|
40
|
+
* (`@workflow/core`'s `runtime/step-handler.js` in 4.x,
|
|
41
|
+
* `runtime/step-executor.js` in 5.x — a fatal error "bubbl[es] up to parent
|
|
42
|
+
* workflow"; anything else is retried toward `maxAttempts`), and
|
|
43
|
+
* `FatalError.is()` DUCK-TYPES: it checks `err.name === 'FatalError'` (5.x
|
|
44
|
+
* also accepts `err.fatal === true`) on any Error-shaped object, precisely because
|
|
41
45
|
* workflows execute in a separate `vm` realm where `instanceof` fails across
|
|
42
46
|
* the boundary. A plain `IntuticGateRefusal` thrown from `needsApproval` or a
|
|
43
47
|
* tool body would therefore be RETRIED — a governance denial replayed on a
|
|
@@ -56,10 +60,45 @@
|
|
|
56
60
|
* "no gate configured" case, which is deterministic and would fail every
|
|
57
61
|
* retry identically) is made fatal.
|
|
58
62
|
*
|
|
63
|
+
* ## 3. `needsApproval` runs in the workflow VM — the gate must run in a step
|
|
64
|
+
*
|
|
65
|
+
* Observed in a live run on the Workflow DevKit's local world (TD-498):
|
|
66
|
+
* `WorkflowAgent`'s loop runs inside the `"use workflow"` function, so it
|
|
67
|
+
* calls `needsApproval` in the workflow VM, which has no Node.js modules.
|
|
68
|
+
* `Gate` reads its policy snapshot with `node:fs`, so evaluating it there
|
|
69
|
+
* fails with `require is not defined` — and when the workflow bundle pulls
|
|
70
|
+
* `node:fs` in at module level, EVERY workflow sharing that bundle fails at
|
|
71
|
+
* load (observed with `workflow/nitro`).
|
|
72
|
+
*
|
|
73
|
+
* So the gate runs in a STEP, which has full Node.js and is durable. The
|
|
74
|
+
* caller declares one `"use step"` function in their own module — the
|
|
75
|
+
* directive must sit in a module the workflow bundler transforms, and the
|
|
76
|
+
* step's body must build/receive the `Gate` itself, because step arguments
|
|
77
|
+
* are serialized and a `Gate` instance is not serializable — whose body is
|
|
78
|
+
* {@link intuticApprovalStep}, and passes it as `{ step }`:
|
|
79
|
+
*
|
|
80
|
+
* ```ts
|
|
81
|
+
* export async function intuticGate(toolName: string, input: unknown) {
|
|
82
|
+
* 'use step'
|
|
83
|
+
* return intuticApprovalStep(toolName, input, { gate: new Gate({ ... }) })
|
|
84
|
+
* }
|
|
85
|
+
* // in the workflow: tools: withIntuticApproval(tools, { step: intuticGate })
|
|
86
|
+
* ```
|
|
87
|
+
*
|
|
88
|
+
* With `{ step }`, the `needsApproval` this module builds only calls the step
|
|
89
|
+
* (a durable step invocation from the VM's point of view) and maps its
|
|
90
|
+
* boolean; nothing Node-only runs in the VM. This module itself is safe to
|
|
91
|
+
* import into workflow code: it imports nothing that touches Node.js
|
|
92
|
+
* (`errors.ts`, `registry.ts`, `wrapTools.ts`; `Gate` is a type-only
|
|
93
|
+
* import). Without `{ step }`, the gate is evaluated in-process, which still
|
|
94
|
+
* works wherever Node.js is available (inside a step, or any plain `ai`
|
|
95
|
+
* loop); called in the workflow VM it throws an {@link IntuticWorkflowRefusal}
|
|
96
|
+
* naming this fix instead of failing with `require is not defined`.
|
|
97
|
+
*
|
|
59
98
|
* @module
|
|
60
99
|
*/
|
|
61
|
-
import { active as activeGate } from './gate.js';
|
|
62
100
|
import { IntuticGateRefusal } from './errors.js';
|
|
101
|
+
import { active as activeGate } from './registry.js';
|
|
63
102
|
import { wrapTools } from './wrapTools.js';
|
|
64
103
|
/**
|
|
65
104
|
* A refused call inside a durable workflow.
|
|
@@ -97,6 +136,25 @@ export class IntuticWorkflowRefusal extends IntuticGateRefusal {
|
|
|
97
136
|
(value.message.startsWith('[Intutic Governance] BLOCKED:')));
|
|
98
137
|
}
|
|
99
138
|
}
|
|
139
|
+
// Set on the workflow VM's global object by the Workflow DevKit runtime
|
|
140
|
+
// (`@workflow/core`'s `workflow.js`: `vmGlobalThis[WORKFLOW_USE_STEP] =
|
|
141
|
+
// useStep`); never set in the Node.js realm where steps execute.
|
|
142
|
+
const WORKFLOW_USE_STEP = Symbol.for('WORKFLOW_USE_STEP');
|
|
143
|
+
function inWorkflowSandbox() {
|
|
144
|
+
return typeof globalThis[WORKFLOW_USE_STEP] === 'function';
|
|
145
|
+
}
|
|
146
|
+
function refuseInWorkflowSandbox(helper) {
|
|
147
|
+
if (!inWorkflowSandbox())
|
|
148
|
+
return;
|
|
149
|
+
// Fail closed, FatalError-shaped, and NAME THE FIX: the gate needs
|
|
150
|
+
// Node.js, which the workflow VM does not have, and retrying cannot
|
|
151
|
+
// change that.
|
|
152
|
+
throw new IntuticWorkflowRefusal(`${helper} ran inside the workflow sandbox, which has no Node.js, so the gate cannot evaluate ` +
|
|
153
|
+
'the call there. Run it in a "use step" function: declare ' +
|
|
154
|
+
"`async function intuticGate(toolName, input) { 'use step'; return intuticApprovalStep(toolName, input, { gate }) }` " +
|
|
155
|
+
'and pass { step: intuticGate } to withIntuticApproval()/intuticNeedsApproval(). ' +
|
|
156
|
+
'Refusing to run the tool unguarded.', 'WORKFLOW_SANDBOX');
|
|
157
|
+
}
|
|
100
158
|
function requireGate(gate, helper) {
|
|
101
159
|
const g = gate ?? activeGate();
|
|
102
160
|
if (g === null) {
|
|
@@ -116,26 +174,60 @@ function renderWorkflowToolInput(input) {
|
|
|
116
174
|
return { args: [input] };
|
|
117
175
|
}
|
|
118
176
|
/**
|
|
119
|
-
*
|
|
177
|
+
* The gate evaluation for ONE call, written to be the body of the caller's
|
|
178
|
+
* `"use step"` function (see module doc, section 3):
|
|
120
179
|
*
|
|
121
180
|
* ```ts
|
|
122
|
-
*
|
|
123
|
-
* import { Gate
|
|
124
|
-
* import {
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
* }
|
|
181
|
+
* // workflows/intutic-gate.ts
|
|
182
|
+
* import { Gate } from '@intutic/gate'
|
|
183
|
+
* import { intuticApprovalStep } from '@intutic/gate/workflow'
|
|
184
|
+
*
|
|
185
|
+
* export async function intuticGate(toolName: string, input: unknown): Promise<boolean> {
|
|
186
|
+
* 'use step'
|
|
187
|
+
* return intuticApprovalStep(toolName, input, {
|
|
188
|
+
* gate: new Gate({ workspaceId: process.env.INTUTIC_WORKSPACE_ID }),
|
|
189
|
+
* })
|
|
190
|
+
* }
|
|
191
|
+
* ```
|
|
192
|
+
*
|
|
193
|
+
* Reference `@intutic/gate` only inside step bodies in that module: the
|
|
194
|
+
* workflow bundler also bundles it into the VM with the step bodies
|
|
195
|
+
* replaced, and a module-level use would keep the Node-only gate there.
|
|
196
|
+
*
|
|
197
|
+
* Verdict mapping: BLOCK → throws {@link IntuticWorkflowRefusal} (fatal — the
|
|
198
|
+
* step runs once and the run fails instead of retry-looping; see module doc);
|
|
199
|
+
* ALLOW → `false`, or `true` with `onAllow: 'human'`. A non-refusal crash in
|
|
200
|
+
* the gate is re-thrown untouched (the step retries — correct for
|
|
201
|
+
* transients). Requires a gate (`{ gate }` or `install()` in the process
|
|
202
|
+
* that runs steps); called in the workflow VM itself, it throws naming the
|
|
203
|
+
* fix.
|
|
204
|
+
*/
|
|
205
|
+
export async function intuticApprovalStep(toolName, input, opts = {}) {
|
|
206
|
+
refuseInWorkflowSandbox('intuticApprovalStep()');
|
|
207
|
+
const g = requireGate(opts.gate, 'intuticApprovalStep()');
|
|
208
|
+
try {
|
|
209
|
+
await g.guard(toolName, renderWorkflowToolInput(input));
|
|
210
|
+
}
|
|
211
|
+
catch (exc) {
|
|
212
|
+
if (exc instanceof IntuticGateRefusal && !(exc instanceof IntuticWorkflowRefusal)) {
|
|
213
|
+
throw IntuticWorkflowRefusal.from(exc);
|
|
214
|
+
}
|
|
215
|
+
throw exc;
|
|
216
|
+
}
|
|
217
|
+
return opts.onAllow === 'human';
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Build an async `needsApproval` function for ONE workflow tool. On a
|
|
221
|
+
* `WorkflowAgent`, pass the caller's gate step (see
|
|
222
|
+
* {@link intuticApprovalStep}):
|
|
223
|
+
*
|
|
224
|
+
* ```ts
|
|
225
|
+
* deployService: {
|
|
226
|
+
* description: '...',
|
|
227
|
+
* inputSchema,
|
|
228
|
+
* execute: deployStep,
|
|
229
|
+
* needsApproval: intuticNeedsApproval('deployService', { step: intuticGate }),
|
|
230
|
+
* },
|
|
139
231
|
* ```
|
|
140
232
|
*
|
|
141
233
|
* The tool name is a parameter because the framework's `needsApproval`
|
|
@@ -144,25 +236,28 @@ function renderWorkflowToolInput(input) {
|
|
|
144
236
|
* {@link withIntuticApproval} to attach this to a whole tools record without
|
|
145
237
|
* hand-repeating each name.
|
|
146
238
|
*
|
|
239
|
+
* With `{ step }`, the returned function only calls the step and maps its
|
|
240
|
+
* answer — safe in the workflow VM. Without it, the gate is evaluated
|
|
241
|
+
* in-process (`{ gate }` or the installed gate), which needs Node.js: fine in
|
|
242
|
+
* a plain `ai` loop or inside a step, and in the workflow VM it throws an
|
|
243
|
+
* {@link IntuticWorkflowRefusal} naming the `{ step }` fix.
|
|
244
|
+
*
|
|
147
245
|
* Verdict mapping: BLOCK → throws {@link IntuticWorkflowRefusal} (fatal —
|
|
148
246
|
* aborts instead of retry-looping; see module doc); ALLOW → `false` or `true`
|
|
149
247
|
* per `onAllow`. A non-refusal crash in the gate is re-thrown untouched
|
|
150
248
|
* (retryable — correct for transients).
|
|
151
249
|
*/
|
|
152
250
|
export function intuticNeedsApproval(toolName, opts = {}) {
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
throw exc;
|
|
164
|
-
}
|
|
165
|
-
return onAllow === 'human';
|
|
251
|
+
const human = (opts.onAllow ?? 'auto') === 'human';
|
|
252
|
+
const step = opts.step;
|
|
253
|
+
if (step !== undefined) {
|
|
254
|
+
// A refusal thrown by the step reaches here already FatalError-shaped
|
|
255
|
+
// (it crossed the step boundary as one) and is rethrown untouched.
|
|
256
|
+
return async (input) => (await step(toolName, input)) || human;
|
|
257
|
+
}
|
|
258
|
+
return async (input) => {
|
|
259
|
+
refuseInWorkflowSandbox('intuticNeedsApproval()');
|
|
260
|
+
return intuticApprovalStep(toolName, input, { gate: opts.gate, onAllow: opts.onAllow });
|
|
166
261
|
};
|
|
167
262
|
}
|
|
168
263
|
/**
|
|
@@ -170,13 +265,29 @@ export function intuticNeedsApproval(toolName, opts = {}) {
|
|
|
170
265
|
* `needsApproval` the tool already declares:
|
|
171
266
|
*
|
|
172
267
|
* ```ts
|
|
173
|
-
*
|
|
268
|
+
* import { WorkflowAgent } from '@ai-sdk/workflow'
|
|
269
|
+
* import { withIntuticApproval } from '@intutic/gate/workflow'
|
|
270
|
+
* import { intuticGate } from './intutic-gate' // the "use step" function
|
|
271
|
+
*
|
|
272
|
+
* export async function deployAgent(messages: ModelMessage[]) {
|
|
273
|
+
* 'use workflow'
|
|
274
|
+
* const agent = new WorkflowAgent({
|
|
275
|
+
* model,
|
|
276
|
+
* tools: withIntuticApproval(tools, { step: intuticGate }),
|
|
277
|
+
* })
|
|
278
|
+
* // ...
|
|
279
|
+
* }
|
|
174
280
|
* ```
|
|
175
281
|
*
|
|
282
|
+
* (`{ step }` is what makes this work on a `WorkflowAgent`, whose
|
|
283
|
+
* `needsApproval` runs in the workflow VM — see {@link intuticApprovalStep}
|
|
284
|
+
* and the module doc, section 3. Without it the gate is evaluated
|
|
285
|
+
* in-process, which needs Node.js.)
|
|
286
|
+
*
|
|
176
287
|
* For each tool (the record KEY is the tool name reported to the gate — the
|
|
177
288
|
* same identity the framework itself dispatches on):
|
|
178
289
|
*
|
|
179
|
-
* 1.
|
|
290
|
+
* 1. The gate runs first. BLOCK throws {@link IntuticWorkflowRefusal}.
|
|
180
291
|
* 2. On allow, the tool's OWN prior `needsApproval` still applies: a
|
|
181
292
|
* boolean is returned as-is; a function is awaited with the original
|
|
182
293
|
* arguments; a tool with none falls back to `onAllow` ('auto' → false).
|
|
@@ -217,7 +328,9 @@ export function withIntuticApproval(tools, opts = {}) {
|
|
|
217
328
|
* "no gate configured" handling and the record-key-is-tool-name convention —
|
|
218
329
|
* is `wrapTools`'s own behaviour, reused rather than reimplemented.
|
|
219
330
|
*
|
|
220
|
-
*
|
|
331
|
+
* Call it inside the tool's `"use step"` body (it evaluates the gate
|
|
332
|
+
* in-process, so it needs Node.js). Prefer {@link withIntuticApproval} as the
|
|
333
|
+
* primary integration: it uses the
|
|
221
334
|
* framework's own pre-execution veto surface, refuses BEFORE the durable
|
|
222
335
|
* step ever starts, and keeps the human-approval lane available. This
|
|
223
336
|
* execute-level wrapper is defense in depth (or the option for callers whose
|
package/dist/workflow.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow.js","sourceRoot":"","sources":["../src/workflow.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"workflow.js","sourceRoot":"","sources":["../src/workflow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkGG;AAMH,OAAO,EAAE,kBAAkB,EAAE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W,EAAE,EAAE;QAC9B,IAAI,CAAC;YACH,OAAO,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,CAAA;QAC1B,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,GAAG,YAAY,kBAAkB,IAAI,CAAC,CAAC,GAAG,YAAY,sBAAsB,CAAC,EAAE,CAAC;gBAClF,MAAM,sBAAsB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;YACxC,CAAC;YACD,MAAM,GAAG,CAAA;QACX,CAAC;IACH,CAAC,CAAA;AACH,CAAC"}
|
package/dist/wrapTools.d.ts
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
* wrapped tool with neither throws, refusing to run the tool unguarded
|
|
29
29
|
* rather than silently skipping enforcement.
|
|
30
30
|
*/
|
|
31
|
-
import {
|
|
31
|
+
import type { Gate } from './gate.js';
|
|
32
32
|
export type AnyFn = (...args: any[]) => any;
|
|
33
33
|
export interface ExecutableTool {
|
|
34
34
|
execute: AnyFn;
|
package/dist/wrapTools.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrapTools.d.ts","sourceRoot":"","sources":["../src/wrapTools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"wrapTools.d.ts","sourceRoot":"","sources":["../src/wrapTools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAIrC,MAAM,MAAM,KAAK,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAA;AAE3C,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,KAAK,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED,MAAM,WAAW,eAAe;IAC9B;uEACmE;IACnE,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,oEAAoE;IACpE,IAAI,CAAC,EAAE,IAAI,CAAA;CACZ;AAgDD;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,KAAK,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,eAAe,GAAG,CAAC,CAAA;AAC3E,wBAAgB,QAAQ,CAAC,CAAC,SAAS,cAAc,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,eAAe,GAAG,CAAC,CAAA;AAgBtF;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,KAAK,GAAG,cAAc,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG,CAAC,EAAE,CAAA;AAClG,wBAAgB,SAAS,CAAC,CAAC,SAAS,KAAK,GAAG,cAAc,EACxD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,EACxB,IAAI,CAAC,EAAE,IAAI,GACV,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA"}
|
package/dist/wrapTools.js
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
* wrapped tool with neither throws, refusing to run the tool unguarded
|
|
29
29
|
* rather than silently skipping enforcement.
|
|
30
30
|
*/
|
|
31
|
-
import { active as activeGate } from './
|
|
31
|
+
import { active as activeGate } from './registry.js';
|
|
32
32
|
const GUARDED = Symbol.for('intutic.gate.guarded');
|
|
33
33
|
function isGuarded(fn) {
|
|
34
34
|
return fn[GUARDED] === true;
|