@gracefultools/astrid-sdk 0.1.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.
@@ -0,0 +1,286 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ /**
4
+ * @gracefultools/astrid-sdk CLI
5
+ *
6
+ * Command-line interface for running the Astrid AI agent worker
7
+ *
8
+ * Usage:
9
+ * npx astrid-agent # Start polling for tasks
10
+ * npx astrid-agent <taskId> # Process a specific task
11
+ * npx astrid-agent --help # Show help
12
+ */
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || (function () {
30
+ var ownKeys = function(o) {
31
+ ownKeys = Object.getOwnPropertyNames || function (o) {
32
+ var ar = [];
33
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
34
+ return ar;
35
+ };
36
+ return ownKeys(o);
37
+ };
38
+ return function (mod) {
39
+ if (mod && mod.__esModule) return mod;
40
+ var result = {};
41
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
42
+ __setModuleDefault(result, mod);
43
+ return result;
44
+ };
45
+ })();
46
+ Object.defineProperty(exports, "__esModule", { value: true });
47
+ const dotenv = __importStar(require("dotenv"));
48
+ const path = __importStar(require("path"));
49
+ // Load environment variables
50
+ dotenv.config({ path: path.resolve(process.cwd(), '.env.local') });
51
+ dotenv.config({ path: path.resolve(process.cwd(), '.env') });
52
+ const claude_js_1 = require("../executors/claude.js");
53
+ const openai_js_1 = require("../executors/openai.js");
54
+ const gemini_js_1 = require("../executors/gemini.js");
55
+ const agent_config_js_1 = require("../utils/agent-config.js");
56
+ const astrid_oauth_js_1 = require("../adapters/astrid-oauth.js");
57
+ // ============================================================================
58
+ // CONFIGURATION
59
+ // ============================================================================
60
+ const CONFIG = {
61
+ // AI Provider API Keys
62
+ anthropicApiKey: process.env.ANTHROPIC_API_KEY,
63
+ openaiApiKey: process.env.OPENAI_API_KEY,
64
+ geminiApiKey: process.env.GEMINI_API_KEY,
65
+ // GitHub
66
+ githubToken: process.env.GITHUB_TOKEN,
67
+ // Astrid OAuth
68
+ astridListId: process.env.ASTRID_OAUTH_LIST_ID,
69
+ // Worker settings
70
+ pollIntervalMs: parseInt(process.env.POLL_INTERVAL_MS || '30000'),
71
+ maxBudgetUsd: parseFloat(process.env.MAX_BUDGET_USD || '10.0'),
72
+ };
73
+ function getApiKeyForService(service) {
74
+ switch (service) {
75
+ case 'claude': return CONFIG.anthropicApiKey;
76
+ case 'openai': return CONFIG.openaiApiKey;
77
+ case 'gemini': return CONFIG.geminiApiKey;
78
+ }
79
+ }
80
+ // ============================================================================
81
+ // LOGGING
82
+ // ============================================================================
83
+ const logger = (level, message, meta) => {
84
+ const timestamp = new Date().toISOString();
85
+ const prefix = level === 'error' ? 'āŒ' : level === 'warn' ? 'āš ļø' : 'šŸ“';
86
+ console.log(`${timestamp} ${prefix} ${message}`, meta ? JSON.stringify(meta, null, 2) : '');
87
+ };
88
+ async function routePlanningToService(service, taskTitle, taskDescription, config) {
89
+ switch (service) {
90
+ case 'claude':
91
+ return (0, claude_js_1.planWithClaude)(taskTitle, taskDescription, config);
92
+ case 'openai':
93
+ return (0, openai_js_1.planWithOpenAI)(taskTitle, taskDescription, config);
94
+ case 'gemini':
95
+ return (0, gemini_js_1.planWithGemini)(taskTitle, taskDescription, config);
96
+ default:
97
+ throw new Error(`Unknown service: ${service}`);
98
+ }
99
+ }
100
+ async function routeExecutionToService(service, plan, taskTitle, taskDescription, config) {
101
+ switch (service) {
102
+ case 'claude':
103
+ return (0, claude_js_1.executeWithClaude)(plan, taskTitle, taskDescription, config);
104
+ case 'openai':
105
+ return (0, openai_js_1.executeWithOpenAI)(plan, taskTitle, taskDescription, config);
106
+ case 'gemini':
107
+ return (0, gemini_js_1.executeWithGemini)(plan, taskTitle, taskDescription, config);
108
+ default:
109
+ throw new Error(`Unknown service: ${service}`);
110
+ }
111
+ }
112
+ // ============================================================================
113
+ // TASK PROCESSING
114
+ // ============================================================================
115
+ async function processTask(task, repoPath) {
116
+ const assigneeEmail = task.assigneeEmail || 'claude@astrid.cc';
117
+ const service = (0, agent_config_js_1.getAgentService)(assigneeEmail);
118
+ const apiKey = getApiKeyForService(service);
119
+ if (!apiKey) {
120
+ throw new Error(`No API key configured for ${service}. Set ${service.toUpperCase()}_API_KEY`);
121
+ }
122
+ const config = {
123
+ repoPath,
124
+ apiKey,
125
+ model: agent_config_js_1.DEFAULT_MODELS[service],
126
+ maxBudgetUsd: CONFIG.maxBudgetUsd,
127
+ maxTurns: 50,
128
+ maxIterations: 50,
129
+ logger,
130
+ onProgress: (msg) => console.log(` → ${msg}`),
131
+ };
132
+ console.log(`\nšŸ”„ Processing task: ${task.title}`);
133
+ console.log(` Service: ${service}`);
134
+ console.log(` Repository: ${repoPath}`);
135
+ // Phase 1: Planning
136
+ console.log('\nšŸ“‹ Phase 1: Planning...');
137
+ const planResult = await routePlanningToService(service, task.title, task.description, config);
138
+ if (!planResult.success || !planResult.plan) {
139
+ throw new Error(`Planning failed: ${planResult.error}`);
140
+ }
141
+ console.log('\nāœ… Plan created:');
142
+ console.log(` Summary: ${planResult.plan.summary}`);
143
+ console.log(` Files: ${planResult.plan.files.length}`);
144
+ console.log(` Complexity: ${planResult.plan.estimatedComplexity}`);
145
+ if (planResult.usage) {
146
+ console.log(` Cost: $${planResult.usage.costUSD.toFixed(4)}`);
147
+ }
148
+ // Phase 2: Execution
149
+ console.log('\nšŸ”Ø Phase 2: Execution...');
150
+ const execResult = await routeExecutionToService(service, planResult.plan, task.title, task.description, config);
151
+ if (!execResult.success) {
152
+ throw new Error(`Execution failed: ${execResult.error}`);
153
+ }
154
+ console.log('\nāœ… Execution complete:');
155
+ console.log(` Files modified: ${execResult.files.length}`);
156
+ console.log(` Commit message: ${execResult.commitMessage}`);
157
+ if (execResult.usage) {
158
+ console.log(` Cost: $${execResult.usage.costUSD.toFixed(4)}`);
159
+ }
160
+ // Show modified files
161
+ if (execResult.files.length > 0) {
162
+ console.log('\nšŸ“ Modified files:');
163
+ for (const file of execResult.files) {
164
+ console.log(` ${file.action === 'create' ? '+' : file.action === 'delete' ? '-' : '~'} ${file.path}`);
165
+ }
166
+ }
167
+ }
168
+ // ============================================================================
169
+ // WORKER LOOP
170
+ // ============================================================================
171
+ async function runWorker() {
172
+ const client = new astrid_oauth_js_1.AstridOAuthClient();
173
+ if (!client.isConfigured()) {
174
+ console.error('āŒ OAuth credentials not configured');
175
+ console.error(' Set ASTRID_OAUTH_CLIENT_ID and ASTRID_OAUTH_CLIENT_SECRET');
176
+ process.exit(1);
177
+ }
178
+ const listId = CONFIG.astridListId;
179
+ if (!listId) {
180
+ console.error('āŒ ASTRID_OAUTH_LIST_ID not configured');
181
+ process.exit(1);
182
+ }
183
+ console.log('šŸ¤– Astrid Agent Worker');
184
+ console.log(` List ID: ${listId}`);
185
+ console.log(` Poll interval: ${CONFIG.pollIntervalMs}ms`);
186
+ console.log('');
187
+ // Test connection
188
+ const testResult = await client.testConnection();
189
+ if (!testResult.success) {
190
+ console.error(`āŒ Connection failed: ${testResult.error}`);
191
+ process.exit(1);
192
+ }
193
+ console.log('āœ… Connected to Astrid API\n');
194
+ // Polling loop
195
+ while (true) {
196
+ try {
197
+ const tasksResult = await client.getTasks(listId, false);
198
+ if (tasksResult.success && tasksResult.data) {
199
+ // Find tasks assigned to AI agents
200
+ const aiTasks = tasksResult.data.filter(task => task.assigneeEmail && (0, agent_config_js_1.isRegisteredAgent)(task.assigneeEmail));
201
+ if (aiTasks.length > 0) {
202
+ console.log(`\nšŸ“‹ Found ${aiTasks.length} AI-assigned task(s)`);
203
+ for (const task of aiTasks) {
204
+ try {
205
+ // TODO: Clone repository and process task
206
+ // For now, just log
207
+ console.log(`\nšŸ“Œ Task: ${task.title}`);
208
+ console.log(` ID: ${task.id}`);
209
+ console.log(` Assignee: ${task.assigneeEmail}`);
210
+ }
211
+ catch (error) {
212
+ console.error(`āŒ Failed to process task ${task.id}:`, error);
213
+ }
214
+ }
215
+ }
216
+ }
217
+ }
218
+ catch (error) {
219
+ console.error('āŒ Poll error:', error);
220
+ }
221
+ // Wait before next poll
222
+ await new Promise(resolve => setTimeout(resolve, CONFIG.pollIntervalMs));
223
+ }
224
+ }
225
+ // ============================================================================
226
+ // MAIN
227
+ // ============================================================================
228
+ function showHelp() {
229
+ console.log(`
230
+ @gracefultools/astrid-sdk - AI Agent Worker
231
+
232
+ Usage:
233
+ npx astrid-agent Start polling for tasks
234
+ npx astrid-agent <taskId> Process a specific task
235
+ npx astrid-agent --help Show this help
236
+
237
+ Environment Variables:
238
+ ASTRID_OAUTH_CLIENT_ID OAuth client ID
239
+ ASTRID_OAUTH_CLIENT_SECRET OAuth client secret
240
+ ASTRID_OAUTH_LIST_ID List ID to monitor
241
+
242
+ ANTHROPIC_API_KEY For Claude tasks
243
+ OPENAI_API_KEY For OpenAI tasks
244
+ GEMINI_API_KEY For Gemini tasks
245
+
246
+ GITHUB_TOKEN For cloning repositories
247
+ POLL_INTERVAL_MS Polling interval (default: 30000)
248
+ MAX_BUDGET_USD Max budget per task (default: 10.0)
249
+ `);
250
+ }
251
+ async function main() {
252
+ const args = process.argv.slice(2);
253
+ if (args.includes('--help') || args.includes('-h')) {
254
+ showHelp();
255
+ process.exit(0);
256
+ }
257
+ if (args.length > 0 && !args[0].startsWith('-')) {
258
+ // Process a specific task
259
+ const taskId = args[0];
260
+ console.log(`\nšŸŽÆ Processing task: ${taskId}`);
261
+ const client = new astrid_oauth_js_1.AstridOAuthClient();
262
+ const taskResult = await client.getTask(taskId);
263
+ if (!taskResult.success || !taskResult.data) {
264
+ console.error(`āŒ Failed to get task: ${taskResult.error}`);
265
+ process.exit(1);
266
+ }
267
+ // TODO: Clone repository based on task's list configuration
268
+ // For now, use current directory
269
+ const repoPath = process.cwd();
270
+ await processTask({
271
+ id: taskResult.data.id,
272
+ title: taskResult.data.title,
273
+ description: taskResult.data.description,
274
+ assigneeEmail: taskResult.data.assigneeEmail,
275
+ }, repoPath);
276
+ }
277
+ else {
278
+ // Run worker loop
279
+ await runWorker();
280
+ }
281
+ }
282
+ main().catch(error => {
283
+ console.error('āŒ Fatal error:', error);
284
+ process.exit(1);
285
+ });
286
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/bin/cli.ts"],"names":[],"mappings":";;AACA;;;;;;;;;GASG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,+CAAgC;AAChC,2CAA4B;AAG5B,6BAA6B;AAC7B,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,YAAY,CAAC,EAAE,CAAC,CAAA;AAClE,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,CAAC,EAAE,CAAC,CAAA;AAE5D,sDAK+B;AAC/B,sDAI+B;AAC/B,sDAI+B;AAC/B,8DAIiC;AAEjC,iEAEoC;AAQpC,+EAA+E;AAC/E,gBAAgB;AAChB,+EAA+E;AAE/E,MAAM,MAAM,GAAG;IACb,uBAAuB;IACvB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ED,4DAA4D;QAC5D,iCAAiC;QACjC,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,EAAE,CAAA;QAE9B,MAAM,WAAW,CAAC;YAChB,EAAE,EAAE,UAAU,CAAC,IAAI,CAAC,EAAE;YACtB,KAAK,EAAE,UAAU,CAAC,IAAI,CAAC,KAAK;YAC5B,WAAW,EAAE,UAAU,CAAC,IAAI,CAAC,WAAW;YACxC,aAAa,EAAE,UAAU,CAAC,IAAI,CAAC,aAAa;SAC7C,EAAE,QAAQ,CAAC,CAAA;IAEd,CAAC;SAAM,CAAC;QACN,kBAAkB;QAClB,MAAM,SAAS,EAAE,CAAA;IACnB,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAA;IACtC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAC,CAAA"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Claude Agent SDK Executor
3
+ *
4
+ * Executes code implementation using Claude Code's native tools (Read, Write, Edit, Bash)
5
+ * instead of generating code via API and parsing JSON responses.
6
+ *
7
+ * This provides:
8
+ * - Better code quality (real file editing vs generated text)
9
+ * - Native error handling and recovery
10
+ * - Actual test execution
11
+ * - Real git operations
12
+ */
13
+ import type { ImplementationPlan, ExecutionResult, PlanningResult, PreviousTaskContext, Logger, ProgressCallback } from '../types/index.js';
14
+ export interface ClaudeExecutorConfig {
15
+ /** Path to the cloned repository */
16
+ repoPath: string;
17
+ /** Anthropic API key (optional, uses ANTHROPIC_API_KEY env var if not provided) */
18
+ apiKey?: string;
19
+ /** Maximum budget in USD */
20
+ maxBudgetUsd?: number;
21
+ /** Maximum turns before stopping */
22
+ maxTurns?: number;
23
+ /** Logger function */
24
+ logger?: Logger;
25
+ /** Callback for progress updates */
26
+ onProgress?: ProgressCallback;
27
+ /** Context from previous attempts */
28
+ previousContext?: PreviousTaskContext;
29
+ }
30
+ /**
31
+ * Generate an implementation plan using Claude Agent SDK
32
+ */
33
+ export declare function planWithClaude(taskTitle: string, taskDescription: string | null, config: ClaudeExecutorConfig): Promise<PlanningResult>;
34
+ /**
35
+ * Execute an implementation plan using Claude Agent SDK
36
+ */
37
+ export declare function executeWithClaude(plan: ImplementationPlan, taskTitle: string, taskDescription: string | null, config: ClaudeExecutorConfig): Promise<ExecutionResult>;
38
+ /**
39
+ * Prepare a repository for execution
40
+ */
41
+ export declare function prepareRepository(repoOwner: string, repoName: string, branch: string, githubToken: string, workDir?: string): Promise<{
42
+ repoPath: string;
43
+ cleanup: () => Promise<void>;
44
+ }>;
45
+ //# sourceMappingURL=claude.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"claude.d.ts","sourceRoot":"","sources":["../../src/executors/claude.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,OAAO,KAAK,EACV,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,mBAAmB,EACnB,MAAM,EACN,gBAAgB,EACjB,MAAM,mBAAmB,CAAA;AAkF1B,MAAM,WAAW,oBAAoB;IACnC,oCAAoC;IACpC,QAAQ,EAAE,MAAM,CAAA;IAChB,mFAAmF;IACnF,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,4BAA4B;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,oCAAoC;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,sBAAsB;IACtB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,oCAAoC;IACpC,UAAU,CAAC,EAAE,gBAAgB,CAAA;IAC7B,qCAAqC;IACrC,eAAe,CAAC,EAAE,mBAAmB,CAAA;CACtC;AAMD;;GAEG;AACH,wBAAsB,cAAc,CAClC,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,GAAG,IAAI,EAC9B,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,cAAc,CAAC,CAg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