@sequenceholdings/agent-spec 0.1.6 → 0.1.7
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 +52 -2
- package/dist/action-review-contract.d.ts +147 -0
- package/dist/action-review-contract.js +76 -0
- package/dist/action-review-format.d.ts +12 -0
- package/dist/action-review-format.js +19 -0
- package/dist/action-review.d.ts +3 -0
- package/dist/action-review.js +3 -0
- package/dist/agent-definition.d.ts +8 -8
- package/dist/agent-definition.js +7 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/input-schema.d.ts +1 -1
- package/dist/tool-review.d.ts +45 -0
- package/dist/tool-review.js +51 -0
- package/dist/voice-api.d.ts +4 -4
- package/dist/voice-drafts.d.ts +4 -4
- package/dist/voice-release.d.ts +4 -4
- package/package.json +6 -1
package/README.md
CHANGED
|
@@ -30,14 +30,14 @@ export const agent = defineAgent({
|
|
|
30
30
|
})
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
-
`RECOMMENDED_AGENT_MODEL` is the model new agents start on; `seq-studio
|
|
33
|
+
`RECOMMENDED_AGENT_MODEL` is the model new agents start on; `seq-studio agent
|
|
34
34
|
init` writes it into the scaffold. A definition that omits `model` keeps the
|
|
35
35
|
schema's original default, so upgrading this package never moves an existing
|
|
36
36
|
agent to another model.
|
|
37
37
|
|
|
38
38
|
Definitions must be pure data literals: do not read environment variables, call
|
|
39
39
|
functions, or compute fields in `agent.ts`. Keep deployment targeting separate
|
|
40
|
-
from a definition, then use `seq-studio
|
|
40
|
+
from a definition, then use `seq-studio agent validate`, `plan`, and `apply`.
|
|
41
41
|
|
|
42
42
|
## Require a declared dependency
|
|
43
43
|
|
|
@@ -196,3 +196,53 @@ Import `voiceAudioReadRequestSchema`, `voiceAudioReadResponseSchema` and
|
|
|
196
196
|
when validating Voice recording metadata in a browser. This narrow entry point
|
|
197
197
|
avoids the Node-only compiler/hash exports at the package root. It defines
|
|
198
198
|
metadata and delivery limits, not provider credentials or an audio transport.
|
|
199
|
+
|
|
200
|
+
### Optional tool review
|
|
201
|
+
|
|
202
|
+
An action remains one tool invocation. Review is opt-in configuration on the
|
|
203
|
+
agent's binding, independent of whether the executor is a Managed Function,
|
|
204
|
+
an MCP tool, or a built-in tool:
|
|
205
|
+
|
|
206
|
+
```ts
|
|
207
|
+
agentCapabilities: {
|
|
208
|
+
toolReviews: [
|
|
209
|
+
{
|
|
210
|
+
tool: { kind: 'function', ref: 'update-record' },
|
|
211
|
+
approval: 'required',
|
|
212
|
+
title: 'Update record',
|
|
213
|
+
labels: { recordId: 'Record', description: 'Description' },
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
tool: { kind: 'mcp', server: 'example', name: 'update_record' },
|
|
217
|
+
approval: 'required',
|
|
218
|
+
},
|
|
219
|
+
],
|
|
220
|
+
}
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
Function references must also be in `managedFunctions`; MCP servers must also
|
|
224
|
+
be in `mcpServers`; built-in names must also be in `tools`. This configuration
|
|
225
|
+
never grants access or removes an existing approval requirement. Omitted
|
|
226
|
+
configuration preserves ordinary tool execution.
|
|
227
|
+
|
|
228
|
+
Interactive approval pauses the existing invocation before execution. The
|
|
229
|
+
review card displays every argument. Approving or rejecting uses the normal
|
|
230
|
+
conversation continuation and tool-call identity. The initial native argument
|
|
231
|
+
review is read-only: ask the agent to revise the call to change its arguments.
|
|
232
|
+
Background runs with a required interactive gate fail closed; use a durable
|
|
233
|
+
human task for those workflows. This policy does not turn a background run
|
|
234
|
+
into a task automatically.
|
|
235
|
+
|
|
236
|
+
The single browser-safe `@sequenceholdings/agent-spec/action-review` entry provides `prepareActionReview`,
|
|
237
|
+
`actionReviewSchema`, and catalog types. Applications supply trusted current
|
|
238
|
+
records and field definitions; generated proposals contain only actions,
|
|
239
|
+
record references, and changed values. The same entry also provides the
|
|
240
|
+
transport-neutral policy schema and argument-card adapter. The
|
|
241
|
+
`ActionReview` component in Atlas UI renders the same contract with
|
|
242
|
+
optional editing. An application-owned executor must independently validate
|
|
243
|
+
permissions, input, stale revisions, and idempotency before saving. Rendering
|
|
244
|
+
or approving a card never grants database access.
|
|
245
|
+
|
|
246
|
+
Required interactive approvals are short-lived server-owned records, bound to the initiating execution principal, thread, tool-call ID and exact prepared JSON arguments. Another editor of the same thread cannot release that invocation. Redis is required; unavailable, expired, altered and consumed approvals fail closed. Client-supplied assistant history cannot replace the pending tool or its payload. The reviewed payload includes any conversation history prepared for outbound coding-agent calls; no history is appended after approval.
|
|
247
|
+
|
|
248
|
+
Subagent, evaluation, stub and experimental/qualification execution paths currently refuse required policies because those paths cannot preserve the configured binding. Provider-executed tools without a server-side executor cannot opt into review. These refusals do not remove ordinary invoke authorization or make background human-task approvals automatic.
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
declare const value: z.ZodUnion<readonly [z.ZodString, z.ZodBoolean, z.ZodObject<{
|
|
3
|
+
from: z.ZodNullable<z.ZodString>;
|
|
4
|
+
to: z.ZodNullable<z.ZodString>;
|
|
5
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
6
|
+
amountMinor: z.ZodNumber;
|
|
7
|
+
currency: z.ZodString;
|
|
8
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
9
|
+
type: z.ZodString;
|
|
10
|
+
id: z.ZodString;
|
|
11
|
+
}, z.core.$strict>, z.ZodNull]>;
|
|
12
|
+
export declare const actionReviewSchema: z.ZodObject<{
|
|
13
|
+
version: z.ZodLiteral<1>;
|
|
14
|
+
action: z.ZodEnum<{
|
|
15
|
+
create: "create";
|
|
16
|
+
update: "update";
|
|
17
|
+
archive: "archive";
|
|
18
|
+
invoke: "invoke";
|
|
19
|
+
}>;
|
|
20
|
+
target: z.ZodObject<{
|
|
21
|
+
type: z.ZodString;
|
|
22
|
+
id: z.ZodNullable<z.ZodString>;
|
|
23
|
+
}, z.core.$strict>;
|
|
24
|
+
changes: z.ZodArray<z.ZodObject<{
|
|
25
|
+
field: z.ZodString;
|
|
26
|
+
value: z.ZodUnion<readonly [z.ZodString, z.ZodBoolean, z.ZodObject<{
|
|
27
|
+
from: z.ZodNullable<z.ZodString>;
|
|
28
|
+
to: z.ZodNullable<z.ZodString>;
|
|
29
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
30
|
+
amountMinor: z.ZodNumber;
|
|
31
|
+
currency: z.ZodString;
|
|
32
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
33
|
+
type: z.ZodString;
|
|
34
|
+
id: z.ZodString;
|
|
35
|
+
}, z.core.$strict>, z.ZodNull]>;
|
|
36
|
+
}, z.core.$strict>>;
|
|
37
|
+
references: z.ZodArray<z.ZodObject<{
|
|
38
|
+
record: z.ZodObject<{
|
|
39
|
+
type: z.ZodString;
|
|
40
|
+
id: z.ZodString;
|
|
41
|
+
}, z.core.$strict>;
|
|
42
|
+
role: z.ZodEnum<{
|
|
43
|
+
retained: "retained";
|
|
44
|
+
related: "related";
|
|
45
|
+
}>;
|
|
46
|
+
}, z.core.$strict>>;
|
|
47
|
+
}, z.core.$strict>;
|
|
48
|
+
export type ActionReviewValue = z.infer<typeof value>;
|
|
49
|
+
export type ActionReviewRequest = z.infer<typeof actionReviewSchema>;
|
|
50
|
+
export interface ActionReviewField {
|
|
51
|
+
key: string;
|
|
52
|
+
label: string;
|
|
53
|
+
kind: 'text' | 'select' | 'boolean' | 'dateRange' | 'money' | 'reference';
|
|
54
|
+
editable: boolean;
|
|
55
|
+
required?: boolean;
|
|
56
|
+
maxLength?: number;
|
|
57
|
+
referenceTypes?: string[];
|
|
58
|
+
options?: {
|
|
59
|
+
value: string;
|
|
60
|
+
label: string;
|
|
61
|
+
}[];
|
|
62
|
+
}
|
|
63
|
+
export interface ActionReviewRecord {
|
|
64
|
+
type: string;
|
|
65
|
+
id: string;
|
|
66
|
+
label: string;
|
|
67
|
+
values: Record<string, ActionReviewValue>;
|
|
68
|
+
allowedActions: ActionReviewRequest['action'][];
|
|
69
|
+
href?: string;
|
|
70
|
+
}
|
|
71
|
+
export interface ActionReviewCatalog {
|
|
72
|
+
types: Record<string, {
|
|
73
|
+
label: string;
|
|
74
|
+
canCreate: boolean;
|
|
75
|
+
canInvoke?: boolean;
|
|
76
|
+
fields: ActionReviewField[];
|
|
77
|
+
}>;
|
|
78
|
+
records: ActionReviewRecord[];
|
|
79
|
+
}
|
|
80
|
+
export declare function actionReviewValuesEqual(a: ActionReviewValue | undefined, b: ActionReviewValue | undefined): boolean;
|
|
81
|
+
export declare function prepareActionReview(input: unknown, catalog: ActionReviewCatalog): {
|
|
82
|
+
spec: {
|
|
83
|
+
version: 1;
|
|
84
|
+
action: "create" | "update" | "archive" | "invoke";
|
|
85
|
+
target: {
|
|
86
|
+
type: string;
|
|
87
|
+
id: string | null;
|
|
88
|
+
};
|
|
89
|
+
changes: {
|
|
90
|
+
field: string;
|
|
91
|
+
value: string | boolean | {
|
|
92
|
+
from: string | null;
|
|
93
|
+
to: string | null;
|
|
94
|
+
} | {
|
|
95
|
+
type: string;
|
|
96
|
+
id: string;
|
|
97
|
+
} | {
|
|
98
|
+
amountMinor: number;
|
|
99
|
+
currency: string;
|
|
100
|
+
} | null;
|
|
101
|
+
}[];
|
|
102
|
+
references: {
|
|
103
|
+
record: {
|
|
104
|
+
type: string;
|
|
105
|
+
id: string;
|
|
106
|
+
};
|
|
107
|
+
role: "retained" | "related";
|
|
108
|
+
}[];
|
|
109
|
+
};
|
|
110
|
+
definition: {
|
|
111
|
+
label: string;
|
|
112
|
+
canCreate: boolean;
|
|
113
|
+
canInvoke?: boolean;
|
|
114
|
+
fields: ActionReviewField[];
|
|
115
|
+
};
|
|
116
|
+
record: ActionReviewRecord | null;
|
|
117
|
+
current: Record<string, string | boolean | {
|
|
118
|
+
from: string | null;
|
|
119
|
+
to: string | null;
|
|
120
|
+
} | {
|
|
121
|
+
type: string;
|
|
122
|
+
id: string;
|
|
123
|
+
} | {
|
|
124
|
+
amountMinor: number;
|
|
125
|
+
currency: string;
|
|
126
|
+
} | null> | null;
|
|
127
|
+
proposed: Record<string, string | boolean | {
|
|
128
|
+
from: string | null;
|
|
129
|
+
to: string | null;
|
|
130
|
+
} | {
|
|
131
|
+
type: string;
|
|
132
|
+
id: string;
|
|
133
|
+
} | {
|
|
134
|
+
amountMinor: number;
|
|
135
|
+
currency: string;
|
|
136
|
+
} | null>;
|
|
137
|
+
references: {
|
|
138
|
+
record: ActionReviewRecord;
|
|
139
|
+
role: "retained" | "related";
|
|
140
|
+
}[];
|
|
141
|
+
};
|
|
142
|
+
export type PreparedActionReview = ReturnType<typeof prepareActionReview>;
|
|
143
|
+
export declare function actionReviewRecordKey(record: {
|
|
144
|
+
type: string;
|
|
145
|
+
id: string;
|
|
146
|
+
}): string;
|
|
147
|
+
export {};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const id = z.string().min(1).max(128).refine(value => !['__proto__', 'prototype', 'constructor'].includes(value), 'Reserved identifier');
|
|
3
|
+
const recordRef = z.object({ type: id, id }).strict();
|
|
4
|
+
const date = z.string().regex(/^\d{4}-\d{2}-\d{2}$/).refine(value => { const parsed = new Date(`${value}T00:00:00Z`); return !Number.isNaN(parsed.valueOf()) && parsed.toISOString().slice(0, 10) === value; }, 'Invalid calendar date');
|
|
5
|
+
const dateRange = z.object({ from: date.nullable(), to: date.nullable() }).strict().refine(value => !value.from || !value.to || value.from <= value.to, 'Date range is reversed');
|
|
6
|
+
const money = z.object({ amountMinor: z.number().int().safe(), currency: z.string().regex(/^[A-Z]{3}$/) }).strict();
|
|
7
|
+
const value = z.union([z.string().max(5000), z.boolean(), dateRange, money, recordRef, z.null()]);
|
|
8
|
+
export const actionReviewSchema = z.object({ version: z.literal(1), action: z.enum(['create', 'update', 'archive', 'invoke']), target: z.object({ type: id, id: id.nullable() }).strict(), changes: z.array(z.object({ field: id, value }).strict()).max(24), references: z.array(z.object({ record: recordRef, role: z.enum(['retained', 'related']) }).strict()).max(8) }).strict();
|
|
9
|
+
export function actionReviewValuesEqual(a, b) {
|
|
10
|
+
const stable = (input) => input && typeof input === 'object' ? Object.entries(input).sort(([a], [b]) => a.localeCompare(b)) : input ?? null;
|
|
11
|
+
return JSON.stringify(stable(a)) === JSON.stringify(stable(b));
|
|
12
|
+
}
|
|
13
|
+
export function prepareActionReview(input, catalog) {
|
|
14
|
+
const spec = actionReviewSchema.parse(typeof input === 'string' ? JSON.parse(input) : input);
|
|
15
|
+
const definition = Object.hasOwn(catalog.types, spec.target.type) ? catalog.types[spec.target.type] : undefined;
|
|
16
|
+
if (!definition)
|
|
17
|
+
throw new Error('Unsupported record type');
|
|
18
|
+
if (definition.fields.length > 24)
|
|
19
|
+
throw new Error('Too many review fields');
|
|
20
|
+
const record = spec.target.id === null ? null : catalog.records.find(row => row.type === spec.target.type && row.id === spec.target.id) ?? null;
|
|
21
|
+
if (spec.action === 'create') {
|
|
22
|
+
if (spec.target.id !== null || !definition.canCreate)
|
|
23
|
+
throw new Error('Cannot create this record');
|
|
24
|
+
}
|
|
25
|
+
else if (spec.action === 'invoke') {
|
|
26
|
+
if (spec.target.id !== null || !definition.canInvoke)
|
|
27
|
+
throw new Error('Cannot invoke this action');
|
|
28
|
+
}
|
|
29
|
+
else if (!record || !record.allowedActions.includes(spec.action))
|
|
30
|
+
throw new Error('Record or action is unavailable');
|
|
31
|
+
if (spec.action === 'archive' && spec.changes.length)
|
|
32
|
+
throw new Error('Archive cannot change fields');
|
|
33
|
+
if (spec.action !== 'archive' && !spec.changes.length)
|
|
34
|
+
throw new Error('No fields proposed');
|
|
35
|
+
const keys = new Set(), proposed = { ...(record?.values ?? {}) };
|
|
36
|
+
for (const patch of spec.changes) {
|
|
37
|
+
if (keys.has(patch.field))
|
|
38
|
+
throw new Error('Duplicate field change');
|
|
39
|
+
keys.add(patch.field);
|
|
40
|
+
const field = definition.fields.find(field => field.key === patch.field);
|
|
41
|
+
if (!field || !field.editable)
|
|
42
|
+
throw new Error('Field is unavailable for changes');
|
|
43
|
+
const v = patch.value;
|
|
44
|
+
const valid = v === null && (field.kind === 'dateRange' || !field.required) || field.kind === 'text' && typeof v === 'string' || field.kind === 'select' && typeof v === 'string' && field.options?.some(option => option.value === v) || field.kind === 'boolean' && typeof v === 'boolean' || field.kind === 'dateRange' && typeof v === 'object' && v !== null && 'from' in v || field.kind === 'money' && typeof v === 'object' && v !== null && 'amountMinor' in v || field.kind === 'reference' && typeof v === 'object' && v !== null && 'type' in v && (!field.referenceTypes || field.referenceTypes.includes(v.type)) && catalog.records.some(row => row.type === v.type && row.id === v.id);
|
|
45
|
+
if (!valid)
|
|
46
|
+
throw new Error(`Invalid value for ${field.label}`);
|
|
47
|
+
if (typeof v === 'string' && field.maxLength && v.length > field.maxLength)
|
|
48
|
+
throw new Error(`${field.label} is too long`);
|
|
49
|
+
proposed[patch.field] = v;
|
|
50
|
+
}
|
|
51
|
+
if (spec.action === 'update' && spec.changes.every(patch => actionReviewValuesEqual(record?.values[patch.field], patch.value)))
|
|
52
|
+
throw new Error('No changes to apply');
|
|
53
|
+
if (spec.action !== 'archive') {
|
|
54
|
+
for (const field of definition.fields) {
|
|
55
|
+
if (field.required && (proposed[field.key] == null || typeof proposed[field.key] === 'string' && !String(proposed[field.key]).trim()))
|
|
56
|
+
throw new Error(`${field.label} is required`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const relatedKeys = new Set();
|
|
60
|
+
const references = spec.references.map(ref => {
|
|
61
|
+
const key = actionReviewRecordKey(ref.record);
|
|
62
|
+
if (relatedKeys.has(key))
|
|
63
|
+
throw new Error('Duplicate related record');
|
|
64
|
+
relatedKeys.add(key);
|
|
65
|
+
const related = catalog.records.find(row => row.type === ref.record.type && row.id === ref.record.id);
|
|
66
|
+
if (!related || related === record)
|
|
67
|
+
throw new Error('Related record is unavailable or is the target');
|
|
68
|
+
if (ref.role === 'retained' && spec.action !== 'archive')
|
|
69
|
+
throw new Error('Retained records only apply to archive');
|
|
70
|
+
return { record: related, role: ref.role };
|
|
71
|
+
});
|
|
72
|
+
return { spec, definition, record, current: record?.values ?? null, proposed, references };
|
|
73
|
+
}
|
|
74
|
+
export function actionReviewRecordKey(record) {
|
|
75
|
+
return JSON.stringify([record.type, record.id]);
|
|
76
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare function formatActionReviewMoney({ amountMinor, currency, locale }: {
|
|
2
|
+
amountMinor: number;
|
|
3
|
+
currency: string;
|
|
4
|
+
locale?: string;
|
|
5
|
+
}): string;
|
|
6
|
+
export declare function actionReviewDateEditor(range: {
|
|
7
|
+
from: string | null;
|
|
8
|
+
to: string | null;
|
|
9
|
+
} | null): {
|
|
10
|
+
partial: boolean;
|
|
11
|
+
label: string;
|
|
12
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export function formatActionReviewMoney({ amountMinor, currency, locale = 'en-US' }) {
|
|
2
|
+
if (!Number.isSafeInteger(amountMinor))
|
|
3
|
+
throw new Error('Amount must use safe integer minor units');
|
|
4
|
+
const formatter = new Intl.NumberFormat(locale, { style: 'currency', currency });
|
|
5
|
+
const digits = formatter.resolvedOptions().maximumFractionDigits ?? 2;
|
|
6
|
+
const minor = BigInt(amountMinor), scale = 10n ** BigInt(digits), whole = minor / scale;
|
|
7
|
+
const fraction = new Intl.NumberFormat(locale, { minimumIntegerDigits: Math.max(1, digits), useGrouping: false }).format((minor < 0n ? -minor : minor) % scale);
|
|
8
|
+
return formatter.formatToParts(whole === 0n && minor < 0n ? -0 : whole).map(part => part.type === 'fraction' ? fraction : part.value).join('');
|
|
9
|
+
}
|
|
10
|
+
export function actionReviewDateEditor(range) {
|
|
11
|
+
const date = (value) => new Intl.DateTimeFormat('en-US', { month: 'short', day: 'numeric', year: 'numeric', timeZone: 'UTC' }).format(new Date(`${value}T00:00:00Z`));
|
|
12
|
+
if (range?.from && range.to)
|
|
13
|
+
return { partial: false, label: `${date(range.from)} – ${date(range.to)}` };
|
|
14
|
+
if (range?.from)
|
|
15
|
+
return { partial: true, label: `From ${date(range.from)}` };
|
|
16
|
+
if (range?.to)
|
|
17
|
+
return { partial: true, label: `Through ${date(range.to)}` };
|
|
18
|
+
return { partial: false, label: 'No date restriction' };
|
|
19
|
+
}
|
|
@@ -113,8 +113,8 @@ export declare const textAgentDefinitionSchema: z.ZodObject<{
|
|
|
113
113
|
string: "string";
|
|
114
114
|
number: "number";
|
|
115
115
|
boolean: "boolean";
|
|
116
|
-
text: "text";
|
|
117
116
|
enum: "enum";
|
|
117
|
+
text: "text";
|
|
118
118
|
}>;
|
|
119
119
|
required: z.ZodOptional<z.ZodBoolean>;
|
|
120
120
|
default: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
@@ -134,8 +134,8 @@ export declare const textAgentDefinitionSchema: z.ZodObject<{
|
|
|
134
134
|
publicOutputs: z.ZodOptional<z.ZodBoolean>;
|
|
135
135
|
permissions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
136
136
|
type: z.ZodEnum<{
|
|
137
|
-
user: "user";
|
|
138
137
|
group: "group";
|
|
138
|
+
user: "user";
|
|
139
139
|
}>;
|
|
140
140
|
id: z.ZodString;
|
|
141
141
|
role: z.ZodEnum<{
|
|
@@ -149,13 +149,13 @@ export declare const textAgentDefinitionSchema: z.ZodObject<{
|
|
|
149
149
|
voice: z.ZodOptional<z.ZodNever>;
|
|
150
150
|
}, z.core.$strict>;
|
|
151
151
|
export declare const voiceAgentDefinitionSchema: z.ZodObject<{
|
|
152
|
+
id: z.ZodString;
|
|
152
153
|
name: z.ZodString;
|
|
153
154
|
description: z.ZodOptional<z.ZodString>;
|
|
154
|
-
id: z.ZodString;
|
|
155
155
|
permissions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
156
156
|
type: z.ZodEnum<{
|
|
157
|
-
user: "user";
|
|
158
157
|
group: "group";
|
|
158
|
+
user: "user";
|
|
159
159
|
}>;
|
|
160
160
|
id: z.ZodString;
|
|
161
161
|
role: z.ZodEnum<{
|
|
@@ -412,8 +412,8 @@ export declare const agentDefinitionSchema: z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
412
412
|
string: "string";
|
|
413
413
|
number: "number";
|
|
414
414
|
boolean: "boolean";
|
|
415
|
-
text: "text";
|
|
416
415
|
enum: "enum";
|
|
416
|
+
text: "text";
|
|
417
417
|
}>;
|
|
418
418
|
required: z.ZodOptional<z.ZodBoolean>;
|
|
419
419
|
default: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
@@ -433,8 +433,8 @@ export declare const agentDefinitionSchema: z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
433
433
|
publicOutputs: z.ZodOptional<z.ZodBoolean>;
|
|
434
434
|
permissions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
435
435
|
type: z.ZodEnum<{
|
|
436
|
-
user: "user";
|
|
437
436
|
group: "group";
|
|
437
|
+
user: "user";
|
|
438
438
|
}>;
|
|
439
439
|
id: z.ZodString;
|
|
440
440
|
role: z.ZodEnum<{
|
|
@@ -447,13 +447,13 @@ export declare const agentDefinitionSchema: z.ZodDiscriminatedUnion<[z.ZodObject
|
|
|
447
447
|
mode: z.ZodOptional<z.ZodLiteral<"text">>;
|
|
448
448
|
voice: z.ZodOptional<z.ZodNever>;
|
|
449
449
|
}, z.core.$strict>, z.ZodObject<{
|
|
450
|
+
id: z.ZodString;
|
|
450
451
|
name: z.ZodString;
|
|
451
452
|
description: z.ZodOptional<z.ZodString>;
|
|
452
|
-
id: z.ZodString;
|
|
453
453
|
permissions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
454
454
|
type: z.ZodEnum<{
|
|
455
|
-
user: "user";
|
|
456
455
|
group: "group";
|
|
456
|
+
user: "user";
|
|
457
457
|
}>;
|
|
458
458
|
id: z.ZodString;
|
|
459
459
|
role: z.ZodEnum<{
|
package/dist/agent-definition.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { readToolReviews } from './tool-review.js';
|
|
1
2
|
import { createHash } from 'node:crypto';
|
|
2
3
|
import { z } from 'zod';
|
|
3
4
|
import { inputSchemaSchema } from './input-schema.js';
|
|
@@ -162,6 +163,12 @@ export const textAgentDefinitionSchema = textDefinitionBaseSchema.safeExtend({
|
|
|
162
163
|
mode: z.literal('text').optional(),
|
|
163
164
|
voice: z.never().optional(),
|
|
164
165
|
}).superRefine((definition, context) => {
|
|
166
|
+
try {
|
|
167
|
+
readToolReviews({ capabilities: definition.agentCapabilities, functions: definition.managedFunctions ?? [], servers: definition.mcpServers, tools: definition.tools });
|
|
168
|
+
}
|
|
169
|
+
catch (error) {
|
|
170
|
+
context.addIssue({ code: 'custom', path: ['agentCapabilities', 'toolReviews'], message: error instanceof Error ? error.message : 'Invalid Function tool review configuration' });
|
|
171
|
+
}
|
|
165
172
|
if (definition.framework === 'claude-agent' && (definition.clientProposals?.length ?? 0) > 0) {
|
|
166
173
|
context.addIssue({ code: 'custom', path: ['clientProposals'], message: 'Client proposals require the Vercel tool runtime' });
|
|
167
174
|
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/input-schema.d.ts
CHANGED
|
@@ -8,8 +8,8 @@ export declare const inputSchemaSchema: z.ZodObject<{
|
|
|
8
8
|
string: "string";
|
|
9
9
|
number: "number";
|
|
10
10
|
boolean: "boolean";
|
|
11
|
-
text: "text";
|
|
12
11
|
enum: "enum";
|
|
12
|
+
text: "text";
|
|
13
13
|
}>;
|
|
14
14
|
required: z.ZodOptional<z.ZodBoolean>;
|
|
15
15
|
default: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type ActionReviewCatalog, type ActionReviewRequest } from './action-review-contract.js';
|
|
3
|
+
export declare const toolReviewSchema: z.ZodObject<{
|
|
4
|
+
approval: z.ZodEnum<{
|
|
5
|
+
required: "required";
|
|
6
|
+
none: "none";
|
|
7
|
+
}>;
|
|
8
|
+
title: z.ZodOptional<z.ZodString>;
|
|
9
|
+
labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
10
|
+
}, z.core.$strict>;
|
|
11
|
+
export type ToolReview = z.infer<typeof toolReviewSchema>;
|
|
12
|
+
export declare const toolReviewBindingSchema: z.ZodObject<{
|
|
13
|
+
approval: z.ZodEnum<{
|
|
14
|
+
required: "required";
|
|
15
|
+
none: "none";
|
|
16
|
+
}>;
|
|
17
|
+
title: z.ZodOptional<z.ZodString>;
|
|
18
|
+
labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
19
|
+
tool: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
20
|
+
kind: z.ZodLiteral<"function">;
|
|
21
|
+
ref: z.ZodString;
|
|
22
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
23
|
+
kind: z.ZodLiteral<"mcp">;
|
|
24
|
+
server: z.ZodString;
|
|
25
|
+
name: z.ZodString;
|
|
26
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
27
|
+
kind: z.ZodLiteral<"builtin">;
|
|
28
|
+
name: z.ZodString;
|
|
29
|
+
}, z.core.$strict>], "kind">;
|
|
30
|
+
}, z.core.$strict>;
|
|
31
|
+
export type ToolReviewBinding = z.infer<typeof toolReviewBindingSchema>;
|
|
32
|
+
export declare function readToolReviews({ capabilities, functions, servers, tools }: {
|
|
33
|
+
capabilities?: unknown;
|
|
34
|
+
functions?: readonly string[];
|
|
35
|
+
servers?: readonly string[];
|
|
36
|
+
tools?: readonly string[];
|
|
37
|
+
}): ToolReviewBinding[];
|
|
38
|
+
export declare function toolReviewCard({ title, input, labels }: {
|
|
39
|
+
title: string;
|
|
40
|
+
input: unknown;
|
|
41
|
+
labels?: Record<string, string>;
|
|
42
|
+
}): {
|
|
43
|
+
spec: ActionReviewRequest;
|
|
44
|
+
catalog: ActionReviewCatalog;
|
|
45
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { prepareActionReview } from './action-review-contract.js';
|
|
3
|
+
export const toolReviewSchema = z.strictObject({
|
|
4
|
+
approval: z.enum(['required', 'none']),
|
|
5
|
+
title: z.string().min(1).max(160).optional(),
|
|
6
|
+
labels: z.record(z.string().min(1).max(128), z.string().min(1).max(160)).optional(),
|
|
7
|
+
});
|
|
8
|
+
export const toolReviewBindingSchema = toolReviewSchema.extend({
|
|
9
|
+
tool: z.discriminatedUnion('kind', [
|
|
10
|
+
z.strictObject({ kind: z.literal('function'), ref: z.string().min(1) }),
|
|
11
|
+
z.strictObject({ kind: z.literal('mcp'), server: z.string().min(1), name: z.string().min(1) }),
|
|
12
|
+
z.strictObject({ kind: z.literal('builtin'), name: z.string().min(1) }),
|
|
13
|
+
]),
|
|
14
|
+
});
|
|
15
|
+
export function readToolReviews({ capabilities, functions = [], servers = [], tools = [] }) {
|
|
16
|
+
const configured = capabilities && typeof capabilities === 'object' ? Reflect.get(capabilities, 'toolReviews') : undefined;
|
|
17
|
+
if (configured === undefined)
|
|
18
|
+
return [];
|
|
19
|
+
const bindings = z.array(toolReviewBindingSchema).max(100).parse(configured);
|
|
20
|
+
const seen = new Set();
|
|
21
|
+
for (const { tool } of bindings) {
|
|
22
|
+
const key = JSON.stringify(tool);
|
|
23
|
+
if (seen.has(key))
|
|
24
|
+
throw new Error('Duplicate tool review binding');
|
|
25
|
+
seen.add(key);
|
|
26
|
+
const declared = tool.kind === 'function' ? functions.includes(tool.ref) : tool.kind === 'mcp' ? servers.includes(tool.server) : tools.includes(tool.name);
|
|
27
|
+
if (!declared)
|
|
28
|
+
throw new Error('Review policy must reference a declared tool or integration');
|
|
29
|
+
}
|
|
30
|
+
return bindings;
|
|
31
|
+
}
|
|
32
|
+
export function toolReviewCard({ title, input, labels = {} }) {
|
|
33
|
+
const entries = input && typeof input === 'object' && !Array.isArray(input) ? Object.entries(input) : [['input', input]];
|
|
34
|
+
if (entries.length > 24)
|
|
35
|
+
throw new Error('Too many fields for an action review card');
|
|
36
|
+
const display = (value) => {
|
|
37
|
+
if (value === null || typeof value === 'boolean')
|
|
38
|
+
return value;
|
|
39
|
+
const text = typeof value === 'string' ? value : JSON.stringify(value, null, 2) ?? '—';
|
|
40
|
+
if (text.length > 5000)
|
|
41
|
+
throw new Error('Argument is too large for an action review card');
|
|
42
|
+
return text;
|
|
43
|
+
};
|
|
44
|
+
const changes = entries.length ? entries.map(([field, value]) => ({ field, value: display(value) })) : [{ field: 'arguments', value: '{}' }];
|
|
45
|
+
const catalog = { types: { action: { label: title, canCreate: false, canInvoke: true, fields: changes.map(({ field, value }) => ({
|
|
46
|
+
key: field, label: Object.hasOwn(labels, field) ? labels[field] : field, kind: typeof value === 'boolean' ? 'boolean' : 'text', editable: true,
|
|
47
|
+
})) } }, records: [] };
|
|
48
|
+
const spec = { version: 1, action: 'invoke', target: { type: 'action', id: null }, changes, references: [] };
|
|
49
|
+
prepareActionReview(spec, catalog);
|
|
50
|
+
return { spec, catalog };
|
|
51
|
+
}
|
package/dist/voice-api.d.ts
CHANGED
|
@@ -398,13 +398,13 @@ export declare const voiceDraftReadResponseSchema: z.ZodObject<{
|
|
|
398
398
|
agentId: z.ZodString;
|
|
399
399
|
revision: z.ZodNumber;
|
|
400
400
|
definition: z.ZodObject<{
|
|
401
|
+
id: z.ZodString;
|
|
401
402
|
name: z.ZodString;
|
|
402
403
|
description: z.ZodOptional<z.ZodString>;
|
|
403
|
-
id: z.ZodString;
|
|
404
404
|
permissions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
405
405
|
type: z.ZodEnum<{
|
|
406
|
-
user: "user";
|
|
407
406
|
group: "group";
|
|
407
|
+
user: "user";
|
|
408
408
|
}>;
|
|
409
409
|
id: z.ZodString;
|
|
410
410
|
role: z.ZodEnum<{
|
|
@@ -583,13 +583,13 @@ export declare const voiceDraftReadResponseSchema: z.ZodObject<{
|
|
|
583
583
|
updatedAt: z.ZodISODateTime;
|
|
584
584
|
}, z.core.$strict>;
|
|
585
585
|
export declare const voiceDefinitionExportResponseSchema: z.ZodObject<{
|
|
586
|
+
id: z.ZodString;
|
|
586
587
|
name: z.ZodString;
|
|
587
588
|
description: z.ZodOptional<z.ZodString>;
|
|
588
|
-
id: z.ZodString;
|
|
589
589
|
permissions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
590
590
|
type: z.ZodEnum<{
|
|
591
|
-
user: "user";
|
|
592
591
|
group: "group";
|
|
592
|
+
user: "user";
|
|
593
593
|
}>;
|
|
594
594
|
id: z.ZodString;
|
|
595
595
|
role: z.ZodEnum<{
|
package/dist/voice-drafts.d.ts
CHANGED
|
@@ -7,13 +7,13 @@ export declare const voiceDraftSchema: z.ZodObject<{
|
|
|
7
7
|
agentId: z.ZodString;
|
|
8
8
|
revision: z.ZodNumber;
|
|
9
9
|
definition: z.ZodObject<{
|
|
10
|
+
id: z.ZodString;
|
|
10
11
|
name: z.ZodString;
|
|
11
12
|
description: z.ZodOptional<z.ZodString>;
|
|
12
|
-
id: z.ZodString;
|
|
13
13
|
permissions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
14
14
|
type: z.ZodEnum<{
|
|
15
|
-
user: "user";
|
|
16
15
|
group: "group";
|
|
16
|
+
user: "user";
|
|
17
17
|
}>;
|
|
18
18
|
id: z.ZodString;
|
|
19
19
|
role: z.ZodEnum<{
|
|
@@ -196,13 +196,13 @@ export declare const voiceDraftSaveRequestSchema: z.ZodObject<{
|
|
|
196
196
|
agentId: z.ZodString;
|
|
197
197
|
expectedRevision: z.ZodNullable<z.ZodNumber>;
|
|
198
198
|
definition: z.ZodObject<{
|
|
199
|
+
id: z.ZodString;
|
|
199
200
|
name: z.ZodString;
|
|
200
201
|
description: z.ZodOptional<z.ZodString>;
|
|
201
|
-
id: z.ZodString;
|
|
202
202
|
permissions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
203
203
|
type: z.ZodEnum<{
|
|
204
|
-
user: "user";
|
|
205
204
|
group: "group";
|
|
205
|
+
user: "user";
|
|
206
206
|
}>;
|
|
207
207
|
id: z.ZodString;
|
|
208
208
|
role: z.ZodEnum<{
|
package/dist/voice-release.d.ts
CHANGED
|
@@ -2,13 +2,13 @@ import { z } from 'zod';
|
|
|
2
2
|
export declare const voiceDefinitionSnapshotSchema: z.ZodObject<{
|
|
3
3
|
agentVersionId: z.ZodString;
|
|
4
4
|
definition: z.ZodObject<{
|
|
5
|
+
id: z.ZodString;
|
|
5
6
|
name: z.ZodString;
|
|
6
7
|
description: z.ZodOptional<z.ZodString>;
|
|
7
|
-
id: z.ZodString;
|
|
8
8
|
permissions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
9
9
|
type: z.ZodEnum<{
|
|
10
|
-
user: "user";
|
|
11
10
|
group: "group";
|
|
11
|
+
user: "user";
|
|
12
12
|
}>;
|
|
13
13
|
id: z.ZodString;
|
|
14
14
|
role: z.ZodEnum<{
|
|
@@ -208,13 +208,13 @@ export declare const voiceReleaseRecordSchema: z.ZodObject<{
|
|
|
208
208
|
snapshot: z.ZodNullable<z.ZodObject<{
|
|
209
209
|
agentVersionId: z.ZodString;
|
|
210
210
|
definition: z.ZodObject<{
|
|
211
|
+
id: z.ZodString;
|
|
211
212
|
name: z.ZodString;
|
|
212
213
|
description: z.ZodOptional<z.ZodString>;
|
|
213
|
-
id: z.ZodString;
|
|
214
214
|
permissions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
215
215
|
type: z.ZodEnum<{
|
|
216
|
-
user: "user";
|
|
217
216
|
group: "group";
|
|
217
|
+
user: "user";
|
|
218
218
|
}>;
|
|
219
219
|
id: z.ZodString;
|
|
220
220
|
role: z.ZodEnum<{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sequenceholdings/agent-spec",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "Typed agent definition contract, compiler, hashing, and migration utilities",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": {
|
|
@@ -35,6 +35,11 @@
|
|
|
35
35
|
"types": "./dist/voice-runs-audio.d.ts",
|
|
36
36
|
"import": "./dist/voice-runs-audio.js",
|
|
37
37
|
"default": "./dist/voice-runs-audio.js"
|
|
38
|
+
},
|
|
39
|
+
"./action-review": {
|
|
40
|
+
"types": "./dist/action-review.d.ts",
|
|
41
|
+
"import": "./dist/action-review.js",
|
|
42
|
+
"default": "./dist/action-review.js"
|
|
38
43
|
}
|
|
39
44
|
},
|
|
40
45
|
"files": [
|