@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
@@ -0,0 +1,212 @@
1
+ /**
2
+ * Collections: the named indexes an agent version searches.
3
+ *
4
+ * A collection is a container and a chunking rule, nothing more. The documents
5
+ * in it are sources, and the chunks those produce live in the vector store the
6
+ * runtime owns.
7
+ *
8
+ * There is no update. The chunk settings are what a collection is, and they
9
+ * cannot change without the chunks already stored disagreeing with the ones
10
+ * added next: half an index split at 1000 characters and half at 400 retrieves
11
+ * badly, and nothing could honestly report which half a run searched. The name
12
+ * is fixed for the reason a secret's name is, since a published version pins
13
+ * it and a rename would silently redirect what a running agent searches.
14
+ * Re-chunking means creating another collection.
15
+ */
16
+ export class KnowledgeCollections {
17
+ transport;
18
+ constructor(transport) {
19
+ this.transport = transport;
20
+ }
21
+ create(params, options = {}) {
22
+ return this.transport.request({
23
+ method: "POST",
24
+ path: "/knowledge/collections",
25
+ body: {
26
+ name: params.name,
27
+ ...(params.description ? { description: params.description } : {}),
28
+ ...(params.chunkStrategy ? { chunk_strategy: params.chunkStrategy } : {}),
29
+ ...(params.chunkSize === undefined ? {} : { chunk_size: params.chunkSize }),
30
+ ...(params.chunkOverlap === undefined
31
+ ? {}
32
+ : { chunk_overlap: params.chunkOverlap }),
33
+ },
34
+ signal: options.signal,
35
+ });
36
+ }
37
+ retrieve(collectionId, options = {}) {
38
+ return this.transport.request({
39
+ method: "GET",
40
+ path: `/knowledge/collections/${encodeURIComponent(collectionId)}`,
41
+ signal: options.signal,
42
+ });
43
+ }
44
+ /**
45
+ * Collections, by name.
46
+ *
47
+ * `source_count` is every document whatever its status, while `chunk_count`
48
+ * covers only the sources that finished, so an index still being ingested
49
+ * reads as emptier than it will be.
50
+ */
51
+ list(params = {}, options = {}) {
52
+ return this.transport.requestPage({
53
+ method: "GET",
54
+ path: "/knowledge/collections",
55
+ query: {
56
+ $limit: params.limit,
57
+ $offset: params.offset,
58
+ name: params.name,
59
+ },
60
+ signal: options.signal,
61
+ });
62
+ }
63
+ /**
64
+ * Delete a collection.
65
+ *
66
+ * Refused while it still holds sources. Their chunks are in the vector store
67
+ * rather than beside this row, so dropping the collection first would leave
68
+ * them with nothing describing them and no scope key that resolves —
69
+ * orphaned vectors a later search could still match. Remove the sources
70
+ * first; their chunks go with them.
71
+ *
72
+ * A published version that named this collection can no longer search it,
73
+ * because a version is frozen and cannot be edited to drop the reference.
74
+ */
75
+ del(collectionId, options = {}) {
76
+ return this.transport.request({
77
+ method: "DELETE",
78
+ path: `/knowledge/collections/${encodeURIComponent(collectionId)}`,
79
+ signal: options.signal,
80
+ });
81
+ }
82
+ }
83
+ /**
84
+ * Sources: the documents inside a collection.
85
+ *
86
+ * Registering one writes a row and returns. Converting, OCR'ing, chunking and
87
+ * embedding all happen afterwards in a worker, because a scanned PDF of three
88
+ * hundred pages takes minutes and nothing useful comes of holding an HTTP
89
+ * request open for it. So `create` answers `pending` rather than `ready`, and
90
+ * `status` is the honest answer to "can my agent use this yet" — which is why
91
+ * it names the step in progress rather than a generic "processing".
92
+ *
93
+ * Uploading a file is `POST /v1/knowledge/sources/upload`, a multipart request
94
+ * this SDK does not yet wrap; `create` covers `text` and `url`, since bytes do
95
+ * not belong in JSON.
96
+ *
97
+ * There is no update. A source is what was ingested: its chunks were produced
98
+ * from the bytes on record, so editing the title or the content here would
99
+ * leave a row describing something other than what an agent actually searches.
100
+ * Replacing a document means ingesting it again.
101
+ */
102
+ export class KnowledgeSources {
103
+ transport;
104
+ constructor(transport) {
105
+ this.transport = transport;
106
+ }
107
+ /**
108
+ * Register a document. Returns before it is searchable.
109
+ *
110
+ * Poll `retrieve` until `status` is `ready`, or `failed` with `error` saying
111
+ * why. A URL is fetched by the worker rather than by this call, so an
112
+ * address that cannot be reached surfaces there too.
113
+ */
114
+ create(params, options = {}) {
115
+ return this.transport.request({
116
+ method: "POST",
117
+ path: "/knowledge/sources",
118
+ body: {
119
+ collection: params.collection,
120
+ kind: params.kind,
121
+ title: params.title,
122
+ content: params.content,
123
+ },
124
+ signal: options.signal,
125
+ });
126
+ }
127
+ retrieve(sourceId, options = {}) {
128
+ return this.transport.request({
129
+ method: "GET",
130
+ path: `/knowledge/sources/${encodeURIComponent(sourceId)}`,
131
+ signal: options.signal,
132
+ });
133
+ }
134
+ /**
135
+ * Sources, newest first, because the one someone is waiting on is the one
136
+ * they just added. Filter on `status` to see what is actually searchable.
137
+ */
138
+ list(params = {}, options = {}) {
139
+ return this.transport.requestPage({
140
+ method: "GET",
141
+ path: "/knowledge/sources",
142
+ query: {
143
+ $limit: params.limit,
144
+ $offset: params.offset,
145
+ collection_id: params.collectionId,
146
+ status: params.status,
147
+ },
148
+ signal: options.signal,
149
+ });
150
+ }
151
+ /**
152
+ * Delete a source.
153
+ *
154
+ * This is what removes a document from an index, and therefore what an
155
+ * erasure request is served by. The original is deleted before the row, so a
156
+ * failure leaves something to retry rather than a file in storage with
157
+ * nothing pointing at it.
158
+ */
159
+ del(sourceId, options = {}) {
160
+ return this.transport.request({
161
+ method: "DELETE",
162
+ path: `/knowledge/sources/${encodeURIComponent(sourceId)}`,
163
+ signal: options.signal,
164
+ });
165
+ }
166
+ }
167
+ /**
168
+ * Knowledge: your own documents, searchable by an agent.
169
+ *
170
+ * ```ts
171
+ * const collection = await nixet.knowledge.collections.create({
172
+ * name: "support-policies",
173
+ * chunkStrategy: "markdown",
174
+ * });
175
+ *
176
+ * const source = await nixet.knowledge.sources.create({
177
+ * collection: collection.name,
178
+ * kind: "text",
179
+ * title: "Refunds",
180
+ * content: "The refund window is thirty days.",
181
+ * });
182
+ *
183
+ * // Ingestion is asynchronous, so the source is `pending` here. Poll until
184
+ * // it is `ready` before expecting an agent to find anything in it.
185
+ * source.status; // "pending"
186
+ * ```
187
+ *
188
+ * Two sub-resources rather than one, because a collection and a source are
189
+ * different lifetimes: a collection is a chunking rule fixed at creation, and
190
+ * a source is a document that arrives, is processed and can be removed on its
191
+ * own. A version pins a collection by name, the way it pins an MCP server, so
192
+ * adding a document changes what a published agent can find without
193
+ * republishing it.
194
+ */
195
+ export class Knowledge {
196
+ collections;
197
+ sources;
198
+ constructor(
199
+ /** Sub-resource, so `nixet.knowledge.collections.create(...)` reads naturally. */
200
+ collections,
201
+ /**
202
+ * Sub-resource for the documents in a collection.
203
+ *
204
+ * Uploading a file is `POST /v1/knowledge/sources/upload` as multipart,
205
+ * which this SDK does not yet wrap; `sources.create` covers `text` and
206
+ * `url`.
207
+ */
208
+ sources) {
209
+ this.collections = collections;
210
+ this.sources = sources;
211
+ }
212
+ }
@@ -0,0 +1,103 @@
1
+ /**
2
+ * MCP servers: tools you run, used by agents we run.
3
+ *
4
+ * ```ts
5
+ * await nixet.secrets.create({ name: "github-token", value: process.env.GH_PAT });
6
+ *
7
+ * const server = await nixet.mcpServers.create({
8
+ * name: "github",
9
+ * url: "https://mcp.example.com/mcp",
10
+ * auth: { type: "bearer", secret: "github-token" },
11
+ * });
12
+ *
13
+ * // Registration discovers what the server offers. What an agent may do with
14
+ * // each tool is a policy, set per version rather than per server.
15
+ * const tools = await nixet.mcpServers.tools(server.id);
16
+ *
17
+ * await nixet.agents.versions.create(agent.id, {
18
+ * instructions: "Use the GitHub tools to answer questions about the repo.",
19
+ * mcpServers: [server.name],
20
+ * });
21
+ * ```
22
+ *
23
+ * Remote only: registering a `stdio` server would mean spawning your process
24
+ * inside our runtime, so that transport does not exist rather than being
25
+ * refused later. The URL is checked at registration against where Nixet is
26
+ * willing to connect, so a private or loopback address is rejected then rather
27
+ * than mid-run.
28
+ *
29
+ * A version names servers by handle, and the runtime connects at execution, so
30
+ * changing a server's URL changes what a published version reaches without
31
+ * republishing it. Its `name` is therefore fixed.
32
+ */
33
+ export class McpServers {
34
+ transport;
35
+ constructor(transport) {
36
+ this.transport = transport;
37
+ }
38
+ create(params, options = {}) {
39
+ return this.transport.request({
40
+ method: "POST",
41
+ path: "/mcp/servers",
42
+ body: {
43
+ name: params.name,
44
+ url: params.url,
45
+ ...(params.transport ? { transport: params.transport } : {}),
46
+ ...(params.description ? { description: params.description } : {}),
47
+ ...(params.auth ? { auth: params.auth } : {}),
48
+ },
49
+ signal: options.signal,
50
+ });
51
+ }
52
+ retrieve(serverId, options = {}) {
53
+ return this.transport.request({
54
+ method: "GET",
55
+ path: `/mcp/servers/${encodeURIComponent(serverId)}`,
56
+ signal: options.signal,
57
+ });
58
+ }
59
+ list(params = {}, options = {}) {
60
+ return this.transport.requestPage({
61
+ method: "GET",
62
+ path: "/mcp/servers",
63
+ query: {
64
+ $limit: params.limit,
65
+ $offset: params.offset,
66
+ name: params.name,
67
+ },
68
+ signal: options.signal,
69
+ });
70
+ }
71
+ /**
72
+ * Change where a server lives or how it authenticates.
73
+ *
74
+ * Moving the URL discards the tools we recorded, because what the old host
75
+ * advertised no longer describes the new one.
76
+ */
77
+ update(serverId, params, options = {}) {
78
+ return this.transport.request({
79
+ method: "PATCH",
80
+ path: `/mcp/servers/${encodeURIComponent(serverId)}`,
81
+ body: {
82
+ ...(params.url ? { url: params.url } : {}),
83
+ ...(params.transport ? { transport: params.transport } : {}),
84
+ ...(params.description === undefined ? {} : { description: params.description }),
85
+ ...(params.auth ? { auth: params.auth } : {}),
86
+ },
87
+ signal: options.signal,
88
+ });
89
+ }
90
+ /**
91
+ * Remove a server.
92
+ *
93
+ * A published version that named it can no longer be run, because a version
94
+ * is frozen and cannot be edited to drop the reference.
95
+ */
96
+ del(serverId, options = {}) {
97
+ return this.transport.request({
98
+ method: "DELETE",
99
+ path: `/mcp/servers/${encodeURIComponent(serverId)}`,
100
+ signal: options.signal,
101
+ });
102
+ }
103
+ }
@@ -0,0 +1,123 @@
1
+ function target(params) {
2
+ return {
3
+ agent_id: params.agentId,
4
+ ...(params.userId ? { user_id: params.userId } : {}),
5
+ ...(params.conversationId ? { conversation_id: params.conversationId } : {}),
6
+ };
7
+ }
8
+ /**
9
+ * Memory: what an agent retains about a person or a thread.
10
+ *
11
+ * Distinct from a conversation transcript, which is the literal record of what
12
+ * was said. A memory is a fact worth keeping — a preference, a constraint, a
13
+ * problem — extracted from conversations or written directly.
14
+ *
15
+ * ```ts
16
+ * await nixet.memory.create({
17
+ * scope: "user",
18
+ * agentId: agent.id,
19
+ * userId: user.id,
20
+ * content: "Prefers metric units and short answers.",
21
+ * });
22
+ *
23
+ * const found = await nixet.memory.search({
24
+ * query: "what are their preferences?",
25
+ * agentId: agent.id,
26
+ * userId: user.id,
27
+ * });
28
+ * ```
29
+ */
30
+ export class MemoryResource {
31
+ transport;
32
+ constructor(transport) {
33
+ this.transport = transport;
34
+ }
35
+ /** Recall memories relevant to a query, most relevant first. */
36
+ search(params, options = {}) {
37
+ return this.transport.request({
38
+ method: "POST",
39
+ path: "/memory/search",
40
+ body: {
41
+ ...target(params),
42
+ query: params.query,
43
+ ...(params.scope ? { scope: params.scope } : {}),
44
+ limit: params.limit ?? 10,
45
+ },
46
+ signal: options.signal,
47
+ });
48
+ }
49
+ /**
50
+ * Everything an agent holds, newest first.
51
+ *
52
+ * Use this to browse. `search` asks a question; this asks for the lot.
53
+ */
54
+ list(params, options = {}) {
55
+ return this.transport.request({
56
+ method: "POST",
57
+ path: "/memory/list",
58
+ body: {
59
+ ...target(params),
60
+ ...(params.scope ? { scope: params.scope } : {}),
61
+ limit: params.limit ?? 50,
62
+ },
63
+ signal: options.signal,
64
+ });
65
+ }
66
+ /**
67
+ * Store a memory directly.
68
+ *
69
+ * Use this for facts you already know — a plan tier, an account setting —
70
+ * rather than waiting for them to be said in a conversation.
71
+ */
72
+ create(params, options = {}) {
73
+ return this.transport.request({
74
+ method: "POST",
75
+ path: "/memory",
76
+ body: {
77
+ ...target(params),
78
+ scope: params.scope,
79
+ content: params.content,
80
+ ...(params.metadata ? { metadata: params.metadata } : {}),
81
+ ...(params.expiresAt ? { expires_at: params.expiresAt } : {}),
82
+ },
83
+ signal: options.signal,
84
+ });
85
+ }
86
+ /** One memory by id. */
87
+ get(memoryId, params, options = {}) {
88
+ return this.transport.request({
89
+ method: "GET",
90
+ path: `/memory/${encodeURIComponent(memoryId)}`,
91
+ query: target(params),
92
+ signal: options.signal,
93
+ });
94
+ }
95
+ /** Correct a memory in place. */
96
+ update(memoryId, params, options = {}) {
97
+ return this.transport.request({
98
+ method: "PATCH",
99
+ path: `/memory/${encodeURIComponent(memoryId)}`,
100
+ body: {
101
+ ...target(params),
102
+ ...(params.content !== undefined ? { content: params.content } : {}),
103
+ ...(params.metadata !== undefined ? { metadata: params.metadata } : {}),
104
+ ...(params.expiresAt !== undefined ? { expires_at: params.expiresAt } : {}),
105
+ },
106
+ signal: options.signal,
107
+ });
108
+ }
109
+ /**
110
+ * Forget a memory.
111
+ *
112
+ * The only way to erase what an agent knows about a person, so it is also
113
+ * what an erasure request is served by.
114
+ */
115
+ delete(memoryId, params, options = {}) {
116
+ return this.transport.request({
117
+ method: "DELETE",
118
+ path: `/memory/${encodeURIComponent(memoryId)}`,
119
+ query: target(params),
120
+ signal: options.signal,
121
+ });
122
+ }
123
+ }
@@ -0,0 +1,83 @@
1
+ import { RunStream } from "../stream.js";
2
+ /**
3
+ * Agent execution.
4
+ *
5
+ * `create` waits and returns the finished run; `stream` returns events as they
6
+ * are produced. Both record the same run, so a stream that drops can still be
7
+ * read afterwards.
8
+ */
9
+ export class Runs {
10
+ transport;
11
+ constructor(transport) {
12
+ this.transport = transport;
13
+ }
14
+ /** Run an agent and wait for it to finish. */
15
+ async create(agentId, params, options = {}) {
16
+ return this.transport.request({
17
+ method: "POST",
18
+ path: `/agents/${encodeURIComponent(agentId)}/runs`,
19
+ body: toBody(params),
20
+ signal: options.signal,
21
+ });
22
+ }
23
+ /**
24
+ * Run an agent and receive events as they happen.
25
+ *
26
+ * ```ts
27
+ * const stream = await nixet.runs.stream(agentId, { input: "Hello" });
28
+ * for await (const chunk of stream.chunks()) process.stdout.write(chunk);
29
+ * ```
30
+ */
31
+ async stream(agentId, params, options = {}) {
32
+ const response = await this.transport.stream({
33
+ method: "POST",
34
+ path: `/agents/${encodeURIComponent(agentId)}/runs/stream`,
35
+ body: toBody(params),
36
+ signal: options.signal,
37
+ });
38
+ return new RunStream(response);
39
+ }
40
+ async retrieve(runId, options = {}) {
41
+ return this.transport.request({
42
+ method: "GET",
43
+ path: `/runs/${encodeURIComponent(runId)}`,
44
+ signal: options.signal,
45
+ });
46
+ }
47
+ async list(agentId, params = {}, options = {}) {
48
+ return this.transport.requestPage({
49
+ method: "GET",
50
+ path: `/agents/${encodeURIComponent(agentId)}/runs`,
51
+ query: { $limit: params.limit, $offset: params.offset },
52
+ signal: options.signal,
53
+ });
54
+ }
55
+ /**
56
+ * The recorded event log.
57
+ *
58
+ * Pass `after` to resume from the last event already seen, rather than
59
+ * running the agent again.
60
+ */
61
+ async events(runId, params = {}, options = {}) {
62
+ return this.transport.requestPage({
63
+ method: "GET",
64
+ path: `/runs/${encodeURIComponent(runId)}/events`,
65
+ query: {
66
+ "sequence[$gt]": params.after,
67
+ type: params.type,
68
+ $limit: params.limit,
69
+ $offset: params.offset,
70
+ },
71
+ signal: options.signal,
72
+ });
73
+ }
74
+ }
75
+ const toBody = (params) => ({
76
+ input: params.input,
77
+ ...(params.version ? { agent_version: params.version } : {}),
78
+ ...(params.provider ? { provider: params.provider } : {}),
79
+ ...(params.sessionId ? { session_id: params.sessionId } : {}),
80
+ ...(params.userId ? { user_id: params.userId } : {}),
81
+ ...(params.variables ? { variables: params.variables } : {}),
82
+ ...(params.mcpServers ? { mcp_servers: params.mcpServers } : {}),
83
+ });
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Secrets: credentials you give us so an agent can reach something of yours.
3
+ *
4
+ * ```ts
5
+ * await nixet.secrets.create({ name: "github-token", value: process.env.GH_PAT });
6
+ *
7
+ * await nixet.mcpServers.create({
8
+ * name: "github",
9
+ * url: "https://mcp.example.com/mcp",
10
+ * auth: { type: "bearer", secret: "github-token" },
11
+ * });
12
+ * ```
13
+ *
14
+ * A value is written once and never returned — `retrieve` and `list` carry a
15
+ * name and a hint, and no route exists that could answer with the credential.
16
+ * To rotate one, store a new value under the same name; whatever refers to it
17
+ * picks the new value up on the next run.
18
+ */
19
+ export class Secrets {
20
+ transport;
21
+ constructor(transport) {
22
+ this.transport = transport;
23
+ }
24
+ create(params, options = {}) {
25
+ return this.transport.request({
26
+ method: "POST",
27
+ path: "/secrets",
28
+ body: {
29
+ name: params.name,
30
+ value: params.value,
31
+ ...(params.description ? { description: params.description } : {}),
32
+ },
33
+ signal: options.signal,
34
+ });
35
+ }
36
+ /** Metadata only. The value is not part of this response by design. */
37
+ retrieve(secretId, options = {}) {
38
+ return this.transport.request({
39
+ method: "GET",
40
+ path: `/secrets/${encodeURIComponent(secretId)}`,
41
+ signal: options.signal,
42
+ });
43
+ }
44
+ list(params = {}, options = {}) {
45
+ return this.transport.requestPage({
46
+ method: "GET",
47
+ path: "/secrets",
48
+ query: {
49
+ $limit: params.limit,
50
+ $offset: params.offset,
51
+ name: params.name,
52
+ },
53
+ signal: options.signal,
54
+ });
55
+ }
56
+ /** Replace the value, or the description. The name is fixed. */
57
+ update(secretId, params, options = {}) {
58
+ return this.transport.request({
59
+ method: "PATCH",
60
+ path: `/secrets/${encodeURIComponent(secretId)}`,
61
+ body: {
62
+ ...(params.value === undefined ? {} : { value: params.value }),
63
+ ...(params.description === undefined ? {} : { description: params.description }),
64
+ },
65
+ signal: options.signal,
66
+ });
67
+ }
68
+ /**
69
+ * Delete a secret.
70
+ *
71
+ * Anything that names it stops authenticating, so a published version
72
+ * referring to this secret will start failing against its server.
73
+ */
74
+ del(secretId, options = {}) {
75
+ return this.transport.request({
76
+ method: "DELETE",
77
+ path: `/secrets/${encodeURIComponent(secretId)}`,
78
+ signal: options.signal,
79
+ });
80
+ }
81
+ }
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Skills: reusable expertise an agent can use.
3
+ *
4
+ * A skill is instructions plus the tools that expertise needs, versioned like
5
+ * an agent. An agent version references one as `name` or `name@v2`.
6
+ */
7
+ export class Skills {
8
+ transport;
9
+ constructor(transport) {
10
+ this.transport = transport;
11
+ }
12
+ /**
13
+ * Create a skill, optionally publishing its first version.
14
+ *
15
+ * ```ts
16
+ * await nixet.skills.create({
17
+ * name: "research/company-lookup",
18
+ * instructions: "State the industry and size of any company asked about.",
19
+ * tools: ["current_time"],
20
+ * });
21
+ * ```
22
+ */
23
+ async create(params, options = {}) {
24
+ const skill = await this.transport.request({
25
+ method: "POST",
26
+ path: "/skills",
27
+ body: {
28
+ name: params.name,
29
+ ...(params.description ? { description: params.description } : {}),
30
+ },
31
+ signal: options.signal,
32
+ });
33
+ if (!params.instructions)
34
+ return skill;
35
+ const version = await this.versions.create(skill.id, { instructions: params.instructions, tools: params.tools }, options);
36
+ // The skill was read before the version published, so its pointer is stale.
37
+ return { ...skill, current_version: version.version, version };
38
+ }
39
+ async retrieve(skillId, options = {}) {
40
+ return this.transport.request({
41
+ method: "GET",
42
+ path: `/skills/${encodeURIComponent(skillId)}`,
43
+ signal: options.signal,
44
+ });
45
+ }
46
+ async list(params = {}, options = {}) {
47
+ return this.transport.requestPage({
48
+ method: "GET",
49
+ path: "/skills",
50
+ query: { $limit: params.limit, $offset: params.offset },
51
+ signal: options.signal,
52
+ });
53
+ }
54
+ /** Immutable versions of a skill. */
55
+ versions = {
56
+ create: async (skillId, params, options = {}) => this.transport.request({
57
+ method: "POST",
58
+ path: `/skills/${encodeURIComponent(skillId)}/versions`,
59
+ body: {
60
+ instructions: params.instructions,
61
+ ...(params.tools ? { tools: params.tools.map(toToolRef) } : {}),
62
+ ...(params.publish === undefined ? {} : { publish: params.publish }),
63
+ },
64
+ signal: options.signal,
65
+ }),
66
+ list: async (skillId, params = {}, options = {}) => this.transport.requestPage({
67
+ method: "GET",
68
+ path: `/skills/${encodeURIComponent(skillId)}/versions`,
69
+ query: { $limit: params.limit, $offset: params.offset },
70
+ signal: options.signal,
71
+ }),
72
+ };
73
+ }
74
+ const toToolRef = (tool) => typeof tool === "string" ? { name: tool } : tool;