groundswell 0.0.3 → 1.0.0

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 (292) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +26 -9
  3. package/dist/cache/cache-key.d.ts +20 -0
  4. package/dist/cache/cache-key.d.ts.map +1 -1
  5. package/dist/cache/cache-key.js +9 -0
  6. package/dist/cache/cache-key.js.map +1 -1
  7. package/dist/core/agent.d.ts +120 -29
  8. package/dist/core/agent.d.ts.map +1 -1
  9. package/dist/core/agent.js +584 -177
  10. package/dist/core/agent.js.map +1 -1
  11. package/dist/core/mcp-handler.d.ts +63 -5
  12. package/dist/core/mcp-handler.d.ts.map +1 -1
  13. package/dist/core/mcp-handler.js +184 -4
  14. package/dist/core/mcp-handler.js.map +1 -1
  15. package/dist/core/workflow-context.d.ts +6 -2
  16. package/dist/core/workflow-context.d.ts.map +1 -1
  17. package/dist/core/workflow-context.js +99 -4
  18. package/dist/core/workflow-context.js.map +1 -1
  19. package/dist/core/workflow.d.ts +315 -13
  20. package/dist/core/workflow.d.ts.map +1 -1
  21. package/dist/core/workflow.js +552 -30
  22. package/dist/core/workflow.js.map +1 -1
  23. package/dist/debugger/event-replayer.d.ts +422 -0
  24. package/dist/debugger/event-replayer.d.ts.map +1 -0
  25. package/dist/debugger/event-replayer.js +639 -0
  26. package/dist/debugger/event-replayer.js.map +1 -0
  27. package/dist/debugger/tree-debugger.d.ts +170 -1
  28. package/dist/debugger/tree-debugger.d.ts.map +1 -1
  29. package/dist/debugger/tree-debugger.js +423 -1
  30. package/dist/debugger/tree-debugger.js.map +1 -1
  31. package/dist/decorators/step.d.ts.map +1 -1
  32. package/dist/decorators/step.js +129 -47
  33. package/dist/decorators/step.js.map +1 -1
  34. package/dist/harnesses/claude-code-harness.d.ts +391 -0
  35. package/dist/harnesses/claude-code-harness.d.ts.map +1 -0
  36. package/dist/harnesses/claude-code-harness.js +1076 -0
  37. package/dist/harnesses/claude-code-harness.js.map +1 -0
  38. package/dist/harnesses/harness-registry.d.ts +440 -0
  39. package/dist/harnesses/harness-registry.d.ts.map +1 -0
  40. package/dist/harnesses/harness-registry.js +543 -0
  41. package/dist/harnesses/harness-registry.js.map +1 -0
  42. package/dist/harnesses/index.d.ts +12 -0
  43. package/dist/harnesses/index.d.ts.map +1 -0
  44. package/dist/harnesses/index.js +11 -0
  45. package/dist/harnesses/index.js.map +1 -0
  46. package/dist/harnesses/pi-harness.d.ts +219 -0
  47. package/dist/harnesses/pi-harness.d.ts.map +1 -0
  48. package/dist/harnesses/pi-harness.js +676 -0
  49. package/dist/harnesses/pi-harness.js.map +1 -0
  50. package/dist/harnesses/pi-schema-converter.d.ts +24 -0
  51. package/dist/harnesses/pi-schema-converter.d.ts.map +1 -0
  52. package/dist/harnesses/pi-schema-converter.js +81 -0
  53. package/dist/harnesses/pi-schema-converter.js.map +1 -0
  54. package/dist/harnesses/register-defaults.d.ts +24 -0
  55. package/dist/harnesses/register-defaults.d.ts.map +1 -0
  56. package/dist/harnesses/register-defaults.js +40 -0
  57. package/dist/harnesses/register-defaults.js.map +1 -0
  58. package/dist/harnesses/session-store.d.ts +201 -0
  59. package/dist/harnesses/session-store.d.ts.map +1 -0
  60. package/dist/harnesses/session-store.js +254 -0
  61. package/dist/harnesses/session-store.js.map +1 -0
  62. package/dist/index.d.ts +12 -2
  63. package/dist/index.d.ts.map +1 -1
  64. package/dist/index.js +17 -0
  65. package/dist/index.js.map +1 -1
  66. package/dist/reflection/reflection.d.ts.map +1 -1
  67. package/dist/reflection/reflection.js +19 -4
  68. package/dist/reflection/reflection.js.map +1 -1
  69. package/dist/types/agent.d.ts +1253 -2
  70. package/dist/types/agent.d.ts.map +1 -1
  71. package/dist/types/agent.js +418 -1
  72. package/dist/types/agent.js.map +1 -1
  73. package/dist/types/decorators.d.ts +10 -1
  74. package/dist/types/decorators.d.ts.map +1 -1
  75. package/dist/types/events.d.ts +26 -0
  76. package/dist/types/events.d.ts.map +1 -1
  77. package/dist/types/harnesses.d.ts +474 -0
  78. package/dist/types/harnesses.d.ts.map +1 -0
  79. package/dist/types/harnesses.js +2 -0
  80. package/dist/types/harnesses.js.map +1 -0
  81. package/dist/types/index.d.ts +9 -1
  82. package/dist/types/index.d.ts.map +1 -1
  83. package/dist/types/index.js +6 -0
  84. package/dist/types/index.js.map +1 -1
  85. package/dist/types/providers.d.ts +691 -0
  86. package/dist/types/providers.d.ts.map +1 -0
  87. package/dist/types/providers.js +14 -0
  88. package/dist/types/providers.js.map +1 -0
  89. package/dist/types/restart.d.ts +132 -0
  90. package/dist/types/restart.d.ts.map +1 -0
  91. package/dist/types/restart.js +2 -0
  92. package/dist/types/restart.js.map +1 -0
  93. package/dist/types/streaming.d.ts +194 -0
  94. package/dist/types/streaming.d.ts.map +1 -0
  95. package/dist/types/streaming.js +67 -0
  96. package/dist/types/streaming.js.map +1 -0
  97. package/dist/types/workflow-context.d.ts +137 -1
  98. package/dist/types/workflow-context.d.ts.map +1 -1
  99. package/dist/utils/agent-validation.d.ts +88 -0
  100. package/dist/utils/agent-validation.d.ts.map +1 -0
  101. package/dist/utils/agent-validation.js +87 -0
  102. package/dist/utils/agent-validation.js.map +1 -0
  103. package/dist/utils/delay.d.ts +7 -0
  104. package/dist/utils/delay.d.ts.map +1 -0
  105. package/dist/utils/delay.js +9 -0
  106. package/dist/utils/delay.js.map +1 -0
  107. package/dist/utils/harness-config.d.ts +180 -0
  108. package/dist/utils/harness-config.d.ts.map +1 -0
  109. package/dist/utils/harness-config.js +311 -0
  110. package/dist/utils/harness-config.js.map +1 -0
  111. package/dist/utils/index.d.ts +9 -1
  112. package/dist/utils/index.d.ts.map +1 -1
  113. package/dist/utils/index.js +8 -1
  114. package/dist/utils/index.js.map +1 -1
  115. package/dist/utils/model-spec.d.ts +110 -0
  116. package/dist/utils/model-spec.d.ts.map +1 -0
  117. package/dist/utils/model-spec.js +149 -0
  118. package/dist/utils/model-spec.js.map +1 -0
  119. package/dist/utils/provider-config.d.ts +10 -0
  120. package/dist/utils/provider-config.d.ts.map +1 -0
  121. package/dist/utils/provider-config.js +10 -0
  122. package/dist/utils/provider-config.js.map +1 -0
  123. package/dist/utils/restart-analysis.d.ts +202 -0
  124. package/dist/utils/restart-analysis.d.ts.map +1 -0
  125. package/dist/utils/restart-analysis.js +426 -0
  126. package/dist/utils/restart-analysis.js.map +1 -0
  127. package/dist/utils/session-serialization.d.ts +118 -0
  128. package/dist/utils/session-serialization.d.ts.map +1 -0
  129. package/dist/utils/session-serialization.js +217 -0
  130. package/dist/utils/session-serialization.js.map +1 -0
  131. package/package.json +31 -5
  132. package/CHANGELOG.md +0 -188
  133. package/dist/__tests__/adversarial/attachChild-performance.test.d.ts +0 -16
  134. package/dist/__tests__/adversarial/attachChild-performance.test.d.ts.map +0 -1
  135. package/dist/__tests__/adversarial/attachChild-performance.test.js +0 -187
  136. package/dist/__tests__/adversarial/attachChild-performance.test.js.map +0 -1
  137. package/dist/__tests__/adversarial/circular-reference.test.d.ts +0 -13
  138. package/dist/__tests__/adversarial/circular-reference.test.d.ts.map +0 -1
  139. package/dist/__tests__/adversarial/circular-reference.test.js +0 -92
  140. package/dist/__tests__/adversarial/circular-reference.test.js.map +0 -1
  141. package/dist/__tests__/adversarial/complex-circular-reference.test.d.ts +0 -16
  142. package/dist/__tests__/adversarial/complex-circular-reference.test.d.ts.map +0 -1
  143. package/dist/__tests__/adversarial/complex-circular-reference.test.js +0 -127
  144. package/dist/__tests__/adversarial/complex-circular-reference.test.js.map +0 -1
  145. package/dist/__tests__/adversarial/concurrent-task-failures.test.d.ts +0 -21
  146. package/dist/__tests__/adversarial/concurrent-task-failures.test.d.ts.map +0 -1
  147. package/dist/__tests__/adversarial/concurrent-task-failures.test.js +0 -667
  148. package/dist/__tests__/adversarial/concurrent-task-failures.test.js.map +0 -1
  149. package/dist/__tests__/adversarial/deep-analysis.test.d.ts +0 -6
  150. package/dist/__tests__/adversarial/deep-analysis.test.d.ts.map +0 -1
  151. package/dist/__tests__/adversarial/deep-analysis.test.js +0 -877
  152. package/dist/__tests__/adversarial/deep-analysis.test.js.map +0 -1
  153. package/dist/__tests__/adversarial/deep-hierarchy-stress.test.d.ts +0 -13
  154. package/dist/__tests__/adversarial/deep-hierarchy-stress.test.d.ts.map +0 -1
  155. package/dist/__tests__/adversarial/deep-hierarchy-stress.test.js +0 -186
  156. package/dist/__tests__/adversarial/deep-hierarchy-stress.test.js.map +0 -1
  157. package/dist/__tests__/adversarial/e2e-prd-validation.test.d.ts +0 -6
  158. package/dist/__tests__/adversarial/e2e-prd-validation.test.d.ts.map +0 -1
  159. package/dist/__tests__/adversarial/e2e-prd-validation.test.js +0 -626
  160. package/dist/__tests__/adversarial/e2e-prd-validation.test.js.map +0 -1
  161. package/dist/__tests__/adversarial/edge-case.test.d.ts +0 -6
  162. package/dist/__tests__/adversarial/edge-case.test.d.ts.map +0 -1
  163. package/dist/__tests__/adversarial/edge-case.test.js +0 -857
  164. package/dist/__tests__/adversarial/edge-case.test.js.map +0 -1
  165. package/dist/__tests__/adversarial/error-merge-strategy.test.d.ts +0 -20
  166. package/dist/__tests__/adversarial/error-merge-strategy.test.d.ts.map +0 -1
  167. package/dist/__tests__/adversarial/error-merge-strategy.test.js +0 -907
  168. package/dist/__tests__/adversarial/error-merge-strategy.test.js.map +0 -1
  169. package/dist/__tests__/adversarial/incremental-performance.test.d.ts +0 -2
  170. package/dist/__tests__/adversarial/incremental-performance.test.d.ts.map +0 -1
  171. package/dist/__tests__/adversarial/incremental-performance.test.js +0 -113
  172. package/dist/__tests__/adversarial/incremental-performance.test.js.map +0 -1
  173. package/dist/__tests__/adversarial/node-map-update-benchmarks.test.d.ts +0 -22
  174. package/dist/__tests__/adversarial/node-map-update-benchmarks.test.d.ts.map +0 -1
  175. package/dist/__tests__/adversarial/node-map-update-benchmarks.test.js +0 -383
  176. package/dist/__tests__/adversarial/node-map-update-benchmarks.test.js.map +0 -1
  177. package/dist/__tests__/adversarial/observer-propagation.test.d.ts +0 -21
  178. package/dist/__tests__/adversarial/observer-propagation.test.d.ts.map +0 -1
  179. package/dist/__tests__/adversarial/observer-propagation.test.js +0 -404
  180. package/dist/__tests__/adversarial/observer-propagation.test.js.map +0 -1
  181. package/dist/__tests__/adversarial/parent-validation.test.d.ts +0 -13
  182. package/dist/__tests__/adversarial/parent-validation.test.d.ts.map +0 -1
  183. package/dist/__tests__/adversarial/parent-validation.test.js +0 -128
  184. package/dist/__tests__/adversarial/parent-validation.test.js.map +0 -1
  185. package/dist/__tests__/adversarial/prd-12-2-compliance.test.d.ts +0 -20
  186. package/dist/__tests__/adversarial/prd-12-2-compliance.test.d.ts.map +0 -1
  187. package/dist/__tests__/adversarial/prd-12-2-compliance.test.js +0 -482
  188. package/dist/__tests__/adversarial/prd-12-2-compliance.test.js.map +0 -1
  189. package/dist/__tests__/adversarial/prd-compliance.test.d.ts +0 -6
  190. package/dist/__tests__/adversarial/prd-compliance.test.d.ts.map +0 -1
  191. package/dist/__tests__/adversarial/prd-compliance.test.js +0 -886
  192. package/dist/__tests__/adversarial/prd-compliance.test.js.map +0 -1
  193. package/dist/__tests__/compatibility/backward-compatibility.test.d.ts +0 -22
  194. package/dist/__tests__/compatibility/backward-compatibility.test.d.ts.map +0 -1
  195. package/dist/__tests__/compatibility/backward-compatibility.test.js +0 -1843
  196. package/dist/__tests__/compatibility/backward-compatibility.test.js.map +0 -1
  197. package/dist/__tests__/helpers/index.d.ts +0 -10
  198. package/dist/__tests__/helpers/index.d.ts.map +0 -1
  199. package/dist/__tests__/helpers/index.js +0 -10
  200. package/dist/__tests__/helpers/index.js.map +0 -1
  201. package/dist/__tests__/helpers/tree-verification.d.ts +0 -90
  202. package/dist/__tests__/helpers/tree-verification.d.ts.map +0 -1
  203. package/dist/__tests__/helpers/tree-verification.js +0 -202
  204. package/dist/__tests__/helpers/tree-verification.js.map +0 -1
  205. package/dist/__tests__/integration/agent-workflow.test.d.ts +0 -2
  206. package/dist/__tests__/integration/agent-workflow.test.d.ts.map +0 -1
  207. package/dist/__tests__/integration/agent-workflow.test.js +0 -256
  208. package/dist/__tests__/integration/agent-workflow.test.js.map +0 -1
  209. package/dist/__tests__/integration/bidirectional-consistency.test.d.ts +0 -14
  210. package/dist/__tests__/integration/bidirectional-consistency.test.d.ts.map +0 -1
  211. package/dist/__tests__/integration/bidirectional-consistency.test.js +0 -668
  212. package/dist/__tests__/integration/bidirectional-consistency.test.js.map +0 -1
  213. package/dist/__tests__/integration/observer-logging.test.d.ts +0 -2
  214. package/dist/__tests__/integration/observer-logging.test.d.ts.map +0 -1
  215. package/dist/__tests__/integration/observer-logging.test.js +0 -517
  216. package/dist/__tests__/integration/observer-logging.test.js.map +0 -1
  217. package/dist/__tests__/integration/tree-mirroring.test.d.ts +0 -2
  218. package/dist/__tests__/integration/tree-mirroring.test.d.ts.map +0 -1
  219. package/dist/__tests__/integration/tree-mirroring.test.js +0 -117
  220. package/dist/__tests__/integration/tree-mirroring.test.js.map +0 -1
  221. package/dist/__tests__/integration/workflow-reparenting.test.d.ts +0 -12
  222. package/dist/__tests__/integration/workflow-reparenting.test.d.ts.map +0 -1
  223. package/dist/__tests__/integration/workflow-reparenting.test.js +0 -239
  224. package/dist/__tests__/integration/workflow-reparenting.test.js.map +0 -1
  225. package/dist/__tests__/unit/agent.test.d.ts +0 -2
  226. package/dist/__tests__/unit/agent.test.d.ts.map +0 -1
  227. package/dist/__tests__/unit/agent.test.js +0 -143
  228. package/dist/__tests__/unit/agent.test.js.map +0 -1
  229. package/dist/__tests__/unit/cache-key.test.d.ts +0 -5
  230. package/dist/__tests__/unit/cache-key.test.d.ts.map +0 -1
  231. package/dist/__tests__/unit/cache-key.test.js +0 -145
  232. package/dist/__tests__/unit/cache-key.test.js.map +0 -1
  233. package/dist/__tests__/unit/cache.test.d.ts +0 -5
  234. package/dist/__tests__/unit/cache.test.d.ts.map +0 -1
  235. package/dist/__tests__/unit/cache.test.js +0 -132
  236. package/dist/__tests__/unit/cache.test.js.map +0 -1
  237. package/dist/__tests__/unit/context.test.d.ts +0 -2
  238. package/dist/__tests__/unit/context.test.d.ts.map +0 -1
  239. package/dist/__tests__/unit/context.test.js +0 -220
  240. package/dist/__tests__/unit/context.test.js.map +0 -1
  241. package/dist/__tests__/unit/decorators.test.d.ts +0 -2
  242. package/dist/__tests__/unit/decorators.test.d.ts.map +0 -1
  243. package/dist/__tests__/unit/decorators.test.js +0 -162
  244. package/dist/__tests__/unit/decorators.test.js.map +0 -1
  245. package/dist/__tests__/unit/introspection-tools.test.d.ts +0 -5
  246. package/dist/__tests__/unit/introspection-tools.test.d.ts.map +0 -1
  247. package/dist/__tests__/unit/introspection-tools.test.js +0 -191
  248. package/dist/__tests__/unit/introspection-tools.test.js.map +0 -1
  249. package/dist/__tests__/unit/logger.test.d.ts +0 -2
  250. package/dist/__tests__/unit/logger.test.d.ts.map +0 -1
  251. package/dist/__tests__/unit/logger.test.js +0 -241
  252. package/dist/__tests__/unit/logger.test.js.map +0 -1
  253. package/dist/__tests__/unit/observable.test.d.ts +0 -2
  254. package/dist/__tests__/unit/observable.test.d.ts.map +0 -1
  255. package/dist/__tests__/unit/observable.test.js +0 -251
  256. package/dist/__tests__/unit/observable.test.js.map +0 -1
  257. package/dist/__tests__/unit/prompt.test.d.ts +0 -2
  258. package/dist/__tests__/unit/prompt.test.d.ts.map +0 -1
  259. package/dist/__tests__/unit/prompt.test.js +0 -113
  260. package/dist/__tests__/unit/prompt.test.js.map +0 -1
  261. package/dist/__tests__/unit/reflection.test.d.ts +0 -5
  262. package/dist/__tests__/unit/reflection.test.d.ts.map +0 -1
  263. package/dist/__tests__/unit/reflection.test.js +0 -160
  264. package/dist/__tests__/unit/reflection.test.js.map +0 -1
  265. package/dist/__tests__/unit/tree-debugger-incremental.test.d.ts +0 -2
  266. package/dist/__tests__/unit/tree-debugger-incremental.test.d.ts.map +0 -1
  267. package/dist/__tests__/unit/tree-debugger-incremental.test.js +0 -136
  268. package/dist/__tests__/unit/tree-debugger-incremental.test.js.map +0 -1
  269. package/dist/__tests__/unit/tree-debugger.test.d.ts +0 -2
  270. package/dist/__tests__/unit/tree-debugger.test.d.ts.map +0 -1
  271. package/dist/__tests__/unit/tree-debugger.test.js +0 -69
  272. package/dist/__tests__/unit/tree-debugger.test.js.map +0 -1
  273. package/dist/__tests__/unit/utils/workflow-error-utils.test.d.ts +0 -2
  274. package/dist/__tests__/unit/utils/workflow-error-utils.test.d.ts.map +0 -1
  275. package/dist/__tests__/unit/utils/workflow-error-utils.test.js +0 -154
  276. package/dist/__tests__/unit/utils/workflow-error-utils.test.js.map +0 -1
  277. package/dist/__tests__/unit/workflow-detachChild.test.d.ts +0 -2
  278. package/dist/__tests__/unit/workflow-detachChild.test.d.ts.map +0 -1
  279. package/dist/__tests__/unit/workflow-detachChild.test.js +0 -76
  280. package/dist/__tests__/unit/workflow-detachChild.test.js.map +0 -1
  281. package/dist/__tests__/unit/workflow-emitEvent-childDetached.test.d.ts +0 -2
  282. package/dist/__tests__/unit/workflow-emitEvent-childDetached.test.d.ts.map +0 -1
  283. package/dist/__tests__/unit/workflow-emitEvent-childDetached.test.js +0 -122
  284. package/dist/__tests__/unit/workflow-emitEvent-childDetached.test.js.map +0 -1
  285. package/dist/__tests__/unit/workflow-isDescendantOf.test.d.ts +0 -2
  286. package/dist/__tests__/unit/workflow-isDescendantOf.test.d.ts.map +0 -1
  287. package/dist/__tests__/unit/workflow-isDescendantOf.test.js +0 -140
  288. package/dist/__tests__/unit/workflow-isDescendantOf.test.js.map +0 -1
  289. package/dist/__tests__/unit/workflow.test.d.ts +0 -2
  290. package/dist/__tests__/unit/workflow.test.d.ts.map +0 -1
  291. package/dist/__tests__/unit/workflow.test.js +0 -330
  292. package/dist/__tests__/unit/workflow.test.js.map +0 -1
