vibeman 0.0.5 → 0.0.7

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 (239) hide show
  1. package/dist/api.js +43 -0
  2. package/dist/index.js +227 -104
  3. package/dist/ui/assets/index-C_kQPI1m.js +9 -0
  4. package/dist/ui/index.html +12 -0
  5. package/package.json +13 -46
  6. package/README.md +0 -12
  7. package/dist/runtime/api/.tsbuildinfo +0 -1
  8. package/dist/runtime/api/agent/agent-service.d.ts +0 -229
  9. package/dist/runtime/api/agent/agent-service.js +0 -963
  10. package/dist/runtime/api/agent/ai-providers/amp-cli-provider.d.ts +0 -38
  11. package/dist/runtime/api/agent/ai-providers/amp-cli-provider.js +0 -268
  12. package/dist/runtime/api/agent/ai-providers/claude-code-adapter.d.ts +0 -61
  13. package/dist/runtime/api/agent/ai-providers/claude-code-adapter.js +0 -362
  14. package/dist/runtime/api/agent/ai-providers/codex-cli-provider.d.ts +0 -36
  15. package/dist/runtime/api/agent/ai-providers/codex-cli-provider.js +0 -375
  16. package/dist/runtime/api/agent/ai-providers/gemini-cli-provider.d.ts +0 -24
  17. package/dist/runtime/api/agent/ai-providers/gemini-cli-provider.js +0 -291
  18. package/dist/runtime/api/agent/ai-providers/index.d.ts +0 -9
  19. package/dist/runtime/api/agent/ai-providers/index.js +0 -9
  20. package/dist/runtime/api/agent/ai-providers/types.d.ts +0 -185
  21. package/dist/runtime/api/agent/ai-providers/types.js +0 -5
  22. package/dist/runtime/api/agent/amp-cli-provider.test.d.ts +0 -1
  23. package/dist/runtime/api/agent/amp-cli-provider.test.js +0 -99
  24. package/dist/runtime/api/agent/codex-cli-provider.test.d.ts +0 -1
  25. package/dist/runtime/api/agent/codex-cli-provider.test.js +0 -172
  26. package/dist/runtime/api/agent/core-agent-service.d.ts +0 -119
  27. package/dist/runtime/api/agent/core-agent-service.js +0 -267
  28. package/dist/runtime/api/agent/parsers.d.ts +0 -16
  29. package/dist/runtime/api/agent/parsers.js +0 -308
  30. package/dist/runtime/api/agent/prompt-service.d.ts +0 -30
  31. package/dist/runtime/api/agent/prompt-service.js +0 -452
  32. package/dist/runtime/api/agent/prompt-service.test.d.ts +0 -1
  33. package/dist/runtime/api/agent/prompt-service.test.js +0 -265
  34. package/dist/runtime/api/agent/routing-policy.d.ts +0 -171
  35. package/dist/runtime/api/agent/routing-policy.js +0 -196
  36. package/dist/runtime/api/agent/routing-policy.test.d.ts +0 -1
  37. package/dist/runtime/api/agent/routing-policy.test.js +0 -63
  38. package/dist/runtime/api/api/router-helpers.d.ts +0 -32
  39. package/dist/runtime/api/api/router-helpers.js +0 -31
  40. package/dist/runtime/api/api/routers/ai.d.ts +0 -200
  41. package/dist/runtime/api/api/routers/ai.js +0 -396
  42. package/dist/runtime/api/api/routers/executions.d.ts +0 -93
  43. package/dist/runtime/api/api/routers/executions.js +0 -94
  44. package/dist/runtime/api/api/routers/git.d.ts +0 -45
  45. package/dist/runtime/api/api/routers/git.js +0 -35
  46. package/dist/runtime/api/api/routers/provider-config.d.ts +0 -199
  47. package/dist/runtime/api/api/routers/provider-config.js +0 -252
  48. package/dist/runtime/api/api/routers/settings.d.ts +0 -158
  49. package/dist/runtime/api/api/routers/settings.js +0 -129
  50. package/dist/runtime/api/api/routers/tasks.d.ts +0 -141
  51. package/dist/runtime/api/api/routers/tasks.js +0 -238
  52. package/dist/runtime/api/api/routers/workflows.d.ts +0 -275
  53. package/dist/runtime/api/api/routers/workflows.js +0 -311
  54. package/dist/runtime/api/api/routers/worktrees.d.ts +0 -101
  55. package/dist/runtime/api/api/routers/worktrees.js +0 -80
  56. package/dist/runtime/api/api/trpc.d.ts +0 -118
  57. package/dist/runtime/api/api/trpc.js +0 -34
  58. package/dist/runtime/api/index.d.ts +0 -9
  59. package/dist/runtime/api/index.js +0 -117
  60. package/dist/runtime/api/lib/id-generator.d.ts +0 -70
  61. package/dist/runtime/api/lib/id-generator.js +0 -123
  62. package/dist/runtime/api/lib/local-config.d.ts +0 -335
  63. package/dist/runtime/api/lib/local-config.js +0 -304
  64. package/dist/runtime/api/lib/logger.d.ts +0 -11
  65. package/dist/runtime/api/lib/logger.js +0 -188
  66. package/dist/runtime/api/lib/provider-detection.d.ts +0 -61
  67. package/dist/runtime/api/lib/provider-detection.js +0 -326
  68. package/dist/runtime/api/lib/server/agent-service-singleton.d.ts +0 -6
  69. package/dist/runtime/api/lib/server/agent-service-singleton.js +0 -27
  70. package/dist/runtime/api/lib/server/bootstrap.d.ts +0 -38
  71. package/dist/runtime/api/lib/server/bootstrap.js +0 -197
  72. package/dist/runtime/api/lib/server/git-service-singleton.d.ts +0 -6
  73. package/dist/runtime/api/lib/server/git-service-singleton.js +0 -47
  74. package/dist/runtime/api/lib/server/project-root.d.ts +0 -2
  75. package/dist/runtime/api/lib/server/project-root.js +0 -61
  76. package/dist/runtime/api/lib/server/task-service-singleton.d.ts +0 -7
  77. package/dist/runtime/api/lib/server/task-service-singleton.js +0 -58
  78. package/dist/runtime/api/lib/server/vibeman-info.d.ts +0 -5
  79. package/dist/runtime/api/lib/server/vibeman-info.js +0 -85
  80. package/dist/runtime/api/lib/server/vibing-orchestrator-singleton.d.ts +0 -7
  81. package/dist/runtime/api/lib/server/vibing-orchestrator-singleton.js +0 -57
  82. package/dist/runtime/api/lib/trpc/server.d.ts +0 -965
  83. package/dist/runtime/api/lib/trpc/server.js +0 -11
  84. package/dist/runtime/api/lib/trpc/ws-server.d.ts +0 -8
  85. package/dist/runtime/api/lib/trpc/ws-server.js +0 -33
  86. package/dist/runtime/api/persistence/database-service.d.ts +0 -14
  87. package/dist/runtime/api/persistence/database-service.js +0 -74
  88. package/dist/runtime/api/persistence/execution-log-persistence.d.ts +0 -90
  89. package/dist/runtime/api/persistence/execution-log-persistence.js +0 -426
  90. package/dist/runtime/api/persistence/execution-log-persistence.test.d.ts +0 -1
  91. package/dist/runtime/api/persistence/execution-log-persistence.test.js +0 -170
  92. package/dist/runtime/api/router.d.ts +0 -968
  93. package/dist/runtime/api/router.js +0 -34
  94. package/dist/runtime/api/settings-service.d.ts +0 -110
  95. package/dist/runtime/api/settings-service.js +0 -678
  96. package/dist/runtime/api/tasks/file-watcher.d.ts +0 -23
  97. package/dist/runtime/api/tasks/file-watcher.js +0 -88
  98. package/dist/runtime/api/tasks/task-file-parser.d.ts +0 -14
  99. package/dist/runtime/api/tasks/task-file-parser.js +0 -180
  100. package/dist/runtime/api/tasks/task-service.d.ts +0 -36
  101. package/dist/runtime/api/tasks/task-service.js +0 -173
  102. package/dist/runtime/api/tasks/task-updater.d.ts +0 -62
  103. package/dist/runtime/api/tasks/task-updater.js +0 -260
  104. package/dist/runtime/api/tasks/task-updater.test.d.ts +0 -1
  105. package/dist/runtime/api/tasks/task-updater.test.js +0 -303
  106. package/dist/runtime/api/types/index.d.ts +0 -186
  107. package/dist/runtime/api/types/index.js +0 -1
  108. package/dist/runtime/api/types/settings.d.ts +0 -105
  109. package/dist/runtime/api/types/settings.js +0 -2
  110. package/dist/runtime/api/types.d.ts +0 -2
  111. package/dist/runtime/api/types.js +0 -1
  112. package/dist/runtime/api/utils/env.d.ts +0 -6
  113. package/dist/runtime/api/utils/env.js +0 -12
  114. package/dist/runtime/api/utils/stripNextEnv.d.ts +0 -7
  115. package/dist/runtime/api/utils/stripNextEnv.js +0 -22
  116. package/dist/runtime/api/utils/title-slug.d.ts +0 -6
  117. package/dist/runtime/api/utils/title-slug.js +0 -77
  118. package/dist/runtime/api/utils/url.d.ts +0 -2
  119. package/dist/runtime/api/utils/url.js +0 -19
  120. package/dist/runtime/api/vcs/git-history-service.d.ts +0 -57
  121. package/dist/runtime/api/vcs/git-history-service.js +0 -228
  122. package/dist/runtime/api/vcs/git-service.d.ts +0 -136
  123. package/dist/runtime/api/vcs/git-service.js +0 -307
  124. package/dist/runtime/api/vcs/worktree-service.d.ts +0 -93
  125. package/dist/runtime/api/vcs/worktree-service.js +0 -518
  126. package/dist/runtime/api/vcs/worktree-service.test.d.ts +0 -1
  127. package/dist/runtime/api/vcs/worktree-service.test.js +0 -20
  128. package/dist/runtime/api/workflows/quality-pipeline.d.ts +0 -58
  129. package/dist/runtime/api/workflows/quality-pipeline.js +0 -401
  130. package/dist/runtime/api/workflows/vibing-orchestrator.d.ts +0 -406
  131. package/dist/runtime/api/workflows/vibing-orchestrator.js +0 -2462
  132. package/dist/runtime/api/workflows/workflow-effects.d.ts +0 -45
  133. package/dist/runtime/api/workflows/workflow-effects.js +0 -49
  134. package/dist/runtime/api/workflows/workflow-reconciler.d.ts +0 -65
  135. package/dist/runtime/api/workflows/workflow-reconciler.js +0 -226
  136. package/dist/runtime/api/workflows/workflow-reducer.d.ts +0 -26
  137. package/dist/runtime/api/workflows/workflow-reducer.js +0 -288
  138. package/dist/runtime/api/workflows/workflow-reducer.test.d.ts +0 -1
  139. package/dist/runtime/api/workflows/workflow-reducer.test.js +0 -247
  140. package/dist/runtime/api/workflows/workflow-schema.d.ts +0 -546
  141. package/dist/runtime/api/workflows/workflow-schema.js +0 -256
  142. package/dist/runtime/web/.next/BUILD_ID +0 -1
  143. package/dist/runtime/web/.next/app-build-manifest.json +0 -66
  144. package/dist/runtime/web/.next/app-path-routes-manifest.json +0 -8
  145. package/dist/runtime/web/.next/build-manifest.json +0 -33
  146. package/dist/runtime/web/.next/package.json +0 -1
  147. package/dist/runtime/web/.next/prerender-manifest.json +0 -61
  148. package/dist/runtime/web/.next/react-loadable-manifest.json +0 -8
  149. package/dist/runtime/web/.next/required-server-files.json +0 -334
  150. package/dist/runtime/web/.next/routes-manifest.json +0 -70
  151. package/dist/runtime/web/.next/server/app/.vibeman/assets/images/[...path]/route.js +0 -1
  152. package/dist/runtime/web/.next/server/app/.vibeman/assets/images/[...path]/route.js.nft.json +0 -1
  153. package/dist/runtime/web/.next/server/app/.vibeman/assets/images/[...path]/route_client-reference-manifest.js +0 -1
  154. package/dist/runtime/web/.next/server/app/_not-found/page.js +0 -2
  155. package/dist/runtime/web/.next/server/app/_not-found/page.js.nft.json +0 -1
  156. package/dist/runtime/web/.next/server/app/_not-found/page_client-reference-manifest.js +0 -1
  157. package/dist/runtime/web/.next/server/app/_not-found.html +0 -7
  158. package/dist/runtime/web/.next/server/app/_not-found.meta +0 -8
  159. package/dist/runtime/web/.next/server/app/_not-found.rsc +0 -22
  160. package/dist/runtime/web/.next/server/app/api/health/route.js +0 -1
  161. package/dist/runtime/web/.next/server/app/api/health/route.js.nft.json +0 -1
  162. package/dist/runtime/web/.next/server/app/api/health/route_client-reference-manifest.js +0 -1
  163. package/dist/runtime/web/.next/server/app/api/images/[...path]/route.js +0 -1
  164. package/dist/runtime/web/.next/server/app/api/images/[...path]/route.js.nft.json +0 -1
  165. package/dist/runtime/web/.next/server/app/api/images/[...path]/route_client-reference-manifest.js +0 -1
  166. package/dist/runtime/web/.next/server/app/api/upload/route.js +0 -1
  167. package/dist/runtime/web/.next/server/app/api/upload/route.js.nft.json +0 -1
  168. package/dist/runtime/web/.next/server/app/api/upload/route_client-reference-manifest.js +0 -1
  169. package/dist/runtime/web/.next/server/app/index.html +0 -7
  170. package/dist/runtime/web/.next/server/app/index.meta +0 -7
  171. package/dist/runtime/web/.next/server/app/index.rsc +0 -27
  172. package/dist/runtime/web/.next/server/app/page.js +0 -112
  173. package/dist/runtime/web/.next/server/app/page.js.nft.json +0 -1
  174. package/dist/runtime/web/.next/server/app/page_client-reference-manifest.js +0 -1
  175. package/dist/runtime/web/.next/server/app-paths-manifest.json +0 -8
  176. package/dist/runtime/web/.next/server/chunks/210.js +0 -1
  177. package/dist/runtime/web/.next/server/chunks/291.js +0 -18
  178. package/dist/runtime/web/.next/server/chunks/552.js +0 -22
  179. package/dist/runtime/web/.next/server/chunks/780.js +0 -1
  180. package/dist/runtime/web/.next/server/chunks/905.js +0 -6
  181. package/dist/runtime/web/.next/server/chunks/98.js +0 -1
  182. package/dist/runtime/web/.next/server/functions-config-manifest.json +0 -4
  183. package/dist/runtime/web/.next/server/middleware-build-manifest.js +0 -1
  184. package/dist/runtime/web/.next/server/middleware-manifest.json +0 -6
  185. package/dist/runtime/web/.next/server/middleware-react-loadable-manifest.js +0 -1
  186. package/dist/runtime/web/.next/server/next-font-manifest.js +0 -1
  187. package/dist/runtime/web/.next/server/next-font-manifest.json +0 -1
  188. package/dist/runtime/web/.next/server/pages/404.html +0 -7
  189. package/dist/runtime/web/.next/server/pages/500.html +0 -1
  190. package/dist/runtime/web/.next/server/pages/_app.js +0 -1
  191. package/dist/runtime/web/.next/server/pages/_app.js.nft.json +0 -1
  192. package/dist/runtime/web/.next/server/pages/_document.js +0 -1
  193. package/dist/runtime/web/.next/server/pages/_document.js.nft.json +0 -1
  194. package/dist/runtime/web/.next/server/pages/_error.js +0 -19
  195. package/dist/runtime/web/.next/server/pages/_error.js.nft.json +0 -1
  196. package/dist/runtime/web/.next/server/pages-manifest.json +0 -6
  197. package/dist/runtime/web/.next/server/server-reference-manifest.js +0 -1
  198. package/dist/runtime/web/.next/server/server-reference-manifest.json +0 -1
  199. package/dist/runtime/web/.next/server/webpack-runtime.js +0 -1
  200. package/dist/runtime/web/.next/static/LJFZk_8tvKFN_Ee4HqUuM/_buildManifest.js +0 -1
  201. package/dist/runtime/web/.next/static/LJFZk_8tvKFN_Ee4HqUuM/_ssgManifest.js +0 -1
  202. package/dist/runtime/web/.next/static/chunks/05c91ade-7d09b2b280adffd1.js +0 -1
  203. package/dist/runtime/web/.next/static/chunks/201-51bef3fa8c832e2e.js +0 -1
  204. package/dist/runtime/web/.next/static/chunks/524-89747ed9b0294f8a.js +0 -1
  205. package/dist/runtime/web/.next/static/chunks/554-8bec6e9cca6acc67.js +0 -1
  206. package/dist/runtime/web/.next/static/chunks/764.86e9503a69d45a85.js +0 -1
  207. package/dist/runtime/web/.next/static/chunks/7ab4dc20-239138e0ae7af24a.js +0 -1
  208. package/dist/runtime/web/.next/static/chunks/905-342391e3d3a3678f.js +0 -20
  209. package/dist/runtime/web/.next/static/chunks/a8a5ce16-4edea7df2d9b544a.js +0 -79
  210. package/dist/runtime/web/.next/static/chunks/ad74d572-4c1b162e2c15acaa.js +0 -1
  211. package/dist/runtime/web/.next/static/chunks/app/.vibeman/assets/images/[...path]/route-7b752a8641f96c1f.js +0 -1
  212. package/dist/runtime/web/.next/static/chunks/app/_not-found/page-34e66b251c2b5044.js +0 -1
  213. package/dist/runtime/web/.next/static/chunks/app/api/health/route-7b752a8641f96c1f.js +0 -1
  214. package/dist/runtime/web/.next/static/chunks/app/api/images/[...path]/route-7b752a8641f96c1f.js +0 -1
  215. package/dist/runtime/web/.next/static/chunks/app/api/upload/route-7b752a8641f96c1f.js +0 -1
  216. package/dist/runtime/web/.next/static/chunks/app/layout-df9ac93cb02b2385.js +0 -1
  217. package/dist/runtime/web/.next/static/chunks/app/page-6610743f7de5f92a.js +0 -1
  218. package/dist/runtime/web/.next/static/chunks/c25e0690-e9b798b8de667da1.js +0 -1
  219. package/dist/runtime/web/.next/static/chunks/framework-57157ec4d37f64aa.js +0 -1
  220. package/dist/runtime/web/.next/static/chunks/main-app-156cc0c60371bd78.js +0 -1
  221. package/dist/runtime/web/.next/static/chunks/main-df25d367c47b1fec.js +0 -1
  222. package/dist/runtime/web/.next/static/chunks/pages/_app-9f629a5e1131d19f.js +0 -1
  223. package/dist/runtime/web/.next/static/chunks/pages/_error-9238238274c7efcd.js +0 -1
  224. package/dist/runtime/web/.next/static/chunks/polyfills-42372ed130431b0a.js +0 -1
  225. package/dist/runtime/web/.next/static/chunks/webpack-cd50e39b423d1808.js +0 -1
  226. package/dist/runtime/web/.next/static/css/2728291c68f99cb1.css +0 -3
  227. package/dist/runtime/web/.next/static/css/4fbf378a264bd4ea.css +0 -1
  228. package/dist/runtime/web/.next/static/css/521bd69cc298cd1a.css +0 -1
  229. package/dist/runtime/web/.next/static/css/537e22821e101b87.css +0 -1
  230. package/dist/runtime/web/.next/static/media/19cfc7226ec3afaa-s.woff2 +0 -0
  231. package/dist/runtime/web/.next/static/media/21350d82a1f187e9-s.woff2 +0 -0
  232. package/dist/runtime/web/.next/static/media/8e9860b6e62d6359-s.woff2 +0 -0
  233. package/dist/runtime/web/.next/static/media/ba9851c3c22cd980-s.woff2 +0 -0
  234. package/dist/runtime/web/.next/static/media/c5fe6dc8356a8c31-s.woff2 +0 -0
  235. package/dist/runtime/web/.next/static/media/df0a9ae256c0569c-s.woff2 +0 -0
  236. package/dist/runtime/web/.next/static/media/e4af272ccee01ff0-s.p.woff2 +0 -0
  237. package/dist/runtime/web/package.json +0 -65
  238. package/dist/runtime/web/server.js +0 -44
  239. package/dist/tsconfig.tsbuildinfo +0 -1
