@shepai/cli 1.8.1 → 1.9.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 (127) hide show
  1. package/dist/src/application/ports/output/agent-executor-factory.interface.d.ts +45 -0
  2. package/dist/src/application/ports/output/agent-executor-factory.interface.d.ts.map +1 -0
  3. package/dist/src/application/ports/output/agent-executor-factory.interface.js +19 -0
  4. package/dist/src/application/ports/output/agent-executor.interface.d.ts +117 -0
  5. package/dist/src/application/ports/output/agent-executor.interface.d.ts.map +1 -0
  6. package/dist/src/application/ports/output/agent-executor.interface.js +23 -0
  7. package/dist/src/application/ports/output/agent-registry.interface.d.ts +91 -0
  8. package/dist/src/application/ports/output/agent-registry.interface.d.ts.map +1 -0
  9. package/dist/src/application/ports/output/agent-registry.interface.js +33 -0
  10. package/dist/src/application/ports/output/agent-run-repository.interface.d.ts +70 -0
  11. package/dist/src/application/ports/output/agent-run-repository.interface.d.ts.map +1 -0
  12. package/dist/src/application/ports/output/agent-run-repository.interface.js +11 -0
  13. package/dist/src/application/ports/output/agent-runner.interface.d.ts +82 -0
  14. package/dist/src/application/ports/output/agent-runner.interface.d.ts.map +1 -0
  15. package/dist/src/application/ports/output/agent-runner.interface.js +23 -0
  16. package/dist/src/application/ports/output/index.d.ts +5 -0
  17. package/dist/src/application/ports/output/index.d.ts.map +1 -1
  18. package/dist/src/application/use-cases/agents/run-agent.use-case.d.ts +52 -0
  19. package/dist/src/application/use-cases/agents/run-agent.use-case.d.ts.map +1 -0
  20. package/dist/src/application/use-cases/agents/run-agent.use-case.js +77 -0
  21. package/dist/src/domain/generated/output.d.ts +98 -0
  22. package/dist/src/domain/generated/output.d.ts.map +1 -1
  23. package/dist/src/domain/generated/output.js +17 -0
  24. package/dist/src/infrastructure/di/container.d.ts.map +1 -1
  25. package/dist/src/infrastructure/di/container.js +42 -1
  26. package/dist/src/infrastructure/persistence/sqlite/mappers/agent-run.mapper.d.ts +51 -0
  27. package/dist/src/infrastructure/persistence/sqlite/mappers/agent-run.mapper.d.ts.map +1 -0
  28. package/dist/src/infrastructure/persistence/sqlite/mappers/agent-run.mapper.js +64 -0
  29. package/dist/src/infrastructure/persistence/sqlite/migrations.d.ts +2 -13
  30. package/dist/src/infrastructure/persistence/sqlite/migrations.d.ts.map +1 -1
  31. package/dist/src/infrastructure/persistence/sqlite/migrations.js +63 -30
  32. package/dist/src/infrastructure/repositories/agent-run.repository.d.ts +25 -0
  33. package/dist/src/infrastructure/repositories/agent-run.repository.d.ts.map +1 -0
  34. package/dist/src/infrastructure/repositories/agent-run.repository.js +119 -0
  35. package/dist/src/infrastructure/services/agents/agent-executor-factory.service.d.ts +43 -0
  36. package/dist/src/infrastructure/services/agents/agent-executor-factory.service.d.ts.map +1 -0
  37. package/dist/src/infrastructure/services/agents/agent-executor-factory.service.js +58 -0
  38. package/dist/src/infrastructure/services/agents/agent-registry.service.d.ts +18 -0
  39. package/dist/src/infrastructure/services/agents/agent-registry.service.d.ts.map +1 -0
  40. package/dist/src/infrastructure/services/agents/agent-registry.service.js +30 -0
  41. package/dist/src/infrastructure/services/agents/agent-runner.service.d.ts +27 -0
  42. package/dist/src/infrastructure/services/agents/agent-runner.service.d.ts.map +1 -0
  43. package/dist/src/infrastructure/services/agents/agent-runner.service.js +117 -0
  44. package/dist/src/infrastructure/services/agents/executors/claude-code-executor.service.d.ts +37 -0
  45. package/dist/src/infrastructure/services/agents/executors/claude-code-executor.service.d.ts.map +1 -0
  46. package/dist/src/infrastructure/services/agents/executors/claude-code-executor.service.js +275 -0
  47. package/dist/src/infrastructure/services/agents/langgraph/analyze-repository-graph.d.ts +119 -0
  48. package/dist/src/infrastructure/services/agents/langgraph/analyze-repository-graph.d.ts.map +1 -0
  49. package/dist/src/infrastructure/services/agents/langgraph/analyze-repository-graph.js +56 -0
  50. package/dist/src/infrastructure/services/agents/langgraph/checkpointer.d.ts +9 -0
  51. package/dist/src/infrastructure/services/agents/langgraph/checkpointer.d.ts.map +1 -0
  52. package/dist/src/infrastructure/services/agents/langgraph/checkpointer.js +10 -0
  53. package/dist/src/infrastructure/services/agents/langgraph/prompts/analyze-repository.prompt.d.ts +3 -0
  54. package/dist/src/infrastructure/services/agents/langgraph/prompts/analyze-repository.prompt.d.ts.map +1 -0
  55. package/dist/src/infrastructure/services/agents/langgraph/prompts/analyze-repository.prompt.js +18 -0
  56. package/dist/src/infrastructure/services/agents/streaming/event-channel.d.ts +39 -0
  57. package/dist/src/infrastructure/services/agents/streaming/event-channel.d.ts.map +1 -0
  58. package/dist/src/infrastructure/services/agents/streaming/event-channel.js +64 -0
  59. package/dist/src/infrastructure/services/agents/streaming/index.d.ts +9 -0
  60. package/dist/src/infrastructure/services/agents/streaming/index.d.ts.map +1 -0
  61. package/dist/src/infrastructure/services/agents/streaming/index.js +8 -0
  62. package/dist/src/infrastructure/services/agents/streaming/streaming-executor-proxy.d.ts +25 -0
  63. package/dist/src/infrastructure/services/agents/streaming/streaming-executor-proxy.d.ts.map +1 -0
  64. package/dist/src/infrastructure/services/agents/streaming/streaming-executor-proxy.js +51 -0
  65. package/dist/src/infrastructure/services/web-server.service.d.ts.map +1 -1
  66. package/dist/src/infrastructure/services/web-server.service.js +2 -3
  67. package/dist/src/presentation/cli/commands/run.command.d.ts +19 -0
  68. package/dist/src/presentation/cli/commands/run.command.d.ts.map +1 -0
  69. package/dist/src/presentation/cli/commands/run.command.js +130 -0
  70. package/dist/src/presentation/cli/index.js +2 -0
  71. package/dist/src/presentation/cli/ui/messages.d.ts +1 -1
  72. package/dist/src/presentation/cli/ui/messages.d.ts.map +1 -1
  73. package/dist/src/presentation/cli/ui/messages.js +9 -3
  74. package/dist/src/presentation/cli/ui/symbols.d.ts +1 -1
  75. package/dist/tsconfig.build.tsbuildinfo +1 -1
  76. package/package.json +7 -3
  77. package/web/.next/BUILD_ID +1 -1
  78. package/web/.next/build-manifest.json +2 -2
  79. package/web/.next/cache/.previewinfo +1 -1
  80. package/web/.next/cache/.rscinfo +1 -1
  81. package/web/.next/cache/config.json +3 -3
  82. package/web/.next/fallback-build-manifest.json +2 -2
  83. package/web/.next/prerender-manifest.json +3 -3
  84. package/web/.next/required-server-files.js +1 -1
  85. package/web/.next/required-server-files.json +1 -1
  86. package/web/.next/server/app/_global-error.html +2 -2
  87. package/web/.next/server/app/_global-error.rsc +1 -1
  88. package/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  89. package/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  90. package/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  91. package/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  92. package/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  93. package/web/.next/server/app/_not-found.html +2 -2
  94. package/web/.next/server/app/_not-found.rsc +1 -1
  95. package/web/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
  96. package/web/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  97. package/web/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
  98. package/web/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  99. package/web/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  100. package/web/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  101. package/web/.next/server/app/index.html +2 -2
  102. package/web/.next/server/app/index.rsc +1 -1
  103. package/web/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  104. package/web/.next/server/app/index.segments/_full.segment.rsc +1 -1
  105. package/web/.next/server/app/index.segments/_head.segment.rsc +1 -1
  106. package/web/.next/server/app/index.segments/_index.segment.rsc +1 -1
  107. package/web/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  108. package/web/.next/server/app/version.html +2 -2
  109. package/web/.next/server/app/version.rsc +1 -1
  110. package/web/.next/server/app/version.segments/_full.segment.rsc +1 -1
  111. package/web/.next/server/app/version.segments/_head.segment.rsc +1 -1
  112. package/web/.next/server/app/version.segments/_index.segment.rsc +1 -1
  113. package/web/.next/server/app/version.segments/_tree.segment.rsc +1 -1
  114. package/web/.next/server/app/version.segments/version/__PAGE__.segment.rsc +1 -1
  115. package/web/.next/server/app/version.segments/version.segment.rsc +1 -1
  116. package/web/.next/server/chunks/ssr/_ccea5183._.js +1 -1
  117. package/web/.next/server/pages/404.html +2 -2
  118. package/web/.next/server/pages/500.html +2 -2
  119. package/web/.next/server/server-reference-manifest.js +1 -1
  120. package/web/.next/server/server-reference-manifest.json +1 -1
  121. package/web/.next/trace +1 -1
  122. package/web/.next/trace-build +1 -1
  123. package/web/next.config.mjs +1 -0
  124. package/web/next.config.ts +0 -47
  125. /package/web/.next/static/{hQhBYhX3g-lgV-ix_LYg2 → -QL3Wkz2EyCtR0S30gd0p}/_buildManifest.js +0 -0
  126. /package/web/.next/static/{hQhBYhX3g-lgV-ix_LYg2 → -QL3Wkz2EyCtR0S30gd0p}/_clientMiddlewareManifest.json +0 -0
  127. /package/web/.next/static/{hQhBYhX3g-lgV-ix_LYg2 → -QL3Wkz2EyCtR0S30gd0p}/_ssgManifest.js +0 -0
