nolo-cli 0.1.10 → 0.1.11

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 (240) hide show
  1. package/README.md +0 -32
  2. package/agentRuntimeCommands.ts +3 -3
  3. package/commandRegistry.ts +2 -2
  4. package/machineCommands.ts +31 -6
  5. package/package.json +6 -22
  6. package/ai/agent/_executeModel.ts +0 -118
  7. package/ai/agent/agentSlice.ts +0 -525
  8. package/ai/agent/appWorkingMemory.ts +0 -126
  9. package/ai/agent/avatarUtils.ts +0 -24
  10. package/ai/agent/buildEditingContext.ts +0 -373
  11. package/ai/agent/buildSystemPrompt.ts +0 -532
  12. package/ai/agent/cleanAgentMessages.ts +0 -140
  13. package/ai/agent/cliChatClient.ts +0 -119
  14. package/ai/agent/cliExecutor.ts +0 -733
  15. package/ai/agent/cliPrompt.ts +0 -10
  16. package/ai/agent/contextCompiler.ts +0 -107
  17. package/ai/agent/contextLayerContract.ts +0 -44
  18. package/ai/agent/createAgentSchema.ts +0 -234
  19. package/ai/agent/executeToolCall.ts +0 -58
  20. package/ai/agent/fetchAgentContexts.ts +0 -42
  21. package/ai/agent/generatePrompt.ts +0 -3
  22. package/ai/agent/getFullChatContextKeys.ts +0 -168
  23. package/ai/agent/hooks/fetchPublicAgents.ts +0 -133
  24. package/ai/agent/hooks/useAgentConfig.ts +0 -61
  25. package/ai/agent/hooks/useAgentDialog.ts +0 -35
  26. package/ai/agent/hooks/useAgentFormValidation.ts +0 -202
  27. package/ai/agent/hooks/usePublicAgents.ts +0 -473
  28. package/ai/agent/machineRunPermissions.ts +0 -95
  29. package/ai/agent/persistMessageWithFixedId.ts +0 -37
  30. package/ai/agent/planSlice.ts +0 -259
  31. package/ai/agent/referenceUtils.ts +0 -229
  32. package/ai/agent/runAgentBackground.ts +0 -238
  33. package/ai/agent/runAgentClientLoop.ts +0 -138
  34. package/ai/agent/runtimeGuidance.ts +0 -97
  35. package/ai/agent/runtimeServerBase.ts +0 -37
  36. package/ai/agent/server/fetchPublicAgents.ts +0 -128
  37. package/ai/agent/startParallelAgentStreams.ts +0 -424
  38. package/ai/agent/startupProtocol.ts +0 -53
  39. package/ai/agent/streamAgentChatTurn.ts +0 -1278
  40. package/ai/agent/streamAgentChatTurnUtils.ts +0 -738
  41. package/ai/agent/types.ts +0 -71
  42. package/ai/agent/utils/imageOutput.ts +0 -33
  43. package/ai/agent/utils/sortUtils.ts +0 -250
  44. package/ai/agent/web/referencePickerUtils.ts +0 -146
  45. package/ai/ai.locale.ts +0 -1079
  46. package/ai/chat/accumulateToolCallChunks.ts +0 -95
  47. package/ai/chat/fetchUtils.native.ts +0 -276
  48. package/ai/chat/fetchUtils.ts +0 -153
  49. package/ai/chat/parseApiError.ts +0 -64
  50. package/ai/chat/parseMultilineSSE.ts +0 -95
  51. package/ai/chat/sendOpenAICompletionsRequest.native.ts +0 -682
  52. package/ai/chat/sendOpenAICompletionsRequest.ts +0 -703
  53. package/ai/chat/sendOpenAIResponseRequest.ts +0 -491
  54. package/ai/chat/shouldUseServerProxy.ts +0 -18
  55. package/ai/chat/sseClient.native.ts +0 -91
  56. package/ai/chat/sseClient.ts +0 -67
  57. package/ai/chat/streamReader.native.ts +0 -31
  58. package/ai/chat/streamReader.ts +0 -62
  59. package/ai/chat/updateTotalUsage.ts +0 -72
  60. package/ai/context/buildReferenceContext.ts +0 -437
  61. package/ai/context/calculateContextUsage.ts +0 -133
  62. package/ai/context/retention.ts +0 -165
  63. package/ai/context/tokenUtils.ts +0 -78
  64. package/ai/index.ts +0 -1
  65. package/ai/llm/calculateGeminiImageTokens.ts +0 -57
  66. package/ai/llm/deepinfra.ts +0 -28
  67. package/ai/llm/fireworks.ts +0 -50
  68. package/ai/llm/generateRequestBody.ts +0 -165
  69. package/ai/llm/getModelContextWindow.ts +0 -84
  70. package/ai/llm/getNoloKey.ts +0 -31
  71. package/ai/llm/getPricing.ts +0 -199
  72. package/ai/llm/hooks/useModelPricing.ts +0 -75
  73. package/ai/llm/imagePricing.ts +0 -40
  74. package/ai/llm/isResponseAPIModel.ts +0 -13
  75. package/ai/llm/mimo.ts +0 -71
  76. package/ai/llm/mistral.ts +0 -22
  77. package/ai/llm/modelAvatar.ts +0 -427
  78. package/ai/llm/models.ts +0 -45
  79. package/ai/llm/openrouterModels.ts +0 -269
  80. package/ai/llm/providers.ts +0 -306
  81. package/ai/llm/reasoningModels.ts +0 -28
  82. package/ai/llm/types.ts +0 -59
  83. package/ai/llm/usageRequestOptions.ts +0 -59
  84. package/ai/memory/capture.ts +0 -148
  85. package/ai/memory/consolidate.ts +0 -104
  86. package/ai/memory/delete.ts +0 -147
  87. package/ai/memory/overlay.ts +0 -84
  88. package/ai/memory/query.ts +0 -38
  89. package/ai/memory/queryShared.ts +0 -160
  90. package/ai/memory/rank.ts +0 -105
  91. package/ai/memory/recentRelationshipRecap.ts +0 -249
  92. package/ai/memory/remember.ts +0 -167
  93. package/ai/memory/runtime.ts +0 -76
  94. package/ai/memory/store.ts +0 -20
  95. package/ai/memory/storeShared.ts +0 -76
  96. package/ai/memory/types.ts +0 -46
  97. package/ai/memory/understanding.ts +0 -349
  98. package/ai/memory/understandingGreeting.ts +0 -264
  99. package/ai/messages/type.ts +0 -20
  100. package/ai/policy/personalizationDialog.ts +0 -333
  101. package/ai/policy/runtimePolicy.ts +0 -440
  102. package/ai/policy/selfUpdateFields.ts +0 -48
  103. package/ai/policy/types.ts +0 -64
  104. package/ai/skills/referenceRuntime.ts +0 -274
  105. package/ai/skills/skillDiagnostics.ts +0 -251
  106. package/ai/skills/skillDocBuilder.ts +0 -139
  107. package/ai/skills/skillDocProtocol.ts +0 -434
  108. package/ai/skills/skillReferenceSummary.ts +0 -63
  109. package/ai/skills/skillSummaryMarker.ts +0 -26
  110. package/ai/token/calculatePrice.ts +0 -544
  111. package/ai/token/db.ts +0 -98
  112. package/ai/token/externalToolCost.ts +0 -330
  113. package/ai/token/hooks/useRecords.ts +0 -65
  114. package/ai/token/missingUsageEstimate.ts +0 -42
  115. package/ai/token/modelUsageQuery.ts +0 -252
  116. package/ai/token/normalizeUsage.ts +0 -84
  117. package/ai/token/openaiImageGenerationUsage.ts +0 -56
  118. package/ai/token/prepareTokenUsageData.ts +0 -88
  119. package/ai/token/query.ts +0 -88
  120. package/ai/token/queryUserTokens.ts +0 -59
  121. package/ai/token/resolveBillingTarget.ts +0 -52
  122. package/ai/token/saveTokenRecord.ts +0 -53
  123. package/ai/token/serverDialogProjection.ts +0 -78
  124. package/ai/token/serverTokenWriter.ts +0 -143
  125. package/ai/token/stats.ts +0 -21
  126. package/ai/token/tokenThunks.ts +0 -24
  127. package/ai/token/types.ts +0 -93
  128. package/ai/tools/agent/agentTools.ts +0 -176
  129. package/ai/tools/agent/agentUpdateShared.ts +0 -311
  130. package/ai/tools/agent/callAgentTool.ts +0 -139
  131. package/ai/tools/agent/createAgentTool.ts +0 -512
  132. package/ai/tools/agent/createDialogTool.ts +0 -69
  133. package/ai/tools/agent/createSkillAgentTool.ts +0 -62
  134. package/ai/tools/agent/parallelBudget.ts +0 -221
  135. package/ai/tools/agent/presets/appBuilderPreset.ts +0 -145
  136. package/ai/tools/agent/runLlmTool.ts +0 -96
  137. package/ai/tools/agent/runStreamingAgentTool.ts +0 -73
  138. package/ai/tools/agent/skillAgentArgs.ts +0 -106
  139. package/ai/tools/agent/skillAgentPreset.ts +0 -89
  140. package/ai/tools/agent/streamParallelAgentsTool.ts +0 -122
  141. package/ai/tools/agent/updateAgentTool.ts +0 -96
  142. package/ai/tools/agent/updateSelfTool.ts +0 -113
  143. package/ai/tools/amazonProductScraperTool.ts +0 -86
  144. package/ai/tools/apifyActorClient.ts +0 -45
  145. package/ai/tools/appEditGuard.ts +0 -372
  146. package/ai/tools/appReadSnapshot.ts +0 -153
  147. package/ai/tools/appTools.ts +0 -1549
  148. package/ai/tools/applyEditTool.ts +0 -256
  149. package/ai/tools/applyLineEditsTool.ts +0 -312
  150. package/ai/tools/browserTools/click.ts +0 -33
  151. package/ai/tools/browserTools/closeSession.ts +0 -29
  152. package/ai/tools/browserTools/common.ts +0 -27
  153. package/ai/tools/browserTools/openSession.ts +0 -48
  154. package/ai/tools/browserTools/readContent.ts +0 -38
  155. package/ai/tools/browserTools/selectOption.ts +0 -46
  156. package/ai/tools/browserTools/typeText.ts +0 -42
  157. package/ai/tools/category/createCategoryTool.ts +0 -66
  158. package/ai/tools/category/queryContentsByCategoryTool.ts +0 -69
  159. package/ai/tools/category/updateContentCategoryTool.ts +0 -75
  160. package/ai/tools/cfBrowserTools.ts +0 -319
  161. package/ai/tools/cfSpeechToTextTool.ts +0 -49
  162. package/ai/tools/checkEnvTool.ts +0 -65
  163. package/ai/tools/cloudflareCrawlTool.ts +0 -289
  164. package/ai/tools/codeSearchTool.ts +0 -111
  165. package/ai/tools/codeTools.ts +0 -101
  166. package/ai/tools/createDocTool.ts +0 -132
  167. package/ai/tools/createPlanTool.ts +0 -999
  168. package/ai/tools/createSkillDocTool.ts +0 -155
  169. package/ai/tools/createWorkflowTool.ts +0 -154
  170. package/ai/tools/deepseekOcrTool.ts +0 -34
  171. package/ai/tools/delayTool.ts +0 -31
  172. package/ai/tools/deleteSpacesTool.ts +0 -325
  173. package/ai/tools/deleteSpacesToolModel.ts +0 -159
  174. package/ai/tools/devReloadUtils.ts +0 -29
  175. package/ai/tools/dialogMessageSearch.ts +0 -137
  176. package/ai/tools/doctorSkillTool.ts +0 -72
  177. package/ai/tools/ecommerceScraperTool.ts +0 -86
  178. package/ai/tools/emailTools.ts +0 -549
  179. package/ai/tools/evalSkillTool.ts +0 -92
  180. package/ai/tools/exaSearchTool.ts +0 -64
  181. package/ai/tools/execBashTool.ts +0 -379
  182. package/ai/tools/executeSqlTool.ts +0 -192
  183. package/ai/tools/fetchWebpageSupport.ts +0 -309
  184. package/ai/tools/fetchWebpageTool.ts +0 -84
  185. package/ai/tools/geminiImagePreviewTool.ts +0 -361
  186. package/ai/tools/generateDocxTool.ts +0 -215
  187. package/ai/tools/googleSearchScraperTool.ts +0 -106
  188. package/ai/tools/importDataTool.ts +0 -133
  189. package/ai/tools/importSkillTool.ts +0 -162
  190. package/ai/tools/index.ts +0 -1858
  191. package/ai/tools/listFilesTool.ts +0 -82
  192. package/ai/tools/listUserSpacesTool.ts +0 -113
  193. package/ai/tools/modelUsageTools.ts +0 -142
  194. package/ai/tools/olmOcrTool.ts +0 -34
  195. package/ai/tools/openaiImageTool.ts +0 -218
  196. package/ai/tools/paddleOcrTool.ts +0 -34
  197. package/ai/tools/prepareTools.ts +0 -23
  198. package/ai/tools/readDocTool.ts +0 -84
  199. package/ai/tools/readFileTool.ts +0 -211
  200. package/ai/tools/readTool.ts +0 -163
  201. package/ai/tools/readXPostTool.ts +0 -233
  202. package/ai/tools/rememberMemoryTool.ts +0 -84
  203. package/ai/tools/remotionVideoTool.ts +0 -151
  204. package/ai/tools/searchDialogMessagesTool.ts +0 -222
  205. package/ai/tools/searchRepoTool.ts +0 -115
  206. package/ai/tools/searchWorkspaceTool.ts +0 -259
  207. package/ai/tools/skillFollowup.ts +0 -86
  208. package/ai/tools/surfWeatherTool.ts +0 -169
  209. package/ai/tools/table/addTableRowTool.ts +0 -217
  210. package/ai/tools/table/createTableTool.ts +0 -315
  211. package/ai/tools/table/rowTools.ts +0 -366
  212. package/ai/tools/table/schemaTools.ts +0 -244
  213. package/ai/tools/table/shareTableTool.ts +0 -148
  214. package/ai/tools/table/toolShared.ts +0 -129
  215. package/ai/tools/toolApiClient.ts +0 -198
  216. package/ai/tools/toolNameAliases.ts +0 -57
  217. package/ai/tools/toolResultError.ts +0 -42
  218. package/ai/tools/toolRunSlice.ts +0 -303
  219. package/ai/tools/toolSchemaCompatibility.ts +0 -53
  220. package/ai/tools/toolVisibility.ts +0 -4
  221. package/ai/tools/types.ts +0 -20
  222. package/ai/tools/uiAskChoiceTool.ts +0 -104
  223. package/ai/tools/updateContentTitleTool.ts +0 -84
  224. package/ai/tools/updateDocTool.ts +0 -105
  225. package/ai/tools/updateUserPreferenceProfileTool.ts +0 -145
  226. package/ai/tools/whisperTool.ts +0 -77
  227. package/ai/tools/writeFileTool.ts +0 -210
  228. package/ai/tools/youtubeScraperTool.ts +0 -116
  229. package/ai/tools/ziweiChartTool.ts +0 -678
  230. package/ai/types.ts +0 -55
  231. package/ai/workflow/workflowExecutor.ts +0 -323
  232. package/ai/workflow/workflowSlice.ts +0 -73
  233. package/ai/workflow/workflowTypes.ts +0 -106
  234. package/client/compactDialog.ts +0 -222
  235. package/connector-experimental/capabilities.ts +0 -73
  236. package/connector-experimental/codexBinary.ts +0 -41
  237. package/connector-experimental/heartbeatLoop.ts +0 -22
  238. package/connector-experimental/index.ts +0 -5
  239. package/connector-experimental/machineInfo.ts +0 -46
  240. package/connector-experimental/protocol.ts +0 -54
