@lih-x-x/kmr 1.0.54 → 1.0.56
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/dist/{chunk-ZXGVA5QX.js → chunk-JUAJGCUT.js} +5 -1
- package/dist/{chunk-WMK5MYOU.js → chunk-MTQECODE.js} +1 -1
- package/dist/{claudeCode-2OTK6CH4.js → claudeCode-AVQOOWP5.js} +2 -2
- package/dist/cli.js +11 -11
- package/dist/{config-L2SVVMAR.js → config-WIQGW5OC.js} +1 -1
- package/dist/index.js +52 -26
- package/package.json +1 -1
|
@@ -36,7 +36,11 @@ function loadConfig() {
|
|
|
36
36
|
\u8BF7\u5148\u8FD0\u884C kmr init`);
|
|
37
37
|
}
|
|
38
38
|
const raw = fs.readFileSync(configPath, "utf-8");
|
|
39
|
-
|
|
39
|
+
const config = JSON.parse(raw);
|
|
40
|
+
if (!config.lark?.appId || !config.lark?.appSecret) {
|
|
41
|
+
throw new Error(`\u914D\u7F6E\u672A\u5B8C\u6210: \u8BF7\u5728 ${configPath} \u4E2D\u586B\u5199 lark.appId \u548C lark.appSecret`);
|
|
42
|
+
}
|
|
43
|
+
return config;
|
|
40
44
|
}
|
|
41
45
|
function getAgentProvider() {
|
|
42
46
|
try {
|
package/dist/cli.js
CHANGED
|
@@ -6,9 +6,9 @@ async function checkUpdate() {
|
|
|
6
6
|
try {
|
|
7
7
|
const res = await fetch(`https://registry.npmjs.org/${"@lih-x-x/kmr"}/latest`, { signal: AbortSignal.timeout(3e3) });
|
|
8
8
|
const data = await res.json();
|
|
9
|
-
if (data.version && data.version !== "1.0.
|
|
9
|
+
if (data.version && data.version !== "1.0.56") {
|
|
10
10
|
console.log(`
|
|
11
|
-
\u2B06\uFE0F \u65B0\u7248\u672C\u53EF\u7528: ${"1.0.
|
|
11
|
+
\u2B06\uFE0F \u65B0\u7248\u672C\u53EF\u7528: ${"1.0.56"} \u2192 ${data.version}`);
|
|
12
12
|
console.log(` \u8FD0\u884C npm install -g ${"@lih-x-x/kmr"} \u66F4\u65B0
|
|
13
13
|
`);
|
|
14
14
|
}
|
|
@@ -17,7 +17,7 @@ async function checkUpdate() {
|
|
|
17
17
|
}
|
|
18
18
|
var command = argv[2];
|
|
19
19
|
if (command === "init") {
|
|
20
|
-
const { initConfig, getKmrDir } = await import("./config-
|
|
20
|
+
const { initConfig, getKmrDir } = await import("./config-WIQGW5OC.js");
|
|
21
21
|
const path = await import("path");
|
|
22
22
|
const kmrDir = getKmrDir();
|
|
23
23
|
console.log(`\u521D\u59CB\u5316 KMR \u914D\u7F6E\u76EE\u5F55: ${kmrDir}`);
|
|
@@ -56,9 +56,9 @@ KMR\uFF08Key Meetings Record\uFF09\u2014 \u4F1A\u8BAE\u6316\u6398\u673A
|
|
|
56
56
|
kmr --help \u663E\u793A\u5E2E\u52A9
|
|
57
57
|
`);
|
|
58
58
|
} else if (command === "--version" || command === "-v") {
|
|
59
|
-
console.log("1.0.
|
|
59
|
+
console.log("1.0.56");
|
|
60
60
|
} else if (command === "list") {
|
|
61
|
-
const { loadConfig } = await import("./config-
|
|
61
|
+
const { loadConfig } = await import("./config-WIQGW5OC.js");
|
|
62
62
|
const { JsonStore } = await import("./jsonStore-AL73KEUG.js");
|
|
63
63
|
const { createLarkClient } = await import("./client-DFBBDD77.js");
|
|
64
64
|
const { TaskCreator } = await import("./taskCreator-TCI3VB5D.js");
|
|
@@ -81,7 +81,7 @@ KMR\uFF08Key Meetings Record\uFF09\u2014 \u4F1A\u8BAE\u6316\u6398\u673A
|
|
|
81
81
|
console.error("\u7528\u6CD5: kmr show <id>");
|
|
82
82
|
process.exit(1);
|
|
83
83
|
}
|
|
84
|
-
const { loadConfig } = await import("./config-
|
|
84
|
+
const { loadConfig } = await import("./config-WIQGW5OC.js");
|
|
85
85
|
const { JsonStore } = await import("./jsonStore-AL73KEUG.js");
|
|
86
86
|
const { createLarkClient } = await import("./client-DFBBDD77.js");
|
|
87
87
|
const { TaskCreator } = await import("./taskCreator-TCI3VB5D.js");
|
|
@@ -98,7 +98,7 @@ KMR\uFF08Key Meetings Record\uFF09\u2014 \u4F1A\u8BAE\u6316\u6398\u673A
|
|
|
98
98
|
}
|
|
99
99
|
console.log(JSON.stringify(record, null, 2));
|
|
100
100
|
} else if (command === "task") {
|
|
101
|
-
const { loadConfig } = await import("./config-
|
|
101
|
+
const { loadConfig } = await import("./config-WIQGW5OC.js");
|
|
102
102
|
const { JsonStore } = await import("./jsonStore-AL73KEUG.js");
|
|
103
103
|
const { createLarkClient } = await import("./client-DFBBDD77.js");
|
|
104
104
|
const { TaskCreator } = await import("./taskCreator-TCI3VB5D.js");
|
|
@@ -129,7 +129,7 @@ KMR\uFF08Key Meetings Record\uFF09\u2014 \u4F1A\u8BAE\u6316\u6398\u673A
|
|
|
129
129
|
console.error("\u7528\u6CD5: kmr del <id>");
|
|
130
130
|
process.exit(1);
|
|
131
131
|
}
|
|
132
|
-
const { loadConfig } = await import("./config-
|
|
132
|
+
const { loadConfig } = await import("./config-WIQGW5OC.js");
|
|
133
133
|
const { JsonStore } = await import("./jsonStore-AL73KEUG.js");
|
|
134
134
|
const store = new JsonStore(loadConfig().storage.dataDir);
|
|
135
135
|
const ok = await store.delete(id);
|
|
@@ -157,7 +157,7 @@ KMR\uFF08Key Meetings Record\uFF09\u2014 \u4F1A\u8BAE\u6316\u6398\u673A
|
|
|
157
157
|
console.error("\u7528\u6CD5: kmr create-task <\u4EFB\u52A1\u6807\u9898> [--due YYYY-MM-DD] [--assignee \u59D3\u540D] [--desc \u63CF\u8FF0]");
|
|
158
158
|
process.exit(1);
|
|
159
159
|
}
|
|
160
|
-
const { loadConfig } = await import("./config-
|
|
160
|
+
const { loadConfig } = await import("./config-WIQGW5OC.js");
|
|
161
161
|
const { createLarkClient } = await import("./client-DFBBDD77.js");
|
|
162
162
|
const { TaskCreator } = await import("./taskCreator-TCI3VB5D.js");
|
|
163
163
|
const { UserResolver } = await import("./userResolver-DTWOTVP6.js");
|
|
@@ -189,8 +189,8 @@ KMR\uFF08Key Meetings Record\uFF09\u2014 \u4F1A\u8BAE\u6316\u6398\u673A
|
|
|
189
189
|
console.error("\u7528\u6CD5: kmr find <query>");
|
|
190
190
|
process.exit(1);
|
|
191
191
|
}
|
|
192
|
-
const { loadConfig } = await import("./config-
|
|
193
|
-
const { ClaudeCodeProvider } = await import("./claudeCode-
|
|
192
|
+
const { loadConfig } = await import("./config-WIQGW5OC.js");
|
|
193
|
+
const { ClaudeCodeProvider } = await import("./claudeCode-AVQOOWP5.js");
|
|
194
194
|
const { QueryHandler } = await import("./handler-46CQQIA2.js");
|
|
195
195
|
const { JsonStore } = await import("./jsonStore-AL73KEUG.js");
|
|
196
196
|
const { createLarkClient } = await import("./client-DFBBDD77.js");
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ClaudeCodeProvider,
|
|
3
3
|
getExecEnv
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-MTQECODE.js";
|
|
5
5
|
import {
|
|
6
6
|
QueryHandler
|
|
7
7
|
} from "./chunk-SGTENG37.js";
|
|
8
8
|
import {
|
|
9
9
|
KMR_DIR,
|
|
10
10
|
getAgentProvider,
|
|
11
|
+
initConfig,
|
|
11
12
|
loadConfig
|
|
12
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-JUAJGCUT.js";
|
|
13
14
|
import {
|
|
14
15
|
JsonStore
|
|
15
16
|
} from "./chunk-TUCCS6QJ.js";
|
|
@@ -660,24 +661,9 @@ ${text}`;
|
|
|
660
661
|
*/
|
|
661
662
|
async trackNewPids(before) {
|
|
662
663
|
const after = await this.getAgentPids();
|
|
663
|
-
const newPids = /* @__PURE__ */ new Set();
|
|
664
664
|
for (const pid of after) {
|
|
665
665
|
if (!before.has(pid)) {
|
|
666
666
|
this.ownedPids.add(pid);
|
|
667
|
-
newPids.add(pid);
|
|
668
|
-
}
|
|
669
|
-
}
|
|
670
|
-
return newPids;
|
|
671
|
-
}
|
|
672
|
-
/**
|
|
673
|
-
* 杀掉指定的 PID 集合(用于单次调用后清理临时进程)
|
|
674
|
-
*/
|
|
675
|
-
killPids(pids) {
|
|
676
|
-
for (const pid of pids) {
|
|
677
|
-
try {
|
|
678
|
-
process.kill(pid, "SIGTERM");
|
|
679
|
-
this.ownedPids.delete(pid);
|
|
680
|
-
} catch {
|
|
681
667
|
}
|
|
682
668
|
}
|
|
683
669
|
}
|
|
@@ -733,8 +719,7 @@ ${text}`;
|
|
|
733
719
|
} catch (err) {
|
|
734
720
|
console.error(`[session] \u89D2\u8272\u8BBE\u5B9A\u5931\u8D25:`, err.stderr || err.message);
|
|
735
721
|
}
|
|
736
|
-
|
|
737
|
-
this.killPids(skillPids);
|
|
722
|
+
await this.trackNewPids(pidsBefore2);
|
|
738
723
|
this.activeSessions.set(userId, {
|
|
739
724
|
name: sessionName,
|
|
740
725
|
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -750,12 +735,10 @@ ${text}`;
|
|
|
750
735
|
["--approve-all", agentCmd, "-s", sessionName, text],
|
|
751
736
|
{ timeout: this.timeout, maxBuffer: 1024 * 1024, env: getExecEnv() }
|
|
752
737
|
);
|
|
753
|
-
|
|
754
|
-
this.killPids(newPids);
|
|
738
|
+
await this.trackNewPids(pidsBefore);
|
|
755
739
|
return this.extractReply(stdout);
|
|
756
740
|
} catch (err) {
|
|
757
|
-
|
|
758
|
-
this.killPids(newPids);
|
|
741
|
+
await this.trackNewPids(pidsBefore);
|
|
759
742
|
console.error(`[session] sendToSession \u5931\u8D25:`, err.stderr || err.message);
|
|
760
743
|
if (err.killed) {
|
|
761
744
|
throw new Error(`AI \u56DE\u590D\u8D85\u65F6 (${this.timeout}ms)`);
|
|
@@ -840,7 +823,43 @@ ${text}`;
|
|
|
840
823
|
};
|
|
841
824
|
|
|
842
825
|
// src/index.ts
|
|
826
|
+
async function waitForConfig(webPort) {
|
|
827
|
+
console.log(`\u2699\uFE0F \u8BF7\u5728 Web \u754C\u9762\u5B8C\u6210\u914D\u7F6E: http://localhost:${webPort}/#settings`);
|
|
828
|
+
console.log(` \u6216\u76F4\u63A5\u7F16\u8F91\u914D\u7F6E\u6587\u4EF6: ${path3.join(KMR_DIR, "config.json")}`);
|
|
829
|
+
console.log(" \u914D\u7F6E\u4FDD\u5B58\u540E\u5C06\u81EA\u52A8\u7EE7\u7EED\u542F\u52A8...");
|
|
830
|
+
return new Promise((resolve) => {
|
|
831
|
+
const timer = setInterval(() => {
|
|
832
|
+
try {
|
|
833
|
+
loadConfig();
|
|
834
|
+
clearInterval(timer);
|
|
835
|
+
console.log("\u2705 \u68C0\u6D4B\u5230\u914D\u7F6E\u5DF2\u5B8C\u6210\uFF0C\u7EE7\u7EED\u542F\u52A8...");
|
|
836
|
+
resolve();
|
|
837
|
+
} catch {
|
|
838
|
+
}
|
|
839
|
+
}, 2e3);
|
|
840
|
+
});
|
|
841
|
+
}
|
|
843
842
|
async function main() {
|
|
843
|
+
const configPath = path3.join(KMR_DIR, "config.json");
|
|
844
|
+
if (!fs3.existsSync(configPath)) {
|
|
845
|
+
initConfig();
|
|
846
|
+
console.log(`\u{1F4C1} \u5DF2\u81EA\u52A8\u521D\u59CB\u5316\u914D\u7F6E\u76EE\u5F55: ${KMR_DIR}`);
|
|
847
|
+
}
|
|
848
|
+
let existingWebPort = null;
|
|
849
|
+
let configReady = false;
|
|
850
|
+
try {
|
|
851
|
+
loadConfig();
|
|
852
|
+
configReady = true;
|
|
853
|
+
} catch {
|
|
854
|
+
configReady = false;
|
|
855
|
+
}
|
|
856
|
+
if (!configReady) {
|
|
857
|
+
const tempStore = new JsonStore(path3.join(KMR_DIR, "data", "meetings"));
|
|
858
|
+
const { port: webPort } = await startWebServer(tempStore, KMR_DIR, 3e3);
|
|
859
|
+
existingWebPort = webPort;
|
|
860
|
+
openBrowser(`http://localhost:${webPort}/#settings`);
|
|
861
|
+
await waitForConfig(webPort);
|
|
862
|
+
}
|
|
844
863
|
const config = loadConfig();
|
|
845
864
|
const client = createLarkClient(config);
|
|
846
865
|
const docReader = new DocReader(client);
|
|
@@ -1053,9 +1072,16 @@ async function main() {
|
|
|
1053
1072
|
}
|
|
1054
1073
|
});
|
|
1055
1074
|
startWSClient(client, dispatcher);
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1075
|
+
let port;
|
|
1076
|
+
if (existingWebPort) {
|
|
1077
|
+
port = existingWebPort;
|
|
1078
|
+
console.log(`KMR Web \u754C\u9762: http://localhost:${port}`);
|
|
1079
|
+
} else {
|
|
1080
|
+
const webResult = await startWebServer(store, KMR_DIR, 3e3);
|
|
1081
|
+
port = webResult.port;
|
|
1082
|
+
openBrowser(`http://localhost:${port}`);
|
|
1083
|
+
console.log(`KMR Web \u754C\u9762\u5DF2\u542F\u52A8: http://localhost:${port}`);
|
|
1084
|
+
}
|
|
1059
1085
|
console.log("KMR \u670D\u52A1\u5DF2\u542F\u52A8\uFF0C\u7B49\u5F85\u98DE\u4E66\u6D88\u606F...");
|
|
1060
1086
|
if (config.lark.adminOpenId) {
|
|
1061
1087
|
messenger.sendToUser(config.lark.adminOpenId, "\u2705 KMR \u670D\u52A1\u5DF2\u542F\u52A8").catch((err) => {
|