@pyxmate/memory 0.31.1 → 0.31.2
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/cli/pyx-mem.mjs +68 -29
- package/package.json +1 -1
package/dist/cli/pyx-mem.mjs
CHANGED
|
@@ -166,9 +166,35 @@ function getDefaultKeychain() {
|
|
|
166
166
|
return new NapiKeychainProvider();
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
+
// src/cli/probe.ts
|
|
170
|
+
var PROBE_PATH = "/api/memory/stats";
|
|
171
|
+
var PROBE_TIMEOUT_MS = 8e3;
|
|
172
|
+
async function probeCredentials(args) {
|
|
173
|
+
const fetcher = args.fetcher ?? fetch;
|
|
174
|
+
const url = `${args.endpoint}${PROBE_PATH}`;
|
|
175
|
+
const ctl = new AbortController();
|
|
176
|
+
const timer = setTimeout(() => ctl.abort(), PROBE_TIMEOUT_MS);
|
|
177
|
+
try {
|
|
178
|
+
const res = await fetcher(url, {
|
|
179
|
+
method: "GET",
|
|
180
|
+
headers: { Authorization: `Bearer ${args.apiKey}`, Accept: "application/json" },
|
|
181
|
+
signal: ctl.signal
|
|
182
|
+
});
|
|
183
|
+
if (res.status === 401 || res.status === 403) return { kind: "invalid", status: res.status };
|
|
184
|
+
if (res.ok) return { kind: "ok", status: res.status };
|
|
185
|
+
return { kind: "unreachable", reason: `HTTP ${res.status}` };
|
|
186
|
+
} catch (err) {
|
|
187
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
188
|
+
return { kind: "unreachable", reason: msg };
|
|
189
|
+
} finally {
|
|
190
|
+
clearTimeout(timer);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
169
194
|
// src/cli/commands/doctor.ts
|
|
170
195
|
async function doctorCommand(opts = {}) {
|
|
171
196
|
const provider = opts.keychain ?? getDefaultKeychain();
|
|
197
|
+
const fetcher = opts.fetchImpl ?? fetch;
|
|
172
198
|
const checks = [];
|
|
173
199
|
const accessCheck = await provider.check();
|
|
174
200
|
if (accessCheck.ok) {
|
|
@@ -198,9 +224,10 @@ async function doctorCommand(opts = {}) {
|
|
|
198
224
|
});
|
|
199
225
|
}
|
|
200
226
|
const accessOk = accessCheck.ok;
|
|
227
|
+
let creds = null;
|
|
201
228
|
if (accessOk) {
|
|
202
229
|
try {
|
|
203
|
-
|
|
230
|
+
creds = await provider.read();
|
|
204
231
|
if (creds) {
|
|
205
232
|
checks.push({
|
|
206
233
|
id: "credentials.present",
|
|
@@ -237,11 +264,45 @@ async function doctorCommand(opts = {}) {
|
|
|
237
264
|
message: "skipped \u2014 keychain access failed"
|
|
238
265
|
});
|
|
239
266
|
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
267
|
+
if (creds) {
|
|
268
|
+
const probe = await probeCredentials({
|
|
269
|
+
endpoint: creds.endpoint,
|
|
270
|
+
apiKey: creds.apiKey,
|
|
271
|
+
fetcher
|
|
272
|
+
});
|
|
273
|
+
if (probe.kind === "ok") {
|
|
274
|
+
checks.push({
|
|
275
|
+
id: "backend.reachable",
|
|
276
|
+
status: "pass",
|
|
277
|
+
message: `pyx-memory API reachable (HTTP ${probe.status})`,
|
|
278
|
+
endpoint: creds.endpoint
|
|
279
|
+
});
|
|
280
|
+
} else if (probe.kind === "invalid") {
|
|
281
|
+
checks.push({
|
|
282
|
+
id: "backend.reachable",
|
|
283
|
+
status: "fail",
|
|
284
|
+
code: "key-rejected",
|
|
285
|
+
message: `API key rejected (HTTP ${probe.status})`,
|
|
286
|
+
endpoint: creds.endpoint,
|
|
287
|
+
guidance: "Re-login with a valid key: pyx-mem login"
|
|
288
|
+
});
|
|
289
|
+
} else {
|
|
290
|
+
checks.push({
|
|
291
|
+
id: "backend.reachable",
|
|
292
|
+
status: "fail",
|
|
293
|
+
code: "unreachable",
|
|
294
|
+
message: `no pyx-memory API at this endpoint (${probe.reason})`,
|
|
295
|
+
endpoint: creds.endpoint,
|
|
296
|
+
guidance: "Verify the endpoint is the API backend, not a web UI: pyx-mem login --endpoint <API_URL>"
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
} else {
|
|
300
|
+
checks.push({
|
|
301
|
+
id: "backend.reachable",
|
|
302
|
+
status: "skip",
|
|
303
|
+
message: "skipped \u2014 no credentials to probe"
|
|
304
|
+
});
|
|
305
|
+
}
|
|
245
306
|
const ok = checks.every((c) => c.status !== "fail");
|
|
246
307
|
if (opts.json) {
|
|
247
308
|
process.stdout.write(`${JSON.stringify({ ok, checks })}
|
|
@@ -337,8 +398,6 @@ async function readSingleLineFromStdin() {
|
|
|
337
398
|
|
|
338
399
|
// src/cli/commands/login.ts
|
|
339
400
|
var DEFAULT_ENDPOINT = "https://memory.api.pyxmate.com";
|
|
340
|
-
var PROBE_PATH = "/api/memory/stats";
|
|
341
|
-
var PROBE_TIMEOUT_MS = 8e3;
|
|
342
401
|
async function loginCommand(opts = {}) {
|
|
343
402
|
const provider = opts.keychain ?? getDefaultKeychain();
|
|
344
403
|
const fetcher = opts.fetchImpl ?? fetch;
|
|
@@ -396,26 +455,6 @@ No credentials were written. pyx-mem does not write plaintext token files.
|
|
|
396
455
|
}
|
|
397
456
|
return EXIT.OK;
|
|
398
457
|
}
|
|
399
|
-
async function probeCredentials(args) {
|
|
400
|
-
const url = `${args.endpoint}${PROBE_PATH}`;
|
|
401
|
-
const ctl = new AbortController();
|
|
402
|
-
const timer = setTimeout(() => ctl.abort(), PROBE_TIMEOUT_MS);
|
|
403
|
-
try {
|
|
404
|
-
const res = await args.fetcher(url, {
|
|
405
|
-
method: "GET",
|
|
406
|
-
headers: { Authorization: `Bearer ${args.apiKey}`, Accept: "application/json" },
|
|
407
|
-
signal: ctl.signal
|
|
408
|
-
});
|
|
409
|
-
if (res.status === 401 || res.status === 403) return { kind: "invalid", status: res.status };
|
|
410
|
-
if (res.ok) return { kind: "ok", status: res.status };
|
|
411
|
-
return { kind: "unreachable", reason: `HTTP ${res.status}` };
|
|
412
|
-
} catch (err) {
|
|
413
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
414
|
-
return { kind: "unreachable", reason: msg };
|
|
415
|
-
} finally {
|
|
416
|
-
clearTimeout(timer);
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
458
|
async function readExistingEndpoint(provider) {
|
|
420
459
|
try {
|
|
421
460
|
const creds = await provider.read();
|
|
@@ -1262,7 +1301,7 @@ var ALL_TOOL_NAMES = ALL_TOOLS.map((t) => t.name);
|
|
|
1262
1301
|
// src/mcp/server.ts
|
|
1263
1302
|
async function runMcpServer(opts) {
|
|
1264
1303
|
const fetchImpl = opts.fetchImpl ?? fetch;
|
|
1265
|
-
const version = opts.version ?? (true ? "0.31.
|
|
1304
|
+
const version = opts.version ?? (true ? "0.31.2" : "0.0.0-dev");
|
|
1266
1305
|
const server = new McpServer(
|
|
1267
1306
|
{ name: "pyx-memory", version },
|
|
1268
1307
|
{ instructions: PYX_MEMORY_INSTRUCTIONS, capabilities: { tools: {} } }
|