polyergon 0.0.0-stage → 0.1.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 (230) hide show
  1. package/.next/BUILD_ID +1 -0
  2. package/.next/app-build-manifest.json +35 -0
  3. package/.next/app-path-routes-manifest.json +1 -0
  4. package/.next/build-manifest.json +32 -0
  5. package/.next/export-marker.json +1 -0
  6. package/.next/images-manifest.json +1 -0
  7. package/.next/next-minimal-server.js.nft.json +1 -0
  8. package/.next/next-server.js.nft.json +1 -0
  9. package/.next/package.json +1 -0
  10. package/.next/prerender-manifest.json +1 -0
  11. package/.next/react-loadable-manifest.json +10 -0
  12. package/.next/required-server-files.json +1 -0
  13. package/.next/routes-manifest.json +1 -0
  14. package/.next/server/app/_not-found/page.js +1 -0
  15. package/.next/server/app/_not-found/page.js.nft.json +1 -0
  16. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -0
  17. package/.next/server/app/_not-found.html +1 -0
  18. package/.next/server/app/_not-found.meta +6 -0
  19. package/.next/server/app/_not-found.rsc +9 -0
  20. package/.next/server/app/api/automations/existing/route.js +1 -0
  21. package/.next/server/app/api/automations/existing/route.js.nft.json +1 -0
  22. package/.next/server/app/api/backends/route.js +1 -0
  23. package/.next/server/app/api/backends/route.js.nft.json +1 -0
  24. package/.next/server/app/api/limits/route.js +1 -0
  25. package/.next/server/app/api/limits/route.js.nft.json +1 -0
  26. package/.next/server/app/api/meetings/[id]/route.js +1 -0
  27. package/.next/server/app/api/meetings/[id]/route.js.nft.json +1 -0
  28. package/.next/server/app/api/meetings/[id]/slack/route.js +3 -0
  29. package/.next/server/app/api/meetings/[id]/slack/route.js.nft.json +1 -0
  30. package/.next/server/app/api/meetings/library/route.js +1 -0
  31. package/.next/server/app/api/meetings/library/route.js.nft.json +1 -0
  32. package/.next/server/app/api/meetings/route.js +1 -0
  33. package/.next/server/app/api/meetings/route.js.nft.json +1 -0
  34. package/.next/server/app/api/models/route.js +1 -0
  35. package/.next/server/app/api/models/route.js.nft.json +1 -0
  36. package/.next/server/app/api/notes/route.js +1 -0
  37. package/.next/server/app/api/notes/route.js.nft.json +1 -0
  38. package/.next/server/app/api/orgs/[id]/route.js +1 -0
  39. package/.next/server/app/api/orgs/[id]/route.js.nft.json +1 -0
  40. package/.next/server/app/api/orgs/route.js +1 -0
  41. package/.next/server/app/api/orgs/route.js.nft.json +1 -0
  42. package/.next/server/app/api/prs/inbox/route.js +1 -0
  43. package/.next/server/app/api/prs/inbox/route.js.nft.json +1 -0
  44. package/.next/server/app/api/prs/refresh/route.js +1 -0
  45. package/.next/server/app/api/prs/refresh/route.js.nft.json +1 -0
  46. package/.next/server/app/api/prs/route.js +1 -0
  47. package/.next/server/app/api/prs/route.js.nft.json +1 -0
  48. package/.next/server/app/api/session-names/route.js +1 -0
  49. package/.next/server/app/api/session-names/route.js.nft.json +1 -0
  50. package/.next/server/app/api/sessions/[id]/route.js +1 -0
  51. package/.next/server/app/api/sessions/[id]/route.js.nft.json +1 -0
  52. package/.next/server/app/api/sessions/route.js +1 -0
  53. package/.next/server/app/api/sessions/route.js.nft.json +1 -0
  54. package/.next/server/app/api/settings/auth/route.js +1 -0
  55. package/.next/server/app/api/settings/auth/route.js.nft.json +1 -0
  56. package/.next/server/app/api/settings/route.js +1 -0
  57. package/.next/server/app/api/settings/route.js.nft.json +1 -0
  58. package/.next/server/app/api/settings/transcription/route.js +1 -0
  59. package/.next/server/app/api/settings/transcription/route.js.nft.json +1 -0
  60. package/.next/server/app/api/skills/[name]/route.js +8 -0
  61. package/.next/server/app/api/skills/[name]/route.js.nft.json +1 -0
  62. package/.next/server/app/api/skills/marketplace/route.js +2 -0
  63. package/.next/server/app/api/skills/marketplace/route.js.nft.json +1 -0
  64. package/.next/server/app/api/skills/route.js +8 -0
  65. package/.next/server/app/api/skills/route.js.nft.json +1 -0
  66. package/.next/server/app/api/skills/view/route.js +8 -0
  67. package/.next/server/app/api/skills/view/route.js.nft.json +1 -0
  68. package/.next/server/app/api/slack/channels/route.js +1 -0
  69. package/.next/server/app/api/slack/channels/route.js.nft.json +1 -0
  70. package/.next/server/app/api/slack/configured/route.js +1 -0
  71. package/.next/server/app/api/slack/configured/route.js.nft.json +1 -0
  72. package/.next/server/app/api/slack/inbox/route.js +1 -0
  73. package/.next/server/app/api/slack/inbox/route.js.nft.json +1 -0
  74. package/.next/server/app/api/usage/route.js +1 -0
  75. package/.next/server/app/api/usage/route.js.nft.json +1 -0
  76. package/.next/server/app/demo/page.js +1 -0
  77. package/.next/server/app/demo/page.js.nft.json +1 -0
  78. package/.next/server/app/demo/page_client-reference-manifest.js +1 -0
  79. package/.next/server/app/demo.html +1 -0
  80. package/.next/server/app/demo.meta +6 -0
  81. package/.next/server/app/demo.rsc +7 -0
  82. package/.next/server/app/favicon.ico/route.js +12 -0
  83. package/.next/server/app/favicon.ico/route.js.nft.json +1 -0
  84. package/.next/server/app/favicon.ico.body +0 -0
  85. package/.next/server/app/favicon.ico.meta +1 -0
  86. package/.next/server/app/index.html +1 -0
  87. package/.next/server/app/index.meta +5 -0
  88. package/.next/server/app/index.rsc +7 -0
  89. package/.next/server/app/page.js +1 -0
  90. package/.next/server/app/page.js.nft.json +1 -0
  91. package/.next/server/app/page_client-reference-manifest.js +1 -0
  92. package/.next/server/app-paths-manifest.json +34 -0
  93. package/.next/server/chunks/348.js +1 -0
  94. package/.next/server/chunks/471.js +2 -0
  95. package/.next/server/chunks/590.js +7 -0
  96. package/.next/server/chunks/621.js +1 -0
  97. package/.next/server/chunks/682.js +6 -0
  98. package/.next/server/chunks/904.js +1 -0
  99. package/.next/server/chunks/948.js +2 -0
  100. package/.next/server/chunks/972.js +12 -0
  101. package/.next/server/chunks/font-manifest.json +1 -0
  102. package/.next/server/font-manifest.json +1 -0
  103. package/.next/server/functions-config-manifest.json +1 -0
  104. package/.next/server/interception-route-rewrite-manifest.js +1 -0
  105. package/.next/server/middleware-build-manifest.js +1 -0
  106. package/.next/server/middleware-manifest.json +6 -0
  107. package/.next/server/middleware-react-loadable-manifest.js +1 -0
  108. package/.next/server/next-font-manifest.js +1 -0
  109. package/.next/server/next-font-manifest.json +1 -0
  110. package/.next/server/pages/404.html +1 -0
  111. package/.next/server/pages/500.html +1 -0
  112. package/.next/server/pages/_app.js +1 -0
  113. package/.next/server/pages/_app.js.nft.json +1 -0
  114. package/.next/server/pages/_document.js +1 -0
  115. package/.next/server/pages/_document.js.nft.json +1 -0
  116. package/.next/server/pages/_error.js +1 -0
  117. package/.next/server/pages/_error.js.nft.json +1 -0
  118. package/.next/server/pages-manifest.json +1 -0
  119. package/.next/server/server-reference-manifest.js +1 -0
  120. package/.next/server/server-reference-manifest.json +1 -0
  121. package/.next/server/webpack-runtime.js +1 -0
  122. package/.next/static/chunks/117-0f4ac3c2c1871d4c.js +2 -0
  123. package/.next/static/chunks/171-f72ed164561ba218.js +1 -0
  124. package/.next/static/chunks/235.aef4cdc783360b73.js +1 -0
  125. package/.next/static/chunks/30d07d85.9045c666bb43d9e1.js +3 -0
  126. package/.next/static/chunks/app/_not-found/page-8ff6572bc7c9bc61.js +1 -0
  127. package/.next/static/chunks/app/demo/page-6711b34cd2af0e4a.js +1 -0
  128. package/.next/static/chunks/app/layout-d058836232e72324.js +1 -0
  129. package/.next/static/chunks/app/page-cebeba7d6d08548a.js +1 -0
  130. package/.next/static/chunks/fd9d1056-26bd8d656b496dba.js +1 -0
  131. package/.next/static/chunks/framework-f66176bb897dc684.js +1 -0
  132. package/.next/static/chunks/main-960df1c7509a5a8b.js +1 -0
  133. package/.next/static/chunks/main-app-4b855ea14675b961.js +1 -0
  134. package/.next/static/chunks/pages/_app-72b849fbd24ac258.js +1 -0
  135. package/.next/static/chunks/pages/_error-7ba65e1336b92748.js +1 -0
  136. package/.next/static/chunks/polyfills-42372ed130431b0a.js +1 -0
  137. package/.next/static/chunks/webpack-1f89b7cb1fca69c4.js +1 -0
  138. package/.next/static/css/a537d3e86c0f36d2.css +3 -0
  139. package/.next/static/css/ab3e4b0f5035257a.css +1 -0
  140. package/.next/static/q-HMeHYZY36qljBJhsyS6/_buildManifest.js +1 -0
  141. package/.next/static/q-HMeHYZY36qljBJhsyS6/_ssgManifest.js +1 -0
  142. package/.next/trace +22 -0
  143. package/.next/types/app/api/automations/existing/route.ts +343 -0
  144. package/.next/types/app/api/backends/route.ts +343 -0
  145. package/.next/types/app/api/limits/route.ts +343 -0
  146. package/.next/types/app/api/meetings/[id]/route.ts +343 -0
  147. package/.next/types/app/api/meetings/[id]/slack/route.ts +343 -0
  148. package/.next/types/app/api/meetings/library/route.ts +343 -0
  149. package/.next/types/app/api/meetings/route.ts +343 -0
  150. package/.next/types/app/api/models/route.ts +343 -0
  151. package/.next/types/app/api/notes/route.ts +343 -0
  152. package/.next/types/app/api/orgs/[id]/route.ts +343 -0
  153. package/.next/types/app/api/orgs/route.ts +343 -0
  154. package/.next/types/app/api/prs/inbox/route.ts +343 -0
  155. package/.next/types/app/api/prs/refresh/route.ts +343 -0
  156. package/.next/types/app/api/prs/route.ts +343 -0
  157. package/.next/types/app/api/session-names/route.ts +343 -0
  158. package/.next/types/app/api/sessions/[id]/route.ts +343 -0
  159. package/.next/types/app/api/sessions/route.ts +343 -0
  160. package/.next/types/app/api/settings/auth/route.ts +343 -0
  161. package/.next/types/app/api/settings/route.ts +343 -0
  162. package/.next/types/app/api/settings/transcription/route.ts +343 -0
  163. package/.next/types/app/api/skills/[name]/route.ts +343 -0
  164. package/.next/types/app/api/skills/marketplace/route.ts +343 -0
  165. package/.next/types/app/api/skills/route.ts +343 -0
  166. package/.next/types/app/api/skills/view/route.ts +343 -0
  167. package/.next/types/app/api/slack/channels/route.ts +343 -0
  168. package/.next/types/app/api/slack/configured/route.ts +343 -0
  169. package/.next/types/app/api/slack/inbox/route.ts +343 -0
  170. package/.next/types/app/api/usage/route.ts +343 -0
  171. package/.next/types/app/demo/page.ts +79 -0
  172. package/.next/types/app/layout.ts +79 -0
  173. package/.next/types/app/page.ts +79 -0
  174. package/.next/types/package.json +1 -0
  175. package/.server-dist/server.js +554 -0
  176. package/.server-dist/src/lib/activeOrg.js +11 -0
  177. package/.server-dist/src/lib/audioCapture.js +157 -0
  178. package/.server-dist/src/lib/backends.js +111 -0
  179. package/.server-dist/src/lib/claudeAuth.js +57 -0
  180. package/.server-dist/src/lib/configFile.js +23 -0
  181. package/.server-dist/src/lib/dataDir.js +7 -0
  182. package/.server-dist/src/lib/existingAutomations.js +132 -0
  183. package/.server-dist/src/lib/ghInbox.js +151 -0
  184. package/.server-dist/src/lib/ghPrStatus.js +86 -0
  185. package/.server-dist/src/lib/gitUtils.js +27 -0
  186. package/.server-dist/src/lib/keepAwake.js +32 -0
  187. package/.server-dist/src/lib/liveSessionStore.js +89 -0
  188. package/.server-dist/src/lib/marketplace.js +63 -0
  189. package/.server-dist/src/lib/meetingAssistant.js +138 -0
  190. package/.server-dist/src/lib/meetingConfig.js +81 -0
  191. package/.server-dist/src/lib/meetingContext.js +82 -0
  192. package/.server-dist/src/lib/meetingManager.js +246 -0
  193. package/.server-dist/src/lib/meetingStore.js +198 -0
  194. package/.server-dist/src/lib/modelCatalog.js +107 -0
  195. package/.server-dist/src/lib/notesStore.js +67 -0
  196. package/.server-dist/src/lib/orgFilter.js +19 -0
  197. package/.server-dist/src/lib/orgParam.js +15 -0
  198. package/.server-dist/src/lib/orgRegistry.js +93 -0
  199. package/.server-dist/src/lib/pipelineView.js +62 -0
  200. package/.server-dist/src/lib/pipelines.js +401 -0
  201. package/.server-dist/src/lib/planLimits.js +101 -0
  202. package/.server-dist/src/lib/prDetector.js +16 -0
  203. package/.server-dist/src/lib/prScanCache.js +144 -0
  204. package/.server-dist/src/lib/prSessionEntries.js +96 -0
  205. package/.server-dist/src/lib/prTypes.js +2 -0
  206. package/.server-dist/src/lib/ptyManager.js +428 -0
  207. package/.server-dist/src/lib/reminders.js +10 -0
  208. package/.server-dist/src/lib/requestGuard.js +29 -0
  209. package/.server-dist/src/lib/sessionNameStore.js +69 -0
  210. package/.server-dist/src/lib/sessionStore.js +215 -0
  211. package/.server-dist/src/lib/settingsStore.js +51 -0
  212. package/.server-dist/src/lib/skillsReader.js +200 -0
  213. package/.server-dist/src/lib/slackBridge.js +270 -0
  214. package/.server-dist/src/lib/slackInbox.js +96 -0
  215. package/.server-dist/src/lib/slackWatchers.js +210 -0
  216. package/.server-dist/src/lib/statusDetector.js +46 -0
  217. package/.server-dist/src/lib/transcriber.js +61 -0
  218. package/.server-dist/src/lib/usageStore.js +254 -0
  219. package/.server-dist/tsconfig.server.tsbuildinfo +1 -0
  220. package/LICENSE +21 -0
  221. package/README.md +99 -2
  222. package/bin/polyergon.js +34 -0
  223. package/next.config.mjs +4 -0
  224. package/package.json +81 -4
  225. package/public/.gitkeep +0 -0
  226. package/public/apple-touch-icon.png +0 -0
  227. package/public/icon-192.png +0 -0
  228. package/public/icon-512.png +0 -0
  229. package/public/icon.svg +1 -0
  230. package/public/manifest.webmanifest +15 -0
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.prStatusCache = void 0;
4
+ exports.isValidPrUrl = isValidPrUrl;
5
+ exports.summarizeChecks = summarizeChecks;
6
+ exports.fetchPrStatus = fetchPrStatus;
7
+ exports.fetchAllPrStatuses = fetchAllPrStatuses;
8
+ const child_process_1 = require("child_process");
9
+ const util_1 = require("util");
10
+ const prDetector_1 = require("./prDetector");
11
+ const execFileAsync = (0, util_1.promisify)(child_process_1.execFile);
12
+ const CONCURRENCY = 6;
13
+ function isValidPrUrl(url) {
14
+ return prDetector_1.STRICT_PR_URL_RE.test(url);
15
+ }
16
+ // gh's statusCheckRollup mixes CheckRun (`status`/`conclusion`) and legacy
17
+ // StatusContext (`state`) shapes — normalize defensively; treat this as
18
+ // approximate and revisit if it misclassifies real PRs.
19
+ function summarizeChecks(items) {
20
+ if (!items || items.length === 0)
21
+ return 'none';
22
+ const FAILURE_CONCLUSIONS = new Set(['FAILURE', 'CANCELLED', 'TIMED_OUT', 'STARTUP_FAILURE']);
23
+ const FAILURE_STATES = new Set(['FAILURE', 'ERROR']);
24
+ const PENDING_STATUSES = new Set(['QUEUED', 'IN_PROGRESS', 'PENDING', 'WAITING', 'REQUESTED']);
25
+ const PENDING_STATES = new Set(['PENDING']);
26
+ let sawPending = false;
27
+ for (const item of items) {
28
+ if (item.conclusion && FAILURE_CONCLUSIONS.has(item.conclusion))
29
+ return 'failing';
30
+ if (item.state && FAILURE_STATES.has(item.state))
31
+ return 'failing';
32
+ if (item.status && PENDING_STATUSES.has(item.status) && !item.conclusion)
33
+ sawPending = true;
34
+ if (item.state && PENDING_STATES.has(item.state))
35
+ sawPending = true;
36
+ }
37
+ return sawPending ? 'pending' : 'passing';
38
+ }
39
+ // In-memory only — volatile data, cheap to refetch, intentionally lost on
40
+ // server restart. Populated only by explicit refresh calls (no background
41
+ // polling in this MVP).
42
+ exports.prStatusCache = new Map();
43
+ async function fetchPrStatus(url) {
44
+ var _a, _b;
45
+ if (!isValidPrUrl(url))
46
+ return null;
47
+ try {
48
+ const { stdout } = await execFileAsync('gh', [
49
+ 'pr', 'view', url,
50
+ '--json', 'state,reviewDecision,statusCheckRollup,number,title,updatedAt',
51
+ ], {
52
+ timeout: 8000,
53
+ env: Object.assign(Object.assign({}, process.env), (process.env.GITHUB_TOKEN ? { GITHUB_TOKEN: process.env.GITHUB_TOKEN } : {})),
54
+ });
55
+ const json = JSON.parse(stdout);
56
+ const updatedAt = json.updatedAt ? Date.parse(json.updatedAt) : NaN;
57
+ const status = {
58
+ number: json.number,
59
+ title: json.title,
60
+ state: json.state,
61
+ reviewDecision: (_a = json.reviewDecision) !== null && _a !== void 0 ? _a : null,
62
+ checks: summarizeChecks((_b = json.statusCheckRollup) !== null && _b !== void 0 ? _b : []),
63
+ updatedAt: Number.isNaN(updatedAt) ? null : updatedAt,
64
+ fetchedAt: Date.now(),
65
+ };
66
+ exports.prStatusCache.set(url, status);
67
+ return status;
68
+ }
69
+ catch (_c) {
70
+ return null;
71
+ }
72
+ }
73
+ // Concurrency-capped so one hung `gh` call can't block the rest.
74
+ async function fetchAllPrStatuses(urls) {
75
+ const unique = Array.from(new Set(urls));
76
+ const results = new Map();
77
+ for (let i = 0; i < unique.length; i += CONCURRENCY) {
78
+ const batch = unique.slice(i, i + CONCURRENCY);
79
+ const settled = await Promise.allSettled(batch.map(url => fetchPrStatus(url)));
80
+ settled.forEach((r, idx) => {
81
+ if (r.status === 'fulfilled' && r.value)
82
+ results.set(batch[idx], r.value);
83
+ });
84
+ }
85
+ return results;
86
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getGitRoot = getGitRoot;
4
+ const child_process_1 = require("child_process");
5
+ const cache = new Map();
6
+ function getGitRoot(dir) {
7
+ if (!dir)
8
+ return null;
9
+ // ~/General/<hash> chat scratch dirs are never repos — skip the synchronous
10
+ // git spawn (hundreds of them made /api/sessions block for ~40s).
11
+ if (/\/General(\/[^/]+)?$/.test(dir))
12
+ return null;
13
+ if (cache.has(dir))
14
+ return cache.get(dir);
15
+ try {
16
+ const root = (0, child_process_1.execSync)(`git -C "${dir}" rev-parse --show-toplevel`, {
17
+ stdio: ['pipe', 'pipe', 'pipe'],
18
+ timeout: 3000,
19
+ }).toString().trim();
20
+ cache.set(dir, root);
21
+ return root;
22
+ }
23
+ catch (_a) {
24
+ cache.set(dir, null);
25
+ return null;
26
+ }
27
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.keepAwake = void 0;
4
+ const child_process_1 = require("child_process");
5
+ const settingsStore_1 = require("./settingsStore");
6
+ // Settings → "Keep Mac awake": runs `caffeinate -i` (no idle sleep; the screen can still
7
+ // lock and turn off) for as long as the server runs. Settings are saved by an API route
8
+ // (separate module copy), so re-read them every 15s.
9
+ // ponytail: macOS only; closing the lid still sleeps (needs sudo pmset, which we don't do).
10
+ class KeepAwake {
11
+ constructor() {
12
+ this.proc = null;
13
+ }
14
+ start() {
15
+ if (process.platform !== 'darwin')
16
+ return;
17
+ this.apply();
18
+ setInterval(() => this.apply(), 15000).unref();
19
+ }
20
+ apply() {
21
+ const want = (0, settingsStore_1.getSettings)().power.keepAwake;
22
+ if (want && !this.proc) {
23
+ this.proc = (0, child_process_1.spawn)('caffeinate', ['-i', '-w', String(process.pid)], { stdio: 'ignore' });
24
+ this.proc.on('exit', () => { this.proc = null; });
25
+ }
26
+ else if (!want && this.proc) {
27
+ this.proc.kill();
28
+ this.proc = null;
29
+ }
30
+ }
31
+ }
32
+ exports.keepAwake = new KeepAwake();
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ var _a;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.liveSessionStore = exports.LiveSessionStore = void 0;
5
+ const dataDir_1 = require("./dataDir");
6
+ const fs_1 = require("fs");
7
+ const path_1 = require("path");
8
+ const DEFAULT_PERSIST_DIR = dataDir_1.DATA_DIR;
9
+ const DEFAULT_PERSIST_FILE = (0, path_1.join)(DEFAULT_PERSIST_DIR, 'live-sessions.json');
10
+ class LiveSessionStore {
11
+ // persistFile defaults to the real on-disk location; tests must pass an
12
+ // isolated path so they never touch the user's actual session state.
13
+ constructor(persistFile = DEFAULT_PERSIST_FILE) {
14
+ this.sessions = new Map();
15
+ this.persistFile = persistFile;
16
+ this.persistDir = (0, path_1.join)(persistFile, '..');
17
+ }
18
+ add(session) {
19
+ this.sessions.set(session.id, session);
20
+ this.persist();
21
+ }
22
+ get(id) {
23
+ return this.sessions.get(id);
24
+ }
25
+ list() {
26
+ return Array.from(this.sessions.values());
27
+ }
28
+ setStatus(id, status) {
29
+ const s = this.sessions.get(id);
30
+ if (s)
31
+ s.status = status;
32
+ }
33
+ setClaudeSessionId(id, claudeSessionId) {
34
+ const s = this.sessions.get(id);
35
+ if (s) {
36
+ s.claudeSessionId = claudeSessionId;
37
+ this.persist();
38
+ }
39
+ }
40
+ setRcUrl(id, rcUrl) {
41
+ const s = this.sessions.get(id);
42
+ if (s)
43
+ s.rcUrl = rcUrl;
44
+ }
45
+ setPrUrl(id, prUrl) {
46
+ const s = this.sessions.get(id);
47
+ if (s && s.prUrl !== prUrl) {
48
+ s.prUrl = prUrl;
49
+ this.persist();
50
+ }
51
+ }
52
+ remove(id) {
53
+ this.sessions.delete(id);
54
+ this.persist();
55
+ }
56
+ persist() {
57
+ try {
58
+ if (!(0, fs_1.existsSync)(this.persistDir))
59
+ (0, fs_1.mkdirSync)(this.persistDir, { recursive: true });
60
+ const saved = Array.from(this.sessions.values()).map(s => ({
61
+ id: s.id, cwd: s.cwd, gitRoot: s.gitRoot, claudeSessionId: s.claudeSessionId, createdAt: s.createdAt, prUrl: s.prUrl, orgId: s.orgId, backend: s.backend, model: s.model, rc: s.rc,
62
+ }));
63
+ (0, fs_1.writeFileSync)(this.persistFile, JSON.stringify(saved));
64
+ }
65
+ catch (_a) { }
66
+ }
67
+ // Keeps the last 5 boot-time copies so a bad restore is recoverable.
68
+ static backupSaved(persistFile = DEFAULT_PERSIST_FILE) {
69
+ try {
70
+ if (!(0, fs_1.existsSync)(persistFile))
71
+ return;
72
+ const dir = (0, path_1.dirname)(persistFile);
73
+ (0, fs_1.copyFileSync)(persistFile, (0, path_1.join)(dir, `live-sessions.boot-${Date.now()}.json`));
74
+ (0, fs_1.readdirSync)(dir).filter(f => f.startsWith('live-sessions.boot-')).sort().slice(0, -5)
75
+ .forEach(f => (0, fs_1.unlinkSync)((0, path_1.join)(dir, f)));
76
+ }
77
+ catch (_a) { }
78
+ }
79
+ static loadSaved(persistFile = DEFAULT_PERSIST_FILE) {
80
+ try {
81
+ return JSON.parse((0, fs_1.readFileSync)(persistFile, 'utf-8'));
82
+ }
83
+ catch (_a) {
84
+ return [];
85
+ }
86
+ }
87
+ }
88
+ exports.LiveSessionStore = LiveSessionStore;
89
+ exports.liveSessionStore = (_a = global.__liveSessionStore) !== null && _a !== void 0 ? _a : (global.__liveSessionStore = new LiveSessionStore());
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.listMarketplacePlugins = listMarketplacePlugins;
4
+ exports.installPlugin = installPlugin;
5
+ const fs_1 = require("fs");
6
+ const path_1 = require("path");
7
+ const child_process_1 = require("child_process");
8
+ const util_1 = require("util");
9
+ const execFileAsync = (0, util_1.promisify)(child_process_1.execFile);
10
+ const pluginsDir = (configDir) => (0, path_1.join)(configDir || (0, path_1.join)(process.env.HOME, '.claude'), 'plugins');
11
+ const SAFE = /^[\w.-]{1,100}$/;
12
+ function installedIds(configDir) {
13
+ var _a;
14
+ try {
15
+ const d = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(pluginsDir(configDir), 'installed_plugins.json'), 'utf-8'));
16
+ return new Set(Object.keys((_a = d.plugins) !== null && _a !== void 0 ? _a : d));
17
+ }
18
+ catch (_b) {
19
+ return new Set();
20
+ }
21
+ }
22
+ function listMarketplacePlugins(configDir) {
23
+ var _a, _b, _c;
24
+ const installed = installedIds(configDir);
25
+ const out = [];
26
+ let markets = [];
27
+ try {
28
+ markets = (0, fs_1.readdirSync)((0, path_1.join)(pluginsDir(configDir), 'marketplaces'));
29
+ }
30
+ catch (_d) {
31
+ return [];
32
+ }
33
+ for (const m of markets) {
34
+ try {
35
+ const d = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(pluginsDir(configDir), 'marketplaces', m, '.claude-plugin', 'marketplace.json'), 'utf-8'));
36
+ const market = typeof d.name === 'string' ? d.name : m;
37
+ for (const p of (_a = d.plugins) !== null && _a !== void 0 ? _a : []) {
38
+ if (typeof (p === null || p === void 0 ? void 0 : p.name) !== 'string')
39
+ continue;
40
+ out.push({ name: p.name, marketplace: market, description: String((_b = p.description) !== null && _b !== void 0 ? _b : ''), category: (_c = p.category) !== null && _c !== void 0 ? _c : null, installed: installed.has(`${p.name}@${market}`) });
41
+ }
42
+ }
43
+ catch ( /* unreadable marketplace */_e) { /* unreadable marketplace */ }
44
+ }
45
+ return out.sort((a, b) => Number(b.installed) - Number(a.installed) || a.name.localeCompare(b.name));
46
+ }
47
+ // Installs for the user (all projects). Plugins that need a marketplace-declared
48
+ // command to be accepted are refused here; the error says to install in a terminal.
49
+ async function installPlugin(name, marketplace, configDir) {
50
+ var _a, _b, _c, _d;
51
+ if (!SAFE.test(name) || !SAFE.test(marketplace))
52
+ throw new Error('Invalid plugin name');
53
+ try {
54
+ await execFileAsync('claude', ['plugin', 'install', `${name}@${marketplace}`, '--scope', 'user', '--json'], { timeout: 180000, maxBuffer: 5 * 1024 * 1024, env: Object.assign(Object.assign({}, process.env), (configDir ? { CLAUDE_CONFIG_DIR: configDir } : {})) });
55
+ }
56
+ catch (e) {
57
+ const err = e;
58
+ const text = `${(_a = err.stdout) !== null && _a !== void 0 ? _a : ''}\n${(_b = err.stderr) !== null && _b !== void 0 ? _b : ''}`.trim() || err.message;
59
+ throw new Error(/shownCommand|accept-command/.test(text)
60
+ ? `This plugin runs a setup command that needs your approval. Install it in a terminal: claude plugin install ${name}@${marketplace}`
61
+ : (_d = (_c = text.split('\n').filter(Boolean).at(-1)) === null || _c === void 0 ? void 0 : _c.slice(0, 300)) !== null && _d !== void 0 ? _d : 'Install failed');
62
+ }
63
+ }
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MeetingAssistant = void 0;
4
+ exports.runClaude = runClaude;
5
+ exports.parseNotesTick = parseNotesTick;
6
+ const child_process_1 = require("child_process");
7
+ const claudeAuth_1 = require("./claudeAuth");
8
+ const CALL_TIMEOUT_MS = 180000;
9
+ // One headless `claude -p` call (optionally resuming a conversation). Runs with
10
+ // permission prompts off so it can use web/file tools and MCP connectors.
11
+ // forkSession: resume a COPY of the conversation (new id); the original is untouched.
12
+ function runClaude(prompt, opts) {
13
+ return new Promise((resolve, reject) => {
14
+ var _a;
15
+ const args = [
16
+ '-p', '--output-format', 'json',
17
+ '--permission-mode', 'bypassPermissions',
18
+ ...(opts.model ? ['--model', opts.model] : []),
19
+ ...(opts.resumeId ? ['--resume', opts.resumeId, ...(opts.forkSession ? ['--fork-session'] : [])] : []),
20
+ ];
21
+ const env = Object.assign(Object.assign(Object.assign(Object.assign({}, Object.fromEntries(['PATH', 'HOME', 'USER', 'LOGNAME', 'SHELL', 'TERM', 'LANG', 'LC_ALL']
22
+ .filter(k => process.env[k])
23
+ .map(k => [k, process.env[k]]))), (0, claudeAuth_1.claudeAuthEnv)()), (opts.configDir ? { CLAUDE_CONFIG_DIR: opts.configDir } : {})), opts.extraEnv);
24
+ const proc = (0, child_process_1.spawn)('claude', args, { cwd: opts.cwd, env });
25
+ let stdout = '';
26
+ let stderr = '';
27
+ proc.stdout.on('data', (d) => { stdout += d.toString(); });
28
+ proc.stderr.on('data', (d) => { stderr = (stderr + d.toString()).slice(-1000); });
29
+ const killer = setTimeout(() => proc.kill('SIGKILL'), (_a = opts.timeoutMs) !== null && _a !== void 0 ? _a : CALL_TIMEOUT_MS);
30
+ proc.on('error', (e) => { clearTimeout(killer); reject(e); });
31
+ proc.on('exit', (code) => {
32
+ var _a, _b;
33
+ clearTimeout(killer);
34
+ if (code !== 0) {
35
+ reject(new Error(code === null ? 'Claude took too long and was stopped' : `claude -p exited ${code}: ${stderr.trim().slice(-300)}`));
36
+ return;
37
+ }
38
+ try {
39
+ const parsed = JSON.parse(stdout);
40
+ resolve({ result: (_a = parsed.result) !== null && _a !== void 0 ? _a : '', sessionId: (_b = parsed.session_id) !== null && _b !== void 0 ? _b : null });
41
+ }
42
+ catch (_c) {
43
+ reject(new Error(`unparseable claude output: ${stdout.slice(0, 200)}`));
44
+ }
45
+ });
46
+ proc.stdin.write(prompt);
47
+ proc.stdin.end();
48
+ });
49
+ }
50
+ const PREAMBLE = `You are a live meeting assistant. You receive transcript excerpts from an ongoing meeting as they happen (transcribed from audio — expect some transcription errors, and possibly mixed Hebrew/English). Your job across this conversation:
51
+ - Maintain structured meeting notes (topics discussed, decisions made, action items with owners when identifiable).
52
+ - Answer questions the user asks mid-meeting, concisely — they're in the meeting and need fast answers.
53
+ - Occasionally offer ONE genuinely useful proactive suggestion (an answer to a question someone raised, a factual correction, relevant context). Most updates need no suggestion — only include one when it truly helps.
54
+ Never invent transcript content. If the transcript is too sparse to conclude something, leave it out.`;
55
+ // One persistent headless Claude conversation (claude -p / --resume) per
56
+ // meeting, under the meeting org's config dir + model. Calls are serialized —
57
+ // notes ticks, asks and the summary share one conversation and must not race.
58
+ class MeetingAssistant {
59
+ constructor(opts, existingSessionId = null) {
60
+ this.queue = Promise.resolve();
61
+ this.onSessionId = null;
62
+ this.opts = opts;
63
+ this.sessionId = existingSessionId;
64
+ }
65
+ // Exposed so the manager can persist it and survive server restarts
66
+ getSessionId() {
67
+ return this.sessionId;
68
+ }
69
+ enqueue(fn) {
70
+ const run = this.queue.then(fn, fn);
71
+ this.queue = run.catch(() => { });
72
+ return run;
73
+ }
74
+ async call(prompt) {
75
+ var _a;
76
+ const { result, sessionId } = await runClaude(prompt, Object.assign(Object.assign({}, this.opts), { resumeId: this.sessionId }));
77
+ if (sessionId) {
78
+ this.sessionId = sessionId;
79
+ (_a = this.onSessionId) === null || _a === void 0 ? void 0 : _a.call(this, sessionId);
80
+ }
81
+ return result;
82
+ }
83
+ withPreamble(body) {
84
+ // The preamble only needs to be sent once; --resume keeps the context
85
+ return this.sessionId ? body : `${PREAMBLE}\n\n${body}`;
86
+ }
87
+ notesTick(transcriptDelta) {
88
+ return this.enqueue(async () => {
89
+ const prompt = this.withPreamble(`New transcript since the last update:\n---\n${transcriptDelta}\n---\n` +
90
+ `Update your running notes for the whole meeting so far. Respond with ONLY a JSON object, no prose, no markdown fences:\n` +
91
+ `{"notes": {"topics": string[], "decisions": string[], "actionItems": string[]}, "suggestion": string | null}`);
92
+ const raw = await this.call(prompt);
93
+ return parseNotesTick(raw);
94
+ });
95
+ }
96
+ ask(question, transcriptDelta) {
97
+ return this.enqueue(() => this.call(this.withPreamble((transcriptDelta ? `New transcript since the last update:\n---\n${transcriptDelta}\n---\n` : '') +
98
+ `The user asks (mid-meeting, answer concisely and directly): ${question}`)));
99
+ }
100
+ // Background material for the rest of the meeting. Returns the assistant's
101
+ // one-line read of it; a line starting with FAILED means it couldn't load it.
102
+ addContext(label, body, fetch) {
103
+ return this.enqueue(() => this.call(this.withPreamble(fetch
104
+ ? `The user added a source as background context for this meeting: ${body}\n` +
105
+ `Load it now with your tools (web fetch, file read, or the matching MCP connector such as Slack, Notion, Google Drive or Gmail). ` +
106
+ `Keep what you learn in mind for notes, answers and suggestions for the rest of the meeting. ` +
107
+ `Reply with ONE short line saying what it is about, or "FAILED: <reason>" if you cannot load it.`
108
+ : `The user added background context for this meeting (${label}):\n---\n${body}\n---\n` +
109
+ `Keep it in mind for notes, answers and suggestions for the rest of the meeting. Reply with ONE short line saying what it is about.`)));
110
+ }
111
+ summarize(transcriptDelta) {
112
+ return this.enqueue(() => this.call(this.withPreamble((transcriptDelta ? `Final transcript segment:\n---\n${transcriptDelta}\n---\n` : '') +
113
+ `The meeting has ended. Write a markdown recap of the ENTIRE meeting with sections: ## Summary (a few sentences), ## Decisions (bullets), ## Action Items (bullets with owners where known). Respond with only the markdown.`)));
114
+ }
115
+ }
116
+ exports.MeetingAssistant = MeetingAssistant;
117
+ // Tolerates fenced or prose-wrapped JSON — extracts the outermost object
118
+ function parseNotesTick(raw) {
119
+ const start = raw.indexOf('{');
120
+ const end = raw.lastIndexOf('}');
121
+ if (start === -1 || end <= start)
122
+ return { notes: null, suggestion: null };
123
+ try {
124
+ const obj = JSON.parse(raw.slice(start, end + 1));
125
+ const n = obj.notes;
126
+ const notes = n && typeof n === 'object'
127
+ ? {
128
+ topics: Array.isArray(n.topics) ? n.topics.filter((x) => typeof x === 'string') : [],
129
+ decisions: Array.isArray(n.decisions) ? n.decisions.filter((x) => typeof x === 'string') : [],
130
+ actionItems: Array.isArray(n.actionItems) ? n.actionItems.filter((x) => typeof x === 'string') : [],
131
+ }
132
+ : null;
133
+ return { notes, suggestion: typeof obj.suggestion === 'string' && obj.suggestion.trim() ? obj.suggestion.trim() : null };
134
+ }
135
+ catch (_a) {
136
+ return { notes: null, suggestion: null };
137
+ }
138
+ }
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getTranscriptionConfig = getTranscriptionConfig;
4
+ exports.getTranscriptionStatus = getTranscriptionStatus;
5
+ exports.saveTranscriptionConfig = saveTranscriptionConfig;
6
+ exports.getAudioDevices = getAudioDevices;
7
+ const configFile_1 = require("./configFile");
8
+ // Azure (AI Foundry deployment) takes precedence when configured; plain
9
+ // OpenAI key works as before.
10
+ function getTranscriptionConfig(file = configFile_1.CONFIG_FILE) {
11
+ const cfg = (0, configFile_1.readConfig)(file);
12
+ const { azureEndpoint, azureApiKey, azureDeployment } = cfg;
13
+ if (typeof azureEndpoint === 'string' && azureEndpoint && typeof azureApiKey === 'string' && azureApiKey) {
14
+ return {
15
+ kind: 'azure',
16
+ endpoint: azureEndpoint.replace(/\/+$/, ''),
17
+ apiKey: azureApiKey,
18
+ deployment: typeof azureDeployment === 'string' && azureDeployment ? azureDeployment : 'gpt-4o-transcribe',
19
+ };
20
+ }
21
+ const key = process.env.OPENAI_API_KEY || cfg.openaiApiKey;
22
+ if (typeof key === 'string' && key)
23
+ return { kind: 'openai', apiKey: key };
24
+ return null;
25
+ }
26
+ function getTranscriptionStatus(file = configFile_1.CONFIG_FILE) {
27
+ const c = getTranscriptionConfig(file);
28
+ const hint = (k) => '…' + k.slice(-4);
29
+ if (!c)
30
+ return { provider: null, keyHint: null, fromEnv: false, endpoint: null, deployment: null };
31
+ if (c.kind === 'azure')
32
+ return { provider: 'azure', keyHint: hint(c.apiKey), fromEnv: false, endpoint: c.endpoint, deployment: c.deployment };
33
+ return { provider: 'openai', keyHint: hint(c.apiKey), fromEnv: !(0, configFile_1.readConfig)(file).openaiApiKey, endpoint: null, deployment: null };
34
+ }
35
+ // Saves provider settings into config.json (0600, other keys kept). An empty
36
+ // apiKey keeps the saved one, so the UI never needs to know it.
37
+ function saveTranscriptionConfig(input, file = configFile_1.CONFIG_FILE) {
38
+ const cfg = (0, configFile_1.readConfig)(file);
39
+ const str = (v) => (typeof v === 'string' ? v.trim() : '');
40
+ if (input.provider === 'none') {
41
+ for (const k of ['azureEndpoint', 'azureApiKey', 'azureDeployment', 'openaiApiKey'])
42
+ delete cfg[k];
43
+ }
44
+ else if (input.provider === 'openai') {
45
+ const key = str(input.apiKey) || str(cfg.openaiApiKey);
46
+ if (!key)
47
+ throw new Error('API key is required');
48
+ for (const k of ['azureEndpoint', 'azureApiKey', 'azureDeployment'])
49
+ delete cfg[k];
50
+ cfg.openaiApiKey = key;
51
+ }
52
+ else if (input.provider === 'azure') {
53
+ const endpoint = str(input.endpoint);
54
+ let url;
55
+ try {
56
+ url = new URL(endpoint);
57
+ }
58
+ catch (_a) {
59
+ throw new Error('Endpoint must be a URL');
60
+ }
61
+ if (url.protocol !== 'https:')
62
+ throw new Error('Endpoint must use https');
63
+ const key = str(input.apiKey) || str(cfg.azureApiKey);
64
+ if (!key)
65
+ throw new Error('API key is required');
66
+ delete cfg.openaiApiKey;
67
+ Object.assign(cfg, { azureEndpoint: endpoint, azureApiKey: key, azureDeployment: str(input.deployment) || 'gpt-4o-transcribe' });
68
+ }
69
+ else {
70
+ throw new Error('Unknown provider');
71
+ }
72
+ (0, configFile_1.writeConfig)(cfg, file);
73
+ return getTranscriptionStatus(file);
74
+ }
75
+ function getAudioDevices() {
76
+ const cfg = (0, configFile_1.readConfig)();
77
+ return {
78
+ system: typeof cfg.systemAudioDevice === 'string' && cfg.systemAudioDevice ? cfg.systemAudioDevice : 'BlackHole 2ch',
79
+ mic: typeof cfg.micDevice === 'string' && cfg.micDevice ? cfg.micDevice : 'MacBook Pro Microphone',
80
+ };
81
+ }
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MAX_CONTEXT_CHARS = void 0;
4
+ exports.resolveContext = resolveContext;
5
+ const path_1 = require("path");
6
+ const fs_1 = require("fs");
7
+ const meetingStore_1 = require("./meetingStore");
8
+ const liveSessionStore_1 = require("./liveSessionStore");
9
+ const orgRegistry_1 = require("./orgRegistry");
10
+ const sessionNameStore_1 = require("./sessionNameStore");
11
+ const sessionStore_1 = require("./sessionStore");
12
+ const ptyManager_1 = require("./ptyManager");
13
+ // ponytail: hard cap per item; summarize long sources first if this proves too small.
14
+ exports.MAX_CONTEXT_CHARS = 40000;
15
+ const clip = (s) => (s.length > exports.MAX_CONTEXT_CHARS ? '…' + s.slice(-exports.MAX_CONTEXT_CHARS) : s);
16
+ // Turns what the user picked into text (or a reference) for the assistant.
17
+ const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
18
+ // Finds <id>.jsonl under any org's projects root (ids are UUIDs, so no path tricks).
19
+ function findTranscript(id) {
20
+ for (const { root } of orgRegistry_1.orgRegistry.projectRoots()) {
21
+ let dirs;
22
+ try {
23
+ dirs = (0, fs_1.readdirSync)(root);
24
+ }
25
+ catch (_a) {
26
+ continue;
27
+ }
28
+ for (const d of dirs) {
29
+ const f = (0, path_1.join)(root, d, `${id}.jsonl`);
30
+ if ((0, fs_1.existsSync)(f))
31
+ return f;
32
+ }
33
+ }
34
+ return null;
35
+ }
36
+ async function resolveContext(kind, value) {
37
+ var _a, _b, _c, _d, _e, _f;
38
+ const v = value.trim();
39
+ if (!v)
40
+ throw new Error('Nothing to add');
41
+ if (kind === 'text')
42
+ return { label: v.split('\n')[0].slice(0, 60), body: clip(v), fetch: false };
43
+ if (kind === 'link')
44
+ return { label: v.slice(0, 80), body: v, fetch: true };
45
+ if (kind === 'slack') {
46
+ const channel = v.startsWith('http') ? v : '#' + v.replace(/^#/, '');
47
+ return { label: `Slack: ${channel}`, body: `the Slack channel ${channel}. Use the Slack connector to read its messages from the last 7 days, including thread replies that matter`, fetch: true };
48
+ }
49
+ if (kind === 'meeting') {
50
+ const m = meetingStore_1.meetingStore.get(v);
51
+ if (!m)
52
+ throw new Error('Meeting not found');
53
+ const notes = meetingStore_1.meetingStore.readNotes(v);
54
+ const summary = meetingStore_1.meetingStore.readSummary(v);
55
+ const parts = [`Past meeting "${m.title}" on ${new Date(m.startedAt).toLocaleString()}`];
56
+ if (summary)
57
+ parts.push(summary);
58
+ else if (notes)
59
+ parts.push(`Decisions:\n- ${notes.decisions.join('\n- ')}\nAction items:\n- ${notes.actionItems.join('\n- ')}`);
60
+ else
61
+ parts.push(meetingStore_1.meetingStore.readTranscript(v).map(s => s.text).join('\n'));
62
+ return { label: `Meeting: ${m.title}`, body: clip(parts.join('\n\n')), fetch: false };
63
+ }
64
+ if (kind === 'session') {
65
+ // A live card id, or a Claude session id from History
66
+ const s = liveSessionStore_1.liveSessionStore.get(v);
67
+ const claudeId = (_a = s === null || s === void 0 ? void 0 : s.claudeSessionId) !== null && _a !== void 0 ? _a : (UUID.test(v) ? v : null);
68
+ const file = (s === null || s === void 0 ? void 0 : s.claudeSessionId)
69
+ ? (0, path_1.join)((0, ptyManager_1.claudeProjectDir)(s.cwd, (_b = orgRegistry_1.orgRegistry.get(s.orgId)) === null || _b === void 0 ? void 0 : _b.configDir), `${s.claudeSessionId}.jsonl`)
70
+ : claudeId ? findTranscript(claudeId) : null;
71
+ if (!claudeId || !file || !(0, fs_1.existsSync)(file))
72
+ throw new Error('Session not found or has no Claude transcript yet');
73
+ const msgs = await (0, sessionStore_1.getSessionMessages)(file, 40);
74
+ if (msgs.length === 0)
75
+ throw new Error('Session transcript is empty');
76
+ const names = sessionNameStore_1.sessionNameStore.all();
77
+ const name = (_f = (_d = (_c = (s && names[s.id])) !== null && _c !== void 0 ? _c : names[claudeId]) !== null && _d !== void 0 ? _d : (_e = (0, sessionStore_1.firstUserMessageSync)(file)) === null || _e === void 0 ? void 0 : _e.slice(0, 60)) !== null && _f !== void 0 ? _f : claudeId;
78
+ const text = msgs.map(m => `${m.role === 'user' ? 'User' : 'Claude'}: ${m.content}`).join('\n\n');
79
+ return { label: `Session: ${name}`, body: clip(`Claude Code session${s ? ` in ${s.cwd}` : ''}\n\n${text}`), fetch: false };
80
+ }
81
+ throw new Error('Unknown context type');
82
+ }