@persistmemory/cli 0.3.0 → 0.3.1

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/bin.js CHANGED
@@ -1527,7 +1527,7 @@ function shortDate(iso) {
1527
1527
  }
1528
1528
 
1529
1529
  // src/help.ts
1530
- var VERSION = true ? "0.3.0" : versionFromManifest();
1530
+ var VERSION = true ? "0.3.1" : versionFromManifest();
1531
1531
  var PACKAGE = "@persistmemory/cli";
1532
1532
  var HELP = `
1533
1533
  pm \u2014 PersistMemory from your terminal
@@ -2496,10 +2496,14 @@ async function agentCommand(context) {
2496
2496
  };
2497
2497
  process.on("SIGINT", stop);
2498
2498
  process.on("SIGTERM", stop);
2499
+ const authorization = async () => {
2500
+ const held = await currentCredential(context.resolved, context.session);
2501
+ return held.token;
2502
+ };
2499
2503
  const call = async (path, body) => fetch(`${apiUrl}/api/v1/agent/${path}`, {
2500
2504
  method: "POST",
2501
2505
  headers: {
2502
- authorization: `Bearer ${credential.token}`,
2506
+ authorization: `Bearer ${await authorization()}`,
2503
2507
  "content-type": "application/json"
2504
2508
  },
2505
2509
  body: JSON.stringify(body)
@@ -2540,7 +2544,7 @@ async function agentCommand(context) {
2540
2544
  const { items } = await claimed.json();
2541
2545
  for (const request of items) {
2542
2546
  context.print(`Reading ${request.path}`);
2543
- const outcome = await answer(context, apiUrl, credential.token, roots, request);
2547
+ const outcome = await answer(context, apiUrl, await authorization(), roots, request);
2544
2548
  const done = await call(
2545
2549
  `complete/${encodeURIComponent(request.id)}`,
2546
2550
  outcome.ok ? { result: { attachToken: outcome.attachToken } } : { error: outcome.error }