@ai-setting/roy-agent-core 1.7.51 → 1.7.53

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 (337) hide show
  1. package/dist/config/config-component.d.ts +346 -0
  2. package/dist/config/config-parser.d.ts +45 -0
  3. package/dist/config/env-key.d.ts +97 -0
  4. package/dist/config/env-source.d.ts +113 -0
  5. package/dist/config/file-source.d.ts +90 -0
  6. package/dist/config/index.d.ts +4 -0
  7. package/dist/config/protocol-resolver.d.ts +94 -0
  8. package/dist/env/agent/agent-component.d.ts +646 -0
  9. package/dist/env/agent/agent-config-registration.d.ts +18 -0
  10. package/dist/env/agent/agent-registry.d.ts +500 -0
  11. package/dist/env/agent/index.d.ts +9 -0
  12. package/dist/env/agent/summary-agent.d.ts +44 -0
  13. package/dist/env/agent/types.d.ts +503 -0
  14. package/dist/env/commands/commands-component.d.ts +97 -0
  15. package/dist/env/commands/commands-config-registration.d.ts +19 -0
  16. package/dist/env/commands/index.d.ts +7 -0
  17. package/dist/env/commands/parser.d.ts +18 -0
  18. package/dist/env/commands/types.d.ts +133 -0
  19. package/dist/env/component.d.ts +186 -0
  20. package/dist/env/constants.d.ts +112 -0
  21. package/dist/env/context/env-context.d.ts +420 -0
  22. package/dist/env/context/env-event.d.ts +144 -0
  23. package/dist/env/context/index.d.ts +13 -0
  24. package/dist/env/debug/debug-component.d.ts +160 -0
  25. package/dist/env/debug/formatters/index.d.ts +8 -0
  26. package/dist/env/debug/formatters/repl-formatter.d.ts +80 -0
  27. package/dist/env/debug/formatters/trace-formatter.d.ts +43 -0
  28. package/dist/env/debug/formatters/tree-formatter.d.ts +72 -0
  29. package/dist/env/debug/index.d.ts +15 -0
  30. package/dist/env/debug/index.js +1 -1
  31. package/dist/env/debug/parser/regex-parser.d.ts +49 -0
  32. package/dist/env/debug/parser/span-builder.d.ts +79 -0
  33. package/dist/env/debug/reader/log-reader.d.ts +55 -0
  34. package/dist/env/debug/reader/span-db-reader.d.ts +70 -0
  35. package/dist/env/debug/types.d.ts +145 -0
  36. package/dist/env/environment.d.ts +185 -0
  37. package/dist/env/errors.d.ts +120 -0
  38. package/dist/env/event-source/bounty-cli-handler.d.ts +42 -0
  39. package/dist/env/event-source/bounty-im-handler.d.ts +232 -0
  40. package/dist/env/event-source/event-source-component.d.ts +177 -0
  41. package/dist/env/event-source/event-source-config-registration.d.ts +18 -0
  42. package/dist/env/event-source/event-source-handlers.d.ts +486 -0
  43. package/dist/env/event-source/event-store.d.ts +110 -0
  44. package/dist/env/event-source/idempotency-key.d.ts +19 -0
  45. package/dist/env/event-source/index.d.ts +15 -0
  46. package/dist/env/event-source/index.js +4 -4
  47. package/dist/env/event-source/timer-handler.d.ts +74 -0
  48. package/dist/env/event-source/types.d.ts +803 -0
  49. package/dist/env/hook/global-hook-manager.d.ts +73 -0
  50. package/dist/env/hook/hook-manager.d.ts +139 -0
  51. package/dist/env/hook/index.d.ts +9 -0
  52. package/dist/env/hook/types.d.ts +107 -0
  53. package/dist/env/index.d.ts +24 -0
  54. package/dist/env/index.js +6 -6
  55. package/dist/env/interface.d.ts +156 -0
  56. package/dist/env/lark-mention-utils.d.ts +59 -0
  57. package/dist/env/llm/adapter-ai-sdk.d.ts +10 -0
  58. package/dist/env/llm/adapter-pi-ai.d.ts +39 -0
  59. package/dist/env/llm/adapter.d.ts +80 -0
  60. package/dist/env/llm/factory.d.ts +13 -0
  61. package/dist/env/llm/hooks.d.ts +150 -0
  62. package/dist/env/llm/index.d.ts +16 -0
  63. package/dist/env/llm/invoke.d.ts +264 -0
  64. package/dist/env/llm/llm-cache.d.ts +38 -0
  65. package/dist/env/llm/llm.d.ts +238 -0
  66. package/dist/env/llm/opencode-session.d.ts +79 -0
  67. package/dist/env/llm/provider.d.ts +40 -0
  68. package/dist/env/llm/tool-args-parser.d.ts +77 -0
  69. package/dist/env/llm/tool-schema.d.ts +54 -0
  70. package/dist/env/llm/transform.d.ts +57 -0
  71. package/dist/env/llm/types.d.ts +818 -0
  72. package/dist/env/log-trace/decorator.d.ts +88 -0
  73. package/dist/env/log-trace/index.d.ts +14 -0
  74. package/dist/env/log-trace/log-trace-component.d.ts +268 -0
  75. package/dist/env/log-trace/log-trace-config-registration.d.ts +25 -0
  76. package/dist/env/log-trace/logger.d.ts +83 -0
  77. package/dist/env/log-trace/opentelemetry/cli-propagation.d.ts +105 -0
  78. package/dist/env/log-trace/opentelemetry/mod.d.ts +24 -0
  79. package/dist/env/log-trace/opentelemetry/propagation-env.d.ts +81 -0
  80. package/dist/env/log-trace/opentelemetry/propagation.d.ts +79 -0
  81. package/dist/env/log-trace/opentelemetry/tracer-provider.d.ts +157 -0
  82. package/dist/env/log-trace/span-storage.d.ts +37 -0
  83. package/dist/env/log-trace/trace-context.d.ts +28 -0
  84. package/dist/env/log-trace/types.d.ts +127 -0
  85. package/dist/env/mcp/command-resolver.d.ts +12 -0
  86. package/dist/env/mcp/config.d.ts +103 -0
  87. package/dist/env/mcp/index.d.ts +13 -0
  88. package/dist/env/mcp/loader.d.ts +78 -0
  89. package/dist/env/mcp/mcp-component.d.ts +54 -0
  90. package/dist/env/mcp/mcp-config-registration.d.ts +19 -0
  91. package/dist/env/mcp/npm-prefix/index.d.ts +17 -0
  92. package/dist/env/mcp/scanner.d.ts +38 -0
  93. package/dist/env/mcp/tool/adapter.d.ts +32 -0
  94. package/dist/env/mcp/tool/index.d.ts +4 -0
  95. package/dist/env/mcp/types.d.ts +131 -0
  96. package/dist/env/memory/built-in/index.d.ts +41 -0
  97. package/dist/env/memory/built-in/recall-memory.d.ts +29 -0
  98. package/dist/env/memory/built-in/record-memory.d.ts +44 -0
  99. package/dist/env/memory/index.d.ts +10 -0
  100. package/dist/env/memory/memory-component.d.ts +114 -0
  101. package/dist/env/memory/memory-config-registration.d.ts +18 -0
  102. package/dist/env/memory/memory-config.d.ts +18 -0
  103. package/dist/env/memory/plugin/index.d.ts +16 -0
  104. package/dist/env/memory/plugin/memory-agent.d.ts +126 -0
  105. package/dist/env/memory/plugin/memory-manager.d.ts +71 -0
  106. package/dist/env/memory/plugin/memory-plugin.d.ts +103 -0
  107. package/dist/env/memory/plugin/recall-memory.d.ts +16 -0
  108. package/dist/env/memory/plugin/types.d.ts +75 -0
  109. package/dist/env/memory/tools/memory-agent-tools.d.ts +109 -0
  110. package/dist/env/memory/types.d.ts +80 -0
  111. package/dist/env/paths.d.ts +46 -0
  112. package/dist/env/plugin/bounty-cli-notification-channel.d.ts +60 -0
  113. package/dist/env/plugin/event-bus-notification-channel.d.ts +50 -0
  114. package/dist/env/plugin/index.d.ts +13 -0
  115. package/dist/env/plugin/lark-cli-notification-channel.d.ts +61 -0
  116. package/dist/env/plugin/notification-channel.d.ts +143 -0
  117. package/dist/env/plugin/plugin-component.d.ts +232 -0
  118. package/dist/env/plugin/types.d.ts +146 -0
  119. package/dist/env/prompt/index.d.ts +7 -0
  120. package/dist/env/prompt/prompt-component.d.ts +194 -0
  121. package/dist/env/prompt/prompt-config-registration.d.ts +18 -0
  122. package/dist/env/prompt/prompt-store.d.ts +26 -0
  123. package/dist/env/prompt/prompts-index.d.ts +146 -0
  124. package/dist/env/prompt/renderer.d.ts +21 -0
  125. package/dist/env/prompt/types.d.ts +176 -0
  126. package/dist/env/session/hooks.d.ts +14 -0
  127. package/dist/env/session/index.d.ts +19 -0
  128. package/dist/env/session/search-query-parser.d.ts +41 -0
  129. package/dist/env/session/session-component.d.ts +464 -0
  130. package/dist/env/session/session-config-registration.d.ts +18 -0
  131. package/dist/env/session/session-id.d.ts +26 -0
  132. package/dist/env/session/session-message-converter.d.ts +142 -0
  133. package/dist/env/session/session-store.d.ts +188 -0
  134. package/dist/env/session/storage/index.d.ts +5 -0
  135. package/dist/env/session/storage/memory.d.ts +119 -0
  136. package/dist/env/session/storage/sqlite.d.ts +108 -0
  137. package/dist/env/session/types.d.ts +705 -0
  138. package/dist/env/session-tree-stopper.d.ts +79 -0
  139. package/dist/env/skill/config.d.ts +13 -0
  140. package/dist/env/skill/index.d.ts +6 -0
  141. package/dist/env/skill/parser.d.ts +9 -0
  142. package/dist/env/skill/scanner.d.ts +25 -0
  143. package/dist/env/skill/skill-component.d.ts +89 -0
  144. package/dist/env/skill/skill-config-registration.d.ts +18 -0
  145. package/dist/env/skill/tool/index.d.ts +1 -0
  146. package/dist/env/skill/tool/skill-tool.d.ts +15 -0
  147. package/dist/env/skill/types.d.ts +61 -0
  148. package/dist/env/task/backend/index.d.ts +24 -0
  149. package/dist/env/task/backend/index.js +704 -0
  150. package/dist/env/task/backend/roy-sidecar-task-port.d.ts +148 -0
  151. package/dist/env/task/backend/sqlite-task-port.d.ts +28 -0
  152. package/dist/env/task/backend/task-store-backend.d.ts +107 -0
  153. package/dist/env/task/backend/types.d.ts +293 -0
  154. package/dist/env/task/delegate/bg-task-id-storage.d.ts +9 -0
  155. package/dist/env/task/delegate/delegate-tool.d.ts +681 -0
  156. package/dist/env/task/delegate/index.d.ts +8 -0
  157. package/dist/env/task/delegate/process-registry.d.ts +58 -0
  158. package/dist/env/task/delegate/stop-tool.d.ts +12 -0
  159. package/dist/env/task/delegate/subagent-resolver.d.ts +25 -0
  160. package/dist/env/task/events/index.d.ts +7 -0
  161. package/dist/env/task/events/task-event-payloads.d.ts +101 -0
  162. package/dist/env/task/events/task-event-types.d.ts +23 -0
  163. package/dist/env/task/hooks/contexts.d.ts +191 -0
  164. package/dist/env/task/hooks/index.d.ts +7 -0
  165. package/dist/env/task/hooks/task-hook-points.d.ts +42 -0
  166. package/dist/env/task/index.d.ts +7 -0
  167. package/dist/env/task/plugins/auto-task-plugin.d.ts +38 -0
  168. package/dist/env/task/plugins/card-chat-routing.d.ts +135 -0
  169. package/dist/env/task/plugins/fake-user-message-helper.d.ts +90 -0
  170. package/dist/env/task/plugins/index.d.ts +8 -0
  171. package/dist/env/task/plugins/index.js +2 -2
  172. package/dist/env/task/plugins/lark-card-action-handler.d.ts +166 -0
  173. package/dist/env/task/plugins/lark-card-patch-notifier.d.ts +651 -0
  174. package/dist/env/task/plugins/lark-cli-task-notify-plugin.d.ts +248 -0
  175. package/dist/env/task/plugins/max-iteration-reminder-plugin.d.ts +112 -0
  176. package/dist/env/task/plugins/per-task-group-chat-plugin.d.ts +561 -0
  177. package/dist/env/task/plugins/task-tag-plugin.d.ts +70 -0
  178. package/dist/env/task/plugins/workflow-extractor-agent.d.ts +43 -0
  179. package/dist/env/task/registry-hook-installer.d.ts +43 -0
  180. package/dist/env/task/storage/index.d.ts +5 -0
  181. package/dist/env/task/storage/migrations/001_add_project_path_context.d.ts +14 -0
  182. package/dist/env/task/storage/migrations/002_add_task_type.d.ts +14 -0
  183. package/dist/env/task/storage/migrations/003_add_process_description.d.ts +20 -0
  184. package/dist/env/task/storage/migrations/004_rename_action_to_milestone.d.ts +37 -0
  185. package/dist/env/task/storage/migrations/005_convert_blob_description_to_text.d.ts +51 -0
  186. package/dist/env/task/storage/sqlite-task-store.d.ts +241 -0
  187. package/dist/env/task/tag-service.d.ts +138 -0
  188. package/dist/env/task/task-child-context.d.ts +70 -0
  189. package/dist/env/task/task-component.d.ts +270 -0
  190. package/dist/env/task/task-config-registration.d.ts +19 -0
  191. package/dist/env/task/task-creation-registry.d.ts +181 -0
  192. package/dist/env/task/task-reuse-context.d.ts +52 -0
  193. package/dist/env/task/task-reuse-registry.d.ts +31 -0
  194. package/dist/env/task/tools/batch-archive-tool.d.ts +9 -0
  195. package/dist/env/task/tools/batch-delete-tool.d.ts +9 -0
  196. package/dist/env/task/tools/complete-tool.d.ts +12 -0
  197. package/dist/env/task/tools/create-tool.d.ts +6 -0
  198. package/dist/env/task/tools/delete-tool.d.ts +6 -0
  199. package/dist/env/task/tools/get-tool.d.ts +6 -0
  200. package/dist/env/task/tools/index.d.ts +13 -0
  201. package/dist/env/task/tools/list-tool.d.ts +6 -0
  202. package/dist/env/task/tools/operation/create-tool.d.ts +12 -0
  203. package/dist/env/task/tools/operation/delete-tool.d.ts +6 -0
  204. package/dist/env/task/tools/operation/get-tool.d.ts +6 -0
  205. package/dist/env/task/tools/operation/index.d.ts +8 -0
  206. package/dist/env/task/tools/operation/list-tool.d.ts +6 -0
  207. package/dist/env/task/tools/operation/operation-types.d.ts +225 -0
  208. package/dist/env/task/tools/operation/update-tool.d.ts +6 -0
  209. package/dist/env/task/tools/search-tool.d.ts +9 -0
  210. package/dist/env/task/tools/task-tree-tool.d.ts +65 -0
  211. package/dist/env/task/tools/task-types.d.ts +255 -0
  212. package/dist/env/task/tools/update-tool.d.ts +6 -0
  213. package/dist/env/task/types.d.ts +290 -0
  214. package/dist/env/tool/built-in/bash-effect.d.ts +36 -0
  215. package/dist/env/tool/built-in/bash.d.ts +16 -0
  216. package/dist/env/tool/built-in/echo.d.ts +7 -0
  217. package/dist/env/tool/built-in/edit-file.d.ts +6 -0
  218. package/dist/env/tool/built-in/glob.d.ts +6 -0
  219. package/dist/env/tool/built-in/grep.d.ts +6 -0
  220. package/dist/env/tool/built-in/index.d.ts +39 -0
  221. package/dist/env/tool/built-in/query-background-process-tool.d.ts +113 -0
  222. package/dist/env/tool/built-in/read-file.d.ts +5 -0
  223. package/dist/env/tool/built-in/understand-image.d.ts +59 -0
  224. package/dist/env/tool/built-in/write-file.d.ts +5 -0
  225. package/dist/env/tool/index.d.ts +16 -0
  226. package/dist/env/tool/registry.d.ts +61 -0
  227. package/dist/env/tool/tool-component.d.ts +242 -0
  228. package/dist/env/tool/tool-config-registration.d.ts +18 -0
  229. package/dist/env/tool/types.d.ts +274 -0
  230. package/dist/env/tool/validator.d.ts +14 -0
  231. package/dist/env/types.d.ts +184 -0
  232. package/dist/env/workflow/decorators/decorator-node.d.ts +76 -0
  233. package/dist/env/workflow/decorators/edge.d.ts +42 -0
  234. package/dist/env/workflow/decorators/index.d.ts +13 -0
  235. package/dist/env/workflow/decorators/node-as.d.ts +40 -0
  236. package/dist/env/workflow/decorators/workflow.d.ts +30 -0
  237. package/dist/env/workflow/engine/dag-manager.d.ts +176 -0
  238. package/dist/env/workflow/engine/engine.d.ts +375 -0
  239. package/dist/env/workflow/engine/event-bus.d.ts +54 -0
  240. package/dist/env/workflow/engine/executor.d.ts +122 -0
  241. package/dist/env/workflow/engine/index.d.ts +15 -0
  242. package/dist/env/workflow/engine/node-registry.d.ts +159 -0
  243. package/dist/env/workflow/engine/scheduler.d.ts +164 -0
  244. package/dist/env/workflow/extractor/workflow-converter.d.ts +55 -0
  245. package/dist/env/workflow/fixtures.d.ts +401 -0
  246. package/dist/env/workflow/hooks/index.d.ts +4 -0
  247. package/dist/env/workflow/hooks/workflow-hook-points.d.ts +161 -0
  248. package/dist/env/workflow/index.d.ts +30 -0
  249. package/dist/env/workflow/index.js +1 -1
  250. package/dist/env/workflow/metadata/keys.d.ts +6 -0
  251. package/dist/env/workflow/nodes/agent-component-adapter.d.ts +175 -0
  252. package/dist/env/workflow/nodes/agent-node.d.ts +206 -0
  253. package/dist/env/workflow/nodes/ask-user-node.d.ts +66 -0
  254. package/dist/env/workflow/nodes/condition-node.d.ts +39 -0
  255. package/dist/env/workflow/nodes/index.d.ts +8 -0
  256. package/dist/env/workflow/nodes/merge-node.d.ts +40 -0
  257. package/dist/env/workflow/nodes/python-call-node.d.ts +95 -0
  258. package/dist/env/workflow/nodes/skill-node.d.ts +29 -0
  259. package/dist/env/workflow/nodes/tool-node.d.ts +58 -0
  260. package/dist/env/workflow/nodes/workflow-node.d.ts +118 -0
  261. package/dist/env/workflow/plugins/index.d.ts +6 -0
  262. package/dist/env/workflow/plugins/index.js +2 -2
  263. package/dist/env/workflow/plugins/lark-cli-workflow-notify-plugin.d.ts +107 -0
  264. package/dist/env/workflow/plugins/workflow-json-output-plugin.d.ts +166 -0
  265. package/dist/env/workflow/runtime/runtime-cancellation-scope.d.ts +121 -0
  266. package/dist/env/workflow/service/index.d.ts +9 -0
  267. package/dist/env/workflow/service/registry.d.ts +37 -0
  268. package/dist/env/workflow/service/workflow-service.d.ts +422 -0
  269. package/dist/env/workflow/storage/index.d.ts +11 -0
  270. package/dist/env/workflow/storage/mock-repositories.d.ts +106 -0
  271. package/dist/env/workflow/storage/safe-json.d.ts +62 -0
  272. package/dist/env/workflow/storage/sqlite.d.ts +57 -0
  273. package/dist/env/workflow/storage/tag-repo.d.ts +65 -0
  274. package/dist/env/workflow/storage/workflow-repo.d.ts +161 -0
  275. package/dist/env/workflow/tools/ask-user-tool.d.ts +35 -0
  276. package/dist/env/workflow/tools/index.d.ts +16 -0
  277. package/dist/env/workflow/tools/run-workflow.d.ts +130 -0
  278. package/dist/env/workflow/tools/submit-json-output-tool.d.ts +38 -0
  279. package/dist/env/workflow/tools/workflow-add-tool.d.ts +47 -0
  280. package/dist/env/workflow/tools/workflow-get-tool.d.ts +29 -0
  281. package/dist/env/workflow/tools/workflow-list-tool.d.ts +55 -0
  282. package/dist/env/workflow/tools/workflow-run-status-tool.d.ts +26 -0
  283. package/dist/env/workflow/tools/workflow-run-stop-tool.d.ts +29 -0
  284. package/dist/env/workflow/tools/workflow-search-tool.d.ts +33 -0
  285. package/dist/env/workflow/tools/workflow-tag-list-tool.d.ts +59 -0
  286. package/dist/env/workflow/tools/workflow-validate-tool.d.ts +60 -0
  287. package/dist/env/workflow/types/context.d.ts +17 -0
  288. package/dist/env/workflow/types/decorators-types.d.ts +182 -0
  289. package/dist/env/workflow/types/edge.d.ts +33 -0
  290. package/dist/env/workflow/types/event.d.ts +869 -0
  291. package/dist/env/workflow/types/index.d.ts +16 -0
  292. package/dist/env/workflow/types/run.d.ts +235 -0
  293. package/dist/env/workflow/types/workflow-error.d.ts +79 -0
  294. package/dist/env/workflow/types/workflow-hil.d.ts +57 -0
  295. package/dist/env/workflow/types/workflow-message.d.ts +193 -0
  296. package/dist/env/workflow/types/workflow-session.d.ts +17 -0
  297. package/dist/env/workflow/types/workflow.d.ts +654 -0
  298. package/dist/env/workflow/types_compat.d.ts +10 -0
  299. package/dist/env/workflow/utils/agent-session-metadata.d.ts +35 -0
  300. package/dist/env/workflow/utils/build-agent-node-output.d.ts +11 -0
  301. package/dist/env/workflow/utils/create-workflow.d.ts +35 -0
  302. package/dist/env/workflow/utils/dependency-prescan.d.ts +67 -0
  303. package/dist/env/workflow/utils/execution-state.d.ts +46 -0
  304. package/dist/env/workflow/utils/extract-agent-json-output.d.ts +6 -0
  305. package/dist/env/workflow/utils/index.d.ts +14 -0
  306. package/dist/env/workflow/utils/json-schema-to-zod.d.ts +23 -0
  307. package/dist/env/workflow/utils/node-id-utils.d.ts +20 -0
  308. package/dist/env/workflow/utils/node-output-contracts.d.ts +137 -0
  309. package/dist/env/workflow/utils/node-registry-helper.d.ts +36 -0
  310. package/dist/env/workflow/utils/output-schema-hint.d.ts +7 -0
  311. package/dist/env/workflow/utils/parse-agent-output-config.d.ts +9 -0
  312. package/dist/env/workflow/utils/recovery-validator.d.ts +30 -0
  313. package/dist/env/workflow/utils/sensitive-redact.d.ts +37 -0
  314. package/dist/env/workflow/utils/session-parser.d.ts +23 -0
  315. package/dist/env/workflow/utils/session-recovery.d.ts +122 -0
  316. package/dist/env/workflow/utils/template-contract-validator.d.ts +87 -0
  317. package/dist/env/workflow/utils/template-resolver.d.ts +285 -0
  318. package/dist/env/workflow/utils/validate-workflow-definition.d.ts +57 -0
  319. package/dist/env/workflow/utils/validation-rules.d.ts +103 -0
  320. package/dist/env/workflow/utils/workflow-message-metadata.d.ts +20 -0
  321. package/dist/env/workflow/utils/workflow-sanitize.d.ts +51 -0
  322. package/dist/env/workflow/workflow-component.d.ts +138 -0
  323. package/dist/index.d.ts +59 -0
  324. package/dist/index.js +7 -7
  325. package/dist/shared/@ai-setting/{roy-agent-core-9faekt5n.js → roy-agent-core-4sx6sdb2.js} +1 -1
  326. package/dist/shared/@ai-setting/{roy-agent-core-wxsgay02.js → roy-agent-core-brwzs8wf.js} +1 -1
  327. package/dist/shared/@ai-setting/{roy-agent-core-kyasfzeh.js → roy-agent-core-hch2geta.js} +45 -14
  328. package/dist/shared/@ai-setting/{roy-agent-core-zd077w51.js → roy-agent-core-j8e92gj8.js} +43 -1
  329. package/dist/shared/@ai-setting/{roy-agent-core-wwytg8rv.js → roy-agent-core-ph5qbqcx.js} +566 -78
  330. package/dist/util/process/process-tree-killer.d.ts +67 -0
  331. package/dist/utils/id.d.ts +11 -0
  332. package/dist/utils/loose-json.d.ts +30 -0
  333. package/dist/utils/media.d.ts +70 -0
  334. package/dist/utils/temp-file-manager/index.d.ts +99 -0
  335. package/package.json +4 -2
  336. /package/dist/shared/@ai-setting/{roy-agent-core-s214vmmd.js → roy-agent-core-4vpk40ss.js} +0 -0
  337. /package/dist/shared/@ai-setting/{roy-agent-core-0cfaqnz9.js → roy-agent-core-k25gv86p.js} +0 -0
