@clinebot/core 0.0.28 → 0.0.30

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 (340) hide show
  1. package/README.md +7 -0
  2. package/dist/ClineCore.d.ts +28 -2
  3. package/dist/ClineCore.d.ts.map +1 -1
  4. package/dist/account/cline-account-service.d.ts +1 -1
  5. package/dist/account/cline-account-service.d.ts.map +1 -1
  6. package/dist/account/index.d.ts +1 -1
  7. package/dist/account/index.d.ts.map +1 -1
  8. package/dist/account/types.d.ts +5 -0
  9. package/dist/account/types.d.ts.map +1 -1
  10. package/dist/auth/bounded-ttl-cache.d.ts +14 -0
  11. package/dist/auth/bounded-ttl-cache.d.ts.map +1 -0
  12. package/dist/auth/cline.d.ts +27 -2
  13. package/dist/auth/cline.d.ts.map +1 -1
  14. package/dist/auth/oca.d.ts.map +1 -1
  15. package/dist/chat/chat-schema.d.ts +11 -11
  16. package/dist/extensions/config/agent-config-loader.d.ts.map +1 -0
  17. package/dist/{agents → extensions/config}/agent-config-parser.d.ts +2 -2
  18. package/dist/extensions/config/agent-config-parser.d.ts.map +1 -0
  19. package/dist/{agents → extensions/config}/hooks-config-loader.d.ts +1 -1
  20. package/dist/extensions/config/hooks-config-loader.d.ts.map +1 -0
  21. package/dist/{agents → extensions/config}/index.d.ts +2 -4
  22. package/dist/extensions/config/index.d.ts.map +1 -0
  23. package/dist/{runtime/commands.d.ts → extensions/config/runtime-commands.d.ts} +2 -3
  24. package/dist/extensions/config/runtime-commands.d.ts.map +1 -0
  25. package/dist/extensions/config/unified-config-file-watcher.d.ts.map +1 -0
  26. package/dist/extensions/config/user-instruction-config-loader.d.ts.map +1 -0
  27. package/dist/extensions/context/agentic-compaction.d.ts +13 -0
  28. package/dist/extensions/context/agentic-compaction.d.ts.map +1 -0
  29. package/dist/extensions/context/basic-compaction.d.ts +9 -0
  30. package/dist/extensions/context/basic-compaction.d.ts.map +1 -0
  31. package/dist/extensions/context/compaction-shared.d.ts +60 -0
  32. package/dist/extensions/context/compaction-shared.d.ts.map +1 -0
  33. package/dist/extensions/context/compaction.d.ts +20 -0
  34. package/dist/extensions/context/compaction.d.ts.map +1 -0
  35. package/dist/extensions/index.d.ts +5 -0
  36. package/dist/extensions/index.d.ts.map +1 -0
  37. package/dist/extensions/mcp/client.d.ts +3 -0
  38. package/dist/extensions/mcp/client.d.ts.map +1 -0
  39. package/dist/extensions/mcp/config-loader.d.ts.map +1 -0
  40. package/dist/extensions/mcp/index.d.ts +9 -0
  41. package/dist/extensions/mcp/index.d.ts.map +1 -0
  42. package/dist/{mcp → extensions/mcp}/manager.d.ts +1 -2
  43. package/dist/extensions/mcp/manager.d.ts.map +1 -0
  44. package/dist/extensions/mcp/name-transform.d.ts +3 -0
  45. package/dist/extensions/mcp/name-transform.d.ts.map +1 -0
  46. package/dist/extensions/mcp/policies.d.ts +15 -0
  47. package/dist/extensions/mcp/policies.d.ts.map +1 -0
  48. package/dist/extensions/mcp/tools.d.ts +4 -0
  49. package/dist/extensions/mcp/tools.d.ts.map +1 -0
  50. package/dist/{mcp → extensions/mcp}/types.d.ts +29 -1
  51. package/dist/extensions/mcp/types.d.ts.map +1 -0
  52. package/dist/{agents → extensions/plugin}/plugin-config-loader.d.ts +1 -1
  53. package/dist/extensions/plugin/plugin-config-loader.d.ts.map +1 -0
  54. package/dist/{agents → extensions/plugin}/plugin-loader.d.ts +1 -1
  55. package/dist/extensions/plugin/plugin-loader.d.ts.map +1 -0
  56. package/dist/extensions/plugin/plugin-module-import.d.ts +5 -0
  57. package/dist/extensions/plugin/plugin-module-import.d.ts.map +1 -0
  58. package/dist/{agents → extensions/plugin}/plugin-sandbox.d.ts +1 -1
  59. package/dist/extensions/plugin/plugin-sandbox.d.ts.map +1 -0
  60. package/dist/extensions/plugin-sandbox-bootstrap.js +485 -0
  61. package/dist/hooks/index.d.ts +4 -0
  62. package/dist/hooks/index.d.ts.map +1 -0
  63. package/dist/hooks/persistent.d.ts +64 -0
  64. package/dist/hooks/persistent.d.ts.map +1 -0
  65. package/dist/hooks/subprocess-runner.d.ts +22 -0
  66. package/dist/hooks/subprocess-runner.d.ts.map +1 -0
  67. package/dist/hooks/subprocess.d.ts +189 -0
  68. package/dist/hooks/subprocess.d.ts.map +1 -0
  69. package/dist/index.d.ts +22 -25
  70. package/dist/index.d.ts.map +1 -1
  71. package/dist/index.js +560 -447
  72. package/dist/prompt/default-system.d.ts +2 -0
  73. package/dist/prompt/default-system.d.ts.map +1 -0
  74. package/dist/providers/local-provider-service.d.ts +1 -1
  75. package/dist/providers/local-provider-service.d.ts.map +1 -1
  76. package/dist/runtime/checkpoint-hooks.d.ts +21 -0
  77. package/dist/runtime/checkpoint-hooks.d.ts.map +1 -0
  78. package/dist/runtime/hook-file-hooks.d.ts +1 -1
  79. package/dist/runtime/hook-file-hooks.d.ts.map +1 -1
  80. package/dist/runtime/rules.d.ts +1 -1
  81. package/dist/runtime/rules.d.ts.map +1 -1
  82. package/dist/runtime/runtime-builder.d.ts +1 -1
  83. package/dist/runtime/runtime-builder.d.ts.map +1 -1
  84. package/dist/runtime/session-runtime.d.ts +25 -5
  85. package/dist/runtime/session-runtime.d.ts.map +1 -1
  86. package/dist/runtime/subprocess-sandbox.d.ts.map +1 -0
  87. package/dist/runtime/team-runtime-registry.d.ts +1 -1
  88. package/dist/runtime/team-runtime-registry.d.ts.map +1 -1
  89. package/dist/runtime/tool-approval.d.ts +1 -1
  90. package/dist/session/default-session-manager.d.ts +9 -3
  91. package/dist/session/default-session-manager.d.ts.map +1 -1
  92. package/dist/session/file-session-service.d.ts +1 -1
  93. package/dist/session/file-session-service.d.ts.map +1 -1
  94. package/dist/session/{unified-session-persistence-service.d.ts → persistence-service.d.ts} +11 -42
  95. package/dist/session/persistence-service.d.ts.map +1 -0
  96. package/dist/session/rpc-session-service.d.ts +1 -1
  97. package/dist/session/rpc-session-service.d.ts.map +1 -1
  98. package/dist/session/session-agent-events.d.ts +1 -1
  99. package/dist/session/session-artifacts.d.ts.map +1 -1
  100. package/dist/session/session-config-builder.d.ts.map +1 -1
  101. package/dist/session/session-graph.d.ts +1 -1
  102. package/dist/session/session-graph.d.ts.map +1 -1
  103. package/dist/session/session-host.d.ts.map +1 -1
  104. package/dist/session/session-manager.d.ts +6 -5
  105. package/dist/session/session-manager.d.ts.map +1 -1
  106. package/dist/session/session-manifest.d.ts +1 -1
  107. package/dist/session/session-service.d.ts +3 -2
  108. package/dist/session/session-service.d.ts.map +1 -1
  109. package/dist/session/session-team-coordination.d.ts +2 -1
  110. package/dist/session/session-team-coordination.d.ts.map +1 -1
  111. package/dist/session/utils/helpers.d.ts +51 -3
  112. package/dist/session/utils/helpers.d.ts.map +1 -1
  113. package/dist/session/utils/types.d.ts +41 -7
  114. package/dist/session/utils/types.d.ts.map +1 -1
  115. package/dist/session/workspace-manager.d.ts +1 -2
  116. package/dist/session/workspace-manager.d.ts.map +1 -1
  117. package/dist/session/workspace-manifest.d.ts +1 -22
  118. package/dist/session/workspace-manifest.d.ts.map +1 -1
  119. package/dist/storage/file-team-store.d.ts +2 -1
  120. package/dist/storage/file-team-store.d.ts.map +1 -1
  121. package/dist/storage/sqlite-team-store.d.ts +4 -1
  122. package/dist/storage/sqlite-team-store.d.ts.map +1 -1
  123. package/dist/storage/team-store.d.ts.map +1 -1
  124. package/dist/team/delegated-agent.d.ts +44 -0
  125. package/dist/team/delegated-agent.d.ts.map +1 -0
  126. package/dist/team/index.d.ts +1 -0
  127. package/dist/team/index.d.ts.map +1 -1
  128. package/dist/team/multi-agent.d.ts +229 -0
  129. package/dist/team/multi-agent.d.ts.map +1 -0
  130. package/dist/team/projections.d.ts +2 -2
  131. package/dist/team/projections.d.ts.map +1 -1
  132. package/dist/team/runtime.d.ts +5 -0
  133. package/dist/team/runtime.d.ts.map +1 -0
  134. package/dist/team/spawn-agent-tool.d.ts +85 -0
  135. package/dist/team/spawn-agent-tool.d.ts.map +1 -0
  136. package/dist/team/subagent-prompts.d.ts +4 -0
  137. package/dist/team/subagent-prompts.d.ts.map +1 -0
  138. package/dist/team/team-tools.d.ts +35 -0
  139. package/dist/team/team-tools.d.ts.map +1 -0
  140. package/dist/telemetry/OpenTelemetryProvider.d.ts +11 -1
  141. package/dist/telemetry/OpenTelemetryProvider.d.ts.map +1 -1
  142. package/dist/telemetry/{LoggerTelemetryAdapter.d.ts → TelemetryLoggerSink.d.ts} +10 -4
  143. package/dist/telemetry/TelemetryLoggerSink.d.ts.map +1 -0
  144. package/dist/telemetry/TelemetryService.d.ts.map +1 -1
  145. package/dist/telemetry/index.js +15 -28
  146. package/dist/tools/definitions.d.ts +4 -3
  147. package/dist/tools/definitions.d.ts.map +1 -1
  148. package/dist/tools/index.d.ts +5 -5
  149. package/dist/tools/index.d.ts.map +1 -1
  150. package/dist/tools/model-tool-routing.d.ts.map +1 -1
  151. package/dist/tools/presets.d.ts +26 -0
  152. package/dist/tools/presets.d.ts.map +1 -1
  153. package/dist/tools/schemas.d.ts +8 -0
  154. package/dist/tools/schemas.d.ts.map +1 -1
  155. package/dist/tools/types.d.ts +23 -2
  156. package/dist/tools/types.d.ts.map +1 -1
  157. package/dist/types/config.d.ts +47 -3
  158. package/dist/types/config.d.ts.map +1 -1
  159. package/dist/types/events.d.ts +1 -1
  160. package/dist/types/provider-settings.d.ts +1 -1
  161. package/dist/types/provider-settings.d.ts.map +1 -1
  162. package/dist/types/storage.d.ts +2 -1
  163. package/dist/types/storage.d.ts.map +1 -1
  164. package/dist/types.d.ts +7 -16
  165. package/dist/types.d.ts.map +1 -1
  166. package/package.json +15 -12
  167. package/src/ClineCore.test.ts +150 -0
  168. package/src/ClineCore.ts +114 -8
  169. package/src/account/cline-account-service.test.ts +84 -0
  170. package/src/account/cline-account-service.ts +2 -2
  171. package/src/account/index.ts +1 -0
  172. package/src/account/types.ts +6 -0
  173. package/src/auth/bounded-ttl-cache.test.ts +38 -0
  174. package/src/auth/bounded-ttl-cache.ts +53 -0
  175. package/src/auth/cline.test.ts +173 -36
  176. package/src/auth/cline.ts +395 -93
  177. package/src/auth/oca.test.ts +125 -0
  178. package/src/auth/oca.ts +17 -4
  179. package/src/{agents → extensions/config}/agent-config-loader.test.ts +1 -1
  180. package/src/{agents → extensions/config}/agent-config-parser.ts +2 -2
  181. package/src/{agents → extensions/config}/hooks-config-loader.ts +1 -1
  182. package/src/{agents → extensions/config}/index.ts +7 -11
  183. package/src/{runtime/commands.test.ts → extensions/config/runtime-commands.test.ts} +20 -3
  184. package/src/{runtime/commands.ts → extensions/config/runtime-commands.ts} +1 -8
  185. package/src/{agents → extensions/config}/unified-config-file-watcher.ts +15 -2
  186. package/src/{agents → extensions/config}/user-instruction-config-loader.test.ts +90 -2
  187. package/src/{agents → extensions/config}/user-instruction-config-loader.ts +126 -12
  188. package/src/extensions/context/agentic-compaction.ts +119 -0
  189. package/src/extensions/context/basic-compaction.ts +275 -0
  190. package/src/extensions/context/compaction-shared.ts +458 -0
  191. package/src/extensions/context/compaction.test.ts +477 -0
  192. package/src/extensions/context/compaction.ts +203 -0
  193. package/src/extensions/index.ts +12 -0
  194. package/src/extensions/mcp/client.ts +420 -0
  195. package/src/{mcp → extensions/mcp}/index.ts +16 -0
  196. package/src/{mcp → extensions/mcp}/manager.test.ts +1 -2
  197. package/src/{mcp → extensions/mcp}/manager.ts +3 -5
  198. package/src/extensions/mcp/name-transform.ts +33 -0
  199. package/src/extensions/mcp/policies.ts +47 -0
  200. package/src/extensions/mcp/tools.ts +47 -0
  201. package/src/{mcp → extensions/mcp}/types.ts +35 -7
  202. package/src/{agents → extensions/plugin}/plugin-config-loader.test.ts +18 -13
  203. package/src/{agents → extensions/plugin}/plugin-config-loader.ts +1 -1
  204. package/src/{agents → extensions/plugin}/plugin-loader.test.ts +41 -4
  205. package/src/extensions/plugin/plugin-loader.ts +106 -0
  206. package/src/extensions/plugin/plugin-module-import.ts +278 -0
  207. package/src/{agents → extensions/plugin}/plugin-sandbox-bootstrap.ts +30 -92
  208. package/src/{agents → extensions/plugin}/plugin-sandbox.test.ts +60 -3
  209. package/src/{agents → extensions/plugin}/plugin-sandbox.ts +146 -56
  210. package/src/hooks/index.ts +25 -0
  211. package/src/hooks/persistent.ts +661 -0
  212. package/src/hooks/subprocess-runner.ts +196 -0
  213. package/src/hooks/subprocess.ts +669 -0
  214. package/src/index.ts +200 -118
  215. package/src/prompt/default-system.ts +21 -0
  216. package/src/providers/local-provider-registry.ts +1 -1
  217. package/src/providers/local-provider-service.test.ts +23 -2
  218. package/src/providers/local-provider-service.ts +2 -2
  219. package/src/runtime/checkpoint-hooks.test.ts +168 -0
  220. package/src/runtime/checkpoint-hooks.ts +186 -0
  221. package/src/runtime/hook-file-hooks.test.ts +40 -1
  222. package/src/runtime/hook-file-hooks.ts +35 -16
  223. package/src/runtime/index.ts +4 -19
  224. package/src/runtime/rules.ts +4 -1
  225. package/src/runtime/runtime-builder.team-persistence.test.ts +3 -6
  226. package/src/runtime/runtime-builder.test.ts +266 -160
  227. package/src/runtime/runtime-builder.ts +120 -47
  228. package/src/runtime/runtime-parity.test.ts +22 -22
  229. package/src/runtime/session-runtime.ts +36 -6
  230. package/src/runtime/{sandbox/subprocess-sandbox.ts → subprocess-sandbox.ts} +24 -3
  231. package/src/runtime/team-runtime-registry.ts +1 -4
  232. package/src/runtime/tool-approval.ts +1 -1
  233. package/src/session/default-session-manager.e2e.test.ts +2 -2
  234. package/src/session/default-session-manager.test.ts +553 -9
  235. package/src/session/default-session-manager.ts +162 -46
  236. package/src/session/file-session-service.ts +3 -3
  237. package/src/session/index.ts +6 -6
  238. package/src/session/persistence-service.test.ts +212 -0
  239. package/src/session/{unified-session-persistence-service.ts → persistence-service.ts} +106 -172
  240. package/src/session/rpc-session-service.ts +3 -3
  241. package/src/session/runtime-oauth-token-manager.ts +1 -1
  242. package/src/session/session-agent-events.ts +1 -1
  243. package/src/session/session-artifacts.ts +32 -4
  244. package/src/session/session-config-builder.ts +22 -9
  245. package/src/session/session-graph.ts +1 -1
  246. package/src/session/session-host.ts +19 -11
  247. package/src/session/session-manager.ts +11 -6
  248. package/src/session/session-service.team-persistence.test.ts +1 -1
  249. package/src/session/session-service.ts +6 -9
  250. package/src/session/session-team-coordination.ts +7 -3
  251. package/src/session/session-telemetry.ts +1 -1
  252. package/src/session/utils/helpers.test.ts +160 -0
  253. package/src/session/utils/helpers.ts +289 -42
  254. package/src/session/utils/types.ts +47 -7
  255. package/src/session/workspace-manager.ts +5 -3
  256. package/src/session/workspace-manifest.ts +3 -49
  257. package/src/storage/file-team-store.ts +2 -5
  258. package/src/storage/provider-settings-legacy-migration.ts +2 -2
  259. package/src/storage/provider-settings-manager.test.ts +1 -1
  260. package/src/storage/sqlite-team-store.ts +212 -125
  261. package/src/storage/team-store.ts +1 -5
  262. package/src/team/delegated-agent.ts +131 -0
  263. package/src/team/index.ts +1 -0
  264. package/src/team/multi-agent.lifecycle.test.ts +201 -0
  265. package/src/team/multi-agent.ts +1666 -0
  266. package/src/team/projections.ts +2 -4
  267. package/src/team/runtime.ts +54 -0
  268. package/src/team/spawn-agent-tool.test.ts +387 -0
  269. package/src/team/spawn-agent-tool.ts +207 -0
  270. package/src/team/subagent-prompts.ts +41 -0
  271. package/src/team/team-tools.test.ts +802 -0
  272. package/src/team/team-tools.ts +792 -0
  273. package/src/telemetry/OpenTelemetryAdapter.ts +1 -1
  274. package/src/telemetry/OpenTelemetryProvider.test.ts +216 -3
  275. package/src/telemetry/OpenTelemetryProvider.ts +110 -20
  276. package/src/telemetry/TelemetryLoggerSink.test.ts +42 -0
  277. package/src/telemetry/{LoggerTelemetryAdapter.ts → TelemetryLoggerSink.ts} +21 -14
  278. package/src/telemetry/TelemetryService.test.ts +7 -7
  279. package/src/telemetry/TelemetryService.ts +2 -4
  280. package/src/tools/definitions.test.ts +76 -0
  281. package/src/tools/definitions.ts +41 -2
  282. package/src/tools/executors/apply-patch.ts +1 -1
  283. package/src/tools/executors/editor.ts +1 -1
  284. package/src/tools/executors/file-read.ts +1 -1
  285. package/src/tools/executors/search.ts +1 -1
  286. package/src/tools/executors/web-fetch.ts +1 -1
  287. package/src/tools/index.ts +6 -1
  288. package/src/tools/model-tool-routing.ts +2 -0
  289. package/src/tools/presets.test.ts +8 -0
  290. package/src/tools/presets.ts +40 -2
  291. package/src/tools/schemas.ts +19 -0
  292. package/src/tools/types.ts +31 -2
  293. package/src/types/config.ts +61 -7
  294. package/src/types/events.ts +1 -1
  295. package/src/types/index.ts +0 -1
  296. package/src/types/provider-settings.ts +1 -1
  297. package/src/types/storage.ts +2 -5
  298. package/src/types.ts +32 -44
  299. package/dist/agents/agent-config-loader.d.ts.map +0 -1
  300. package/dist/agents/agent-config-parser.d.ts.map +0 -1
  301. package/dist/agents/hooks-config-loader.d.ts.map +0 -1
  302. package/dist/agents/index.d.ts.map +0 -1
  303. package/dist/agents/plugin-config-loader.d.ts.map +0 -1
  304. package/dist/agents/plugin-loader.d.ts.map +0 -1
  305. package/dist/agents/plugin-sandbox-bootstrap.js +0 -446
  306. package/dist/agents/plugin-sandbox.d.ts.map +0 -1
  307. package/dist/agents/unified-config-file-watcher.d.ts.map +0 -1
  308. package/dist/agents/user-instruction-config-loader.d.ts.map +0 -1
  309. package/dist/mcp/config-loader.d.ts.map +0 -1
  310. package/dist/mcp/index.d.ts +0 -5
  311. package/dist/mcp/index.d.ts.map +0 -1
  312. package/dist/mcp/manager.d.ts.map +0 -1
  313. package/dist/mcp/types.d.ts.map +0 -1
  314. package/dist/runtime/commands.d.ts.map +0 -1
  315. package/dist/runtime/sandbox/subprocess-sandbox.d.ts.map +0 -1
  316. package/dist/runtime/skills.d.ts +0 -14
  317. package/dist/runtime/skills.d.ts.map +0 -1
  318. package/dist/runtime/workflows.d.ts +0 -14
  319. package/dist/runtime/workflows.d.ts.map +0 -1
  320. package/dist/session/unified-session-persistence-service.d.ts.map +0 -1
  321. package/dist/telemetry/LoggerTelemetryAdapter.d.ts.map +0 -1
  322. package/dist/types/workspace.d.ts +0 -8
  323. package/dist/types/workspace.d.ts.map +0 -1
  324. package/src/agents/plugin-loader.ts +0 -175
  325. package/src/runtime/skills.ts +0 -44
  326. package/src/runtime/workflows.test.ts +0 -119
  327. package/src/runtime/workflows.ts +0 -45
  328. package/src/session/unified-session-persistence-service.test.ts +0 -85
  329. package/src/telemetry/LoggerTelemetryAdapter.test.ts +0 -42
  330. package/src/types/workspace.ts +0 -7
  331. /package/dist/{agents → extensions/config}/agent-config-loader.d.ts +0 -0
  332. /package/dist/{agents → extensions/config}/unified-config-file-watcher.d.ts +0 -0
  333. /package/dist/{agents → extensions/config}/user-instruction-config-loader.d.ts +0 -0
  334. /package/dist/{mcp → extensions/mcp}/config-loader.d.ts +0 -0
  335. /package/dist/runtime/{sandbox/subprocess-sandbox.d.ts → subprocess-sandbox.d.ts} +0 -0
  336. /package/src/{agents → extensions/config}/agent-config-loader.ts +0 -0
  337. /package/src/{agents → extensions/config}/hooks-config-loader.test.ts +0 -0
  338. /package/src/{agents → extensions/config}/unified-config-file-watcher.test.ts +0 -0
  339. /package/src/{mcp → extensions/mcp}/config-loader.test.ts +0 -0
  340. /package/src/{mcp → extensions/mcp}/config-loader.ts +0 -0
