@songsid/agend 2.1.5 → 2.1.6-beta.2

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 (102) hide show
  1. package/dist/apply-job.d.ts +114 -0
  2. package/dist/apply-job.js +214 -0
  3. package/dist/apply-job.js.map +1 -0
  4. package/dist/backend/codex.d.ts +16 -0
  5. package/dist/backend/codex.js +50 -0
  6. package/dist/backend/codex.js.map +1 -1
  7. package/dist/backend/credential-profile.d.ts +114 -0
  8. package/dist/backend/credential-profile.js +242 -0
  9. package/dist/backend/credential-profile.js.map +1 -0
  10. package/dist/backend/kiro-auth-store.d.ts +25 -0
  11. package/dist/backend/kiro-auth-store.js +61 -0
  12. package/dist/backend/kiro-auth-store.js.map +1 -0
  13. package/dist/backend/kiro.d.ts +8 -0
  14. package/dist/backend/kiro.js +31 -2
  15. package/dist/backend/kiro.js.map +1 -1
  16. package/dist/backend/types.d.ts +13 -0
  17. package/dist/backend/types.js.map +1 -1
  18. package/dist/cli.js +113 -0
  19. package/dist/cli.js.map +1 -1
  20. package/dist/config-validator.js +21 -0
  21. package/dist/config-validator.js.map +1 -1
  22. package/dist/daemon.d.ts +25 -0
  23. package/dist/daemon.js +157 -16
  24. package/dist/daemon.js.map +1 -1
  25. package/dist/fleet-level-config.d.ts +42 -0
  26. package/dist/fleet-level-config.js +78 -0
  27. package/dist/fleet-level-config.js.map +1 -0
  28. package/dist/fleet-lock.d.ts +21 -0
  29. package/dist/fleet-lock.js +42 -8
  30. package/dist/fleet-lock.js.map +1 -1
  31. package/dist/fleet-manager.d.ts +130 -1
  32. package/dist/fleet-manager.js +611 -83
  33. package/dist/fleet-manager.js.map +1 -1
  34. package/dist/general-knowledge/skills/credential-profiles/SKILL.md +121 -0
  35. package/dist/instance-config-impact.d.ts +55 -0
  36. package/dist/instance-config-impact.js +152 -0
  37. package/dist/instance-config-impact.js.map +1 -0
  38. package/dist/locale.js +2 -0
  39. package/dist/locale.js.map +1 -1
  40. package/dist/outbound-handlers.d.ts +5 -1
  41. package/dist/outbound-handlers.js +179 -1
  42. package/dist/outbound-handlers.js.map +1 -1
  43. package/dist/outbound-schemas.d.ts +6 -5
  44. package/dist/outbound-schemas.js +1 -0
  45. package/dist/outbound-schemas.js.map +1 -1
  46. package/dist/provider-probe.d.ts +45 -0
  47. package/dist/provider-probe.js +111 -0
  48. package/dist/provider-probe.js.map +1 -0
  49. package/dist/quickstart-api.d.ts +161 -0
  50. package/dist/quickstart-api.js +340 -0
  51. package/dist/quickstart-api.js.map +1 -0
  52. package/dist/quickstart.js +23 -50
  53. package/dist/quickstart.js.map +1 -1
  54. package/dist/self-restart-limit.d.ts +21 -0
  55. package/dist/self-restart-limit.js +129 -0
  56. package/dist/self-restart-limit.js.map +1 -0
  57. package/dist/settings-api.d.ts +15 -0
  58. package/dist/settings-api.js +126 -1
  59. package/dist/settings-api.js.map +1 -1
  60. package/dist/setup-auth.d.ts +113 -0
  61. package/dist/setup-auth.js +181 -0
  62. package/dist/setup-auth.js.map +1 -0
  63. package/dist/setup-form.d.ts +18 -0
  64. package/dist/setup-form.js +315 -0
  65. package/dist/setup-form.js.map +1 -0
  66. package/dist/setup-host.d.ts +162 -0
  67. package/dist/setup-host.js +496 -0
  68. package/dist/setup-host.js.map +1 -0
  69. package/dist/setup-marker.d.ts +8 -0
  70. package/dist/setup-marker.js +39 -0
  71. package/dist/setup-marker.js.map +1 -0
  72. package/dist/setup-tunnel-consent.d.ts +53 -0
  73. package/dist/setup-tunnel-consent.js +82 -0
  74. package/dist/setup-tunnel-consent.js.map +1 -0
  75. package/dist/tips.js +1 -1
  76. package/dist/tips.js.map +1 -1
  77. package/dist/transcript-sources.d.ts +12 -1
  78. package/dist/transcript-sources.js +19 -3
  79. package/dist/transcript-sources.js.map +1 -1
  80. package/dist/tunnel/cloudflared.d.ts +71 -0
  81. package/dist/tunnel/cloudflared.js +447 -0
  82. package/dist/tunnel/cloudflared.js.map +1 -0
  83. package/dist/tunnel/lease.d.ts +75 -0
  84. package/dist/tunnel/lease.js +209 -0
  85. package/dist/tunnel/lease.js.map +1 -0
  86. package/dist/tunnel/manager.d.ts +56 -0
  87. package/dist/tunnel/manager.js +167 -0
  88. package/dist/tunnel/manager.js.map +1 -0
  89. package/dist/tunnel/types.d.ts +119 -0
  90. package/dist/tunnel/types.js +33 -0
  91. package/dist/tunnel/types.js.map +1 -0
  92. package/dist/ui/dashboard.html +4 -3
  93. package/dist/ui/settings.html +640 -153
  94. package/dist/usage/providers.d.ts +16 -13
  95. package/dist/usage/providers.js +79 -53
  96. package/dist/usage/providers.js.map +1 -1
  97. package/dist/web-api.js +6 -4
  98. package/dist/web-api.js.map +1 -1
  99. package/dist/web-auth.d.ts +75 -0
  100. package/dist/web-auth.js +208 -2
  101. package/dist/web-auth.js.map +1 -1
  102. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -1659,6 +1659,101 @@ program