@@ -0,0 +1,80 @@
1
+ /**
2
+ * @fileoverview LLM Adapter 抽象接口。
3
+ *
4
+ * roy-agent 的 LLM 接入点统一通过 LLMAdapter;
5
+ * 当前实现:
6
+ * - PiAiAdapter — 包装 @earendil-works/pi-ai(默认路径)
7
+ * - AiSdkAdapter — 包装 Vercel AI SDK(fallback 路径)
8
+ *
9
+ * 通过 {@link createLLMAdapter} 选择,由环境变量 `ROY_LLM_PROVIDER` 控制。
10
+ */
11
+ import type { LLMMessage, ToolInfo, UsageInfo } from "./types";
12
+ /** Adapter 名称(联合类型 + 运行时数组) */
13
+ export type AdapterName = "pi-ai" | "ai-sdk";
14
+ /** 运行时可用的 adapter 列表 */
15
+ export declare const ADAPTER_NAMES: readonly AdapterName[];
16
+ /** Provider 解析结果 */
17
+ export interface ResolvedProvider {
18
+ api: string;
19
+ provider: string;
20
+ modelId: string;
21
+ contextLimit: number;
22
+ maxTokensLimit: number;
23
+ }
24
+ /** Chat 请求 */
25
+ export interface ChatRequest {
26
+ provider: string;
27
+ modelId: string;
28
+ messages: LLMMessage[];
29
+ tools?: ToolInfo[];
30
+ systemPrompt?: string;
31
+ temperature?: number;
32
+ maxTokens?: number;
33
+ apiKey: string;
34
+ baseURL?: string;
35
+ signal?: AbortSignal;
36
+ /**
37
+ * Conversation / session id (e.g. roy-agent session id, or the Feishu
38
+ * chat-keyed session id `oc_...`). Used by providers that need a stable
39
+ * per-conversation identifier — notably OpenCode Go, which requires a stable
40
+ * `x-opencode-session` header (see opencode-session.ts).
41
+ */
42
+ sessionId?: string;
43
+ }
44
+ /** Chat 响应(统一形状) */
45
+ export interface ChatResponse {
46
+ text: string;
47
+ finishReason: "stop" | "length" | "toolUse" | "error" | "aborted";
48
+ toolCalls?: Array<{
49
+ id: string;
50
+ name: string;
51
+ arguments: string;
52
+ }>;
53
+ usage: UsageInfo;
54
+ raw?: unknown;
55
+ }
56
+ /** Stream handle:暴露异步事件流 + 最终结果 */
57
+ export interface StreamHandle {
58
+ events: AsyncIterable<unknown>;
59
+ result: () => Promise<ChatResponse>;
60
+ }
61
+ /** LLM Adapter 接口(3 个核心方法) */
62
+ export interface EmbedRequest {
63
+ provider: string;
64
+ modelId: string;
65
+ input: string | string[];
66
+ apiKey: string;
67
+ baseURL?: string;
68
+ signal?: AbortSignal;
69
+ }
70
+ export interface EmbedResponse {
71
+ embeddings: number[][];
72
+ usage: UsageInfo;
73
+ }
74
+ export interface LLMAdapter {
75
+ readonly name: AdapterName;
76
+ chat(req: ChatRequest): Promise<ChatResponse>;
77
+ stream(req: ChatRequest): Promise<StreamHandle>;
78
+ resolveProvider(provider: string, modelId: string): Promise<ResolvedProvider>;
79
+ embed(req: EmbedRequest): Promise<EmbedResponse>;
80
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @fileoverview LLM Adapter 工厂
3
+ *
4
+ * 读取 ROY_LLM_PROVIDER 环境变量选择 adapter:
5
+ * - "pi-ai" → PiAiAdapter(默认)
6
+ * - "ai-sdk" → AiSdkAdapter(fallback)
7
+ *
8
+ * 通过 setLLMProvider() 可在运行时覆盖(用于测试)。
9
+ */
10
+ import type { LLMAdapter, AdapterName } from "./adapter";
11
+ export declare function setLLMProvider(name: AdapterName | undefined): void;
12
+ export declare function getLLMProviderOverride(): AdapterName | undefined;
13
+ export declare const createLLMAdapter: () => LLMAdapter;
@@ -0,0 +1,150 @@
1
+ import type { LLMInvokeRequest, LLMInvokeResult, StreamEvent } from "./types";
2
+ /**
3
+ * LLM Hook 类型(兼容旧接口)
4
+ */
5
+ export type LLMHookType = "before-invoke" | "after-invoke" | "stream";
6
+ /**
7
+ * LLM Hook 上下文
8
+ */
9
+ export interface LLMHookContext {
10
+ /** 请求 */
11
+ request: LLMInvokeRequest;
12
+ /** Provider ID */
13
+ providerId: string;
14
+ /** 模型名称 */
15
+ model: string;
16
+ /** 元数据 */
17
+ metadata?: Record<string, unknown>;
18
+ }
19
+ /**
20
+ * Before Invoke Hook
21
+ * 在 LLM 调用之前执行,可以修改请求
22
+ */
23
+ export type LLMBeforeInvokeHook = (context: LLMHookContext) => Promise<void>;
24
+ /**
25
+ * After Invoke Hook
26
+ * 在 LLM 调用之后执行,可以处理结果
27
+ */
28
+ export type LLMAfterInvokeHook = (context: LLMHookContext, result: LLMInvokeResult) => Promise<void>;
29
+ /**
30
+ * Stream Hook
31
+ * 在流式调用时处理每个事件
32
+ */
33
+ export type LLMStreamHook = (context: LLMHookContext, event: StreamEvent) => Promise<void>;
34
+ /**
35
+ * Hook 注册项
36
+ */
37
+ export interface LLMHookRegistration {
38
+ /** Hook 类型 */
39
+ type: LLMHookType;
40
+ /** Hook 名称(可选,用于标识) */
41
+ name?: string;
42
+ /** Before Invoke Hook */
43
+ beforeInvoke?: LLMBeforeInvokeHook;
44
+ /** After Invoke Hook */
45
+ afterInvoke?: LLMAfterInvokeHook;
46
+ /** Stream Hook */
47
+ stream?: LLMStreamHook;
48
+ }
49
+ /**
50
+ * LLMHookManager
51
+ *
52
+ * 代理到 globalHookManager 的 LLM Hook 管理器
53
+ *
54
+ * @deprecated 请直接使用 globalHookManager.register() 注册 hooks
55
+ */
56
+ export declare class LLMHookManager {
57
+ private registrations;
58
+ /**
59
+ * 注册 Hook
60
+ */
61
+ register(type: LLMHookType, handler: LLMBeforeInvokeHook | LLMAfterInvokeHook | LLMStreamHook, name?: string): void;
62
+ /**
63
+ * 注册单个 registration 到 globalHookManager
64
+ */
65
+ private registerToGlobal;
66
+ /**
67
+ * 取消注册 Hook
68
+ */
69
+ unregister(hook: LLMBeforeInvokeHook | LLMAfterInvokeHook | LLMStreamHook): void;
70
+ /**
71
+ * 从 globalHookManager 取消注册
72
+ */
73
+ private unregisterFromGlobal;
74
+ /**
75
+ * 按名称取消注册 Hook
76
+ */
77
+ unregisterByName(name: string): void;
78
+ /**
79
+ * 按类型取消注册所有 Hook
80
+ */
81
+ unregisterByType(type: LLMHookType): void;
82
+ /**
83
+ * 清空所有 Hook
84
+ */
85
+ clear(): void;
86
+ /**
87
+ * 获取所有 Hook
88
+ */
89
+ getHooks(): LLMHookRegistration[];
90
+ /**
91
+ * 按类型获取 Hook
92
+ */
93
+ getHooksByType(type: LLMHookType): LLMHookRegistration[];
94
+ }
95
+ /**
96
+ * LLMHooks
97
+ *
98
+ * 兼容旧接口,内部委托给 globalHookManager
99
+ *
100
+ * @deprecated 请直接使用 globalHookManager
101
+ */
102
+ export declare class LLMHooks {
103
+ private hookManager;
104
+ /**
105
+ * 注册 Hook
106
+ */
107
+ register(type: LLMHookType, handler: LLMBeforeInvokeHook | LLMAfterInvokeHook | LLMStreamHook, name?: string): void;
108
+ /**
109
+ * 取消注册 Hook
110
+ */
111
+ unregister(hook: LLMBeforeInvokeHook | LLMAfterInvokeHook | LLMStreamHook): void;
112
+ /**
113
+ * 按名称取消注册 Hook
114
+ */
115
+ unregisterByName(name: string): void;
116
+ /**
117
+ * 按类型取消注册所有 Hook
118
+ */
119
+ unregisterByType(type: LLMHookType): void;
120
+ /**
121
+ * 清空所有 Hook
122
+ */
123
+ clear(): void;
124
+ /**
125
+ * 获取所有 Hook
126
+ */
127
+ getHooks(): LLMHookRegistration[];
128
+ /**
129
+ * 按类型获取 Hook
130
+ */
131
+ getHooksByType(type: LLMHookType): LLMHookRegistration[];
132
+ /**
133
+ * 执行 Before Invoke Hooks
134
+ *
135
+ * @deprecated 请使用 globalHookManager.execute(LLMHookPoints.BEFORE_INVOKE, ...)
136
+ */
137
+ executeBeforeInvoke(context: LLMHookContext): Promise<void>;
138
+ /**
139
+ * 执行 After Invoke Hooks
140
+ *
141
+ * @deprecated 请使用 globalHookManager.execute(LLMHookPoints.AFTER_INVOKE, ...)
142
+ */
143
+ executeAfterInvoke(context: LLMHookContext, result: LLMInvokeResult): Promise<void>;
144
+ /**
145
+ * 执行 Stream Hooks
146
+ *
147
+ * @deprecated 请使用 globalHookManager.execute(LLMHookPoints.ON_STREAM, ...)
148
+ */
149
+ executeStream(context: LLMHookContext, event: StreamEvent): Promise<void>;
150
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * LLM Component
3
+ * 提供 LLM 调用能力
4
+ */
5
+ export { type LLMAdapter, type AdapterName, type ChatRequest, type ChatResponse, type StreamHandle, type ResolvedProvider, ADAPTER_NAMES, } from "./adapter";
6
+ export { PiAiAdapter } from "./adapter-pi-ai";
7
+ export { AiSdkAdapter } from "./adapter-ai-sdk";
8
+ export { createLLMAdapter, setLLMProvider, getLLMProviderOverride } from "./factory";
9
+ export { type ContentPart, type LLMMessage, type LLMOutput, type UsageInfo, type ToolCall, type ToolResult, type ToolInfo, type LLMConfig, type LLMProvider, type ProviderConfig, type ProviderType, type LLMInvokeRequest, type LLMInvokeResult, type StreamEvent, } from "./types";
10
+ export { LLMConfigSchema, ProviderConfigSchema, ProviderCapabilitiesSchema, ModelLimitsSchema, LLMDefaultConfigSchema, } from "./types";
11
+ export { ProviderManager } from "./provider";
12
+ export { LLMTransform } from "./transform";
13
+ export { invoke, invokeNonStream, parseModelString, createInvokeConfig, convertToSDKMessages, type InvokeConfig, type InvokeOptions, type LLMToolContext, type ConvertedUsageInfo, } from "./invoke";
14
+ export { isOpencodeProvider, isOpencodeEndpoint, buildOpencodeHeaders, getOrCreateOpencodeSessionId, generateOpencodeSessionId, } from "./opencode-session";
15
+ export { type LLMHookType, type LLMHookContext, type LLMBeforeInvokeHook, type LLMAfterInvokeHook, type LLMStreamHook, type LLMHookRegistration, LLMHooks, } from "./hooks";
16
+ export { LLMComponent, type LLMComponentOptions } from "./llm";
@@ -0,0 +1,264 @@
1
+ /**
2
+ * @fileoverview LLM invocation with AI SDK integration.
3
+ *
4
+ * This module provides LLM invocation using AI SDK for better provider support.
5
+ * Stream events are published via Environment.pushEnvEvent().
6
+ */
7
+ import { type ModelMessage } from "ai";
8
+ import type { ToolInfo, ToolResult, LLMOutput, LLMMessage } from "./types";
9
+ import type { Environment } from "../interface";
10
+ import { __clearOpencodeSessionIdCache } from "./opencode-session";
11
+ /**
12
+ * Re-exported for backwards compatibility with existing tests
13
+ * (`packages/core/test/llm/opencode-go-interactive.test.ts`). The implementation
14
+ * now lives in `opencode-session.ts` so the default PiAiAdapter path can share it.
15
+ */
16
+ export { __clearOpencodeSessionIdCache };
17
+ /**
18
+ * Invoke LLM 配置
19
+ */
20
+ export interface InvokeConfig {
21
+ /** 模型标识符(格式: providerId/modelId) */
22
+ model: string;
23
+ /** Base URL */
24
+ baseURL?: string;
25
+ /** API Key */
26
+ apiKey: string;
27
+ /** 额外选项 */
28
+ options?: {
29
+ /**
30
+ * 文本内嵌思考标签处理配置
31
+ *
32
+ * 对齐 `ProviderCapabilities.thinkingInText` (`packages/core/src/env/llm/types.ts`):
33
+ * - `enabled`: 是否启用标签剥离
34
+ * - `tags`: 标签名列表(例如 `["think"]` → `""`)
35
+ * - `removeFromOutput`: 剥离后是否从返回值中移除(`false` 则保留原始含标签内容,
36
+ * 便于维持消息历史中的推理连续性,例如 MiniMax 需要看历史中的标签才会继续输出 reasoning)
37
+ */
38
+ thinkingInText?: {
39
+ enabled?: boolean;
40
+ tags?: string[];
41
+ removeFromOutput?: boolean;
42
+ };
43
+ };
44
+ }
45
+ /**
46
+ * LLM 选项
47
+ */
48
+ export interface InvokeOptions {
49
+ /** 消息列表 */
50
+ messages: LLMMessage[];
51
+ /** 工具列表 */
52
+ tools?: ToolInfo[];
53
+ /** 模型标识符(可选) */
54
+ model?: string;
55
+ /** 温度参数 */
56
+ temperature?: number;
57
+ /** 最大 Token 数 */
58
+ maxTokens?: number;
59
+ /** Environment 实例(用于发布流式事件,可选) */
60
+ env?: Environment;
61
+ /** 上下文信息(用于事件元数据) */
62
+ context?: {
63
+ /** Session ID */
64
+ sessionId?: string;
65
+ /** Message ID */
66
+ messageId?: string;
67
+ };
68
+ /**
69
+ * 工具选择策略(强制 LLM 调用特定工具)
70
+ *
71
+ * - "auto" — LLM 自主决定(默认)
72
+ * - "none" — 禁止调用任何工具
73
+ * - "required" — 必须调用至少一个工具(Issue #1694: 确保 json-extract 必须调用 workflow_submit_output)
74
+ * - { type: "function", function: { name: "..." } } — 强制调用指定工具
75
+ */
76
+ toolChoice?: "auto" | "none" | "required" | {
77
+ type: "function";
78
+ function: {
79
+ name: string;
80
+ };
81
+ };
82
+ }
83
+ /**
84
+ * LLM Tool Context - Context for tool calls during LLM invocation
85
+ */
86
+ export interface LLMToolContext {
87
+ /** Abort Signal */
88
+ abort?: AbortSignal | undefined;
89
+ /** 额外上下文 */
90
+ context?: Record<string, unknown>;
91
+ }
92
+ /**
93
+ * Usage 信息(AI SDK 格式)
94
+ * 参考: LanguageModelV3Usage from @ai-sdk/provider
95
+ */
96
+ interface AISDKUsage {
97
+ inputTokens?: {
98
+ total?: number;
99
+ noCache?: number;
100
+ cacheRead?: number;
101
+ cacheWrite?: number;
102
+ [key: string]: unknown;
103
+ };
104
+ outputTokens?: {
105
+ total?: number;
106
+ [key: string]: unknown;
107
+ };
108
+ totalTokens?: number;
109
+ promptTokens?: number;
110
+ completionTokens?: number;
111
+ inputTokenDetails?: {
112
+ tokens?: number;
113
+ [key: string]: unknown;
114
+ };
115
+ outputTokenDetails?: {
116
+ tokens?: number;
117
+ [key: string]: unknown;
118
+ };
119
+ raw?: {
120
+ total_tokens?: number;
121
+ prompt_tokens?: number;
122
+ completion_tokens?: number;
123
+ };
124
+ }
125
+ /**
126
+ * Usage 信息转换
127
+ */
128
+ export interface ConvertedUsageInfo {
129
+ /** Prompt Token 数 */
130
+ promptTokens: number;
131
+ /** Completion Token 数 */
132
+ completionTokens: number;
133
+ /** 总 Token 数 */
134
+ totalTokens: number;
135
+ /**
136
+ * Anthropic prompt cache read tokens (cache_read_input_tokens).
137
+ * `undefined` when the provider did not report a cache-read field.
138
+ * `0` means the cache was checked but no tokens hit (distinct from
139
+ * the field being absent).
140
+ */
141
+ cacheRead?: number;
142
+ /**
143
+ * Anthropic prompt cache write tokens (cache_creation_input_tokens).
144
+ * See {@link cacheRead} for semantics.
145
+ */
146
+ cacheWrite?: number;
147
+ }
148
+ /**
149
+ * 超时错误
150
+ */
151
+ export declare class TimeoutError extends Error {
152
+ readonly timeout: number;
153
+ constructor(message: string, timeout: number);
154
+ }
155
+ /**
156
+ * 带超时的 Promise 包装器
157
+ *
158
+ * @param promise 要执行的 Promise
159
+ * @param timeoutMs 超时时间(毫秒)
160
+ * @param message 自定义错误消息
161
+ * @returns Promise 结果
162
+ * @throws TimeoutError 当超时时
163
+ */
164
+ export declare function withTimeout<T>(promise: Promise<T>, timeoutMs?: number, message?: string): Promise<T>;
165
+ /**
166
+ * 解析模型字符串
167
+ * 格式: "providerId/modelId"
168
+ */
169
+ export declare function parseModelString(model?: string): {
170
+ providerId: string;
171
+ modelId: string;
172
+ };
173
+ /**
174
+ * 从 Usage 信息提取标准格式
175
+ *
176
+ * I4 (review-cache-stability.md): now exposes `cacheRead` / `cacheWrite` so
177
+ * callers can observe Anthropic prompt cache effectiveness.
178
+ *
179
+ * AI SDK v3 usage shape places cache tokens at two possible locations:
180
+ * 1. `usage.inputTokens.cacheRead` / `usage.inputTokens.cacheWrite`
181
+ * (modern LanguageModelV3Usage object form)
182
+ * 2. `usage.inputTokenDetails.cacheReadTokens` / `cacheWriteTokens`
183
+ * (legacy / MiniMax / DeepSeek form)
184
+ *
185
+ * We check the modern form first and fall back to the legacy form.
186
+ * A reported `0` is preserved (the cache was checked, no hit);
187
+ * `undefined` means the provider did not report the field at all.
188
+ */
189
+ export declare function extractUsageInfo(usage: AISDKUsage | undefined): ConvertedUsageInfo | undefined;
190
+ /**
191
+ * Recursively sort object keys for deterministic byte serialization.
192
+ *
193
+ * I2 (review-cache-stability.md): the LLM may emit the same tool call
194
+ * with keys in different orders across turns (e.g. `{a:1,b:2}` vs
195
+ * `{b:2,a:1}`). AI SDK internally JSON.stringifies tool-call `input`
196
+ * before forwarding to Anthropic — if the key order shifts, the cache
197
+ * prefix changes and Anthropic reports a cache miss.
198
+ *
199
+ * Sorting keys before JSON.stringify (or before handing to AI SDK)
200
+ * guarantees the bytes are deterministic regardless of LLM key order.
201
+ *
202
+ * Behavioral notes:
203
+ * - Arrays preserve their order (element order is semantically meaningful).
204
+ * - Uint8Array / Buffer are returned by identity (we don't try to sort
205
+ * their bytes — that would be lossy and impossible for binary data).
206
+ * - Primitives (string, number, boolean, null, undefined) pass through.
207
+ *
208
+ * @see https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching
209
+ */
210
+ export declare function sortObjectKeysDeep<T>(obj: T, seen?: WeakSet<object>): T;
211
+ export { applyToolCacheControl, canonicalizeParts } from "./llm-cache";
212
+ /**
213
+ * 将 LLMMessage 转换为 AI SDK 格式
214
+ *
215
+ * I1 (review-cache-stability.md): inserts Anthropic prompt-cache breakpoints
216
+ * on the system message and the last user message. Without these, Anthropic
217
+ * never caches anything and we pay full input price every turn.
218
+ *
219
+ * Task #2748 §5.3: 支持 sessionId 参数,给 OpenAI-Compatible provider
220
+ * 注入 prompt_cache_key=sessionId。
221
+ */
222
+ export declare function convertToSDKMessages(messages: LLMMessage[], options?: {
223
+ sessionId?: string;
224
+ provider?: string;
225
+ }): ModelMessage[];
226
+ /**
227
+ * 从 AI SDK stream part 提取文本增量(兼容 text / delta 字段)
228
+ */
229
+ export declare function getStreamPartText(part: Record<string, unknown>): string;
230
+ /**
231
+ * 核心 LLM 调用函数
232
+ * 使用 AI SDK 的 streamText
233
+ *
234
+ * 流式事件通过 env.pushEnvEvent() 发布
235
+ *
236
+ * @param config - Invoke 配置
237
+ * @param options - LLM 选项
238
+ * @param ctx - Tool Context
239
+ * @returns ToolResult
240
+ */
241
+ export declare function invoke(config: InvokeConfig, options: InvokeOptions, ctx: LLMToolContext): Promise<ToolResult>;
242
+ /**
243
+ * 创建 Provider 实例
244
+ * 根据 providerId 创建对应的 AI SDK Provider
245
+ */
246
+ declare function createProviderInstance(providerId: string, apiKey: string, baseURL?: string, conversationId?: string): any;
247
+ /**
248
+ * Test-only re-export of createProviderInstance so that unit tests can verify
249
+ * header injection behavior without booting the full invoke() stack.
250
+ *
251
+ * This is gated by an explicit `__` prefix to make it obvious in code review
252
+ * that this surface is for tests only. Production code MUST NOT import this.
253
+ */
254
+ export declare const __createProviderInstanceForTest: typeof createProviderInstance;
255
+ /**
256
+ * 非流式 LLM 调用
257
+ *
258
+ * 使用 AI SDK 的 generateText API,返回完整响应
259
+ */
260
+ export declare function invokeNonStream(config: InvokeConfig, options: InvokeOptions, ctx: LLMToolContext): Promise<LLMOutput>;
261
+ /**
262
+ * 创建 LLM 配置
263
+ */
264
+ export declare function createInvokeConfig(model: string, apiKey: string, baseURL?: string): InvokeConfig;
@@ -0,0 +1,38 @@
1
+ /**
2
+ * @fileoverview LLM Cache Options Helpers (Task #2748 §5.3-5.5)
3
+ *
4
+ * 4 项 cache 优化相关的 helper 集中在此模块:
5
+ * - §5.3: OpenAI-Compatible prompt_cache_key
6
+ * - §5.4: Tool schema cache_control (Anthropic)
7
+ * - §5.5: parts JSON canonicalize
8
+ *
9
+ * 集中导出便于复用、单元测试、独立演进。
10
+ */
11
+ /**
12
+ * §5.3: OpenAI-Compatible provider 的 prompt_cache_key
13
+ *
14
+ * Anthropic 端用 cache_control; OpenAI 端用 prompt_cache_key。
15
+ * roy-agent 当前完全没给 OpenAI-Compatible (minimax/DeepSeek/GLM) 挂这个,
16
+ * 导致这些 provider 的 cache 完全靠隐式行为,命中率低。
17
+ *
18
+ * 参考 pi-agent: openai-completions.ts:680-695 (prompt_cache_key=sessionId)
19
+ */
20
+ export declare function isOpenAICompatibleProvider(providerName: string): boolean;
21
+ export declare function clampOpenAIPromptCacheKey(sessionId: string, maxLen?: number): string;
22
+ export declare function buildOpenAICompatProviderOptions(sessionId: string | undefined, cacheRetention?: "short" | "long" | "none"): Record<string, unknown>;
23
+ /**
24
+ * §5.4: 给工具 schema 的末 tool 挂 cache_control (Anthropic 3 层)
25
+ *
26
+ * pi-agent: anthropic-messages.ts:1005 (compat.supportsCacheControlOnTools ? cacheControl : undefined)
27
+ * 收益:工具 schema 大的 agent 多省 10-30% input cost。
28
+ */
29
+ export declare function applyToolCacheControl<T extends Record<string, unknown>>(tools: T[] | undefined, providerName: string): T[] | undefined;
30
+ /**
31
+ * §5.5: parts JSON canonicalize
32
+ *
33
+ * SQLite 存 parts 为 JSON 字符串,读出来时 JSON.parse 的 key 顺序不保证稳定。
34
+ * 在写入时对 parts 做 sortObjectKeysDeep → byte-stable 序列化。
35
+ *
36
+ * 同时也处理 tool-call arguments 字符串(如果是 string,需要 parse → sort → stringify)。
37
+ */
38
+ export declare function canonicalizeParts(parts: unknown): string;