@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.
- package/README.md +160 -0
- package/dist/adapters/astrid-oauth.d.ts +95 -0
- package/dist/adapters/astrid-oauth.d.ts.map +1 -0
- package/dist/adapters/astrid-oauth.js +230 -0
- package/dist/adapters/astrid-oauth.js.map +1 -0
- package/dist/bin/cli.d.ts +13 -0
- package/dist/bin/cli.d.ts.map +1 -0
- package/dist/bin/cli.js +286 -0
- package/dist/bin/cli.js.map +1 -0
- package/dist/executors/claude.d.ts +45 -0
- package/dist/executors/claude.d.ts.map +1 -0
- package/dist/executors/claude.js +654 -0
- package/dist/executors/claude.js.map +1 -0
- package/dist/executors/gemini.d.ts +23 -0
- package/dist/executors/gemini.d.ts.map +1 -0
- package/dist/executors/gemini.js +487 -0
- package/dist/executors/gemini.js.map +1 -0
- package/dist/executors/openai.d.ts +24 -0
- package/dist/executors/openai.d.ts.map +1 -0
- package/dist/executors/openai.js +502 -0
- package/dist/executors/openai.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/types/index.d.ts +143 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +6 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/agent-config.d.ts +56 -0
- package/dist/utils/agent-config.d.ts.map +1 -0
- package/dist/utils/agent-config.js +125 -0
- package/dist/utils/agent-config.js.map +1 -0
- package/package.json +65 -0
package/README.md
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# @gracefultools/astrid-sdk
|
|
2
|
+
|
|
3
|
+
AI agent SDK for automated coding tasks with Claude, OpenAI, and Gemini.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @gracefultools/astrid-sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
### CLI Usage
|
|
14
|
+
|
|
15
|
+
Run the agent worker to poll for tasks:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# Set up environment variables
|
|
19
|
+
export ASTRID_OAUTH_CLIENT_ID=your_client_id
|
|
20
|
+
export ASTRID_OAUTH_CLIENT_SECRET=your_client_secret
|
|
21
|
+
export ASTRID_OAUTH_LIST_ID=your_list_id
|
|
22
|
+
export ANTHROPIC_API_KEY=sk-ant-... # For Claude
|
|
23
|
+
|
|
24
|
+
# Start the worker
|
|
25
|
+
npx astrid-agent
|
|
26
|
+
|
|
27
|
+
# Or process a specific task
|
|
28
|
+
npx astrid-agent <taskId>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Programmatic Usage
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
import {
|
|
35
|
+
planWithClaude,
|
|
36
|
+
executeWithClaude,
|
|
37
|
+
AstridOAuthClient,
|
|
38
|
+
} from '@gracefultools/astrid-sdk'
|
|
39
|
+
|
|
40
|
+
// Connect to Astrid
|
|
41
|
+
const client = new AstridOAuthClient({
|
|
42
|
+
clientId: process.env.ASTRID_OAUTH_CLIENT_ID,
|
|
43
|
+
clientSecret: process.env.ASTRID_OAUTH_CLIENT_SECRET,
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
// Get tasks
|
|
47
|
+
const tasks = await client.getTasks(listId)
|
|
48
|
+
|
|
49
|
+
// Plan implementation
|
|
50
|
+
const planResult = await planWithClaude(
|
|
51
|
+
task.title,
|
|
52
|
+
task.description,
|
|
53
|
+
{
|
|
54
|
+
repoPath: '/path/to/repo',
|
|
55
|
+
apiKey: process.env.ANTHROPIC_API_KEY,
|
|
56
|
+
maxBudgetUsd: 5.0,
|
|
57
|
+
logger: console.log,
|
|
58
|
+
onProgress: (msg) => console.log(msg),
|
|
59
|
+
}
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
// Execute the plan
|
|
63
|
+
if (planResult.success && planResult.plan) {
|
|
64
|
+
const execResult = await executeWithClaude(
|
|
65
|
+
planResult.plan,
|
|
66
|
+
task.title,
|
|
67
|
+
task.description,
|
|
68
|
+
config
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
console.log('Files modified:', execResult.files.length)
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Environment Variables
|
|
76
|
+
|
|
77
|
+
| Variable | Required | Description |
|
|
78
|
+
|----------|----------|-------------|
|
|
79
|
+
| `ASTRID_OAUTH_CLIENT_ID` | Yes | OAuth client ID from Astrid |
|
|
80
|
+
| `ASTRID_OAUTH_CLIENT_SECRET` | Yes | OAuth client secret |
|
|
81
|
+
| `ASTRID_OAUTH_LIST_ID` | Yes | List ID to monitor for tasks |
|
|
82
|
+
| `ANTHROPIC_API_KEY` | For Claude | Anthropic API key |
|
|
83
|
+
| `OPENAI_API_KEY` | For OpenAI | OpenAI API key |
|
|
84
|
+
| `GEMINI_API_KEY` | For Gemini | Google Gemini API key |
|
|
85
|
+
| `GITHUB_TOKEN` | For repos | GitHub token for cloning |
|
|
86
|
+
| `POLL_INTERVAL_MS` | No | Poll interval (default: 30000) |
|
|
87
|
+
| `MAX_BUDGET_USD` | No | Max budget per task (default: 10.0) |
|
|
88
|
+
|
|
89
|
+
## AI Providers
|
|
90
|
+
|
|
91
|
+
The SDK supports three AI providers:
|
|
92
|
+
|
|
93
|
+
### Claude (Recommended)
|
|
94
|
+
|
|
95
|
+
Uses the Claude Agent SDK for native tool use:
|
|
96
|
+
- Best code quality
|
|
97
|
+
- Native file editing
|
|
98
|
+
- Real test execution
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
import { planWithClaude, executeWithClaude } from '@gracefultools/astrid-sdk'
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### OpenAI
|
|
105
|
+
|
|
106
|
+
Uses GPT-4 with function calling:
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
import { planWithOpenAI, executeWithOpenAI } from '@gracefultools/astrid-sdk'
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Gemini
|
|
113
|
+
|
|
114
|
+
Uses Gemini with function calling:
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
import { planWithGemini, executeWithGemini } from '@gracefultools/astrid-sdk'
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Astrid OAuth Client
|
|
121
|
+
|
|
122
|
+
The SDK includes a client for the Astrid OAuth API:
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
import { AstridOAuthClient } from '@gracefultools/astrid-sdk'
|
|
126
|
+
|
|
127
|
+
const client = new AstridOAuthClient()
|
|
128
|
+
|
|
129
|
+
// Get lists
|
|
130
|
+
const lists = await client.getLists()
|
|
131
|
+
|
|
132
|
+
// Get tasks
|
|
133
|
+
const tasks = await client.getTasks(listId)
|
|
134
|
+
|
|
135
|
+
// Get a specific task
|
|
136
|
+
const task = await client.getTask(taskId)
|
|
137
|
+
|
|
138
|
+
// Add a comment
|
|
139
|
+
await client.addComment(taskId, 'Work in progress...')
|
|
140
|
+
|
|
141
|
+
// Complete a task
|
|
142
|
+
await client.completeTask(taskId)
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Keeping Updated
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
# Update to latest version
|
|
149
|
+
npm update @gracefultools/astrid-sdk
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## License
|
|
153
|
+
|
|
154
|
+
MIT
|
|
155
|
+
|
|
156
|
+
## Links
|
|
157
|
+
|
|
158
|
+
- [Astrid](https://astrid.cc)
|
|
159
|
+
- [Documentation](https://astrid.cc/docs)
|
|
160
|
+
- [GitHub](https://github.com/Graceful-Tools/astrid-res-www)
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Astrid OAuth API Client
|
|
3
|
+
*
|
|
4
|
+
* Client for accessing Astrid tasks via OAuth 2.0 Client Credentials flow
|
|
5
|
+
*/
|
|
6
|
+
import type { AstridTask, AstridList } from '../types/index.js';
|
|
7
|
+
interface APIResponse<T = unknown> {
|
|
8
|
+
success: boolean;
|
|
9
|
+
data?: T;
|
|
10
|
+
error?: string;
|
|
11
|
+
}
|
|
12
|
+
interface Comment {
|
|
13
|
+
id: string;
|
|
14
|
+
content: string;
|
|
15
|
+
createdAt: string;
|
|
16
|
+
authorId: string;
|
|
17
|
+
authorEmail?: string;
|
|
18
|
+
}
|
|
19
|
+
interface CreateTaskData {
|
|
20
|
+
title: string;
|
|
21
|
+
description?: string;
|
|
22
|
+
priority?: number;
|
|
23
|
+
listId?: string;
|
|
24
|
+
dueDateTime?: string;
|
|
25
|
+
}
|
|
26
|
+
interface UpdateTaskData {
|
|
27
|
+
title?: string;
|
|
28
|
+
description?: string;
|
|
29
|
+
priority?: number;
|
|
30
|
+
isCompleted?: boolean;
|
|
31
|
+
dueDateTime?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface AstridOAuthConfig {
|
|
34
|
+
baseUrl?: string;
|
|
35
|
+
clientId?: string;
|
|
36
|
+
clientSecret?: string;
|
|
37
|
+
}
|
|
38
|
+
export declare class AstridOAuthClient {
|
|
39
|
+
private readonly baseUrl;
|
|
40
|
+
private readonly clientId;
|
|
41
|
+
private readonly clientSecret;
|
|
42
|
+
private accessToken;
|
|
43
|
+
private tokenExpiry;
|
|
44
|
+
constructor(config?: AstridOAuthConfig);
|
|
45
|
+
/**
|
|
46
|
+
* Check if the client is properly configured
|
|
47
|
+
*/
|
|
48
|
+
isConfigured(): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Obtain an access token using client credentials flow
|
|
51
|
+
*/
|
|
52
|
+
private obtainAccessToken;
|
|
53
|
+
/**
|
|
54
|
+
* Make an authenticated API request
|
|
55
|
+
*/
|
|
56
|
+
private makeRequest;
|
|
57
|
+
/**
|
|
58
|
+
* Get all lists accessible to the authenticated user
|
|
59
|
+
*/
|
|
60
|
+
getLists(): Promise<APIResponse<AstridList[]>>;
|
|
61
|
+
/**
|
|
62
|
+
* Get all tasks, optionally filtered by list
|
|
63
|
+
*/
|
|
64
|
+
getTasks(listId?: string, includeCompleted?: boolean): Promise<APIResponse<AstridTask[]>>;
|
|
65
|
+
/**
|
|
66
|
+
* Get a specific task by ID with comments
|
|
67
|
+
*/
|
|
68
|
+
getTask(taskId: string): Promise<APIResponse<AstridTask>>;
|
|
69
|
+
/**
|
|
70
|
+
* Get comments for a task
|
|
71
|
+
*/
|
|
72
|
+
getComments(taskId: string): Promise<APIResponse<Comment[]>>;
|
|
73
|
+
/**
|
|
74
|
+
* Create a new task
|
|
75
|
+
*/
|
|
76
|
+
createTask(taskData: CreateTaskData): Promise<APIResponse<AstridTask>>;
|
|
77
|
+
/**
|
|
78
|
+
* Update an existing task
|
|
79
|
+
*/
|
|
80
|
+
updateTask(taskId: string, updates: UpdateTaskData): Promise<APIResponse<AstridTask>>;
|
|
81
|
+
/**
|
|
82
|
+
* Mark a task as complete
|
|
83
|
+
*/
|
|
84
|
+
completeTask(taskId: string): Promise<APIResponse<AstridTask>>;
|
|
85
|
+
/**
|
|
86
|
+
* Add a comment to a task
|
|
87
|
+
*/
|
|
88
|
+
addComment(taskId: string, content: string): Promise<APIResponse<Comment>>;
|
|
89
|
+
/**
|
|
90
|
+
* Test the connection to the API
|
|
91
|
+
*/
|
|
92
|
+
testConnection(): Promise<APIResponse>;
|
|
93
|
+
}
|
|
94
|
+
export type { APIResponse, Comment, CreateTaskData, UpdateTaskData };
|
|
95
|
+
//# sourceMappingURL=astrid-oauth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"astrid-oauth.d.ts","sourceRoot":"","sources":["../../src/adapters/astrid-oauth.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAS/D,UAAU,WAAW,C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AAC,WAAW,CAAC,UAAU,EAAE,CAAC,CAAC;IAYpD;;OAEG;IACG,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,gBAAgB,GAAE,OAAe,GAAG,OAAO,CAAC,WAAW,CAAC,UAAU,EAAE,CAAC,CAAC;IAmBtG;;OAEG;IACG,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IAY/D;;OAEG;IACG,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC,CAAC;IAYlE;;OAEG;IACG,UAAU,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IAe5E;;OAEG;IACG,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IAe3F;;OAEG;IACG,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IAIpE;;OAEG;IACG,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAkBhF;;OAEG;IACG,cAAc,IAAI,OAAO,CAAC,WAAW,CAAC;CA0B7C;AAGD,YAAY,EAAE,WAAW,EAAE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,CAAA"}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Astrid OAuth API Client
|
|
4
|
+
*
|
|
5
|
+
* Client for accessing Astrid tasks via OAuth 2.0 Client Credentials flow
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.AstridOAuthClient = void 0;
|
|
9
|
+
class AstridOAuthClient {
|
|
10
|
+
baseUrl;
|
|
11
|
+
clientId;
|
|
12
|
+
clientSecret;
|
|
13
|
+
accessToken = null;
|
|
14
|
+
tokenExpiry = 0;
|
|
15
|
+
constructor(config) {
|
|
16
|
+
this.baseUrl = config?.baseUrl || process.env.ASTRID_API_URL || 'https://astrid.cc';
|
|
17
|
+
this.clientId = config?.clientId || process.env.ASTRID_OAUTH_CLIENT_ID || '';
|
|
18
|
+
this.clientSecret = config?.clientSecret || process.env.ASTRID_OAUTH_CLIENT_SECRET || '';
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Check if the client is properly configured
|
|
22
|
+
*/
|
|
23
|
+
isConfigured() {
|
|
24
|
+
return !!this.clientId && !!this.clientSecret;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Obtain an access token using client credentials flow
|
|
28
|
+
*/
|
|
29
|
+
async obtainAccessToken() {
|
|
30
|
+
// Check if we have a valid token
|
|
31
|
+
if (this.accessToken && Date.now() < this.tokenExpiry) {
|
|
32
|
+
return this.accessToken;
|
|
33
|
+
}
|
|
34
|
+
const response = await fetch(`${this.baseUrl}/api/v1/oauth/token`, {
|
|
35
|
+
method: 'POST',
|
|
36
|
+
headers: { 'Content-Type': 'application/json' },
|
|
37
|
+
body: JSON.stringify({
|
|
38
|
+
grant_type: 'client_credentials',
|
|
39
|
+
client_id: this.clientId,
|
|
40
|
+
client_secret: this.clientSecret,
|
|
41
|
+
}),
|
|
42
|
+
});
|
|
43
|
+
if (!response.ok) {
|
|
44
|
+
const errorData = await response.json().catch(() => ({ error: response.statusText }));
|
|
45
|
+
throw new Error(errorData.error || `HTTP ${response.status}: ${response.statusText}`);
|
|
46
|
+
}
|
|
47
|
+
const data = await response.json();
|
|
48
|
+
this.accessToken = data.access_token;
|
|
49
|
+
// Set expiry to 5 minutes before actual expiry for safety
|
|
50
|
+
this.tokenExpiry = Date.now() + ((data.expires_in - 300) * 1000);
|
|
51
|
+
return this.accessToken;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Make an authenticated API request
|
|
55
|
+
*/
|
|
56
|
+
async makeRequest(endpoint, options = {}) {
|
|
57
|
+
const token = await this.obtainAccessToken();
|
|
58
|
+
const response = await fetch(`${this.baseUrl}${endpoint}`, {
|
|
59
|
+
...options,
|
|
60
|
+
headers: {
|
|
61
|
+
...options.headers,
|
|
62
|
+
'X-OAuth-Token': token,
|
|
63
|
+
'Content-Type': 'application/json',
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
if (!response.ok) {
|
|
67
|
+
const errorData = await response.json().catch(() => ({ error: response.statusText }));
|
|
68
|
+
throw new Error(errorData.error || `HTTP ${response.status}: ${response.statusText}`);
|
|
69
|
+
}
|
|
70
|
+
return response.json();
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Get all lists accessible to the authenticated user
|
|
74
|
+
*/
|
|
75
|
+
async getLists() {
|
|
76
|
+
try {
|
|
77
|
+
const data = await this.makeRequest('/api/v1/lists');
|
|
78
|
+
return { success: true, data: data.lists };
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
return {
|
|
82
|
+
success: false,
|
|
83
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Get all tasks, optionally filtered by list
|
|
89
|
+
*/
|
|
90
|
+
async getTasks(listId, includeCompleted = false) {
|
|
91
|
+
try {
|
|
92
|
+
const params = new URLSearchParams();
|
|
93
|
+
if (listId)
|
|
94
|
+
params.append('listId', listId);
|
|
95
|
+
if (includeCompleted)
|
|
96
|
+
params.append('includeCompleted', 'true');
|
|
97
|
+
const queryString = params.toString();
|
|
98
|
+
const endpoint = queryString ? `/api/v1/tasks?${queryString}` : '/api/v1/tasks';
|
|
99
|
+
const data = await this.makeRequest(endpoint);
|
|
100
|
+
return { success: true, data: data.tasks };
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
return {
|
|
104
|
+
success: false,
|
|
105
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Get a specific task by ID with comments
|
|
111
|
+
*/
|
|
112
|
+
async getTask(taskId) {
|
|
113
|
+
try {
|
|
114
|
+
const data = await this.makeRequest(`/api/v1/tasks/${taskId}`);
|
|
115
|
+
return { success: true, data: data.task };
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
return {
|
|
119
|
+
success: false,
|
|
120
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Get comments for a task
|
|
126
|
+
*/
|
|
127
|
+
async getComments(taskId) {
|
|
128
|
+
try {
|
|
129
|
+
const data = await this.makeRequest(`/api/v1/tasks/${taskId}/comments`);
|
|
130
|
+
return { success: true, data: data.comments };
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
return {
|
|
134
|
+
success: false,
|
|
135
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Create a new task
|
|
141
|
+
*/
|
|
142
|
+
async createTask(taskData) {
|
|
143
|
+
try {
|
|
144
|
+
const data = await this.makeRequest('/api/v1/tasks', {
|
|
145
|
+
method: 'POST',
|
|
146
|
+
body: JSON.stringify(taskData),
|
|
147
|
+
});
|
|
148
|
+
return { success: true, data: data.task };
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
return {
|
|
152
|
+
success: false,
|
|
153
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Update an existing task
|
|
159
|
+
*/
|
|
160
|
+
async updateTask(taskId, updates) {
|
|
161
|
+
try {
|
|
162
|
+
const data = await this.makeRequest(`/api/v1/tasks/${taskId}`, {
|
|
163
|
+
method: 'PATCH',
|
|
164
|
+
body: JSON.stringify(updates),
|
|
165
|
+
});
|
|
166
|
+
return { success: true, data: data.task };
|
|
167
|
+
}
|
|
168
|
+
catch (error) {
|
|
169
|
+
return {
|
|
170
|
+
success: false,
|
|
171
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Mark a task as complete
|
|
177
|
+
*/
|
|
178
|
+
async completeTask(taskId) {
|
|
179
|
+
return this.updateTask(taskId, { isCompleted: true });
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Add a comment to a task
|
|
183
|
+
*/
|
|
184
|
+
async addComment(taskId, content) {
|
|
185
|
+
try {
|
|
186
|
+
const data = await this.makeRequest(`/api/v1/tasks/${taskId}/comments`, {
|
|
187
|
+
method: 'POST',
|
|
188
|
+
body: JSON.stringify({ content }),
|
|
189
|
+
});
|
|
190
|
+
return { success: true, data: data.comment };
|
|
191
|
+
}
|
|
192
|
+
catch (error) {
|
|
193
|
+
return {
|
|
194
|
+
success: false,
|
|
195
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Test the connection to the API
|
|
201
|
+
*/
|
|
202
|
+
async testConnection() {
|
|
203
|
+
try {
|
|
204
|
+
if (!this.isConfigured()) {
|
|
205
|
+
throw new Error('OAuth credentials not configured');
|
|
206
|
+
}
|
|
207
|
+
const result = await this.getLists();
|
|
208
|
+
if (result.success) {
|
|
209
|
+
return {
|
|
210
|
+
success: true,
|
|
211
|
+
data: {
|
|
212
|
+
message: 'Connection successful',
|
|
213
|
+
listsCount: result.data?.length || 0,
|
|
214
|
+
},
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
throw new Error(result.error);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
catch (error) {
|
|
222
|
+
return {
|
|
223
|
+
success: false,
|
|
224
|
+
error: error instanceof Error ? error.message : 'Connection failed',
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
exports.AstridOAuthClient = AstridOAuthClient;
|
|
230
|
+
//# sourceMappingURL=astrid-oauth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"astrid-oauth.js","sourceRoot":"","sources":["../../src/adapters/astrid-oauth.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AA+CH,MAAa,iBAAiB;IACX,OAAO,CAAQ;IACf,QAAQ,CAAQ;IAChB,YAAY,CAAQ;IAC7B,WAAW,GAAkB,IAAI,CAAA;IACjC,WAAW,GAAW,CAAC,CAAA;IAE/B,YAAY,MAA0B;QACpC,IAAI,CAAC,OAAO,GAAG,MAAM,EAAE,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,mBAAmB,CAAA;QACnF,IAAI,CAAC,QAAQ,GAAG,MAAM,EAAE,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,sBAAsB,IAAI,EAAE,CAAA;QAC5E,IAAI,CAAC,YAAY,GAAG,MAAM,EAAE,YAAY,IAAI,OAAO,CAAC,GAAG,CAAC,0BAA0B,IAAI,EAAE,CAAA;IAC1F,CAAC;IAED;;OAEG;IACH,YAAY;QACV,OAAO,CAAC,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,CAAC,IAAI,CAAC,YAAY,CAAA;IAC/C,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,iBAAiB;QAC7B,iCAAiC;QACjC,IAAI,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;YACtD,OAAO,IAAI,CAAC,WAAW,CAAA;QACzB,CA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CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;YAC/B,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,mBAAmB;aACpE,CAAA;QACH,CAAC;IACH,CAAC;CACF;AA/OD,8CA+OC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* @gracefultools/astrid-sdk CLI
|
|
4
|
+
*
|
|
5
|
+
* Command-line interface for running the Astrid AI agent worker
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* npx astrid-agent # Start polling for tasks
|
|
9
|
+
* npx astrid-agent <taskId> # Process a specific task
|
|
10
|
+
* npx astrid-agent --help # Show help
|
|
11
|
+
*/
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/bin/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;GASG"}
|