@clinebot/core 0.0.20 → 0.0.21

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 (356) hide show
  1. package/dist/account/cline-account-service.d.ts +3 -2
  2. package/dist/account/cline-account-service.d.ts.map +1 -0
  3. package/dist/account/index.d.ts +1 -0
  4. package/dist/account/index.d.ts.map +1 -0
  5. package/dist/account/rpc.d.ts +1 -0
  6. package/dist/account/rpc.d.ts.map +1 -0
  7. package/dist/account/types.d.ts +1 -0
  8. package/dist/account/types.d.ts.map +1 -0
  9. package/dist/agents/agent-config-loader.d.ts +1 -0
  10. package/dist/agents/agent-config-loader.d.ts.map +1 -0
  11. package/dist/agents/agent-config-parser.d.ts +1 -0
  12. package/dist/agents/agent-config-parser.d.ts.map +1 -0
  13. package/dist/agents/hooks-config-loader.d.ts +1 -0
  14. package/dist/agents/hooks-config-loader.d.ts.map +1 -0
  15. package/dist/agents/index.d.ts +1 -0
  16. package/dist/agents/index.d.ts.map +1 -0
  17. package/dist/agents/plugin-config-loader.d.ts +1 -0
  18. package/dist/agents/plugin-config-loader.d.ts.map +1 -0
  19. package/dist/agents/plugin-loader.d.ts +1 -0
  20. package/dist/agents/plugin-loader.d.ts.map +1 -0
  21. package/dist/agents/plugin-sandbox.d.ts +1 -0
  22. package/dist/agents/plugin-sandbox.d.ts.map +1 -0
  23. package/dist/agents/unified-config-file-watcher.d.ts +1 -0
  24. package/dist/agents/unified-config-file-watcher.d.ts.map +1 -0
  25. package/dist/agents/user-instruction-config-loader.d.ts +1 -0
  26. package/dist/agents/user-instruction-config-loader.d.ts.map +1 -0
  27. package/dist/auth/client.d.ts +1 -0
  28. package/dist/auth/client.d.ts.map +1 -0
  29. package/dist/auth/cline.d.ts +1 -0
  30. package/dist/auth/cline.d.ts.map +1 -0
  31. package/dist/auth/codex.d.ts +1 -0
  32. package/dist/auth/codex.d.ts.map +1 -0
  33. package/dist/auth/oca.d.ts +1 -0
  34. package/dist/auth/oca.d.ts.map +1 -0
  35. package/dist/auth/server.d.ts +1 -0
  36. package/dist/auth/server.d.ts.map +1 -0
  37. package/dist/auth/types.d.ts +1 -0
  38. package/dist/auth/types.d.ts.map +1 -0
  39. package/dist/auth/utils.d.ts +1 -0
  40. package/dist/auth/utils.d.ts.map +1 -0
  41. package/dist/chat/chat-schema.d.ts +13 -12
  42. package/dist/chat/chat-schema.d.ts.map +1 -0
  43. package/dist/index.d.ts +3 -1
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/index.node.d.ts +2 -0
  46. package/dist/index.node.d.ts.map +1 -0
  47. package/dist/index.node.js +303 -302
  48. package/dist/input/file-indexer.d.ts +1 -0
  49. package/dist/input/file-indexer.d.ts.map +1 -0
  50. package/dist/input/index.d.ts +1 -0
  51. package/dist/input/index.d.ts.map +1 -0
  52. package/dist/input/mention-enricher.d.ts +1 -0
  53. package/dist/input/mention-enricher.d.ts.map +1 -0
  54. package/dist/mcp/config-loader.d.ts +1 -0
  55. package/dist/mcp/config-loader.d.ts.map +1 -0
  56. package/dist/mcp/index.d.ts +1 -0
  57. package/dist/mcp/index.d.ts.map +1 -0
  58. package/dist/mcp/manager.d.ts +1 -0
  59. package/dist/mcp/manager.d.ts.map +1 -0
  60. package/dist/mcp/types.d.ts +1 -0
  61. package/dist/mcp/types.d.ts.map +1 -0
  62. package/dist/providers/local-provider-registry.d.ts +36 -0
  63. package/dist/providers/local-provider-registry.d.ts.map +1 -0
  64. package/dist/providers/local-provider-service.d.ts +2 -1
  65. package/dist/providers/local-provider-service.d.ts.map +1 -0
  66. package/dist/runtime/commands.d.ts +1 -0
  67. package/dist/runtime/commands.d.ts.map +1 -0
  68. package/dist/runtime/hook-file-hooks.d.ts +1 -0
  69. package/dist/runtime/hook-file-hooks.d.ts.map +1 -0
  70. package/dist/runtime/rules.d.ts +1 -0
  71. package/dist/runtime/rules.d.ts.map +1 -0
  72. package/dist/runtime/runtime-builder.d.ts +1 -0
  73. package/dist/runtime/runtime-builder.d.ts.map +1 -0
  74. package/dist/runtime/sandbox/subprocess-sandbox.d.ts +1 -0
  75. package/dist/runtime/sandbox/subprocess-sandbox.d.ts.map +1 -0
  76. package/dist/runtime/session-runtime.d.ts +2 -0
  77. package/dist/runtime/session-runtime.d.ts.map +1 -0
  78. package/dist/runtime/skills.d.ts +1 -0
  79. package/dist/runtime/skills.d.ts.map +1 -0
  80. package/dist/runtime/tool-approval.d.ts +1 -0
  81. package/dist/runtime/tool-approval.d.ts.map +1 -0
  82. package/dist/runtime/workflows.d.ts +1 -0
  83. package/dist/runtime/workflows.d.ts.map +1 -0
  84. package/dist/session/default-session-manager.d.ts +4 -0
  85. package/dist/session/default-session-manager.d.ts.map +1 -0
  86. package/dist/session/file-session-service.d.ts +1 -0
  87. package/dist/session/file-session-service.d.ts.map +1 -0
  88. package/dist/session/rpc-session-service.d.ts +1 -0
  89. package/dist/session/rpc-session-service.d.ts.map +1 -0
  90. package/dist/session/rpc-spawn-lease.d.ts +1 -0
  91. package/dist/session/rpc-spawn-lease.d.ts.map +1 -0
  92. package/dist/session/runtime-oauth-token-manager.d.ts +1 -0
  93. package/dist/session/runtime-oauth-token-manager.d.ts.map +1 -0
  94. package/dist/session/session-agent-events.d.ts +20 -1
  95. package/dist/session/session-agent-events.d.ts.map +1 -0
  96. package/dist/session/session-artifacts.d.ts +1 -0
  97. package/dist/session/session-artifacts.d.ts.map +1 -0
  98. package/dist/session/session-config-builder.d.ts +1 -0
  99. package/dist/session/session-config-builder.d.ts.map +1 -0
  100. package/dist/session/session-graph.d.ts +1 -0
  101. package/dist/session/session-graph.d.ts.map +1 -0
  102. package/dist/session/session-host.d.ts +1 -0
  103. package/dist/session/session-host.d.ts.map +1 -0
  104. package/dist/session/session-manager.d.ts +1 -0
  105. package/dist/session/session-manager.d.ts.map +1 -0
  106. package/dist/session/session-manifest.d.ts +2 -1
  107. package/dist/session/session-manifest.d.ts.map +1 -0
  108. package/dist/session/session-service.d.ts +1 -0
  109. package/dist/session/session-service.d.ts.map +1 -0
  110. package/dist/session/session-team-coordination.d.ts +1 -0
  111. package/dist/session/session-team-coordination.d.ts.map +1 -0
  112. package/dist/session/session-telemetry.d.ts +3 -1
  113. package/dist/session/session-telemetry.d.ts.map +1 -0
  114. package/dist/session/sqlite-rpc-session-backend.d.ts +1 -0
  115. package/dist/session/sqlite-rpc-session-backend.d.ts.map +1 -0
  116. package/dist/session/unified-session-persistence-service.d.ts +1 -0
  117. package/dist/session/unified-session-persistence-service.d.ts.map +1 -0
  118. package/dist/session/utils/helpers.d.ts +1 -0
  119. package/dist/session/utils/helpers.d.ts.map +1 -0
  120. package/dist/session/utils/types.d.ts +1 -0
  121. package/dist/session/utils/types.d.ts.map +1 -0
  122. package/dist/session/utils/usage.d.ts +1 -0
  123. package/dist/session/utils/usage.d.ts.map +1 -0
  124. package/dist/session/workspace-manager.d.ts +1 -0
  125. package/dist/session/workspace-manager.d.ts.map +1 -0
  126. package/dist/session/workspace-manifest.d.ts +1 -0
  127. package/dist/session/workspace-manifest.d.ts.map +1 -0
  128. package/dist/storage/file-team-store.d.ts +1 -0
  129. package/dist/storage/file-team-store.d.ts.map +1 -0
  130. package/dist/storage/provider-settings-legacy-migration.d.ts +1 -0
  131. package/dist/storage/provider-settings-legacy-migration.d.ts.map +1 -0
  132. package/dist/storage/provider-settings-manager.d.ts +1 -0
  133. package/dist/storage/provider-settings-manager.d.ts.map +1 -0
  134. package/dist/storage/sqlite-session-store.d.ts +1 -0
  135. package/dist/storage/sqlite-session-store.d.ts.map +1 -0
  136. package/dist/storage/sqlite-team-store.d.ts +1 -0
  137. package/dist/storage/sqlite-team-store.d.ts.map +1 -0
  138. package/dist/storage/team-store.d.ts +1 -0
  139. package/dist/storage/team-store.d.ts.map +1 -0
  140. package/dist/team/index.d.ts +1 -0
  141. package/dist/team/index.d.ts.map +1 -0
  142. package/dist/team/projections.d.ts +1 -0
  143. package/dist/team/projections.d.ts.map +1 -0
  144. package/dist/telemetry/ITelemetryAdapter.d.ts +1 -0
  145. package/dist/telemetry/ITelemetryAdapter.d.ts.map +1 -0
  146. package/dist/telemetry/LoggerTelemetryAdapter.d.ts +1 -0
  147. package/dist/telemetry/LoggerTelemetryAdapter.d.ts.map +1 -0
  148. package/dist/telemetry/OpenTelemetryAdapter.d.ts +1 -0
  149. package/dist/telemetry/OpenTelemetryAdapter.d.ts.map +1 -0
  150. package/dist/telemetry/OpenTelemetryProvider.d.ts +1 -0
  151. package/dist/telemetry/OpenTelemetryProvider.d.ts.map +1 -0
  152. package/dist/telemetry/TelemetryService.d.ts +1 -0
  153. package/dist/telemetry/TelemetryService.d.ts.map +1 -0
  154. package/dist/telemetry/core-events.d.ts +55 -22
  155. package/dist/telemetry/core-events.d.ts.map +1 -0
  156. package/dist/telemetry/opentelemetry.d.ts +1 -0
  157. package/dist/telemetry/opentelemetry.d.ts.map +1 -0
  158. package/dist/tools/constants.d.ts +1 -0
  159. package/dist/tools/constants.d.ts.map +1 -0
  160. package/dist/tools/definitions.d.ts +8 -1
  161. package/dist/tools/definitions.d.ts.map +1 -0
  162. package/dist/tools/executors/apply-patch-parser.d.ts +1 -0
  163. package/dist/tools/executors/apply-patch-parser.d.ts.map +1 -0
  164. package/dist/tools/executors/apply-patch.d.ts +1 -0
  165. package/dist/tools/executors/apply-patch.d.ts.map +1 -0
  166. package/dist/tools/executors/bash.d.ts +2 -1
  167. package/dist/tools/executors/bash.d.ts.map +1 -0
  168. package/dist/tools/executors/editor.d.ts +1 -0
  169. package/dist/tools/executors/editor.d.ts.map +1 -0
  170. package/dist/tools/executors/file-read.d.ts +1 -0
  171. package/dist/tools/executors/file-read.d.ts.map +1 -0
  172. package/dist/tools/executors/index.d.ts +14 -7
  173. package/dist/tools/executors/index.d.ts.map +1 -0
  174. package/dist/tools/executors/search.d.ts +1 -0
  175. package/dist/tools/executors/search.d.ts.map +1 -0
  176. package/dist/tools/executors/web-fetch.d.ts +1 -0
  177. package/dist/tools/executors/web-fetch.d.ts.map +1 -0
  178. package/dist/tools/helpers.d.ts +15 -0
  179. package/dist/tools/helpers.d.ts.map +1 -0
  180. package/dist/tools/index.d.ts +2 -1
  181. package/dist/tools/index.d.ts.map +1 -0
  182. package/dist/tools/model-tool-routing.d.ts +1 -0
  183. package/dist/tools/model-tool-routing.d.ts.map +1 -0
  184. package/dist/tools/presets.d.ts +1 -0
  185. package/dist/tools/presets.d.ts.map +1 -0
  186. package/dist/tools/schemas.d.ts +41 -0
  187. package/dist/tools/schemas.d.ts.map +1 -0
  188. package/dist/tools/types.d.ts +3 -2
  189. package/dist/tools/types.d.ts.map +1 -0
  190. package/dist/types/common.d.ts +1 -0
  191. package/dist/types/common.d.ts.map +1 -0
  192. package/dist/types/config.d.ts +1 -0
  193. package/dist/types/config.d.ts.map +1 -0
  194. package/dist/types/events.d.ts +1 -0
  195. package/dist/types/events.d.ts.map +1 -0
  196. package/dist/types/provider-settings.d.ts +1 -0
  197. package/dist/types/provider-settings.d.ts.map +1 -0
  198. package/dist/types/sessions.d.ts +1 -0
  199. package/dist/types/sessions.d.ts.map +1 -0
  200. package/dist/types/storage.d.ts +1 -0
  201. package/dist/types/storage.d.ts.map +1 -0
  202. package/dist/types/workspace.d.ts +1 -0
  203. package/dist/types/workspace.d.ts.map +1 -0
  204. package/dist/types.d.ts +1 -0
  205. package/dist/types.d.ts.map +1 -0
  206. package/package.json +6 -4
  207. package/src/account/cline-account-service.test.ts +0 -101
  208. package/src/account/cline-account-service.ts +0 -287
  209. package/src/account/index.ts +0 -22
  210. package/src/account/rpc.test.ts +0 -62
  211. package/src/account/rpc.ts +0 -172
  212. package/src/account/types.ts +0 -98
  213. package/src/agents/agent-config-loader.test.ts +0 -236
  214. package/src/agents/agent-config-loader.ts +0 -108
  215. package/src/agents/agent-config-parser.ts +0 -198
  216. package/src/agents/hooks-config-loader.test.ts +0 -20
  217. package/src/agents/hooks-config-loader.ts +0 -118
  218. package/src/agents/index.ts +0 -85
  219. package/src/agents/plugin-config-loader.test.ts +0 -140
  220. package/src/agents/plugin-config-loader.ts +0 -97
  221. package/src/agents/plugin-loader.test.ts +0 -228
  222. package/src/agents/plugin-loader.ts +0 -172
  223. package/src/agents/plugin-sandbox-bootstrap.ts +0 -445
  224. package/src/agents/plugin-sandbox.test.ts +0 -317
  225. package/src/agents/plugin-sandbox.ts +0 -341
  226. package/src/agents/unified-config-file-watcher.test.ts +0 -196
  227. package/src/agents/unified-config-file-watcher.ts +0 -483
  228. package/src/agents/user-instruction-config-loader.test.ts +0 -158
  229. package/src/agents/user-instruction-config-loader.ts +0 -438
  230. package/src/auth/client.test.ts +0 -40
  231. package/src/auth/client.ts +0 -25
  232. package/src/auth/cline.test.ts +0 -130
  233. package/src/auth/cline.ts +0 -420
  234. package/src/auth/codex.test.ts +0 -170
  235. package/src/auth/codex.ts +0 -491
  236. package/src/auth/oca.test.ts +0 -215
  237. package/src/auth/oca.ts +0 -573
  238. package/src/auth/server.ts +0 -216
  239. package/src/auth/types.ts +0 -81
  240. package/src/auth/utils.test.ts +0 -128
  241. package/src/auth/utils.ts +0 -247
  242. package/src/chat/chat-schema.ts +0 -82
  243. package/src/index.node.ts +0 -285
  244. package/src/index.ts +0 -211
  245. package/src/input/file-indexer.d.ts +0 -11
  246. package/src/input/file-indexer.test.ts +0 -127
  247. package/src/input/file-indexer.ts +0 -327
  248. package/src/input/index.ts +0 -7
  249. package/src/input/mention-enricher.test.ts +0 -85
  250. package/src/input/mention-enricher.ts +0 -122
  251. package/src/mcp/config-loader.test.ts +0 -238
  252. package/src/mcp/config-loader.ts +0 -219
  253. package/src/mcp/index.ts +0 -26
  254. package/src/mcp/manager.test.ts +0 -106
  255. package/src/mcp/manager.ts +0 -262
  256. package/src/mcp/types.ts +0 -88
  257. package/src/providers/local-provider-service.ts +0 -608
  258. package/src/runtime/commands.test.ts +0 -98
  259. package/src/runtime/commands.ts +0 -83
  260. package/src/runtime/hook-file-hooks.test.ts +0 -237
  261. package/src/runtime/hook-file-hooks.ts +0 -859
  262. package/src/runtime/index.ts +0 -37
  263. package/src/runtime/rules.ts +0 -34
  264. package/src/runtime/runtime-builder.team-persistence.test.ts +0 -202
  265. package/src/runtime/runtime-builder.test.ts +0 -371
  266. package/src/runtime/runtime-builder.ts +0 -589
  267. package/src/runtime/runtime-parity.test.ts +0 -143
  268. package/src/runtime/sandbox/subprocess-sandbox.ts +0 -231
  269. package/src/runtime/session-runtime.ts +0 -46
  270. package/src/runtime/skills.ts +0 -44
  271. package/src/runtime/tool-approval.ts +0 -104
  272. package/src/runtime/workflows.test.ts +0 -119
  273. package/src/runtime/workflows.ts +0 -45
  274. package/src/session/default-session-manager.e2e.test.ts +0 -384
  275. package/src/session/default-session-manager.test.ts +0 -1741
  276. package/src/session/default-session-manager.ts +0 -1233
  277. package/src/session/file-session-service.ts +0 -280
  278. package/src/session/index.ts +0 -42
  279. package/src/session/rpc-session-service.ts +0 -107
  280. package/src/session/rpc-spawn-lease.test.ts +0 -49
  281. package/src/session/rpc-spawn-lease.ts +0 -122
  282. package/src/session/runtime-oauth-token-manager.test.ts +0 -137
  283. package/src/session/runtime-oauth-token-manager.ts +0 -272
  284. package/src/session/session-agent-events.ts +0 -159
  285. package/src/session/session-artifacts.ts +0 -106
  286. package/src/session/session-config-builder.ts +0 -113
  287. package/src/session/session-graph.ts +0 -92
  288. package/src/session/session-host.test.ts +0 -29
  289. package/src/session/session-host.ts +0 -242
  290. package/src/session/session-manager.ts +0 -69
  291. package/src/session/session-manifest.ts +0 -29
  292. package/src/session/session-service.team-persistence.test.ts +0 -48
  293. package/src/session/session-service.ts +0 -673
  294. package/src/session/session-team-coordination.ts +0 -229
  295. package/src/session/session-telemetry.ts +0 -95
  296. package/src/session/sqlite-rpc-session-backend.ts +0 -303
  297. package/src/session/unified-session-persistence-service.test.ts +0 -85
  298. package/src/session/unified-session-persistence-service.ts +0 -996
  299. package/src/session/utils/helpers.ts +0 -139
  300. package/src/session/utils/types.ts +0 -57
  301. package/src/session/utils/usage.ts +0 -32
  302. package/src/session/workspace-manager.ts +0 -98
  303. package/src/session/workspace-manifest.ts +0 -100
  304. package/src/storage/artifact-store.ts +0 -1
  305. package/src/storage/file-team-store.ts +0 -257
  306. package/src/storage/index.ts +0 -11
  307. package/src/storage/provider-settings-legacy-migration.test.ts +0 -307
  308. package/src/storage/provider-settings-legacy-migration.ts +0 -689
  309. package/src/storage/provider-settings-manager.test.ts +0 -145
  310. package/src/storage/provider-settings-manager.ts +0 -150
  311. package/src/storage/session-store.ts +0 -1
  312. package/src/storage/sqlite-session-store.ts +0 -275
  313. package/src/storage/sqlite-team-store.ts +0 -454
  314. package/src/storage/team-store.ts +0 -40
  315. package/src/team/index.ts +0 -4
  316. package/src/team/projections.ts +0 -285
  317. package/src/telemetry/ITelemetryAdapter.ts +0 -94
  318. package/src/telemetry/LoggerTelemetryAdapter.test.ts +0 -42
  319. package/src/telemetry/LoggerTelemetryAdapter.ts +0 -114
  320. package/src/telemetry/OpenTelemetryAdapter.test.ts +0 -157
  321. package/src/telemetry/OpenTelemetryAdapter.ts +0 -348
  322. package/src/telemetry/OpenTelemetryProvider.test.ts +0 -113
  323. package/src/telemetry/OpenTelemetryProvider.ts +0 -322
  324. package/src/telemetry/TelemetryService.test.ts +0 -134
  325. package/src/telemetry/TelemetryService.ts +0 -141
  326. package/src/telemetry/core-events.ts +0 -344
  327. package/src/telemetry/opentelemetry.ts +0 -20
  328. package/src/tools/constants.ts +0 -35
  329. package/src/tools/definitions.test.ts +0 -658
  330. package/src/tools/definitions.ts +0 -726
  331. package/src/tools/executors/apply-patch-parser.ts +0 -520
  332. package/src/tools/executors/apply-patch.ts +0 -359
  333. package/src/tools/executors/bash.ts +0 -205
  334. package/src/tools/executors/editor.test.ts +0 -35
  335. package/src/tools/executors/editor.ts +0 -219
  336. package/src/tools/executors/file-read.test.ts +0 -49
  337. package/src/tools/executors/file-read.ts +0 -110
  338. package/src/tools/executors/index.ts +0 -75
  339. package/src/tools/executors/search.ts +0 -278
  340. package/src/tools/executors/web-fetch.ts +0 -259
  341. package/src/tools/index.ts +0 -168
  342. package/src/tools/model-tool-routing.test.ts +0 -86
  343. package/src/tools/model-tool-routing.ts +0 -132
  344. package/src/tools/presets.test.ts +0 -62
  345. package/src/tools/presets.ts +0 -168
  346. package/src/tools/schemas.ts +0 -284
  347. package/src/tools/types.ts +0 -328
  348. package/src/types/common.ts +0 -14
  349. package/src/types/config.ts +0 -84
  350. package/src/types/events.ts +0 -74
  351. package/src/types/index.ts +0 -24
  352. package/src/types/provider-settings.ts +0 -43
  353. package/src/types/sessions.ts +0 -16
  354. package/src/types/storage.ts +0 -64
  355. package/src/types/workspace.ts +0 -7
  356. package/src/types.ts +0 -128
