@alveus-ai/std 0.1.55 → 0.1.57

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.
@@ -0,0 +1,118 @@
1
+ /**
2
+ * Action Gate — proof-gated side effects.
3
+ *
4
+ * An action gate takes a proposed consequential action (`{ action, input }`),
5
+ * freezes it, scores it against pinned **scorers**, and executes it — with the
6
+ * EXACT frozen payload — only when every required criterion passes. Otherwise it
7
+ * denies, or (when a revise agent is configured) revises the payload once and
8
+ * re-scores, up to a bound.
9
+ *
10
+ * The authoritative record of a gated action is the platform-served Action
11
+ * Receipt: which pinned scorer measured which payload, the decision, and proof
12
+ * that the executed payload was byte-for-byte the one that was scored — not this
13
+ * agent's own return value (which an agent could fake).
14
+ *
15
+ * Where a goal agent attests an OUTCOME, an action gate attests an ACTION. It
16
+ * reuses the same scoring substrate (scorers, `ScorerInput`/`ScorerOutput`,
17
+ * thresholds) as the goal controller.
18
+ */
19
+ import type { ExecutionContext, ActionGateInput, ActionGateResult, VirtualAgent } from '@alveus-ai/core';
20
+ import type { NormalizedCriterion, GoalCriterionSpec } from './goal.js';
21
+ /**
22
+ * Internal input to the action-gate controller: the pinned contract (criteria
23
+ * with scorers, the execute agent, bounds) merged with the runtime proposal.
24
+ */
25
+ export interface ActionGateLogicInput extends ActionGateInput {
26
+ criteria: NormalizedCriterion[];
27
+ /** Pinned code hash of the agent that performs the side effect. */
28
+ executeHash: string;
29
+ /** Optional pinned agent that revises a failed payload from feedback. */
30
+ reviseHash?: string;
31
+ /** Configuration for the revise agent instance. */
32
+ reviseConfig?: Record<string, unknown>;
33
+ /** Maximum bounded revisions (0 = evaluate once, then allow or deny). */
34
+ maxRevisions: number;
35
+ /**
36
+ * Optional pinned postcondition criteria. When present, the gate scores them
37
+ * after the action executes, over `{ action, input, result }`, to attest the
38
+ * side effect actually took effect.
39
+ */
40
+ verifyCriteria?: NormalizedCriterion[];
41
+ }
42
+ /**
43
+ * The precompiled action-gate controller. Configured (not authored) by
44
+ * `actionGate`.
45
+ *
46
+ * It validates its own contract (so it cannot be tricked into executing for an
47
+ * empty or malformed criteria set, even when invoked directly), freezes the
48
+ * proposed payload, scores every criterion against that frozen payload via its
49
+ * pinned scorer, and executes the side effect with the **exact same frozen
50
+ * payload** only when all required criteria pass. On failure it denies, or
51
+ * revises once (when a revise agent is configured) and re-scores, up to the
52
+ * bound. It never self-attests — the platform authors the receipt.
53
+ */
54
+ export declare const ActionGateLogic: import("@alveus-ai/core").Agent<{}, ActionGateLogicInput, ExecutionContext, any>;
55
+ /** An agent reference usable as a scorer, execute, or revise agent. */
56
+ type AgentRef = {
57
+ definition: {
58
+ hash: string;
59
+ };
60
+ } | VirtualAgent | string;
61
+ /** A gating criterion with an optional per-criterion scorer and reference. */
62
+ export type ActionCriterionSpec = GoalCriterionSpec;
63
+ /** Options for {@link actionGate}. */
64
+ export interface ActionGateOptions {
65
+ /** At least one uniquely-identified gating criterion. */
66
+ criteria: ActionCriterionSpec[];
67
+ /** Default scorer for criteria that do not name their own. */
68
+ scorer?: AgentRef;
69
+ /** Default scorer configuration. */
70
+ scorerConfig?: Record<string, unknown>;
71
+ /**
72
+ * The agent that performs the side effect. It receives EXACTLY the frozen
73
+ * proposal `{ action, input }` — nothing is merged in — so the executed
74
+ * payload is provably the payload that was scored. It must therefore carry no
75
+ * `defaultInput`/config of its own.
76
+ */
77
+ execute: AgentRef;
78
+ /** Optional agent that revises a failed payload from unmet-criterion feedback. */
79
+ revise?: AgentRef;
80
+ /** Maximum bounded revisions before deciding. Defaults to 0 (no revise). */
81
+ maxRevisions?: number;
82
+ /**
83
+ * Optional postcondition criteria scored AFTER the action executes, over
84
+ * `{ action, input, result }`, to attest the side effect actually took effect.
85
+ * The receipt then carries `verification` (attested by the platform).
86
+ */
87
+ verifyCriteria?: ActionCriterionSpec[];
88
+ /** Default scorer for verify criteria that do not name their own. */
89
+ verify?: AgentRef;
90
+ /** Default verify-scorer configuration. */
91
+ verifyConfig?: Record<string, unknown>;
92
+ }
93
+ /**
94
+ * Create an action gate: a proof-gated wrapper around a consequential side
95
+ * effect. The proposal is supplied at run time; criteria, scorers, the execute
96
+ * agent, and bounds are fixed here. Every terminal run yields a platform-served
97
+ * Action Receipt (the authoritative outcome).
98
+ *
99
+ * Deploy it by composing it inside an exported agent, so the platform can
100
+ * recognize and attest the gated action:
101
+ *
102
+ * @example
103
+ * ```ts
104
+ * const justified = agent$(async (_s, { subject }, ctx) => {
105
+ * const { input } = subject as { input: { amount: number } };
106
+ * return { results: [{ criterionId: 'amount_ok', verdict: input.amount <= 500, method: 'deterministic' }] };
107
+ * });
108
+ * const refundAgent = agent$(async (_s, { input }, ctx) => ctx.fetch(...));
109
+ *
110
+ * const gate = actionGate({ criteria: [{ id: 'amount_ok' }], scorer: justified, execute: refundAgent });
111
+ * export const refund = agent$((_s, input, ctx) => ctx.call(gate, input));
112
+ * ```
113
+ */
114
+ export declare function actionGate(options: ActionGateOptions): VirtualAgent<ActionGateInput, ActionGateResult>;
115
+ /** Alias for {@link actionGate}. */
116
+ export declare const createActionAgent: typeof actionGate;
117
+ export {};
118
+ //# sourceMappingURL=action.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../src/agents/action.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAKhB,YAAY,EACb,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAIxE;;;GAGG;AACH,MAAM,WAAW,oBAAqB,SAAQ,eAAe;IAC3D,QAAQ,EAAE,mBAAmB,EAAE,CAAC;IAChC,mEAAmE;IACnE,WAAW,EAAE,MAAM,CAAC;IACpB,yEAAyE;IACzE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mDAAmD;IACnD,YAAY,CAAC,EA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side effects.
3
+ *
4
+ * An action gate takes a proposed consequential action (`{ action, input }`),
5
+ * freezes it, scores it against pinned **scorers**, and executes it — with the
6
+ * EXACT frozen payload — only when every required criterion passes. Otherwise it
7
+ * denies, or (when a revise agent is configured) revises the payload once and
8
+ * re-scores, up to a bound.
9
+ *
10
+ * The authoritative record of a gated action is the platform-served Action
11
+ * Receipt: which pinned scorer measured which payload, the decision, and proof
12
+ * that the executed payload was byte-for-byte the one that was scored — not this
13
+ * agent's own return value (which an agent could fake).
14
+ *
15
+ * Where a goal agent attests an OUTCOME, an action gate attests an ACTION. It
16
+ * reuses the same scoring substrate (scorers, `ScorerInput`/`ScorerOutput`,
17
+ * thresholds) as the goal controller.
18
+ */
19
+ import { agent$ } from '@alveus-ai/core';
20
+ const METHODS = new Set(['deterministic', 'model_assessed', 'opaque']);
21
+ /**
22
+ * The precompiled action-gate controller. Configured (not authored) by
23
+ * `actionGate`.
24
+ *
25
+ * It validates its own contract (so it cannot be tricked into executing for an
26
+ * empty or malformed criteria set, even when invoked directly), freezes the
27
+ * proposed payload, scores every criterion against that frozen payload via its
28
+ * pinned scorer, and executes the side effect with the **exact same frozen
29
+ * payload** only when all required criteria pass. On failure it denies, or
30
+ * revises once (when a revise agent is configured) and re-scores, up to the
31
+ * bound. It never self-attests — the platform authors the receipt.
32
+ */
33
+ export const ActionGateLogic = agent$(async (_state, event, ctx) => {
34
+ const { action, criteria, executeHash, reviseHash, reviseConfig, verifyCriteria } = event;
35
+ const maxRevisions = event.maxRevisions;
36
+ // ===== CONTRACT VALIDATION (trust boundary) =====
37
+ // The controller is publicly callable by hash, so it must independently
38
+ // reject an invalid contract rather than trust the factory. An invalid
39
+ // contract is an execution failure, never a silent allow.
40
+ if (typeof action !== 'string' || action.length === 0) {
41
+ throw new Error('Action contract invalid: action must be a non-empty string');
42
+ }
43
+ if (!Array.isArray(criteria) || criteria.length === 0) {
44
+ throw new Error('Action contract invalid: at least one criterion is required');
45
+ }
46
+ if (typeof executeHash !== 'string' || executeHash.length === 0) {
47
+ throw new Error('Action contract invalid: an execute agent is required');
48
+ }
49
+ if (!Number.isInteger(maxRevisions) || maxRevisions < 0) {
50
+ throw new Error('Action contract invalid: maxRevisions must be a non-negative integer');
51
+ }
52
+ const seenIds = new Set();
53
+ for (const c of criteria) {
54
+ if (!c || typeof c.id !== 'string' || c.id.length === 0) {
55
+ throw new Error('Action contract invalid: every criterion needs a non-empty id');
56
+ }
57
+ if (seenIds.has(c.id)) {
58
+ throw new Error(`Action contract invalid: duplicate criterion id "${c.id}"`);
59
+ }
60
+ seenIds.add(c.id);
61
+ if (typeof c.scorerHash !== 'string' || c.scorerHash.length === 0) {
62
+ throw new Error(`Action contract invalid: criterion "${c.id}" has no pinned scorer`);
63
+ }
64
+ }
65
+ if (verifyCriteria !== undefined) {
66
+ if (!Array.isArray(verifyCriteria)) {
67
+ throw new Error('Action contract invalid: verifyCriteria must be an array');
68
+ }
69
+ const seenVerify = new Set();
70
+ for (const c of verifyCriteria) {
71
+ if (!c || typeof c.id !== 'string' || c.id.length === 0) {
72
+ throw new Error('Action contract invalid: every verify criterion needs a non-empty id');
73
+ }
74
+ if (seenVerify.has(c.id)) {
75
+ throw new Error(`Action contract invalid: duplicate verify criterion id "${c.id}"`);
76
+ }
77
+ seenVerify.add(c.id);
78
+ if (typeof c.scorerHash !== 'string' || c.scorerHash.length === 0) {
79
+ throw new Error(`Action contract invalid: verify criterion "${c.id}" has no pinned scorer`);
80
+ }
81
+ }
82
+ }
83
+ // ===== HELPERS (mirror the goal controller's strict scoring) =====
84
+ const passes = (threshold, r, id) => {
85
+ const t = threshold ?? { kind: 'verdict' };
86
+ if (t.kind === 'verdict') {
87
+ if (typeof r.verdict !== 'boolean') {
88
+ throw new Error(`Scorer did not return a boolean verdict for "${id}"`);
89
+ }
90
+ return r.verdict === true;
91
+ }
92
+ if (t.kind === 'minScore') {
93
+ if (typeof r.score !== 'number' || !Number.isFinite(r.score)) {
94
+ throw new Error(`Scorer did not return a numeric score for "${id}"`);
95
+ }
96
+ return r.score >= t.min;
97
+ }
98
+ throw new Error(`Unknown threshold kind for "${id}"`);
99
+ };
100
+ const parseScores = (raw, expected) => {
101
+ if (!raw ||
102
+ typeof raw !== 'object' ||
103
+ !Array.isArray(raw.results)) {
104
+ throw new Error('Scorer output invalid: missing results array');
105
+ }
106
+ const expectedSet = new Set(expected);
107
+ const byId = new Map();
108
+ for (const entry of raw.results) {
109
+ if (!entry || typeof entry !== 'object') {
110
+ throw new Error('Scorer output invalid: non-object result entry');
111
+ }
112
+ const { criterionId, method, verdict, score, label, reasoning, metadata, ...extra } = entry;
113
+ if (typeof criterionId !== 'string') {
114
+ throw new Error('Scorer output invalid: result missing string criterionId');
115
+ }
116
+ if (!expectedSet.has(criterionId)) {
117
+ throw new Error(`Scorer output invalid: unexpected criterionId "${criterionId}"`);
118
+ }
119
+ if (byId.has(criterionId)) {
120
+ throw new Error(`Scorer output invalid: duplicate result for "${criterionId}"`);
121
+ }
122
+ const extraKeys = Object.keys(extra);
123
+ if (extraKeys.length > 0) {
124
+ throw new Error(`Scorer output invalid: unknown field(s) for "${criterionId}": ${extraKeys.join(', ')}`);
125
+ }
126
+ if (verdict !== undefined && typeof verdict !== 'boolean') {
127
+ throw new Error(`Scorer output invalid: "${criterionId}" verdict must be boolean`);
128
+ }
129
+ if (score !== undefined && (typeof score !== 'number' || !Number.isFinite(score))) {
130
+ throw new Error(`Scorer output invalid: "${criterionId}" score must be a finite number`);
131
+ }
132
+ if (label !== undefined && typeof label !== 'string') {
133
+ throw new Error(`Scorer output invalid: "${criterionId}" label must be a string`);
134
+ }
135
+ if (reasoning !== undefined && typeof reasoning !== 'string') {
136
+ throw new Error(`Scorer output invalid: "${criterionId}" reasoning must be a string`);
137
+ }
138
+ if (method !== undefined && !METHODS.has(method)) {
139
+ throw new Error(`Scorer output invalid: "${criterionId}" has an unknown method`);
140
+ }
141
+ byId.set(criterionId, {
142
+ result: { verdict, score, label, reasoning, metadata },
143
+ method: method ?? 'opaque',
144
+ });
145
+ }
146
+ for (const id of expected) {
147
+ if (!byId.has(id)) {
148
+ throw new Error(`Scorer output invalid: missing result for "${id}"`);
149
+ }
150
+ }
151
+ return byId;
152
+ };
153
+ const buildGroups = (crits) => {
154
+ const groups = new Map();
155
+ for (const c of crits) {
156
+ const key = `${c.scorerHash} ${JSON.stringify(c.scorerConfig ?? null)} ${JSON.stringify(c.reference ?? null)}`;
157
+ let g = groups.get(key);
158
+ if (!g) {
159
+ g = {
160
+ scorerHash: c.scorerHash,
161
+ scorerConfig: c.scorerConfig,
162
+ reference: c.reference,
163
+ ids: [],
164
+ };
165
+ groups.set(key, g);
166
+ }
167
+ g.ids.push(c.id);
168
+ }
169
+ return [...groups.values()];
170
+ };
171
+ // Score one subject against a set of criteria via their pinned scorers. Each
172
+ // scorer group is one durable step whose recorded input carries the subject.
173
+ const scoreCriteria = async (subject, crits, labelPrefix) => {
174
+ const results = new Map();
175
+ for (const g of buildGroups(crits)) {
176
+ const scorerInput = {
177
+ subject,
178
+ criteria: g.ids.map((criterionId) => ({ criterionId })),
179
+ reference: g.reference,
180
+ config: g.scorerConfig,
181
+ };
182
+ const raw = await ctx.call(g.scorerHash, scorerInput, {
183
+ label: `${labelPrefix}: ${g.ids.join(', ')}`,
184
+ });
185
+ const parsed = parseScores(raw, g.ids);
186
+ for (const [id, v] of parsed)
187
+ results.set(id, v);
188
+ }
189
+ return crits.map((c) => {
190
+ const scored = results.get(c.id);
191
+ return {
192
+ id: c.id,
193
+ passed: passes(c.threshold, scored.result, c.id),
194
+ reasoning: scored.result.reasoning,
195
+ };
196
+ });
197
+ };
198
+ ctx.logger.info('Action gate started', {
199
+ action,
200
+ criteria: criteria.map((c) => c.id),
201
+ scorerCount: buildGroups(criteria).length,
202
+ verifyCriteria: (verifyCriteria ?? []).map((c) => c.id),
203
+ maxRevisions,
204
+ });
205
+ // ===== EVALUATE → (revise) → decide =====
206
+ // The frozen payload is the caller's proposal { action, input }. The SAME
207
+ // object is scored and, on allow, executed — no config is merged into either
208
+ // spawn, so the scored payload is byte-for-byte the executed payload.
209
+ let payload = { action, input: event.input };
210
+ let revisions = 0;
211
+ for (;;) {
212
+ await ctx.setState(`action.round.${revisions}.payload`, payload);
213
+ const evaluated = await scoreCriteria(payload, criteria, 'check');
214
+ const unmet = evaluated.filter((e) => !e.passed);
215
+ ctx.logger.info('Action evaluated', {
216
+ revisions,
217
+ passed: evaluated.filter((e) => e.passed).map((e) => e.id),
218
+ unmet: unmet.map((e) => e.id),
219
+ });
220
+ if (unmet.length === 0) {
221
+ // ALLOW: execute the EXACT frozen payload (the same object that was scored).
222
+ const result = await ctx.call(executeHash, payload, { label: action });
223
+ ctx.logger.info('Action allowed and executed', { action, revisions });
224
+ // POSTCONDITION: if verify criteria are pinned, score the effect that
225
+ // just happened — over { action, input, result } — AFTER the execute
226
+ // child, so the platform can attest whether the side effect took hold.
227
+ let verified;
228
+ if (verifyCriteria && verifyCriteria.length > 0) {
229
+ const verifySubject = { action, input: payload.input, result };
230
+ await ctx.setState('action.verify.subject', verifySubject);
231
+ const checked = await scoreCriteria(verifySubject, verifyCriteria, 'verify');
232
+ const unverified = checked.filter((e) => !e.passed);
233
+ verified = unverified.length === 0;
234
+ ctx.logger.info('Action verified', {
235
+ action,
236
+ verified,
237
+ unverified: unverified.map((e) => e.id),
238
+ });
239
+ }
240
+ return {
241
+ decision: 'ALLOWED',
242
+ revisions,
243
+ executed: true,
244
+ ...(verified !== undefined ? { verified } : {}),
245
+ };
246
+ }
247
+ // Revise once more only if a revise agent is configured and budget remains.
248
+ if (reviseHash && revisions < maxRevisions) {
249
+ const feedback = unmet.map((e) => `- Criterion "${e.id}" not met.${e.reasoning ? ` ${e.reasoning}` : ''}`);
250
+ const revised = await ctx.call(reviseHash, { ...(reviseConfig ?? {}), action, input: payload.input, feedback }, { label: `revise: ${action}` });
251
+ // The revise agent returns the new input payload (bare, or wrapped in `{ input }`).
252
+ const newInput = revised && typeof revised === 'object' && 'input' in revised
253
+ ? revised.input
254
+ : revised;
255
+ payload = { action, input: newInput };
256
+ revisions++;
257
+ continue;
258
+ }
259
+ // DENY: the side effect never runs.
260
+ ctx.logger.info('Action denied', {
261
+ action,
262
+ revisions,
263
+ unmet: unmet.map((e) => e.id),
264
+ });
265
+ return { decision: 'DENIED', revisions, executed: false };
266
+ }
267
+ }, { name: 'ActionGateLogic', hash: "cce616f5c108d4edecc10d877b734e3b96b977726f76302d2cb4c921ebaf17db" });
268
+ /** Resolve an agent reference to its pinned code hash and (for virtual agents) config. */
269
+ function resolveRef(ref) {
270
+ if (typeof ref === 'string')
271
+ return { hash: ref };
272
+ const anyRef = ref;
273
+ if (anyRef.definition?.definition?.hash) {
274
+ return { hash: anyRef.definition.definition.hash, config: anyRef.defaultInput };
275
+ }
276
+ if (anyRef.definition?.hash)
277
+ return { hash: anyRef.definition.hash };
278
+ throw new Error('actionGate: could not resolve scorer/execute/revise agent hash');
279
+ }
280
+ function mergeConfig(...parts) {
281
+ const merged = Object.assign({}, ...parts.filter(Boolean));
282
+ return Object.keys(merged).length > 0 ? merged : undefined;
283
+ }
284
+ /**
285
+ * Create an action gate: a proof-gated wrapper around a consequential side
286
+ * effect. The proposal is supplied at run time; criteria, scorers, the execute
287
+ * agent, and bounds are fixed here. Every terminal run yields a platform-served
288
+ * Action Receipt (the authoritative outcome).
289
+ *
290
+ * Deploy it by composing it inside an exported agent, so the platform can
291
+ * recognize and attest the gated action:
292
+ *
293
+ * @example
294
+ * ```ts
295
+ * const justified = agent$(async (_s, { subject }, ctx) => {
296
+ * const { input } = subject as { input: { amount: number } };
297
+ * return { results: [{ criterionId: 'amount_ok', verdict: input.amount <= 500, method: 'deterministic' }] };
298
+ * });
299
+ * const refundAgent = agent$(async (_s, { input }, ctx) => ctx.fetch(...));
300
+ *
301
+ * const gate = actionGate({ criteria: [{ id: 'amount_ok' }], scorer: justified, execute: refundAgent });
302
+ * export const refund = agent$((_s, input, ctx) => ctx.call(gate, input));
303
+ * ```
304
+ */
305
+ export function actionGate(options) {
306
+ const { criteria, scorer, scorerConfig, execute, revise, maxRevisions } = options;
307
+ const { verify, verifyCriteria, verifyConfig } = options;
308
+ if (!criteria || criteria.length === 0) {
309
+ throw new Error('actionGate: at least one criterion is required');
310
+ }
311
+ if (!execute) {
312
+ throw new Error('actionGate: an execute agent is required');
313
+ }
314
+ const defaultScorer = scorer ? resolveRef(scorer) : undefined;
315
+ const ids = new Set();
316
+ const normalized = criteria.map((c) => {
317
+ if (!c.id)
318
+ throw new Error('actionGate: every criterion needs an id');
319
+ if (ids.has(c.id))
320
+ throw new Error(`actionGate: duplicate criterion id "${c.id}"`);
321
+ ids.add(c.id);
322
+ const resolved = c.scorer ? resolveRef(c.scorer) : defaultScorer;
323
+ if (!resolved) {
324
+ throw new Error(`actionGate: criterion "${c.id}" has no scorer (set a default \`scorer\` or a per-criterion \`scorer\`)`);
325
+ }
326
+ return {
327
+ id: c.id,
328
+ threshold: c.threshold,
329
+ scorerHash: resolved.hash,
330
+ scorerConfig: mergeConfig(resolved.config, scorerConfig, c.scorerConfig),
331
+ reference: c.reference,
332
+ };
333
+ });
334
+ const limit = maxRevisions ?? 0;
335
+ if (!Number.isInteger(limit) || limit < 0) {
336
+ throw new Error('actionGate: maxRevisions must be a non-negative integer');
337
+ }
338
+ const resolvedExecute = resolveRef(execute);
339
+ // The execute agent must receive exactly the frozen payload; a carried config
340
+ // would change what runs vs. what was scored and break the guarantee.
341
+ if (resolvedExecute.config && Object.keys(resolvedExecute.config).length > 0) {
342
+ throw new Error('actionGate: the execute agent must not carry defaultInput/config — it receives exactly the proposed payload so the executed payload provably equals the scored one');
343
+ }
344
+ const resolvedRevise = revise ? resolveRef(revise) : undefined;
345
+ // Normalize the optional postcondition criteria (same shape as the gating
346
+ // criteria). Each is scored after execution to attest the effect took hold.
347
+ const defaultVerifyScorer = verify ? resolveRef(verify) : undefined;
348
+ let normalizedVerify;
349
+ if (verifyCriteria && verifyCriteria.length > 0) {
350
+ const vids = new Set();
351
+ normalizedVerify = verifyCriteria.map((c) => {
352
+ if (!c.id)
353
+ throw new Error('actionGate: every verify criterion needs an id');
354
+ if (vids.has(c.id))
355
+ throw new Error(`actionGate: duplicate verify criterion id "${c.id}"`);
356
+ vids.add(c.id);
357
+ const resolved = c.scorer ? resolveRef(c.scorer) : defaultVerifyScorer;
358
+ if (!resolved) {
359
+ throw new Error(`actionGate: verify criterion "${c.id}" has no scorer (set a default \`verify\` or a per-criterion \`scorer\`)`);
360
+ }
361
+ return {
362
+ id: c.id,
363
+ threshold: c.threshold,
364
+ scorerHash: resolved.hash,
365
+ scorerConfig: mergeConfig(resolved.config, verifyConfig, c.scorerConfig),
366
+ reference: c.reference,
367
+ };
368
+ });
369
+ }
370
+ else if (verify) {
371
+ throw new Error('actionGate: a `verify` scorer was set but there are no `verifyCriteria` to check');
372
+ }
373
+ const defaultInput = {
374
+ criteria: normalized,
375
+ executeHash: resolvedExecute.hash,
376
+ reviseHash: resolvedRevise?.hash,
377
+ reviseConfig: resolvedRevise?.config,
378
+ maxRevisions: limit,
379
+ ...(normalizedVerify ? { verifyCriteria: normalizedVerify } : {}),
380
+ };
381
+ return {
382
+ definition: ActionGateLogic,
383
+ defaultInput: defaultInput,
384
+ };
385
+ }
386
+ /** Alias for {@link actionGate}. */
387
+ export const createActionAgent = actionGate;
388
+ //# sourceMappingURL=action.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action.js","sourceRoot":"","sources":["../../src/agents/action.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAazC,MAAM,OAAO,GAAwB,IAAI,GAAG,CAAC,CAAC,eAAe,EAAE,gBAAgB,EAAE,QAAQ,CAAC,CAAC,CAAC;AAwB5F;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CACnC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAA6B,E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AM,IAAI,GAAG,iBAAiB,CAAI,KAAK,CAAC,CAAC;QAEzC,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;IAC9B,CAAC,EACD;QACE,IAAI,EAAE,IAAI,IAAI,iBAAiB;QAC/B,WAAW,EAAE,WAAW,IAAI,8BAA8B;KAC3D,CACF,CAAC;AACJ,CAAC"}
@@ -6,4 +6,5 @@
6
6
  export { createChatAgent, createJsonChatAgent, type ChatInput, type ChatOutput, type ChatAgentOptions, } from './basic-chat.js';
