@slashml/memory 1.0.7 → 1.0.9

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.
package/dist/index.mjs CHANGED
@@ -1,629 +1,25 @@
1
- /**
2
- * @slashml/memory -- Official TypeScript / Node.js SDK for the / ml Memory API (ESM)
3
- */
4
-
5
- export const DEFAULT_BASE_URL = "https://api.slashml.ai";
6
- export const DEFAULT_MODEL = "slashml-1.5-fast";
7
- export const DEFAULT_TIMEOUT_MS = 30_000;
8
-
9
- export class SlashMLAPIError extends Error {
10
- constructor(statusCode, message, details = {}) {
11
- super(`SlashMLAPIError (${statusCode}): ${message}`);
12
- this.name = "SlashMLAPIError";
13
- this.statusCode = statusCode;
14
- this.details = details;
15
- }
16
- }
17
-
18
- function getEnv(name) {
19
- if (typeof process !== "undefined" && process.env) {
20
- return process.env[name];
21
- }
22
- return undefined;
23
- }
24
-
25
- export class ProjectManager {
26
- constructor(client) {
27
- this.client = client;
28
- }
29
-
30
- async get(fieldsOrOptions) {
31
- const fields = Array.isArray(fieldsOrOptions)
32
- ? fieldsOrOptions
33
- : fieldsOrOptions?.fields;
34
- return this.client.request("GET", "/v1/project", {
35
- params: {
36
- org_id: this.client.orgId ?? undefined,
37
- project_id: this.client.projectId ?? undefined,
38
- fields: Array.isArray(fields) && fields.length > 0 ? fields.join(",") : undefined,
39
- },
40
- });
41
- }
42
-
43
- async create(nameOrOptions, description, extra = {}) {
44
- const body =
45
- typeof nameOrOptions === "string"
46
- ? { name: nameOrOptions, description, ...extra }
47
- : { ...nameOrOptions };
48
- return this.client.request("POST", "/v1/project", {
49
- jsonBody: {
50
- org_id: this.client.orgId ?? undefined,
51
- ...body,
52
- },
53
- });
54
- }
55
-
56
- async update(settings = {}) {
57
- const payload = {
58
- org_id: this.client.orgId ?? undefined,
59
- project_id: this.client.projectId ?? undefined,
60
- ...settings,
61
- };
62
- if (settings.customInstructions !== undefined && payload.custom_instructions === undefined) {
63
- payload.custom_instructions = settings.customInstructions;
64
- }
65
- if (settings.customCategories !== undefined && payload.custom_categories === undefined) {
66
- payload.custom_categories = settings.customCategories;
67
- }
68
- if (settings.enableGraph !== undefined && payload.enable_graph === undefined) {
69
- payload.enable_graph = settings.enableGraph;
70
- }
71
- return this.client.request("PATCH", "/v1/project", {
72
- jsonBody: payload,
73
- });
74
- }
75
-
76
- async delete() {
77
- return this.client.request("DELETE", "/v1/project", {
78
- params: {
79
- org_id: this.client.orgId ?? undefined,
80
- project_id: this.client.projectId ?? undefined,
81
- },
82
- });
83
- }
84
-
85
- async getMembers() {
86
- return this.client.request("GET", "/v1/project/members", {
87
- params: {
88
- org_id: this.client.orgId ?? undefined,
89
- project_id: this.client.projectId ?? undefined,
90
- },
91
- });
92
- }
93
-
94
- async get_members() {
95
- return this.getMembers();
96
- }
97
-
98
- async addMember(emailOrOptions, role = "READER") {
99
- const email = typeof emailOrOptions === "string" ? emailOrOptions : emailOrOptions?.email;
100
- const resolvedRole =
101
- typeof emailOrOptions === "string" ? role : (emailOrOptions?.role ?? role);
102
- return this.client.request("POST", "/v1/project/members", {
103
- jsonBody: {
104
- email,
105
- role: resolvedRole,
106
- org_id: this.client.orgId ?? undefined,
107
- project_id: this.client.projectId ?? undefined,
108
- },
109
- });
110
- }
111
-
112
- async add_member(emailOrOptions, role = "READER") {
113
- return this.addMember(emailOrOptions, role);
114
- }
115
-
116
- async removeMember(emailOrOptions) {
117
- const email = typeof emailOrOptions === "string" ? emailOrOptions : emailOrOptions?.email;
118
- return this.client.request("DELETE", "/v1/project/members", {
119
- params: {
120
- email,
121
- org_id: this.client.orgId ?? undefined,
122
- project_id: this.client.projectId ?? undefined,
123
- },
124
- });
125
- }
126
-
127
- async remove_member(emailOrOptions) {
128
- return this.removeMember(emailOrOptions);
129
- }
130
- }
131
-
132
- export class MemoryClient {
133
- constructor(options = {}) {
134
- const resolvedKey =
135
- options.apiKey ||
136
- options.api_key ||
137
- options.mem0ApiKey ||
138
- getEnv("SLASHML_API_KEY") ||
139
- getEnv("MEM0_API_KEY") ||
140
- "";
141
- const resolvedUrl =
142
- options.baseUrl ||
143
- options.base_url ||
144
- options.host ||
145
- getEnv("SLASHML_BASE_URL") ||
146
- getEnv("SLASHML_API_URL") ||
147
- DEFAULT_BASE_URL;
148
- const resolvedModel =
149
- options.model ||
150
- getEnv("SLASHML_MODEL") ||
151
- DEFAULT_MODEL;
152
-
153
- this.apiKey = resolvedKey;
154
- this.baseUrl = resolvedUrl.replace(/\/+$/, "");
155
- this.orgId = options.orgId || options.org_id || getEnv("SLASHML_ORG_ID") || null;
156
- this.projectId = options.projectId || options.project_id || getEnv("SLASHML_PROJECT_ID") || null;
157
- this.model = resolvedModel;
158
- this.timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
159
- this.fetchImpl = options.fetchImpl ?? globalThis.fetch;
160
- this.project = new ProjectManager(this);
161
- }
162
-
163
- async request(method, path, options = {}) {
164
- if (!this.apiKey) {
165
- throw new SlashMLAPIError(
166
- 401,
167
- "API key is required. Pass `apiKey: 'sml_...'` or set SLASHML_API_KEY.",
168
- );
169
- }
170
- let url = `${this.baseUrl}${path.startsWith("/") ? path : `/${path}`}`;
171
- if (options.params) {
172
- const searchParams = new URLSearchParams();
173
- for (const [key, value] of Object.entries(options.params)) {
174
- if (value !== undefined && value !== null) {
175
- searchParams.set(key, String(value));
176
- }
177
- }
178
- const qs = searchParams.toString();
179
- if (qs) {
180
- url = `${url}?${qs}`;
181
- }
182
- }
183
-
184
- const headers = {
185
- Accept: "application/json",
186
- "Content-Type": "application/json",
187
- "User-Agent": "slashml-memory-ts/1.0.7",
188
- };
189
- if (this.apiKey) {
190
- headers.Authorization = `Bearer ${this.apiKey}`;
191
- headers["X-API-Key"] = this.apiKey;
192
- }
193
- if (this.orgId) {
194
- headers["X-SlashML-Org-Id"] = this.orgId;
195
- }
196
- if (this.projectId) {
197
- headers["X-SlashML-Project-Id"] = this.projectId;
198
- }
199
-
200
- const controller = new AbortController();
201
- const timer = setTimeout(() => controller.abort(), this.timeoutMs);
202
-
203
- try {
204
- const response = await this.fetchImpl(url, {
205
- method: method.toUpperCase(),
206
- headers,
207
- body: options.jsonBody !== undefined ? JSON.stringify(options.jsonBody) : undefined,
208
- signal: controller.signal,
209
- });
210
-
211
- const rawText = await response.text();
212
- let parsed = {};
213
- if (rawText) {
214
- try {
215
- parsed = JSON.parse(rawText);
216
- } catch {
217
- parsed = { raw: rawText };
218
- }
219
- }
220
-
221
- if (!response.ok) {
222
- const message =
223
- parsed.error ||
224
- parsed.detail ||
225
- parsed.message ||
226
- response.statusText ||
227
- "HTTP Error";
228
- throw new SlashMLAPIError(response.status, message, parsed);
229
- }
230
-
231
- return parsed;
232
- } catch (err) {
233
- if (err instanceof SlashMLAPIError) {
234
- throw err;
235
- }
236
- const message = err instanceof Error ? err.message : String(err);
237
- throw new SlashMLAPIError(0, `Failed to reach / ml API at ${url}: ${message}`);
238
- } finally {
239
- clearTimeout(timer);
240
- }
241
- }
242
-
243
- async ingest(documents, options = {}) {
244
- const docs = typeof documents === "string" ? [documents] : Array.from(documents);
245
- return this.request("POST", "/v1/memory/ingest", {
246
- jsonBody: {
247
- namespace: options.namespace ?? "default",
248
- model: options.model ?? this.model,
249
- documents: docs,
250
- metadata: options.metadata ?? {},
251
- },
252
- });
253
- }
254
-
255
- async query(prompt, options = {}) {
256
- return this.request("POST", "/v1/memory/query", {
257
- jsonBody: {
258
- namespace: options.namespace ?? "default",
259
- model: options.model ?? this.model,
260
- prompt,
261
- top_k: options.top_k ?? 5,
262
- },
263
- });
264
- }
265
-
266
- async forget(target, options = {}) {
267
- return this.request("POST", "/v1/memory/forget", {
268
- jsonBody: {
269
- namespace: options.namespace ?? "default",
270
- target,
271
- },
272
- });
273
- }
274
-
275
- async intervene(textOrPayload, options = {}) {
276
- const opts =
277
- typeof textOrPayload === "string"
278
- ? { ...options, prompt: options.prompt ?? textOrPayload, text: options.text ?? textOrPayload }
279
- : { ...(textOrPayload || {}), ...options };
280
- const resolvedText = opts.text ?? opts.prompt ?? "";
281
- const resolvedModel = opts.model ?? this.model;
282
- const resolvedProjectId = opts.project_id ?? opts.projectId ?? this.projectId ?? null;
283
- const resolvedSessionId = opts.session_id ?? opts.sessionId ?? null;
284
- const lastAssistantMsg =
285
- opts.last_assistant_message ?? opts.lastAssistantMessage ?? undefined;
286
- const stopHookActive =
287
- opts.stop_hook_active ?? opts.stopHookActive ?? undefined;
288
- const whisperedIds =
289
- opts.whispered_memory_ids ?? opts.whisperedMemoryIds ?? undefined;
290
- return this.request("POST", "/v1/memory/intervene", {
291
- jsonBody: {
292
- hook_event_name: opts.hook_event_name ?? opts.hookEventName ?? "UserPromptSubmit",
293
- prompt: opts.prompt ?? resolvedText,
294
- text: resolvedText,
295
- ...(lastAssistantMsg !== undefined ? { last_assistant_message: lastAssistantMsg } : {}),
296
- ...(stopHookActive !== undefined ? { stop_hook_active: Boolean(stopHookActive) } : {}),
297
- ...(whisperedIds && whisperedIds.length > 0 ? { whispered_memory_ids: whisperedIds } : {}),
298
- tool_name: opts.tool_name ?? opts.toolName ?? null,
299
- tool_input: opts.tool_input ?? opts.toolInput ?? null,
300
- tool_response: opts.tool_response ?? opts.toolResponse ?? null,
301
- user_id: opts.user_id ?? opts.userId ?? "default",
302
- ...(resolvedProjectId ? { project_id: resolvedProjectId } : {}),
303
- ...(resolvedSessionId ? { session_id: resolvedSessionId } : {}),
304
- model: resolvedModel,
305
- commit_writes: opts.commit_writes ?? opts.commitWrites ?? true,
306
- top_k: opts.top_k ?? opts.topK ?? 5,
307
- client_raw_tokens_delta: opts.client_raw_tokens_delta ?? opts.clientRawTokensDelta ?? 0,
308
- client_dropped_tokens_delta:
309
- opts.client_dropped_tokens_delta ?? opts.clientDroppedTokensDelta ?? 0,
310
- client_dropped_events_delta:
311
- opts.client_dropped_events_delta ?? opts.clientDroppedEventsDelta ?? 0,
312
- },
313
- });
314
- }
315
-
316
- async status(options = {}) {
317
- const uid = options.user_id ?? options.userId ?? "default";
318
- const rawDelta = options.client_raw_tokens_delta ?? options.clientRawTokensDelta ?? 0;
319
- const droppedTokDelta =
320
- options.client_dropped_tokens_delta ?? options.clientDroppedTokensDelta ?? 0;
321
- const droppedEvDelta =
322
- options.client_dropped_events_delta ?? options.clientDroppedEventsDelta ?? 0;
323
- if (rawDelta > 0 || droppedTokDelta > 0 || droppedEvDelta > 0) {
324
- return this.request("POST", "/v1/memory/status", {
325
- jsonBody: {
326
- user_id: uid,
327
- client_raw_tokens_delta: rawDelta,
328
- client_dropped_tokens_delta: droppedTokDelta,
329
- client_dropped_events_delta: droppedEvDelta,
330
- },
331
- });
332
- }
333
- return this.request("GET", "/v1/memory/status", {
334
- params: { user_id: uid },
335
- });
336
- }
337
-
338
- async add(messages, options = {}) {
339
- const memId = options.memory_id ?? options.memoryId;
340
- const normalizedMessages =
341
- typeof messages === "string"
342
- ? [{ role: "user", content: messages, ...(memId ? { id: memId } : {}) }]
343
- : Array.isArray(messages)
344
- ? messages
345
- : [messages];
346
- const payload = {
347
- messages: normalizedMessages,
348
- ...(typeof messages === "string" ? { text: messages } : {}),
349
- user_id: options.user_id ?? options.userId ?? null,
350
- agent_id: options.agent_id ?? options.agentId ?? null,
351
- app_id: options.app_id ?? options.appId ?? null,
352
- run_id: options.run_id ?? options.runId ?? null,
353
- metadata: options.metadata ?? {},
354
- infer: options.infer ?? true,
355
- model: this.model,
356
- };
357
- if (memId) {
358
- payload.memory_id = memId;
359
- payload.id = memId;
360
- }
361
- return this.request("POST", "/v1/memories", { jsonBody: payload });
362
- }
363
-
364
- async search(queryOrOptions, options = {}) {
365
- const isObj = typeof queryOrOptions === "object" && queryOrOptions !== null;
366
- const query = isObj ? queryOrOptions.query : queryOrOptions;
367
- const opts = isObj ? queryOrOptions : options;
368
- const effectiveLimit = opts.top_k ?? opts.topK ?? opts.limit ?? 5;
369
- return this.request("POST", "/v1/memories/search", {
370
- jsonBody: {
371
- query,
372
- user_id: opts.user_id ?? opts.userId ?? null,
373
- agent_id: opts.agent_id ?? opts.agentId ?? null,
374
- app_id: opts.app_id ?? opts.appId ?? null,
375
- run_id: opts.run_id ?? opts.runId ?? null,
376
- limit: effectiveLimit,
377
- top_k: effectiveLimit,
378
- filters: opts.filters ?? opts.metadata ?? null,
379
- threshold: opts.threshold ?? null,
380
- model: this.model,
381
- },
382
- });
383
- }
384
-
385
- async recall(queryOrOptions, options = {}) {
386
- return this.search(queryOrOptions, options);
387
- }
388
-
389
- async getAll(options = {}) {
390
- return this.request("GET", "/v1/memories", {
391
- params: {
392
- user_id: options.user_id ?? options.userId ?? undefined,
393
- agent_id: options.agent_id ?? options.agentId ?? undefined,
394
- app_id: options.app_id ?? options.appId ?? undefined,
395
- run_id: options.run_id ?? options.runId ?? undefined,
396
- limit: options.limit ?? 100,
397
- },
398
- });
399
- }
400
-
401
- async get_all(options = {}) {
402
- return this.getAll(options);
403
- }
404
-
405
- async get(memoryId) {
406
- try {
407
- return await this.request("GET", `/v1/memories/${encodeURIComponent(memoryId)}`);
408
- } catch (err) {
409
- if (err instanceof SlashMLAPIError && err.statusCode === 404) {
410
- return null;
411
- }
412
- throw err;
413
- }
414
- }
415
-
416
- async update(memoryId, data) {
417
- const body =
418
- typeof data === "string"
419
- ? { text: data }
420
- : { text: data.text ?? "", metadata: data.metadata };
421
- return this.request("PUT", `/v1/memories/${encodeURIComponent(memoryId)}`, {
422
- jsonBody: body,
423
- });
424
- }
425
-
426
- async delete(memoryId) {
427
- return this.request("DELETE", `/v1/memories/${encodeURIComponent(memoryId)}`);
428
- }
429
-
430
- async deleteAll(options = {}) {
431
- return this.request("DELETE", "/v1/memories", {
432
- params: {
433
- user_id: options.user_id ?? options.userId ?? undefined,
434
- agent_id: options.agent_id ?? options.agentId ?? undefined,
435
- app_id: options.app_id ?? options.appId ?? undefined,
436
- run_id: options.run_id ?? options.runId ?? undefined,
437
- },
438
- });
439
- }
440
-
441
- async delete_all(options = {}) {
442
- return this.deleteAll(options);
443
- }
444
-
445
- async reset() {
446
- return this.request("POST", "/v1/memories/reset", { jsonBody: {} });
447
- }
448
-
449
- async history(memoryId) {
450
- const resp = await this.request("GET", `/v1/memories/${encodeURIComponent(memoryId)}/history`);
451
- if (Array.isArray(resp)) {
452
- return resp;
453
- }
454
- if (Array.isArray(resp.history)) {
455
- return resp.history;
456
- }
457
- if (Array.isArray(resp.results)) {
458
- return resp.results;
459
- }
460
- return [];
461
- }
462
-
463
- async batchUpdate(memories) {
464
- const normalized = memories.map((m) => ({
465
- ...m,
466
- memory_id: m.memory_id ?? m.memoryId ?? m.id,
467
- }));
468
- return this.request("PUT", "/v1/batch", { jsonBody: { memories: normalized } });
469
- }
470
-
471
- async batch_update(memories) {
472
- return this.batchUpdate(memories);
473
- }
474
-
475
- async batchDelete(memories) {
476
- const normalized = memories.map((m) =>
477
- typeof m === "string"
478
- ? { memory_id: m, id: m }
479
- : { ...m, memory_id: m.memory_id ?? m.memoryId ?? m.id },
480
- );
481
- return this.request("DELETE", "/v1/batch", { jsonBody: { memories: normalized } });
482
- }
483
-
484
- async batch_delete(memories) {
485
- return this.batchDelete(memories);
486
- }
487
-
488
- async users() {
489
- return this.request("GET", "/v1/entities", {
490
- params: {
491
- org_id: this.orgId ?? undefined,
492
- project_id: this.projectId ?? undefined,
493
- },
494
- });
495
- }
496
-
497
- async deleteUsers(options = {}) {
498
- return this.request("DELETE", "/v1/entities", {
499
- params: {
500
- user_id: options.user_id ?? options.userId ?? undefined,
501
- agent_id: options.agent_id ?? options.agentId ?? undefined,
502
- app_id: options.app_id ?? options.appId ?? undefined,
503
- run_id: options.run_id ?? options.runId ?? undefined,
504
- org_id: this.orgId ?? undefined,
505
- project_id: this.projectId ?? undefined,
506
- },
507
- });
508
- }
509
-
510
- async delete_users(options = {}) {
511
- return this.deleteUsers(options);
512
- }
513
-
514
- async feedback(memoryIdOrPayload, feedback, feedbackReason) {
515
- const payload =
516
- typeof memoryIdOrPayload === "string"
517
- ? {
518
- memory_id: memoryIdOrPayload,
519
- feedback: feedback ?? null,
520
- feedback_reason: feedbackReason ?? null,
521
- }
522
- : {
523
- memory_id: memoryIdOrPayload.memory_id ?? memoryIdOrPayload.memoryId,
524
- feedback: memoryIdOrPayload.feedback ?? null,
525
- feedback_reason:
526
- memoryIdOrPayload.feedback_reason ?? memoryIdOrPayload.feedbackReason ?? null,
527
- };
528
- return this.request("POST", "/v1/feedback", { jsonBody: payload });
529
- }
530
-
531
- async getProject(fields) {
532
- return this.project.get(fields);
533
- }
534
-
535
- async get_project(fields) {
536
- return this.project.get(fields);
537
- }
538
-
539
- async updateProject(settings = {}) {
540
- return this.project.update(settings);
541
- }
542
-
543
- async update_project(settings = {}) {
544
- return this.project.update(settings);
545
- }
546
-
547
- async getWebhooks(projectId) {
548
- return this.request("GET", "/v1/webhooks", {
549
- params: { project_id: projectId ?? this.projectId ?? undefined },
550
- });
551
- }
552
-
553
- async get_webhooks(projectId) {
554
- return this.getWebhooks(projectId);
555
- }
556
-
557
- async createWebhook(options) {
558
- return this.request("POST", "/v1/webhooks", {
559
- jsonBody: {
560
- url: options.url,
561
- name: options.name,
562
- event_types: options.event_types ?? options.eventTypes ?? [],
563
- project_id: options.project_id ?? options.projectId ?? this.projectId ?? undefined,
564
- },
565
- });
566
- }
567
-
568
- async create_webhook(options) {
569
- return this.createWebhook(options);
570
- }
571
-
572
- async updateWebhook(webhookIdOrOptions, options = {}) {
573
- const isObj = typeof webhookIdOrOptions === "object" && webhookIdOrOptions !== null;
574
- const wid = isObj
575
- ? (webhookIdOrOptions.webhook_id ?? webhookIdOrOptions.webhookId)
576
- : webhookIdOrOptions;
577
- const opts = isObj ? webhookIdOrOptions : options;
578
- return this.request("PUT", `/v1/webhooks/${encodeURIComponent(String(wid))}`, {
579
- jsonBody: {
580
- name: opts.name,
581
- url: opts.url,
582
- event_types: opts.event_types ?? opts.eventTypes,
583
- project_id: opts.project_id ?? opts.projectId ?? this.projectId ?? undefined,
584
- },
585
- });
586
- }
587
-
588
- async update_webhook(webhookIdOrOptions, options = {}) {
589
- return this.updateWebhook(webhookIdOrOptions, options);
590
- }
591
-
592
- async deleteWebhook(webhookIdOrOptions) {
593
- const wid =
594
- typeof webhookIdOrOptions === "object" && webhookIdOrOptions !== null
595
- ? (webhookIdOrOptions.webhook_id ?? webhookIdOrOptions.webhookId)
596
- : webhookIdOrOptions;
597
- return this.request("DELETE", `/v1/webhooks/${encodeURIComponent(String(wid))}`);
598
- }
599
-
600
- async delete_webhook(webhookIdOrOptions) {
601
- return this.deleteWebhook(webhookIdOrOptions);
602
- }
603
- }
604
-
605
- export class Memory extends MemoryClient {
606
- static fromConfig(configDict = {}) {
607
- return new this({
608
- apiKey: configDict.api_key || configDict.apiKey || configDict.mem0ApiKey,
609
- baseUrl: configDict.base_url || configDict.baseUrl || configDict.host,
610
- orgId: configDict.org_id || configDict.orgId,
611
- projectId: configDict.project_id || configDict.projectId,
612
- model: configDict.model,
613
- timeoutMs: configDict.timeoutMs,
614
- });
615
- }
616
-
617
- static from_config(configDict = {}) {
618
- return this.fromConfig(configDict);
619
- }
620
- }
621
-
622
- export class AsyncMemoryClient extends MemoryClient {}
623
- export class AsyncMemory extends Memory {}
624
- export class SlashMLMemory extends MemoryClient {}
625
- export class SlashMLClient extends MemoryClient {}
626
- export class AsyncSlashMLMemory extends MemoryClient {}
627
- export class AsyncSlashMLClient extends MemoryClient {}
628
-
629
- export default Memory;
1
+ import { createRequire } from "node:module";
2
+ const require = createRequire(import.meta.url);
3
+ const cjs = require("./index.js");
4
+
5
+ export const {
6
+ DEFAULT_BASE_URL,
7
+ DEFAULT_MODEL,
8
+ DEFAULT_TIMEOUT_MS,
9
+ RuleScope,
10
+ SlashMLAPIError,
11
+ ProjectManager,
12
+ MemoryClient,
13
+ Memory,
14
+ AsyncMemoryClient,
15
+ AsyncMemory,
16
+ SlashMLMemory,
17
+ SlashMLClient,
18
+ AsyncSlashMLMemory,
19
+ AsyncSlashMLClient,
20
+ extractCanonicalSlotKey,
21
+ compileContrastiveRule,
22
+ formatCacheAlignedPrompt,
23
+ } = cjs;
24
+
25
+ export default cjs;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@slashml/memory",
3
- "version": "1.0.7",
4
- "description": "/ ml (SlashML): Sub-Millisecond Stateful Agent & Code Memory SDK for TypeScript & Node.js",
3
+ "version": "1.0.9",
4
+ "description": "Official HTTP TypeScript & Node.js SDK for / ml (https://api.slashml.ai)",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://slashml.ai",
7
7
  "repository": {
@@ -31,6 +31,7 @@
31
31
  "LICENSE"
32
32
  ],
33
33
  "scripts": {
34
+ "build": "tsc && node -e \"const fs = require('node:fs'); const code = 'import { createRequire } from \\\"node:module\\\";\\nconst require = createRequire(import.meta.url);\\nconst cjs = require(\\\"./index.js\\\");\\n\\nexport const {\\n DEFAULT_BASE_URL,\\n DEFAULT_MODEL,\\n DEFAULT_TIMEOUT_MS,\\n RuleScope,\\n SlashMLAPIError,\\n ProjectManager,\\n MemoryClient,\\n Memory,\\n AsyncMemoryClient,\\n AsyncMemory,\\n SlashMLMemory,\\n SlashMLClient,\\n AsyncSlashMLMemory,\\n AsyncSlashMLClient,\\n extractCanonicalSlotKey,\\n compileContrastiveRule,\\n formatCacheAlignedPrompt,\\n} = cjs;\\n\\nexport default cjs;\\n'; fs.writeFileSync('dist/index.mjs', code);\"",
34
35
  "test": "node --test test/sdk.test.js"
35
36
  },
36
37
  "engines": {