@statechange/council 0.3.0 → 0.4.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/assets/icon.icns +0 -0
- package/assets/icon.png +0 -0
- package/assets/logo.png +0 -0
- package/dist/commands/install.js +67 -46
- package/dist/commands/install.js.map +1 -1
- package/dist/electron/main.js +31 -4
- package/dist/electron/main.js.map +1 -1
- package/dist-electron/main.js +241 -218
- package/dist-renderer/assets/{ar-SA-G6X2FPQ2-CNUtTBRd.js → ar-SA-G6X2FPQ2-BEmsGUDo.js} +1 -1
- package/dist-renderer/assets/{arc-BsV2XMg-.js → arc-C-3eukZI.js} +1 -1
- package/dist-renderer/assets/{az-AZ-76LH7QW2-BU-6SB21.js → az-AZ-76LH7QW2-Bf0F1qpB.js} +1 -1
- package/dist-renderer/assets/{bg-BG-XCXSNQG7-L1xMEEzs.js → bg-BG-XCXSNQG7-DYOpZlHd.js} +1 -1
- package/dist-renderer/assets/{blockDiagram-38ab4fdb-BHS1f8SU.js → blockDiagram-38ab4fdb-D9VICLGW.js} +1 -1
- package/dist-renderer/assets/{bn-BD-2XOGV67Q-BgaYSNWB.js → bn-BD-2XOGV67Q-BjEh0t20.js} +1 -1
- package/dist-renderer/assets/{c4Diagram-3d4e48cf-D2Rl9Buo.js → c4Diagram-3d4e48cf-CZnDXMcn.js} +1 -1
- package/dist-renderer/assets/{ca-ES-6MX7JW3Y-DsFYhkLC.js → ca-ES-6MX7JW3Y-Df__LthM.js} +1 -1
- package/dist-renderer/assets/channel-BlrodDB2.js +1 -0
- package/dist-renderer/assets/{classDiagram-70f12bd4-BGxDdVFC.js → classDiagram-70f12bd4-DXF7s66S.js} +1 -1
- package/dist-renderer/assets/{classDiagram-v2-f2320105-BuoUwdmW.js → classDiagram-v2-f2320105-Co3T9cX2.js} +1 -1
- package/dist-renderer/assets/clone-Bajg6GS8.js +1 -0
- package/dist-renderer/assets/{createText-2e5e7dd3-BX6eAgL1.js → createText-2e5e7dd3-4yNgbt5z.js} +1 -1
- package/dist-renderer/assets/{cs-CZ-2BRQDIVT-CXV-i633.js → cs-CZ-2BRQDIVT-D02tEETl.js} +1 -1
- package/dist-renderer/assets/{da-DK-5WZEPLOC-DmYIifsm.js → da-DK-5WZEPLOC-D0Vxz9Vk.js} +1 -1
- package/dist-renderer/assets/{de-DE-XR44H4JA-B2T52TzN.js → de-DE-XR44H4JA-COwIKGj-.js} +1 -1
- package/dist-renderer/assets/{edges-e0da2a9e-ChSiyO2u.js → edges-e0da2a9e-Csy7YN2f.js} +1 -1
- package/dist-renderer/assets/{el-GR-BZB4AONW-DlS_8ZJJ.js → el-GR-BZB4AONW-iL6-ntEA.js} +1 -1
- package/dist-renderer/assets/{erDiagram-9861fffd-REAc3tDU.js → erDiagram-9861fffd-DyRcuDtU.js} +1 -1
- package/dist-renderer/assets/{es-ES-U4NZUMDT-DL-zHXpT.js → es-ES-U4NZUMDT-C3_2w4H5.js} +1 -1
- package/dist-renderer/assets/{eu-ES-A7QVB2H4-Cq0Kx947.js → eu-ES-A7QVB2H4-B68OTfIa.js} +1 -1
- package/dist-renderer/assets/{fa-IR-HGAKTJCU-DJqZOqAL.js → fa-IR-HGAKTJCU-RH_bUdQt.js} +1 -1
- package/dist-renderer/assets/{fi-FI-Z5N7JZ37-CQiIDJrs.js → fi-FI-Z5N7JZ37-D_8PqlfJ.js} +1 -1
- package/dist-renderer/assets/{flowDb-956e92f1-iZnRwdLd.js → flowDb-956e92f1-Bwg_Bau-.js} +1 -1
- package/dist-renderer/assets/{flowDiagram-66a62f08-Cww5ErID.js → flowDiagram-66a62f08-Ukgy_1TP.js} +1 -1
- package/dist-renderer/assets/flowDiagram-v2-96b9c2cf-tYbWRv_s.js +1 -0
- package/dist-renderer/assets/{flowchart-elk-definition-4a651766-B3GjdX0I.js → flowchart-elk-definition-4a651766-D9wgUOiJ.js} +1 -1
- package/dist-renderer/assets/{fr-FR-RHASNOE6-DXRyDBSp.js → fr-FR-RHASNOE6-Dm8QCd71.js} +1 -1
- package/dist-renderer/assets/{ganttDiagram-c361ad54-Dh5UuCf5.js → ganttDiagram-c361ad54-BLXDD75q.js} +1 -1
- package/dist-renderer/assets/{gitGraphDiagram-72cf32ee-CUrdiK9f.js → gitGraphDiagram-72cf32ee-ByHTP6zu.js} +1 -1
- package/dist-renderer/assets/{gl-ES-HMX3MZ6V-DB2LhjQl.js → gl-ES-HMX3MZ6V-DUKlmpw0.js} +1 -1
- package/dist-renderer/assets/{graph-KS9cHKTv.js → graph-7VOBm4BD.js} +1 -1
- package/dist-renderer/assets/{he-IL-6SHJWFNN-CWdud4mG.js → he-IL-6SHJWFNN-CoS2sda5.js} +1 -1
- package/dist-renderer/assets/{hi-IN-IWLTKZ5I-DkfCxaBI.js → hi-IN-IWLTKZ5I-SFghE6jx.js} +1 -1
- package/dist-renderer/assets/{hu-HU-A5ZG7DT2-DVX9rddx.js → hu-HU-A5ZG7DT2-BjpWP_uc.js} +1 -1
- package/dist-renderer/assets/{id-ID-SAP4L64H-CIosyByg.js → id-ID-SAP4L64H-DiwgVOXB.js} +1 -1
- package/dist-renderer/assets/{index-3862675e-CVxUAJo4.js → index-3862675e-Cv1-zuCn.js} +1 -1
- package/dist-renderer/assets/{index-3RkkhxnO.js → index-BbXXBOD5.js} +2 -2
- package/dist-renderer/assets/{index-B61Czmwn.js → index-DqWupD0e.js} +4 -4
- package/dist-renderer/assets/index-jTu4f6ys.css +1 -0
- package/dist-renderer/assets/{infoDiagram-f8f76790-CWACEGb6.js → infoDiagram-f8f76790-BWmMhC4P.js} +1 -1
- package/dist-renderer/assets/{it-IT-JPQ66NNP-D-TuMToN.js → it-IT-JPQ66NNP-Ca5US-RN.js} +1 -1
- package/dist-renderer/assets/{ja-JP-DBVTYXUO-CK6puaHx.js → ja-JP-DBVTYXUO-BaDej1C9.js} +1 -1
- package/dist-renderer/assets/{journeyDiagram-49397b02-DM-laNCt.js → journeyDiagram-49397b02-DaPuGc0H.js} +1 -1
- package/dist-renderer/assets/{kaa-6HZHGXH3-CiRWfMKd.js → kaa-6HZHGXH3-DZ1sjUzm.js} +1 -1
- package/dist-renderer/assets/{kab-KAB-ZGHBKWFO-D4w9BQ8H.js → kab-KAB-ZGHBKWFO-DGQGFUhW.js} +1 -1
- package/dist-renderer/assets/{kk-KZ-P5N5QNE5-RZi2AGvr.js → kk-KZ-P5N5QNE5-BEZQqWHo.js} +1 -1
- package/dist-renderer/assets/{km-KH-HSX4SM5Z-Dm-OPxhU.js → km-KH-HSX4SM5Z-CO9vn9kN.js} +1 -1
- package/dist-renderer/assets/{ko-KR-MTYHY66A-PbPGVqVz.js → ko-KR-MTYHY66A-BBZ7Ud6z.js} +1 -1
- package/dist-renderer/assets/{ku-TR-6OUDTVRD-Bw0cMtYj.js → ku-TR-6OUDTVRD-DKfTGyMV.js} +1 -1
- package/dist-renderer/assets/{layout-zADYSvqS.js → layout-mlXn6Ojp.js} +1 -1
- package/dist-renderer/assets/{line-DfBkzhQg.js → line-BNQpE2Vh.js} +1 -1
- package/dist-renderer/assets/{linear-O3lyK7Iz.js → linear-D2QI1dee.js} +1 -1
- package/dist-renderer/assets/{lt-LT-XHIRWOB4-06ru_RZe.js → lt-LT-XHIRWOB4-BMmpYFGj.js} +1 -1
- package/dist-renderer/assets/{lv-LV-5QDEKY6T-DsGBjFui.js → lv-LV-5QDEKY6T-Bfb3if1K.js} +1 -1
- package/dist-renderer/assets/{mindmap-definition-fc14e90a-Bg9UaNPK.js → mindmap-definition-fc14e90a-EDdQyXuv.js} +1 -1
- package/dist-renderer/assets/{mr-IN-CRQNXWMA-C1kWOErC.js → mr-IN-CRQNXWMA-BapNRVzr.js} +1 -1
- package/dist-renderer/assets/{my-MM-5M5IBNSE-C8wD2OFs.js → my-MM-5M5IBNSE-W9rGsh-o.js} +1 -1
- package/dist-renderer/assets/{nb-NO-T6EIAALU-B7ac-R_W.js → nb-NO-T6EIAALU-BZeyzeQ5.js} +1 -1
- package/dist-renderer/assets/{nl-NL-IS3SIHDZ-Up67nxB7.js → nl-NL-IS3SIHDZ-BIIy5I6E.js} +1 -1
- package/dist-renderer/assets/{nn-NO-6E72VCQL-BPlkzXM9.js → nn-NO-6E72VCQL-BSs-SHef.js} +1 -1
- package/dist-renderer/assets/{oc-FR-POXYY2M6-TRLIkgml.js → oc-FR-POXYY2M6-fLrkwS2M.js} +1 -1
- package/dist-renderer/assets/{pa-IN-N4M65BXN-Dl7hF9RX.js → pa-IN-N4M65BXN-lqr6ro4k.js} +1 -1
- package/dist-renderer/assets/{percentages-BXMCSKIN-wBXtRqNn.js → percentages-BXMCSKIN-CcGqwI82.js} +7 -7
- package/dist-renderer/assets/{pica-CGZUgvhx.js → pica-CsoVhDGL.js} +1 -1
- package/dist-renderer/assets/{pieDiagram-8a3498a8-ZPRkRtpu.js → pieDiagram-8a3498a8-TG2guad1.js} +1 -1
- package/dist-renderer/assets/{pl-PL-T2D74RX3-DkwkT852.js → pl-PL-T2D74RX3-CdSVjK8j.js} +1 -1
- package/dist-renderer/assets/{pt-BR-5N22H2LF-BMFWH_jN.js → pt-BR-5N22H2LF-CLKJESeE.js} +1 -1
- package/dist-renderer/assets/{pt-PT-UZXXM6DQ-BPSC-yrG.js → pt-PT-UZXXM6DQ-C6P0W49t.js} +1 -1
- package/dist-renderer/assets/{quadrantDiagram-120e2f19-DB1TyNBK.js → quadrantDiagram-120e2f19-BRoTbIzZ.js} +1 -1
- package/dist-renderer/assets/{requirementDiagram-deff3bca-DqVc_A29.js → requirementDiagram-deff3bca-C3uaot9h.js} +1 -1
- package/dist-renderer/assets/{ro-RO-JPDTUUEW-CgkEXyU-.js → ro-RO-JPDTUUEW-DriQxnmt.js} +1 -1
- package/dist-renderer/assets/{ru-RU-B4JR7IUQ-BJIahd0q.js → ru-RU-B4JR7IUQ-CxQ01ey-.js} +1 -1
- package/dist-renderer/assets/{sankeyDiagram-04a897e0-DZqGbQ0e.js → sankeyDiagram-04a897e0-CnvkX9pX.js} +1 -1
- package/dist-renderer/assets/{sequenceDiagram-704730f1-D0Q04jBP.js → sequenceDiagram-704730f1-aEouT8p6.js} +1 -1
- package/dist-renderer/assets/{si-LK-N5RQ5JYF-DZ97xsfW.js → si-LK-N5RQ5JYF-CV8Pu1aJ.js} +1 -1
- package/dist-renderer/assets/{sk-SK-C5VTKIMK-3O0GcaTE.js → sk-SK-C5VTKIMK-DDgRCRI0.js} +1 -1
- package/dist-renderer/assets/{sl-SI-NN7IZMDC-x_-Ca4Po.js → sl-SI-NN7IZMDC-YDda-RwR.js} +1 -1
- package/dist-renderer/assets/{stateDiagram-587899a1-BkW3tbK-.js → stateDiagram-587899a1-D6akiRDN.js} +1 -1
- package/dist-renderer/assets/{stateDiagram-v2-d93cdb3a-CZYVILLk.js → stateDiagram-v2-d93cdb3a-gvz5zeGn.js} +1 -1
- package/dist-renderer/assets/{styles-6aaf32cf-BQKVAqEs.js → styles-6aaf32cf-BcHCt677.js} +1 -1
- package/dist-renderer/assets/{styles-9a916d00-DTjDY-zu.js → styles-9a916d00-BBaXvwsx.js} +1 -1
- package/dist-renderer/assets/{styles-c10674c1-CviHLZ2K.js → styles-c10674c1-DqIcUSxt.js} +1 -1
- package/dist-renderer/assets/{subset-shared.chunk-DIxPfZhi.js → subset-shared.chunk-S20joIBg.js} +1 -1
- package/dist-renderer/assets/{subset-worker.chunk-DDMwauN2.js → subset-worker.chunk-pDuYq8bJ.js} +1 -1
- package/dist-renderer/assets/{sv-SE-XGPEYMSR-DmtUCQiw.js → sv-SE-XGPEYMSR-Bgr_wBxE.js} +1 -1
- package/dist-renderer/assets/{svgDrawCommon-08f97a94-B6bAmadW.js → svgDrawCommon-08f97a94-BubXvRJb.js} +1 -1
- package/dist-renderer/assets/{ta-IN-2NMHFXQM-D7fiXwNW.js → ta-IN-2NMHFXQM-DMEKGupe.js} +1 -1
- package/dist-renderer/assets/{th-TH-HPSO5L25-D_F5D_Tj.js → th-TH-HPSO5L25-Bbz5ouCQ.js} +1 -1
- package/dist-renderer/assets/{timeline-definition-85554ec2-BZuaxri2.js → timeline-definition-85554ec2-ClLLYM_x.js} +1 -1
- package/dist-renderer/assets/{tr-TR-DEFEU3FU-CzwSWbpN.js → tr-TR-DEFEU3FU-B208BWXV.js} +1 -1
- package/dist-renderer/assets/{uk-UA-QMV73CPH-BaaxaBLn.js → uk-UA-QMV73CPH-B34h_DiI.js} +1 -1
- package/dist-renderer/assets/{vi-VN-M7AON7JQ-BQ9szPme.js → vi-VN-M7AON7JQ-BuDqd7xN.js} +1 -1
- package/dist-renderer/assets/{xychartDiagram-e933f94c-7rTYP6vy.js → xychartDiagram-e933f94c-B176yJLm.js} +1 -1
- package/dist-renderer/assets/{zh-CN-LNUGB5OW-DDjjE3j0.js → zh-CN-LNUGB5OW-DXZTQsAk.js} +1 -1
- package/dist-renderer/assets/{zh-HK-E62DVLB3-CUaw1jmU.js → zh-HK-E62DVLB3-ho9ioNpE.js} +1 -1
- package/dist-renderer/assets/{zh-TW-RAJ6MFWO-BFOuD9P0.js → zh-TW-RAJ6MFWO-Cjm_oNAG.js} +1 -1
- package/dist-renderer/icon.png +0 -0
- package/dist-renderer/index.html +3 -3
- package/package.json +2 -1
- package/skills/council-install/SKILL.md +9 -9
- package/dist-renderer/assets/channel-D6rvl4sk.js +0 -1
- package/dist-renderer/assets/clone-ya1OS7ZU.js +0 -1
- package/dist-renderer/assets/flowDiagram-v2-96b9c2cf-DMQnUrJv.js +0 -1
- package/dist-renderer/assets/index-BF6L2_KC.css +0 -1
package/dist-electron/main.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { shell as
|
|
2
|
-
import { join as u, basename as C, resolve as
|
|
3
|
-
import { fileURLToPath as
|
|
4
|
-
import { existsSync as v, writeFileSync as
|
|
5
|
-
import { readFile as y, readdir as
|
|
1
|
+
import { shell as ee, dialog as ke, app as L, protocol as me, Menu as te, net as ve, BrowserWindow as pe, ipcMain as _e } from "electron";
|
|
2
|
+
import { join as u, basename as C, resolve as J, dirname as Ee } from "node:path";
|
|
3
|
+
import { fileURLToPath as Ae, pathToFileURL as Ie } from "node:url";
|
|
4
|
+
import { existsSync as v, writeFileSync as Se, appendFileSync as Oe } from "node:fs";
|
|
5
|
+
import { readFile as y, readdir as z, stat as fe, mkdir as N, rm as G, writeFile as $, appendFile as Pe } from "node:fs/promises";
|
|
6
6
|
import { execFile as U } from "node:child_process";
|
|
7
7
|
import { promisify as R } from "node:util";
|
|
8
8
|
import { homedir as w } from "node:os";
|
|
9
|
-
import
|
|
9
|
+
import V from "gray-matter";
|
|
10
10
|
import { z as k } from "zod";
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import { GoogleGenerativeAI as
|
|
14
|
-
import { Ollama as
|
|
15
|
-
import { createRequire as
|
|
11
|
+
import $e from "@anthropic-ai/sdk";
|
|
12
|
+
import Ce from "openai";
|
|
13
|
+
import { GoogleGenerativeAI as Ne } from "@google/generative-ai";
|
|
14
|
+
import { Ollama as xe } from "ollama";
|
|
15
|
+
import { createRequire as Ue } from "node:module";
|
|
16
16
|
import "dotenv/config";
|
|
17
|
-
const
|
|
17
|
+
const Re = k.object({
|
|
18
18
|
name: k.string(),
|
|
19
19
|
description: k.string(),
|
|
20
20
|
interests: k.array(k.string()).default([]),
|
|
@@ -23,24 +23,24 @@ const Ue = k.object({
|
|
|
23
23
|
skills: k.array(k.string()).default([]),
|
|
24
24
|
temperature: k.number().min(0).max(2).optional(),
|
|
25
25
|
avatar: k.string().optional()
|
|
26
|
-
}),
|
|
26
|
+
}), Te = (n, r) => [
|
|
27
27
|
u(n, "skills", r, "SKILL.md"),
|
|
28
28
|
u(process.cwd(), ".claude", "skills", r, "SKILL.md"),
|
|
29
29
|
u(w(), ".agents", "skills", r, "SKILL.md"),
|
|
30
30
|
u(w(), ".claude", "skills", r, "SKILL.md")
|
|
31
31
|
];
|
|
32
|
-
async function
|
|
33
|
-
for (const t of
|
|
32
|
+
async function Le(n, r) {
|
|
33
|
+
for (const t of Te(r, n))
|
|
34
34
|
if (v(t)) {
|
|
35
|
-
const e = await y(t, "utf-8"), { content: o } =
|
|
35
|
+
const e = await y(t, "utf-8"), { content: o } = V(e);
|
|
36
36
|
return o.trim();
|
|
37
37
|
}
|
|
38
38
|
return null;
|
|
39
39
|
}
|
|
40
|
-
async function
|
|
40
|
+
async function De(n, r) {
|
|
41
41
|
const t = [];
|
|
42
42
|
for (const e of n) {
|
|
43
|
-
const o = await
|
|
43
|
+
const o = await Le(e, r);
|
|
44
44
|
o && t.push(`## Skill: ${e}
|
|
45
45
|
|
|
46
46
|
${o}`);
|
|
@@ -49,10 +49,10 @@ ${o}`);
|
|
|
49
49
|
|
|
50
50
|
`);
|
|
51
51
|
}
|
|
52
|
-
function
|
|
52
|
+
function Ke(n, r) {
|
|
53
53
|
return n ? n.startsWith("http://") || n.startsWith("https://") ? n : `council-file://${n.startsWith("/") ? n : u(r, n)}` : void 0;
|
|
54
54
|
}
|
|
55
|
-
async function
|
|
55
|
+
async function je(n, r) {
|
|
56
56
|
const t = /\{\{(.+?)\}\}/g;
|
|
57
57
|
let e = n;
|
|
58
58
|
for (const o of n.matchAll(t)) {
|
|
@@ -65,14 +65,14 @@ async function Ke(n, r) {
|
|
|
65
65
|
}
|
|
66
66
|
return e;
|
|
67
67
|
}
|
|
68
|
-
async function
|
|
69
|
-
const r =
|
|
68
|
+
async function ne(n) {
|
|
69
|
+
const r = J(n), t = u(r, "ABOUT.md");
|
|
70
70
|
if (!v(t))
|
|
71
71
|
throw new Error(`No ABOUT.md found in ${r}`);
|
|
72
|
-
const e = await y(t, "utf-8"), { data: o, content: s } =
|
|
73
|
-
let i = await
|
|
72
|
+
const e = await y(t, "utf-8"), { data: o, content: s } = V(e), a = Re.parse(o);
|
|
73
|
+
let i = await je(s.trim(), r);
|
|
74
74
|
if (a.skills.length > 0) {
|
|
75
|
-
const l = await
|
|
75
|
+
const l = await De(a.skills, r);
|
|
76
76
|
l && (i += `
|
|
77
77
|
|
|
78
78
|
` + l);
|
|
@@ -82,51 +82,51 @@ async function ee(n) {
|
|
|
82
82
|
frontmatter: a,
|
|
83
83
|
systemPrompt: i,
|
|
84
84
|
dirPath: r,
|
|
85
|
-
avatarUrl:
|
|
85
|
+
avatarUrl: Ke(a.avatar, r)
|
|
86
86
|
};
|
|
87
87
|
}
|
|
88
|
-
async function
|
|
88
|
+
async function oe(n, r) {
|
|
89
89
|
const t = [], e = /* @__PURE__ */ new Set();
|
|
90
90
|
if (r?.length) {
|
|
91
91
|
for (const o of r)
|
|
92
92
|
if (v(u(o, "ABOUT.md")))
|
|
93
93
|
try {
|
|
94
|
-
const s = await
|
|
94
|
+
const s = await ne(o);
|
|
95
95
|
e.has(s.id) || (t.push(s), e.add(s.id));
|
|
96
96
|
} catch {
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
if (v(n)) {
|
|
100
|
-
const o = await
|
|
100
|
+
const o = await z(n);
|
|
101
101
|
for (const s of o) {
|
|
102
102
|
const a = u(n, s);
|
|
103
|
-
(await fe(a)).isDirectory() && v(u(a, "ABOUT.md")) && (e.has(C(a)) || (t.push(await
|
|
103
|
+
(await fe(a)).isDirectory() && v(u(a, "ABOUT.md")) && (e.has(C(a)) || (t.push(await ne(a)), e.add(C(a))));
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
if (t.length === 0)
|
|
107
107
|
throw new Error(`No counsellors found in ${n}. Each counsellor needs a directory with an ABOUT.md file.`);
|
|
108
108
|
return t;
|
|
109
109
|
}
|
|
110
|
-
const
|
|
111
|
-
async function
|
|
110
|
+
const Be = R(U), he = u(w(), ".ai-council", "config.json"), se = u(w(), ".ai-council", "counsellors");
|
|
111
|
+
async function X() {
|
|
112
112
|
try {
|
|
113
|
-
return JSON.parse(await y(
|
|
113
|
+
return JSON.parse(await y(he, "utf-8"));
|
|
114
114
|
} catch {
|
|
115
115
|
return { backends: {} };
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
|
-
async function
|
|
118
|
+
async function Q(n) {
|
|
119
119
|
const r = u(w(), ".ai-council");
|
|
120
|
-
await N(r, { recursive: !0 }), await $(
|
|
120
|
+
await N(r, { recursive: !0 }), await $(he, JSON.stringify(n, null, 2), "utf-8");
|
|
121
121
|
}
|
|
122
|
-
function
|
|
122
|
+
function re(n) {
|
|
123
123
|
return Object.values(n.counsellors ?? {}).map((r) => r.path);
|
|
124
124
|
}
|
|
125
|
-
async function
|
|
126
|
-
const r =
|
|
125
|
+
async function Ge(n) {
|
|
126
|
+
const r = J(n), t = u(r, "ABOUT.md");
|
|
127
127
|
if (!v(t))
|
|
128
128
|
throw new Error(`No ABOUT.md found in ${r}`);
|
|
129
|
-
const e = C(r), o = await
|
|
129
|
+
const e = C(r), o = await X(), s = o.counsellors ?? {};
|
|
130
130
|
if (s[e])
|
|
131
131
|
throw new Error(`Counsellor "${e}" is already registered (path: ${s[e].path})`);
|
|
132
132
|
const l = (await y(t, "utf-8")).match(/^name:\s*["']?(.+?)["']?\s*$/m)?.[1] ?? e;
|
|
@@ -134,15 +134,15 @@ async function Be(n) {
|
|
|
134
134
|
path: r,
|
|
135
135
|
source: "local",
|
|
136
136
|
addedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
137
|
-
}, o.counsellors = s, await
|
|
137
|
+
}, o.counsellors = s, await Q(o), { id: e, name: l };
|
|
138
138
|
}
|
|
139
|
-
async function
|
|
140
|
-
await N(
|
|
141
|
-
const r = C(n, ".git").replace(/\.git$/, ""), t = u(
|
|
139
|
+
async function Fe(n) {
|
|
140
|
+
await N(se, { recursive: !0 });
|
|
141
|
+
const r = C(n, ".git").replace(/\.git$/, ""), t = u(se, r);
|
|
142
142
|
if (v(t))
|
|
143
143
|
throw new Error(`Directory already exists: ${t}. Remove it first or use a different URL.`);
|
|
144
|
-
await
|
|
145
|
-
const e = [], o = await
|
|
144
|
+
await Be("git", ["clone", "--depth", "1", n, t]);
|
|
145
|
+
const e = [], o = await X(), s = o.counsellors ?? {};
|
|
146
146
|
if (v(u(t, "ABOUT.md"))) {
|
|
147
147
|
const a = r;
|
|
148
148
|
if (s[a])
|
|
@@ -155,35 +155,35 @@ async function Ge(n) {
|
|
|
155
155
|
addedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
156
156
|
}, e.push({ id: a, name: c });
|
|
157
157
|
} else {
|
|
158
|
-
const a = await
|
|
158
|
+
const a = await z(t);
|
|
159
159
|
for (const i of a) {
|
|
160
160
|
if (i.startsWith(".")) continue;
|
|
161
161
|
const l = u(t, i);
|
|
162
162
|
if ((await fe(l)).isDirectory() && v(u(l, "ABOUT.md"))) {
|
|
163
163
|
const m = i;
|
|
164
164
|
if (s[m]) continue;
|
|
165
|
-
const
|
|
165
|
+
const f = (await y(u(l, "ABOUT.md"), "utf-8")).match(/^name:\s*["']?(.+?)["']?\s*$/m)?.[1] ?? m;
|
|
166
166
|
s[m] = {
|
|
167
167
|
path: l,
|
|
168
168
|
source: "git",
|
|
169
169
|
url: n,
|
|
170
170
|
addedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
171
|
-
}, e.push({ id: m, name:
|
|
171
|
+
}, e.push({ id: m, name: f });
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
174
|
if (e.length === 0)
|
|
175
|
-
throw await
|
|
175
|
+
throw await G(t, { recursive: !0, force: !0 }), new Error("No counsellors found in cloned repository (no ABOUT.md files)");
|
|
176
176
|
}
|
|
177
|
-
return o.counsellors = s, await
|
|
177
|
+
return o.counsellors = s, await Q(o), e;
|
|
178
178
|
}
|
|
179
|
-
async function
|
|
180
|
-
const t = await
|
|
179
|
+
async function We(n, r = !1) {
|
|
180
|
+
const t = await X(), e = t.counsellors ?? {}, o = e[n];
|
|
181
181
|
if (!o)
|
|
182
182
|
throw new Error(`Counsellor "${n}" is not registered`);
|
|
183
|
-
r && o.source === "git" && v(o.path) && await
|
|
183
|
+
r && o.source === "git" && v(o.path) && await G(o.path, { recursive: !0, force: !0 }), delete e[n], t.counsellors = e, await Q(t);
|
|
184
184
|
}
|
|
185
|
-
function
|
|
186
|
-
const r = new
|
|
185
|
+
function Me(n) {
|
|
186
|
+
const r = new $e({
|
|
187
187
|
apiKey: n.apiKey ?? process.env.ANTHROPIC_API_KEY,
|
|
188
188
|
...n.baseUrl ? { baseURL: n.baseUrl } : {}
|
|
189
189
|
});
|
|
@@ -234,7 +234,7 @@ function We(n) {
|
|
|
234
234
|
};
|
|
235
235
|
}
|
|
236
236
|
function Ye(n) {
|
|
237
|
-
const r = new
|
|
237
|
+
const r = new Ce({
|
|
238
238
|
apiKey: n.apiKey ?? process.env.OPENAI_API_KEY,
|
|
239
239
|
...n.baseUrl ? { baseURL: n.baseUrl } : {}
|
|
240
240
|
});
|
|
@@ -285,8 +285,8 @@ function Ye(n) {
|
|
|
285
285
|
}
|
|
286
286
|
};
|
|
287
287
|
}
|
|
288
|
-
function
|
|
289
|
-
const r = n.apiKey ?? process.env.GOOGLE_API_KEY ?? "", t = new
|
|
288
|
+
function He(n) {
|
|
289
|
+
const r = n.apiKey ?? process.env.GOOGLE_API_KEY ?? "", t = new Ne(r);
|
|
290
290
|
return {
|
|
291
291
|
name: "google",
|
|
292
292
|
defaultModel: "gemini-2.0-flash",
|
|
@@ -336,7 +336,7 @@ function Me(n) {
|
|
|
336
336
|
};
|
|
337
337
|
}
|
|
338
338
|
function Je(n) {
|
|
339
|
-
const r = new
|
|
339
|
+
const r = new xe({
|
|
340
340
|
host: n.baseUrl ?? "http://localhost:11434"
|
|
341
341
|
});
|
|
342
342
|
return {
|
|
@@ -389,14 +389,14 @@ function Je(n) {
|
|
|
389
389
|
}
|
|
390
390
|
};
|
|
391
391
|
}
|
|
392
|
-
const
|
|
393
|
-
anthropic:
|
|
392
|
+
const ae = {
|
|
393
|
+
anthropic: Me,
|
|
394
394
|
openai: Ye,
|
|
395
|
-
google:
|
|
395
|
+
google: He,
|
|
396
396
|
ollama: Je
|
|
397
397
|
};
|
|
398
398
|
let T = null;
|
|
399
|
-
async function
|
|
399
|
+
async function ze() {
|
|
400
400
|
if (T) return T;
|
|
401
401
|
const n = u(w(), ".ai-council", "config.json");
|
|
402
402
|
try {
|
|
@@ -407,23 +407,23 @@ async function He() {
|
|
|
407
407
|
}
|
|
408
408
|
return T;
|
|
409
409
|
}
|
|
410
|
-
const
|
|
411
|
-
function
|
|
412
|
-
T = null,
|
|
410
|
+
const H = /* @__PURE__ */ new Map();
|
|
411
|
+
function Ve() {
|
|
412
|
+
T = null, H.clear();
|
|
413
413
|
}
|
|
414
|
-
async function
|
|
415
|
-
const r =
|
|
414
|
+
async function F(n) {
|
|
415
|
+
const r = H.get(n);
|
|
416
416
|
if (r) return r;
|
|
417
|
-
const t =
|
|
417
|
+
const t = ae[n];
|
|
418
418
|
if (!t)
|
|
419
|
-
throw new Error(`Unknown backend: "${n}". Available: ${Object.keys(
|
|
420
|
-
const o = (await
|
|
421
|
-
return
|
|
419
|
+
throw new Error(`Unknown backend: "${n}". Available: ${Object.keys(ae).join(", ")}`);
|
|
420
|
+
const o = (await ze()).backends[n] ?? {}, s = t(o);
|
|
421
|
+
return H.set(n, s), s;
|
|
422
422
|
}
|
|
423
|
-
function
|
|
423
|
+
function Xe() {
|
|
424
424
|
return '\n## Excalidraw Element Reference\n\nOutput a JSON array of Excalidraw elements. Each element needs these fields:\n\n### Common Fields (all elements)\n- `type`: "rectangle" | "ellipse" | "diamond" | "text" | "arrow" | "line"\n- `id`: unique string (e.g. "rect1", "text1", "arrow1")\n- `x`, `y`: number (top-left origin, x increases right, y increases down)\n- `width`, `height`: number\n- `strokeColor`: hex string (e.g. "#1e1e1e")\n- `backgroundColor`: hex string or "transparent"\n- `fillStyle`: "solid" | "hachure" | "cross-hatch"\n- `strokeWidth`: 1 | 2 | 4\n- `roughness`: 0 (sharp) | 1 (sketchy)\n- `opacity`: 100\n- `angle`: 0\n- `seed`: any integer (e.g. 1)\n- `version`: 1\n- `isDeleted`: false\n- `groupIds`: []\n- `boundElements`: null or array of { id: string, type: "text" | "arrow" }\n- `link`: null\n- `locked`: false\n\n### Text Elements\nAdditional fields: `text`, `fontSize` (16-24), `fontFamily` (1=hand, 2=normal, 3=mono), `textAlign` ("left"|"center"|"right"), `verticalAlign` ("top"|"middle"), `baseline`: 0, `containerId`: null or parent shape id\n\n### Arrow/Line Elements\nAdditional fields: `points` (array of [x,y] relative to element x,y — first point always [0,0]), `startBinding` and `endBinding`: null or { elementId: string, focus: 0, gap: 5 }, `lastCommittedPoint`: null, `startArrowhead`: null, `endArrowhead`: "arrow" | null\n\n### Color Palette\n- Blue: "#1971c2", Light blue bg: "#a5d8ff"\n- Green: "#2f9e44", Light green bg: "#b2f2bb"\n- Red: "#e03131", Light red bg: "#ffc9c9"\n- Orange: "#e8590c", Light orange bg: "#ffd8a8"\n- Purple: "#7048e8", Light purple bg: "#d0bfff"\n- Yellow: "#f08c00", Light yellow bg: "#ffec99"\n- Gray: "#868e96", Light gray bg: "#dee2e6"\n- Dark: "#1e1e1e"\n\n### Layout Tips\n- Space shapes ~200px apart horizontally, ~150px vertically\n- Typical shape size: 160×80 for rectangles, 120×60 for ellipses\n- Center text inside shapes using containerId\n- Use arrows to show relationships (agreement, disagreement, influence)\n\n### Compact Example\n```json\n[\n {"type":"rectangle","id":"r1","x":50,"y":50,"width":160,"height":80,"strokeColor":"#1971c2","backgroundColor":"#a5d8ff","fillStyle":"solid","strokeWidth":2,"roughness":1,"opacity":100,"angle":0,"seed":1,"version":1,"isDeleted":false,"groupIds":[],"boundElements":[{"id":"t1","type":"text"},{"id":"a1","type":"arrow"}],"link":null,"locked":false},\n {"type":"text","id":"t1","x":60,"y":70,"width":140,"height":40,"text":"Counsellor A","fontSize":16,"fontFamily":2,"textAlign":"center","verticalAlign":"middle","baseline":0,"containerId":"r1","strokeColor":"#1e1e1e","backgroundColor":"transparent","fillStyle":"solid","strokeWidth":1,"roughness":0,"opacity":100,"angle":0,"seed":2,"version":1,"isDeleted":false,"groupIds":[],"boundElements":null,"link":null,"locked":false},\n {"type":"rectangle","id":"r2","x":350,"y":50,"width":160,"height":80,"strokeColor":"#2f9e44","backgroundColor":"#b2f2bb","fillStyle":"solid","strokeWidth":2,"roughness":1,"opacity":100,"angle":0,"seed":3,"version":1,"isDeleted":false,"groupIds":[],"boundElements":[{"id":"t2","type":"text"},{"id":"a1","type":"arrow"}],"link":null,"locked":false},\n {"type":"text","id":"t2","x":360,"y":70,"width":140,"height":40,"text":"Counsellor B","fontSize":16,"fontFamily":2,"textAlign":"center","verticalAlign":"middle","baseline":0,"containerId":"r2","strokeColor":"#1e1e1e","backgroundColor":"transparent","fillStyle":"solid","strokeWidth":1,"roughness":0,"opacity":100,"angle":0,"seed":4,"version":1,"isDeleted":false,"groupIds":[],"boundElements":null,"link":null,"locked":false},\n {"type":"arrow","id":"a1","x":210,"y":90,"width":140,"height":0,"points":[[0,0],[140,0]],"startBinding":{"elementId":"r1","focus":0,"gap":5},"endBinding":{"elementId":"r2","focus":0,"gap":5},"startArrowhead":null,"endArrowhead":"arrow","strokeColor":"#1e1e1e","backgroundColor":"transparent","fillStyle":"solid","strokeWidth":2,"roughness":1,"opacity":100,"angle":0,"seed":5,"version":1,"isDeleted":false,"groupIds":[],"boundElements":null,"link":null,"locked":false,"lastCommittedPoint":null}\n]\n```\n'.trim();
|
|
425
425
|
}
|
|
426
|
-
const
|
|
426
|
+
const W = "---EXCALIDRAW---", Qe = `You are the Secretary of a council discussion. Your job is to synthesize a clear, structured summary of the conversation that just took place.
|
|
427
427
|
|
|
428
428
|
Structure your summary with these sections:
|
|
429
429
|
|
|
@@ -440,7 +440,7 @@ Where did they disagree? What are the key tensions?
|
|
|
440
440
|
What are the most important takeaways? What would you recommend based on the full discussion?
|
|
441
441
|
|
|
442
442
|
Be concise but thorough. Use markdown formatting.`;
|
|
443
|
-
function
|
|
443
|
+
function Ze(n) {
|
|
444
444
|
const r = [];
|
|
445
445
|
r.push(`Topic: ${n.topic}`), r.push(`Counsellors: ${n.counsellors.map((e) => e.name).join(", ")}`), r.push(`Rounds: ${n.rounds}`), r.push("");
|
|
446
446
|
let t = 0;
|
|
@@ -449,7 +449,7 @@ function Qe(n) {
|
|
|
449
449
|
return r.join(`
|
|
450
450
|
`);
|
|
451
451
|
}
|
|
452
|
-
async function
|
|
452
|
+
async function qe({
|
|
453
453
|
result: n,
|
|
454
454
|
config: r,
|
|
455
455
|
onChunk: t,
|
|
@@ -458,11 +458,11 @@ async function Ze({
|
|
|
458
458
|
const o = r.secretary;
|
|
459
459
|
if (!o?.backend)
|
|
460
460
|
throw new Error("No secretary backend configured");
|
|
461
|
-
const s = await
|
|
461
|
+
const s = await F(o.backend), a = o.model ?? s.defaultModel, i = o.systemPrompt || Qe, l = Xe(), c = `${i}
|
|
462
462
|
|
|
463
463
|
${l}
|
|
464
464
|
|
|
465
|
-
After your text summary, output \`${
|
|
465
|
+
After your text summary, output \`${W}\` on its own line, then a JSON array of Excalidraw elements showing a visual map of where each counsellor stands on the topic. Use shapes for each counsellor with their name, arrows to show relationships (agreement/disagreement), and position them to visually represent the discussion dynamics.`, m = Ze(n), g = {
|
|
466
466
|
model: a,
|
|
467
467
|
systemPrompt: c,
|
|
468
468
|
messages: [{ role: "user", content: `Please summarize this council discussion and create a position diagram:
|
|
@@ -470,18 +470,18 @@ After your text summary, output \`${F}\` on its own line, then a JSON array of E
|
|
|
470
470
|
${m}` }],
|
|
471
471
|
temperature: 0.5
|
|
472
472
|
};
|
|
473
|
-
let
|
|
473
|
+
let p = "";
|
|
474
474
|
if (s.chatStream)
|
|
475
475
|
for await (const E of s.chatStream(g)) {
|
|
476
476
|
if (e?.aborted) break;
|
|
477
|
-
|
|
477
|
+
p += E.delta, E.delta && t && t(E.delta);
|
|
478
478
|
}
|
|
479
479
|
else
|
|
480
|
-
|
|
481
|
-
const
|
|
482
|
-
if (
|
|
483
|
-
return { text:
|
|
484
|
-
const d =
|
|
480
|
+
p = (await s.chat(g)).content, t && t(p);
|
|
481
|
+
const f = p.indexOf(W);
|
|
482
|
+
if (f === -1)
|
|
483
|
+
return { text: p.trim() };
|
|
484
|
+
const d = p.slice(0, f).trim(), h = p.slice(f + W.length).trim();
|
|
485
485
|
let b;
|
|
486
486
|
try {
|
|
487
487
|
const E = h.match(/\[[\s\S]*\]/);
|
|
@@ -490,8 +490,8 @@ ${m}` }],
|
|
|
490
490
|
}
|
|
491
491
|
return { text: d, diagram: b };
|
|
492
492
|
}
|
|
493
|
-
const
|
|
494
|
-
async function
|
|
493
|
+
const et = "You are the Secretary of a council debate. Briefly summarize this round of discussion. Note emerging agreements, disagreements, and shifts in position. 2-3 paragraphs max. Use markdown formatting.";
|
|
494
|
+
async function tt({
|
|
495
495
|
result: n,
|
|
496
496
|
roundNumber: r,
|
|
497
497
|
config: t,
|
|
@@ -501,13 +501,13 @@ async function et({
|
|
|
501
501
|
const s = t.secretary;
|
|
502
502
|
if (!s?.backend)
|
|
503
503
|
throw new Error("No secretary backend configured");
|
|
504
|
-
const a = await
|
|
504
|
+
const a = await F(s.backend), i = s.model ?? a.defaultModel, l = n.turns.filter((p) => p.round === r), c = [];
|
|
505
505
|
c.push(`Topic: ${n.topic}`), c.push(`Round ${r}${r === 1 ? " (Constructive)" : " (Rebuttal)"}`), c.push("");
|
|
506
|
-
for (const
|
|
507
|
-
c.push(`[${
|
|
506
|
+
for (const p of l)
|
|
507
|
+
c.push(`[${p.counsellorName}]:`), c.push(p.content), c.push("");
|
|
508
508
|
const m = {
|
|
509
509
|
model: i,
|
|
510
|
-
systemPrompt:
|
|
510
|
+
systemPrompt: et,
|
|
511
511
|
messages: [{ role: "user", content: `Please summarize this round:
|
|
512
512
|
|
|
513
513
|
${c.join(`
|
|
@@ -516,15 +516,15 @@ ${c.join(`
|
|
|
516
516
|
};
|
|
517
517
|
let g = "";
|
|
518
518
|
if (a.chatStream)
|
|
519
|
-
for await (const
|
|
519
|
+
for await (const p of a.chatStream(m)) {
|
|
520
520
|
if (o?.aborted) break;
|
|
521
|
-
g +=
|
|
521
|
+
g += p.delta, p.delta && e && e(p.delta);
|
|
522
522
|
}
|
|
523
523
|
else
|
|
524
524
|
g = (await a.chat(m)).content, e && e(g);
|
|
525
525
|
return g.trim();
|
|
526
526
|
}
|
|
527
|
-
async function
|
|
527
|
+
async function nt({
|
|
528
528
|
topic: n,
|
|
529
529
|
firstRoundTurns: r,
|
|
530
530
|
config: t
|
|
@@ -532,7 +532,7 @@ async function tt({
|
|
|
532
532
|
const e = t.secretary;
|
|
533
533
|
if (!e?.backend)
|
|
534
534
|
throw new Error("No secretary backend configured");
|
|
535
|
-
const o = await
|
|
535
|
+
const o = await F(e.backend), s = e.model ?? o.defaultModel, a = r.map((l) => `[${l.counsellorName}]: ${l.content.slice(0, 300)}`).join(`
|
|
536
536
|
|
|
537
537
|
`);
|
|
538
538
|
return (await o.chat({
|
|
@@ -550,12 +550,12 @@ ${a}`
|
|
|
550
550
|
temperature: 0.3
|
|
551
551
|
})).content.trim().replace(/^["']+|["']+$/g, "").replace(/[.!?]+$/, "").trim();
|
|
552
552
|
}
|
|
553
|
-
const
|
|
554
|
-
let
|
|
555
|
-
async function
|
|
556
|
-
|
|
553
|
+
const ge = u(w(), ".ai-council"), ot = u(ge, "council.log");
|
|
554
|
+
let ie = !1;
|
|
555
|
+
async function st() {
|
|
556
|
+
ie || (await N(ge, { recursive: !0 }), ie = !0);
|
|
557
557
|
}
|
|
558
|
-
function
|
|
558
|
+
function rt(n, r, t, e) {
|
|
559
559
|
let s = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${n} [${r}] ${t}`;
|
|
560
560
|
if (e !== void 0) {
|
|
561
561
|
const a = e instanceof Error ? `${e.message}
|
|
@@ -567,18 +567,18 @@ ${e.stack ?? ""}` : typeof e == "string" ? e : JSON.stringify(e, null, 2);
|
|
|
567
567
|
return s + `
|
|
568
568
|
`;
|
|
569
569
|
}
|
|
570
|
-
async function
|
|
570
|
+
async function M(n, r, t, e) {
|
|
571
571
|
try {
|
|
572
|
-
await
|
|
572
|
+
await st(), await Pe(ot, rt(n, r, t, e));
|
|
573
573
|
} catch {
|
|
574
574
|
}
|
|
575
575
|
}
|
|
576
576
|
const O = {
|
|
577
|
-
info: (n, r, t) =>
|
|
578
|
-
warn: (n, r, t) =>
|
|
579
|
-
error: (n, r, t) =>
|
|
577
|
+
info: (n, r, t) => M("INFO", n, r, t),
|
|
578
|
+
warn: (n, r, t) => M("WARN", n, r, t),
|
|
579
|
+
error: (n, r, t) => M("ERROR", n, r, t)
|
|
580
580
|
};
|
|
581
|
-
function
|
|
581
|
+
function at(n, r, t) {
|
|
582
582
|
const e = [{ role: "user", content: n }];
|
|
583
583
|
for (const o of r)
|
|
584
584
|
o.counsellorId === t ? e.push({ role: "assistant", content: o.content }) : e.push({
|
|
@@ -587,7 +587,7 @@ function rt(n, r, t) {
|
|
|
587
587
|
});
|
|
588
588
|
return e;
|
|
589
589
|
}
|
|
590
|
-
function
|
|
590
|
+
function it(n, r, t, e) {
|
|
591
591
|
const o = [{ role: "user", content: n }];
|
|
592
592
|
if (e === 1)
|
|
593
593
|
return o;
|
|
@@ -610,7 +610,7 @@ function at(n, r, t, e) {
|
|
|
610
610
|
i.counsellorId === t && i.round !== 1 && i.round !== a && i.round < e && o.push({ role: "assistant", content: i.content });
|
|
611
611
|
return o;
|
|
612
612
|
}
|
|
613
|
-
function
|
|
613
|
+
function ct(n, r) {
|
|
614
614
|
const t = [...n];
|
|
615
615
|
let e = r | 0;
|
|
616
616
|
const o = () => {
|
|
@@ -645,7 +645,7 @@ function Y(n, r, t, e, o, s) {
|
|
|
645
645
|
...n.mode === "debate" ? { mode: "debate" } : {}
|
|
646
646
|
};
|
|
647
647
|
}
|
|
648
|
-
async function
|
|
648
|
+
async function lt(n, r, t, e, o) {
|
|
649
649
|
let s;
|
|
650
650
|
typeof n == "string" ? s = {
|
|
651
651
|
topic: n,
|
|
@@ -658,86 +658,86 @@ async function ct(n, r, t, e, o) {
|
|
|
658
658
|
let l = 0, c = 0;
|
|
659
659
|
const m = s.mode === "debate", g = {};
|
|
660
660
|
O.info("conversation", `Starting ${m ? "debate" : "freeform"} — ${s.counsellors.length} counsellors, ${s.rounds} rounds`, {
|
|
661
|
-
counsellors: s.counsellors.map((
|
|
661
|
+
counsellors: s.counsellors.map((p) => `${p.frontmatter.name} (${p.frontmatter.backend}/${p.frontmatter.model ?? "default"})`),
|
|
662
662
|
topic: s.topic.slice(0, 200)
|
|
663
663
|
});
|
|
664
|
-
for (let
|
|
665
|
-
const
|
|
666
|
-
for (const d of
|
|
664
|
+
for (let p = 1; p <= s.rounds; p++) {
|
|
665
|
+
const f = m && p > 1 ? ct(s.counsellors, p) : s.counsellors;
|
|
666
|
+
for (const d of f) {
|
|
667
667
|
if (s.signal?.aborted)
|
|
668
668
|
return Y(s, i, a, l, c, g);
|
|
669
669
|
if (s.beforeTurn) {
|
|
670
670
|
const h = await s.beforeTurn();
|
|
671
671
|
h && (i.push(h), s.onEvent({ type: "turn_complete", turn: h }));
|
|
672
672
|
}
|
|
673
|
-
s.onEvent({ type: "turn_start", round:
|
|
673
|
+
s.onEvent({ type: "turn_start", round: p, counsellorName: d.frontmatter.name });
|
|
674
674
|
try {
|
|
675
|
-
const h = await
|
|
675
|
+
const h = await F(d.frontmatter.backend), b = d.frontmatter.model ?? h.defaultModel, E = m ? it(s.topic, i, d.id, p) : at(s.topic, i, d.id), Z = {
|
|
676
676
|
model: b,
|
|
677
677
|
systemPrompt: d.systemPrompt,
|
|
678
678
|
messages: E,
|
|
679
679
|
temperature: d.frontmatter.temperature
|
|
680
680
|
};
|
|
681
|
-
let
|
|
681
|
+
let D, x;
|
|
682
682
|
if (h.chatStream) {
|
|
683
|
-
|
|
684
|
-
for await (const S of h.chatStream(
|
|
683
|
+
D = "";
|
|
684
|
+
for await (const S of h.chatStream(Z)) {
|
|
685
685
|
if (s.signal?.aborted) break;
|
|
686
|
-
|
|
686
|
+
D += S.delta, S.delta && s.onEvent({ type: "turn_chunk", counsellorName: d.frontmatter.name, delta: S.delta }), S.tokenUsage && (x = S.tokenUsage);
|
|
687
687
|
}
|
|
688
688
|
} else {
|
|
689
|
-
const S = await h.chat(
|
|
690
|
-
|
|
689
|
+
const S = await h.chat(Z);
|
|
690
|
+
D = S.content, x = S.tokenUsage;
|
|
691
691
|
}
|
|
692
|
-
const
|
|
693
|
-
round:
|
|
692
|
+
const q = {
|
|
693
|
+
round: p,
|
|
694
694
|
counsellorId: d.id,
|
|
695
695
|
counsellorName: d.frontmatter.name,
|
|
696
|
-
content:
|
|
696
|
+
content: D,
|
|
697
697
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
698
698
|
model: b,
|
|
699
699
|
backend: d.frontmatter.backend,
|
|
700
700
|
tokenUsage: x,
|
|
701
701
|
avatarUrl: d.avatarUrl
|
|
702
702
|
};
|
|
703
|
-
x && (l += x.input, c += x.output), i.push(
|
|
703
|
+
x && (l += x.input, c += x.output), i.push(q), s.onEvent({ type: "turn_complete", turn: q });
|
|
704
704
|
} catch (h) {
|
|
705
705
|
const b = h instanceof Error ? h.message : String(h);
|
|
706
|
-
O.error("conversation", `Turn failed for ${d.frontmatter.name} (round ${
|
|
706
|
+
O.error("conversation", `Turn failed for ${d.frontmatter.name} (round ${p}, model ${d.frontmatter.model ?? "default"}, backend ${d.frontmatter.backend})`, h), s.onEvent({ type: "error", counsellorName: d.frontmatter.name, error: b });
|
|
707
707
|
}
|
|
708
708
|
}
|
|
709
|
-
if (s.onEvent({ type: "round_complete", round:
|
|
709
|
+
if (s.onEvent({ type: "round_complete", round: p }), m && s.config?.secretary?.backend && !s.signal?.aborted)
|
|
710
710
|
try {
|
|
711
711
|
const d = Y(s, i, a, l, c, g);
|
|
712
|
-
s.onEvent({ type: "round_summary_start", round:
|
|
713
|
-
const h = await
|
|
712
|
+
s.onEvent({ type: "round_summary_start", round: p });
|
|
713
|
+
const h = await tt({
|
|
714
714
|
result: d,
|
|
715
|
-
roundNumber:
|
|
715
|
+
roundNumber: p,
|
|
716
716
|
config: s.config,
|
|
717
717
|
onChunk: (b) => {
|
|
718
|
-
s.onEvent({ type: "round_summary_chunk", round:
|
|
718
|
+
s.onEvent({ type: "round_summary_chunk", round: p, delta: b });
|
|
719
719
|
},
|
|
720
720
|
signal: s.signal
|
|
721
721
|
});
|
|
722
|
-
g[
|
|
722
|
+
g[p] = h, s.onEvent({ type: "round_summary_complete", round: p, summary: h });
|
|
723
723
|
} catch (d) {
|
|
724
|
-
O.error("conversation", `Interim summary failed for round ${
|
|
724
|
+
O.error("conversation", `Interim summary failed for round ${p}`, d);
|
|
725
725
|
}
|
|
726
726
|
}
|
|
727
727
|
return Y(s, i, a, l, c, g);
|
|
728
728
|
}
|
|
729
729
|
const I = u(w(), ".ai-council", "history");
|
|
730
|
-
function
|
|
730
|
+
function ut(n) {
|
|
731
731
|
return n.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 40);
|
|
732
732
|
}
|
|
733
|
-
async function
|
|
733
|
+
async function dt(n) {
|
|
734
734
|
await N(I, { recursive: !0 });
|
|
735
|
-
const r = new Date(n.startedAt).toISOString().replace(/[:.]/g, "-").slice(0, 19), t =
|
|
735
|
+
const r = new Date(n.startedAt).toISOString().replace(/[:.]/g, "-").slice(0, 19), t = ut(n.topic), e = `${r}-${t}`, o = u(I, `${e}.json`);
|
|
736
736
|
return await $(o, JSON.stringify(n, null, 2), "utf-8"), e;
|
|
737
737
|
}
|
|
738
|
-
async function
|
|
738
|
+
async function mt() {
|
|
739
739
|
await N(I, { recursive: !0 });
|
|
740
|
-
const n = await
|
|
740
|
+
const n = await z(I), r = [];
|
|
741
741
|
for (const t of n)
|
|
742
742
|
if (t.endsWith(".json"))
|
|
743
743
|
try {
|
|
@@ -755,24 +755,24 @@ async function dt() {
|
|
|
755
755
|
}
|
|
756
756
|
return r.sort((t, e) => e.startedAt.localeCompare(t.startedAt));
|
|
757
757
|
}
|
|
758
|
-
async function
|
|
758
|
+
async function ce(n) {
|
|
759
759
|
const r = u(I, `${n}.json`), t = await y(r, "utf-8"), e = JSON.parse(t);
|
|
760
760
|
return e.infographic && !e.infographics && (e.infographics = [e.infographic], delete e.infographic), e;
|
|
761
761
|
}
|
|
762
|
-
async function
|
|
762
|
+
async function pt(n) {
|
|
763
763
|
const r = u(I, `${n}.json`);
|
|
764
|
-
await
|
|
764
|
+
await G(r);
|
|
765
765
|
}
|
|
766
766
|
async function ft(n, r) {
|
|
767
767
|
const t = u(I, `${n}.json`), e = await y(t, "utf-8"), o = JSON.parse(e);
|
|
768
768
|
o.infographics || (o.infographics = []), o.infographics.push(r), await $(t, JSON.stringify(o, null, 2), "utf-8");
|
|
769
769
|
}
|
|
770
|
-
async function
|
|
770
|
+
async function ht(n, r) {
|
|
771
771
|
const t = u(I, `${n}.json`), e = await y(t, "utf-8"), o = JSON.parse(e);
|
|
772
772
|
o.infographics && r >= 0 && r < o.infographics.length && o.infographics.splice(r, 1), await $(t, JSON.stringify(o, null, 2), "utf-8");
|
|
773
773
|
}
|
|
774
|
-
const
|
|
775
|
-
function
|
|
774
|
+
const ye = Ue(import.meta.url);
|
|
775
|
+
function gt(n) {
|
|
776
776
|
const r = n.counsellors.map((e) => e.name).join(", "), t = n.summary ?? n.turns.map((e) => `${e.counsellorName}: ${e.content.slice(0, 200)}`).join(`
|
|
777
777
|
`);
|
|
778
778
|
return [
|
|
@@ -784,13 +784,13 @@ function ht(n) {
|
|
|
784
784
|
"Include relevant icons and visual hierarchy. Use a horizontal landscape layout."
|
|
785
785
|
].join(" ");
|
|
786
786
|
}
|
|
787
|
-
function
|
|
787
|
+
function yt(n) {
|
|
788
788
|
if (n.infographic?.backend) return n.infographic.backend;
|
|
789
789
|
const r = !!(n.backends.google?.apiKey || process.env.GOOGLE_API_KEY), t = !!(n.backends.openai?.apiKey || process.env.OPENAI_API_KEY);
|
|
790
790
|
return r ? "google" : t ? "openai" : null;
|
|
791
791
|
}
|
|
792
|
-
async function
|
|
793
|
-
const t =
|
|
792
|
+
async function wt(n, r) {
|
|
793
|
+
const t = ye("openai").default, s = (await new t({
|
|
794
794
|
apiKey: r.backends.openai?.apiKey || process.env.OPENAI_API_KEY,
|
|
795
795
|
...r.backends.openai?.baseUrl ? { baseURL: r.backends.openai.baseUrl } : {}
|
|
796
796
|
}).images.generate({
|
|
@@ -802,8 +802,8 @@ async function yt(n, r) {
|
|
|
802
802
|
if (!s) throw new Error("No image data returned from OpenAI");
|
|
803
803
|
return s;
|
|
804
804
|
}
|
|
805
|
-
async function
|
|
806
|
-
const { GoogleGenAI: t } =
|
|
805
|
+
async function bt(n, r) {
|
|
806
|
+
const { GoogleGenAI: t } = ye("@google/genai"), e = r.backends.google?.apiKey || process.env.GOOGLE_API_KEY;
|
|
807
807
|
if (!e) throw new Error("No Google API key configured");
|
|
808
808
|
const a = (await new t({ apiKey: e }).models.generateContent({
|
|
809
809
|
model: "gemini-3-pro-image-preview",
|
|
@@ -818,24 +818,24 @@ async function wt(n, r) {
|
|
|
818
818
|
return i.inlineData.data;
|
|
819
819
|
throw new Error("No image data in Gemini response");
|
|
820
820
|
}
|
|
821
|
-
async function
|
|
822
|
-
const e = t ??
|
|
821
|
+
async function le(n, r, t) {
|
|
822
|
+
const e = t ?? yt(r);
|
|
823
823
|
if (!e) throw new Error("No image-capable backend configured (need OpenAI or Google API key)");
|
|
824
|
-
const o =
|
|
825
|
-
return e === "openai" ?
|
|
824
|
+
const o = gt(n);
|
|
825
|
+
return e === "openai" ? wt(o, r) : bt(o, r);
|
|
826
826
|
}
|
|
827
|
-
const
|
|
827
|
+
const we = {
|
|
828
828
|
anthropic: "https://api.anthropic.com",
|
|
829
829
|
openai: "https://api.openai.com/v1",
|
|
830
830
|
google: "https://generativelanguage.googleapis.com",
|
|
831
831
|
ollama: "http://localhost:11434"
|
|
832
|
-
},
|
|
832
|
+
}, ue = [
|
|
833
833
|
"claude-opus-4-20250514",
|
|
834
834
|
"claude-sonnet-4-5-20250514",
|
|
835
835
|
"claude-sonnet-4-20250514",
|
|
836
836
|
"claude-haiku-4-20250414",
|
|
837
837
|
"claude-3-5-haiku-20241022"
|
|
838
|
-
],
|
|
838
|
+
], K = [
|
|
839
839
|
"gemini-2.5-pro",
|
|
840
840
|
"gemini-2.5-flash",
|
|
841
841
|
"gemini-2.0-flash",
|
|
@@ -843,12 +843,12 @@ const ye = {
|
|
|
843
843
|
"gemini-1.5-pro",
|
|
844
844
|
"gemini-1.5-flash"
|
|
845
845
|
];
|
|
846
|
-
async function
|
|
846
|
+
async function kt(n, r) {
|
|
847
847
|
try {
|
|
848
848
|
switch (n) {
|
|
849
849
|
case "ollama": {
|
|
850
850
|
const { Ollama: t } = await import("ollama");
|
|
851
|
-
return { connected: !0, models: (await new t({ host: r.baseUrl ||
|
|
851
|
+
return { connected: !0, models: (await new t({ host: r.baseUrl || we.ollama }).list()).models.map((a) => a.name).sort() };
|
|
852
852
|
}
|
|
853
853
|
case "openai": {
|
|
854
854
|
const { default: t } = await import("openai");
|
|
@@ -865,32 +865,32 @@ async function bt(n, r) {
|
|
|
865
865
|
try {
|
|
866
866
|
return { connected: !0, models: (await e.models.list({ limit: 100 })).data.map((a) => a.id).sort() };
|
|
867
867
|
} catch {
|
|
868
|
-
return { connected: !0, models:
|
|
868
|
+
return { connected: !0, models: ue };
|
|
869
869
|
}
|
|
870
870
|
}
|
|
871
871
|
case "google": {
|
|
872
872
|
const t = r.apiKey || process.env.GOOGLE_API_KEY || "";
|
|
873
|
-
if (!t) return { connected: !1, models:
|
|
873
|
+
if (!t) return { connected: !1, models: K, error: "No API key" };
|
|
874
874
|
const e = await fetch(
|
|
875
875
|
`https://generativelanguage.googleapis.com/v1beta/models?key=${t}`
|
|
876
876
|
);
|
|
877
877
|
if (!e.ok) {
|
|
878
878
|
const i = (await e.json().catch(() => ({})))?.error?.message || `HTTP ${e.status}`;
|
|
879
|
-
return { connected: !1, models:
|
|
879
|
+
return { connected: !1, models: K, error: i };
|
|
880
880
|
}
|
|
881
881
|
const s = ((await e.json()).models || []).filter((a) => a.name.includes("gemini") && a.supportedGenerationMethods?.includes("generateContent")).map((a) => a.name.replace("models/", "")).sort();
|
|
882
|
-
return { connected: !0, models: s.length > 0 ? s :
|
|
882
|
+
return { connected: !0, models: s.length > 0 ? s : K };
|
|
883
883
|
}
|
|
884
884
|
default:
|
|
885
885
|
return { connected: !1, models: [], error: `Unknown backend: ${n}` };
|
|
886
886
|
}
|
|
887
887
|
} catch (t) {
|
|
888
888
|
const e = t instanceof Error ? t.message : String(t);
|
|
889
|
-
return { connected: !1, models: n === "anthropic" ?
|
|
889
|
+
return { connected: !1, models: n === "anthropic" ? ue : n === "google" ? K : [], error: e };
|
|
890
890
|
}
|
|
891
891
|
}
|
|
892
|
-
let A = null,
|
|
893
|
-
function
|
|
892
|
+
let A = null, j = [];
|
|
893
|
+
function vt(n, r) {
|
|
894
894
|
n.handle("counsellors:list", async (t, e) => {
|
|
895
895
|
const o = u(w(), ".ai-council", "config.json");
|
|
896
896
|
let s = { backends: {} };
|
|
@@ -899,8 +899,8 @@ function kt(n, r) {
|
|
|
899
899
|
s = JSON.parse(c);
|
|
900
900
|
} catch {
|
|
901
901
|
}
|
|
902
|
-
const a =
|
|
903
|
-
return (await
|
|
902
|
+
const a = re(s), i = s.counsellors ?? {};
|
|
903
|
+
return (await oe(e, a)).map((c) => {
|
|
904
904
|
const m = i[c.id];
|
|
905
905
|
return {
|
|
906
906
|
id: c.id,
|
|
@@ -917,7 +917,7 @@ function kt(n, r) {
|
|
|
917
917
|
};
|
|
918
918
|
});
|
|
919
919
|
}), n.handle("counsellors:get", async (t, e) => {
|
|
920
|
-
const o = u(e, "ABOUT.md"), s = await y(o, "utf-8"), { data: a, content: i } =
|
|
920
|
+
const o = u(e, "ABOUT.md"), s = await y(o, "utf-8"), { data: a, content: i } = V(s);
|
|
921
921
|
return { frontmatter: a, body: i.trim(), raw: s };
|
|
922
922
|
}), n.handle("counsellors:save", async (t, e, o) => {
|
|
923
923
|
const s = u(e, "ABOUT.md");
|
|
@@ -925,7 +925,7 @@ function kt(n, r) {
|
|
|
925
925
|
}), n.handle("counsellors:create", async (t, e, o, s) => {
|
|
926
926
|
const a = u(e, o);
|
|
927
927
|
return await N(a, { recursive: !0 }), await $(u(a, "ABOUT.md"), s, "utf-8"), { success: !0, dirPath: a };
|
|
928
|
-
}), n.handle("counsellors:delete", async (t, e) => (await
|
|
928
|
+
}), n.handle("counsellors:delete", async (t, e) => (await G(e, { recursive: !0, force: !0 }), { success: !0 })), n.handle("config:get", async () => {
|
|
929
929
|
const t = u(w(), ".ai-council", "config.json");
|
|
930
930
|
let e = { backends: {} };
|
|
931
931
|
try {
|
|
@@ -942,37 +942,37 @@ function kt(n, r) {
|
|
|
942
942
|
OPENAI_API_KEY: s(process.env.OPENAI_API_KEY),
|
|
943
943
|
GOOGLE_API_KEY: s(process.env.GOOGLE_API_KEY)
|
|
944
944
|
};
|
|
945
|
-
return { config: e, envStatus: o, envKeySuffix: a, defaultUrls:
|
|
946
|
-
}), n.handle("backend:probe", async (t, e, o) =>
|
|
945
|
+
return { config: e, envStatus: o, envKeySuffix: a, defaultUrls: we };
|
|
946
|
+
}), n.handle("backend:probe", async (t, e, o) => kt(e, o)), n.handle("config:save", async (t, e) => {
|
|
947
947
|
const o = u(w(), ".ai-council");
|
|
948
|
-
return await N(o, { recursive: !0 }), await $(u(o, "config.json"), JSON.stringify(e, null, 2), "utf-8"),
|
|
948
|
+
return await N(o, { recursive: !0 }), await $(u(o, "config.json"), JSON.stringify(e, null, 2), "utf-8"), Ve(), { success: !0 };
|
|
949
949
|
}), n.handle("discussion:start", async (t, e) => {
|
|
950
950
|
const o = r();
|
|
951
951
|
if (!o) return { error: "No window" };
|
|
952
|
-
A && A.abort(), A = new AbortController(),
|
|
952
|
+
A && A.abort(), A = new AbortController(), j = [];
|
|
953
953
|
const s = u(w(), ".ai-council", "config.json");
|
|
954
954
|
let a = { backends: {} };
|
|
955
955
|
try {
|
|
956
|
-
const
|
|
957
|
-
a = JSON.parse(
|
|
956
|
+
const f = await y(s, "utf-8");
|
|
957
|
+
a = JSON.parse(f);
|
|
958
958
|
} catch {
|
|
959
959
|
}
|
|
960
|
-
const i =
|
|
960
|
+
const i = re(a), l = await oe(e.councilDir, i), c = e.counsellorIds?.length ? l.filter((f) => e.counsellorIds.includes(f.id)) : l;
|
|
961
961
|
if (c.length === 0) {
|
|
962
962
|
o.webContents.send("discussion:event", { type: "error", counsellorName: "", error: "No counsellors found" });
|
|
963
963
|
return;
|
|
964
964
|
}
|
|
965
|
-
const m = (
|
|
966
|
-
o.isDestroyed() || o.webContents.send("discussion:event",
|
|
967
|
-
}, g = async () =>
|
|
965
|
+
const m = (f) => {
|
|
966
|
+
o.isDestroyed() || o.webContents.send("discussion:event", f);
|
|
967
|
+
}, g = async () => j.length === 0 ? null : {
|
|
968
968
|
round: 0,
|
|
969
969
|
counsellorId: "__user__",
|
|
970
970
|
counsellorName: "You",
|
|
971
|
-
content:
|
|
971
|
+
content: j.shift(),
|
|
972
972
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
973
973
|
model: "human",
|
|
974
974
|
backend: "human"
|
|
975
|
-
},
|
|
975
|
+
}, p = {
|
|
976
976
|
topic: e.topic,
|
|
977
977
|
topicSource: e.topicSource,
|
|
978
978
|
counsellors: c,
|
|
@@ -984,30 +984,30 @@ function kt(n, r) {
|
|
|
984
984
|
config: a
|
|
985
985
|
};
|
|
986
986
|
try {
|
|
987
|
-
const
|
|
987
|
+
const f = await lt(p);
|
|
988
988
|
if (a.secretary?.backend)
|
|
989
989
|
try {
|
|
990
990
|
m({ type: "summary_start" });
|
|
991
|
-
const d = await
|
|
992
|
-
result:
|
|
991
|
+
const d = await qe({
|
|
992
|
+
result: f,
|
|
993
993
|
config: a,
|
|
994
994
|
onChunk: (h) => {
|
|
995
995
|
m({ type: "summary_chunk", delta: h });
|
|
996
996
|
},
|
|
997
997
|
signal: A?.signal
|
|
998
998
|
});
|
|
999
|
-
|
|
999
|
+
f.summary = d.text, d.diagram && (f.diagram = d.diagram), m({ type: "summary_complete", summary: d.text, diagram: d.diagram });
|
|
1000
1000
|
} catch (d) {
|
|
1001
1001
|
O.error("ipc:discussion", "Secretary summary failed", d), m({ type: "error", counsellorName: "Secretary", error: d instanceof Error ? d.message : String(d) });
|
|
1002
1002
|
}
|
|
1003
1003
|
if (a.secretary?.backend)
|
|
1004
1004
|
try {
|
|
1005
|
-
const d =
|
|
1006
|
-
topic:
|
|
1005
|
+
const d = f.turns.filter((b) => b.round === 1), h = await nt({
|
|
1006
|
+
topic: f.topic,
|
|
1007
1007
|
firstRoundTurns: d,
|
|
1008
1008
|
config: a
|
|
1009
1009
|
});
|
|
1010
|
-
|
|
1010
|
+
f.title = h, m({ type: "title_generated", title: h });
|
|
1011
1011
|
} catch (d) {
|
|
1012
1012
|
O.error("ipc:discussion", "Title generation failed", d);
|
|
1013
1013
|
}
|
|
@@ -1015,24 +1015,24 @@ function kt(n, r) {
|
|
|
1015
1015
|
for (const d of e.infographicBackends)
|
|
1016
1016
|
try {
|
|
1017
1017
|
m({ type: "infographic_start" });
|
|
1018
|
-
const h = await
|
|
1019
|
-
|
|
1018
|
+
const h = await le(f, a, d);
|
|
1019
|
+
f.infographics || (f.infographics = []), f.infographics.push(h), m({ type: "infographic_complete", infographic: h });
|
|
1020
1020
|
} catch (h) {
|
|
1021
1021
|
O.error("ipc:discussion", `Infographic generation failed (${d})`, h), m({ type: "infographic_error", error: h instanceof Error ? h.message : String(h) });
|
|
1022
1022
|
}
|
|
1023
|
-
m({ type: "complete", result:
|
|
1023
|
+
m({ type: "complete", result: f });
|
|
1024
1024
|
try {
|
|
1025
|
-
await
|
|
1025
|
+
await dt(f);
|
|
1026
1026
|
} catch (d) {
|
|
1027
1027
|
O.error("ipc:discussion", "Failed to save to history", d);
|
|
1028
1028
|
}
|
|
1029
|
-
} catch (
|
|
1030
|
-
O.error("ipc:discussion", "Discussion failed",
|
|
1029
|
+
} catch (f) {
|
|
1030
|
+
O.error("ipc:discussion", "Discussion failed", f), m({ type: "error", counsellorName: "", error: f instanceof Error ? f.message : String(f) });
|
|
1031
1031
|
} finally {
|
|
1032
1032
|
A = null;
|
|
1033
1033
|
}
|
|
1034
|
-
}), n.handle("discussion:stop", async () => (A && (A.abort(), A = null), { success: !0 })), n.handle("discussion:inject", async (t, e) => (
|
|
1035
|
-
|
|
1034
|
+
}), n.handle("discussion:stop", async () => (A && (A.abort(), A = null), { success: !0 })), n.handle("discussion:inject", async (t, e) => (j.push(e), { success: !0 })), n.handle("registry:add-local", async (t, e) => Ge(e)), n.handle("registry:add-remote", async (t, e) => Fe(e)), n.handle("registry:remove", async (t, e, o) => (await We(e, o), { success: !0 })), n.handle("shell:open-in-finder", async (t, e) => {
|
|
1035
|
+
ee.showItemInFolder(u(e, "ABOUT.md"));
|
|
1036
1036
|
}), n.handle("shell:open-in-terminal", async (t, e) => {
|
|
1037
1037
|
await R(U)("open", ["-a", "Terminal", e]);
|
|
1038
1038
|
}), n.handle("shell:open-in-editor", async (t, e) => {
|
|
@@ -1040,9 +1040,9 @@ function kt(n, r) {
|
|
|
1040
1040
|
try {
|
|
1041
1041
|
await o("code", [e]);
|
|
1042
1042
|
} catch {
|
|
1043
|
-
|
|
1043
|
+
ee.openPath(e);
|
|
1044
1044
|
}
|
|
1045
|
-
}), n.handle("history:list", async () =>
|
|
1045
|
+
}), n.handle("history:list", async () => mt()), n.handle("history:get", async (t, e) => ce(e)), n.handle("history:delete", async (t, e) => (await pt(e), { success: !0 })), n.handle("infographic:generate", async (t, e, o) => {
|
|
1046
1046
|
const s = u(w(), ".ai-council", "config.json");
|
|
1047
1047
|
let a = { backends: {} };
|
|
1048
1048
|
try {
|
|
@@ -1050,9 +1050,9 @@ function kt(n, r) {
|
|
|
1050
1050
|
a = JSON.parse(c);
|
|
1051
1051
|
} catch {
|
|
1052
1052
|
}
|
|
1053
|
-
const i = await
|
|
1053
|
+
const i = await ce(e), l = await le(i, a, o);
|
|
1054
1054
|
return await ft(e, l), { infographic: l };
|
|
1055
|
-
}), n.handle("infographic:delete", async (t, e, o) => (await
|
|
1055
|
+
}), n.handle("infographic:delete", async (t, e, o) => (await ht(e, o), { success: !0 })), n.handle("file:read-as-text", async (t, e) => {
|
|
1056
1056
|
const o = C(e), s = o.includes(".") ? "." + o.split(".").pop().toLowerCase() : "", a = /* @__PURE__ */ new Set([
|
|
1057
1057
|
".txt",
|
|
1058
1058
|
".md",
|
|
@@ -1147,32 +1147,34 @@ function kt(n, r) {
|
|
|
1147
1147
|
}), n.handle("dialog:selectDirectory", async () => {
|
|
1148
1148
|
const t = r();
|
|
1149
1149
|
if (!t) return null;
|
|
1150
|
-
const e = await
|
|
1150
|
+
const e = await ke.showOpenDialog(t, {
|
|
1151
1151
|
properties: ["openDirectory"]
|
|
1152
1152
|
});
|
|
1153
1153
|
return e.canceled ? null : e.filePaths[0];
|
|
1154
1154
|
});
|
|
1155
1155
|
}
|
|
1156
|
-
const
|
|
1156
|
+
const _t = Ae(import.meta.url), B = Ee(_t), be = u(B, "..", "electron-debug.log");
|
|
1157
1157
|
function P(n, ...r) {
|
|
1158
1158
|
const t = `[${(/* @__PURE__ */ new Date()).toISOString()}] [${n}] ${r.map((e) => typeof e == "string" ? e : JSON.stringify(e)).join(" ")}
|
|
1159
1159
|
`;
|
|
1160
|
-
|
|
1160
|
+
Oe(be, t);
|
|
1161
1161
|
}
|
|
1162
|
-
|
|
1162
|
+
Se(be, `=== State Change Council Electron — started ${(/* @__PURE__ */ new Date()).toISOString()} ===
|
|
1163
1163
|
`);
|
|
1164
|
+
L.name = "State Change Council";
|
|
1164
1165
|
let _ = null;
|
|
1165
|
-
function
|
|
1166
|
-
P("main", "Creating BrowserWindow"), _ = new
|
|
1166
|
+
function de() {
|
|
1167
|
+
P("main", "Creating BrowserWindow"), _ = new pe({
|
|
1167
1168
|
width: 1200,
|
|
1168
1169
|
height: 800,
|
|
1169
1170
|
minWidth: 800,
|
|
1170
1171
|
minHeight: 600,
|
|
1171
|
-
title: "
|
|
1172
|
+
title: "State Change Council",
|
|
1173
|
+
icon: J(B, "..", "assets", "icon.png"),
|
|
1172
1174
|
webPreferences: {
|
|
1173
1175
|
contextIsolation: !0,
|
|
1174
1176
|
nodeIntegration: !1,
|
|
1175
|
-
preload: u(
|
|
1177
|
+
preload: u(B, "preload.mjs")
|
|
1176
1178
|
}
|
|
1177
1179
|
}), _.webContents.on("console-message", (r, t, e, o, s) => {
|
|
1178
1180
|
const a = ["DEBUG", "INFO", "WARN", "ERROR"][t] || "LOG";
|
|
@@ -1186,24 +1188,45 @@ function le() {
|
|
|
1186
1188
|
if (n)
|
|
1187
1189
|
P("main", `Loading dev server URL: ${n}`), _.loadURL(n);
|
|
1188
1190
|
else {
|
|
1189
|
-
const r = u(
|
|
1191
|
+
const r = u(B, "../dist-renderer/index.html");
|
|
1190
1192
|
P("main", `Loading file: ${r}`), _.loadFile(r);
|
|
1191
1193
|
}
|
|
1192
1194
|
process.env.VITE_DEV_SERVER_URL && _.webContents.openDevTools(), _.on("closed", () => {
|
|
1193
1195
|
_ = null;
|
|
1194
1196
|
});
|
|
1195
1197
|
}
|
|
1196
|
-
|
|
1198
|
+
me.registerSchemesAsPrivileged([
|
|
1197
1199
|
{ scheme: "council-file", privileges: { bypassCSP: !0, supportFetchAPI: !0 } }
|
|
1198
1200
|
]);
|
|
1199
|
-
|
|
1200
|
-
P("main", "App ready, registering IPC handlers")
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1201
|
+
L.whenReady().then(() => {
|
|
1202
|
+
P("main", "App ready, registering IPC handlers");
|
|
1203
|
+
const n = "State Change Council", r = [
|
|
1204
|
+
{
|
|
1205
|
+
label: n,
|
|
1206
|
+
submenu: [
|
|
1207
|
+
{ role: "about", label: `About ${n}` },
|
|
1208
|
+
{ type: "separator" },
|
|
1209
|
+
{ role: "services" },
|
|
1210
|
+
{ type: "separator" },
|
|
1211
|
+
{ role: "hide", label: `Hide ${n}` },
|
|
1212
|
+
{ role: "hideOthers" },
|
|
1213
|
+
{ role: "unhide" },
|
|
1214
|
+
{ type: "separator" },
|
|
1215
|
+
{ role: "quit", label: `Quit ${n}` }
|
|
1216
|
+
]
|
|
1217
|
+
},
|
|
1218
|
+
{ role: "fileMenu" },
|
|
1219
|
+
{ role: "editMenu" },
|
|
1220
|
+
{ role: "viewMenu" },
|
|
1221
|
+
{ role: "windowMenu" }
|
|
1222
|
+
];
|
|
1223
|
+
te.setApplicationMenu(te.buildFromTemplate(r)), me.handle("council-file", (t) => {
|
|
1224
|
+
const e = decodeURIComponent(t.url.replace("council-file://", ""));
|
|
1225
|
+
return ve.fetch(Ie(e).href);
|
|
1226
|
+
}), vt(_e, () => _), de(), L.on("activate", () => {
|
|
1227
|
+
pe.getAllWindows().length === 0 && de();
|
|
1205
1228
|
});
|
|
1206
1229
|
});
|
|
1207
|
-
|
|
1208
|
-
process.platform !== "darwin" &&
|
|
1230
|
+
L.on("window-all-closed", () => {
|
|
1231
|
+
process.platform !== "darwin" && L.quit();
|
|
1209
1232
|
});
|