@@ -0,0 +1,119 @@
1
+ /**
2
+ * SQLite Agent Run Repository Implementation
3
+ *
4
+ * Implements IAgentRunRepository using SQLite database.
5
+ * Uses prepared statements to prevent SQL injection.
6
+ */
7
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
8
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
9
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
10
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
11
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
12
+ };
13
+ var __metadata = (this && this.__metadata) || function (k, v) {
14
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
15
+ };
16
+ import { injectable } from 'tsyringe';
17
+ import { toDatabase, fromDatabase, } from '../persistence/sqlite/mappers/agent-run.mapper.js';
18
+ /**
19
+ * SQLite implementation of IAgentRunRepository.
20
+ * Manages AgentRun persistence with CRUD operations.
21
+ */
22
+ let SQLiteAgentRunRepository = class SQLiteAgentRunRepository {
23
+ db;
24
+ constructor(db) {
25
+ this.db = db;
26
+ }
27
+ async create(agentRun) {
28
+ const row = toDatabase(agentRun);
29
+ const stmt = this.db.prepare(`
30
+ INSERT INTO agent_runs (
31
+ id, agent_type, agent_name, status, prompt, result,
32
+ session_id, thread_id, pid, last_heartbeat,
33
+ started_at, completed_at, error,
34
+ created_at, updated_at
35
+ ) VALUES (
36
+ @id, @agent_type, @agent_name, @status, @prompt, @result,
37
+ @session_id, @thread_id, @pid, @last_heartbeat,
38
+ @started_at, @completed_at, @error,
39
+ @created_at, @updated_at
40
+ )
41
+ `);
42
+ stmt.run(row);
43
+ }
44
+ async findById(id) {
45
+ const stmt = this.db.prepare('SELECT * FROM agent_runs WHERE id = ?');
46
+ const row = stmt.get(id);
47
+ if (!row) {
48
+ return null;
49
+ }
50
+ return fromDatabase(row);
51
+ }
52
+ async findByThreadId(threadId) {
53
+ const stmt = this.db.prepare('SELECT * FROM agent_runs WHERE thread_id = ?');
54
+ const row = stmt.get(threadId);
55
+ if (!row) {
56
+ return null;
57
+ }
58
+ return fromDatabase(row);
59
+ }
60
+ async updateStatus(id, status, updates) {
61
+ const setClauses = ['status = @status', 'updated_at = @updated_at'];
62
+ const params = {
63
+ id,
64
+ status,
65
+ updated_at: updates?.updatedAt instanceof Date ? updates.updatedAt.getTime() : Date.now(),
66
+ };
67
+ if (updates?.result !== undefined) {
68
+ setClauses.push('result = @result');
69
+ params.result = updates.result;
70
+ }
71
+ if (updates?.sessionId !== undefined) {
72
+ setClauses.push('session_id = @session_id');
73
+ params.session_id = updates.sessionId;
74
+ }
75
+ if (updates?.pid !== undefined) {
76
+ setClauses.push('pid = @pid');
77
+ params.pid = updates.pid;
78
+ }
79
+ if (updates?.lastHeartbeat !== undefined) {
80
+ setClauses.push('last_heartbeat = @last_heartbeat');
81
+ params.last_heartbeat =
82
+ updates.lastHeartbeat instanceof Date ? updates.lastHeartbeat.getTime() : null;
83
+ }
84
+ if (updates?.startedAt !== undefined) {
85
+ setClauses.push('started_at = @started_at');
86
+ params.started_at = updates.startedAt instanceof Date ? updates.startedAt.getTime() : null;
87
+ }
88
+ if (updates?.completedAt !== undefined) {
89
+ setClauses.push('completed_at = @completed_at');
90
+ params.completed_at =
91
+ updates.completedAt instanceof Date ? updates.completedAt.getTime() : null;
92
+ }
93
+ if (updates?.error !== undefined) {
94
+ setClauses.push('error = @error');
95
+ params.error = updates.error;
96
+ }
97
+ const stmt = this.db.prepare(`UPDATE agent_runs SET ${setClauses.join(', ')} WHERE id = @id`);
98
+ stmt.run(params);
99
+ }
100
+ async findRunningByPid(pid) {
101
+ const stmt = this.db.prepare('SELECT * FROM agent_runs WHERE pid = ? AND status = ?');
102
+ const rows = stmt.all(pid, 'running');
103
+ return rows.map(fromDatabase);
104
+ }
105
+ async list() {
106
+ const stmt = this.db.prepare('SELECT * FROM agent_runs');
107
+ const rows = stmt.all();
108
+ return rows.map(fromDatabase);
109
+ }
110
+ async delete(id) {
111
+ const stmt = this.db.prepare('DELETE FROM agent_runs WHERE id = ?');
112
+ stmt.run(id);
113
+ }
114
+ };
115
+ SQLiteAgentRunRepository = __decorate([
116
+ injectable(),
117
+ __metadata("design:paramtypes", [Object])
118
+ ], SQLiteAgentRunRepository);
119
+ export { SQLiteAgentRunRepository };
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Agent Executor Factory Service
3
+ *
4
+ * Infrastructure implementation of the IAgentExecutorFactory port.
5
+ * Creates and caches agent executor instances based on agent type.
6
+ *
7
+ * Uses constructor dependency injection for the spawn function
8
+ * to enable testability without mocking node:child_process directly.
9
+ */
10
+ import type { AgentType, AgentConfig } from '../../../domain/generated/output.js';
11
+ import type { IAgentExecutor } from '../../../application/ports/output/agent-executor.interface.js';
12
+ import type { IAgentExecutorFactory } from '../../../application/ports/output/agent-executor-factory.interface.js';
13
+ import { type SpawnFunction } from './executors/claude-code-executor.service.js';
14
+ /**
15
+ * Factory that creates and caches agent executor instances.
16
+ *
17
+ * Executor instances are cached per agent type (singleton per type)
18
+ * to avoid unnecessary re-creation of stateless executors.
19
+ */
20
+ export declare class AgentExecutorFactory implements IAgentExecutorFactory {
21
+ private readonly spawn;
22
+ private readonly cache;
23
+ /**
24
+ * @param spawn - Spawn function for creating subprocesses (injectable for testing).
25
+ */
26
+ constructor(spawn: SpawnFunction);
27
+ /**
28
+ * Create (or return cached) executor for the specified agent type.
29
+ *
30
+ * @param agentType - The type of agent to create an executor for
31
+ * @param _authConfig - Agent authentication and configuration
32
+ * @returns A configured agent executor
33
+ * @throws Error if the agent type is not supported
34
+ */
35
+ createExecutor(agentType: AgentType, _authConfig: AgentConfig): IAgentExecutor;
36
+ /**
37
+ * Get the list of agent types this factory can create executors for.
38
+ *
39
+ * @returns Array of supported agent types
40
+ */
41
+ getSupportedAgents(): AgentType[];
42
+ }
43
+ //# sourceMappingURL=agent-executor-factory.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-executor-factory.service.d.ts","sourceRoot":"","sources":["../../../../../src/infrastructure/services/agents/agent-executor-factory.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAClF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+DAA+D,CAAC;AACpG,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uEAAuE,CAAC;AACnH,OAAO,EAEL,KAAK,aAAa,EACnB,MAAM,6CAA6C,CAAC;AAErD;;;;;GAKG;AACH,qBAAa,oBAAqB,YAAW,qBAAqB;IAMpD,OAAO,CAAC,QAAQ,CAAC,KAAK;IALlC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAqC;IAE3D;;OAEG;gBAC0B,KAAK,EAAE,aAAa;IAEjD;;;;;;;OAOG;IACH,cAAc,CAAC,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,GAAG,cAAc;IAoB9E;;;;OAIG;IACH,kBAAkB,IAAI,SAAS,EAAE;CAGlC"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Agent Executor Factory Service
3
+ *
4
+ * Infrastructure implementation of the IAgentExecutorFactory port.
5
+ * Creates and caches agent executor instances based on agent type.
6
+ *
7
+ * Uses constructor dependency injection for the spawn function
8
+ * to enable testability without mocking node:child_process directly.
9
+ */
10
+ import { ClaudeCodeExecutorService, } from './executors/claude-code-executor.service.js';
11
+ /**
12
+ * Factory that creates and caches agent executor instances.
13
+ *
14
+ * Executor instances are cached per agent type (singleton per type)
15
+ * to avoid unnecessary re-creation of stateless executors.
16
+ */
17
+ export class AgentExecutorFactory {
18
+ spawn;
19
+ cache = new Map();
20
+ /**
21
+ * @param spawn - Spawn function for creating subprocesses (injectable for testing).
22
+ */
23
+ constructor(spawn) {
24
+ this.spawn = spawn;
25
+ }
26
+ /**
27
+ * Create (or return cached) executor for the specified agent type.
28
+ *
29
+ * @param agentType - The type of agent to create an executor for
30
+ * @param _authConfig - Agent authentication and configuration
31
+ * @returns A configured agent executor
32
+ * @throws Error if the agent type is not supported
33
+ */
34
+ createExecutor(agentType, _authConfig) {
35
+ const key = agentType;
36
+ const cached = this.cache.get(key);
37
+ if (cached)
38
+ return cached;
39
+ let executor;
40
+ switch (key) {
41
+ case 'claude-code':
42
+ executor = new ClaudeCodeExecutorService(this.spawn);
43
+ break;
44
+ default:
45
+ throw new Error(`Unsupported agent type: ${agentType}. Supported: ${this.getSupportedAgents().join(', ')}`);
46
+ }
47
+ this.cache.set(key, executor);
48
+ return executor;
49
+ }
50
+ /**
51
+ * Get the list of agent types this factory can create executors for.
52
+ *
53
+ * @returns Array of supported agent types
54
+ */
55
+ getSupportedAgents() {
56
+ return ['claude-code'];
57
+ }
58
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Agent Registry Service
3
+ *
4
+ * Infrastructure implementation of the IAgentRegistry port.
5
+ * Manages agent workflow definitions in an in-memory map,
6
+ * enabling runtime discovery and instantiation of agent workflows.
7
+ *
8
+ * Pre-registers built-in agents (analyze-repository) at construction time.
9
+ */
10
+ import type { IAgentRegistry, AgentDefinitionWithFactory } from '../../../application/ports/output/agent-registry.interface.js';
11
+ export declare class AgentRegistryService implements IAgentRegistry {
12
+ private readonly agents;
13
+ constructor();
14
+ register(definition: AgentDefinitionWithFactory): void;
15
+ get(name: string): AgentDefinitionWithFactory | undefined;
16
+ list(): AgentDefinitionWithFactory[];
17
+ }
18
+ //# sourceMappingURL=agent-registry.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-registry.service.d.ts","sourceRoot":"","sources":["../../../../../src/infrastructure/services/agents/agent-registry.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,0BAA0B,EAC3B,MAAM,wDAAwD,CAAC;AAGhE,qBAAa,oBAAqB,YAAW,cAAc;IACzD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiD;;IAWxE,QAAQ,CAAC,UAAU,EAAE,0BAA0B,GAAG,IAAI;IAItD,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,0BAA0B,GAAG,SAAS;IAIzD,IAAI,IAAI,0BAA0B,EAAE;CAGrC"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Agent Registry Service
3
+ *
4
+ * Infrastructure implementation of the IAgentRegistry port.
5
+ * Manages agent workflow definitions in an in-memory map,
6
+ * enabling runtime discovery and instantiation of agent workflows.
7
+ *
8
+ * Pre-registers built-in agents (analyze-repository) at construction time.
9
+ */
10
+ import { createAnalyzeRepositoryGraph } from './langgraph/analyze-repository-graph.js';
11
+ export class AgentRegistryService {
12
+ agents = new Map();
13
+ constructor() {
14
+ // Register built-in agents
15
+ this.register({
16
+ name: 'analyze-repository',
17
+ description: 'Analyze repository structure, dependencies, and architecture',
18
+ graphFactory: createAnalyzeRepositoryGraph,
19
+ });
20
+ }
21
+ register(definition) {
22
+ this.agents.set(definition.name, definition);
23
+ }
24
+ get(name) {
25
+ return this.agents.get(name);
26
+ }
27
+ list() {
28
+ return Array.from(this.agents.values());
29
+ }
30
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Agent Runner Service
3
+ *
4
+ * Infrastructure implementation of the IAgentRunner port.
5
+ * Orchestrates agent execution by resolving definitions from the registry,
6
+ * creating executors, compiling LangGraph workflows, and tracking runs
7
+ * in the repository.
8
+ */
9
+ import type { BaseCheckpointSaver } from '@langchain/langgraph';
10
+ import type { IAgentRunner, AgentRunOptions } from '../../../application/ports/output/agent-runner.interface.js';
11
+ import type { IAgentRegistry } from '../../../application/ports/output/agent-registry.interface.js';
12
+ import type { IAgentExecutorFactory } from '../../../application/ports/output/agent-executor-factory.interface.js';
13
+ import type { IAgentRunRepository } from '../../../application/ports/output/agent-run-repository.interface.js';
14
+ import type { AgentRun, AgentRunEvent } from '../../../domain/generated/output.js';
15
+ export declare class AgentRunnerService implements IAgentRunner {
16
+ private readonly registry;
17
+ private readonly executorFactory;
18
+ private readonly checkpointer;
19
+ private readonly runRepository;
20
+ constructor(registry: IAgentRegistry, executorFactory: IAgentExecutorFactory, checkpointer: BaseCheckpointSaver, runRepository: IAgentRunRepository);
21
+ runAgent(agentName: string, prompt: string, options?: AgentRunOptions): Promise<AgentRun>;
22
+ runAgentStream(agentName: string, prompt: string, options?: AgentRunOptions): AsyncIterable<AgentRunEvent>;
23
+ private setupRun;
24
+ private markCompleted;
25
+ private markFailed;
26
+ }
27
+ //# sourceMappingURL=agent-runner.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-runner.service.d.ts","sourceRoot":"","sources":["../../../../../src/infrastructure/services/agents/agent-runner.service.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,KAAK,EACV,YAAY,EACZ,eAAe,EAChB,MAAM,sDAAsD,CAAC;AAC9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wDAAwD,CAAC;AAC7F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gEAAgE,CAAC;AAC5G,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8DAA8D,CAAC;AAExG,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAM5E,qBAAa,kBAAmB,YAAW,YAAY;IAEnD,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,aAAa;gBAHb,QAAQ,EAAE,cAAc,EACxB,eAAe,EAAE,qBAAqB,EACtC,YAAY,EAAE,mBAAmB,EACjC,aAAa,EAAE,mBAAmB;IAG/C,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC;IAmBxF,cAAc,CACnB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,eAAe,GACxB,aAAa,CAAC,aAAa,CAAC;YAwCjB,QAAQ;YAwCR,aAAa;YAUb,UAAU;CAQzB"}
@@ -0,0 +1,117 @@
1
+ /**
2
+ * Agent Runner Service
3
+ *
4
+ * Infrastructure implementation of the IAgentRunner port.
5
+ * Orchestrates agent execution by resolving definitions from the registry,
6
+ * creating executors, compiling LangGraph workflows, and tracking runs
7
+ * in the repository.
8
+ */
9
+ import * as crypto from 'node:crypto';
10
+ import { AgentRunStatus } from '../../../domain/generated/output.js';
11
+ import { getSettings } from '../../../infrastructure/services/settings.service.js';
12
+ import { EventChannel } from './streaming/event-channel.js';
13
+ import { StreamingExecutorProxy } from './streaming/streaming-executor-proxy.js';
14
+ export class AgentRunnerService {
15
+ registry;
16
+ executorFactory;
17
+ checkpointer;
18
+ runRepository;
19
+ constructor(registry, executorFactory, checkpointer, runRepository) {
20
+ this.registry = registry;
21
+ this.executorFactory = executorFactory;
22
+ this.checkpointer = checkpointer;
23
+ this.runRepository = runRepository;
24
+ }
25
+ async runAgent(agentName, prompt, options) {
26
+ const { definition, executor, runId, threadId } = await this.setupRun(agentName, prompt);
27
+ try {
28
+ const compiledGraph = definition.graphFactory(executor, this.checkpointer);
29
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
30
+ const result = await compiledGraph.invoke({ repositoryPath: options?.repositoryPath ?? process.cwd() }, { configurable: { thread_id: threadId } });
31
+ await this.markCompleted(runId, result);
32
+ return (await this.runRepository.findById(runId));
33
+ }
34
+ catch (error) {
35
+ await this.markFailed(runId, error);
36
+ return (await this.runRepository.findById(runId));
37
+ }
38
+ }
39
+ async *runAgentStream(agentName, prompt, options) {
40
+ const { definition, executor, runId, threadId } = await this.setupRun(agentName, prompt);
41
+ // Create streaming channel and proxy
42
+ const channel = new EventChannel();
43
+ const proxy = new StreamingExecutorProxy(executor, channel);
44
+ // Compile graph with proxy (graph doesn't know about streaming)
45
+ const compiledGraph = definition.graphFactory(proxy, this.checkpointer);
46
+ // Start graph invocation in background
47
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
48
+ const graphPromise = compiledGraph
49
+ .invoke({ repositoryPath: options?.repositoryPath ?? process.cwd() }, { configurable: { thread_id: threadId } })
50
+ .then(async (result) => {
51
+ channel.close();
52
+ await this.markCompleted(runId, result);
53
+ })
54
+ .catch(async (error) => {
55
+ channel.close();
56
+ await this.markFailed(runId, error);
57
+ });
58
+ // Yield events as they arrive, mapping infra → domain type
59
+ for await (const event of channel) {
60
+ yield {
61
+ type: event.type,
62
+ content: event.content,
63
+ timestamp: event.timestamp instanceof Date ? event.timestamp.toISOString() : event.timestamp,
64
+ };
65
+ }
66
+ // Ensure graph promise cleanup completes
67
+ await graphPromise;
68
+ }
69
+ async setupRun(agentName, prompt) {
70
+ const definition = this.registry.get(agentName);
71
+ if (!definition) {
72
+ throw new Error(`Agent '${agentName}' not found. Available: ${this.registry
73
+ .list()
74
+ .map((a) => a.name)
75
+ .join(', ')}`);
76
+ }
77
+ const settings = getSettings();
78
+ const agentType = settings.agent.type;
79
+ const executor = this.executorFactory.createExecutor(agentType, settings.agent);
80
+ const runId = crypto.randomUUID();
81
+ const threadId = crypto.randomUUID();
82
+ const now = new Date().toISOString();
83
+ const agentRun = {
84
+ id: runId,
85
+ agentType,
86
+ agentName,
87
+ status: AgentRunStatus.pending,
88
+ prompt,
89
+ threadId,
90
+ createdAt: now,
91
+ updatedAt: now,
92
+ };
93
+ await this.runRepository.create(agentRun);
94
+ await this.runRepository.updateStatus(runId, AgentRunStatus.running, {
95
+ pid: process.pid,
96
+ startedAt: now,
97
+ updatedAt: now,
98
+ });
99
+ return { definition, executor, runId, threadId };
100
+ }
101
+ async markCompleted(runId, result) {
102
+ const completedAt = new Date().toISOString();
103
+ await this.runRepository.updateStatus(runId, AgentRunStatus.completed, {
104
+ result: result.analysisMarkdown ?? result.result ?? JSON.stringify(result),
105
+ completedAt,
106
+ updatedAt: completedAt,
107
+ });
108
+ }
109
+ async markFailed(runId, error) {
110
+ const failedAt = new Date().toISOString();
111
+ await this.runRepository.updateStatus(runId, AgentRunStatus.failed, {
112
+ error: error instanceof Error ? error.message : String(error),
113
+ completedAt: failedAt,
114
+ updatedAt: failedAt,
115
+ });
116
+ }
117
+ }
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Claude Code Executor Service
3
+ *
4
+ * Infrastructure implementation of IAgentExecutor for Claude Code agent.
5
+ * Executes prompts via the `claude` CLI subprocess with JSON and stream-json
6
+ * output formats.
7
+ *
8
+ * Uses constructor dependency injection for the spawn function
9
+ * to enable testability without mocking node:child_process directly.
10
+ */
11
+ import type { ChildProcess } from 'node:child_process';
12
+ import type { AgentType, AgentFeature } from '../../../../domain/generated/output.js';
13
+ import type { IAgentExecutor, AgentExecutionOptions, AgentExecutionResult, AgentExecutionStreamEvent } from '../../../../application/ports/output/agent-executor.interface.js';
14
+ /**
15
+ * Type for the spawn dependency.
16
+ * Matches the signature of child_process.spawn.
17
+ * Injected via constructor to enable testability.
18
+ */
19
+ export type SpawnFunction = (command: string, args: string[], options?: object) => ChildProcess;
20
+ /**
21
+ * Executor service for Claude Code agent.
22
+ * Uses subprocess spawning to interact with the `claude` CLI.
23
+ */
24
+ export declare class ClaudeCodeExecutorService implements IAgentExecutor {
25
+ private readonly spawn;
26
+ readonly agentType: AgentType;
27
+ constructor(spawn: SpawnFunction);
28
+ execute(prompt: string, options?: AgentExecutionOptions): Promise<AgentExecutionResult>;
29
+ executeStream(prompt: string, options?: AgentExecutionOptions): AsyncIterable<AgentExecutionStreamEvent>;
30
+ supportsFeature(feature: AgentFeature): boolean;
31
+ private buildArgs;
32
+ private buildStreamArgs;
33
+ private buildSpawnOptions;
34
+ private parseJsonResult;
35
+ private parseStreamLine;
36
+ }
37
+ //# sourceMappingURL=claude-code-executor.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claude-code-executor.service.d.ts","sourceRoot":"","sources":["../../../../../../src/infrastructure/services/agents/executors/claude-code-executor.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AACtF,OAAO,KAAK,EACV,cAAc,EACd,qBAAqB,EACrB,oBAAoB,EACpB,yBAAyB,EAC1B,MAAM,kEAAkE,CAAC;AAE1E;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,YAAY,CAAC;AAUhG;;;GAGG;AACH,qBAAa,yBAA0B,YAAW,cAAc;IAGlD,OAAO,CAAC,QAAQ,CAAC,KAAK;IAFlC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAA8B;gBAE9B,KAAK,EAAE,aAAa;IAE3C,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAiDtF,aAAa,CAClB,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,qBAAqB,GAC9B,aAAa,CAAC,yBAAyB,CAAC;IA+F3C,eAAe,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO;IAI/C,OAAO,CAAC,SAAS;IAWjB,OAAO,CAAC,eAAe;IAUvB,OAAO,CAAC,iBAAiB;IAMzB,OAAO,CAAC,eAAe;IAiCvB,OAAO,CAAC,eAAe;CAkExB"}