@keyou007/agent-bot 0.1.14-alpha.3 → 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.
Files changed (45) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +6 -4
  3. package/README.zh.md +6 -4
  4. package/dist/cli/help.js +6 -6
  5. package/dist/cli/initOptions.js +1 -4
  6. package/dist/cli/initOptions.js.map +1 -1
  7. package/dist/cli.js +4 -4
  8. package/dist/cli.js.map +1 -1
  9. package/dist/feishu/CardRenderer.js +40 -37
  10. package/dist/feishu/CardRenderer.js.map +1 -1
  11. package/dist/feishu/FeishuConnector.js +22 -7
  12. package/dist/feishu/FeishuConnector.js.map +1 -1
  13. package/dist/feishu/FeishuMessageClient.js +75 -0
  14. package/dist/feishu/FeishuMessageClient.js.map +1 -1
  15. package/dist/feishu/FeishuTurnPresenter.js +23 -1
  16. package/dist/feishu/FeishuTurnPresenter.js.map +1 -1
  17. package/dist/feishu/InboundText.js +13 -0
  18. package/dist/feishu/InboundText.js.map +1 -0
  19. package/dist/feishu/MergedForwardMessage.js +317 -0
  20. package/dist/feishu/MergedForwardMessage.js.map +1 -0
  21. package/dist/presentation/OutboundRouter.js +21 -0
  22. package/dist/presentation/OutboundRouter.js.map +1 -1
  23. package/dist/proxy/ProxySessionController.js +344 -22
  24. package/dist/proxy/ProxySessionController.js.map +1 -1
  25. package/dist/state/StateStore.js +35 -3
  26. package/dist/state/StateStore.js.map +1 -1
  27. package/dist/state/migrations.js +1 -0
  28. package/dist/state/migrations.js.map +1 -1
  29. package/npm-shrinkwrap.json +2 -2
  30. package/package.json +1 -1
  31. package/skills/agent-bot/SKILL.md +1 -1
  32. package/src/cli/help.ts +6 -6
  33. package/src/cli/initOptions.ts +1 -10
  34. package/src/cli.ts +4 -5
  35. package/src/feishu/CardRenderer.ts +41 -36
  36. package/src/feishu/FeishuConnector.ts +27 -7
  37. package/src/feishu/FeishuMessageClient.ts +110 -0
  38. package/src/feishu/FeishuTurnPresenter.ts +24 -3
  39. package/src/feishu/InboundText.ts +12 -0
  40. package/src/feishu/MergedForwardMessage.ts +372 -0
  41. package/src/feishu/types.ts +15 -0
  42. package/src/presentation/OutboundRouter.ts +28 -0
  43. package/src/proxy/ProxySessionController.ts +434 -20
  44. package/src/state/StateStore.ts +50 -2
  45. package/src/state/migrations.ts +1 -0
@@ -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,
@@ -118,6 +118,7 @@ export const migrations = [
118
118
  local_session_id TEXT NOT NULL,
119
119
  context_key TEXT NOT NULL,
120
120
  prompt_text TEXT NOT NULL,
121
+ display_prompt TEXT,
121
122
  local_image_paths_json TEXT NOT NULL DEFAULT '[]',
122
123
  message_id TEXT,
123
124
  reply_message_id TEXT,