nolo-cli 0.8.0-alpha.12 → 0.8.0-alpha.14

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 (87) hide show
  1. package/{_executeModel-JOUHEEDS.js → _executeModel-KBMAUV6G.js} +26 -22
  2. package/{action-PAXRPJJF.js → action-SQGI5JY5.js} +5 -4
  3. package/{addContentAction-CZVWF3QZ.js → addContentAction-ZX2PUS3X.js} +4 -3
  4. package/{addDialogAgentAction-CCIDTPHC.js → addDialogAgentAction-ULADQX2Q.js} +3 -2
  5. package/{agentDeleteCommand-TVJH2JID.js → agentDeleteCommand-GNVYHOGZ.js} +11 -8
  6. package/{agentEmailCommands-TB2RKQJL.js → agentEmailCommands-QETL62SU.js} +29 -25
  7. package/{agentListCommands-GVD6ZQ3B.js → agentListCommands-FM4OWXYT.js} +12 -9
  8. package/{agentMachineCommands-UJI6CDKE.js → agentMachineCommands-LDHJBWQO.js} +11 -8
  9. package/{agentRecordCommands-IQBFI3QO.js → agentRecordCommands-UW76EZ25.js} +29 -25
  10. package/{agentRunCommand-VCQ5ONRC.js → agentRunCommand-UFBOW4ZF.js} +33 -26
  11. package/{agentRuntimeLocal-JTCFVEEL.js → agentRuntimeLocal-XL5PLRJV.js} +16 -12
  12. package/{agentSlice-NZMLVXT5.js → agentSlice-2IBSFH4O.js} +5 -4
  13. package/{authCommand-WXMD3IPR.js → authCommand-PXFX6JDT.js} +8 -1
  14. package/{authCommands-X74AFDTC.js → authCommands-356AYWEK.js} +10 -1
  15. package/{chunk-FUU63UA7.js → chunk-2IRF4LEX.js} +418 -12
  16. package/chunk-3TZDXYSF.js +71 -0
  17. package/chunk-4ZDM73SD.js +34 -0
  18. package/{chunk-TDIQFT2F.js → chunk-5CS33IBL.js} +1 -1
  19. package/{chunk-IYQV26RA.js → chunk-6A3LI5TZ.js} +2 -2
  20. package/{chunk-VEJLAVTC.js → chunk-6CBN7GGH.js} +2 -2
  21. package/{chunk-BSTNFPHD.js → chunk-6XKX2N2E.js} +1 -1
  22. package/{chunk-IEPE5Z7Y.js → chunk-7IPLJUYC.js} +1 -1
  23. package/{chunk-6VTZSYDT.js → chunk-B6DFDN4R.js} +2 -2
  24. package/{chunk-QNCWJXVH.js → chunk-BKPVTIEK.js} +4 -4
  25. package/{chunk-LM25IZBJ.js → chunk-DG7AAAR3.js} +1 -1
  26. package/{chunk-K367HWYT.js → chunk-DGFWICQJ.js} +1 -1
  27. package/chunk-DSNONPGW.js +386 -0
  28. package/{chunk-GH7LOVLY.js → chunk-EQHI2AR3.js} +21 -17
  29. package/{chunk-OF5H3QWS.js → chunk-EXTIQUCI.js} +182 -0
  30. package/chunk-I42VC5KR.js +15 -0
  31. package/{chunk-FY4NQTEC.js → chunk-I6DI7SGU.js} +41 -19
  32. package/chunk-JEXVIMYZ.js +55 -0
  33. package/{chunk-4EPRP7A3.js → chunk-JRPR5M4O.js} +2 -2
  34. package/{chunk-VJEKUYDK.js → chunk-JW43YCM5.js} +1 -1
  35. package/{chunk-GSENGCXB.js → chunk-MMRAIO5Y.js} +3 -3
  36. package/{chunk-AAKR4CKW.js → chunk-MXLQWBVM.js} +1 -88
  37. package/chunk-OPZYGHUC.js +89 -0
  38. package/{chunk-J4576WMJ.js → chunk-PCWC3JTN.js} +1 -1
  39. package/{chunk-6HSAQUHW.js → chunk-PFUCDPUH.js} +19 -20
  40. package/{chunk-HEIIIZBX.js → chunk-Q2YZULBH.js} +1 -1
  41. package/{chunk-6G3WLUY5.js → chunk-QKRUUZCL.js} +6 -6
  42. package/{chunk-IAXBCTTE.js → chunk-QO4YO77G.js} +2 -2
  43. package/{chunk-NDZOFKHS.js → chunk-QTFSBLCF.js} +8 -15
  44. package/{chunk-RAUV2V7X.js → chunk-RJKDVL4L.js} +2 -2
  45. package/{chunk-MTV2I4IF.js → chunk-RLCFUU46.js} +3 -3
  46. package/{chunk-OF6IBT3Z.js → chunk-RTZFUR3V.js} +5 -5
  47. package/{chunk-U5CWPEKM.js → chunk-SACYB45H.js} +19 -378
  48. package/{chunk-PN7AFLOK.js → chunk-SH2CFQOH.js} +3 -13
  49. package/{chunk-CM54RSSA.js → chunk-SL35K7AH.js} +21 -1
  50. package/{chunk-OW6OA65Z.js → chunk-SRLZ7IVA.js} +170 -176
  51. package/{chunk-VEWET5JQ.js → chunk-TWPGVS2U.js} +2 -2
  52. package/{chunk-G5H7RNFL.js → chunk-V2AISYMA.js} +2 -2
  53. package/{chunk-5KDNEBJR.js → chunk-VH4YK6KZ.js} +14 -4
  54. package/{chunk-AUGHVUFE.js → chunk-YYUCRDOK.js} +1 -1
  55. package/{chunk-H2RMRZJE.js → chunk-ZDXZSXYQ.js} +1 -1
  56. package/{chunk-NXZGF7F7.js → chunk-ZQ2UM4KG.js} +1 -1
  57. package/{createAgentAutomationAction-CGYKGZQK.js → createAgentAutomationAction-CSWOQOY5.js} +12 -10
  58. package/{createDialogAction-W34WVXOG.js → createDialogAction-6VWL2TDI.js} +15 -13
  59. package/{createPageAction-BX3BTTBM.js → createPageAction-INRC4MH2.js} +13 -11
  60. package/{dbSlice-C4UJLRZP.js → dbSlice-TO2TSMWM.js} +3 -2
  61. package/{dialogCommands-DS6WHBNJ.js → dialogCommands-DWSE4PMW.js} +13 -10
  62. package/{dialogSlice-3QIHGXBA.js → dialogSlice-CELFVS3F.js} +12 -10
  63. package/{docCreateCommands-X6ACQKZU.js → docCreateCommands-UFJL5PUM.js} +12 -9
  64. package/{docDeleteCommands-NS7VBNDH.js → docDeleteCommands-XHEIBAB2.js} +13 -10
  65. package/{docReadCommands-U5PGIWTF.js → docReadCommands-PEDIC2CW.js} +12 -9
  66. package/{docStore-ZUQS4K5X.js → docStore-Q5AFYT6G.js} +13 -11
  67. package/{docUpdateCommands-MKUDMRFB.js → docUpdateCommands-WBRODQ7P.js} +12 -9
  68. package/{fetchMessages-JOCYIFKL.js → fetchMessages-U6ZHN56A.js} +3 -2
  69. package/{handleSendMessageAction-T4LFZFCM.js → handleSendMessageAction-PPIGKCBQ.js} +12 -10
  70. package/index.js +49 -45
  71. package/{localDialogRead-D3BELSTF.js → localDialogRead-Z5UTAJPU.js} +1 -1
  72. package/{machineCommands-EFFHN5DU.js → machineCommands-3D7JMHUP.js} +28 -24
  73. package/{machineWsRunDispatch-NXBROTNC.js → machineWsRunDispatch-PA5BR4AX.js} +28 -24
  74. package/package.json +1 -1
  75. package/{readlineWorkspace-32SJR27M.js → readlineWorkspace-7WPA5OUS.js} +166 -32
  76. package/{removeDialogAgentAction-CXLST3N6.js → removeDialogAgentAction-3MUQGFZX.js} +5 -4
  77. package/{runAgentClientLoop-AUA4XII6.js → runAgentClientLoop-DRAXPP6R.js} +21 -19
  78. package/{setDialogExtraReferencesAction-LP6VYGU7.js → setDialogExtraReferencesAction-MXHX2HPK.js} +3 -2
  79. package/{setPrimaryDialogAgentAction-D3GGH23T.js → setPrimaryDialogAgentAction-7DLDZHDT.js} +5 -4
  80. package/{settingSlice-J4I3Z5H7.js → settingSlice-PNLASZGI.js} +4 -3
  81. package/{spaceCommands-JLMZTC3V.js → spaceCommands-ORSFAWEY.js} +11 -8
  82. package/{spaceSlice-ECPEQE5G.js → spaceSlice-5F2CDP2O.js} +12 -10
  83. package/{streamAgentChatTurn-5UNGDRXQ.js → streamAgentChatTurn-ROOB5RLM.js} +29 -27
  84. package/{tools-BLAZGXMF.js → tools-BAWXW4F6.js} +19 -17
  85. package/tuiSummaryLlmCaller-JSI4GL6W.js +78 -0
  86. package/{understanding-HCSFPE7R.js → understanding-GQKNDDWM.js} +7 -54
  87. package/{updateDialogTitleAction-Y4SKBCZX.js → updateDialogTitleAction-KJM65IGF.js} +14 -11
