@nixet/sdk 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 +164 -2
  3. package/dist/cjs/errors.d.ts +37 -0
  4. package/dist/cjs/errors.js +79 -0
  5. package/dist/cjs/index.d.ts +88 -0
  6. package/dist/cjs/index.js +118 -0
  7. package/dist/cjs/resources/agents.d.ts +67 -0
  8. package/dist/cjs/resources/agents.js +74 -0
  9. package/dist/cjs/resources/connections.d.ts +94 -0
  10. package/dist/cjs/resources/connections.js +106 -0
  11. package/dist/cjs/resources/conversations.d.ts +62 -0
  12. package/dist/cjs/resources/conversations.js +86 -0
  13. package/dist/cjs/resources/documents.d.ts +65 -0
  14. package/dist/cjs/resources/documents.js +61 -0
  15. package/dist/cjs/resources/guardrails.d.ts +56 -0
  16. package/dist/cjs/resources/guardrails.js +76 -0
  17. package/dist/cjs/resources/knowledge.d.ts +192 -0
  18. package/dist/cjs/resources/knowledge.js +221 -0
  19. package/dist/cjs/resources/mcp-servers.d.ts +83 -0
  20. package/dist/cjs/resources/mcp-servers.js +107 -0
  21. package/dist/cjs/resources/memory.d.ts +95 -0
  22. package/dist/cjs/resources/memory.js +127 -0
  23. package/dist/cjs/resources/runs.d.ts +78 -0
  24. package/dist/cjs/resources/runs.js +87 -0
  25. package/dist/cjs/resources/secrets.d.ts +60 -0
  26. package/dist/cjs/resources/secrets.js +85 -0
  27. package/dist/cjs/resources/skills.d.ts +57 -0
  28. package/dist/cjs/resources/skills.js +78 -0
  29. package/dist/cjs/resources/tasks.d.ts +91 -0
  30. package/dist/cjs/resources/tasks.js +129 -0
  31. package/dist/cjs/resources/tools.d.ts +42 -0
  32. package/dist/cjs/resources/tools.js +57 -0
  33. package/dist/cjs/resources/users.d.ts +39 -0
  34. package/dist/cjs/resources/users.js +57 -0
  35. package/dist/cjs/resources/versions.d.ts +105 -0
  36. package/dist/cjs/resources/versions.js +78 -0
  37. package/dist/cjs/stream.d.ts +57 -0
  38. package/dist/cjs/stream.js +170 -0
  39. package/dist/cjs/transport.d.ts +45 -0
  40. package/dist/cjs/transport.js +106 -0
  41. package/dist/cjs/types.d.ts +537 -0
  42. package/dist/cjs/types.js +3 -0
  43. package/dist/esm/errors.js +66 -0
  44. package/dist/esm/index.js +103 -0
  45. package/dist/esm/package.json +1 -0
  46. package/dist/esm/resources/agents.js +70 -0
  47. package/dist/esm/resources/connections.js +102 -0
  48. package/dist/esm/resources/conversations.js +82 -0
  49. package/dist/esm/resources/documents.js +57 -0
  50. package/dist/esm/resources/guardrails.js +72 -0
  51. package/dist/esm/resources/knowledge.js +215 -0
  52. package/dist/esm/resources/mcp-servers.js +103 -0
  53. package/dist/esm/resources/memory.js +123 -0
  54. package/dist/esm/resources/runs.js +83 -0
  55. package/dist/esm/resources/secrets.js +81 -0
  56. package/dist/esm/resources/skills.js +74 -0
  57. package/dist/esm/resources/tasks.js +125 -0
  58. package/dist/esm/resources/tools.js +53 -0
  59. package/dist/esm/resources/users.js +53 -0
  60. package/dist/esm/resources/versions.js +74 -0
  61. package/dist/esm/stream.js +166 -0
  62. package/dist/esm/transport.js +102 -0
  63. package/dist/esm/types.js +2 -0
  64. package/package.json +42 -4
