nolo-cli 0.1.44 → 0.1.46

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 (613) hide show
  1. package/README.md +258 -102
  2. package/index.js +73433 -0
  3. package/package.json +10 -633
  4. package/LICENSE +0 -21
  5. package/agent-runtime/agentConfigOptions.ts +0 -12
  6. package/agent-runtime/agentRecordConfig.ts +0 -101
  7. package/agent-runtime/agentRecordKeys.ts +0 -14
  8. package/agent-runtime/agentThread.ts +0 -222
  9. package/agent-runtime/agentThreadAdmission.ts +0 -74
  10. package/agent-runtime/dialogMessageRecord.ts +0 -16
  11. package/agent-runtime/dialogWritePlan.ts +0 -211
  12. package/agent-runtime/hostAdapter.ts +0 -81
  13. package/agent-runtime/hybridRecordStore.ts +0 -170
  14. package/agent-runtime/index.ts +0 -184
  15. package/agent-runtime/localDialogRead.ts +0 -23
  16. package/agent-runtime/localLoop.ts +0 -334
  17. package/agent-runtime/localToolPolicy.ts +0 -179
  18. package/agent-runtime/localWorkspaceTools.ts +0 -2310
  19. package/agent-runtime/noloWorkspaceTools.ts +0 -390
  20. package/agent-runtime/openAiCompatibleProvider.ts +0 -74
  21. package/agent-runtime/openAiCompatibleProviderConfig.ts +0 -27
  22. package/agent-runtime/platformChatProvider.ts +0 -229
  23. package/agent-runtime/providerResolution.ts +0 -302
  24. package/agent-runtime/runtimeDecision.ts +0 -70
  25. package/agent-runtime/runtimeFacts.ts +0 -40
  26. package/agent-runtime/runtimeToolPolicy.ts +0 -191
  27. package/agent-runtime/runtimeToolSurface.ts +0 -199
  28. package/agent-runtime/shellCommandPolicy.ts +0 -120
  29. package/agent-runtime/types.ts +0 -137
  30. package/agentAliases.ts +0 -110
  31. package/agentCommandSupport.ts +0 -81
  32. package/agentInternalCommandEntries.ts +0 -44
  33. package/agentListCommands.ts +0 -185
  34. package/agentListHelpers.ts +0 -242
  35. package/agentMachineCommands.ts +0 -403
  36. package/agentPullCommand.ts +0 -142
  37. package/agentRecordCommands.ts +0 -226
  38. package/agentRecordHelpers.ts +0 -571
  39. package/agentRunCommand.ts +0 -556
  40. package/agentRuntimeCommands.ts +0 -7
  41. package/agentRuntimeLocal.ts +0 -45
  42. package/ai/agent/_executeModel.ts +0 -146
  43. package/ai/agent/agentSlice.ts +0 -557
  44. package/ai/agent/appWorkingMemory.ts +0 -126
  45. package/ai/agent/buildEditingContext.ts +0 -378
  46. package/ai/agent/buildSystemPrompt.ts +0 -599
  47. package/ai/agent/canvasEditingContext.ts +0 -49
  48. package/ai/agent/cleanAgentMessages.ts +0 -140
  49. package/ai/agent/cliChatClient.ts +0 -153
  50. package/ai/agent/cliExecutor.ts +0 -1465
  51. package/ai/agent/cliPrompt.ts +0 -10
  52. package/ai/agent/contextCompiler.ts +0 -107
  53. package/ai/agent/contextLayerContract.ts +0 -44
  54. package/ai/agent/createAgentSchema.ts +0 -272
  55. package/ai/agent/currentTimeContext.ts +0 -65
  56. package/ai/agent/executeToolCall.ts +0 -58
  57. package/ai/agent/fetchAgentContexts.ts +0 -42
  58. package/ai/agent/generatePrompt.ts +0 -3
  59. package/ai/agent/getFullChatContextKeys.ts +0 -168
  60. package/ai/agent/guidedCreation/capabilities.ts +0 -84
  61. package/ai/agent/guidedCreation/types.ts +0 -38
  62. package/ai/agent/isLiveAudioOnlyAgent.ts +0 -26
  63. package/ai/agent/liveAudioModel.ts +0 -2
  64. package/ai/agent/machineRunPermissions.ts +0 -113
  65. package/ai/agent/pageBuilderHandoffRules.ts +0 -75
  66. package/ai/agent/persistMessageWithFixedId.ts +0 -37
  67. package/ai/agent/planSlice.ts +0 -259
  68. package/ai/agent/referenceUtils.ts +0 -229
  69. package/ai/agent/runAgentBackground.ts +0 -310
  70. package/ai/agent/runAgentClientLoop.ts +0 -164
  71. package/ai/agent/runtimeGuidance.ts +0 -116
  72. package/ai/agent/serverOrigin.ts +0 -7
  73. package/ai/agent/startParallelAgentStreams.ts +0 -424
  74. package/ai/agent/startupProtocol.ts +0 -53
  75. package/ai/agent/streamAgentChatTurn.ts +0 -2135
  76. package/ai/agent/streamAgentChatTurnUtils.ts +0 -923
  77. package/ai/agent/toolFailureGuard.ts +0 -99
  78. package/ai/agent/types.ts +0 -73
  79. package/ai/agent/utils/imageOutput.ts +0 -37
  80. package/ai/agent/utils/publicImageAgentMode.ts +0 -26
  81. package/ai/agent.ts +0 -2
  82. package/ai/ai.locale.ts +0 -1165
  83. package/ai/chat/accumulateToolCallChunks.ts +0 -126
  84. package/ai/chat/fetchUtils.ts +0 -143
  85. package/ai/chat/inlineImageUrlsForCustomProvider.ts +0 -122
  86. package/ai/chat/parseApiError.ts +0 -67
  87. package/ai/chat/parseMultilineSSE.ts +0 -95
  88. package/ai/chat/sendOpenAICompletionsRequest.ts +0 -921
  89. package/ai/chat/sendOpenAIResponseRequest.ts +0 -720
  90. package/ai/chat/serverProxyRetry.ts +0 -102
  91. package/ai/chat/shouldUseServerProxy.ts +0 -18
  92. package/ai/chat/streamRetry.ts +0 -46
  93. package/ai/chat/updateTotalUsage.ts +0 -89
  94. package/ai/context/buildReferenceContext.ts +0 -437
  95. package/ai/context/retention.ts +0 -165
  96. package/ai/context/tokenUtils.ts +0 -78
  97. package/ai/index.ts +0 -1
  98. package/ai/llm/agentCapabilities.ts +0 -74
  99. package/ai/llm/deepinfra.ts +0 -79
  100. package/ai/llm/fireworks.ts +0 -68
  101. package/ai/llm/generateRequestBody.ts +0 -165
  102. package/ai/llm/getModelContextWindow.ts +0 -93
  103. package/ai/llm/getPricing.ts +0 -252
  104. package/ai/llm/imagePricing.ts +0 -66
  105. package/ai/llm/isResponseAPIModel.ts +0 -13
  106. package/ai/llm/kimi.ts +0 -22
  107. package/ai/llm/mimo.ts +0 -99
  108. package/ai/llm/mistral.ts +0 -21
  109. package/ai/llm/models.ts +0 -45
  110. package/ai/llm/openrouterModels.ts +0 -31
  111. package/ai/llm/providers.ts +0 -313
  112. package/ai/llm/reasoningModels.ts +0 -27
  113. package/ai/llm/types.ts +0 -82
  114. package/ai/llm/usageRequestOptions.ts +0 -59
  115. package/ai/memory/policy.ts +0 -49
  116. package/ai/memory/queryShared.ts +0 -167
  117. package/ai/memory/recentRelationshipRecap.ts +0 -251
  118. package/ai/memory/remember.ts +0 -111
  119. package/ai/memory/scope.ts +0 -74
  120. package/ai/memory/store.ts +0 -20
  121. package/ai/memory/storeShared.ts +0 -76
  122. package/ai/memory/types.ts +0 -52
  123. package/ai/memory/understanding.ts +0 -341
  124. package/ai/memory/understandingGreeting.ts +0 -264
  125. package/ai/policy/personalizationDialog.ts +0 -333
  126. package/ai/policy/runtimePolicy.ts +0 -526
  127. package/ai/policy/selfUpdateFields.ts +0 -48
  128. package/ai/policy/types.ts +0 -64
  129. package/ai/skills/referenceRuntime.ts +0 -274
  130. package/ai/skills/skillDiagnostics.ts +0 -251
  131. package/ai/skills/skillDocBuilder.ts +0 -139
  132. package/ai/skills/skillDocProtocol.ts +0 -526
  133. package/ai/skills/skillSummaryMarker.ts +0 -26
  134. package/ai/token/calculatePrice.ts +0 -576
  135. package/ai/token/missingUsageEstimate.ts +0 -42
  136. package/ai/token/normalizeUsage.ts +0 -124
  137. package/ai/token/openaiImageGenerationUsage.ts +0 -56
  138. package/ai/token/prepareTokenUsageData.ts +0 -93
  139. package/ai/token/resolveBillingTarget.ts +0 -52
  140. package/ai/token/saveTokenRecord.ts +0 -53
  141. package/ai/token/types.ts +0 -103
  142. package/ai/tools/agent/agentTools.ts +0 -214
  143. package/ai/tools/agent/agentUpdateShared.ts +0 -311
  144. package/ai/tools/agent/callAgentTool.ts +0 -139
  145. package/ai/tools/agent/createAgentTool.ts +0 -512
  146. package/ai/tools/agent/createDialogTool.ts +0 -69
  147. package/ai/tools/agent/createSkillAgentTool.ts +0 -62
  148. package/ai/tools/agent/parallelBudget.ts +0 -221
  149. package/ai/tools/agent/prepareAgentDraftTool.ts +0 -159
  150. package/ai/tools/agent/presets/appBuilderPreset.ts +0 -154
  151. package/ai/tools/agent/runLlmTool.ts +0 -96
  152. package/ai/tools/agent/runStreamingAgentTool.ts +0 -73
  153. package/ai/tools/agent/skillAgentArgs.ts +0 -106
  154. package/ai/tools/agent/startAgentDialogTool.ts +0 -54
  155. package/ai/tools/agent/streamParallelAgentsTool.ts +0 -123
  156. package/ai/tools/agent/updateAgentTool.ts +0 -96
  157. package/ai/tools/agent/updateSelfTool.ts +0 -113
  158. package/ai/tools/amazonProductScraperTool.ts +0 -86
  159. package/ai/tools/apifyActorClient.ts +0 -45
  160. package/ai/tools/appEditGuard.ts +0 -372
  161. package/ai/tools/appReadSnapshot.ts +0 -153
  162. package/ai/tools/appTools.ts +0 -1549
  163. package/ai/tools/applyEditTool.ts +0 -259
  164. package/ai/tools/applyLineEditsTool.ts +0 -315
  165. package/ai/tools/browserTools/click.ts +0 -33
  166. package/ai/tools/browserTools/closeSession.ts +0 -29
  167. package/ai/tools/browserTools/common.ts +0 -27
  168. package/ai/tools/browserTools/openSession.ts +0 -48
  169. package/ai/tools/browserTools/readContent.ts +0 -38
  170. package/ai/tools/browserTools/selectOption.ts +0 -46
  171. package/ai/tools/browserTools/typeText.ts +0 -42
  172. package/ai/tools/category/createCategoryTool.ts +0 -66
  173. package/ai/tools/category/queryContentsByCategoryTool.ts +0 -69
  174. package/ai/tools/category/updateContentCategoryTool.ts +0 -75
  175. package/ai/tools/cfBrowserTools.ts +0 -319
  176. package/ai/tools/cfSpeechToTextTool.ts +0 -49
  177. package/ai/tools/checkEnvTool.ts +0 -102
  178. package/ai/tools/cloudflareCrawlTool.ts +0 -289
  179. package/ai/tools/codeSearchTool.ts +0 -123
  180. package/ai/tools/codeTools.ts +0 -101
  181. package/ai/tools/convertMarxistsBookTool.ts +0 -103
  182. package/ai/tools/createDocTool.ts +0 -132
  183. package/ai/tools/createSkillDocTool.ts +0 -155
  184. package/ai/tools/createWorkflowTool.ts +0 -154
  185. package/ai/tools/delayTool.ts +0 -31
  186. package/ai/tools/deleteSpacesTool.ts +0 -325
  187. package/ai/tools/deleteSpacesToolModel.ts +0 -159
  188. package/ai/tools/devReloadUtils.ts +0 -29
  189. package/ai/tools/dialogMessageSearch.ts +0 -137
  190. package/ai/tools/doctorSkillTool.ts +0 -72
  191. package/ai/tools/ecommerceScraperTool.ts +0 -86
  192. package/ai/tools/emailTools.ts +0 -549
  193. package/ai/tools/evalSkillTool.ts +0 -92
  194. package/ai/tools/exaSearchTool.ts +0 -63
  195. package/ai/tools/execShellTool.ts +0 -266
  196. package/ai/tools/executeSqlTool.ts +0 -192
  197. package/ai/tools/fetchWebpageSupport.ts +0 -333
  198. package/ai/tools/fetchWebpageTool.ts +0 -97
  199. package/ai/tools/geminiImagePreviewTool.ts +0 -386
  200. package/ai/tools/generateDocxTool.ts +0 -215
  201. package/ai/tools/googleSearchScraperTool.ts +0 -106
  202. package/ai/tools/importDataTool.ts +0 -133
  203. package/ai/tools/importSkillTool.ts +0 -162
  204. package/ai/tools/index.ts +0 -2290
  205. package/ai/tools/jdProductScraperTool.ts +0 -821
  206. package/ai/tools/listUserSpacesTool.ts +0 -113
  207. package/ai/tools/localFilesTool.ts +0 -276
  208. package/ai/tools/marxistsOfflineBook.ts +0 -253
  209. package/ai/tools/modelUsageTools.ts +0 -206
  210. package/ai/tools/noloWorkspaceReadTools.ts +0 -467
  211. package/ai/tools/olmOcrTool.ts +0 -33
  212. package/ai/tools/openaiImageTool.ts +0 -267
  213. package/ai/tools/prepareTools.ts +0 -193
  214. package/ai/tools/readDocTool.ts +0 -88
  215. package/ai/tools/readFileTool.ts +0 -214
  216. package/ai/tools/readTool.ts +0 -194
  217. package/ai/tools/readXPostTool.ts +0 -229
  218. package/ai/tools/readXhsProfileTool.ts +0 -638
  219. package/ai/tools/rememberMemoryTool.ts +0 -84
  220. package/ai/tools/remotionVideoTool.ts +0 -151
  221. package/ai/tools/searchDialogMessagesTool.ts +0 -222
  222. package/ai/tools/searchWorkspaceTool.ts +0 -259
  223. package/ai/tools/skillFollowup.ts +0 -86
  224. package/ai/tools/surfWeatherTool.ts +0 -169
  225. package/ai/tools/table/addTableRowTool.ts +0 -217
  226. package/ai/tools/table/createTableTool.ts +0 -326
  227. package/ai/tools/table/rowTools.ts +0 -386
  228. package/ai/tools/table/schemaTools.ts +0 -244
  229. package/ai/tools/table/shareTableTool.ts +0 -148
  230. package/ai/tools/table/toolShared.ts +0 -129
  231. package/ai/tools/taobaoTmallProductScraperTool.ts +0 -49
  232. package/ai/tools/toolApiClient.ts +0 -279
  233. package/ai/tools/toolNameAliases.ts +0 -70
  234. package/ai/tools/toolPacks.ts +0 -19
  235. package/ai/tools/toolResultError.ts +0 -42
  236. package/ai/tools/toolRunSlice.ts +0 -303
  237. package/ai/tools/toolSchemaCompatibility.ts +0 -53
  238. package/ai/tools/uiAskChoiceTool.ts +0 -104
  239. package/ai/tools/updateContentTitleTool.ts +0 -84
  240. package/ai/tools/updateDocTool.ts +0 -105
  241. package/ai/tools/updateUserPreferenceProfileTool.ts +0 -153
  242. package/ai/tools/wereadGatewayTool.ts +0 -152
  243. package/ai/tools/whisperTool.ts +0 -76
  244. package/ai/tools/writeFileTool.ts +0 -213
  245. package/ai/tools/youtubeScraperTool.ts +0 -116
  246. package/ai/tools/ziweiChartTool.ts +0 -678
  247. package/ai/types.ts +0 -58
  248. package/ai/workflow/workflowExecutor.ts +0 -323
  249. package/ai/workflow/workflowSlice.ts +0 -73
  250. package/ai/workflow/workflowTypes.ts +0 -106
  251. package/app/actions/syncAppRecord.ts +0 -73
  252. package/app/constants/animationSets.ts +0 -21
  253. package/app/constants/appEditor.ts +0 -99
  254. package/app/favorite/deletedFavoriteProjection.ts +0 -31
  255. package/app/favorite/favoriteSlice.ts +0 -690
  256. package/app/favorite/type.ts +0 -43
  257. package/app/hooks/deleteDbKey.ts +0 -254
  258. package/app/i18n/client.ts +0 -13
  259. package/app/i18n/i18n.base.ts +0 -14
  260. package/app/i18n/i18n.config.ts +0 -77
  261. package/app/i18n/index.ts +0 -15
  262. package/app/i18n/mapLanguage.ts +0 -11
  263. package/app/i18n/translations/appBuilder.locale.ts +0 -453
  264. package/app/i18n/translations/error.locale.ts +0 -246
  265. package/app/i18n/translations/interface.locale.ts +0 -2206
  266. package/app/i18n/translations/pricing.locale.ts +0 -397
  267. package/app/i18n/translations/privacy.locale.ts +0 -168
  268. package/app/i18n/translations/seo.locale.ts +0 -129
  269. package/app/i18n/translations/terms.locale.ts +0 -124
  270. package/app/i18n/types.ts +0 -6
  271. package/app/notifications/model.ts +0 -77
  272. package/app/notifications/notificationSlice.ts +0 -141
  273. package/app/reducer.ts +0 -36
  274. package/app/settings/dbActionThunks.ts +0 -34
  275. package/app/settings/defaultSpacePreference.ts +0 -87
  276. package/app/settings/settingSlice.tsx +0 -1212
  277. package/app/settings/settingsRecord.ts +0 -8
  278. package/app/stateViews/runtime.ts +0 -90
  279. package/app/store.ts +0 -55
  280. package/app/theme/colors.ts +0 -280
  281. package/app/theme/fontPreference.ts +0 -77
  282. package/app/theme/theme.config.ts +0 -120
  283. package/app/theme/themeModeBootstrap.ts +0 -123
  284. package/app/types/appSummary.ts +0 -118
  285. package/app/types.ts +0 -358
  286. package/app/utils/appKeys.ts +0 -55
  287. package/app/utils/async.ts +0 -28
  288. package/app/utils/desktopAgentRuntimeTurnClient.ts +0 -75
  289. package/app/utils/env.ts +0 -17
  290. package/app/utils/fileUtils.ts +0 -229
  291. package/app/utils/imageUtils.ts +0 -274
  292. package/app/utils/myContentItems.ts +0 -317
  293. package/app/utils/retryAfter.ts +0 -36
  294. package/app/utils/retryFetch.ts +0 -61
  295. package/app/utils/toast.ts +0 -3
  296. package/auth/action/signUpAction.ts +0 -227
  297. package/auth/adminPermissions.ts +0 -78
  298. package/auth/authSlice.ts +0 -531
  299. package/auth/client/loginRequest.ts +0 -14
  300. package/auth/resetAuthScopedClientState.ts +0 -27
  301. package/auth/routes.ts +0 -183
  302. package/auth/token.ts +0 -63
  303. package/auth/types.ts +0 -40
  304. package/authCommands.ts +0 -230
  305. package/chat/chat.locale.ts +0 -817
  306. package/chat/dialog/actions/addCybotAction.ts +0 -52
  307. package/chat/dialog/actions/addReferenceKeysAction.ts +0 -62
  308. package/chat/dialog/actions/builtinDialogLlm.ts +0 -35
  309. package/chat/dialog/actions/cleanupCliSession.ts +0 -40
  310. package/chat/dialog/actions/createDialogAction.ts +0 -379
  311. package/chat/dialog/actions/createScheduledTaskAction.ts +0 -78
  312. package/chat/dialog/actions/handleSendMessageAction.ts +0 -202
  313. package/chat/dialog/actions/handleSendMessageResolver.ts +0 -27
  314. package/chat/dialog/actions/removeCybotAction.ts +0 -6
  315. package/chat/dialog/actions/removeDialogAgentAction.ts +0 -44
  316. package/chat/dialog/actions/replacePrimaryCybotAction.ts +0 -6
  317. package/chat/dialog/actions/setPrimaryDialogAgentAction.ts +0 -52
  318. package/chat/dialog/actions/updateDialogSummaryAction.ts +0 -430
  319. package/chat/dialog/actions/updateDialogTitleAction.ts +0 -151
  320. package/chat/dialog/actions/updateDialogTitlePolicy.ts +0 -30
  321. package/chat/dialog/actions/updateTokensAction.ts +0 -233
  322. package/chat/dialog/dialogAgents.ts +0 -72
  323. package/chat/dialog/dialogAttachmentCleanup.ts +0 -135
  324. package/chat/dialog/dialogSlice.ts +0 -985
  325. package/chat/dialog/dialogTitle.ts +0 -81
  326. package/chat/dialog/dialogTokenStats.ts +0 -12
  327. package/chat/dialog/dialogUrl.ts +0 -6
  328. package/chat/dialog/goal.ts +0 -108
  329. package/chat/dialog/objectAssistantRegistry.ts +0 -286
  330. package/chat/dialog/schedule.ts +0 -17
  331. package/chat/messages/activityCompletion.ts +0 -97
  332. package/chat/messages/fetchAndCacheMessages.ts +0 -119
  333. package/chat/messages/fetchConvMsgs.ts +0 -51
  334. package/chat/messages/fetchMessages.ts +0 -84
  335. package/chat/messages/fileUrl.ts +0 -13
  336. package/chat/messages/imagePayloadPersistence.ts +0 -22
  337. package/chat/messages/messageAgent.ts +0 -8
  338. package/chat/messages/messageContent.ts +0 -203
  339. package/chat/messages/messageContract.ts +0 -88
  340. package/chat/messages/messageSlice.ts +0 -1386
  341. package/chat/messages/toolThunks.ts +0 -646
  342. package/chat/messages/types.ts +0 -192
  343. package/chat/messages/web/toolDisplayName.ts +0 -686
  344. package/cli/agentAliases.ts +0 -110
  345. package/cli/agentCommandSupport.ts +0 -81
  346. package/cli/agentInternalCommandEntries.ts +0 -44
  347. package/cli/agentListCommands.ts +0 -185
  348. package/cli/agentListHelpers.ts +0 -242
  349. package/cli/agentMachineCommands.ts +0 -403
  350. package/cli/agentPullCommand.ts +0 -142
  351. package/cli/agentRecordCommands.ts +0 -226
  352. package/cli/agentRecordHelpers.ts +0 -571
  353. package/cli/agentRunCommand.ts +0 -556
  354. package/cli/agentRuntimeLocal.ts +0 -45
  355. package/cli/authCommands.ts +0 -230
  356. package/cli/cliCommandAdapters.ts +0 -28
  357. package/cli/cliCommandDispatch.ts +0 -66
  358. package/cli/cliCommandFactories.ts +0 -66
  359. package/cli/cliCommandTypes.ts +0 -49
  360. package/cli/cliEnvHelpers.ts +0 -116
  361. package/cli/cliSpaceHelpers.ts +0 -39
  362. package/cli/client/agentConfigResolver.ts +0 -1
  363. package/cli/client/agentRun.ts +0 -795
  364. package/cli/client/compactDialog.ts +0 -222
  365. package/cli/client/hybridRecordStore.ts +0 -52
  366. package/cli/client/localAgentRecords.ts +0 -7
  367. package/cli/client/localDialogRecords.ts +0 -30
  368. package/cli/client/localProviderResolver.ts +0 -1
  369. package/cli/client/localRuntimeAdapter.ts +0 -1104
  370. package/cli/client/localToolPolicy.ts +0 -8
  371. package/cli/client/profileConfig.ts +0 -101
  372. package/cli/client/streamingOutput.ts +0 -38
  373. package/cli/commandRegistry.ts +0 -98
  374. package/cli/connectorRunArtifact.ts +0 -120
  375. package/cli/connectorWebSocketTarget.ts +0 -112
  376. package/cli/defaultServer.ts +0 -1
  377. package/cli/dialogAttachmentCleanup.ts +0 -151
  378. package/cli/dialogCommands.ts +0 -1120
  379. package/cli/dialogInternalCommandEntries.ts +0 -17
  380. package/cli/docCreateCommands.ts +0 -345
  381. package/cli/docInternalCommandEntries.ts +0 -11
  382. package/cli/docPageHelpers.ts +0 -80
  383. package/cli/docSkillHelpers.ts +0 -67
  384. package/cli/docSpaceHelpers.ts +0 -46
  385. package/cli/globalRecordOperations.ts +0 -258
  386. package/cli/internalCommandEntries.ts +0 -18
  387. package/cli/localRuntimeAuthority.ts +0 -182
  388. package/cli/localRuntimeDb.ts +0 -26
  389. package/cli/machineCommands.ts +0 -307
  390. package/cli/machineDaemonCommands.ts +0 -185
  391. package/cli/machineHeartbeatCommands.ts +0 -30
  392. package/cli/machineStatusCommands.ts +0 -95
  393. package/cli/machineWatchCommands.ts +0 -41
  394. package/cli/machineWsPromptMaterialization.ts +0 -89
  395. package/cli/machineWsRunDispatch.ts +0 -695
  396. package/cli/machineWsSession.ts +0 -213
  397. package/cli/memoryCommands.ts +0 -253
  398. package/cli/memoryInternalCommandEntries.ts +0 -9
  399. package/cli/offlineMarxistsAgentCommand.ts +0 -316
  400. package/cli/qoderUsageProbe.ts +0 -252
  401. package/cli/runtimeDoctorCommands.ts +0 -174
  402. package/cli/runtimeModeArgs.ts +0 -33
  403. package/cli/scriptCommandEntries.ts +0 -66
  404. package/cli/secretScan.ts +0 -31
  405. package/cli/systemInternalCommandEntries.ts +0 -65
  406. package/cli/tableCommands.ts +0 -453
  407. package/cli/tui/readlineWorkspace.ts +0 -210
  408. package/cli/tui/session.ts +0 -554
  409. package/cli/updateCommands.ts +0 -134
  410. package/cli/workflowInternalCommandEntries.ts +0 -10
  411. package/cliCommandAdapters.ts +0 -28
  412. package/cliCommandDispatch.ts +0 -66
  413. package/cliCommandFactories.ts +0 -66
  414. package/cliCommandTypes.ts +0 -49
  415. package/cliEnvHelpers.ts +0 -116
  416. package/cliSpaceHelpers.ts +0 -39
  417. package/client/agentConfigResolver.test.ts +0 -69
  418. package/client/agentConfigResolver.ts +0 -1
  419. package/client/agentRun.test.ts +0 -1344
  420. package/client/agentRun.ts +0 -795
  421. package/client/compactDialog.test.ts +0 -238
  422. package/client/compactDialog.ts +0 -222
  423. package/client/hybridRecordStore.test.ts +0 -157
  424. package/client/hybridRecordStore.ts +0 -52
  425. package/client/localAgentRecords.test.ts +0 -27
  426. package/client/localAgentRecords.ts +0 -7
  427. package/client/localDialogRecords.test.ts +0 -124
  428. package/client/localDialogRecords.ts +0 -30
  429. package/client/localProviderResolver.test.ts +0 -102
  430. package/client/localProviderResolver.ts +0 -1
  431. package/client/localRuntimeAdapter.test.ts +0 -2804
  432. package/client/localRuntimeAdapter.ts +0 -1104
  433. package/client/localRuntimeDryRun.test.ts +0 -135
  434. package/client/localToolPolicy.test.ts +0 -48
  435. package/client/localToolPolicy.ts +0 -8
  436. package/client/profileConfig.test.ts +0 -106
  437. package/client/profileConfig.ts +0 -101
  438. package/client/streamingOutput.test.ts +0 -22
  439. package/client/streamingOutput.ts +0 -38
  440. package/commandRegistry.ts +0 -98
  441. package/connector-experimental/capabilities.ts +0 -75
  442. package/connector-experimental/codexBinary.ts +0 -41
  443. package/connector-experimental/heartbeatLoop.ts +0 -22
  444. package/connector-experimental/machineInfo.ts +0 -46
  445. package/connector-experimental/protocol.ts +0 -54
  446. package/connectorRunArtifact.ts +0 -120
  447. package/connectorWebSocketTarget.ts +0 -112
  448. package/core/builtinAgents.ts +0 -209
  449. package/core/config.ts +0 -15
  450. package/core/crypto.ts +0 -51
  451. package/core/generateKeyPairFromSeedV1.ts +0 -15
  452. package/core/generateMainKey.ts +0 -22
  453. package/core/init.ts +0 -41
  454. package/core/localOrigins.ts +0 -8
  455. package/core/password.ts +0 -13
  456. package/core/prefix.ts +0 -23
  457. package/create/editor/transforms/fromMarkdown/index.ts +0 -260
  458. package/create/editor/transforms/fromMarkdown/inline.ts +0 -285
  459. package/create/editor/transforms/fromMarkdown/table.ts +0 -130
  460. package/create/editor/transforms/markdownToSlate.ts +0 -24
  461. package/create/editor/transforms/slateToRenderMarkdown.ts +0 -218
  462. package/create/editor/transforms/slateToSimplifiedMarkdown.ts +0 -224
  463. package/create/editor/transforms/slateToText.ts +0 -33
  464. package/create/editor/utils/slateUtils.ts +0 -233
  465. package/create/space/addSpaceAction.ts +0 -193
  466. package/create/space/category/categoryActions.ts +0 -427
  467. package/create/space/changeSpaceAction.ts +0 -36
  468. package/create/space/constants.ts +0 -8
  469. package/create/space/content/addContentAction.ts +0 -116
  470. package/create/space/content/contentThunks.ts +0 -90
  471. package/create/space/content/deleteContentFromSpaceAction.ts +0 -187
  472. package/create/space/content/deleteMultipleContentAction.ts +0 -112
  473. package/create/space/content/moveContentAction.ts +0 -285
  474. package/create/space/content/updateContentCategoryAction.ts +0 -154
  475. package/create/space/content/updateContentTitleAction.ts +0 -151
  476. package/create/space/content/uploadAndAddFileToSpaceAction.ts +0 -98
  477. package/create/space/contentKeyUtils.ts +0 -117
  478. package/create/space/deleteSpaceAction.ts +0 -276
  479. package/create/space/fetchSpaceAction.ts +0 -70
  480. package/create/space/fetchSpaceSidebarStateAction.ts +0 -26
  481. package/create/space/loadDefaultSpaceAction.ts +0 -57
  482. package/create/space/member/addMemberAction.ts +0 -79
  483. package/create/space/member/fetchUserSpaceMembershipsAction.ts +0 -386
  484. package/create/space/member/memberThunks.ts +0 -47
  485. package/create/space/member/removeMemberAction.ts +0 -67
  486. package/create/space/resolvePreferredSpaceId.ts +0 -113
  487. package/create/space/sidebarVisibleTypes.ts +0 -260
  488. package/create/space/space.locale.ts +0 -1087
  489. package/create/space/spaceAccess.ts +0 -182
  490. package/create/space/spaceCollapsedState.ts +0 -54
  491. package/create/space/spaceKeys.ts +0 -65
  492. package/create/space/spaceSlice.ts +0 -328
  493. package/create/space/spaceThunks.ts +0 -410
  494. package/create/space/types.ts +0 -27
  495. package/create/space/updateSpaceAction.ts +0 -107
  496. package/create/space/utils/permissions.ts +0 -47
  497. package/create/types.ts +0 -21
  498. package/database/actions/agentReadResolution.ts +0 -33
  499. package/database/actions/common.ts +0 -243
  500. package/database/actions/deleteFile.ts +0 -40
  501. package/database/actions/fileContent.ts +0 -125
  502. package/database/actions/patch.ts +0 -155
  503. package/database/actions/read.ts +0 -358
  504. package/database/actions/readAndWait.ts +0 -260
  505. package/database/actions/readRequestManager.ts +0 -120
  506. package/database/actions/readResolution.ts +0 -125
  507. package/database/actions/remove.ts +0 -94
  508. package/database/actions/replication.ts +0 -477
  509. package/database/actions/upload.ts +0 -186
  510. package/database/actions/upsert.ts +0 -56
  511. package/database/actions/write.ts +0 -146
  512. package/database/authority/ownerKey.ts +0 -80
  513. package/database/authority/recordAuthority.ts +0 -67
  514. package/database/authority/userAuthorityRegistry.ts +0 -54
  515. package/database/client/fetchUserData.ts +0 -61
  516. package/database/config.ts +0 -40
  517. package/database/dbActionThunks.ts +0 -1
  518. package/database/dbSlice.ts +0 -149
  519. package/database/fileRing.ts +0 -51
  520. package/database/fileStorage.ts +0 -232
  521. package/database/fileUrl.ts +0 -34
  522. package/database/keys.ts +0 -767
  523. package/database/queryPrefixes.ts +0 -14
  524. package/database/requests.ts +0 -443
  525. package/database/runtimeServerContext.ts +0 -54
  526. package/database/server/authorityStoreTypes.ts +0 -31
  527. package/database/server/cliAuthorityBrokerClient.ts +0 -227
  528. package/database/server/cliAuthorityBrokerServer.ts +0 -283
  529. package/database/server/cliAuthorityBrokerTypes.ts +0 -43
  530. package/database/server/cliAuthorityStoreDriver.ts +0 -98
  531. package/database/server/db.ts +0 -99
  532. package/database/server/dbPath.ts +0 -20
  533. package/database/server/ensureDbOpen.ts +0 -12
  534. package/database/server/legacyServerDb.ts +0 -58
  535. package/database/server/levelAuthorityStore.ts +0 -114
  536. package/database/server/memoryAuthorityStore.ts +0 -133
  537. package/database/server/serverStoreFactory.ts +0 -118
  538. package/database/tenantPlacement.ts +0 -57
  539. package/database/tombstones.ts +0 -52
  540. package/database/userDataMerge.ts +0 -95
  541. package/database/userPreferenceRegister.ts +0 -131
  542. package/database/utils/ulid.ts +0 -1
  543. package/defaultServer.ts +0 -1
  544. package/dialogAttachmentCleanup.ts +0 -151
  545. package/dialogCommands.ts +0 -1120
  546. package/dialogInternalCommandEntries.ts +0 -17
  547. package/docCreateCommands.ts +0 -345
  548. package/docInternalCommandEntries.ts +0 -11
  549. package/docPageHelpers.ts +0 -80
  550. package/docSkillHelpers.ts +0 -67
  551. package/docSpaceHelpers.ts +0 -46
  552. package/globalRecordOperations.ts +0 -258
  553. package/index.ts +0 -78
  554. package/integrations/anthropic/anthropicModels.ts +0 -47
  555. package/integrations/deepseek/models.ts +0 -37
  556. package/integrations/google/models.ts +0 -341
  557. package/integrations/openai/chatCompletionStreamMode.ts +0 -10
  558. package/integrations/openai/filterAndCleanMessages.ts +0 -284
  559. package/integrations/openai/flexTier.ts +0 -102
  560. package/integrations/openai/generateOpenAIRequestBody.ts +0 -271
  561. package/integrations/openai/generateResponseRequestBody.ts +0 -77
  562. package/integrations/openai/models.ts +0 -271
  563. package/integrations/openai/providerBodyCompatibility.ts +0 -23
  564. package/integrations/openai/responsesHelpers.ts +0 -297
  565. package/integrations/x-reader/types.ts +0 -109
  566. package/integrations/xai/models.ts +0 -13
  567. package/integrations/xhs-reader/redaction.ts +0 -68
  568. package/integrations/xhs-reader/types.ts +0 -277
  569. package/integrations/xhs-reader/url.ts +0 -80
  570. package/internalCommandEntries.ts +0 -18
  571. package/localRuntimeAuthority.ts +0 -182
  572. package/localRuntimeDb.ts +0 -26
  573. package/machineCommands.ts +0 -307
  574. package/machineDaemonCommands.ts +0 -185
  575. package/machineHeartbeatCommands.ts +0 -30
  576. package/machineStatusCommands.ts +0 -95
  577. package/machineWatchCommands.ts +0 -41
  578. package/machineWsPromptMaterialization.ts +0 -89
  579. package/machineWsRunDispatch.ts +0 -695
  580. package/machineWsSession.ts +0 -213
  581. package/memoryCommands.ts +0 -253
  582. package/memoryInternalCommandEntries.ts +0 -9
  583. package/offlineMarxistsAgentCommand.ts +0 -316
  584. package/qoderUsageProbe.ts +0 -252
  585. package/render/contentIcon/types.ts +0 -167
  586. package/render/page/createPageAction.ts +0 -183
  587. package/render/page/docSlice.ts +0 -495
  588. package/render/page/types.ts +0 -19
  589. package/render/table/activityColumns.ts +0 -6
  590. package/render/table/createTableAction.ts +0 -274
  591. package/render/table/deleteTableAction.ts +0 -193
  592. package/render/table/fetchAndCacheTableRows.ts +0 -174
  593. package/render/table/tableSlice.ts +0 -1167
  594. package/render/table/toolValueUtils.ts +0 -363
  595. package/render/table/types.ts +0 -262
  596. package/render/table/utils/tableSerialization.ts +0 -50
  597. package/runtimeDoctorCommands.ts +0 -174
  598. package/runtimeModeArgs.ts +0 -33
  599. package/scriptCommandEntries.ts +0 -66
  600. package/secretScan.ts +0 -31
  601. package/server/handlers/agentRun/types.ts +0 -105
  602. package/share/action.ts +0 -225
  603. package/share/helpers.ts +0 -302
  604. package/share/keys.ts +0 -243
  605. package/share/publicSharePolicy.ts +0 -27
  606. package/share/shareSlice.ts +0 -53
  607. package/share/types.ts +0 -100
  608. package/systemInternalCommandEntries.ts +0 -65
  609. package/tableCommands.ts +0 -453
  610. package/tui/readlineWorkspace.ts +0 -210
  611. package/tui/session.ts +0 -554
  612. package/updateCommands.ts +0 -134
  613. package/workflowInternalCommandEntries.ts +0 -10
