@nixet/sdk 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.
Files changed (67) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/LICENSE +21 -0
  3. package/README.md +870 -2
  4. package/SECURITY.md +30 -0
  5. package/api.md +485 -0
  6. package/dist/cjs/errors.d.ts +37 -0
  7. package/dist/cjs/errors.js +79 -0
  8. package/dist/cjs/index.d.ts +89 -0
  9. package/dist/cjs/index.js +118 -0
  10. package/dist/cjs/resources/agents.d.ts +67 -0
  11. package/dist/cjs/resources/agents.js +74 -0
  12. package/dist/cjs/resources/connections.d.ts +94 -0
  13. package/dist/cjs/resources/connections.js +106 -0
  14. package/dist/cjs/resources/conversations.d.ts +62 -0
  15. package/dist/cjs/resources/conversations.js +86 -0
  16. package/dist/cjs/resources/documents.d.ts +65 -0
  17. package/dist/cjs/resources/documents.js +61 -0
  18. package/dist/cjs/resources/guardrails.d.ts +56 -0
  19. package/dist/cjs/resources/guardrails.js +76 -0
  20. package/dist/cjs/resources/knowledge.d.ts +189 -0
  21. package/dist/cjs/resources/knowledge.js +218 -0
  22. package/dist/cjs/resources/mcp-servers.d.ts +83 -0
  23. package/dist/cjs/resources/mcp-servers.js +107 -0
  24. package/dist/cjs/resources/memory.d.ts +95 -0
  25. package/dist/cjs/resources/memory.js +127 -0
  26. package/dist/cjs/resources/runs.d.ts +78 -0
  27. package/dist/cjs/resources/runs.js +87 -0
  28. package/dist/cjs/resources/secrets.d.ts +60 -0
  29. package/dist/cjs/resources/secrets.js +85 -0
  30. package/dist/cjs/resources/skills.d.ts +57 -0
  31. package/dist/cjs/resources/skills.js +78 -0
  32. package/dist/cjs/resources/tasks.d.ts +91 -0
  33. package/dist/cjs/resources/tasks.js +129 -0
  34. package/dist/cjs/resources/tools.d.ts +42 -0
  35. package/dist/cjs/resources/tools.js +57 -0
  36. package/dist/cjs/resources/users.d.ts +39 -0
  37. package/dist/cjs/resources/users.js +57 -0
  38. package/dist/cjs/resources/versions.d.ts +105 -0
  39. package/dist/cjs/resources/versions.js +78 -0
  40. package/dist/cjs/stream.d.ts +57 -0
  41. package/dist/cjs/stream.js +170 -0
  42. package/dist/cjs/transport.d.ts +45 -0
  43. package/dist/cjs/transport.js +106 -0
  44. package/dist/cjs/types.d.ts +537 -0
  45. package/dist/cjs/types.js +3 -0
  46. package/dist/esm/errors.js +66 -0
  47. package/dist/esm/index.js +103 -0
  48. package/dist/esm/package.json +1 -0
  49. package/dist/esm/resources/agents.js +70 -0
  50. package/dist/esm/resources/connections.js +102 -0
  51. package/dist/esm/resources/conversations.js +82 -0
  52. package/dist/esm/resources/documents.js +57 -0
  53. package/dist/esm/resources/guardrails.js +72 -0
  54. package/dist/esm/resources/knowledge.js +212 -0
  55. package/dist/esm/resources/mcp-servers.js +103 -0
  56. package/dist/esm/resources/memory.js +123 -0
  57. package/dist/esm/resources/runs.js +83 -0
  58. package/dist/esm/resources/secrets.js +81 -0
  59. package/dist/esm/resources/skills.js +74 -0
  60. package/dist/esm/resources/tasks.js +125 -0
  61. package/dist/esm/resources/tools.js +53 -0
  62. package/dist/esm/resources/users.js +53 -0
  63. package/dist/esm/resources/versions.js +74 -0
  64. package/dist/esm/stream.js +166 -0
  65. package/dist/esm/transport.js +102 -0
  66. package/dist/esm/types.js +2 -0
  67. package/package.json +59 -4