7
7
  export { ReActLogic, createReActAgent, availableTools, type ReActInput, type ReActOutput, type ReActStep, type ReActAgentOptions, type ToolDefinition, } from './react.js';
8
8
  export { GoalAgentLogic, createGoalAgent, type GoalAgentOptions, type GoalCriterionSpec, type GoalAgentLogicInput, type NormalizedCriterion, } from './goal.js';
9
+ export { ActionGateLogic, actionGate, createActionAgent, type ActionGateOptions, type ActionCriterionSpec, type ActionGateLogicInput, } from './action.js';
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agents/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,gBAAgB,GACtB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAEL,UAAU,EAEV,gBAAgB,EAEhB,cAAc,EAEd,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,cAAc,GACpB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAEL,cAAc,EAEd,eAAe,EAEf,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,GACzB,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agents/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,gBAAgB,GACtB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAEL,UAAU,EAEV,gBAAgB,EAEhB,cAAc,EAEd,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,cAAc,GACpB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAEL,cAAc,EAEd,eAAe,EAEf,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,GACzB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAEL,eAAe,EAEf,UAAU,EACV,iBAAiB,EAEjB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,GAC1B,MAAM,aAAa,CAAC"}
@@ -16,4 +16,9 @@ export {
16
16
  GoalAgentLogic,
17
17
  // The factory (returns VirtualAgent)
18
18
  createGoalAgent, } from './goal.js';