@@ -1,599 +0,0 @@
1
- // 文件路径: ai/agent/buildSystemPrompt.ts
2
- // 平台通用 Agent System Prompt 生成器
3
- // 所有模型调用的 system prompt 均由此函数构建
4
-
5
- import { mapLanguage } from "../../app/i18n/mapLanguage";
6
- import { Agent } from "../../app/types";
7
- import { buildSkillGuidancePromptBlock } from "../skills/referenceRuntime";
8
- import { buildRuntimeGuidanceBlocks } from "../agent/runtimeGuidance";
9
- import { canonicalizeToolNames } from "../tools/toolNameAliases";
10
- import { PAGE_BUILDER_HANDOFF_INSTRUCTIONS } from "./pageBuilderHandoffRules";
11
- import { compileContextLayers, type CompiledContext } from "./contextCompiler";
12
- import { buildCurrentTimeBlock } from "./currentTimeContext";
13
- import { Contexts } from "../types";
14
-
15
- // ============================================================================
16
- // 参考资料使用说明(对所有 Agent 注入)
17
- // ============================================================================
18
-
19
- const CONTEXT_USAGE_INSTRUCTIONS = `参考资料使用说明:
20
- - 下方提供的资料是你的主要权威信息来源。
21
- - 回答问题时,应优先依赖这些资料。它们按优先级从高到低排列。
22
- - 使用其中的事实、数据和名称时,要保持精准。
23
- - 如果资料中没有包含答案,应说明这一点,然后再使用你的通用知识进行回答。
24
- - 如果你在资料中发现相互矛盾的信息,也要在回答中指出这一点。
25
- - 当通用指令与更具体的"按 Agent / 按文档"的规则发生冲突时,必须优先遵守更具体、优先级更高的规则。`;
26
-
27
- // ============================================================================
28
- // 交互说明(有 ui_ask_choice 工具时注入)
29
- // ============================================================================
30
-
31
- const MENU_USAGE_INSTRUCTIONS = `--- 交互说明(菜单与快捷入口) ---
32
- 在这个系统里,无论用户是手动输入文字,还是点击某个按钮/菜单,最终你只会收到一条普通的自然语言消息(就像用户直接键入的一样)。
33
-
34
- 对你来说:
35
- - 不要假设或讨论用户点击了哪些按钮、使用了什么菜单,也不要在回复中提到"按钮""菜单""界面""第几个选项"等字样。
36
- - 把所有收到的消息都当作用户刚刚输入的一句话,根据这句话的内容直接理解和回答即可。`;
37
-
38
- // ============================================================================
39
- // 网页访问(有 exa_search 工具时注入)
40
- // ============================================================================
41
-
42
- const WEBPAGE_ACCESS_INSTRUCTIONS = `--- 网页访问能力 (Web Access) ---
43
- 在需要获取外部信息时,请遵循以下由简入繁的策略:
44
-
45
- 0. **如果用户已经给了明确 URL,先直接抓这些 URL**
46
- - 不要先搜索,不要先猜备用网址,不要忽略用户给的链接。
47
- - 用户明确给出的 URL,默认就是本次任务的最高优先级网页真值来源。
48
- - 如果任务是“根据这些网页更新代码 / 文档 / 配置”,先逐个 fetch,再基于抓到的内容提取字段。
49
- - 只要这些 URL 能正常抓取,就不要再调用 exa_search 搜索“更权威”的来源,也不要自行切换到其他站点或镜像页。
50
- - 只有在用户给的 URL 抓取失败、页面明显缺字段、或页面内容与任务不匹配时,才允许额外搜索;如果发生这种降级,最终回复里要明确说明原因。
51
-
52
- 1. **优先使用 exa_search (Exa.ai)**
53
- - 适用于:用户没有给明确 URL 时,搜索互联网信息、寻找教程、获取最新动态。
54
- - 对陌生的文档站或你还不确定具体页面路径的 docs 站点,优先先用它发现权威入口,而不是直接猜 docs 子路径。
55
- - 优点:它是专为 AI 设计的神经网络搜索引擎,能直接返回高质量、结构化的内容(包含正文),无需再去爬取。
56
- - *Always try this FIRST for searches.*
57
-
58
- 2. **其次使用 fetchWebpage (全渲染)**
59
- - 适用于:你已经有了明确的 URL,需要获取该页面的完整内容(含 JS 渲染、动态内容、SPA)。
60
- - 底层走 Cloudflare Browser Rendering,支持 JS 执行,返回渲染后的正文。
61
- - 对于 \`docs.*\` 文档站,fetchWebpage 会自动检查 \`/llms.txt\` 和 \`/llms-full.txt\`,并把你推测的文档 URL 规范化为权威页面。
62
- - 如果你不确定 docs 站里有哪些页面,先用 exa_search 做发现;如果你只是大致猜到了 docs 子路径,可以直接交给 fetchWebpage 去规范化并抓取。
63
- - 优点:一次调用即可获取完整页面内容,无需手动操控浏览器。
64
-
65
- 3. **仅当需要复杂交互时使用 browser_openSession**
66
- - 仅当需要登录、填表、多步点击等复杂操作时使用。
67
- - 适用于:需要登录的站点、需要填写表单、需要连续交互的场景。
68
- - 流程:先 openSession -> 拿到 ID -> 再 typeText / click / readContent。
69
-
70
-
71
- 3. **精准数据抓取 (Scrapers)**
72
- - 如果用户明确需要 YouTube 视频信息、亚马逊商品数据、Google 搜索结果,请直接使用对应的专用 Scraper 工具 (youtubeScraper, amazonProductScraper 等),效果比自己去爬网页更好。`;
73
-
74
- // ============================================================================
75
- // 本地文件整理(有 local desktop file tools 时注入)
76
- // ============================================================================
77
-
78
- const LOCAL_FILE_ORGANIZATION_INSTRUCTIONS = `--- 本地文件整理能力 ---
79
- 你可以帮助用户整理桌面客户端里已授权的本地文件夹。必须遵守:
80
-
81
- - 只能访问用户已授权的本地文件夹,所有路径都必须是授权根目录内的相对路径。
82
- - 开始使用 listLocalFiles / readLocalFile 之前,先调用 listLocalRoots 查看当前已授权 roots。
83
- - 如果目标文件夹还没授权,先调用 requestLocalFolderAccess 请求授权,拿到 rootId 后再继续。
84
- - 如果用户要求“默认桌面路径 / 默认下载路径 / 默认文档路径”,不要把“默认”原样传给工具;先用 execShell 解析当前机器上的绝对路径,再把具体 path 传给 requestLocalFolderAccess。
85
- - 对工作区或代码仓库任务,不要用本地文件夹授权工具;优先使用 readFile / listFiles / writeFile / editFile / searchFiles 这组 workspace-scoped coding 工具。
86
- - 开始整理前,先列目录和读取必要文件,理解现状后再提出计划。
87
- - 对移动、重命名、写入、删除等改动,不要直接修改文件;先调用 proposeLocalFileChanges 创建待确认计划。
88
- - 用户确认后,才执行已确认的本地文件整理计划。
89
- - 删除类操作要保守;能通过移动到整理目录解决时,不要优先删除。
90
- - 回复用户时说明将要改哪些文件、为什么改、以及是否可撤销。`;
91
-
92
- // ============================================================================
93
- // Agent 编排协作(有 callAgent / runStreamingAgent 工具时注入)
94
- // ============================================================================
95
-
96
- const AGENT_ORCHESTRATION_INSTRUCTIONS = `--- Agent 编排与协作 ---
97
- 你所在的系统支持多个子 Agent 和工作流工具,请把自己视为"总协调者":
98
-
99
- 1)子 Agent 协作
100
- - 如果目标 Agent 记录已经声明 delegation.serverBase / runtimeServerBase,工具会自动路由到对应 nolo server;你不需要重复填写 serverBase。
101
- - 如果用户明确给了另一个可访问的 server origin(例如 Windows 机器的 Cloudflare 域名),可以在工具参数里传 serverBase 覆盖自动路由;不要臆造地址,也不要把普通 localhost 当成远端机器。
102
- - 当用户需要多视角分析或辩论时,你可以:
103
- - 先用 callAgent 依次询问多个 Agent 对同一问题的看法;
104
- - 在最后一条回复中,用你自己的话帮用户总结这些观点的异同,并给出综合结论。
105
-
106
- 2)工作流 / Workflow 工具
107
- - 对于需要多步骤、顺序依赖或批量工具调用的复杂任务,应优先考虑使用 createWorkflow 这类工作流工具。
108
- - 调用工作流工具时,你负责:
109
- - 清楚描述目标和约束;
110
- - 在工作流执行过程中关注其输出的中间结果和最终结果;
111
- - 当你认为任务足够完成,或用户要求总结时,对整个过程和结果进行总结,指出可能的错误或风险。
112
-
113
- 3)危险 / 不可逆操作
114
- - 涉及不可逆操作时(修改文件、删除数据、发送消息、生成正式文件、执行交易等),请优先预览或向用户确认。
115
- - 当工具返回"预览"或"待确认"状态时,请暂停进一步自动修改,等待用户明确确认或反馈后再继续。不要在用户未确认前连续发出多次破坏性修改。`;
116
-
117
- // ============================================================================
118
- // 知识管理(有 createDoc / updateDoc / read 工具时注入)
119
- // 仅包含页面级知识管理,不含自我更新能力
120
- // ============================================================================
121
-
122
- const KNOWLEDGE_MANAGEMENT_INSTRUCTIONS = `--- 知识管理 ---
123
-
124
- ## 三层知识决策
125
-
126
- **1. references 挂载知识(每次对话自动加载)**
127
- - Agent 配置里的 references 会在每次对话开始时自动展开注入到 system prompt
128
- - type=instruction:高优先级,注入到 system prompt 顶部,适合行为规则、操作指南
129
- - type=knowledge:作为参考资料注入,适合领域知识、背景资料
130
- - 支持挂载:page / dialog / table(内容完整展开)
131
- - **page 里的 @mention 只展开元信息(标题+dbKey),不递归展开内容本身**
132
-
133
- **2. createDoc 创建文档(按需 read 加载)**
134
- - 总知识页(索引):跨会话的决策规则、路由表,用 @[page:PAGE-xxx|标题] mention 指向细分页
135
- - 细分知识页(内容):具体领域内容、任务结果,通过总知识索引
136
- - mention 只是指针,要获取细分页内容必须显式调用 read({ dbKey })
137
-
138
- ## 读取路径
139
- 1. prompt / references 有答案 → 直接用(自动加载,最快)
140
- 2. 没有 → read({ dbKey: 总知识索引页 }) 找到细分页 dbKey
141
- 3. 找到 dbKey → read({ dbKey: 细分页 }) 获取完整内容
142
-
143
- ## 何时主动创建/更新知识
144
- - 用户提供了值得复用的信息 → createDoc 记录,再用 updateAgent 把该页加入 references
145
- - 完成有价值的调研/分析 → createDoc 保存结论
146
- - 总知识索引缺入口 → updateDoc 补充 @mention
147
- - **不要**把临时性、一次性的内容写成知识页`;
148
-
149
- // ============================================================================
150
- // 长期记忆(有 rememberMemory 工具时注入)
151
- // ============================================================================
152
-
153
- const MEMORY_CAPTURE_INSTRUCTIONS = `--- 长期记忆 ---
154
- 你拥有 rememberMemory 能力,可以在必要时把值得长期保留的信息写成一条 episodic memory。
155
-
156
- ## 何时记录
157
- - 当你识别到对未来协作明显有帮助、且相对稳定的用户偏好、判断标准、信息组织偏好或场景化抉择模式时,可以记录
158
- - 当对话里形成了后续还会反复用到的空间共识、协作约定或团队规则时,可以记录
159
-
160
- ## 何时不要记录
161
- - 一次性的当前任务细节
162
- - 当前对话里显而易见、很快就会过期的事实
163
- - 只是为了“多记一点”而勉强抽出来的内容
164
-
165
- ## 记录方式
166
- - 优先写成简短、可复用的抽象表达,例如“这个用户在什么场景下通常怎么选 / 怎么协作”
167
- - 不要复制整段对话,也不要把临时上下文原样塞进去
168
- - 只有当前 dialog 明确绑定了 space,且这条信息确实属于共享协作共识时,才传 scope=space;否则保持默认 auto
169
- - 默认静默执行;除非用户正在讨论记忆本身,或需要用户感知这件事,否则不要专门宣布“我正在记忆”
170
- - 如果这条信息对未来帮助不明显,就不要调用 rememberMemory`;
171
-
172
- const MEMORY_USE_GUIDANCE = `--- 记忆使用方式 ---
173
- - 记忆是个性化与连续性增强层;当前用户输入、当前对话、系统规则、Agent prompt、skill 和用户全局偏好都优先于记忆。
174
- - 如果记忆包含用户身份、名字、称呼、与你的关系、长期偏好或当前项目背景,相关时要自然体现,例如开场称呼、确认上下文、回答结构、取舍标准或下一步建议;不要每句话机械称呼用户。
175
- - 处理“上次/继续/跟之前一样/这个项目”这类指代时,优先使用当前 dialog、space、project、agent、sourceDialog 等 KV 路径和时间线来定位;不要只按语义相似度捞一条看起来像的记忆。
176
- - 当当前输入给出新的语言、技术栈、项目、数值、约束或明确覆盖旧偏好时,必须采用当前输入;不要把旧记忆当成更高优先级的真值。
177
- - 推断型理解记忆只能帮助你把握语气、状态和未完成事项;不要说成“你明确告诉过我”,也不要把它显示成用户已授权保存的事实。
178
- - 如果记忆互相冲突或适用场景不明,说明你的判断依据或简短确认,而不是硬套。`;
179
-
180
- // ============================================================================
181
- // 自我更新能力(仅在 Agent 拥有 updateSelf 工具时注入)
182
- // ============================================================================
183
-
184
- const SELF_UPDATE_INSTRUCTIONS = `--- Agent 自我更新能力 ---
185
-
186
- ## 何时更新自己
187
- - 重要决策/进度变化 → updateDoc 写回状态页
188
- - 值得复用的知识 → createDoc 建细分页,再按需要更新自己的 references / greeting / introduction
189
- - 小幅体验优化 → updateSelf 调整 greeting / introduction / tags
190
-
191
- ## 更新原则
192
- - 优先形成最小、可解释的变更,不要为了“显得在进化”而频繁改自己
193
- - 低风险沉淀优先写入 memory / doc;只有当这些知识需要长期改变你的行为方式时,再考虑 updateSelf
194
- - prompt / references / tools / model 这类高影响字段,默认按需要确认来处理,不要静默大改
195
- - 如果工具返回 policy limit / ask / reject,不要重复尝试,应先向用户解释或等待更高权限确认
196
- - 没有发生实际更新时,不要在回复末尾额外汇报“未更新”状态`;
197
-
198
- const GENERIC_AGENT_UPDATE_INSTRUCTIONS = `--- Agent 维护能力 ---
199
- 你拥有 updateAgent 权限,可以更新指定的 Agent。
200
-
201
- ## 何时更新别的 Agent
202
- - 用户明确要求你维护、修复或批量调整另一个 Agent
203
- - 你需要修改的目标不是当前正在运行的自己
204
-
205
- ## 更新原则
206
- - 默认把 updateAgent 当成高风险维护操作,优先最小改动
207
- - 修改前先确认目标 Agent 是否正确,避免误改
208
- - 如果工具返回需要确认,不要绕过确认流程`;
209
-
210
- const CODE_EDITING_FIDELITY_INSTRUCTIONS = `--- 代码编辑真值规则 ---
211
- 当任务涉及 readFile / writeFile / applyEdit / applyLineEdits 等代码编辑工具时,必须遵守以下规则:
212
-
213
- - 先读取目标文件的最新内容,再决定修改。
214
- - 读取本地或代码仓库文件时,必须调用 readFile。不要用 read、readDoc、readPage 读取本地路径;这些工具用于知识库页面/文档 ID。
215
- - 执行本地 shell/bash 命令时,必须调用 execShell。
216
- - 如果用户提供了 URL、文档页或产品页,且你需要据此改代码,必须先抓取这些网页,再开始编辑。
217
- - 如果用户已经提供可用 URL,就不要再搜索替代来源;只有这些 URL 无法满足任务时,才允许降级到搜索,并在最终回复中说明。
218
- - 网页中直接出现的模型名、价格、上下文窗口、发布日期、能力描述、是否支持 function calling / vision 等字段,视为本次修改的权威来源。
219
- - 如果用户提供了精确代码块、对象字面量、字段值、补丁片段或“唯一真值”,必须逐字使用这些内容,不得自行润色、改写数值、替换描述或补全你记忆里的“更合理版本”。
220
- - 对价格、上下文窗口、模型能力、布尔字段、枚举值这类结构化配置,禁止凭记忆推断。
221
- - 如果网页没有明确给出某个字段,不要编造。优先保留文件中已有的相邻风格与安全默认值,或只填写网页能直接支持的字段。
222
- - 保守默认值规则:
223
- - 对“新加模型条目”,recommended 必须默认 false。只有用户明确要求“设为推荐/高亮”,才允许写成 true。网页里的营销词(如 flagship、strong default、best-in-class)不构成 recommended=true 的证据。
224
- - deprecated 默认 false,除非网页明确写了废弃、停用、legacy、sunset。
225
- - supportReasoning 默认 false,除非网页明确说明该模型支持 reasoning / thinking / reasoning tokens。
226
- - supportVision 只有在网页明确出现 image input / multimodal / vision 支持时才设为 true。
227
- - supportTool 只有在网页明确出现 function calling / tool calling / tools 支持时才设为 true。
228
- - 最终汇报必须以“实际写入后的文件内容”或 applyEdit / writeFile 的返回结果为准,不要汇报没有真正落盘的字段值。
229
- - 编辑完成后,最终回复只做简短结果汇报:说清改了哪些条目、依据了哪些 URL、是否还有缺失字段。不要长篇复述网页正文。`;
230
-
231
- const TABLE_SHARE_INSTRUCTIONS = `--- 表格创建与分享 ---
232
- 如果用户明确要求“社区分享 / 公开分享 / 分享链接”,并且你有 shareTable 工具:
233
- - 优先调用 shareTable;
234
- - 传入表的 dbKey,或 tenantId + tableId;
235
- - 完成后直接返回 /share/... 链接。`;
236
-
237
- const AGENT_CREATION_DRAFT_INSTRUCTIONS = `--- Agent 创建草稿流程 ---
238
- 当用户想创建、定制、配置自己的 Agent / AI 助手时,必须走草稿优先流程:
239
-
240
- - 不要直接创建真实 Agent 记录,也不要声称已经创建完成。
241
- - 先基于当前对话和用户刚说的话整理一个可预览草稿,调用 prepareAgentDraft。
242
- - 草稿应尽量包含名称、用途简介、prompt 摘要、完整 prompt、能力、知识引用建议、公开状态和仍需确认的问题。
243
- - 用户表达模糊时,也先给出合理的初版草稿;信息不足时每次只问一个关键问题。
244
- - 对知识引用、公开状态、高风险工具能力,必须等待用户确认后再视为已选。
245
- - 草稿足够完整后,引导用户点击“预览并创建”,进入 /create/agent 做最终确认。`;
246
-
247
- // ============================================================================
248
- // 无 prompt 时的澄清模式
249
- // ============================================================================
250
-
251
- const CLARIFICATION_MODE_INSTRUCTIONS = `在你还不了解用户意图时,通过提问来澄清需求,而不是仓促给出答案。`;
252
-
253
- const isBrowser = typeof window !== "undefined";
254
-
255
- // ============================================================================
256
- // 工具函数
257
- // ============================================================================
258
-
259
- /** 创建一个上下文 section,如果 content 为空则返回空字符串 */
260
- const createContextSection = (
261
- title: string,
262
- description: string,
263
- content?: string | null
264
- ): string =>
265
- content ? `### ${title} \n${description} \n\n${content} ` : "";
266
-
267
- /** 根据屏幕宽度生成响应式布局建议 */
268
- const buildResponseGuidelines = (isMobile: boolean): string => {
269
- if (isMobile) {
270
- return `-- - 响应展示指南-- -
271
- 请为移动端进行优化:
272
- - 使用更短的段落和简洁的项目符号列表。
273
- - 避免过宽的表格或代码块,以免产生横向滚动。
274
- - 优先采用垂直排布,而不是左右并排的布局。`;
275
- }
276
- return `-- - 响应展示指南-- -
277
- 你的回复将显示在大屏幕上。你可以:
278
- - 提供更丰富的推理过程说明和更有层次的结构。
279
- - 在合适的场景下使用宽屏优势,例如更宽的表格、并排对比展示、更长的代码块等。`;
280
- };
281
-
282
- /** 构建参考资料区块 */
283
- const buildReferenceMaterialsBlock = (contexts: Contexts): string => {
284
- const sections = [
285
- createContextSection(
286
- "说明性文档(Instructional Documents)",
287
- "(最高优先级:具体规则与流程)",
288
- contexts.botInstructionsContext
289
- ),
290
- createContextSection(
291
- "当前输入上下文(Current Input Context)",
292
- "(高优先级:来自用户本次输入)",
293
- contexts.currentInputContext
294
- ),
295
- createContextSection(
296
- "会话历史引用(Conversation History References)",
297
- "(中等优先级:来自过往消息)",
298
- contexts.historyContext
299
- ),
300
- createContextSection(
301
- "知识库文档(Knowledge Base Documents)",
302
- "(参考优先级:用于通用查阅)",
303
- contexts.botKnowledgeContext
304
- ),
305
- ].filter(Boolean);
306
-
307
- if (sections.length === 0) {
308
- return "";
309
- }
310
-
311
- return [
312
- "--- 参考资料 ---",
313
- CONTEXT_USAGE_INSTRUCTIONS,
314
- "",
315
- sections.join("\n\n"),
316
- ].join("\n");
317
- };
318
-
319
- /** 构建「当前编辑上下文」区块 */
320
- const buildEditingContextBlock = (contexts: Contexts): string => {
321
- if (!contexts.editingContext) return "";
322
-
323
- return [
324
- "--- 当前编辑上下文 ---",
325
- "下面是用户当前正在查看或编辑的对象描述,请在涉及修改、建议或结构性操作时优先参考这里:",
326
- "",
327
- contexts.editingContext,
328
- ].join("\n");
329
- };
330
-
331
- const buildAppWorkingMemoryBlock = (contexts: Contexts): string => {
332
- if (!contexts.appWorkingMemory) return "";
333
-
334
- return [
335
- "--- 最近应用工作记忆 ---",
336
- "下面是从当前对话最近的应用相关工具调用中提炼出的真值。即使用户没有打开右侧应用侧栏,只要他说“刚才那个 app / 那个网站 / 那个项目”,也优先参考这里:",
337
- "",
338
- contexts.appWorkingMemory,
339
- ].join("\n");
340
- };
341
-
342
- /** 构建「当前 Space 环境」区块 */
343
- const buildSpaceContextBlock = (contexts: Contexts): string => {
344
- if (!contexts.spaceContext) return "";
345
-
346
- return [
347
- "--- 当前空间环境 (Current Space Context) ---",
348
- contexts.spaceContext,
349
- "",
350
- "重要指令 (Space Awareness):",
351
- "- 你正处于上述工作空间中。如果用户的问题涉及到该空间的内容、文件或知识:",
352
- " - 使用 `read` 工具查阅普通数据记录或数据表项。",
353
- "- 如果你在对话中产出了值得保存的重要信息(如总结、方案、代码片段等),请主动询问用户或使用 `createDoc` 工具将其保存为新页面,以便作为长期记忆留存。",
354
- "",
355
- "跨空间导航 (Cross-Space Navigation):",
356
- "- 使用 `listUserSpaces` 工具可获取用户所有可访问的 Space 列表(ID 和名称)。",
357
- "- 使用 `read({ dbKey: \"space-{spaceId}\" })` 可获取指定 Space 的完整数据,包括:",
358
- " - categories: 分类字典,key 是分类 ID,value 包含 name 和 order",
359
- " - contents: 内容字典,每项包含 contentKey(dbKey)、title、type、categoryId",
360
- ].join("\n");
361
- };
362
-
363
- const buildUserPolicyBlock = (contexts: Contexts): string => {
364
- if (!contexts.userPolicyContext) return "";
365
-
366
- return [
367
- "--- 用户偏好与自动化边界 ---",
368
- contexts.userPolicyContext,
369
- ].join("\n");
370
- };
371
-
372
- const buildSkillGuidanceBlock = (agentConfig: Agent): string => {
373
- const recommendedSkillHints = Array.isArray((agentConfig as any).recommendedSkillHints)
374
- ? ((agentConfig as any).recommendedSkillHints as string[]).filter(Boolean)
375
- : [];
376
- const skillPromptPatches = Array.isArray((agentConfig as any).skillPromptPatches)
377
- ? ((agentConfig as any).skillPromptPatches as string[]).filter(Boolean)
378
- : [];
379
-
380
- if (recommendedSkillHints.length === 0 && skillPromptPatches.length === 0) {
381
- return "";
382
- }
383
-
384
- return buildSkillGuidancePromptBlock({
385
- title: "--- 技能提示 ---",
386
- recommendedSkillHints,
387
- skillPromptPatches,
388
- });
389
- };
390
-
391
- // ============================================================================
392
- // 主函数
393
- // ============================================================================
394
-
395
- export const buildSystemPrompt = (options: {
396
- agentConfig: Agent;
397
- language?: string;
398
- contexts?: Contexts;
399
- viewport?: { width: number; height: number };
400
- mobileBreakpoint?: number;
401
- now?: Date;
402
- timeZone?: string;
403
- }): string => buildSystemPromptContext(options).content;
404
-
405
- export const buildSystemPromptContext = (options: {
406
- agentConfig: Agent;
407
- language?: string;
408
- contexts?: Contexts;
409
- viewport?: { width: number; height: number };
410
- mobileBreakpoint?: number;
411
- now?: Date;
412
- timeZone?: string;
413
- }): CompiledContext => {
414
- const {
415
- agentConfig,
416
- contexts = {},
417
- viewport,
418
- mobileBreakpoint = 768,
419
- now = new Date(),
420
- timeZone,
421
- } = options;
422
-
423
- const safeLanguage =
424
- options.language ??
425
- (typeof navigator !== "undefined" ? navigator.language : "en");
426
-
427
- const { name, prompt: mainPrompt, dbKey } = agentConfig;
428
- const mappedLanguage = mapLanguage(safeLanguage);
429
-
430
- const identitySection = [
431
- "--- 身份信息 ---",
432
- name ? `名称: ${name} ` : "",
433
- dbKey ? `ID: ${dbKey} ` : "",
434
- mappedLanguage ? `回复语言: ${mappedLanguage} ` : "",
435
- ]
436
- .filter(Boolean)
437
- .join("\n");
438
-
439
- const corePersonaSection = mainPrompt
440
- ? `-- - 核心角色与任务-- -\n${mainPrompt}`
441
- : "";
442
-
443
- const agentTools = canonicalizeToolNames(agentConfig.tools ?? []);
444
-
445
- // 按工具能力条件注入各指令块
446
- const agentOrchestrationSection = agentTools.some((t) =>
447
- ["callAgent", "runStreamingAgent", "streamParallelAgents"].includes(t)
448
- )
449
- ? [
450
- AGENT_ORCHESTRATION_INSTRUCTIONS,
451
- agentTools.includes("runStreamingAgent") ? PAGE_BUILDER_HANDOFF_INSTRUCTIONS : "",
452
- ].filter(Boolean).join("\n\n")
453
- : "";
454
-
455
- const menuUsageSection = agentTools.includes("ui_ask_choice")
456
- ? MENU_USAGE_INSTRUCTIONS
457
- : "";
458
-
459
- const webAccessSection = agentTools.some((t) =>
460
- ["exa_search", "fetchWebpage", "browser_openSession", "read_x_post"].includes(t)
461
- )
462
- ? WEBPAGE_ACCESS_INSTRUCTIONS
463
- : "";
464
- const localFileOrganizationSection = agentTools.some((t) =>
465
- [
466
- "listLocalRoots",
467
- "requestLocalFolderAccess",
468
- "listLocalFiles",
469
- "readLocalFile",
470
- "proposeLocalFileChanges",
471
- "executeApprovedLocalFileChanges",
472
- "undoLocalFileChangeBatch",
473
- ].includes(t)
474
- )
475
- ? LOCAL_FILE_ORGANIZATION_INSTRUCTIONS
476
- : "";
477
- const tableShareSection = agentTools.some((t) =>
478
- ["createTable", "shareTable", "addTableRow", "addTableRows"].includes(t)
479
- )
480
- ? TABLE_SHARE_INSTRUCTIONS
481
- : "";
482
-
483
- const agentCreationDraftSection = agentTools.includes("prepareAgentDraft")
484
- ? AGENT_CREATION_DRAFT_INSTRUCTIONS
485
- : "";
486
-
487
- // 知识管理:有页面读写工具时注入通用知识管理说明
488
- const knowledgeManagementSection = agentTools.some((t) =>
489
- ["createDoc", "updateDoc", "read", "readDoc", "readPage"].includes(t)
490
- )
491
- ? KNOWLEDGE_MANAGEMENT_INSTRUCTIONS
492
- : "";
493
-
494
- const memoryCaptureSection = agentTools.includes("rememberMemory")
495
- ? MEMORY_CAPTURE_INSTRUCTIONS
496
- : "";
497
-
498
- const selfUpdateSection = agentTools.includes("updateSelf")
499
- ? SELF_UPDATE_INSTRUCTIONS
500
- : "";
501
-
502
- const genericAgentUpdateSection = agentTools.includes("updateAgent")
503
- ? GENERIC_AGENT_UPDATE_INSTRUCTIONS
504
- : "";
505
-
506
- const codeEditingFidelitySection = agentTools.some((t) =>
507
- ["readFile", "writeFile", "applyEdit", "applyLineEdits"].includes(t)
508
- )
509
- ? CODE_EDITING_FIDELITY_INSTRUCTIONS
510
- : "";
511
-
512
- const {
513
- startupProtocol,
514
- contextLayerContract,
515
- emailRegistrationWorkflow,
516
- webResearchToolPolicy,
517
- } =
518
- buildRuntimeGuidanceBlocks(agentTools);
519
-
520
- const clarifyingSection = !mainPrompt ? CLARIFICATION_MODE_INSTRUCTIONS : "";
521
-
522
- const userGlobalPromptSection = contexts.userGlobalPrompt?.trim()
523
- ? `-- - 用户全局偏好-- -\n${contexts.userGlobalPrompt.trim()} `
524
- : "";
525
-
526
- const isMobile =
527
- (viewport?.width ?? (isBrowser ? window.innerWidth : 1440)) <
528
- mobileBreakpoint;
529
-
530
- const responseGuidelinesSection = buildResponseGuidelines(isMobile);
531
- const editingContextSection = buildEditingContextBlock(contexts);
532
- const appWorkingMemorySection = buildAppWorkingMemoryBlock(contexts);
533
- const spaceContextSection = buildSpaceContextBlock(contexts);
534
- const userPolicySection = buildUserPolicyBlock(contexts);
535
- const rawMemoryOverlay = contexts.memoryOverlay?.trim() || "";
536
- const memoryOverlaySection = rawMemoryOverlay
537
- ? rawMemoryOverlay + "\n\n" + MEMORY_USE_GUIDANCE
538
- : "";
539
-
540
- const skillGuidanceSection = buildSkillGuidanceBlock(agentConfig);
541
- const referenceMaterialsSection = buildReferenceMaterialsBlock(contexts);
542
-
543
- const dialogSummarySection = contexts.dialogSummary?.trim()
544
- ? `--- 历史对话摘要 ---\n以下是此前对话轮次的压缩摘要(精确细节可能有简化,请优先参考最近的消息原文):\n\n${contexts.dialogSummary.trim()}`
545
- : "";
546
-
547
- const proactiveSummarySection = contexts.proactiveSummary?.trim()
548
- ? `--- 阶段工作摘要 ---\n以下是系统主动整理的近期工作摘要,原始消息仍在近期上下文中;如有冲突,请优先参考最近的消息原文:\n\n${contexts.proactiveSummary.trim()}`
549
- : "";
550
-
551
- return compileContextLayers([
552
- { id: "identity", owner: "platform", content: identitySection },
553
- {
554
- id: "current-time",
555
- owner: "platform",
556
- cacheScope: "turn",
557
- content: buildCurrentTimeBlock(now, timeZone),
558
- },
559
- { id: "core-persona", owner: "agent", content: corePersonaSection },
560
- { id: "agent-orchestration", owner: "platform", content: agentOrchestrationSection },
561
- { id: "web-access", owner: "platform", content: webAccessSection },
562
- { id: "local-file-organization", owner: "platform", content: localFileOrganizationSection },
563
- { id: "table-share", owner: "platform", content: tableShareSection },
564
- { id: "agent-creation-draft", owner: "platform", content: agentCreationDraftSection },
565
- { id: "menu-usage", owner: "platform", content: menuUsageSection },
566
- { id: "clarification-mode", owner: "platform", content: clarifyingSection },
567
- { id: "knowledge-management", owner: "platform", content: knowledgeManagementSection },
568
- { id: "memory-capture", owner: "platform", content: memoryCaptureSection },
569
- { id: "self-update", owner: "platform", content: selfUpdateSection },
570
- { id: "generic-agent-update", owner: "platform", content: genericAgentUpdateSection },
571
- { id: "code-editing-fidelity", owner: "platform", content: codeEditingFidelitySection },
572
- { id: "startup-protocol", owner: "platform", content: startupProtocol },
573
- { id: "context-layer-contract", owner: "platform", content: contextLayerContract },
574
- {
575
- id: "email-registration-workflow",
576
- owner: "platform",
577
- content: emailRegistrationWorkflow,
578
- },
579
- {
580
- id: "web-research-tool-policy",
581
- owner: "platform",
582
- content: webResearchToolPolicy,
583
- },
584
- { id: "user-global-prompt", owner: "user", content: userGlobalPromptSection },
585
- { id: "response-guidelines", owner: "platform", content: responseGuidelinesSection },
586
- { id: "skill-guidance", owner: "runtime", content: skillGuidanceSection },
587
- { id: "dialog-summary", owner: "runtime", content: dialogSummarySection },
588
- { id: "proactive-summary", owner: "runtime", content: proactiveSummarySection },
589
- { id: "space-context", owner: "runtime", content: spaceContextSection },
590
- { id: "user-policy", owner: "user", content: userPolicySection },
591
- { id: "memory-overlay", owner: "runtime", content: memoryOverlaySection },
592
- { id: "reference-materials", owner: "agent", content: referenceMaterialsSection },
593
- { id: "app-working-memory", owner: "runtime", content: appWorkingMemorySection },
594
- { id: "editing-context", owner: "runtime", content: editingContextSection },
595
- ]);
596
- };
597
-
598
- // 向后兼容:旧名称重新导出
599
- export const generatePrompt = buildSystemPrompt;
@@ -1,49 +0,0 @@
1
- import type { AgentRuntimeOptions } from "./types";
2
-
3
- export function buildCanvasNodeEditingContextSummary(
4
- runtimeOptions?: AgentRuntimeOptions
5
- ): string | null {
6
- if (runtimeOptions?.editingTarget?.kind !== "canvas_node") return null;
7
-
8
- const editingTarget = runtimeOptions.editingTarget;
9
- const metadata = editingTarget.metadata ?? {};
10
- const selectedNodeId =
11
- typeof metadata.selectedNodeId === "string"
12
- ? metadata.selectedNodeId
13
- : editingTarget.key ?? "(未知节点)";
14
- const part =
15
- typeof metadata.part === "string"
16
- ? metadata.part
17
- : editingTarget.title ?? selectedNodeId;
18
- const nodeType =
19
- typeof metadata.type === "string" ? metadata.type : "(未知类型)";
20
- const path = Array.isArray(metadata.path)
21
- ? metadata.path.filter((item): item is string => typeof item === "string")
22
- : [];
23
- const props = metadata.props && typeof metadata.props === "object"
24
- ? metadata.props
25
- : {};
26
- const style = metadata.style && typeof metadata.style === "object"
27
- ? metadata.style
28
- : {};
29
-
30
- return [
31
- "当前编辑目标:Canvas Tree 中的一个选中节点。",
32
- `- 节点 ID: ${selectedNodeId}`,
33
- `- part: ${part}`,
34
- `- 节点类型: ${nodeType}`,
35
- ...(path.length ? [`- 节点路径: ${path.join(" > ")}`] : []),
36
- "",
37
- "当前节点 props:",
38
- JSON.stringify(props, null, 2),
39
- "",
40
- "当前节点 style:",
41
- JSON.stringify(style, null, 2),
42
- "",
43
- "【给 AI 的操作指南 / 非用户原话】",
44
- `1. 如果用户要求修改当前模块,只输出 updateNode,目标 id 必须是 ${selectedNodeId}。`,
45
- "2. 不要重建 root/shell,不要重新 append 已存在的大块内容。",
46
- "3. 除非用户明确要求新增子模块,否则不要 appendNode。",
47
- "4. 回复仍必须遵守 Canvas Tree MVP 协议:只输出 canvas_snapshot NDJSON,不要输出解释或源码。",
48
- ].join("\n");
49
- }