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