@recursorsdk/sdk 1.0.1 → 1.0.2

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,61 @@
1
+ import { RecursorBase, Constructor } from "../base.js";
2
+ import { IntentResponse, IntentHistoryItem, ChatMessage, ChatGatewayResponse, ChatProxyRequest, ChatProxyResponse } from "../types.js";
3
+ export declare function IntelligenceMixin<TBase extends Constructor<RecursorBase>>(Base: TBase): {
4
+ new (...args: any[]): {
5
+ detectIntent(args: {
6
+ user_request: string;
7
+ current_file?: string;
8
+ user_id?: string;
9
+ project_id?: string;
10
+ tags?: string[];
11
+ similar_limit?: number;
12
+ }): Promise<IntentResponse>;
13
+ getIntentHistory(limit?: number, project_id?: string): Promise<IntentHistoryItem[]>;
14
+ predictCorrection(input_text: string, user_id: string, context?: Record<string, any>): Promise<any>;
15
+ correctCode(code: string, language: string, project_profile?: Record<string, unknown>): Promise<Record<string, unknown>>;
16
+ correctTests(test_code: string, test_framework: string, language: string): Promise<any>;
17
+ correctConfig(config: string, config_type: string): Promise<Record<string, unknown>>;
18
+ correctDocumentation(markdown: string, doc_type?: string): Promise<Record<string, unknown>>;
19
+ applyAutoCorrections(user_id: string, model_name: string, corrections: Array<Record<string, unknown>>): Promise<Record<string, unknown>>;
20
+ getTrustScore(user_id: string, model_name: string): Promise<number>;
21
+ submitFeedback(prediction_id: string, accepted: boolean): Promise<void>;
22
+ getAutoCorrectStats(user_id: string): Promise<Record<string, unknown>>;
23
+ getPatterns(user_id?: string): Promise<Array<Record<string, unknown>>>;
24
+ gatewayChat(args: {
25
+ provider?: string;
26
+ model?: string;
27
+ messages: ChatMessage[];
28
+ call_provider?: boolean;
29
+ user_id?: string;
30
+ }): Promise<ChatGatewayResponse>;
31
+ chatProxy(request: ChatProxyRequest): Promise<ChatProxyResponse>;
32
+ getLLMGatewayPolicy(): Promise<any>;
33
+ getRoboticsGatewayPolicy(): Promise<any>;
34
+ getAvGatewayPolicy(): Promise<any>;
35
+ listCorrections(args: {
36
+ page?: number;
37
+ page_size?: number;
38
+ }): Promise<any>;
39
+ searchCorrections(query: string, limit?: number): Promise<any[]>;
40
+ createCorrection(data: {
41
+ input_text: string;
42
+ output_text: string;
43
+ }): Promise<any>;
44
+ baseUrl: string;
45
+ apiKey?: string;
46
+ accessToken?: string;
47
+ timeoutMs: number;
48
+ wsClient?: any;
49
+ localIndex: Record<string, any>;
50
+ offlineQueue: any[];
51
+ setAccessToken(token: string): void;
52
+ setApiKey(key: string): void;
53
+ headers(): import("../types.js").HeadersInit;
54
+ get<T>(path: string, params?: Record<string, unknown>): Promise<T>;
55
+ post<T>(path: string, body?: unknown, method?: string): Promise<T>;
56
+ put<T>(path: string, body?: unknown): Promise<T>;
57
+ patch<T>(path: string, body?: unknown): Promise<T>;
58
+ delete<T>(path: string): Promise<T>;
59
+ checkHealth(): Promise<boolean>;
60
+ };
61
+ } & TBase;
@@ -0,0 +1,94 @@
1
+ export function IntelligenceMixin(Base) {
2
+ return class extends Base {
3
+ // ==================== Code Intelligence ====================
4
+ async detectIntent(args) {
5
+ const payload = {
6
+ user_request: (args.user_request ?? "").trim().slice(0, 4000),
7
+ current_file: args.current_file ?? null,
8
+ user_id: args.user_id ?? null,
9
+ project_id: args.project_id ?? null,
10
+ tags: args.tags ?? [],
11
+ similar_limit: args.similar_limit ?? 5,
12
+ };
13
+ return await this.post("/client/code_intelligence/detect-intent", payload);
14
+ }
15
+ async getIntentHistory(limit = 50, project_id) {
16
+ const params = { limit: Math.max(1, Math.min(limit, 200)) };
17
+ if (project_id)
18
+ params.project_id = project_id;
19
+ return await this.get("/client/code_intelligence/intent-history", params);
20
+ }
21
+ async predictCorrection(input_text, user_id, context = {}) {
22
+ const body = { input_text, user_id, context };
23
+ return await this.post("/client/code_intelligence/predict", body);
24
+ }
25
+ async correctCode(code, language, project_profile) {
26
+ const body = { code, language, project_profile: project_profile ?? {} };
27
+ return await this.post("/client/code_intelligence/correct/code", body);
28
+ }
29
+ async correctTests(test_code, test_framework, language) {
30
+ const body = { test_code, test_framework, language };
31
+ return await this.post("/client/code_intelligence/correct/tests", body);
32
+ }
33
+ async correctConfig(config, config_type) {
34
+ const body = { config, config_type };
35
+ return await this.post("/client/code_intelligence/correct/config", body);
36
+ }
37
+ async correctDocumentation(markdown, doc_type = "README") {
38
+ const body = { markdown, doc_type };
39
+ return await this.post("/client/code_intelligence/correct/documentation", body);
40
+ }
41
+ async applyAutoCorrections(user_id, model_name, corrections) {
42
+ const body = { user_id, model_name, corrections };
43
+ return await this.post("/client/code_intelligence/auto-correct", body);
44
+ }
45
+ async getTrustScore(user_id, model_name) {
46
+ const data = await this.get("/client/code_intelligence/trust-score", { user_id, model_name });
47
+ return typeof data?.trust_score === "number" ? data.trust_score : 0;
48
+ }
49
+ async submitFeedback(prediction_id, accepted) {
50
+ await this.post("/client/code_intelligence/feedback", { prediction_id, accepted: !!accepted });
51
+ }
52
+ async getAutoCorrectStats(user_id) {
53
+ return await this.get("/client/code_intelligence/stats", { user_id });
54
+ }
55
+ async getPatterns(user_id) {
56
+ const params = user_id ? { user_id } : undefined;
57
+ const data = await this.get("/client/code_intelligence/patterns", params);
58
+ return Array.isArray(data) ? data : [];
59
+ }
60
+ // ==================== LLM & Gateways ====================
61
+ async gatewayChat(args) {
62
+ const body = {
63
+ provider: args.provider ?? "gradient",
64
+ model: args.model ?? undefined,
65
+ messages: (args.messages ?? []).map(m => ({ role: m.role, content: String(m.content).slice(0, 4000) })),
66
+ call_provider: !!(args.call_provider ?? true),
67
+ user_id: args.user_id ?? undefined,
68
+ };
69
+ return await this.post("/recursor/llm/gateway/chat", body);
70
+ }
71
+ async chatProxy(request) {
72
+ return await this.post("/client/proxy/chat", request);
73
+ }
74
+ async getLLMGatewayPolicy() {
75
+ return await this.get("/recursor/llm/gateway/policy");
76
+ }
77
+ async getRoboticsGatewayPolicy() {
78
+ return await this.get("/recursor/robotics/gateway/policy");
79
+ }
80
+ async getAvGatewayPolicy() {
81
+ return await this.get("/recursor/av/gateway/policy");
82
+ }
83
+ // ==================== Corrections ====================
84
+ async listCorrections(args) {
85
+ return await this.get("/client/corrections", args);
86
+ }
87
+ async searchCorrections(query, limit = 5) {
88
+ return await this.get("/client/corrections/search", { query, limit });
89
+ }
90
+ async createCorrection(data) {
91
+ return await this.post("/client/corrections", data);
92
+ }
93
+ };
94
+ }
@@ -0,0 +1,25 @@
1
+ import { RecursorBase, Constructor } from "../base.js";
2
+ export declare function WebSocketMixin<TBase extends Constructor<RecursorBase>>(Base: TBase): {
3
+ new (...args: any[]): {
4
+ createWebSocket(): Promise<import("../websocket.js").RecursorWebSocket>;
5
+ connectWebSocket(): Promise<import("../websocket.js").RecursorWebSocket>;
6
+ disconnectWebSocket(): void;
7
+ close(): void;
8
+ baseUrl: string;
9
+ apiKey?: string;
10
+ accessToken?: string;
11
+ timeoutMs: number;
12
+ wsClient?: any;
13
+ localIndex: Record<string, any>;
14
+ offlineQueue: any[];
15
+ setAccessToken(token: string): void;
16
+ setApiKey(key: string): void;
17
+ headers(): import("../types.js").HeadersInit;
18
+ get<T>(path: string, params?: Record<string, unknown>): Promise<T>;
19
+ post<T>(path: string, body?: unknown, method?: string): Promise<T>;
20
+ put<T>(path: string, body?: unknown): Promise<T>;
21
+ patch<T>(path: string, body?: unknown): Promise<T>;
22
+ delete<T>(path: string): Promise<T>;
23
+ checkHealth(): Promise<boolean>;
24
+ };
25
+ } & TBase;
@@ -0,0 +1,28 @@
1
+ export function WebSocketMixin(Base) {
2
+ return class extends Base {
3
+ async createWebSocket() {
4
+ if (!this.accessToken)
5
+ throw new Error("Access token required");
6
+ if (!this.wsClient) {
7
+ // Dynamic import to avoid circular dependency issues if websocket.ts imports RecursorSDK
8
+ const { RecursorWebSocket } = await import("../websocket.js");
9
+ this.wsClient = new RecursorWebSocket(this.baseUrl, this.accessToken);
10
+ }
11
+ return this.wsClient;
12
+ }
13
+ async connectWebSocket() {
14
+ const ws = await this.createWebSocket();
15
+ await ws.connect();
16
+ return ws;
17
+ }
18
+ disconnectWebSocket() {
19
+ if (this.wsClient) {
20
+ this.wsClient.disconnect();
21
+ this.wsClient = undefined;
22
+ }
23
+ }
24
+ close() {
25
+ this.disconnectWebSocket();
26
+ }
27
+ };
28
+ }
@@ -0,0 +1,26 @@
1
+ import { RecursorBase, Constructor } from "../base.js";
2
+ import { WorkflowCreate, WorkflowResponse, WorkflowExecutionResponse } from "../types.js";
3
+ export declare function WorkflowMixin<TBase extends Constructor<RecursorBase>>(Base: TBase): {
4
+ new (...args: any[]): {
5
+ createWorkflow(data: WorkflowCreate): Promise<WorkflowResponse>;
6
+ listWorkflows(): Promise<WorkflowResponse[]>;
7
+ executeWorkflow(workflowId: string, inputData: Record<string, any>): Promise<WorkflowExecutionResponse>;
8
+ getExecutionStatus(executionId: string): Promise<WorkflowExecutionResponse>;
9
+ baseUrl: string;
10
+ apiKey?: string;
11
+ accessToken?: string;
12
+ timeoutMs: number;
13
+ wsClient?: any;
14
+ localIndex: Record<string, any>;
15
+ offlineQueue: any[];
16
+ setAccessToken(token: string): void;
17
+ setApiKey(key: string): void;
18
+ headers(): import("../types.js").HeadersInit;
19
+ get<T>(path: string, params?: Record<string, unknown>): Promise<T>;
20
+ post<T>(path: string, body?: unknown, method?: string): Promise<T>;
21
+ put<T>(path: string, body?: unknown): Promise<T>;
22
+ patch<T>(path: string, body?: unknown): Promise<T>;
23
+ delete<T>(path: string): Promise<T>;
24
+ checkHealth(): Promise<boolean>;
25
+ };
26
+ } & TBase;
@@ -0,0 +1,16 @@
1
+ export function WorkflowMixin(Base) {
2
+ return class extends Base {
3
+ async createWorkflow(data) {
4
+ return await this.post("/client/workflows/", data);
5
+ }
6
+ async listWorkflows() {
7
+ return await this.get("/client/workflows/");
8
+ }
9
+ async executeWorkflow(workflowId, inputData) {
10
+ return await this.post(`/client/workflows/${workflowId}/execute`, inputData);
11
+ }
12
+ async getExecutionStatus(executionId) {
13
+ return await this.get(`/client/workflows/executions/${executionId}`);
14
+ }
15
+ };
16
+ }
@@ -0,0 +1,204 @@
1
+ export type HeadersInit = Record<string, string>;
2
+ export interface IntentResponse {
3
+ action: string;
4
+ scope: string[];
5
+ constraints: Record<string, unknown>;
6
+ quality: string;
7
+ preserve_existing: boolean;
8
+ similar_past_requests: string[];
9
+ }
10
+ export interface ChatMessage {
11
+ role: string;
12
+ content: string;
13
+ }
14
+ export interface ChatGatewayResponse {
15
+ policy: Record<string, unknown>;
16
+ normalized_messages: ChatMessage[];
17
+ provider_response?: Record<string, unknown>;
18
+ }
19
+ export interface RoboticsGatewayResponse {
20
+ policy: Record<string, unknown>;
21
+ result: Record<string, unknown>;
22
+ }
23
+ export interface AVGatewayResponse {
24
+ policy: Record<string, unknown>;
25
+ result: Record<string, unknown>;
26
+ }
27
+ export interface IntentHistoryItem {
28
+ id: string;
29
+ text: string;
30
+ created_at: string;
31
+ project_id?: string | null;
32
+ tags?: string[];
33
+ }
34
+ export interface CorrectionResponseList {
35
+ corrections: unknown[];
36
+ total: number;
37
+ page: number;
38
+ page_size: number;
39
+ }
40
+ export interface UserRegister {
41
+ email: string;
42
+ password: string;
43
+ full_name?: string;
44
+ username: string;
45
+ }
46
+ export interface UserLogin {
47
+ email: string;
48
+ password: string;
49
+ }
50
+ export interface TokenResponse {
51
+ access_token: string;
52
+ refresh_token?: string;
53
+ token_type: string;
54
+ expires_in: number;
55
+ }
56
+ export interface UserProfile {
57
+ id: string;
58
+ email: string;
59
+ username: string;
60
+ full_name?: string;
61
+ role: string;
62
+ is_active: boolean;
63
+ is_verified: boolean;
64
+ created_at: string;
65
+ last_login?: string;
66
+ }
67
+ export interface UserResponse {
68
+ id: string;
69
+ email: string;
70
+ username: string;
71
+ full_name?: string;
72
+ created_at: string;
73
+ }
74
+ export interface UserUpdate {
75
+ full_name?: string;
76
+ username?: string;
77
+ }
78
+ export interface PasswordChange {
79
+ current_password: string;
80
+ new_password: string;
81
+ }
82
+ export interface APIKeyResponse {
83
+ api_key: string;
84
+ created_at: string;
85
+ }
86
+ export interface ProjectCreate {
87
+ name: string;
88
+ description?: string;
89
+ settings?: Record<string, unknown>;
90
+ }
91
+ export interface ProjectUpdate {
92
+ name?: string;
93
+ description?: string;
94
+ settings?: Record<string, unknown>;
95
+ is_active?: boolean;
96
+ }
97
+ export interface ProjectResponse {
98
+ id: string;
99
+ name: string;
100
+ description?: string;
101
+ created_by?: string;
102
+ api_key?: string;
103
+ is_active: boolean;
104
+ created_at: string;
105
+ updated_at: string;
106
+ settings?: Record<string, unknown>;
107
+ }
108
+ export interface UsageStatsResponse {
109
+ api_calls: {
110
+ used: number;
111
+ limit: number;
112
+ percentage: number;
113
+ };
114
+ corrections: {
115
+ used: number;
116
+ limit: number;
117
+ percentage: number;
118
+ };
119
+ storage_gb: {
120
+ used: number;
121
+ limit: number;
122
+ percentage: number;
123
+ };
124
+ llm_tokens: {
125
+ used: number;
126
+ limit: number;
127
+ percentage: number;
128
+ };
129
+ cost: {
130
+ current_period: number;
131
+ estimated_monthly: number;
132
+ };
133
+ subscription: {
134
+ plan_name: string;
135
+ status: string;
136
+ billing_period: string;
137
+ };
138
+ }
139
+ export interface BillingPlanResponse {
140
+ id: string;
141
+ name: string;
142
+ slug: string;
143
+ description: string;
144
+ price_monthly: number;
145
+ price_yearly: number;
146
+ features: string[];
147
+ }
148
+ export interface NotificationResponse {
149
+ id: string;
150
+ type: string;
151
+ title: string;
152
+ message: string;
153
+ is_read: boolean;
154
+ created_at: string;
155
+ }
156
+ export interface CodebaseIndexResponse {
157
+ files: number;
158
+ size: number;
159
+ last_updated: string;
160
+ }
161
+ export interface WorkflowCreate {
162
+ name: string;
163
+ steps: unknown[];
164
+ }
165
+ export interface WorkflowResponse {
166
+ id: string;
167
+ name: string;
168
+ created_at: string;
169
+ updated_at: string;
170
+ steps: unknown[];
171
+ }
172
+ export interface WorkflowExecutionResponse {
173
+ id: string;
174
+ status: string;
175
+ results?: Record<string, any>;
176
+ steps?: any[];
177
+ }
178
+ export interface AuditLog {
179
+ id: string;
180
+ action: string;
181
+ timestamp: string;
182
+ details: Record<string, any>;
183
+ }
184
+ export interface AuditLogResponse {
185
+ logs: AuditLog[];
186
+ user_id: string;
187
+ limit: number;
188
+ offset: number;
189
+ }
190
+ export interface ChatProxyRequest {
191
+ model: string;
192
+ messages: ChatMessage[];
193
+ temperature?: number;
194
+ max_tokens?: number;
195
+ stream?: boolean;
196
+ }
197
+ export interface ChatProxyResponse {
198
+ id: string;
199
+ object: string;
200
+ created: number;
201
+ model: string;
202
+ choices: any[];
203
+ usage: Record<string, number>;
204
+ }
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@recursorsdk/sdk",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Recursor SDK for Node.js",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -23,6 +23,9 @@
23
23
  "prepare": "npm run build",
24
24
  "prepublishOnly": "npm run clean && npm run build"
25
25
  },
26
+ "bin": {
27
+ "recursor-sdk": "./dist/cli.js"
28
+ },
26
29
  "engines": {
27
30
  "node": ">=18"
28
31
  },