@@ -1,26 +1,7 @@
1
1
  import { basename, resolve } from "node:path";
2
+ import type { WorkspaceInfo } from "@clinebot/shared";
3
+ import { processWorkspaceInfo } from "@clinebot/shared";
2
4
  import simpleGit from "simple-git";
3
- import { z } from "zod";
4
- import type { WorkspaceInfo } from "../types/workspace";
5
-
6
- export const WorkspaceInfoSchema = z.object({
7
- rootPath: z.string().min(1),
8
- hint: z.string().min(1).optional(),
9
- associatedRemoteUrls: z.array(z.string().min(1)).optional(),
10
- latestGitCommitHash: z.string().min(1).optional(),
11
- latestGitBranchName: z.string().min(1).optional(),
12
- });
13
-
14
- export const WorkspaceManifestSchema = z.object({
15
- currentWorkspacePath: z.string().min(1).optional(),
16
- workspaces: z.record(z.string().min(1), WorkspaceInfoSchema),
17
- });
18
-
19
- export type WorkspaceManifest = z.infer<typeof WorkspaceManifestSchema>;
20
-
21
- export function emptyWorkspaceManifest(): WorkspaceManifest {
22
- return { workspaces: {} };
23
- }
24
5
 
25
6
  export function normalizeWorkspacePath(workspacePath: string): string {
26
7
  return resolve(workspacePath);
@@ -67,34 +48,7 @@ export async function generateWorkspaceInfo(
67
48
  return info;
68
49
  }
69
50
 
70
- export function upsertWorkspaceInfo(
71
- manifest: WorkspaceManifest,
72
- info: WorkspaceInfo,
73
- ): WorkspaceManifest {
74
- const nextManifest: WorkspaceManifest = {
75
- ...manifest,
76
- workspaces: {
77
- ...manifest.workspaces,
78
- [info.rootPath]: info,
79
- },
80
- };
81
- if (!nextManifest.currentWorkspacePath) {
82
- nextManifest.currentWorkspacePath = info.rootPath;
83
- }
84
- return WorkspaceManifestSchema.parse(nextManifest);
85
- }
86
-
87
51
  export async function buildWorkspaceMetadata(cwd: string): Promise<string> {
88
52
  const workspaceInfo = await generateWorkspaceInfo(cwd);
89
- const workspaceConfig = {
90
- workspaces: {
91
- [workspaceInfo.rootPath]: {
92
- hint: workspaceInfo.hint,
93
- associatedRemoteUrls: workspaceInfo.associatedRemoteUrls,
94
- latestGitCommitHash: workspaceInfo.latestGitCommitHash,
95
- latestGitBranchName: workspaceInfo.latestGitBranchName,
96
- },
97
- },
98
- };
99
- return `# Workspace Configuration\n${JSON.stringify(workspaceConfig, null, 2)}`;
53
+ return processWorkspaceInfo(workspaceInfo);
100
54
  }
@@ -8,12 +8,9 @@ import {
8
8
  writeFileSync,
9
9
  } from "node:fs";
10
10
  import { join } from "node:path";
11
- import type {
12
- TeamEvent,
13
- TeamRuntimeState,
14
- TeamTeammateSpec,
15
- } from "@clinebot/agents";
11
+ import type { TeamRuntimeState, TeamTeammateSpec } from "@clinebot/shared";
16
12
  import { resolveTeamDataDir } from "@clinebot/shared/storage";
13
+ import type { TeamEvent } from "../team";
17
14
  import type { TeamStore } from "../types/storage";
18
15
 
19
16
  function nowIso(): string {
@@ -1,7 +1,7 @@
1
1
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
2
2
  import { dirname, join } from "node:path";
3
- import * as LlmsModels from "@clinebot/llms/models";
4
- import * as LlmsProviders from "@clinebot/llms/providers";
3
+ import * as LlmsModels from "@clinebot/llms";
4
+ import * as LlmsProviders from "@clinebot/llms";
5
5
  import { resolveClineDataDir } from "@clinebot/shared/storage";
6
6
  import type { ProviderSettings } from "../types/provider-settings";
7
7
  import { emptyStoredProviderSettings } from "../types/provider-settings";
@@ -1,7 +1,7 @@
1
1
  import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
2
2
  import os from "node:os";
3
3
  import path from "node:path";
4
- import * as LlmsModels from "@clinebot/llms/models";
4
+ import * as LlmsModels from "@clinebot/llms";
5
5
  import { afterEach, describe, expect, it } from "vitest";
6
6
  import { ProviderSettingsManager } from "./provider-settings-manager";
7
7
 
@@ -1,12 +1,13 @@
1
1
  import { existsSync, mkdirSync } from "node:fs";
2
2
  import { join } from "node:path";
3
- import type {
4
- TeamEvent,
5
- TeamRuntimeState,
6
- TeamTeammateSpec,
7
- } from "@clinebot/agents";
3
+ import {
4
+ safeJsonParse,
5
+ type TeamRuntimeState,
6
+ type TeamTeammateSpec,
7
+ } from "@clinebot/shared";
8
8
  import { loadSqliteDb, nowIso, type SqliteDb } from "@clinebot/shared/db";
9
9
  import { resolveTeamDataDir } from "@clinebot/shared/storage";
10
+ import type { TeamEvent } from "../team";
10
11
  import type { TeamStore } from "../types/storage";
11
12
 
12
13
  function defaultTeamDir(): string {
@@ -41,6 +42,43 @@ interface TeamRunRow {
41
42
  run_id: string;
42
43
  }
43
44
 
45
+ function parseTeammatesJson(raw: string): TeamTeammateSpec[] {
46
+ const parsed = safeJsonParse<unknown>(raw);
47
+ if (!Array.isArray(parsed)) {
48
+ return [];
49
+ }
50
+ const out: TeamTeammateSpec[] = [];
51
+ for (const entry of parsed) {
52
+ if (!entry || typeof entry !== "object") {
53
+ continue;
54
+ }
55
+ const rec = entry as Record<string, unknown>;
56
+ const agentId = rec.agentId;
57
+ const rolePrompt = rec.rolePrompt;
58
+ if (typeof agentId !== "string" || !agentId.trim()) {
59
+ continue;
60
+ }
61
+ if (typeof rolePrompt !== "string" || !rolePrompt.trim()) {
62
+ continue;
63
+ }
64
+ const spec: TeamTeammateSpec = {
65
+ agentId: agentId.trim(),
66
+ rolePrompt,
67
+ };
68
+ if (typeof rec.modelId === "string" && rec.modelId.trim()) {
69
+ spec.modelId = rec.modelId.trim();
70
+ }
71
+ if (
72
+ typeof rec.maxIterations === "number" &&
73
+ Number.isFinite(rec.maxIterations)
74
+ ) {
75
+ spec.maxIterations = Math.max(1, Math.floor(rec.maxIterations));
76
+ }
77
+ out.push(spec);
78
+ }
79
+ return out;
80
+ }
81
+
44
82
  function reviveTeamRuntimeStateDates(
45
83
  state: TeamRuntimeState,
46
84
  ): TeamRuntimeState {
@@ -122,6 +160,22 @@ export class SqliteTeamStore implements TeamStore {
122
160
  private ensureSchema(db: SqliteDb): void {
123
161
  db.exec("PRAGMA journal_mode = WAL;");
124
162
  db.exec("PRAGMA busy_timeout = 5000;");
163
+ // Single-row table so ALTER-based upgrades can run in order (baseline = 1).
164
+ // Session/schedule schemas use separate migration paths in @clinebot/shared.
165
+ db.exec(`
166
+ CREATE TABLE IF NOT EXISTS team_store_schema_version (
167
+ lock INTEGER PRIMARY KEY CHECK (lock = 1),
168
+ version INTEGER NOT NULL
169
+ );
170
+ `);
171
+ const versionRow = db
172
+ .prepare("SELECT version FROM team_store_schema_version WHERE lock = 1")
173
+ .get() as { version: number } | null;
174
+ if (!versionRow) {
175
+ db.prepare(
176
+ "INSERT INTO team_store_schema_version (lock, version) VALUES (1, 1)",
177
+ ).run();
178
+ }
125
179
  db.exec(`
126
180
  CREATE TABLE IF NOT EXISTS team_events (
127
181
  id INTEGER PRIMARY KEY AUTOINCREMENT,
@@ -230,6 +284,23 @@ export class SqliteTeamStore implements TeamStore {
230
284
  .all(...params) as T[];
231
285
  }
232
286
 
287
+ /** Runs `work` in a single SQLite transaction (rollback on any error). */
288
+ private withTransaction(work: () => void): void {
289
+ const db = this.getRawDb();
290
+ db.exec("BEGIN IMMEDIATE;");
291
+ try {
292
+ work();
293
+ db.exec("COMMIT;");
294
+ } catch (error) {
295
+ try {
296
+ db.exec("ROLLBACK;");
297
+ } catch {
298
+ // ignore secondary failure
299
+ }
300
+ throw error;
301
+ }
302
+ }
303
+
233
304
  listTeamNames(): string[] {
234
305
  return this.queryAll<{ team_name: string }>(
235
306
  `SELECT team_name FROM team_runtime_snapshot ORDER BY team_name ASC`,
@@ -244,9 +315,15 @@ export class SqliteTeamStore implements TeamStore {
244
315
  if (!row) {
245
316
  return undefined;
246
317
  }
247
- return reviveTeamRuntimeStateDates(
248
- JSON.parse(row.state_json) as TeamRuntimeState,
249
- );
318
+ const parsed = safeJsonParse<TeamRuntimeState>(row.state_json);
319
+ if (!parsed) {
320
+ return undefined;
321
+ }
322
+ try {
323
+ return reviveTeamRuntimeStateDates(parsed);
324
+ } catch {
325
+ return undefined;
326
+ }
250
327
  }
251
328
 
252
329
  readHistory(teamName: string, limit = 200): unknown[] {
@@ -257,11 +334,19 @@ export class SqliteTeamStore implements TeamStore {
257
334
  }>(
258
335
  `SELECT event_type, payload_json, ts FROM team_events WHERE team_name = ? ORDER BY id DESC LIMIT ?`,
259
336
  [sanitizeTeamName(teamName), limit],
260
- ).map((row) => ({
261
- eventType: row.event_type,
262
- payload: JSON.parse(row.payload_json),
263
- ts: row.ts,
264
- }));
337
+ ).flatMap((row) => {
338
+ try {
339
+ return [
340
+ {
341
+ eventType: row.event_type,
342
+ payload: JSON.parse(row.payload_json),
343
+ ts: row.ts,
344
+ },
345
+ ];
346
+ } catch {
347
+ return [];
348
+ }
349
+ });
265
350
  }
266
351
 
267
352
  loadRuntime(teamName: string): TeamRuntimeLoadResult {
@@ -272,7 +357,7 @@ export class SqliteTeamStore implements TeamStore {
272
357
  [safeTeamName],
273
358
  );
274
359
  const teammates = snapshotRow
275
- ? (JSON.parse(snapshotRow.teammates_json) as TeamTeammateSpec[])
360
+ ? parseTeammatesJson(snapshotRow.teammates_json)
276
361
  : [];
277
362
  const interruptedRunIds = this.markInProgressRunsInterrupted(
278
363
  safeTeamName,
@@ -311,123 +396,125 @@ export class SqliteTeamStore implements TeamStore {
311
396
  ): void {
312
397
  const safeTeamName = sanitizeTeamName(teamName);
313
398
  const now = nowIso();
314
- this.run(
315
- `INSERT INTO team_runtime_snapshot (team_name, state_json, teammates_json, updated_at)
316
- VALUES (?, ?, ?, ?)
317
- ON CONFLICT(team_name) DO UPDATE SET
318
- state_json = excluded.state_json,
319
- teammates_json = excluded.teammates_json,
320
- updated_at = excluded.updated_at`,
321
- [safeTeamName, JSON.stringify(state), JSON.stringify(teammates), now],
322
- );
323
-
324
- for (const task of state.tasks) {
399
+ this.withTransaction(() => {
325
400
  this.run(
326
- `INSERT INTO team_tasks (team_name, task_id, title, description, status, assignee, depends_on_json, summary, version, updated_at)
327
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, 1, ?)
328
- ON CONFLICT(team_name, task_id) DO UPDATE SET
329
- title = excluded.title,
330
- description = excluded.description,
331
- status = excluded.status,
332
- assignee = excluded.assignee,
333
- depends_on_json = excluded.depends_on_json,
334
- summary = excluded.summary,
335
- version = team_tasks.version + 1,
401
+ `INSERT INTO team_runtime_snapshot (team_name, state_json, teammates_json, updated_at)
402
+ VALUES (?, ?, ?, ?)
403
+ ON CONFLICT(team_name) DO UPDATE SET
404
+ state_json = excluded.state_json,
405
+ teammates_json = excluded.teammates_json,
336
406
  updated_at = excluded.updated_at`,
337
- [
338
- safeTeamName,
339
- task.id,
340
- task.title,
341
- task.description,
342
- task.status,
343
- task.assignee ?? null,
344
- JSON.stringify(task.dependsOn ?? []),
345
- task.summary ?? null,
346
- task.updatedAt.toISOString(),
347
- ],
407
+ [safeTeamName, JSON.stringify(state), JSON.stringify(teammates), now],
348
408
  );
349
- }
350
409
 
351
- for (const run of state.runs ?? []) {
352
- this.run(
353
- `INSERT INTO team_runs (team_name, run_id, agent_id, task_id, status, message, started_at, ended_at, error, lease_owner, heartbeat_at, version)
354
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1)
355
- ON CONFLICT(team_name, run_id) DO UPDATE SET
356
- agent_id = excluded.agent_id,
357
- task_id = excluded.task_id,
358
- status = excluded.status,
359
- message = excluded.message,
360
- started_at = excluded.started_at,
361
- ended_at = excluded.ended_at,
362
- error = excluded.error,
363
- lease_owner = excluded.lease_owner,
364
- heartbeat_at = excluded.heartbeat_at,
365
- version = team_runs.version + 1`,
366
- [
367
- safeTeamName,
368
- run.id,
369
- run.agentId,
370
- run.taskId ?? null,
371
- run.status,
372
- run.message,
373
- run.startedAt ? run.startedAt.toISOString() : null,
374
- run.endedAt ? run.endedAt.toISOString() : null,
375
- run.error ?? null,
376
- run.leaseOwner ?? null,
377
- run.heartbeatAt ? run.heartbeatAt.toISOString() : null,
378
- ],
379
- );
380
- }
410
+ for (const task of state.tasks) {
411
+ this.run(
412
+ `INSERT INTO team_tasks (team_name, task_id, title, description, status, assignee, depends_on_json, summary, version, updated_at)
413
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, 1, ?)
414
+ ON CONFLICT(team_name, task_id) DO UPDATE SET
415
+ title = excluded.title,
416
+ description = excluded.description,
417
+ status = excluded.status,
418
+ assignee = excluded.assignee,
419
+ depends_on_json = excluded.depends_on_json,
420
+ summary = excluded.summary,
421
+ version = team_tasks.version + 1,
422
+ updated_at = excluded.updated_at`,
423
+ [
424
+ safeTeamName,
425
+ task.id,
426
+ task.title,
427
+ task.description,
428
+ task.status,
429
+ task.assignee ?? null,
430
+ JSON.stringify(task.dependsOn ?? []),
431
+ task.summary ?? null,
432
+ task.updatedAt.toISOString(),
433
+ ],
434
+ );
435
+ }
381
436
 
382
- for (const outcome of state.outcomes ?? []) {
383
- this.run(
384
- `INSERT INTO team_outcomes (team_name, outcome_id, title, status, schema_json, finalized_at, version)
385
- VALUES (?, ?, ?, ?, ?, ?, 1)
386
- ON CONFLICT(team_name, outcome_id) DO UPDATE SET
387
- title = excluded.title,
388
- status = excluded.status,
389
- schema_json = excluded.schema_json,
390
- finalized_at = excluded.finalized_at,
391
- version = team_outcomes.version + 1`,
392
- [
393
- safeTeamName,
394
- outcome.id,
395
- outcome.title,
396
- outcome.status,
397
- JSON.stringify({ requiredSections: outcome.requiredSections }),
398
- outcome.finalizedAt ? outcome.finalizedAt.toISOString() : null,
399
- ],
400
- );
401
- }
437
+ for (const run of state.runs ?? []) {
438
+ this.run(
439
+ `INSERT INTO team_runs (team_name, run_id, agent_id, task_id, status, message, started_at, ended_at, error, lease_owner, heartbeat_at, version)
440
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1)
441
+ ON CONFLICT(team_name, run_id) DO UPDATE SET
442
+ agent_id = excluded.agent_id,
443
+ task_id = excluded.task_id,
444
+ status = excluded.status,
445
+ message = excluded.message,
446
+ started_at = excluded.started_at,
447
+ ended_at = excluded.ended_at,
448
+ error = excluded.error,
449
+ lease_owner = excluded.lease_owner,
450
+ heartbeat_at = excluded.heartbeat_at,
451
+ version = team_runs.version + 1`,
452
+ [
453
+ safeTeamName,
454
+ run.id,
455
+ run.agentId,
456
+ run.taskId ?? null,
457
+ run.status,
458
+ run.message,
459
+ run.startedAt ? run.startedAt.toISOString() : null,
460
+ run.endedAt ? run.endedAt.toISOString() : null,
461
+ run.error ?? null,
462
+ run.leaseOwner ?? null,
463
+ run.heartbeatAt ? run.heartbeatAt.toISOString() : null,
464
+ ],
465
+ );
466
+ }
402
467
 
403
- for (const fragment of state.outcomeFragments ?? []) {
404
- this.run(
405
- `INSERT INTO team_outcome_fragments (team_name, outcome_id, fragment_id, section, source_agent_id, source_run_id, content, status, reviewed_by, reviewed_at, version)
406
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1)
407
- ON CONFLICT(team_name, fragment_id) DO UPDATE SET
408
- outcome_id = excluded.outcome_id,
409
- section = excluded.section,
410
- source_agent_id = excluded.source_agent_id,
411
- source_run_id = excluded.source_run_id,
412
- content = excluded.content,
413
- status = excluded.status,
414
- reviewed_by = excluded.reviewed_by,
415
- reviewed_at = excluded.reviewed_at,
416
- version = team_outcome_fragments.version + 1`,
417
- [
418
- safeTeamName,
419
- fragment.outcomeId,
420
- fragment.id,
421
- fragment.section,
422
- fragment.sourceAgentId,
423
- fragment.sourceRunId ?? null,
424
- fragment.content,
425
- fragment.status,
426
- fragment.reviewedBy ?? null,
427
- fragment.reviewedAt ? fragment.reviewedAt.toISOString() : null,
428
- ],
429
- );
430
- }
468
+ for (const outcome of state.outcomes ?? []) {
469
+ this.run(
470
+ `INSERT INTO team_outcomes (team_name, outcome_id, title, status, schema_json, finalized_at, version)
471
+ VALUES (?, ?, ?, ?, ?, ?, 1)
472
+ ON CONFLICT(team_name, outcome_id) DO UPDATE SET
473
+ title = excluded.title,
474
+ status = excluded.status,
475
+ schema_json = excluded.schema_json,
476
+ finalized_at = excluded.finalized_at,
477
+ version = team_outcomes.version + 1`,
478
+ [
479
+ safeTeamName,
480
+ outcome.id,
481
+ outcome.title,
482
+ outcome.status,
483
+ JSON.stringify({ requiredSections: outcome.requiredSections }),
484
+ outcome.finalizedAt ? outcome.finalizedAt.toISOString() : null,
485
+ ],
486
+ );
487
+ }
488
+
489
+ for (const fragment of state.outcomeFragments ?? []) {
490
+ this.run(
491
+ `INSERT INTO team_outcome_fragments (team_name, outcome_id, fragment_id, section, source_agent_id, source_run_id, content, status, reviewed_by, reviewed_at, version)
492
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1)
493
+ ON CONFLICT(team_name, fragment_id) DO UPDATE SET
494
+ outcome_id = excluded.outcome_id,
495
+ section = excluded.section,
496
+ source_agent_id = excluded.source_agent_id,
497
+ source_run_id = excluded.source_run_id,
498
+ content = excluded.content,
499
+ status = excluded.status,
500
+ reviewed_by = excluded.reviewed_by,
501
+ reviewed_at = excluded.reviewed_at,
502
+ version = team_outcome_fragments.version + 1`,
503
+ [
504
+ safeTeamName,
505
+ fragment.outcomeId,
506
+ fragment.id,
507
+ fragment.section,
508
+ fragment.sourceAgentId,
509
+ fragment.sourceRunId ?? null,
510
+ fragment.content,
511
+ fragment.status,
512
+ fragment.reviewedBy ?? null,
513
+ fragment.reviewedAt ? fragment.reviewedAt.toISOString() : null,
514
+ ],
515
+ );
516
+ }
517
+ });
431
518
  }
432
519
 
433
520
  markInProgressRunsInterrupted(teamName: string, reason: string): string[] {
@@ -28,11 +28,7 @@ export function createLocalTeamStore(options: SqliteTeamStoreOptions = {}): {
28
28
  const store = new SqliteTeamStore(options);
29
29
  store.init();
30
30
  return store;
31
- } catch (error) {
32
- console.warn(
33
- "SQLite team persistence unavailable, falling back to file-based team storage.",
34
- error,
35
- );
31
+ } catch {
36
32
  const store = new FileTeamStore({ teamDir: options.teamDir });
37
33
  store.init();
38
34
  return store;
@@ -0,0 +1,131 @@
1
+ import { Agent } from "@clinebot/agents";
2
+ import type {
3
+ AgentConfig,
4
+ AgentEvent,
5
+ AgentHooks,
6
+ BasicLogger,
7
+ HookErrorMode,
8
+ ITelemetryService,
9
+ Tool,
10
+ ToolApprovalRequest,
11
+ ToolApprovalResult,
12
+ } from "@clinebot/shared";
13
+ import {
14
+ buildSubAgentSystemPrompt,
15
+ buildTeammateSystemPrompt,
16
+ } from "./subagent-prompts";
17
+
18
+ type AgentExtension = NonNullable<AgentConfig["extensions"]>[number];
19
+
20
+ export type DelegatedAgentConnectionConfig = Pick<
21
+ AgentConfig,
22
+ | "providerId"
23
+ | "modelId"
24
+ | "apiKey"
25
+ | "baseUrl"
26
+ | "headers"
27
+ | "providerConfig"
28
+ | "knownModels"
29
+ | "thinking"
30
+ >;
31
+
32
+ export interface DelegatedAgentRuntimeConfig
33
+ extends DelegatedAgentConnectionConfig {
34
+ cwd?: string;
35
+ providerId: string;
36
+ clinePlatform?: string;
37
+ clineIdeName?: string;
38
+ maxIterations?: number;
39
+ hooks?: AgentHooks;
40
+ extensions?: AgentExtension[];
41
+ logger?: BasicLogger;
42
+ telemetry?: ITelemetryService;
43
+ workspaceMetadata?: string;
44
+ }
45
+
46
+ export interface DelegatedAgentConfigProvider {
47
+ getRuntimeConfig(): DelegatedAgentRuntimeConfig;
48
+ getConnectionConfig(): DelegatedAgentConnectionConfig;
49
+ updateConnectionDefaults(
50
+ overrides: Partial<DelegatedAgentConnectionConfig>,
51
+ ): void;
52
+ }
53
+
54
+ export type DelegatedAgentKind = "subagent" | "teammate";
55
+
56
+ export interface BuildDelegatedAgentConfigOptions {
57
+ kind: DelegatedAgentKind;
58
+ prompt: string;
59
+ tools: Tool[];
60
+ configProvider: DelegatedAgentConfigProvider;
61
+ parentAgentId?: string;
62
+ maxIterations?: number;
63
+ abortSignal?: AbortSignal;
64
+ onEvent?: (event: AgentEvent) => void;
65
+ hookErrorMode?: HookErrorMode;
66
+ toolPolicies?: AgentConfig["toolPolicies"];
67
+ requestToolApproval?: (
68
+ request: ToolApprovalRequest,
69
+ ) => Promise<ToolApprovalResult> | ToolApprovalResult;
70
+ role?: string;
71
+ cwd?: string;
72
+ }
73
+
74
+ export function createDelegatedAgentConfigProvider(
75
+ initialConfig: DelegatedAgentRuntimeConfig,
76
+ ): DelegatedAgentConfigProvider {
77
+ let runtimeConfig: DelegatedAgentRuntimeConfig = { ...initialConfig };
78
+
79
+ return {
80
+ getRuntimeConfig: () => runtimeConfig,
81
+ getConnectionConfig: () => ({
82
+ providerId: runtimeConfig.providerId,
83
+ modelId: runtimeConfig.modelId,
84
+ apiKey: runtimeConfig.apiKey,
85
+ baseUrl: runtimeConfig.baseUrl,
86
+ headers: runtimeConfig.headers,
87
+ providerConfig: runtimeConfig.providerConfig,
88
+ knownModels: runtimeConfig.knownModels,
89
+ thinking: runtimeConfig.thinking,
90
+ }),
91
+ updateConnectionDefaults: (overrides) => {
92
+ runtimeConfig = {
93
+ ...runtimeConfig,
94
+ ...overrides,
95
+ };
96
+ },
97
+ };
98
+ }
99
+
100
+ export function buildDelegatedAgentConfig(
101
+ options: BuildDelegatedAgentConfigOptions,
102
+ ): AgentConfig & { role?: string } {
103
+ const runtimeConfig = options.configProvider.getRuntimeConfig();
104
+ const systemPrompt =
105
+ options.kind === "teammate"
106
+ ? buildTeammateSystemPrompt(options.prompt, runtimeConfig)
107
+ : buildSubAgentSystemPrompt(options.prompt, runtimeConfig);
108
+
109
+ return {
110
+ ...options.configProvider.getConnectionConfig(),
111
+ systemPrompt,
112
+ tools: options.tools,
113
+ maxIterations: options.maxIterations ?? runtimeConfig.maxIterations,
114
+ parentAgentId: options.parentAgentId,
115
+ abortSignal: options.abortSignal,
116
+ onEvent: options.onEvent,
117
+ hooks: runtimeConfig.hooks,
118
+ extensions: runtimeConfig.extensions,
119
+ hookErrorMode: options.hookErrorMode,
120
+ toolPolicies: options.toolPolicies,
121
+ requestToolApproval: options.requestToolApproval,
122
+ logger: runtimeConfig.logger,
123
+ role: options.role,
124
+ };
125
+ }
126
+
127
+ export function createDelegatedAgent(
128
+ options: BuildDelegatedAgentConfigOptions,
129
+ ): Agent {
130
+ return new Agent(buildDelegatedAgentConfig(options));
131
+ }
package/src/team/index.ts CHANGED
@@ -2,3 +2,4 @@ export {
2
2
  buildTeamProgressSummary,
3
3
  toTeamProgressLifecycleEvent,
4
4
  } from "./projections";
5
+ export * from "./runtime";