@@ -0,0 +1,192 @@
1
+ import type { Transport } from "../transport.js";
2
+ import type { ChunkStrategy, KnowledgeCollection, KnowledgeSource, ListParams, Page, SourceStatus } from "../types.js";
3
+ export interface CreateKnowledgeCollectionParams {
4
+ /** Lowercase and hyphenated. This is what an agent version pins. */
5
+ name: string;
6
+ description?: string;
7
+ /** Defaults to `recursive`. Fixed once the collection exists. */
8
+ chunkStrategy?: ChunkStrategy;
9
+ /** Characters per chunk, 128 to 8000. Defaults to 1000. Fixed at creation. */
10
+ chunkSize?: number;
11
+ /**
12
+ * Characters each chunk repeats from the one before, 0 to 2000. Defaults to
13
+ * 200, and must be smaller than `chunkSize`. Fixed at creation.
14
+ */
15
+ chunkOverlap?: number;
16
+ }
17
+ export interface ListKnowledgeCollectionParams extends ListParams {
18
+ /** Find one collection by its name. */
19
+ name?: string;
20
+ }
21
+ export interface CreateKnowledgeSourceParams {
22
+ /** The collection's name, not its id — the same handle a version pins. */
23
+ collection: string;
24
+ /** `file` is not here: bytes arrive as multipart, on the upload route. */
25
+ kind: "text" | "url";
26
+ title: string;
27
+ /** The text itself for `text`, the address for `url`. */
28
+ content: string;
29
+ }
30
+ export interface ListKnowledgeSourceParams extends ListParams {
31
+ collectionId?: string;
32
+ /** Usually `ready` or `failed`: what an agent can search, and what went wrong. */
33
+ status?: SourceStatus;
34
+ }
35
+ /**
36
+ * Collections: the named indexes an agent version searches.
37
+ *
38
+ * A collection is a container and a chunking rule, nothing more. The documents
39
+ * in it are sources, and the chunks those produce live in the vector store the
40
+ * runtime owns.
41
+ *
42
+ * There is no update. The chunk settings are what a collection is, and they
43
+ * cannot change without the chunks already stored disagreeing with the ones
44
+ * added next: half an index split at 1000 characters and half at 400 retrieves
45
+ * badly, and nothing could honestly report which half a run searched. The name
46
+ * is fixed for the reason a secret's name is, since a published version pins
47
+ * it and a rename would silently redirect what a running agent searches.
48
+ * Re-chunking means creating another collection.
49
+ */
50
+ export declare class KnowledgeCollections {
51
+ private readonly transport;
52
+ constructor(transport: Transport);
53
+ create(params: CreateKnowledgeCollectionParams, options?: {
54
+ signal?: AbortSignal;
55
+ }): Promise<KnowledgeCollection>;
56
+ retrieve(collectionId: string, options?: {
57
+ signal?: AbortSignal;
58
+ }): Promise<KnowledgeCollection>;
59
+ /**
60
+ * Collections, by name.
61
+ *
62
+ * `source_count` is every document whatever its status, while `chunk_count`
63
+ * covers only the sources that finished, so an index still being ingested
64
+ * reads as emptier than it will be.
65
+ */
66
+ list(params?: ListKnowledgeCollectionParams, options?: {
67
+ signal?: AbortSignal;
68
+ }): Promise<Page<KnowledgeCollection>>;
69
+ /**
70
+ * Delete a collection.
71
+ *
72
+ * Refused while it still holds sources. Their chunks are in the vector store
73
+ * rather than beside this row, so dropping the collection first would leave
74
+ * them with nothing describing them and no scope key that resolves —
75
+ * orphaned vectors a later search could still match. Remove the sources
76
+ * first; their chunks go with them.
77
+ *
78
+ * A published version that named this collection can no longer search it,
79
+ * because a version is frozen and cannot be edited to drop the reference.
80
+ */
81
+ del(collectionId: string, options?: {
82
+ signal?: AbortSignal;
83
+ }): Promise<KnowledgeCollection>;
84
+ }
85
+ /**
86
+ * Sources: the documents inside a collection.
87
+ *
88
+ * Registering one writes a row and returns. Converting, OCR'ing, chunking and
89
+ * embedding all happen afterwards in a worker, because a scanned PDF of three
90
+ * hundred pages takes minutes and nothing useful comes of holding an HTTP
91
+ * request open for it. So `create` answers `pending` rather than `ready`, and
92
+ * `status` is the honest answer to "can my agent use this yet" — which is why
93
+ * it names the step in progress rather than a generic "processing".
94
+ *
95
+ * Uploading a file is `POST /v1/knowledge/sources/upload`, a multipart request
96
+ * this SDK does not yet wrap; `create` covers `text` and `url`, since bytes do
97
+ * not belong in JSON.
98
+ *
99
+ * There is no update. A source is what was ingested: its chunks were produced
100
+ * from the bytes on record, so editing the title or the content here would
101
+ * leave a row describing something other than what an agent actually searches.
102
+ * Replacing a document means ingesting it again.
103
+ */
104
+ export declare class KnowledgeSources {
105
+ private readonly transport;
106
+ constructor(transport: Transport);
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: CreateKnowledgeSourceParams, options?: {
115
+ signal?: AbortSignal;
116
+ }): Promise<KnowledgeSource>;
117
+ retrieve(sourceId: string, options?: {
118
+ signal?: AbortSignal;
119
+ }): Promise<KnowledgeSource>;
120
+ /**
121
+ * Sources, newest first, because the one someone is waiting on is the one
122
+ * they just added. Filter on `status` to see what is actually searchable.
123
+ */
124
+ list(params?: ListKnowledgeSourceParams, options?: {
125
+ signal?: AbortSignal;
126
+ }): Promise<Page<KnowledgeSource>>;
127
+ /**
128
+ * Delete a source.
129
+ *
130
+ * This is what removes a document from an index, and therefore what an
131
+ * erasure request is served by. The original is deleted before the row, so a
132
+ * failure leaves something to retry rather than a file in storage with
133
+ * nothing pointing at it.
134
+ */
135
+ del(sourceId: string, options?: {
136
+ signal?: AbortSignal;
137
+ }): Promise<KnowledgeSource>;
138
+ }
139
+ /**
140
+ * Knowledge: your own documents, searchable by an agent.
141
+ *
142
+ * ```ts
143
+ * const collection = await nixet.knowledge.collections.create({
144
+ * name: "support-policies",
145
+ * chunkStrategy: "markdown",
146
+ * });
147
+ *
148
+ * const source = await nixet.knowledge.sources.create({
149
+ * collection: collection.name,
150
+ * kind: "text",
151
+ * title: "Refunds",
152
+ * content: "The refund window is thirty days.",
153
+ * });
154
+ *
155
+ * // Ingestion is asynchronous, so the source is `pending` here. Poll until
156
+ * // it is `ready` before expecting an agent to find anything in it.
157
+ * source.status; // "pending"
158
+ * ```
159
+ *
160
+ * Two sub-resources rather than one, because a collection and a source are
161
+ * different lifetimes: a collection is a chunking rule fixed at creation, and
162
+ * a source is a document that arrives, is processed and can be removed on its
163
+ * own. A version pins a collection by name, the way it pins an MCP server, so
164
+ * adding a document changes what a published agent can find without
165
+ * republishing it.
166
+ *
167
+ * Naming collections on a version is `knowledge_collections` on the publish
168
+ * request, which this SDK's `versions.create` does not yet expose.
169
+ */
170
+ export declare class Knowledge {
171
+ /** Sub-resource, so `nixet.knowledge.collections.create(...)` reads naturally. */
172
+ readonly collections: KnowledgeCollections;
173
+ /**
174
+ * Sub-resource for the documents in a collection.
175
+ *
176
+ * Uploading a file is `POST /v1/knowledge/sources/upload` as multipart,
177
+ * which this SDK does not yet wrap; `sources.create` covers `text` and
178
+ * `url`.
179
+ */
180
+ readonly sources: KnowledgeSources;
181
+ constructor(
182
+ /** Sub-resource, so `nixet.knowledge.collections.create(...)` reads naturally. */
183
+ collections: KnowledgeCollections,
184
+ /**
185
+ * Sub-resource for the documents in a collection.
186
+ *
187
+ * Uploading a file is `POST /v1/knowledge/sources/upload` as multipart,
188
+ * which this SDK does not yet wrap; `sources.create` covers `text` and
189
+ * `url`.
190
+ */
191
+ sources: KnowledgeSources);
192
+ }
@@ -0,0 +1,221 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Knowledge = exports.KnowledgeSources = exports.KnowledgeCollections = void 0;
4
+ /**
5
+ * Collections: the named indexes an agent version searches.
6
+ *
7
+ * A collection is a container and a chunking rule, nothing more. The documents
8
+ * in it are sources, and the chunks those produce live in the vector store the
9
+ * runtime owns.
10
+ *
11
+ * There is no update. The chunk settings are what a collection is, and they
12
+ * cannot change without the chunks already stored disagreeing with the ones
13
+ * added next: half an index split at 1000 characters and half at 400 retrieves
14
+ * badly, and nothing could honestly report which half a run searched. The name
15
+ * is fixed for the reason a secret's name is, since a published version pins
16
+ * it and a rename would silently redirect what a running agent searches.
17
+ * Re-chunking means creating another collection.
18
+ */
19
+ class KnowledgeCollections {
20
+ transport;
21
+ constructor(transport) {
22
+ this.transport = transport;
23
+ }
24
+ create(params, options = {}) {
25
+ return this.transport.request({
26
+ method: "POST",
27
+ path: "/knowledge/collections",
28
+ body: {
29
+ name: params.name,
30
+ ...(params.description ? { description: params.description } : {}),
31
+ ...(params.chunkStrategy ? { chunk_strategy: params.chunkStrategy } : {}),
32
+ ...(params.chunkSize === undefined ? {} : { chunk_size: params.chunkSize }),
33
+ ...(params.chunkOverlap === undefined
34
+ ? {}
35
+ : { chunk_overlap: params.chunkOverlap }),
36
+ },
37
+ signal: options.signal,
38
+ });
39
+ }
40
+ retrieve(collectionId, options = {}) {
41
+ return this.transport.request({
42
+ method: "GET",
43
+ path: `/knowledge/collections/${encodeURIComponent(collectionId)}`,
44
+ signal: options.signal,
45
+ });
46
+ }
47
+ /**
48
+ * Collections, by name.
49
+ *
50
+ * `source_count` is every document whatever its status, while `chunk_count`
51
+ * covers only the sources that finished, so an index still being ingested
52
+ * reads as emptier than it will be.
53
+ */
54
+ list(params = {}, options = {}) {
55
+ return this.transport.requestPage({
56
+ method: "GET",
57
+ path: "/knowledge/collections",
58
+ query: {
59
+ $limit: params.limit,
60
+ $offset: params.offset,
61
+ name: params.name,
62
+ },
63
+ signal: options.signal,
64
+ });
65
+ }
66
+ /**
67
+ * Delete a collection.
68
+ *
69
+ * Refused while it still holds sources. Their chunks are in the vector store
70
+ * rather than beside this row, so dropping the collection first would leave
71
+ * them with nothing describing them and no scope key that resolves —
72
+ * orphaned vectors a later search could still match. Remove the sources
73
+ * first; their chunks go with them.
74
+ *
75
+ * A published version that named this collection can no longer search it,
76
+ * because a version is frozen and cannot be edited to drop the reference.
77
+ */
78
+ del(collectionId, options = {}) {
79
+ return this.transport.request({
80
+ method: "DELETE",
81
+ path: `/knowledge/collections/${encodeURIComponent(collectionId)}`,
82
+ signal: options.signal,
83
+ });
84
+ }
85
+ }
86
+ exports.KnowledgeCollections = KnowledgeCollections;
87
+ /**
88
+ * Sources: the documents inside a collection.
89
+ *
90
+ * Registering one writes a row and returns. Converting, OCR'ing, chunking and
91
+ * embedding all happen afterwards in a worker, because a scanned PDF of three
92
+ * hundred pages takes minutes and nothing useful comes of holding an HTTP
93
+ * request open for it. So `create` answers `pending` rather than `ready`, and
94
+ * `status` is the honest answer to "can my agent use this yet" — which is why
95
+ * it names the step in progress rather than a generic "processing".
96
+ *
97
+ * Uploading a file is `POST /v1/knowledge/sources/upload`, a multipart request
98
+ * this SDK does not yet wrap; `create` covers `text` and `url`, since bytes do
99
+ * not belong in JSON.
100
+ *
101
+ * There is no update. A source is what was ingested: its chunks were produced
102
+ * from the bytes on record, so editing the title or the content here would
103
+ * leave a row describing something other than what an agent actually searches.
104
+ * Replacing a document means ingesting it again.
105
+ */
106
+ class KnowledgeSources {
107
+ transport;
108
+ constructor(transport) {
109
+ this.transport = transport;
110
+ }
111
+ /**
112
+ * Register a document. Returns before it is searchable.
113
+ *
114
+ * Poll `retrieve` until `status` is `ready`, or `failed` with `error` saying
115
+ * why. A URL is fetched by the worker rather than by this call, so an
116
+ * address that cannot be reached surfaces there too.
117
+ */
118
+ create(params, options = {}) {
119
+ return this.transport.request({
120
+ method: "POST",
121
+ path: "/knowledge/sources",
122
+ body: {
123
+ collection: params.collection,
124
+ kind: params.kind,
125
+ title: params.title,
126
+ content: params.content,
127
+ },
128
+ signal: options.signal,
129
+ });
130
+ }
131
+ retrieve(sourceId, options = {}) {
132
+ return this.transport.request({
133
+ method: "GET",
134
+ path: `/knowledge/sources/${encodeURIComponent(sourceId)}`,
135
+ signal: options.signal,
136
+ });
137
+ }
138
+ /**
139
+ * Sources, newest first, because the one someone is waiting on is the one
140
+ * they just added. Filter on `status` to see what is actually searchable.
141
+ */
142
+ list(params = {}, options = {}) {
143
+ return this.transport.requestPage({
144
+ method: "GET",
145
+ path: "/knowledge/sources",
146
+ query: {
147
+ $limit: params.limit,
148
+ $offset: params.offset,
149
+ collection_id: params.collectionId,
150
+ status: params.status,
151
+ },
152
+ signal: options.signal,
153
+ });
154
+ }
155
+ /**
156
+ * Delete a source.
157
+ *
158
+ * This is what removes a document from an index, and therefore what an
159
+ * erasure request is served by. The original is deleted before the row, so a
160
+ * failure leaves something to retry rather than a file in storage with
161
+ * nothing pointing at it.
162
+ */
163
+ del(sourceId, options = {}) {
164
+ return this.transport.request({
165
+ method: "DELETE",
166
+ path: `/knowledge/sources/${encodeURIComponent(sourceId)}`,
167
+ signal: options.signal,
168
+ });
169
+ }
170
+ }
171
+ exports.KnowledgeSources = KnowledgeSources;
172
+ /**
173
+ * Knowledge: your own documents, searchable by an agent.
174
+ *
175
+ * ```ts
176
+ * const collection = await nixet.knowledge.collections.create({
177
+ * name: "support-policies",
178
+ * chunkStrategy: "markdown",
179
+ * });
180
+ *
181
+ * const source = await nixet.knowledge.sources.create({
182
+ * collection: collection.name,
183
+ * kind: "text",
184
+ * title: "Refunds",
185
+ * content: "The refund window is thirty days.",
186
+ * });
187
+ *
188
+ * // Ingestion is asynchronous, so the source is `pending` here. Poll until
189
+ * // it is `ready` before expecting an agent to find anything in it.
190
+ * source.status; // "pending"
191
+ * ```
192
+ *
193
+ * Two sub-resources rather than one, because a collection and a source are
194
+ * different lifetimes: a collection is a chunking rule fixed at creation, and
195
+ * a source is a document that arrives, is processed and can be removed on its
196
+ * own. A version pins a collection by name, the way it pins an MCP server, so
197
+ * adding a document changes what a published agent can find without
198
+ * republishing it.
199
+ *
200
+ * Naming collections on a version is `knowledge_collections` on the publish
201
+ * request, which this SDK's `versions.create` does not yet expose.
202
+ */
203
+ class Knowledge {
204
+ collections;
205
+ sources;
206
+ constructor(
207
+ /** Sub-resource, so `nixet.knowledge.collections.create(...)` reads naturally. */
208
+ collections,
209
+ /**
210
+ * Sub-resource for the documents in a collection.
211
+ *
212
+ * Uploading a file is `POST /v1/knowledge/sources/upload` as multipart,
213
+ * which this SDK does not yet wrap; `sources.create` covers `text` and
214
+ * `url`.
215
+ */
216
+ sources) {
217
+ this.collections = collections;
218
+ this.sources = sources;
219
+ }
220
+ }
221
+ exports.Knowledge = Knowledge;
@@ -0,0 +1,83 @@
1
+ import type { Transport } from "../transport.js";
2
+ import type { ListParams, McpAuth, McpServer, McpTransport, Page } from "../types.js";
3
+ export interface CreateMcpServerParams {
4
+ /** Lowercase and hyphenated. This is what an agent version pins. */
5
+ name: string;
6
+ url: string;
7
+ /** Defaults to `http`. */
8
+ transport?: McpTransport;
9
+ description?: string;
10
+ /** Defaults to `none`. Authenticated variants name a stored secret. */
11
+ auth?: McpAuth;
12
+ }
13
+ export interface UpdateMcpServerParams {
14
+ url?: string;
15
+ transport?: McpTransport;
16
+ description?: string;
17
+ auth?: McpAuth;
18
+ }
19
+ /**
20
+ * MCP servers: tools you run, used by agents we run.
21
+ *
22
+ * ```ts
23
+ * await nixet.secrets.create({ name: "github-token", value: process.env.GH_PAT });
24
+ *
25
+ * const server = await nixet.mcpServers.create({
26
+ * name: "github",
27
+ * url: "https://mcp.example.com/mcp",
28
+ * auth: { type: "bearer", secret: "github-token" },
29
+ * });
30
+ *
31
+ * // Registration discovers what the server offers. What an agent may do with
32
+ * // each tool is a policy, set per version rather than per server.
33
+ * const tools = await nixet.mcpServers.tools(server.id);
34
+ *
35
+ * await nixet.agents.versions.create(agent.id, {
36
+ * instructions: "Use the GitHub tools to answer questions about the repo.",
37
+ * mcpServers: [server.name],
38
+ * });
39
+ * ```
40
+ *
41
+ * Remote only: registering a `stdio` server would mean spawning your process
42
+ * inside our runtime, so that transport does not exist rather than being
43
+ * refused later. The URL is checked at registration against where Nixet is
44
+ * willing to connect, so a private or loopback address is rejected then rather
45
+ * than mid-run.
46
+ *
47
+ * A version names servers by handle, and the runtime connects at execution, so
48
+ * changing a server's URL changes what a published version reaches without
49
+ * republishing it. Its `name` is therefore fixed.
50
+ */
51
+ export declare class McpServers {
52
+ private readonly transport;
53
+ constructor(transport: Transport);
54
+ create(params: CreateMcpServerParams, options?: {
55
+ signal?: AbortSignal;
56
+ }): Promise<McpServer>;
57
+ retrieve(serverId: string, options?: {
58
+ signal?: AbortSignal;
59
+ }): Promise<McpServer>;
60
+ list(params?: ListParams & {
61
+ name?: string;
62
+ }, options?: {
63
+ signal?: AbortSignal;
64
+ }): Promise<Page<McpServer>>;
65
+ /**
66
+ * Change where a server lives or how it authenticates.
67
+ *
68
+ * Moving the URL discards the tools we recorded, because what the old host
69
+ * advertised no longer describes the new one.
70
+ */
71
+ update(serverId: string, params: UpdateMcpServerParams, options?: {
72
+ signal?: AbortSignal;
73
+ }): Promise<McpServer>;
74
+ /**
75
+ * Remove a server.
76
+ *
77
+ * A published version that named it can no longer be run, because a version
78
+ * is frozen and cannot be edited to drop the reference.
79
+ */
80
+ del(serverId: string, options?: {
81
+ signal?: AbortSignal;
82
+ }): Promise<McpServer>;
83
+ }
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.McpServers = void 0;
4
+ /**
5
+ * MCP servers: tools you run, used by agents we run.
6
+ *
7
+ * ```ts
8
+ * await nixet.secrets.create({ name: "github-token", value: process.env.GH_PAT });
9
+ *
10
+ * const server = await nixet.mcpServers.create({
11
+ * name: "github",
12
+ * url: "https://mcp.example.com/mcp",
13
+ * auth: { type: "bearer", secret: "github-token" },
14
+ * });
15
+ *
16
+ * // Registration discovers what the server offers. What an agent may do with
17
+ * // each tool is a policy, set per version rather than per server.
18
+ * const tools = await nixet.mcpServers.tools(server.id);
19
+ *
20
+ * await nixet.agents.versions.create(agent.id, {
21
+ * instructions: "Use the GitHub tools to answer questions about the repo.",
22
+ * mcpServers: [server.name],
23
+ * });
24
+ * ```
25
+ *
26
+ * Remote only: registering a `stdio` server would mean spawning your process
27
+ * inside our runtime, so that transport does not exist rather than being
28
+ * refused later. The URL is checked at registration against where Nixet is
29
+ * willing to connect, so a private or loopback address is rejected then rather
30
+ * than mid-run.
31
+ *
32
+ * A version names servers by handle, and the runtime connects at execution, so
33
+ * changing a server's URL changes what a published version reaches without
34
+ * republishing it. Its `name` is therefore fixed.
35
+ */
36
+ class McpServers {
37
+ transport;
38
+ constructor(transport) {
39
+ this.transport = transport;
40
+ }
41
+ create(params, options = {}) {
42
+ return this.transport.request({
43
+ method: "POST",
44
+ path: "/mcp/servers",
45
+ body: {
46
+ name: params.name,
47
+ url: params.url,
48
+ ...(params.transport ? { transport: params.transport } : {}),
49
+ ...(params.description ? { description: params.description } : {}),
50
+ ...(params.auth ? { auth: params.auth } : {}),
51
+ },
52
+ signal: options.signal,
53
+ });
54
+ }
55
+ retrieve(serverId, options = {}) {
56
+ return this.transport.request({
57
+ method: "GET",
58
+ path: `/mcp/servers/${encodeURIComponent(serverId)}`,
59
+ signal: options.signal,
60
+ });
61
+ }
62
+ list(params = {}, options = {}) {
63
+ return this.transport.requestPage({
64
+ method: "GET",
65
+ path: "/mcp/servers",
66
+ query: {
67
+ $limit: params.limit,
68
+ $offset: params.offset,
69
+ name: params.name,
70
+ },
71
+ signal: options.signal,
72
+ });
73
+ }
74
+ /**
75
+ * Change where a server lives or how it authenticates.
76
+ *
77
+ * Moving the URL discards the tools we recorded, because what the old host
78
+ * advertised no longer describes the new one.
79
+ */
80
+ update(serverId, params, options = {}) {
81
+ return this.transport.request({
82
+ method: "PATCH",
83
+ path: `/mcp/servers/${encodeURIComponent(serverId)}`,
84
+ body: {
85
+ ...(params.url ? { url: params.url } : {}),
86
+ ...(params.transport ? { transport: params.transport } : {}),
87
+ ...(params.description === undefined ? {} : { description: params.description }),
88
+ ...(params.auth ? { auth: params.auth } : {}),
89
+ },
90
+ signal: options.signal,
91
+ });
92
+ }
93
+ /**
94
+ * Remove a server.
95
+ *
96
+ * A published version that named it can no longer be run, because a version
97
+ * is frozen and cannot be edited to drop the reference.
98
+ */
99
+ del(serverId, options = {}) {
100
+ return this.transport.request({
101
+ method: "DELETE",
102
+ path: `/mcp/servers/${encodeURIComponent(serverId)}`,
103
+ signal: options.signal,
104
+ });
105
+ }
106
+ }
107
+ exports.McpServers = McpServers;
@@ -0,0 +1,95 @@
1
+ import type { Transport } from "../transport.js";
2
+ import type { MemoryRow, MemoryScope } from "../types.js";
3
+ /** Where a request may address memory. Every read and write names one. */
4
+ export interface MemoryTargetParams {
5
+ agentId: string;
6
+ userId?: string;
7
+ conversationId?: string;
8
+ }
9
+ export interface SearchMemoryParams extends MemoryTargetParams {
10
+ query: string;
11
+ /** Narrow to one scope. Omit to search all the request can address. */
12
+ scope?: MemoryScope;
13
+ limit?: number;
14
+ }
15
+ export interface ListMemoryParams extends MemoryTargetParams {
16
+ scope?: MemoryScope;
17
+ limit?: number;
18
+ }
19
+ export interface CreateMemoryParams extends MemoryTargetParams {
20
+ scope: MemoryScope;
21
+ content: string;
22
+ metadata?: Record<string, unknown>;
23
+ /** ISO date after which the memory stops being recalled. */
24
+ expiresAt?: string;
25
+ }
26
+ export interface UpdateMemoryParams extends MemoryTargetParams {
27
+ content?: string;
28
+ metadata?: Record<string, unknown>;
29
+ /** Null clears an existing expiry. */
30
+ expiresAt?: string | null;
31
+ }
32
+ /**
33
+ * Memory: what an agent retains about a person or a thread.
34
+ *
35
+ * Distinct from a conversation transcript, which is the literal record of what
36
+ * was said. A memory is a fact worth keeping — a preference, a constraint, a
37
+ * problem — extracted from conversations or written directly.
38
+ *
39
+ * ```ts
40
+ * await nixet.memory.create({
41
+ * scope: "user",
42
+ * agentId: agent.id,
43
+ * userId: user.id,
44
+ * content: "Prefers metric units and short answers.",
45
+ * });
46
+ *
47
+ * const found = await nixet.memory.search({
48
+ * query: "what are their preferences?",
49
+ * agentId: agent.id,
50
+ * userId: user.id,
51
+ * });
52
+ * ```
53
+ */
54
+ export declare class MemoryResource {
55
+ private readonly transport;
56
+ constructor(transport: Transport);
57
+ /** Recall memories relevant to a query, most relevant first. */
58
+ search(params: SearchMemoryParams, options?: {
59
+ signal?: AbortSignal;
60
+ }): Promise<MemoryRow[]>;
61
+ /**
62
+ * Everything an agent holds, newest first.
63
+ *
64
+ * Use this to browse. `search` asks a question; this asks for the lot.
65
+ */
66
+ list(params: ListMemoryParams, options?: {
67
+ signal?: AbortSignal;
68
+ }): Promise<MemoryRow[]>;
69
+ /**
70
+ * Store a memory directly.
71
+ *
72
+ * Use this for facts you already know — a plan tier, an account setting —
73
+ * rather than waiting for them to be said in a conversation.
74
+ */
75
+ create(params: CreateMemoryParams, options?: {
76
+ signal?: AbortSignal;
77
+ }): Promise<MemoryRow[]>;
78
+ /** One memory by id. */
79
+ get(memoryId: string, params: MemoryTargetParams, options?: {
80
+ signal?: AbortSignal;
81
+ }): Promise<MemoryRow>;
82
+ /** Correct a memory in place. */
83
+ update(memoryId: string, params: UpdateMemoryParams, options?: {
84
+ signal?: AbortSignal;
85
+ }): Promise<MemoryRow>;
86
+ /**
87
+ * Forget a memory.
88
+ *
89
+ * The only way to erase what an agent knows about a person, so it is also
90
+ * what an erasure request is served by.
91
+ */
92
+ delete(memoryId: string, params: MemoryTargetParams, options?: {
93
+ signal?: AbortSignal;
94
+ }): Promise<void>;
95
+ }