package/SECURITY.md ADDED
@@ -0,0 +1,30 @@
1
+ # Security policy
2
+
3
+ ## Reporting a vulnerability
4
+
5
+ Please do not report security issues in public issues or discussions.
6
+
7
+ Email **shubham@nixet.ai** with:
8
+
9
+ - a description of the issue and its impact,
10
+ - steps to reproduce, or a proof of concept,
11
+ - the SDK version and runtime (Node, Deno, Bun, browser) you used.
12
+
13
+ We acknowledge reports within three business days and keep you informed until
14
+ the issue is resolved. We ask that you give us reasonable time to fix an issue
15
+ before disclosing it.
16
+
17
+ ## Supported versions
18
+
19
+ Security fixes are released for the latest minor version of `@nixet/sdk`.
20
+
21
+ ## Handling credentials
22
+
23
+ - Keep API keys on a server. Never ship one in browser or mobile code, where
24
+ anyone can read it.
25
+ - Pass keys through `NIXET_API_KEY` or a secret manager rather than committing
26
+ them to source control.
27
+ - Secret values, MCP connection credentials and document passwords are
28
+ write-only: the API never returns them, and this SDK never logs them.
29
+ - If a key is exposed, revoke it in the [console](https://console.nixet.ai)
30
+ and issue a new one.
package/api.md ADDED
@@ -0,0 +1,485 @@
1
+ # API reference
2
+
3
+ Every method on the `Nixet` client, the HTTP request it makes, and what it
4
+ returns. Paths are relative to the base URL, `https://api.nixet.ai/v1` by default.
5
+
6
+ Every method also accepts a final `options` argument, `{ signal?: AbortSignal }`,
7
+ omitted from the signatures below. List methods return `Page<T>`:
8
+ `{ data: T[]; count: number }`, where `count` is the total across all pages, and
9
+ accept `{ limit?, offset? }`.
10
+
11
+ - [Client](#client)
12
+ - [Agents](#agents)
13
+ - [Agent versions](#agent-versions)
14
+ - [Runs](#runs)
15
+ - [Tasks](#tasks)
16
+ - [Users](#users)
17
+ - [Conversations](#conversations)
18
+ - [Memory](#memory)
19
+ - [Skills](#skills)
20
+ - [Knowledge collections](#knowledge-collections)
21
+ - [Knowledge sources](#knowledge-sources)
22
+ - [Documents](#documents)
23
+ - [MCP servers](#mcp-servers)
24
+ - [Tools](#tools)
25
+ - [Connections](#connections)
26
+ - [Guardrails](#guardrails)
27
+ - [Secrets](#secrets)
28
+ - [RunStream](#runstream)
29
+ - [Errors](#errors)
30
+ - [Types](#types)
31
+
32
+ ## Client
33
+
34
+ ```ts
35
+ new Nixet(options?: NixetOptions)
36
+ ```
37
+
38
+ | Option | Type | Default |
39
+ | --- | --- | --- |
40
+ | `apiKey` | `string` | `process.env.NIXET_API_KEY` (required) |
41
+ | `baseURL` | `string` | `process.env.NIXET_BASE_URL` or `https://api.nixet.ai/v1` |
42
+ | `timeout` | `number` (ms) | `600000` |
43
+ | `maxRetries` | `number` | `2` |
44
+ | `fetch` | `typeof fetch` | `globalThis.fetch` |
45
+
46
+ | Method | Request | Returns |
47
+ | --- | --- | --- |
48
+ | `nixet.whoami()` | `GET /whoami` | `Identity` |
49
+
50
+ ## Agents
51
+
52
+ | Method | Request | Returns |
53
+ | --- | --- | --- |
54
+ | `nixet.agents.create(params)` | `POST /agents`, then `POST /agents/{id}/versions` when `instructions` is given | `CreatedAgent` |
55
+ | `nixet.agents.retrieve(agentId)` | `GET /agents/{id}` | `Agent` |
56
+ | `nixet.agents.list(params?)` | `GET /agents` | `Page<Agent>` |
57
+
58
+ **`CreateAgentParams`**
59
+
60
+ | Param | Type | Notes |
61
+ | --- | --- | --- |
62
+ | `name` | `string` | Required |
63
+ | `description` | `string` | |
64
+ | `instructions` | `string` | When given, publishes v1 with the fields below |
65
+ | `model` | `ModelConfig` | |
66
+ | `tools` | `(string \| ToolRef)[]` | |
67
+ | `skills` | `string[]` | `name` or `name@v2` |
68
+ | `mcpServers` | `string[]` | |
69
+ | `toolPolicies` | `Record<string, ToolPolicy>` | Keys are `server.tool` |
70
+ | `knowledgeCollections` | `string[]` | |
71
+ | `variables` | `string[]` | |
72
+ | `guardrails` | `CreateVersionParams["guardrails"]` | |
73
+
74
+ `CreatedAgent` is `Agent` plus `version?: AgentVersion`, present when a version
75
+ was published.
76
+
77
+ ## Agent versions
78
+
79
+ | Method | Request | Returns |
80
+ | --- | --- | --- |
81
+ | `nixet.agents.versions.create(agentId, params)` | `POST /agents/{id}/versions` | `AgentVersion` |
82
+ | `nixet.agents.versions.retrieve(agentId, version)` | `GET /agents/{id}/versions/{version}` | `AgentVersion` |
83
+ | `nixet.agents.versions.list(agentId, params?)` | `GET /agents/{id}/versions` | `Page<AgentVersion>` |
84
+
85
+ **`CreateVersionParams`**
86
+
87
+ | Param | Type | Notes |
88
+ | --- | --- | --- |
89
+ | `instructions` | `string` | Required |
90
+ | `model` | `ModelConfig` | Default `{ provider: "nix", tier: "balanced" }` |
91
+ | `tools` | `(string \| ToolRef)[]` | `current_time`, `calculate`, `web_search`, `fetch_url` |
92
+ | `skills` | `string[]` | Pinned at publish |
93
+ | `redaction` | `RedactionPolicyInput` | Cannot be combined with `mcpServers` |
94
+ | `mcpServers` | `string[]` | Registered server names |
95
+ | `toolPolicies` | `Record<string, ToolPolicy>` | Only exceptions to the defaults; `ask` refused for now |
96
+ | `knowledgeCollections` | `string[]` | Collection names |
97
+ | `variables` | `string[]` | Must match the `{{placeholders}}` in `instructions` exactly |
98
+ | `guardrails` | `{ input?, output?, tool_result?: string[]; mode?: "run_all" \| "fail_fast"; on_block?: "return_message" \| "error" }` | Defaults `run_all`, `return_message` |
99
+ | `publish` | `boolean` | Default `true` |
100
+
101
+ ## Runs
102
+
103
+ | Method | Request | Returns |
104
+ | --- | --- | --- |
105
+ | `nixet.runs.create(agentId, params)` | `POST /agents/{id}/runs` | `Run` |
106
+ | `nixet.runs.stream(agentId, params)` | `POST /agents/{id}/runs/stream` (server-sent events) | `RunStream` |
107
+ | `nixet.runs.retrieve(runId)` | `GET /runs/{id}` | `Run` |
108
+ | `nixet.runs.list(agentId, params?)` | `GET /agents/{id}/runs` | `Page<Run>` |
109
+ | `nixet.runs.events(runId, params?)` | `GET /runs/{id}/events` | `Page<RunEvent>` |
110
+
111
+ **`CreateRunParams`**
112
+
113
+ | Param | Type | Notes |
114
+ | --- | --- | --- |
115
+ | `input` | `string` | Required |
116
+ | `version` | `string` | e.g. `"v2"`. Default: the published version |
117
+ | `provider` | `Provider` | Overrides the version's provider for this run |
118
+ | `sessionId` | `string` | Groups related runs |
119
+ | `userId` | `string` | Decides whose memory and connections apply |
120
+ | `variables` | `Record<string, string>` | Every declared variable, nothing else |
121
+ | `mcpServers` | `string[]` | Subset of the version's servers |
122
+
123
+ **`ListEventsParams`** — `limit`, `offset`, plus:
124
+
125
+ | Param | Type | Notes |
126
+ | --- | --- | --- |
127
+ | `after` | `number` | Only events with a higher `sequence` |
128
+ | `type` | `RunEventType` | Only this event type |
129
+
130
+ ## Tasks
131
+
132
+ | Method | Request | Returns |
133
+ | --- | --- | --- |
134
+ | `nixet.tasks.create(params)` | `POST /tasks` | `Task` |
135
+ | `nixet.tasks.retrieve(taskId)` | `GET /tasks/{id}` | `Task` |
136
+ | `nixet.tasks.list(params?)` | `GET /tasks` | `Page<Task>` |
137
+ | `nixet.tasks.cancel(taskId)` | `POST /tasks/{id}/cancel` | `Task` |
138
+ | `nixet.tasks.retry(taskId)` | `POST /tasks/{id}/retry` | `Task` |
139
+ | `nixet.tasks.resume(taskId)` | `POST /tasks/{id}/resume` | `Task` |
140
+ | `nixet.tasks.wait(taskId, options?)` | Polls `GET /tasks/{id}` | `Task` |
141
+
142
+ **`CreateTaskParams`**: `agentId` (required), `input` (required), `version`,
143
+ `conversationId`, `userId`, `provider`, `memory: MemoryPolicy`,
144
+ `maxAttempts` (default 3).
145
+
146
+ **`ListTaskParams`**: `limit`, `offset`, `status: TaskStatus`, `agentId`,
147
+ `conversationId`.
148
+
149
+ **`wait` options**: `intervalMs` (default 2000), `timeoutMs` (default 600000),
150
+ `onUpdate(task)`, `signal`. Resolves when the status is `completed`, `failed`
151
+ or `cancelled`; throws on timeout without cancelling the task.
152
+
153
+ `resume` exists for paused tasks; nothing pauses a task yet.
154
+
155
+ ## Users
156
+
157
+ | Method | Request | Returns |
158
+ | --- | --- | --- |
159
+ | `nixet.users.create(params)` | `POST /users` | `User` |
160
+ | `nixet.users.retrieve(userId)` | `GET /users/{id}` | `User` |
161
+ | `nixet.users.list(params?)` | `GET /users` | `Page<User>` |
162
+
163
+ **`CreateUserParams`**: `reference` (required, unique in the workspace),
164
+ `email`, `name`, `metadata: Record<string, unknown>`.
165
+
166
+ `list` accepts `reference` to find a user by your own ID.
167
+
168
+ ## Conversations
169
+
170
+ | Method | Request | Returns |
171
+ | --- | --- | --- |
172
+ | `nixet.conversations.create(params)` | `POST /conversations` | `Conversation` |
173
+ | `nixet.conversations.retrieve(conversationId)` | `GET /conversations/{id}` | `Conversation` |
174
+ | `nixet.conversations.list(params?)` | `GET /conversations` | `Page<Conversation>` |
175
+ | `nixet.conversations.send(conversationId, params)` | `POST /conversations/{id}/messages` | `SendMessageResponse` |
176
+ | `nixet.conversations.messages(conversationId)` | `GET /conversations/{id}/messages` | `Page<ConversationMessage>` |
177
+
178
+ **`CreateConversationParams`**: `agentId` (required), `userId`, `title`,
179
+ `agentVersion`, `memory: Partial<MemoryPolicy>`.
180
+
181
+ **`SendMessageParams`**: `input` (required), `provider`.
182
+
183
+ `list` accepts `agentId` and `userId`.
184
+
185
+ ## Memory
186
+
187
+ Every call names a target: `agentId` (required), and optionally `userId` and
188
+ `conversationId`.
189
+
190
+ | Method | Request | Returns |
191
+ | --- | --- | --- |
192
+ | `nixet.memory.create(params)` | `POST /memory` | `MemoryRow[]` |
193
+ | `nixet.memory.search(params)` | `POST /memory/search` | `MemoryRow[]` |
194
+ | `nixet.memory.list(params)` | `POST /memory/list` | `MemoryRow[]` |
195
+ | `nixet.memory.get(memoryId, target)` | `GET /memory/{id}` | `MemoryRow` |
196
+ | `nixet.memory.update(memoryId, params)` | `PATCH /memory/{id}` | `MemoryRow` |
197
+ | `nixet.memory.delete(memoryId, target)` | `DELETE /memory/{id}` | `void` |
198
+
199
+ | Params | Fields |
200
+ | --- | --- |
201
+ | `CreateMemoryParams` | target + `scope: MemoryScope` (required), `content` (required), `metadata`, `expiresAt` |
202
+ | `SearchMemoryParams` | target + `query` (required), `scope`, `limit` (default 10) |
203
+ | `ListMemoryParams` | target + `scope`, `limit` (default 50) |
204
+ | `UpdateMemoryParams` | target + `content`, `metadata`, `expiresAt` (`null` clears) |
205
+
206
+ ## Skills
207
+
208
+ | Method | Request | Returns |
209
+ | --- | --- | --- |
210
+ | `nixet.skills.create(params)` | `POST /skills`, then `POST /skills/{id}/versions` when `instructions` is given | `Skill & { version?: SkillVersion }` |
211
+ | `nixet.skills.retrieve(skillId)` | `GET /skills/{id}` | `Skill` |
212
+ | `nixet.skills.list(params?)` | `GET /skills` | `Page<Skill>` |
213
+ | `nixet.skills.versions.create(skillId, params)` | `POST /skills/{id}/versions` | `SkillVersion` |
214
+ | `nixet.skills.versions.list(skillId, params?)` | `GET /skills/{id}/versions` | `Page<SkillVersion>` |
215
+
216
+ **`CreateSkillParams`**: `name` (required; lowercase, optionally `group/name`),
217
+ `description`, `instructions`, `tools`.
218
+
219
+ **`CreateSkillVersionParams`**: `instructions` (required), `tools`, `publish`
220
+ (default `true`).
221
+
222
+ ## Knowledge collections
223
+
224
+ | Method | Request | Returns |
225
+ | --- | --- | --- |
226
+ | `nixet.knowledge.collections.create(params)` | `POST /knowledge/collections` | `KnowledgeCollection` |
227
+ | `nixet.knowledge.collections.retrieve(collectionId)` | `GET /knowledge/collections/{id}` | `KnowledgeCollection` |
228
+ | `nixet.knowledge.collections.list(params?)` | `GET /knowledge/collections` | `Page<KnowledgeCollection>` |
229
+ | `nixet.knowledge.collections.del(collectionId)` | `DELETE /knowledge/collections/{id}` | `KnowledgeCollection` |
230
+
231
+ **`CreateKnowledgeCollectionParams`**: `name` (required; lowercase and
232
+ hyphenated), `description`, `chunkStrategy: "recursive" | "markdown"` (default
233
+ `recursive`), `chunkSize` (128–8000, default 1000), `chunkOverlap` (0–2000,
234
+ default 200, below `chunkSize`). Chunk settings are fixed at creation.
235
+
236
+ `list` accepts `name`. `del` is refused while the collection has sources.
237
+
238
+ ## Knowledge sources
239
+
240
+ | Method | Request | Returns |
241
+ | --- | --- | --- |
242
+ | `nixet.knowledge.sources.create(params)` | `POST /knowledge/sources` | `KnowledgeSource` |
243
+ | `nixet.knowledge.sources.retrieve(sourceId)` | `GET /knowledge/sources/{id}` | `KnowledgeSource` |
244
+ | `nixet.knowledge.sources.list(params?)` | `GET /knowledge/sources` | `Page<KnowledgeSource>` |
245
+ | `nixet.knowledge.sources.del(sourceId)` | `DELETE /knowledge/sources/{id}` | `KnowledgeSource` |
246
+
247
+ **`CreateKnowledgeSourceParams`**: `collection` (required; the name),
248
+ `kind: "text" | "url"` (required), `title` (required), `content` (required; the
249
+ text, or the URL).
250
+
251
+ `create` returns while the source is still `pending`; poll `retrieve` until
252
+ `status` is `ready` or `failed`. `list` accepts `collectionId` and `status`.
253
+ To add a file, use `documents.convert` with `collection`.
254
+
255
+ ## Documents
256
+
257
+ | Method | Request | Returns |
258
+ | --- | --- | --- |
259
+ | `nixet.documents.convert(params)` | `POST /documents/convert` (multipart) | `DocumentConversionResult` |
260
+
261
+ **`ConvertDocumentParams`**
262
+
263
+ | Param | Type | Notes |
264
+ | --- | --- | --- |
265
+ | `file` | `Blob \| Uint8Array` | Required. Up to 20 MB |
266
+ | `filename` | `string` | Needed for bytes; matters for CSV |
267
+ | `password` | `string` | Opens a protected PDF; never stored |
268
+ | `collection` | `string` | Also store as a knowledge source. Needs `knowledge:write` |
269
+ | `title` | `string` | Source title when storing |
270
+ | `signal` | `AbortSignal` | Passed here rather than as a second argument |
271
+
272
+ **`DocumentConversionResult`**: `markdown`, `bytes`, `page_count` (null for
273
+ spreadsheets), `ocr_pages: number[]`, `source` (null unless a collection was
274
+ named; otherwise `{ id, collection, status }`).
275
+
276
+ ## MCP servers
277
+
278
+ | Method | Request | Returns |
279
+ | --- | --- | --- |
280
+ | `nixet.mcpServers.create(params)` | `POST /mcp/servers` | `McpServer` |
281
+ | `nixet.mcpServers.retrieve(serverId)` | `GET /mcp/servers/{id}` | `McpServer` |
282
+ | `nixet.mcpServers.list(params?)` | `GET /mcp/servers` | `Page<McpServer>` |
283
+ | `nixet.mcpServers.update(serverId, params)` | `PATCH /mcp/servers/{id}` | `McpServer` |
284
+ | `nixet.mcpServers.del(serverId)` | `DELETE /mcp/servers/{id}` | `McpServer` |
285
+
286
+ **`CreateMcpServerParams`**: `name` (required, fixed once created), `url`
287
+ (required; public `http(s)` only), `transport: "http" | "sse"` (default
288
+ `http`), `description`, `auth: McpAuth` (default `{ type: "none" }`).
289
+
290
+ **`UpdateMcpServerParams`**: `url`, `transport`, `description`, `auth`.
291
+ Changing `url` rediscovers the tools.
292
+
293
+ `list` accepts `name`.
294
+
295
+ ## Tools
296
+
297
+ Read-only: tools are discovered from registered MCP servers.
298
+
299
+ | Method | Request | Returns |
300
+ | --- | --- | --- |
301
+ | `nixet.tools.list(params?)` | `GET /mcp/tools` | `Page<McpTool>` |
302
+ | `nixet.tools.retrieve(toolId)` | `GET /mcp/tools/{id}` | `McpTool` |
303
+
304
+ `list` accepts `serverName` and `name`.
305
+
306
+ ## Connections
307
+
308
+ | Method | Request | Returns |
309
+ | --- | --- | --- |
310
+ | `nixet.connections.create(params)` | `POST /mcp/connections` | `Connection` |
311
+ | `nixet.connections.retrieve(id)` | `GET /mcp/connections/{id}` | `Connection` |
312
+ | `nixet.connections.list(params?)` | `GET /mcp/connections` | `Page<Connection>` |
313
+ | `nixet.connections.revoke(id)` | `DELETE /mcp/connections/{id}` | `Connection` |
314
+
315
+ **`CreateConnectionParams`**: `userId` (required), `server` (required; a server
316
+ with `per_user` auth), `value` (required; never returned), `expiresAt`,
317
+ `refreshValue`.
318
+
319
+ **`ListConnectionParams`**: `limit`, `offset`, `userId`, `server`,
320
+ `status: ConnectionStatus`.
321
+
322
+ **`Connection`**: `id`, `user_id`, `server`, `scheme`, `status`, `expires_at`,
323
+ `last_used_at`, `created_at`, `updated_at`.
324
+
325
+ ## Guardrails
326
+
327
+ | Method | Request | Returns |
328
+ | --- | --- | --- |
329
+ | `nixet.guardrails.create(params)` | `POST /guardrails` | `Guardrail` |
330
+ | `nixet.guardrails.retrieve(id)` | `GET /guardrails/{id}` | `Guardrail` |
331
+ | `nixet.guardrails.list(params?)` | `GET /guardrails` | `Page<Guardrail>` |
332
+
333
+ **`CreateGuardrailParams`** (wire field names)
334
+
335
+ | Param | Type | Notes |
336
+ | --- | --- | --- |
337
+ | `name` | `string` | Required; lowercase, numbers, hyphens |
338
+ | `description` | `string` | |
339
+ | `stage` | `"input" \| "output" \| "tool_result"` | Required |
340
+ | `action` | `"allow" \| "modify" \| "warn" \| "block"` | Required. `modify` needs `replace` on every pattern |
341
+ | `patterns` | `{ match: string; replace?: string }[]` | Case-insensitive regular expressions, up to 50 |
342
+ | `detector` | `"pii" \| "topics" \| "length"` | Instead of `patterns` |
343
+ | `topics` | `string[]` | For the `topics` detector |
344
+ | `max_characters` | `number` | For the `length` detector |
345
+ | `message` | `string` | Shown when the guard blocks |
346
+
347
+ `list` accepts `name` and `stage`. Guardrails have no update or delete through
348
+ the API.
349
+
350
+ ## Secrets
351
+
352
+ | Method | Request | Returns |
353
+ | --- | --- | --- |
354
+ | `nixet.secrets.create(params)` | `POST /secrets` | `Secret` |
355
+ | `nixet.secrets.retrieve(secretId)` | `GET /secrets/{id}` | `Secret` |
356
+ | `nixet.secrets.list(params?)` | `GET /secrets` | `Page<Secret>` |
357
+ | `nixet.secrets.update(secretId, params)` | `PATCH /secrets/{id}` | `Secret` |
358
+ | `nixet.secrets.del(secretId)` | `DELETE /secrets/{id}` | `Secret` |
359
+
360
+ **`CreateSecretParams`**: `name` (required; lowercase and hyphenated, fixed),
361
+ `value` (required; never returned), `description`.
362
+
363
+ **`UpdateSecretParams`**: `value`, `description`.
364
+
365
+ `list` accepts `name`. `Secret` holds metadata and a hint, never the value.
366
+
367
+ ## RunStream
368
+
369
+ Returned by `nixet.runs.stream`. Read it one way per run.
370
+
371
+ | Member | Type | Notes |
372
+ | --- | --- | --- |
373
+ | `runId` | `Promise<string>` | Resolves when the server accepts the run |
374
+ | `[Symbol.asyncIterator]()` | `AsyncGenerator<RunEvent>` | Every event |
375
+ | `chunks()` | `AsyncGenerator<string>` | Only `run.output` text |
376
+ | `text()` | `Promise<string>` | The full output once finished |
377
+ | `on(type \| "*", handler)` | `() => void` | Subscribe; returns an unsubscribe function |
378
+
379
+ Reading a stream twice throws.
380
+
381
+ ## Errors
382
+
383
+ ```text
384
+ NixetError
385
+ ├── APIError status, requestId
386
+ │ ├── BadRequestError 400
387
+ │ ├── AuthenticationError 401
388
+ │ ├── PermissionError 403
389
+ │ ├── NotFoundError 404
390
+ │ ├── ConflictError 409
391
+ │ ├── RateLimitError 429
392
+ │ └── ServerError 5xx
393
+ └── ConnectionError cause
394
+ ```
395
+
396
+ `ConnectionError`, `RateLimitError` and `ServerError` are retried automatically
397
+ up to `maxRetries` times before being thrown.
398
+
399
+ ## Types
400
+
401
+ All types are exported from `@nixet/sdk`. Response objects use the API's
402
+ `snake_case` field names.
403
+
404
+ ```ts
405
+ type Provider = "nix" | "openai" | "anthropic";
406
+ type Tier = "fast" | "balanced" | "powerful";
407
+
408
+ type ModelConfig =
409
+ | { provider: "nix"; tier?: Tier }
410
+ | { provider: "openai" | "anthropic"; model: string };
411
+
412
+ type RunStatus = "queued" | "running" | "completed" | "failed" | "cancelled";
413
+
414
+ type TaskStatus =
415
+ | "queued" | "running" | "completed" | "failed" | "cancelled"
416
+ // declared for future approvals and pauses; not produced yet
417
+ | "waiting_for_tool" | "waiting_for_approval" | "waiting_for_user" | "paused";
418
+
419
+ type MemoryScope = "conversation" | "user" | "agent";
420
+ interface MemoryPolicy { conversation: boolean; user: boolean; agent: boolean }
421
+
422
+ type ToolTag = "read" | "write" | "destructive" | "external";
423
+ type ToolPolicy = "allow" | "ask" | "deny";
424
+
425
+ type McpTransport = "http" | "sse";
426
+ type McpConnectionScheme = "api_key" | "oauth2" | "session";
427
+ type McpAuth =
428
+ | { type: "none" }
429
+ | { type: "bearer"; secret: string }
430
+ | { type: "header"; header: string; secret: string }
431
+ | { type: "oauth"; secret: string }
432
+ | { type: "per_user"; scheme: McpConnectionScheme };
433
+
434
+ type ConnectionStatus = "pending" | "active" | "expired" | "revoked";
435
+
436
+ type SourceKind = "file" | "text" | "url";
437
+ type ChunkStrategy = "markdown" | "recursive";
438
+
439
+ type RedactionMode = "off" | "structured" | "standard" | "strict";
440
+ interface RedactionPolicyInput {
441
+ mode: RedactionMode;
442
+ reversible?: boolean;
443
+ minimumConfidence?: number;
444
+ labels?: RedactionLabel[];
445
+ retainFor?: "1h" | "24h" | "7d" | "30d";
446
+ }
447
+
448
+ interface Identity {
449
+ key_id: string | null;
450
+ organization_id: string;
451
+ project_id: string;
452
+ environment_id: "development" | "production";
453
+ permissions: string[];
454
+ }
455
+ ```
456
+
457
+ ### Run events
458
+
459
+ ```ts
460
+ type RunEventType =
461
+ | "run.started" | "run.completed" | "run.failed" | "run.cancelled"
462
+ | "run.paused" | "run.continued"
463
+ | "run.output"
464
+ | "run.model.started" | "run.model.completed"
465
+ | "run.tool.started" | "run.tool.completed" | "run.tool.failed"
466
+ | "run.knowledge.started" | "run.knowledge.completed"
467
+ | "run.memory.recall.started" | "run.memory.recall.completed"
468
+ | "run.memory.update.started" | "run.memory.update.completed"
469
+ | "run.reasoning.started" | "run.reasoning.completed"
470
+ | "run.subagent.spawned" | "run.subagent.completed"
471
+ | "run.subagent.failed" | "run.subagent.killed"
472
+ | "run.workflow.step.started" | "run.workflow.step.completed"
473
+ | "run.workflow.step.failed" | "run.workflow.step.skipped"
474
+ | "run.task.created" | "run.task.status"
475
+ | "run.session.summarised" | "run.context.compressed"
476
+ | "run.skill.loaded";
477
+ ```
478
+
479
+ Each `RunEvent` carries a `sequence` (monotonic within a run), a `type`, a
480
+ `category`, optional `data`, and timestamps. Resume a dropped stream with
481
+ `runs.events(runId, { after: sequence })`.
482
+
483
+ For the exact fields of every response object, see the type declarations
484
+ shipped in the package (`dist/cjs/types.d.ts`) or the
485
+ [`@nixet/contracts`](https://www.npmjs.com/package/@nixet/contracts) schemas.
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Errors the SDK raises.
3
+ *
4
+ * Subclasses exist per status so callers can branch on the kind of failure
5
+ * rather than parse a message: a rate limit is worth retrying, a permission
6
+ * problem is not.
7
+ */
8
+ export declare class NixetError extends Error {
9
+ constructor(message: string);
10
+ }
11
+ export declare class APIError extends NixetError {
12
+ readonly status: number;
13
+ /** Correlates a report with a server-side log entry. */
14
+ readonly requestId: string | null;
15
+ constructor(status: number, message: string, requestId: string | null);
16
+ /** Build the most specific error class the status warrants. */
17
+ static from(status: number, message: string, requestId: string | null): APIError;
18
+ }
19
+ export declare class BadRequestError extends APIError {
20
+ }
21
+ export declare class AuthenticationError extends APIError {
22
+ }
23
+ export declare class PermissionError extends APIError {
24
+ }
25
+ export declare class NotFoundError extends APIError {
26
+ }
27
+ export declare class ConflictError extends APIError {
28
+ }
29
+ export declare class RateLimitError extends APIError {
30
+ }
31
+ export declare class ServerError extends APIError {
32
+ }
33
+ /** The API was unreachable, which is different from the API refusing. */
34
+ export declare class ConnectionError extends NixetError {
35
+ readonly cause?: unknown;
36
+ constructor(message: string, cause?: unknown);
37
+ }
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConnectionError = exports.ServerError = exports.RateLimitError = exports.ConflictError = exports.NotFoundError = exports.PermissionError = exports.AuthenticationError = exports.BadRequestError = exports.APIError = exports.NixetError = void 0;
4
+ /**
5
+ * Errors the SDK raises.
6
+ *
7
+ * Subclasses exist per status so callers can branch on the kind of failure
8
+ * rather than parse a message: a rate limit is worth retrying, a permission
9
+ * problem is not.
10
+ */
11
+ class NixetError extends Error {
12
+ constructor(message) {
13
+ super(message);
14
+ this.name = new.target.name;
15
+ }
16
+ }
17
+ exports.NixetError = NixetError;
18
+ class APIError extends NixetError {
19
+ status;
20
+ /** Correlates a report with a server-side log entry. */
21
+ requestId;
22
+ constructor(status, message, requestId) {
23
+ super(message);
24
+ this.status = status;
25
+ this.requestId = requestId;
26
+ }
27
+ /** Build the most specific error class the status warrants. */
28
+ static from(status, message, requestId) {
29
+ switch (status) {
30
+ case 400:
31
+ return new BadRequestError(status, message, requestId);
32
+ case 401:
33
+ return new AuthenticationError(status, message, requestId);
34
+ case 403:
35
+ return new PermissionError(status, message, requestId);
36
+ case 404:
37
+ return new NotFoundError(status, message, requestId);
38
+ case 409:
39
+ return new ConflictError(status, message, requestId);
40
+ case 429:
41
+ return new RateLimitError(status, message, requestId);
42
+ default:
43
+ return status >= 500
44
+ ? new ServerError(status, message, requestId)
45
+ : new APIError(status, message, requestId);
46
+ }
47
+ }
48
+ }
49
+ exports.APIError = APIError;
50
+ class BadRequestError extends APIError {
51
+ }
52
+ exports.BadRequestError = BadRequestError;
53
+ class AuthenticationError extends APIError {
54
+ }
55
+ exports.AuthenticationError = AuthenticationError;
56
+ class PermissionError extends APIError {
57
+ }
58
+ exports.PermissionError = PermissionError;
59
+ class NotFoundError extends APIError {
60
+ }
61
+ exports.NotFoundError = NotFoundError;
62
+ class ConflictError extends APIError {
63
+ }
64
+ exports.ConflictError = ConflictError;
65
+ class RateLimitError extends APIError {
66
+ }
67
+ exports.RateLimitError = RateLimitError;
68
+ class ServerError extends APIError {
69
+ }
70
+ exports.ServerError = ServerError;
71
+ /** The API was unreachable, which is different from the API refusing. */
72
+ class ConnectionError extends NixetError {
73
+ cause;
74
+ constructor(message, cause) {
75
+ super(message);
76
+ this.cause = cause;
77
+ }
78
+ }
79
+ exports.ConnectionError = ConnectionError;