@commandgarden/cli 2.12.1 → 2.14.0

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 (73) hide show
  1. package/dist/main.js +58 -28
  2. package/node_modules/@commandgarden/app/dist/client/assets/{Slides-CHeVcB9K.js → Slides-DWQmJfkp.js} +1 -1
  3. package/node_modules/@commandgarden/app/dist/client/assets/{index-DR1TjI6k.js → index-C8yqRQk-.js} +37 -37
  4. package/node_modules/@commandgarden/app/dist/client/assets/index-rHqHbsBw.css +1 -0
  5. package/node_modules/@commandgarden/app/dist/client/index.html +19 -19
  6. package/node_modules/@commandgarden/app/dist/server/journal/journal.service.d.ts +2 -0
  7. package/node_modules/@commandgarden/app/dist/server/journal/journal.service.js +54 -24
  8. package/node_modules/@commandgarden/app/dist/server/journal/journal.types.d.ts +8 -0
  9. package/node_modules/@commandgarden/app/dist/server/main.js +1 -1
  10. package/node_modules/@commandgarden/app/dist/server/routes/audit.js +27 -16
  11. package/node_modules/@commandgarden/app/dist/server/routes/config.js +8 -2
  12. package/node_modules/@commandgarden/app/dist/server/routes/connectors.js +37 -26
  13. package/node_modules/@commandgarden/app/dist/server/routes/run.js +3 -4
  14. package/node_modules/@commandgarden/app/dist/server/routes/status.js +2 -1
  15. package/node_modules/@commandgarden/app/dist/server/routes/utils.d.ts +2 -0
  16. package/node_modules/@commandgarden/app/dist/server/routes/utils.js +4 -0
  17. package/node_modules/@commandgarden/app/dist/server/store.js +53 -53
  18. package/node_modules/@commandgarden/app/package.json +42 -42
  19. package/node_modules/@commandgarden/chrome/dist/content-script.js.map +1 -1
  20. package/node_modules/@commandgarden/chrome/dist/manifest.json +26 -26
  21. package/node_modules/@commandgarden/chrome/dist/popup.html +218 -218
  22. package/node_modules/@commandgarden/chrome/dist/popup.js.map +1 -1
  23. package/node_modules/@commandgarden/chrome/dist/service-worker.js.map +1 -1
  24. package/node_modules/@commandgarden/chrome/package.json +26 -26
  25. package/node_modules/@commandgarden/daemon/connectors/ado-git-commits.eval.js +100 -100
  26. package/node_modules/@commandgarden/daemon/connectors/ado-git-commits.yaml +71 -71
  27. package/node_modules/@commandgarden/daemon/connectors/gcs-kb-content.yaml +61 -61
  28. package/node_modules/@commandgarden/daemon/connectors/gcs-kb-pages.yaml +54 -54
  29. package/node_modules/@commandgarden/daemon/connectors/jira-my-tickets.eval.js +115 -115
  30. package/node_modules/@commandgarden/daemon/connectors/jira-my-tickets.yaml +54 -54
  31. package/node_modules/@commandgarden/daemon/connectors/lib/msal-token.js +20 -20
  32. package/node_modules/@commandgarden/daemon/connectors/outlook-my-meetings.eval.js +204 -204
  33. package/node_modules/@commandgarden/daemon/connectors/outlook-my-meetings.yaml +42 -42
  34. package/node_modules/@commandgarden/daemon/connectors/saba-pending-training.eval.js +94 -94
  35. package/node_modules/@commandgarden/daemon/connectors/saba-pending-training.yaml +34 -34
  36. package/node_modules/@commandgarden/daemon/connectors/socket-security-news.yaml +63 -63
  37. package/node_modules/@commandgarden/daemon/connectors/teams-room-availability.eval.js +437 -437
  38. package/node_modules/@commandgarden/daemon/connectors/teams-room-availability.yaml +53 -53
  39. package/node_modules/@commandgarden/daemon/connectors/teams-rooms-availability.eval.js +547 -547
  40. package/node_modules/@commandgarden/daemon/connectors/teams-rooms-availability.yaml +48 -48
  41. package/node_modules/@commandgarden/daemon/connectors/timetracking-projects.eval.js +52 -52
  42. package/node_modules/@commandgarden/daemon/connectors/timetracking-projects.yaml +42 -42
  43. package/node_modules/@commandgarden/daemon/connectors/timetracking-report.eval.js +81 -81
  44. package/node_modules/@commandgarden/daemon/connectors/timetracking-report.yaml +52 -52
  45. package/node_modules/@commandgarden/daemon/connectors/tldrsec-newsletter.eval.js +27 -27
  46. package/node_modules/@commandgarden/daemon/connectors/tldrsec-newsletter.yaml +38 -38
  47. package/node_modules/@commandgarden/daemon/connectors/tokenmaster-clients-list.yaml +55 -55
  48. package/node_modules/@commandgarden/daemon/dist/audit-store.js +8 -8
  49. package/node_modules/@commandgarden/daemon/dist/auth.d.ts +1 -0
  50. package/node_modules/@commandgarden/daemon/dist/auth.d.ts.map +1 -1
  51. package/node_modules/@commandgarden/daemon/dist/auth.js +10 -0
  52. package/node_modules/@commandgarden/daemon/dist/auth.js.map +1 -1
  53. package/node_modules/@commandgarden/daemon/dist/main.js +12 -5
  54. package/node_modules/@commandgarden/daemon/dist/main.js.map +1 -1
  55. package/node_modules/@commandgarden/daemon/dist/server.d.ts.map +1 -1
  56. package/node_modules/@commandgarden/daemon/dist/server.js +10 -0
  57. package/node_modules/@commandgarden/daemon/dist/server.js.map +1 -1
  58. package/node_modules/@commandgarden/daemon/package.json +32 -32
  59. package/node_modules/@commandgarden/shared/dist/daemon-client.d.ts +5 -1
  60. package/node_modules/@commandgarden/shared/dist/daemon-client.d.ts.map +1 -1
  61. package/node_modules/@commandgarden/shared/dist/daemon-client.js +32 -14
  62. package/node_modules/@commandgarden/shared/dist/daemon-client.js.map +1 -1
  63. package/node_modules/@commandgarden/shared/package.json +32 -32
  64. package/package.json +58 -58
  65. package/node_modules/@commandgarden/app/dist/client/assets/index-CDD2bVHm.css +0 -1
  66. package/node_modules/@commandgarden/app/dist/server/daemon-client.test.js +0 -47
  67. package/node_modules/@commandgarden/app/dist/server/routes/routes.test.js +0 -137
  68. package/node_modules/@commandgarden/app/dist/server/store.test.js +0 -59
  69. package/node_modules/@commandgarden/chrome/dist/fetch-interceptor.js +0 -44
  70. package/node_modules/@commandgarden/daemon/dist/cdp-client.d.ts +0 -24
  71. package/node_modules/@commandgarden/daemon/dist/cdp-client.d.ts.map +0 -1
  72. package/node_modules/@commandgarden/daemon/dist/cdp-client.js +0 -150
  73. package/node_modules/@commandgarden/daemon/dist/cdp-client.js.map +0 -1