@@ -0,0 +1,391 @@
1
+ /**
2
+ * Claude Code harness implementation (PRD §7.1)
3
+ *
4
+ * Wraps the @anthropic-ai/claude-agent-sdk to provide Anthropic Claude
5
+ * model access through the unified Harness interface.
6
+ *
7
+ * ## Capabilities
8
+ *
9
+ * - **MCP**: Model Context Protocol integration via createSdkMcpServer
10
+ * - **Skills**: System prompt-based skill loading
11
+ * - **LSP**: Language Server Protocol via MCP plugins
12
+ * - **Streaming**: Streaming response support
13
+ * - **Sessions**: Session-based state via abstraction layer
14
+ * - **Extended Thinking**: maxThinkingTokens for extended reasoning
15
+ *
16
+ * ## SDK Integration
17
+ *
18
+ * Uses lazy loading for the Anthropic SDK. The SDK is imported dynamically
19
+ * in the initialize() method to support optional dependencies.
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * import { ClaudeCodeHarness } from 'groundswell';
24
+ *
25
+ * const harness = new ClaudeCodeHarness();
26
+ * await harness.initialize({ apiKey: 'sk-...' });
27
+ *
28
+ * const result = await harness.execute(
29
+ * { prompt: 'Hello, Claude!', options: {} },
30
+ * toolExecutor
31
+ * );
32
+ * ```
33
+ *
34
+ * @see {@link https://docs.anthropic.com/en/api/messages | Anthropic Messages API}
35
+ * @see {@link https://www.npmjs.com/package/@anthropic-ai/claude-agent-sdk | Agent SDK Package}
36
+ */
37
+ import type { Harness, HarnessId, HarnessCapabilities, HarnessOptions, HarnessRequest, HarnessHookEvents, ToolExecutionRequest, ToolExecutionResult, ModelSpec } from "../types/harnesses.js";
38
+ import type { SessionState } from "../types/providers.js";
39
+ import type { AgentResponse } from "../types/agent.js";
40
+ import type { Tool, MCPServer, Skill } from "../types/sdk-primitives.js";
41
+ import { type SessionStore } from "./session-store.js";
42
+ import type { StreamEvent } from "../types/streaming.js";
43
+ /**
44
+ * Claude Code harness options (PRD §7.5).
45
+ * Extends {@link HarnessOptions} with adapter-internal session-store configuration that the
46
+ * slimmed base contract intentionally omits.
47
+ */
48
+ export interface ClaudeCodeHarnessOptions extends HarnessOptions {
49
+ /** Direct session-store injection (mutually exclusive with sessionPersistence). */
50
+ sessionStore?: SessionStore<SessionState>;
51
+ /** Declarative store selection; constructs the appropriate SessionStore. */
52
+ sessionPersistence?: "memory" | "file" | "redis";
53
+ /** Session TTL in ms (default 86400000 = 24h). */
54
+ sessionTtl?: number;
55
+ /** Directory for FileSessionStore (default './sessions'). Only when sessionPersistence='file'. */
56
+ sessionPath?: string;
57
+ }
58
+ /**
59
+ * Thrown when a harness receives a configuration it cannot honour — e.g. a model
60
+ * provider it cannot run (ClaudeCodeHarness + non-anthropic, PRD §7.8). Carries a
61
+ * machine-readable `code` (default `AGENT_ERROR_CODES.CONFIG_ERROR`) so callers and
62
+ * Agent retry logic can branch structurally rather than parsing message text.
63
+ *
64
+ * @see AGENT_ERROR_CODES
65
+ */
66
+ export declare class ConfigError extends Error {
67
+ readonly code: string;
68
+ readonly details?: Record<string, unknown>;
69
+ constructor(message: string, options?: {
70
+ code?: string;
71
+ details?: Record<string, unknown>;
72
+ });
73
+ }
74
+ export declare class ClaudeCodeHarness implements Harness {
75
+ /**
76
+ * Unique harness identifier (PRD §7.2)
77
+ *
78
+ * @readonly
79
+ */
80
+ readonly id: HarnessId;
81
+ /**
82
+ * Provider capability flags
83
+ *
84
+ * Anthropic SDK v0.1.77 capabilities:
85
+ * - MCP via createSdkMcpServer
86
+ * - Skills via system prompt
87
+ * - LSP via MCP plugins
88
+ * - Streaming responses
89
+ * - No native sessions (stateless)
90
+ * - Extended thinking via maxThinkingTokens
91
+ *
92
+ * @readonly
93
+ */
94
+ readonly capabilities: HarnessCapabilities;
95
+ /**
96
+ * Check if a specific capability is supported
97
+ *
98
+ * @param capability - The capability to check
99
+ * @returns true if the capability is supported
100
+ */
101
+ supports(capability: keyof HarnessCapabilities): boolean;
102
+ /**
103
+ * Check if all specified features are supported
104
+ *
105
+ * @param features - Array of capability keys to check
106
+ * @returns true if all features are supported
107
+ */
108
+ requiresFeatures(features: (keyof HarnessCapabilities)[]): boolean;
109
+ /**
110
+ * Anthropic SDK module (lazy loaded)
111
+ *
112
+ * Dynamically imported in initialize() to support optional dependencies.
113
+ * Typed using typeof import() pattern for accurate module types.
114
+ *
115
+ * @internal
116
+ */
117
+ private sdk;
118
+ /**
119
+ * MCP handler for server registration and tool management
120
+ *
121
+ * Manages MCP server connections and converts tools to SDK format.
122
+ * Created on first use and reused for subsequent registrations.
123
+ *
124
+ * @internal
125
+ */
126
+ private mcpHandler;
127
+ /**
128
+ * SDK MCP server configuration for use in execute()
129
+ *
130
+ * Stores the converted SDK server config from registerMCPs().
131
+ * Used in sdkOptions.mcpServers during execute() calls.
132
+ *
133
+ * @internal
134
+ */
135
+ private mcpServerConfig;
136
+ /**
137
+ * Combined skills prompt for injection into system prompts
138
+ *
139
+ * Stores the formatted skills content from loadSkills() for injection
140
+ * into system prompts during execute() calls. Skills are combined with
141
+ * markdown headers and separators.
142
+ *
143
+ * @internal
144
+ */
145
+ private skillsPrompt;
146
+ /**
147
+ * Session storage backend
148
+ *
149
+ * Manages session state using pluggable storage backends. Defaults to
150
+ * in-memory storage but can be configured with file-based, Redis, or
151
+ * custom implementations via ProviderOptions or setSessionStore().
152
+ *
153
+ * @internal
154
+ */
155
+ private sessionStore;
156
+ /**
157
+ * Session TTL in milliseconds from ProviderOptions
158
+ *
159
+ * @internal
160
+ */
161
+ private sessionTtl?;
162
+ /**
163
+ * Initialize the Anthropic provider
164
+ *
165
+ * Loads the Anthropic SDK and initializes the client.
166
+ *
167
+ * @param options - Optional provider configuration (apiKey, endpoint, sessionPersistence, etc.)
168
+ * @remarks Session storage defaults to MemorySessionStore if not specified.
169
+ * Implemented in P2.M1.T1.S2
170
+ */
171
+ initialize(options?: ClaudeCodeHarnessOptions): Promise<void>;
172
+ /**
173
+ * Terminate the provider and cleanup resources
174
+ *
175
+ * Clears the SDK module reference to allow garbage collection.
176
+ * The Anthropic SDK is stateless and manages its own resources internally.
177
+ *
178
+ * @remarks
179
+ * Implemented in P2.M1.T1.S3
180
+ */
181
+ terminate(): Promise<void>;
182
+ /**
183
+ * Execute a prompt request
184
+ *
185
+ * Constructs the SDK query from ProviderRequest and executes it via the Anthropic SDK.
186
+ *
187
+ * When options.streaming is true, returns an AsyncGenerator that yields StreamEvent objects.
188
+ * When options.streaming is false or undefined, returns a complete AgentResponse.
189
+ *
190
+ * @param request - Provider request with prompt and options
191
+ * @param toolExecutor - Callback for executing tools (used in P2.M1.T1.S6)
192
+ * @param hooks - Optional lifecycle hooks (adapter in P2.M1.T2.S1)
193
+ * @returns Typed agent response or AsyncGenerator for streaming
194
+ * @throws {ConfigError} (code CONFIG_ERROR) if request.options.model resolves to a
195
+ * non-anthropic provider (PRD §7.8) — enforced via normalizeModel.
196
+ * @remarks
197
+ * P2.M1.T1.S5: Query construction - builds AgentSDKOptions and calls SDK query()
198
+ * P2.M1.T1.S6: Message iteration - iterates AsyncGenerator and builds AgentResponse
199
+ * Streaming: Returns AsyncGenerator<StreamEvent> when options.streaming = true
200
+ */
201
+ execute<T>(request: HarnessRequest, toolExecutor: (req: ToolExecutionRequest) => Promise<ToolExecutionResult>, hooks?: HarnessHookEvents): Promise<AgentResponse<T>> | AsyncGenerator<StreamEvent, AgentResponse<T>, unknown>;
202
+ /**
203
+ * Execute a prompt request with streaming
204
+ *
205
+ * Returns an AsyncGenerator that yields StreamEvent objects during execution.
206
+ * Implements streaming mode for real-time response generation.
207
+ *
208
+ * @param request - Provider request with prompt and options
209
+ * @param toolExecutor - Callback for executing tools
210
+ * @param hooks - Optional lifecycle hooks
211
+ * @returns AsyncGenerator yielding StreamEvent objects, returning final AgentResponse
212
+ * @private
213
+ * @remarks
214
+ * Streaming mode implementation following PRP P4.M2.T1.S4 specification.
215
+ */
216
+ private executeStreaming;
217
+ /**
218
+ * Register MCP servers and return available tools
219
+ *
220
+ * Registers MCP servers with the internal MCPHandler and returns
221
+ * discovered tools in MCP format. Also converts tools to SDK format
222
+ * and stores the configuration for use in execute().
223
+ *
224
+ * @param servers - Array of MCP server configurations (required)
225
+ * @returns Array of discovered tools in MCP format (serverName__toolName)
226
+ * @remarks Modifies internal MCP handler state, converts tools to SDK format.
227
+ * Implemented in P2.M1.T1.S7
228
+ *
229
+ * @example
230
+ * ```ts
231
+ * const provider = new AnthropicProvider();
232
+ * await provider.initialize();
233
+ *
234
+ * const tools = await provider.registerMCPs([
235
+ * {
236
+ * name: 'filesystem',
237
+ * transport: 'inprocess',
238
+ * tools: [
239
+ * {
240
+ * name: 'read_file',
241
+ * description: 'Read a file',
242
+ * input_schema: {
243
+ * type: 'object',
244
+ * properties: { path: { type: 'string' } },
245
+ * required: ['path']
246
+ * }
247
+ * }
248
+ * ]
249
+ * }
250
+ * ]);
251
+ *
252
+ * console.log(tools); // [{ name: 'filesystem__read_file', ... }]
253
+ * ```
254
+ */
255
+ registerMCPs(servers: MCPServer[]): Promise<Tool[]>;
256
+ /**
257
+ * Load skills into the provider
258
+ *
259
+ * Skills are read from SKILL.md files in each skill directory and combined
260
+ * into a formatted system prompt fragment for injection during execute().
261
+ *
262
+ * @param skills - Array of skill definitions with name and path (empty array clears existing skills)
263
+ * @throws {Error} When SDK is not initialized
264
+ * @throws {Error} When SKILL.md file cannot be read
265
+ * @remarks Each skill directory must contain a SKILL.md file. Skills are combined
266
+ * with markdown headers (### Skill Name) and separators (---).
267
+ *
268
+ * @example
269
+ * ```ts
270
+ * const provider = new AnthropicProvider();
271
+ * await provider.initialize();
272
+ * await provider.loadSkills([
273
+ * { name: 'math-expert', path: '/skills/math' },
274
+ * { name: 'code-reviewer', path: '/skills/code' }
275
+ * ]);
276
+ * ```
277
+ */
278
+ loadSkills(skills: Skill[]): Promise<void>;
279
+ /**
280
+ * Build system prompt with skills injected
281
+ *
282
+ * Combines the base system prompt with loaded skills for injection into
283
+ * the Anthropic SDK's systemPrompt parameter.
284
+ *
285
+ * @param baseSystemPrompt - Optional base system prompt to enhance with skills
286
+ * @returns Enhanced system prompt with skills section, or base prompt unchanged if no skills loaded
287
+ * @internal
288
+ * @remarks
289
+ * Three handling cases:
290
+ * 1. No skills loaded - returns basePrompt unchanged
291
+ * 2. No base prompt - returns skills-only prompt with default header
292
+ * 3. Both exist - combines with "## Available Skills" section
293
+ */
294
+ private buildSystemPromptWithSkills;
295
+ /**
296
+ * Build Agent SDK hooks from Provider hook events
297
+ *
298
+ * Adapts ProviderHookEvents to Anthropic Agent SDK-compatible hook format.
299
+ * Transforms signatures between Provider and SDK hook formats and handles
300
+ * async/sync hook execution.
301
+ *
302
+ * @param hooks - Optional provider hook events to adapt
303
+ * @returns SDK-compatible hooks object with HookCallbackMatcher arrays
304
+ * @internal
305
+ * @remarks
306
+ * Hook mapping:
307
+ * - onToolStart → PreToolUse
308
+ * - onToolEnd → PostToolUse
309
+ * - onSessionStart → SessionStart
310
+ * - onSessionEnd → SessionEnd
311
+ *
312
+ * Each adapter returns { continue: true } for SDK compatibility.
313
+ * Duration values are set to 0 as SDK doesn't provide them in hook input.
314
+ */
315
+ private buildAgentSDKHooks;
316
+ /**
317
+ * Normalize a model string to a ModelSpec
318
+ *
319
+ * Parses model strings in two formats:
320
+ * - Plain: "claude-sonnet-4" → { provider: 'anthropic', model: 'claude-sonnet-4', raw: 'claude-sonnet-4' }
321
+ * - Qualified: "anthropic/claude-opus-4" → { provider: 'anthropic', model: 'claude-opus-4', raw: 'anthropic/claude-opus-4' }
322
+ *
323
+ * Delegates to {@link parseModelSpec} for parsing and validation.
324
+ * Validates that the provider is 'anthropic'.
325
+ *
326
+ * @param model - Model string to normalize (required)
327
+ * @returns Parsed ModelSpec with provider='anthropic'
328
+ * @throws {Error} When model specification is invalid (delegated to parseModelSpec)
329
+ * @throws {ConfigError} When provider is not 'anthropic' (code === AGENT_ERROR_CODES.CONFIG_ERROR)
330
+ *
331
+ * @example
332
+ * ```ts
333
+ * const provider = new AnthropicProvider();
334
+ *
335
+ * // Plain format
336
+ * provider.normalizeModel('claude-sonnet-4');
337
+ * // Returns: { provider: 'anthropic', model: 'claude-sonnet-4', raw: 'claude-sonnet-4' }
338
+ *
339
+ * // Qualified format
340
+ * provider.normalizeModel('anthropic/claude-opus-4');
341
+ * // Returns: { provider: 'anthropic', model: 'claude-opus-4', raw: 'anthropic/claude-opus-4' }
342
+ *
343
+ * // Error: wrong provider
344
+ * provider.normalizeModel('openai/gpt-4');
345
+ * // Throws: "Cannot normalize openai/gpt-4 with ClaudeCodeHarness..."
346
+ * ```
347
+ */
348
+ normalizeModel(model: string): ModelSpec;
349
+ /**
350
+ * Create a new session with the specified ID
351
+ *
352
+ * Initializes empty session state for the given session ID.
353
+ * If session already exists, this is a no-op (idempotent).
354
+ *
355
+ * @param sessionId - Unique identifier for the session (required)
356
+ * @throws {Error} If SDK is not initialized
357
+ * @remarks Idempotent: if session exists, this is a no-op.
358
+ * Session will be used when execute() receives matching sessionId in options.
359
+ */
360
+ createSession(sessionId: string): Promise<void>;
361
+ /**
362
+ * Get session state for the specified ID
363
+ *
364
+ * Retrieves the current session state including conversation history
365
+ * and last result. Returns undefined if session doesn't exist.
366
+ *
367
+ * @param sessionId - Session identifier to retrieve (required)
368
+ * @returns Session state or undefined if not found
369
+ * @remarks Updates lastAccessedAt timestamp and saves back to persistent stores.
370
+ */
371
+ getSession(sessionId: string): Promise<SessionState | undefined>;
372
+ /**
373
+ * Delete a session
374
+ *
375
+ * Removes the session from storage. If the session doesn't exist,
376
+ * returns false.
377
+ *
378
+ * @param sessionId - Session identifier to delete (required)
379
+ * @returns true if deleted, false if not found
380
+ * @throws {Error} If SDK is not initialized
381
+ * @remarks Destructive operation: deleted sessions cannot be recovered
382
+ * unless the store has backup/retention policies.
383
+ */
384
+ deleteSession(sessionId: string): Promise<boolean>;
385
+ }
386
+ /**
387
+ * @deprecated Since v1.2. Use {@link ClaudeCodeHarness}. Renamed as part of the
388
+ * Harness/Provider split (PRD §7). Identity preserved for backward compatibility.
389
+ */
390
+ export declare const AnthropicProvider: typeof ClaudeCodeHarness;
391
+ //# sourceMappingURL=claude-code-harness.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claude-code-harness.d.ts","sourceRoot":"","sources":["../../src/harnesses/claude-code-harness.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO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