@keyou007/agent-bot 0.1.23 → 0.1.24-alpha.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/CHANGELOG.md +7 -0
- package/README.md +14 -0
- package/README.zh.md +14 -0
- package/dist/cli/controlProtocol.js.map +1 -1
- package/dist/cli/help.js +4 -0
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/taskGroupOptions.js +27 -0
- package/dist/cli/taskGroupOptions.js.map +1 -1
- package/dist/cli.js +21 -1
- package/dist/cli.js.map +1 -1
- package/dist/codex/CodexProcessManager.js +19 -3
- package/dist/codex/CodexProcessManager.js.map +1 -1
- package/dist/codex/CodexRuntime.js +92 -9
- package/dist/codex/CodexRuntime.js.map +1 -1
- package/dist/commands/CommandRouter.js +27 -0
- package/dist/commands/CommandRouter.js.map +1 -1
- package/dist/feishu/FeishuMessageClient.js +4 -1
- package/dist/feishu/FeishuMessageClient.js.map +1 -1
- package/dist/feishu/MergedForwardMessage.js +17 -7
- package/dist/feishu/MergedForwardMessage.js.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/proxy/ConversationExport.js +41 -0
- package/dist/proxy/ConversationExport.js.map +1 -0
- package/dist/proxy/ProxySessionController.js +106 -5
- package/dist/proxy/ProxySessionController.js.map +1 -1
- package/dist/state/StateStore.js +40 -0
- package/dist/state/StateStore.js.map +1 -1
- package/docs/technical-reference.md +4 -0
- package/docs/technical-reference.zh.md +4 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/skills/agent-bot/SKILL.md +9 -0
- package/src/cli/controlProtocol.ts +9 -0
- package/src/cli/help.ts +4 -0
- package/src/cli/taskGroupOptions.ts +33 -3
- package/src/cli.ts +21 -0
- package/src/codex/CodexProcessManager.ts +21 -4
- package/src/codex/CodexRuntime.ts +104 -12
- package/src/commands/CommandRouter.ts +24 -0
- package/src/commands/commandTypes.ts +1 -0
- package/src/feishu/FeishuMessageClient.ts +4 -1
- package/src/feishu/MergedForwardMessage.ts +29 -7
- package/src/index.ts +9 -0
- package/src/proxy/ConversationExport.ts +43 -0
- package/src/proxy/ProxySessionController.ts +152 -6
- package/src/runtime/types.ts +6 -0
- package/src/state/StateStore.ts +38 -0
package/src/state/StateStore.ts
CHANGED
|
@@ -3,6 +3,7 @@ import path from "node:path";
|
|
|
3
3
|
import Database from "better-sqlite3";
|
|
4
4
|
import { migrations } from "./migrations.js";
|
|
5
5
|
import type { UpdateCheckSchedule, UpdateNotice } from "../updates/types.js";
|
|
6
|
+
import type { ConversationTurn } from "../runtime/types.js";
|
|
6
7
|
|
|
7
8
|
export type SessionStatus = "starting" | "ready" | "running" | "closed" | "failed";
|
|
8
9
|
|
|
@@ -1078,6 +1079,43 @@ export class StateStore {
|
|
|
1078
1079
|
return row ? JSON.parse(row.snapshot_json) : undefined;
|
|
1079
1080
|
}
|
|
1080
1081
|
|
|
1082
|
+
*readConversation(localSessionId: string, throughTurnId?: string): Iterable<ConversationTurn> {
|
|
1083
|
+
const index = this.listTaskTurnGraphIndex(localSessionId);
|
|
1084
|
+
const byId = new Map(index.map((turn) => [turn.turnId, turn]));
|
|
1085
|
+
const current = this.getSession(localSessionId)?.lastTurnId;
|
|
1086
|
+
const parent = current ? this.getTurnParent(current, localSessionId) : undefined;
|
|
1087
|
+
const head = throughTurnId ?? (current && byId.has(current) ? current : undefined)
|
|
1088
|
+
?? (parent && byId.has(parent) ? parent : undefined)
|
|
1089
|
+
?? this.findLatestCompletedTurnId(localSessionId) ?? index[0]?.turnId;
|
|
1090
|
+
const branch: string[] = [];
|
|
1091
|
+
const seen = new Set<string>();
|
|
1092
|
+
let turnId: string | undefined = head;
|
|
1093
|
+
while (turnId && !seen.has(turnId)) {
|
|
1094
|
+
seen.add(turnId);
|
|
1095
|
+
const turn = byId.get(turnId);
|
|
1096
|
+
if (!turn) throw new Error("上下文历史不完整,无法导出当前分支。");
|
|
1097
|
+
branch.push(turnId);
|
|
1098
|
+
turnId = turn.parentTurnId;
|
|
1099
|
+
}
|
|
1100
|
+
if (turnId) throw new Error("上下文历史包含循环,无法导出当前分支。");
|
|
1101
|
+
const read = this.db.prepare(`SELECT
|
|
1102
|
+
json_extract(snapshot_json, '$.prompt') AS prompt,
|
|
1103
|
+
json_extract(snapshot_json, '$.finalResponse') AS answer,
|
|
1104
|
+
(SELECT json_group_array(json_extract(value, '$.text'))
|
|
1105
|
+
FROM json_each(snapshot_json, '$.activities')
|
|
1106
|
+
WHERE json_extract(value, '$.kind') = 'user') AS followups
|
|
1107
|
+
FROM turn_snapshots WHERE turn_id = ?`);
|
|
1108
|
+
for (const id of branch.reverse()) {
|
|
1109
|
+
const row = read.get(id) as { prompt: string | null; answer: string | null; followups: string };
|
|
1110
|
+
const messages: ConversationTurn["messages"] = [];
|
|
1111
|
+
for (const text of [row.prompt, ...(JSON.parse(row.followups) as string[])]) {
|
|
1112
|
+
if (text?.trim()) messages.push({ role: "user", text });
|
|
1113
|
+
}
|
|
1114
|
+
if (row.answer?.trim()) messages.push({ role: "assistant", text: row.answer });
|
|
1115
|
+
yield { turnId: id, messages };
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1081
1119
|
getTurnPromptSummary(turnId: string): TurnPromptSummary | undefined {
|
|
1082
1120
|
const row = this.db.prepare(`SELECT
|
|
1083
1121
|
json_extract(snapshot_json, '$.status') AS status,
|