@fluxa-pay/planner 0.2.2 → 0.2.3

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/package.json +1 -1
  2. package/planner.mjs +12 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluxa-pay/planner",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "FluxA Planner CLI. Recommend the right models, APIs and skills for a task, run paid calls via x402, and manage your oneshot APIs.",
5
5
  "type": "module",
6
6
  "bin": {
package/planner.mjs CHANGED
@@ -47,6 +47,12 @@ const KIND = { model: c.cyan("model"), api: c.lime("api "), skill: c.green("ski
47
47
  const pad = (s, n) => { s = String(s); return s.length > n ? s.slice(0, n - 1) + "…" : s.padEnd(n); };
48
48
  const usd = (units) => { const v = (units || 0) * UNIT_USD; return v < 0.01 ? `$${v.toFixed(4)}` : `$${v.toFixed(2)}`; };
49
49
  const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
50
+ // The planner brain occasionally HTML-escapes angle brackets in free text
51
+ // (e.g. "&lt;merchant&gt;"); un-escape the common entities for terminal output.
52
+ // &amp; is undone LAST so "&amp;lt;" doesn't collapse into "<".
53
+ const unesc = (s) => typeof s === "string"
54
+ ? s.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#3?9;/g, "'").replace(/&amp;/g, "&")
55
+ : s;
50
56
 
51
57
  // --- config / auth ----------------------------------------------------------
52
58
  function loadConfig() {
@@ -629,14 +635,14 @@ async function cmdPlan(task) {
629
635
  }
630
636
 
631
637
  function printAnswer(a) {
632
- console.log("\n " + c.bold(a.answer));
638
+ console.log("\n " + c.bold(unesc(a.answer)));
633
639
  if (a.command) {
634
640
  console.log("\n " + c.dim("run:"));
635
- console.log(" " + c.cyan(a.command));
641
+ console.log(" " + c.cyan(unesc(a.command)));
636
642
  }
637
643
  if (a.prompt) {
638
644
  console.log("\n " + c.dim("copy this prompt for your agent:"));
639
- for (const line of a.prompt.split("\n")) console.log(" " + line);
645
+ for (const line of unesc(a.prompt).split("\n")) console.log(" " + line);
640
646
  }
641
647
  console.log("");
642
648
  }
@@ -644,17 +650,17 @@ function printAnswer(a) {
644
650
  // Render a PlanOrAnswer plan: tools carry kind/slug/name/units/detail.
645
651
  function printPlan(plan) {
646
652
  const tools = plan.tools || [];
647
- const heading = plan.reason || plan.task || "Recommended";
653
+ const heading = unesc(plan.reason || plan.task || "Recommended");
648
654
  console.log("\n " + c.bold("Recommended") + " " + c.dim(heading));
649
655
  let total = 0;
650
656
  for (const t of tools) {
651
657
  const k = KIND[t.kind] || pad(t.kind, 5);
652
658
  total += t.units || 0;
653
- console.log(` ${k} ${c.bold(pad(t.slug, 36))} ${c.dim(pad(t.detail || "", 30))} ${c.lime("~" + (t.units || 0).toLocaleString() + " Units")}`);
659
+ console.log(` ${k} ${c.bold(pad(t.slug, 36))} ${c.dim(pad(unesc(t.detail || ""), 30))} ${c.lime("~" + (t.units || 0).toLocaleString() + " Units")}`);
654
660
  }
655
661
  console.log(c.gray(" " + "─".repeat(78)));
656
662
  console.log(` ${c.bold("est")} ${c.lime("~" + total.toLocaleString() + " Units")} ${c.dim("(~" + usd(total) + ")")}`);
657
- if (plan.instructions) console.log("\n " + c.dim(plan.instructions));
663
+ if (plan.instructions) console.log("\n " + c.dim(unesc(plan.instructions)));
658
664
  console.log(c.dim("\n → call these tools directly — FluxA settles each paid call from your wallet. No keys, no subs."));
659
665
  return total;
660
666
  }