@ocxp/client 0.2.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/LICENSE +21 -0
- package/README.md +103 -0
- package/dist/index.cjs +4141 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +9268 -0
- package/dist/index.d.ts +9268 -0
- package/dist/index.js +3913 -0
- package/dist/index.js.map +1 -0
- package/package.json +74 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,4141 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var zod = require('zod');
|
|
4
|
+
|
|
5
|
+
// src/generated/core/bodySerializer.gen.ts
|
|
6
|
+
var serializeUrlSearchParamsPair = (data, key, value) => {
|
|
7
|
+
if (typeof value === "string") {
|
|
8
|
+
data.append(key, value);
|
|
9
|
+
} else {
|
|
10
|
+
data.append(key, JSON.stringify(value));
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
var jsonBodySerializer = {
|
|
14
|
+
bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value)
|
|
15
|
+
};
|
|
16
|
+
var urlSearchParamsBodySerializer = {
|
|
17
|
+
bodySerializer: (body) => {
|
|
18
|
+
const data = new URLSearchParams();
|
|
19
|
+
Object.entries(body).forEach(([key, value]) => {
|
|
20
|
+
if (value === void 0 || value === null) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (Array.isArray(value)) {
|
|
24
|
+
value.forEach((v) => serializeUrlSearchParamsPair(data, key, v));
|
|
25
|
+
} else {
|
|
26
|
+
serializeUrlSearchParamsPair(data, key, value);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
return data.toString();
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// src/generated/core/serverSentEvents.gen.ts
|
|
34
|
+
var createSseClient = ({
|
|
35
|
+
onRequest,
|
|
36
|
+
onSseError,
|
|
37
|
+
onSseEvent,
|
|
38
|
+
responseTransformer,
|
|
39
|
+
responseValidator,
|
|
40
|
+
sseDefaultRetryDelay,
|
|
41
|
+
sseMaxRetryAttempts,
|
|
42
|
+
sseMaxRetryDelay,
|
|
43
|
+
sseSleepFn,
|
|
44
|
+
url,
|
|
45
|
+
...options
|
|
46
|
+
}) => {
|
|
47
|
+
let lastEventId;
|
|
48
|
+
const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
49
|
+
const createStream = async function* () {
|
|
50
|
+
let retryDelay = sseDefaultRetryDelay ?? 3e3;
|
|
51
|
+
let attempt = 0;
|
|
52
|
+
const signal = options.signal ?? new AbortController().signal;
|
|
53
|
+
while (true) {
|
|
54
|
+
if (signal.aborted) break;
|
|
55
|
+
attempt++;
|
|
56
|
+
const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
|
|
57
|
+
if (lastEventId !== void 0) {
|
|
58
|
+
headers.set("Last-Event-ID", lastEventId);
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
const requestInit = {
|
|
62
|
+
redirect: "follow",
|
|
63
|
+
...options,
|
|
64
|
+
body: options.serializedBody,
|
|
65
|
+
headers,
|
|
66
|
+
signal
|
|
67
|
+
};
|
|
68
|
+
let request = new Request(url, requestInit);
|
|
69
|
+
if (onRequest) {
|
|
70
|
+
request = await onRequest(url, requestInit);
|
|
71
|
+
}
|
|
72
|
+
const _fetch = options.fetch ?? globalThis.fetch;
|
|
73
|
+
const response = await _fetch(request);
|
|
74
|
+
if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
|
|
75
|
+
if (!response.body) throw new Error("No body in SSE response");
|
|
76
|
+
const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
|
|
77
|
+
let buffer = "";
|
|
78
|
+
const abortHandler = () => {
|
|
79
|
+
try {
|
|
80
|
+
reader.cancel();
|
|
81
|
+
} catch {
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
signal.addEventListener("abort", abortHandler);
|
|
85
|
+
try {
|
|
86
|
+
while (true) {
|
|
87
|
+
const { done, value } = await reader.read();
|
|
88
|
+
if (done) break;
|
|
89
|
+
buffer += value;
|
|
90
|
+
buffer = buffer.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
|
91
|
+
const chunks = buffer.split("\n\n");
|
|
92
|
+
buffer = chunks.pop() ?? "";
|
|
93
|
+
for (const chunk of chunks) {
|
|
94
|
+
const lines = chunk.split("\n");
|
|
95
|
+
const dataLines = [];
|
|
96
|
+
let eventName;
|
|
97
|
+
for (const line of lines) {
|
|
98
|
+
if (line.startsWith("data:")) {
|
|
99
|
+
dataLines.push(line.replace(/^data:\s*/, ""));
|
|
100
|
+
} else if (line.startsWith("event:")) {
|
|
101
|
+
eventName = line.replace(/^event:\s*/, "");
|
|
102
|
+
} else if (line.startsWith("id:")) {
|
|
103
|
+
lastEventId = line.replace(/^id:\s*/, "");
|
|
104
|
+
} else if (line.startsWith("retry:")) {
|
|
105
|
+
const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
|
|
106
|
+
if (!Number.isNaN(parsed)) {
|
|
107
|
+
retryDelay = parsed;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
let data;
|
|
112
|
+
let parsedJson = false;
|
|
113
|
+
if (dataLines.length) {
|
|
114
|
+
const rawData = dataLines.join("\n");
|
|
115
|
+
try {
|
|
116
|
+
data = JSON.parse(rawData);
|
|
117
|
+
parsedJson = true;
|
|
118
|
+
} catch {
|
|
119
|
+
data = rawData;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (parsedJson) {
|
|
123
|
+
if (responseValidator) {
|
|
124
|
+
await responseValidator(data);
|
|
125
|
+
}
|
|
126
|
+
if (responseTransformer) {
|
|
127
|
+
data = await responseTransformer(data);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
onSseEvent?.({
|
|
131
|
+
data,
|
|
132
|
+
event: eventName,
|
|
133
|
+
id: lastEventId,
|
|
134
|
+
retry: retryDelay
|
|
135
|
+
});
|
|
136
|
+
if (dataLines.length) {
|
|
137
|
+
yield data;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
} finally {
|
|
142
|
+
signal.removeEventListener("abort", abortHandler);
|
|
143
|
+
reader.releaseLock();
|
|
144
|
+
}
|
|
145
|
+
break;
|
|
146
|
+
} catch (error) {
|
|
147
|
+
onSseError?.(error);
|
|
148
|
+
if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) {
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4);
|
|
152
|
+
await sleep(backoff);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
const stream = createStream();
|
|
157
|
+
return { stream };
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
// src/generated/core/pathSerializer.gen.ts
|
|
161
|
+
var separatorArrayExplode = (style) => {
|
|
162
|
+
switch (style) {
|
|
163
|
+
case "label":
|
|
164
|
+
return ".";
|
|
165
|
+
case "matrix":
|
|
166
|
+
return ";";
|
|
167
|
+
case "simple":
|
|
168
|
+
return ",";
|
|
169
|
+
default:
|
|
170
|
+
return "&";
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
var separatorArrayNoExplode = (style) => {
|
|
174
|
+
switch (style) {
|
|
175
|
+
case "form":
|
|
176
|
+
return ",";
|
|
177
|
+
case "pipeDelimited":
|
|
178
|
+
return "|";
|
|
179
|
+
case "spaceDelimited":
|
|
180
|
+
return "%20";
|
|
181
|
+
default:
|
|
182
|
+
return ",";
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
var separatorObjectExplode = (style) => {
|
|
186
|
+
switch (style) {
|
|
187
|
+
case "label":
|
|
188
|
+
return ".";
|
|
189
|
+
case "matrix":
|
|
190
|
+
return ";";
|
|
191
|
+
case "simple":
|
|
192
|
+
return ",";
|
|
193
|
+
default:
|
|
194
|
+
return "&";
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
var serializeArrayParam = ({
|
|
198
|
+
allowReserved,
|
|
199
|
+
explode,
|
|
200
|
+
name,
|
|
201
|
+
style,
|
|
202
|
+
value
|
|
203
|
+
}) => {
|
|
204
|
+
if (!explode) {
|
|
205
|
+
const joinedValues2 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
|
|
206
|
+
switch (style) {
|
|
207
|
+
case "label":
|
|
208
|
+
return `.${joinedValues2}`;
|
|
209
|
+
case "matrix":
|
|
210
|
+
return `;${name}=${joinedValues2}`;
|
|
211
|
+
case "simple":
|
|
212
|
+
return joinedValues2;
|
|
213
|
+
default:
|
|
214
|
+
return `${name}=${joinedValues2}`;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
const separator = separatorArrayExplode(style);
|
|
218
|
+
const joinedValues = value.map((v) => {
|
|
219
|
+
if (style === "label" || style === "simple") {
|
|
220
|
+
return allowReserved ? v : encodeURIComponent(v);
|
|
221
|
+
}
|
|
222
|
+
return serializePrimitiveParam({
|
|
223
|
+
allowReserved,
|
|
224
|
+
name,
|
|
225
|
+
value: v
|
|
226
|
+
});
|
|
227
|
+
}).join(separator);
|
|
228
|
+
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
229
|
+
};
|
|
230
|
+
var serializePrimitiveParam = ({
|
|
231
|
+
allowReserved,
|
|
232
|
+
name,
|
|
233
|
+
value
|
|
234
|
+
}) => {
|
|
235
|
+
if (value === void 0 || value === null) {
|
|
236
|
+
return "";
|
|
237
|
+
}
|
|
238
|
+
if (typeof value === "object") {
|
|
239
|
+
throw new Error(
|
|
240
|
+
"Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these."
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
|
|
244
|
+
};
|
|
245
|
+
var serializeObjectParam = ({
|
|
246
|
+
allowReserved,
|
|
247
|
+
explode,
|
|
248
|
+
name,
|
|
249
|
+
style,
|
|
250
|
+
value,
|
|
251
|
+
valueOnly
|
|
252
|
+
}) => {
|
|
253
|
+
if (value instanceof Date) {
|
|
254
|
+
return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
|
|
255
|
+
}
|
|
256
|
+
if (style !== "deepObject" && !explode) {
|
|
257
|
+
let values = [];
|
|
258
|
+
Object.entries(value).forEach(([key, v]) => {
|
|
259
|
+
values = [...values, key, allowReserved ? v : encodeURIComponent(v)];
|
|
260
|
+
});
|
|
261
|
+
const joinedValues2 = values.join(",");
|
|
262
|
+
switch (style) {
|
|
263
|
+
case "form":
|
|
264
|
+
return `${name}=${joinedValues2}`;
|
|
265
|
+
case "label":
|
|
266
|
+
return `.${joinedValues2}`;
|
|
267
|
+
case "matrix":
|
|
268
|
+
return `;${name}=${joinedValues2}`;
|
|
269
|
+
default:
|
|
270
|
+
return joinedValues2;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
const separator = separatorObjectExplode(style);
|
|
274
|
+
const joinedValues = Object.entries(value).map(
|
|
275
|
+
([key, v]) => serializePrimitiveParam({
|
|
276
|
+
allowReserved,
|
|
277
|
+
name: style === "deepObject" ? `${name}[${key}]` : key,
|
|
278
|
+
value: v
|
|
279
|
+
})
|
|
280
|
+
).join(separator);
|
|
281
|
+
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
// src/generated/core/utils.gen.ts
|
|
285
|
+
var PATH_PARAM_RE = /\{[^{}]+\}/g;
|
|
286
|
+
var defaultPathSerializer = ({ path, url: _url }) => {
|
|
287
|
+
let url = _url;
|
|
288
|
+
const matches = _url.match(PATH_PARAM_RE);
|
|
289
|
+
if (matches) {
|
|
290
|
+
for (const match of matches) {
|
|
291
|
+
let explode = false;
|
|
292
|
+
let name = match.substring(1, match.length - 1);
|
|
293
|
+
let style = "simple";
|
|
294
|
+
if (name.endsWith("*")) {
|
|
295
|
+
explode = true;
|
|
296
|
+
name = name.substring(0, name.length - 1);
|
|
297
|
+
}
|
|
298
|
+
if (name.startsWith(".")) {
|
|
299
|
+
name = name.substring(1);
|
|
300
|
+
style = "label";
|
|
301
|
+
} else if (name.startsWith(";")) {
|
|
302
|
+
name = name.substring(1);
|
|
303
|
+
style = "matrix";
|
|
304
|
+
}
|
|
305
|
+
const value = path[name];
|
|
306
|
+
if (value === void 0 || value === null) {
|
|
307
|
+
continue;
|
|
308
|
+
}
|
|
309
|
+
if (Array.isArray(value)) {
|
|
310
|
+
url = url.replace(match, serializeArrayParam({ explode, name, style, value }));
|
|
311
|
+
continue;
|
|
312
|
+
}
|
|
313
|
+
if (typeof value === "object") {
|
|
314
|
+
url = url.replace(
|
|
315
|
+
match,
|
|
316
|
+
serializeObjectParam({
|
|
317
|
+
explode,
|
|
318
|
+
name,
|
|
319
|
+
style,
|
|
320
|
+
value,
|
|
321
|
+
valueOnly: true
|
|
322
|
+
})
|
|
323
|
+
);
|
|
324
|
+
continue;
|
|
325
|
+
}
|
|
326
|
+
if (style === "matrix") {
|
|
327
|
+
url = url.replace(
|
|
328
|
+
match,
|
|
329
|
+
`;${serializePrimitiveParam({
|
|
330
|
+
name,
|
|
331
|
+
value
|
|
332
|
+
})}`
|
|
333
|
+
);
|
|
334
|
+
continue;
|
|
335
|
+
}
|
|
336
|
+
const replaceValue = encodeURIComponent(
|
|
337
|
+
style === "label" ? `.${value}` : value
|
|
338
|
+
);
|
|
339
|
+
url = url.replace(match, replaceValue);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
return url;
|
|
343
|
+
};
|
|
344
|
+
var getUrl = ({
|
|
345
|
+
baseUrl,
|
|
346
|
+
path,
|
|
347
|
+
query,
|
|
348
|
+
querySerializer,
|
|
349
|
+
url: _url
|
|
350
|
+
}) => {
|
|
351
|
+
const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
|
|
352
|
+
let url = (baseUrl ?? "") + pathUrl;
|
|
353
|
+
if (path) {
|
|
354
|
+
url = defaultPathSerializer({ path, url });
|
|
355
|
+
}
|
|
356
|
+
let search = query ? querySerializer(query) : "";
|
|
357
|
+
if (search.startsWith("?")) {
|
|
358
|
+
search = search.substring(1);
|
|
359
|
+
}
|
|
360
|
+
if (search) {
|
|
361
|
+
url += `?${search}`;
|
|
362
|
+
}
|
|
363
|
+
return url;
|
|
364
|
+
};
|
|
365
|
+
function getValidRequestBody(options) {
|
|
366
|
+
const hasBody = options.body !== void 0;
|
|
367
|
+
const isSerializedBody = hasBody && options.bodySerializer;
|
|
368
|
+
if (isSerializedBody) {
|
|
369
|
+
if ("serializedBody" in options) {
|
|
370
|
+
const hasSerializedBody = options.serializedBody !== void 0 && options.serializedBody !== "";
|
|
371
|
+
return hasSerializedBody ? options.serializedBody : null;
|
|
372
|
+
}
|
|
373
|
+
return options.body !== "" ? options.body : null;
|
|
374
|
+
}
|
|
375
|
+
if (hasBody) {
|
|
376
|
+
return options.body;
|
|
377
|
+
}
|
|
378
|
+
return void 0;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
// src/generated/core/auth.gen.ts
|
|
382
|
+
var getAuthToken = async (auth, callback) => {
|
|
383
|
+
const token = typeof callback === "function" ? await callback(auth) : callback;
|
|
384
|
+
if (!token) {
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
if (auth.scheme === "bearer") {
|
|
388
|
+
return `Bearer ${token}`;
|
|
389
|
+
}
|
|
390
|
+
if (auth.scheme === "basic") {
|
|
391
|
+
return `Basic ${btoa(token)}`;
|
|
392
|
+
}
|
|
393
|
+
return token;
|
|
394
|
+
};
|
|
395
|
+
|
|
396
|
+
// src/generated/client/utils.gen.ts
|
|
397
|
+
var createQuerySerializer = ({
|
|
398
|
+
parameters = {},
|
|
399
|
+
...args
|
|
400
|
+
} = {}) => {
|
|
401
|
+
const querySerializer = (queryParams) => {
|
|
402
|
+
const search = [];
|
|
403
|
+
if (queryParams && typeof queryParams === "object") {
|
|
404
|
+
for (const name in queryParams) {
|
|
405
|
+
const value = queryParams[name];
|
|
406
|
+
if (value === void 0 || value === null) {
|
|
407
|
+
continue;
|
|
408
|
+
}
|
|
409
|
+
const options = parameters[name] || args;
|
|
410
|
+
if (Array.isArray(value)) {
|
|
411
|
+
const serializedArray = serializeArrayParam({
|
|
412
|
+
allowReserved: options.allowReserved,
|
|
413
|
+
explode: true,
|
|
414
|
+
name,
|
|
415
|
+
style: "form",
|
|
416
|
+
value,
|
|
417
|
+
...options.array
|
|
418
|
+
});
|
|
419
|
+
if (serializedArray) search.push(serializedArray);
|
|
420
|
+
} else if (typeof value === "object") {
|
|
421
|
+
const serializedObject = serializeObjectParam({
|
|
422
|
+
allowReserved: options.allowReserved,
|
|
423
|
+
explode: true,
|
|
424
|
+
name,
|
|
425
|
+
style: "deepObject",
|
|
426
|
+
value,
|
|
427
|
+
...options.object
|
|
428
|
+
});
|
|
429
|
+
if (serializedObject) search.push(serializedObject);
|
|
430
|
+
} else {
|
|
431
|
+
const serializedPrimitive = serializePrimitiveParam({
|
|
432
|
+
allowReserved: options.allowReserved,
|
|
433
|
+
name,
|
|
434
|
+
value
|
|
435
|
+
});
|
|
436
|
+
if (serializedPrimitive) search.push(serializedPrimitive);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
return search.join("&");
|
|
441
|
+
};
|
|
442
|
+
return querySerializer;
|
|
443
|
+
};
|
|
444
|
+
var getParseAs = (contentType) => {
|
|
445
|
+
if (!contentType) {
|
|
446
|
+
return "stream";
|
|
447
|
+
}
|
|
448
|
+
const cleanContent = contentType.split(";")[0]?.trim();
|
|
449
|
+
if (!cleanContent) {
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
|
|
453
|
+
return "json";
|
|
454
|
+
}
|
|
455
|
+
if (cleanContent === "multipart/form-data") {
|
|
456
|
+
return "formData";
|
|
457
|
+
}
|
|
458
|
+
if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
|
|
459
|
+
return "blob";
|
|
460
|
+
}
|
|
461
|
+
if (cleanContent.startsWith("text/")) {
|
|
462
|
+
return "text";
|
|
463
|
+
}
|
|
464
|
+
return;
|
|
465
|
+
};
|
|
466
|
+
var checkForExistence = (options, name) => {
|
|
467
|
+
if (!name) {
|
|
468
|
+
return false;
|
|
469
|
+
}
|
|
470
|
+
if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
|
|
471
|
+
return true;
|
|
472
|
+
}
|
|
473
|
+
return false;
|
|
474
|
+
};
|
|
475
|
+
var setAuthParams = async ({
|
|
476
|
+
security,
|
|
477
|
+
...options
|
|
478
|
+
}) => {
|
|
479
|
+
for (const auth of security) {
|
|
480
|
+
if (checkForExistence(options, auth.name)) {
|
|
481
|
+
continue;
|
|
482
|
+
}
|
|
483
|
+
const token = await getAuthToken(auth, options.auth);
|
|
484
|
+
if (!token) {
|
|
485
|
+
continue;
|
|
486
|
+
}
|
|
487
|
+
const name = auth.name ?? "Authorization";
|
|
488
|
+
switch (auth.in) {
|
|
489
|
+
case "query":
|
|
490
|
+
if (!options.query) {
|
|
491
|
+
options.query = {};
|
|
492
|
+
}
|
|
493
|
+
options.query[name] = token;
|
|
494
|
+
break;
|
|
495
|
+
case "cookie":
|
|
496
|
+
options.headers.append("Cookie", `${name}=${token}`);
|
|
497
|
+
break;
|
|
498
|
+
case "header":
|
|
499
|
+
default:
|
|
500
|
+
options.headers.set(name, token);
|
|
501
|
+
break;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
};
|
|
505
|
+
var buildUrl = (options) => getUrl({
|
|
506
|
+
baseUrl: options.baseUrl,
|
|
507
|
+
path: options.path,
|
|
508
|
+
query: options.query,
|
|
509
|
+
querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer(options.querySerializer),
|
|
510
|
+
url: options.url
|
|
511
|
+
});
|
|
512
|
+
var mergeConfigs = (a, b) => {
|
|
513
|
+
const config = { ...a, ...b };
|
|
514
|
+
if (config.baseUrl?.endsWith("/")) {
|
|
515
|
+
config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
|
|
516
|
+
}
|
|
517
|
+
config.headers = mergeHeaders(a.headers, b.headers);
|
|
518
|
+
return config;
|
|
519
|
+
};
|
|
520
|
+
var headersEntries = (headers) => {
|
|
521
|
+
const entries = [];
|
|
522
|
+
headers.forEach((value, key) => {
|
|
523
|
+
entries.push([key, value]);
|
|
524
|
+
});
|
|
525
|
+
return entries;
|
|
526
|
+
};
|
|
527
|
+
var mergeHeaders = (...headers) => {
|
|
528
|
+
const mergedHeaders = new Headers();
|
|
529
|
+
for (const header of headers) {
|
|
530
|
+
if (!header) {
|
|
531
|
+
continue;
|
|
532
|
+
}
|
|
533
|
+
const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
|
|
534
|
+
for (const [key, value] of iterator) {
|
|
535
|
+
if (value === null) {
|
|
536
|
+
mergedHeaders.delete(key);
|
|
537
|
+
} else if (Array.isArray(value)) {
|
|
538
|
+
for (const v of value) {
|
|
539
|
+
mergedHeaders.append(key, v);
|
|
540
|
+
}
|
|
541
|
+
} else if (value !== void 0) {
|
|
542
|
+
mergedHeaders.set(
|
|
543
|
+
key,
|
|
544
|
+
typeof value === "object" ? JSON.stringify(value) : value
|
|
545
|
+
);
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
return mergedHeaders;
|
|
550
|
+
};
|
|
551
|
+
var Interceptors = class {
|
|
552
|
+
fns = [];
|
|
553
|
+
clear() {
|
|
554
|
+
this.fns = [];
|
|
555
|
+
}
|
|
556
|
+
eject(id) {
|
|
557
|
+
const index = this.getInterceptorIndex(id);
|
|
558
|
+
if (this.fns[index]) {
|
|
559
|
+
this.fns[index] = null;
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
exists(id) {
|
|
563
|
+
const index = this.getInterceptorIndex(id);
|
|
564
|
+
return Boolean(this.fns[index]);
|
|
565
|
+
}
|
|
566
|
+
getInterceptorIndex(id) {
|
|
567
|
+
if (typeof id === "number") {
|
|
568
|
+
return this.fns[id] ? id : -1;
|
|
569
|
+
}
|
|
570
|
+
return this.fns.indexOf(id);
|
|
571
|
+
}
|
|
572
|
+
update(id, fn) {
|
|
573
|
+
const index = this.getInterceptorIndex(id);
|
|
574
|
+
if (this.fns[index]) {
|
|
575
|
+
this.fns[index] = fn;
|
|
576
|
+
return id;
|
|
577
|
+
}
|
|
578
|
+
return false;
|
|
579
|
+
}
|
|
580
|
+
use(fn) {
|
|
581
|
+
this.fns.push(fn);
|
|
582
|
+
return this.fns.length - 1;
|
|
583
|
+
}
|
|
584
|
+
};
|
|
585
|
+
var createInterceptors = () => ({
|
|
586
|
+
error: new Interceptors(),
|
|
587
|
+
request: new Interceptors(),
|
|
588
|
+
response: new Interceptors()
|
|
589
|
+
});
|
|
590
|
+
var defaultQuerySerializer = createQuerySerializer({
|
|
591
|
+
allowReserved: false,
|
|
592
|
+
array: {
|
|
593
|
+
explode: true,
|
|
594
|
+
style: "form"
|
|
595
|
+
},
|
|
596
|
+
object: {
|
|
597
|
+
explode: true,
|
|
598
|
+
style: "deepObject"
|
|
599
|
+
}
|
|
600
|
+
});
|
|
601
|
+
var defaultHeaders = {
|
|
602
|
+
"Content-Type": "application/json"
|
|
603
|
+
};
|
|
604
|
+
var createConfig = (override = {}) => ({
|
|
605
|
+
...jsonBodySerializer,
|
|
606
|
+
headers: defaultHeaders,
|
|
607
|
+
parseAs: "auto",
|
|
608
|
+
querySerializer: defaultQuerySerializer,
|
|
609
|
+
...override
|
|
610
|
+
});
|
|
611
|
+
|
|
612
|
+
// src/generated/client/client.gen.ts
|
|
613
|
+
var createClient = (config = {}) => {
|
|
614
|
+
let _config = mergeConfigs(createConfig(), config);
|
|
615
|
+
const getConfig = () => ({ ..._config });
|
|
616
|
+
const setConfig = (config2) => {
|
|
617
|
+
_config = mergeConfigs(_config, config2);
|
|
618
|
+
return getConfig();
|
|
619
|
+
};
|
|
620
|
+
const interceptors = createInterceptors();
|
|
621
|
+
const beforeRequest = async (options) => {
|
|
622
|
+
const opts = {
|
|
623
|
+
..._config,
|
|
624
|
+
...options,
|
|
625
|
+
fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
|
|
626
|
+
headers: mergeHeaders(_config.headers, options.headers),
|
|
627
|
+
serializedBody: void 0
|
|
628
|
+
};
|
|
629
|
+
if (opts.security) {
|
|
630
|
+
await setAuthParams({
|
|
631
|
+
...opts,
|
|
632
|
+
security: opts.security
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
if (opts.requestValidator) {
|
|
636
|
+
await opts.requestValidator(opts);
|
|
637
|
+
}
|
|
638
|
+
if (opts.body !== void 0 && opts.bodySerializer) {
|
|
639
|
+
opts.serializedBody = opts.bodySerializer(opts.body);
|
|
640
|
+
}
|
|
641
|
+
if (opts.body === void 0 || opts.serializedBody === "") {
|
|
642
|
+
opts.headers.delete("Content-Type");
|
|
643
|
+
}
|
|
644
|
+
const url = buildUrl(opts);
|
|
645
|
+
return { opts, url };
|
|
646
|
+
};
|
|
647
|
+
const request = async (options) => {
|
|
648
|
+
const { opts, url } = await beforeRequest(options);
|
|
649
|
+
const requestInit = {
|
|
650
|
+
redirect: "follow",
|
|
651
|
+
...opts,
|
|
652
|
+
body: getValidRequestBody(opts)
|
|
653
|
+
};
|
|
654
|
+
let request2 = new Request(url, requestInit);
|
|
655
|
+
for (const fn of interceptors.request.fns) {
|
|
656
|
+
if (fn) {
|
|
657
|
+
request2 = await fn(request2, opts);
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
const _fetch = opts.fetch;
|
|
661
|
+
let response;
|
|
662
|
+
try {
|
|
663
|
+
response = await _fetch(request2);
|
|
664
|
+
} catch (error2) {
|
|
665
|
+
let finalError2 = error2;
|
|
666
|
+
for (const fn of interceptors.error.fns) {
|
|
667
|
+
if (fn) {
|
|
668
|
+
finalError2 = await fn(error2, void 0, request2, opts);
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
finalError2 = finalError2 || {};
|
|
672
|
+
if (opts.throwOnError) {
|
|
673
|
+
throw finalError2;
|
|
674
|
+
}
|
|
675
|
+
return opts.responseStyle === "data" ? void 0 : {
|
|
676
|
+
error: finalError2,
|
|
677
|
+
request: request2,
|
|
678
|
+
response: void 0
|
|
679
|
+
};
|
|
680
|
+
}
|
|
681
|
+
for (const fn of interceptors.response.fns) {
|
|
682
|
+
if (fn) {
|
|
683
|
+
response = await fn(response, request2, opts);
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
const result = {
|
|
687
|
+
request: request2,
|
|
688
|
+
response
|
|
689
|
+
};
|
|
690
|
+
if (response.ok) {
|
|
691
|
+
const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
|
|
692
|
+
if (response.status === 204 || response.headers.get("Content-Length") === "0") {
|
|
693
|
+
let emptyData;
|
|
694
|
+
switch (parseAs) {
|
|
695
|
+
case "arrayBuffer":
|
|
696
|
+
case "blob":
|
|
697
|
+
case "text":
|
|
698
|
+
emptyData = await response[parseAs]();
|
|
699
|
+
break;
|
|
700
|
+
case "formData":
|
|
701
|
+
emptyData = new FormData();
|
|
702
|
+
break;
|
|
703
|
+
case "stream":
|
|
704
|
+
emptyData = response.body;
|
|
705
|
+
break;
|
|
706
|
+
case "json":
|
|
707
|
+
default:
|
|
708
|
+
emptyData = {};
|
|
709
|
+
break;
|
|
710
|
+
}
|
|
711
|
+
return opts.responseStyle === "data" ? emptyData : {
|
|
712
|
+
data: emptyData,
|
|
713
|
+
...result
|
|
714
|
+
};
|
|
715
|
+
}
|
|
716
|
+
let data;
|
|
717
|
+
switch (parseAs) {
|
|
718
|
+
case "arrayBuffer":
|
|
719
|
+
case "blob":
|
|
720
|
+
case "formData":
|
|
721
|
+
case "json":
|
|
722
|
+
case "text":
|
|
723
|
+
data = await response[parseAs]();
|
|
724
|
+
break;
|
|
725
|
+
case "stream":
|
|
726
|
+
return opts.responseStyle === "data" ? response.body : {
|
|
727
|
+
data: response.body,
|
|
728
|
+
...result
|
|
729
|
+
};
|
|
730
|
+
}
|
|
731
|
+
if (parseAs === "json") {
|
|
732
|
+
if (opts.responseValidator) {
|
|
733
|
+
await opts.responseValidator(data);
|
|
734
|
+
}
|
|
735
|
+
if (opts.responseTransformer) {
|
|
736
|
+
data = await opts.responseTransformer(data);
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
return opts.responseStyle === "data" ? data : {
|
|
740
|
+
data,
|
|
741
|
+
...result
|
|
742
|
+
};
|
|
743
|
+
}
|
|
744
|
+
const textError = await response.text();
|
|
745
|
+
let jsonError;
|
|
746
|
+
try {
|
|
747
|
+
jsonError = JSON.parse(textError);
|
|
748
|
+
} catch {
|
|
749
|
+
}
|
|
750
|
+
const error = jsonError ?? textError;
|
|
751
|
+
let finalError = error;
|
|
752
|
+
for (const fn of interceptors.error.fns) {
|
|
753
|
+
if (fn) {
|
|
754
|
+
finalError = await fn(error, response, request2, opts);
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
finalError = finalError || {};
|
|
758
|
+
if (opts.throwOnError) {
|
|
759
|
+
throw finalError;
|
|
760
|
+
}
|
|
761
|
+
return opts.responseStyle === "data" ? void 0 : {
|
|
762
|
+
error: finalError,
|
|
763
|
+
...result
|
|
764
|
+
};
|
|
765
|
+
};
|
|
766
|
+
const makeMethodFn = (method) => (options) => request({ ...options, method });
|
|
767
|
+
const makeSseFn = (method) => async (options) => {
|
|
768
|
+
const { opts, url } = await beforeRequest(options);
|
|
769
|
+
return createSseClient({
|
|
770
|
+
...opts,
|
|
771
|
+
body: opts.body,
|
|
772
|
+
headers: opts.headers,
|
|
773
|
+
method,
|
|
774
|
+
onRequest: async (url2, init) => {
|
|
775
|
+
let request2 = new Request(url2, init);
|
|
776
|
+
for (const fn of interceptors.request.fns) {
|
|
777
|
+
if (fn) {
|
|
778
|
+
request2 = await fn(request2, opts);
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
return request2;
|
|
782
|
+
},
|
|
783
|
+
url
|
|
784
|
+
});
|
|
785
|
+
};
|
|
786
|
+
return {
|
|
787
|
+
buildUrl,
|
|
788
|
+
connect: makeMethodFn("CONNECT"),
|
|
789
|
+
delete: makeMethodFn("DELETE"),
|
|
790
|
+
get: makeMethodFn("GET"),
|
|
791
|
+
getConfig,
|
|
792
|
+
head: makeMethodFn("HEAD"),
|
|
793
|
+
interceptors,
|
|
794
|
+
options: makeMethodFn("OPTIONS"),
|
|
795
|
+
patch: makeMethodFn("PATCH"),
|
|
796
|
+
post: makeMethodFn("POST"),
|
|
797
|
+
put: makeMethodFn("PUT"),
|
|
798
|
+
request,
|
|
799
|
+
setConfig,
|
|
800
|
+
sse: {
|
|
801
|
+
connect: makeSseFn("CONNECT"),
|
|
802
|
+
delete: makeSseFn("DELETE"),
|
|
803
|
+
get: makeSseFn("GET"),
|
|
804
|
+
head: makeSseFn("HEAD"),
|
|
805
|
+
options: makeSseFn("OPTIONS"),
|
|
806
|
+
patch: makeSseFn("PATCH"),
|
|
807
|
+
post: makeSseFn("POST"),
|
|
808
|
+
put: makeSseFn("PUT"),
|
|
809
|
+
trace: makeSseFn("TRACE")
|
|
810
|
+
},
|
|
811
|
+
trace: makeMethodFn("TRACE")
|
|
812
|
+
};
|
|
813
|
+
};
|
|
814
|
+
|
|
815
|
+
// src/generated/client.gen.ts
|
|
816
|
+
var client = createClient(
|
|
817
|
+
createConfig({
|
|
818
|
+
baseUrl: "https://ix8b43sg3j.execute-api.us-west-2.amazonaws.com"
|
|
819
|
+
})
|
|
820
|
+
);
|
|
821
|
+
|
|
822
|
+
// src/generated/sdk.gen.ts
|
|
823
|
+
var bulkReadContent = (options) => (options.client ?? client).post({
|
|
824
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
825
|
+
url: "/ocxp/context/{content_type}/bulk/read",
|
|
826
|
+
...options,
|
|
827
|
+
headers: {
|
|
828
|
+
"Content-Type": "application/json",
|
|
829
|
+
...options.headers
|
|
830
|
+
}
|
|
831
|
+
});
|
|
832
|
+
var bulkWriteContent = (options) => (options.client ?? client).post({
|
|
833
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
834
|
+
url: "/ocxp/context/{content_type}/bulk/write",
|
|
835
|
+
...options,
|
|
836
|
+
headers: {
|
|
837
|
+
"Content-Type": "application/json",
|
|
838
|
+
...options.headers
|
|
839
|
+
}
|
|
840
|
+
});
|
|
841
|
+
var bulkDeleteContent = (options) => (options.client ?? client).post({
|
|
842
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
843
|
+
url: "/ocxp/context/{content_type}/bulk/delete",
|
|
844
|
+
...options,
|
|
845
|
+
headers: {
|
|
846
|
+
"Content-Type": "application/json",
|
|
847
|
+
...options.headers
|
|
848
|
+
}
|
|
849
|
+
});
|
|
850
|
+
var listSessions = (options) => (options?.client ?? client).get({
|
|
851
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
852
|
+
url: "/ocxp/session",
|
|
853
|
+
...options
|
|
854
|
+
});
|
|
855
|
+
var getSessionMessages = (options) => (options.client ?? client).get({
|
|
856
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
857
|
+
url: "/ocxp/session/{session_id}/messages",
|
|
858
|
+
...options
|
|
859
|
+
});
|
|
860
|
+
var updateSessionMetadata = (options) => (options.client ?? client).post({
|
|
861
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
862
|
+
url: "/ocxp/session/{session_id}/metadata",
|
|
863
|
+
...options,
|
|
864
|
+
headers: {
|
|
865
|
+
"Content-Type": "application/json",
|
|
866
|
+
...options.headers
|
|
867
|
+
}
|
|
868
|
+
});
|
|
869
|
+
var forkSession = (options) => (options.client ?? client).post({
|
|
870
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
871
|
+
url: "/ocxp/session/{session_id}/fork",
|
|
872
|
+
...options,
|
|
873
|
+
headers: {
|
|
874
|
+
"Content-Type": "application/json",
|
|
875
|
+
...options.headers
|
|
876
|
+
}
|
|
877
|
+
});
|
|
878
|
+
var archiveSession = (options) => (options.client ?? client).post({
|
|
879
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
880
|
+
url: "/ocxp/session/{session_id}/archive",
|
|
881
|
+
...options
|
|
882
|
+
});
|
|
883
|
+
var listProjects = (options) => (options?.client ?? client).get({
|
|
884
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
885
|
+
url: "/ocxp/project",
|
|
886
|
+
...options
|
|
887
|
+
});
|
|
888
|
+
var createProject = (options) => (options.client ?? client).post({
|
|
889
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
890
|
+
url: "/ocxp/project",
|
|
891
|
+
...options,
|
|
892
|
+
headers: {
|
|
893
|
+
"Content-Type": "application/json",
|
|
894
|
+
...options.headers
|
|
895
|
+
}
|
|
896
|
+
});
|
|
897
|
+
var deleteProject = (options) => (options.client ?? client).delete({
|
|
898
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
899
|
+
url: "/ocxp/project/{project_id}",
|
|
900
|
+
...options
|
|
901
|
+
});
|
|
902
|
+
var getProject = (options) => (options.client ?? client).get({
|
|
903
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
904
|
+
url: "/ocxp/project/{project_id}",
|
|
905
|
+
...options
|
|
906
|
+
});
|
|
907
|
+
var updateProject = (options) => (options.client ?? client).put({
|
|
908
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
909
|
+
url: "/ocxp/project/{project_id}",
|
|
910
|
+
...options,
|
|
911
|
+
headers: {
|
|
912
|
+
"Content-Type": "application/json",
|
|
913
|
+
...options.headers
|
|
914
|
+
}
|
|
915
|
+
});
|
|
916
|
+
var addLinkedRepo = (options) => (options.client ?? client).post({
|
|
917
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
918
|
+
url: "/ocxp/project/{project_id}/repos",
|
|
919
|
+
...options,
|
|
920
|
+
headers: {
|
|
921
|
+
"Content-Type": "application/json",
|
|
922
|
+
...options.headers
|
|
923
|
+
}
|
|
924
|
+
});
|
|
925
|
+
var removeLinkedRepo = (options) => (options.client ?? client).delete({
|
|
926
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
927
|
+
url: "/ocxp/project/{project_id}/repos/{repo_id}",
|
|
928
|
+
...options
|
|
929
|
+
});
|
|
930
|
+
var setDefaultRepo = (options) => (options.client ?? client).put({
|
|
931
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
932
|
+
url: "/ocxp/project/{project_id}/default-repo",
|
|
933
|
+
...options,
|
|
934
|
+
headers: {
|
|
935
|
+
"Content-Type": "application/json",
|
|
936
|
+
...options.headers
|
|
937
|
+
}
|
|
938
|
+
});
|
|
939
|
+
var getContextRepos = (options) => (options.client ?? client).get({
|
|
940
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
941
|
+
url: "/ocxp/project/{project_id}/context-repos",
|
|
942
|
+
...options
|
|
943
|
+
});
|
|
944
|
+
var addMission = (options) => (options.client ?? client).post({
|
|
945
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
946
|
+
url: "/ocxp/project/{project_id}/missions",
|
|
947
|
+
...options,
|
|
948
|
+
headers: {
|
|
949
|
+
"Content-Type": "application/json",
|
|
950
|
+
...options.headers
|
|
951
|
+
}
|
|
952
|
+
});
|
|
953
|
+
var removeMission = (options) => (options.client ?? client).delete({
|
|
954
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
955
|
+
url: "/ocxp/project/{project_id}/missions/{mission_id}",
|
|
956
|
+
...options
|
|
957
|
+
});
|
|
958
|
+
var getProjectDatabases = (options) => (options.client ?? client).get({
|
|
959
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
960
|
+
url: "/ocxp/project/{project_id}/databases",
|
|
961
|
+
...options
|
|
962
|
+
});
|
|
963
|
+
var addDatabase = (options) => (options.client ?? client).post({
|
|
964
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
965
|
+
url: "/ocxp/project/{project_id}/databases",
|
|
966
|
+
...options,
|
|
967
|
+
headers: {
|
|
968
|
+
"Content-Type": "application/json",
|
|
969
|
+
...options.headers
|
|
970
|
+
}
|
|
971
|
+
});
|
|
972
|
+
var removeDatabase = (options) => (options.client ?? client).delete({
|
|
973
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
974
|
+
url: "/ocxp/project/{project_id}/databases/{database_id}",
|
|
975
|
+
...options
|
|
976
|
+
});
|
|
977
|
+
var setDefaultDatabase = (options) => (options.client ?? client).put({
|
|
978
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
979
|
+
url: "/ocxp/project/{project_id}/default-database",
|
|
980
|
+
...options,
|
|
981
|
+
headers: {
|
|
982
|
+
"Content-Type": "application/json",
|
|
983
|
+
...options.headers
|
|
984
|
+
}
|
|
985
|
+
});
|
|
986
|
+
var listMissions = (options) => (options?.client ?? client).get({
|
|
987
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
988
|
+
url: "/ocxp/mission",
|
|
989
|
+
...options
|
|
990
|
+
});
|
|
991
|
+
var createMission = (options) => (options.client ?? client).post({
|
|
992
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
993
|
+
url: "/ocxp/mission",
|
|
994
|
+
...options,
|
|
995
|
+
headers: {
|
|
996
|
+
"Content-Type": "application/json",
|
|
997
|
+
...options.headers
|
|
998
|
+
}
|
|
999
|
+
});
|
|
1000
|
+
var deleteMission = (options) => (options.client ?? client).delete({
|
|
1001
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1002
|
+
url: "/ocxp/mission/{mission_id}",
|
|
1003
|
+
...options
|
|
1004
|
+
});
|
|
1005
|
+
var getMission = (options) => (options.client ?? client).get({
|
|
1006
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1007
|
+
url: "/ocxp/mission/{mission_id}",
|
|
1008
|
+
...options
|
|
1009
|
+
});
|
|
1010
|
+
var updateMission = (options) => (options.client ?? client).put({
|
|
1011
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1012
|
+
url: "/ocxp/mission/{mission_id}",
|
|
1013
|
+
...options,
|
|
1014
|
+
headers: {
|
|
1015
|
+
"Content-Type": "application/json",
|
|
1016
|
+
...options.headers
|
|
1017
|
+
}
|
|
1018
|
+
});
|
|
1019
|
+
var addSession = (options) => (options.client ?? client).post({
|
|
1020
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1021
|
+
url: "/ocxp/mission/{mission_id}/sessions",
|
|
1022
|
+
...options,
|
|
1023
|
+
headers: {
|
|
1024
|
+
"Content-Type": "application/json",
|
|
1025
|
+
...options.headers
|
|
1026
|
+
}
|
|
1027
|
+
});
|
|
1028
|
+
var removeSession = (options) => (options.client ?? client).delete({
|
|
1029
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1030
|
+
url: "/ocxp/mission/{mission_id}/sessions/{session_id}",
|
|
1031
|
+
...options
|
|
1032
|
+
});
|
|
1033
|
+
var regenerateMission = (options) => (options.client ?? client).post({
|
|
1034
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1035
|
+
url: "/ocxp/mission/{mission_id}/regenerate",
|
|
1036
|
+
...options,
|
|
1037
|
+
headers: {
|
|
1038
|
+
"Content-Type": "application/json",
|
|
1039
|
+
...options.headers
|
|
1040
|
+
}
|
|
1041
|
+
});
|
|
1042
|
+
var queryKnowledgeBase = (options) => (options.client ?? client).post({
|
|
1043
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1044
|
+
url: "/ocxp/kb/query",
|
|
1045
|
+
...options,
|
|
1046
|
+
headers: {
|
|
1047
|
+
"Content-Type": "application/json",
|
|
1048
|
+
...options.headers
|
|
1049
|
+
}
|
|
1050
|
+
});
|
|
1051
|
+
var ragKnowledgeBase = (options) => (options.client ?? client).post({
|
|
1052
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1053
|
+
url: "/ocxp/kb/rag",
|
|
1054
|
+
...options,
|
|
1055
|
+
headers: {
|
|
1056
|
+
"Content-Type": "application/json",
|
|
1057
|
+
...options.headers
|
|
1058
|
+
}
|
|
1059
|
+
});
|
|
1060
|
+
var listMemos = (options) => (options?.client ?? client).get({
|
|
1061
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1062
|
+
url: "/ocxp/memo",
|
|
1063
|
+
...options
|
|
1064
|
+
});
|
|
1065
|
+
var createMemo = (options) => (options.client ?? client).post({
|
|
1066
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1067
|
+
url: "/ocxp/memo",
|
|
1068
|
+
...options,
|
|
1069
|
+
headers: {
|
|
1070
|
+
"Content-Type": "application/json",
|
|
1071
|
+
...options.headers
|
|
1072
|
+
}
|
|
1073
|
+
});
|
|
1074
|
+
var deleteMemo = (options) => (options.client ?? client).delete({
|
|
1075
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1076
|
+
url: "/ocxp/memo/{memo_id}",
|
|
1077
|
+
...options
|
|
1078
|
+
});
|
|
1079
|
+
var getMemo = (options) => (options.client ?? client).get({
|
|
1080
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1081
|
+
url: "/ocxp/memo/{memo_id}",
|
|
1082
|
+
...options
|
|
1083
|
+
});
|
|
1084
|
+
var getMemoForSource = (options) => (options.client ?? client).get({
|
|
1085
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1086
|
+
url: "/ocxp/memo/source/{source_type}/{source_id}",
|
|
1087
|
+
...options
|
|
1088
|
+
});
|
|
1089
|
+
var resolveMemo = (options) => (options.client ?? client).post({
|
|
1090
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1091
|
+
url: "/ocxp/memo/{memo_id}/resolve",
|
|
1092
|
+
...options,
|
|
1093
|
+
headers: {
|
|
1094
|
+
"Content-Type": "application/json",
|
|
1095
|
+
...options.headers
|
|
1096
|
+
}
|
|
1097
|
+
});
|
|
1098
|
+
var acknowledgeMemo = (options) => (options.client ?? client).post({
|
|
1099
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1100
|
+
url: "/ocxp/memo/{memo_id}/acknowledge",
|
|
1101
|
+
...options
|
|
1102
|
+
});
|
|
1103
|
+
var ignoreMemo = (options) => (options.client ?? client).post({
|
|
1104
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1105
|
+
url: "/ocxp/memo/{memo_id}/ignore",
|
|
1106
|
+
...options
|
|
1107
|
+
});
|
|
1108
|
+
var downloadRepository = (options) => (options.client ?? client).post({
|
|
1109
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1110
|
+
url: "/ocxp/repo/download",
|
|
1111
|
+
...options,
|
|
1112
|
+
headers: {
|
|
1113
|
+
"Content-Type": "application/json",
|
|
1114
|
+
...options.headers
|
|
1115
|
+
}
|
|
1116
|
+
});
|
|
1117
|
+
var getRepoDownloadStatus = (options) => (options.client ?? client).get({
|
|
1118
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1119
|
+
url: "/ocxp/repo/status/{job_id}",
|
|
1120
|
+
...options
|
|
1121
|
+
});
|
|
1122
|
+
var listDownloadedRepos = (options) => (options?.client ?? client).get({
|
|
1123
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1124
|
+
url: "/ocxp/repo/list",
|
|
1125
|
+
...options
|
|
1126
|
+
});
|
|
1127
|
+
var deleteRepo = (options) => (options.client ?? client).delete({
|
|
1128
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1129
|
+
url: "/ocxp/repo/{repo_id}",
|
|
1130
|
+
...options
|
|
1131
|
+
});
|
|
1132
|
+
var githubCheckAccess = (options) => (options.client ?? client).post({
|
|
1133
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1134
|
+
url: "/ocxp/github/check-access",
|
|
1135
|
+
...options,
|
|
1136
|
+
headers: {
|
|
1137
|
+
"Content-Type": "application/json",
|
|
1138
|
+
...options.headers
|
|
1139
|
+
}
|
|
1140
|
+
});
|
|
1141
|
+
var githubListBranches = (options) => (options.client ?? client).post({
|
|
1142
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1143
|
+
url: "/ocxp/github/branches",
|
|
1144
|
+
...options,
|
|
1145
|
+
headers: {
|
|
1146
|
+
"Content-Type": "application/json",
|
|
1147
|
+
...options.headers
|
|
1148
|
+
}
|
|
1149
|
+
});
|
|
1150
|
+
var githubGetContents = (options) => (options.client ?? client).post({
|
|
1151
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1152
|
+
url: "/ocxp/github/contents",
|
|
1153
|
+
...options,
|
|
1154
|
+
headers: {
|
|
1155
|
+
"Content-Type": "application/json",
|
|
1156
|
+
...options.headers
|
|
1157
|
+
}
|
|
1158
|
+
});
|
|
1159
|
+
var listDatabases = (options) => (options?.client ?? client).get({
|
|
1160
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1161
|
+
url: "/ocxp/database",
|
|
1162
|
+
...options
|
|
1163
|
+
});
|
|
1164
|
+
var createDatabase = (options) => (options.client ?? client).post({
|
|
1165
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1166
|
+
url: "/ocxp/database",
|
|
1167
|
+
...options,
|
|
1168
|
+
headers: {
|
|
1169
|
+
"Content-Type": "application/json",
|
|
1170
|
+
...options.headers
|
|
1171
|
+
}
|
|
1172
|
+
});
|
|
1173
|
+
var deleteDatabase = (options) => (options.client ?? client).delete({
|
|
1174
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1175
|
+
url: "/ocxp/database/{database_id}",
|
|
1176
|
+
...options
|
|
1177
|
+
});
|
|
1178
|
+
var getDatabase = (options) => (options.client ?? client).get({
|
|
1179
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1180
|
+
url: "/ocxp/database/{database_id}",
|
|
1181
|
+
...options
|
|
1182
|
+
});
|
|
1183
|
+
var updateDatabase = (options) => (options.client ?? client).put({
|
|
1184
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1185
|
+
url: "/ocxp/database/{database_id}",
|
|
1186
|
+
...options,
|
|
1187
|
+
headers: {
|
|
1188
|
+
"Content-Type": "application/json",
|
|
1189
|
+
...options.headers
|
|
1190
|
+
}
|
|
1191
|
+
});
|
|
1192
|
+
var testDatabaseConnection = (options) => (options.client ?? client).post({
|
|
1193
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1194
|
+
url: "/ocxp/database/{database_id}/test",
|
|
1195
|
+
...options
|
|
1196
|
+
});
|
|
1197
|
+
var getSchema = (options) => (options?.client ?? client).get({
|
|
1198
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1199
|
+
url: "/ocxp/context/database/schema",
|
|
1200
|
+
...options
|
|
1201
|
+
});
|
|
1202
|
+
var getSample = (options) => (options.client ?? client).get({
|
|
1203
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1204
|
+
url: "/ocxp/context/database/sample/{table_name}",
|
|
1205
|
+
...options
|
|
1206
|
+
});
|
|
1207
|
+
var listTables = (options) => (options?.client ?? client).get({
|
|
1208
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1209
|
+
url: "/ocxp/context/database/tables",
|
|
1210
|
+
...options
|
|
1211
|
+
});
|
|
1212
|
+
var listContextDatabases = (options) => (options?.client ?? client).get({
|
|
1213
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1214
|
+
url: "/ocxp/context/database/databases",
|
|
1215
|
+
...options
|
|
1216
|
+
});
|
|
1217
|
+
var getContentTypes = (options) => (options?.client ?? client).get({
|
|
1218
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1219
|
+
url: "/ocxp/context/types",
|
|
1220
|
+
...options
|
|
1221
|
+
});
|
|
1222
|
+
var listContent = (options) => (options.client ?? client).get({
|
|
1223
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1224
|
+
url: "/ocxp/context/{content_type}/list",
|
|
1225
|
+
...options
|
|
1226
|
+
});
|
|
1227
|
+
var queryContent = (options) => (options.client ?? client).post({
|
|
1228
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1229
|
+
url: "/ocxp/context/{content_type}/query",
|
|
1230
|
+
...options,
|
|
1231
|
+
headers: {
|
|
1232
|
+
"Content-Type": "application/json",
|
|
1233
|
+
...options.headers
|
|
1234
|
+
}
|
|
1235
|
+
});
|
|
1236
|
+
var searchContent = (options) => (options.client ?? client).get({
|
|
1237
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1238
|
+
url: "/ocxp/context/{content_type}/search",
|
|
1239
|
+
...options
|
|
1240
|
+
});
|
|
1241
|
+
var getContentTree = (options) => (options.client ?? client).get({
|
|
1242
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1243
|
+
url: "/ocxp/context/{content_type}/tree",
|
|
1244
|
+
...options
|
|
1245
|
+
});
|
|
1246
|
+
var getContentStats = (options) => (options.client ?? client).get({
|
|
1247
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1248
|
+
url: "/ocxp/context/{content_type}/stats",
|
|
1249
|
+
...options
|
|
1250
|
+
});
|
|
1251
|
+
var deleteContent = (options) => (options.client ?? client).delete({
|
|
1252
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1253
|
+
url: "/ocxp/context/{content_type}/{content_id}",
|
|
1254
|
+
...options
|
|
1255
|
+
});
|
|
1256
|
+
var readContent = (options) => (options.client ?? client).get({
|
|
1257
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1258
|
+
url: "/ocxp/context/{content_type}/{content_id}",
|
|
1259
|
+
...options
|
|
1260
|
+
});
|
|
1261
|
+
var writeContent = (options) => (options.client ?? client).post({
|
|
1262
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1263
|
+
url: "/ocxp/context/{content_type}/{content_id}",
|
|
1264
|
+
...options,
|
|
1265
|
+
headers: {
|
|
1266
|
+
"Content-Type": "application/json",
|
|
1267
|
+
...options.headers
|
|
1268
|
+
}
|
|
1269
|
+
});
|
|
1270
|
+
var moveContent = (options) => (options.client ?? client).post({
|
|
1271
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1272
|
+
url: "/ocxp/context/move",
|
|
1273
|
+
...options,
|
|
1274
|
+
headers: {
|
|
1275
|
+
"Content-Type": "application/json",
|
|
1276
|
+
...options.headers
|
|
1277
|
+
}
|
|
1278
|
+
});
|
|
1279
|
+
var lockContent = (options) => (options.client ?? client).post({
|
|
1280
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1281
|
+
url: "/ocxp/context/lock",
|
|
1282
|
+
...options,
|
|
1283
|
+
headers: {
|
|
1284
|
+
"Content-Type": "application/json",
|
|
1285
|
+
...options.headers
|
|
1286
|
+
}
|
|
1287
|
+
});
|
|
1288
|
+
var unlockContent = (options) => (options.client ?? client).post({
|
|
1289
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1290
|
+
url: "/ocxp/context/unlock",
|
|
1291
|
+
...options,
|
|
1292
|
+
headers: {
|
|
1293
|
+
"Content-Type": "application/json",
|
|
1294
|
+
...options.headers
|
|
1295
|
+
}
|
|
1296
|
+
});
|
|
1297
|
+
var toolCreateMission = (options) => (options.client ?? client).post({
|
|
1298
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1299
|
+
url: "/tools/mission/create",
|
|
1300
|
+
...options,
|
|
1301
|
+
headers: {
|
|
1302
|
+
"Content-Type": "application/json",
|
|
1303
|
+
...options.headers
|
|
1304
|
+
}
|
|
1305
|
+
});
|
|
1306
|
+
var toolUpdateMission = (options) => (options.client ?? client).post({
|
|
1307
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1308
|
+
url: "/tools/mission/{mission_id}/update",
|
|
1309
|
+
...options,
|
|
1310
|
+
headers: {
|
|
1311
|
+
"Content-Type": "application/json",
|
|
1312
|
+
...options.headers
|
|
1313
|
+
}
|
|
1314
|
+
});
|
|
1315
|
+
var getMissionContext = (options) => (options.client ?? client).get(
|
|
1316
|
+
{
|
|
1317
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1318
|
+
url: "/tools/mission/{mission_id}/context",
|
|
1319
|
+
...options
|
|
1320
|
+
}
|
|
1321
|
+
);
|
|
1322
|
+
var loginForAccessToken = (options) => (options.client ?? client).post({
|
|
1323
|
+
...urlSearchParamsBodySerializer,
|
|
1324
|
+
url: "/auth/token",
|
|
1325
|
+
...options,
|
|
1326
|
+
headers: {
|
|
1327
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
1328
|
+
...options.headers
|
|
1329
|
+
}
|
|
1330
|
+
});
|
|
1331
|
+
var login = (options) => (options.client ?? client).post({
|
|
1332
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1333
|
+
url: "/auth/login",
|
|
1334
|
+
...options,
|
|
1335
|
+
headers: {
|
|
1336
|
+
"Content-Type": "application/json",
|
|
1337
|
+
...options.headers
|
|
1338
|
+
}
|
|
1339
|
+
});
|
|
1340
|
+
var refreshTokens = (options) => (options.client ?? client).post({
|
|
1341
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1342
|
+
url: "/auth/refresh",
|
|
1343
|
+
...options,
|
|
1344
|
+
headers: {
|
|
1345
|
+
"Content-Type": "application/json",
|
|
1346
|
+
...options.headers
|
|
1347
|
+
}
|
|
1348
|
+
});
|
|
1349
|
+
var getAuthConfig = (options) => (options?.client ?? client).get({
|
|
1350
|
+
url: "/auth/config",
|
|
1351
|
+
...options
|
|
1352
|
+
});
|
|
1353
|
+
var getCurrentUser = (options) => (options?.client ?? client).get({
|
|
1354
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1355
|
+
url: "/auth/me",
|
|
1356
|
+
...options
|
|
1357
|
+
});
|
|
1358
|
+
var listWorkspaces = (options) => (options?.client ?? client).get({
|
|
1359
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1360
|
+
url: "/auth/workspaces",
|
|
1361
|
+
...options
|
|
1362
|
+
});
|
|
1363
|
+
|
|
1364
|
+
// src/client.ts
|
|
1365
|
+
function extractData(response) {
|
|
1366
|
+
if (response.error) {
|
|
1367
|
+
throw new Error(
|
|
1368
|
+
typeof response.error === "object" && response.error !== null ? response.error.message || JSON.stringify(response.error) : String(response.error)
|
|
1369
|
+
);
|
|
1370
|
+
}
|
|
1371
|
+
return response.data;
|
|
1372
|
+
}
|
|
1373
|
+
var OCXPClient = class {
|
|
1374
|
+
client;
|
|
1375
|
+
workspace;
|
|
1376
|
+
tokenProvider;
|
|
1377
|
+
constructor(options) {
|
|
1378
|
+
this.workspace = options.workspace || "dev";
|
|
1379
|
+
this.tokenProvider = options.token;
|
|
1380
|
+
const config = createConfig({
|
|
1381
|
+
baseUrl: options.endpoint.replace(/\/$/, ""),
|
|
1382
|
+
throwOnError: true
|
|
1383
|
+
});
|
|
1384
|
+
this.client = createClient(config);
|
|
1385
|
+
}
|
|
1386
|
+
/**
|
|
1387
|
+
* Get headers including workspace and auth
|
|
1388
|
+
*/
|
|
1389
|
+
async getHeaders() {
|
|
1390
|
+
const headers = {
|
|
1391
|
+
"X-Workspace": this.workspace
|
|
1392
|
+
};
|
|
1393
|
+
if (this.tokenProvider) {
|
|
1394
|
+
const token = typeof this.tokenProvider === "function" ? await this.tokenProvider() : this.tokenProvider;
|
|
1395
|
+
if (token) {
|
|
1396
|
+
headers["Authorization"] = `Bearer ${token}`;
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
return headers;
|
|
1400
|
+
}
|
|
1401
|
+
/**
|
|
1402
|
+
* Set the workspace for subsequent operations
|
|
1403
|
+
*/
|
|
1404
|
+
setWorkspace(workspace) {
|
|
1405
|
+
this.workspace = workspace;
|
|
1406
|
+
}
|
|
1407
|
+
/**
|
|
1408
|
+
* Get current workspace
|
|
1409
|
+
*/
|
|
1410
|
+
getWorkspace() {
|
|
1411
|
+
return this.workspace;
|
|
1412
|
+
}
|
|
1413
|
+
/**
|
|
1414
|
+
* Get the underlying client for SDK function calls
|
|
1415
|
+
*/
|
|
1416
|
+
getClient() {
|
|
1417
|
+
return this.client;
|
|
1418
|
+
}
|
|
1419
|
+
/**
|
|
1420
|
+
* Set the auth token or token provider
|
|
1421
|
+
*/
|
|
1422
|
+
setToken(token) {
|
|
1423
|
+
this.tokenProvider = token;
|
|
1424
|
+
}
|
|
1425
|
+
// ============== Content Types ==============
|
|
1426
|
+
/**
|
|
1427
|
+
* Get available content types with metadata
|
|
1428
|
+
*/
|
|
1429
|
+
async getContentTypes(counts = false) {
|
|
1430
|
+
const headers = await this.getHeaders();
|
|
1431
|
+
const response = await getContentTypes({
|
|
1432
|
+
client: this.client,
|
|
1433
|
+
query: { counts },
|
|
1434
|
+
headers
|
|
1435
|
+
});
|
|
1436
|
+
const data = extractData(response);
|
|
1437
|
+
return {
|
|
1438
|
+
types: data.types || [],
|
|
1439
|
+
total: data.total || 0
|
|
1440
|
+
};
|
|
1441
|
+
}
|
|
1442
|
+
// ============== CRUD Operations ==============
|
|
1443
|
+
/**
|
|
1444
|
+
* List content of a specific type
|
|
1445
|
+
*/
|
|
1446
|
+
async list(type, path, limit) {
|
|
1447
|
+
const headers = await this.getHeaders();
|
|
1448
|
+
const response = await listContent({
|
|
1449
|
+
client: this.client,
|
|
1450
|
+
path: { content_type: type },
|
|
1451
|
+
query: { path, limit },
|
|
1452
|
+
headers
|
|
1453
|
+
});
|
|
1454
|
+
const data = extractData(response);
|
|
1455
|
+
return {
|
|
1456
|
+
entries: data.entries || [],
|
|
1457
|
+
cursor: data.cursor,
|
|
1458
|
+
hasMore: data.has_more || false,
|
|
1459
|
+
total: data.total || 0
|
|
1460
|
+
};
|
|
1461
|
+
}
|
|
1462
|
+
/**
|
|
1463
|
+
* Read content by ID
|
|
1464
|
+
*/
|
|
1465
|
+
async read(type, id) {
|
|
1466
|
+
const headers = await this.getHeaders();
|
|
1467
|
+
const response = await readContent({
|
|
1468
|
+
client: this.client,
|
|
1469
|
+
path: { content_type: type, content_id: id },
|
|
1470
|
+
headers
|
|
1471
|
+
});
|
|
1472
|
+
const data = extractData(response);
|
|
1473
|
+
return {
|
|
1474
|
+
content: data.content || "",
|
|
1475
|
+
size: data.size,
|
|
1476
|
+
mtime: data.mtime,
|
|
1477
|
+
encoding: data.encoding,
|
|
1478
|
+
metadata: data.metadata
|
|
1479
|
+
};
|
|
1480
|
+
}
|
|
1481
|
+
/**
|
|
1482
|
+
* Write content
|
|
1483
|
+
*/
|
|
1484
|
+
async write(type, id, content, options) {
|
|
1485
|
+
const headers = await this.getHeaders();
|
|
1486
|
+
const body = {
|
|
1487
|
+
content,
|
|
1488
|
+
encoding: options?.encoding || "utf-8",
|
|
1489
|
+
etag: options?.etag,
|
|
1490
|
+
ifNotExists: options?.ifNotExists
|
|
1491
|
+
};
|
|
1492
|
+
const response = await writeContent({
|
|
1493
|
+
client: this.client,
|
|
1494
|
+
path: { content_type: type, content_id: id },
|
|
1495
|
+
body,
|
|
1496
|
+
headers
|
|
1497
|
+
});
|
|
1498
|
+
const data = extractData(response);
|
|
1499
|
+
return {
|
|
1500
|
+
path: data.path || `${type}/${id}`,
|
|
1501
|
+
etag: data.etag
|
|
1502
|
+
};
|
|
1503
|
+
}
|
|
1504
|
+
/**
|
|
1505
|
+
* Delete content
|
|
1506
|
+
*/
|
|
1507
|
+
async delete(type, id, recursive = false, confirm = false) {
|
|
1508
|
+
const headers = await this.getHeaders();
|
|
1509
|
+
const response = await deleteContent({
|
|
1510
|
+
client: this.client,
|
|
1511
|
+
path: { content_type: type, content_id: id },
|
|
1512
|
+
query: { recursive, confirm },
|
|
1513
|
+
headers
|
|
1514
|
+
});
|
|
1515
|
+
const data = extractData(response);
|
|
1516
|
+
return {
|
|
1517
|
+
deleted: data.deleted ?? true,
|
|
1518
|
+
path: data.path || `${type}/${id}`
|
|
1519
|
+
};
|
|
1520
|
+
}
|
|
1521
|
+
// ============== Query & Search ==============
|
|
1522
|
+
/**
|
|
1523
|
+
* Query content with filters
|
|
1524
|
+
*/
|
|
1525
|
+
async query(type, filters, limit) {
|
|
1526
|
+
const headers = await this.getHeaders();
|
|
1527
|
+
return queryContent({
|
|
1528
|
+
client: this.client,
|
|
1529
|
+
path: { content_type: type },
|
|
1530
|
+
body: { filters: filters || [], limit: limit || 100 },
|
|
1531
|
+
headers
|
|
1532
|
+
});
|
|
1533
|
+
}
|
|
1534
|
+
/**
|
|
1535
|
+
* Full-text search
|
|
1536
|
+
*/
|
|
1537
|
+
async search(type, q, limit) {
|
|
1538
|
+
const headers = await this.getHeaders();
|
|
1539
|
+
return searchContent({
|
|
1540
|
+
client: this.client,
|
|
1541
|
+
path: { content_type: type },
|
|
1542
|
+
query: { q, limit },
|
|
1543
|
+
headers
|
|
1544
|
+
});
|
|
1545
|
+
}
|
|
1546
|
+
// ============== Tree & Stats ==============
|
|
1547
|
+
/**
|
|
1548
|
+
* Get hierarchical tree structure from S3 context
|
|
1549
|
+
*/
|
|
1550
|
+
async tree(type, path, depth) {
|
|
1551
|
+
const headers = await this.getHeaders();
|
|
1552
|
+
const response = await getContentTree({
|
|
1553
|
+
client: this.client,
|
|
1554
|
+
path: { content_type: type },
|
|
1555
|
+
query: { path, depth },
|
|
1556
|
+
headers
|
|
1557
|
+
});
|
|
1558
|
+
return extractData(response);
|
|
1559
|
+
}
|
|
1560
|
+
/**
|
|
1561
|
+
* Get content statistics
|
|
1562
|
+
*/
|
|
1563
|
+
async stats(type, path) {
|
|
1564
|
+
const headers = await this.getHeaders();
|
|
1565
|
+
return getContentStats({
|
|
1566
|
+
client: this.client,
|
|
1567
|
+
path: { content_type: type },
|
|
1568
|
+
query: { path },
|
|
1569
|
+
headers
|
|
1570
|
+
});
|
|
1571
|
+
}
|
|
1572
|
+
// ============== Bulk Operations ==============
|
|
1573
|
+
/**
|
|
1574
|
+
* Read multiple items at once
|
|
1575
|
+
*/
|
|
1576
|
+
async bulkRead(type, ids) {
|
|
1577
|
+
const headers = await this.getHeaders();
|
|
1578
|
+
return bulkReadContent({
|
|
1579
|
+
client: this.client,
|
|
1580
|
+
path: { content_type: type },
|
|
1581
|
+
body: { ids },
|
|
1582
|
+
headers
|
|
1583
|
+
});
|
|
1584
|
+
}
|
|
1585
|
+
/**
|
|
1586
|
+
* Write multiple items at once
|
|
1587
|
+
*/
|
|
1588
|
+
async bulkWrite(type, items) {
|
|
1589
|
+
const headers = await this.getHeaders();
|
|
1590
|
+
return bulkWriteContent({
|
|
1591
|
+
client: this.client,
|
|
1592
|
+
path: { content_type: type },
|
|
1593
|
+
body: { items },
|
|
1594
|
+
headers
|
|
1595
|
+
});
|
|
1596
|
+
}
|
|
1597
|
+
/**
|
|
1598
|
+
* Delete multiple items at once
|
|
1599
|
+
*/
|
|
1600
|
+
async bulkDelete(type, ids) {
|
|
1601
|
+
const headers = await this.getHeaders();
|
|
1602
|
+
return bulkDeleteContent({
|
|
1603
|
+
client: this.client,
|
|
1604
|
+
path: { content_type: type },
|
|
1605
|
+
body: { ids },
|
|
1606
|
+
headers
|
|
1607
|
+
});
|
|
1608
|
+
}
|
|
1609
|
+
// ============== Knowledge Base ==============
|
|
1610
|
+
/**
|
|
1611
|
+
* Semantic search in Knowledge Base with optional external docs fallback
|
|
1612
|
+
*/
|
|
1613
|
+
async kbQuery(query, options) {
|
|
1614
|
+
const headers = await this.getHeaders();
|
|
1615
|
+
const body = {
|
|
1616
|
+
query,
|
|
1617
|
+
search_type: options?.searchType || "SEMANTIC",
|
|
1618
|
+
max_results: options?.maxResults || 5,
|
|
1619
|
+
doc_id: options?.docId,
|
|
1620
|
+
repo_ids: options?.repoIds,
|
|
1621
|
+
project_id: options?.projectId,
|
|
1622
|
+
mission_id: options?.missionId,
|
|
1623
|
+
enable_fallback: options?.enableFallback ?? true,
|
|
1624
|
+
fallback_threshold: options?.fallbackThreshold ?? 0.5,
|
|
1625
|
+
persist_external_docs: options?.persistExternalDocs ?? true
|
|
1626
|
+
};
|
|
1627
|
+
const response = await queryKnowledgeBase({
|
|
1628
|
+
client: this.client,
|
|
1629
|
+
body,
|
|
1630
|
+
headers
|
|
1631
|
+
});
|
|
1632
|
+
return extractData(response);
|
|
1633
|
+
}
|
|
1634
|
+
/**
|
|
1635
|
+
* RAG with citations
|
|
1636
|
+
*/
|
|
1637
|
+
async kbRag(query, sessionId) {
|
|
1638
|
+
const headers = await this.getHeaders();
|
|
1639
|
+
const response = await ragKnowledgeBase({
|
|
1640
|
+
client: this.client,
|
|
1641
|
+
body: { query, session_id: sessionId },
|
|
1642
|
+
headers
|
|
1643
|
+
});
|
|
1644
|
+
return extractData(response);
|
|
1645
|
+
}
|
|
1646
|
+
// ============== Mission Operations ==============
|
|
1647
|
+
/**
|
|
1648
|
+
* List all missions in workspace
|
|
1649
|
+
*/
|
|
1650
|
+
async listMissions(options) {
|
|
1651
|
+
const headers = await this.getHeaders();
|
|
1652
|
+
const response = await listMissions({
|
|
1653
|
+
client: this.client,
|
|
1654
|
+
query: {
|
|
1655
|
+
project_id: options?.projectId,
|
|
1656
|
+
status: options?.status,
|
|
1657
|
+
limit: options?.limit
|
|
1658
|
+
},
|
|
1659
|
+
headers
|
|
1660
|
+
});
|
|
1661
|
+
return extractData(response);
|
|
1662
|
+
}
|
|
1663
|
+
/**
|
|
1664
|
+
* Create a new mission with auto-generated UUID
|
|
1665
|
+
*/
|
|
1666
|
+
async createMission(title, description, projectId, goals) {
|
|
1667
|
+
const headers = await this.getHeaders();
|
|
1668
|
+
const body = {
|
|
1669
|
+
title,
|
|
1670
|
+
description,
|
|
1671
|
+
project_id: projectId,
|
|
1672
|
+
goals
|
|
1673
|
+
};
|
|
1674
|
+
const response = await createMission({
|
|
1675
|
+
client: this.client,
|
|
1676
|
+
body,
|
|
1677
|
+
headers
|
|
1678
|
+
});
|
|
1679
|
+
return extractData(response);
|
|
1680
|
+
}
|
|
1681
|
+
/**
|
|
1682
|
+
* Get mission by ID
|
|
1683
|
+
*/
|
|
1684
|
+
async getMission(missionId) {
|
|
1685
|
+
const headers = await this.getHeaders();
|
|
1686
|
+
const response = await getMission({
|
|
1687
|
+
client: this.client,
|
|
1688
|
+
path: { mission_id: missionId },
|
|
1689
|
+
headers
|
|
1690
|
+
});
|
|
1691
|
+
return extractData(response);
|
|
1692
|
+
}
|
|
1693
|
+
/**
|
|
1694
|
+
* Update mission
|
|
1695
|
+
*/
|
|
1696
|
+
async updateMission(missionId, updates) {
|
|
1697
|
+
const headers = await this.getHeaders();
|
|
1698
|
+
const response = await updateMission({
|
|
1699
|
+
client: this.client,
|
|
1700
|
+
path: { mission_id: missionId },
|
|
1701
|
+
body: updates,
|
|
1702
|
+
headers
|
|
1703
|
+
});
|
|
1704
|
+
return extractData(response);
|
|
1705
|
+
}
|
|
1706
|
+
/**
|
|
1707
|
+
* Delete mission
|
|
1708
|
+
*/
|
|
1709
|
+
async deleteMission(missionId) {
|
|
1710
|
+
const headers = await this.getHeaders();
|
|
1711
|
+
await deleteMission({
|
|
1712
|
+
client: this.client,
|
|
1713
|
+
path: { mission_id: missionId },
|
|
1714
|
+
headers
|
|
1715
|
+
});
|
|
1716
|
+
}
|
|
1717
|
+
/**
|
|
1718
|
+
* Add session to mission
|
|
1719
|
+
*/
|
|
1720
|
+
async addMissionSession(missionId, sessionId) {
|
|
1721
|
+
const headers = await this.getHeaders();
|
|
1722
|
+
const response = await addSession({
|
|
1723
|
+
client: this.client,
|
|
1724
|
+
path: { mission_id: missionId },
|
|
1725
|
+
body: { session_id: sessionId },
|
|
1726
|
+
headers
|
|
1727
|
+
});
|
|
1728
|
+
return extractData(response);
|
|
1729
|
+
}
|
|
1730
|
+
/**
|
|
1731
|
+
* Remove session from mission
|
|
1732
|
+
*/
|
|
1733
|
+
async removeMissionSession(missionId, sessionId) {
|
|
1734
|
+
const headers = await this.getHeaders();
|
|
1735
|
+
const response = await removeSession({
|
|
1736
|
+
client: this.client,
|
|
1737
|
+
path: { mission_id: missionId, session_id: sessionId },
|
|
1738
|
+
headers
|
|
1739
|
+
});
|
|
1740
|
+
return extractData(response);
|
|
1741
|
+
}
|
|
1742
|
+
/**
|
|
1743
|
+
* Regenerate mission - archives old docs and triggers AgentCore
|
|
1744
|
+
*/
|
|
1745
|
+
async regenerateMission(missionId, options) {
|
|
1746
|
+
const headers = await this.getHeaders();
|
|
1747
|
+
const response = await regenerateMission({
|
|
1748
|
+
client: this.client,
|
|
1749
|
+
path: { mission_id: missionId },
|
|
1750
|
+
body: {
|
|
1751
|
+
ticket_id: options?.ticket_id,
|
|
1752
|
+
ticket_summary: options?.ticket_summary,
|
|
1753
|
+
ticket_description: options?.ticket_description,
|
|
1754
|
+
archive_old_docs: options?.archive_old_docs ?? true,
|
|
1755
|
+
auto_increment_version: options?.auto_increment_version ?? true
|
|
1756
|
+
},
|
|
1757
|
+
headers
|
|
1758
|
+
});
|
|
1759
|
+
return extractData(response);
|
|
1760
|
+
}
|
|
1761
|
+
/**
|
|
1762
|
+
* Download mission pack as ZIP file
|
|
1763
|
+
* @param missionId - Mission ID
|
|
1764
|
+
* @returns Blob containing ZIP file
|
|
1765
|
+
*/
|
|
1766
|
+
async downloadMissionPack(missionId) {
|
|
1767
|
+
const headers = await this.getHeaders();
|
|
1768
|
+
const config = this.client.getConfig();
|
|
1769
|
+
const baseUrl = config.baseUrl || "";
|
|
1770
|
+
const response = await fetch(`${baseUrl}/ocxp/mission/${missionId}/download`, {
|
|
1771
|
+
method: "GET",
|
|
1772
|
+
headers: {
|
|
1773
|
+
...headers,
|
|
1774
|
+
"X-Workspace": this.workspace
|
|
1775
|
+
}
|
|
1776
|
+
});
|
|
1777
|
+
if (!response.ok) {
|
|
1778
|
+
throw new Error(`Failed to download mission: ${response.status} ${response.statusText}`);
|
|
1779
|
+
}
|
|
1780
|
+
return await response.blob();
|
|
1781
|
+
}
|
|
1782
|
+
// ============== Tools ==============
|
|
1783
|
+
/**
|
|
1784
|
+
* Get mission context for agents
|
|
1785
|
+
*/
|
|
1786
|
+
async getMissionContext(missionId) {
|
|
1787
|
+
const headers = await this.getHeaders();
|
|
1788
|
+
return getMissionContext({
|
|
1789
|
+
client: this.client,
|
|
1790
|
+
path: { mission_id: missionId },
|
|
1791
|
+
headers
|
|
1792
|
+
});
|
|
1793
|
+
}
|
|
1794
|
+
// ============== Locking ==============
|
|
1795
|
+
/**
|
|
1796
|
+
* Acquire exclusive lock on content
|
|
1797
|
+
* @param contentType - Content type (e.g., "mission")
|
|
1798
|
+
* @param contentId - Content ID (e.g., "my-mission")
|
|
1799
|
+
* @param ttl - Lock time-to-live in seconds
|
|
1800
|
+
*/
|
|
1801
|
+
async lock(contentType, contentId, ttl) {
|
|
1802
|
+
const headers = await this.getHeaders();
|
|
1803
|
+
return lockContent({
|
|
1804
|
+
client: this.client,
|
|
1805
|
+
body: {
|
|
1806
|
+
content_type: contentType,
|
|
1807
|
+
content_id: contentId,
|
|
1808
|
+
ttl
|
|
1809
|
+
},
|
|
1810
|
+
headers
|
|
1811
|
+
});
|
|
1812
|
+
}
|
|
1813
|
+
/**
|
|
1814
|
+
* Release exclusive lock
|
|
1815
|
+
* @param contentType - Content type
|
|
1816
|
+
* @param contentId - Content ID
|
|
1817
|
+
*/
|
|
1818
|
+
async unlock(contentType, contentId) {
|
|
1819
|
+
const headers = await this.getHeaders();
|
|
1820
|
+
return unlockContent({
|
|
1821
|
+
client: this.client,
|
|
1822
|
+
body: {
|
|
1823
|
+
content_type: contentType,
|
|
1824
|
+
content_id: contentId
|
|
1825
|
+
},
|
|
1826
|
+
headers
|
|
1827
|
+
});
|
|
1828
|
+
}
|
|
1829
|
+
/**
|
|
1830
|
+
* Move/rename content
|
|
1831
|
+
* @param source - Source path (e.g., "mission/old-id")
|
|
1832
|
+
* @param destination - Destination path (e.g., "mission/new-id")
|
|
1833
|
+
* @param overwrite - Whether to overwrite existing content at destination
|
|
1834
|
+
*/
|
|
1835
|
+
async move(source, destination, overwrite = false) {
|
|
1836
|
+
const headers = await this.getHeaders();
|
|
1837
|
+
const response = await moveContent({
|
|
1838
|
+
client: this.client,
|
|
1839
|
+
body: { source, destination, overwrite },
|
|
1840
|
+
headers
|
|
1841
|
+
});
|
|
1842
|
+
return extractData(response);
|
|
1843
|
+
}
|
|
1844
|
+
// ============== GitHub API Proxy ==============
|
|
1845
|
+
/**
|
|
1846
|
+
* Check if a repository is accessible
|
|
1847
|
+
* @param repoUrl - Full GitHub repository URL
|
|
1848
|
+
*/
|
|
1849
|
+
async githubCheckAccess(repoUrl) {
|
|
1850
|
+
const headers = await this.getHeaders();
|
|
1851
|
+
const response = await githubCheckAccess({
|
|
1852
|
+
client: this.client,
|
|
1853
|
+
body: { repo_url: repoUrl },
|
|
1854
|
+
headers
|
|
1855
|
+
});
|
|
1856
|
+
return extractData(response);
|
|
1857
|
+
}
|
|
1858
|
+
/**
|
|
1859
|
+
* List branches for a repository
|
|
1860
|
+
* @param repoUrl - Full GitHub repository URL
|
|
1861
|
+
*/
|
|
1862
|
+
async githubListBranches(repoUrl) {
|
|
1863
|
+
const headers = await this.getHeaders();
|
|
1864
|
+
const response = await githubListBranches({
|
|
1865
|
+
client: this.client,
|
|
1866
|
+
body: { repo_url: repoUrl },
|
|
1867
|
+
headers
|
|
1868
|
+
});
|
|
1869
|
+
return extractData(response);
|
|
1870
|
+
}
|
|
1871
|
+
/**
|
|
1872
|
+
* Get repository contents at a path
|
|
1873
|
+
* @param repoUrl - Full GitHub repository URL
|
|
1874
|
+
* @param path - Path within the repository
|
|
1875
|
+
* @param ref - Git ref (branch, tag, or commit)
|
|
1876
|
+
*/
|
|
1877
|
+
async githubGetContents(repoUrl, path = "", ref) {
|
|
1878
|
+
const headers = await this.getHeaders();
|
|
1879
|
+
const response = await githubGetContents({
|
|
1880
|
+
client: this.client,
|
|
1881
|
+
body: { repo_url: repoUrl, path, ref },
|
|
1882
|
+
headers
|
|
1883
|
+
});
|
|
1884
|
+
return extractData(response);
|
|
1885
|
+
}
|
|
1886
|
+
// ============== Repository Management ==============
|
|
1887
|
+
/**
|
|
1888
|
+
* Download repository and trigger vectorization
|
|
1889
|
+
* @param repoUrl - Full GitHub repository URL
|
|
1890
|
+
* @param branch - Optional branch (default: main)
|
|
1891
|
+
* @param options - Download options (mode, repo_type, path)
|
|
1892
|
+
*/
|
|
1893
|
+
async downloadRepository(repoUrl, branch, options) {
|
|
1894
|
+
const headers = await this.getHeaders();
|
|
1895
|
+
const response = await downloadRepository({
|
|
1896
|
+
client: this.client,
|
|
1897
|
+
body: {
|
|
1898
|
+
repo_url: repoUrl,
|
|
1899
|
+
branch,
|
|
1900
|
+
mode: options?.mode,
|
|
1901
|
+
repo_type: options?.repo_type,
|
|
1902
|
+
path: options?.path
|
|
1903
|
+
},
|
|
1904
|
+
headers
|
|
1905
|
+
});
|
|
1906
|
+
return extractData(response);
|
|
1907
|
+
}
|
|
1908
|
+
/**
|
|
1909
|
+
* Get repository download status
|
|
1910
|
+
*/
|
|
1911
|
+
async getRepoStatus(jobId) {
|
|
1912
|
+
const headers = await this.getHeaders();
|
|
1913
|
+
const response = await getRepoDownloadStatus({
|
|
1914
|
+
client: this.client,
|
|
1915
|
+
path: { job_id: jobId },
|
|
1916
|
+
headers
|
|
1917
|
+
});
|
|
1918
|
+
return extractData(response);
|
|
1919
|
+
}
|
|
1920
|
+
/**
|
|
1921
|
+
* List all downloaded repositories in workspace
|
|
1922
|
+
*/
|
|
1923
|
+
async listRepos() {
|
|
1924
|
+
const headers = await this.getHeaders();
|
|
1925
|
+
const response = await listDownloadedRepos({
|
|
1926
|
+
client: this.client,
|
|
1927
|
+
headers
|
|
1928
|
+
});
|
|
1929
|
+
return extractData(response);
|
|
1930
|
+
}
|
|
1931
|
+
/**
|
|
1932
|
+
* Delete a downloaded repository by its UUID
|
|
1933
|
+
*/
|
|
1934
|
+
async deleteRepo(repoId) {
|
|
1935
|
+
const headers = await this.getHeaders();
|
|
1936
|
+
const response = await deleteRepo({
|
|
1937
|
+
client: this.client,
|
|
1938
|
+
path: { repo_id: repoId },
|
|
1939
|
+
headers
|
|
1940
|
+
});
|
|
1941
|
+
return extractData(response);
|
|
1942
|
+
}
|
|
1943
|
+
// ============== Database Operations ==============
|
|
1944
|
+
/**
|
|
1945
|
+
* List all database configurations in workspace
|
|
1946
|
+
*/
|
|
1947
|
+
async listDatabases() {
|
|
1948
|
+
const headers = await this.getHeaders();
|
|
1949
|
+
const response = await listDatabases({
|
|
1950
|
+
client: this.client,
|
|
1951
|
+
headers
|
|
1952
|
+
});
|
|
1953
|
+
return extractData(response);
|
|
1954
|
+
}
|
|
1955
|
+
/**
|
|
1956
|
+
* Create a new database configuration
|
|
1957
|
+
*/
|
|
1958
|
+
async createDatabase(config) {
|
|
1959
|
+
const headers = await this.getHeaders();
|
|
1960
|
+
const response = await createDatabase({
|
|
1961
|
+
client: this.client,
|
|
1962
|
+
body: config,
|
|
1963
|
+
headers
|
|
1964
|
+
});
|
|
1965
|
+
return extractData(response);
|
|
1966
|
+
}
|
|
1967
|
+
/**
|
|
1968
|
+
* Get database configuration by ID
|
|
1969
|
+
*/
|
|
1970
|
+
async getDatabase(databaseId) {
|
|
1971
|
+
const headers = await this.getHeaders();
|
|
1972
|
+
const response = await getDatabase({
|
|
1973
|
+
client: this.client,
|
|
1974
|
+
path: { database_id: databaseId },
|
|
1975
|
+
headers
|
|
1976
|
+
});
|
|
1977
|
+
return extractData(response);
|
|
1978
|
+
}
|
|
1979
|
+
/**
|
|
1980
|
+
* Update database configuration
|
|
1981
|
+
*/
|
|
1982
|
+
async updateDatabase(databaseId, updates) {
|
|
1983
|
+
const headers = await this.getHeaders();
|
|
1984
|
+
const response = await updateDatabase({
|
|
1985
|
+
client: this.client,
|
|
1986
|
+
path: { database_id: databaseId },
|
|
1987
|
+
body: updates,
|
|
1988
|
+
headers
|
|
1989
|
+
});
|
|
1990
|
+
return extractData(response);
|
|
1991
|
+
}
|
|
1992
|
+
/**
|
|
1993
|
+
* Delete database configuration
|
|
1994
|
+
*/
|
|
1995
|
+
async deleteDatabase(databaseId) {
|
|
1996
|
+
const headers = await this.getHeaders();
|
|
1997
|
+
await deleteDatabase({
|
|
1998
|
+
client: this.client,
|
|
1999
|
+
path: { database_id: databaseId },
|
|
2000
|
+
headers
|
|
2001
|
+
});
|
|
2002
|
+
}
|
|
2003
|
+
/**
|
|
2004
|
+
* Test database connection
|
|
2005
|
+
*/
|
|
2006
|
+
async testDatabaseConnection(databaseId) {
|
|
2007
|
+
const headers = await this.getHeaders();
|
|
2008
|
+
const response = await testDatabaseConnection({
|
|
2009
|
+
client: this.client,
|
|
2010
|
+
path: { database_id: databaseId },
|
|
2011
|
+
headers
|
|
2012
|
+
});
|
|
2013
|
+
return extractData(response);
|
|
2014
|
+
}
|
|
2015
|
+
/**
|
|
2016
|
+
* Get database schema (tables and columns)
|
|
2017
|
+
*/
|
|
2018
|
+
async getDatabaseSchema(databaseId) {
|
|
2019
|
+
const headers = await this.getHeaders();
|
|
2020
|
+
const response = await getSchema({
|
|
2021
|
+
client: this.client,
|
|
2022
|
+
query: { database_id: databaseId },
|
|
2023
|
+
headers
|
|
2024
|
+
});
|
|
2025
|
+
return extractData(response);
|
|
2026
|
+
}
|
|
2027
|
+
/**
|
|
2028
|
+
* Get sample data from a table
|
|
2029
|
+
*/
|
|
2030
|
+
async getDatabaseSample(tableName, databaseId, limit) {
|
|
2031
|
+
const headers = await this.getHeaders();
|
|
2032
|
+
const response = await getSample({
|
|
2033
|
+
client: this.client,
|
|
2034
|
+
path: { table_name: tableName },
|
|
2035
|
+
query: { database_id: databaseId, limit },
|
|
2036
|
+
headers
|
|
2037
|
+
});
|
|
2038
|
+
return extractData(response);
|
|
2039
|
+
}
|
|
2040
|
+
/**
|
|
2041
|
+
* List all tables in database
|
|
2042
|
+
*/
|
|
2043
|
+
async listDatabaseTables(databaseId) {
|
|
2044
|
+
const headers = await this.getHeaders();
|
|
2045
|
+
const response = await listTables({
|
|
2046
|
+
client: this.client,
|
|
2047
|
+
query: { database_id: databaseId },
|
|
2048
|
+
headers
|
|
2049
|
+
});
|
|
2050
|
+
return extractData(response);
|
|
2051
|
+
}
|
|
2052
|
+
// ============== Project Operations ==============
|
|
2053
|
+
/**
|
|
2054
|
+
* List all projects in workspace
|
|
2055
|
+
*/
|
|
2056
|
+
async listProjects(limit) {
|
|
2057
|
+
const headers = await this.getHeaders();
|
|
2058
|
+
const response = await listProjects({
|
|
2059
|
+
client: this.client,
|
|
2060
|
+
query: { limit },
|
|
2061
|
+
headers
|
|
2062
|
+
});
|
|
2063
|
+
return extractData(response);
|
|
2064
|
+
}
|
|
2065
|
+
/**
|
|
2066
|
+
* Create a new project with auto-generated UUID
|
|
2067
|
+
*/
|
|
2068
|
+
async createProject(name, description) {
|
|
2069
|
+
const headers = await this.getHeaders();
|
|
2070
|
+
const body = {
|
|
2071
|
+
name,
|
|
2072
|
+
description
|
|
2073
|
+
};
|
|
2074
|
+
const response = await createProject({
|
|
2075
|
+
client: this.client,
|
|
2076
|
+
body,
|
|
2077
|
+
headers
|
|
2078
|
+
});
|
|
2079
|
+
return extractData(response);
|
|
2080
|
+
}
|
|
2081
|
+
/**
|
|
2082
|
+
* Get project by ID
|
|
2083
|
+
*/
|
|
2084
|
+
async getProject(projectId) {
|
|
2085
|
+
const headers = await this.getHeaders();
|
|
2086
|
+
const response = await getProject({
|
|
2087
|
+
client: this.client,
|
|
2088
|
+
path: { project_id: projectId },
|
|
2089
|
+
headers
|
|
2090
|
+
});
|
|
2091
|
+
return extractData(response);
|
|
2092
|
+
}
|
|
2093
|
+
/**
|
|
2094
|
+
* Update project
|
|
2095
|
+
*/
|
|
2096
|
+
async updateProject(projectId, updates) {
|
|
2097
|
+
const headers = await this.getHeaders();
|
|
2098
|
+
const response = await updateProject({
|
|
2099
|
+
client: this.client,
|
|
2100
|
+
path: { project_id: projectId },
|
|
2101
|
+
body: updates,
|
|
2102
|
+
headers
|
|
2103
|
+
});
|
|
2104
|
+
return extractData(response);
|
|
2105
|
+
}
|
|
2106
|
+
/**
|
|
2107
|
+
* Delete project
|
|
2108
|
+
*/
|
|
2109
|
+
async deleteProject(projectId) {
|
|
2110
|
+
const headers = await this.getHeaders();
|
|
2111
|
+
await deleteProject({
|
|
2112
|
+
client: this.client,
|
|
2113
|
+
path: { project_id: projectId },
|
|
2114
|
+
headers
|
|
2115
|
+
});
|
|
2116
|
+
}
|
|
2117
|
+
/**
|
|
2118
|
+
* Add repository to project
|
|
2119
|
+
*/
|
|
2120
|
+
async addProjectRepo(projectId, repoId, options) {
|
|
2121
|
+
const headers = await this.getHeaders();
|
|
2122
|
+
const body = {
|
|
2123
|
+
repo_id: repoId,
|
|
2124
|
+
category: options?.category,
|
|
2125
|
+
priority: options?.priority,
|
|
2126
|
+
auto_include: options?.autoInclude,
|
|
2127
|
+
branch: options?.branch
|
|
2128
|
+
};
|
|
2129
|
+
const response = await addLinkedRepo({
|
|
2130
|
+
client: this.client,
|
|
2131
|
+
path: { project_id: projectId },
|
|
2132
|
+
body,
|
|
2133
|
+
headers
|
|
2134
|
+
});
|
|
2135
|
+
return extractData(response);
|
|
2136
|
+
}
|
|
2137
|
+
/**
|
|
2138
|
+
* Remove repository from project
|
|
2139
|
+
*/
|
|
2140
|
+
async removeProjectRepo(projectId, repoId) {
|
|
2141
|
+
const headers = await this.getHeaders();
|
|
2142
|
+
const response = await removeLinkedRepo({
|
|
2143
|
+
client: this.client,
|
|
2144
|
+
path: { project_id: projectId, repo_id: repoId },
|
|
2145
|
+
headers
|
|
2146
|
+
});
|
|
2147
|
+
return extractData(response);
|
|
2148
|
+
}
|
|
2149
|
+
/**
|
|
2150
|
+
* Set default repository for project
|
|
2151
|
+
*/
|
|
2152
|
+
async setDefaultRepo(projectId, repoId) {
|
|
2153
|
+
const headers = await this.getHeaders();
|
|
2154
|
+
const body = { repo_id: repoId };
|
|
2155
|
+
const response = await setDefaultRepo({
|
|
2156
|
+
client: this.client,
|
|
2157
|
+
path: { project_id: projectId },
|
|
2158
|
+
body,
|
|
2159
|
+
headers
|
|
2160
|
+
});
|
|
2161
|
+
return extractData(response);
|
|
2162
|
+
}
|
|
2163
|
+
/**
|
|
2164
|
+
* Get context repositories for project (auto-include enabled)
|
|
2165
|
+
*/
|
|
2166
|
+
async getContextRepos(projectId) {
|
|
2167
|
+
const headers = await this.getHeaders();
|
|
2168
|
+
const response = await getContextRepos({
|
|
2169
|
+
client: this.client,
|
|
2170
|
+
path: { project_id: projectId },
|
|
2171
|
+
headers
|
|
2172
|
+
});
|
|
2173
|
+
const data = extractData(response);
|
|
2174
|
+
return data.repos || [];
|
|
2175
|
+
}
|
|
2176
|
+
/**
|
|
2177
|
+
* Add mission to project
|
|
2178
|
+
*/
|
|
2179
|
+
async addProjectMission(projectId, missionId) {
|
|
2180
|
+
const headers = await this.getHeaders();
|
|
2181
|
+
const body = { mission_id: missionId };
|
|
2182
|
+
const response = await addMission({
|
|
2183
|
+
client: this.client,
|
|
2184
|
+
path: { project_id: projectId },
|
|
2185
|
+
body,
|
|
2186
|
+
headers
|
|
2187
|
+
});
|
|
2188
|
+
return extractData(response);
|
|
2189
|
+
}
|
|
2190
|
+
/**
|
|
2191
|
+
* Remove mission from project
|
|
2192
|
+
*/
|
|
2193
|
+
async removeProjectMission(projectId, missionId) {
|
|
2194
|
+
const headers = await this.getHeaders();
|
|
2195
|
+
const response = await removeMission({
|
|
2196
|
+
client: this.client,
|
|
2197
|
+
path: { project_id: projectId, mission_id: missionId },
|
|
2198
|
+
headers
|
|
2199
|
+
});
|
|
2200
|
+
return extractData(response);
|
|
2201
|
+
}
|
|
2202
|
+
// ============== Session Operations ==============
|
|
2203
|
+
/**
|
|
2204
|
+
* List all sessions in workspace
|
|
2205
|
+
*/
|
|
2206
|
+
async listSessions(limit, status) {
|
|
2207
|
+
const headers = await this.getHeaders();
|
|
2208
|
+
const response = await listSessions({
|
|
2209
|
+
client: this.client,
|
|
2210
|
+
query: { limit, status },
|
|
2211
|
+
headers
|
|
2212
|
+
});
|
|
2213
|
+
return extractData(response);
|
|
2214
|
+
}
|
|
2215
|
+
/**
|
|
2216
|
+
* Get session messages
|
|
2217
|
+
*/
|
|
2218
|
+
async getSessionMessages(sessionId, limit) {
|
|
2219
|
+
const headers = await this.getHeaders();
|
|
2220
|
+
const response = await getSessionMessages({
|
|
2221
|
+
client: this.client,
|
|
2222
|
+
path: { session_id: sessionId },
|
|
2223
|
+
query: { limit },
|
|
2224
|
+
headers
|
|
2225
|
+
});
|
|
2226
|
+
return extractData(response);
|
|
2227
|
+
}
|
|
2228
|
+
/**
|
|
2229
|
+
* Update session metadata
|
|
2230
|
+
*/
|
|
2231
|
+
async updateSessionMetadata(sessionId, updates) {
|
|
2232
|
+
const headers = await this.getHeaders();
|
|
2233
|
+
const response = await updateSessionMetadata({
|
|
2234
|
+
client: this.client,
|
|
2235
|
+
path: { session_id: sessionId },
|
|
2236
|
+
body: updates,
|
|
2237
|
+
headers
|
|
2238
|
+
});
|
|
2239
|
+
return extractData(response);
|
|
2240
|
+
}
|
|
2241
|
+
/**
|
|
2242
|
+
* Fork session
|
|
2243
|
+
*/
|
|
2244
|
+
async forkSession(sessionId, missionId, forkPoint) {
|
|
2245
|
+
const headers = await this.getHeaders();
|
|
2246
|
+
const body = { mission_id: missionId, fork_point: forkPoint };
|
|
2247
|
+
const response = await forkSession({
|
|
2248
|
+
client: this.client,
|
|
2249
|
+
path: { session_id: sessionId },
|
|
2250
|
+
body,
|
|
2251
|
+
headers
|
|
2252
|
+
});
|
|
2253
|
+
return extractData(response);
|
|
2254
|
+
}
|
|
2255
|
+
/**
|
|
2256
|
+
* Archive session
|
|
2257
|
+
*/
|
|
2258
|
+
async archiveSession(sessionId) {
|
|
2259
|
+
const headers = await this.getHeaders();
|
|
2260
|
+
await archiveSession({
|
|
2261
|
+
client: this.client,
|
|
2262
|
+
path: { session_id: sessionId },
|
|
2263
|
+
headers
|
|
2264
|
+
});
|
|
2265
|
+
}
|
|
2266
|
+
// ============== Auth Operations ==============
|
|
2267
|
+
/**
|
|
2268
|
+
* Get auth configuration (public endpoint)
|
|
2269
|
+
*/
|
|
2270
|
+
async getAuthConfig() {
|
|
2271
|
+
const response = await getAuthConfig({
|
|
2272
|
+
client: this.client
|
|
2273
|
+
});
|
|
2274
|
+
return extractData(response);
|
|
2275
|
+
}
|
|
2276
|
+
/**
|
|
2277
|
+
* Get current authenticated user
|
|
2278
|
+
*/
|
|
2279
|
+
async getCurrentUser() {
|
|
2280
|
+
const headers = await this.getHeaders();
|
|
2281
|
+
const response = await getCurrentUser({
|
|
2282
|
+
client: this.client,
|
|
2283
|
+
headers
|
|
2284
|
+
});
|
|
2285
|
+
return extractData(response);
|
|
2286
|
+
}
|
|
2287
|
+
/**
|
|
2288
|
+
* List workspaces for authenticated user
|
|
2289
|
+
*/
|
|
2290
|
+
async listWorkspaces() {
|
|
2291
|
+
const headers = await this.getHeaders();
|
|
2292
|
+
const response = await listWorkspaces({
|
|
2293
|
+
client: this.client,
|
|
2294
|
+
headers
|
|
2295
|
+
});
|
|
2296
|
+
return extractData(response);
|
|
2297
|
+
}
|
|
2298
|
+
/**
|
|
2299
|
+
* Login with username and password (JSON endpoint for programmatic clients)
|
|
2300
|
+
* @param username - Cognito username
|
|
2301
|
+
* @param password - User password
|
|
2302
|
+
* @returns Token response with access_token, refresh_token, and expires_in
|
|
2303
|
+
*/
|
|
2304
|
+
async login(username, password) {
|
|
2305
|
+
const response = await login({
|
|
2306
|
+
client: this.client,
|
|
2307
|
+
body: { username, password }
|
|
2308
|
+
});
|
|
2309
|
+
return extractData(response);
|
|
2310
|
+
}
|
|
2311
|
+
/**
|
|
2312
|
+
* Refresh access token using refresh token
|
|
2313
|
+
* @param refreshToken - The refresh token from login
|
|
2314
|
+
* @returns New access token (refresh token remains the same)
|
|
2315
|
+
*/
|
|
2316
|
+
async refreshToken(refreshToken) {
|
|
2317
|
+
const response = await refreshTokens({
|
|
2318
|
+
client: this.client,
|
|
2319
|
+
body: { refreshToken }
|
|
2320
|
+
});
|
|
2321
|
+
return extractData(response);
|
|
2322
|
+
}
|
|
2323
|
+
/**
|
|
2324
|
+
* Set GitHub token for the authenticated user
|
|
2325
|
+
* Stores the token server-side linked to the Cognito identity
|
|
2326
|
+
* @param token - GitHub Personal Access Token
|
|
2327
|
+
* @returns Success response
|
|
2328
|
+
*/
|
|
2329
|
+
async setGitHubToken(token) {
|
|
2330
|
+
const headers = await this.getHeaders();
|
|
2331
|
+
const response = await this.client.request({
|
|
2332
|
+
method: "PUT",
|
|
2333
|
+
url: "/auth/github-token",
|
|
2334
|
+
headers,
|
|
2335
|
+
body: { github_token: token }
|
|
2336
|
+
});
|
|
2337
|
+
if (response.error) {
|
|
2338
|
+
throw new Error(`Failed to set GitHub token: ${typeof response.error === "object" ? JSON.stringify(response.error) : response.error}`);
|
|
2339
|
+
}
|
|
2340
|
+
if (response.data === true) {
|
|
2341
|
+
return { success: true };
|
|
2342
|
+
}
|
|
2343
|
+
return response.data || { success: true };
|
|
2344
|
+
}
|
|
2345
|
+
/**
|
|
2346
|
+
* Get GitHub token status for the authenticated user
|
|
2347
|
+
* @returns Token status (configured or not)
|
|
2348
|
+
*/
|
|
2349
|
+
async getGitHubTokenStatus() {
|
|
2350
|
+
const headers = await this.getHeaders();
|
|
2351
|
+
const response = await this.client.request({
|
|
2352
|
+
method: "GET",
|
|
2353
|
+
url: "/auth/github-token",
|
|
2354
|
+
headers
|
|
2355
|
+
});
|
|
2356
|
+
if (response.error) {
|
|
2357
|
+
throw new Error(`Failed to get GitHub token status: ${typeof response.error === "object" ? JSON.stringify(response.error) : response.error}`);
|
|
2358
|
+
}
|
|
2359
|
+
const data = response.data;
|
|
2360
|
+
if (data && typeof data === "object" && "configured" in data) {
|
|
2361
|
+
return data;
|
|
2362
|
+
}
|
|
2363
|
+
return { configured: false };
|
|
2364
|
+
}
|
|
2365
|
+
/**
|
|
2366
|
+
* Delete GitHub token for the authenticated user
|
|
2367
|
+
* @returns Success response
|
|
2368
|
+
*/
|
|
2369
|
+
async deleteGitHubToken() {
|
|
2370
|
+
const headers = await this.getHeaders();
|
|
2371
|
+
const response = await this.client.request({
|
|
2372
|
+
method: "DELETE",
|
|
2373
|
+
url: "/auth/github-token",
|
|
2374
|
+
headers
|
|
2375
|
+
});
|
|
2376
|
+
if (response.error) {
|
|
2377
|
+
throw new Error(`Failed to delete GitHub token: ${typeof response.error === "object" ? JSON.stringify(response.error) : response.error}`);
|
|
2378
|
+
}
|
|
2379
|
+
if (response.data === true) {
|
|
2380
|
+
return { success: true };
|
|
2381
|
+
}
|
|
2382
|
+
return response.data || { success: true };
|
|
2383
|
+
}
|
|
2384
|
+
// ============== Namespaced Accessors ==============
|
|
2385
|
+
_mission;
|
|
2386
|
+
_project;
|
|
2387
|
+
_session;
|
|
2388
|
+
_kb;
|
|
2389
|
+
/**
|
|
2390
|
+
* Mission namespace for convenient mission operations
|
|
2391
|
+
* @example ocxp.mission.list({ status: 'pending' })
|
|
2392
|
+
*/
|
|
2393
|
+
get mission() {
|
|
2394
|
+
if (!this._mission) {
|
|
2395
|
+
this._mission = new MissionNamespace(this);
|
|
2396
|
+
}
|
|
2397
|
+
return this._mission;
|
|
2398
|
+
}
|
|
2399
|
+
/**
|
|
2400
|
+
* Project namespace for convenient project operations
|
|
2401
|
+
* @example ocxp.project.list()
|
|
2402
|
+
*/
|
|
2403
|
+
get project() {
|
|
2404
|
+
if (!this._project) {
|
|
2405
|
+
this._project = new ProjectNamespace(this);
|
|
2406
|
+
}
|
|
2407
|
+
return this._project;
|
|
2408
|
+
}
|
|
2409
|
+
/**
|
|
2410
|
+
* Session namespace for convenient session operations
|
|
2411
|
+
* @example ocxp.session.list({ status: 'active' })
|
|
2412
|
+
*/
|
|
2413
|
+
get session() {
|
|
2414
|
+
if (!this._session) {
|
|
2415
|
+
this._session = new SessionNamespace(this);
|
|
2416
|
+
}
|
|
2417
|
+
return this._session;
|
|
2418
|
+
}
|
|
2419
|
+
/**
|
|
2420
|
+
* KB namespace for convenient knowledge base operations
|
|
2421
|
+
* @example ocxp.kb.query('search term')
|
|
2422
|
+
*/
|
|
2423
|
+
get kb() {
|
|
2424
|
+
if (!this._kb) {
|
|
2425
|
+
this._kb = new KBNamespace(this);
|
|
2426
|
+
}
|
|
2427
|
+
return this._kb;
|
|
2428
|
+
}
|
|
2429
|
+
};
|
|
2430
|
+
var MissionNamespace = class {
|
|
2431
|
+
constructor(client2) {
|
|
2432
|
+
this.client = client2;
|
|
2433
|
+
}
|
|
2434
|
+
/**
|
|
2435
|
+
* List missions with optional filtering
|
|
2436
|
+
* @example ocxp.mission.list({ status: 'active', limit: 10 })
|
|
2437
|
+
*/
|
|
2438
|
+
async list(options) {
|
|
2439
|
+
return this.client.listMissions(options);
|
|
2440
|
+
}
|
|
2441
|
+
/**
|
|
2442
|
+
* Get a mission by ID
|
|
2443
|
+
* @example ocxp.mission.get('uuid')
|
|
2444
|
+
*/
|
|
2445
|
+
async get(missionId) {
|
|
2446
|
+
return this.client.getMission(missionId);
|
|
2447
|
+
}
|
|
2448
|
+
/**
|
|
2449
|
+
* Create a new mission with auto-generated UUID
|
|
2450
|
+
* @example ocxp.mission.create({ title: 'My Mission', description: 'Description' })
|
|
2451
|
+
*/
|
|
2452
|
+
async create(data) {
|
|
2453
|
+
return this.client.createMission(data.title, data.description, data.projectId, data.goals);
|
|
2454
|
+
}
|
|
2455
|
+
/**
|
|
2456
|
+
* Update mission
|
|
2457
|
+
*/
|
|
2458
|
+
async update(missionId, updates) {
|
|
2459
|
+
return this.client.updateMission(missionId, updates);
|
|
2460
|
+
}
|
|
2461
|
+
/**
|
|
2462
|
+
* Delete mission
|
|
2463
|
+
*/
|
|
2464
|
+
async delete(missionId) {
|
|
2465
|
+
return this.client.deleteMission(missionId);
|
|
2466
|
+
}
|
|
2467
|
+
/**
|
|
2468
|
+
* Add session to mission
|
|
2469
|
+
*/
|
|
2470
|
+
async addSession(missionId, sessionId) {
|
|
2471
|
+
return this.client.addMissionSession(missionId, sessionId);
|
|
2472
|
+
}
|
|
2473
|
+
/**
|
|
2474
|
+
* Remove session from mission
|
|
2475
|
+
*/
|
|
2476
|
+
async removeSession(missionId, sessionId) {
|
|
2477
|
+
return this.client.removeMissionSession(missionId, sessionId);
|
|
2478
|
+
}
|
|
2479
|
+
/**
|
|
2480
|
+
* Regenerate mission - archives old docs and triggers AgentCore
|
|
2481
|
+
* @example ocxp.mission.regenerate('uuid', { ticket_id: 'AMC-123' })
|
|
2482
|
+
*/
|
|
2483
|
+
async regenerate(missionId, options) {
|
|
2484
|
+
return this.client.regenerateMission(missionId, options);
|
|
2485
|
+
}
|
|
2486
|
+
/**
|
|
2487
|
+
* Download mission pack as ZIP
|
|
2488
|
+
* @example await ocxp.mission.download('mission-id')
|
|
2489
|
+
*/
|
|
2490
|
+
async download(missionId) {
|
|
2491
|
+
return this.client.downloadMissionPack(missionId);
|
|
2492
|
+
}
|
|
2493
|
+
/**
|
|
2494
|
+
* Get mission context for agents
|
|
2495
|
+
* @example ocxp.mission.getContext('uuid')
|
|
2496
|
+
*/
|
|
2497
|
+
async getContext(missionId) {
|
|
2498
|
+
return this.client.getMissionContext(missionId);
|
|
2499
|
+
}
|
|
2500
|
+
/**
|
|
2501
|
+
* Get mission content tree structure from S3
|
|
2502
|
+
* @example ocxp.mission.tree('subfolder', 5)
|
|
2503
|
+
*/
|
|
2504
|
+
async tree(path, depth) {
|
|
2505
|
+
return this.client.tree("mission", path, depth);
|
|
2506
|
+
}
|
|
2507
|
+
};
|
|
2508
|
+
var ProjectNamespace = class {
|
|
2509
|
+
constructor(client2) {
|
|
2510
|
+
this.client = client2;
|
|
2511
|
+
}
|
|
2512
|
+
/**
|
|
2513
|
+
* List all projects
|
|
2514
|
+
* @example ocxp.project.list()
|
|
2515
|
+
*/
|
|
2516
|
+
async list(limit) {
|
|
2517
|
+
return this.client.listProjects(limit);
|
|
2518
|
+
}
|
|
2519
|
+
/**
|
|
2520
|
+
* Get a project by ID
|
|
2521
|
+
* @example ocxp.project.get('my-project')
|
|
2522
|
+
*/
|
|
2523
|
+
async get(projectId) {
|
|
2524
|
+
return this.client.getProject(projectId);
|
|
2525
|
+
}
|
|
2526
|
+
/**
|
|
2527
|
+
* Create a new project with auto-generated UUID
|
|
2528
|
+
* @example ocxp.project.create({ name: 'My Project', description: 'Optional description' })
|
|
2529
|
+
*/
|
|
2530
|
+
async create(data) {
|
|
2531
|
+
return this.client.createProject(data.name, data.description);
|
|
2532
|
+
}
|
|
2533
|
+
/**
|
|
2534
|
+
* Update a project
|
|
2535
|
+
*/
|
|
2536
|
+
async update(projectId, data) {
|
|
2537
|
+
return this.client.updateProject(projectId, data);
|
|
2538
|
+
}
|
|
2539
|
+
/**
|
|
2540
|
+
* Delete a project
|
|
2541
|
+
*/
|
|
2542
|
+
async delete(projectId) {
|
|
2543
|
+
return this.client.deleteProject(projectId);
|
|
2544
|
+
}
|
|
2545
|
+
/**
|
|
2546
|
+
* Add a repository to a project
|
|
2547
|
+
*/
|
|
2548
|
+
async addRepo(projectId, repoId, options) {
|
|
2549
|
+
return this.client.addProjectRepo(projectId, repoId, options);
|
|
2550
|
+
}
|
|
2551
|
+
/**
|
|
2552
|
+
* Remove a repository from a project
|
|
2553
|
+
*/
|
|
2554
|
+
async removeRepo(projectId, repoId) {
|
|
2555
|
+
return this.client.removeProjectRepo(projectId, repoId);
|
|
2556
|
+
}
|
|
2557
|
+
/**
|
|
2558
|
+
* Set the default repository for a project
|
|
2559
|
+
*/
|
|
2560
|
+
async setDefaultRepo(projectId, repoId) {
|
|
2561
|
+
return this.client.setDefaultRepo(projectId, repoId);
|
|
2562
|
+
}
|
|
2563
|
+
/**
|
|
2564
|
+
* Get context repositories for a project
|
|
2565
|
+
*/
|
|
2566
|
+
async getContextRepos(projectId) {
|
|
2567
|
+
return this.client.getContextRepos(projectId);
|
|
2568
|
+
}
|
|
2569
|
+
/**
|
|
2570
|
+
* Add a mission to a project
|
|
2571
|
+
*/
|
|
2572
|
+
async addMission(projectId, missionId) {
|
|
2573
|
+
return this.client.addProjectMission(projectId, missionId);
|
|
2574
|
+
}
|
|
2575
|
+
/**
|
|
2576
|
+
* Remove a mission from a project
|
|
2577
|
+
*/
|
|
2578
|
+
async removeMission(projectId, missionId) {
|
|
2579
|
+
return this.client.removeProjectMission(projectId, missionId);
|
|
2580
|
+
}
|
|
2581
|
+
/**
|
|
2582
|
+
* Get project content tree structure from S3
|
|
2583
|
+
* @example ocxp.project.tree('subfolder', 5)
|
|
2584
|
+
*/
|
|
2585
|
+
async tree(path, depth) {
|
|
2586
|
+
return this.client.tree("project", path, depth);
|
|
2587
|
+
}
|
|
2588
|
+
};
|
|
2589
|
+
var SessionNamespace = class {
|
|
2590
|
+
constructor(client2) {
|
|
2591
|
+
this.client = client2;
|
|
2592
|
+
}
|
|
2593
|
+
/**
|
|
2594
|
+
* List sessions with optional filtering
|
|
2595
|
+
* @example ocxp.session.list({ status: 'active', limit: 10 })
|
|
2596
|
+
*/
|
|
2597
|
+
async list(options) {
|
|
2598
|
+
return this.client.listSessions(options?.limit, options?.status);
|
|
2599
|
+
}
|
|
2600
|
+
/**
|
|
2601
|
+
* Get session messages
|
|
2602
|
+
* @example ocxp.session.getMessages('session-id')
|
|
2603
|
+
*/
|
|
2604
|
+
async getMessages(sessionId) {
|
|
2605
|
+
return this.client.getSessionMessages(sessionId);
|
|
2606
|
+
}
|
|
2607
|
+
/**
|
|
2608
|
+
* Update session metadata
|
|
2609
|
+
*/
|
|
2610
|
+
async updateMetadata(sessionId, data) {
|
|
2611
|
+
return this.client.updateSessionMetadata(sessionId, data);
|
|
2612
|
+
}
|
|
2613
|
+
/**
|
|
2614
|
+
* Fork a session
|
|
2615
|
+
*/
|
|
2616
|
+
async fork(sessionId, missionId, forkPoint) {
|
|
2617
|
+
return this.client.forkSession(sessionId, missionId, forkPoint);
|
|
2618
|
+
}
|
|
2619
|
+
/**
|
|
2620
|
+
* Archive a session
|
|
2621
|
+
*/
|
|
2622
|
+
async archive(sessionId) {
|
|
2623
|
+
return this.client.archiveSession(sessionId);
|
|
2624
|
+
}
|
|
2625
|
+
};
|
|
2626
|
+
var KBNamespace = class {
|
|
2627
|
+
constructor(client2) {
|
|
2628
|
+
this.client = client2;
|
|
2629
|
+
}
|
|
2630
|
+
/**
|
|
2631
|
+
* Query the knowledge base with optional filtering and external docs fallback
|
|
2632
|
+
* @example ocxp.kb.query('search term', { searchType: 'HYBRID', maxResults: 10 })
|
|
2633
|
+
* @example ocxp.kb.query('authentication', { projectId: 'my-project', missionId: 'CTX-123' })
|
|
2634
|
+
* @example ocxp.kb.query('strands agent', { enableFallback: true, persistExternalDocs: true })
|
|
2635
|
+
*/
|
|
2636
|
+
async query(query, options) {
|
|
2637
|
+
return this.client.kbQuery(query, options);
|
|
2638
|
+
}
|
|
2639
|
+
/**
|
|
2640
|
+
* RAG query with LLM response and citations
|
|
2641
|
+
* @example ocxp.kb.rag('What is OCXP?')
|
|
2642
|
+
*/
|
|
2643
|
+
async rag(query, sessionId) {
|
|
2644
|
+
return this.client.kbRag(query, sessionId);
|
|
2645
|
+
}
|
|
2646
|
+
};
|
|
2647
|
+
function createOCXPClient(options) {
|
|
2648
|
+
return new OCXPClient(options);
|
|
2649
|
+
}
|
|
2650
|
+
|
|
2651
|
+
// src/path.ts
|
|
2652
|
+
var VALID_CONTENT_TYPES = [
|
|
2653
|
+
"mission",
|
|
2654
|
+
"project",
|
|
2655
|
+
"context",
|
|
2656
|
+
"sop",
|
|
2657
|
+
"repo",
|
|
2658
|
+
"artifact",
|
|
2659
|
+
"kb",
|
|
2660
|
+
"docs"
|
|
2661
|
+
];
|
|
2662
|
+
var TYPE_ALIASES = {
|
|
2663
|
+
mission: "mission",
|
|
2664
|
+
missions: "mission",
|
|
2665
|
+
project: "project",
|
|
2666
|
+
projects: "project",
|
|
2667
|
+
context: "context",
|
|
2668
|
+
contexts: "context",
|
|
2669
|
+
sop: "sop",
|
|
2670
|
+
sops: "sop",
|
|
2671
|
+
repo: "repo",
|
|
2672
|
+
repos: "repo",
|
|
2673
|
+
artifact: "artifact",
|
|
2674
|
+
artifacts: "artifact",
|
|
2675
|
+
kb: "kb",
|
|
2676
|
+
kbs: "kb",
|
|
2677
|
+
docs: "docs"
|
|
2678
|
+
};
|
|
2679
|
+
function parsePath(path) {
|
|
2680
|
+
const normalized = path.replace(/^\/+/, "").replace(/\/+$/, "");
|
|
2681
|
+
const parts = normalized.split("/");
|
|
2682
|
+
if (parts.length === 0 || !parts[0]) {
|
|
2683
|
+
throw new Error(`Invalid path: ${path}`);
|
|
2684
|
+
}
|
|
2685
|
+
const typeKey = parts[0].toLowerCase();
|
|
2686
|
+
const type = TYPE_ALIASES[typeKey];
|
|
2687
|
+
if (!type) {
|
|
2688
|
+
throw new Error(
|
|
2689
|
+
`Invalid content type: ${parts[0]}. Valid types: ${VALID_CONTENT_TYPES.join(", ")}`
|
|
2690
|
+
);
|
|
2691
|
+
}
|
|
2692
|
+
const id = parts.length > 1 ? parts.slice(1).join("/") : void 0;
|
|
2693
|
+
return { type, id };
|
|
2694
|
+
}
|
|
2695
|
+
function normalizePath(path) {
|
|
2696
|
+
return path.replace(/^missions\//, "mission/").replace(/^projects\//, "project/").replace(/^contexts\//, "context/").replace(/^sops\//, "sop/").replace(/^repos\//, "repo/").replace(/^artifacts\//, "artifact/").replace(/^kbs\//, "kb/");
|
|
2697
|
+
}
|
|
2698
|
+
function isValidContentType(type) {
|
|
2699
|
+
return VALID_CONTENT_TYPES.includes(type);
|
|
2700
|
+
}
|
|
2701
|
+
function getCanonicalType(type) {
|
|
2702
|
+
return TYPE_ALIASES[type.toLowerCase()];
|
|
2703
|
+
}
|
|
2704
|
+
function buildPath(type, id) {
|
|
2705
|
+
if (id) {
|
|
2706
|
+
return `${type}/${id}`;
|
|
2707
|
+
}
|
|
2708
|
+
return `${type}/`;
|
|
2709
|
+
}
|
|
2710
|
+
|
|
2711
|
+
// src/path-service.ts
|
|
2712
|
+
var OCXPPathService = class {
|
|
2713
|
+
client;
|
|
2714
|
+
endpoint;
|
|
2715
|
+
workspace;
|
|
2716
|
+
constructor(options) {
|
|
2717
|
+
this.endpoint = options.endpoint;
|
|
2718
|
+
this.workspace = options.workspace || "dev";
|
|
2719
|
+
this.client = new OCXPClient({
|
|
2720
|
+
endpoint: options.endpoint,
|
|
2721
|
+
workspace: this.workspace,
|
|
2722
|
+
token: options.token
|
|
2723
|
+
});
|
|
2724
|
+
}
|
|
2725
|
+
// ===========================================================================
|
|
2726
|
+
// Read Operations
|
|
2727
|
+
// ===========================================================================
|
|
2728
|
+
/**
|
|
2729
|
+
* List directory contents
|
|
2730
|
+
*
|
|
2731
|
+
* @param path - Path like 'mission/' or 'project/'
|
|
2732
|
+
* @param limit - Maximum entries to return
|
|
2733
|
+
* @returns List result with entries
|
|
2734
|
+
*/
|
|
2735
|
+
async list(path, limit) {
|
|
2736
|
+
const { type, id } = parsePath(path);
|
|
2737
|
+
const result = await this.client.list(type, id, limit);
|
|
2738
|
+
return {
|
|
2739
|
+
path,
|
|
2740
|
+
entries: result.entries.map(
|
|
2741
|
+
(entry) => ({
|
|
2742
|
+
name: entry.name ?? "",
|
|
2743
|
+
path: normalizePath(entry.path ?? ""),
|
|
2744
|
+
type: entry.type ?? "file",
|
|
2745
|
+
size: entry.size,
|
|
2746
|
+
mtime: entry.mtime
|
|
2747
|
+
})
|
|
2748
|
+
),
|
|
2749
|
+
cursor: result.cursor,
|
|
2750
|
+
hasMore: result.hasMore,
|
|
2751
|
+
total: result.total
|
|
2752
|
+
};
|
|
2753
|
+
}
|
|
2754
|
+
/**
|
|
2755
|
+
* Read file content
|
|
2756
|
+
*
|
|
2757
|
+
* @param path - Path like 'mission/CTX-123/PHASES.md'
|
|
2758
|
+
* @returns Read result with content
|
|
2759
|
+
*/
|
|
2760
|
+
async read(path) {
|
|
2761
|
+
const { type, id } = parsePath(path);
|
|
2762
|
+
if (!id) {
|
|
2763
|
+
throw new Error(`Cannot read directory path: ${path}`);
|
|
2764
|
+
}
|
|
2765
|
+
const result = await this.client.read(type, id);
|
|
2766
|
+
return {
|
|
2767
|
+
path,
|
|
2768
|
+
type: "text",
|
|
2769
|
+
content: result.content,
|
|
2770
|
+
encoding: result.encoding ?? "utf-8",
|
|
2771
|
+
info: {
|
|
2772
|
+
path,
|
|
2773
|
+
size: result.size,
|
|
2774
|
+
mtime: result.mtime
|
|
2775
|
+
}
|
|
2776
|
+
};
|
|
2777
|
+
}
|
|
2778
|
+
/**
|
|
2779
|
+
* Check if path exists
|
|
2780
|
+
*
|
|
2781
|
+
* @param path - Path to check
|
|
2782
|
+
* @returns true if exists
|
|
2783
|
+
*/
|
|
2784
|
+
async exists(path) {
|
|
2785
|
+
try {
|
|
2786
|
+
const { type, id } = parsePath(path);
|
|
2787
|
+
if (!id) {
|
|
2788
|
+
await this.client.list(type);
|
|
2789
|
+
return true;
|
|
2790
|
+
}
|
|
2791
|
+
await this.client.read(type, id);
|
|
2792
|
+
return true;
|
|
2793
|
+
} catch {
|
|
2794
|
+
return false;
|
|
2795
|
+
}
|
|
2796
|
+
}
|
|
2797
|
+
/**
|
|
2798
|
+
* Get file metadata
|
|
2799
|
+
*
|
|
2800
|
+
* @param path - Path to get info for
|
|
2801
|
+
* @returns File info
|
|
2802
|
+
*/
|
|
2803
|
+
async info(path) {
|
|
2804
|
+
const { type, id } = parsePath(path);
|
|
2805
|
+
const result = await this.client.stats(type, id);
|
|
2806
|
+
const data = result?.data || {};
|
|
2807
|
+
return {
|
|
2808
|
+
path,
|
|
2809
|
+
size: data.size,
|
|
2810
|
+
mtime: data.mtime,
|
|
2811
|
+
hash: data.hash,
|
|
2812
|
+
contentType: data.contentType
|
|
2813
|
+
};
|
|
2814
|
+
}
|
|
2815
|
+
// ===========================================================================
|
|
2816
|
+
// Write Operations
|
|
2817
|
+
// ===========================================================================
|
|
2818
|
+
/**
|
|
2819
|
+
* Write/update file content
|
|
2820
|
+
*
|
|
2821
|
+
* @param path - Path like 'mission/CTX-123/PHASES.md'
|
|
2822
|
+
* @param content - File content
|
|
2823
|
+
* @param options - Write options
|
|
2824
|
+
* @returns Write result
|
|
2825
|
+
*/
|
|
2826
|
+
async write(path, content, options) {
|
|
2827
|
+
const { type, id } = parsePath(path);
|
|
2828
|
+
if (!id) {
|
|
2829
|
+
throw new Error(`Cannot write to directory path: ${path}`);
|
|
2830
|
+
}
|
|
2831
|
+
await this.client.write(type, id, content, {
|
|
2832
|
+
encoding: options?.encoding,
|
|
2833
|
+
ifNotExists: options?.ifNotExists,
|
|
2834
|
+
etag: options?.etag
|
|
2835
|
+
});
|
|
2836
|
+
return {
|
|
2837
|
+
success: true,
|
|
2838
|
+
path
|
|
2839
|
+
};
|
|
2840
|
+
}
|
|
2841
|
+
/**
|
|
2842
|
+
* Delete a file
|
|
2843
|
+
*
|
|
2844
|
+
* @param path - Path like 'mission/CTX-123/PHASES.md'
|
|
2845
|
+
* @returns Write result
|
|
2846
|
+
*/
|
|
2847
|
+
async delete(path) {
|
|
2848
|
+
const { type, id } = parsePath(path);
|
|
2849
|
+
if (!id) {
|
|
2850
|
+
throw new Error(`Cannot delete directory path without id: ${path}`);
|
|
2851
|
+
}
|
|
2852
|
+
await this.client.delete(type, id);
|
|
2853
|
+
return {
|
|
2854
|
+
success: true,
|
|
2855
|
+
path
|
|
2856
|
+
};
|
|
2857
|
+
}
|
|
2858
|
+
/**
|
|
2859
|
+
* Move/rename a file
|
|
2860
|
+
*
|
|
2861
|
+
* Implemented as read + write + delete
|
|
2862
|
+
*
|
|
2863
|
+
* @param sourcePath - Source path
|
|
2864
|
+
* @param destPath - Destination path
|
|
2865
|
+
* @returns Move result
|
|
2866
|
+
*/
|
|
2867
|
+
async move(sourcePath, destPath) {
|
|
2868
|
+
const content = await this.read(sourcePath);
|
|
2869
|
+
await this.write(destPath, content.content);
|
|
2870
|
+
await this.delete(sourcePath);
|
|
2871
|
+
return {
|
|
2872
|
+
success: true,
|
|
2873
|
+
sourcePath,
|
|
2874
|
+
destPath
|
|
2875
|
+
};
|
|
2876
|
+
}
|
|
2877
|
+
// ===========================================================================
|
|
2878
|
+
// Utility Methods
|
|
2879
|
+
// ===========================================================================
|
|
2880
|
+
/**
|
|
2881
|
+
* Get the underlying OCXPClient
|
|
2882
|
+
*/
|
|
2883
|
+
getClient() {
|
|
2884
|
+
return this.client;
|
|
2885
|
+
}
|
|
2886
|
+
/**
|
|
2887
|
+
* Get the API endpoint
|
|
2888
|
+
*/
|
|
2889
|
+
getEndpoint() {
|
|
2890
|
+
return this.endpoint;
|
|
2891
|
+
}
|
|
2892
|
+
/**
|
|
2893
|
+
* Get the workspace ID
|
|
2894
|
+
*/
|
|
2895
|
+
getWorkspace() {
|
|
2896
|
+
return this.workspace;
|
|
2897
|
+
}
|
|
2898
|
+
/**
|
|
2899
|
+
* Update the workspace
|
|
2900
|
+
*/
|
|
2901
|
+
setWorkspace(workspace) {
|
|
2902
|
+
this.client.setWorkspace(workspace);
|
|
2903
|
+
}
|
|
2904
|
+
/**
|
|
2905
|
+
* Update the auth token
|
|
2906
|
+
*/
|
|
2907
|
+
setToken(token) {
|
|
2908
|
+
this.client.setToken(token);
|
|
2909
|
+
}
|
|
2910
|
+
};
|
|
2911
|
+
function createPathService(options) {
|
|
2912
|
+
return new OCXPPathService(options);
|
|
2913
|
+
}
|
|
2914
|
+
|
|
2915
|
+
// src/websocket.ts
|
|
2916
|
+
var WebSocketService = class {
|
|
2917
|
+
constructor(options) {
|
|
2918
|
+
this.options = options;
|
|
2919
|
+
}
|
|
2920
|
+
ws = null;
|
|
2921
|
+
reconnectAttempts = 0;
|
|
2922
|
+
reconnectTimeout = null;
|
|
2923
|
+
eventHandlers = /* @__PURE__ */ new Map();
|
|
2924
|
+
connectionStateHandlers = /* @__PURE__ */ new Set();
|
|
2925
|
+
connectionPromise = null;
|
|
2926
|
+
_connectionState = "disconnected";
|
|
2927
|
+
shouldReconnect = true;
|
|
2928
|
+
/**
|
|
2929
|
+
* Get current connection state
|
|
2930
|
+
*/
|
|
2931
|
+
get connectionState() {
|
|
2932
|
+
return this._connectionState;
|
|
2933
|
+
}
|
|
2934
|
+
/**
|
|
2935
|
+
* Check if connected
|
|
2936
|
+
*/
|
|
2937
|
+
get connected() {
|
|
2938
|
+
return this.ws?.readyState === WebSocket.OPEN;
|
|
2939
|
+
}
|
|
2940
|
+
/**
|
|
2941
|
+
* Connect to WebSocket server
|
|
2942
|
+
*/
|
|
2943
|
+
async connect() {
|
|
2944
|
+
if (this.connectionPromise) return this.connectionPromise;
|
|
2945
|
+
if (this.connected) return Promise.resolve();
|
|
2946
|
+
this.shouldReconnect = true;
|
|
2947
|
+
this.connectionPromise = this.doConnect();
|
|
2948
|
+
return this.connectionPromise;
|
|
2949
|
+
}
|
|
2950
|
+
setConnectionState(state) {
|
|
2951
|
+
this._connectionState = state;
|
|
2952
|
+
this.connectionStateHandlers.forEach((handler) => handler(state));
|
|
2953
|
+
}
|
|
2954
|
+
async doConnect() {
|
|
2955
|
+
this.setConnectionState("connecting");
|
|
2956
|
+
const token = typeof this.options.token === "function" ? await this.options.token() : this.options.token;
|
|
2957
|
+
const params = new URLSearchParams({
|
|
2958
|
+
workspace: this.options.workspace
|
|
2959
|
+
});
|
|
2960
|
+
if (this.options.userId) {
|
|
2961
|
+
params.set("user_id", this.options.userId);
|
|
2962
|
+
}
|
|
2963
|
+
if (token) {
|
|
2964
|
+
params.set("token", token);
|
|
2965
|
+
}
|
|
2966
|
+
const url = `${this.options.endpoint}?${params}`;
|
|
2967
|
+
return new Promise((resolve, reject) => {
|
|
2968
|
+
const timeout = setTimeout(() => {
|
|
2969
|
+
this.ws?.close();
|
|
2970
|
+
reject(new Error("WebSocket connection timeout"));
|
|
2971
|
+
}, this.options.connectionTimeoutMs ?? 1e4);
|
|
2972
|
+
try {
|
|
2973
|
+
this.ws = new WebSocket(url);
|
|
2974
|
+
} catch (error) {
|
|
2975
|
+
clearTimeout(timeout);
|
|
2976
|
+
this.connectionPromise = null;
|
|
2977
|
+
this.setConnectionState("disconnected");
|
|
2978
|
+
reject(error instanceof Error ? error : new Error(String(error)));
|
|
2979
|
+
return;
|
|
2980
|
+
}
|
|
2981
|
+
this.ws.onopen = () => {
|
|
2982
|
+
clearTimeout(timeout);
|
|
2983
|
+
this.reconnectAttempts = 0;
|
|
2984
|
+
this.setConnectionState("connected");
|
|
2985
|
+
resolve();
|
|
2986
|
+
};
|
|
2987
|
+
this.ws.onmessage = (event) => {
|
|
2988
|
+
try {
|
|
2989
|
+
const message = JSON.parse(event.data);
|
|
2990
|
+
this.dispatchMessage(message);
|
|
2991
|
+
} catch {
|
|
2992
|
+
}
|
|
2993
|
+
};
|
|
2994
|
+
this.ws.onclose = (event) => {
|
|
2995
|
+
clearTimeout(timeout);
|
|
2996
|
+
this.connectionPromise = null;
|
|
2997
|
+
if (this.shouldReconnect && event.code !== 1e3) {
|
|
2998
|
+
this.setConnectionState("reconnecting");
|
|
2999
|
+
this.handleReconnect();
|
|
3000
|
+
} else {
|
|
3001
|
+
this.setConnectionState("disconnected");
|
|
3002
|
+
}
|
|
3003
|
+
};
|
|
3004
|
+
this.ws.onerror = () => {
|
|
3005
|
+
clearTimeout(timeout);
|
|
3006
|
+
this.connectionPromise = null;
|
|
3007
|
+
reject(new Error("WebSocket connection failed"));
|
|
3008
|
+
};
|
|
3009
|
+
});
|
|
3010
|
+
}
|
|
3011
|
+
handleReconnect() {
|
|
3012
|
+
if (!this.shouldReconnect) return;
|
|
3013
|
+
const maxAttempts = this.options.maxReconnectAttempts ?? 5;
|
|
3014
|
+
if (this.reconnectAttempts >= maxAttempts) {
|
|
3015
|
+
this.setConnectionState("disconnected");
|
|
3016
|
+
return;
|
|
3017
|
+
}
|
|
3018
|
+
const delay = (this.options.reconnectDelayMs ?? 1e3) * Math.pow(2, this.reconnectAttempts);
|
|
3019
|
+
this.reconnectAttempts++;
|
|
3020
|
+
this.reconnectTimeout = setTimeout(() => {
|
|
3021
|
+
this.connect().catch(() => {
|
|
3022
|
+
});
|
|
3023
|
+
}, delay);
|
|
3024
|
+
}
|
|
3025
|
+
dispatchMessage(message) {
|
|
3026
|
+
const handlers = this.eventHandlers.get(message.type);
|
|
3027
|
+
handlers?.forEach((handler) => handler(message));
|
|
3028
|
+
const wildcardHandlers = this.eventHandlers.get("*");
|
|
3029
|
+
wildcardHandlers?.forEach((handler) => handler(message));
|
|
3030
|
+
}
|
|
3031
|
+
/**
|
|
3032
|
+
* Subscribe to message types
|
|
3033
|
+
* @returns Unsubscribe function
|
|
3034
|
+
*/
|
|
3035
|
+
on(type, handler) {
|
|
3036
|
+
if (!this.eventHandlers.has(type)) {
|
|
3037
|
+
this.eventHandlers.set(type, /* @__PURE__ */ new Set());
|
|
3038
|
+
}
|
|
3039
|
+
this.eventHandlers.get(type).add(handler);
|
|
3040
|
+
return () => this.eventHandlers.get(type)?.delete(handler);
|
|
3041
|
+
}
|
|
3042
|
+
/**
|
|
3043
|
+
* Subscribe to job progress updates
|
|
3044
|
+
*/
|
|
3045
|
+
onJobProgress(handler) {
|
|
3046
|
+
return this.on("job_progress", handler);
|
|
3047
|
+
}
|
|
3048
|
+
/**
|
|
3049
|
+
* Subscribe to repository status updates
|
|
3050
|
+
*/
|
|
3051
|
+
onRepoStatus(handler) {
|
|
3052
|
+
return this.on("repo_status", handler);
|
|
3053
|
+
}
|
|
3054
|
+
/**
|
|
3055
|
+
* Subscribe to notifications
|
|
3056
|
+
*/
|
|
3057
|
+
onNotification(handler) {
|
|
3058
|
+
return this.on("notification", handler);
|
|
3059
|
+
}
|
|
3060
|
+
/**
|
|
3061
|
+
* Subscribe to sync events
|
|
3062
|
+
*/
|
|
3063
|
+
onSyncEvent(handler) {
|
|
3064
|
+
return this.on("sync_event", handler);
|
|
3065
|
+
}
|
|
3066
|
+
/**
|
|
3067
|
+
* Subscribe to connection state changes
|
|
3068
|
+
*/
|
|
3069
|
+
onConnectionStateChange(handler) {
|
|
3070
|
+
this.connectionStateHandlers.add(handler);
|
|
3071
|
+
return () => this.connectionStateHandlers.delete(handler);
|
|
3072
|
+
}
|
|
3073
|
+
/**
|
|
3074
|
+
* Subscribe to specific job updates
|
|
3075
|
+
*/
|
|
3076
|
+
subscribeToJob(jobId) {
|
|
3077
|
+
this.send({ action: "subscribe", type: "job", id: jobId });
|
|
3078
|
+
}
|
|
3079
|
+
/**
|
|
3080
|
+
* Subscribe to repository updates
|
|
3081
|
+
*/
|
|
3082
|
+
subscribeToRepo(repoId) {
|
|
3083
|
+
this.send({ action: "subscribe", type: "repo", id: repoId });
|
|
3084
|
+
}
|
|
3085
|
+
/**
|
|
3086
|
+
* Send message to server
|
|
3087
|
+
*/
|
|
3088
|
+
send(data) {
|
|
3089
|
+
if (this.ws?.readyState === WebSocket.OPEN) {
|
|
3090
|
+
this.ws.send(JSON.stringify(data));
|
|
3091
|
+
}
|
|
3092
|
+
}
|
|
3093
|
+
/**
|
|
3094
|
+
* Send ping to keep connection alive
|
|
3095
|
+
*/
|
|
3096
|
+
ping() {
|
|
3097
|
+
this.send({ action: "ping" });
|
|
3098
|
+
}
|
|
3099
|
+
/**
|
|
3100
|
+
* Disconnect and cleanup
|
|
3101
|
+
*/
|
|
3102
|
+
disconnect() {
|
|
3103
|
+
this.shouldReconnect = false;
|
|
3104
|
+
if (this.reconnectTimeout) {
|
|
3105
|
+
clearTimeout(this.reconnectTimeout);
|
|
3106
|
+
this.reconnectTimeout = null;
|
|
3107
|
+
}
|
|
3108
|
+
if (this.ws) {
|
|
3109
|
+
this.ws.close(1e3, "Client disconnect");
|
|
3110
|
+
this.ws = null;
|
|
3111
|
+
}
|
|
3112
|
+
this.connectionPromise = null;
|
|
3113
|
+
this.reconnectAttempts = 0;
|
|
3114
|
+
this.setConnectionState("disconnected");
|
|
3115
|
+
}
|
|
3116
|
+
/**
|
|
3117
|
+
* Clear all event handlers
|
|
3118
|
+
*/
|
|
3119
|
+
clearHandlers() {
|
|
3120
|
+
this.eventHandlers.clear();
|
|
3121
|
+
this.connectionStateHandlers.clear();
|
|
3122
|
+
}
|
|
3123
|
+
};
|
|
3124
|
+
function createWebSocketService(options) {
|
|
3125
|
+
return new WebSocketService(options);
|
|
3126
|
+
}
|
|
3127
|
+
|
|
3128
|
+
// src/types/errors.ts
|
|
3129
|
+
var OCXPErrorCode = /* @__PURE__ */ ((OCXPErrorCode2) => {
|
|
3130
|
+
OCXPErrorCode2["NETWORK_ERROR"] = "NETWORK_ERROR";
|
|
3131
|
+
OCXPErrorCode2["VALIDATION_ERROR"] = "VALIDATION_ERROR";
|
|
3132
|
+
OCXPErrorCode2["AUTH_ERROR"] = "AUTH_ERROR";
|
|
3133
|
+
OCXPErrorCode2["NOT_FOUND"] = "NOT_FOUND";
|
|
3134
|
+
OCXPErrorCode2["RATE_LIMITED"] = "RATE_LIMITED";
|
|
3135
|
+
OCXPErrorCode2["CONFLICT"] = "CONFLICT";
|
|
3136
|
+
OCXPErrorCode2["TIMEOUT"] = "TIMEOUT";
|
|
3137
|
+
OCXPErrorCode2["SERVER_ERROR"] = "SERVER_ERROR";
|
|
3138
|
+
OCXPErrorCode2["UNKNOWN"] = "UNKNOWN";
|
|
3139
|
+
return OCXPErrorCode2;
|
|
3140
|
+
})(OCXPErrorCode || {});
|
|
3141
|
+
var OCXPError = class extends Error {
|
|
3142
|
+
/** Error code for programmatic handling */
|
|
3143
|
+
code;
|
|
3144
|
+
/** HTTP status code if applicable */
|
|
3145
|
+
statusCode;
|
|
3146
|
+
/** Additional error details */
|
|
3147
|
+
details;
|
|
3148
|
+
/** Request ID for debugging */
|
|
3149
|
+
requestId;
|
|
3150
|
+
/** Original cause of the error */
|
|
3151
|
+
cause;
|
|
3152
|
+
constructor(message, code = "UNKNOWN" /* UNKNOWN */, statusCode = 500, options) {
|
|
3153
|
+
super(message);
|
|
3154
|
+
this.name = "OCXPError";
|
|
3155
|
+
this.code = code;
|
|
3156
|
+
this.statusCode = statusCode;
|
|
3157
|
+
this.details = options?.details;
|
|
3158
|
+
this.requestId = options?.requestId;
|
|
3159
|
+
this.cause = options?.cause;
|
|
3160
|
+
if ("captureStackTrace" in Error && typeof Error.captureStackTrace === "function") {
|
|
3161
|
+
Error.captureStackTrace(this, this.constructor);
|
|
3162
|
+
}
|
|
3163
|
+
}
|
|
3164
|
+
/**
|
|
3165
|
+
* Convert error to JSON for logging/serialization
|
|
3166
|
+
*/
|
|
3167
|
+
toJSON() {
|
|
3168
|
+
return {
|
|
3169
|
+
name: this.name,
|
|
3170
|
+
message: this.message,
|
|
3171
|
+
code: this.code,
|
|
3172
|
+
statusCode: this.statusCode,
|
|
3173
|
+
details: this.details,
|
|
3174
|
+
requestId: this.requestId,
|
|
3175
|
+
stack: this.stack
|
|
3176
|
+
};
|
|
3177
|
+
}
|
|
3178
|
+
};
|
|
3179
|
+
var OCXPNetworkError = class extends OCXPError {
|
|
3180
|
+
constructor(message, options) {
|
|
3181
|
+
super(message, "NETWORK_ERROR" /* NETWORK_ERROR */, 0, options);
|
|
3182
|
+
this.name = "OCXPNetworkError";
|
|
3183
|
+
}
|
|
3184
|
+
};
|
|
3185
|
+
var OCXPValidationError = class extends OCXPError {
|
|
3186
|
+
/** Field-level validation errors */
|
|
3187
|
+
validationErrors;
|
|
3188
|
+
constructor(message, validationErrors, options) {
|
|
3189
|
+
super(message, "VALIDATION_ERROR" /* VALIDATION_ERROR */, 400, {
|
|
3190
|
+
...options,
|
|
3191
|
+
details: { ...options?.details, validationErrors }
|
|
3192
|
+
});
|
|
3193
|
+
this.name = "OCXPValidationError";
|
|
3194
|
+
this.validationErrors = validationErrors;
|
|
3195
|
+
}
|
|
3196
|
+
};
|
|
3197
|
+
var OCXPAuthError = class extends OCXPError {
|
|
3198
|
+
constructor(message, options) {
|
|
3199
|
+
super(message, "AUTH_ERROR" /* AUTH_ERROR */, 401, options);
|
|
3200
|
+
this.name = "OCXPAuthError";
|
|
3201
|
+
}
|
|
3202
|
+
};
|
|
3203
|
+
var OCXPNotFoundError = class extends OCXPError {
|
|
3204
|
+
/** The resource path that was not found */
|
|
3205
|
+
path;
|
|
3206
|
+
constructor(message, path, options) {
|
|
3207
|
+
super(message, "NOT_FOUND" /* NOT_FOUND */, 404, {
|
|
3208
|
+
...options,
|
|
3209
|
+
details: { ...options?.details, path }
|
|
3210
|
+
});
|
|
3211
|
+
this.name = "OCXPNotFoundError";
|
|
3212
|
+
this.path = path;
|
|
3213
|
+
}
|
|
3214
|
+
};
|
|
3215
|
+
var OCXPRateLimitError = class extends OCXPError {
|
|
3216
|
+
/** Seconds until rate limit resets */
|
|
3217
|
+
retryAfter;
|
|
3218
|
+
constructor(message = "Rate limit exceeded", retryAfter, options) {
|
|
3219
|
+
super(message, "RATE_LIMITED" /* RATE_LIMITED */, 429, {
|
|
3220
|
+
...options,
|
|
3221
|
+
details: { ...options?.details, retryAfter }
|
|
3222
|
+
});
|
|
3223
|
+
this.name = "OCXPRateLimitError";
|
|
3224
|
+
this.retryAfter = retryAfter;
|
|
3225
|
+
}
|
|
3226
|
+
};
|
|
3227
|
+
var OCXPConflictError = class extends OCXPError {
|
|
3228
|
+
/** Expected etag value */
|
|
3229
|
+
expectedEtag;
|
|
3230
|
+
/** Actual etag value */
|
|
3231
|
+
actualEtag;
|
|
3232
|
+
constructor(message, options) {
|
|
3233
|
+
super(message, "CONFLICT" /* CONFLICT */, 409, {
|
|
3234
|
+
details: {
|
|
3235
|
+
...options?.details,
|
|
3236
|
+
expectedEtag: options?.expectedEtag,
|
|
3237
|
+
actualEtag: options?.actualEtag
|
|
3238
|
+
},
|
|
3239
|
+
requestId: options?.requestId,
|
|
3240
|
+
cause: options?.cause
|
|
3241
|
+
});
|
|
3242
|
+
this.name = "OCXPConflictError";
|
|
3243
|
+
this.expectedEtag = options?.expectedEtag;
|
|
3244
|
+
this.actualEtag = options?.actualEtag;
|
|
3245
|
+
}
|
|
3246
|
+
};
|
|
3247
|
+
var OCXPTimeoutError = class extends OCXPError {
|
|
3248
|
+
/** Timeout duration in milliseconds */
|
|
3249
|
+
timeoutMs;
|
|
3250
|
+
constructor(message = "Operation timed out", timeoutMs, options) {
|
|
3251
|
+
super(message, "TIMEOUT" /* TIMEOUT */, 408, {
|
|
3252
|
+
...options,
|
|
3253
|
+
details: { ...options?.details, timeoutMs }
|
|
3254
|
+
});
|
|
3255
|
+
this.name = "OCXPTimeoutError";
|
|
3256
|
+
this.timeoutMs = timeoutMs;
|
|
3257
|
+
}
|
|
3258
|
+
};
|
|
3259
|
+
function isOCXPError(error) {
|
|
3260
|
+
return error instanceof OCXPError;
|
|
3261
|
+
}
|
|
3262
|
+
function isOCXPNetworkError(error) {
|
|
3263
|
+
return error instanceof OCXPNetworkError;
|
|
3264
|
+
}
|
|
3265
|
+
function isOCXPValidationError(error) {
|
|
3266
|
+
return error instanceof OCXPValidationError;
|
|
3267
|
+
}
|
|
3268
|
+
function isOCXPAuthError(error) {
|
|
3269
|
+
return error instanceof OCXPAuthError;
|
|
3270
|
+
}
|
|
3271
|
+
function isOCXPNotFoundError(error) {
|
|
3272
|
+
return error instanceof OCXPNotFoundError;
|
|
3273
|
+
}
|
|
3274
|
+
function isOCXPRateLimitError(error) {
|
|
3275
|
+
return error instanceof OCXPRateLimitError;
|
|
3276
|
+
}
|
|
3277
|
+
function isOCXPConflictError(error) {
|
|
3278
|
+
return error instanceof OCXPConflictError;
|
|
3279
|
+
}
|
|
3280
|
+
function isOCXPTimeoutError(error) {
|
|
3281
|
+
return error instanceof OCXPTimeoutError;
|
|
3282
|
+
}
|
|
3283
|
+
function mapHttpError(statusCode, message, options) {
|
|
3284
|
+
const baseOptions = {
|
|
3285
|
+
details: options?.details,
|
|
3286
|
+
requestId: options?.requestId
|
|
3287
|
+
};
|
|
3288
|
+
switch (statusCode) {
|
|
3289
|
+
case 400:
|
|
3290
|
+
return new OCXPValidationError(message, void 0, baseOptions);
|
|
3291
|
+
case 401:
|
|
3292
|
+
case 403:
|
|
3293
|
+
return new OCXPAuthError(message, baseOptions);
|
|
3294
|
+
case 404:
|
|
3295
|
+
return new OCXPNotFoundError(message, options?.path, baseOptions);
|
|
3296
|
+
case 408:
|
|
3297
|
+
return new OCXPTimeoutError(message, void 0, baseOptions);
|
|
3298
|
+
case 409:
|
|
3299
|
+
return new OCXPConflictError(message, baseOptions);
|
|
3300
|
+
case 429:
|
|
3301
|
+
return new OCXPRateLimitError(message, options?.retryAfter, baseOptions);
|
|
3302
|
+
default:
|
|
3303
|
+
if (statusCode >= 500) {
|
|
3304
|
+
return new OCXPError(message, "SERVER_ERROR" /* SERVER_ERROR */, statusCode, baseOptions);
|
|
3305
|
+
}
|
|
3306
|
+
return new OCXPError(message, "UNKNOWN" /* UNKNOWN */, statusCode, baseOptions);
|
|
3307
|
+
}
|
|
3308
|
+
}
|
|
3309
|
+
var MetaSchema = zod.z.object({
|
|
3310
|
+
requestId: zod.z.string(),
|
|
3311
|
+
timestamp: zod.z.string(),
|
|
3312
|
+
durationMs: zod.z.number(),
|
|
3313
|
+
operation: zod.z.string()
|
|
3314
|
+
});
|
|
3315
|
+
var ErrorResponseSchema = zod.z.object({
|
|
3316
|
+
code: zod.z.string(),
|
|
3317
|
+
message: zod.z.string(),
|
|
3318
|
+
details: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
3319
|
+
});
|
|
3320
|
+
var OCXPResponseSchema = zod.z.object({
|
|
3321
|
+
success: zod.z.boolean(),
|
|
3322
|
+
data: zod.z.unknown().optional(),
|
|
3323
|
+
error: ErrorResponseSchema.nullable().optional(),
|
|
3324
|
+
notifications: zod.z.array(zod.z.unknown()).optional(),
|
|
3325
|
+
meta: MetaSchema.optional()
|
|
3326
|
+
});
|
|
3327
|
+
var PaginationSchema = zod.z.object({
|
|
3328
|
+
cursor: zod.z.string().nullable().optional(),
|
|
3329
|
+
hasMore: zod.z.boolean(),
|
|
3330
|
+
total: zod.z.number()
|
|
3331
|
+
});
|
|
3332
|
+
var ContentTypeSchema = zod.z.enum([
|
|
3333
|
+
"mission",
|
|
3334
|
+
"project",
|
|
3335
|
+
"context",
|
|
3336
|
+
"sop",
|
|
3337
|
+
"repo",
|
|
3338
|
+
"artifact",
|
|
3339
|
+
"kb",
|
|
3340
|
+
"docs"
|
|
3341
|
+
]);
|
|
3342
|
+
function createResponseSchema(dataSchema) {
|
|
3343
|
+
return zod.z.object({
|
|
3344
|
+
success: zod.z.boolean(),
|
|
3345
|
+
data: dataSchema.optional(),
|
|
3346
|
+
error: ErrorResponseSchema.nullable().optional(),
|
|
3347
|
+
notifications: zod.z.array(zod.z.unknown()).optional(),
|
|
3348
|
+
meta: MetaSchema.optional()
|
|
3349
|
+
});
|
|
3350
|
+
}
|
|
3351
|
+
var ListEntrySchema = zod.z.object({
|
|
3352
|
+
name: zod.z.string(),
|
|
3353
|
+
type: zod.z.enum(["file", "directory"]),
|
|
3354
|
+
path: zod.z.string(),
|
|
3355
|
+
size: zod.z.number().optional(),
|
|
3356
|
+
mtime: zod.z.string().optional()
|
|
3357
|
+
});
|
|
3358
|
+
var ListDataSchema = zod.z.object({
|
|
3359
|
+
entries: zod.z.array(ListEntrySchema),
|
|
3360
|
+
cursor: zod.z.string().nullable().optional(),
|
|
3361
|
+
hasMore: zod.z.boolean().optional().default(false),
|
|
3362
|
+
total: zod.z.number().optional().default(0)
|
|
3363
|
+
});
|
|
3364
|
+
var ListResponseSchema = createResponseSchema(ListDataSchema);
|
|
3365
|
+
var ReadDataSchema = zod.z.object({
|
|
3366
|
+
content: zod.z.string(),
|
|
3367
|
+
size: zod.z.number().optional(),
|
|
3368
|
+
mtime: zod.z.string().optional(),
|
|
3369
|
+
encoding: zod.z.string().optional(),
|
|
3370
|
+
metadata: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
3371
|
+
etag: zod.z.string().optional()
|
|
3372
|
+
});
|
|
3373
|
+
var ReadResponseSchema = createResponseSchema(ReadDataSchema);
|
|
3374
|
+
var WriteDataSchema = zod.z.object({
|
|
3375
|
+
path: zod.z.string(),
|
|
3376
|
+
etag: zod.z.string().optional(),
|
|
3377
|
+
size: zod.z.number().optional()
|
|
3378
|
+
});
|
|
3379
|
+
var WriteResponseSchema = createResponseSchema(WriteDataSchema);
|
|
3380
|
+
var DeleteDataSchema = zod.z.object({
|
|
3381
|
+
path: zod.z.string(),
|
|
3382
|
+
deleted: zod.z.boolean().optional().default(true)
|
|
3383
|
+
});
|
|
3384
|
+
var DeleteResponseSchema = createResponseSchema(DeleteDataSchema);
|
|
3385
|
+
var QueryFilterSchema = zod.z.object({
|
|
3386
|
+
field: zod.z.string(),
|
|
3387
|
+
operator: zod.z.enum(["eq", "ne", "gt", "lt", "gte", "lte", "contains", "startsWith"]),
|
|
3388
|
+
value: zod.z.unknown()
|
|
3389
|
+
});
|
|
3390
|
+
var QueryDataSchema = zod.z.object({
|
|
3391
|
+
items: zod.z.array(zod.z.record(zod.z.string(), zod.z.unknown())),
|
|
3392
|
+
cursor: zod.z.string().nullable().optional(),
|
|
3393
|
+
hasMore: zod.z.boolean().optional().default(false),
|
|
3394
|
+
total: zod.z.number().optional().default(0)
|
|
3395
|
+
});
|
|
3396
|
+
var QueryResponseSchema = createResponseSchema(QueryDataSchema);
|
|
3397
|
+
var SearchDataSchema = zod.z.object({
|
|
3398
|
+
results: zod.z.array(
|
|
3399
|
+
zod.z.object({
|
|
3400
|
+
path: zod.z.string(),
|
|
3401
|
+
score: zod.z.number().optional(),
|
|
3402
|
+
highlights: zod.z.array(zod.z.string()).optional(),
|
|
3403
|
+
content: zod.z.string().optional()
|
|
3404
|
+
})
|
|
3405
|
+
),
|
|
3406
|
+
total: zod.z.number().optional().default(0)
|
|
3407
|
+
});
|
|
3408
|
+
var SearchResponseSchema = createResponseSchema(SearchDataSchema);
|
|
3409
|
+
var TreeNodeSchema = zod.z.lazy(
|
|
3410
|
+
() => zod.z.object({
|
|
3411
|
+
name: zod.z.string(),
|
|
3412
|
+
path: zod.z.string(),
|
|
3413
|
+
type: zod.z.enum(["file", "directory"]),
|
|
3414
|
+
size: zod.z.number().optional(),
|
|
3415
|
+
children: zod.z.array(TreeNodeSchema).optional()
|
|
3416
|
+
})
|
|
3417
|
+
);
|
|
3418
|
+
var TreeDataSchema = zod.z.object({
|
|
3419
|
+
root: TreeNodeSchema,
|
|
3420
|
+
depth: zod.z.number().optional()
|
|
3421
|
+
});
|
|
3422
|
+
var TreeResponseSchema = createResponseSchema(TreeDataSchema);
|
|
3423
|
+
var StatsDataSchema = zod.z.object({
|
|
3424
|
+
totalFiles: zod.z.number(),
|
|
3425
|
+
totalSize: zod.z.number(),
|
|
3426
|
+
lastModified: zod.z.string().optional(),
|
|
3427
|
+
fileTypes: zod.z.record(zod.z.string(), zod.z.number()).optional()
|
|
3428
|
+
});
|
|
3429
|
+
var StatsResponseSchema = createResponseSchema(StatsDataSchema);
|
|
3430
|
+
var ContentTypeInfoSchema = zod.z.object({
|
|
3431
|
+
name: zod.z.string(),
|
|
3432
|
+
description: zod.z.string().optional(),
|
|
3433
|
+
prefix: zod.z.string().nullable().optional(),
|
|
3434
|
+
isVirtual: zod.z.boolean().optional(),
|
|
3435
|
+
isGlobal: zod.z.boolean().optional(),
|
|
3436
|
+
count: zod.z.number().nullable().optional(),
|
|
3437
|
+
endpoints: zod.z.record(zod.z.string(), zod.z.string()).optional()
|
|
3438
|
+
});
|
|
3439
|
+
var ContentTypesDataSchema = zod.z.object({
|
|
3440
|
+
types: zod.z.array(ContentTypeInfoSchema)
|
|
3441
|
+
});
|
|
3442
|
+
var ContentTypesResponseSchema = createResponseSchema(ContentTypesDataSchema);
|
|
3443
|
+
var PresignedUrlDataSchema = zod.z.object({
|
|
3444
|
+
url: zod.z.string(),
|
|
3445
|
+
expiresAt: zod.z.string().optional(),
|
|
3446
|
+
method: zod.z.enum(["GET", "PUT"]).optional()
|
|
3447
|
+
});
|
|
3448
|
+
var PresignedUrlResponseSchema = createResponseSchema(PresignedUrlDataSchema);
|
|
3449
|
+
var SessionMessageSchema = zod.z.object({
|
|
3450
|
+
id: zod.z.string(),
|
|
3451
|
+
role: zod.z.enum(["user", "assistant", "system"]),
|
|
3452
|
+
content: zod.z.string(),
|
|
3453
|
+
timestamp: zod.z.string(),
|
|
3454
|
+
metadata: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
3455
|
+
});
|
|
3456
|
+
var SessionSchema = zod.z.object({
|
|
3457
|
+
id: zod.z.string(),
|
|
3458
|
+
missionId: zod.z.string().optional(),
|
|
3459
|
+
title: zod.z.string().optional(),
|
|
3460
|
+
createdAt: zod.z.string(),
|
|
3461
|
+
updatedAt: zod.z.string().optional(),
|
|
3462
|
+
metadata: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
3463
|
+
messageCount: zod.z.number().optional()
|
|
3464
|
+
});
|
|
3465
|
+
var ListSessionsDataSchema = zod.z.object({
|
|
3466
|
+
sessions: zod.z.array(SessionSchema),
|
|
3467
|
+
total: zod.z.number().optional()
|
|
3468
|
+
});
|
|
3469
|
+
var ListSessionsResponseSchema = createResponseSchema(ListSessionsDataSchema);
|
|
3470
|
+
var CreateSessionDataSchema = zod.z.object({
|
|
3471
|
+
sessionId: zod.z.string(),
|
|
3472
|
+
missionId: zod.z.string().optional()
|
|
3473
|
+
});
|
|
3474
|
+
var CreateSessionResponseSchema = createResponseSchema(CreateSessionDataSchema);
|
|
3475
|
+
var GetSessionMessagesDataSchema = zod.z.object({
|
|
3476
|
+
messages: zod.z.array(SessionMessageSchema),
|
|
3477
|
+
sessionId: zod.z.string()
|
|
3478
|
+
});
|
|
3479
|
+
var GetSessionMessagesResponseSchema = createResponseSchema(GetSessionMessagesDataSchema);
|
|
3480
|
+
var UpdateSessionMetadataDataSchema = zod.z.object({
|
|
3481
|
+
sessionId: zod.z.string(),
|
|
3482
|
+
metadata: zod.z.record(zod.z.string(), zod.z.unknown())
|
|
3483
|
+
});
|
|
3484
|
+
var UpdateSessionMetadataResponseSchema = createResponseSchema(
|
|
3485
|
+
UpdateSessionMetadataDataSchema
|
|
3486
|
+
);
|
|
3487
|
+
var ForkSessionDataSchema = zod.z.object({
|
|
3488
|
+
sessionId: zod.z.string(),
|
|
3489
|
+
forkedFromId: zod.z.string()
|
|
3490
|
+
});
|
|
3491
|
+
var ForkSessionResponseSchema = createResponseSchema(ForkSessionDataSchema);
|
|
3492
|
+
var ProjectRepoSchema = zod.z.object({
|
|
3493
|
+
repoId: zod.z.string(),
|
|
3494
|
+
isDefault: zod.z.boolean().optional(),
|
|
3495
|
+
addedAt: zod.z.string().optional()
|
|
3496
|
+
});
|
|
3497
|
+
var ProjectMissionSchema = zod.z.object({
|
|
3498
|
+
missionId: zod.z.string(),
|
|
3499
|
+
addedAt: zod.z.string().optional()
|
|
3500
|
+
});
|
|
3501
|
+
var ProjectSchema = zod.z.object({
|
|
3502
|
+
id: zod.z.string(),
|
|
3503
|
+
name: zod.z.string(),
|
|
3504
|
+
description: zod.z.string().optional(),
|
|
3505
|
+
createdAt: zod.z.string(),
|
|
3506
|
+
updatedAt: zod.z.string().optional(),
|
|
3507
|
+
repos: zod.z.array(ProjectRepoSchema).optional(),
|
|
3508
|
+
missions: zod.z.array(ProjectMissionSchema).optional(),
|
|
3509
|
+
defaultRepoId: zod.z.string().optional(),
|
|
3510
|
+
metadata: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
3511
|
+
});
|
|
3512
|
+
var ListProjectsDataSchema = zod.z.object({
|
|
3513
|
+
projects: zod.z.array(ProjectSchema),
|
|
3514
|
+
total: zod.z.number().optional()
|
|
3515
|
+
});
|
|
3516
|
+
var ListProjectsResponseSchema = createResponseSchema(ListProjectsDataSchema);
|
|
3517
|
+
var CreateProjectDataSchema = zod.z.object({
|
|
3518
|
+
projectId: zod.z.string(),
|
|
3519
|
+
project: ProjectSchema.optional()
|
|
3520
|
+
});
|
|
3521
|
+
var CreateProjectResponseSchema = createResponseSchema(CreateProjectDataSchema);
|
|
3522
|
+
var GetProjectDataSchema = ProjectSchema;
|
|
3523
|
+
var GetProjectResponseSchema = createResponseSchema(GetProjectDataSchema);
|
|
3524
|
+
var UpdateProjectDataSchema = zod.z.object({
|
|
3525
|
+
projectId: zod.z.string(),
|
|
3526
|
+
project: ProjectSchema.optional()
|
|
3527
|
+
});
|
|
3528
|
+
var UpdateProjectResponseSchema = createResponseSchema(UpdateProjectDataSchema);
|
|
3529
|
+
var DeleteProjectDataSchema = zod.z.object({
|
|
3530
|
+
projectId: zod.z.string(),
|
|
3531
|
+
deleted: zod.z.boolean()
|
|
3532
|
+
});
|
|
3533
|
+
var DeleteProjectResponseSchema = createResponseSchema(DeleteProjectDataSchema);
|
|
3534
|
+
var AddProjectRepoDataSchema = zod.z.object({
|
|
3535
|
+
projectId: zod.z.string(),
|
|
3536
|
+
repoId: zod.z.string()
|
|
3537
|
+
});
|
|
3538
|
+
var AddProjectRepoResponseSchema = createResponseSchema(AddProjectRepoDataSchema);
|
|
3539
|
+
var ContextReposDataSchema = zod.z.object({
|
|
3540
|
+
repos: zod.z.array(
|
|
3541
|
+
zod.z.object({
|
|
3542
|
+
repoId: zod.z.string(),
|
|
3543
|
+
name: zod.z.string().optional(),
|
|
3544
|
+
isDefault: zod.z.boolean().optional()
|
|
3545
|
+
})
|
|
3546
|
+
)
|
|
3547
|
+
});
|
|
3548
|
+
var ContextReposResponseSchema = createResponseSchema(ContextReposDataSchema);
|
|
3549
|
+
var RepoStatusEnum = zod.z.enum([
|
|
3550
|
+
"queued",
|
|
3551
|
+
"processing",
|
|
3552
|
+
"uploading",
|
|
3553
|
+
"vectorizing",
|
|
3554
|
+
"complete",
|
|
3555
|
+
"failed"
|
|
3556
|
+
]);
|
|
3557
|
+
var RepoDownloadRequestSchema = zod.z.object({
|
|
3558
|
+
github_url: zod.z.string(),
|
|
3559
|
+
repo_id: zod.z.string(),
|
|
3560
|
+
branch: zod.z.string().optional().default("main"),
|
|
3561
|
+
path: zod.z.string().nullable().optional(),
|
|
3562
|
+
mode: zod.z.enum(["full", "docs_only"]).optional().default("full"),
|
|
3563
|
+
include_extensions: zod.z.array(zod.z.string()).optional(),
|
|
3564
|
+
exclude_patterns: zod.z.array(zod.z.string()).optional(),
|
|
3565
|
+
max_file_size_kb: zod.z.number().min(1).max(5e3).optional().default(500),
|
|
3566
|
+
visibility: zod.z.enum(["private", "public"]).optional().default("private"),
|
|
3567
|
+
trigger_vectorization: zod.z.boolean().optional().default(true),
|
|
3568
|
+
generate_metadata: zod.z.boolean().optional().default(true),
|
|
3569
|
+
is_private: zod.z.boolean().optional().default(false)
|
|
3570
|
+
});
|
|
3571
|
+
var RepoDownloadDataSchema = zod.z.object({
|
|
3572
|
+
repo_id: zod.z.string(),
|
|
3573
|
+
job_id: zod.z.string(),
|
|
3574
|
+
s3_path: zod.z.string().optional(),
|
|
3575
|
+
status: RepoStatusEnum,
|
|
3576
|
+
files_processed: zod.z.number().optional(),
|
|
3577
|
+
metadata_files_created: zod.z.number().optional(),
|
|
3578
|
+
ingestion_job_id: zod.z.string().nullable().optional()
|
|
3579
|
+
});
|
|
3580
|
+
var RepoDownloadResponseSchema = createResponseSchema(RepoDownloadDataSchema);
|
|
3581
|
+
var RepoStatusDataSchema = zod.z.object({
|
|
3582
|
+
job_id: zod.z.string(),
|
|
3583
|
+
status: RepoStatusEnum,
|
|
3584
|
+
progress: zod.z.number().min(0).max(100).optional(),
|
|
3585
|
+
files_processed: zod.z.number().optional(),
|
|
3586
|
+
total_files: zod.z.number().optional(),
|
|
3587
|
+
error: zod.z.string().nullable().optional(),
|
|
3588
|
+
started_at: zod.z.string().nullable().optional(),
|
|
3589
|
+
completed_at: zod.z.string().nullable().optional()
|
|
3590
|
+
});
|
|
3591
|
+
var RepoStatusResponseSchema = createResponseSchema(RepoStatusDataSchema);
|
|
3592
|
+
var RepoListItemSchema = zod.z.object({
|
|
3593
|
+
repo_id: zod.z.string(),
|
|
3594
|
+
github_url: zod.z.string().optional(),
|
|
3595
|
+
branch: zod.z.string().optional(),
|
|
3596
|
+
visibility: zod.z.enum(["private", "public"]).optional(),
|
|
3597
|
+
mode: zod.z.enum(["full", "docs_only"]).optional(),
|
|
3598
|
+
files_count: zod.z.number().optional(),
|
|
3599
|
+
last_synced: zod.z.string().optional(),
|
|
3600
|
+
s3_path: zod.z.string().optional()
|
|
3601
|
+
});
|
|
3602
|
+
var RepoListDataSchema = zod.z.object({
|
|
3603
|
+
repos: zod.z.array(RepoListItemSchema),
|
|
3604
|
+
total: zod.z.number().optional()
|
|
3605
|
+
});
|
|
3606
|
+
var RepoListResponseSchema = createResponseSchema(RepoListDataSchema);
|
|
3607
|
+
var RepoExistsDataSchema = zod.z.object({
|
|
3608
|
+
repo_id: zod.z.string(),
|
|
3609
|
+
exists: zod.z.boolean(),
|
|
3610
|
+
indexed_at: zod.z.string().nullable().optional(),
|
|
3611
|
+
files_count: zod.z.number().optional()
|
|
3612
|
+
});
|
|
3613
|
+
var RepoExistsResponseSchema = createResponseSchema(RepoExistsDataSchema);
|
|
3614
|
+
var RepoDeleteDataSchema = zod.z.object({
|
|
3615
|
+
repo_id: zod.z.string(),
|
|
3616
|
+
success: zod.z.boolean(),
|
|
3617
|
+
s3_files_deleted: zod.z.number().optional(),
|
|
3618
|
+
projects_updated: zod.z.number().optional(),
|
|
3619
|
+
error: zod.z.string().optional()
|
|
3620
|
+
});
|
|
3621
|
+
var RepoDeleteResponseSchema = createResponseSchema(RepoDeleteDataSchema);
|
|
3622
|
+
var AuthTokenDataSchema = zod.z.object({
|
|
3623
|
+
accessToken: zod.z.string(),
|
|
3624
|
+
tokenType: zod.z.string().optional().default("Bearer"),
|
|
3625
|
+
expiresIn: zod.z.number().optional(),
|
|
3626
|
+
expiresAt: zod.z.string().optional(),
|
|
3627
|
+
refreshToken: zod.z.string().optional(),
|
|
3628
|
+
scope: zod.z.string().optional()
|
|
3629
|
+
});
|
|
3630
|
+
var AuthTokenResponseSchema = createResponseSchema(AuthTokenDataSchema);
|
|
3631
|
+
var AuthUserInfoSchema = zod.z.object({
|
|
3632
|
+
userId: zod.z.string(),
|
|
3633
|
+
email: zod.z.string().optional(),
|
|
3634
|
+
name: zod.z.string().optional(),
|
|
3635
|
+
roles: zod.z.array(zod.z.string()).optional(),
|
|
3636
|
+
permissions: zod.z.array(zod.z.string()).optional(),
|
|
3637
|
+
metadata: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
3638
|
+
});
|
|
3639
|
+
var AuthUserInfoResponseSchema = createResponseSchema(AuthUserInfoSchema);
|
|
3640
|
+
var AuthValidateDataSchema = zod.z.object({
|
|
3641
|
+
valid: zod.z.boolean(),
|
|
3642
|
+
userId: zod.z.string().optional(),
|
|
3643
|
+
expiresAt: zod.z.string().optional()
|
|
3644
|
+
});
|
|
3645
|
+
var AuthValidateResponseSchema = createResponseSchema(AuthValidateDataSchema);
|
|
3646
|
+
var SearchResultItemSchema = zod.z.object({
|
|
3647
|
+
id: zod.z.string(),
|
|
3648
|
+
path: zod.z.string().optional(),
|
|
3649
|
+
content: zod.z.string().optional(),
|
|
3650
|
+
score: zod.z.number().optional(),
|
|
3651
|
+
highlights: zod.z.array(zod.z.string()).optional(),
|
|
3652
|
+
metadata: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
3653
|
+
source: zod.z.string().optional(),
|
|
3654
|
+
type: zod.z.string().optional()
|
|
3655
|
+
});
|
|
3656
|
+
var VectorSearchDataSchema = zod.z.object({
|
|
3657
|
+
results: zod.z.array(SearchResultItemSchema),
|
|
3658
|
+
total: zod.z.number().optional(),
|
|
3659
|
+
query: zod.z.string().optional(),
|
|
3660
|
+
processingTimeMs: zod.z.number().optional()
|
|
3661
|
+
});
|
|
3662
|
+
var VectorSearchResponseSchema = createResponseSchema(VectorSearchDataSchema);
|
|
3663
|
+
var KBDocumentSchema = zod.z.object({
|
|
3664
|
+
id: zod.z.string(),
|
|
3665
|
+
title: zod.z.string().optional(),
|
|
3666
|
+
content: zod.z.string(),
|
|
3667
|
+
path: zod.z.string().optional(),
|
|
3668
|
+
source: zod.z.string().optional(),
|
|
3669
|
+
createdAt: zod.z.string().optional(),
|
|
3670
|
+
updatedAt: zod.z.string().optional(),
|
|
3671
|
+
metadata: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
3672
|
+
vectorId: zod.z.string().optional()
|
|
3673
|
+
});
|
|
3674
|
+
var KBListDataSchema = zod.z.object({
|
|
3675
|
+
documents: zod.z.array(KBDocumentSchema),
|
|
3676
|
+
total: zod.z.number().optional(),
|
|
3677
|
+
cursor: zod.z.string().nullable().optional(),
|
|
3678
|
+
hasMore: zod.z.boolean().optional()
|
|
3679
|
+
});
|
|
3680
|
+
var KBListResponseSchema = createResponseSchema(KBListDataSchema);
|
|
3681
|
+
var KBIngestDataSchema = zod.z.object({
|
|
3682
|
+
documentId: zod.z.string(),
|
|
3683
|
+
vectorId: zod.z.string().optional(),
|
|
3684
|
+
chunksCreated: zod.z.number().optional(),
|
|
3685
|
+
status: zod.z.enum(["pending", "processing", "complete", "failed"]).optional()
|
|
3686
|
+
});
|
|
3687
|
+
var KBIngestResponseSchema = createResponseSchema(KBIngestDataSchema);
|
|
3688
|
+
var DiscoveryEndpointSchema = zod.z.object({
|
|
3689
|
+
name: zod.z.string(),
|
|
3690
|
+
path: zod.z.string(),
|
|
3691
|
+
methods: zod.z.array(zod.z.string()),
|
|
3692
|
+
description: zod.z.string().optional(),
|
|
3693
|
+
parameters: zod.z.array(zod.z.record(zod.z.string(), zod.z.unknown())).optional()
|
|
3694
|
+
});
|
|
3695
|
+
var DiscoveryDataSchema = zod.z.object({
|
|
3696
|
+
version: zod.z.string().optional(),
|
|
3697
|
+
endpoints: zod.z.array(DiscoveryEndpointSchema),
|
|
3698
|
+
contentTypes: zod.z.array(zod.z.string()).optional(),
|
|
3699
|
+
capabilities: zod.z.array(zod.z.string()).optional()
|
|
3700
|
+
});
|
|
3701
|
+
var DiscoveryResponseSchema = createResponseSchema(DiscoveryDataSchema);
|
|
3702
|
+
var IngestionJobSchema = zod.z.object({
|
|
3703
|
+
jobId: zod.z.string(),
|
|
3704
|
+
status: zod.z.enum(["queued", "processing", "complete", "failed"]),
|
|
3705
|
+
progress: zod.z.number().min(0).max(100).optional(),
|
|
3706
|
+
documentsProcessed: zod.z.number().optional(),
|
|
3707
|
+
totalDocuments: zod.z.number().optional(),
|
|
3708
|
+
error: zod.z.string().nullable().optional(),
|
|
3709
|
+
startedAt: zod.z.string().nullable().optional(),
|
|
3710
|
+
completedAt: zod.z.string().nullable().optional()
|
|
3711
|
+
});
|
|
3712
|
+
var IngestionJobResponseSchema = createResponseSchema(IngestionJobSchema);
|
|
3713
|
+
var WSMessageTypeSchema = zod.z.enum([
|
|
3714
|
+
"chat",
|
|
3715
|
+
"chat_response",
|
|
3716
|
+
"stream_start",
|
|
3717
|
+
"stream_chunk",
|
|
3718
|
+
"stream_end",
|
|
3719
|
+
"error",
|
|
3720
|
+
"ping",
|
|
3721
|
+
"pong",
|
|
3722
|
+
"connected",
|
|
3723
|
+
"disconnected",
|
|
3724
|
+
"session_start",
|
|
3725
|
+
"session_end",
|
|
3726
|
+
"typing",
|
|
3727
|
+
"status"
|
|
3728
|
+
]);
|
|
3729
|
+
var WSBaseMessageSchema = zod.z.object({
|
|
3730
|
+
type: WSMessageTypeSchema,
|
|
3731
|
+
id: zod.z.string().optional(),
|
|
3732
|
+
timestamp: zod.z.string().optional(),
|
|
3733
|
+
sessionId: zod.z.string().optional()
|
|
3734
|
+
});
|
|
3735
|
+
var WSChatMessageSchema = WSBaseMessageSchema.extend({
|
|
3736
|
+
type: zod.z.literal("chat"),
|
|
3737
|
+
content: zod.z.string(),
|
|
3738
|
+
missionId: zod.z.string().optional(),
|
|
3739
|
+
projectId: zod.z.string().optional(),
|
|
3740
|
+
metadata: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
3741
|
+
});
|
|
3742
|
+
var WSChatResponseSchema = WSBaseMessageSchema.extend({
|
|
3743
|
+
type: zod.z.literal("chat_response"),
|
|
3744
|
+
content: zod.z.string(),
|
|
3745
|
+
role: zod.z.enum(["assistant", "system"]).optional(),
|
|
3746
|
+
metadata: zod.z.record(zod.z.string(), zod.z.unknown()).optional(),
|
|
3747
|
+
usage: zod.z.object({
|
|
3748
|
+
promptTokens: zod.z.number().optional(),
|
|
3749
|
+
completionTokens: zod.z.number().optional(),
|
|
3750
|
+
totalTokens: zod.z.number().optional()
|
|
3751
|
+
}).optional()
|
|
3752
|
+
});
|
|
3753
|
+
var WSStreamStartSchema = WSBaseMessageSchema.extend({
|
|
3754
|
+
type: zod.z.literal("stream_start"),
|
|
3755
|
+
streamId: zod.z.string()
|
|
3756
|
+
});
|
|
3757
|
+
var WSStreamChunkSchema = WSBaseMessageSchema.extend({
|
|
3758
|
+
type: zod.z.literal("stream_chunk"),
|
|
3759
|
+
streamId: zod.z.string(),
|
|
3760
|
+
content: zod.z.string(),
|
|
3761
|
+
index: zod.z.number().optional()
|
|
3762
|
+
});
|
|
3763
|
+
var WSStreamEndSchema = WSBaseMessageSchema.extend({
|
|
3764
|
+
type: zod.z.literal("stream_end"),
|
|
3765
|
+
streamId: zod.z.string(),
|
|
3766
|
+
usage: zod.z.object({
|
|
3767
|
+
promptTokens: zod.z.number().optional(),
|
|
3768
|
+
completionTokens: zod.z.number().optional(),
|
|
3769
|
+
totalTokens: zod.z.number().optional()
|
|
3770
|
+
}).optional()
|
|
3771
|
+
});
|
|
3772
|
+
var WSErrorMessageSchema = WSBaseMessageSchema.extend({
|
|
3773
|
+
type: zod.z.literal("error"),
|
|
3774
|
+
code: zod.z.string(),
|
|
3775
|
+
message: zod.z.string(),
|
|
3776
|
+
details: zod.z.record(zod.z.string(), zod.z.unknown()).optional()
|
|
3777
|
+
});
|
|
3778
|
+
var WSPingPongSchema = WSBaseMessageSchema.extend({
|
|
3779
|
+
type: zod.z.enum(["ping", "pong"])
|
|
3780
|
+
});
|
|
3781
|
+
var WSConnectedSchema = WSBaseMessageSchema.extend({
|
|
3782
|
+
type: zod.z.literal("connected"),
|
|
3783
|
+
connectionId: zod.z.string().optional(),
|
|
3784
|
+
serverVersion: zod.z.string().optional()
|
|
3785
|
+
});
|
|
3786
|
+
var WSStatusSchema = WSBaseMessageSchema.extend({
|
|
3787
|
+
type: zod.z.literal("status"),
|
|
3788
|
+
status: zod.z.enum(["ready", "busy", "processing", "idle"]),
|
|
3789
|
+
message: zod.z.string().optional()
|
|
3790
|
+
});
|
|
3791
|
+
var WSMessageSchema = zod.z.discriminatedUnion("type", [
|
|
3792
|
+
WSChatMessageSchema,
|
|
3793
|
+
WSChatResponseSchema,
|
|
3794
|
+
WSStreamStartSchema,
|
|
3795
|
+
WSStreamChunkSchema,
|
|
3796
|
+
WSStreamEndSchema,
|
|
3797
|
+
WSErrorMessageSchema,
|
|
3798
|
+
WSPingPongSchema.extend({ type: zod.z.literal("ping") }),
|
|
3799
|
+
WSPingPongSchema.extend({ type: zod.z.literal("pong") }),
|
|
3800
|
+
WSConnectedSchema,
|
|
3801
|
+
WSStatusSchema
|
|
3802
|
+
]);
|
|
3803
|
+
function parseWSMessage(data) {
|
|
3804
|
+
const parsed = JSON.parse(data);
|
|
3805
|
+
return WSMessageSchema.parse(parsed);
|
|
3806
|
+
}
|
|
3807
|
+
function safeParseWSMessage(data) {
|
|
3808
|
+
try {
|
|
3809
|
+
const parsed = JSON.parse(data);
|
|
3810
|
+
const result = WSMessageSchema.safeParse(parsed);
|
|
3811
|
+
if (result.success) {
|
|
3812
|
+
return { success: true, data: result.data };
|
|
3813
|
+
}
|
|
3814
|
+
return { success: false, error: result.error };
|
|
3815
|
+
} catch {
|
|
3816
|
+
return {
|
|
3817
|
+
success: false,
|
|
3818
|
+
error: new zod.z.ZodError([
|
|
3819
|
+
{
|
|
3820
|
+
code: "custom",
|
|
3821
|
+
message: "Invalid JSON",
|
|
3822
|
+
path: []
|
|
3823
|
+
}
|
|
3824
|
+
])
|
|
3825
|
+
};
|
|
3826
|
+
}
|
|
3827
|
+
}
|
|
3828
|
+
var GithubFileInfoSchema = zod.z.object({
|
|
3829
|
+
name: zod.z.string(),
|
|
3830
|
+
path: zod.z.string(),
|
|
3831
|
+
sha: zod.z.string(),
|
|
3832
|
+
size: zod.z.number(),
|
|
3833
|
+
type: zod.z.enum(["file", "dir", "symlink", "submodule"]),
|
|
3834
|
+
url: zod.z.string().optional(),
|
|
3835
|
+
html_url: zod.z.string().optional(),
|
|
3836
|
+
git_url: zod.z.string().optional(),
|
|
3837
|
+
download_url: zod.z.string().nullable().optional(),
|
|
3838
|
+
content: zod.z.string().optional(),
|
|
3839
|
+
encoding: zod.z.string().optional()
|
|
3840
|
+
});
|
|
3841
|
+
var GithubRepoInfoSchema = zod.z.object({
|
|
3842
|
+
id: zod.z.number(),
|
|
3843
|
+
name: zod.z.string(),
|
|
3844
|
+
full_name: zod.z.string(),
|
|
3845
|
+
private: zod.z.boolean(),
|
|
3846
|
+
owner: zod.z.object({
|
|
3847
|
+
login: zod.z.string(),
|
|
3848
|
+
id: zod.z.number(),
|
|
3849
|
+
avatar_url: zod.z.string().optional(),
|
|
3850
|
+
type: zod.z.string().optional()
|
|
3851
|
+
}),
|
|
3852
|
+
html_url: zod.z.string(),
|
|
3853
|
+
description: zod.z.string().nullable().optional(),
|
|
3854
|
+
fork: zod.z.boolean().optional(),
|
|
3855
|
+
created_at: zod.z.string().optional(),
|
|
3856
|
+
updated_at: zod.z.string().optional(),
|
|
3857
|
+
pushed_at: zod.z.string().optional(),
|
|
3858
|
+
size: zod.z.number().optional(),
|
|
3859
|
+
stargazers_count: zod.z.number().optional(),
|
|
3860
|
+
watchers_count: zod.z.number().optional(),
|
|
3861
|
+
language: zod.z.string().nullable().optional(),
|
|
3862
|
+
default_branch: zod.z.string().optional(),
|
|
3863
|
+
visibility: zod.z.string().optional()
|
|
3864
|
+
});
|
|
3865
|
+
var GithubBranchInfoSchema = zod.z.object({
|
|
3866
|
+
name: zod.z.string(),
|
|
3867
|
+
commit: zod.z.object({
|
|
3868
|
+
sha: zod.z.string(),
|
|
3869
|
+
url: zod.z.string().optional()
|
|
3870
|
+
}),
|
|
3871
|
+
protected: zod.z.boolean().optional()
|
|
3872
|
+
});
|
|
3873
|
+
var GithubCommitInfoSchema = zod.z.object({
|
|
3874
|
+
sha: zod.z.string(),
|
|
3875
|
+
message: zod.z.string().optional(),
|
|
3876
|
+
author: zod.z.object({
|
|
3877
|
+
name: zod.z.string().optional(),
|
|
3878
|
+
email: zod.z.string().optional(),
|
|
3879
|
+
date: zod.z.string().optional()
|
|
3880
|
+
}).optional(),
|
|
3881
|
+
committer: zod.z.object({
|
|
3882
|
+
name: zod.z.string().optional(),
|
|
3883
|
+
email: zod.z.string().optional(),
|
|
3884
|
+
date: zod.z.string().optional()
|
|
3885
|
+
}).optional(),
|
|
3886
|
+
url: zod.z.string().optional(),
|
|
3887
|
+
html_url: zod.z.string().optional()
|
|
3888
|
+
});
|
|
3889
|
+
var GithubFileDataSchema = zod.z.object({
|
|
3890
|
+
file: GithubFileInfoSchema,
|
|
3891
|
+
content: zod.z.string().optional(),
|
|
3892
|
+
encoding: zod.z.string().optional()
|
|
3893
|
+
});
|
|
3894
|
+
var GithubFileResponseSchema = createResponseSchema(GithubFileDataSchema);
|
|
3895
|
+
var GithubDirectoryDataSchema = zod.z.object({
|
|
3896
|
+
entries: zod.z.array(GithubFileInfoSchema),
|
|
3897
|
+
path: zod.z.string()
|
|
3898
|
+
});
|
|
3899
|
+
var GithubDirectoryResponseSchema = createResponseSchema(GithubDirectoryDataSchema);
|
|
3900
|
+
var GithubRepoDataSchema = zod.z.object({
|
|
3901
|
+
repository: GithubRepoInfoSchema
|
|
3902
|
+
});
|
|
3903
|
+
var GithubRepoResponseSchema = createResponseSchema(GithubRepoDataSchema);
|
|
3904
|
+
var GithubBranchesDataSchema = zod.z.object({
|
|
3905
|
+
branches: zod.z.array(GithubBranchInfoSchema)
|
|
3906
|
+
});
|
|
3907
|
+
var GithubBranchesResponseSchema = createResponseSchema(GithubBranchesDataSchema);
|
|
3908
|
+
var GithubCommitsDataSchema = zod.z.object({
|
|
3909
|
+
commits: zod.z.array(GithubCommitInfoSchema)
|
|
3910
|
+
});
|
|
3911
|
+
var GithubCommitsResponseSchema = createResponseSchema(GithubCommitsDataSchema);
|
|
3912
|
+
|
|
3913
|
+
exports.AddProjectRepoDataSchema = AddProjectRepoDataSchema;
|
|
3914
|
+
exports.AddProjectRepoResponseSchema = AddProjectRepoResponseSchema;
|
|
3915
|
+
exports.AuthTokenDataSchema = AuthTokenDataSchema;
|
|
3916
|
+
exports.AuthTokenResponseSchema = AuthTokenResponseSchema;
|
|
3917
|
+
exports.AuthUserInfoResponseSchema = AuthUserInfoResponseSchema;
|
|
3918
|
+
exports.AuthUserInfoSchema = AuthUserInfoSchema;
|
|
3919
|
+
exports.AuthValidateDataSchema = AuthValidateDataSchema;
|
|
3920
|
+
exports.AuthValidateResponseSchema = AuthValidateResponseSchema;
|
|
3921
|
+
exports.ContentTypeInfoSchema = ContentTypeInfoSchema;
|
|
3922
|
+
exports.ContentTypeSchema = ContentTypeSchema;
|
|
3923
|
+
exports.ContentTypesDataSchema = ContentTypesDataSchema;
|
|
3924
|
+
exports.ContentTypesResponseSchema = ContentTypesResponseSchema;
|
|
3925
|
+
exports.ContextReposDataSchema = ContextReposDataSchema;
|
|
3926
|
+
exports.ContextReposResponseSchema = ContextReposResponseSchema;
|
|
3927
|
+
exports.CreateProjectDataSchema = CreateProjectDataSchema;
|
|
3928
|
+
exports.CreateProjectResponseSchema = CreateProjectResponseSchema;
|
|
3929
|
+
exports.CreateSessionDataSchema = CreateSessionDataSchema;
|
|
3930
|
+
exports.CreateSessionResponseSchema = CreateSessionResponseSchema;
|
|
3931
|
+
exports.DeleteDataSchema = DeleteDataSchema;
|
|
3932
|
+
exports.DeleteProjectDataSchema = DeleteProjectDataSchema;
|
|
3933
|
+
exports.DeleteProjectResponseSchema = DeleteProjectResponseSchema;
|
|
3934
|
+
exports.DeleteResponseSchema = DeleteResponseSchema;
|
|
3935
|
+
exports.DiscoveryDataSchema = DiscoveryDataSchema;
|
|
3936
|
+
exports.DiscoveryEndpointSchema = DiscoveryEndpointSchema;
|
|
3937
|
+
exports.DiscoveryResponseSchema = DiscoveryResponseSchema;
|
|
3938
|
+
exports.ErrorResponseSchema = ErrorResponseSchema;
|
|
3939
|
+
exports.ForkSessionDataSchema = ForkSessionDataSchema;
|
|
3940
|
+
exports.ForkSessionResponseSchema = ForkSessionResponseSchema;
|
|
3941
|
+
exports.GetProjectDataSchema = GetProjectDataSchema;
|
|
3942
|
+
exports.GetProjectResponseSchema = GetProjectResponseSchema;
|
|
3943
|
+
exports.GetSessionMessagesDataSchema = GetSessionMessagesDataSchema;
|
|
3944
|
+
exports.GetSessionMessagesResponseSchema = GetSessionMessagesResponseSchema;
|
|
3945
|
+
exports.GithubBranchInfoSchema = GithubBranchInfoSchema;
|
|
3946
|
+
exports.GithubBranchesDataSchema = GithubBranchesDataSchema;
|
|
3947
|
+
exports.GithubBranchesResponseSchema = GithubBranchesResponseSchema;
|
|
3948
|
+
exports.GithubCommitInfoSchema = GithubCommitInfoSchema;
|
|
3949
|
+
exports.GithubCommitsDataSchema = GithubCommitsDataSchema;
|
|
3950
|
+
exports.GithubCommitsResponseSchema = GithubCommitsResponseSchema;
|
|
3951
|
+
exports.GithubDirectoryDataSchema = GithubDirectoryDataSchema;
|
|
3952
|
+
exports.GithubDirectoryResponseSchema = GithubDirectoryResponseSchema;
|
|
3953
|
+
exports.GithubFileDataSchema = GithubFileDataSchema;
|
|
3954
|
+
exports.GithubFileInfoSchema = GithubFileInfoSchema;
|
|
3955
|
+
exports.GithubFileResponseSchema = GithubFileResponseSchema;
|
|
3956
|
+
exports.GithubRepoDataSchema = GithubRepoDataSchema;
|
|
3957
|
+
exports.GithubRepoInfoSchema = GithubRepoInfoSchema;
|
|
3958
|
+
exports.GithubRepoResponseSchema = GithubRepoResponseSchema;
|
|
3959
|
+
exports.IngestionJobResponseSchema = IngestionJobResponseSchema;
|
|
3960
|
+
exports.IngestionJobSchema = IngestionJobSchema;
|
|
3961
|
+
exports.KBDocumentSchema = KBDocumentSchema;
|
|
3962
|
+
exports.KBIngestDataSchema = KBIngestDataSchema;
|
|
3963
|
+
exports.KBIngestResponseSchema = KBIngestResponseSchema;
|
|
3964
|
+
exports.KBListDataSchema = KBListDataSchema;
|
|
3965
|
+
exports.KBListResponseSchema = KBListResponseSchema;
|
|
3966
|
+
exports.KBNamespace = KBNamespace;
|
|
3967
|
+
exports.ListDataSchema = ListDataSchema;
|
|
3968
|
+
exports.ListEntrySchema = ListEntrySchema;
|
|
3969
|
+
exports.ListProjectsDataSchema = ListProjectsDataSchema;
|
|
3970
|
+
exports.ListProjectsResponseSchema = ListProjectsResponseSchema;
|
|
3971
|
+
exports.ListResponseSchema = ListResponseSchema;
|
|
3972
|
+
exports.ListSessionsDataSchema = ListSessionsDataSchema;
|
|
3973
|
+
exports.ListSessionsResponseSchema = ListSessionsResponseSchema;
|
|
3974
|
+
exports.MetaSchema = MetaSchema;
|
|
3975
|
+
exports.MissionNamespace = MissionNamespace;
|
|
3976
|
+
exports.OCXPAuthError = OCXPAuthError;
|
|
3977
|
+
exports.OCXPClient = OCXPClient;
|
|
3978
|
+
exports.OCXPConflictError = OCXPConflictError;
|
|
3979
|
+
exports.OCXPError = OCXPError;
|
|
3980
|
+
exports.OCXPErrorCode = OCXPErrorCode;
|
|
3981
|
+
exports.OCXPNetworkError = OCXPNetworkError;
|
|
3982
|
+
exports.OCXPNotFoundError = OCXPNotFoundError;
|
|
3983
|
+
exports.OCXPPathService = OCXPPathService;
|
|
3984
|
+
exports.OCXPRateLimitError = OCXPRateLimitError;
|
|
3985
|
+
exports.OCXPResponseSchema = OCXPResponseSchema;
|
|
3986
|
+
exports.OCXPTimeoutError = OCXPTimeoutError;
|
|
3987
|
+
exports.OCXPValidationError = OCXPValidationError;
|
|
3988
|
+
exports.PaginationSchema = PaginationSchema;
|
|
3989
|
+
exports.PresignedUrlDataSchema = PresignedUrlDataSchema;
|
|
3990
|
+
exports.PresignedUrlResponseSchema = PresignedUrlResponseSchema;
|
|
3991
|
+
exports.ProjectMissionSchema = ProjectMissionSchema;
|
|
3992
|
+
exports.ProjectNamespace = ProjectNamespace;
|
|
3993
|
+
exports.ProjectRepoSchema = ProjectRepoSchema;
|
|
3994
|
+
exports.ProjectSchema = ProjectSchema;
|
|
3995
|
+
exports.QueryDataSchema = QueryDataSchema;
|
|
3996
|
+
exports.QueryFilterSchema = QueryFilterSchema;
|
|
3997
|
+
exports.QueryResponseSchema = QueryResponseSchema;
|
|
3998
|
+
exports.ReadDataSchema = ReadDataSchema;
|
|
3999
|
+
exports.ReadResponseSchema = ReadResponseSchema;
|
|
4000
|
+
exports.RepoDeleteDataSchema = RepoDeleteDataSchema;
|
|
4001
|
+
exports.RepoDeleteResponseSchema = RepoDeleteResponseSchema;
|
|
4002
|
+
exports.RepoDownloadDataSchema = RepoDownloadDataSchema;
|
|
4003
|
+
exports.RepoDownloadRequestSchema = RepoDownloadRequestSchema;
|
|
4004
|
+
exports.RepoDownloadResponseSchema = RepoDownloadResponseSchema;
|
|
4005
|
+
exports.RepoExistsDataSchema = RepoExistsDataSchema;
|
|
4006
|
+
exports.RepoExistsResponseSchema = RepoExistsResponseSchema;
|
|
4007
|
+
exports.RepoListDataSchema = RepoListDataSchema;
|
|
4008
|
+
exports.RepoListItemSchema = RepoListItemSchema;
|
|
4009
|
+
exports.RepoListResponseSchema = RepoListResponseSchema;
|
|
4010
|
+
exports.RepoStatusDataSchema = RepoStatusDataSchema;
|
|
4011
|
+
exports.RepoStatusEnum = RepoStatusEnum;
|
|
4012
|
+
exports.RepoStatusResponseSchema = RepoStatusResponseSchema;
|
|
4013
|
+
exports.SearchDataSchema = SearchDataSchema;
|
|
4014
|
+
exports.SearchResponseSchema = SearchResponseSchema;
|
|
4015
|
+
exports.SearchResultItemSchema = SearchResultItemSchema;
|
|
4016
|
+
exports.SessionMessageSchema = SessionMessageSchema;
|
|
4017
|
+
exports.SessionNamespace = SessionNamespace;
|
|
4018
|
+
exports.SessionSchema = SessionSchema;
|
|
4019
|
+
exports.StatsDataSchema = StatsDataSchema;
|
|
4020
|
+
exports.StatsResponseSchema = StatsResponseSchema;
|
|
4021
|
+
exports.TreeDataSchema = TreeDataSchema;
|
|
4022
|
+
exports.TreeNodeSchema = TreeNodeSchema;
|
|
4023
|
+
exports.TreeResponseSchema = TreeResponseSchema;
|
|
4024
|
+
exports.UpdateProjectDataSchema = UpdateProjectDataSchema;
|
|
4025
|
+
exports.UpdateProjectResponseSchema = UpdateProjectResponseSchema;
|
|
4026
|
+
exports.UpdateSessionMetadataDataSchema = UpdateSessionMetadataDataSchema;
|
|
4027
|
+
exports.UpdateSessionMetadataResponseSchema = UpdateSessionMetadataResponseSchema;
|
|
4028
|
+
exports.VALID_CONTENT_TYPES = VALID_CONTENT_TYPES;
|
|
4029
|
+
exports.VectorSearchDataSchema = VectorSearchDataSchema;
|
|
4030
|
+
exports.VectorSearchResponseSchema = VectorSearchResponseSchema;
|
|
4031
|
+
exports.WSBaseMessageSchema = WSBaseMessageSchema;
|
|
4032
|
+
exports.WSChatMessageSchema = WSChatMessageSchema;
|
|
4033
|
+
exports.WSChatResponseSchema = WSChatResponseSchema;
|
|
4034
|
+
exports.WSConnectedSchema = WSConnectedSchema;
|
|
4035
|
+
exports.WSErrorMessageSchema = WSErrorMessageSchema;
|
|
4036
|
+
exports.WSMessageSchema = WSMessageSchema;
|
|
4037
|
+
exports.WSMessageTypeSchema = WSMessageTypeSchema;
|
|
4038
|
+
exports.WSPingPongSchema = WSPingPongSchema;
|
|
4039
|
+
exports.WSStatusSchema = WSStatusSchema;
|
|
4040
|
+
exports.WSStreamChunkSchema = WSStreamChunkSchema;
|
|
4041
|
+
exports.WSStreamEndSchema = WSStreamEndSchema;
|
|
4042
|
+
exports.WSStreamStartSchema = WSStreamStartSchema;
|
|
4043
|
+
exports.WebSocketService = WebSocketService;
|
|
4044
|
+
exports.WriteDataSchema = WriteDataSchema;
|
|
4045
|
+
exports.WriteResponseSchema = WriteResponseSchema;
|
|
4046
|
+
exports.acknowledgeMemo = acknowledgeMemo;
|
|
4047
|
+
exports.addDatabase = addDatabase;
|
|
4048
|
+
exports.addLinkedRepo = addLinkedRepo;
|
|
4049
|
+
exports.addMission = addMission;
|
|
4050
|
+
exports.archiveSession = archiveSession;
|
|
4051
|
+
exports.buildPath = buildPath;
|
|
4052
|
+
exports.bulkDeleteContent = bulkDeleteContent;
|
|
4053
|
+
exports.bulkReadContent = bulkReadContent;
|
|
4054
|
+
exports.bulkWriteContent = bulkWriteContent;
|
|
4055
|
+
exports.createClient = createClient;
|
|
4056
|
+
exports.createConfig = createConfig;
|
|
4057
|
+
exports.createDatabase = createDatabase;
|
|
4058
|
+
exports.createMemo = createMemo;
|
|
4059
|
+
exports.createOCXPClient = createOCXPClient;
|
|
4060
|
+
exports.createPathService = createPathService;
|
|
4061
|
+
exports.createProject = createProject;
|
|
4062
|
+
exports.createResponseSchema = createResponseSchema;
|
|
4063
|
+
exports.createWebSocketService = createWebSocketService;
|
|
4064
|
+
exports.deleteContent = deleteContent;
|
|
4065
|
+
exports.deleteDatabase = deleteDatabase;
|
|
4066
|
+
exports.deleteMemo = deleteMemo;
|
|
4067
|
+
exports.deleteProject = deleteProject;
|
|
4068
|
+
exports.deleteRepo = deleteRepo;
|
|
4069
|
+
exports.downloadRepository = downloadRepository;
|
|
4070
|
+
exports.forkSession = forkSession;
|
|
4071
|
+
exports.getAuthConfig = getAuthConfig;
|
|
4072
|
+
exports.getCanonicalType = getCanonicalType;
|
|
4073
|
+
exports.getContentStats = getContentStats;
|
|
4074
|
+
exports.getContentTree = getContentTree;
|
|
4075
|
+
exports.getContentTypes = getContentTypes;
|
|
4076
|
+
exports.getContextRepos = getContextRepos;
|
|
4077
|
+
exports.getCurrentUser = getCurrentUser;
|
|
4078
|
+
exports.getDatabase = getDatabase;
|
|
4079
|
+
exports.getMemo = getMemo;
|
|
4080
|
+
exports.getMemoForSource = getMemoForSource;
|
|
4081
|
+
exports.getMissionContext = getMissionContext;
|
|
4082
|
+
exports.getProject = getProject;
|
|
4083
|
+
exports.getProjectDatabases = getProjectDatabases;
|
|
4084
|
+
exports.getRepoDownloadStatus = getRepoDownloadStatus;
|
|
4085
|
+
exports.getSample = getSample;
|
|
4086
|
+
exports.getSchema = getSchema;
|
|
4087
|
+
exports.getSessionMessages = getSessionMessages;
|
|
4088
|
+
exports.githubCheckAccess = githubCheckAccess;
|
|
4089
|
+
exports.githubGetContents = githubGetContents;
|
|
4090
|
+
exports.githubListBranches = githubListBranches;
|
|
4091
|
+
exports.ignoreMemo = ignoreMemo;
|
|
4092
|
+
exports.isOCXPAuthError = isOCXPAuthError;
|
|
4093
|
+
exports.isOCXPConflictError = isOCXPConflictError;
|
|
4094
|
+
exports.isOCXPError = isOCXPError;
|
|
4095
|
+
exports.isOCXPNetworkError = isOCXPNetworkError;
|
|
4096
|
+
exports.isOCXPNotFoundError = isOCXPNotFoundError;
|
|
4097
|
+
exports.isOCXPRateLimitError = isOCXPRateLimitError;
|
|
4098
|
+
exports.isOCXPTimeoutError = isOCXPTimeoutError;
|
|
4099
|
+
exports.isOCXPValidationError = isOCXPValidationError;
|
|
4100
|
+
exports.isValidContentType = isValidContentType;
|
|
4101
|
+
exports.listContent = listContent;
|
|
4102
|
+
exports.listContextDatabases = listContextDatabases;
|
|
4103
|
+
exports.listDatabases = listDatabases;
|
|
4104
|
+
exports.listDownloadedRepos = listDownloadedRepos;
|
|
4105
|
+
exports.listMemos = listMemos;
|
|
4106
|
+
exports.listProjects = listProjects;
|
|
4107
|
+
exports.listSessions = listSessions;
|
|
4108
|
+
exports.listTables = listTables;
|
|
4109
|
+
exports.listWorkspaces = listWorkspaces;
|
|
4110
|
+
exports.lockContent = lockContent;
|
|
4111
|
+
exports.login = login;
|
|
4112
|
+
exports.loginForAccessToken = loginForAccessToken;
|
|
4113
|
+
exports.mapHttpError = mapHttpError;
|
|
4114
|
+
exports.moveContent = moveContent;
|
|
4115
|
+
exports.normalizePath = normalizePath;
|
|
4116
|
+
exports.parsePath = parsePath;
|
|
4117
|
+
exports.parseWSMessage = parseWSMessage;
|
|
4118
|
+
exports.queryContent = queryContent;
|
|
4119
|
+
exports.queryKnowledgeBase = queryKnowledgeBase;
|
|
4120
|
+
exports.ragKnowledgeBase = ragKnowledgeBase;
|
|
4121
|
+
exports.readContent = readContent;
|
|
4122
|
+
exports.refreshTokens = refreshTokens;
|
|
4123
|
+
exports.regenerateMission = regenerateMission;
|
|
4124
|
+
exports.removeDatabase = removeDatabase;
|
|
4125
|
+
exports.removeLinkedRepo = removeLinkedRepo;
|
|
4126
|
+
exports.removeMission = removeMission;
|
|
4127
|
+
exports.resolveMemo = resolveMemo;
|
|
4128
|
+
exports.safeParseWSMessage = safeParseWSMessage;
|
|
4129
|
+
exports.searchContent = searchContent;
|
|
4130
|
+
exports.setDefaultDatabase = setDefaultDatabase;
|
|
4131
|
+
exports.setDefaultRepo = setDefaultRepo;
|
|
4132
|
+
exports.testDatabaseConnection = testDatabaseConnection;
|
|
4133
|
+
exports.toolCreateMission = toolCreateMission;
|
|
4134
|
+
exports.toolUpdateMission = toolUpdateMission;
|
|
4135
|
+
exports.unlockContent = unlockContent;
|
|
4136
|
+
exports.updateDatabase = updateDatabase;
|
|
4137
|
+
exports.updateProject = updateProject;
|
|
4138
|
+
exports.updateSessionMetadata = updateSessionMetadata;
|
|
4139
|
+
exports.writeContent = writeContent;
|
|
4140
|
+
//# sourceMappingURL=index.cjs.map
|
|
4141
|
+
//# sourceMappingURL=index.cjs.map
|