@ai-matrx/agents 0.8.0 → 0.9.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.
- package/CHANGELOG.md +135 -0
- package/dist/catalog/index.cjs +50 -3
- package/dist/catalog/index.cjs.map +1 -1
- package/dist/catalog/index.d.cts +11 -615
- package/dist/catalog/index.d.ts +11 -615
- package/dist/catalog/index.js +50 -3
- package/dist/catalog/index.js.map +1 -1
- package/dist/catalog/native/index.cjs +2806 -0
- package/dist/catalog/native/index.cjs.map +1 -0
- package/dist/catalog/native/index.d.cts +655 -0
- package/dist/catalog/native/index.d.ts +655 -0
- package/dist/catalog/native/index.js +2802 -0
- package/dist/catalog/native/index.js.map +1 -0
- package/dist/catalog/react/index.cjs +470 -394
- package/dist/catalog/react/index.cjs.map +1 -1
- package/dist/catalog/react/index.d.cts +64 -26
- package/dist/catalog/react/index.d.ts +64 -26
- package/dist/catalog/react/index.js +354 -278
- package/dist/catalog/react/index.js.map +1 -1
- package/dist/orchestra-BWJM2MWP.d.cts +643 -0
- package/dist/orchestra-BWJM2MWP.d.ts +643 -0
- package/package.json +22 -2
package/dist/catalog/index.js
CHANGED
|
@@ -337,6 +337,51 @@ function writeCachedDefaultRow(storage, resolved) {
|
|
|
337
337
|
} catch {
|
|
338
338
|
}
|
|
339
339
|
}
|
|
340
|
+
function parseCachedDefaultRow(mandateKey, raw) {
|
|
341
|
+
try {
|
|
342
|
+
if (!raw) return null;
|
|
343
|
+
const parsed = JSON.parse(raw);
|
|
344
|
+
if (!isRecord2(parsed)) return null;
|
|
345
|
+
const holderId = parsed["holderId"];
|
|
346
|
+
const holderName = parsed["holderName"];
|
|
347
|
+
if (typeof holderId !== "string" || typeof holderName !== "string") {
|
|
348
|
+
return null;
|
|
349
|
+
}
|
|
350
|
+
const description = parsed["holderDescription"];
|
|
351
|
+
const provenance = parsed["provenance"];
|
|
352
|
+
const at = parsed["at"];
|
|
353
|
+
return {
|
|
354
|
+
mandateKey,
|
|
355
|
+
holderId,
|
|
356
|
+
holderName,
|
|
357
|
+
holderDescription: typeof description === "string" ? description : null,
|
|
358
|
+
provenance: typeof provenance === "string" ? provenance : "system",
|
|
359
|
+
at: typeof at === "number" ? at : 0
|
|
360
|
+
};
|
|
361
|
+
} catch {
|
|
362
|
+
return null;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
async function readCachedDefaultRowAsync(storage, mandateKey) {
|
|
366
|
+
let raw;
|
|
367
|
+
try {
|
|
368
|
+
raw = await storage.getItem(
|
|
369
|
+
CACHE_PREFIX + mandateKey
|
|
370
|
+
);
|
|
371
|
+
} catch {
|
|
372
|
+
return null;
|
|
373
|
+
}
|
|
374
|
+
return parseCachedDefaultRow(mandateKey, raw);
|
|
375
|
+
}
|
|
376
|
+
async function writeCachedDefaultRowAsync(storage, resolved) {
|
|
377
|
+
try {
|
|
378
|
+
await storage.setItem(
|
|
379
|
+
CACHE_PREFIX + resolved.mandateKey,
|
|
380
|
+
JSON.stringify(resolved)
|
|
381
|
+
);
|
|
382
|
+
} catch {
|
|
383
|
+
}
|
|
384
|
+
}
|
|
340
385
|
function defaultRowFromResolution(resolved) {
|
|
341
386
|
return {
|
|
342
387
|
id: mandateAgentId(resolved.mandateKey),
|
|
@@ -376,7 +421,7 @@ function detectDefaultRowDrift(cached, live) {
|
|
|
376
421
|
}
|
|
377
422
|
async function resolveDefaultRow(args) {
|
|
378
423
|
const { mandateKey, transport, client, storage, lookupRow } = args;
|
|
379
|
-
const cached =
|
|
424
|
+
const cached = await readCachedDefaultRowAsync(storage, mandateKey);
|
|
380
425
|
const verdict = await askTheServer(transport, mandateKey);
|
|
381
426
|
if (verdict.holderType !== "agent") {
|
|
382
427
|
throw new MandateDefaultRowError({
|
|
@@ -413,7 +458,7 @@ async function resolveDefaultRow(args) {
|
|
|
413
458
|
at: Date.now()
|
|
414
459
|
};
|
|
415
460
|
const drift = detectDefaultRowDrift(cached, resolved);
|
|
416
|
-
|
|
461
|
+
await writeCachedDefaultRowAsync(storage, resolved);
|
|
417
462
|
return { resolved, row: defaultRowFromResolution(resolved), drift };
|
|
418
463
|
}
|
|
419
464
|
|
|
@@ -1364,6 +1409,7 @@ export {
|
|
|
1364
1409
|
parseMandateResolution,
|
|
1365
1410
|
readAgentCatalogRows,
|
|
1366
1411
|
readCachedDefaultRow,
|
|
1412
|
+
readCachedDefaultRowAsync,
|
|
1367
1413
|
readSingleAgentRow,
|
|
1368
1414
|
resolveDefaultRow,
|
|
1369
1415
|
searchAgentsOnServer,
|
|
@@ -1382,6 +1428,7 @@ export {
|
|
|
1382
1428
|
sortFilteredAgents,
|
|
1383
1429
|
toAgentSummary,
|
|
1384
1430
|
writeAgentFavorite,
|
|
1385
|
-
writeCachedDefaultRow
|
|
1431
|
+
writeCachedDefaultRow,
|
|
1432
|
+
writeCachedDefaultRowAsync
|
|
1386
1433
|
};
|
|
1387
1434
|
//# sourceMappingURL=index.js.map
|