@recursorsdk/sdk 1.0.0 → 1.0.1
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 +6 -33
- package/dist/index.d.ts +7 -33
- package/dist/index.js +13 -35
- package/dist/plugins/windsurfStub.d.ts +1 -1
- package/dist/plugins/windsurfStub.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ Complete Node.js SDK for interacting with the Recursor API. Provides authenticat
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm install @
|
|
8
|
+
npm install @recursorsdk/sdk
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
Or build from source:
|
|
@@ -22,7 +22,7 @@ npm pack
|
|
|
22
22
|
### Basic Usage
|
|
23
23
|
|
|
24
24
|
```typescript
|
|
25
|
-
import { RecursorSDK } from "@
|
|
25
|
+
import { RecursorSDK } from "@recursorsdk/sdk";
|
|
26
26
|
|
|
27
27
|
const sdk = new RecursorSDK({
|
|
28
28
|
baseUrl: "https://api.recursor.dev/api/v1",
|
|
@@ -73,7 +73,6 @@ await sdk.changePassword({
|
|
|
73
73
|
// Create a project
|
|
74
74
|
const project = await sdk.createProject({
|
|
75
75
|
name: "My Project",
|
|
76
|
-
organization_id: "org-123",
|
|
77
76
|
description: "Project description",
|
|
78
77
|
});
|
|
79
78
|
|
|
@@ -81,7 +80,7 @@ const project = await sdk.createProject({
|
|
|
81
80
|
const projectDetails = await sdk.getProject(project.id);
|
|
82
81
|
|
|
83
82
|
// List projects
|
|
84
|
-
const projects = await sdk.listProjects(
|
|
83
|
+
const projects = await sdk.listProjects();
|
|
85
84
|
|
|
86
85
|
// Get MCP configuration
|
|
87
86
|
const mcpConfig = await sdk.getMcpConfig(project.id);
|
|
@@ -100,25 +99,6 @@ const updated = await sdk.updateProject(project.id, {
|
|
|
100
99
|
await sdk.deleteProject(project.id);
|
|
101
100
|
```
|
|
102
101
|
|
|
103
|
-
### Organizations & Teams
|
|
104
|
-
|
|
105
|
-
```typescript
|
|
106
|
-
// Create organization
|
|
107
|
-
const org = await sdk.createOrganization({
|
|
108
|
-
name: "My Organization",
|
|
109
|
-
description: "Organization description",
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
// List organizations
|
|
113
|
-
const orgs = await sdk.listOrganizations();
|
|
114
|
-
|
|
115
|
-
// Add member
|
|
116
|
-
await sdk.addMemberToOrganization(org.id, "user-123");
|
|
117
|
-
|
|
118
|
-
// Remove member
|
|
119
|
-
await sdk.removeMemberFromOrganization(org.id, "user-123");
|
|
120
|
-
```
|
|
121
|
-
|
|
122
102
|
### Corrections
|
|
123
103
|
|
|
124
104
|
```typescript
|
|
@@ -235,7 +215,7 @@ const guidelines = await sdk.getGuidelines();
|
|
|
235
215
|
### WebSocket (Real-time Updates)
|
|
236
216
|
|
|
237
217
|
```typescript
|
|
238
|
-
import { RecursorSDK, RecursorWebSocket } from "@
|
|
218
|
+
import { RecursorSDK, RecursorWebSocket } from "@recursorsdk/sdk";
|
|
239
219
|
|
|
240
220
|
// Login first to get access token
|
|
241
221
|
await sdk.login({ email: "user@example.com", password: "password" });
|
|
@@ -322,25 +302,18 @@ const avResult = await sdk.avGatewayObserve({
|
|
|
322
302
|
### Project Methods
|
|
323
303
|
- `createProject(projectData)` - Create project
|
|
324
304
|
- `getProject(projectId)` - Get project
|
|
325
|
-
- `listProjects(
|
|
305
|
+
- `listProjects()` - List projects
|
|
326
306
|
- `updateProject(projectId, updates)` - Update project
|
|
327
307
|
- `deleteProject(projectId)` - Delete project
|
|
328
308
|
- `regenerateProjectApiKey(projectId)` - Regenerate API key
|
|
329
309
|
- `getMcpConfig(projectId)` - Get MCP configuration
|
|
330
310
|
- `getMcpStats(projectId)` - Get MCP statistics
|
|
331
311
|
|
|
332
|
-
### Organization Methods
|
|
333
|
-
- `createOrganization(orgData)` - Create organization
|
|
334
|
-
- `listOrganizations()` - List organizations
|
|
335
|
-
- `getOrganization(orgId)` - Get organization
|
|
336
|
-
- `updateOrganization(orgId, updates)` - Update organization
|
|
337
|
-
- `addMemberToOrganization(orgId, userId)` - Add member
|
|
338
|
-
- `removeMemberFromOrganization(orgId, userId)` - Remove member
|
|
339
312
|
|
|
340
313
|
### Correction Methods
|
|
341
314
|
- `createCorrection(correctionData)` - Create correction
|
|
342
315
|
- `listCorrections(options?)` - List corrections
|
|
343
|
-
- `searchCorrections(query, limit
|
|
316
|
+
- `searchCorrections(query, limit)` - Search corrections
|
|
344
317
|
- `getCorrection(correctionId)` - Get correction
|
|
345
318
|
- `updateCorrection(correctionId, updates)` - Update correction
|
|
346
319
|
- `getCorrectionStats()` - Get statistics
|
package/dist/index.d.ts
CHANGED
|
@@ -85,7 +85,6 @@ export interface APIKeyResponse {
|
|
|
85
85
|
export interface ProjectCreate {
|
|
86
86
|
name: string;
|
|
87
87
|
description?: string;
|
|
88
|
-
organization_id: string;
|
|
89
88
|
settings?: Record<string, unknown>;
|
|
90
89
|
}
|
|
91
90
|
export interface ProjectUpdate {
|
|
@@ -98,7 +97,6 @@ export interface ProjectResponse {
|
|
|
98
97
|
id: string;
|
|
99
98
|
name: string;
|
|
100
99
|
description?: string;
|
|
101
|
-
organization_id: string;
|
|
102
100
|
created_by?: string;
|
|
103
101
|
api_key?: string;
|
|
104
102
|
is_active: boolean;
|
|
@@ -106,23 +104,6 @@ export interface ProjectResponse {
|
|
|
106
104
|
updated_at: string;
|
|
107
105
|
settings?: Record<string, unknown>;
|
|
108
106
|
}
|
|
109
|
-
export interface OrganizationCreate {
|
|
110
|
-
name: string;
|
|
111
|
-
description?: string;
|
|
112
|
-
}
|
|
113
|
-
export interface OrganizationUpdate {
|
|
114
|
-
name?: string;
|
|
115
|
-
description?: string;
|
|
116
|
-
}
|
|
117
|
-
export interface OrganizationResponse {
|
|
118
|
-
id: string;
|
|
119
|
-
name: string;
|
|
120
|
-
slug: string;
|
|
121
|
-
description?: string;
|
|
122
|
-
created_by: string;
|
|
123
|
-
created_at: string;
|
|
124
|
-
updated_at: string;
|
|
125
|
-
}
|
|
126
107
|
export interface UsageStatsResponse {
|
|
127
108
|
api_calls: {
|
|
128
109
|
used: number;
|
|
@@ -194,6 +175,11 @@ export declare class RecursorSDK {
|
|
|
194
175
|
private patch;
|
|
195
176
|
private delete;
|
|
196
177
|
checkHealth(): Promise<boolean>;
|
|
178
|
+
/**
|
|
179
|
+
* Close the SDK client and cleanup resources
|
|
180
|
+
* Disconnects WebSocket if connected
|
|
181
|
+
*/
|
|
182
|
+
close(): void;
|
|
197
183
|
detectIntent(args: {
|
|
198
184
|
user_request: string;
|
|
199
185
|
current_file?: string;
|
|
@@ -201,7 +187,6 @@ export declare class RecursorSDK {
|
|
|
201
187
|
project_id?: string;
|
|
202
188
|
tags?: string[];
|
|
203
189
|
similar_limit?: number;
|
|
204
|
-
organization_id?: string;
|
|
205
190
|
}): Promise<IntentResponse>;
|
|
206
191
|
getLLMGatewayPolicy(): Promise<Record<string, unknown>>;
|
|
207
192
|
gatewayChat(args: {
|
|
@@ -210,7 +195,6 @@ export declare class RecursorSDK {
|
|
|
210
195
|
messages: ChatMessage[];
|
|
211
196
|
call_provider?: boolean;
|
|
212
197
|
user_id?: string;
|
|
213
|
-
organization_id?: string;
|
|
214
198
|
}): Promise<ChatGatewayResponse>;
|
|
215
199
|
getRoboticsGatewayPolicy(): Promise<Record<string, unknown>>;
|
|
216
200
|
roboticsGatewayObserve(args: {
|
|
@@ -218,7 +202,6 @@ export declare class RecursorSDK {
|
|
|
218
202
|
command?: Record<string, unknown>;
|
|
219
203
|
environment?: Record<string, unknown>[];
|
|
220
204
|
user_id?: string;
|
|
221
|
-
organization_id?: string;
|
|
222
205
|
}): Promise<RoboticsGatewayResponse>;
|
|
223
206
|
getAvGatewayPolicy(): Promise<Record<string, unknown>>;
|
|
224
207
|
avGatewayObserve(args: {
|
|
@@ -228,7 +211,6 @@ export declare class RecursorSDK {
|
|
|
228
211
|
timestamp: number;
|
|
229
212
|
vehicle_id: string;
|
|
230
213
|
user_id?: string;
|
|
231
|
-
organization_id?: string;
|
|
232
214
|
}): Promise<AVGatewayResponse>;
|
|
233
215
|
getIntentHistory(limit?: number, project_id?: string): Promise<IntentHistoryItem[]>;
|
|
234
216
|
createCorrection(args: {
|
|
@@ -237,15 +219,13 @@ export declare class RecursorSDK {
|
|
|
237
219
|
expected_output?: string;
|
|
238
220
|
context?: Record<string, unknown>;
|
|
239
221
|
correction_type?: string;
|
|
240
|
-
organization_id?: string;
|
|
241
222
|
}): Promise<Record<string, unknown>>;
|
|
242
223
|
listCorrections(args?: {
|
|
243
224
|
page?: number;
|
|
244
225
|
page_size?: number;
|
|
245
226
|
include_inactive?: boolean;
|
|
246
|
-
organization_id?: string;
|
|
247
227
|
}): Promise<CorrectionResponseList>;
|
|
248
|
-
searchCorrections(query: string, limit?: number
|
|
228
|
+
searchCorrections(query: string, limit?: number): Promise<CorrectionResponseList>;
|
|
249
229
|
getAnalyticsDashboard(user_id: string, period?: string, project_id?: string): Promise<Record<string, unknown>>;
|
|
250
230
|
getTimeSaved(user_id: string, period?: string, project_id?: string): Promise<Record<string, unknown>>;
|
|
251
231
|
getQualityMetrics(user_id: string, period?: string, project_id?: string): Promise<Record<string, unknown>>;
|
|
@@ -274,18 +254,12 @@ export declare class RecursorSDK {
|
|
|
274
254
|
}>;
|
|
275
255
|
createProject(projectData: ProjectCreate): Promise<ProjectResponse>;
|
|
276
256
|
getProject(projectId: string): Promise<ProjectResponse>;
|
|
277
|
-
listProjects(
|
|
257
|
+
listProjects(): Promise<ProjectResponse[]>;
|
|
278
258
|
updateProject(projectId: string, updates: ProjectUpdate): Promise<ProjectResponse>;
|
|
279
259
|
deleteProject(projectId: string): Promise<void>;
|
|
280
260
|
regenerateProjectApiKey(projectId: string): Promise<APIKeyResponse>;
|
|
281
261
|
getMcpConfig(projectId: string): Promise<Record<string, unknown>>;
|
|
282
262
|
getMcpStats(projectId: string): Promise<Record<string, unknown>>;
|
|
283
|
-
createOrganization(orgData: OrganizationCreate): Promise<OrganizationResponse>;
|
|
284
|
-
listOrganizations(): Promise<OrganizationResponse[]>;
|
|
285
|
-
getOrganization(orgId: string): Promise<OrganizationResponse>;
|
|
286
|
-
updateOrganization(orgId: string, updates: OrganizationUpdate): Promise<OrganizationResponse>;
|
|
287
|
-
addMemberToOrganization(orgId: string, userId: string): Promise<void>;
|
|
288
|
-
removeMemberFromOrganization(orgId: string, userId: string): Promise<void>;
|
|
289
263
|
getUsage(): Promise<UsageStatsResponse>;
|
|
290
264
|
getUsageHistory(days?: number, resourceType?: string): Promise<Record<string, unknown>>;
|
|
291
265
|
listBillingPlans(): Promise<BillingPlanResponse[]>;
|
package/dist/index.js
CHANGED
|
@@ -84,6 +84,15 @@ export class RecursorSDK {
|
|
|
84
84
|
return false;
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Close the SDK client and cleanup resources
|
|
89
|
+
* Disconnects WebSocket if connected
|
|
90
|
+
*/
|
|
91
|
+
close() {
|
|
92
|
+
this.disconnectWebSocket();
|
|
93
|
+
// In Node.js, fetch doesn't need explicit closing like Python's httpx.Client
|
|
94
|
+
// But we clean up WebSocket connections
|
|
95
|
+
}
|
|
87
96
|
async detectIntent(args) {
|
|
88
97
|
const payload = {
|
|
89
98
|
user_request: (args.user_request ?? "").trim().slice(0, 4000),
|
|
@@ -92,7 +101,6 @@ export class RecursorSDK {
|
|
|
92
101
|
project_id: args.project_id ?? null,
|
|
93
102
|
tags: args.tags ?? [],
|
|
94
103
|
similar_limit: args.similar_limit ?? 5,
|
|
95
|
-
organization_id: args.organization_id ?? null,
|
|
96
104
|
};
|
|
97
105
|
return await this.post("/client/code_intelligence/detect-intent", payload);
|
|
98
106
|
}
|
|
@@ -107,7 +115,6 @@ export class RecursorSDK {
|
|
|
107
115
|
messages: (args.messages ?? []).map(m => ({ role: m.role, content: String(m.content).slice(0, 4000) })),
|
|
108
116
|
call_provider: !!(args.call_provider ?? false),
|
|
109
117
|
user_id: args.user_id ?? undefined,
|
|
110
|
-
organization_id: args.organization_id ?? undefined,
|
|
111
118
|
};
|
|
112
119
|
return await this.post("/recursor/llm/gateway/chat", body);
|
|
113
120
|
}
|
|
@@ -121,7 +128,6 @@ export class RecursorSDK {
|
|
|
121
128
|
command: args.command ?? undefined,
|
|
122
129
|
environment: args.environment ?? [],
|
|
123
130
|
user_id: args.user_id ?? undefined,
|
|
124
|
-
organization_id: args.organization_id ?? undefined,
|
|
125
131
|
};
|
|
126
132
|
return await this.post("/recursor/robotics/gateway/observe", body);
|
|
127
133
|
}
|
|
@@ -137,7 +143,6 @@ export class RecursorSDK {
|
|
|
137
143
|
timestamp: args.timestamp,
|
|
138
144
|
vehicle_id: args.vehicle_id,
|
|
139
145
|
user_id: args.user_id ?? undefined,
|
|
140
|
-
organization_id: args.organization_id ?? undefined,
|
|
141
146
|
};
|
|
142
147
|
return await this.post("/recursor/av/gateway/observe", body);
|
|
143
148
|
}
|
|
@@ -155,10 +160,7 @@ export class RecursorSDK {
|
|
|
155
160
|
context: args.context ?? {},
|
|
156
161
|
correction_type: args.correction_type ?? null,
|
|
157
162
|
};
|
|
158
|
-
|
|
159
|
-
? `/client/corrections/?organization_id=${encodeURIComponent(args.organization_id)}`
|
|
160
|
-
: "/client/corrections/";
|
|
161
|
-
return await this.post(path, body);
|
|
163
|
+
return await this.post("/client/corrections/", body);
|
|
162
164
|
}
|
|
163
165
|
async listCorrections(args) {
|
|
164
166
|
const params = {
|
|
@@ -166,17 +168,13 @@ export class RecursorSDK {
|
|
|
166
168
|
page_size: Math.max(1, Math.min(args?.page_size ?? 50, 100)),
|
|
167
169
|
include_inactive: !!(args?.include_inactive ?? false),
|
|
168
170
|
};
|
|
169
|
-
if (args?.organization_id)
|
|
170
|
-
params.organization_id = args.organization_id;
|
|
171
171
|
return await this.get("/client/corrections/", params);
|
|
172
172
|
}
|
|
173
|
-
async searchCorrections(query, limit = 10
|
|
173
|
+
async searchCorrections(query, limit = 10) {
|
|
174
174
|
const params = {
|
|
175
175
|
query: (query ?? "").trim().slice(0, 4000),
|
|
176
176
|
limit: Math.max(1, Math.min(limit, 50)),
|
|
177
177
|
};
|
|
178
|
-
if (organization_id)
|
|
179
|
-
params.organization_id = organization_id;
|
|
180
178
|
return await this.get("/client/corrections/search", params);
|
|
181
179
|
}
|
|
182
180
|
async getAnalyticsDashboard(user_id, period = "30d", project_id) {
|
|
@@ -282,9 +280,8 @@ export class RecursorSDK {
|
|
|
282
280
|
async getProject(projectId) {
|
|
283
281
|
return await this.get(`/client/projects/${projectId}`);
|
|
284
282
|
}
|
|
285
|
-
async listProjects(
|
|
286
|
-
|
|
287
|
-
return await this.get(path);
|
|
283
|
+
async listProjects() {
|
|
284
|
+
return await this.get("/client/projects/");
|
|
288
285
|
}
|
|
289
286
|
async updateProject(projectId, updates) {
|
|
290
287
|
return await this.patch(`/client/projects/${projectId}`, updates);
|
|
@@ -301,25 +298,6 @@ export class RecursorSDK {
|
|
|
301
298
|
async getMcpStats(projectId) {
|
|
302
299
|
return await this.get(`/client/projects/${projectId}/mcp-stats`);
|
|
303
300
|
}
|
|
304
|
-
// ==================== Organizations & Teams ====================
|
|
305
|
-
async createOrganization(orgData) {
|
|
306
|
-
return await this.post("/client/organizations/", orgData);
|
|
307
|
-
}
|
|
308
|
-
async listOrganizations() {
|
|
309
|
-
return await this.get("/client/organizations/");
|
|
310
|
-
}
|
|
311
|
-
async getOrganization(orgId) {
|
|
312
|
-
return await this.get(`/client/organizations/${orgId}`);
|
|
313
|
-
}
|
|
314
|
-
async updateOrganization(orgId, updates) {
|
|
315
|
-
return await this.put(`/client/organizations/${orgId}`, updates);
|
|
316
|
-
}
|
|
317
|
-
async addMemberToOrganization(orgId, userId) {
|
|
318
|
-
await this.post(`/client/organizations/${orgId}/members`, { user_id: userId });
|
|
319
|
-
}
|
|
320
|
-
async removeMemberFromOrganization(orgId, userId) {
|
|
321
|
-
await this.post(`/client/organizations/${orgId}/members/${userId}`, {});
|
|
322
|
-
}
|
|
323
301
|
// ==================== Billing & Usage ====================
|
|
324
302
|
async getUsage() {
|
|
325
303
|
return await this.get("/client/billing/usage");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function initAgentSession(userId?: string
|
|
1
|
+
export declare function initAgentSession(userId?: string): Promise<void>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { RecursorSDK } from "../index";
|
|
2
|
-
export async function initAgentSession(userId
|
|
2
|
+
export async function initAgentSession(userId) {
|
|
3
3
|
const sdk = new RecursorSDK();
|
|
4
4
|
try {
|
|
5
5
|
const policy = await sdk.getLLMGatewayPolicy();
|
|
6
6
|
const messages = [
|
|
7
7
|
{ role: "system", content: "Windsurf agent: route through Recursor gateway" },
|
|
8
8
|
];
|
|
9
|
-
await sdk.gatewayChat({ provider: "openai", model: undefined, messages, call_provider: false, user_id: userId
|
|
9
|
+
await sdk.gatewayChat({ provider: "openai", model: undefined, messages, call_provider: false, user_id: userId });
|
|
10
10
|
}
|
|
11
11
|
catch (e) {
|
|
12
12
|
// silent fail to avoid disrupting agent
|