@@ -0,0 +1,71 @@
1
+ import {
2
+ createMemoryKey,
3
+ createMemoryOwnerIndexKey,
4
+ createMemorySubjectKindIndexKey,
5
+ ulid
6
+ } from "./chunk-SH2CFQOH.js";
7
+
8
+ // packages/ai/memory/storeShared.ts
9
+ var createMemoryItem = (input) => {
10
+ const now = (/* @__PURE__ */ new Date()).toISOString();
11
+ return {
12
+ id: ulid(),
13
+ createdAt: now,
14
+ lastActivatedAt: now,
15
+ activationCount: 0,
16
+ ...input
17
+ };
18
+ };
19
+ var writeMemoryItemWithIndexesToDb = async (db, item) => {
20
+ const batch = db.batch();
21
+ batch.put(createMemoryKey(item.ownerType, item.ownerId, item.id), item);
22
+ batch.put(
23
+ createMemoryOwnerIndexKey(
24
+ item.ownerType,
25
+ item.ownerId,
26
+ item.createdAt,
27
+ item.id
28
+ ),
29
+ {
30
+ memoryKey: createMemoryKey(item.ownerType, item.ownerId, item.id),
31
+ ownerType: item.ownerType,
32
+ ownerId: item.ownerId,
33
+ memoryId: item.id
34
+ }
35
+ );
36
+ batch.put(
37
+ createMemorySubjectKindIndexKey(
38
+ item.subjectType,
39
+ item.subjectId,
40
+ item.kind,
41
+ item.createdAt,
42
+ item.id
43
+ ),
44
+ {
45
+ memoryKey: createMemoryKey(item.ownerType, item.ownerId, item.id),
46
+ subjectType: item.subjectType,
47
+ subjectId: item.subjectId,
48
+ kind: item.kind,
49
+ memoryId: item.id
50
+ }
51
+ );
52
+ await batch.write();
53
+ };
54
+ var touchMemoryItemsInDb = async (db, items, now = (/* @__PURE__ */ new Date()).toISOString()) => {
55
+ if (items.length === 0) return;
56
+ const batch = db.batch();
57
+ for (const item of items) {
58
+ batch.put(createMemoryKey(item.ownerType, item.ownerId, item.id), {
59
+ ...item,
60
+ lastActivatedAt: now,
61
+ activationCount: (item.activationCount ?? 0) + 1
62
+ });
63
+ }
64
+ await batch.write();
65
+ };
66
+
67
+ export {
68
+ createMemoryItem,
69
+ writeMemoryItemWithIndexesToDb,
70
+ touchMemoryItemsInDb
71
+ };
@@ -0,0 +1,34 @@
1
+ // packages/chat/dialog/actions/builtinDialogLlm.ts
2
+ var BASE_BUILTIN_DIALOG_LLM_CONFIG = {
3
+ apiSource: "platform",
4
+ useServerProxy: true
5
+ };
6
+ var BUILTIN_TITLE_LLM_CONFIG = {
7
+ ...BASE_BUILTIN_DIALOG_LLM_CONFIG,
8
+ provider: "deepseek",
9
+ id: "builtin-dialog-title-llm",
10
+ name: "Builtin Dialog Title LLM",
11
+ model: "deepseek-v4-flash",
12
+ prompt: "You are a title generator for chat history. \u4F60\u53EA\u505A\u4E00\u4EF6\u4E8B\uFF1A\u6839\u636E\u5BF9\u8BDD\u5185\u5BB9\u8F93\u51FA\u6700\u7EC8\u6807\u9898\u3002\u786C\u6027\u89C4\u5219\uFF1A1) \u53EA\u8F93\u51FA\u6807\u9898\u8FD9\u4E00\u884C\uFF1B\u4E25\u7981\u8F93\u51FA\u63A8\u7406\u3001\u5206\u6790\u3001\u6B65\u9AA4\u3001\u89E3\u91CA\u3001\u524D\u8A00\u3001\u540E\u8BB0\u3001\u7FFB\u8BD1\u3001\u81F4\u6B49\u6216\u4EFB\u4F55\u989D\u5916\u8BF4\u660E\u30022) \u4E0D\u8981\u56DE\u7B54\u7528\u6237\u8BF7\u6C42\uFF0C\u4E0D\u8981\u5199\u6458\u8981\uFF0C\u53EA\u7ED9\u6807\u9898\u7ED3\u679C\u30023) \u6807\u9898\u5C3D\u91CF\u77ED\uFF1A\u901A\u5E38 2-5 \u4E2A\u8BCD\uFF0C\u82F1\u6587\u4E0D\u8D85\u8FC7 6 \u4E2A\u8BCD\u30024) \u4F7F\u7528\u5BF9\u8BDD\u4E3B\u8BED\u8A00\uFF1B\u6DF7\u5408\u8BED\u8A00\u65F6\u4F18\u5148\u7528\u6237\u4E3B\u8981\u8BED\u8A00\u30025) \u4F18\u5148\u590D\u7528\u5BF9\u8BDD\u4E2D\u7684\u5177\u4F53\u4E3B\u9898\u8BCD\uFF0C\u907F\u514D issue\u3001help\u3001discussion\u3001analysis\u3001update \u8FD9\u7C7B\u7A7A\u6CDB\u8BCD\u30026) \u5FFD\u7565 tool JSON\u3001\u51FD\u6570\u540D\u3001branch label\u3001agent \u540D\u3001\u7CFB\u7EDF\u6307\u4EE4\u548C\u7F16\u6392\u75D5\u8FF9\uFF08\u5982 GPT\u3001Claude\u3001Gemini\uFF09\uFF1B\u6807\u9898\u8981\u843D\u5728\u7528\u6237\u771F\u6B63\u8BA8\u8BBA\u7684\u5BF9\u8C61\u6216\u51B3\u7B56\u4E0A\u30027) \u66F4\u504F\u597D\u201C\u5BF9\u8C61 + \u52A8\u4F5C/\u5224\u65AD\u201D\u7684\u77ED\u6807\u9898\uFF0C\u4F8B\u5982\u201CAI \u90AE\u4EF6\u52A9\u624B\u53D6\u820D\u201D\u201C\u4E1C\u4EAC\u56DB\u65E5\u6162\u65C5\u884C\u201D\u201C\u91CD\u590D\u6263\u8D39\u9000\u6B3E\u201D\u30028) \u7EAF\u6587\u672C\uFF0C\u4E0D\u8981\u9879\u76EE\u7B26\u53F7\u3001\u7F16\u53F7\u3001markdown\u3001emoji\u3002\u6700\u7EC8\u53EA\u8FD4\u56DE\u6807\u9898\u6587\u672C\u3002 Output only the title text."
13
+ };
14
+ var BUILTIN_SUMMARY_LLM_CONFIG = {
15
+ ...BASE_BUILTIN_DIALOG_LLM_CONFIG,
16
+ provider: "deepseek",
17
+ id: "builtin-dialog-summary-llm",
18
+ name: "Builtin Dialog Summary LLM",
19
+ model: "deepseek-v4-pro",
20
+ prompt: "\u4F60\u662F\u4E00\u4E2A\u4E13\u4E1A\u7684\u5BF9\u8BDD\u8BB0\u5FC6\u52A9\u7406\u3002\u8BF7\u57FA\u4E8E\u3010\u73B0\u6709\u8BB0\u5FC6\u3011\u548C\u3010\u65B0\u589E\u5BF9\u8BDD\u3011\uFF0C\u8F93\u51FA\u4E00\u4EFD\u66F4\u65B0\u540E\u7684\u5BF9\u8BDD\u8BB0\u5FC6\u6863\u6848\u3002\u4E25\u683C\u53EA\u8F93\u51FA\u4E0B\u9762\u4E24\u90E8\u5206\uFF0C\u6807\u9898\u5FC5\u987B\u5B8C\u5168\u4E00\u81F4\uFF1A\n\u5173\u952E\u4E8B\u5B9E\u6863\u6848\n- ...\n\u5BF9\u8BDD\u5267\u60C5\u6458\u8981\n- ...\n\u8981\u6C42\uFF1A1) \u4F7F\u7528\u5BF9\u8BDD\u4E3B\u8BED\u8A00\uFF1B\u6DF7\u5408\u8BED\u8A00\u65F6\u4F18\u5148\u8DDF\u968F\u7528\u6237\u4E3B\u8981\u8BED\u8A00\uFF0C\u4E13\u6709\u540D\u8BCD\u4FDD\u7559\u539F\u6587\u30022) \u5173\u952E\u4E8B\u5B9E\u6863\u6848\u53EA\u4FDD\u7559\u4E4B\u540E\u7EE7\u7EED\u5BF9\u8BDD\u4ECD\u6709\u4EF7\u503C\u7684\u4FE1\u606F\uFF0C\u4F8B\u5982\u7528\u6237\u504F\u597D\u3001\u76EE\u6807\u3001\u7EA6\u675F\u3001\u6280\u672F\u6808\u3001\u786E\u5B9A\u7684\u6587\u4EF6\u540D/\u53D8\u91CF\u540D\u3001\u6838\u5FC3\u51B3\u7B56\u3001\u5F85\u529E\u4E8B\u9879\u30023) \u5BF9\u8BDD\u5267\u60C5\u6458\u8981\u5148\u6781\u7B80\u6982\u62EC\u65E7\u4E0A\u4E0B\u6587\uFF0C\u518D\u66F4\u8BE6\u7EC6\u8BB0\u5F55\u6700\u8FD1\u65B0\u589E\u7684\u8FDB\u5C55\u3001\u5206\u6B67\u3001\u7ED3\u8BBA\u548C\u4E0B\u4E00\u6B65\u30024) \u5FFD\u7565\u5BD2\u6684\u3001\u91CD\u590D\u5C1D\u8BD5\u3001\u5DF2\u653E\u5F03\u65B9\u6848\u548C\u65E0\u4EF7\u503C\u5E9F\u8BDD\u30025) \u4E0D\u8981\u7F16\u9020\u672A\u51FA\u73B0\u7684\u4FE1\u606F\uFF0C\u4E0D\u8981\u8F93\u51FA\u5F00\u573A\u767D\u3001\u7ED3\u675F\u8BED\u3001markdown \u4EE3\u7801\u5757\u6216\u989D\u5916\u7AE0\u8282\u3002"
21
+ };
22
+ var buildBuiltinSummaryContent = (previousSummary, messagesText) => `
23
+ \u3010\u73B0\u6709\u8BB0\u5FC6\u3011\uFF1A
24
+ ${previousSummary || "(\u65E0)"}
25
+
26
+ \u3010\u65B0\u589E\u5BF9\u8BDD\u3011\uFF1A
27
+ ${messagesText}
28
+ `.trim();
29
+
30
+ export {
31
+ BUILTIN_TITLE_LLM_CONFIG,
32
+ BUILTIN_SUMMARY_LLM_CONFIG,
33
+ buildBuiltinSummaryContent
34
+ };
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-JZPBVBIY.js";
4
4
  import {
5
5
  asNonEmptyStringArray
6
- } from "./chunk-PN7AFLOK.js";
6
+ } from "./chunk-I42VC5KR.js";
7
7
  import {
8
8
  asTrimmedString
9
9
  } from "./chunk-3EUW3WEO.js";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  selectCurrentServer
