@keyou007/agent-bot 0.1.14-alpha.1 → 0.1.14-alpha.3
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 +19 -1
- package/README.md +48 -15
- package/README.zh.md +48 -15
- package/config.example.yaml +1 -1
- package/dist/cli/AutostartManager.js +431 -0
- package/dist/cli/AutostartManager.js.map +1 -0
- package/dist/cli/FeishuAppConfiguration.js +21 -13
- package/dist/cli/FeishuAppConfiguration.js.map +1 -1
- package/dist/cli/Initializer.js +35 -0
- package/dist/cli/Initializer.js.map +1 -1
- package/dist/cli/SelfUpdateRunner.js +552 -0
- package/dist/cli/SelfUpdateRunner.js.map +1 -0
- package/dist/cli/SelfUpdater.js +431 -0
- package/dist/cli/SelfUpdater.js.map +1 -0
- package/dist/cli/autostartOutput.js +63 -0
- package/dist/cli/autostartOutput.js.map +1 -0
- package/dist/cli/controlProtocol.js.map +1 -1
- package/dist/cli/help.js +94 -18
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/taskGroupOptions.js +14 -11
- package/dist/cli/taskGroupOptions.js.map +1 -1
- package/dist/cli/taskListOutput.js +3 -0
- package/dist/cli/taskListOutput.js.map +1 -1
- package/dist/cli/taskTarget.js +99 -0
- package/dist/cli/taskTarget.js.map +1 -0
- package/dist/cli.js +661 -58
- package/dist/cli.js.map +1 -1
- package/dist/codex/CodexRuntime.js +8 -2
- package/dist/codex/CodexRuntime.js.map +1 -1
- package/dist/commands/CommandRouter.js +16 -1
- package/dist/commands/CommandRouter.js.map +1 -1
- package/dist/feishu/CardRenderer.js +266 -38
- package/dist/feishu/CardRenderer.js.map +1 -1
- package/dist/feishu/FeishuMarkdown.js +25 -1
- package/dist/feishu/FeishuMarkdown.js.map +1 -1
- package/dist/feishu/FeishuMessageClient.js +16 -0
- package/dist/feishu/FeishuMessageClient.js.map +1 -1
- package/dist/feishu/FeishuTurnPresenter.js +42 -6
- package/dist/feishu/FeishuTurnPresenter.js.map +1 -1
- package/dist/index.js +136 -2
- package/dist/index.js.map +1 -1
- package/dist/presentation/OutboundRouter.js +7 -0
- package/dist/presentation/OutboundRouter.js.map +1 -1
- package/dist/presentation/TurnStateReducer.js +21 -7
- package/dist/presentation/TurnStateReducer.js.map +1 -1
- package/dist/proxy/ProxySessionController.js +537 -13
- package/dist/proxy/ProxySessionController.js.map +1 -1
- package/dist/state/StateStore.js +53 -0
- package/dist/state/StateStore.js.map +1 -1
- package/docs/technical-reference.md +17 -7
- package/docs/technical-reference.zh.md +17 -7
- package/npm-shrinkwrap.json +2 -2
- package/package.json +2 -2
- package/skills/agent-bot/SKILL.md +109 -188
- package/src/cli/AutostartManager.ts +579 -0
- package/src/cli/FeishuAppConfiguration.ts +26 -7
- package/src/cli/Initializer.ts +57 -0
- package/src/cli/SelfUpdateRunner.ts +817 -0
- package/src/cli/SelfUpdater.ts +688 -0
- package/src/cli/autostartOutput.ts +75 -0
- package/src/cli/controlProtocol.ts +119 -1
- package/src/cli/help.ts +94 -18
- package/src/cli/taskGroupOptions.ts +27 -17
- package/src/cli/taskListOutput.ts +10 -0
- package/src/cli/taskTarget.ts +168 -0
- package/src/cli.ts +809 -65
- package/src/codex/CodexRuntime.ts +8 -2
- package/src/commands/CommandRouter.ts +14 -1
- package/src/commands/commandTypes.ts +2 -0
- package/src/feishu/CardRenderer.ts +313 -35
- package/src/feishu/FeishuMarkdown.ts +27 -1
- package/src/feishu/FeishuMessageClient.ts +33 -0
- package/src/feishu/FeishuTurnPresenter.ts +43 -6
- package/src/feishu/types.ts +1 -0
- package/src/index.ts +174 -2
- package/src/presentation/OutboundRouter.ts +7 -0
- package/src/presentation/TurnStateReducer.ts +21 -7
- package/src/proxy/ProxySessionController.ts +661 -16
- package/src/runtime/types.ts +1 -0
- package/src/state/StateStore.ts +56 -0
package/src/runtime/types.ts
CHANGED
|
@@ -221,6 +221,7 @@ export interface AgentRuntime {
|
|
|
221
221
|
steerTurn(sessionId: string, turnId: string, prompt: RuntimePrompt): Promise<void>;
|
|
222
222
|
cancelTurn(sessionId: string, turnId: string): Promise<void>;
|
|
223
223
|
interruptRemoteTurn?(remoteSessionId: string, turnId: string): Promise<void>;
|
|
224
|
+
archiveRemoteSession?(remoteSessionId: string): Promise<void>;
|
|
224
225
|
closeSession(sessionId: string): Promise<void>;
|
|
225
226
|
setTitle?(sessionId: string, title: string): Promise<void>;
|
|
226
227
|
getGoal?(sessionId: string): Promise<RuntimeGoal | undefined>;
|
package/src/state/StateStore.ts
CHANGED
|
@@ -344,6 +344,31 @@ export class StateStore {
|
|
|
344
344
|
return rows.map(mapChatContext);
|
|
345
345
|
}
|
|
346
346
|
|
|
347
|
+
removeChatContext(contextKey: string): string[] {
|
|
348
|
+
const threadPrefix = `${contextKey}:thread_id:`;
|
|
349
|
+
const linked = this.db.prepare(`
|
|
350
|
+
SELECT DISTINCT local_session_id
|
|
351
|
+
FROM context_sessions
|
|
352
|
+
WHERE context_key = ? OR instr(context_key, ?) = 1
|
|
353
|
+
`).all(contextKey, threadPrefix) as Array<{ local_session_id: string }>;
|
|
354
|
+
const remove = this.db.transaction(() => {
|
|
355
|
+
this.db.prepare(`
|
|
356
|
+
DELETE FROM context_sessions
|
|
357
|
+
WHERE context_key = ? OR instr(context_key, ?) = 1
|
|
358
|
+
`).run(contextKey, threadPrefix);
|
|
359
|
+
this.db.prepare(`
|
|
360
|
+
DELETE FROM user_contexts
|
|
361
|
+
WHERE context_key = ? OR instr(context_key, ?) = 1
|
|
362
|
+
`).run(contextKey, threadPrefix);
|
|
363
|
+
this.db.prepare(`
|
|
364
|
+
DELETE FROM chat_contexts
|
|
365
|
+
WHERE context_key = ? OR instr(context_key, ?) = 1
|
|
366
|
+
`).run(contextKey, threadPrefix);
|
|
367
|
+
});
|
|
368
|
+
remove();
|
|
369
|
+
return linked.map((row) => row.local_session_id);
|
|
370
|
+
}
|
|
371
|
+
|
|
347
372
|
enqueuePrompt(input: {
|
|
348
373
|
promptId: string;
|
|
349
374
|
localSessionId: string;
|
|
@@ -743,6 +768,25 @@ export class StateStore {
|
|
|
743
768
|
);
|
|
744
769
|
}
|
|
745
770
|
|
|
771
|
+
archiveSession(localSessionId: string): void {
|
|
772
|
+
const now = new Date().toISOString();
|
|
773
|
+
const archive = this.db.transaction(() => {
|
|
774
|
+
this.db.prepare(`
|
|
775
|
+
UPDATE sessions
|
|
776
|
+
SET status = 'closed', updated_at = ?
|
|
777
|
+
WHERE local_session_id = ?
|
|
778
|
+
`).run(now, localSessionId);
|
|
779
|
+
this.db.prepare(`
|
|
780
|
+
UPDATE user_contexts
|
|
781
|
+
SET current_session_id = CASE WHEN current_session_id = ? THEN NULL ELSE current_session_id END,
|
|
782
|
+
previous_session_id = CASE WHEN previous_session_id = ? THEN NULL ELSE previous_session_id END,
|
|
783
|
+
updated_at = ?
|
|
784
|
+
WHERE current_session_id = ? OR previous_session_id = ?
|
|
785
|
+
`).run(localSessionId, localSessionId, now, localSessionId, localSessionId);
|
|
786
|
+
});
|
|
787
|
+
archive();
|
|
788
|
+
}
|
|
789
|
+
|
|
746
790
|
updateRuntimeSession(
|
|
747
791
|
localSessionId: string,
|
|
748
792
|
patch: Partial<
|
|
@@ -1214,6 +1258,18 @@ export class StateStore {
|
|
|
1214
1258
|
return rows.map((row) => ({ ...mapSession(row), contextKey }));
|
|
1215
1259
|
}
|
|
1216
1260
|
|
|
1261
|
+
listSessionsForChat(contextKey: string): SessionRecord[] {
|
|
1262
|
+
const threadPrefix = `${contextKey}:thread_id:`;
|
|
1263
|
+
const rows = this.db.prepare(`
|
|
1264
|
+
SELECT DISTINCT sessions.*
|
|
1265
|
+
FROM context_sessions
|
|
1266
|
+
JOIN sessions ON sessions.local_session_id = context_sessions.local_session_id
|
|
1267
|
+
WHERE context_sessions.context_key = ? OR instr(context_sessions.context_key, ?) = 1
|
|
1268
|
+
ORDER BY sessions.updated_at DESC
|
|
1269
|
+
`).all(contextKey, threadPrefix) as SessionRow[];
|
|
1270
|
+
return rows.map(mapSession);
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1217
1273
|
listAllSessions(): SessionRecord[] {
|
|
1218
1274
|
const rows = this.db
|
|
1219
1275
|
.prepare("SELECT * FROM sessions ORDER BY updated_at DESC, created_at DESC")
|