@nixet/contracts 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +12 -2
  3. package/dist/cjs/domains/agents.d.ts +284 -0
  4. package/dist/cjs/domains/agents.js +244 -0
  5. package/dist/cjs/domains/api-keys.d.ts +265 -0
  6. package/dist/cjs/domains/api-keys.js +87 -0
  7. package/dist/cjs/domains/billing.d.ts +98 -0
  8. package/dist/cjs/domains/billing.js +122 -0
  9. package/dist/cjs/domains/connections.d.ts +101 -0
  10. package/dist/cjs/domains/connections.js +130 -0
  11. package/dist/cjs/domains/conversations.d.ts +113 -0
  12. package/dist/cjs/domains/conversations.js +85 -0
  13. package/dist/cjs/domains/documents.d.ts +48 -0
  14. package/dist/cjs/domains/documents.js +64 -0
  15. package/dist/cjs/domains/guardrails.d.ts +211 -0
  16. package/dist/cjs/domains/guardrails.js +206 -0
  17. package/dist/cjs/domains/identity.d.ts +55 -0
  18. package/dist/cjs/domains/identity.js +26 -0
  19. package/dist/cjs/domains/knowledge.d.ts +167 -0
  20. package/dist/cjs/domains/knowledge.js +174 -0
  21. package/dist/cjs/domains/mcp.d.ts +189 -0
  22. package/dist/cjs/domains/mcp.js +183 -0
  23. package/dist/cjs/domains/memory.d.ts +109 -0
  24. package/dist/cjs/domains/memory.js +92 -0
  25. package/dist/cjs/domains/redaction.d.ts +181 -0
  26. package/dist/cjs/domains/redaction.js +166 -0
  27. package/dist/cjs/domains/runs.d.ts +260 -0
  28. package/dist/cjs/domains/runs.js +260 -0
  29. package/dist/cjs/domains/secrets.d.ts +56 -0
  30. package/dist/cjs/domains/secrets.js +72 -0
  31. package/dist/cjs/domains/skills.d.ts +70 -0
  32. package/dist/cjs/domains/skills.js +82 -0
  33. package/dist/cjs/domains/tasks.d.ts +111 -0
  34. package/dist/cjs/domains/tasks.js +113 -0
  35. package/dist/cjs/domains/tools.d.ts +159 -0
  36. package/dist/cjs/domains/tools.js +203 -0
  37. package/dist/cjs/domains/users.d.ts +40 -0
  38. package/dist/cjs/domains/users.js +48 -0
  39. package/dist/cjs/index.d.ts +25 -0
  40. package/dist/cjs/index.js +41 -0
  41. package/dist/cjs/primitives.d.ts +75 -0
  42. package/dist/cjs/primitives.js +117 -0
  43. package/dist/esm/domains/agents.js +239 -0
  44. package/dist/esm/domains/api-keys.js +83 -0
  45. package/dist/esm/domains/billing.js +116 -0
  46. package/dist/esm/domains/connections.js +127 -0
  47. package/dist/esm/domains/conversations.js +82 -0
  48. package/dist/esm/domains/documents.js +61 -0
  49. package/dist/esm/domains/guardrails.js +202 -0
  50. package/dist/esm/domains/identity.js +23 -0
  51. package/dist/esm/domains/knowledge.js +170 -0
  52. package/dist/esm/domains/mcp.js +178 -0
  53. package/dist/esm/domains/memory.js +89 -0
  54. package/dist/esm/domains/redaction.js +162 -0
  55. package/dist/esm/domains/runs.js +256 -0
  56. package/dist/esm/domains/secrets.js +68 -0
  57. package/dist/esm/domains/skills.js +79 -0
  58. package/dist/esm/domains/tasks.js +109 -0
  59. package/dist/esm/domains/tools.js +196 -0
  60. package/dist/esm/domains/users.js +45 -0
  61. package/dist/esm/index.js +25 -0
  62. package/dist/esm/package.json +1 -0
  63. package/dist/esm/primitives.js +114 -0
  64. package/package.json +38 -4