3
- } from "./chunk-VEJLAVTC.js";
3
+ } from "./chunk-6CBN7GGH.js";
4
4
  import {
5
5
  patch
6
- } from "./chunk-G5H7RNFL.js";
6
+ } from "./chunk-V2AISYMA.js";
7
7
  import {
8
8
  selectIdentityToken
9
9
  } from "./chunk-EYEEHCU4.js";
@@ -7,7 +7,7 @@ import {
7
7
  toTimestampMs,
8
8
  upsert,
9
9
  write
10
- } from "./chunk-G5H7RNFL.js";
10
+ } from "./chunk-V2AISYMA.js";
11
11
  import {
12
12
  asRecordOrEmpty
13
13
  } from "./chunk-KX6YBIHG.js";
@@ -15,7 +15,7 @@ import {
15
15
  createUserKey,
16
16
  createUserPreferenceKey,
17
17
  ulid
18
- } from "./chunk-PN7AFLOK.js";
18
+ } from "./chunk-SH2CFQOH.js";
19
19
  import {
20
20
  asTrimmedLowercaseString
21
21
  } from "./chunk-QSJ3HFEF.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  DEFAULT_AGENT_BASE_POLICY,
3
3
  DEFAULT_USER_PREFERENCE_PROFILE
4
- } from "./chunk-VEJLAVTC.js";
4
+ } from "./chunk-6CBN7GGH.js";
5
5
 
