memax-sdk 0.1.2 → 0.1.3
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/client.d.ts +15 -95
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +21 -277
- package/dist/client.js.map +1 -1
- package/dist/errors.d.ts +6 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +11 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/resources/auth.d.ts +11 -0
- package/dist/resources/auth.d.ts.map +1 -0
- package/dist/resources/auth.js +25 -0
- package/dist/resources/auth.js.map +1 -0
- package/dist/resources/configs.d.ts +23 -0
- package/dist/resources/configs.d.ts.map +1 -0
- package/dist/resources/configs.js +33 -0
- package/dist/resources/configs.js.map +1 -0
- package/dist/resources/hubs.d.ts +10 -0
- package/dist/resources/hubs.d.ts.map +1 -0
- package/dist/resources/hubs.js +16 -0
- package/dist/resources/hubs.js.map +1 -0
- package/dist/resources/memories.d.ts +13 -0
- package/dist/resources/memories.d.ts.map +1 -0
- package/dist/resources/memories.js +73 -0
- package/dist/resources/memories.js.map +1 -0
- package/dist/resources/settings.d.ts +8 -0
- package/dist/resources/settings.d.ts.map +1 -0
- package/dist/resources/settings.js +10 -0
- package/dist/resources/settings.js.map +1 -0
- package/dist/resources/topics.d.ts +19 -0
- package/dist/resources/topics.d.ts.map +1 -0
- package/dist/resources/topics.js +45 -0
- package/dist/resources/topics.js.map +1 -0
- package/dist/transport.d.ts +18 -0
- package/dist/transport.d.ts.map +1 -0
- package/dist/transport.js +107 -0
- package/dist/transport.js.map +1 -0
- package/dist/transport.test.d.ts +2 -0
- package/dist/transport.test.d.ts.map +1 -0
- package/dist/transport.test.js +70 -0
- package/dist/transport.test.js.map +1 -0
- package/dist/types.d.ts +91 -5
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -1,100 +1,20 @@
|
|
|
1
|
-
import type { MemaxConfig
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
1
|
+
import type { MemaxConfig } from "./types.js";
|
|
2
|
+
import { MemoriesResource } from "./resources/memories.js";
|
|
3
|
+
import { ConfigsResource } from "./resources/configs.js";
|
|
4
|
+
import { AuthResource } from "./resources/auth.js";
|
|
5
|
+
import { HubsResource } from "./resources/hubs.js";
|
|
6
|
+
import { TopicsResource } from "./resources/topics.js";
|
|
7
|
+
import { SettingsResource } from "./resources/settings.js";
|
|
7
8
|
export declare class Memax {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
readonly
|
|
12
|
-
|
|
13
|
-
readonly configs: Configs;
|
|
14
|
-
/** Auth & API key management */
|
|
15
|
-
readonly auth: Auth;
|
|
16
|
-
/** Hub management */
|
|
17
|
-
readonly hubs: Hubs;
|
|
18
|
-
/** User settings */
|
|
9
|
+
readonly memories: MemoriesResource;
|
|
10
|
+
readonly configs: ConfigsResource;
|
|
11
|
+
readonly auth: AuthResource;
|
|
12
|
+
readonly hubs: HubsResource;
|
|
13
|
+
readonly topics: TopicsResource;
|
|
19
14
|
readonly settings: SettingsResource;
|
|
20
15
|
constructor(config: MemaxConfig);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
recall(query: string, options?: RecallOptions): Promise<RecallResult>;
|
|
25
|
-
/** Ask a question and get an AI-synthesized answer with citations */
|
|
26
|
-
ask(query: string, options?: AskOptions): Promise<AskResult>;
|
|
27
|
-
/** @internal — exposed for resource namespaces */
|
|
28
|
-
request<T>(method: string, path: string, options?: {
|
|
29
|
-
body?: unknown;
|
|
30
|
-
hubId?: string;
|
|
31
|
-
query?: Record<string, string>;
|
|
32
|
-
}): Promise<T>;
|
|
33
|
-
}
|
|
34
|
-
type RequestFn = Memax["request"];
|
|
35
|
-
/** Memory CRUD */
|
|
36
|
-
declare class Memories {
|
|
37
|
-
private req;
|
|
38
|
-
constructor(req: RequestFn);
|
|
39
|
-
list(options?: ListMemoriesOptions): Promise<ListMemoriesResult>;
|
|
40
|
-
get(id: string): Promise<Memory>;
|
|
41
|
-
delete(id: string): Promise<void>;
|
|
42
|
-
}
|
|
43
|
-
/** Agent config sync */
|
|
44
|
-
declare class Configs {
|
|
45
|
-
private req;
|
|
46
|
-
constructor(req: RequestFn);
|
|
47
|
-
/** Send local manifest, receive sync plan */
|
|
48
|
-
sync(configs: SyncManifestEntry[]): Promise<{
|
|
49
|
-
actions: SyncPlanAction[];
|
|
50
|
-
}>;
|
|
51
|
-
/** Get a single config by ID */
|
|
52
|
-
get(id: string): Promise<AgentConfig>;
|
|
53
|
-
/** Create or update a config (idempotent) */
|
|
54
|
-
upsert(config: ConfigUpsertRequest): Promise<AgentConfig>;
|
|
55
|
-
/** List all synced configs, optionally filtered by agent */
|
|
56
|
-
list(options?: {
|
|
57
|
-
agent?: string;
|
|
58
|
-
}): Promise<{
|
|
59
|
-
configs: AgentConfig[];
|
|
60
|
-
}>;
|
|
61
|
-
/** Delete a config by ID */
|
|
62
|
-
delete(id: string): Promise<void>;
|
|
63
|
-
/** LLM-powered merge of conflicting configs */
|
|
64
|
-
merge(request: ConfigMergeRequest): Promise<{
|
|
65
|
-
merged_content: string;
|
|
66
|
-
}>;
|
|
67
|
-
}
|
|
68
|
-
/** Auth & API key management */
|
|
69
|
-
declare class Auth {
|
|
70
|
-
private req;
|
|
71
|
-
constructor(req: RequestFn);
|
|
72
|
-
/** Get current user profile, hubs, and usage */
|
|
73
|
-
me(): Promise<MeResponse>;
|
|
74
|
-
/** Create an API key */
|
|
75
|
-
createKey(options: ApiKeyCreateOptions): Promise<ApiKey>;
|
|
76
|
-
/** List all API keys */
|
|
77
|
-
listKeys(): Promise<ApiKeyListItem[]>;
|
|
78
|
-
/** Revoke an API key */
|
|
79
|
-
revokeKey(id: string): Promise<void>;
|
|
80
|
-
}
|
|
81
|
-
/** Hub management */
|
|
82
|
-
declare class Hubs {
|
|
83
|
-
private req;
|
|
84
|
-
constructor(req: RequestFn);
|
|
85
|
-
/** List all accessible hubs */
|
|
86
|
-
list(): Promise<HubWithRole[]>;
|
|
87
|
-
/** Create a new hub */
|
|
88
|
-
create(name: string): Promise<Hub>;
|
|
89
|
-
/** Switch active hub */
|
|
90
|
-
switch(idOrSlug: string): Promise<HubSwitchResult>;
|
|
91
|
-
}
|
|
92
|
-
/** User settings */
|
|
93
|
-
declare class SettingsResource {
|
|
94
|
-
private req;
|
|
95
|
-
constructor(req: RequestFn);
|
|
96
|
-
/** Get user settings */
|
|
97
|
-
get(): Promise<Settings>;
|
|
16
|
+
push(...args: Parameters<MemoriesResource["push"]>): Promise<import("./types.js").Memory>;
|
|
17
|
+
recall(...args: Parameters<MemoriesResource["recall"]>): Promise<import("./types.js").RecallResult>;
|
|
18
|
+
ask(...args: Parameters<MemoriesResource["ask"]>): Promise<import("./types.js").AskResult>;
|
|
98
19
|
}
|
|
99
|
-
export {};
|
|
100
20
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,qBAAa,KAAK;IAChB,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;gBAExB,MAAM,EAAE,WAAW;IAYzB,IAAI,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAIlD,MAAM,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAItD,GAAG,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;CAGvD"}
|
package/dist/client.js
CHANGED
|
@@ -1,291 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const RETRY_DELAY_MS = 1500;
|
|
9
|
-
// --- Errors ---
|
|
10
|
-
export class MemaxError extends Error {
|
|
11
|
-
code;
|
|
12
|
-
status;
|
|
13
|
-
constructor(message, code, status) {
|
|
14
|
-
super(message);
|
|
15
|
-
this.code = code;
|
|
16
|
-
this.status = status;
|
|
17
|
-
this.name = "MemaxError";
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
// --- Client ---
|
|
1
|
+
import { ApiTransport } from "./transport.js";
|
|
2
|
+
import { MemoriesResource } from "./resources/memories.js";
|
|
3
|
+
import { ConfigsResource } from "./resources/configs.js";
|
|
4
|
+
import { AuthResource } from "./resources/auth.js";
|
|
5
|
+
import { HubsResource } from "./resources/hubs.js";
|
|
6
|
+
import { TopicsResource } from "./resources/topics.js";
|
|
7
|
+
import { SettingsResource } from "./resources/settings.js";
|
|
21
8
|
export class Memax {
|
|
22
|
-
apiUrl;
|
|
23
|
-
getAuth;
|
|
24
|
-
/** Memory CRUD operations */
|
|
25
9
|
memories;
|
|
26
|
-
/** Agent config sync operations */
|
|
27
10
|
configs;
|
|
28
|
-
/** Auth & API key management */
|
|
29
11
|
auth;
|
|
30
|
-
/** Hub management */
|
|
31
12
|
hubs;
|
|
32
|
-
|
|
13
|
+
topics;
|
|
33
14
|
settings;
|
|
34
15
|
constructor(config) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
this.getAuth = async () => ({});
|
|
45
|
-
}
|
|
46
|
-
// Initialize resource namespaces
|
|
47
|
-
const req = this.request.bind(this);
|
|
48
|
-
this.memories = new Memories(req);
|
|
49
|
-
this.configs = new Configs(req);
|
|
50
|
-
this.auth = new Auth(req);
|
|
51
|
-
this.hubs = new Hubs(req);
|
|
16
|
+
const transport = new ApiTransport(config);
|
|
17
|
+
const req = transport.request.bind(transport);
|
|
18
|
+
this.memories = new MemoriesResource(req);
|
|
19
|
+
this.configs = new ConfigsResource(req);
|
|
20
|
+
this.auth = new AuthResource(req);
|
|
21
|
+
this.hubs = new HubsResource(req);
|
|
22
|
+
this.topics = new TopicsResource(req);
|
|
52
23
|
this.settings = new SettingsResource(req);
|
|
53
24
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
async push(content, options) {
|
|
57
|
-
return this.request("POST", "/v1/memories", {
|
|
58
|
-
body: {
|
|
59
|
-
content,
|
|
60
|
-
title: options?.title ?? "",
|
|
61
|
-
category: options?.category ?? "",
|
|
62
|
-
tags: options?.tags ?? [],
|
|
63
|
-
source: options?.source ?? "sdk",
|
|
64
|
-
source_path: options?.sourcePath,
|
|
65
|
-
content_type: options?.contentType ?? "markdown",
|
|
66
|
-
project_context: options?.projectContext,
|
|
67
|
-
},
|
|
68
|
-
hubId: options?.hubId,
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
/** Recall relevant memories using semantic search */
|
|
72
|
-
async recall(query, options) {
|
|
73
|
-
return this.request("POST", "/v1/recall", {
|
|
74
|
-
body: {
|
|
75
|
-
query,
|
|
76
|
-
limit: options?.limit ?? 5,
|
|
77
|
-
category: options?.category,
|
|
78
|
-
tags: options?.tags,
|
|
79
|
-
include_archived: options?.includeArchived,
|
|
80
|
-
source: options?.source ?? "sdk",
|
|
81
|
-
working_dir: options?.workingDir,
|
|
82
|
-
project_context: options?.projectContext,
|
|
83
|
-
},
|
|
84
|
-
hubId: options?.hubId,
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
/** Ask a question and get an AI-synthesized answer with citations */
|
|
88
|
-
async ask(query, options) {
|
|
89
|
-
return this.request("POST", "/v1/ask", {
|
|
90
|
-
body: {
|
|
91
|
-
query,
|
|
92
|
-
limit: options?.limit ?? 10,
|
|
93
|
-
model: options?.model ?? "auto",
|
|
94
|
-
locale: options?.locale,
|
|
95
|
-
},
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
// --- Internal HTTP transport ---
|
|
99
|
-
/** @internal — exposed for resource namespaces */
|
|
100
|
-
async request(method, path, options) {
|
|
101
|
-
const params = options?.query;
|
|
102
|
-
const qs = params ? "?" + new URLSearchParams(params).toString() : "";
|
|
103
|
-
const url = `${this.apiUrl}${path}${qs}`;
|
|
104
|
-
const authHeaders = await this.getAuth();
|
|
105
|
-
const headers = {
|
|
106
|
-
"Content-Type": "application/json",
|
|
107
|
-
...authHeaders,
|
|
108
|
-
};
|
|
109
|
-
if (options?.hubId) {
|
|
110
|
-
headers["X-Hub-ID"] = options.hubId;
|
|
111
|
-
}
|
|
112
|
-
// Determine body — if options has a `body` key, use it; otherwise use options itself
|
|
113
|
-
// (supports both `request("POST", path, { body: {...}, hubId })` and
|
|
114
|
-
// `request("POST", path, rawPayload)`)
|
|
115
|
-
const payload = options?.body !== undefined ? options.body : undefined;
|
|
116
|
-
let lastErr;
|
|
117
|
-
for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
|
|
118
|
-
let res;
|
|
119
|
-
try {
|
|
120
|
-
res = await fetch(url, {
|
|
121
|
-
method,
|
|
122
|
-
headers,
|
|
123
|
-
body: payload !== undefined ? JSON.stringify(payload) : undefined,
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
catch {
|
|
127
|
-
throw new MemaxError(`Cannot reach API at ${url} — is the server running?`, "network_error", 0);
|
|
128
|
-
}
|
|
129
|
-
// Handle empty responses (204 No Content, etc.)
|
|
130
|
-
const text = await res.text();
|
|
131
|
-
if (!text && res.ok) {
|
|
132
|
-
return undefined;
|
|
133
|
-
}
|
|
134
|
-
let json;
|
|
135
|
-
try {
|
|
136
|
-
json = JSON.parse(text);
|
|
137
|
-
}
|
|
138
|
-
catch {
|
|
139
|
-
if (res.status === 401) {
|
|
140
|
-
throw new MemaxError("Not authenticated — run `memax login` first", "unauthorized", 401);
|
|
141
|
-
}
|
|
142
|
-
throw new MemaxError(`API returned ${res.status} with non-JSON response`, "invalid_response", res.status);
|
|
143
|
-
}
|
|
144
|
-
if (json.error) {
|
|
145
|
-
const err = new MemaxError(json.error.message, json.error.code, res.status);
|
|
146
|
-
if (json.error.code === "not_ready" && attempt < MAX_RETRIES) {
|
|
147
|
-
lastErr = err;
|
|
148
|
-
await new Promise((r) => setTimeout(r, RETRY_DELAY_MS));
|
|
149
|
-
continue;
|
|
150
|
-
}
|
|
151
|
-
throw err;
|
|
152
|
-
}
|
|
153
|
-
return json.data;
|
|
154
|
-
}
|
|
155
|
-
throw lastErr;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
/** Memory CRUD */
|
|
159
|
-
class Memories {
|
|
160
|
-
req;
|
|
161
|
-
constructor(req) {
|
|
162
|
-
this.req = req;
|
|
163
|
-
}
|
|
164
|
-
async list(options) {
|
|
165
|
-
const query = {};
|
|
166
|
-
if (options?.limit)
|
|
167
|
-
query.limit = String(options.limit);
|
|
168
|
-
if (options?.cursor)
|
|
169
|
-
query.cursor = options.cursor;
|
|
170
|
-
if (options?.sort)
|
|
171
|
-
query.sort = options.sort;
|
|
172
|
-
const res = await this.req("GET", "/v1/memories", {
|
|
173
|
-
query: Object.keys(query).length ? query : undefined,
|
|
174
|
-
hubId: options?.hubId,
|
|
175
|
-
});
|
|
176
|
-
// Handle both paginated and legacy array response
|
|
177
|
-
if (Array.isArray(res)) {
|
|
178
|
-
return {
|
|
179
|
-
memories: res,
|
|
180
|
-
next_cursor: "",
|
|
181
|
-
has_more: false,
|
|
182
|
-
total: res.length,
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
return res;
|
|
186
|
-
}
|
|
187
|
-
async get(id) {
|
|
188
|
-
return this.req("GET", `/v1/memories/${id}`);
|
|
189
|
-
}
|
|
190
|
-
async delete(id) {
|
|
191
|
-
await this.req("DELETE", `/v1/memories/${id}`);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
/** Agent config sync */
|
|
195
|
-
class Configs {
|
|
196
|
-
req;
|
|
197
|
-
constructor(req) {
|
|
198
|
-
this.req = req;
|
|
199
|
-
}
|
|
200
|
-
/** Send local manifest, receive sync plan */
|
|
201
|
-
async sync(configs) {
|
|
202
|
-
return this.req("POST", "/v1/configs/sync", {
|
|
203
|
-
body: { configs },
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
/** Get a single config by ID */
|
|
207
|
-
async get(id) {
|
|
208
|
-
return this.req("GET", `/v1/configs/${id}`);
|
|
209
|
-
}
|
|
210
|
-
/** Create or update a config (idempotent) */
|
|
211
|
-
async upsert(config) {
|
|
212
|
-
return this.req("PUT", "/v1/configs", { body: config });
|
|
25
|
+
async push(...args) {
|
|
26
|
+
return this.memories.push(...args);
|
|
213
27
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
const query = {};
|
|
217
|
-
if (options?.agent)
|
|
218
|
-
query.agent = options.agent;
|
|
219
|
-
return this.req("GET", "/v1/configs", {
|
|
220
|
-
query: Object.keys(query).length ? query : undefined,
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
/** Delete a config by ID */
|
|
224
|
-
async delete(id) {
|
|
225
|
-
await this.req("DELETE", `/v1/configs/${id}`);
|
|
226
|
-
}
|
|
227
|
-
/** LLM-powered merge of conflicting configs */
|
|
228
|
-
async merge(request) {
|
|
229
|
-
return this.req("POST", "/v1/configs/merge", { body: request });
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
/** Auth & API key management */
|
|
233
|
-
class Auth {
|
|
234
|
-
req;
|
|
235
|
-
constructor(req) {
|
|
236
|
-
this.req = req;
|
|
237
|
-
}
|
|
238
|
-
/** Get current user profile, hubs, and usage */
|
|
239
|
-
async me() {
|
|
240
|
-
return this.req("GET", "/v1/auth/me");
|
|
241
|
-
}
|
|
242
|
-
/** Create an API key */
|
|
243
|
-
async createKey(options) {
|
|
244
|
-
return this.req("POST", "/v1/auth/api-keys", {
|
|
245
|
-
body: {
|
|
246
|
-
name: options.name,
|
|
247
|
-
hub_id: options.hubId,
|
|
248
|
-
expires_in_days: options.expiresInDays,
|
|
249
|
-
},
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
/** List all API keys */
|
|
253
|
-
async listKeys() {
|
|
254
|
-
return this.req("GET", "/v1/auth/api-keys");
|
|
255
|
-
}
|
|
256
|
-
/** Revoke an API key */
|
|
257
|
-
async revokeKey(id) {
|
|
258
|
-
await this.req("DELETE", `/v1/auth/api-keys/${id}`);
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
/** Hub management */
|
|
262
|
-
class Hubs {
|
|
263
|
-
req;
|
|
264
|
-
constructor(req) {
|
|
265
|
-
this.req = req;
|
|
266
|
-
}
|
|
267
|
-
/** List all accessible hubs */
|
|
268
|
-
async list() {
|
|
269
|
-
return this.req("GET", "/v1/hubs");
|
|
270
|
-
}
|
|
271
|
-
/** Create a new hub */
|
|
272
|
-
async create(name) {
|
|
273
|
-
return this.req("POST", "/v1/hubs", { body: { name } });
|
|
274
|
-
}
|
|
275
|
-
/** Switch active hub */
|
|
276
|
-
async switch(idOrSlug) {
|
|
277
|
-
return this.req("POST", `/v1/hubs/${idOrSlug}/switch`, { body: {} });
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
/** User settings */
|
|
281
|
-
class SettingsResource {
|
|
282
|
-
req;
|
|
283
|
-
constructor(req) {
|
|
284
|
-
this.req = req;
|
|
28
|
+
async recall(...args) {
|
|
29
|
+
return this.memories.recall(...args);
|
|
285
30
|
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
return this.req("GET", "/v1/settings");
|
|
31
|
+
async ask(...args) {
|
|
32
|
+
return this.memories.ask(...args);
|
|
289
33
|
}
|
|
290
34
|
}
|
|
291
35
|
//# sourceMappingURL=client.js.map
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,MAAM,OAAO,KAAK;IACP,QAAQ,CAAmB;IAC3B,OAAO,CAAkB;IACzB,IAAI,CAAe;IACnB,IAAI,CAAe;IACnB,MAAM,CAAiB;IACvB,QAAQ,CAAmB;IAEpC,YAAY,MAAmB;QAC7B,MAAM,SAAS,GAAG,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;QAC3C,MAAM,GAAG,GAAG,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAE9C,IAAI,CAAC,QAAQ,GAAG,IAAI,gBAAgB,CAAC,GAAG,CAAC,CAAC;QAC1C,IAAI,CAAC,OAAO,GAAG,IAAI,eAAe,CAAC,GAAG,CAAC,CAAC;QACxC,IAAI,CAAC,IAAI,GAAG,IAAI,YAAY,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,CAAC,IAAI,GAAG,IAAI,YAAY,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,CAAC,MAAM,GAAG,IAAI,cAAc,CAAC,GAAG,CAAC,CAAC;QACtC,IAAI,CAAC,QAAQ,GAAG,IAAI,gBAAgB,CAAC,GAAG,CAAC,CAAC;IAC5C,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,GAAG,IAA0C;QACtD,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,GAAG,IAA4C;QAC1D,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;IACvC,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GAAG,IAAyC;QACpD,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;IACpC,CAAC;CACF"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,UAAW,SAAQ,KAAK;IAG1B,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,MAAM;gBAFrB,OAAO,EAAE,MAAM,EACR,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM;CAKxB"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,UAAW,SAAQ,KAAK;IAG1B;IACA;IAHT,YACE,OAAe,EACR,IAAY,EACZ,MAAc;QAErB,KAAK,CAAC,OAAO,CAAC,CAAC;QAHR,SAAI,GAAJ,IAAI,CAAQ;QACZ,WAAM,GAAN,MAAM,CAAQ;QAGrB,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;IAC3B,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export { Memax
|
|
2
|
-
export
|
|
1
|
+
export { Memax } from "./client.js";
|
|
2
|
+
export { MemaxError } from "./errors.js";
|
|
3
|
+
export type { MemaxConfig, AuthProvider, PushOptions, RecallOptions, AskOptions, ListMemoriesOptions, Memory, RecalledMemory, RecallResult, AskResult, ListMemoriesResult, AgentConfig, SyncAction, SyncPlanAction, SyncManifestEntry, ConfigSyncRequest, AgentConfigSyncAck, ConfigSyncAckRequest, ConfigLocalDeleteRequest, ConfigUpsertRequest, ConfigMergeRequest, User, MeResponse, ApiKeyCreateOptions, ApiKey, ApiKeyListItem, Hub, HubWithRole, HubSwitchResult, Settings, Topic, TopicTree, TopicListResponse, TopicCreateParams, TopicUpdateParams, TopicReorderOperation, TopicMemoriesResponse, } from "./types.js";
|
|
3
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,YAAY,EAEV,WAAW,EACX,YAAY,EAEZ,WAAW,EACX,aAAa,EACb,UAAU,EACV,mBAAmB,EAEnB,MAAM,EACN,cAAc,EACd,YAAY,EACZ,SAAS,EACT,kBAAkB,EAElB,WAAW,EACX,UAAU,EACV,cAAc,EACd,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,wBAAwB,EACxB,mBAAmB,EACnB,kBAAkB,EAElB,IAAI,EACJ,UAAU,EACV,mBAAmB,EACnB,MAAM,EACN,cAAc,EAEd,GAAG,EACH,WAAW,EACX,eAAe,EAEf,QAAQ,EAER,KAAK,EACL,SAAS,EACT,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -2,5 +2,6 @@
|
|
|
2
2
|
// memax-sdk — TypeScript SDK for the Memax API
|
|
3
3
|
// Works in Node.js, Deno, and edge runtimes (uses fetch, not http)
|
|
4
4
|
// =============================================================================
|
|
5
|
-
export { Memax
|
|
5
|
+
export { Memax } from "./client.js";
|
|
6
|
+
export { MemaxError } from "./errors.js";
|
|
6
7
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,+CAA+C;AAC/C,mEAAmE;AACnE,gFAAgF;AAEhF,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,+CAA+C;AAC/C,mEAAmE;AACnE,gFAAgF;AAEhF,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ApiKey, ApiKeyCreateOptions, ApiKeyListItem, MeResponse } from "../types.js";
|
|
2
|
+
import type { RequestFn } from "../transport.js";
|
|
3
|
+
export declare class AuthResource {
|
|
4
|
+
private readonly req;
|
|
5
|
+
constructor(req: RequestFn);
|
|
6
|
+
me(): Promise<MeResponse>;
|
|
7
|
+
createKey(options: ApiKeyCreateOptions): Promise<ApiKey>;
|
|
8
|
+
listKeys(): Promise<ApiKeyListItem[]>;
|
|
9
|
+
revokeKey(id: string): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/resources/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,mBAAmB,EACnB,cAAc,EACd,UAAU,EACX,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,qBAAa,YAAY;IACX,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,SAAS;IAErC,EAAE,IAAI,OAAO,CAAC,UAAU,CAAC;IAIzB,SAAS,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC;IAUxD,QAAQ,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IAIrC,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAG3C"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export class AuthResource {
|
|
2
|
+
req;
|
|
3
|
+
constructor(req) {
|
|
4
|
+
this.req = req;
|
|
5
|
+
}
|
|
6
|
+
async me() {
|
|
7
|
+
return this.req("GET", "/v1/auth/me");
|
|
8
|
+
}
|
|
9
|
+
async createKey(options) {
|
|
10
|
+
return this.req("POST", "/v1/auth/api-keys", {
|
|
11
|
+
body: {
|
|
12
|
+
name: options.name,
|
|
13
|
+
hub_id: options.hubId,
|
|
14
|
+
expires_in_days: options.expiresInDays,
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
async listKeys() {
|
|
19
|
+
return this.req("GET", "/v1/auth/api-keys");
|
|
20
|
+
}
|
|
21
|
+
async revokeKey(id) {
|
|
22
|
+
await this.req("DELETE", `/v1/auth/api-keys/${id}`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/resources/auth.ts"],"names":[],"mappings":"AAQA,MAAM,OAAO,YAAY;IACM;IAA7B,YAA6B,GAAc;QAAd,QAAG,GAAH,GAAG,CAAW;IAAG,CAAC;IAE/C,KAAK,CAAC,EAAE;QACN,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;IACxC,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,OAA4B;QAC1C,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,mBAAmB,EAAE;YAC3C,IAAI,EAAE;gBACJ,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,MAAM,EAAE,OAAO,CAAC,KAAK;gBACrB,eAAe,EAAE,OAAO,CAAC,aAAa;aACvC;SACF,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,mBAAmB,CAAC,CAAC;IAC9C,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,EAAU;QACxB,MAAM,IAAI,CAAC,GAAG,CAAO,QAAQ,EAAE,qBAAqB,EAAE,EAAE,CAAC,CAAC;IAC5D,CAAC;CACF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { AgentConfig, ConfigLocalDeleteRequest, ConfigMergeRequest, ConfigSyncAckRequest, ConfigSyncRequest, ConfigUpsertRequest, SyncPlanAction } from "../types.js";
|
|
2
|
+
import type { RequestFn } from "../transport.js";
|
|
3
|
+
export declare class ConfigsResource {
|
|
4
|
+
private readonly req;
|
|
5
|
+
constructor(req: RequestFn);
|
|
6
|
+
sync(request: ConfigSyncRequest): Promise<{
|
|
7
|
+
actions: SyncPlanAction[];
|
|
8
|
+
}>;
|
|
9
|
+
ack(request: ConfigSyncAckRequest): Promise<void>;
|
|
10
|
+
localDelete(request: ConfigLocalDeleteRequest): Promise<void>;
|
|
11
|
+
get(id: string): Promise<AgentConfig>;
|
|
12
|
+
upsert(config: ConfigUpsertRequest): Promise<AgentConfig>;
|
|
13
|
+
list(options?: {
|
|
14
|
+
agent?: string;
|
|
15
|
+
}): Promise<{
|
|
16
|
+
configs: AgentConfig[];
|
|
17
|
+
}>;
|
|
18
|
+
delete(id: string): Promise<void>;
|
|
19
|
+
merge(request: ConfigMergeRequest): Promise<{
|
|
20
|
+
merged_content: string;
|
|
21
|
+
}>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=configs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configs.d.ts","sourceRoot":"","sources":["../../src/resources/configs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,wBAAwB,EACxB,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACf,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,qBAAa,eAAe;IACd,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,SAAS;IAErC,IAAI,CACR,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC;QAAE,OAAO,EAAE,cAAc,EAAE,CAAA;KAAE,CAAC;IAInC,GAAG,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAIjD,WAAW,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC;IAI7D,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAIrC,MAAM,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,WAAW,CAAC;IAIzD,IAAI,CAAC,OAAO,CAAC,EAAE;QACnB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,WAAW,EAAE,CAAA;KAAE,CAAC;IAMjC,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIjC,KAAK,CACT,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC;QAAE,cAAc,EAAE,MAAM,CAAA;KAAE,CAAC;CAGvC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export class ConfigsResource {
|
|
2
|
+
req;
|
|
3
|
+
constructor(req) {
|
|
4
|
+
this.req = req;
|
|
5
|
+
}
|
|
6
|
+
async sync(request) {
|
|
7
|
+
return this.req("POST", "/v1/configs/sync", { body: request });
|
|
8
|
+
}
|
|
9
|
+
async ack(request) {
|
|
10
|
+
await this.req("POST", "/v1/configs/ack", { body: request });
|
|
11
|
+
}
|
|
12
|
+
async localDelete(request) {
|
|
13
|
+
await this.req("POST", "/v1/configs/local-delete", { body: request });
|
|
14
|
+
}
|
|
15
|
+
async get(id) {
|
|
16
|
+
return this.req("GET", `/v1/configs/${id}`);
|
|
17
|
+
}
|
|
18
|
+
async upsert(config) {
|
|
19
|
+
return this.req("PUT", "/v1/configs", { body: config });
|
|
20
|
+
}
|
|
21
|
+
async list(options) {
|
|
22
|
+
return this.req("GET", "/v1/configs", {
|
|
23
|
+
query: { agent: options?.agent },
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
async delete(id) {
|
|
27
|
+
await this.req("DELETE", `/v1/configs/${id}`);
|
|
28
|
+
}
|
|
29
|
+
async merge(request) {
|
|
30
|
+
return this.req("POST", "/v1/configs/merge", { body: request });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=configs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configs.js","sourceRoot":"","sources":["../../src/resources/configs.ts"],"names":[],"mappings":"AAWA,MAAM,OAAO,eAAe;IACG;IAA7B,YAA6B,GAAc;QAAd,QAAG,GAAH,GAAG,CAAW;IAAG,CAAC;IAE/C,KAAK,CAAC,IAAI,CACR,OAA0B;QAE1B,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,kBAAkB,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;IACjE,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,OAA6B;QACrC,MAAM,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,iBAAiB,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;IAC/D,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,OAAiC;QACjD,MAAM,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,0BAA0B,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;IACxE,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,EAAU;QAClB,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,eAAe,EAAE,EAAE,CAAC,CAAC;IAC9C,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,MAA2B;QACtC,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;IAC1D,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,OAEV;QACC,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,aAAa,EAAE;YACpC,KAAK,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE;SACjC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAAU;QACrB,MAAM,IAAI,CAAC,GAAG,CAAO,QAAQ,EAAE,eAAe,EAAE,EAAE,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,KAAK,CACT,OAA2B;QAE3B,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,mBAAmB,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;IAClE,CAAC;CACF"}
|