19
+ export {
20
+ // The master logic (compiled controller)
21
+ ActionGateLogic,
22
+ // The factories (return VirtualAgent)
23
+ actionGate, createActionAgent, } from './action.js';
19
24
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/agents/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,eAAe,EACf,mBAAmB,GAIpB,MAAM,iBAAiB,CAAC;AAEzB,OAAO;AACL,oCAAoC;AACpC,UAAU;AACV,qCAAqC;AACrC,gBAAgB;AAChB,uBAAuB;AACvB,cAAc,GAOf,MAAM,YAAY,CAAC;AAEpB,OAAO;AACL,yCAAyC;AACzC,cAAc;AACd,qCAAqC;AACrC,eAAe,GAMhB,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/agents/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,eAAe,EACf,mBAAmB,GAIpB,MAAM,iBAAiB,CAAC;AAEzB,OAAO;AACL,oCAAoC;AACpC,UAAU;AACV,qCAAqC;AACrC,gBAAgB;AAChB,uBAAuB;AACvB,cAAc,GAOf,MAAM,YAAY,CAAC;AAEpB,OAAO;AACL,yCAAyC;AACzC,cAAc;AACd,qCAAqC;AACrC,eAAe,GAMhB,MAAM,WAAW,CAAC;AAEnB,OAAO;AACL,yCAAyC;AACzC,eAAe;AACf,sCAAsC;AACtC,UAAU,EACV,iBAAiB,GAKlB,MAAM,aAAa,CAAC"}
@@ -0,0 +1,246 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/agents/virtual-agent.ts
20
+ var virtual_agent_exports = {};
21
+ __export(virtual_agent_exports, {
22
+ default: () => virtual_agent_default
23
+ });
24
+ module.exports = __toCommonJS(virtual_agent_exports);
25
+ var METHODS = /* @__PURE__ */ new Set(["deterministic", "model_assessed", "opaque"]);
26
+ var __alveusHandler = async (_state, event, ctx) => {
27
+ const { action, criteria, executeHash, reviseHash, reviseConfig, verifyCriteria } = event;
28
+ const maxRevisions = event.maxRevisions;
29
+ if (typeof action !== "string" || action.length === 0) {
30
+ throw new Error("Action contract invalid: action must be a non-empty string");
31
+ }
32
+ if (!Array.isArray(criteria) || criteria.length === 0) {
33
+ throw new Error("Action contract invalid: at least one criterion is required");
34
+ }
35
+ if (typeof executeHash !== "string" || executeHash.length === 0) {
36
+ throw new Error("Action contract invalid: an execute agent is required");
37
+ }
38
+ if (!Number.isInteger(maxRevisions) || maxRevisions < 0) {
39
+ throw new Error("Action contract invalid: maxRevisions must be a non-negative integer");
40
+ }
41
+ const seenIds = /* @__PURE__ */ new Set();
42
+ for (const c of criteria) {
43
+ if (!c || typeof c.id !== "string" || c.id.length === 0) {
44
+ throw new Error("Action contract invalid: every criterion needs a non-empty id");
45
+ }
46
+ if (seenIds.has(c.id)) {
47
+ throw new Error(`Action contract invalid: duplicate criterion id "${c.id}"`);
48
+ }
49
+ seenIds.add(c.id);
50
+ if (typeof c.scorerHash !== "string" || c.scorerHash.length === 0) {
51
+ throw new Error(`Action contract invalid: criterion "${c.id}" has no pinned scorer`);
52
+ }
53
+ }
54
+ if (verifyCriteria !== void 0) {
55
+ if (!Array.isArray(verifyCriteria)) {
56
+ throw new Error("Action contract invalid: verifyCriteria must be an array");
57
+ }
58
+ const seenVerify = /* @__PURE__ */ new Set();
59
+ for (const c of verifyCriteria) {
60
+ if (!c || typeof c.id !== "string" || c.id.length === 0) {
61
+ throw new Error("Action contract invalid: every verify criterion needs a non-empty id");
62
+ }
63
+ if (seenVerify.has(c.id)) {
64
+ throw new Error(`Action contract invalid: duplicate verify criterion id "${c.id}"`);
65
+ }
66
+ seenVerify.add(c.id);
67
+ if (typeof c.scorerHash !== "string" || c.scorerHash.length === 0) {
68
+ throw new Error(`Action contract invalid: verify criterion "${c.id}" has no pinned scorer`);
69
+ }
70
+ }
71
+ }
72
+ const passes = (threshold, r, id) => {
73
+ const t = threshold ?? { kind: "verdict" };
74
+ if (t.kind === "verdict") {
75
+ if (typeof r.verdict !== "boolean") {
76
+ throw new Error(`Scorer did not return a boolean verdict for "${id}"`);
77
+ }
78
+ return r.verdict === true;
79
+ }
80
+ if (t.kind === "minScore") {
81
+ if (typeof r.score !== "number" || !Number.isFinite(r.score)) {
82
+ throw new Error(`Scorer did not return a numeric score for "${id}"`);
83
+ }
84
+ return r.score >= t.min;
85
+ }
86
+ throw new Error(`Unknown threshold kind for "${id}"`);
87
+ };
88
+ const parseScores = (raw, expected) => {
89
+ if (!raw || typeof raw !== "object" || !Array.isArray(raw.results)) {
90
+ throw new Error("Scorer output invalid: missing results array");
91
+ }
92
+ const expectedSet = new Set(expected);
93
+ const byId = /* @__PURE__ */ new Map();
94
+ for (const entry of raw.results) {
95
+ if (!entry || typeof entry !== "object") {
96
+ throw new Error("Scorer output invalid: non-object result entry");
97
+ }
98
+ const { criterionId, method, verdict, score, label, reasoning, metadata, ...extra } = entry;
99
+ if (typeof criterionId !== "string") {
100
+ throw new Error("Scorer output invalid: result missing string criterionId");
101
+ }
102
+ if (!expectedSet.has(criterionId)) {
103
+ throw new Error(`Scorer output invalid: unexpected criterionId "${criterionId}"`);
104
+ }
105
+ if (byId.has(criterionId)) {
106
+ throw new Error(`Scorer output invalid: duplicate result for "${criterionId}"`);
107
+ }
108
+ const extraKeys = Object.keys(extra);
109
+ if (extraKeys.length > 0) {
110
+ throw new Error(
111
+ `Scorer output invalid: unknown field(s) for "${criterionId}": ${extraKeys.join(", ")}`
112
+ );
113
+ }
114
+ if (verdict !== void 0 && typeof verdict !== "boolean") {
115
+ throw new Error(`Scorer output invalid: "${criterionId}" verdict must be boolean`);
116
+ }
117
+ if (score !== void 0 && (typeof score !== "number" || !Number.isFinite(score))) {
118
+ throw new Error(`Scorer output invalid: "${criterionId}" score must be a finite number`);
119
+ }
120
+ if (label !== void 0 && typeof label !== "string") {
121
+ throw new Error(`Scorer output invalid: "${criterionId}" label must be a string`);
122
+ }
123
+ if (reasoning !== void 0 && typeof reasoning !== "string") {
124
+ throw new Error(`Scorer output invalid: "${criterionId}" reasoning must be a string`);
125
+ }
126
+ if (method !== void 0 && !METHODS.has(method)) {
127
+ throw new Error(`Scorer output invalid: "${criterionId}" has an unknown method`);
128
+ }
129
+ byId.set(criterionId, {
130
+ result: { verdict, score, label, reasoning, metadata },
131
+ method: method ?? "opaque"
132
+ });
133
+ }
134
+ for (const id of expected) {
135
+ if (!byId.has(id)) {
136
+ throw new Error(`Scorer output invalid: missing result for "${id}"`);
137
+ }
138
+ }
139
+ return byId;
140
+ };
141
+ const buildGroups = (crits) => {
142
+ const groups = /* @__PURE__ */ new Map();
143
+ for (const c of crits) {
144
+ const key = `${c.scorerHash} ${JSON.stringify(c.scorerConfig ?? null)} ${JSON.stringify(c.reference ?? null)}`;
145
+ let g = groups.get(key);
146
+ if (!g) {
147
+ g = {
148
+ scorerHash: c.scorerHash,
149
+ scorerConfig: c.scorerConfig,
150
+ reference: c.reference,
151
+ ids: []
152
+ };
153
+ groups.set(key, g);
154
+ }
155
+ g.ids.push(c.id);
156
+ }
157
+ return [...groups.values()];
158
+ };
159
+ const scoreCriteria = async (subject, crits, labelPrefix) => {
160
+ const results = /* @__PURE__ */ new Map();
161
+ for (const g of buildGroups(crits)) {
162
+ const scorerInput = {
163
+ subject,
164
+ criteria: g.ids.map((criterionId) => ({ criterionId })),
165
+ reference: g.reference,
166
+ config: g.scorerConfig
167
+ };
168
+ const raw = await ctx.call(g.scorerHash, scorerInput, {
169
+ label: `${labelPrefix}: ${g.ids.join(", ")}`
170
+ });
171
+ const parsed = parseScores(raw, g.ids);
172
+ for (const [id, v] of parsed) results.set(id, v);
173
+ }
174
+ return crits.map((c) => {
175
+ const scored = results.get(c.id);
176
+ return {
177
+ id: c.id,
178
+ passed: passes(c.threshold, scored.result, c.id),
179
+ reasoning: scored.result.reasoning
180
+ };
181
+ });
182
+ };
183
+ ctx.logger.info("Action gate started", {
184
+ action,
185
+ criteria: criteria.map((c) => c.id),
186
+ scorerCount: buildGroups(criteria).length,
187
+ verifyCriteria: (verifyCriteria ?? []).map((c) => c.id),
188
+ maxRevisions
189
+ });
190
+ let payload = { action, input: event.input };
191
+ let revisions = 0;
192
+ for (; ; ) {
193
+ await ctx.setState(`action.round.${revisions}.payload`, payload);
194
+ const evaluated = await scoreCriteria(payload, criteria, "check");
195
+ const unmet = evaluated.filter((e) => !e.passed);
196
+ ctx.logger.info("Action evaluated", {
197
+ revisions,
198
+ passed: evaluated.filter((e) => e.passed).map((e) => e.id),
199
+ unmet: unmet.map((e) => e.id)
200
+ });
201
+ if (unmet.length === 0) {
202
+ const result = await ctx.call(executeHash, payload, { label: action });
203
+ ctx.logger.info("Action allowed and executed", { action, revisions });
204
+ let verified;
205
+ if (verifyCriteria && verifyCriteria.length > 0) {
206
+ const verifySubject = { action, input: payload.input, result };
207
+ await ctx.setState("action.verify.subject", verifySubject);
208
+ const checked = await scoreCriteria(verifySubject, verifyCriteria, "verify");
209
+ const unverified = checked.filter((e) => !e.passed);
210
+ verified = unverified.length === 0;
211
+ ctx.logger.info("Action verified", {
212
+ action,
213
+ verified,
214
+ unverified: unverified.map((e) => e.id)
215
+ });
216
+ }
217
+ return {
218
+ decision: "ALLOWED",
219
+ revisions,
220
+ executed: true,
221
+ ...verified !== void 0 ? { verified } : {}
222
+ };
223
+ }
224
+ if (reviseHash && revisions < maxRevisions) {
225
+ const feedback = unmet.map(
226
+ (e) => `- Criterion "${e.id}" not met.${e.reasoning ? ` ${e.reasoning}` : ""}`
227
+ );
228
+ const revised = await ctx.call(
229
+ reviseHash,
230
+ { ...reviseConfig ?? {}, action, input: payload.input, feedback },
231
+ { label: `revise: ${action}` }
232
+ );
233
+ const newInput = revised && typeof revised === "object" && "input" in revised ? revised.input : revised;
234
+ payload = { action, input: newInput };
235
+ revisions++;
236
+ continue;
237
+ }
238
+ ctx.logger.info("Action denied", {
239
+ action,
240
+ revisions,
241
+ unmet: unmet.map((e) => e.id)
242
+ });
243
+ return { decision: "DENIED", revisions, executed: false };
244
+ }
245
+ };
246
+ var virtual_agent_default = __alveusHandler;
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/composition/errors.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,QAAQ,EAAE,sBAAsB,EAAE,CAAC;gBAEhC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,sBAAsB,EAAE;CAKhE;AAED,qBAAa,qBAAsB,SAAQ,KAAK;gBAClC,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,6BAA8B,SAAQ,KAAK;gBAC1C,OAAO,EAAE,MAAM;CAI5B;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAAC,OAAO,CAAC,CAE3E"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/composition/errors.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,QAAQ,EAAE,sBAAsB,EAAE,CAAC;IAE5C,YAAY,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,sBAAsB,EAAE,EAI9D;CACF;AAED,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF;AAED,qBAAa,6BAA8B,SAAQ,KA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;;GAQG;AACH,MAAM,UAAU,cAAc,CAAC,QAAuB;IACpD,MAAM,UAAU,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAC1E,OAAO,IAAI,CAAC,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;AACnC,CAAC"}
@@ -65,9 +65,9 @@ export interface ApprovalResponse {
65
65
  */
66
66
  export declare const ApprovalTopics: {
67
67
  /** Topic for approval requests */
68
- readonly NEEDED: "approval.needed";
68
+ readonly NEEDED: 'approval.needed';
69
69
  /** Topic for approval responses */
70
- readonly RESPONSE: "approval.response";
70
+ readonly RESPONSE: 'approval.response';
71
71
  };
72
72
  /**
73
73
  * Wait for human approval
@@ -1 +1 @@
1
- {"version":3,"file":"approval.d.ts","sourceRoot":"","sources":["../../src/patterns/approval.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,oCAAoC;IACpC,MAAM,EAAE,MAAM,CAAC;IAEf,0CAA0C;IAC1C,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAElC,8CAA8C;IAC9C,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,sCAAsC;IACtC,QAAQ,EAAE,OAAO,CAAC;IAElB,uCAAuC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,yCAAyC;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,gCAAgC;IAChC,SAAS,EAAE,MAAM,CAAC;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,CAAC"}
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Action Gate Example
3
+ *
4
+ * A proof-gated side effect: a refund is proposed, frozen, and scored against
5
+ * explicit criteria by a pinned scorer. The refund executes ONLY when every
6
+ * criterion passes, with the exact payload that was scored. When a criterion
7
+ * fails, the gate revises the payload once and re-scores, or denies. Every
8
+ * terminal run yields a platform-served Action Receipt (the authoritative
9
+ * outcome) that the agent itself cannot forge, proving what was allowed, on what
10
+ * evidence, and that the executed payload was byte-for-byte the one that scored.
11
+ *
12
+ * Usage:
13
+ * alveus deploy
14
+ * alveus run @yourscope/action-gate --input '{"amount": 100, "reason": "duplicate charge"}' # ALLOWED
15
+ * alveus run @yourscope/action-gate --input '{"amount": 5000, "reason": "duplicate charge"}' # revised, then ALLOWED
16
+ * alveus run @yourscope/action-gate --input '{"amount": 100}' # DENIED (no reason)
17
+ * alveus receipt <execution-id>
18
+ */
19
+
20
+ import { agent$ } from '@alveus-ai/core';
21
+ import type { ExecutionContext, ScorerInput, ScorerOutput } from '@alveus-ai/core';
22
+ import { actionGate } from '@alveus-ai/std';
23
+
24
+ const POLICY_LIMIT = 1000;
25
+
26
+ interface RefundInput {
27
+ amount: number;
28
+ reason?: string;
29
+ }
30
+
31
+ /**
32
+ * Scorer: a deterministic check over the frozen proposal. It only measures; it
33
+ * returns a verdict per criterion and never decides whether to execute.
34
+ */
35
+ const refundScorer = agent$(async (_state, input: ScorerInput, _ctx: ExecutionContext) => {
36
+ const proposal = input.subject as { input?: RefundInput };
37
+ const amount = proposal?.input?.amount;
38
+ const reason = proposal?.input?.reason;
39
+
40
+ const check = (id: string): boolean => {
41
+ if (id === 'within_policy') return typeof amount === 'number' && amount <= POLICY_LIMIT;
42
+ if (id === 'reason_given') return typeof reason === 'string' && reason.length > 0;
43
+ return false;
44
+ };
45
+
46
+ const output: ScorerOutput = {
47
+ results: input.criteria.map((c) => ({
48
+ criterionId: c.criterionId,
49
+ verdict: check(c.criterionId),
50
+ method: 'deterministic',
51
+ })),
52
+ };
53
+ return output;
54
+ });
55
+
56
+ /**
57
+ * Execute step: the actual side effect. It runs ONLY when every criterion
58
+ * passed, with the exact frozen payload `{ action, input }` that was scored. In
59
+ * production this would call your payments API via `ctx.fetch`; keep it
60
+ * idempotent so a retry never double-refunds.
61
+ */
62
+ const issueRefund = agent$(
63
+ async (_state, payload: { action: string; input: RefundInput }, _ctx: ExecutionContext) => {
64
+ return { refunded: true, amount: payload.input.amount };
65
+ },
66
+ );
67
+
68
+ /**
69
+ * Revise step: bring an over-policy refund within policy, then it is re-scored.
70
+ * It receives the current input plus the unmet-criterion feedback and returns
71
+ * the new input. It cannot invent a missing reason, so a no-reason proposal is
72
+ * denied rather than executed.
73
+ */
74
+ const clampRefund = agent$(
75
+ async (
76
+ _state,
77
+ event: { action: string; input: RefundInput; feedback: string[] },
78
+ _ctx: ExecutionContext,
79
+ ) => {
80
+ return { input: { ...event.input, amount: Math.min(event.input.amount, POLICY_LIMIT) } };
81
+ },
82
+ );
83
+
84
+ const gate = actionGate({
85
+ criteria: [{ id: 'within_policy' }, { id: 'reason_given' }],
86
+ scorer: refundScorer,
87
+ execute: issueRefund,
88
+ revise: clampRefund,
89
+ maxRevisions: 1,
90
+ });
91
+
92
+ /**
93
+ * Deployable root: propose the action so the platform can recognize and attest
94
+ * the gated run. The receipt is retrieved separately, from the platform.
95
+ */
96
+ export const refundGate = agent$((_state, input: RefundInput, ctx: ExecutionContext) =>
97
+ // Freeze the proposal and label the run by the action it gates.
98
+ ctx.call(gate, { action: 'issue-refund', input }, { label: 'issue-refund' }),
99
+ );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alveus-ai/std",
3
- "version": "0.1.55",
3
+ "version": "0.1.57",
4
4
  "description": "Standard library of reusable agents and utilities for Alveus",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -36,8 +36,8 @@
36
36
  "examples"
37
37
  ],
38
38
  "scripts": {
39
- "build": "tsc && node --import tsx scripts/build-blobs.ts",
40
- "dev": "tsc --watch",
39
+ "build": "node \"$PROJECT_CWD/scripts/native-tsc.mjs\" && node --import tsx scripts/build-blobs.ts",
40
+ "dev": "node \"$PROJECT_CWD/scripts/native-tsc.mjs\" --watch",
41
41
  "test": "node --import tsx --test test/**/*.test.ts",
42
42
  "clean": "rm -rf dist .alveus",
43
43
  "seed": "node --import tsx scripts/seed.ts"
@@ -53,6 +53,6 @@
53
53
  },
54
54
  "devDependencies": {
55
55
  "@alveus-ai/core": "workspace:*",
56
- "typescript": "^5.3.0"
56
+ "typescript": "^6.0.3"
57
57
  }
58
58
  }