6
6
  // packages/ai/policy/runtimePolicy.ts
7
7
  var clampLevel = (value, fallback) => {
@@ -2,7 +2,7 @@ import {
2
2
  deleteDbRecord,
3
3
  queryUserRecords,
4
4
  readDbRecord
5
- } from "./chunk-RAUV2V7X.js";
5
+ } from "./chunk-RJKDVL4L.js";
6
6
  import {
7
7
  mergeAndDedupUserData
8
8
  } from "./chunk-KQHGZWSV.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  clearCliLocalRuntimePreparedAgentCache
3
- } from "./chunk-GH7LOVLY.js";
3
+ } from "./chunk-EQHI2AR3.js";
4
4
  import {
5
5
  getReadableCliDb
6
6
  } from "./chunk-W4NVOSFF.js";
@@ -12,7 +12,7 @@ import {
12
12
  resolveAgentRecordFromHybridStore,
13
13
  sanitizeAgentRecordForCliOutput,
14
14
  writeAgentRecord
15
- } from "./chunk-RAUV2V7X.js";
15
+ } from "./chunk-RJKDVL4L.js";
16
16
  import {
17
17
  resolveCliAgentKeyInput
18
18
  } from "./chunk-VHBWHNVT.js";
@@ -7,11 +7,11 @@ import {
7
7
  listUserRecordsFromServers,
8
8
  readDbRecordFromServers,
9
9
  readLiveDbRecordAfterTombstoneMerge
10
- } from "./chunk-IEPE5Z7Y.js";
10
+ } from "./chunk-7IPLJUYC.js";
11
11
  import {
12
12
  buildDialogAttachmentPlan,
13
13
  extractFileContentIds
14
- } from "./chunk-J4576WMJ.js";
14
+ } from "./chunk-PCWC3JTN.js";
15
15
  import {
16
16
  parseUserIdFromAuthToken,
17
17
  readOption,
@@ -32,7 +32,7 @@ import {
32
32
  import {
33
33
  asNonEmptyStringArray,
34
34
  asTrimmedNonEmptyStringArray
35
- } from "./chunk-PN7AFLOK.js";
35
+ } from "./chunk-I42VC5KR.js";
36
36
  import {
37
37
  asTrimmedString
38
38
  } from "./chunk-3EUW3WEO.js";
@@ -625,7 +625,7 @@ async function tryHttpDialogCandidates(args) {
625
625
  throw Object.assign(new Error("All HTTP dialog reads failed"), { attempts });
626
626
  }
627
627
  async function readDialogFromLocalDb(dialogKey, dialogId, limit) {
628
- const { readDialogFromLocalDb: readLocalDialog } = await import("./localDialogRead-D3BELSTF.js");
628
+ const { readDialogFromLocalDb: readLocalDialog } = await import("./localDialogRead-Z5UTAJPU.js");
629
629
  const result = await readLocalDialog({ dialogKey, dialogId, limit });
630
630
  return {
631
631
  ...result,
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  asNonEmptyStringArray,
6
6
  asTrimmedNonEmptyStringArray
7
- } from "./chunk-PN7AFLOK.js";
7
+ } from "./chunk-I42VC5KR.js";
8
8
  import {
9
9
  asOptionalFiniteNumber
10
10
  } from "./chunk-WWC7I6TA.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  buildAgentRuntimeAgentLookupKeys,
3
3
  shouldFetchAgentRuntimeRecordRemotely
4
- } from "./chunk-U5CWPEKM.js";
4
+ } from "./chunk-SACYB45H.js";
5
5
 
