@ricsam/r5d-api 0.0.6 → 0.0.8
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 +8 -8
- package/dist/cjs/index.cjs +65 -32
- package/dist/cjs/package.json +1 -1
- package/dist/mjs/index.mjs +63 -30
- package/dist/mjs/package.json +1 -1
- package/dist/types/index.d.ts +116 -44
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -11,12 +11,12 @@ npm install @ricsam/r5d-api
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
13
|
```ts
|
|
14
|
-
import {
|
|
14
|
+
import { R5dctlClient } from "@ricsam/r5d-api";
|
|
15
15
|
|
|
16
|
-
const client = new
|
|
16
|
+
const client = new R5dctlClient({
|
|
17
17
|
baseUrl: "https://r5d.dev",
|
|
18
|
-
token: process.env.
|
|
19
|
-
// or apiKey: process.env.
|
|
18
|
+
token: process.env.R5DCTL_TOKEN,
|
|
19
|
+
// or apiKey: process.env.R5DCTL_API_KEY
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
const projects = await client.projects.list();
|
|
@@ -25,9 +25,9 @@ console.log(projects);
|
|
|
25
25
|
|
|
26
26
|
## Auth
|
|
27
27
|
|
|
28
|
-
`
|
|
29
|
-
- interactive token (`
|
|
30
|
-
- API key (`
|
|
28
|
+
`R5dctlClient` supports:
|
|
29
|
+
- interactive token (`r5dctl_tok_*`)
|
|
30
|
+
- API key (`r5dctl_key_*`)
|
|
31
31
|
|
|
32
32
|
Set either `token` or `apiKey` in client options, or later via:
|
|
33
33
|
- `client.setToken(...)`
|
|
@@ -60,7 +60,7 @@ Trusted server-side callers that authenticate through custom headers, such as a
|
|
|
60
60
|
|
|
61
61
|
## Errors
|
|
62
62
|
|
|
63
|
-
Non-2xx responses throw `
|
|
63
|
+
Non-2xx responses throw `R5dctlApiError` with:
|
|
64
64
|
- `status`
|
|
65
65
|
- `path`
|
|
66
66
|
- `body`
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -18,17 +18,17 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var index_exports = {};
|
|
20
20
|
__export(index_exports, {
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
R5dctlApiError: () => R5dctlApiError,
|
|
22
|
+
R5dctlClient: () => R5dctlClient
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(index_exports);
|
|
25
|
-
class
|
|
25
|
+
class R5dctlApiError extends Error {
|
|
26
26
|
status;
|
|
27
27
|
path;
|
|
28
28
|
body;
|
|
29
29
|
constructor(message, input) {
|
|
30
30
|
super(message);
|
|
31
|
-
this.name = "
|
|
31
|
+
this.name = "R5dctlApiError";
|
|
32
32
|
this.status = input.status;
|
|
33
33
|
this.path = input.path;
|
|
34
34
|
this.body = input.body;
|
|
@@ -49,7 +49,7 @@ function withQuery(path, query) {
|
|
|
49
49
|
const queryString = params.toString();
|
|
50
50
|
return queryString.length > 0 ? `${path}?${queryString}` : path;
|
|
51
51
|
}
|
|
52
|
-
class
|
|
52
|
+
class R5dctlClient {
|
|
53
53
|
fetchImpl;
|
|
54
54
|
baseUrl;
|
|
55
55
|
token;
|
|
@@ -86,7 +86,7 @@ class BinctlClient {
|
|
|
86
86
|
if (authMode === "auto") {
|
|
87
87
|
if (!bearerToken) {
|
|
88
88
|
if (this.authMode !== "headers") {
|
|
89
|
-
throw new
|
|
89
|
+
throw new R5dctlApiError("Authentication required. Set token or apiKey in R5dctlClient.", {
|
|
90
90
|
status: 401,
|
|
91
91
|
path: input.path,
|
|
92
92
|
body: { error: "Missing credentials" }
|
|
@@ -110,7 +110,7 @@ class BinctlClient {
|
|
|
110
110
|
const payload = text.length > 0 ? safeJsonParse(text) : null;
|
|
111
111
|
if (!response.ok) {
|
|
112
112
|
const message = typeof payload === "object" && payload && "error" in payload && typeof payload.error === "string" ? payload.error : `Request failed (${response.status})`;
|
|
113
|
-
throw new
|
|
113
|
+
throw new R5dctlApiError(message, {
|
|
114
114
|
status: response.status,
|
|
115
115
|
path: pathWithQuery,
|
|
116
116
|
body: payload
|
|
@@ -121,7 +121,7 @@ class BinctlClient {
|
|
|
121
121
|
auth = {
|
|
122
122
|
loginStart: (input) => this.request({
|
|
123
123
|
method: "POST",
|
|
124
|
-
path: "/api/
|
|
124
|
+
path: "/api/r5dctl/auth/login/start",
|
|
125
125
|
auth: "none",
|
|
126
126
|
body: {
|
|
127
127
|
baseUrl: input?.baseUrl
|
|
@@ -129,7 +129,7 @@ class BinctlClient {
|
|
|
129
129
|
}),
|
|
130
130
|
loginPoll: (requestId, input) => this.request({
|
|
131
131
|
method: "GET",
|
|
132
|
-
path: `/api/
|
|
132
|
+
path: `/api/r5dctl/auth/login/poll/${encodeURIComponent(requestId)}`,
|
|
133
133
|
auth: "none",
|
|
134
134
|
query: {
|
|
135
135
|
pollCode: input.pollCode
|
|
@@ -137,103 +137,136 @@ class BinctlClient {
|
|
|
137
137
|
}),
|
|
138
138
|
logout: () => this.request({
|
|
139
139
|
method: "POST",
|
|
140
|
-
path: "/api/
|
|
140
|
+
path: "/api/r5dctl/auth/logout",
|
|
141
141
|
body: {}
|
|
142
142
|
}),
|
|
143
143
|
status: () => this.request({
|
|
144
144
|
method: "GET",
|
|
145
|
-
path: "/api/
|
|
145
|
+
path: "/api/r5dctl/auth/status"
|
|
146
146
|
}),
|
|
147
147
|
apiKeys: {
|
|
148
148
|
create: (input) => this.request({
|
|
149
149
|
method: "POST",
|
|
150
|
-
path: "/api/
|
|
150
|
+
path: "/api/r5dctl/auth/api-keys",
|
|
151
151
|
body: input
|
|
152
152
|
}),
|
|
153
153
|
list: () => this.request({
|
|
154
154
|
method: "GET",
|
|
155
|
-
path: "/api/
|
|
155
|
+
path: "/api/r5dctl/auth/api-keys"
|
|
156
156
|
}),
|
|
157
157
|
revoke: (keyId) => this.request({
|
|
158
158
|
method: "DELETE",
|
|
159
|
-
path: `/api/
|
|
159
|
+
path: `/api/r5dctl/auth/api-keys/${encodeURIComponent(keyId)}`
|
|
160
160
|
})
|
|
161
161
|
}
|
|
162
162
|
};
|
|
163
163
|
projects = {
|
|
164
164
|
list: () => this.request({
|
|
165
165
|
method: "GET",
|
|
166
|
-
path: "/api/
|
|
166
|
+
path: "/api/r5dctl/projects"
|
|
167
167
|
}),
|
|
168
168
|
describe: (projectRef) => this.request({
|
|
169
169
|
method: "GET",
|
|
170
|
-
path: `/api/
|
|
170
|
+
path: `/api/r5dctl/projects/${encodeURIComponent(projectRef)}`
|
|
171
171
|
}),
|
|
172
172
|
update: (projectRef, input) => this.request({
|
|
173
173
|
method: "PUT",
|
|
174
|
-
path: `/api/
|
|
174
|
+
path: `/api/r5dctl/projects/${encodeURIComponent(projectRef)}`,
|
|
175
175
|
body: input
|
|
176
176
|
}),
|
|
177
177
|
delete: (projectRef) => this.request({
|
|
178
178
|
method: "DELETE",
|
|
179
|
-
path: `/api/
|
|
179
|
+
path: `/api/r5dctl/projects/${encodeURIComponent(projectRef)}`
|
|
180
180
|
}),
|
|
181
181
|
branches: {
|
|
182
182
|
list: (projectRef) => this.request({
|
|
183
183
|
method: "GET",
|
|
184
|
-
path: `/api/
|
|
184
|
+
path: `/api/r5dctl/projects/${encodeURIComponent(projectRef)}/branches`
|
|
185
185
|
}),
|
|
186
186
|
describe: (projectRef, branch) => this.request({
|
|
187
187
|
method: "GET",
|
|
188
|
-
path: `/api/
|
|
188
|
+
path: `/api/r5dctl/projects/${encodeURIComponent(projectRef)}/branches/${encodeURIComponent(branch)}`
|
|
189
189
|
})
|
|
190
190
|
},
|
|
191
191
|
sessions: {
|
|
192
192
|
list: (projectRef, input) => this.request({
|
|
193
193
|
method: "GET",
|
|
194
|
-
path: `/api/
|
|
194
|
+
path: `/api/r5dctl/projects/${encodeURIComponent(projectRef)}/sessions`,
|
|
195
195
|
query: {
|
|
196
196
|
branch: input?.branch
|
|
197
197
|
}
|
|
198
198
|
}),
|
|
199
199
|
create: (projectRef, input) => this.request({
|
|
200
200
|
method: "POST",
|
|
201
|
-
path: `/api/
|
|
201
|
+
path: `/api/r5dctl/projects/${encodeURIComponent(projectRef)}/sessions`,
|
|
202
202
|
body: input
|
|
203
203
|
})
|
|
204
|
-
}
|
|
204
|
+
},
|
|
205
|
+
agents: {
|
|
206
|
+
start: (projectRef, input) => this.request({
|
|
207
|
+
method: "POST",
|
|
208
|
+
path: `/api/r5dctl/projects/${encodeURIComponent(projectRef)}/agents`,
|
|
209
|
+
body: input
|
|
210
|
+
})
|
|
211
|
+
},
|
|
212
|
+
mergeChanges: (projectRef, input) => this.request({
|
|
213
|
+
method: "POST",
|
|
214
|
+
path: `/api/r5dctl/projects/${encodeURIComponent(projectRef)}/merge-changes`,
|
|
215
|
+
body: input
|
|
216
|
+
}),
|
|
217
|
+
continueMerge: (projectRef, input) => this.request({
|
|
218
|
+
method: "POST",
|
|
219
|
+
path: `/api/r5dctl/projects/${encodeURIComponent(projectRef)}/continue-merge`,
|
|
220
|
+
body: input
|
|
221
|
+
}),
|
|
222
|
+
abortMerge: (projectRef, input) => this.request({
|
|
223
|
+
method: "POST",
|
|
224
|
+
path: `/api/r5dctl/projects/${encodeURIComponent(projectRef)}/abort-merge`,
|
|
225
|
+
body: input
|
|
226
|
+
})
|
|
227
|
+
};
|
|
228
|
+
agents = {
|
|
229
|
+
status: (sessionId) => this.request({
|
|
230
|
+
method: "GET",
|
|
231
|
+
path: `/api/r5dctl/agents/${encodeURIComponent(sessionId)}`
|
|
232
|
+
}),
|
|
233
|
+
sendPrompt: (sessionId, input) => this.request({
|
|
234
|
+
method: "POST",
|
|
235
|
+
path: `/api/r5dctl/agents/${encodeURIComponent(sessionId)}/prompt`,
|
|
236
|
+
body: input
|
|
237
|
+
})
|
|
205
238
|
};
|
|
206
239
|
sessions = {
|
|
207
240
|
describe: (sessionId) => this.request({
|
|
208
241
|
method: "GET",
|
|
209
|
-
path: `/api/
|
|
242
|
+
path: `/api/r5dctl/sessions/${encodeURIComponent(sessionId)}`
|
|
210
243
|
}),
|
|
211
244
|
update: (sessionId, input) => this.request({
|
|
212
245
|
method: "PUT",
|
|
213
|
-
path: `/api/
|
|
246
|
+
path: `/api/r5dctl/sessions/${encodeURIComponent(sessionId)}`,
|
|
214
247
|
body: input
|
|
215
248
|
}),
|
|
216
249
|
delete: (sessionId) => this.request({
|
|
217
250
|
method: "DELETE",
|
|
218
|
-
path: `/api/
|
|
251
|
+
path: `/api/r5dctl/sessions/${encodeURIComponent(sessionId)}`
|
|
219
252
|
}),
|
|
220
253
|
conversation: (sessionId) => this.request({
|
|
221
254
|
method: "GET",
|
|
222
|
-
path: `/api/
|
|
255
|
+
path: `/api/r5dctl/sessions/${encodeURIComponent(sessionId)}/conversation`
|
|
223
256
|
}),
|
|
224
257
|
prompt: (sessionId, input) => this.request({
|
|
225
258
|
method: "POST",
|
|
226
|
-
path: `/api/
|
|
259
|
+
path: `/api/r5dctl/sessions/${encodeURIComponent(sessionId)}/prompt`,
|
|
227
260
|
body: input
|
|
228
261
|
}),
|
|
229
262
|
answerQuestions: (sessionId, input) => this.request({
|
|
230
263
|
method: "POST",
|
|
231
|
-
path: `/api/
|
|
264
|
+
path: `/api/r5dctl/sessions/${encodeURIComponent(sessionId)}/answer-questions`,
|
|
232
265
|
body: input
|
|
233
266
|
}),
|
|
234
267
|
applyRequiredEnvs: (sessionId, input) => this.request({
|
|
235
268
|
method: "POST",
|
|
236
|
-
path: `/api/
|
|
269
|
+
path: `/api/r5dctl/sessions/${encodeURIComponent(sessionId)}/apply-required-envs`,
|
|
237
270
|
body: input
|
|
238
271
|
})
|
|
239
272
|
};
|
|
@@ -247,6 +280,6 @@ function safeJsonParse(text) {
|
|
|
247
280
|
}
|
|
248
281
|
// Annotate the CommonJS export names for ESM import in node:
|
|
249
282
|
0 && (module.exports = {
|
|
250
|
-
|
|
251
|
-
|
|
283
|
+
R5dctlApiError,
|
|
284
|
+
R5dctlClient
|
|
252
285
|
});
|
package/dist/cjs/package.json
CHANGED
package/dist/mjs/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
class
|
|
1
|
+
class R5dctlApiError extends Error {
|
|
2
2
|
status;
|
|
3
3
|
path;
|
|
4
4
|
body;
|
|
5
5
|
constructor(message, input) {
|
|
6
6
|
super(message);
|
|
7
|
-
this.name = "
|
|
7
|
+
this.name = "R5dctlApiError";
|
|
8
8
|
this.status = input.status;
|
|
9
9
|
this.path = input.path;
|
|
10
10
|
this.body = input.body;
|
|
@@ -25,7 +25,7 @@ function withQuery(path, query) {
|
|
|
25
25
|
const queryString = params.toString();
|
|
26
26
|
return queryString.length > 0 ? `${path}?${queryString}` : path;
|
|
27
27
|
}
|
|
28
|
-
class
|
|
28
|
+
class R5dctlClient {
|
|
29
29
|
fetchImpl;
|
|
30
30
|
baseUrl;
|
|
31
31
|
token;
|
|
@@ -62,7 +62,7 @@ class BinctlClient {
|
|
|
62
62
|
if (authMode === "auto") {
|
|
63
63
|
if (!bearerToken) {
|
|
64
64
|
if (this.authMode !== "headers") {
|
|
65
|
-
throw new
|
|
65
|
+
throw new R5dctlApiError("Authentication required. Set token or apiKey in R5dctlClient.", {
|
|
66
66
|
status: 401,
|
|
67
67
|
path: input.path,
|
|
68
68
|
body: { error: "Missing credentials" }
|
|
@@ -86,7 +86,7 @@ class BinctlClient {
|
|
|
86
86
|
const payload = text.length > 0 ? safeJsonParse(text) : null;
|
|
87
87
|
if (!response.ok) {
|
|
88
88
|
const message = typeof payload === "object" && payload && "error" in payload && typeof payload.error === "string" ? payload.error : `Request failed (${response.status})`;
|
|
89
|
-
throw new
|
|
89
|
+
throw new R5dctlApiError(message, {
|
|
90
90
|
status: response.status,
|
|
91
91
|
path: pathWithQuery,
|
|
92
92
|
body: payload
|
|
@@ -97,7 +97,7 @@ class BinctlClient {
|
|
|
97
97
|
auth = {
|
|
98
98
|
loginStart: (input) => this.request({
|
|
99
99
|
method: "POST",
|
|
100
|
-
path: "/api/
|
|
100
|
+
path: "/api/r5dctl/auth/login/start",
|
|
101
101
|
auth: "none",
|
|
102
102
|
body: {
|
|
103
103
|
baseUrl: input?.baseUrl
|
|
@@ -105,7 +105,7 @@ class BinctlClient {
|
|
|
105
105
|
}),
|
|
106
106
|
loginPoll: (requestId, input) => this.request({
|
|
107
107
|
method: "GET",
|
|
108
|
-
path: `/api/
|
|
108
|
+
path: `/api/r5dctl/auth/login/poll/${encodeURIComponent(requestId)}`,
|
|
109
109
|
auth: "none",
|
|
110
110
|
query: {
|
|
111
111
|
pollCode: input.pollCode
|
|
@@ -113,103 +113,136 @@ class BinctlClient {
|
|
|
113
113
|
}),
|
|
114
114
|
logout: () => this.request({
|
|
115
115
|
method: "POST",
|
|
116
|
-
path: "/api/
|
|
116
|
+
path: "/api/r5dctl/auth/logout",
|
|
117
117
|
body: {}
|
|
118
118
|
}),
|
|
119
119
|
status: () => this.request({
|
|
120
120
|
method: "GET",
|
|
121
|
-
path: "/api/
|
|
121
|
+
path: "/api/r5dctl/auth/status"
|
|
122
122
|
}),
|
|
123
123
|
apiKeys: {
|
|
124
124
|
create: (input) => this.request({
|
|
125
125
|
method: "POST",
|
|
126
|
-
path: "/api/
|
|
126
|
+
path: "/api/r5dctl/auth/api-keys",
|
|
127
127
|
body: input
|
|
128
128
|
}),
|
|
129
129
|
list: () => this.request({
|
|
130
130
|
method: "GET",
|
|
131
|
-
path: "/api/
|
|
131
|
+
path: "/api/r5dctl/auth/api-keys"
|
|
132
132
|
}),
|
|
133
133
|
revoke: (keyId) => this.request({
|
|
134
134
|
method: "DELETE",
|
|
135
|
-
path: `/api/
|
|
135
|
+
path: `/api/r5dctl/auth/api-keys/${encodeURIComponent(keyId)}`
|
|
136
136
|
})
|
|
137
137
|
}
|
|
138
138
|
};
|
|
139
139
|
projects = {
|
|
140
140
|
list: () => this.request({
|
|
141
141
|
method: "GET",
|
|
142
|
-
path: "/api/
|
|
142
|
+
path: "/api/r5dctl/projects"
|
|
143
143
|
}),
|
|
144
144
|
describe: (projectRef) => this.request({
|
|
145
145
|
method: "GET",
|
|
146
|
-
path: `/api/
|
|
146
|
+
path: `/api/r5dctl/projects/${encodeURIComponent(projectRef)}`
|
|
147
147
|
}),
|
|
148
148
|
update: (projectRef, input) => this.request({
|
|
149
149
|
method: "PUT",
|
|
150
|
-
path: `/api/
|
|
150
|
+
path: `/api/r5dctl/projects/${encodeURIComponent(projectRef)}`,
|
|
151
151
|
body: input
|
|
152
152
|
}),
|
|
153
153
|
delete: (projectRef) => this.request({
|
|
154
154
|
method: "DELETE",
|
|
155
|
-
path: `/api/
|
|
155
|
+
path: `/api/r5dctl/projects/${encodeURIComponent(projectRef)}`
|
|
156
156
|
}),
|
|
157
157
|
branches: {
|
|
158
158
|
list: (projectRef) => this.request({
|
|
159
159
|
method: "GET",
|
|
160
|
-
path: `/api/
|
|
160
|
+
path: `/api/r5dctl/projects/${encodeURIComponent(projectRef)}/branches`
|
|
161
161
|
}),
|
|
162
162
|
describe: (projectRef, branch) => this.request({
|
|
163
163
|
method: "GET",
|
|
164
|
-
path: `/api/
|
|
164
|
+
path: `/api/r5dctl/projects/${encodeURIComponent(projectRef)}/branches/${encodeURIComponent(branch)}`
|
|
165
165
|
})
|
|
166
166
|
},
|
|
167
167
|
sessions: {
|
|
168
168
|
list: (projectRef, input) => this.request({
|
|
169
169
|
method: "GET",
|
|
170
|
-
path: `/api/
|
|
170
|
+
path: `/api/r5dctl/projects/${encodeURIComponent(projectRef)}/sessions`,
|
|
171
171
|
query: {
|
|
172
172
|
branch: input?.branch
|
|
173
173
|
}
|
|
174
174
|
}),
|
|
175
175
|
create: (projectRef, input) => this.request({
|
|
176
176
|
method: "POST",
|
|
177
|
-
path: `/api/
|
|
177
|
+
path: `/api/r5dctl/projects/${encodeURIComponent(projectRef)}/sessions`,
|
|
178
178
|
body: input
|
|
179
179
|
})
|
|
180
|
-
}
|
|
180
|
+
},
|
|
181
|
+
agents: {
|
|
182
|
+
start: (projectRef, input) => this.request({
|
|
183
|
+
method: "POST",
|
|
184
|
+
path: `/api/r5dctl/projects/${encodeURIComponent(projectRef)}/agents`,
|
|
185
|
+
body: input
|
|
186
|
+
})
|
|
187
|
+
},
|
|
188
|
+
mergeChanges: (projectRef, input) => this.request({
|
|
189
|
+
method: "POST",
|
|
190
|
+
path: `/api/r5dctl/projects/${encodeURIComponent(projectRef)}/merge-changes`,
|
|
191
|
+
body: input
|
|
192
|
+
}),
|
|
193
|
+
continueMerge: (projectRef, input) => this.request({
|
|
194
|
+
method: "POST",
|
|
195
|
+
path: `/api/r5dctl/projects/${encodeURIComponent(projectRef)}/continue-merge`,
|
|
196
|
+
body: input
|
|
197
|
+
}),
|
|
198
|
+
abortMerge: (projectRef, input) => this.request({
|
|
199
|
+
method: "POST",
|
|
200
|
+
path: `/api/r5dctl/projects/${encodeURIComponent(projectRef)}/abort-merge`,
|
|
201
|
+
body: input
|
|
202
|
+
})
|
|
203
|
+
};
|
|
204
|
+
agents = {
|
|
205
|
+
status: (sessionId) => this.request({
|
|
206
|
+
method: "GET",
|
|
207
|
+
path: `/api/r5dctl/agents/${encodeURIComponent(sessionId)}`
|
|
208
|
+
}),
|
|
209
|
+
sendPrompt: (sessionId, input) => this.request({
|
|
210
|
+
method: "POST",
|
|
211
|
+
path: `/api/r5dctl/agents/${encodeURIComponent(sessionId)}/prompt`,
|
|
212
|
+
body: input
|
|
213
|
+
})
|
|
181
214
|
};
|
|
182
215
|
sessions = {
|
|
183
216
|
describe: (sessionId) => this.request({
|
|
184
217
|
method: "GET",
|
|
185
|
-
path: `/api/
|
|
218
|
+
path: `/api/r5dctl/sessions/${encodeURIComponent(sessionId)}`
|
|
186
219
|
}),
|
|
187
220
|
update: (sessionId, input) => this.request({
|
|
188
221
|
method: "PUT",
|
|
189
|
-
path: `/api/
|
|
222
|
+
path: `/api/r5dctl/sessions/${encodeURIComponent(sessionId)}`,
|
|
190
223
|
body: input
|
|
191
224
|
}),
|
|
192
225
|
delete: (sessionId) => this.request({
|
|
193
226
|
method: "DELETE",
|
|
194
|
-
path: `/api/
|
|
227
|
+
path: `/api/r5dctl/sessions/${encodeURIComponent(sessionId)}`
|
|
195
228
|
}),
|
|
196
229
|
conversation: (sessionId) => this.request({
|
|
197
230
|
method: "GET",
|
|
198
|
-
path: `/api/
|
|
231
|
+
path: `/api/r5dctl/sessions/${encodeURIComponent(sessionId)}/conversation`
|
|
199
232
|
}),
|
|
200
233
|
prompt: (sessionId, input) => this.request({
|
|
201
234
|
method: "POST",
|
|
202
|
-
path: `/api/
|
|
235
|
+
path: `/api/r5dctl/sessions/${encodeURIComponent(sessionId)}/prompt`,
|
|
203
236
|
body: input
|
|
204
237
|
}),
|
|
205
238
|
answerQuestions: (sessionId, input) => this.request({
|
|
206
239
|
method: "POST",
|
|
207
|
-
path: `/api/
|
|
240
|
+
path: `/api/r5dctl/sessions/${encodeURIComponent(sessionId)}/answer-questions`,
|
|
208
241
|
body: input
|
|
209
242
|
}),
|
|
210
243
|
applyRequiredEnvs: (sessionId, input) => this.request({
|
|
211
244
|
method: "POST",
|
|
212
|
-
path: `/api/
|
|
245
|
+
path: `/api/r5dctl/sessions/${encodeURIComponent(sessionId)}/apply-required-envs`,
|
|
213
246
|
body: input
|
|
214
247
|
})
|
|
215
248
|
};
|
|
@@ -222,6 +255,6 @@ function safeJsonParse(text) {
|
|
|
222
255
|
}
|
|
223
256
|
}
|
|
224
257
|
export {
|
|
225
|
-
|
|
226
|
-
|
|
258
|
+
R5dctlApiError,
|
|
259
|
+
R5dctlClient
|
|
227
260
|
};
|
package/dist/mjs/package.json
CHANGED
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export type ChatMode = "ask" | "plan" | "build" | "agent" | "explore" | "review" | "test" | "research";
|
|
1
|
+
export type ChatMode = "ask" | "plan" | "build" | "agent" | "explore" | "review" | "test" | "research" | "security_review" | "large_diff_remediation";
|
|
2
2
|
export type ModelTier = "low" | "medium" | "high" | "max";
|
|
3
|
-
export type
|
|
3
|
+
export type R5dctlAgentType = "research" | "debug" | "test";
|
|
4
|
+
export type R5dctlProject = {
|
|
4
5
|
id: string;
|
|
5
6
|
namespace: string;
|
|
6
7
|
name: string;
|
|
@@ -9,22 +10,22 @@ export type BinctlProject = {
|
|
|
9
10
|
createdAt: string;
|
|
10
11
|
updatedAt: string;
|
|
11
12
|
};
|
|
12
|
-
export type
|
|
13
|
+
export type R5dctlProjectDescription = R5dctlProject & {
|
|
13
14
|
orgId: string | null;
|
|
14
15
|
};
|
|
15
|
-
export type
|
|
16
|
+
export type R5dctlBranch = {
|
|
16
17
|
branchName: string;
|
|
17
18
|
sessionCount: number;
|
|
18
19
|
lastSessionAt: string | null;
|
|
19
20
|
};
|
|
20
|
-
export type
|
|
21
|
+
export type R5dctlSessionSummary = {
|
|
21
22
|
id: string;
|
|
22
23
|
name: string | null;
|
|
23
24
|
branchName: string;
|
|
24
25
|
createdAt: string;
|
|
25
26
|
updatedAt: string;
|
|
26
27
|
};
|
|
27
|
-
export type
|
|
28
|
+
export type R5dctlSessionDescription = {
|
|
28
29
|
id: string;
|
|
29
30
|
projectId: string;
|
|
30
31
|
projectPath: string;
|
|
@@ -36,39 +37,87 @@ export type BinctlSessionDescription = {
|
|
|
36
37
|
createdAt: string;
|
|
37
38
|
updatedAt: string;
|
|
38
39
|
};
|
|
39
|
-
export type
|
|
40
|
+
export type R5dctlPendingQuestionOption = {
|
|
40
41
|
id: string;
|
|
41
42
|
label: string;
|
|
42
43
|
description?: string;
|
|
43
44
|
};
|
|
44
|
-
export type
|
|
45
|
+
export type R5dctlPendingQuestion = {
|
|
45
46
|
id: string;
|
|
46
47
|
question: string;
|
|
47
48
|
allowMultiple?: boolean;
|
|
48
|
-
options:
|
|
49
|
+
options: R5dctlPendingQuestionOption[];
|
|
49
50
|
};
|
|
50
|
-
export type
|
|
51
|
+
export type R5dctlRequiredEnv = {
|
|
51
52
|
target: "backend" | "frontend";
|
|
52
53
|
name: string;
|
|
53
54
|
optional: boolean;
|
|
54
55
|
generateScript?: string;
|
|
55
56
|
description: string;
|
|
56
57
|
};
|
|
57
|
-
export type
|
|
58
|
-
session:
|
|
58
|
+
export type R5dctlConversationResponse = {
|
|
59
|
+
session: R5dctlSessionDescription;
|
|
59
60
|
conversation: unknown;
|
|
60
61
|
thread: unknown[];
|
|
61
|
-
pendingQuestions:
|
|
62
|
-
requiredEnvs:
|
|
62
|
+
pendingQuestions: R5dctlPendingQuestion[];
|
|
63
|
+
requiredEnvs: R5dctlRequiredEnv[];
|
|
63
64
|
};
|
|
64
|
-
export type
|
|
65
|
+
export type R5dctlAgentStartResponse = {
|
|
66
|
+
sessionId: string;
|
|
67
|
+
branchName: string;
|
|
68
|
+
baseBranch: string;
|
|
69
|
+
baseCommit: string;
|
|
70
|
+
status: "running";
|
|
71
|
+
};
|
|
72
|
+
export type R5dctlAgentStatusResponse = {
|
|
73
|
+
sessionId: string;
|
|
74
|
+
branchName: string;
|
|
75
|
+
baseBranch: string | null;
|
|
76
|
+
baseCommit: string | null;
|
|
77
|
+
status: "running" | "completed" | "failed";
|
|
78
|
+
startedAt: string;
|
|
79
|
+
updatedAt: string;
|
|
80
|
+
completedAt?: string;
|
|
81
|
+
failedAt?: string;
|
|
82
|
+
error?: string;
|
|
83
|
+
headCommit: string;
|
|
84
|
+
summary: string;
|
|
85
|
+
diffSummary: string;
|
|
86
|
+
};
|
|
87
|
+
export type R5dctlMergeResult = {
|
|
88
|
+
type: "merge_branch";
|
|
89
|
+
status: "merged";
|
|
90
|
+
sourceBranch: string;
|
|
91
|
+
targetBranch: string;
|
|
92
|
+
commitHash: string;
|
|
93
|
+
message: string;
|
|
94
|
+
} | {
|
|
95
|
+
type: "merge_branch";
|
|
96
|
+
status: "conflicts";
|
|
97
|
+
sourceBranch: string;
|
|
98
|
+
targetBranch: string;
|
|
99
|
+
conflictedFiles: string[];
|
|
100
|
+
message: string;
|
|
101
|
+
};
|
|
102
|
+
export type R5dctlContinueMergeResult = {
|
|
103
|
+
type: "continue_merge";
|
|
104
|
+
status: "committed";
|
|
105
|
+
commitHash: string;
|
|
106
|
+
message: string;
|
|
107
|
+
};
|
|
108
|
+
export type R5dctlAbortMergeResult = {
|
|
109
|
+
type: "abort_merge";
|
|
110
|
+
status: "aborted";
|
|
111
|
+
message: string;
|
|
112
|
+
};
|
|
113
|
+
export type R5dctlLoginStartResponse = {
|
|
65
114
|
requestId: string;
|
|
66
115
|
pollCode: string;
|
|
67
116
|
loginUrl: string;
|
|
68
117
|
expiresAt: string;
|
|
69
118
|
intervalMs: number;
|
|
70
119
|
};
|
|
71
|
-
export type
|
|
120
|
+
export type R5dctlLoginPollResponse = {
|
|
72
121
|
status: "pending";
|
|
73
122
|
expiresAt: string;
|
|
74
123
|
intervalMs: number;
|
|
@@ -79,32 +128,32 @@ export type BinctlLoginPollResponse = {
|
|
|
79
128
|
} | {
|
|
80
129
|
status: "expired" | "consumed";
|
|
81
130
|
};
|
|
82
|
-
export type
|
|
131
|
+
export type R5dctlAuthStatusResponse = {
|
|
83
132
|
authenticated: true;
|
|
84
|
-
source: "session" | "
|
|
133
|
+
source: "session" | "r5dctl";
|
|
85
134
|
user: {
|
|
86
135
|
id: string;
|
|
87
136
|
email: string;
|
|
88
137
|
name: string | null;
|
|
89
138
|
};
|
|
90
139
|
};
|
|
91
|
-
export type
|
|
140
|
+
export type R5dctlApiKey = {
|
|
92
141
|
id: string;
|
|
93
142
|
name: string;
|
|
94
143
|
createdAt: string;
|
|
95
144
|
lastUsedAt: string | null;
|
|
96
145
|
};
|
|
97
|
-
export type
|
|
146
|
+
export type R5dctlProjectUpdateInput = {
|
|
98
147
|
mode?: "greenfield" | "prod";
|
|
99
148
|
};
|
|
100
|
-
export type
|
|
149
|
+
export type R5dctlSessionCreateInput = {
|
|
101
150
|
name?: string;
|
|
102
151
|
branchName: string;
|
|
103
152
|
};
|
|
104
|
-
export type
|
|
153
|
+
export type R5dctlSessionUpdateInput = {
|
|
105
154
|
name: string | null;
|
|
106
155
|
};
|
|
107
|
-
export type
|
|
156
|
+
export type R5dctlClientOptions = {
|
|
108
157
|
baseUrl?: string;
|
|
109
158
|
token?: string;
|
|
110
159
|
apiKey?: string;
|
|
@@ -112,7 +161,7 @@ export type BinctlClientOptions = {
|
|
|
112
161
|
headers?: Record<string, string>;
|
|
113
162
|
authMode?: "bearer" | "headers";
|
|
114
163
|
};
|
|
115
|
-
export declare class
|
|
164
|
+
export declare class R5dctlApiError extends Error {
|
|
116
165
|
readonly status: number;
|
|
117
166
|
readonly path: string;
|
|
118
167
|
readonly body: unknown;
|
|
@@ -122,14 +171,14 @@ export declare class BinctlApiError extends Error {
|
|
|
122
171
|
body: unknown;
|
|
123
172
|
});
|
|
124
173
|
}
|
|
125
|
-
export declare class
|
|
174
|
+
export declare class R5dctlClient {
|
|
126
175
|
private readonly fetchImpl;
|
|
127
176
|
private baseUrl;
|
|
128
177
|
private token?;
|
|
129
178
|
private apiKey?;
|
|
130
179
|
private readonly extraHeaders;
|
|
131
180
|
private readonly authMode;
|
|
132
|
-
constructor(options?:
|
|
181
|
+
constructor(options?: R5dctlClientOptions);
|
|
133
182
|
setBaseUrl(baseUrl: string): void;
|
|
134
183
|
setToken(token?: string): void;
|
|
135
184
|
setApiKey(apiKey?: string): void;
|
|
@@ -138,15 +187,15 @@ export declare class BinctlClient {
|
|
|
138
187
|
readonly auth: {
|
|
139
188
|
loginStart: (input?: {
|
|
140
189
|
baseUrl?: string;
|
|
141
|
-
}) => Promise<
|
|
190
|
+
}) => Promise<R5dctlLoginStartResponse>;
|
|
142
191
|
loginPoll: (requestId: string, input: {
|
|
143
192
|
pollCode: string;
|
|
144
|
-
}) => Promise<
|
|
193
|
+
}) => Promise<R5dctlLoginPollResponse>;
|
|
145
194
|
logout: () => Promise<{
|
|
146
195
|
success: boolean;
|
|
147
196
|
revokedCredential: boolean;
|
|
148
197
|
}>;
|
|
149
|
-
status: () => Promise<
|
|
198
|
+
status: () => Promise<R5dctlAuthStatusResponse>;
|
|
150
199
|
apiKeys: {
|
|
151
200
|
create: (input: {
|
|
152
201
|
name: string;
|
|
@@ -156,51 +205,74 @@ export declare class BinctlClient {
|
|
|
156
205
|
name: string;
|
|
157
206
|
createdAt: string;
|
|
158
207
|
}>;
|
|
159
|
-
list: () => Promise<
|
|
208
|
+
list: () => Promise<R5dctlApiKey[]>;
|
|
160
209
|
revoke: (keyId: string) => Promise<{
|
|
161
210
|
success: boolean;
|
|
162
211
|
}>;
|
|
163
212
|
};
|
|
164
213
|
};
|
|
165
214
|
readonly projects: {
|
|
166
|
-
list: () => Promise<
|
|
167
|
-
describe: (projectRef: string) => Promise<
|
|
168
|
-
update: (projectRef: string, input:
|
|
215
|
+
list: () => Promise<R5dctlProject[]>;
|
|
216
|
+
describe: (projectRef: string) => Promise<R5dctlProjectDescription>;
|
|
217
|
+
update: (projectRef: string, input: R5dctlProjectUpdateInput) => Promise<R5dctlProjectDescription>;
|
|
169
218
|
delete: (projectRef: string) => Promise<{
|
|
170
219
|
success: boolean;
|
|
171
220
|
}>;
|
|
172
221
|
branches: {
|
|
173
|
-
list: (projectRef: string) => Promise<
|
|
222
|
+
list: (projectRef: string) => Promise<R5dctlBranch[]>;
|
|
174
223
|
describe: (projectRef: string, branch: string) => Promise<{
|
|
175
|
-
project:
|
|
224
|
+
project: R5dctlProject;
|
|
176
225
|
branchName: string;
|
|
177
|
-
sessions:
|
|
226
|
+
sessions: R5dctlSessionSummary[];
|
|
178
227
|
}>;
|
|
179
228
|
};
|
|
180
229
|
sessions: {
|
|
181
230
|
list: (projectRef: string, input?: {
|
|
182
231
|
branch?: string;
|
|
183
|
-
}) => Promise<
|
|
184
|
-
create: (projectRef: string, input:
|
|
232
|
+
}) => Promise<R5dctlSessionSummary[]>;
|
|
233
|
+
create: (projectRef: string, input: R5dctlSessionCreateInput) => Promise<R5dctlSessionDescription>;
|
|
185
234
|
};
|
|
235
|
+
agents: {
|
|
236
|
+
start: (projectRef: string, input: {
|
|
237
|
+
sourceBranch: string;
|
|
238
|
+
agentType: R5dctlAgentType;
|
|
239
|
+
prompt: string;
|
|
240
|
+
}) => Promise<R5dctlAgentStartResponse>;
|
|
241
|
+
};
|
|
242
|
+
mergeChanges: (projectRef: string, input: {
|
|
243
|
+
targetBranch: string;
|
|
244
|
+
sourceBranch: string;
|
|
245
|
+
}) => Promise<R5dctlMergeResult>;
|
|
246
|
+
continueMerge: (projectRef: string, input: {
|
|
247
|
+
targetBranch: string;
|
|
248
|
+
}) => Promise<R5dctlContinueMergeResult>;
|
|
249
|
+
abortMerge: (projectRef: string, input: {
|
|
250
|
+
targetBranch: string;
|
|
251
|
+
}) => Promise<R5dctlAbortMergeResult>;
|
|
252
|
+
};
|
|
253
|
+
readonly agents: {
|
|
254
|
+
status: (sessionId: string) => Promise<R5dctlAgentStatusResponse>;
|
|
255
|
+
sendPrompt: (sessionId: string, input: {
|
|
256
|
+
prompt: string;
|
|
257
|
+
}) => Promise<R5dctlAgentStatusResponse>;
|
|
186
258
|
};
|
|
187
259
|
readonly sessions: {
|
|
188
|
-
describe: (sessionId: string) => Promise<
|
|
189
|
-
update: (sessionId: string, input:
|
|
260
|
+
describe: (sessionId: string) => Promise<R5dctlSessionDescription>;
|
|
261
|
+
update: (sessionId: string, input: R5dctlSessionUpdateInput) => Promise<R5dctlSessionDescription>;
|
|
190
262
|
delete: (sessionId: string) => Promise<{
|
|
191
263
|
success: boolean;
|
|
192
264
|
}>;
|
|
193
|
-
conversation: (sessionId: string) => Promise<
|
|
265
|
+
conversation: (sessionId: string) => Promise<R5dctlConversationResponse>;
|
|
194
266
|
prompt: (sessionId: string, input: {
|
|
195
267
|
message: string;
|
|
196
268
|
mode: ChatMode;
|
|
197
269
|
model: ModelTier;
|
|
198
|
-
}) => Promise<
|
|
270
|
+
}) => Promise<R5dctlConversationResponse>;
|
|
199
271
|
answerQuestions: (sessionId: string, input: {
|
|
200
272
|
answers: string[];
|
|
201
|
-
}) => Promise<
|
|
273
|
+
}) => Promise<R5dctlConversationResponse>;
|
|
202
274
|
applyRequiredEnvs: (sessionId: string, input: {
|
|
203
275
|
envs: string[];
|
|
204
|
-
}) => Promise<
|
|
276
|
+
}) => Promise<R5dctlConversationResponse>;
|
|
205
277
|
};
|
|
206
278
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ricsam/r5d-api",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/cjs/index.cjs",
|
|
6
6
|
"module": "./dist/mjs/index.mjs",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"repository": {
|
|
16
16
|
"type": "git",
|
|
17
17
|
"url": "git+https://github.com/ricsam/r5d-dev.git",
|
|
18
|
-
"directory": "
|
|
18
|
+
"directory": "packages/r5d-api"
|
|
19
19
|
},
|
|
20
20
|
"files": [
|
|
21
21
|
"dist",
|