@@ -1,38 +0,0 @@
1
- /**
2
- * Amp CLI Provider
3
- * Headless wrapper around the Amp CLI `amp -x` command.
4
- */
5
- import { AIProvider, ExecutionMessage, ExecutionOptions, ModelInfo, ProviderCapabilities, ProviderStatus } from './types.js';
6
- export interface AmpCliConfig {
7
- ampBinPath?: string;
8
- defaultWorkingDirectory?: string;
9
- /**
10
- * Amp CLI does not support explicit model selection in this integration.
11
- * Kept for backwards compatibility but ignored.
12
- */
13
- defaultModel?: string;
14
- defaultTimeoutMs?: number;
15
- }
16
- export declare class AmpCliProvider implements AIProvider {
17
- private config;
18
- readonly name = "amp";
19
- readonly displayName = "Amp CLI";
20
- constructor(config?: AmpCliConfig);
21
- private resolveExecutable;
22
- execute(prompt: string, options?: ExecutionOptions): AsyncIterableIterator<ExecutionMessage>;
23
- executeSync(prompt: string, options?: ExecutionOptions): Promise<{
24
- id: string;
25
- provider: string;
26
- model: string;
27
- content: string;
28
- usage: {
29
- promptTokens: number;
30
- completionTokens: number;
31
- totalTokens: number;
32
- };
33
- duration: number;
34
- }>;
35
- detectAvailableModels(): Promise<ModelInfo[]>;
36
- validateSetup(): Promise<ProviderStatus>;
37
- getCapabilities(): ProviderCapabilities;
38
- }
@@ -1,268 +0,0 @@
1
- /**
2
- * Amp CLI Provider
3
- * Headless wrapper around the Amp CLI `amp -x` command.
4
- */
5
- import { spawn } from 'child_process';
6
- import { getSettingsService } from '../../settings-service.js';
7
- import { getProviderDetectionService } from '../../lib/provider-detection.js';
8
- import { logger } from '../../lib/logger.js';
9
- export class AmpCliProvider {
10
- constructor(config = {}) {
11
- this.config = config;
12
- this.name = 'amp';
13
- this.displayName = 'Amp CLI';
14
- }
15
- async resolveExecutable() {
16
- if (this.config.ampBinPath)
17
- return this.config.ampBinPath;
18
- // Use enhanced detection service
19
- const detectionService = getProviderDetectionService();
20
- const result = await detectionService.detectProvider('amp');
21
- if (result.found && result.path) {
22
- return result.path;
23
- }
24
- // Fallback: try old settings-based approach (though new for Amp, following pattern)
25
- const settingsBinPath = (() => {
26
- try {
27
- const svc = getSettingsService();
28
- const s = svc.getSettings();
29
- return s?.agents?.providers?.amp?.binPath;
30
- }
31
- catch {
32
- return undefined;
33
- }
34
- })();
35
- if (settingsBinPath?.trim())
36
- return settingsBinPath.trim();
37
- // Default to binary name (resolve via PATH)
38
- return 'amp';
39
- }
40
- async *execute(prompt, options) {
41
- // Effective options
42
- const cwd = options?.workingDirectory || this.config.defaultWorkingDirectory || process.cwd();
43
- // Amp CLI runs in an automatic mode for model/tool selection in this integration.
44
- // We intentionally ignore any requested model.
45
- const requestedModel = options?.model || this.config.defaultModel;
46
- const model = 'auto';
47
- const timeoutMs = options?.timeout ?? this.config.defaultTimeoutMs ?? 10 * 60 * 1000; // 10m
48
- const systemPrompt = options?.systemPrompt?.trim();
49
- const appendSystemPrompt = options?.appendSystemPrompt?.trim();
50
- // Construct effective prompt
51
- const promptSegments = [];
52
- if (systemPrompt) {
53
- promptSegments.push(systemPrompt);
54
- }
55
- if (appendSystemPrompt) {
56
- promptSegments.push(appendSystemPrompt);
57
- }
58
- promptSegments.push(prompt);
59
- const effectivePrompt = promptSegments.join('\n\n');
60
- // Build argv for `amp -x`
61
- const argv = ['-x', effectivePrompt];
62
- if (options?.dangerouslyBypassApprovalsAndSandbox) {
63
- argv.push('--dangerously-allow-all');
64
- }
65
- const cmd = await this.resolveExecutable();
66
- const child = spawn(cmd, argv, {
67
- cwd,
68
- env: { ...process.env },
69
- stdio: ['ignore', 'pipe', 'pipe'],
70
- });
71
- // Emit an init/system message with effective command
72
- const init = {
73
- type: 'init',
74
- timestamp: new Date().toISOString(),
75
- sessionId: `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
76
- model,
77
- provider: this.name,
78
- };
79
- yield init;
80
- yield {
81
- type: 'system',
82
- timestamp: new Date().toISOString(),
83
- content: `Running: ${cmd} ${argv
84
- .map((a) => (a.includes(' ') ? '"' + a + '"' : a))
85
- .join(' ')} (cwd=${cwd})`,
86
- metadata: {
87
- provider: this.name,
88
- requestedModel,
89
- systemPrompt,
90
- appendSystemPrompt,
91
- dangerouslyBypassApprovalsAndSandbox: !!options?.dangerouslyBypassApprovalsAndSandbox,
92
- },
93
- };
94
- let stdoutBuf = '';
95
- let finished = false;
96
- let lastFlushedIndex = 0;
97
- let lineCarry = '';
98
- // Helper to push incremental stdout as assistant log lines
99
- const flushNewOutput = () => {
100
- const newChunk = stdoutBuf.slice(lastFlushedIndex);
101
- if (!newChunk)
102
- return;
103
- lastFlushedIndex = stdoutBuf.length;
104
- // Accumulate and split by line breaks, keep trailing partial
105
- lineCarry += newChunk;
106
- const parts = lineCarry.split(/\r?\n/);
107
- lineCarry = parts.pop() || '';
108
- return parts.map((l) => l.trimEnd()).filter(Boolean);
109
- };
110
- const onAbort = () => {
111
- try {
112
- child.kill('SIGTERM');
113
- }
114
- catch {
115
- /* ignore */
116
- }
117
- setTimeout(() => {
118
- if (!finished) {
119
- try {
120
- child.kill('SIGKILL');
121
- }
122
- catch {
123
- /* ignore */
124
- }
125
- }
126
- }, 3000);
127
- };
128
- if (options?.abortSignal) {
129
- if (options.abortSignal.aborted)
130
- onAbort();
131
- else
132
- options.abortSignal.addEventListener('abort', onAbort, { once: true });
133
- }
134
- const guard = setTimeout(() => {
135
- onAbort();
136
- }, timeoutMs);
137
- child.stdout?.on('data', (data) => {
138
- stdoutBuf += data.toString('utf8');
139
- });
140
- const exitPromise = new Promise((resolve) => {
141
- child.on('exit', (code, signal) => resolve({ code, signal }));
142
- });
143
- // Poll for output until the process exits
144
- let exitStatus;
145
- while (!finished) {
146
- const tick = new Promise((r) => setTimeout(r, 150));
147
- const exit = await Promise.race([exitPromise, tick]);
148
- if (exit && typeof exit.code !== 'undefined') {
149
- const lines = flushNewOutput();
150
- if (lines && lines.length) {
151
- for (const text of lines) {
152
- yield {
153
- type: 'assistant',
154
- timestamp: new Date().toISOString(),
155
- content: text,
156
- };
157
- }
158
- }
159
- finished = true;
160
- exitStatus = exit;
161
- break;
162
- }
163
- const lines = flushNewOutput();
164
- if (lines && lines.length) {
165
- for (const text of lines) {
166
- yield {
167
- type: 'assistant',
168
- timestamp: new Date().toISOString(),
169
- content: text,
170
- };
171
- }
172
- }
173
- }
174
- const exit = exitStatus ?? (await exitPromise);
175
- finished = true;
176
- clearTimeout(guard);
177
- if (lineCarry.trim()) {
178
- yield {
179
- type: 'assistant',
180
- timestamp: new Date().toISOString(),
181
- content: lineCarry.trimEnd(),
182
- };
183
- lineCarry = '';
184
- }
185
- const success = (exit.code ?? 1) === 0 && !exit.signal;
186
- const remainingStdout = stdoutBuf.trim();
187
- const resultMsg = {
188
- type: 'result',
189
- timestamp: new Date().toISOString(),
190
- success,
191
- result: success ? (remainingStdout || '').toString() : undefined,
192
- error: success
193
- ? undefined
194
- : `amp exited ${exit.signal ? 'by ' + exit.signal : 'with code ' + exit.code}`,
195
- usage: { promptTokens: 0, completionTokens: 0, totalTokens: 0 },
196
- };
197
- yield resultMsg;
198
- }
199
- async executeSync(prompt, options) {
200
- let content = '';
201
- const start = Date.now();
202
- for await (const msg of this.execute(prompt, options)) {
203
- if (msg.type === 'assistant' && typeof msg.content === 'string') {
204
- content += (content ? '\n' : '') + msg.content;
205
- }
206
- }
207
- return {
208
- id: `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
209
- provider: this.name,
210
- model: 'auto',
211
- content,
212
- usage: { promptTokens: 0, completionTokens: 0, totalTokens: 0 },
213
- duration: Date.now() - start,
214
- };
215
- }
216
- async detectAvailableModels() {
217
- const capabilities = ['code', 'analysis', 'tools', 'vision', 'reasoning'];
218
- const makeModel = (id, displayName) => ({
219
- id,
220
- name: id,
221
- displayName,
222
- provider: this.name,
223
- contextWindow: 128000,
224
- maxOutputTokens: 16384,
225
- capabilities,
226
- });
227
- return [makeModel('auto', 'Auto (recommended)')];
228
- }
229
- async validateSetup() {
230
- try {
231
- const detectionService = getProviderDetectionService();
232
- const result = await detectionService.detectProvider('amp');
233
- if (!result.found) {
234
- return {
235
- available: false,
236
- error: result.error || 'Amp CLI not found. Install Amp and ensure it is in your PATH.',
237
- models: [],
238
- capabilities: this.getCapabilities(),
239
- };
240
- }
241
- return {
242
- available: true,
243
- models: await this.detectAvailableModels(),
244
- capabilities: this.getCapabilities(),
245
- };
246
- }
247
- catch (error) {
248
- logger.error(error);
249
- return {
250
- available: false,
251
- error: error instanceof Error ? error.message : String(error),
252
- models: [],
253
- capabilities: this.getCapabilities(),
254
- };
255
- }
256
- }
257
- getCapabilities() {
258
- return {
259
- streaming: true,
260
- tools: true,
261
- functionCalling: false,
262
- vision: true,
263
- codeExecution: true,
264
- maxContextWindow: 128000,
265
- maxOutputTokens: 8192,
266
- };
267
- }
268
- }
@@ -1,61 +0,0 @@
1
- /**
2
- * Claude Code Adapter
3
- * Implements AIProvider interface for Claude Code SDK
4
- */
5
- import { AIProvider, ExecutionOptions, ExecutionMessage, ExecutionResult, ModelInfo, ProviderStatus, ProviderCapabilities } from './types.js';
6
- /**
7
- * Configuration for Claude Code Adapter
8
- */
9
- export interface ClaudeCodeConfig {
10
- /**
11
- * Path to Claude CLI executable
12
- * If not provided, will use default resolution
13
- */
14
- claudeBinPath?: string;
15
- /**
16
- * Default working directory
17
- */
18
- defaultWorkingDirectory?: string;
19
- /**
20
- * Default model to use
21
- */
22
- defaultModel?: string;
23
- }
24
- /**
25
- * Claude Code Adapter
26
- * Wraps the Claude Code SDK to implement the AIProvider interface
27
- */
28
- export declare class ClaudeCodeAdapter implements AIProvider {
29
- readonly name = "claude-code";
30
- readonly displayName = "Claude Code";
31
- private config;
32
- constructor(config?: ClaudeCodeConfig);
33
- /**
34
- * Execute a prompt using Claude Code SDK
35
- */
36
- execute(prompt: string, options?: ExecutionOptions): AsyncIterableIterator<ExecutionMessage>;
37
- /**
38
- * Execute synchronously and return the final result
39
- */
40
- executeSync(prompt: string, options?: ExecutionOptions): Promise<ExecutionResult>;
41
- /**
42
- * Detect available Claude models
43
- */
44
- detectAvailableModels(): Promise<ModelInfo[]>;
45
- /**
46
- * Validate Claude Code setup using enhanced detection
47
- */
48
- validateSetup(): Promise<ProviderStatus>;
49
- /**
50
- * Get provider capabilities
51
- */
52
- getCapabilities(): ProviderCapabilities;
53
- /**
54
- * Map ExecutionOptions to Claude Code Options
55
- */
56
- private mapToClaudeOptions;
57
- /**
58
- * Resolve Claude CLI executable path using enhanced detection
59
- */
60
- private getClaudeExecutablePath;
61
- }