@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,218 @@
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
+ class Knowledge {
201
+ collections;
202
+ sources;
203
+ constructor(
204
+ /** Sub-resource, so `nixet.knowledge.collections.create(...)` reads naturally. */
205
+ collections,
206
+ /**
207
+ * Sub-resource for the documents in a collection.
208
+ *
209
+ * Uploading a file is `POST /v1/knowledge/sources/upload` as multipart,
210
+ * which this SDK does not yet wrap; `sources.create` covers `text` and
211
+ * `url`.
212
+ */
213
+ sources) {
214
+ this.collections = collections;
215
+ this.sources = sources;
216
+ }
217
+ }
218
+ 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
+ }
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MemoryResource = void 0;
4
+ function target(params) {
5
+ return {
6
+ agent_id: params.agentId,
7
+ ...(params.userId ? { user_id: params.userId } : {}),
8
+ ...(params.conversationId ? { conversation_id: params.conversationId } : {}),
9
+ };
10
+ }
11
+ /**
12
+ * Memory: what an agent retains about a person or a thread.
13
+ *
14
+ * Distinct from a conversation transcript, which is the literal record of what
15
+ * was said. A memory is a fact worth keeping — a preference, a constraint, a
16
+ * problem — extracted from conversations or written directly.
17
+ *
18
+ * ```ts
19
+ * await nixet.memory.create({
20
+ * scope: "user",
21
+ * agentId: agent.id,
22
+ * userId: user.id,
23
+ * content: "Prefers metric units and short answers.",
24
+ * });
25
+ *
26
+ * const found = await nixet.memory.search({
27
+ * query: "what are their preferences?",
28
+ * agentId: agent.id,
29
+ * userId: user.id,
30
+ * });
31
+ * ```
32
+ */
33
+ class MemoryResource {
34
+ transport;
35
+ constructor(transport) {
36
+ this.transport = transport;
37
+ }
38
+ /** Recall memories relevant to a query, most relevant first. */
39
+ search(params, options = {}) {
40
+ return this.transport.request({
41
+ method: "POST",
42
+ path: "/memory/search",
43
+ body: {
44
+ ...target(params),
45
+ query: params.query,
46
+ ...(params.scope ? { scope: params.scope } : {}),
47
+ limit: params.limit ?? 10,
48
+ },
49
+ signal: options.signal,
50
+ });
51
+ }
52
+ /**
53
+ * Everything an agent holds, newest first.
54
+ *
55
+ * Use this to browse. `search` asks a question; this asks for the lot.
56
+ */
57
+ list(params, options = {}) {
58
+ return this.transport.request({
59
+ method: "POST",
60
+ path: "/memory/list",
61
+ body: {
62
+ ...target(params),
63
+ ...(params.scope ? { scope: params.scope } : {}),
64
+ limit: params.limit ?? 50,
65
+ },
66
+ signal: options.signal,
67
+ });
68
+ }
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, options = {}) {
76
+ return this.transport.request({
77
+ method: "POST",
78
+ path: "/memory",
79
+ body: {
80
+ ...target(params),
81
+ scope: params.scope,
82
+ content: params.content,
83
+ ...(params.metadata ? { metadata: params.metadata } : {}),
84
+ ...(params.expiresAt ? { expires_at: params.expiresAt } : {}),
85
+ },
86
+ signal: options.signal,
87
+ });
88
+ }
89
+ /** One memory by id. */
90
+ get(memoryId, params, options = {}) {
91
+ return this.transport.request({
92
+ method: "GET",
93
+ path: `/memory/${encodeURIComponent(memoryId)}`,
94
+ query: target(params),
95
+ signal: options.signal,
96
+ });
97
+ }
98
+ /** Correct a memory in place. */
99
+ update(memoryId, params, options = {}) {
100
+ return this.transport.request({
101
+ method: "PATCH",
102
+ path: `/memory/${encodeURIComponent(memoryId)}`,
103
+ body: {
104
+ ...target(params),
105
+ ...(params.content !== undefined ? { content: params.content } : {}),
106
+ ...(params.metadata !== undefined ? { metadata: params.metadata } : {}),
107
+ ...(params.expiresAt !== undefined ? { expires_at: params.expiresAt } : {}),
108
+ },
109
+ signal: options.signal,
110
+ });
111
+ }
112
+ /**
113
+ * Forget a memory.
114
+ *
115
+ * The only way to erase what an agent knows about a person, so it is also
116
+ * what an erasure request is served by.
117
+ */
118
+ delete(memoryId, params, options = {}) {
119
+ return this.transport.request({
120
+ method: "DELETE",
121
+ path: `/memory/${encodeURIComponent(memoryId)}`,
122
+ query: target(params),
123
+ signal: options.signal,
124
+ });
125
+ }
126
+ }
127
+ exports.MemoryResource = MemoryResource;