1659
1659
  console.log("Fleet not running. Start with: agend start");
1660
1660
  process.exitCode = 1;
1661
1661
  });
1662
+ program
1663
+ .command("setup")
1664
+ .description("Open the guided setup page in a browser (before a fleet exists)")
1665
+ .option("--reset", "Allow setup again after it has already been completed")
1666
+ .option("--port <port>", "Port for the setup page (default: the health port)")
1667
+ .option("--tunnel", "Expose the setup page through a Cloudflare quick tunnel so a phone can open it")
1668
+ .action(async (opts) => {
1669
+ const { clearSetupComplete, isSetupComplete } = await import("./setup-marker.js");
1670
+ if (opts.reset) {
1671
+ console.log(clearSetupComplete(DATA_DIR) ? "Setup marker cleared." : "No setup marker to clear.");
1672
+ }
1673
+ else if (isSetupComplete(DATA_DIR)) {
1674
+ // Not keyed on fleet.yaml existing: a deleted or truncated config must not
1675
+ // reopen a setup page that starts out reachable to whoever finds it.
1676
+ console.error("Setup has already been completed. Use `agend setup --reset` to run it again, or edit settings from the dashboard.");
1677
+ process.exit(1);
1678
+ }
1679
+ if (opts.tunnel && opts.port) {
1680
+ // Not "ignored": a fixed port behind a tunnel is the one arrangement this
1681
+ // whole design exists to prevent, and silently overriding the flag would
1682
+ // leave someone believing they got the port they asked for.
1683
+ console.error("--tunnel and --port cannot be combined: a tunnelled setup page always binds an ephemeral port.");
1684
+ process.exit(1);
1685
+ }
1686
+ const { loadFleetConfig } = await import("./config.js");
1687
+ const fleet = existsSync(FLEET_CONFIG_PATH) ? loadFleetConfig(FLEET_CONFIG_PATH) : { defaults: {}, instances: {} };
1688
+ const { SetupHost, resolvePort, SETUP_HOST_TTL_MS } = await import("./setup-host.js");
1689
+ // Asked before anything is created: no lock taken, no listener bound, no
1690
+ // cloudflared spawned. Every time, because there is no configuration that
1691
+ // makes the consequences smaller, and there is no chat channel yet to put a
1692
+ // confirmation button in.
1693
+ if (opts.tunnel) {
1694
+ const { confirmPublicTunnel } = await import("./setup-tunnel-consent.js");
1695
+ const { createInterface } = await import("node:readline/promises");
1696
+ const consent = await confirmPublicTunnel({
1697
+ isTTY: !!process.stdin.isTTY,
1698
+ say: line => console.log(line),
1699
+ ask: async (question) => {
1700
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
1701
+ try {
1702
+ return await rl.question(question);
1703
+ }
1704
+ finally {
1705
+ rl.close();
1706
+ }
1707
+ },
1708
+ }, Math.round(SETUP_HOST_TTL_MS / 60_000));
1709
+ if (!consent.granted) {
1710
+ process.exit(1);
1711
+ }
1712
+ }
1713
+ // In tunnel mode this ignores `--port`, `health_port` and the default
1714
+ // alike: the health port is what the fleet will bind later, and a tunnel
1715
+ // that outlived this process would then be pointed at its dashboard.
1716
+ const port = resolvePort({
1717
+ tunnel: opts.tunnel,
1718
+ port: opts.port === undefined ? undefined : Number(opts.port),
1719
+ healthPort: fleet.health_port,
1720
+ });
1721
+ const host = new SetupHost({ dataDir: DATA_DIR, configPath: FLEET_CONFIG_PATH, port, tunnel: opts.tunnel });
1722
+ let started;
1723
+ try {
1724
+ started = await host.start();
1725
+ }
1726
+ catch (err) {
1727
+ console.error(err.message);
1728
+ process.exit(1);
1729
+ }
1730
+ // Two things, and only the second one is a credential. The link is where
1731
+ // the page lives — a random path so nothing finds it by looking — and the
1732
+ // code is what proves you are the person who ran this command. Putting the
1733
+ // credential in the link would mean a preview fetch, a shell history or a
1734
+ // forwarded message carries the whole thing.
1735
+ const { formatSetupCode } = await import("./setup-auth.js");
1736
+ const pageUrl = started.publicUrl ?? `http://127.0.0.1:${started.port}${started.path}`;
1737
+ // A tunnel was asked for and there is no public URL: say why, and say what
1738
+ // that means, rather than printing a loopback link under a flag that
1739
+ // promised a phone could open it.
1740
+ if (opts.tunnel && !started.publicUrl) {
1741
+ const { noTunnelBinaryMessage } = await import("./setup-tunnel-consent.js");
1742
+ console.log("");
1743
+ for (const line of noTunnelBinaryMessage())
1744
+ console.log(line);
1745
+ }
1746
+ console.log(`\n Setup page: ${pageUrl}`);
1747
+ console.log(` Setup code: ${formatSetupCode(started.code)}`);
1748
+ console.log(" Open the page, type the code. Five wrong attempts closes it,");
1749
+ console.log(" and it closes itself after 15 minutes.\n");
1750
+ // Every way this command is asked to stop, not just Ctrl-C: a host that
1751
+ // exits without releasing the lock leaves the next `agend start` to prove
1752
+ // the pid is stale before it can run.
1753
+ for (const signal of ["SIGINT", "SIGTERM", "SIGHUP"]) {
1754
+ process.on(signal, () => { void host.shutdown(false, signal.toLowerCase()).then(() => process.exit(0)); });
1755
+ }
1756
+ });
1662
1757
  program
