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.
- package/.next/BUILD_ID +1 -0
- package/.next/app-build-manifest.json +35 -0
- package/.next/app-path-routes-manifest.json +1 -0
- package/.next/build-manifest.json +32 -0
- package/.next/export-marker.json +1 -0
- package/.next/images-manifest.json +1 -0
- package/.next/next-minimal-server.js.nft.json +1 -0
- package/.next/next-server.js.nft.json +1 -0
- package/.next/package.json +1 -0
- package/.next/prerender-manifest.json +1 -0
- package/.next/react-loadable-manifest.json +10 -0
- package/.next/required-server-files.json +1 -0
- package/.next/routes-manifest.json +1 -0
- package/.next/server/app/_not-found/page.js +1 -0
- package/.next/server/app/_not-found/page.js.nft.json +1 -0
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -0
- package/.next/server/app/_not-found.html +1 -0
- package/.next/server/app/_not-found.meta +6 -0
- package/.next/server/app/_not-found.rsc +9 -0
- package/.next/server/app/api/automations/existing/route.js +1 -0
- package/.next/server/app/api/automations/existing/route.js.nft.json +1 -0
- package/.next/server/app/api/backends/route.js +1 -0
- package/.next/server/app/api/backends/route.js.nft.json +1 -0
- package/.next/server/app/api/limits/route.js +1 -0
- package/.next/server/app/api/limits/route.js.nft.json +1 -0
- package/.next/server/app/api/meetings/[id]/route.js +1 -0
- package/.next/server/app/api/meetings/[id]/route.js.nft.json +1 -0
- package/.next/server/app/api/meetings/[id]/slack/route.js +3 -0
- package/.next/server/app/api/meetings/[id]/slack/route.js.nft.json +1 -0
- package/.next/server/app/api/meetings/library/route.js +1 -0
- package/.next/server/app/api/meetings/library/route.js.nft.json +1 -0
- package/.next/server/app/api/meetings/route.js +1 -0
- package/.next/server/app/api/meetings/route.js.nft.json +1 -0
- package/.next/server/app/api/models/route.js +1 -0
- package/.next/server/app/api/models/route.js.nft.json +1 -0
- package/.next/server/app/api/notes/route.js +1 -0
- package/.next/server/app/api/notes/route.js.nft.json +1 -0
- package/.next/server/app/api/orgs/[id]/route.js +1 -0
- package/.next/server/app/api/orgs/[id]/route.js.nft.json +1 -0
- package/.next/server/app/api/orgs/route.js +1 -0
- package/.next/server/app/api/orgs/route.js.nft.json +1 -0
- package/.next/server/app/api/prs/inbox/route.js +1 -0
- package/.next/server/app/api/prs/inbox/route.js.nft.json +1 -0
- package/.next/server/app/api/prs/refresh/route.js +1 -0
- package/.next/server/app/api/prs/refresh/route.js.nft.json +1 -0
- package/.next/server/app/api/prs/route.js +1 -0
- package/.next/server/app/api/prs/route.js.nft.json +1 -0
- package/.next/server/app/api/session-names/route.js +1 -0
- package/.next/server/app/api/session-names/route.js.nft.json +1 -0
- package/.next/server/app/api/sessions/[id]/route.js +1 -0
- package/.next/server/app/api/sessions/[id]/route.js.nft.json +1 -0
- package/.next/server/app/api/sessions/route.js +1 -0
- package/.next/server/app/api/sessions/route.js.nft.json +1 -0
- package/.next/server/app/api/settings/auth/route.js +1 -0
- package/.next/server/app/api/settings/auth/route.js.nft.json +1 -0
- package/.next/server/app/api/settings/route.js +1 -0
- package/.next/server/app/api/settings/route.js.nft.json +1 -0
- package/.next/server/app/api/settings/transcription/route.js +1 -0
- package/.next/server/app/api/settings/transcription/route.js.nft.json +1 -0
- package/.next/server/app/api/skills/[name]/route.js +8 -0
- package/.next/server/app/api/skills/[name]/route.js.nft.json +1 -0
- package/.next/server/app/api/skills/marketplace/route.js +2 -0
- package/.next/server/app/api/skills/marketplace/route.js.nft.json +1 -0
- package/.next/server/app/api/skills/route.js +8 -0
- package/.next/server/app/api/skills/route.js.nft.json +1 -0
- package/.next/server/app/api/skills/view/route.js +8 -0
- package/.next/server/app/api/skills/view/route.js.nft.json +1 -0
- package/.next/server/app/api/slack/channels/route.js +1 -0
- package/.next/server/app/api/slack/channels/route.js.nft.json +1 -0
- package/.next/server/app/api/slack/configured/route.js +1 -0
- package/.next/server/app/api/slack/configured/route.js.nft.json +1 -0
- package/.next/server/app/api/slack/inbox/route.js +1 -0
- package/.next/server/app/api/slack/inbox/route.js.nft.json +1 -0
- package/.next/server/app/api/usage/route.js +1 -0
- package/.next/server/app/api/usage/route.js.nft.json +1 -0
- package/.next/server/app/demo/page.js +1 -0
- package/.next/server/app/demo/page.js.nft.json +1 -0
- package/.next/server/app/demo/page_client-reference-manifest.js +1 -0
- package/.next/server/app/demo.html +1 -0
- package/.next/server/app/demo.meta +6 -0
- package/.next/server/app/demo.rsc +7 -0
- package/.next/server/app/favicon.ico/route.js +12 -0
- package/.next/server/app/favicon.ico/route.js.nft.json +1 -0
- package/.next/server/app/favicon.ico.body +0 -0
- package/.next/server/app/favicon.ico.meta +1 -0
- package/.next/server/app/index.html +1 -0
- package/.next/server/app/index.meta +5 -0
- package/.next/server/app/index.rsc +7 -0
- package/.next/server/app/page.js +1 -0
- package/.next/server/app/page.js.nft.json +1 -0
- package/.next/server/app/page_client-reference-manifest.js +1 -0
- package/.next/server/app-paths-manifest.json +34 -0
- package/.next/server/chunks/348.js +1 -0
- package/.next/server/chunks/471.js +2 -0
- package/.next/server/chunks/590.js +7 -0
- package/.next/server/chunks/621.js +1 -0
- package/.next/server/chunks/682.js +6 -0
- package/.next/server/chunks/904.js +1 -0
- package/.next/server/chunks/948.js +2 -0
- package/.next/server/chunks/972.js +12 -0
- package/.next/server/chunks/font-manifest.json +1 -0
- package/.next/server/font-manifest.json +1 -0
- package/.next/server/functions-config-manifest.json +1 -0
- package/.next/server/interception-route-rewrite-manifest.js +1 -0
- package/.next/server/middleware-build-manifest.js +1 -0
- package/.next/server/middleware-manifest.json +6 -0
- package/.next/server/middleware-react-loadable-manifest.js +1 -0
- package/.next/server/next-font-manifest.js +1 -0
- package/.next/server/next-font-manifest.json +1 -0
- package/.next/server/pages/404.html +1 -0
- package/.next/server/pages/500.html +1 -0
- package/.next/server/pages/_app.js +1 -0
- package/.next/server/pages/_app.js.nft.json +1 -0
- package/.next/server/pages/_document.js +1 -0
- package/.next/server/pages/_document.js.nft.json +1 -0
- package/.next/server/pages/_error.js +1 -0
- package/.next/server/pages/_error.js.nft.json +1 -0
- package/.next/server/pages-manifest.json +1 -0
- package/.next/server/server-reference-manifest.js +1 -0
- package/.next/server/server-reference-manifest.json +1 -0
- package/.next/server/webpack-runtime.js +1 -0
- package/.next/static/chunks/117-0f4ac3c2c1871d4c.js +2 -0
- package/.next/static/chunks/171-f72ed164561ba218.js +1 -0
- package/.next/static/chunks/235.aef4cdc783360b73.js +1 -0
- package/.next/static/chunks/30d07d85.9045c666bb43d9e1.js +3 -0
- package/.next/static/chunks/app/_not-found/page-8ff6572bc7c9bc61.js +1 -0
- package/.next/static/chunks/app/demo/page-6711b34cd2af0e4a.js +1 -0
- package/.next/static/chunks/app/layout-d058836232e72324.js +1 -0
- package/.next/static/chunks/app/page-cebeba7d6d08548a.js +1 -0
- package/.next/static/chunks/fd9d1056-26bd8d656b496dba.js +1 -0
- package/.next/static/chunks/framework-f66176bb897dc684.js +1 -0
- package/.next/static/chunks/main-960df1c7509a5a8b.js +1 -0
- package/.next/static/chunks/main-app-4b855ea14675b961.js +1 -0
- package/.next/static/chunks/pages/_app-72b849fbd24ac258.js +1 -0
- package/.next/static/chunks/pages/_error-7ba65e1336b92748.js +1 -0
- package/.next/static/chunks/polyfills-42372ed130431b0a.js +1 -0
- package/.next/static/chunks/webpack-1f89b7cb1fca69c4.js +1 -0
- package/.next/static/css/a537d3e86c0f36d2.css +3 -0
- package/.next/static/css/ab3e4b0f5035257a.css +1 -0
- package/.next/static/q-HMeHYZY36qljBJhsyS6/_buildManifest.js +1 -0
- package/.next/static/q-HMeHYZY36qljBJhsyS6/_ssgManifest.js +1 -0
- package/.next/trace +22 -0
- package/.next/types/app/api/automations/existing/route.ts +343 -0
- package/.next/types/app/api/backends/route.ts +343 -0
- package/.next/types/app/api/limits/route.ts +343 -0
- package/.next/types/app/api/meetings/[id]/route.ts +343 -0
- package/.next/types/app/api/meetings/[id]/slack/route.ts +343 -0
- package/.next/types/app/api/meetings/library/route.ts +343 -0
- package/.next/types/app/api/meetings/route.ts +343 -0
- package/.next/types/app/api/models/route.ts +343 -0
- package/.next/types/app/api/notes/route.ts +343 -0
- package/.next/types/app/api/orgs/[id]/route.ts +343 -0
- package/.next/types/app/api/orgs/route.ts +343 -0
- package/.next/types/app/api/prs/inbox/route.ts +343 -0
- package/.next/types/app/api/prs/refresh/route.ts +343 -0
- package/.next/types/app/api/prs/route.ts +343 -0
- package/.next/types/app/api/session-names/route.ts +343 -0
- package/.next/types/app/api/sessions/[id]/route.ts +343 -0
- package/.next/types/app/api/sessions/route.ts +343 -0
- package/.next/types/app/api/settings/auth/route.ts +343 -0
- package/.next/types/app/api/settings/route.ts +343 -0
- package/.next/types/app/api/settings/transcription/route.ts +343 -0
- package/.next/types/app/api/skills/[name]/route.ts +343 -0
- package/.next/types/app/api/skills/marketplace/route.ts +343 -0
- package/.next/types/app/api/skills/route.ts +343 -0
- package/.next/types/app/api/skills/view/route.ts +343 -0
- package/.next/types/app/api/slack/channels/route.ts +343 -0
- package/.next/types/app/api/slack/configured/route.ts +343 -0
- package/.next/types/app/api/slack/inbox/route.ts +343 -0
- package/.next/types/app/api/usage/route.ts +343 -0
- package/.next/types/app/demo/page.ts +79 -0
- package/.next/types/app/layout.ts +79 -0
- package/.next/types/app/page.ts +79 -0
- package/.next/types/package.json +1 -0
- package/.server-dist/server.js +554 -0
- package/.server-dist/src/lib/activeOrg.js +11 -0
- package/.server-dist/src/lib/audioCapture.js +157 -0
- package/.server-dist/src/lib/backends.js +111 -0
- package/.server-dist/src/lib/claudeAuth.js +57 -0
- package/.server-dist/src/lib/configFile.js +23 -0
- package/.server-dist/src/lib/dataDir.js +7 -0
- package/.server-dist/src/lib/existingAutomations.js +132 -0
- package/.server-dist/src/lib/ghInbox.js +151 -0
- package/.server-dist/src/lib/ghPrStatus.js +86 -0
- package/.server-dist/src/lib/gitUtils.js +27 -0
- package/.server-dist/src/lib/keepAwake.js +32 -0
- package/.server-dist/src/lib/liveSessionStore.js +89 -0
- package/.server-dist/src/lib/marketplace.js +63 -0
- package/.server-dist/src/lib/meetingAssistant.js +138 -0
- package/.server-dist/src/lib/meetingConfig.js +81 -0
- package/.server-dist/src/lib/meetingContext.js +82 -0
- package/.server-dist/src/lib/meetingManager.js +246 -0
- package/.server-dist/src/lib/meetingStore.js +198 -0
- package/.server-dist/src/lib/modelCatalog.js +107 -0
- package/.server-dist/src/lib/notesStore.js +67 -0
- package/.server-dist/src/lib/orgFilter.js +19 -0
- package/.server-dist/src/lib/orgParam.js +15 -0
- package/.server-dist/src/lib/orgRegistry.js +93 -0
- package/.server-dist/src/lib/pipelineView.js +62 -0
- package/.server-dist/src/lib/pipelines.js +401 -0
- package/.server-dist/src/lib/planLimits.js +101 -0
- package/.server-dist/src/lib/prDetector.js +16 -0
- package/.server-dist/src/lib/prScanCache.js +144 -0
- package/.server-dist/src/lib/prSessionEntries.js +96 -0
- package/.server-dist/src/lib/prTypes.js +2 -0
- package/.server-dist/src/lib/ptyManager.js +428 -0
- package/.server-dist/src/lib/reminders.js +10 -0
- package/.server-dist/src/lib/requestGuard.js +29 -0
- package/.server-dist/src/lib/sessionNameStore.js +69 -0
- package/.server-dist/src/lib/sessionStore.js +215 -0
- package/.server-dist/src/lib/settingsStore.js +51 -0
- package/.server-dist/src/lib/skillsReader.js +200 -0
- package/.server-dist/src/lib/slackBridge.js +270 -0
- package/.server-dist/src/lib/slackInbox.js +96 -0
- package/.server-dist/src/lib/slackWatchers.js +210 -0
- package/.server-dist/src/lib/statusDetector.js +46 -0
- package/.server-dist/src/lib/transcriber.js +61 -0
- package/.server-dist/src/lib/usageStore.js +254 -0
- package/.server-dist/tsconfig.server.tsbuildinfo +1 -0
- package/LICENSE +21 -0
- package/README.md +99 -2
- package/bin/polyergon.js +34 -0
- package/next.config.mjs +4 -0
- package/package.json +81 -4
- package/public/.gitkeep +0 -0
- package/public/apple-touch-icon.png +0 -0
- package/public/icon-192.png +0 -0
- package/public/icon-512.png +0 -0
- package/public/icon.svg +1 -0
- package/public/manifest.webmanifest +15 -0
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.meetingManager = void 0;
|
|
5
|
+
const meetingStore_1 = require("./meetingStore");
|
|
6
|
+
const meetingContext_1 = require("./meetingContext");
|
|
7
|
+
const crypto_1 = require("crypto");
|
|
8
|
+
const audioCapture_1 = require("./audioCapture");
|
|
9
|
+
const transcriber_1 = require("./transcriber");
|
|
10
|
+
const meetingAssistant_1 = require("./meetingAssistant");
|
|
11
|
+
const meetingConfig_1 = require("./meetingConfig");
|
|
12
|
+
const orgRegistry_1 = require("./orgRegistry");
|
|
13
|
+
const NOTES_TICK_MS = 90000;
|
|
14
|
+
class MeetingManager {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.active = new Map();
|
|
17
|
+
this.listeners = new Set();
|
|
18
|
+
}
|
|
19
|
+
on(fn) {
|
|
20
|
+
this.listeners.add(fn);
|
|
21
|
+
return () => { this.listeners.delete(fn); };
|
|
22
|
+
}
|
|
23
|
+
emit(ev) {
|
|
24
|
+
this.listeners.forEach(fn => fn(ev));
|
|
25
|
+
}
|
|
26
|
+
activeMeetings() {
|
|
27
|
+
return Array.from(this.active.values()).map(a => a.meeting);
|
|
28
|
+
}
|
|
29
|
+
micTest() {
|
|
30
|
+
return (0, audioCapture_1.micTest)((0, meetingConfig_1.getAudioDevices)());
|
|
31
|
+
}
|
|
32
|
+
start(title, orgId) {
|
|
33
|
+
if (!(0, meetingConfig_1.getTranscriptionConfig)()) {
|
|
34
|
+
return { error: 'Transcription not configured: open Settings → Meeting transcription and add an OpenAI or Azure OpenAI key.' };
|
|
35
|
+
}
|
|
36
|
+
return this.begin(meetingStore_1.meetingStore.create(title, orgId || orgRegistry_1.DEFAULT_ORG_ID));
|
|
37
|
+
}
|
|
38
|
+
// Continue an ended/interrupted meeting: same transcript, notes and assistant
|
|
39
|
+
// conversation; new audio is appended. The summary is rewritten on stop.
|
|
40
|
+
resume(meetingId) {
|
|
41
|
+
var _a;
|
|
42
|
+
if (!(0, meetingConfig_1.getTranscriptionConfig)()) {
|
|
43
|
+
return { error: 'Transcription not configured: open Settings → Meeting transcription and add an OpenAI or Azure OpenAI key.' };
|
|
44
|
+
}
|
|
45
|
+
const existing = meetingStore_1.meetingStore.get(meetingId);
|
|
46
|
+
if (!existing)
|
|
47
|
+
return { error: 'Meeting not found' };
|
|
48
|
+
if (this.active.has(meetingId) || existing.status === 'recording')
|
|
49
|
+
return { error: 'Meeting is already recording' };
|
|
50
|
+
if (this.active.size > 0)
|
|
51
|
+
return { error: 'Another meeting is recording. Stop it first.' };
|
|
52
|
+
const meeting = (_a = meetingStore_1.meetingStore.update(meetingId, { status: 'recording', endedAt: null })) !== null && _a !== void 0 ? _a : existing;
|
|
53
|
+
return this.begin(meeting);
|
|
54
|
+
}
|
|
55
|
+
begin(meeting) {
|
|
56
|
+
var _a, _b;
|
|
57
|
+
const org = orgRegistry_1.orgRegistry.get(meeting.orgId);
|
|
58
|
+
const assistant = new meetingAssistant_1.MeetingAssistant({
|
|
59
|
+
cwd: meetingStore_1.meetingStore.dir(meeting.id),
|
|
60
|
+
configDir: (_a = org === null || org === void 0 ? void 0 : org.configDir) !== null && _a !== void 0 ? _a : null,
|
|
61
|
+
model: (_b = org === null || org === void 0 ? void 0 : org.model) !== null && _b !== void 0 ? _b : null,
|
|
62
|
+
}, meeting.claudeSessionId);
|
|
63
|
+
assistant.onSessionId = (sid) => {
|
|
64
|
+
const updated = meetingStore_1.meetingStore.update(meeting.id, { claudeSessionId: sid });
|
|
65
|
+
const a = this.active.get(meeting.id);
|
|
66
|
+
if (a && updated)
|
|
67
|
+
a.meeting = updated;
|
|
68
|
+
};
|
|
69
|
+
// On resume, the earlier transcript was already sent to the assistant
|
|
70
|
+
const priorText = meetingStore_1.meetingStore.readTranscript(meeting.id).map(s => s.text).join('\n');
|
|
71
|
+
const active = {
|
|
72
|
+
meeting,
|
|
73
|
+
assistant,
|
|
74
|
+
chunkQueue: [],
|
|
75
|
+
transcribing: false,
|
|
76
|
+
restarted: false,
|
|
77
|
+
sentTranscriptChars: priorText.length,
|
|
78
|
+
transcriptText: priorText,
|
|
79
|
+
capture: this.spawnCapture(meeting.id),
|
|
80
|
+
notesTimer: setInterval(() => this.notesTick(meeting.id), NOTES_TICK_MS),
|
|
81
|
+
};
|
|
82
|
+
this.active.set(meeting.id, active);
|
|
83
|
+
this.emit({ type: 'meeting-status', meeting });
|
|
84
|
+
return meeting;
|
|
85
|
+
}
|
|
86
|
+
spawnCapture(meetingId) {
|
|
87
|
+
return (0, audioCapture_1.startCapture)(meetingStore_1.meetingStore.dir(meetingId), (0, meetingConfig_1.getAudioDevices)(), {
|
|
88
|
+
onChunk: (filePath) => this.enqueueChunk(meetingId, filePath),
|
|
89
|
+
onExit: (code, stderrTail) => {
|
|
90
|
+
var _a;
|
|
91
|
+
const a = this.active.get(meetingId);
|
|
92
|
+
if (!a)
|
|
93
|
+
return;
|
|
94
|
+
// One automatic restart; a second death surfaces to the user
|
|
95
|
+
if (!a.restarted) {
|
|
96
|
+
a.restarted = true;
|
|
97
|
+
a.capture = this.spawnCapture(meetingId);
|
|
98
|
+
this.emit({ type: 'meeting-error', meetingId, message: 'Audio capture restarted after an unexpected exit' });
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
this.emit({ type: 'meeting-error', meetingId, message: `Audio capture died (ffmpeg exit ${code}): ${(_a = stderrTail.split('\n').at(-1)) !== null && _a !== void 0 ? _a : ''}` });
|
|
102
|
+
this.stop(meetingId).catch(() => { });
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
enqueueChunk(meetingId, filePath) {
|
|
108
|
+
const a = this.active.get(meetingId);
|
|
109
|
+
if (!a)
|
|
110
|
+
return;
|
|
111
|
+
a.chunkQueue.push(filePath);
|
|
112
|
+
this.drainChunks(meetingId);
|
|
113
|
+
}
|
|
114
|
+
async drainChunks(meetingId) {
|
|
115
|
+
const a = this.active.get(meetingId);
|
|
116
|
+
if (!a || a.transcribing)
|
|
117
|
+
return;
|
|
118
|
+
a.transcribing = true;
|
|
119
|
+
try {
|
|
120
|
+
const config = (0, meetingConfig_1.getTranscriptionConfig)();
|
|
121
|
+
while (a.chunkQueue.length > 0) {
|
|
122
|
+
const filePath = a.chunkQueue.shift();
|
|
123
|
+
if (!config)
|
|
124
|
+
continue;
|
|
125
|
+
try {
|
|
126
|
+
// Last ~200 chars of transcript as context for language consistency
|
|
127
|
+
const text = await (0, transcriber_1.transcribeChunk)(filePath, config, a.transcriptText.slice(-200));
|
|
128
|
+
if (text) {
|
|
129
|
+
const segment = { t: Date.now(), text };
|
|
130
|
+
meetingStore_1.meetingStore.appendTranscript(meetingId, segment);
|
|
131
|
+
a.transcriptText += (a.transcriptText ? '\n' : '') + text;
|
|
132
|
+
this.emit({ type: 'meeting-transcript', meetingId, segment });
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
catch (e) {
|
|
136
|
+
this.emit({ type: 'meeting-error', meetingId, message: `Transcription gap: ${e instanceof Error ? e.message : 'unknown error'}` });
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
finally {
|
|
141
|
+
a.transcribing = false;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
transcriptDelta(a) {
|
|
145
|
+
const delta = a.transcriptText.slice(a.sentTranscriptChars);
|
|
146
|
+
a.sentTranscriptChars = a.transcriptText.length;
|
|
147
|
+
return delta;
|
|
148
|
+
}
|
|
149
|
+
async notesTick(meetingId) {
|
|
150
|
+
const a = this.active.get(meetingId);
|
|
151
|
+
if (!a)
|
|
152
|
+
return;
|
|
153
|
+
const delta = a.transcriptText.slice(a.sentTranscriptChars);
|
|
154
|
+
if (!delta.trim())
|
|
155
|
+
return; // nobody said anything new — skip the call
|
|
156
|
+
a.sentTranscriptChars = a.transcriptText.length;
|
|
157
|
+
try {
|
|
158
|
+
const { notes, suggestion } = await a.assistant.notesTick(delta);
|
|
159
|
+
if (notes) {
|
|
160
|
+
meetingStore_1.meetingStore.saveNotes(meetingId, notes);
|
|
161
|
+
this.emit({ type: 'meeting-notes', meetingId, notes });
|
|
162
|
+
}
|
|
163
|
+
if (suggestion)
|
|
164
|
+
this.emit({ type: 'meeting-suggestion', meetingId, suggestion });
|
|
165
|
+
}
|
|
166
|
+
catch (e) {
|
|
167
|
+
// Notes going stale is fine; next tick retries with a bigger delta
|
|
168
|
+
this.emit({ type: 'meeting-error', meetingId, message: `Notes update failed (will retry): ${e instanceof Error ? e.message : 'unknown'}` });
|
|
169
|
+
a.sentTranscriptChars -= delta.length; // resend this delta next tick
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
async ask(meetingId, question) {
|
|
173
|
+
const a = this.active.get(meetingId);
|
|
174
|
+
if (!a) {
|
|
175
|
+
this.emit({ type: 'meeting-error', meetingId, message: 'Meeting is not active' });
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
try {
|
|
179
|
+
const answer = await a.assistant.ask(question, this.transcriptDelta(a));
|
|
180
|
+
this.emit({ type: 'meeting-answer', meetingId, question, answer });
|
|
181
|
+
}
|
|
182
|
+
catch (e) {
|
|
183
|
+
this.emit({ type: 'meeting-error', meetingId, message: `Ask failed: ${e instanceof Error ? e.message : 'unknown'}` });
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
async addContext(meetingId, kind, value) {
|
|
187
|
+
const a = this.active.get(meetingId);
|
|
188
|
+
if (!a) {
|
|
189
|
+
this.emit({ type: 'meeting-error', meetingId, message: 'Context can only be added while the meeting is recording' });
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
const item = { id: (0, crypto_1.randomUUID)(), kind, label: value.trim().slice(0, 60) || kind, value, addedAt: Date.now(), status: 'loading', summary: null };
|
|
193
|
+
const save = (patch) => {
|
|
194
|
+
const items = meetingStore_1.meetingStore.readContext(meetingId);
|
|
195
|
+
const i = items.findIndex(x => x.id === item.id);
|
|
196
|
+
if (i >= 0)
|
|
197
|
+
items[i] = Object.assign(Object.assign({}, items[i]), patch);
|
|
198
|
+
else
|
|
199
|
+
items.push(Object.assign(Object.assign({}, item), patch));
|
|
200
|
+
meetingStore_1.meetingStore.saveContext(meetingId, items);
|
|
201
|
+
this.emit({ type: 'meeting-context', meetingId, items });
|
|
202
|
+
};
|
|
203
|
+
save({});
|
|
204
|
+
try {
|
|
205
|
+
const resolved = await (0, meetingContext_1.resolveContext)(kind, value);
|
|
206
|
+
save({ label: resolved.label });
|
|
207
|
+
const reply = (await a.assistant.addContext(resolved.label, resolved.body, resolved.fetch)).trim().split('\n')[0];
|
|
208
|
+
save(/^FAILED/i.test(reply) ? { status: 'failed', summary: reply.replace(/^FAILED:?\s*/i, '') } : { status: 'loaded', summary: reply });
|
|
209
|
+
}
|
|
210
|
+
catch (e) {
|
|
211
|
+
save({ status: 'failed', summary: e instanceof Error ? e.message : 'unknown error' });
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
async stop(meetingId) {
|
|
215
|
+
var _a, _b;
|
|
216
|
+
const a = this.active.get(meetingId);
|
|
217
|
+
if (!a)
|
|
218
|
+
return;
|
|
219
|
+
clearInterval(a.notesTimer);
|
|
220
|
+
// Graceful ffmpeg stop flushes the final chunks into the queue (the
|
|
221
|
+
// meeting must still be in `active` for enqueueChunk to accept them)
|
|
222
|
+
await a.capture.stop();
|
|
223
|
+
this.drainChunks(meetingId);
|
|
224
|
+
// Wait for the final chunks to transcribe, but cap it — a wedged transcribe
|
|
225
|
+
// must never hang teardown forever (transcribeChunk itself now times out at
|
|
226
|
+
// 30s/attempt, so ~45s is a generous ceiling past normal drain).
|
|
227
|
+
const drainDeadline = Date.now() + 45000;
|
|
228
|
+
while ((a.chunkQueue.length > 0 || a.transcribing) && Date.now() < drainDeadline) {
|
|
229
|
+
await new Promise(r => setTimeout(r, 250));
|
|
230
|
+
}
|
|
231
|
+
this.active.delete(meetingId);
|
|
232
|
+
let meeting = (_a = meetingStore_1.meetingStore.update(meetingId, { status: 'ended', endedAt: Date.now() })) !== null && _a !== void 0 ? _a : a.meeting;
|
|
233
|
+
this.emit({ type: 'meeting-status', meeting });
|
|
234
|
+
try {
|
|
235
|
+
const summary = await a.assistant.summarize(this.transcriptDelta(a));
|
|
236
|
+
if (summary.trim())
|
|
237
|
+
meetingStore_1.meetingStore.saveSummary(meetingId, summary);
|
|
238
|
+
}
|
|
239
|
+
catch (e) {
|
|
240
|
+
this.emit({ type: 'meeting-error', meetingId, message: `Summary failed: ${e instanceof Error ? e.message : 'unknown'}` });
|
|
241
|
+
}
|
|
242
|
+
meeting = (_b = meetingStore_1.meetingStore.get(meetingId)) !== null && _b !== void 0 ? _b : meeting;
|
|
243
|
+
this.emit({ type: 'meeting-status', meeting });
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
exports.meetingManager = (_a = global.__meetingManager) !== null && _a !== void 0 ? _a : (global.__meetingManager = new MeetingManager());
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.meetingStore = exports.MeetingStore = void 0;
|
|
5
|
+
exports.summarySnippet = summarySnippet;
|
|
6
|
+
const dataDir_1 = require("./dataDir");
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
const path_1 = require("path");
|
|
9
|
+
const crypto_1 = require("crypto");
|
|
10
|
+
// First line of the summary that is prose, with markdown markers stripped.
|
|
11
|
+
function summarySnippet(md) {
|
|
12
|
+
if (!md)
|
|
13
|
+
return null;
|
|
14
|
+
for (const raw of md.split('\n')) {
|
|
15
|
+
const line = raw.replace(/^[\s>*#\-\d.]+/, '').replace(/\*\*|__|`/g, '').trim();
|
|
16
|
+
if (line.length >= 30)
|
|
17
|
+
return line; // shorter lines are headings like "Meeting Recap"
|
|
18
|
+
}
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
// Excerpt of `text` around the first occurrence of `word` (lowercase).
|
|
22
|
+
function excerpt(raw, word) {
|
|
23
|
+
const text = raw.replace(/\*\*|__|`|^#+\s*/gm, '');
|
|
24
|
+
const i = text.toLowerCase().indexOf(word);
|
|
25
|
+
const start = Math.max(0, i - 60);
|
|
26
|
+
return (start > 0 ? '…' : '') + text.slice(start, i + word.length + 80).replace(/\s+/g, ' ').trim() + '…';
|
|
27
|
+
}
|
|
28
|
+
const DEFAULT_BASE_DIR = (0, path_1.join)(dataDir_1.DATA_DIR, 'meetings');
|
|
29
|
+
class MeetingStore {
|
|
30
|
+
// baseDir defaults to the real on-disk location; tests must pass an
|
|
31
|
+
// isolated path so they never touch the user's actual meetings.
|
|
32
|
+
constructor(baseDir = DEFAULT_BASE_DIR) {
|
|
33
|
+
this.baseDir = baseDir;
|
|
34
|
+
}
|
|
35
|
+
dir(id) {
|
|
36
|
+
return (0, path_1.join)(this.baseDir, id);
|
|
37
|
+
}
|
|
38
|
+
metaPath(id) {
|
|
39
|
+
return (0, path_1.join)(this.dir(id), 'meta.json');
|
|
40
|
+
}
|
|
41
|
+
create(title, orgId) {
|
|
42
|
+
const meeting = {
|
|
43
|
+
id: (0, crypto_1.randomUUID)(),
|
|
44
|
+
title: title || `Meeting ${new Date().toLocaleString()}`,
|
|
45
|
+
orgId,
|
|
46
|
+
startedAt: Date.now(),
|
|
47
|
+
endedAt: null,
|
|
48
|
+
status: 'recording',
|
|
49
|
+
claudeSessionId: null,
|
|
50
|
+
};
|
|
51
|
+
(0, fs_1.mkdirSync)((0, path_1.join)(this.dir(meeting.id), 'audio'), { recursive: true });
|
|
52
|
+
this.writeMeta(meeting);
|
|
53
|
+
return meeting;
|
|
54
|
+
}
|
|
55
|
+
get(id) {
|
|
56
|
+
try {
|
|
57
|
+
return JSON.parse((0, fs_1.readFileSync)(this.metaPath(id), 'utf-8'));
|
|
58
|
+
}
|
|
59
|
+
catch (_a) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
update(id, patch) {
|
|
64
|
+
const meeting = this.get(id);
|
|
65
|
+
if (!meeting)
|
|
66
|
+
return null;
|
|
67
|
+
const updated = Object.assign(Object.assign({}, meeting), patch);
|
|
68
|
+
this.writeMeta(updated);
|
|
69
|
+
return updated;
|
|
70
|
+
}
|
|
71
|
+
list() {
|
|
72
|
+
let ids;
|
|
73
|
+
try {
|
|
74
|
+
ids = (0, fs_1.readdirSync)(this.baseDir);
|
|
75
|
+
}
|
|
76
|
+
catch (_a) {
|
|
77
|
+
return [];
|
|
78
|
+
}
|
|
79
|
+
const meetings = [];
|
|
80
|
+
for (const id of ids) {
|
|
81
|
+
const m = this.get(id);
|
|
82
|
+
if (m)
|
|
83
|
+
meetings.push(m);
|
|
84
|
+
}
|
|
85
|
+
return meetings.sort((a, b) => b.startedAt - a.startedAt);
|
|
86
|
+
}
|
|
87
|
+
// A server restart can't resume audio capture, so anything still marked
|
|
88
|
+
// 'recording' from a previous run becomes 'interrupted' (transcript/notes
|
|
89
|
+
// are preserved and a summary can still be generated).
|
|
90
|
+
markInterrupted() {
|
|
91
|
+
var _a;
|
|
92
|
+
for (const m of this.list()) {
|
|
93
|
+
if (m.status === 'recording')
|
|
94
|
+
this.update(m.id, { status: 'interrupted', endedAt: (_a = m.endedAt) !== null && _a !== void 0 ? _a : Date.now() });
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
appendTranscript(id, seg) {
|
|
98
|
+
(0, fs_1.appendFileSync)((0, path_1.join)(this.dir(id), 'transcript.jsonl'), JSON.stringify(seg) + '\n');
|
|
99
|
+
}
|
|
100
|
+
readTranscript(id) {
|
|
101
|
+
try {
|
|
102
|
+
return (0, fs_1.readFileSync)((0, path_1.join)(this.dir(id), 'transcript.jsonl'), 'utf-8')
|
|
103
|
+
.split('\n')
|
|
104
|
+
.filter(Boolean)
|
|
105
|
+
.map(line => JSON.parse(line));
|
|
106
|
+
}
|
|
107
|
+
catch (_a) {
|
|
108
|
+
return [];
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
saveNotes(id, notes) {
|
|
112
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(this.dir(id), 'notes.json'), JSON.stringify(notes, null, 2));
|
|
113
|
+
}
|
|
114
|
+
readNotes(id) {
|
|
115
|
+
try {
|
|
116
|
+
return JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(this.dir(id), 'notes.json'), 'utf-8'));
|
|
117
|
+
}
|
|
118
|
+
catch (_a) {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
saveSummary(id, markdown) {
|
|
123
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(this.dir(id), 'summary.md'), markdown);
|
|
124
|
+
}
|
|
125
|
+
readSummary(id) {
|
|
126
|
+
try {
|
|
127
|
+
return (0, fs_1.readFileSync)((0, path_1.join)(this.dir(id), 'summary.md'), 'utf-8');
|
|
128
|
+
}
|
|
129
|
+
catch (_a) {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
// Recordings library. Every query word must appear somewhere in the title,
|
|
134
|
+
// summary, notes or transcript (case-insensitive).
|
|
135
|
+
// ponytail: reads every transcript per search; fine for hundreds of meetings, add an index past that.
|
|
136
|
+
library(query = '') {
|
|
137
|
+
var _a, _b, _c;
|
|
138
|
+
const words = query.toLowerCase().split(/\s+/).filter(Boolean);
|
|
139
|
+
const out = [];
|
|
140
|
+
for (const m of this.list()) {
|
|
141
|
+
const summary = this.readSummary(m.id);
|
|
142
|
+
const notes = this.readNotes(m.id);
|
|
143
|
+
let match = null;
|
|
144
|
+
if (words.length) {
|
|
145
|
+
const transcript = this.readTranscript(m.id).map(s => s.text).join(' ');
|
|
146
|
+
const notesText = notes ? [...notes.topics, ...notes.decisions, ...notes.actionItems].join(' ') : '';
|
|
147
|
+
const hay = [m.title, summary !== null && summary !== void 0 ? summary : '', notesText, transcript].join('\n').toLowerCase();
|
|
148
|
+
if (!words.every(w => hay.includes(w)))
|
|
149
|
+
continue;
|
|
150
|
+
const w = words[0];
|
|
151
|
+
for (const field of [summary !== null && summary !== void 0 ? summary : '', notesText, transcript]) {
|
|
152
|
+
if (field.toLowerCase().includes(w)) {
|
|
153
|
+
match = excerpt(field, w);
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
let chunks = 0, bytes = 0;
|
|
159
|
+
try {
|
|
160
|
+
for (const f of (0, fs_1.readdirSync)((0, path_1.join)(this.dir(m.id), 'audio'))) {
|
|
161
|
+
chunks++;
|
|
162
|
+
bytes += (0, fs_1.statSync)((0, path_1.join)(this.dir(m.id), 'audio', f)).size;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
catch ( /* no audio dir */_d) { /* no audio dir */ }
|
|
166
|
+
out.push(Object.assign(Object.assign({}, m), { snippet: summarySnippet(summary), counts: { topics: (_a = notes === null || notes === void 0 ? void 0 : notes.topics.length) !== null && _a !== void 0 ? _a : 0, decisions: (_b = notes === null || notes === void 0 ? void 0 : notes.decisions.length) !== null && _b !== void 0 ? _b : 0, actionItems: (_c = notes === null || notes === void 0 ? void 0 : notes.actionItems.length) !== null && _c !== void 0 ? _c : 0 }, audio: { chunks, bytes }, match }));
|
|
167
|
+
}
|
|
168
|
+
return out;
|
|
169
|
+
}
|
|
170
|
+
readContext(id) {
|
|
171
|
+
try {
|
|
172
|
+
return JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(this.dir(id), 'context.json'), 'utf-8'));
|
|
173
|
+
}
|
|
174
|
+
catch (_a) {
|
|
175
|
+
return [];
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
saveContext(id, items) {
|
|
179
|
+
(0, fs_1.writeFileSync)((0, path_1.join)(this.dir(id), 'context.json'), JSON.stringify(items, null, 2));
|
|
180
|
+
}
|
|
181
|
+
// Moves the meeting folder to <data>/trash/meetings instead of deleting it.
|
|
182
|
+
trash(id) {
|
|
183
|
+
const m = this.get(id);
|
|
184
|
+
if (!m || m.status === 'recording')
|
|
185
|
+
return false;
|
|
186
|
+
const dest = (0, path_1.join)(this.baseDir, '..', 'trash', 'meetings');
|
|
187
|
+
(0, fs_1.mkdirSync)(dest, { recursive: true });
|
|
188
|
+
(0, fs_1.renameSync)(this.dir(id), (0, path_1.join)(dest, `${id}-${Date.now()}`));
|
|
189
|
+
return true;
|
|
190
|
+
}
|
|
191
|
+
writeMeta(meeting) {
|
|
192
|
+
if (!(0, fs_1.existsSync)(this.dir(meeting.id)))
|
|
193
|
+
(0, fs_1.mkdirSync)(this.dir(meeting.id), { recursive: true });
|
|
194
|
+
(0, fs_1.writeFileSync)(this.metaPath(meeting.id), JSON.stringify(meeting, null, 2));
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
exports.MeetingStore = MeetingStore;
|
|
198
|
+
exports.meetingStore = (_a = global.__meetingStore) !== null && _a !== void 0 ? _a : (global.__meetingStore = new MeetingStore());
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getModels = getModels;
|
|
4
|
+
const child_process_1 = require("child_process");
|
|
5
|
+
const util_1 = require("util");
|
|
6
|
+
const crypto_1 = require("crypto");
|
|
7
|
+
const orgRegistry_1 = require("./orgRegistry");
|
|
8
|
+
const execFileAsync = (0, util_1.promisify)(child_process_1.execFile);
|
|
9
|
+
const MODELS_URL = 'https://api.anthropic.com/v1/models?limit=1000';
|
|
10
|
+
const CACHE_TTL_MS = 10 * 60000;
|
|
11
|
+
// Same keychain scheme planLimits.ts uses: each config dir's OAuth token lives
|
|
12
|
+
// under "Claude Code-credentials[-<first 8 hex of sha256(configDir)>]".
|
|
13
|
+
function keychainService(configDir) {
|
|
14
|
+
if (!configDir)
|
|
15
|
+
return 'Claude Code-credentials';
|
|
16
|
+
return `Claude Code-credentials-${(0, crypto_1.createHash)('sha256').update(configDir).digest('hex').slice(0, 8)}`;
|
|
17
|
+
}
|
|
18
|
+
async function readToken(configDir) {
|
|
19
|
+
var _a, _b;
|
|
20
|
+
try {
|
|
21
|
+
const { stdout } = await execFileAsync('security', [
|
|
22
|
+
'find-generic-password', '-s', keychainService(configDir), '-w',
|
|
23
|
+
], { timeout: 5000 });
|
|
24
|
+
return (_b = (_a = JSON.parse(stdout.trim()).claudeAiOauth) === null || _a === void 0 ? void 0 : _a.accessToken) !== null && _b !== void 0 ? _b : null;
|
|
25
|
+
}
|
|
26
|
+
catch (_c) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
// GitHub Copilot exposes its model list at api.githubcopilot.com/models,
|
|
31
|
+
// authenticated with the user's gh OAuth token (Bearer). It returns chat models
|
|
32
|
+
// plus embedding models — we keep only the ones usable for a coding session.
|
|
33
|
+
async function fetchCopilotModels() {
|
|
34
|
+
var _a;
|
|
35
|
+
let token;
|
|
36
|
+
try {
|
|
37
|
+
const { stdout } = await execFileAsync('gh', ['auth', 'token'], { timeout: 5000 });
|
|
38
|
+
token = stdout.trim();
|
|
39
|
+
}
|
|
40
|
+
catch (_b) {
|
|
41
|
+
throw new Error('Not logged into gh — run `gh auth login`');
|
|
42
|
+
}
|
|
43
|
+
if (!token)
|
|
44
|
+
throw new Error('No gh token found');
|
|
45
|
+
const res = await fetch('https://api.githubcopilot.com/models', {
|
|
46
|
+
headers: {
|
|
47
|
+
Authorization: `Bearer ${token}`,
|
|
48
|
+
'Editor-Version': 'copilot-cli/1.0.83',
|
|
49
|
+
'Copilot-Integration-Id': 'copilot-cli',
|
|
50
|
+
},
|
|
51
|
+
signal: AbortSignal.timeout(15000),
|
|
52
|
+
});
|
|
53
|
+
if (res.status === 401 || res.status === 403)
|
|
54
|
+
throw new Error('gh token lacks Copilot access');
|
|
55
|
+
if (!res.ok)
|
|
56
|
+
throw new Error(`Copilot models endpoint returned ${res.status}`);
|
|
57
|
+
const d = await res.json();
|
|
58
|
+
const seen = new Set();
|
|
59
|
+
return ((_a = d.data) !== null && _a !== void 0 ? _a : [])
|
|
60
|
+
// Drop embeddings and anything not a chat model.
|
|
61
|
+
.filter(m => { var _a, _b; return !/embedding/i.test(m.id) && ((_b = (_a = m.capabilities) === null || _a === void 0 ? void 0 : _a.type) !== null && _b !== void 0 ? _b : 'chat') === 'chat'; })
|
|
62
|
+
.filter(m => (seen.has(m.id) ? false : (seen.add(m.id), true)))
|
|
63
|
+
.map(m => { var _a; return ({ id: m.id, displayName: (_a = m.name) !== null && _a !== void 0 ? _a : m.id }); });
|
|
64
|
+
}
|
|
65
|
+
async function fetchClaudeModels(configDir) {
|
|
66
|
+
var _a;
|
|
67
|
+
const token = await readToken(configDir);
|
|
68
|
+
if (!token)
|
|
69
|
+
throw new Error('No login found for this org');
|
|
70
|
+
const res = await fetch(MODELS_URL, {
|
|
71
|
+
headers: {
|
|
72
|
+
Authorization: `Bearer ${token}`,
|
|
73
|
+
'anthropic-version': '2023-06-01',
|
|
74
|
+
'anthropic-beta': 'oauth-2025-04-20',
|
|
75
|
+
},
|
|
76
|
+
signal: AbortSignal.timeout(15000),
|
|
77
|
+
});
|
|
78
|
+
if (res.status === 401)
|
|
79
|
+
throw new Error('Token expired — open a Claude session in this org to refresh it');
|
|
80
|
+
if (!res.ok)
|
|
81
|
+
throw new Error(`Models endpoint returned ${res.status}`);
|
|
82
|
+
const d = await res.json();
|
|
83
|
+
return ((_a = d.data) !== null && _a !== void 0 ? _a : []).map(m => { var _a; return ({ id: m.id, displayName: (_a = m.display_name) !== null && _a !== void 0 ? _a : m.id }); });
|
|
84
|
+
}
|
|
85
|
+
const cache = new Map();
|
|
86
|
+
// Keyed by backend + org so each org's own entitlements are reflected.
|
|
87
|
+
async function getModels(backend, orgId, force = false) {
|
|
88
|
+
var _a;
|
|
89
|
+
const key = `${backend}:${orgId}`;
|
|
90
|
+
const hit = cache.get(key);
|
|
91
|
+
if (!force && hit && Date.now() - hit.at < CACHE_TTL_MS)
|
|
92
|
+
return hit.models;
|
|
93
|
+
try {
|
|
94
|
+
const org = orgRegistry_1.orgRegistry.get(orgId);
|
|
95
|
+
const models = backend === 'copilot'
|
|
96
|
+
? await fetchCopilotModels()
|
|
97
|
+
: await fetchClaudeModels((_a = org === null || org === void 0 ? void 0 : org.configDir) !== null && _a !== void 0 ? _a : null);
|
|
98
|
+
cache.set(key, { at: Date.now(), models });
|
|
99
|
+
return models;
|
|
100
|
+
}
|
|
101
|
+
catch (e) {
|
|
102
|
+
// Serve stale on failure rather than an empty dropdown.
|
|
103
|
+
if (hit)
|
|
104
|
+
return hit.models;
|
|
105
|
+
throw e;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.notesStore = exports.NotesStore = void 0;
|
|
5
|
+
const dataDir_1 = require("./dataDir");
|
|
6
|
+
const fs_1 = require("fs");
|
|
7
|
+
const path_1 = require("path");
|
|
8
|
+
// Server-side persistence for notes — origin/browser/machine-independent, so
|
|
9
|
+
// they don't vanish when the app's hostname changes (localhost vs polyergon).
|
|
10
|
+
const DEFAULT_FILE = (0, path_1.join)(dataDir_1.DATA_DIR, 'notes.json');
|
|
11
|
+
class NotesStore {
|
|
12
|
+
constructor(file = DEFAULT_FILE) {
|
|
13
|
+
this.notes = [];
|
|
14
|
+
this.file = file;
|
|
15
|
+
this.dir = (0, path_1.join)(file, '..');
|
|
16
|
+
this.load();
|
|
17
|
+
}
|
|
18
|
+
load() {
|
|
19
|
+
try {
|
|
20
|
+
const parsed = JSON.parse((0, fs_1.readFileSync)(this.file, 'utf-8'));
|
|
21
|
+
if (Array.isArray(parsed))
|
|
22
|
+
this.notes = parsed;
|
|
23
|
+
}
|
|
24
|
+
catch (_a) {
|
|
25
|
+
this.notes = [];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
all() {
|
|
29
|
+
return [...this.notes];
|
|
30
|
+
}
|
|
31
|
+
// Replace the whole list (the client owns ordering — newest first).
|
|
32
|
+
replace(notes) {
|
|
33
|
+
if (!Array.isArray(notes))
|
|
34
|
+
return;
|
|
35
|
+
this.notes = notes.filter(n => n && typeof n.id === 'string' && typeof n.text === 'string');
|
|
36
|
+
this.persist();
|
|
37
|
+
}
|
|
38
|
+
// Import notes from the client's localStorage the first time — only adds ids
|
|
39
|
+
// we don't already have, so it can't clobber server-side edits.
|
|
40
|
+
merge(incoming) {
|
|
41
|
+
if (!Array.isArray(incoming))
|
|
42
|
+
return;
|
|
43
|
+
const have = new Set(this.notes.map(n => n.id));
|
|
44
|
+
let changed = false;
|
|
45
|
+
for (const n of incoming) {
|
|
46
|
+
if (n && typeof n.id === 'string' && !have.has(n.id)) {
|
|
47
|
+
this.notes.push(n);
|
|
48
|
+
have.add(n.id);
|
|
49
|
+
changed = true;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (changed) {
|
|
53
|
+
this.notes.sort((a, b) => b.createdAt - a.createdAt); // newest first
|
|
54
|
+
this.persist();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
persist() {
|
|
58
|
+
try {
|
|
59
|
+
if (!(0, fs_1.existsSync)(this.dir))
|
|
60
|
+
(0, fs_1.mkdirSync)(this.dir, { recursive: true });
|
|
61
|
+
(0, fs_1.writeFileSync)(this.file, JSON.stringify(this.notes));
|
|
62
|
+
}
|
|
63
|
+
catch (_a) { }
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.NotesStore = NotesStore;
|
|
67
|
+
exports.notesStore = (_a = global.__notesStore) !== null && _a !== void 0 ? _a : (global.__notesStore = new NotesStore());
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.repoInOrg = repoInOrg;
|
|
4
|
+
// Which Claude org does a GitHub repo (owner/name) belong to?
|
|
5
|
+
// - 'all' matches everything.
|
|
6
|
+
// - An org with githubOrgs matches owners on its list.
|
|
7
|
+
// - An org with no githubOrgs owns every owner no other org has claimed.
|
|
8
|
+
function repoInOrg(repo, activeOrgId, orgs) {
|
|
9
|
+
var _a, _b;
|
|
10
|
+
if (activeOrgId === 'all')
|
|
11
|
+
return true;
|
|
12
|
+
const owner = ((_a = repo.split('/')[0]) !== null && _a !== void 0 ? _a : '').toLowerCase();
|
|
13
|
+
const active = orgs.find(o => o.id === activeOrgId);
|
|
14
|
+
const activeOwners = ((_b = active === null || active === void 0 ? void 0 : active.githubOrgs) !== null && _b !== void 0 ? _b : []).map(s => s.toLowerCase());
|
|
15
|
+
if (activeOwners.length > 0)
|
|
16
|
+
return activeOwners.includes(owner);
|
|
17
|
+
const claimed = new Set(orgs.filter(o => o.id !== activeOrgId).flatMap(o => { var _a; return (_a = o.githubOrgs) !== null && _a !== void 0 ? _a : []; }).map(s => s.toLowerCase()));
|
|
18
|
+
return !claimed.has(owner);
|
|
19
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.orgParam = orgParam;
|
|
4
|
+
exports.orgConfigDir = orgConfigDir;
|
|
5
|
+
const orgRegistry_1 = require("./orgRegistry");
|
|
6
|
+
// ?org=<id> on API calls; 'all', missing or unknown → Default.
|
|
7
|
+
function orgParam(req) {
|
|
8
|
+
const id = req.nextUrl.searchParams.get('org');
|
|
9
|
+
return id && id !== 'all' && orgRegistry_1.orgRegistry.get(id) ? id : orgRegistry_1.DEFAULT_ORG_ID;
|
|
10
|
+
}
|
|
11
|
+
// The org's Claude config folder (null = ~/.claude), for skills/plugins
|
|
12
|
+
function orgConfigDir(req) {
|
|
13
|
+
var _a, _b;
|
|
14
|
+
return (_b = (_a = orgRegistry_1.orgRegistry.get(orgParam(req))) === null || _a === void 0 ? void 0 : _a.configDir) !== null && _b !== void 0 ? _b : null;
|
|
15
|
+
}
|