6
6
  // packages/cli/client/localAgentRecords.ts
7
7
  var buildLocalAgentLookupKeys = buildAgentRuntimeAgentLookupKeys;
@@ -0,0 +1,386 @@
1
+ import {
2
+ extractThinkContent,
3
+ flushThinkParser,
4
+ processThinkChunk
5
+ } from "./chunk-OPZYGHUC.js";
6
+ import {
7
+ buildProviderExecutionPlan,
8
+ canUsePlatformChatProvider,
9
+ convertMessagesToResponsesInput,
10
+ extractTextFromResponseOutput,
11
+ extractToolCallsFromResponseOutput,
12
+ hasDirectOpenAiCompatibleProvider,
13
+ resolveAgentRuntimeLocation,
14
+ resolvePlatformAuthToken,
15
+ resolvePlatformServerUrl,
16
+ resolveProviderTransportDecision,
17
+ toResponsesTools
18
+ } from "./chunk-XDVAYP26.js";
19
+
20
+ // packages/agent-runtime/openAiCompatibleMessages.ts
21
+ function toOpenAiCompatibleMessages(messages) {
22
+ return messages.map((message) => ({
23
+ role: message.role,
24
+ content: message.content ?? "",
25
+ ...message.tool_call_id ? { tool_call_id: message.tool_call_id } : {},
26
+ ...Array.isArray(message.tool_calls) ? { tool_calls: message.tool_calls } : {},
27
+ ...message.reasoning_content ? { reasoning_content: message.reasoning_content } : {}
28
+ }));
29
+ }
30
+
31
+ // packages/agent-runtime/toolCallAccumulator.ts
32
+ function accumulateToolCallDelta(accumulated, deltas) {
33
+ for (const delta of deltas) {
34
+ const index = typeof delta.index === "number" ? delta.index : 0;
35
+ const current = accumulated[index] ?? {
36
+ id: "",
37
+ type: "function",
38
+ function: { name: "", arguments: "" }
39
+ };
40
+ if (typeof delta.id === "string" && delta.id) current.id = delta.id;
41
+ const fn = delta.function;
42
+ if (fn && typeof fn === "object") {
43
+ const functionDelta = fn;
44
+ if (typeof functionDelta.name === "string" && functionDelta.name) {
45
+ current.function.name += functionDelta.name;
46
+ }
47
+ if (typeof functionDelta.arguments === "string" && functionDelta.arguments) {
48
+ current.function.arguments += functionDelta.arguments;
49
+ }
50
+ }
51
+ accumulated[index] = current;
52
+ }
53
+ }
54
+ function finalizeAccumulatedToolCalls(accumulated) {
55
+ return Object.keys(accumulated).map((key) => accumulated[Number(key)]).filter((call) => call?.function?.name);
56
+ }
57
+
58
+ // packages/agent-runtime/processChatCompletionDelta.ts
59
+ function extractChatCompletionStreamError(parsed) {
60
+ const raw = parsed?.error;
61
+ if (!raw) return null;
62
+ if (typeof raw === "string") {
63
+ return raw.trim() ? { message: raw.trim() } : null;
64
+ }
65
+ if (typeof raw !== "object") return null;
66
+ const message = typeof raw.msg === "string" && raw.msg.trim() ? raw.msg.trim() : typeof raw.message === "string" && raw.message.trim() ? raw.message.trim() : "";
67
+ const code = typeof raw.code === "string" && raw.code.trim() ? raw.code.trim() : typeof raw.type === "string" && raw.type.trim() ? raw.type.trim() : void 0;
68
+ if (!message && !code) return null;
69
+ return {
70
+ message: message || "upstream stream error",
71
+ ...code ? { code } : {}
72
+ };
73
+ }
74
+ function throwIfChatCompletionStreamFailed(state) {
75
+ const failure = state.streamError;
76
+ if (!failure) return;
77
+ const error = new Error(
78
+ failure.code ? `${failure.message} (${failure.code})` : failure.message
79
+ );
80
+ if (failure.code) error.code = failure.code;
81
+ throw error;
82
+ }
83
+ function applyChatCompletionDelta(parsed, state) {
84
+ const streamError = extractChatCompletionStreamError(parsed);
85
+ if (streamError && !state.streamError) {
86
+ state.streamError = streamError;
87
+ }
88
+ if (parsed?.usage && typeof parsed.usage === "object") {
89
+ state.usage = parsed.usage;
90
+ }
91
+ const rawFinishReason = parsed?.choices?.[0]?.finish_reason;
92
+ if (typeof rawFinishReason === "string" && rawFinishReason.length > 0) {
93
+ state.finishReason = rawFinishReason;
94
+ }
95
+ const delta = parsed?.choices?.[0]?.delta;
96
+ if (!delta || typeof delta !== "object") return false;
97
+ const reasoningChunk = typeof delta.reasoning_content === "string" ? delta.reasoning_content : typeof delta.reasoning === "string" ? delta.reasoning : "";
98
+ if (reasoningChunk) {
99
+ state.reasoning += reasoningChunk;
100
+ state.onReasoningDelta?.(reasoningChunk);
101
+ }
102
+ if (Array.isArray(delta.tool_calls) && delta.tool_calls.length > 0) {
103
+ accumulateToolCallDelta(state.accumulatedToolCalls, delta.tool_calls);
104
+ }
105
+ const textChunk = typeof delta.content === "string" ? delta.content : "";
106
+ if (textChunk) {
107
+ const parsedChunk = processThinkChunk(textChunk, state.thinkState);
108
+ state.thinkState = parsedChunk.state;
109
+ if (parsedChunk.content) {
110
+ state.content += parsedChunk.content;
111
+ state.onTextDelta?.(parsedChunk.content);
112
+ }
113
+ if (parsedChunk.reasoning) {
114
+ state.reasoning += parsedChunk.reasoning;
115
+ state.onReasoningDelta?.(parsedChunk.reasoning);
116
+ }
117
+ }
118
+ return true;
119
+ }
120
+ function flushChatCompletionStream(state) {
121
+ const flushed = flushThinkParser(state.thinkState);
122
+ state.thinkState = flushed.state;
123
+ if (flushed.content) {
124
+ state.content += flushed.content;
125
+ state.onTextDelta?.(flushed.content);
126
+ }
127
+ if (flushed.reasoning) {
128
+ state.reasoning += flushed.reasoning;
129
+ state.onReasoningDelta?.(flushed.reasoning);
130
+ }
131
+ }
132
+
133
+ // packages/agent-runtime/sseFrames.ts
134
+ async function* readSseFrames(response) {
135
+ const reader = response.body?.getReader();
136
+ if (!reader) {
137
+ throw new Error("SSE response did not include a readable body.");
138
+ }
139
+ const decoder = new TextDecoder();
140
+ let buffer = "";
141
+ while (true) {
142
+ const { done, value } = await reader.read();
143
+ if (done) break;
144
+ buffer += decoder.decode(value, { stream: true });
145
+ let boundary = buffer.indexOf("\n\n");
146
+ while (boundary !== -1) {
147
+ yield buffer.slice(0, boundary);
148
+ buffer = buffer.slice(boundary + 2);
149
+ boundary = buffer.indexOf("\n\n");
150
+ }
151
+ }
152
+ if (buffer.trim()) yield buffer;
153
+ }
154
+ async function readSseDataValues(response, parse) {
155
+ const reader = response.body?.getReader();
156
+ if (!reader) return [];
157
+ const decoder = new TextDecoder();
158
+ const values = [];
159
+ let buffer = "";
160
+ while (true) {
161
+ const { done, value } = await reader.read();
162
+ if (done) break;
163
+ buffer += decoder.decode(value, { stream: true });
164
+ const lines = buffer.split("\n");
165
+ buffer = lines.pop() ?? "";
166
+ for (const line of lines) {
167
+ const parsed = parse(line);
168
+ if (parsed) values.push(parsed);
169
+ }
170
+ }
171
+ if (buffer.trim()) {
172
+ const parsed = parse(buffer);
173
+ if (parsed) values.push(parsed);
174
+ }
175
+ return values;
176
+ }
177
+
178
+ // packages/agent-runtime/platformChatProvider.ts
179
+ var CHAT_PROXY_PATH = "/api/v1/chat";
180
+ function shouldDisableThinking(providerConfig) {
181
+ return providerConfig.provider.toLowerCase() === "mimo" || /xiaomimimo\.com/i.test(providerConfig.endpoint);
182
+ }
183
+ function isResponsesEndpoint(endpoint) {
184
+ return /\/responses$/i.test(endpoint.trim());
185
+ }
186
+ function toResponsesRequestOptions(options) {
187
+ const next = { ...options };
188
+ const reasoningEffort = next.reasoning_effort;
189
+ if (typeof reasoningEffort === "string" && reasoningEffort) {
190
+ next.reasoning = { effort: reasoningEffort };
191
+ delete next.reasoning_effort;
192
+ }
193
+ if (next.max_tokens !== void 0) {
194
+ next.max_output_tokens = next.max_tokens;
195
+ delete next.max_tokens;
196
+ }
197
+ return next;
198
+ }
199
+ async function resolvePlatformChatProviderConfig(args) {
200
+ const plan = await buildProviderExecutionPlan({
201
+ agentConfig: args.agentConfig,
202
+ env: args.env,
203
+ runtimeKind: "local",
204
+ ...args.apiKeyRefResolver ? { apiKeyRefResolver: args.apiKeyRefResolver } : {},
205
+ ...args.credentialBroker ? { credentialBroker: args.credentialBroker } : {},
206
+ ...args.syncFetcher ? { syncFetcher: args.syncFetcher } : {}
207
+ });
208
+ if (plan.mode === "cli") {
209
+ throw new Error("Platform chat provider does not support cli agents.");
210
+ }
211
+ if (plan.transport === "direct") {
212
+ return {
213
+ serverUrl: resolvePlatformServerUrl(args.env),
214
+ authToken: resolvePlatformAuthToken(args.env),
215
+ agentKey: args.agentConfig.key,
216
+ model: plan.model,
217
+ provider: plan.provider,
218
+ endpoint: plan.endpoint,
219
+ requestOptions: plan.requestOptions,
220
+ ...plan.apiKey ? { apiKey: plan.apiKey } : {},
221
+ ...plan.apiKeyHeader ? { apiKeyHeader: plan.apiKeyHeader } : {},
222
+ ...args.agentConfig.apiSource ? { apiSource: args.agentConfig.apiSource } : {}
223
+ };
224
+ }
225
+ return {
226
+ serverUrl: plan.serverUrl,
227
+ authToken: plan.authToken,
228
+ agentKey: plan.agentKey,
229
+ model: plan.model,
230
+ provider: plan.provider,
231
+ endpoint: plan.endpoint,
232
+ requestOptions: plan.requestOptions,
233
+ ...plan.apiKey ? { apiKey: plan.apiKey } : {},
234
+ ...plan.apiKeyHeader ? { apiKeyHeader: plan.apiKeyHeader } : {},
235
+ ...plan.apiSource ? { apiSource: plan.apiSource } : {}
236
+ };
237
+ }
238
+ function buildPlatformChatCompletionRequest(args) {
239
+ const usesResponsesApi = isResponsesEndpoint(args.providerConfig.endpoint);
240
+ const requestOptions = usesResponsesApi ? toResponsesRequestOptions(args.providerConfig.requestOptions) : args.providerConfig.requestOptions;
241
+ const body = {
242
+ model: args.providerConfig.model,
243
+ ...usesResponsesApi ? { input: convertMessagesToResponsesInput(args.messages) } : { messages: toOpenAiCompatibleMessages(args.messages) },
244
+ stream: args.stream ?? false,
245
+ ...args.stream ? { stream_options: { include_usage: true } } : {},
246
+ ...requestOptions,
247
+ ...args.tools && args.tools.length > 0 ? {
248
+ tools: usesResponsesApi ? toResponsesTools(args.tools) : args.tools,
249
+ ...usesResponsesApi ? {} : { tool_choice: "auto" }
250
+ } : {},
251
+ ...shouldDisableThinking(args.providerConfig) ? { thinking: { type: "disabled" } } : {},
252
+ url: args.providerConfig.endpoint,
253
+ provider: args.providerConfig.provider,
254
+ agentKey: args.providerConfig.agentKey,
255
+ ...args.providerConfig.apiSource ? { apiSource: args.providerConfig.apiSource } : {},
256
+ ...args.providerConfig.apiKey ? { KEY: args.providerConfig.apiKey } : {},
257
+ ...args.providerConfig.apiKeyHeader ? { apiKeyHeader: args.providerConfig.apiKeyHeader } : {}
258
+ };
259
+ return {
260
+ url: `${args.providerConfig.serverUrl}${CHAT_PROXY_PATH}`,
261
+ init: {
262
+ method: "POST",
263
+ headers: {
264
+ "Content-Type": "application/json",
265
+ Authorization: `Bearer ${args.providerConfig.authToken}`
266
+ },
267
+ body: JSON.stringify(body)
268
+ }
269
+ };
270
+ }
271
+ function tryParseJson(raw) {
272
+ try {
273
+ return JSON.parse(raw);
274
+ } catch {
275
+ return null;
276
+ }
277
+ }
278
+ function extractJsonObjects(raw) {
279
+ const objects = [];
280
+ let depth = 0;
281
+ let start = -1;
282
+ let inString = false;
283
+ let escaped = false;
284
+ for (let index = 0; index < raw.length; index += 1) {
285
+ const char = raw[index];
286
+ if (inString) {
287
+ if (escaped) {
288
+ escaped = false;
289
+ } else if (char === "\\") {
290
+ escaped = true;
291
+ } else if (char === '"') {
292
+ inString = false;
293
+ }
294
+ continue;
295
+ }
296
+ if (char === '"') {
297
+ inString = true;
298
+ continue;
299
+ }
300
+ if (char === "{") {
301
+ if (depth === 0) start = index;
302
+ depth += 1;
303
+ continue;
304
+ }
305
+ if (char !== "}" || depth === 0) continue;
306
+ depth -= 1;
307
+ if (depth === 0 && start >= 0) {
308
+ const parsed = tryParseJson(raw.slice(start, index + 1));
309
+ if (parsed) objects.push(parsed);
310
+ start = -1;
311
+ }
312
+ }
313
+ return objects;
314
+ }
315
+ function parsePlatformChatCompletionData(raw) {
316
+ const direct = tryParseJson(raw.trim());
317
+ if (direct) return direct;
318
+ const objects = extractJsonObjects(raw);
319
+ return objects.find((object) => Array.isArray(object?.choices)) ?? objects[0] ?? {};
320
+ }
321
+ function parsePlatformChatCompletionResponse(args) {
322
+ if (isResponsesEndpoint(args.providerConfig.endpoint)) {
323
+ const content2 = extractTextFromResponseOutput(args.data);
324
+ const tool_calls = extractToolCallsFromResponseOutput(args.data);
325
+ return {
326
+ content: content2,
327
+ model: args.providerConfig.model,
328
+ provider: args.providerConfig.provider,
329
+ ...tool_calls.length > 0 ? { tool_calls } : {},
330
+ usage: args.data?.usage,
331
+ trace: args.trace
332
+ };
333
+ }
334
+ const choiceMessage = args.data?.choices?.[0]?.message ?? {};
335
+ const rawContent = String(choiceMessage?.content ?? "");
336
+ const { content, reasoning } = extractThinkContent(rawContent);
337
+ return {
338
+ content,
339
+ model: args.providerConfig.model,
340
+ provider: args.providerConfig.provider,
341
+ ...Array.isArray(choiceMessage?.tool_calls) ? { tool_calls: choiceMessage.tool_calls } : {},
342
+ ...reasoning ? { reasoning_content: reasoning } : typeof choiceMessage?.reasoning_content === "string" && choiceMessage.reasoning_content ? { reasoning_content: choiceMessage.reasoning_content } : {},
343
+ usage: args.data?.usage,
344
+ trace: args.trace
345
+ };
346
+ }
347
+ function canUsePlatformChatProvider2(env) {
348
+ return canUsePlatformChatProvider(env);
349
+ }
350
+ function hasDirectOpenAiCompatibleProvider2(env) {
351
+ return hasDirectOpenAiCompatibleProvider(env);
352
+ }
353
+ function shouldUsePlatformChatProvider(env, agentConfig) {
354
+ if (!agentConfig) {
355
+ return resolveProviderTransportDecision({
356
+ agentConfig: { key: "default-platform" },
357
+ env,
358
+ runtimeLocation: "local-host"
359
+ }).transport === "proxy";
360
+ }
361
+ return resolveProviderTransportDecision({
362
+ agentConfig,
363
+ env,
364
+ runtimeLocation: resolveAgentRuntimeLocation({
365
+ agentConfig,
366
+ runtimeKind: "local"
367
+ })
368
+ }).transport === "proxy";
369
+ }
370
+
371
+ export {
372
+ finalizeAccumulatedToolCalls,
373
+ throwIfChatCompletionStreamFailed,
374
+ applyChatCompletionDelta,
375
+ flushChatCompletionStream,
376
+ toOpenAiCompatibleMessages,
377
+ readSseFrames,
378
+ readSseDataValues,
379
+ resolvePlatformChatProviderConfig,
380
+ buildPlatformChatCompletionRequest,
381
+ parsePlatformChatCompletionData,
382
+ parsePlatformChatCompletionResponse,
383
+ canUsePlatformChatProvider2 as canUsePlatformChatProvider,
384
+ hasDirectOpenAiCompatibleProvider2 as hasDirectOpenAiCompatibleProvider,
385
+ shouldUsePlatformChatProvider
386
+ };