@@ -1,62 +0,0 @@
1
- import { describe, expect, it, vi } from "vitest";
2
- import {
3
- type ClineAccountOperations,
4
- executeRpcClineAccountAction,
5
- RpcClineAccountService,
6
- } from "./rpc";
7
-
8
- describe("executeRpcClineAccountAction", () => {
9
- it("dispatches fetchMe", async () => {
10
- const service: ClineAccountOperations = {
11
- fetchMe: vi.fn(async () => ({
12
- id: "u1",
13
- email: "user1@example.com",
14
- displayName: "User 1",
15
- photoUrl: "",
16
- createdAt: "2025-01-01T00:00:00Z",
17
- updatedAt: "2025-01-01T00:00:00Z",
18
- organizations: [],
19
- })),
20
- fetchBalance: vi.fn(async () => ({ balance: 1, userId: "u1" })),
21
- fetchUsageTransactions: vi.fn(async () => []),
22
- fetchPaymentTransactions: vi.fn(async () => []),
23
- fetchUserOrganizations: vi.fn(async () => []),
24
- fetchOrganizationBalance: vi.fn(async () => ({
25
- balance: 1,
26
- organizationId: "org-1",
27
- })),
28
- fetchOrganizationUsageTransactions: vi.fn(async () => []),
29
- switchAccount: vi.fn(async () => {}),
30
- };
31
-
32
- const result = await executeRpcClineAccountAction(
33
- { action: "clineAccount", operation: "fetchMe" },
34
- service,
35
- );
36
- expect(service.fetchMe).toHaveBeenCalledTimes(1);
37
- expect(result).toMatchObject({ id: "u1" });
38
- });
39
- });
40
-
41
- describe("RpcClineAccountService", () => {
42
- it("sends provider action payload and parses response", async () => {
43
- const runProviderAction = vi.fn(async (request: unknown) => {
44
- const parsed = request as {
45
- action: string;
46
- operation: string;
47
- };
48
- expect(parsed).toEqual({
49
- action: "clineAccount",
50
- operation: "fetchMe",
51
- });
52
- return {
53
- result: { id: "u2", email: "u2@example.com" },
54
- };
55
- });
56
- const service = new RpcClineAccountService({ runProviderAction });
57
-
58
- const me = await service.fetchMe();
59
- expect(runProviderAction).toHaveBeenCalledTimes(1);
60
- expect(me).toEqual({ id: "u2", email: "u2@example.com" });
61
- });
62
- });
@@ -1,172 +0,0 @@
1
- import type {
2
- RpcClineAccountActionRequest,
3
- RpcProviderActionRequest,
4
- } from "@clinebot/shared";
5
- import type {
6
- ClineAccountBalance,
7
- ClineAccountOrganization,
8
- ClineAccountOrganizationBalance,
9
- ClineAccountOrganizationUsageTransaction,
10
- ClineAccountPaymentTransaction,
11
- ClineAccountUsageTransaction,
12
- ClineAccountUser,
13
- } from "./types";
14
-
15
- export interface ClineAccountOperations {
16
- fetchMe(): Promise<ClineAccountUser>;
17
- fetchBalance(userId?: string): Promise<ClineAccountBalance>;
18
- fetchUsageTransactions(
19
- userId?: string,
20
- ): Promise<ClineAccountUsageTransaction[]>;
21
- fetchPaymentTransactions(
22
- userId?: string,
23
- ): Promise<ClineAccountPaymentTransaction[]>;
24
- fetchUserOrganizations(): Promise<ClineAccountOrganization[]>;
25
- fetchOrganizationBalance(
26
- organizationId: string,
27
- ): Promise<ClineAccountOrganizationBalance>;
28
- fetchOrganizationUsageTransactions(input: {
29
- organizationId: string;
30
- memberId?: string;
31
- }): Promise<ClineAccountOrganizationUsageTransaction[]>;
32
- switchAccount(organizationId?: string | null): Promise<void>;
33
- }
34
-
35
- export function isRpcClineAccountActionRequest(
36
- request: RpcProviderActionRequest,
37
- ): request is RpcClineAccountActionRequest {
38
- return request.action === "clineAccount";
39
- }
40
-
41
- export async function executeRpcClineAccountAction(
42
- request: RpcClineAccountActionRequest,
43
- service: ClineAccountOperations,
44
- ): Promise<unknown> {
45
- switch (request.operation) {
46
- case "fetchMe":
47
- return service.fetchMe();
48
- case "fetchBalance":
49
- return service.fetchBalance(request.userId);
50
- case "fetchUsageTransactions":
51
- return service.fetchUsageTransactions(request.userId);
52
- case "fetchPaymentTransactions":
53
- return service.fetchPaymentTransactions(request.userId);
54
- case "fetchUserOrganizations":
55
- return service.fetchUserOrganizations();
56
- case "fetchOrganizationBalance":
57
- return service.fetchOrganizationBalance(request.organizationId);
58
- case "fetchOrganizationUsageTransactions":
59
- return service.fetchOrganizationUsageTransactions({
60
- organizationId: request.organizationId,
61
- memberId: request.memberId,
62
- });
63
- case "switchAccount":
64
- await service.switchAccount(request.organizationId);
65
- return { updated: true };
66
- default: {
67
- const exhaustive: never = request;
68
- throw new Error(
69
- `Unsupported Cline account operation: ${String(exhaustive)}`,
70
- );
71
- }
72
- }
73
- }
74
-
75
- export interface RpcProviderActionExecutor {
76
- runProviderAction(request: RpcProviderActionRequest): Promise<{
77
- result: unknown;
78
- }>;
79
- }
80
-
81
- export class RpcClineAccountService implements ClineAccountOperations {
82
- private readonly executor: RpcProviderActionExecutor;
83
-
84
- constructor(executor: RpcProviderActionExecutor) {
85
- this.executor = executor;
86
- }
87
-
88
- public async fetchMe(): Promise<ClineAccountUser> {
89
- return this.request<ClineAccountUser>({
90
- action: "clineAccount",
91
- operation: "fetchMe",
92
- });
93
- }
94
-
95
- public async fetchBalance(userId?: string): Promise<ClineAccountBalance> {
96
- return this.request<ClineAccountBalance>({
97
- action: "clineAccount",
98
- operation: "fetchBalance",
99
- ...(userId?.trim() ? { userId: userId.trim() } : {}),
100
- });
101
- }
102
-
103
- public async fetchUsageTransactions(
104
- userId?: string,
105
- ): Promise<ClineAccountUsageTransaction[]> {
106
- return this.request<ClineAccountUsageTransaction[]>({
107
- action: "clineAccount",
108
- operation: "fetchUsageTransactions",
109
- ...(userId?.trim() ? { userId: userId.trim() } : {}),
110
- });
111
- }
112
-
113
- public async fetchPaymentTransactions(
114
- userId?: string,
115
- ): Promise<ClineAccountPaymentTransaction[]> {
116
- return this.request<ClineAccountPaymentTransaction[]>({
117
- action: "clineAccount",
118
- operation: "fetchPaymentTransactions",
119
- ...(userId?.trim() ? { userId: userId.trim() } : {}),
120
- });
121
- }
122
-
123
- public async fetchUserOrganizations(): Promise<ClineAccountOrganization[]> {
124
- return this.request<ClineAccountOrganization[]>({
125
- action: "clineAccount",
126
- operation: "fetchUserOrganizations",
127
- });
128
- }
129
-
130
- public async fetchOrganizationBalance(
131
- organizationId: string,
132
- ): Promise<ClineAccountOrganizationBalance> {
133
- const orgId = organizationId.trim();
134
- if (!orgId) {
135
- throw new Error("organizationId is required");
136
- }
137
- return this.request<ClineAccountOrganizationBalance>({
138
- action: "clineAccount",
139
- operation: "fetchOrganizationBalance",
140
- organizationId: orgId,
141
- });
142
- }
143
-
144
- public async fetchOrganizationUsageTransactions(input: {
145
- organizationId: string;
146
- memberId?: string;
147
- }): Promise<ClineAccountOrganizationUsageTransaction[]> {
148
- const orgId = input.organizationId.trim();
149
- if (!orgId) {
150
- throw new Error("organizationId is required");
151
- }
152
- return this.request<ClineAccountOrganizationUsageTransaction[]>({
153
- action: "clineAccount",
154
- operation: "fetchOrganizationUsageTransactions",
155
- organizationId: orgId,
156
- ...(input.memberId?.trim() ? { memberId: input.memberId.trim() } : {}),
157
- });
158
- }
159
-
160
- public async switchAccount(organizationId?: string | null): Promise<void> {
161
- await this.request<{ updated: boolean }>({
162
- action: "clineAccount",
163
- operation: "switchAccount",
164
- organizationId: organizationId?.trim() || null,
165
- });
166
- }
167
-
168
- private async request<T>(request: RpcClineAccountActionRequest): Promise<T> {
169
- const response = await this.executor.runProviderAction(request);
170
- return response.result as T;
171
- }
172
- }
@@ -1,98 +0,0 @@
1
- export interface ClineAccountOrganization {
2
- active: boolean;
3
- memberId: string;
4
- name: string;
5
- organizationId: string;
6
- roles: Array<"admin" | "member" | "owner">;
7
- }
8
-
9
- export interface ClineAccountUser {
10
- id: string;
11
- email: string;
12
- displayName: string;
13
- photoUrl: string;
14
- createdAt: string;
15
- updatedAt: string;
16
- organizations: ClineAccountOrganization[];
17
- }
18
-
19
- export interface UserRemoteConfigResponse {
20
- organizationId: string;
21
- value: string;
22
- enabled: boolean;
23
- }
24
-
25
- export interface ClineAccountBalance {
26
- balance: number;
27
- userId: string;
28
- }
29
-
30
- export interface ClineAccountUsageTransaction {
31
- aiInferenceProviderName: string;
32
- aiModelName: string;
33
- aiModelTypeName: string;
34
- completionTokens: number;
35
- costUsd: number;
36
- createdAt: string;
37
- creditsUsed: number;
38
- generationId: string;
39
- id: string;
40
- metadata: {
41
- additionalProp1: string;
42
- additionalProp2: string;
43
- additionalProp3: string;
44
- };
45
- operation?: string;
46
- organizationId: string;
47
- promptTokens: number;
48
- totalTokens: number;
49
- userId: string;
50
- }
51
-
52
- export interface ClineAccountPaymentTransaction {
53
- paidAt: string;
54
- creatorId: string;
55
- amountCents: number;
56
- credits: number;
57
- }
58
-
59
- export interface ClineOrganization {
60
- createdAt: string;
61
- defaultRemoteConfig?: string;
62
- deletedAt?: string;
63
- externalOrganizationId?: string;
64
- id: string;
65
- memberCount?: number;
66
- name: string;
67
- remoteConfigEnabled: boolean;
68
- updatedAt: string;
69
- }
70
-
71
- export interface ClineAccountOrganizationBalance {
72
- balance: number;
73
- organizationId: string;
74
- }
75
-
76
- export interface ClineAccountOrganizationUsageTransaction {
77
- aiInferenceProviderName: string;
78
- aiModelName: string;
79
- aiModelTypeName: string;
80
- completionTokens: number;
81
- costUsd: number;
82
- createdAt: string;
83
- creditsUsed: number;
84
- generationId: string;
85
- id: string;
86
- memberDisplayName: string;
87
- memberEmail: string;
88
- metadata: {
89
- additionalProp1: string;
90
- additionalProp2: string;
91
- additionalProp3: string;
92
- };
93
- operation?: string;
94
- organizationId: string;
95
- promptTokens: number;
96
- totalTokens: number;
97
- userId: string;
98
- }
@@ -1,236 +0,0 @@
1
- import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
2
- import { tmpdir } from "node:os";
3
- import { join } from "node:path";
4
- import type { Tool, ToolContext } from "@clinebot/agents";
5
- import { afterEach, describe, expect, it } from "vitest";
6
- import {
7
- AGENT_CONFIG_DIRECTORY_NAME,
8
- createAgentConfigDefinition,
9
- parseAgentConfigFromYaml,
10
- parsePartialAgentConfigFromYaml,
11
- readAgentConfigsFromDisk,
12
- resolveAgentConfigSearchPaths,
13
- resolveAgentsConfigDirPath,
14
- resolveAgentTools,
15
- resolveDocumentsAgentConfigDirectoryPath,
16
- toPartialAgentConfig,
17
- } from "./agent-config-loader";
18
-
19
- function createMockTool(name: string): Tool {
20
- return {
21
- name,
22
- description: `${name} tool`,
23
- inputSchema: {
24
- type: "object",
25
- properties: {},
26
- },
27
- execute: async (_input: unknown, _context: ToolContext) => null,
28
- };
29
- }
30
-
31
- describe("agent config YAML loader", () => {
32
- const envSnapshot = {
33
- CLINE_DATA_DIR: process.env.CLINE_DATA_DIR,
34
- };
35
- afterEach(() => {
36
- process.env.CLINE_DATA_DIR = envSnapshot.CLINE_DATA_DIR;
37
- });
38
-
39
- it("resolves default agents settings directory from CLINE_DATA_DIR", () => {
40
- process.env.CLINE_DATA_DIR = "/tmp/cline-data";
41
- expect(resolveAgentsConfigDirPath()).toBe(
42
- join("/tmp/cline-data", "settings", AGENT_CONFIG_DIRECTORY_NAME),
43
- );
44
- });
45
-
46
- it("includes documents and settings search paths", () => {
47
- process.env.CLINE_DATA_DIR = "/tmp/cline-data";
48
- expect(resolveAgentConfigSearchPaths()).toEqual([
49
- resolveDocumentsAgentConfigDirectoryPath(),
50
- join("/tmp/cline-data", "settings", AGENT_CONFIG_DIRECTORY_NAME),
51
- ]);
52
- });
53
-
54
- it("builds a reusable unified watcher definition with expected defaults", () => {
55
- process.env.CLINE_DATA_DIR = "/tmp/cline-data";
56
- const definition = createAgentConfigDefinition();
57
- expect(definition.type).toBe("agent");
58
- expect(definition.directories).toEqual([
59
- resolveDocumentsAgentConfigDirectoryPath(),
60
- join("/tmp/cline-data", "settings", AGENT_CONFIG_DIRECTORY_NAME),
61
- ]);
62
- expect(definition.includeFile?.("agent.yaml", "/tmp/agent.yaml")).toBe(
63
- true,
64
- );
65
- expect(definition.includeFile?.("agent.md", "/tmp/agent.md")).toBe(false);
66
- });
67
-
68
- it("parses yaml frontmatter and prompt body", () => {
69
- const content = `---
70
- name: Researcher
71
- description: Focus on repository analysis
72
- modelId: claude-sonnet-4-6
73
- tools:
74
- - read_files
75
- - search_codebase
76
- skills:
77
- - context-gathering
78
- ---
79
- You are a focused codebase researcher.`;
80
-
81
- const parsed = parseAgentConfigFromYaml(content);
82
-
83
- expect(parsed).toEqual({
84
- name: "Researcher",
85
- description: "Focus on repository analysis",
86
- modelId: "claude-sonnet-4-6",
87
- tools: ["read_files", "search_codebase"],
88
- skills: ["context-gathering"],
89
- systemPrompt: "You are a focused codebase researcher.",
90
- });
91
- });
92
-
93
- it("supports comma-separated tool and skill values", () => {
94
- const parsed = parseAgentConfigFromYaml(`---
95
- name: Reviewer
96
- description: Reviews diffs
97
- tools: read_files,search_codebase,read_files
98
- skills: quality, quality,architecture
99
- ---
100
- Review every patch for regressions.`);
101
-
102
- expect(parsed.tools).toEqual(["read_files", "search_codebase"]);
103
- expect(parsed.skills).toEqual(["quality", "architecture"]);
104
- });
105
-
106
- it("throws when frontmatter is missing", () => {
107
- expect(() => parseAgentConfigFromYaml("No frontmatter")).toThrow(
108
- "Missing YAML frontmatter block in agent config file.",
109
- );
110
- });
111
-
112
- it("throws for unknown tools", () => {
113
- expect(() =>
114
- parseAgentConfigFromYaml(`---
115
- name: UnknownTool
116
- description: test
117
- tools: invalid_tool
118
- ---
119
- prompt`),
120
- ).toThrow("Unknown tool 'invalid_tool'.");
121
- });
122
-
123
- it("resolves configured tool names from available tools", () => {
124
- const readFiles = createMockTool("read_files");
125
- const searchCodebase = createMockTool("search_codebase");
126
-
127
- expect(
128
- resolveAgentTools(
129
- ["read_files", "search_codebase"],
130
- [searchCodebase, readFiles],
131
- ),
132
- ).toEqual([readFiles, searchCodebase]);
133
- });
134
-
135
- it("converts parsed config to partial AgentConfig", () => {
136
- const readFiles = createMockTool("read_files");
137
- const config = parseAgentConfigFromYaml(`---
138
- name: Reader
139
- description: Reads files
140
- modelId: claude-sonnet-4-6
141
- tools: read_files
142
- skills: commit, review
143
- ---
144
- Be precise.`);
145
-
146
- const partial = toPartialAgentConfig(config, {
147
- availableTools: [readFiles],
148
- });
149
-
150
- expect(partial.modelId).toBe("claude-sonnet-4-6");
151
- expect(partial.systemPrompt).toBe("Be precise.");
152
- expect(partial.tools).toEqual([readFiles]);
153
- expect(partial.skills).toEqual(["commit", "review"]);
154
- });
155
-
156
- it("throws when tool overrides are configured without available tools", () => {
157
- expect(() =>
158
- parsePartialAgentConfigFromYaml(`---
159
- name: Reader
160
- description: Reads files
161
- tools: read_files
162
- ---
163
- Be precise.`),
164
- ).toThrow(
165
- "Configured tools cannot be converted into AgentConfig.tools without availableTools.",
166
- );
167
- });
168
-
169
- it("reads agent configs from ~/.cline/data/settings/agents-compatible directory", async () => {
170
- const tempRoot = await mkdtemp(join(tmpdir(), "core-agent-config-loader-"));
171
- const agentsDir = join(tempRoot, "settings", AGENT_CONFIG_DIRECTORY_NAME);
172
- await mkdir(agentsDir, { recursive: true });
173
- try {
174
- await writeFile(
175
- join(agentsDir, "reviewer.yaml"),
176
- `---
177
- name: Reviewer
178
- description: Reviews patches
179
- tools: read_files
180
- ---
181
- Review code for regressions.`,
182
- );
183
- await writeFile(
184
- join(agentsDir, "invalid.yaml"),
185
- `---
186
- name:
187
- ---
188
- `,
189
- );
190
-
191
- const loaded = await readAgentConfigsFromDisk(agentsDir);
192
- expect([...loaded.keys()]).toEqual(["reviewer"]);
193
- expect(loaded.get("reviewer")?.systemPrompt).toBe(
194
- "Review code for regressions.",
195
- );
196
- } finally {
197
- await rm(tempRoot, { recursive: true, force: true });
198
- }
199
- });
200
-
201
- it("reads from both documents and settings directories", async () => {
202
- const tempRoot = await mkdtemp(join(tmpdir(), "core-agent-config-loader-"));
203
- const documentsDir = join(tempRoot, "Documents", "Cline", "Agents");
204
- const settingsDir = join(tempRoot, "settings", AGENT_CONFIG_DIRECTORY_NAME);
205
- await mkdir(documentsDir, { recursive: true });
206
- await mkdir(settingsDir, { recursive: true });
207
- try {
208
- await writeFile(
209
- join(documentsDir, "legacy.yaml"),
210
- `---
211
- name: LegacyAgent
212
- description: legacy
213
- ---
214
- legacy prompt`,
215
- );
216
- await writeFile(
217
- join(settingsDir, "new.yaml"),
218
- `---
219
- name: NewAgent
220
- description: new
221
- ---
222
- new prompt`,
223
- );
224
-
225
- const loaded = await readAgentConfigsFromDisk([
226
- documentsDir,
227
- settingsDir,
228
- ]);
229
- expect([...loaded.keys()].sort()).toEqual(["legacyagent", "newagent"]);
230
- expect(loaded.get("legacyagent")?.systemPrompt).toBe("legacy prompt");
231
- expect(loaded.get("newagent")?.systemPrompt).toBe("new prompt");
232
- } finally {
233
- await rm(tempRoot, { recursive: true, force: true });
234
- }
235
- });
236
- });
@@ -1,108 +0,0 @@
1
- import {
2
- AGENT_CONFIG_DIRECTORY_NAME,
3
- resolveAgentConfigSearchPaths as resolveAgentConfigSearchPathsFromShared,
4
- resolveAgentsConfigDirPath as resolveAgentsConfigDirPathFromShared,
5
- resolveDocumentsAgentConfigDirectoryPath,
6
- } from "@clinebot/shared/storage";
7
- import {
8
- type AgentYamlConfig,
9
- isAgentConfigYamlFile,
10
- normalizeAgentConfigName,
11
- parseAgentConfigFromYaml,
12
- } from "./agent-config-parser";
13
- import {
14
- type UnifiedConfigDefinition,
15
- UnifiedConfigFileWatcher,
16
- type UnifiedConfigWatcherEvent,
17
- } from "./unified-config-file-watcher";
18
-
19
- export type {
20
- AgentYamlConfig,
21
- BuildAgentConfigOverridesOptions,
22
- ParseYamlFrontmatterResult,
23
- PartialAgentConfigOverrides,
24
- } from "./agent-config-parser";
25
- export {
26
- parseAgentConfigFromYaml,
27
- parsePartialAgentConfigFromYaml,
28
- resolveAgentTools,
29
- toPartialAgentConfig,
30
- } from "./agent-config-parser";
31
-
32
- export type AgentConfigWatcher = UnifiedConfigFileWatcher<
33
- "agent",
34
- AgentYamlConfig
35
- >;
36
- export type AgentConfigWatcherEvent = UnifiedConfigWatcherEvent<
37
- "agent",
38
- AgentYamlConfig
39
- >;
40
-
41
- export {
42
- AGENT_CONFIG_DIRECTORY_NAME,
43
- resolveDocumentsAgentConfigDirectoryPath,
44
- };
45
-
46
- export function resolveAgentsConfigDirPath(): string {
47
- return resolveAgentsConfigDirPathFromShared();
48
- }
49
-
50
- export function resolveAgentConfigSearchPaths(): string[] {
51
- // Documents path first, then settings path so settings location takes precedence.
52
- return resolveAgentConfigSearchPathsFromShared();
53
- }
54
-
55
- export interface CreateAgentConfigWatcherOptions {
56
- directoryPathOrPaths?: string | ReadonlyArray<string>;
57
- debounceMs?: number;
58
- emitParseErrors?: boolean;
59
- }
60
-
61
- function toDirectoryPaths(
62
- directoryPathOrPaths?: string | ReadonlyArray<string>,
63
- ): string[] {
64
- if (Array.isArray(directoryPathOrPaths)) {
65
- return [...directoryPathOrPaths];
66
- }
67
- if (typeof directoryPathOrPaths === "string") {
68
- return [directoryPathOrPaths];
69
- }
70
- return resolveAgentConfigSearchPaths();
71
- }
72
-
73
- export function createAgentConfigDefinition(
74
- directoryPathOrPaths?: string | ReadonlyArray<string>,
75
- ): UnifiedConfigDefinition<"agent", AgentYamlConfig> {
76
- return {
77
- type: "agent",
78
- directories: toDirectoryPaths(directoryPathOrPaths),
79
- includeFile: (fileName) => isAgentConfigYamlFile(fileName),
80
- parseFile: (context) => parseAgentConfigFromYaml(context.content),
81
- resolveId: (config) => normalizeAgentConfigName(config.name),
82
- };
83
- }
84
-
85
- export function createAgentConfigWatcher(
86
- options?: CreateAgentConfigWatcherOptions,
87
- ): AgentConfigWatcher {
88
- return new UnifiedConfigFileWatcher(
89
- [createAgentConfigDefinition(options?.directoryPathOrPaths)],
90
- {
91
- debounceMs: options?.debounceMs,
92
- emitParseErrors: options?.emitParseErrors,
93
- },
94
- );
95
- }
96
-
97
- export async function readAgentConfigsFromDisk(
98
- directoryPathOrPaths?: string | ReadonlyArray<string>,
99
- ): Promise<Map<string, AgentYamlConfig>> {
100
- const watcher = new UnifiedConfigFileWatcher([
101
- createAgentConfigDefinition(directoryPathOrPaths),
102
- ]);
103
- await watcher.refreshAll();
104
- const snapshot = watcher.getSnapshot("agent");
105
- return new Map(
106
- [...snapshot.entries()].map(([id, record]) => [id, record.item]),
107
- );
108
- }