@floomhq/floom 1.0.37 → 1.0.38

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 (2) hide show
  1. package/dist/sync.js +26 -1
  2. package/package.json +1 -1
package/dist/sync.js CHANGED
@@ -270,7 +270,7 @@ export async function sync(opts = {}) {
270
270
  const spinner = opts.spinner === false ? null : ora({ text: c.dim("Syncing skills..."), color: "yellow" }).start();
271
271
  let payload;
272
272
  try {
273
- payload = await getJson(`${apiUrl}/api/v1/me/skills`, "load your skills", cfg.accessToken);
273
+ payload = await loadSyncPayload(apiUrl, cfg.accessToken);
274
274
  }
275
275
  catch (err) {
276
276
  spinner?.stop();
@@ -442,3 +442,28 @@ export async function sync(opts = {}) {
442
442
  throw err;
443
443
  }
444
444
  }
445
+ async function loadSyncPayload(apiUrl, token) {
446
+ const all = [];
447
+ let fullSync = false;
448
+ let cursor;
449
+ const seenCursors = new Set();
450
+ for (let page = 0; page < 1000; page += 1) {
451
+ const url = new URL(`${apiUrl}/api/v1/me/skills`);
452
+ url.searchParams.set("limit", "25");
453
+ if (cursor)
454
+ url.searchParams.set("cursor", cursor);
455
+ const payload = await getJson(url.toString(), "load your skills", token);
456
+ if (!Array.isArray(payload.skills))
457
+ throw new FloomError("Invalid sync response.");
458
+ all.push(...payload.skills);
459
+ fullSync = payload.full_sync === true;
460
+ if (!payload.next_cursor) {
461
+ return { skills: all, full_sync: fullSync };
462
+ }
463
+ if (seenCursors.has(payload.next_cursor))
464
+ throw new FloomError("Invalid sync response.");
465
+ seenCursors.add(payload.next_cursor);
466
+ cursor = payload.next_cursor;
467
+ }
468
+ throw new FloomError("Invalid sync response.");
469
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floomhq/floom",
3
- "version": "1.0.37",
3
+ "version": "1.0.38",
4
4
  "description": "Sync AI skills across agents and machines.",
5
5
  "license": "MIT",
6
6
  "type": "module",