@keyou007/agent-bot 0.1.14 → 0.1.15-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 +11 -0
- package/README.md +6 -4
- package/README.zh.md +6 -4
- package/dist/cli/help.js +6 -6
- package/dist/cli/initOptions.js +1 -4
- package/dist/cli/initOptions.js.map +1 -1
- package/dist/cli.js +4 -4
- package/dist/cli.js.map +1 -1
- package/dist/feishu/CardRenderer.js +40 -37
- package/dist/feishu/CardRenderer.js.map +1 -1
- package/dist/feishu/FeishuConnector.js +22 -7
- package/dist/feishu/FeishuConnector.js.map +1 -1
- package/dist/feishu/FeishuMessageClient.js +75 -0
- package/dist/feishu/FeishuMessageClient.js.map +1 -1
- package/dist/feishu/FeishuTurnPresenter.js +23 -1
- package/dist/feishu/FeishuTurnPresenter.js.map +1 -1
- package/dist/feishu/InboundText.js +13 -0
- package/dist/feishu/InboundText.js.map +1 -0
- package/dist/feishu/MergedForwardMessage.js +317 -0
- package/dist/feishu/MergedForwardMessage.js.map +1 -0
- package/dist/presentation/OutboundRouter.js +21 -0
- package/dist/presentation/OutboundRouter.js.map +1 -1
- package/dist/proxy/ProxySessionController.js +344 -22
- package/dist/proxy/ProxySessionController.js.map +1 -1
- package/dist/state/StateStore.js +35 -3
- package/dist/state/StateStore.js.map +1 -1
- package/dist/state/migrations.js +1 -0
- package/dist/state/migrations.js.map +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/skills/agent-bot/SKILL.md +1 -1
- package/src/cli/help.ts +6 -6
- package/src/cli/initOptions.ts +1 -10
- package/src/cli.ts +4 -5
- package/src/feishu/CardRenderer.ts +41 -36
- package/src/feishu/FeishuConnector.ts +27 -7
- package/src/feishu/FeishuMessageClient.ts +110 -0
- package/src/feishu/FeishuTurnPresenter.ts +24 -3
- package/src/feishu/InboundText.ts +12 -0
- package/src/feishu/MergedForwardMessage.ts +372 -0
- package/src/feishu/types.ts +15 -0
- package/src/presentation/OutboundRouter.ts +28 -0
- package/src/proxy/ProxySessionController.ts +434 -20
- package/src/state/StateStore.ts +50 -2
- package/src/state/migrations.ts +1 -0
package/src/state/StateStore.ts
CHANGED
|
@@ -64,6 +64,10 @@ export interface TurnAnchorRecord {
|
|
|
64
64
|
contextKey?: string;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
export interface AgentBotTurnMessageRecord extends TurnAnchorRecord {
|
|
68
|
+
messageKind: "progress" | "final";
|
|
69
|
+
}
|
|
70
|
+
|
|
67
71
|
export interface TurnRuntimeOriginRecord {
|
|
68
72
|
turnId: string;
|
|
69
73
|
localSessionId: string;
|
|
@@ -84,6 +88,7 @@ export interface QueuedPromptRecord {
|
|
|
84
88
|
localSessionId: string;
|
|
85
89
|
contextKey: string;
|
|
86
90
|
text: string;
|
|
91
|
+
displayPrompt?: string;
|
|
87
92
|
localImagePaths?: string[];
|
|
88
93
|
messageId?: string;
|
|
89
94
|
replyMessageId?: string;
|
|
@@ -181,6 +186,7 @@ interface QueuedPromptRow {
|
|
|
181
186
|
local_session_id: string;
|
|
182
187
|
context_key: string;
|
|
183
188
|
prompt_text: string;
|
|
189
|
+
display_prompt: string | null;
|
|
184
190
|
local_image_paths_json: string;
|
|
185
191
|
message_id: string | null;
|
|
186
192
|
reply_message_id: string | null;
|
|
@@ -221,6 +227,7 @@ export class StateStore {
|
|
|
221
227
|
this.ensureTurnSnapshotColumns();
|
|
222
228
|
this.ensureChatContextColumns();
|
|
223
229
|
this.ensureTurnAttemptColumns();
|
|
230
|
+
this.ensureQueuedPromptColumns();
|
|
224
231
|
this.initializeContextSessionMappings();
|
|
225
232
|
this.db.exec("DROP INDEX IF EXISTS idx_sessions_remote_session_id_unique");
|
|
226
233
|
this.reconcileDuplicateRemoteSessions();
|
|
@@ -374,6 +381,7 @@ export class StateStore {
|
|
|
374
381
|
localSessionId: string;
|
|
375
382
|
contextKey: string;
|
|
376
383
|
text: string;
|
|
384
|
+
displayPrompt?: string;
|
|
377
385
|
localImagePaths?: string[];
|
|
378
386
|
messageId?: string;
|
|
379
387
|
replyMessageId?: string;
|
|
@@ -381,14 +389,15 @@ export class StateStore {
|
|
|
381
389
|
const createdAt = new Date().toISOString();
|
|
382
390
|
this.db.prepare(`
|
|
383
391
|
INSERT INTO queued_prompts (
|
|
384
|
-
prompt_id, local_session_id, context_key, prompt_text, local_image_paths_json,
|
|
392
|
+
prompt_id, local_session_id, context_key, prompt_text, display_prompt, local_image_paths_json,
|
|
385
393
|
message_id, reply_message_id, created_at
|
|
386
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
394
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
387
395
|
`).run(
|
|
388
396
|
input.promptId,
|
|
389
397
|
input.localSessionId,
|
|
390
398
|
input.contextKey,
|
|
391
399
|
input.text,
|
|
400
|
+
input.displayPrompt ?? null,
|
|
392
401
|
JSON.stringify(input.localImagePaths ?? []),
|
|
393
402
|
input.messageId ?? null,
|
|
394
403
|
input.replyMessageId ?? null,
|
|
@@ -1586,6 +1595,35 @@ export class StateStore {
|
|
|
1586
1595
|
: undefined;
|
|
1587
1596
|
}
|
|
1588
1597
|
|
|
1598
|
+
findAgentBotTurnMessageById(messageId: string): AgentBotTurnMessageRecord | undefined {
|
|
1599
|
+
const row = this.db.prepare(`
|
|
1600
|
+
SELECT deliveries.turn_id, snapshots.local_session_id,
|
|
1601
|
+
CASE WHEN deliveries.progress_message_id = ? THEN 'progress' ELSE 'final' END AS message_kind
|
|
1602
|
+
FROM turn_deliveries AS deliveries
|
|
1603
|
+
JOIN turn_snapshots AS snapshots ON snapshots.turn_id = deliveries.turn_id
|
|
1604
|
+
WHERE deliveries.progress_message_id = ?
|
|
1605
|
+
OR EXISTS (
|
|
1606
|
+
SELECT 1
|
|
1607
|
+
FROM json_each(deliveries.final_message_ids_json)
|
|
1608
|
+
WHERE json_each.value = ?
|
|
1609
|
+
)
|
|
1610
|
+
ORDER BY deliveries.updated_at DESC
|
|
1611
|
+
LIMIT 1
|
|
1612
|
+
`).get(messageId, messageId, messageId) as {
|
|
1613
|
+
turn_id: string;
|
|
1614
|
+
local_session_id: string;
|
|
1615
|
+
message_kind: "progress" | "final";
|
|
1616
|
+
} | undefined;
|
|
1617
|
+
return row
|
|
1618
|
+
? {
|
|
1619
|
+
turnId: row.turn_id,
|
|
1620
|
+
localSessionId: row.local_session_id,
|
|
1621
|
+
contextKey: this.getTurnContextKey(row.turn_id),
|
|
1622
|
+
messageKind: row.message_kind,
|
|
1623
|
+
}
|
|
1624
|
+
: undefined;
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1589
1627
|
private initializeContextSessionMappings(): void {
|
|
1590
1628
|
this.db.exec(`
|
|
1591
1629
|
INSERT OR IGNORE INTO context_sessions (context_key, local_session_id, created_at, updated_at)
|
|
@@ -1749,6 +1787,15 @@ export class StateStore {
|
|
|
1749
1787
|
this.db.exec("ALTER TABLE turn_attempts ADD COLUMN retry_count INTEGER NOT NULL DEFAULT 0");
|
|
1750
1788
|
}
|
|
1751
1789
|
}
|
|
1790
|
+
|
|
1791
|
+
private ensureQueuedPromptColumns(): void {
|
|
1792
|
+
const existing = new Set(
|
|
1793
|
+
(this.db.pragma("table_info(queued_prompts)") as Array<{ name: string }>).map((column) => column.name),
|
|
1794
|
+
);
|
|
1795
|
+
if (!existing.has("display_prompt")) {
|
|
1796
|
+
this.db.exec("ALTER TABLE queued_prompts ADD COLUMN display_prompt TEXT");
|
|
1797
|
+
}
|
|
1798
|
+
}
|
|
1752
1799
|
}
|
|
1753
1800
|
|
|
1754
1801
|
const MAX_TASK_TITLE_LENGTH = 120;
|
|
@@ -1836,6 +1883,7 @@ function mapQueuedPrompt(row: QueuedPromptRow): QueuedPromptRecord {
|
|
|
1836
1883
|
localSessionId: row.local_session_id,
|
|
1837
1884
|
contextKey: row.context_key,
|
|
1838
1885
|
text: row.prompt_text,
|
|
1886
|
+
displayPrompt: row.display_prompt ?? undefined,
|
|
1839
1887
|
localImagePaths: localImagePaths.length > 0 ? localImagePaths : undefined,
|
|
1840
1888
|
messageId: row.message_id ?? undefined,
|
|
1841
1889
|
replyMessageId: row.reply_message_id ?? undefined,
|
package/src/state/migrations.ts
CHANGED