@@ -1,82 +0,0 @@
1
- // 文件路径: packages/ai/tools/listFilesTool.ts
2
-
3
- import { getToolBaseUrl } from "./toolApiClient";
4
-
5
- // ---- Types ----
6
-
7
- export type ListFilesArgs = {
8
- path?: string;
9
- maxFiles?: number;
10
- ignore?: string[];
11
- };
12
-
13
- // ---- 工具 Schema ----
14
-
15
- export const listFilesFunctionSchema = {
16
- name: "list_files",
17
- description: [
18
- "列出项目中的文件和目录结构。",
19
- "当你初次进入项目,或需要了解特定目录下的文件列表以便进行下一步搜索或读取时,请使用此工具。",
20
- "它会自动忽略常见的非源码目录(如 node_modules),并支持深度递归(受 maxFiles 限制)。",
21
- ].join("\n"),
22
- parameters: {
23
- type: "object",
24
- properties: {
25
- path: {
26
- type: "string",
27
- description: "可选:要列出的目录路径,默认 '.'(项目根目录)。",
28
- },
29
- maxFiles: {
30
- type: "number",
31
- description: "可选:返回文件的最大数量,默认 300。",
32
- },
33
- ignore: {
34
- type: "array",
35
- items: { type: "string" },
36
- description: "可选:要额外忽略的模式或目录名。",
37
- },
38
- },
39
- },
40
- };
41
-
42
- // ---- 执行函数 ----
43
-
44
- export async function listFilesFunc(
45
- args: ListFilesArgs,
46
- thunkApi: any,
47
- context?: { signal?: AbortSignal }
48
- ): Promise<{ rawData: any; displayData?: string }> {
49
- try {
50
- const baseUrl = getToolBaseUrl(thunkApi);
51
- const apiUrl = `${baseUrl}/api/list-files`;
52
-
53
- const response = await fetch(apiUrl, {
54
- method: "POST",
55
- headers: { "Content-Type": "application/json" },
56
- signal: context?.signal,
57
- body: JSON.stringify(args),
58
- });
59
-
60
- const data = (await response.json()) as { ok?: boolean; error?: string; files?: any[]; totalFiles?: number; truncated?: boolean };
61
-
62
- if (!response.ok || data?.error) {
63
- throw new Error(data?.error || `列出文件失败: ${response.status}`);
64
- }
65
-
66
- const files = data.files || [];
67
- const count = files.length;
68
- const displayData = `📁 文件列表: 找到 ${data.totalFiles} 个文件${data.truncated ? ' (已截断)' : ''}`;
69
-
70
- return {
71
- rawData: {
72
- ok: true,
73
- files,
74
- totalFiles: data.totalFiles,
75
- truncated: data.truncated
76
- },
77
- displayData,
78
- };
79
- } catch (error: any) {
80
- throw new Error(`列出文件失败:${error?.message || String(error)}`);
81
- }
82
- }
@@ -1,113 +0,0 @@
1
- // 文件路径: ai/tools/listUserSpacesTool.ts
2
-
3
- /**
4
- * listUserSpaces 工具
5
- *
6
- * 用于 AI 获取当前用户可访问的所有 Space 列表(概览)。
7
- * 只返回 Space 名称和 ID,不返回详细内容,避免 Token 爆炸。
8
- *
9
- * 使用场景:
10
- * - 用户询问"我有哪些空间"
11
- * - AI 需要确定要查询哪个 Space
12
- * - 跨 Space 导航
13
- */
14
-
15
- import type { RootState } from "app/store";
16
- import { selectAllMemberSpaces } from "create/space/spaceSlice";
17
-
18
- // ---- Types ----
19
-
20
- export type ListUserSpacesArgs = {
21
- /**
22
- * 是否只返回用户拥有的 Space(角色为 owner)
23
- */
24
- ownedOnly?: boolean;
25
- };
26
-
27
- // ---- 工具 Schema,供 LLM 调用 ----
28
-
29
- export const listUserSpacesFunctionSchema = {
30
- name: "listUserSpaces",
31
- description: [
32
- "获取当前用户可访问的所有 Space(工作空间)列表。",
33
- "",
34
- "返回内容:",
35
- "- 每个 Space 的 ID 和名称",
36
- "- 用户在该 Space 的角色(owner/member)",
37
- "",
38
- "使用场景:",
39
- "- 用户询问'我有哪些空间'",
40
- "- 需要确定要查询哪个 Space",
41
- "- 跨 Space 导航",
42
- "",
43
- "注意:只返回概览信息,如需查看 Space 详细内容,使用 listSpaceContent 工具。",
44
- ].join("\n"),
45
- parameters: {
46
- type: "object",
47
- properties: {
48
- ownedOnly: {
49
- type: "boolean",
50
- description: "是否只返回用户拥有的 Space。默认 false(返回所有可访问的 Space)。",
51
- default: false,
52
- },
53
- },
54
- required: [],
55
- },
56
- };
57
-
58
- // ---- 执行函数 ----
59
-
60
- export async function listUserSpacesFunc(
61
- args: ListUserSpacesArgs,
62
- thunkApi: any,
63
- context?: { parentMessageId?: string; signal?: AbortSignal }
64
- ): Promise<{ rawData: any; displayData?: string }> {
65
- const { ownedOnly = false } = args || {};
66
-
67
- try {
68
- const { getState } = thunkApi;
69
- const state: RootState = getState();
70
-
71
- let memberSpaces = selectAllMemberSpaces(state);
72
-
73
- if (ownedOnly) {
74
- memberSpaces = memberSpaces.filter((ms) => ms.role === "owner");
75
- }
76
-
77
- if (memberSpaces.length === 0) {
78
- return {
79
- rawData: { spaces: [] },
80
- displayData: ownedOnly
81
- ? "当前用户没有拥有任何 Space。"
82
- : "当前用户没有可访问的 Space。",
83
- };
84
- }
85
-
86
- // 格式化输出
87
- let resultText = `=== 用户可访问的 Space 列表 (${memberSpaces.length}) ===\n\n`;
88
-
89
- const spacesData = memberSpaces.map((ms, index) => {
90
- const roleLabel = ms.role === "owner" ? "👑 Owner" : "👤 Member";
91
- resultText += `${index + 1}. ${ms.spaceName || ms.spaceId}\n`;
92
- resultText += ` ID: ${ms.spaceId} | Role: ${roleLabel}\n`;
93
-
94
- return {
95
- spaceId: ms.spaceId,
96
- name: ms.spaceName || ms.spaceId,
97
- role: ms.role,
98
- };
99
- });
100
-
101
- resultText += `\n提示:使用 listSpaceContent(spaceId) 可查看指定 Space 的详细内容。`;
102
-
103
- return {
104
- rawData: { spaces: spacesData },
105
- displayData: resultText,
106
- };
107
- } catch (error: any) {
108
- console.error("执行 listUserSpaces 工具时发生错误:", error);
109
- throw new Error(
110
- `获取用户 Space 列表失败:${error?.message || String(error)}`
111
- );
112
- }
113
- }
@@ -1,142 +0,0 @@
1
- export const queryModelUsageFunctionSchema = {
2
- name: "queryModelUsage",
3
- description:
4
- "查询模型/API 用量与费用。普通用户只能查自己的用量;系统管理员可以查指定用户或全站。费用默认返回 credits,也可附带 USD 换算。",
5
- parameters: {
6
- type: "object",
7
- properties: {
8
- scope: {
9
- type: "string",
10
- enum: ["user", "all", "space"],
11
- description:
12
- "查询范围。user 为个人,all 为全站管理员查询,space 预留给空间范围。",
13
- default: "user",
14
- },
15
- userId: {
16
- type: "string",
17
- description: "管理员查询指定用户时使用;普通用户不允许指定他人。",
18
- },
19
- spaceId: {
20
- type: "string",
21
- description: "空间范围查询预留字段,当前版本会返回未实现。",
22
- },
23
- provider: {
24
- type: "string",
25
- description: "可选 provider 过滤,例如 google、openai、anthropic。",
26
- },
27
- model: {
28
- type: "string",
29
- description: "可选模型过滤,例如 gemini-2.5-flash。",
30
- },
31
- serviceTier: {
32
- type: "string",
33
- description: "可选计费档位过滤,例如 standard、flex。",
34
- },
35
- startDate: {
36
- type: "string",
37
- description: "开始日期,YYYY-MM-DD。默认今天。",
38
- },
39
- endDate: {
40
- type: "string",
41
- description: "结束日期,YYYY-MM-DD。默认等于 startDate。",
42
- },
43
- currency: {
44
- type: "string",
45
- description: "展示货币/单位标签。默认 CREDITS;可填 USD、CNY 等。",
46
- default: "CREDITS",
47
- },
48
- creditsPerUsd: {
49
- type: "number",
50
- description: "credits 与 USD 的换算比例,默认 8 credits = 1 USD。",
51
- default: 8,
52
- },
53
- thresholdCredits: {
54
- type: "number",
55
- description: "可选阈值,单位 credits;返回 threshold.exceeded。",
56
- },
57
- thresholdUsd: {
58
- type: "number",
59
- description: "可选阈值,单位 USD;会按 creditsPerUsd 换算。",
60
- },
61
- },
62
- },
63
- };
64
-
65
- export const createScheduledTaskFunctionSchema = {
66
- name: "createScheduledTask",
67
- description:
68
- "创建一个每日/周期性后台任务。适合让 agent 按 cron 定时检查用量、生成报告或执行提醒;可选择创建后立刻试运行一次。",
69
- parameters: {
70
- type: "object",
71
- properties: {
72
- title: {
73
- type: "string",
74
- description: "任务标题。",
75
- },
76
- taskPrompt: {
77
- type: "string",
78
- description:
79
- "定时任务每次执行时交给 agent 的完整任务描述,应包含检查条件和通知方式。",
80
- },
81
- schedule: {
82
- type: "string",
83
- description: "cron 表达式,例如每天 09:00 执行为 0 9 * * *。",
84
- },
85
- agentKey: {
86
- type: "string",
87
- description: "执行该任务的 agentKey。默认使用当前 agent。",
88
- },
89
- spaceId: {
90
- type: "string",
91
- description: "可选空间 ID;任务对话会归属到该空间。",
92
- },
93
- runOnceNow: {
94
- type: "boolean",
95
- description: "创建后是否立即执行一次,用来验证任务会产生什么结果。",
96
- default: false,
97
- },
98
- },
99
- required: ["schedule", "taskPrompt"],
100
- },
101
- };
102
-
103
- export const notifyUserFunctionSchema = {
104
- name: "notifyUser",
105
- description:
106
- "发送一条站内通知给当前用户。第一版只支持站内通知,后续可扩展邮件、桌面端、网页和移动端通知。",
107
- parameters: {
108
- type: "object",
109
- properties: {
110
- title: {
111
- type: "string",
112
- description: "通知标题。",
113
- },
114
- message: {
115
- type: "string",
116
- description: "通知正文。",
117
- },
118
- severity: {
119
- type: "string",
120
- enum: ["info", "warning", "critical"],
121
- description: "通知级别。",
122
- default: "info",
123
- },
124
- href: {
125
- type: "string",
126
- description: "可选跳转链接。",
127
- },
128
- },
129
- required: ["title", "message"],
130
- },
131
- };
132
-
133
- const serverOnlyResult = (toolName: string) => ({
134
- rawData: {
135
- error: `${toolName} must run on the server-side agent runtime.`,
136
- },
137
- displayData: `${toolName} 需要在服务端 agent runtime 中执行。`,
138
- });
139
-
140
- export const queryModelUsageFunc = async () => serverOnlyResult("queryModelUsage");
141
- export const createScheduledTaskFunc = async () => serverOnlyResult("createScheduledTask");
142
- export const notifyUserFunc = async () => serverOnlyResult("notifyUser");
@@ -1,34 +0,0 @@
1
- import { ToolDefinition } from ".";
2
- import { callToolApi } from "./toolApiClient";
3
-
4
- export const olmOcrSchema = {
5
- name: "olm_ocr",
6
- description: "使用 allenai/olmOCR-2-7B-1025 模型进行光学字符识别 (OCR)。适合文档、论文等结构化文本的高质量识别。",
7
- parameters: {
8
- type: "object",
9
- properties: {
10
- imageUrl: {
11
- type: "string",
12
- description: "要进行 OCR 的图片 URL、base64 编码的图片数据,或者内部文件 ID (如 'file-...')。",
13
- },
14
- prompt: {
15
- type: "string",
16
- description: "可选的提示词,用于指导模型如何提取信息(例如:'提取所有表格数据' 或 '识别图片中的所有文字')。默认为 '识别图片中的所有文字'。",
17
- default: "识别图片中的所有文字"
18
- }
19
- },
20
- required: ["imageUrl"],
21
- },
22
- };
23
-
24
- export const olmOcrFunc: ToolDefinition["executor"] = async (input: any, thunkApi) => {
25
- const { imageUrl, prompt = "识别图片中的所有文字" } = input;
26
-
27
- const data = await callToolApi(thunkApi, "/api/olm-ocr", { imageUrl, prompt }, { withAuth: true });
28
-
29
- return {
30
- summary: "OCR processing completed",
31
- text: data.choices?.[0]?.message?.content || "No text detected",
32
- rawData: data
33
- };
34
- };
@@ -1,218 +0,0 @@
1
- import { callToolApi } from "./toolApiClient";
2
- import { selectCurrentSpaceId } from "create/space/spaceSlice";
3
- import { selectUserId } from "auth/authSlice";
4
- import { selectCurrentServer } from "app/settings/settingSlice";
5
- import { selectCurrentDialogKey } from "chat/dialog/dialogSlice";
6
- import { addContentAction } from "create/space/content/addContentAction";
7
- import { ContentType } from "app/types";
8
- import { fileKey } from "database/keys";
9
- import { buildDatabaseFileContentUrl } from "database/fileUrl";
10
- import { extractCustomId } from "core/prefix";
11
-
12
- const DEFAULT_OPENAI_IMAGE_MODEL = "gpt-image-1.5" as const;
13
-
14
- type OpenAIImageInput = {
15
- data: string;
16
- mimeType?: string;
17
- };
18
-
19
- type OpenAIImageArgs = {
20
- prompt: string;
21
- images?: OpenAIImageInput[];
22
- size?: "1024x1024" | "1024x1536" | "1536x1024" | "auto";
23
- quality?: "low" | "medium" | "high" | "auto";
24
- background?: "transparent" | "opaque" | "auto";
25
- outputFormat?: "png" | "jpeg" | "webp";
26
- outputCompression?: number;
27
- moderation?: "low" | "auto";
28
- n?: number;
29
- };
30
-
31
- const buildOpenAIImageLlmContext = ({
32
- result,
33
- userId,
34
- currentServer,
35
- }: {
36
- result: any;
37
- userId?: string | null;
38
- currentServer?: string | null;
39
- }): string | undefined => {
40
- const files = Array.isArray(result?.files) ? result.files : [];
41
- if (files.length === 0) return undefined;
42
-
43
- const lines = [
44
- "The image generation tool produced the following reusable images.",
45
- "If you mention, embed, or tabulate these images later, reuse these exact references and never invent placeholder URLs.",
46
- ];
47
-
48
- for (let index = 0; index < files.length; index += 1) {
49
- const file = files[index];
50
- const bareFileId =
51
- typeof file?.fileId === "string" && file.fileId.trim()
52
- ? file.fileId.trim()
53
- : "";
54
- const fileDbKey =
55
- userId && bareFileId ? fileKey.single(userId, bareFileId) : "";
56
- const fileUrl = buildDatabaseFileContentUrl(
57
- currentServer,
58
- fileDbKey || bareFileId
59
- );
60
- const originalName =
61
- typeof file?.metadata?.originalName === "string"
62
- ? file.metadata.originalName.trim()
63
- : "";
64
-
65
- lines.push(`image ${index + 1}:`);
66
- if (bareFileId) lines.push(`- fileId: ${bareFileId}`);
67
- if (fileDbKey) lines.push(`- fileDbKey: ${fileDbKey}`);
68
- if (fileUrl) lines.push(`- url: ${fileUrl}`);
69
- if (originalName) lines.push(`- name: ${originalName}`);
70
- }
71
-
72
- return lines.join("\n");
73
- };
74
-
75
- export const openAIGptImageFunctionSchema = {
76
- name: "openAIGptImage",
77
- description: [
78
- "使用 OpenAI GPT Image 1.5 生成或编辑图片。",
79
- "",
80
- "使用建议(面向模型):",
81
- "1. 当用户要为当前项目生成插画、封面、配图、海报、Logo 草图、背景素材时,优先使用本工具。",
82
- "2. 如果用户提供了现有图片并要求改图、延展、换背景、加元素,也使用本工具,并在 images 中显式传入相关图片。",
83
- "3. 这是单轮图片生成/编辑工具;如果只是分析图片内容,不要调用它。",
84
- "",
85
- "关于 images:",
86
- "- 不传 images:文生图。",
87
- "- 传 images:走图片编辑接口。",
88
- "- images[*].data 支持 Base64、data URL、或 http(s) URL。",
89
- ].join("\n"),
90
- parameters: {
91
- type: "object",
92
- properties: {
93
- prompt: {
94
- type: "string",
95
- description: "生成或编辑图片的提示词。",
96
- },
97
- images: {
98
- type: "array",
99
- description: "可选输入图片。传入后会按图片编辑模式处理。",
100
- items: {
101
- type: "object",
102
- properties: {
103
- data: {
104
- type: "string",
105
- description: "图片数据,可为 Base64、data URL、或 http(s) URL。",
106
- },
107
- mimeType: {
108
- type: "string",
109
- description: "可选 MIME 类型,例如 image/png 或 image/jpeg。",
110
- },
111
- },
112
- required: ["data"],
113
- },
114
- },
115
- size: {
116
- type: "string",
117
- description:
118
- '输出尺寸,可选 "1024x1024"、"1024x1536"、"1536x1024"、"auto"。',
119
- },
120
- quality: {
121
- type: "string",
122
- description:
123
- '输出质量,可选 "low"、"medium"、"high"、"auto"。',
124
- },
125
- background: {
126
- type: "string",
127
- description:
128
- '背景,可选 "transparent"、"opaque"、"auto"。',
129
- },
130
- outputFormat: {
131
- type: "string",
132
- description: '输出格式,可选 "png"、"jpeg"、"webp"。',
133
- },
134
- outputCompression: {
135
- type: "number",
136
- description: "JPEG/WebP 输出压缩率,0-100。",
137
- },
138
- moderation: {
139
- type: "string",
140
- description: '内容过滤级别,可选 "low" 或 "auto"。',
141
- },
142
- n: {
143
- type: "number",
144
- description: "一次生成的图片数量。",
145
- },
146
- },
147
- required: ["prompt"],
148
- },
149
- };
150
-
151
- export const openAIGptImageFunc = async (
152
- args: OpenAIImageArgs,
153
- thunkApi: any
154
- ): Promise<{ rawData: any; displayData: string; llmContext?: string }> => {
155
- const trimmedPrompt = args.prompt?.trim();
156
- if (!trimmedPrompt) {
157
- throw new Error("prompt 不能为空");
158
- }
159
-
160
- const state = thunkApi.getState();
161
- const currentDialogKey = selectCurrentDialogKey(state);
162
- const dialogId = currentDialogKey
163
- ? extractCustomId(currentDialogKey)
164
- : undefined;
165
-
166
- const result = await callToolApi(
167
- thunkApi,
168
- "/api/openai-image",
169
- {
170
- prompt: trimmedPrompt,
171
- images: Array.isArray(args.images) ? args.images : [],
172
- size: args.size,
173
- quality: args.quality,
174
- background: args.background,
175
- outputFormat: args.outputFormat,
176
- outputCompression: args.outputCompression,
177
- moderation: args.moderation,
178
- n: args.n,
179
- model: DEFAULT_OPENAI_IMAGE_MODEL,
180
- dialogId,
181
- },
182
- { withAuth: true }
183
- );
184
-
185
- const spaceId = selectCurrentSpaceId(state);
186
- const userId = selectUserId(state);
187
- const currentServer = selectCurrentServer(state);
188
-
189
- if (spaceId && userId && result?.files?.length) {
190
- for (let i = 0; i < result.files.length; i += 1) {
191
- const file = result.files[i];
192
- if (!file?.fileId) continue;
193
- const contentKey = fileKey.single(userId, file.fileId);
194
- const title = file.metadata?.originalName || `OpenAI Image ${i + 1}`;
195
- try {
196
- await addContentAction(
197
- { spaceId, contentKey, title, type: ContentType.IMAGE },
198
- { dispatch: thunkApi.dispatch, getState: thunkApi.getState }
199
- );
200
- } catch (error) {
201
- console.warn("[openAIGptImageFunc] Failed to add image to space:", error);
202
- }
203
- }
204
- }
205
-
206
- const llmContext = buildOpenAIImageLlmContext({
207
- result,
208
- userId,
209
- currentServer,
210
- });
211
-
212
- return {
213
- rawData: result,
214
- displayData:
215
- result?.text || "已使用 OpenAI GPT Image 生成新的图片资源。",
216
- llmContext,
217
- };
218
- };
@@ -1,34 +0,0 @@
1
- import { ToolDefinition } from ".";
2
- import { callToolApi } from "./toolApiClient";
3
-
4
- export const paddleOcrSchema = {
5
- name: "paddle_ocr",
6
- description: "使用 PaddleOCR-VL-0.9B 模型进行光学字符识别 (OCR)。支持识别图片中的文本、表格、公式和图表。",
7
- parameters: {
8
- type: "object",
9
- properties: {
10
- imageUrl: {
11
- type: "string",
12
- description: "要进行 OCR 的图片 URL、base64 编码的图片数据,或者内部文件 ID (如 'file-...')。使用文件 ID 可以避免在工具调用中包含较大的图片数据,从而节省 token。",
13
- },
14
- prompt: {
15
- type: "string",
16
- description: "可选的提示词,用于指导模型如何提取信息(例如:'提取所有表格数据' 或 '识别图片中的所有文字')。默认为 '识别图片中的所有文字'。",
17
- default: "识别图片中的所有文字"
18
- }
19
- },
20
- required: ["imageUrl"],
21
- },
22
- };
23
-
24
- export const paddleOcrFunc: ToolDefinition["executor"] = async (input: any, thunkApi) => {
25
- const { imageUrl, prompt = "识别图片中的所有文字" } = input;
26
-
27
- const data = await callToolApi(thunkApi, "/api/paddle-ocr", { imageUrl, prompt }, { withAuth: true });
28
-
29
- return {
30
- summary: "OCR processing completed",
31
- text: data.choices?.[0]?.message?.content || "No text detected",
32
- rawData: data
33
- };
34
- };
@@ -1,23 +0,0 @@
1
- import {
2
- toolRegistry,
3
- toolDefinitionsByName,
4
- findToolExecutor,
5
- ToolBehavior,
6
- } from ".";
7
- import { canonicalizeToolNames } from "./toolNameAliases";
8
- import { sanitizeToolForProvider } from "./toolSchemaCompatibility";
9
-
10
- export const prepareTools = (
11
- toolNames: string[],
12
- options?: { provider?: string; disabledToolNames?: string[] }
13
- ) => {
14
- // logic moved to mergeAgentToolsWithRuntime for better tiered capabilities
15
- const disabledToolNames = new Set(
16
- canonicalizeToolNames(options?.disabledToolNames ?? [])
17
- );
18
- return canonicalizeToolNames(toolNames)
19
- .filter((toolName) => !disabledToolNames.has(toolName))
20
- .map((toolName: string) => toolRegistry[toolName])
21
- .map((tool) => sanitizeToolForProvider(tool, options?.provider))
22
- .filter(Boolean); // 过滤掉未找到的工具
23
- };