package/dist/main.js CHANGED
@@ -16534,9 +16534,20 @@ function readToken(tokenPath) {
16534
16534
  var DaemonClient = class {
16535
16535
  baseUrl;
16536
16536
  token;
16537
- constructor(baseUrl, token) {
16537
+ tokenPath;
16538
+ constructor(baseUrl, token, tokenPath) {
16538
16539
  this.baseUrl = baseUrl;
16539
16540
  this.token = token;
16541
+ this.tokenPath = tokenPath;
16542
+ }
16543
+ tryRefreshToken() {
16544
+ if (!this.tokenPath)
16545
+ return false;
16546
+ const fresh = readToken(this.tokenPath);
16547
+ if (!fresh || fresh === this.token)
16548
+ return false;
16549
+ this.token = fresh;
16550
+ return true;
16540
16551
  }
16541
16552
  async get(path) {
16542
16553
  return this.request("GET", path);
@@ -16558,20 +16569,20 @@ var DaemonClient = class {
16558
16569
  return data;
16559
16570
  }
16560
16571
  async pipeRaw(path) {
16561
- const resp = await this.rawFetch(path, {
16572
+ const resp = await this.fetchWithRetry(path, () => ({
16562
16573
  method: "GET",
16563
16574
  headers: this.sseHeaders()
16564
- });
16575
+ }));
16565
16576
  if (!resp.ok)
16566
16577
  throw new Error(`SSE connection failed: HTTP ${resp.status}`);
16567
16578
  return resp;
16568
16579
  }
16569
16580
  async connectSSE(path, onEvent, signal) {
16570
- const resp = await this.rawFetch(path, {
16581
+ const resp = await this.fetchWithRetry(path, () => ({
16571
16582
  method: "GET",
16572
16583
  headers: this.sseHeaders(),
16573
16584
  signal
16574
- });
16585
+ }));
16575
16586
  if (!resp.ok || !resp.body) {
16576
16587
  throw new Error(`SSE connection failed: HTTP ${resp.status}`);
16577
16588
  }
@@ -16619,18 +16630,18 @@ var DaemonClient = class {
16619
16630
  "Accept": "text/event-stream"
16620
16631
  };
16621
16632
  }
16633
+ authHeaders() {
16634
+ return {
16635
+ "Authorization": `Bearer ${this.token}`,
16636
+ "X-CommandGarden": "1",
16637
+ "Content-Type": "application/json"
16638
+ };
16639
+ }
16622
16640
  async request(method, path, body) {
16641
+ const jsonBody = body ? JSON.stringify(body) : void 0;
16623
16642
  let resp;
16624
16643
  try {
16625
- resp = await this.rawFetch(path, {
16626
- method,
16627
- headers: {
16628
- "Authorization": `Bearer ${this.token}`,
16629
- "X-CommandGarden": "1",
16630
- "Content-Type": "application/json"
16631
- },
16632
- body: body ? JSON.stringify(body) : void 0
16633
- });
16644
+ resp = await this.fetchWithRetry(path, () => ({ method, headers: this.authHeaders(), body: jsonBody }));
16634
16645
  } catch {
16635
16646
  throw new Error("Cannot connect to daemon. Is it running? Try: cg daemon start");
16636
16647
  }
@@ -16640,6 +16651,13 @@ var DaemonClient = class {
16640
16651
  }
16641
16652
  return data;
16642
16653
  }
16654
+ async fetchWithRetry(path, initFn) {
16655
+ let resp = await this.rawFetch(path, initFn());
16656
+ if (resp.status === 401 && this.tryRefreshToken()) {
16657
+ resp = await this.rawFetch(path, initFn());
16658
+ }
16659
+ return resp;
16660
+ }
16643
16661
  rawFetch(path, init) {
16644
16662
  return fetch(`${this.baseUrl}${path}`, init);
16645
16663
  }
@@ -17009,7 +17027,7 @@ function executeValidate(filePath) {
17009
17027
 
17010
17028
  // src/commands/daemon-cmd.ts
17011
17029
  import { spawn } from "child_process";
17012
- import { readFileSync as readFileSync5, writeFileSync as writeFileSync2, existsSync as existsSync3, unlinkSync as unlinkSync2, mkdirSync, openSync, closeSync } from "fs";
17030
+ import { readFileSync as readFileSync5, existsSync as existsSync3, unlinkSync as unlinkSync2, mkdirSync, openSync, closeSync } from "fs";
17013
17031
  import { join as join2 } from "path";
17014
17032
 
17015
17033
  // src/poll.ts
@@ -17089,7 +17107,6 @@ async function executeDaemonStart(baseUrl, cgHome, daemonScript) {
17089
17107
  child.on("error", () => {
17090
17108
  spawnFailed = true;
17091
17109
  });
17092
- if (child.pid) writeFileSync2(pidPath, String(child.pid));
17093
17110
  child.unref();
17094
17111
  const outcome = await pollUntilReady({
17095
17112
  checkReady: async () => {
@@ -17130,20 +17147,33 @@ function readLogTail(logPath, lines) {
17130
17147
  return "(no log available)";
17131
17148
  }
17132
17149
  }
17133
- async function executeDaemonStop(cgHome) {
17150
+ async function executeDaemonStop(cgHome, baseUrl = "http://127.0.0.1:9091") {
17134
17151
  const pidPath = join2(cgHome, "daemon.pid");
17135
- if (!existsSync3(pidPath)) {
17136
- return "Daemon is not running (no PID file found).";
17152
+ if (existsSync3(pidPath)) {
17153
+ const pid = parseInt(readFileSync5(pidPath, "utf-8").trim(), 10);
17154
+ try {
17155
+ process.kill(pid, "SIGTERM");
17156
+ unlinkSync2(pidPath);
17157
+ return `Daemon stopped (PID: ${pid}).`;
17158
+ } catch {
17159
+ unlinkSync2(pidPath);
17160
+ return `Daemon process ${pid} not found (stale PID file cleaned up).`;
17161
+ }
17137
17162
  }
17138
- const pid = parseInt(readFileSync5(pidPath, "utf-8").trim(), 10);
17139
17163
  try {
17140
- process.kill(pid, "SIGTERM");
17141
- unlinkSync2(pidPath);
17142
- return `Daemon stopped (PID: ${pid}).`;
17164
+ const tokenPath = join2(cgHome, "session-token");
17165
+ const token = existsSync3(tokenPath) ? readFileSync5(tokenPath, "utf-8").trim() : null;
17166
+ if (token) {
17167
+ const resp = await fetch(`${baseUrl}/api/shutdown`, {
17168
+ method: "POST",
17169
+ headers: { "Authorization": `Bearer ${token}`, "X-CommandGarden": "1", "Content-Type": "application/json" },
17170
+ body: JSON.stringify({ confirm: true })
17171
+ });
17172
+ if (resp.ok) return "Daemon stopped via API (PID file was missing).";
17173
+ }
17143
17174
  } catch {
17144
- unlinkSync2(pidPath);
17145
- return `Daemon process ${pid} not found (stale PID file cleaned up).`;
17146
17175
  }
17176
+ return "Daemon is not running (no PID file found).";
17147
17177
  }
17148
17178
 
17149
17179
  // src/commands/audit.ts
@@ -17294,7 +17324,7 @@ async function executeConfigSet(client, key, value) {
17294
17324
  // src/commands/gui-cmd.ts
17295
17325
  var import_yaml2 = __toESM(require_dist(), 1);
17296
17326
  import { spawn as spawn2 } from "child_process";
17297
- import { readFileSync as readFileSync7, writeFileSync as writeFileSync3, existsSync as existsSync5, unlinkSync as unlinkSync3, mkdirSync as mkdirSync2, openSync as openSync2, closeSync as closeSync2 } from "fs";
17327
+ import { readFileSync as readFileSync7, writeFileSync as writeFileSync2, existsSync as existsSync5, unlinkSync as unlinkSync3, mkdirSync as mkdirSync2, openSync as openSync2, closeSync as closeSync2 } from "fs";
17298
17328
  import { join as join3 } from "path";
17299
17329
  function readAppPort(configPath) {
17300
17330
  try {
@@ -17343,7 +17373,7 @@ async function executeGuiStart(baseUrl, cgHome, appScript, opts) {
17343
17373
  child2.on("error", () => {
17344
17374
  spawnFailed = true;
17345
17375
  });
17346
- if (child2.pid) writeFileSync3(pidPath, String(child2.pid));
17376
+ if (child2.pid) writeFileSync2(pidPath, String(child2.pid));
17347
17377
  child2.unref();
17348
17378
  if (opts.noOpen) {
17349
17379
  return { status: "started", message: `GUI started (PID: ${child2.pid ?? "unknown"}).`, pid: child2.pid };
@@ -17430,7 +17460,7 @@ function openBrowser(url, cgHome) {
17430
17460
  const logPath = join3(cgHome, "browser.log");
17431
17461
  const log = (line) => {
17432
17462
  try {
17433
- writeFileSync3(logPath, `[${(/* @__PURE__ */ new Date()).toISOString()}] ${line}
17463
+ writeFileSync2(logPath, `[${(/* @__PURE__ */ new Date()).toISOString()}] ${line}
17434
17464
  `, { flag: "a" });
17435
17465
  } catch {
17436
17466
  }
@@ -1,4 +1,4 @@
1
- import{c as h,r as l,u as y,j as e,C as f,a as k,G as b,b as w,L as g,d as v,T as j,S as N,P as S,F as A,B as M,D as L,e as T,f as E,E as I,g as C}from"./index-DR1TjI6k.js";/**
1
+ import{c as h,r as l,u as y,j as e,C as f,a as k,G as b,b as w,L as g,d as v,T as j,S as N,P as S,F as A,B as M,D as L,e as T,f as E,E as I,g as C}from"./index-C8yqRQk-.js";/**
2
2
  * @license lucide-react v1.23.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.