@nixet/contracts 0.0.0-stage → 0.1.1
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/CHANGELOG.md +17 -0
- package/LICENSE +21 -0
- package/README.md +12 -2
- package/dist/cjs/domains/agents.d.ts +284 -0
- package/dist/cjs/domains/agents.js +244 -0
- package/dist/cjs/domains/api-keys.d.ts +265 -0
- package/dist/cjs/domains/api-keys.js +87 -0
- package/dist/cjs/domains/billing.d.ts +98 -0
- package/dist/cjs/domains/billing.js +122 -0
- package/dist/cjs/domains/connections.d.ts +101 -0
- package/dist/cjs/domains/connections.js +130 -0
- package/dist/cjs/domains/conversations.d.ts +113 -0
- package/dist/cjs/domains/conversations.js +85 -0
- package/dist/cjs/domains/documents.d.ts +48 -0
- package/dist/cjs/domains/documents.js +64 -0
- package/dist/cjs/domains/guardrails.d.ts +213 -0
- package/dist/cjs/domains/guardrails.js +206 -0
- package/dist/cjs/domains/identity.d.ts +55 -0
- package/dist/cjs/domains/identity.js +26 -0
- package/dist/cjs/domains/knowledge.d.ts +167 -0
- package/dist/cjs/domains/knowledge.js +174 -0
- package/dist/cjs/domains/mcp.d.ts +189 -0
- package/dist/cjs/domains/mcp.js +183 -0
- package/dist/cjs/domains/memory.d.ts +109 -0
- package/dist/cjs/domains/memory.js +92 -0
- package/dist/cjs/domains/redaction.d.ts +181 -0
- package/dist/cjs/domains/redaction.js +166 -0
- package/dist/cjs/domains/runs.d.ts +260 -0
- package/dist/cjs/domains/runs.js +260 -0
- package/dist/cjs/domains/secrets.d.ts +56 -0
- package/dist/cjs/domains/secrets.js +72 -0
- package/dist/cjs/domains/skills.d.ts +70 -0
- package/dist/cjs/domains/skills.js +82 -0
- package/dist/cjs/domains/tasks.d.ts +111 -0
- package/dist/cjs/domains/tasks.js +113 -0
- package/dist/cjs/domains/tools.d.ts +159 -0
- package/dist/cjs/domains/tools.js +203 -0
- package/dist/cjs/domains/users.d.ts +40 -0
- package/dist/cjs/domains/users.js +48 -0
- package/dist/cjs/index.d.ts +25 -0
- package/dist/cjs/index.js +41 -0
- package/dist/cjs/primitives.d.ts +75 -0
- package/dist/cjs/primitives.js +117 -0
- package/dist/esm/domains/agents.js +239 -0
- package/dist/esm/domains/api-keys.js +83 -0
- package/dist/esm/domains/billing.js +116 -0
- package/dist/esm/domains/connections.js +127 -0
- package/dist/esm/domains/conversations.js +82 -0
- package/dist/esm/domains/documents.js +61 -0
- package/dist/esm/domains/guardrails.js +202 -0
- package/dist/esm/domains/identity.js +23 -0
- package/dist/esm/domains/knowledge.js +170 -0
- package/dist/esm/domains/mcp.js +178 -0
- package/dist/esm/domains/memory.js +89 -0
- package/dist/esm/domains/redaction.js +162 -0
- package/dist/esm/domains/runs.js +256 -0
- package/dist/esm/domains/secrets.js +68 -0
- package/dist/esm/domains/skills.js +79 -0
- package/dist/esm/domains/tasks.js +109 -0
- package/dist/esm/domains/tools.js +196 -0
- package/dist/esm/domains/users.js +45 -0
- package/dist/esm/index.js +25 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/primitives.js +114 -0
- package/package.json +47 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@nixet/contracts` are recorded here, following
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and
|
|
5
|
+
[Semantic Versioning](https://semver.org/).
|
|
6
|
+
|
|
7
|
+
## [0.1.1] — 2026-11-10
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- `CreateGuardrailParams`, the request type a caller writes. Fields with
|
|
12
|
+
defaults (`patterns`, `topics`) are optional in it, where
|
|
13
|
+
`CreateGuardrailRequest` describes the parsed result and requires them.
|
|
14
|
+
|
|
15
|
+
## [0.1.0] — 2026-11-09
|
|
16
|
+
|
|
17
|
+
First public release: request, response and event schemas for the Nixet API.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Nixet
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @nixet/contracts
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Request, response and event schemas for the Nixet API, as [Zod](https://zod.dev) schemas and the TypeScript types inferred from them.
|
|
4
|
+
|
|
5
|
+
Most applications want [`@nixet/sdk`](https://www.npmjs.com/package/@nixet/sdk), which depends on this package for its types. Use this one directly to validate payloads yourself — for example a run event received over a stream.
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { runEventSchema } from "@nixet/contracts";
|
|
9
|
+
|
|
10
|
+
const event = runEventSchema.parse(JSON.parse(line));
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
MIT licensed.
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Agents and their versions.
|
|
4
|
+
*
|
|
5
|
+
* An agent is a stable identity. A version is an immutable snapshot of the
|
|
6
|
+
* configuration used to build it: instructions, model, tools. A run pins one
|
|
7
|
+
* version, so a run can always be reproduced from what it recorded.
|
|
8
|
+
*/
|
|
9
|
+
export declare const MAX_AGENT_NAME = 80;
|
|
10
|
+
export declare const MAX_INSTRUCTIONS = 20000;
|
|
11
|
+
export declare const agentSchema: z.ZodObject<{
|
|
12
|
+
id: z.ZodString;
|
|
13
|
+
name: z.ZodString;
|
|
14
|
+
description: z.ZodNullable<z.ZodString>;
|
|
15
|
+
current_version: z.ZodNullable<z.ZodString>;
|
|
16
|
+
created_at: z.ZodString;
|
|
17
|
+
updated_at: z.ZodString;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
export type Agent = z.infer<typeof agentSchema>;
|
|
20
|
+
/** Ownership is never accepted from a body: scope comes from the API key. */
|
|
21
|
+
export declare const createAgentSchema: z.ZodObject<{
|
|
22
|
+
name: z.ZodString;
|
|
23
|
+
description: z.ZodOptional<z.ZodString>;
|
|
24
|
+
}, z.core.$strict>;
|
|
25
|
+
export type CreateAgentRequest = z.infer<typeof createAgentSchema>;
|
|
26
|
+
/**
|
|
27
|
+
* Model selection.
|
|
28
|
+
*
|
|
29
|
+
* `nix` is the managed default and needs no customer credential. The other
|
|
30
|
+
* providers use a key the customer supplies. The model behind `nix` is
|
|
31
|
+
* deliberately not part of the contract.
|
|
32
|
+
*/
|
|
33
|
+
export declare const providerSchema: z.ZodEnum<{
|
|
34
|
+
nix: "nix";
|
|
35
|
+
openai: "openai";
|
|
36
|
+
anthropic: "anthropic";
|
|
37
|
+
}>;
|
|
38
|
+
export type Provider = z.infer<typeof providerSchema>;
|
|
39
|
+
/**
|
|
40
|
+
* Capability tier for the managed `nix` provider.
|
|
41
|
+
*
|
|
42
|
+
* A tier states intent rather than naming a model, so the backing model can
|
|
43
|
+
* change without breaking callers and without disclosing which model serves a
|
|
44
|
+
* request. Callers who need an exact model bring their own provider key.
|
|
45
|
+
*/
|
|
46
|
+
export declare const tierSchema: z.ZodEnum<{
|
|
47
|
+
fast: "fast";
|
|
48
|
+
balanced: "balanced";
|
|
49
|
+
powerful: "powerful";
|
|
50
|
+
}>;
|
|
51
|
+
export type Tier = z.infer<typeof tierSchema>;
|
|
52
|
+
export declare const modelSchema: z.ZodObject<{
|
|
53
|
+
provider: z.ZodDefault<z.ZodEnum<{
|
|
54
|
+
nix: "nix";
|
|
55
|
+
openai: "openai";
|
|
56
|
+
anthropic: "anthropic";
|
|
57
|
+
}>>;
|
|
58
|
+
model: z.ZodOptional<z.ZodString>;
|
|
59
|
+
tier: z.ZodOptional<z.ZodEnum<{
|
|
60
|
+
fast: "fast";
|
|
61
|
+
balanced: "balanced";
|
|
62
|
+
powerful: "powerful";
|
|
63
|
+
}>>;
|
|
64
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
65
|
+
max_tokens: z.ZodOptional<z.ZodNumber>;
|
|
66
|
+
}, z.core.$strict>;
|
|
67
|
+
export type ModelConfig = z.infer<typeof modelSchema>;
|
|
68
|
+
/** A tool the runtime resolves by name from its registry. */
|
|
69
|
+
export declare const toolRefSchema: z.ZodObject<{
|
|
70
|
+
name: z.ZodString;
|
|
71
|
+
}, z.core.$strict>;
|
|
72
|
+
/** Skills an agent version uses, stored already resolved to a version. */
|
|
73
|
+
export declare const agentSkillSchema: z.ZodObject<{
|
|
74
|
+
name: z.ZodString;
|
|
75
|
+
version: z.ZodString;
|
|
76
|
+
digest: z.ZodString;
|
|
77
|
+
}, z.core.$strip>;
|
|
78
|
+
/**
|
|
79
|
+
* A placeholder an agent's instructions may contain.
|
|
80
|
+
*
|
|
81
|
+
* Lowercase, because `{{Data_Context}}` and `{{data_context}}` being different
|
|
82
|
+
* slots is a bug waiting to be filed.
|
|
83
|
+
*/
|
|
84
|
+
export declare const variableNameSchema: z.ZodString;
|
|
85
|
+
/** The most a run may substitute into one placeholder. */
|
|
86
|
+
export declare const MAX_VARIABLE_VALUE = 10000;
|
|
87
|
+
/**
|
|
88
|
+
* Finds `{{name}}` in instructions.
|
|
89
|
+
*
|
|
90
|
+
* Deliberately strict: no spaces inside the braces, no nesting, no
|
|
91
|
+
* expressions. A template language here would be a second thing to learn and a
|
|
92
|
+
* second thing to get wrong, and the requirement is substitution.
|
|
93
|
+
*/
|
|
94
|
+
export declare const VARIABLE_PATTERN: RegExp;
|
|
95
|
+
/** Every placeholder an instruction string names, in order, without repeats. */
|
|
96
|
+
export declare function variablesIn(instructions: string): string[];
|
|
97
|
+
/**
|
|
98
|
+
* Substitute a run's values into a version's instructions.
|
|
99
|
+
*
|
|
100
|
+
* Values are inserted literally and never re-scanned, so a value that itself
|
|
101
|
+
* contains `{{other}}` cannot pull in a second variable. That matters because
|
|
102
|
+
* values come from a customer's backend at run time while the template was
|
|
103
|
+
* fixed at publish: re-scanning would let a value reach a placeholder the
|
|
104
|
+
* version never declared.
|
|
105
|
+
*/
|
|
106
|
+
export declare function applyVariables(instructions: string, values: Record<string, string>): string;
|
|
107
|
+
export declare const agentVersionSchema: z.ZodObject<{
|
|
108
|
+
id: z.ZodString;
|
|
109
|
+
agent_id: z.ZodString;
|
|
110
|
+
version: z.ZodString;
|
|
111
|
+
instructions: z.ZodString;
|
|
112
|
+
model: z.ZodObject<{
|
|
113
|
+
provider: z.ZodDefault<z.ZodEnum<{
|
|
114
|
+
nix: "nix";
|
|
115
|
+
openai: "openai";
|
|
116
|
+
anthropic: "anthropic";
|
|
117
|
+
}>>;
|
|
118
|
+
model: z.ZodOptional<z.ZodString>;
|
|
119
|
+
tier: z.ZodOptional<z.ZodEnum<{
|
|
120
|
+
fast: "fast";
|
|
121
|
+
balanced: "balanced";
|
|
122
|
+
powerful: "powerful";
|
|
123
|
+
}>>;
|
|
124
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
125
|
+
max_tokens: z.ZodOptional<z.ZodNumber>;
|
|
126
|
+
}, z.core.$strict>;
|
|
127
|
+
tools: z.ZodArray<z.ZodObject<{
|
|
128
|
+
name: z.ZodString;
|
|
129
|
+
}, z.core.$strict>>;
|
|
130
|
+
skills: z.ZodArray<z.ZodObject<{
|
|
131
|
+
name: z.ZodString;
|
|
132
|
+
version: z.ZodString;
|
|
133
|
+
digest: z.ZodString;
|
|
134
|
+
}, z.core.$strip>>;
|
|
135
|
+
redaction: z.ZodObject<{
|
|
136
|
+
mode: z.ZodDefault<z.ZodEnum<{
|
|
137
|
+
standard: "standard";
|
|
138
|
+
off: "off";
|
|
139
|
+
structured: "structured";
|
|
140
|
+
strict: "strict";
|
|
141
|
+
}>>;
|
|
142
|
+
reversible: z.ZodDefault<z.ZodBoolean>;
|
|
143
|
+
minimum_confidence: z.ZodDefault<z.ZodNumber>;
|
|
144
|
+
labels: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
145
|
+
GIVEN_NAME: "GIVEN_NAME";
|
|
146
|
+
SURNAME: "SURNAME";
|
|
147
|
+
STREET_NAME: "STREET_NAME";
|
|
148
|
+
BUILDING_NUMBER: "BUILDING_NUMBER";
|
|
149
|
+
SECONDARY_ADDRESS: "SECONDARY_ADDRESS";
|
|
150
|
+
CITY: "CITY";
|
|
151
|
+
STATE: "STATE";
|
|
152
|
+
ZIP_CODE: "ZIP_CODE";
|
|
153
|
+
EMAIL: "EMAIL";
|
|
154
|
+
PHONE: "PHONE";
|
|
155
|
+
CREDIT_CARD: "CREDIT_CARD";
|
|
156
|
+
BANK_ACCOUNT: "BANK_ACCOUNT";
|
|
157
|
+
ROUTING_NUMBER: "ROUTING_NUMBER";
|
|
158
|
+
IP_ADDRESS: "IP_ADDRESS";
|
|
159
|
+
URL: "URL";
|
|
160
|
+
GOVERNMENT_ID: "GOVERNMENT_ID";
|
|
161
|
+
PASSPORT: "PASSPORT";
|
|
162
|
+
DRIVERS_LICENSE: "DRIVERS_LICENSE";
|
|
163
|
+
TAX_ID: "TAX_ID";
|
|
164
|
+
SSN: "SSN";
|
|
165
|
+
IMEI: "IMEI";
|
|
166
|
+
ORG: "ORG";
|
|
167
|
+
}>>>;
|
|
168
|
+
retain_for: z.ZodDefault<z.ZodEnum<{
|
|
169
|
+
"1h": "1h";
|
|
170
|
+
"24h": "24h";
|
|
171
|
+
"7d": "7d";
|
|
172
|
+
"30d": "30d";
|
|
173
|
+
}>>;
|
|
174
|
+
}, z.core.$strict>;
|
|
175
|
+
mcp_servers: z.ZodArray<z.ZodString>;
|
|
176
|
+
tool_policies: z.ZodRecord<z.ZodString, z.ZodEnum<{
|
|
177
|
+
allow: "allow";
|
|
178
|
+
ask: "ask";
|
|
179
|
+
deny: "deny";
|
|
180
|
+
}>>;
|
|
181
|
+
knowledge_collections: z.ZodArray<z.ZodString>;
|
|
182
|
+
variables: z.ZodArray<z.ZodString>;
|
|
183
|
+
guardrails: z.ZodObject<{
|
|
184
|
+
input: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
185
|
+
output: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
186
|
+
tool_result: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
187
|
+
mode: z.ZodDefault<z.ZodEnum<{
|
|
188
|
+
fail_fast: "fail_fast";
|
|
189
|
+
run_all: "run_all";
|
|
190
|
+
}>>;
|
|
191
|
+
on_block: z.ZodDefault<z.ZodEnum<{
|
|
192
|
+
error: "error";
|
|
193
|
+
return_message: "return_message";
|
|
194
|
+
}>>;
|
|
195
|
+
}, z.core.$strict>;
|
|
196
|
+
digest: z.ZodString;
|
|
197
|
+
created_at: z.ZodString;
|
|
198
|
+
}, z.core.$strip>;
|
|
199
|
+
export type AgentVersion = z.infer<typeof agentVersionSchema>;
|
|
200
|
+
export declare const createAgentVersionSchema: z.ZodObject<{
|
|
201
|
+
instructions: z.ZodString;
|
|
202
|
+
model: z.ZodDefault<z.ZodObject<{
|
|
203
|
+
provider: z.ZodDefault<z.ZodEnum<{
|
|
204
|
+
nix: "nix";
|
|
205
|
+
openai: "openai";
|
|
206
|
+
anthropic: "anthropic";
|
|
207
|
+
}>>;
|
|
208
|
+
model: z.ZodOptional<z.ZodString>;
|
|
209
|
+
tier: z.ZodOptional<z.ZodEnum<{
|
|
210
|
+
fast: "fast";
|
|
211
|
+
balanced: "balanced";
|
|
212
|
+
powerful: "powerful";
|
|
213
|
+
}>>;
|
|
214
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
215
|
+
max_tokens: z.ZodOptional<z.ZodNumber>;
|
|
216
|
+
}, z.core.$strict>>;
|
|
217
|
+
tools: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
218
|
+
name: z.ZodString;
|
|
219
|
+
}, z.core.$strict>>>;
|
|
220
|
+
skills: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
221
|
+
redaction: z.ZodDefault<z.ZodObject<{
|
|
222
|
+
mode: z.ZodDefault<z.ZodEnum<{
|
|
223
|
+
standard: "standard";
|
|
224
|
+
off: "off";
|
|
225
|
+
structured: "structured";
|
|
226
|
+
strict: "strict";
|
|
227
|
+
}>>;
|
|
228
|
+
reversible: z.ZodDefault<z.ZodBoolean>;
|
|
229
|
+
minimum_confidence: z.ZodDefault<z.ZodNumber>;
|
|
230
|
+
labels: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
231
|
+
GIVEN_NAME: "GIVEN_NAME";
|
|
232
|
+
SURNAME: "SURNAME";
|
|
233
|
+
STREET_NAME: "STREET_NAME";
|
|
234
|
+
BUILDING_NUMBER: "BUILDING_NUMBER";
|
|
235
|
+
SECONDARY_ADDRESS: "SECONDARY_ADDRESS";
|
|
236
|
+
CITY: "CITY";
|
|
237
|
+
STATE: "STATE";
|
|
238
|
+
ZIP_CODE: "ZIP_CODE";
|
|
239
|
+
EMAIL: "EMAIL";
|
|
240
|
+
PHONE: "PHONE";
|
|
241
|
+
CREDIT_CARD: "CREDIT_CARD";
|
|
242
|
+
BANK_ACCOUNT: "BANK_ACCOUNT";
|
|
243
|
+
ROUTING_NUMBER: "ROUTING_NUMBER";
|
|
244
|
+
IP_ADDRESS: "IP_ADDRESS";
|
|
245
|
+
URL: "URL";
|
|
246
|
+
GOVERNMENT_ID: "GOVERNMENT_ID";
|
|
247
|
+
PASSPORT: "PASSPORT";
|
|
248
|
+
DRIVERS_LICENSE: "DRIVERS_LICENSE";
|
|
249
|
+
TAX_ID: "TAX_ID";
|
|
250
|
+
SSN: "SSN";
|
|
251
|
+
IMEI: "IMEI";
|
|
252
|
+
ORG: "ORG";
|
|
253
|
+
}>>>;
|
|
254
|
+
retain_for: z.ZodDefault<z.ZodEnum<{
|
|
255
|
+
"1h": "1h";
|
|
256
|
+
"24h": "24h";
|
|
257
|
+
"7d": "7d";
|
|
258
|
+
"30d": "30d";
|
|
259
|
+
}>>;
|
|
260
|
+
}, z.core.$strict>>;
|
|
261
|
+
mcp_servers: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
262
|
+
tool_policies: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodEnum<{
|
|
263
|
+
allow: "allow";
|
|
264
|
+
ask: "ask";
|
|
265
|
+
deny: "deny";
|
|
266
|
+
}>>>;
|
|
267
|
+
knowledge_collections: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
268
|
+
variables: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
269
|
+
guardrails: z.ZodDefault<z.ZodObject<{
|
|
270
|
+
input: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
271
|
+
output: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
272
|
+
tool_result: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
273
|
+
mode: z.ZodDefault<z.ZodEnum<{
|
|
274
|
+
fail_fast: "fail_fast";
|
|
275
|
+
run_all: "run_all";
|
|
276
|
+
}>>;
|
|
277
|
+
on_block: z.ZodDefault<z.ZodEnum<{
|
|
278
|
+
error: "error";
|
|
279
|
+
return_message: "return_message";
|
|
280
|
+
}>>;
|
|
281
|
+
}, z.core.$strict>>;
|
|
282
|
+
publish: z.ZodDefault<z.ZodBoolean>;
|
|
283
|
+
}, z.core.$strict>;
|
|
284
|
+
export type CreateAgentVersionRequest = z.infer<typeof createAgentVersionSchema>;
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createAgentVersionSchema = exports.agentVersionSchema = exports.VARIABLE_PATTERN = exports.MAX_VARIABLE_VALUE = exports.variableNameSchema = exports.agentSkillSchema = exports.toolRefSchema = exports.modelSchema = exports.tierSchema = exports.providerSchema = exports.createAgentSchema = exports.agentSchema = exports.MAX_INSTRUCTIONS = exports.MAX_AGENT_NAME = void 0;
|
|
4
|
+
exports.variablesIn = variablesIn;
|
|
5
|
+
exports.applyVariables = applyVariables;
|
|
6
|
+
const zod_1 = require("zod");
|
|
7
|
+
const redaction_js_1 = require("./redaction.js");
|
|
8
|
+
const tools_js_1 = require("./tools.js");
|
|
9
|
+
const guardrails_js_1 = require("./guardrails.js");
|
|
10
|
+
/**
|
|
11
|
+
* Agents and their versions.
|
|
12
|
+
*
|
|
13
|
+
* An agent is a stable identity. A version is an immutable snapshot of the
|
|
14
|
+
* configuration used to build it: instructions, model, tools. A run pins one
|
|
15
|
+
* version, so a run can always be reproduced from what it recorded.
|
|
16
|
+
*/
|
|
17
|
+
exports.MAX_AGENT_NAME = 80;
|
|
18
|
+
exports.MAX_INSTRUCTIONS = 20_000;
|
|
19
|
+
exports.agentSchema = zod_1.z.object({
|
|
20
|
+
id: zod_1.z.string().describe("Unique identifier, prefixed `agt_`."),
|
|
21
|
+
name: zod_1.z.string().describe("Human-readable name."),
|
|
22
|
+
description: zod_1.z.string().nullable().describe("Optional summary of what the agent does."),
|
|
23
|
+
current_version: zod_1.z
|
|
24
|
+
.string()
|
|
25
|
+
.nullable()
|
|
26
|
+
.describe("Version used when a run does not name one. Null until the first publish."),
|
|
27
|
+
created_at: zod_1.z.string().describe("RFC 3339 creation timestamp."),
|
|
28
|
+
updated_at: zod_1.z.string().describe("RFC 3339 timestamp of the last change."),
|
|
29
|
+
});
|
|
30
|
+
/** Ownership is never accepted from a body: scope comes from the API key. */
|
|
31
|
+
exports.createAgentSchema = zod_1.z
|
|
32
|
+
.object({
|
|
33
|
+
name: zod_1.z.string().trim().min(1).max(exports.MAX_AGENT_NAME).describe("Human-readable name."),
|
|
34
|
+
description: zod_1.z
|
|
35
|
+
.string()
|
|
36
|
+
.trim()
|
|
37
|
+
.max(500)
|
|
38
|
+
.optional()
|
|
39
|
+
.describe("Optional summary of what the agent does."),
|
|
40
|
+
})
|
|
41
|
+
.strict();
|
|
42
|
+
/**
|
|
43
|
+
* Model selection.
|
|
44
|
+
*
|
|
45
|
+
* `nix` is the managed default and needs no customer credential. The other
|
|
46
|
+
* providers use a key the customer supplies. The model behind `nix` is
|
|
47
|
+
* deliberately not part of the contract.
|
|
48
|
+
*/
|
|
49
|
+
exports.providerSchema = zod_1.z.enum(["nix", "openai", "anthropic"]);
|
|
50
|
+
/**
|
|
51
|
+
* Capability tier for the managed `nix` provider.
|
|
52
|
+
*
|
|
53
|
+
* A tier states intent rather than naming a model, so the backing model can
|
|
54
|
+
* change without breaking callers and without disclosing which model serves a
|
|
55
|
+
* request. Callers who need an exact model bring their own provider key.
|
|
56
|
+
*/
|
|
57
|
+
exports.tierSchema = zod_1.z.enum(["fast", "balanced", "powerful"]);
|
|
58
|
+
exports.modelSchema = zod_1.z
|
|
59
|
+
.object({
|
|
60
|
+
provider: exports.providerSchema
|
|
61
|
+
.default("nix")
|
|
62
|
+
.describe("`nix` is managed and needs no key of your own."),
|
|
63
|
+
model: zod_1.z
|
|
64
|
+
.string()
|
|
65
|
+
.min(1)
|
|
66
|
+
.max(100)
|
|
67
|
+
.optional()
|
|
68
|
+
.describe("Model identifier. Required for `openai` and `anthropic`; rejected for `nix`, which selects by tier."),
|
|
69
|
+
tier: exports.tierSchema
|
|
70
|
+
.optional()
|
|
71
|
+
.describe("Capability tier for `nix`, defaulting to `balanced`. Rejected for other providers."),
|
|
72
|
+
temperature: zod_1.z.number().min(0).max(2).optional().describe("Sampling temperature."),
|
|
73
|
+
max_tokens: zod_1.z
|
|
74
|
+
.number()
|
|
75
|
+
.int()
|
|
76
|
+
.min(1)
|
|
77
|
+
.max(200_000)
|
|
78
|
+
.optional()
|
|
79
|
+
.describe("Upper bound on generated tokens."),
|
|
80
|
+
})
|
|
81
|
+
.strict()
|
|
82
|
+
.superRefine((value, ctx) => {
|
|
83
|
+
if (value.provider === "nix" && value.model) {
|
|
84
|
+
// Accepting a model id here would publish a third party's model names as
|
|
85
|
+
// part of this contract and undo the non-disclosure the tier provides.
|
|
86
|
+
ctx.addIssue({
|
|
87
|
+
code: "custom",
|
|
88
|
+
path: ["model"],
|
|
89
|
+
message: "The nix provider selects a model by tier. Use `tier` instead.",
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
if (value.provider !== "nix") {
|
|
93
|
+
if (!value.model) {
|
|
94
|
+
ctx.addIssue({
|
|
95
|
+
code: "custom",
|
|
96
|
+
path: ["model"],
|
|
97
|
+
message: `A model is required for the ${value.provider} provider.`,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
if (value.tier) {
|
|
101
|
+
ctx.addIssue({
|
|
102
|
+
code: "custom",
|
|
103
|
+
path: ["tier"],
|
|
104
|
+
message: "Tiers apply only to the nix provider. Name a model instead.",
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
/** A tool the runtime resolves by name from its registry. */
|
|
110
|
+
exports.toolRefSchema = zod_1.z.object({ name: zod_1.z.string().max(80) }).strict();
|
|
111
|
+
/** Skills an agent version uses, stored already resolved to a version. */
|
|
112
|
+
exports.agentSkillSchema = zod_1.z.object({
|
|
113
|
+
name: zod_1.z.string(),
|
|
114
|
+
version: zod_1.z.string(),
|
|
115
|
+
digest: zod_1.z.string(),
|
|
116
|
+
});
|
|
117
|
+
/**
|
|
118
|
+
* A placeholder an agent's instructions may contain.
|
|
119
|
+
*
|
|
120
|
+
* Lowercase, because `{{Data_Context}}` and `{{data_context}}` being different
|
|
121
|
+
* slots is a bug waiting to be filed.
|
|
122
|
+
*/
|
|
123
|
+
exports.variableNameSchema = zod_1.z
|
|
124
|
+
.string()
|
|
125
|
+
.trim()
|
|
126
|
+
.min(1)
|
|
127
|
+
.max(64)
|
|
128
|
+
.regex(/^[a-z][a-z0-9_]*$/, "A variable name starts with a letter and holds lowercase letters, numbers and underscores.");
|
|
129
|
+
/** The most a run may substitute into one placeholder. */
|
|
130
|
+
exports.MAX_VARIABLE_VALUE = 10_000;
|
|
131
|
+
/**
|
|
132
|
+
* Finds `{{name}}` in instructions.
|
|
133
|
+
*
|
|
134
|
+
* Deliberately strict: no spaces inside the braces, no nesting, no
|
|
135
|
+
* expressions. A template language here would be a second thing to learn and a
|
|
136
|
+
* second thing to get wrong, and the requirement is substitution.
|
|
137
|
+
*/
|
|
138
|
+
exports.VARIABLE_PATTERN = /\{\{([a-z][a-z0-9_]*)\}\}/g;
|
|
139
|
+
/** Every placeholder an instruction string names, in order, without repeats. */
|
|
140
|
+
function variablesIn(instructions) {
|
|
141
|
+
const found = new Set();
|
|
142
|
+
for (const match of instructions.matchAll(exports.VARIABLE_PATTERN))
|
|
143
|
+
found.add(match[1]);
|
|
144
|
+
return [...found];
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Substitute a run's values into a version's instructions.
|
|
148
|
+
*
|
|
149
|
+
* Values are inserted literally and never re-scanned, so a value that itself
|
|
150
|
+
* contains `{{other}}` cannot pull in a second variable. That matters because
|
|
151
|
+
* values come from a customer's backend at run time while the template was
|
|
152
|
+
* fixed at publish: re-scanning would let a value reach a placeholder the
|
|
153
|
+
* version never declared.
|
|
154
|
+
*/
|
|
155
|
+
function applyVariables(instructions, values) {
|
|
156
|
+
return instructions.replace(exports.VARIABLE_PATTERN, (whole, name) => Object.prototype.hasOwnProperty.call(values, name) ? values[name] : whole);
|
|
157
|
+
}
|
|
158
|
+
exports.agentVersionSchema = zod_1.z.object({
|
|
159
|
+
id: zod_1.z.string(),
|
|
160
|
+
agent_id: zod_1.z.string(),
|
|
161
|
+
/** Monotonic within an agent: v1, v2, v3. */
|
|
162
|
+
version: zod_1.z.string(),
|
|
163
|
+
instructions: zod_1.z.string(),
|
|
164
|
+
model: exports.modelSchema,
|
|
165
|
+
tools: zod_1.z.array(exports.toolRefSchema),
|
|
166
|
+
skills: zod_1.z.array(exports.agentSkillSchema).describe("Resolved at publish, not at run."),
|
|
167
|
+
redaction: redaction_js_1.redactionPolicySchema.describe("Masking applied to run input and output."),
|
|
168
|
+
mcp_servers: zod_1.z
|
|
169
|
+
.array(zod_1.z.string())
|
|
170
|
+
.describe("MCP servers this version may use, pinned by name at publish."),
|
|
171
|
+
tool_policies: tools_js_1.toolPoliciesSchema.describe("Per-tool overrides as `server.tool`. Anything unnamed takes its tag's default."),
|
|
172
|
+
knowledge_collections: zod_1.z
|
|
173
|
+
.array(zod_1.z.string())
|
|
174
|
+
.describe("Knowledge collections this version may search, pinned by name at publish."),
|
|
175
|
+
variables: zod_1.z
|
|
176
|
+
.array(zod_1.z.string())
|
|
177
|
+
.describe("Placeholders in `instructions` that a run must supply."),
|
|
178
|
+
guardrails: guardrails_js_1.guardrailBindingSchema.describe("Guardrails this version runs, pinned by name at publish."),
|
|
179
|
+
/** Content hash of the frozen configuration, recorded on every run. */
|
|
180
|
+
digest: zod_1.z.string(),
|
|
181
|
+
created_at: zod_1.z.string(),
|
|
182
|
+
});
|
|
183
|
+
exports.createAgentVersionSchema = zod_1.z
|
|
184
|
+
.object({
|
|
185
|
+
instructions: zod_1.z
|
|
186
|
+
.string()
|
|
187
|
+
.trim()
|
|
188
|
+
.min(1)
|
|
189
|
+
.max(exports.MAX_INSTRUCTIONS)
|
|
190
|
+
.describe("System prompt that defines the agent's behaviour."),
|
|
191
|
+
model: exports.modelSchema.default({ provider: "nix" }).describe("Model configuration."),
|
|
192
|
+
tools: zod_1.z
|
|
193
|
+
.array(exports.toolRefSchema)
|
|
194
|
+
.max(32)
|
|
195
|
+
.default([])
|
|
196
|
+
.describe("Tools the agent may call, by name. Unknown names are rejected at publish rather " +
|
|
197
|
+
"than failing a run. Nixet provides `current_time`, `calculate`, `web_search` and " +
|
|
198
|
+
"`fetch_url`; your own tools reach an agent through an MCP server instead. " +
|
|
199
|
+
"`fetch_url` reads a page the model chose, so the address is resolved and checked " +
|
|
200
|
+
"first — a private, loopback or cloud-metadata address is refused."),
|
|
201
|
+
skills: zod_1.z
|
|
202
|
+
.array(zod_1.z.string())
|
|
203
|
+
.max(16)
|
|
204
|
+
.default([])
|
|
205
|
+
.describe("Skills to use, as `name` or `name@v2`."),
|
|
206
|
+
redaction: redaction_js_1.redactionPolicySchema
|
|
207
|
+
.default(redaction_js_1.REDACTION_OFF)
|
|
208
|
+
.describe("Mask personal data in run input and output before dispatch. Traces are not redacted."),
|
|
209
|
+
mcp_servers: zod_1.z
|
|
210
|
+
.array(zod_1.z.string().min(1).max(64))
|
|
211
|
+
.max(10)
|
|
212
|
+
.default([])
|
|
213
|
+
.describe("Names of registered MCP servers. Cannot be combined with redaction: a masked " +
|
|
214
|
+
"run would hand tools placeholders instead of values."),
|
|
215
|
+
tool_policies: tools_js_1.toolPoliciesSchema
|
|
216
|
+
.default({})
|
|
217
|
+
.describe("Per-tool overrides as `server.tool`, each `allow`, `ask` or `deny`. Only the " +
|
|
218
|
+
"exceptions: anything unnamed takes its tag's default, so a server adding a " +
|
|
219
|
+
"tool does not require republishing. `ask` is refused until approvals exist."),
|
|
220
|
+
knowledge_collections: zod_1.z
|
|
221
|
+
.array(zod_1.z.string().min(1).max(64))
|
|
222
|
+
.max(10)
|
|
223
|
+
.default([])
|
|
224
|
+
.describe("Names of knowledge collections this version may search. A collection with no " +
|
|
225
|
+
"ready sources is not an error: it returns nothing until one finishes."),
|
|
226
|
+
variables: zod_1.z
|
|
227
|
+
.array(exports.variableNameSchema)
|
|
228
|
+
.max(16)
|
|
229
|
+
.default([])
|
|
230
|
+
.describe("Placeholders in `instructions`, as `{{name}}`, that a run supplies. Declared here " +
|
|
231
|
+
"so a run can only fill slots this version named: a run that could inject arbitrary " +
|
|
232
|
+
"prompt text would make the caller's own backend a prompt-injection surface, and the " +
|
|
233
|
+
"version would no longer describe how the agent behaves."),
|
|
234
|
+
guardrails: guardrails_js_1.guardrailBindingSchema
|
|
235
|
+
.default(guardrails_js_1.GUARDRAILS_OFF)
|
|
236
|
+
.describe("Named guardrails to run, per stage. Order is the order given: under `run_all` each " +
|
|
237
|
+
"guard sees the text the previous one produced, so which runs first is part of the " +
|
|
238
|
+
"configuration rather than incidental."),
|
|
239
|
+
publish: zod_1.z
|
|
240
|
+
.boolean()
|
|
241
|
+
.default(true)
|
|
242
|
+
.describe("Make this the version new runs use by default."),
|
|
243
|
+
})
|
|
244
|
+
.strict();
|