1663
1758
  .command("quickstart")
1664
1759
  .description("Guided setup for a Backend, chat channel, projects, and fleet service")
@@ -1702,6 +1797,24 @@ program
1702
1797
  const child = spawn(cmd, [htmlPath], { detached: true, stdio: "ignore" });
1703
1798
  child.unref();
1704
1799
  });
1800
+ program
1801
+ .command("web-token")
1802
+ .description("Rotate the web dashboard access token")
1803
+ .argument("<action>", "rotate")
1804
+ .action(async (action) => {
1805
+ if (action !== "rotate") {
1806
+ console.error(`Unknown action "${action}". Only "rotate" is supported.`);
1807
+ process.exit(1);
1808
+ }
1809
+ const { rotateWebToken } = await import("./web-auth.js");
1810
+ rotateWebToken(DATA_DIR);
1811
+ // The new token is deliberately not printed: it would land in shell history
1812
+ // and scrollback, which is what moving it out of URLs and logs was for.
1813
+ console.log("Web token rotated.");
1814
+ console.log("Every previously issued dashboard link and browser session is now rejected.");
1815
+ console.log("A running fleet picks this up immediately — no restart needed.");
1816
+ console.log("Get a new link with `agend web`, or /dashboard in your chat channel.");
1817
+ });
1705
1818
  program
1706
1819
  .command("view")
1707
1820
  .description("Open the read-only View dashboard in your browser")