@@ -0,0 +1,260 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runEventSchema = exports.eventTokensSchema = exports.skillToolSource = exports.TOOL_SOURCE_AGENT = exports.runEventTypeSchema = exports.eventCategorySchema = exports.createRunSchema = exports.MAX_INPUT_LENGTH = exports.runSchema = exports.usageSchema = exports.runStatusSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const redaction_js_1 = require("./redaction.js");
6
+ const agents_js_1 = require("./agents.js");
7
+ /**
8
+ * Runs and their event stream.
9
+ *
10
+ * A run is the durable record of one execution: which version produced it, what
11
+ * it returned, what it cost. Events are the live view of the same execution.
12
+ */
13
+ exports.runStatusSchema = zod_1.z.enum([
14
+ "queued",
15
+ "running",
16
+ "completed",
17
+ "failed",
18
+ "cancelled",
19
+ ]);
20
+ exports.usageSchema = zod_1.z.object({
21
+ input_tokens: zod_1.z.number().int().nonnegative(),
22
+ output_tokens: zod_1.z.number().int().nonnegative(),
23
+ });
24
+ exports.runSchema = zod_1.z.object({
25
+ id: zod_1.z.string().describe("Unique identifier, prefixed `run_`."),
26
+ agent_id: zod_1.z.string().describe("Agent that produced this run."),
27
+ agent_version: zod_1.z
28
+ .string()
29
+ .describe("Version pinned at admission. It cannot change mid-run."),
30
+ variables: zod_1.z
31
+ .record(zod_1.z.string(), zod_1.z.string())
32
+ .nullable()
33
+ .describe("Placeholder values this run was given. Null when the version declared none."),
34
+ version_digest: zod_1.z
35
+ .string()
36
+ .describe("Content hash of the configuration that produced this run."),
37
+ status: exports.runStatusSchema.describe("Lifecycle state."),
38
+ provider: agents_js_1.providerSchema.describe("Provider that served the run. The model behind `nix` is not disclosed."),
39
+ input: zod_1.z
40
+ .string()
41
+ .describe("Message sent to the agent. Masked when the version redacts, so this is what was stored rather than what the caller sent."),
42
+ output: zod_1.z
43
+ .string()
44
+ .nullable()
45
+ .describe("Final text, present once the run reaches a terminal state. Masked when the version redacts."),
46
+ redaction: redaction_js_1.redactionSummarySchema
47
+ .nullable()
48
+ .describe("What was masked, as counts. Null when the version does not redact."),
49
+ error: zod_1.z
50
+ .string()
51
+ .nullable()
52
+ .describe("Safe failure reason. Never a stack trace or provider payload."),
53
+ usage: exports.usageSchema.nullable().describe("Token counts, present on completion."),
54
+ latency_ms: zod_1.z
55
+ .number()
56
+ .int()
57
+ .nonnegative()
58
+ .nullable()
59
+ .describe("Wall-clock duration of the run."),
60
+ trace_id: zod_1.z.string().nullable().describe("Correlates this run with its trace."),
61
+ cost_usd: zod_1.z
62
+ .number()
63
+ .nullable()
64
+ .describe("Total cost in USD, summed from the run's model calls."),
65
+ session_id: zod_1.z.string().nullable().describe("Conversation this run belongs to."),
66
+ created_at: zod_1.z.string().describe("RFC 3339 admission timestamp."),
67
+ completed_at: zod_1.z.string().nullable().describe("RFC 3339 completion timestamp."),
68
+ });
69
+ exports.MAX_INPUT_LENGTH = 100_000;
70
+ exports.createRunSchema = zod_1.z
71
+ .object({
72
+ agent_id: zod_1.z.string().min(1).describe("Agent to run. Taken from the path."),
73
+ input: zod_1.z.string().min(1).max(exports.MAX_INPUT_LENGTH).describe("Message sent to the agent."),
74
+ agent_version: zod_1.z
75
+ .string()
76
+ .optional()
77
+ .describe("Version to pin. Defaults to the agent's published version."),
78
+ provider: agents_js_1.providerSchema
79
+ .optional()
80
+ .describe("Override the version's provider for this run only."),
81
+ session_id: zod_1.z
82
+ .string()
83
+ .max(128)
84
+ .optional()
85
+ .describe("Groups related runs into one conversation."),
86
+ stream: zod_1.z.boolean().default(false).describe("Set by the streaming endpoint."),
87
+ conversation_id: zod_1.z
88
+ .string()
89
+ .max(64)
90
+ .nullish()
91
+ .describe("Set when a conversation dispatched this run."),
92
+ user_id: zod_1.z
93
+ .string()
94
+ .max(64)
95
+ .nullish()
96
+ .describe("Who the agent is serving."),
97
+ /**
98
+ * Narrow this run to some of the version's MCP servers.
99
+ *
100
+ * A subset, never an addition. The version's list is the boundary of what
101
+ * the agent may reach, and a run that could name a server outside it would
102
+ * be a run that could grant itself a tool the agent was never published
103
+ * with — an unannotated tool defaults to `allow`, so the escalation would
104
+ * be silent.
105
+ *
106
+ * Omitted means every server the version named, which is the common case:
107
+ * a caller sends a user and lets their connections decide what is
108
+ * reachable.
109
+ */
110
+ mcp_servers: zod_1.z
111
+ .array(zod_1.z.string().min(1).max(64))
112
+ .max(10)
113
+ .optional()
114
+ .describe("Subset of the version's MCP servers to use for this run."),
115
+ /**
116
+ * Values for the placeholders the version declared.
117
+ *
118
+ * Every declared variable must be supplied and nothing else may be: an
119
+ * unknown key is refused rather than ignored, so a caller cannot reach a
120
+ * slot the version never named, and a missing one is refused rather than
121
+ * left blank, because a prompt with a hole in it is worse than a run that
122
+ * did not start.
123
+ *
124
+ * The resolved values are recorded on the run. Without that, the
125
+ * instructions a run actually used are unrecoverable, and a version digest
126
+ * would no longer explain what the agent was told.
127
+ */
128
+ variables: zod_1.z
129
+ .record(zod_1.z.string(), zod_1.z.string().max(agents_js_1.MAX_VARIABLE_VALUE))
130
+ .optional()
131
+ .describe("Values for the version's declared instruction placeholders."),
132
+ /**
133
+ * Prior turns, oldest first.
134
+ *
135
+ * Supplied by the conversation rather than stored on the run: the runtime
136
+ * is stateless, so history has to travel with the request that needs it.
137
+ */
138
+ history: zod_1.z
139
+ .array(zod_1.z.object({
140
+ role: zod_1.z.string().max(16),
141
+ content: zod_1.z.string(),
142
+ }))
143
+ .optional(),
144
+ /** What this run may recall and retain. Supplied by a conversation. */
145
+ memory: zod_1.z
146
+ .object({
147
+ conversation: zod_1.z.boolean(),
148
+ user: zod_1.z.boolean(),
149
+ agent: zod_1.z.boolean(),
150
+ })
151
+ .optional(),
152
+ })
153
+ .strict();
154
+ /**
155
+ * What a trace event describes.
156
+ *
157
+ * Coarser than the event type, so a timeline can be grouped or filtered without
158
+ * knowing every individual type. Adding a capability adds types within an
159
+ * existing category far more often than it adds a category.
160
+ */
161
+ exports.eventCategorySchema = zod_1.z.enum([
162
+ "run",
163
+ "model",
164
+ "tool",
165
+ "output",
166
+ "memory",
167
+ "knowledge",
168
+ "reasoning",
169
+ "approval",
170
+ "subagent",
171
+ "workflow",
172
+ "task",
173
+ "session",
174
+ "context",
175
+ "skill",
176
+ ]);
177
+ /**
178
+ * Public event types.
179
+ *
180
+ * A stable surface mapped from the framework's much larger internal vocabulary,
181
+ * so the internals can change without breaking customers. Unmapped internal
182
+ * events are dropped rather than forwarded.
183
+ */
184
+ exports.runEventTypeSchema = zod_1.z.enum([
185
+ "run.started",
186
+ "run.completed",
187
+ "run.failed",
188
+ "run.cancelled",
189
+ "run.paused",
190
+ "run.continued",
191
+ "run.output",
192
+ "run.model.started",
193
+ "run.model.completed",
194
+ "run.tool.started",
195
+ "run.tool.completed",
196
+ "run.tool.failed",
197
+ "run.knowledge.started",
198
+ "run.knowledge.completed",
199
+ "run.memory.recall.started",
200
+ "run.memory.recall.completed",
201
+ "run.memory.update.started",
202
+ "run.memory.update.completed",
203
+ "run.reasoning.started",
204
+ "run.reasoning.completed",
205
+ "run.subagent.spawned",
206
+ "run.subagent.completed",
207
+ "run.subagent.failed",
208
+ "run.subagent.killed",
209
+ "run.workflow.step.started",
210
+ "run.workflow.step.completed",
211
+ "run.workflow.step.failed",
212
+ "run.workflow.step.skipped",
213
+ "run.task.created",
214
+ "run.task.status",
215
+ "run.session.summarised",
216
+ "run.context.compressed",
217
+ /** Emitted by Nixet: the runtime cannot name a skill once it is merged. */
218
+ "run.skill.loaded",
219
+ ]);
220
+ /** Where a tool came from: `agent`, or `skill:<name>` if a skill supplied it. */
221
+ exports.TOOL_SOURCE_AGENT = "agent";
222
+ const skillToolSource = (name) => `skill:${name}`;
223
+ exports.skillToolSource = skillToolSource;
224
+ /** Token counts for one span, where the provider reports them. */
225
+ exports.eventTokensSchema = zod_1.z.object({
226
+ input: zod_1.z.number().int().nonnegative().optional(),
227
+ output: zod_1.z.number().int().nonnegative().optional(),
228
+ cache_read: zod_1.z.number().int().nonnegative().optional(),
229
+ reasoning: zod_1.z.number().int().nonnegative().optional(),
230
+ });
231
+ exports.runEventSchema = zod_1.z.object({
232
+ sequence: zod_1.z
233
+ .number()
234
+ .int()
235
+ .nonnegative()
236
+ .describe("Monotonic within a run, so a dropped stream can resume."),
237
+ type: exports.runEventTypeSchema.describe("Event type."),
238
+ category: exports.eventCategorySchema.describe("What this event describes."),
239
+ run_id: zod_1.z.string().describe("Run this event belongs to."),
240
+ data: zod_1.z
241
+ .string()
242
+ .nullable()
243
+ .describe("Short label: a text delta, a tool name, or a failure reason."),
244
+ /**
245
+ * Fields specific to this event type. Shapes differ by category, so this is
246
+ * an object rather than columns: a knowledge event reports documents found,
247
+ * a tool event reports arguments and a result.
248
+ */
249
+ payload: zod_1.z.record(zod_1.z.string(), zod_1.z.unknown()).nullable(),
250
+ duration_ms: zod_1.z.number().int().nonnegative().nullable(),
251
+ tokens: exports.eventTokensSchema.nullable(),
252
+ /** Computed from tokens; null when the model has no published rate. */
253
+ cost_usd: zod_1.z.number().nullable(),
254
+ /**
255
+ * The event that produced this one. A sub-agent's events point at the event
256
+ * that spawned it, so a trace is a tree rather than a flat list.
257
+ */
258
+ parent_event_id: zod_1.z.string().nullable(),
259
+ created_at: zod_1.z.string().describe("RFC 3339 timestamp."),
260
+ });
@@ -0,0 +1,56 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Secrets.
4
+ *
5
+ * A credential a customer gives us so an agent can reach something of theirs —
6
+ * an MCP server's bearer token, later an HTTP tool's API key.
7
+ *
8
+ * The value is written once and never returned. Everything that uses a secret
9
+ * refers to it by name, so a configuration can be read, copied and versioned
10
+ * without the credential travelling with it.
11
+ */
12
+ export declare const MAX_SECRET_VALUE = 8000;
13
+ /**
14
+ * Lowercase, hyphenated, stable.
15
+ *
16
+ * A version pins a secret by name, so renaming one would silently change what
17
+ * a published agent reaches for.
18
+ */
19
+ export declare const secretNameSchema: z.ZodString;
20
+ /**
21
+ * What a read returns.
22
+ *
23
+ * Never the value. A secret that could be read back is a secret store that
24
+ * leaks the moment any read path is wrong, so the API has no way to ask.
25
+ */
26
+ export declare const secretSchema: z.ZodObject<{
27
+ id: z.ZodString;
28
+ name: z.ZodString;
29
+ description: z.ZodNullable<z.ZodString>;
30
+ hint: z.ZodString;
31
+ created_at: z.ZodString;
32
+ updated_at: z.ZodString;
33
+ }, z.core.$strip>;
34
+ export type Secret = z.infer<typeof secretSchema>;
35
+ export declare const createSecretSchema: z.ZodObject<{
36
+ name: z.ZodString;
37
+ value: z.ZodString;
38
+ description: z.ZodOptional<z.ZodString>;
39
+ }, z.core.$strict>;
40
+ export type CreateSecretRequest = z.infer<typeof createSecretSchema>;
41
+ /** Replacing a value. The name cannot change, because versions pin it. */
42
+ export declare const updateSecretSchema: z.ZodObject<{
43
+ value: z.ZodOptional<z.ZodString>;
44
+ description: z.ZodOptional<z.ZodString>;
45
+ }, z.core.$strict>;
46
+ export type UpdateSecretRequest = z.infer<typeof updateSecretSchema>;
47
+ /**
48
+ * How a configuration refers to a secret.
49
+ *
50
+ * `{{ secret.github-token }}` inside a header value. The reference is what gets
51
+ * stored and versioned; the value is resolved at execution and never persisted
52
+ * alongside the thing that used it.
53
+ */
54
+ export declare const SECRET_REFERENCE: RegExp;
55
+ /** Every secret a string refers to, in the order they appear. */
56
+ export declare function secretsReferencedBy(value: string): string[];
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SECRET_REFERENCE = exports.updateSecretSchema = exports.createSecretSchema = exports.secretSchema = exports.secretNameSchema = exports.MAX_SECRET_VALUE = void 0;
4
+ exports.secretsReferencedBy = secretsReferencedBy;
5
+ const zod_1 = require("zod");
6
+ /**
7
+ * Secrets.
8
+ *
9
+ * A credential a customer gives us so an agent can reach something of theirs —
10
+ * an MCP server's bearer token, later an HTTP tool's API key.
11
+ *
12
+ * The value is written once and never returned. Everything that uses a secret
13
+ * refers to it by name, so a configuration can be read, copied and versioned
14
+ * without the credential travelling with it.
15
+ */
16
+ exports.MAX_SECRET_VALUE = 8_000;
17
+ /**
18
+ * Lowercase, hyphenated, stable.
19
+ *
20
+ * A version pins a secret by name, so renaming one would silently change what
21
+ * a published agent reaches for.
22
+ */
23
+ exports.secretNameSchema = zod_1.z
24
+ .string()
25
+ .trim()
26
+ .min(1)
27
+ .max(64)
28
+ .regex(/^[a-z0-9]+(-[a-z0-9]+)*$/, "Use lowercase letters, numbers and hyphens, e.g. `github-token`.");
29
+ /**
30
+ * What a read returns.
31
+ *
32
+ * Never the value. A secret that could be read back is a secret store that
33
+ * leaks the moment any read path is wrong, so the API has no way to ask.
34
+ */
35
+ exports.secretSchema = zod_1.z.object({
36
+ id: zod_1.z.string().describe("Unique identifier, prefixed `sec_`."),
37
+ name: exports.secretNameSchema,
38
+ description: zod_1.z.string().nullable(),
39
+ /** First few characters, so a reader can tell two secrets apart. */
40
+ hint: zod_1.z.string().describe("A short, non-reversible excerpt. Never the value."),
41
+ created_at: zod_1.z.string(),
42
+ updated_at: zod_1.z.string(),
43
+ });
44
+ exports.createSecretSchema = zod_1.z
45
+ .object({
46
+ name: exports.secretNameSchema,
47
+ value: zod_1.z.string().min(1).max(exports.MAX_SECRET_VALUE),
48
+ description: zod_1.z.string().trim().max(200).optional(),
49
+ })
50
+ .strict();
51
+ /** Replacing a value. The name cannot change, because versions pin it. */
52
+ exports.updateSecretSchema = zod_1.z
53
+ .object({
54
+ value: zod_1.z.string().min(1).max(exports.MAX_SECRET_VALUE).optional(),
55
+ description: zod_1.z.string().trim().max(200).optional(),
56
+ })
57
+ .strict()
58
+ .refine((body) => body.value !== undefined || body.description !== undefined, {
59
+ message: "Nothing to update.",
60
+ });
61
+ /**
62
+ * How a configuration refers to a secret.
63
+ *
64
+ * `{{ secret.github-token }}` inside a header value. The reference is what gets
65
+ * stored and versioned; the value is resolved at execution and never persisted
66
+ * alongside the thing that used it.
67
+ */
68
+ exports.SECRET_REFERENCE = /\{\{\s*secret\.([a-z0-9-]+)\s*\}\}/g;
69
+ /** Every secret a string refers to, in the order they appear. */
70
+ function secretsReferencedBy(value) {
71
+ return [...value.matchAll(exports.SECRET_REFERENCE)].map((match) => match[1]);
72
+ }
@@ -0,0 +1,70 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Skills.
4
+ *
5
+ * A skill is reusable expertise: instructions plus the tools that expertise
6
+ * needs, packaged under a name and versioned like an agent. An agent version
7
+ * references skills by `name@version`, so what an agent knew at run time can
8
+ * always be reconstructed.
9
+ */
10
+ export declare const MAX_SKILL_NAME = 80;
11
+ export declare const MAX_SKILL_INSTRUCTIONS = 20000;
12
+ /**
13
+ * Names may be namespaced with a single slash, as in `research/company-lookup`,
14
+ * which groups related skills without a directory to maintain.
15
+ */
16
+ export declare const skillNameSchema: z.ZodString;
17
+ export declare const skillSchema: z.ZodObject<{
18
+ id: z.ZodString;
19
+ name: z.ZodString;
20
+ description: z.ZodNullable<z.ZodString>;
21
+ current_version: z.ZodNullable<z.ZodString>;
22
+ created_at: z.ZodString;
23
+ updated_at: z.ZodString;
24
+ }, z.core.$strip>;
25
+ export type Skill = z.infer<typeof skillSchema>;
26
+ export declare const createSkillSchema: z.ZodObject<{
27
+ name: z.ZodString;
28
+ description: z.ZodOptional<z.ZodString>;
29
+ instructions: z.ZodOptional<z.ZodString>;
30
+ tools: z.ZodOptional<z.ZodArray<z.ZodObject<{
31
+ name: z.ZodString;
32
+ }, z.core.$strict>>>;
33
+ }, z.core.$strict>;
34
+ export type CreateSkillRequest = z.infer<typeof createSkillSchema>;
35
+ export declare const skillVersionSchema: z.ZodObject<{
36
+ id: z.ZodString;
37
+ skill_id: z.ZodString;
38
+ version: z.ZodString;
39
+ instructions: z.ZodString;
40
+ tools: z.ZodArray<z.ZodObject<{
41
+ name: z.ZodString;
42
+ }, z.core.$strict>>;
43
+ digest: z.ZodString;
44
+ created_at: z.ZodString;
45
+ }, z.core.$strip>;
46
+ export type SkillVersion = z.infer<typeof skillVersionSchema>;
47
+ export declare const createSkillVersionSchema: z.ZodObject<{
48
+ instructions: z.ZodString;
49
+ tools: z.ZodDefault<z.ZodArray<z.ZodObject<{
50
+ name: z.ZodString;
51
+ }, z.core.$strict>>>;
52
+ publish: z.ZodDefault<z.ZodBoolean>;
53
+ }, z.core.$strict>;
54
+ export type CreateSkillVersionRequest = z.infer<typeof createSkillVersionSchema>;
55
+ /**
56
+ * How an agent version names a skill.
57
+ *
58
+ * `name@v2` pins a version. A bare `name` resolves to the published version
59
+ * when the agent version is created, and the resolved value is what gets
60
+ * stored: resolving at run time would make a past run unreproducible.
61
+ */
62
+ export declare const skillRefSchema: z.ZodString;
63
+ export type SkillRef = z.infer<typeof skillRefSchema>;
64
+ /** A skill as stored on an agent version, already resolved to one version. */
65
+ export declare const resolvedSkillSchema: z.ZodObject<{
66
+ name: z.ZodString;
67
+ version: z.ZodString;
68
+ digest: z.ZodString;
69
+ }, z.core.$strip>;
70
+ export type ResolvedSkill = z.infer<typeof resolvedSkillSchema>;
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolvedSkillSchema = exports.skillRefSchema = exports.createSkillVersionSchema = exports.skillVersionSchema = exports.createSkillSchema = exports.skillSchema = exports.skillNameSchema = exports.MAX_SKILL_INSTRUCTIONS = exports.MAX_SKILL_NAME = void 0;
4
+ const zod_1 = require("zod");
5
+ const agents_js_1 = require("./agents.js");
6
+ /**
7
+ * Skills.
8
+ *
9
+ * A skill is reusable expertise: instructions plus the tools that expertise
10
+ * needs, packaged under a name and versioned like an agent. An agent version
11
+ * references skills by `name@version`, so what an agent knew at run time can
12
+ * always be reconstructed.
13
+ */
14
+ exports.MAX_SKILL_NAME = 80;
15
+ exports.MAX_SKILL_INSTRUCTIONS = 20_000;
16
+ /**
17
+ * Names may be namespaced with a single slash, as in `research/company-lookup`,
18
+ * which groups related skills without a directory to maintain.
19
+ */
20
+ exports.skillNameSchema = zod_1.z
21
+ .string()
22
+ .trim()
23
+ .min(1)
24
+ .max(exports.MAX_SKILL_NAME)
25
+ .regex(/^[a-z0-9][a-z0-9-]*(\/[a-z0-9][a-z0-9-]*)?$/, "Use lowercase letters, numbers and hyphens, optionally namespaced as `group/name`.");
26
+ exports.skillSchema = zod_1.z.object({
27
+ id: zod_1.z.string().describe("Unique identifier, prefixed `skl_`."),
28
+ name: exports.skillNameSchema.describe("Unique within a workspace and environment."),
29
+ description: zod_1.z.string().nullable(),
30
+ current_version: zod_1.z
31
+ .string()
32
+ .nullable()
33
+ .describe("Version used when a reference names no version."),
34
+ created_at: zod_1.z.string(),
35
+ updated_at: zod_1.z.string(),
36
+ });
37
+ exports.createSkillSchema = zod_1.z
38
+ .object({
39
+ name: exports.skillNameSchema,
40
+ description: zod_1.z.string().trim().max(500).optional(),
41
+ /** Supplying instructions also publishes the first version. */
42
+ instructions: zod_1.z.string().trim().min(1).max(exports.MAX_SKILL_INSTRUCTIONS).optional(),
43
+ tools: zod_1.z.array(agents_js_1.toolRefSchema).max(32).optional(),
44
+ })
45
+ .strict();
46
+ exports.skillVersionSchema = zod_1.z.object({
47
+ id: zod_1.z.string(),
48
+ skill_id: zod_1.z.string(),
49
+ version: zod_1.z.string().describe("Monotonic within a skill: v1, v2, v3."),
50
+ instructions: zod_1.z
51
+ .string()
52
+ .describe("Added to the agent's prompt when the skill is in use."),
53
+ tools: zod_1.z.array(agents_js_1.toolRefSchema).describe("Tools this expertise requires."),
54
+ digest: zod_1.z.string().describe("Content hash of the frozen skill."),
55
+ created_at: zod_1.z.string(),
56
+ });
57
+ exports.createSkillVersionSchema = zod_1.z
58
+ .object({
59
+ instructions: zod_1.z.string().trim().min(1).max(exports.MAX_SKILL_INSTRUCTIONS),
60
+ tools: zod_1.z.array(agents_js_1.toolRefSchema).max(32).default([]),
61
+ publish: zod_1.z.boolean().default(true),
62
+ })
63
+ .strict();
64
+ /**
65
+ * How an agent version names a skill.
66
+ *
67
+ * `name@v2` pins a version. A bare `name` resolves to the published version
68
+ * when the agent version is created, and the resolved value is what gets
69
+ * stored: resolving at run time would make a past run unreproducible.
70
+ */
71
+ exports.skillRefSchema = zod_1.z
72
+ .string()
73
+ .trim()
74
+ .min(1)
75
+ .max(exports.MAX_SKILL_NAME + 12)
76
+ .regex(/^[a-z0-9][a-z0-9-]*(\/[a-z0-9][a-z0-9-]*)?(@v\d+)?$/, "Reference a skill as `name` or `name@v2`.");
77
+ /** A skill as stored on an agent version, already resolved to one version. */
78
+ exports.resolvedSkillSchema = zod_1.z.object({
79
+ name: zod_1.z.string(),
80
+ version: zod_1.z.string(),
81
+ digest: zod_1.z.string(),
82
+ });
@@ -0,0 +1,111 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Tasks.
4
+ *
5
+ * A run is one HTTP request: the caller waits, and the work has to finish
6
+ * inside that request. A task is work that outlives the request — research,
7
+ * a long report, anything that would otherwise time out.
8
+ *
9
+ * A task owns the lifecycle; a run owns the execution. The worker starts a run
10
+ * and records its id, so a task's trace, cost and redaction are the run's and
11
+ * nothing is duplicated.
12
+ */
13
+ /**
14
+ * Every state a task can report.
15
+ *
16
+ * Five are reachable today. `waiting_for_tool`, `waiting_for_approval`,
17
+ * `waiting_for_user` and `paused` are declared because the platform will
18
+ * produce them once tools, policies and a resume mechanism exist — widening a
19
+ * published enum later would break an exhaustive switch a customer already
20
+ * wrote. Until then nothing sets them, and the documentation says so.
21
+ */
22
+ export declare const taskStatusSchema: z.ZodEnum<{
23
+ queued: "queued";
24
+ running: "running";
25
+ completed: "completed";
26
+ failed: "failed";
27
+ cancelled: "cancelled";
28
+ waiting_for_tool: "waiting_for_tool";
29
+ waiting_for_approval: "waiting_for_approval";
30
+ waiting_for_user: "waiting_for_user";
31
+ paused: "paused";
32
+ }>;
33
+ export type TaskStatus = z.infer<typeof taskStatusSchema>;
34
+ /** States nothing currently produces. Exported so the docs cannot drift. */
35
+ export declare const UNREACHABLE_TASK_STATES: readonly TaskStatus[];
36
+ /** A task that has stopped for good, whatever the outcome. */
37
+ export declare const TERMINAL_TASK_STATES: readonly TaskStatus[];
38
+ export declare const MAX_TASK_INPUT = 32000;
39
+ export declare const DEFAULT_MAX_ATTEMPTS = 3;
40
+ export declare const taskSchema: z.ZodObject<{
41
+ id: z.ZodString;
42
+ agent_id: z.ZodString;
43
+ agent_version: z.ZodString;
44
+ version_digest: z.ZodString;
45
+ status: z.ZodEnum<{
46
+ queued: "queued";
47
+ running: "running";
48
+ completed: "completed";
49
+ failed: "failed";
50
+ cancelled: "cancelled";
51
+ waiting_for_tool: "waiting_for_tool";
52
+ waiting_for_approval: "waiting_for_approval";
53
+ waiting_for_user: "waiting_for_user";
54
+ paused: "paused";
55
+ }>;
56
+ input: z.ZodString;
57
+ output: z.ZodNullable<z.ZodString>;
58
+ error: z.ZodNullable<z.ZodString>;
59
+ run_id: z.ZodNullable<z.ZodString>;
60
+ conversation_id: z.ZodNullable<z.ZodString>;
61
+ user_id: z.ZodNullable<z.ZodString>;
62
+ attempt: z.ZodNumber;
63
+ max_attempts: z.ZodNumber;
64
+ run_after: z.ZodNullable<z.ZodString>;
65
+ created_at: z.ZodString;
66
+ updated_at: z.ZodString;
67
+ completed_at: z.ZodNullable<z.ZodString>;
68
+ }, z.core.$strip>;
69
+ export type Task = z.infer<typeof taskSchema>;
70
+ export declare const createTaskSchema: z.ZodObject<{
71
+ input: z.ZodString;
72
+ agent_version: z.ZodOptional<z.ZodString>;
73
+ conversation_id: z.ZodOptional<z.ZodString>;
74
+ user_id: z.ZodOptional<z.ZodString>;
75
+ provider: z.ZodOptional<z.ZodEnum<{
76
+ nix: "nix";
77
+ openai: "openai";
78
+ anthropic: "anthropic";
79
+ }>>;
80
+ memory: z.ZodOptional<z.ZodObject<{
81
+ conversation: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
82
+ user: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
83
+ agent: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
84
+ }, z.core.$strict>>;
85
+ max_attempts: z.ZodDefault<z.ZodNumber>;
86
+ }, z.core.$strict>;
87
+ export type CreateTaskRequest = z.infer<typeof createTaskSchema>;
88
+ export declare const listTasksSchema: z.ZodObject<{
89
+ status: z.ZodOptional<z.ZodEnum<{
90
+ queued: "queued";
91
+ running: "running";
92
+ completed: "completed";
93
+ failed: "failed";
94
+ cancelled: "cancelled";
95
+ waiting_for_tool: "waiting_for_tool";
96
+ waiting_for_approval: "waiting_for_approval";
97
+ waiting_for_user: "waiting_for_user";
98
+ paused: "paused";
99
+ }>>;
100
+ agent_id: z.ZodOptional<z.ZodString>;
101
+ conversation_id: z.ZodOptional<z.ZodString>;
102
+ }, z.core.$strict>;
103
+ export type ListTasksRequest = z.infer<typeof listTasksSchema>;
104
+ /**
105
+ * How long to wait before attempt `n`.
106
+ *
107
+ * Exponential from ten seconds, capped at five minutes. A failure is usually a
108
+ * rate limit or a provider blip, so retrying immediately tends to fail the same
109
+ * way; waiting an hour is longer than anyone will tolerate.
110
+ */
111
+ export declare function backoffMs(attempt: number): number;