@kindgi/client 0.0.0-bootstrap.0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +141 -1
- package/dist/index.cjs +3811 -0
- package/dist/index.d.cts +12120 -0
- package/dist/index.d.ts +12120 -0
- package/dist/index.js +3800 -0
- package/package.json +68 -4
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,3811 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/errors.ts
|
|
4
|
+
function notImplementedInPreview(method) {
|
|
5
|
+
return {
|
|
6
|
+
code: "not-implemented-in-preview",
|
|
7
|
+
message: `${method}: transport not implemented in this preview`,
|
|
8
|
+
method
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function notYetWired(method, reason) {
|
|
12
|
+
return {
|
|
13
|
+
code: "not-yet-wired",
|
|
14
|
+
message: `${method}: ${reason}`,
|
|
15
|
+
method,
|
|
16
|
+
reason
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function fromWire(body) {
|
|
20
|
+
if (!body || typeof body !== "object") {
|
|
21
|
+
return {
|
|
22
|
+
code: "server",
|
|
23
|
+
serverCode: "unknown",
|
|
24
|
+
message: "Malformed error body from server"
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const obj = body;
|
|
28
|
+
const code = typeof obj.code === "string" ? obj.code : "unknown";
|
|
29
|
+
const message = typeof obj.message === "string" ? obj.message : `Server error: ${code}`;
|
|
30
|
+
const details = obj.details && typeof obj.details === "object" ? obj.details : void 0;
|
|
31
|
+
switch (code) {
|
|
32
|
+
case "auth":
|
|
33
|
+
return {
|
|
34
|
+
code: "auth",
|
|
35
|
+
message,
|
|
36
|
+
reason: obj.reason ?? "unauthenticated"
|
|
37
|
+
};
|
|
38
|
+
// Wire-level auth codes per API-ROUTE-CONVENTIONS §4.3.
|
|
39
|
+
case "auth-missing":
|
|
40
|
+
return { code: "auth", message, reason: "unauthenticated" };
|
|
41
|
+
case "auth-expired":
|
|
42
|
+
return { code: "auth", message, reason: "token-expired" };
|
|
43
|
+
case "auth-revoked":
|
|
44
|
+
return { code: "auth", message, reason: "unauthenticated" };
|
|
45
|
+
case "permission-denied":
|
|
46
|
+
return { code: "auth", message, reason: "forbidden" };
|
|
47
|
+
case "rate-limited":
|
|
48
|
+
case "rate-limit-exceeded":
|
|
49
|
+
return {
|
|
50
|
+
code: "rate-limited",
|
|
51
|
+
message,
|
|
52
|
+
...typeof obj.retryAfterSeconds === "number" ? { retryAfterSeconds: obj.retryAfterSeconds } : {}
|
|
53
|
+
};
|
|
54
|
+
case "not-found":
|
|
55
|
+
case "run-not-found":
|
|
56
|
+
case "agent-not-found":
|
|
57
|
+
case "tool-not-found":
|
|
58
|
+
case "guardrail-not-found":
|
|
59
|
+
case "flow-not-found":
|
|
60
|
+
case "conversation-not-found":
|
|
61
|
+
case "approval-not-found":
|
|
62
|
+
case "reviewer-not-found":
|
|
63
|
+
case "proposal-not-found":
|
|
64
|
+
case "provenance-not-found":
|
|
65
|
+
case "observation-not-found":
|
|
66
|
+
case "blob-not-found":
|
|
67
|
+
case "audit-bundle-not-found":
|
|
68
|
+
case "signing-not-configured":
|
|
69
|
+
case "signing-key-not-found":
|
|
70
|
+
case "adapter-not-found":
|
|
71
|
+
case "fact-not-found":
|
|
72
|
+
case "identity-user-not-found":
|
|
73
|
+
case "provider-not-found":
|
|
74
|
+
case "capability-not-found":
|
|
75
|
+
case "token-not-found":
|
|
76
|
+
return {
|
|
77
|
+
code: "not-found",
|
|
78
|
+
message,
|
|
79
|
+
resource: {
|
|
80
|
+
kind: code.replace(/-not-found$/u, "") || "unknown",
|
|
81
|
+
id: readStringField(
|
|
82
|
+
details,
|
|
83
|
+
"agentId",
|
|
84
|
+
"toolId",
|
|
85
|
+
"runId",
|
|
86
|
+
"adapterId",
|
|
87
|
+
"userId",
|
|
88
|
+
"providerId",
|
|
89
|
+
"capabilityId",
|
|
90
|
+
"tokenId",
|
|
91
|
+
"factId",
|
|
92
|
+
"guardrailId",
|
|
93
|
+
"id"
|
|
94
|
+
) ?? "unknown"
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
case "conflict":
|
|
98
|
+
case "already-terminal":
|
|
99
|
+
case "run-already-terminal":
|
|
100
|
+
case "idempotency-key-body-mismatch":
|
|
101
|
+
case "hitl-required":
|
|
102
|
+
case "agent-already-registered":
|
|
103
|
+
case "tool-already-registered":
|
|
104
|
+
case "guardrail-already-registered":
|
|
105
|
+
case "flow-already-registered":
|
|
106
|
+
case "conversation-closed":
|
|
107
|
+
case "provider-already-registered":
|
|
108
|
+
case "proposal-invalid-state-transition":
|
|
109
|
+
case "approval-not-decided":
|
|
110
|
+
return { code: "conflict", message, reason: code };
|
|
111
|
+
case "invalid-request":
|
|
112
|
+
case "validation-failed":
|
|
113
|
+
case "unknown-field":
|
|
114
|
+
case "bad-input":
|
|
115
|
+
case "unresolved-tool":
|
|
116
|
+
case "unresolved-guardrail":
|
|
117
|
+
case "schema-validation-failed":
|
|
118
|
+
case "invalid-agent":
|
|
119
|
+
case "invalid-tool-definition":
|
|
120
|
+
case "invalid-schema":
|
|
121
|
+
case "unknown-effect":
|
|
122
|
+
case "invalid-guardrail":
|
|
123
|
+
case "invalid-provider":
|
|
124
|
+
case "supervisor-header-missing":
|
|
125
|
+
return {
|
|
126
|
+
code: "invalid-request",
|
|
127
|
+
message,
|
|
128
|
+
issues: obj.issues ?? details?.issues ?? []
|
|
129
|
+
};
|
|
130
|
+
case "guardrail-violation":
|
|
131
|
+
return {
|
|
132
|
+
code: "guardrail-violation",
|
|
133
|
+
message,
|
|
134
|
+
violations: readGuardrailViolations(details?.violations),
|
|
135
|
+
evaluationErrors: readEvaluationErrors(details?.evaluationErrors)
|
|
136
|
+
};
|
|
137
|
+
default:
|
|
138
|
+
return {
|
|
139
|
+
code: "server",
|
|
140
|
+
serverCode: code,
|
|
141
|
+
message,
|
|
142
|
+
...details !== void 0 ? { fields: details } : {}
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
function readStringField(obj, ...keys) {
|
|
147
|
+
if (obj === void 0) return void 0;
|
|
148
|
+
for (const key of keys) {
|
|
149
|
+
const v = obj[key];
|
|
150
|
+
if (typeof v === "string" && v.length > 0) return v;
|
|
151
|
+
}
|
|
152
|
+
return void 0;
|
|
153
|
+
}
|
|
154
|
+
function asRecord(value) {
|
|
155
|
+
return value !== null && typeof value === "object" ? value : void 0;
|
|
156
|
+
}
|
|
157
|
+
function readGuardrailViolations(raw) {
|
|
158
|
+
if (!Array.isArray(raw)) return [];
|
|
159
|
+
const out = [];
|
|
160
|
+
for (const entry of raw) {
|
|
161
|
+
const v = asRecord(entry);
|
|
162
|
+
if (v === void 0 || typeof v.guardrailId !== "string") continue;
|
|
163
|
+
const reason = asRecord(v.result)?.reason;
|
|
164
|
+
out.push({
|
|
165
|
+
guardrailId: v.guardrailId,
|
|
166
|
+
severity: typeof v.severity === "string" ? v.severity : "unknown",
|
|
167
|
+
action: typeof v.action === "string" ? v.action : "unknown",
|
|
168
|
+
...typeof reason === "string" && { reason }
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
return out;
|
|
172
|
+
}
|
|
173
|
+
function readEvaluationErrors(raw) {
|
|
174
|
+
if (!Array.isArray(raw)) return [];
|
|
175
|
+
const out = [];
|
|
176
|
+
for (const entry of raw) {
|
|
177
|
+
const e = asRecord(entry);
|
|
178
|
+
if (e === void 0 || typeof e.guardrailId !== "string") continue;
|
|
179
|
+
out.push({
|
|
180
|
+
guardrailId: e.guardrailId,
|
|
181
|
+
message: typeof e.message === "string" ? e.message : ""
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
return out;
|
|
185
|
+
}
|
|
186
|
+
var KindgiApiError = class extends Error {
|
|
187
|
+
error;
|
|
188
|
+
constructor(error) {
|
|
189
|
+
super(error.message);
|
|
190
|
+
this.name = "KindgiApiError";
|
|
191
|
+
this.error = error;
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
// src/streaming.ts
|
|
196
|
+
async function* readSse(options) {
|
|
197
|
+
const fetchImpl = options.fetchImpl ?? fetch;
|
|
198
|
+
const initialBackoff = options.initialBackoffMs ?? 500;
|
|
199
|
+
const maxBackoff = options.maxBackoffMs ?? 3e4;
|
|
200
|
+
const shouldRetry = options.shouldRetry ?? ((attempt2) => attempt2 < 10);
|
|
201
|
+
let lastEventId = options.lastEventId;
|
|
202
|
+
let attempt = 0;
|
|
203
|
+
while (!options.signal?.aborted) {
|
|
204
|
+
try {
|
|
205
|
+
const extra = typeof options.headers === "function" ? await options.headers() : options.headers ?? {};
|
|
206
|
+
const headers = {
|
|
207
|
+
Accept: "text/event-stream",
|
|
208
|
+
...extra
|
|
209
|
+
};
|
|
210
|
+
if (lastEventId !== void 0) headers["Last-Event-Id"] = lastEventId;
|
|
211
|
+
const response = await fetchImpl(options.url, {
|
|
212
|
+
method: "GET",
|
|
213
|
+
headers,
|
|
214
|
+
...options.signal ? { signal: options.signal } : {}
|
|
215
|
+
});
|
|
216
|
+
if (!response.ok || response.body === null) {
|
|
217
|
+
throw new SseHttpError(response.status);
|
|
218
|
+
}
|
|
219
|
+
attempt = 0;
|
|
220
|
+
for await (const event of parseSseStream(response.body)) {
|
|
221
|
+
if (event.id !== void 0) lastEventId = event.id;
|
|
222
|
+
yield event;
|
|
223
|
+
}
|
|
224
|
+
return;
|
|
225
|
+
} catch (err) {
|
|
226
|
+
if (options.signal?.aborted) return;
|
|
227
|
+
attempt += 1;
|
|
228
|
+
if (!shouldRetry(attempt, err)) throw err;
|
|
229
|
+
const backoff = Math.min(initialBackoff * 2 ** (attempt - 1), maxBackoff);
|
|
230
|
+
await sleep(backoff, options.signal);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
var SseHttpError = class extends Error {
|
|
235
|
+
status;
|
|
236
|
+
constructor(status) {
|
|
237
|
+
super(`SSE upstream returned HTTP ${status}`);
|
|
238
|
+
this.name = "SseHttpError";
|
|
239
|
+
this.status = status;
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
async function* unwrapSseData(source) {
|
|
243
|
+
for await (const event of source) {
|
|
244
|
+
yield event.data;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
async function* parseSseStream(body) {
|
|
248
|
+
const decoder = new TextDecoder();
|
|
249
|
+
const reader = body.getReader();
|
|
250
|
+
let buffer = "";
|
|
251
|
+
let eventName = "message";
|
|
252
|
+
let dataLines = [];
|
|
253
|
+
let eventId;
|
|
254
|
+
try {
|
|
255
|
+
while (true) {
|
|
256
|
+
const { done, value } = await reader.read();
|
|
257
|
+
if (done) break;
|
|
258
|
+
buffer += decoder.decode(value, { stream: true });
|
|
259
|
+
let newlineIdx = buffer.indexOf("\n");
|
|
260
|
+
while (newlineIdx !== -1) {
|
|
261
|
+
const line = buffer.slice(0, newlineIdx).replace(/\r$/, "");
|
|
262
|
+
buffer = buffer.slice(newlineIdx + 1);
|
|
263
|
+
newlineIdx = buffer.indexOf("\n");
|
|
264
|
+
if (line === "") {
|
|
265
|
+
if (dataLines.length > 0) {
|
|
266
|
+
const raw = dataLines.join("\n");
|
|
267
|
+
try {
|
|
268
|
+
const data = JSON.parse(raw);
|
|
269
|
+
yield { event: eventName, data, ...eventId !== void 0 ? { id: eventId } : {} };
|
|
270
|
+
} catch {
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
eventName = "message";
|
|
274
|
+
dataLines = [];
|
|
275
|
+
eventId = void 0;
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
if (line.startsWith(":")) continue;
|
|
279
|
+
const colonIdx = line.indexOf(":");
|
|
280
|
+
const field = colonIdx === -1 ? line : line.slice(0, colonIdx);
|
|
281
|
+
const rawVal = colonIdx === -1 ? "" : line.slice(colonIdx + 1);
|
|
282
|
+
const val = rawVal.startsWith(" ") ? rawVal.slice(1) : rawVal;
|
|
283
|
+
switch (field) {
|
|
284
|
+
case "event":
|
|
285
|
+
eventName = val;
|
|
286
|
+
break;
|
|
287
|
+
case "data":
|
|
288
|
+
dataLines.push(val);
|
|
289
|
+
break;
|
|
290
|
+
case "id":
|
|
291
|
+
eventId = val;
|
|
292
|
+
break;
|
|
293
|
+
default:
|
|
294
|
+
break;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
} finally {
|
|
299
|
+
reader.releaseLock();
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
async function* postSse(options) {
|
|
303
|
+
const fetchImpl = options.fetchImpl ?? fetch;
|
|
304
|
+
const headers = {
|
|
305
|
+
Accept: "text/event-stream",
|
|
306
|
+
...options.body !== void 0 && { "Content-Type": "application/json" },
|
|
307
|
+
...options.headers ?? {}
|
|
308
|
+
};
|
|
309
|
+
const response = await fetchImpl(options.url, {
|
|
310
|
+
method: "POST",
|
|
311
|
+
headers,
|
|
312
|
+
...options.body !== void 0 && { body: JSON.stringify(options.body) },
|
|
313
|
+
...options.signal ? { signal: options.signal } : {}
|
|
314
|
+
});
|
|
315
|
+
if (!response.ok || response.body === null) {
|
|
316
|
+
throw new Error(`SSE upstream returned HTTP ${response.status}`);
|
|
317
|
+
}
|
|
318
|
+
for await (const event of parseSseStream(response.body)) {
|
|
319
|
+
yield event;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
function sleep(ms, signal) {
|
|
323
|
+
return new Promise((resolve) => {
|
|
324
|
+
const t = setTimeout(resolve, ms);
|
|
325
|
+
signal?.addEventListener(
|
|
326
|
+
"abort",
|
|
327
|
+
() => {
|
|
328
|
+
clearTimeout(t);
|
|
329
|
+
resolve();
|
|
330
|
+
},
|
|
331
|
+
{ once: true }
|
|
332
|
+
);
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// src/resources/adapters.ts
|
|
337
|
+
function makeAdaptersClient(transport) {
|
|
338
|
+
return {
|
|
339
|
+
async list(filter) {
|
|
340
|
+
const page = await transport.request({
|
|
341
|
+
method: "GET",
|
|
342
|
+
path: "/v1/adapters",
|
|
343
|
+
query: {
|
|
344
|
+
...filter?.limit !== void 0 && { limit: filter.limit },
|
|
345
|
+
...filter?.cursor !== void 0 && { cursor: filter.cursor },
|
|
346
|
+
...filter?.kind !== void 0 && { kind: filter.kind },
|
|
347
|
+
...filter?.status !== void 0 && { status: filter.status }
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
return {
|
|
351
|
+
items: page.data,
|
|
352
|
+
...page.nextCursor !== void 0 && { nextCursor: page.nextCursor }
|
|
353
|
+
};
|
|
354
|
+
},
|
|
355
|
+
async get(adapterId) {
|
|
356
|
+
return transport.request({
|
|
357
|
+
method: "GET",
|
|
358
|
+
path: `/v1/adapters/${encodeURIComponent(adapterId)}`
|
|
359
|
+
});
|
|
360
|
+
},
|
|
361
|
+
async test(input) {
|
|
362
|
+
return transport.request({
|
|
363
|
+
method: "POST",
|
|
364
|
+
path: `/v1/adapters/${encodeURIComponent(input.adapterId)}/test`,
|
|
365
|
+
body: input.probe ?? {},
|
|
366
|
+
...input.idempotencyKey !== void 0 && { idempotencyKey: input.idempotencyKey }
|
|
367
|
+
});
|
|
368
|
+
},
|
|
369
|
+
prepare(input) {
|
|
370
|
+
const url = `${transport.apiUrl}/v1/adapters/${encodeURIComponent(input.adapterId)}/prepare`;
|
|
371
|
+
const source = postSse({
|
|
372
|
+
url,
|
|
373
|
+
headers: transport.authHeaders(),
|
|
374
|
+
fetchImpl: transport.fetchImpl,
|
|
375
|
+
...input.params !== void 0 && { body: { params: input.params } },
|
|
376
|
+
...input.signal !== void 0 && { signal: input.signal }
|
|
377
|
+
});
|
|
378
|
+
return unwrapSseData(source);
|
|
379
|
+
},
|
|
380
|
+
async candidates() {
|
|
381
|
+
throw new KindgiApiError(
|
|
382
|
+
notYetWired(
|
|
383
|
+
"adapters.candidates",
|
|
384
|
+
"no /v1/adapters/candidates route on the API \u2014 deployment-wired set is authoritative, no upstream catalog surface"
|
|
385
|
+
)
|
|
386
|
+
);
|
|
387
|
+
},
|
|
388
|
+
async configured() {
|
|
389
|
+
throw new KindgiApiError(
|
|
390
|
+
notYetWired(
|
|
391
|
+
"adapters.configured",
|
|
392
|
+
"use adapters.list() \u2014 the record-by-kind shape does not map to the wire paginated list"
|
|
393
|
+
)
|
|
394
|
+
);
|
|
395
|
+
},
|
|
396
|
+
async configure(_input) {
|
|
397
|
+
throw new KindgiApiError(
|
|
398
|
+
notYetWired(
|
|
399
|
+
"adapters.configure",
|
|
400
|
+
"adapters are wired at boot via config-as-code; runtime rebinding requires a platform capability that has not landed"
|
|
401
|
+
)
|
|
402
|
+
);
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// src/resources/agents.ts
|
|
408
|
+
function makeAgentsClient(transport) {
|
|
409
|
+
const seg = (s) => encodeURIComponent(s);
|
|
410
|
+
return {
|
|
411
|
+
async define(spec, options) {
|
|
412
|
+
const result = await transport.request({
|
|
413
|
+
method: "POST",
|
|
414
|
+
path: "/v1/agents",
|
|
415
|
+
body: { ...spec, projectId: options.projectId },
|
|
416
|
+
...options.idempotencyKey !== void 0 && {
|
|
417
|
+
idempotencyKey: options.idempotencyKey
|
|
418
|
+
}
|
|
419
|
+
});
|
|
420
|
+
return result.agentId;
|
|
421
|
+
},
|
|
422
|
+
async list(filter) {
|
|
423
|
+
return transport.request({
|
|
424
|
+
method: "GET",
|
|
425
|
+
path: "/v1/agents",
|
|
426
|
+
query: {
|
|
427
|
+
...filter?.limit !== void 0 && { limit: filter.limit },
|
|
428
|
+
...filter?.cursor !== void 0 && { cursor: filter.cursor },
|
|
429
|
+
...filter?.name !== void 0 && { name: filter.name }
|
|
430
|
+
}
|
|
431
|
+
});
|
|
432
|
+
},
|
|
433
|
+
async get(agentId) {
|
|
434
|
+
return transport.request({
|
|
435
|
+
method: "GET",
|
|
436
|
+
path: `/v1/agents/${seg(agentId)}`
|
|
437
|
+
});
|
|
438
|
+
},
|
|
439
|
+
versions: {
|
|
440
|
+
async list(agentId, filter) {
|
|
441
|
+
return transport.request({
|
|
442
|
+
method: "GET",
|
|
443
|
+
path: `/v1/agents/${seg(agentId)}/versions`,
|
|
444
|
+
query: {
|
|
445
|
+
...filter?.limit !== void 0 && { limit: filter.limit },
|
|
446
|
+
...filter?.cursor !== void 0 && { cursor: filter.cursor }
|
|
447
|
+
}
|
|
448
|
+
});
|
|
449
|
+
},
|
|
450
|
+
async get(agentId, version) {
|
|
451
|
+
return transport.request({
|
|
452
|
+
method: "GET",
|
|
453
|
+
path: `/v1/agents/${seg(agentId)}/versions/${seg(version)}`
|
|
454
|
+
});
|
|
455
|
+
},
|
|
456
|
+
async unregister(agentId, version, options) {
|
|
457
|
+
return transport.request({
|
|
458
|
+
method: "POST",
|
|
459
|
+
path: `/v1/agents/${seg(agentId)}/versions/${seg(version)}/unregister`,
|
|
460
|
+
...options?.idempotencyKey !== void 0 && {
|
|
461
|
+
idempotencyKey: options.idempotencyKey
|
|
462
|
+
}
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
},
|
|
466
|
+
async reinstateVersion(agentId, version, options) {
|
|
467
|
+
const wire = await transport.request({
|
|
468
|
+
method: "POST",
|
|
469
|
+
path: `/v1/agents/${seg(agentId)}/versions/${seg(version)}/reinstate`,
|
|
470
|
+
...options?.idempotencyKey !== void 0 && {
|
|
471
|
+
idempotencyKey: options.idempotencyKey
|
|
472
|
+
}
|
|
473
|
+
});
|
|
474
|
+
return {
|
|
475
|
+
agentId: wire.agentId,
|
|
476
|
+
version: wire.version,
|
|
477
|
+
wasTombstoned: wire.wasTombstoned
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
// src/status-query.ts
|
|
484
|
+
function singleStatusQuery(method, status) {
|
|
485
|
+
if (status === void 0) return void 0;
|
|
486
|
+
if (!Array.isArray(status)) return status;
|
|
487
|
+
const statuses = status;
|
|
488
|
+
if (statuses.length <= 1) return statuses[0];
|
|
489
|
+
const error = {
|
|
490
|
+
code: "invalid-request",
|
|
491
|
+
message: `${method}: filter by one status at a time; the API accepts a single \`status\` value`,
|
|
492
|
+
issues: [{ path: "/status", message: "expected a single status" }]
|
|
493
|
+
};
|
|
494
|
+
throw new KindgiApiError(error);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
// src/resources/approvals.ts
|
|
498
|
+
function makeApprovalsClient(transport) {
|
|
499
|
+
return {
|
|
500
|
+
async list(filter) {
|
|
501
|
+
const statusParam = singleStatusQuery("approvals.list", filter?.status);
|
|
502
|
+
const page = await transport.request({
|
|
503
|
+
method: "GET",
|
|
504
|
+
path: "/v1/approvals",
|
|
505
|
+
query: {
|
|
506
|
+
...filter?.limit !== void 0 && { limit: filter.limit },
|
|
507
|
+
...filter?.cursor !== void 0 && { cursor: filter.cursor },
|
|
508
|
+
...statusParam !== void 0 && { status: statusParam },
|
|
509
|
+
...filter?.requiredRole !== void 0 && { requiredRole: filter.requiredRole },
|
|
510
|
+
...filter?.createdAfter !== void 0 && {
|
|
511
|
+
createdAfter: filter.createdAfter
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
});
|
|
515
|
+
return {
|
|
516
|
+
items: page.data,
|
|
517
|
+
...page.nextCursor !== void 0 && {
|
|
518
|
+
nextCursor: page.nextCursor
|
|
519
|
+
}
|
|
520
|
+
};
|
|
521
|
+
},
|
|
522
|
+
async get(id) {
|
|
523
|
+
return transport.request({
|
|
524
|
+
method: "GET",
|
|
525
|
+
path: `/v1/approvals/${encodeURIComponent(id)}`
|
|
526
|
+
});
|
|
527
|
+
},
|
|
528
|
+
async decide(id, input) {
|
|
529
|
+
const body = { decision: input.decision };
|
|
530
|
+
if (input.rationale !== void 0) body.rationale = input.rationale;
|
|
531
|
+
if (input.value !== void 0) body.value = input.value;
|
|
532
|
+
return transport.request({
|
|
533
|
+
method: "POST",
|
|
534
|
+
path: `/v1/approvals/${encodeURIComponent(id)}/complete`,
|
|
535
|
+
body,
|
|
536
|
+
...input.idempotencyKey !== void 0 && { idempotencyKey: input.idempotencyKey }
|
|
537
|
+
});
|
|
538
|
+
},
|
|
539
|
+
async batch(_input) {
|
|
540
|
+
throw new KindgiApiError(
|
|
541
|
+
notYetWired(
|
|
542
|
+
"approvals.batch",
|
|
543
|
+
"no bulk-decide route on the API \u2014 per-approval POST /v1/approvals/{id}/complete is the primitive; a bulk wrapper needs a design on partial-failure semantics"
|
|
544
|
+
)
|
|
545
|
+
);
|
|
546
|
+
},
|
|
547
|
+
async assign(_id, _reviewerId) {
|
|
548
|
+
throw new KindgiApiError(
|
|
549
|
+
notYetWired(
|
|
550
|
+
"approvals.assign",
|
|
551
|
+
"no per-approval assign route on the API \u2014 assignment happens at approval-creation time via HITL binding resolveReviewer, external re-assign is a planned follow-up"
|
|
552
|
+
)
|
|
553
|
+
);
|
|
554
|
+
},
|
|
555
|
+
async completeToken(_id, _input) {
|
|
556
|
+
throw new KindgiApiError(
|
|
557
|
+
notYetWired(
|
|
558
|
+
"approvals.completeToken",
|
|
559
|
+
"no standalone complete-token route on the API \u2014 wire fuses waitpoint resume into POST /v1/approvals/{id}/complete (any decide that terminates + carries a waitTokenId auto-resumes), use approvals.decide instead"
|
|
560
|
+
)
|
|
561
|
+
);
|
|
562
|
+
},
|
|
563
|
+
reviewers: {
|
|
564
|
+
async register(spec, options) {
|
|
565
|
+
return transport.request({
|
|
566
|
+
method: "POST",
|
|
567
|
+
path: "/v1/approvals/reviewers",
|
|
568
|
+
body: {
|
|
569
|
+
userId: spec.userId,
|
|
570
|
+
role: spec.role,
|
|
571
|
+
...spec.displayName !== void 0 && { displayName: spec.displayName }
|
|
572
|
+
},
|
|
573
|
+
...options?.idempotencyKey !== void 0 && {
|
|
574
|
+
idempotencyKey: options.idempotencyKey
|
|
575
|
+
}
|
|
576
|
+
});
|
|
577
|
+
},
|
|
578
|
+
async list(filter) {
|
|
579
|
+
const page = await transport.request({
|
|
580
|
+
method: "GET",
|
|
581
|
+
path: "/v1/approvals/reviewers",
|
|
582
|
+
query: {
|
|
583
|
+
...filter?.limit !== void 0 && { limit: filter.limit },
|
|
584
|
+
...filter?.cursor !== void 0 && { cursor: filter.cursor },
|
|
585
|
+
...filter?.role !== void 0 && { role: filter.role }
|
|
586
|
+
}
|
|
587
|
+
});
|
|
588
|
+
return {
|
|
589
|
+
items: page.data,
|
|
590
|
+
...page.nextCursor !== void 0 && {
|
|
591
|
+
nextCursor: page.nextCursor
|
|
592
|
+
}
|
|
593
|
+
};
|
|
594
|
+
},
|
|
595
|
+
async get(id) {
|
|
596
|
+
return transport.request({
|
|
597
|
+
method: "GET",
|
|
598
|
+
path: `/v1/approvals/reviewers/${encodeURIComponent(id)}`
|
|
599
|
+
});
|
|
600
|
+
},
|
|
601
|
+
async updateRole(_id, _role) {
|
|
602
|
+
throw new KindgiApiError(
|
|
603
|
+
notYetWired(
|
|
604
|
+
"approvals.reviewers.updateRole",
|
|
605
|
+
"no dedicated update-role route on the API \u2014 role rotation happens via re-register (idempotent per (tenantId, userId) rewrites the role), wire only if a bespoke audit-log entry for role changes is needed"
|
|
606
|
+
)
|
|
607
|
+
);
|
|
608
|
+
},
|
|
609
|
+
async deactivate(id, options) {
|
|
610
|
+
return transport.request({
|
|
611
|
+
method: "POST",
|
|
612
|
+
path: `/v1/approvals/reviewers/${encodeURIComponent(id)}/unregister`,
|
|
613
|
+
body: {},
|
|
614
|
+
...options?.idempotencyKey !== void 0 && {
|
|
615
|
+
idempotencyKey: options.idempotencyKey
|
|
616
|
+
}
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
},
|
|
620
|
+
audit: {
|
|
621
|
+
async export(input) {
|
|
622
|
+
return transport.request({
|
|
623
|
+
method: "POST",
|
|
624
|
+
path: `/v1/approvals/${encodeURIComponent(input.approvalId)}/audit-bundle`,
|
|
625
|
+
body: {
|
|
626
|
+
signingKeyId: input.signingKeyId,
|
|
627
|
+
...input.includeMessages !== void 0 && {
|
|
628
|
+
includeMessages: input.includeMessages
|
|
629
|
+
}
|
|
630
|
+
},
|
|
631
|
+
...input.idempotencyKey !== void 0 && { idempotencyKey: input.idempotencyKey }
|
|
632
|
+
});
|
|
633
|
+
},
|
|
634
|
+
async get(_id) {
|
|
635
|
+
throw new KindgiApiError(
|
|
636
|
+
notYetWired(
|
|
637
|
+
"approvals.audit.get",
|
|
638
|
+
"no GET /v1/audit-bundles/{id} route on the API \u2014 wire ships the signed body inline from export (bundles are not durably stored server-side today)"
|
|
639
|
+
)
|
|
640
|
+
);
|
|
641
|
+
},
|
|
642
|
+
async list(_filter) {
|
|
643
|
+
throw new KindgiApiError(
|
|
644
|
+
notYetWired(
|
|
645
|
+
"approvals.audit.list",
|
|
646
|
+
"no GET /v1/audit-bundles route on the API \u2014 bundles are not durably stored server-side today"
|
|
647
|
+
)
|
|
648
|
+
);
|
|
649
|
+
},
|
|
650
|
+
async verify(_bundle, _publicKey) {
|
|
651
|
+
throw new KindgiApiError(
|
|
652
|
+
notYetWired(
|
|
653
|
+
"approvals.audit.verify",
|
|
654
|
+
"client-side verifier requires the crypto module reachability from the SDK bundle \u2014 not yet vendored (same constraint as provenance.verify + webhooks.verify)"
|
|
655
|
+
)
|
|
656
|
+
);
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
};
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
// src/resources/artifacts.ts
|
|
663
|
+
function makeArtifactsClient(transport) {
|
|
664
|
+
return {
|
|
665
|
+
async put(_input) {
|
|
666
|
+
throw new KindgiApiError(
|
|
667
|
+
notYetWired(
|
|
668
|
+
"artifacts.put",
|
|
669
|
+
"POST /v1/artifacts is a multipart-form upload; the SDK transport is JSON-only. Multipart / raw-stream body support is a planned follow-up"
|
|
670
|
+
)
|
|
671
|
+
);
|
|
672
|
+
},
|
|
673
|
+
async get(_ref) {
|
|
674
|
+
throw new KindgiApiError(
|
|
675
|
+
notYetWired(
|
|
676
|
+
"artifacts.get",
|
|
677
|
+
"GET /v1/artifacts/{blobId} streams binary bytes; the SDK transport hydrates JSON only. Raw-stream response support is a planned follow-up"
|
|
678
|
+
)
|
|
679
|
+
);
|
|
680
|
+
},
|
|
681
|
+
async list(filter) {
|
|
682
|
+
const page = await transport.request({
|
|
683
|
+
method: "GET",
|
|
684
|
+
path: "/v1/artifacts",
|
|
685
|
+
query: {
|
|
686
|
+
...filter?.limit !== void 0 && { limit: filter.limit },
|
|
687
|
+
...filter?.cursor !== void 0 && { cursor: filter.cursor },
|
|
688
|
+
...filter?.ownerRunId !== void 0 && {
|
|
689
|
+
ownerRunId: filter.ownerRunId
|
|
690
|
+
},
|
|
691
|
+
...filter?.contentType !== void 0 && { contentType: filter.contentType }
|
|
692
|
+
}
|
|
693
|
+
});
|
|
694
|
+
return {
|
|
695
|
+
items: page.data,
|
|
696
|
+
...page.nextCursor !== void 0 && {
|
|
697
|
+
nextCursor: page.nextCursor
|
|
698
|
+
}
|
|
699
|
+
};
|
|
700
|
+
},
|
|
701
|
+
async delete(blobId, options) {
|
|
702
|
+
return transport.request({
|
|
703
|
+
method: "DELETE",
|
|
704
|
+
path: `/v1/artifacts/${encodeURIComponent(blobId)}`,
|
|
705
|
+
...options?.idempotencyKey !== void 0 && {
|
|
706
|
+
idempotencyKey: options.idempotencyKey
|
|
707
|
+
}
|
|
708
|
+
});
|
|
709
|
+
},
|
|
710
|
+
async presign(_input) {
|
|
711
|
+
throw new KindgiApiError(
|
|
712
|
+
notYetWired(
|
|
713
|
+
"artifacts.presign",
|
|
714
|
+
"no POST /v1/artifacts/presign route on the API \u2014 presigned URLs are a per-backend concern (S3/GCS/R2 native)"
|
|
715
|
+
)
|
|
716
|
+
);
|
|
717
|
+
},
|
|
718
|
+
async setRetentionLock(_ref, _until) {
|
|
719
|
+
throw new KindgiApiError(
|
|
720
|
+
notYetWired(
|
|
721
|
+
"artifacts.setRetentionLock",
|
|
722
|
+
"no POST /v1/artifacts/{blobId}/retention-lock route on the API \u2014 retention locks are a per-backend concern (S3 Object Lock, MinIO retention)"
|
|
723
|
+
)
|
|
724
|
+
);
|
|
725
|
+
}
|
|
726
|
+
};
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
// src/resources/audit.ts
|
|
730
|
+
function makeAuditClient(transport) {
|
|
731
|
+
return {
|
|
732
|
+
authz: {
|
|
733
|
+
async list(filter) {
|
|
734
|
+
return transport.request({
|
|
735
|
+
method: "GET",
|
|
736
|
+
path: "/v1/audit/authz",
|
|
737
|
+
query: {
|
|
738
|
+
...filter?.limit !== void 0 && { limit: filter.limit },
|
|
739
|
+
...filter?.cursor !== void 0 && { cursor: filter.cursor },
|
|
740
|
+
...filter?.actorSubject !== void 0 && { actorSubject: filter.actorSubject },
|
|
741
|
+
...filter?.onBehalfOf !== void 0 && { onBehalfOf: filter.onBehalfOf },
|
|
742
|
+
...filter?.action !== void 0 && { action: filter.action },
|
|
743
|
+
...filter?.resource !== void 0 && { resource: filter.resource },
|
|
744
|
+
...filter?.outcome !== void 0 && { outcome: filter.outcome },
|
|
745
|
+
...filter?.runId !== void 0 && { runId: filter.runId },
|
|
746
|
+
...filter?.from !== void 0 && { from: filter.from },
|
|
747
|
+
...filter?.to !== void 0 && { to: filter.to }
|
|
748
|
+
}
|
|
749
|
+
});
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
};
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
// src/resources/auth.ts
|
|
756
|
+
function makeAuthClient(transport) {
|
|
757
|
+
const seg = (s) => encodeURIComponent(s);
|
|
758
|
+
return {
|
|
759
|
+
providers: {
|
|
760
|
+
async list() {
|
|
761
|
+
return transport.request({
|
|
762
|
+
method: "GET",
|
|
763
|
+
path: "/v1/auth/providers"
|
|
764
|
+
});
|
|
765
|
+
},
|
|
766
|
+
async register(input, options) {
|
|
767
|
+
return transport.request({
|
|
768
|
+
method: "POST",
|
|
769
|
+
path: "/v1/auth/providers",
|
|
770
|
+
body: input,
|
|
771
|
+
...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
|
|
772
|
+
});
|
|
773
|
+
},
|
|
774
|
+
async unregister(providerId, options) {
|
|
775
|
+
return transport.request({
|
|
776
|
+
method: "POST",
|
|
777
|
+
path: `/v1/auth/providers/${seg(providerId)}/unregister`,
|
|
778
|
+
...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
|
|
779
|
+
});
|
|
780
|
+
}
|
|
781
|
+
},
|
|
782
|
+
async login(providerId, input, options) {
|
|
783
|
+
return transport.request({
|
|
784
|
+
method: "POST",
|
|
785
|
+
path: `/v1/auth/login/${seg(providerId)}`,
|
|
786
|
+
...input !== void 0 && { body: input },
|
|
787
|
+
...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
|
|
788
|
+
});
|
|
789
|
+
},
|
|
790
|
+
async callback(providerId, input) {
|
|
791
|
+
return transport.request({
|
|
792
|
+
method: "POST",
|
|
793
|
+
path: `/v1/auth/callback/${seg(providerId)}`,
|
|
794
|
+
body: input
|
|
795
|
+
});
|
|
796
|
+
},
|
|
797
|
+
async refresh(options) {
|
|
798
|
+
return transport.request({
|
|
799
|
+
method: "POST",
|
|
800
|
+
path: "/v1/auth/refresh",
|
|
801
|
+
...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
|
|
802
|
+
});
|
|
803
|
+
},
|
|
804
|
+
async logout(options) {
|
|
805
|
+
return transport.request({
|
|
806
|
+
method: "POST",
|
|
807
|
+
path: "/v1/auth/logout",
|
|
808
|
+
...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
|
|
809
|
+
});
|
|
810
|
+
}
|
|
811
|
+
};
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
// src/resources/capabilities.ts
|
|
815
|
+
function makeCapabilitiesClient(transport) {
|
|
816
|
+
return {
|
|
817
|
+
async list(filter) {
|
|
818
|
+
const page = await transport.request({
|
|
819
|
+
method: "GET",
|
|
820
|
+
path: "/v1/capabilities",
|
|
821
|
+
query: {
|
|
822
|
+
...filter?.limit !== void 0 && { limit: filter.limit },
|
|
823
|
+
...filter?.cursor !== void 0 && { cursor: filter.cursor },
|
|
824
|
+
...filter?.feature !== void 0 && { feature: filter.feature }
|
|
825
|
+
}
|
|
826
|
+
});
|
|
827
|
+
return {
|
|
828
|
+
items: page.data,
|
|
829
|
+
...page.nextCursor !== void 0 && {
|
|
830
|
+
nextCursor: page.nextCursor
|
|
831
|
+
}
|
|
832
|
+
};
|
|
833
|
+
},
|
|
834
|
+
async get(capabilityId) {
|
|
835
|
+
return transport.request({
|
|
836
|
+
method: "GET",
|
|
837
|
+
path: `/v1/capabilities/${encodeURIComponent(capabilityId)}`
|
|
838
|
+
});
|
|
839
|
+
},
|
|
840
|
+
async route(_needs) {
|
|
841
|
+
throw new KindgiApiError(
|
|
842
|
+
notYetWired(
|
|
843
|
+
"capabilities.route",
|
|
844
|
+
"no POST /v1/capabilities/route route on the API \u2014 preview routing is a runtime primitive without an HTTP surface yet"
|
|
845
|
+
)
|
|
846
|
+
);
|
|
847
|
+
},
|
|
848
|
+
providers: {
|
|
849
|
+
async list(filter) {
|
|
850
|
+
const page = await transport.request({
|
|
851
|
+
method: "GET",
|
|
852
|
+
path: "/v1/providers",
|
|
853
|
+
query: {
|
|
854
|
+
...filter?.limit !== void 0 && { limit: filter.limit },
|
|
855
|
+
...filter?.cursor !== void 0 && { cursor: filter.cursor },
|
|
856
|
+
...filter?.feature !== void 0 && { feature: filter.feature }
|
|
857
|
+
}
|
|
858
|
+
});
|
|
859
|
+
return {
|
|
860
|
+
items: page.data,
|
|
861
|
+
...page.nextCursor !== void 0 && {
|
|
862
|
+
nextCursor: page.nextCursor
|
|
863
|
+
}
|
|
864
|
+
};
|
|
865
|
+
},
|
|
866
|
+
async get(id) {
|
|
867
|
+
return transport.request({
|
|
868
|
+
method: "GET",
|
|
869
|
+
path: `/v1/providers/${encodeURIComponent(id)}`
|
|
870
|
+
});
|
|
871
|
+
},
|
|
872
|
+
async configure(spec, options) {
|
|
873
|
+
return transport.request({
|
|
874
|
+
method: "POST",
|
|
875
|
+
path: "/v1/providers",
|
|
876
|
+
body: spec,
|
|
877
|
+
...options?.idempotencyKey !== void 0 && {
|
|
878
|
+
idempotencyKey: options.idempotencyKey
|
|
879
|
+
}
|
|
880
|
+
});
|
|
881
|
+
},
|
|
882
|
+
async capabilitiesFor(id) {
|
|
883
|
+
const envelope = await transport.request({
|
|
884
|
+
method: "GET",
|
|
885
|
+
path: `/v1/providers/${encodeURIComponent(id)}/capabilities`
|
|
886
|
+
});
|
|
887
|
+
return envelope.data;
|
|
888
|
+
},
|
|
889
|
+
async enable(_id) {
|
|
890
|
+
throw new KindgiApiError(
|
|
891
|
+
notYetWired(
|
|
892
|
+
"capabilities.providers.enable",
|
|
893
|
+
"no POST /v1/providers/{id}/enable route on the API \u2014 wire has no active/inactive state"
|
|
894
|
+
)
|
|
895
|
+
);
|
|
896
|
+
},
|
|
897
|
+
async disable(_id) {
|
|
898
|
+
throw new KindgiApiError(
|
|
899
|
+
notYetWired(
|
|
900
|
+
"capabilities.providers.disable",
|
|
901
|
+
"no POST /v1/providers/{id}/disable route on the API \u2014 wire has no active/inactive state"
|
|
902
|
+
)
|
|
903
|
+
);
|
|
904
|
+
},
|
|
905
|
+
async delete(id, options) {
|
|
906
|
+
return transport.request({
|
|
907
|
+
method: "POST",
|
|
908
|
+
path: `/v1/providers/${encodeURIComponent(id)}/unregister`,
|
|
909
|
+
body: {},
|
|
910
|
+
...options?.idempotencyKey !== void 0 && {
|
|
911
|
+
idempotencyKey: options.idempotencyKey
|
|
912
|
+
}
|
|
913
|
+
});
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
};
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
// src/resources/compliance.ts
|
|
920
|
+
function makeComplianceClient(transport) {
|
|
921
|
+
return {
|
|
922
|
+
evidence: {
|
|
923
|
+
async list(filter) {
|
|
924
|
+
return transport.request({
|
|
925
|
+
method: "GET",
|
|
926
|
+
path: "/v1/compliance/evidence",
|
|
927
|
+
query: {
|
|
928
|
+
...filter?.limit !== void 0 && { limit: filter.limit },
|
|
929
|
+
...filter?.cursor !== void 0 && { cursor: filter.cursor },
|
|
930
|
+
...filter?.runId !== void 0 && { runId: filter.runId },
|
|
931
|
+
...filter?.agentId !== void 0 && { agentId: filter.agentId },
|
|
932
|
+
...filter?.flowId !== void 0 && { flowId: filter.flowId },
|
|
933
|
+
...filter?.kind !== void 0 && { kind: filter.kind },
|
|
934
|
+
...filter?.from !== void 0 && { from: filter.from },
|
|
935
|
+
...filter?.to !== void 0 && { to: filter.to }
|
|
936
|
+
}
|
|
937
|
+
});
|
|
938
|
+
},
|
|
939
|
+
async get(evidenceId) {
|
|
940
|
+
return transport.request({
|
|
941
|
+
method: "GET",
|
|
942
|
+
path: `/v1/compliance/evidence/${encodeURIComponent(evidenceId)}`
|
|
943
|
+
});
|
|
944
|
+
},
|
|
945
|
+
async export(input, options) {
|
|
946
|
+
return transport.request({
|
|
947
|
+
method: "POST",
|
|
948
|
+
path: "/v1/compliance/evidence/export",
|
|
949
|
+
body: input,
|
|
950
|
+
...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
|
|
951
|
+
});
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
};
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
// src/resources/conversations.ts
|
|
958
|
+
function makeConversationsClient(transport) {
|
|
959
|
+
return {
|
|
960
|
+
async open(input, options) {
|
|
961
|
+
return transport.request({
|
|
962
|
+
method: "POST",
|
|
963
|
+
path: "/v1/conversations",
|
|
964
|
+
body: {
|
|
965
|
+
agentId: input.agentId,
|
|
966
|
+
agentVersion: input.agentVersion,
|
|
967
|
+
...input.title !== void 0 && { title: input.title },
|
|
968
|
+
...input.scope !== void 0 && { scope: input.scope },
|
|
969
|
+
...input.participantId !== void 0 && { participantId: input.participantId },
|
|
970
|
+
...input.metadata !== void 0 && { metadata: input.metadata }
|
|
971
|
+
},
|
|
972
|
+
...options?.idempotencyKey !== void 0 && {
|
|
973
|
+
idempotencyKey: options.idempotencyKey
|
|
974
|
+
}
|
|
975
|
+
});
|
|
976
|
+
},
|
|
977
|
+
async get(id) {
|
|
978
|
+
return transport.request({
|
|
979
|
+
method: "GET",
|
|
980
|
+
path: `/v1/conversations/${encodeURIComponent(id)}`
|
|
981
|
+
});
|
|
982
|
+
},
|
|
983
|
+
async list(filter) {
|
|
984
|
+
const statusParam = singleStatusQuery("conversations.list", filter?.status);
|
|
985
|
+
const page = await transport.request({
|
|
986
|
+
method: "GET",
|
|
987
|
+
path: "/v1/conversations",
|
|
988
|
+
query: {
|
|
989
|
+
...filter?.limit !== void 0 && { limit: filter.limit },
|
|
990
|
+
...filter?.cursor !== void 0 && { cursor: filter.cursor },
|
|
991
|
+
...statusParam !== void 0 && { status: statusParam },
|
|
992
|
+
...filter?.agent !== void 0 && { agentId: filter.agent }
|
|
993
|
+
}
|
|
994
|
+
});
|
|
995
|
+
return {
|
|
996
|
+
items: page.data,
|
|
997
|
+
...page.nextCursor !== void 0 && { nextCursor: page.nextCursor }
|
|
998
|
+
};
|
|
999
|
+
},
|
|
1000
|
+
async close(id, options) {
|
|
1001
|
+
return transport.request({
|
|
1002
|
+
method: "POST",
|
|
1003
|
+
path: `/v1/conversations/${encodeURIComponent(id)}/close`,
|
|
1004
|
+
body: {},
|
|
1005
|
+
...options?.idempotencyKey !== void 0 && {
|
|
1006
|
+
idempotencyKey: options.idempotencyKey
|
|
1007
|
+
}
|
|
1008
|
+
});
|
|
1009
|
+
},
|
|
1010
|
+
async messages(id, filter) {
|
|
1011
|
+
const page = await transport.request({
|
|
1012
|
+
method: "GET",
|
|
1013
|
+
path: `/v1/conversations/${encodeURIComponent(id)}/messages`,
|
|
1014
|
+
query: {
|
|
1015
|
+
...filter?.limit !== void 0 && { limit: filter.limit },
|
|
1016
|
+
...filter?.cursor !== void 0 && { cursor: filter.cursor }
|
|
1017
|
+
}
|
|
1018
|
+
});
|
|
1019
|
+
return {
|
|
1020
|
+
items: page.data,
|
|
1021
|
+
...page.nextCursor !== void 0 && { nextCursor: page.nextCursor }
|
|
1022
|
+
};
|
|
1023
|
+
}
|
|
1024
|
+
};
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
// src/resources/cost.ts
|
|
1028
|
+
function makeCostClient(transport) {
|
|
1029
|
+
return {
|
|
1030
|
+
usage: {
|
|
1031
|
+
async query(filter) {
|
|
1032
|
+
const page = await transport.request({
|
|
1033
|
+
method: "GET",
|
|
1034
|
+
path: "/v1/cost/records",
|
|
1035
|
+
query: {
|
|
1036
|
+
...filter?.limit !== void 0 && { limit: filter.limit },
|
|
1037
|
+
...filter?.cursor !== void 0 && { cursor: filter.cursor },
|
|
1038
|
+
...filter?.runId !== void 0 && { runId: filter.runId },
|
|
1039
|
+
...filter?.agentId !== void 0 && { agentId: filter.agentId },
|
|
1040
|
+
...filter?.conversationId !== void 0 && {
|
|
1041
|
+
conversationId: filter.conversationId
|
|
1042
|
+
},
|
|
1043
|
+
...filter?.category !== void 0 && { category: filter.category },
|
|
1044
|
+
...filter?.providerId !== void 0 && {
|
|
1045
|
+
providerId: filter.providerId
|
|
1046
|
+
},
|
|
1047
|
+
...filter?.from !== void 0 && { from: filter.from },
|
|
1048
|
+
...filter?.to !== void 0 && { to: filter.to }
|
|
1049
|
+
}
|
|
1050
|
+
});
|
|
1051
|
+
return {
|
|
1052
|
+
items: page.data,
|
|
1053
|
+
...page.nextCursor !== void 0 && {
|
|
1054
|
+
nextCursor: page.nextCursor
|
|
1055
|
+
}
|
|
1056
|
+
};
|
|
1057
|
+
},
|
|
1058
|
+
async get(recordId) {
|
|
1059
|
+
return transport.request({
|
|
1060
|
+
method: "GET",
|
|
1061
|
+
path: `/v1/cost/records/${encodeURIComponent(recordId)}`
|
|
1062
|
+
});
|
|
1063
|
+
},
|
|
1064
|
+
async summary(input) {
|
|
1065
|
+
return transport.request({
|
|
1066
|
+
method: "GET",
|
|
1067
|
+
path: "/v1/cost/aggregate",
|
|
1068
|
+
query: {
|
|
1069
|
+
from: input.from,
|
|
1070
|
+
to: input.to,
|
|
1071
|
+
...input.groupBy !== void 0 && { groupBy: input.groupBy.join(",") },
|
|
1072
|
+
...input.category !== void 0 && { category: input.category },
|
|
1073
|
+
...input.providerId !== void 0 && {
|
|
1074
|
+
providerId: input.providerId
|
|
1075
|
+
},
|
|
1076
|
+
...input.agentId !== void 0 && { agentId: input.agentId },
|
|
1077
|
+
...input.runId !== void 0 && { runId: input.runId },
|
|
1078
|
+
...input.conversationId !== void 0 && {
|
|
1079
|
+
conversationId: input.conversationId
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
});
|
|
1083
|
+
}
|
|
1084
|
+
},
|
|
1085
|
+
budgets: {
|
|
1086
|
+
async get() {
|
|
1087
|
+
throw new KindgiApiError(
|
|
1088
|
+
notYetWired(
|
|
1089
|
+
"cost.budgets.get",
|
|
1090
|
+
"no GET /v1/tenant/budgets route on the API \u2014 budget enforcement primitive not surfaced on the wire"
|
|
1091
|
+
)
|
|
1092
|
+
);
|
|
1093
|
+
},
|
|
1094
|
+
async set(_input) {
|
|
1095
|
+
throw new KindgiApiError(
|
|
1096
|
+
notYetWired(
|
|
1097
|
+
"cost.budgets.set",
|
|
1098
|
+
"no PUT /v1/tenant/budgets route on the API \u2014 admin-scope budget writes not surfaced yet"
|
|
1099
|
+
)
|
|
1100
|
+
);
|
|
1101
|
+
},
|
|
1102
|
+
async getRemaining() {
|
|
1103
|
+
throw new KindgiApiError(
|
|
1104
|
+
notYetWired(
|
|
1105
|
+
"cost.budgets.getRemaining",
|
|
1106
|
+
"no GET /v1/tenant/budgets/remaining route on the API \u2014 window-remaining computation not surfaced yet"
|
|
1107
|
+
)
|
|
1108
|
+
);
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
};
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
// src/resources/deployments.ts
|
|
1115
|
+
function makeDeploymentsClient(transport) {
|
|
1116
|
+
return {
|
|
1117
|
+
async register(input, options) {
|
|
1118
|
+
return transport.request({
|
|
1119
|
+
method: "POST",
|
|
1120
|
+
path: "/v1/deployments",
|
|
1121
|
+
body: input,
|
|
1122
|
+
...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
|
|
1123
|
+
});
|
|
1124
|
+
},
|
|
1125
|
+
async list(filter) {
|
|
1126
|
+
return transport.request({
|
|
1127
|
+
method: "GET",
|
|
1128
|
+
path: "/v1/deployments",
|
|
1129
|
+
query: {
|
|
1130
|
+
...filter?.limit !== void 0 && { limit: filter.limit },
|
|
1131
|
+
...filter?.cursor !== void 0 && { cursor: filter.cursor },
|
|
1132
|
+
...filter?.imageRefPrefix !== void 0 && { imageRefPrefix: filter.imageRefPrefix },
|
|
1133
|
+
...filter?.signerKeyId !== void 0 && { signerKeyId: filter.signerKeyId }
|
|
1134
|
+
}
|
|
1135
|
+
});
|
|
1136
|
+
},
|
|
1137
|
+
async get(deploymentId) {
|
|
1138
|
+
return transport.request({
|
|
1139
|
+
method: "GET",
|
|
1140
|
+
path: `/v1/deployments/${encodeURIComponent(deploymentId)}`
|
|
1141
|
+
});
|
|
1142
|
+
},
|
|
1143
|
+
async syncSecrets(deploymentId, input, options) {
|
|
1144
|
+
return transport.request({
|
|
1145
|
+
method: "POST",
|
|
1146
|
+
path: `/v1/deployments/${encodeURIComponent(deploymentId)}/secrets`,
|
|
1147
|
+
body: input,
|
|
1148
|
+
...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
|
|
1149
|
+
});
|
|
1150
|
+
}
|
|
1151
|
+
};
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
// src/scope-wire.ts
|
|
1155
|
+
function scopeForBody(scope) {
|
|
1156
|
+
if (scope.kind === "tenant") return { kind: "tenant" };
|
|
1157
|
+
if (scope.kind === "org") return { kind: "org", orgId: scope.orgId };
|
|
1158
|
+
return { kind: "project", projectId: scope.projectId };
|
|
1159
|
+
}
|
|
1160
|
+
function scopeToQuery(scope) {
|
|
1161
|
+
if (scope.kind === "tenant") return { scopeKind: "tenant" };
|
|
1162
|
+
if (scope.kind === "org") {
|
|
1163
|
+
return { scopeKind: "org", scopeId: scope.orgId };
|
|
1164
|
+
}
|
|
1165
|
+
return { scopeKind: "project", scopeId: scope.projectId };
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
// src/resources/env.ts
|
|
1169
|
+
function makeEnvClient(transport) {
|
|
1170
|
+
return {
|
|
1171
|
+
async list(input) {
|
|
1172
|
+
const q = scopeToQuery(input.scope);
|
|
1173
|
+
const page = await transport.request({
|
|
1174
|
+
method: "GET",
|
|
1175
|
+
path: "/v1/env",
|
|
1176
|
+
query: {
|
|
1177
|
+
envName: input.envName,
|
|
1178
|
+
scopeKind: q.scopeKind,
|
|
1179
|
+
...q.scopeId !== void 0 && { scopeId: q.scopeId },
|
|
1180
|
+
...input.cursor !== void 0 && {
|
|
1181
|
+
cursor: input.cursor
|
|
1182
|
+
},
|
|
1183
|
+
...input.namePrefix !== void 0 && { namePrefix: input.namePrefix },
|
|
1184
|
+
...input.limit !== void 0 && { limit: input.limit }
|
|
1185
|
+
}
|
|
1186
|
+
});
|
|
1187
|
+
return {
|
|
1188
|
+
data: page.data,
|
|
1189
|
+
...page.nextCursor !== void 0 && {
|
|
1190
|
+
nextCursor: page.nextCursor
|
|
1191
|
+
}
|
|
1192
|
+
};
|
|
1193
|
+
},
|
|
1194
|
+
async get(input) {
|
|
1195
|
+
const q = scopeToQuery(input.scope);
|
|
1196
|
+
try {
|
|
1197
|
+
return await transport.request({
|
|
1198
|
+
method: "GET",
|
|
1199
|
+
path: `/v1/env/${encodeURIComponent(input.name)}`,
|
|
1200
|
+
query: {
|
|
1201
|
+
envName: input.envName,
|
|
1202
|
+
scopeKind: q.scopeKind,
|
|
1203
|
+
...q.scopeId !== void 0 && { scopeId: q.scopeId }
|
|
1204
|
+
}
|
|
1205
|
+
});
|
|
1206
|
+
} catch (err) {
|
|
1207
|
+
if (isEnvNotFound(err)) return null;
|
|
1208
|
+
throw err;
|
|
1209
|
+
}
|
|
1210
|
+
},
|
|
1211
|
+
async set(input) {
|
|
1212
|
+
const q = scopeToQuery(input.scope);
|
|
1213
|
+
try {
|
|
1214
|
+
const record = await transport.request({
|
|
1215
|
+
method: "PUT",
|
|
1216
|
+
path: `/v1/env/${encodeURIComponent(input.name)}`,
|
|
1217
|
+
query: {
|
|
1218
|
+
envName: input.envName,
|
|
1219
|
+
scopeKind: q.scopeKind,
|
|
1220
|
+
...q.scopeId !== void 0 && { scopeId: q.scopeId }
|
|
1221
|
+
},
|
|
1222
|
+
body: {
|
|
1223
|
+
scope: scopeForBody(input.scope),
|
|
1224
|
+
envName: input.envName,
|
|
1225
|
+
name: input.name,
|
|
1226
|
+
value: input.value,
|
|
1227
|
+
...input.ifRevision !== void 0 && { ifRevision: input.ifRevision },
|
|
1228
|
+
...input.tags !== void 0 && { tags: input.tags }
|
|
1229
|
+
}
|
|
1230
|
+
});
|
|
1231
|
+
return { kind: "ok", record };
|
|
1232
|
+
} catch (err) {
|
|
1233
|
+
const conflict = tryReadRevisionConflict(err);
|
|
1234
|
+
if (conflict !== null) {
|
|
1235
|
+
return { kind: "revision-conflict", currentRevision: conflict };
|
|
1236
|
+
}
|
|
1237
|
+
throw err;
|
|
1238
|
+
}
|
|
1239
|
+
},
|
|
1240
|
+
async delete(input) {
|
|
1241
|
+
const q = scopeToQuery(input.scope);
|
|
1242
|
+
return transport.request({
|
|
1243
|
+
method: "DELETE",
|
|
1244
|
+
path: `/v1/env/${encodeURIComponent(input.name)}`,
|
|
1245
|
+
query: {
|
|
1246
|
+
envName: input.envName,
|
|
1247
|
+
scopeKind: q.scopeKind,
|
|
1248
|
+
...q.scopeId !== void 0 && { scopeId: q.scopeId }
|
|
1249
|
+
}
|
|
1250
|
+
});
|
|
1251
|
+
}
|
|
1252
|
+
};
|
|
1253
|
+
}
|
|
1254
|
+
function isEnvNotFound(err) {
|
|
1255
|
+
if (err === null || typeof err !== "object") return false;
|
|
1256
|
+
const asAny = err;
|
|
1257
|
+
const inner = asAny.error;
|
|
1258
|
+
if (inner === void 0) return false;
|
|
1259
|
+
const code = inner.code;
|
|
1260
|
+
const serverCode = inner.serverCode;
|
|
1261
|
+
if (code === "env-not-found") return true;
|
|
1262
|
+
if (code === "not-found" && typeof inner.resource === "object" && inner.resource !== null && inner.resource.kind === "env") {
|
|
1263
|
+
return true;
|
|
1264
|
+
}
|
|
1265
|
+
if (code === "server" && serverCode === "env-not-found") return true;
|
|
1266
|
+
return false;
|
|
1267
|
+
}
|
|
1268
|
+
function tryReadRevisionConflict(err) {
|
|
1269
|
+
if (err === null || typeof err !== "object") return null;
|
|
1270
|
+
const asAny = err;
|
|
1271
|
+
const inner = asAny.error;
|
|
1272
|
+
if (inner === void 0) return null;
|
|
1273
|
+
const isConflict = inner.code === "env-write-conflict" || inner.code === "conflict" || inner.serverCode === "env-write-conflict";
|
|
1274
|
+
if (!isConflict) return null;
|
|
1275
|
+
const fromFields = inner.fields?.currentRevision;
|
|
1276
|
+
if (typeof fromFields === "number") return fromFields;
|
|
1277
|
+
const cur = inner.currentRevision;
|
|
1278
|
+
if (typeof cur !== "number") return null;
|
|
1279
|
+
return cur;
|
|
1280
|
+
}
|
|
1281
|
+
|
|
1282
|
+
// src/resources/eval-runs.ts
|
|
1283
|
+
function makeEvalRunsClient(transport) {
|
|
1284
|
+
const seg = (s) => encodeURIComponent(s);
|
|
1285
|
+
return {
|
|
1286
|
+
async start(suiteId, input, options) {
|
|
1287
|
+
return transport.request({
|
|
1288
|
+
method: "POST",
|
|
1289
|
+
path: `/v1/eval-suites/${seg(suiteId)}/runs`,
|
|
1290
|
+
body: { ...input, projectId: options.projectId },
|
|
1291
|
+
...options.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
|
|
1292
|
+
});
|
|
1293
|
+
},
|
|
1294
|
+
async list(filter) {
|
|
1295
|
+
return transport.request({
|
|
1296
|
+
method: "GET",
|
|
1297
|
+
path: "/v1/eval-runs",
|
|
1298
|
+
query: {
|
|
1299
|
+
...filter?.limit !== void 0 && { limit: filter.limit },
|
|
1300
|
+
...filter?.cursor !== void 0 && { cursor: filter.cursor },
|
|
1301
|
+
...filter?.suiteId !== void 0 && { suiteId: filter.suiteId },
|
|
1302
|
+
...filter?.status !== void 0 && { status: filter.status },
|
|
1303
|
+
...filter?.agentId !== void 0 && { agentId: filter.agentId }
|
|
1304
|
+
}
|
|
1305
|
+
});
|
|
1306
|
+
},
|
|
1307
|
+
async get(runId) {
|
|
1308
|
+
return transport.request({
|
|
1309
|
+
method: "GET",
|
|
1310
|
+
path: `/v1/eval-runs/${seg(runId)}`
|
|
1311
|
+
});
|
|
1312
|
+
},
|
|
1313
|
+
async cancel(runId) {
|
|
1314
|
+
return transport.request({
|
|
1315
|
+
method: "POST",
|
|
1316
|
+
path: `/v1/eval-runs/${seg(runId)}/cancel`
|
|
1317
|
+
});
|
|
1318
|
+
},
|
|
1319
|
+
events(runId, options) {
|
|
1320
|
+
const url = `${transport.apiUrl}/v1/eval-runs/${seg(runId)}/events`;
|
|
1321
|
+
const source = readSse({
|
|
1322
|
+
url,
|
|
1323
|
+
headers: transport.authHeaders(),
|
|
1324
|
+
fetchImpl: transport.fetchImpl,
|
|
1325
|
+
...options?.signal !== void 0 && { signal: options.signal },
|
|
1326
|
+
...options?.initialBackoffMs !== void 0 && {
|
|
1327
|
+
initialBackoffMs: options.initialBackoffMs
|
|
1328
|
+
},
|
|
1329
|
+
...options?.maxBackoffMs !== void 0 && {
|
|
1330
|
+
maxBackoffMs: options.maxBackoffMs
|
|
1331
|
+
}
|
|
1332
|
+
});
|
|
1333
|
+
return unwrapSseData(source);
|
|
1334
|
+
}
|
|
1335
|
+
};
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
// src/resources/eval-suites.ts
|
|
1339
|
+
function makeEvalSuitesClient(transport) {
|
|
1340
|
+
const seg = (s) => encodeURIComponent(s);
|
|
1341
|
+
return {
|
|
1342
|
+
async publish(input, options) {
|
|
1343
|
+
return transport.request({
|
|
1344
|
+
method: "POST",
|
|
1345
|
+
path: "/v1/eval-suites",
|
|
1346
|
+
body: { ...input, projectId: options.projectId },
|
|
1347
|
+
...options.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
|
|
1348
|
+
});
|
|
1349
|
+
},
|
|
1350
|
+
async list(filter) {
|
|
1351
|
+
return transport.request({
|
|
1352
|
+
method: "GET",
|
|
1353
|
+
path: "/v1/eval-suites",
|
|
1354
|
+
query: {
|
|
1355
|
+
...filter?.limit !== void 0 && { limit: filter.limit },
|
|
1356
|
+
...filter?.cursor !== void 0 && { cursor: filter.cursor },
|
|
1357
|
+
...filter?.kind !== void 0 && { kind: filter.kind },
|
|
1358
|
+
...filter?.name !== void 0 && { name: filter.name },
|
|
1359
|
+
...filter?.scopeKind !== void 0 && { scopeKind: filter.scopeKind },
|
|
1360
|
+
...filter?.scopeId !== void 0 && { scopeId: filter.scopeId },
|
|
1361
|
+
...filter?.inherit !== void 0 && { inherit: filter.inherit }
|
|
1362
|
+
}
|
|
1363
|
+
});
|
|
1364
|
+
},
|
|
1365
|
+
async get(suiteId) {
|
|
1366
|
+
return transport.request({
|
|
1367
|
+
method: "GET",
|
|
1368
|
+
path: `/v1/eval-suites/${seg(suiteId)}`
|
|
1369
|
+
});
|
|
1370
|
+
},
|
|
1371
|
+
versions: {
|
|
1372
|
+
async list(suiteId, filter) {
|
|
1373
|
+
return transport.request({
|
|
1374
|
+
method: "GET",
|
|
1375
|
+
path: `/v1/eval-suites/${seg(suiteId)}/versions`,
|
|
1376
|
+
query: {
|
|
1377
|
+
...filter?.limit !== void 0 && { limit: filter.limit },
|
|
1378
|
+
...filter?.cursor !== void 0 && { cursor: filter.cursor }
|
|
1379
|
+
}
|
|
1380
|
+
});
|
|
1381
|
+
},
|
|
1382
|
+
async get(suiteId, version) {
|
|
1383
|
+
return transport.request({
|
|
1384
|
+
method: "GET",
|
|
1385
|
+
path: `/v1/eval-suites/${seg(suiteId)}/versions/${seg(version)}`
|
|
1386
|
+
});
|
|
1387
|
+
},
|
|
1388
|
+
async unregister(suiteId, version, options) {
|
|
1389
|
+
return transport.request({
|
|
1390
|
+
method: "POST",
|
|
1391
|
+
path: `/v1/eval-suites/${seg(suiteId)}/versions/${seg(version)}/unregister`,
|
|
1392
|
+
...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
|
|
1393
|
+
});
|
|
1394
|
+
},
|
|
1395
|
+
async reinstate(suiteId, version, options) {
|
|
1396
|
+
return transport.request({
|
|
1397
|
+
method: "POST",
|
|
1398
|
+
path: `/v1/eval-suites/${seg(suiteId)}/versions/${seg(version)}/reinstate`,
|
|
1399
|
+
...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
|
|
1400
|
+
});
|
|
1401
|
+
}
|
|
1402
|
+
}
|
|
1403
|
+
};
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
// src/resources/event-triggers.ts
|
|
1407
|
+
function makeEventTriggersClient(transport) {
|
|
1408
|
+
return {
|
|
1409
|
+
async register(input, options) {
|
|
1410
|
+
return transport.request({
|
|
1411
|
+
method: "POST",
|
|
1412
|
+
path: "/v1/event-triggers",
|
|
1413
|
+
body: input,
|
|
1414
|
+
...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
|
|
1415
|
+
});
|
|
1416
|
+
},
|
|
1417
|
+
async list(filter) {
|
|
1418
|
+
return transport.request({
|
|
1419
|
+
method: "GET",
|
|
1420
|
+
path: "/v1/event-triggers",
|
|
1421
|
+
query: {
|
|
1422
|
+
...filter?.limit !== void 0 && { limit: filter.limit },
|
|
1423
|
+
...filter?.cursor !== void 0 && { cursor: filter.cursor },
|
|
1424
|
+
...filter?.status !== void 0 && { status: filter.status }
|
|
1425
|
+
}
|
|
1426
|
+
});
|
|
1427
|
+
},
|
|
1428
|
+
async get(triggerId) {
|
|
1429
|
+
return transport.request({
|
|
1430
|
+
method: "GET",
|
|
1431
|
+
path: `/v1/event-triggers/${encodeURIComponent(triggerId)}`
|
|
1432
|
+
});
|
|
1433
|
+
},
|
|
1434
|
+
async update(triggerId, input, options) {
|
|
1435
|
+
return transport.request({
|
|
1436
|
+
method: "PATCH",
|
|
1437
|
+
path: `/v1/event-triggers/${encodeURIComponent(triggerId)}`,
|
|
1438
|
+
body: input,
|
|
1439
|
+
...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
|
|
1440
|
+
});
|
|
1441
|
+
},
|
|
1442
|
+
async pause(triggerId, options) {
|
|
1443
|
+
return transport.request({
|
|
1444
|
+
method: "POST",
|
|
1445
|
+
path: `/v1/event-triggers/${encodeURIComponent(triggerId)}/pause`,
|
|
1446
|
+
...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
|
|
1447
|
+
});
|
|
1448
|
+
},
|
|
1449
|
+
async resume(triggerId, options) {
|
|
1450
|
+
return transport.request({
|
|
1451
|
+
method: "POST",
|
|
1452
|
+
path: `/v1/event-triggers/${encodeURIComponent(triggerId)}/resume`,
|
|
1453
|
+
...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
|
|
1454
|
+
});
|
|
1455
|
+
},
|
|
1456
|
+
async unregister(triggerId, options) {
|
|
1457
|
+
return transport.request({
|
|
1458
|
+
method: "POST",
|
|
1459
|
+
path: `/v1/event-triggers/${encodeURIComponent(triggerId)}/unregister`,
|
|
1460
|
+
...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
|
|
1461
|
+
});
|
|
1462
|
+
}
|
|
1463
|
+
};
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1466
|
+
// src/resources/events.ts
|
|
1467
|
+
function makeEventsClient(_transport) {
|
|
1468
|
+
return {
|
|
1469
|
+
async emit(_spec) {
|
|
1470
|
+
throw new KindgiApiError(
|
|
1471
|
+
notYetWired(
|
|
1472
|
+
"events.emit",
|
|
1473
|
+
"no POST /v1/events route on the API \u2014 outbound event-emit surface has not landed (runtime event-bus primitive is live; HTTP surface pending)"
|
|
1474
|
+
)
|
|
1475
|
+
);
|
|
1476
|
+
},
|
|
1477
|
+
async subscribe(_spec) {
|
|
1478
|
+
throw new KindgiApiError(
|
|
1479
|
+
notYetWired(
|
|
1480
|
+
"events.subscribe",
|
|
1481
|
+
"no POST /v1/events/subscriptions route on the API \u2014 subscription registration surface has not landed"
|
|
1482
|
+
)
|
|
1483
|
+
);
|
|
1484
|
+
},
|
|
1485
|
+
subscriptions: {
|
|
1486
|
+
async list() {
|
|
1487
|
+
throw new KindgiApiError(
|
|
1488
|
+
notYetWired(
|
|
1489
|
+
"events.subscriptions.list",
|
|
1490
|
+
"no GET /v1/events/subscriptions route on the API"
|
|
1491
|
+
)
|
|
1492
|
+
);
|
|
1493
|
+
},
|
|
1494
|
+
async get(_id) {
|
|
1495
|
+
throw new KindgiApiError(
|
|
1496
|
+
notYetWired(
|
|
1497
|
+
"events.subscriptions.get",
|
|
1498
|
+
"no GET /v1/events/subscriptions/{id} route on the API"
|
|
1499
|
+
)
|
|
1500
|
+
);
|
|
1501
|
+
},
|
|
1502
|
+
async delete(_id) {
|
|
1503
|
+
throw new KindgiApiError(
|
|
1504
|
+
notYetWired(
|
|
1505
|
+
"events.subscriptions.delete",
|
|
1506
|
+
"no DELETE /v1/events/subscriptions/{id} route on the API"
|
|
1507
|
+
)
|
|
1508
|
+
);
|
|
1509
|
+
}
|
|
1510
|
+
},
|
|
1511
|
+
stream(_subscriptionId) {
|
|
1512
|
+
const iter = {
|
|
1513
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
1514
|
+
[Symbol.asyncIterator]() {
|
|
1515
|
+
return {
|
|
1516
|
+
next() {
|
|
1517
|
+
return Promise.reject(
|
|
1518
|
+
new KindgiApiError(
|
|
1519
|
+
notYetWired(
|
|
1520
|
+
"events.stream",
|
|
1521
|
+
"no GET /v1/events/subscriptions/{id}/stream route on the API \u2014 subscription-scoped SSE surface has not landed (runtime event bus is live; SDK-side SSE reader is ready via readSse; HTTP route pending). Use client.runs.stream(runId) for live run-scoped events."
|
|
1522
|
+
)
|
|
1523
|
+
)
|
|
1524
|
+
);
|
|
1525
|
+
}
|
|
1526
|
+
};
|
|
1527
|
+
}
|
|
1528
|
+
};
|
|
1529
|
+
return iter;
|
|
1530
|
+
},
|
|
1531
|
+
async query(_filter) {
|
|
1532
|
+
throw new KindgiApiError(
|
|
1533
|
+
notYetWired(
|
|
1534
|
+
"events.query",
|
|
1535
|
+
"no GET /v1/events route on the API \u2014 event-history query surface has not landed"
|
|
1536
|
+
)
|
|
1537
|
+
);
|
|
1538
|
+
}
|
|
1539
|
+
};
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1542
|
+
// src/resources/flows.ts
|
|
1543
|
+
function makeFlowsClient(transport) {
|
|
1544
|
+
return {
|
|
1545
|
+
async define(flow, options) {
|
|
1546
|
+
const result = await transport.request({
|
|
1547
|
+
method: "POST",
|
|
1548
|
+
path: "/v1/flows",
|
|
1549
|
+
body: { ...flow, projectId: options.projectId },
|
|
1550
|
+
...options.idempotencyKey !== void 0 && {
|
|
1551
|
+
idempotencyKey: options.idempotencyKey
|
|
1552
|
+
}
|
|
1553
|
+
});
|
|
1554
|
+
return {
|
|
1555
|
+
flowId: result.flowId,
|
|
1556
|
+
version: result.version
|
|
1557
|
+
};
|
|
1558
|
+
},
|
|
1559
|
+
async validate(_graph) {
|
|
1560
|
+
throw new KindgiApiError(
|
|
1561
|
+
notYetWired(
|
|
1562
|
+
"flows.validate",
|
|
1563
|
+
"no POST /v1/flows/validate route on the API \u2014 validation is inline on define() (server returns 400 validation-failed)"
|
|
1564
|
+
)
|
|
1565
|
+
);
|
|
1566
|
+
},
|
|
1567
|
+
async get(id) {
|
|
1568
|
+
return transport.request({
|
|
1569
|
+
method: "GET",
|
|
1570
|
+
path: `/v1/flows/${encodeURIComponent(id)}`
|
|
1571
|
+
});
|
|
1572
|
+
},
|
|
1573
|
+
async list(filter) {
|
|
1574
|
+
const page = await transport.request({
|
|
1575
|
+
method: "GET",
|
|
1576
|
+
path: "/v1/flows",
|
|
1577
|
+
query: {
|
|
1578
|
+
...filter?.limit !== void 0 && { limit: filter.limit },
|
|
1579
|
+
...filter?.cursor !== void 0 && { cursor: filter.cursor },
|
|
1580
|
+
...filter?.name !== void 0 && { name: filter.name }
|
|
1581
|
+
}
|
|
1582
|
+
});
|
|
1583
|
+
return {
|
|
1584
|
+
items: page.data,
|
|
1585
|
+
...page.nextCursor !== void 0 && {
|
|
1586
|
+
nextCursor: page.nextCursor
|
|
1587
|
+
}
|
|
1588
|
+
};
|
|
1589
|
+
},
|
|
1590
|
+
async versions(id, filter) {
|
|
1591
|
+
const page = await transport.request({
|
|
1592
|
+
method: "GET",
|
|
1593
|
+
path: `/v1/flows/${encodeURIComponent(id)}/versions`,
|
|
1594
|
+
query: {
|
|
1595
|
+
...filter?.limit !== void 0 && { limit: filter.limit },
|
|
1596
|
+
...filter?.cursor !== void 0 && { cursor: filter.cursor }
|
|
1597
|
+
}
|
|
1598
|
+
});
|
|
1599
|
+
return {
|
|
1600
|
+
items: page.data,
|
|
1601
|
+
...page.nextCursor !== void 0 && {
|
|
1602
|
+
nextCursor: page.nextCursor
|
|
1603
|
+
}
|
|
1604
|
+
};
|
|
1605
|
+
},
|
|
1606
|
+
async getVersion(id, version) {
|
|
1607
|
+
return transport.request({
|
|
1608
|
+
method: "GET",
|
|
1609
|
+
path: `/v1/flows/${encodeURIComponent(id)}/versions/${encodeURIComponent(version)}`
|
|
1610
|
+
});
|
|
1611
|
+
},
|
|
1612
|
+
async delete(id, version, options) {
|
|
1613
|
+
await transport.request({
|
|
1614
|
+
method: "POST",
|
|
1615
|
+
path: `/v1/flows/${encodeURIComponent(id)}/versions/${encodeURIComponent(version)}/unregister`,
|
|
1616
|
+
body: {},
|
|
1617
|
+
discardResponse: true,
|
|
1618
|
+
...options?.idempotencyKey !== void 0 && {
|
|
1619
|
+
idempotencyKey: options.idempotencyKey
|
|
1620
|
+
}
|
|
1621
|
+
});
|
|
1622
|
+
},
|
|
1623
|
+
async reinstateVersion(id, version, options) {
|
|
1624
|
+
const wire = await transport.request({
|
|
1625
|
+
method: "POST",
|
|
1626
|
+
path: `/v1/flows/${encodeURIComponent(id)}/versions/${encodeURIComponent(version)}/reinstate`,
|
|
1627
|
+
...options?.idempotencyKey !== void 0 && {
|
|
1628
|
+
idempotencyKey: options.idempotencyKey
|
|
1629
|
+
}
|
|
1630
|
+
});
|
|
1631
|
+
return {
|
|
1632
|
+
flowId: wire.flowId,
|
|
1633
|
+
version: wire.version,
|
|
1634
|
+
wasTombstoned: wire.wasTombstoned
|
|
1635
|
+
};
|
|
1636
|
+
}
|
|
1637
|
+
};
|
|
1638
|
+
}
|
|
1639
|
+
|
|
1640
|
+
// src/resources/guardrails.ts
|
|
1641
|
+
function makeGuardrailsClient(transport) {
|
|
1642
|
+
return {
|
|
1643
|
+
async author(spec, options) {
|
|
1644
|
+
return transport.request({
|
|
1645
|
+
method: "POST",
|
|
1646
|
+
path: "/v1/guardrails",
|
|
1647
|
+
body: { ...spec, projectId: options.projectId },
|
|
1648
|
+
...options.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
|
|
1649
|
+
});
|
|
1650
|
+
},
|
|
1651
|
+
async get(id) {
|
|
1652
|
+
return transport.request({
|
|
1653
|
+
method: "GET",
|
|
1654
|
+
path: `/v1/guardrails/${encodeURIComponent(id)}`
|
|
1655
|
+
});
|
|
1656
|
+
},
|
|
1657
|
+
async list(filter) {
|
|
1658
|
+
const page = await transport.request({
|
|
1659
|
+
method: "GET",
|
|
1660
|
+
path: "/v1/guardrails",
|
|
1661
|
+
query: {
|
|
1662
|
+
...filter?.limit !== void 0 && { limit: filter.limit },
|
|
1663
|
+
...filter?.cursor !== void 0 && { cursor: filter.cursor },
|
|
1664
|
+
...filter?.name !== void 0 && { name: filter.name }
|
|
1665
|
+
}
|
|
1666
|
+
});
|
|
1667
|
+
return {
|
|
1668
|
+
items: page.data,
|
|
1669
|
+
...page.nextCursor !== void 0 && {
|
|
1670
|
+
nextCursor: page.nextCursor
|
|
1671
|
+
}
|
|
1672
|
+
};
|
|
1673
|
+
},
|
|
1674
|
+
async delete(id, options) {
|
|
1675
|
+
return transport.request({
|
|
1676
|
+
method: "POST",
|
|
1677
|
+
path: `/v1/guardrails/${encodeURIComponent(id)}/unregister`,
|
|
1678
|
+
body: {},
|
|
1679
|
+
...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
|
|
1680
|
+
});
|
|
1681
|
+
},
|
|
1682
|
+
async versions(_id) {
|
|
1683
|
+
throw new KindgiApiError(
|
|
1684
|
+
notYetWired(
|
|
1685
|
+
"guardrails.versions",
|
|
1686
|
+
"no GET /v1/guardrails/{id}/versions route on the API \u2014 wire treats guardrails as flat metadata registrations, no version history"
|
|
1687
|
+
)
|
|
1688
|
+
);
|
|
1689
|
+
},
|
|
1690
|
+
async builtIns() {
|
|
1691
|
+
throw new KindgiApiError(
|
|
1692
|
+
notYetWired(
|
|
1693
|
+
"guardrails.builtIns",
|
|
1694
|
+
"no GET /v1/guardrails/built-ins route on the API \u2014 built-in catalog is a runtime discovery primitive without an HTTP surface yet"
|
|
1695
|
+
)
|
|
1696
|
+
);
|
|
1697
|
+
},
|
|
1698
|
+
async evaluate(_id, _trace) {
|
|
1699
|
+
throw new KindgiApiError(
|
|
1700
|
+
notYetWired(
|
|
1701
|
+
"guardrails.evaluate",
|
|
1702
|
+
"no POST /v1/guardrails/{id}/evaluate route on the API \u2014 direct evaluation is a runtime primitive; standalone HTTP evaluation has no wire surface yet"
|
|
1703
|
+
)
|
|
1704
|
+
);
|
|
1705
|
+
}
|
|
1706
|
+
};
|
|
1707
|
+
}
|
|
1708
|
+
|
|
1709
|
+
// src/resources/identity.ts
|
|
1710
|
+
function makeIdentityClient(transport) {
|
|
1711
|
+
const seg = (s) => encodeURIComponent(s);
|
|
1712
|
+
return {
|
|
1713
|
+
async whoami() {
|
|
1714
|
+
return transport.request({
|
|
1715
|
+
method: "GET",
|
|
1716
|
+
path: "/v1/identity/whoami"
|
|
1717
|
+
});
|
|
1718
|
+
},
|
|
1719
|
+
users: {
|
|
1720
|
+
async list(filter) {
|
|
1721
|
+
return transport.request({
|
|
1722
|
+
method: "GET",
|
|
1723
|
+
path: "/v1/identity/users",
|
|
1724
|
+
query: {
|
|
1725
|
+
...filter?.limit !== void 0 && { limit: filter.limit },
|
|
1726
|
+
...filter?.cursor !== void 0 && { cursor: filter.cursor },
|
|
1727
|
+
...filter?.query !== void 0 && { query: filter.query }
|
|
1728
|
+
}
|
|
1729
|
+
});
|
|
1730
|
+
},
|
|
1731
|
+
async get(userId) {
|
|
1732
|
+
return transport.request({
|
|
1733
|
+
method: "GET",
|
|
1734
|
+
path: `/v1/identity/users/${seg(userId)}`
|
|
1735
|
+
});
|
|
1736
|
+
},
|
|
1737
|
+
async listSessions(userId) {
|
|
1738
|
+
return transport.request({
|
|
1739
|
+
method: "GET",
|
|
1740
|
+
path: `/v1/identity/users/${seg(userId)}/sessions`
|
|
1741
|
+
});
|
|
1742
|
+
},
|
|
1743
|
+
async revokeSessions(userId, options) {
|
|
1744
|
+
return transport.request({
|
|
1745
|
+
method: "POST",
|
|
1746
|
+
path: `/v1/identity/users/${seg(userId)}/revoke-sessions`,
|
|
1747
|
+
...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
|
|
1748
|
+
});
|
|
1749
|
+
}
|
|
1750
|
+
}
|
|
1751
|
+
};
|
|
1752
|
+
}
|
|
1753
|
+
|
|
1754
|
+
// src/resources/mcp.ts
|
|
1755
|
+
function makeMcpClient(transport) {
|
|
1756
|
+
return {
|
|
1757
|
+
endpoints: {
|
|
1758
|
+
async list(filter) {
|
|
1759
|
+
const page = await transport.request({
|
|
1760
|
+
method: "GET",
|
|
1761
|
+
path: "/v1/mcp/endpoints",
|
|
1762
|
+
query: {
|
|
1763
|
+
...filter?.limit !== void 0 && { limit: filter.limit },
|
|
1764
|
+
...filter?.cursor !== void 0 && { cursor: filter.cursor },
|
|
1765
|
+
...filter?.transport !== void 0 && { transport: filter.transport }
|
|
1766
|
+
}
|
|
1767
|
+
});
|
|
1768
|
+
return {
|
|
1769
|
+
items: page.data,
|
|
1770
|
+
...page.nextCursor !== void 0 && {
|
|
1771
|
+
nextCursor: page.nextCursor
|
|
1772
|
+
}
|
|
1773
|
+
};
|
|
1774
|
+
},
|
|
1775
|
+
async register(input, options) {
|
|
1776
|
+
const { scope, ...endpoint } = input;
|
|
1777
|
+
return transport.request({
|
|
1778
|
+
method: "POST",
|
|
1779
|
+
path: "/v1/mcp/endpoints",
|
|
1780
|
+
// The scope travels as the `scopeKind` + `scopeId` pair.
|
|
1781
|
+
body: { ...endpoint, ...scopeToQuery(scope) },
|
|
1782
|
+
...options?.idempotencyKey !== void 0 && {
|
|
1783
|
+
idempotencyKey: options.idempotencyKey
|
|
1784
|
+
}
|
|
1785
|
+
});
|
|
1786
|
+
},
|
|
1787
|
+
async get(endpointId) {
|
|
1788
|
+
return transport.request({
|
|
1789
|
+
method: "GET",
|
|
1790
|
+
path: `/v1/mcp/endpoints/${encodeURIComponent(endpointId)}`
|
|
1791
|
+
});
|
|
1792
|
+
},
|
|
1793
|
+
async unregister(endpointId, options) {
|
|
1794
|
+
await transport.request({
|
|
1795
|
+
method: "POST",
|
|
1796
|
+
path: `/v1/mcp/endpoints/${encodeURIComponent(endpointId)}/unregister`,
|
|
1797
|
+
body: {},
|
|
1798
|
+
discardResponse: true,
|
|
1799
|
+
...options?.idempotencyKey !== void 0 && {
|
|
1800
|
+
idempotencyKey: options.idempotencyKey
|
|
1801
|
+
}
|
|
1802
|
+
});
|
|
1803
|
+
},
|
|
1804
|
+
resources: {
|
|
1805
|
+
async list(endpointId) {
|
|
1806
|
+
return transport.request({
|
|
1807
|
+
method: "GET",
|
|
1808
|
+
path: `/v1/mcp/endpoints/${encodeURIComponent(endpointId)}/resources`
|
|
1809
|
+
});
|
|
1810
|
+
},
|
|
1811
|
+
async read(endpointId, uri) {
|
|
1812
|
+
return transport.request({
|
|
1813
|
+
method: "GET",
|
|
1814
|
+
path: `/v1/mcp/endpoints/${encodeURIComponent(endpointId)}/resources/${encodeURIComponent(uri)}`
|
|
1815
|
+
});
|
|
1816
|
+
}
|
|
1817
|
+
},
|
|
1818
|
+
prompts: {
|
|
1819
|
+
async list(endpointId) {
|
|
1820
|
+
return transport.request({
|
|
1821
|
+
method: "GET",
|
|
1822
|
+
path: `/v1/mcp/endpoints/${encodeURIComponent(endpointId)}/prompts`
|
|
1823
|
+
});
|
|
1824
|
+
},
|
|
1825
|
+
async get(endpointId, name, args, options) {
|
|
1826
|
+
return transport.request({
|
|
1827
|
+
method: "POST",
|
|
1828
|
+
path: `/v1/mcp/endpoints/${encodeURIComponent(endpointId)}/prompts/${encodeURIComponent(name)}`,
|
|
1829
|
+
body: args ?? {},
|
|
1830
|
+
...options?.idempotencyKey !== void 0 && {
|
|
1831
|
+
idempotencyKey: options.idempotencyKey
|
|
1832
|
+
}
|
|
1833
|
+
});
|
|
1834
|
+
}
|
|
1835
|
+
}
|
|
1836
|
+
},
|
|
1837
|
+
async serverInfo() {
|
|
1838
|
+
throw new KindgiApiError(
|
|
1839
|
+
notYetWired(
|
|
1840
|
+
"mcp.serverInfo",
|
|
1841
|
+
"no GET /v1/mcp/server-info route on the API \u2014 inbound MCP-server surface (exposing the OS via MCP) not routed yet"
|
|
1842
|
+
)
|
|
1843
|
+
);
|
|
1844
|
+
},
|
|
1845
|
+
async tools() {
|
|
1846
|
+
throw new KindgiApiError(
|
|
1847
|
+
notYetWired(
|
|
1848
|
+
"mcp.tools",
|
|
1849
|
+
"no GET /v1/mcp/tools route on the API \u2014 use client.tools.list() (wire Tool IS the MCP manifest)"
|
|
1850
|
+
)
|
|
1851
|
+
);
|
|
1852
|
+
},
|
|
1853
|
+
async agents() {
|
|
1854
|
+
throw new KindgiApiError(
|
|
1855
|
+
notYetWired(
|
|
1856
|
+
"mcp.agents",
|
|
1857
|
+
"no GET /v1/mcp/agents route on the API \u2014 inbound-server exposure of agents not routed yet"
|
|
1858
|
+
)
|
|
1859
|
+
);
|
|
1860
|
+
},
|
|
1861
|
+
async invokeTool(_name, _input) {
|
|
1862
|
+
throw new KindgiApiError(
|
|
1863
|
+
notYetWired(
|
|
1864
|
+
"mcp.invokeTool",
|
|
1865
|
+
"no POST /v1/mcp/invoke-tool route on the API \u2014 MCP-transport tool invocation not surfaced yet"
|
|
1866
|
+
)
|
|
1867
|
+
);
|
|
1868
|
+
},
|
|
1869
|
+
async invokeAgent(_agentId, _input) {
|
|
1870
|
+
throw new KindgiApiError(
|
|
1871
|
+
notYetWired(
|
|
1872
|
+
"mcp.invokeAgent",
|
|
1873
|
+
"no POST /v1/mcp/invoke-agent route on the API \u2014 use client.runs.start({ agent }) for agent invocation"
|
|
1874
|
+
)
|
|
1875
|
+
);
|
|
1876
|
+
}
|
|
1877
|
+
};
|
|
1878
|
+
}
|
|
1879
|
+
|
|
1880
|
+
// src/resources/memory.ts
|
|
1881
|
+
function makeMemoryClient(transport) {
|
|
1882
|
+
return {
|
|
1883
|
+
facts: {
|
|
1884
|
+
async write(input, options) {
|
|
1885
|
+
return transport.request({
|
|
1886
|
+
method: "POST",
|
|
1887
|
+
path: "/v1/memory/facts",
|
|
1888
|
+
body: input,
|
|
1889
|
+
...options?.idempotencyKey !== void 0 && {
|
|
1890
|
+
idempotencyKey: options.idempotencyKey
|
|
1891
|
+
}
|
|
1892
|
+
});
|
|
1893
|
+
},
|
|
1894
|
+
async read(id) {
|
|
1895
|
+
return transport.request({
|
|
1896
|
+
method: "GET",
|
|
1897
|
+
path: `/v1/memory/facts/${encodeURIComponent(id)}`
|
|
1898
|
+
});
|
|
1899
|
+
},
|
|
1900
|
+
async list(filter) {
|
|
1901
|
+
const page = await transport.request({
|
|
1902
|
+
method: "GET",
|
|
1903
|
+
path: "/v1/memory/facts",
|
|
1904
|
+
query: {
|
|
1905
|
+
...filter?.limit !== void 0 && { limit: filter.limit },
|
|
1906
|
+
...filter?.cursor !== void 0 && { cursor: filter.cursor },
|
|
1907
|
+
...filter?.type !== void 0 && { type: filter.type },
|
|
1908
|
+
...filter?.scope !== void 0 && { scope: JSON.stringify(filter.scope) }
|
|
1909
|
+
}
|
|
1910
|
+
});
|
|
1911
|
+
return {
|
|
1912
|
+
items: page.data,
|
|
1913
|
+
...page.nextCursor !== void 0 && {
|
|
1914
|
+
nextCursor: page.nextCursor
|
|
1915
|
+
}
|
|
1916
|
+
};
|
|
1917
|
+
},
|
|
1918
|
+
async delete(id, options) {
|
|
1919
|
+
return transport.request({
|
|
1920
|
+
method: "POST",
|
|
1921
|
+
path: `/v1/memory/facts/${encodeURIComponent(id)}/supersede`,
|
|
1922
|
+
body: {},
|
|
1923
|
+
...options?.idempotencyKey !== void 0 && {
|
|
1924
|
+
idempotencyKey: options.idempotencyKey
|
|
1925
|
+
}
|
|
1926
|
+
});
|
|
1927
|
+
}
|
|
1928
|
+
},
|
|
1929
|
+
logs: {
|
|
1930
|
+
async append(_input) {
|
|
1931
|
+
throw new KindgiApiError(
|
|
1932
|
+
notYetWired(
|
|
1933
|
+
"memory.logs.append",
|
|
1934
|
+
"no POST /v1/memory/logs route on the API \u2014 append-only log HTTP surface has not landed (runtime primitive exists in-process)"
|
|
1935
|
+
)
|
|
1936
|
+
);
|
|
1937
|
+
},
|
|
1938
|
+
async list(_filter) {
|
|
1939
|
+
throw new KindgiApiError(
|
|
1940
|
+
notYetWired(
|
|
1941
|
+
"memory.logs.list",
|
|
1942
|
+
"no GET /v1/memory/logs route on the API \u2014 log HTTP surface has not landed"
|
|
1943
|
+
)
|
|
1944
|
+
);
|
|
1945
|
+
},
|
|
1946
|
+
async verify(_entries) {
|
|
1947
|
+
throw new KindgiApiError(
|
|
1948
|
+
notYetWired(
|
|
1949
|
+
"memory.logs.verify",
|
|
1950
|
+
"no POST /v1/memory/logs/verify route on the API \u2014 log HTTP surface has not landed; verification is client-side callable in principle but requires logs.list first"
|
|
1951
|
+
)
|
|
1952
|
+
);
|
|
1953
|
+
}
|
|
1954
|
+
},
|
|
1955
|
+
async search(input) {
|
|
1956
|
+
const envelope = await transport.request({
|
|
1957
|
+
method: "POST",
|
|
1958
|
+
path: "/v1/memory/retrieve",
|
|
1959
|
+
body: input
|
|
1960
|
+
});
|
|
1961
|
+
return envelope.results;
|
|
1962
|
+
}
|
|
1963
|
+
};
|
|
1964
|
+
}
|
|
1965
|
+
|
|
1966
|
+
// src/resources/observations.ts
|
|
1967
|
+
function makeObservationsClient(transport) {
|
|
1968
|
+
return {
|
|
1969
|
+
async recordRun(_runId) {
|
|
1970
|
+
throw new KindgiApiError(
|
|
1971
|
+
notYetWired(
|
|
1972
|
+
"observations.recordRun",
|
|
1973
|
+
"no POST /v1/observations route on the API \u2014 supervisor runtime records observations server-internally"
|
|
1974
|
+
)
|
|
1975
|
+
);
|
|
1976
|
+
},
|
|
1977
|
+
async query(filter) {
|
|
1978
|
+
const page = await transport.request({
|
|
1979
|
+
method: "GET",
|
|
1980
|
+
path: "/v1/observations",
|
|
1981
|
+
query: {
|
|
1982
|
+
...filter?.limit !== void 0 && { limit: filter.limit },
|
|
1983
|
+
...filter?.cursor !== void 0 && { cursor: filter.cursor },
|
|
1984
|
+
...filter?.status !== void 0 && { status: filter.status },
|
|
1985
|
+
...filter?.supervisorId !== void 0 && {
|
|
1986
|
+
supervisorId: filter.supervisorId
|
|
1987
|
+
},
|
|
1988
|
+
...filter?.agentId !== void 0 && { agentId: filter.agentId },
|
|
1989
|
+
...filter?.agentVersion !== void 0 && { agentVersion: filter.agentVersion },
|
|
1990
|
+
...filter?.conversationId !== void 0 && {
|
|
1991
|
+
conversationId: filter.conversationId
|
|
1992
|
+
},
|
|
1993
|
+
...filter?.since !== void 0 && { since: filter.since },
|
|
1994
|
+
...filter?.until !== void 0 && { until: filter.until }
|
|
1995
|
+
}
|
|
1996
|
+
});
|
|
1997
|
+
return {
|
|
1998
|
+
items: page.data,
|
|
1999
|
+
...page.nextCursor !== void 0 && { nextCursor: page.nextCursor }
|
|
2000
|
+
};
|
|
2001
|
+
},
|
|
2002
|
+
async patterns(_input) {
|
|
2003
|
+
throw new KindgiApiError(
|
|
2004
|
+
notYetWired(
|
|
2005
|
+
"observations.patterns",
|
|
2006
|
+
"no /v1/observations/patterns route on the API \u2014 aggregation surface unrouted"
|
|
2007
|
+
)
|
|
2008
|
+
);
|
|
2009
|
+
}
|
|
2010
|
+
};
|
|
2011
|
+
}
|
|
2012
|
+
|
|
2013
|
+
// src/resources/orgs.ts
|
|
2014
|
+
function makeOrgsClient(transport) {
|
|
2015
|
+
const seg = (s) => encodeURIComponent(s);
|
|
2016
|
+
return {
|
|
2017
|
+
async create(input, options) {
|
|
2018
|
+
return transport.request({
|
|
2019
|
+
method: "POST",
|
|
2020
|
+
path: "/v1/orgs",
|
|
2021
|
+
body: input,
|
|
2022
|
+
...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
|
|
2023
|
+
});
|
|
2024
|
+
},
|
|
2025
|
+
async list(filter) {
|
|
2026
|
+
return transport.request({
|
|
2027
|
+
method: "GET",
|
|
2028
|
+
path: "/v1/orgs",
|
|
2029
|
+
query: {
|
|
2030
|
+
...filter?.limit !== void 0 && { limit: filter.limit },
|
|
2031
|
+
...filter?.cursor !== void 0 && { cursor: filter.cursor }
|
|
2032
|
+
}
|
|
2033
|
+
});
|
|
2034
|
+
},
|
|
2035
|
+
async get(orgId) {
|
|
2036
|
+
return transport.request({
|
|
2037
|
+
method: "GET",
|
|
2038
|
+
path: `/v1/orgs/${seg(orgId)}`
|
|
2039
|
+
});
|
|
2040
|
+
},
|
|
2041
|
+
async update(orgId, input, options) {
|
|
2042
|
+
return transport.request({
|
|
2043
|
+
method: "PATCH",
|
|
2044
|
+
path: `/v1/orgs/${seg(orgId)}`,
|
|
2045
|
+
body: input,
|
|
2046
|
+
...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
|
|
2047
|
+
});
|
|
2048
|
+
},
|
|
2049
|
+
async delete(orgId) {
|
|
2050
|
+
return transport.request({
|
|
2051
|
+
method: "DELETE",
|
|
2052
|
+
path: `/v1/orgs/${seg(orgId)}`,
|
|
2053
|
+
discardResponse: true
|
|
2054
|
+
});
|
|
2055
|
+
}
|
|
2056
|
+
};
|
|
2057
|
+
}
|
|
2058
|
+
|
|
2059
|
+
// src/resources/packs.ts
|
|
2060
|
+
var REASON_NO_PACK_API = "the API has no pack routes or wire schemas (Pack / InstalledPack / PackInstallInput) yet";
|
|
2061
|
+
function makePacksClient(_transport) {
|
|
2062
|
+
return {
|
|
2063
|
+
async install(_input) {
|
|
2064
|
+
throw new KindgiApiError(notYetWired("packs.install", REASON_NO_PACK_API));
|
|
2065
|
+
},
|
|
2066
|
+
async installed(_filter) {
|
|
2067
|
+
throw new KindgiApiError(notYetWired("packs.installed", REASON_NO_PACK_API));
|
|
2068
|
+
},
|
|
2069
|
+
async get(_id) {
|
|
2070
|
+
throw new KindgiApiError(notYetWired("packs.get", REASON_NO_PACK_API));
|
|
2071
|
+
},
|
|
2072
|
+
async versions(_id) {
|
|
2073
|
+
throw new KindgiApiError(notYetWired("packs.versions", REASON_NO_PACK_API));
|
|
2074
|
+
},
|
|
2075
|
+
async configure(_id, _config) {
|
|
2076
|
+
throw new KindgiApiError(notYetWired("packs.configure", REASON_NO_PACK_API));
|
|
2077
|
+
},
|
|
2078
|
+
async disable(_id) {
|
|
2079
|
+
throw new KindgiApiError(notYetWired("packs.disable", REASON_NO_PACK_API));
|
|
2080
|
+
},
|
|
2081
|
+
async enable(_id) {
|
|
2082
|
+
throw new KindgiApiError(notYetWired("packs.enable", REASON_NO_PACK_API));
|
|
2083
|
+
},
|
|
2084
|
+
async upgrade(_id, _newVersion) {
|
|
2085
|
+
throw new KindgiApiError(notYetWired("packs.upgrade", REASON_NO_PACK_API));
|
|
2086
|
+
},
|
|
2087
|
+
async uninstall(_id) {
|
|
2088
|
+
throw new KindgiApiError(notYetWired("packs.uninstall", REASON_NO_PACK_API));
|
|
2089
|
+
},
|
|
2090
|
+
registry: {
|
|
2091
|
+
async browse(_filter) {
|
|
2092
|
+
throw new KindgiApiError(
|
|
2093
|
+
notYetWired(
|
|
2094
|
+
"packs.registry.browse",
|
|
2095
|
+
"v2 pack registry (public + private catalog federation) builds on the pack authoring API \u2014 not implemented yet"
|
|
2096
|
+
)
|
|
2097
|
+
);
|
|
2098
|
+
},
|
|
2099
|
+
async configured() {
|
|
2100
|
+
throw new KindgiApiError(
|
|
2101
|
+
notYetWired(
|
|
2102
|
+
"packs.registry.configured",
|
|
2103
|
+
"v2 pack registry (public + private catalog federation) builds on the pack authoring API \u2014 not implemented yet"
|
|
2104
|
+
)
|
|
2105
|
+
);
|
|
2106
|
+
}
|
|
2107
|
+
}
|
|
2108
|
+
};
|
|
2109
|
+
}
|
|
2110
|
+
|
|
2111
|
+
// src/resources/policies.ts
|
|
2112
|
+
function makePoliciesClient(transport) {
|
|
2113
|
+
return {
|
|
2114
|
+
async author(spec, options) {
|
|
2115
|
+
const result = await transport.request({
|
|
2116
|
+
method: "POST",
|
|
2117
|
+
path: "/v1/policies",
|
|
2118
|
+
body: {
|
|
2119
|
+
id: spec.id,
|
|
2120
|
+
version: spec.version,
|
|
2121
|
+
kind: spec.kind,
|
|
2122
|
+
...spec.description !== void 0 && { description: spec.description },
|
|
2123
|
+
spec: spec.spec
|
|
2124
|
+
},
|
|
2125
|
+
...options?.idempotencyKey !== void 0 && {
|
|
2126
|
+
idempotencyKey: options.idempotencyKey
|
|
2127
|
+
}
|
|
2128
|
+
});
|
|
2129
|
+
return {
|
|
2130
|
+
policyId: result.policyId,
|
|
2131
|
+
version: result.version
|
|
2132
|
+
};
|
|
2133
|
+
},
|
|
2134
|
+
async get(id) {
|
|
2135
|
+
return transport.request({
|
|
2136
|
+
method: "GET",
|
|
2137
|
+
path: `/v1/policies/${encodeURIComponent(id)}`
|
|
2138
|
+
});
|
|
2139
|
+
},
|
|
2140
|
+
async list(filter) {
|
|
2141
|
+
const page = await transport.request({
|
|
2142
|
+
method: "GET",
|
|
2143
|
+
path: "/v1/policies",
|
|
2144
|
+
query: {
|
|
2145
|
+
...filter?.limit !== void 0 && { limit: filter.limit },
|
|
2146
|
+
...filter?.cursor !== void 0 && { cursor: filter.cursor },
|
|
2147
|
+
...filter?.kind !== void 0 && { kind: filter.kind },
|
|
2148
|
+
...filter?.name !== void 0 && { name: filter.name }
|
|
2149
|
+
}
|
|
2150
|
+
});
|
|
2151
|
+
return {
|
|
2152
|
+
items: page.data,
|
|
2153
|
+
...page.nextCursor !== void 0 && {
|
|
2154
|
+
nextCursor: page.nextCursor
|
|
2155
|
+
}
|
|
2156
|
+
};
|
|
2157
|
+
},
|
|
2158
|
+
async versions(id, filter) {
|
|
2159
|
+
const page = await transport.request({
|
|
2160
|
+
method: "GET",
|
|
2161
|
+
path: `/v1/policies/${encodeURIComponent(id)}/versions`,
|
|
2162
|
+
query: {
|
|
2163
|
+
...filter?.limit !== void 0 && { limit: filter.limit },
|
|
2164
|
+
...filter?.cursor !== void 0 && { cursor: filter.cursor },
|
|
2165
|
+
...filter?.includeTombstoned === true && { includeTombstoned: "true" }
|
|
2166
|
+
}
|
|
2167
|
+
});
|
|
2168
|
+
return {
|
|
2169
|
+
items: page.data,
|
|
2170
|
+
...page.nextCursor !== void 0 && {
|
|
2171
|
+
nextCursor: page.nextCursor
|
|
2172
|
+
}
|
|
2173
|
+
};
|
|
2174
|
+
},
|
|
2175
|
+
async getVersion(id, version) {
|
|
2176
|
+
return transport.request({
|
|
2177
|
+
method: "GET",
|
|
2178
|
+
path: `/v1/policies/${encodeURIComponent(id)}/versions/${encodeURIComponent(version)}`
|
|
2179
|
+
});
|
|
2180
|
+
},
|
|
2181
|
+
async unregister(id, version, options) {
|
|
2182
|
+
await transport.request({
|
|
2183
|
+
method: "POST",
|
|
2184
|
+
path: `/v1/policies/${encodeURIComponent(id)}/versions/${encodeURIComponent(version)}/unregister`,
|
|
2185
|
+
body: {},
|
|
2186
|
+
discardResponse: true,
|
|
2187
|
+
...options?.idempotencyKey !== void 0 && {
|
|
2188
|
+
idempotencyKey: options.idempotencyKey
|
|
2189
|
+
}
|
|
2190
|
+
});
|
|
2191
|
+
},
|
|
2192
|
+
async reinstateVersion(id, version, options) {
|
|
2193
|
+
const wire = await transport.request({
|
|
2194
|
+
method: "POST",
|
|
2195
|
+
path: `/v1/policies/${encodeURIComponent(id)}/versions/${encodeURIComponent(version)}/reinstate`,
|
|
2196
|
+
...options?.idempotencyKey !== void 0 && {
|
|
2197
|
+
idempotencyKey: options.idempotencyKey
|
|
2198
|
+
}
|
|
2199
|
+
});
|
|
2200
|
+
return {
|
|
2201
|
+
policyId: wire.policyId,
|
|
2202
|
+
version: wire.version,
|
|
2203
|
+
wasTombstoned: wire.wasTombstoned
|
|
2204
|
+
};
|
|
2205
|
+
},
|
|
2206
|
+
async activate(_id) {
|
|
2207
|
+
throw new KindgiApiError(
|
|
2208
|
+
notYetWired(
|
|
2209
|
+
"policies.activate",
|
|
2210
|
+
"no POST /v1/policies/{policyId}/activate route on the API \u2014 the wire has no draft/active lifecycle; policies are active at publish"
|
|
2211
|
+
)
|
|
2212
|
+
);
|
|
2213
|
+
},
|
|
2214
|
+
async evaluate(_id, _input) {
|
|
2215
|
+
throw new KindgiApiError(
|
|
2216
|
+
notYetWired(
|
|
2217
|
+
"policies.evaluate",
|
|
2218
|
+
"no POST /v1/policies/{policyId}/evaluate route on the API \u2014 evaluation is a runtime primitive without an SDK surface yet"
|
|
2219
|
+
)
|
|
2220
|
+
);
|
|
2221
|
+
}
|
|
2222
|
+
};
|
|
2223
|
+
}
|
|
2224
|
+
|
|
2225
|
+
// src/resources/projects.ts
|
|
2226
|
+
function makeProjectsClient(transport) {
|
|
2227
|
+
const seg = (s) => encodeURIComponent(s);
|
|
2228
|
+
return {
|
|
2229
|
+
async create(input, options) {
|
|
2230
|
+
return transport.request({
|
|
2231
|
+
method: "POST",
|
|
2232
|
+
path: "/v1/projects",
|
|
2233
|
+
body: input,
|
|
2234
|
+
...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
|
|
2235
|
+
});
|
|
2236
|
+
},
|
|
2237
|
+
async list(filter) {
|
|
2238
|
+
return transport.request({
|
|
2239
|
+
method: "GET",
|
|
2240
|
+
path: "/v1/projects",
|
|
2241
|
+
query: {
|
|
2242
|
+
...filter?.limit !== void 0 && { limit: filter.limit },
|
|
2243
|
+
...filter?.cursor !== void 0 && { cursor: filter.cursor }
|
|
2244
|
+
}
|
|
2245
|
+
});
|
|
2246
|
+
},
|
|
2247
|
+
async getDefault() {
|
|
2248
|
+
return transport.request({
|
|
2249
|
+
method: "GET",
|
|
2250
|
+
path: "/v1/projects/default"
|
|
2251
|
+
});
|
|
2252
|
+
},
|
|
2253
|
+
async get(projectId) {
|
|
2254
|
+
return transport.request({
|
|
2255
|
+
method: "GET",
|
|
2256
|
+
path: `/v1/projects/${seg(projectId)}`
|
|
2257
|
+
});
|
|
2258
|
+
},
|
|
2259
|
+
async update(projectId, input, options) {
|
|
2260
|
+
return transport.request({
|
|
2261
|
+
method: "PATCH",
|
|
2262
|
+
path: `/v1/projects/${seg(projectId)}`,
|
|
2263
|
+
body: input,
|
|
2264
|
+
...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
|
|
2265
|
+
});
|
|
2266
|
+
},
|
|
2267
|
+
async delete(projectId) {
|
|
2268
|
+
return transport.request({
|
|
2269
|
+
method: "DELETE",
|
|
2270
|
+
path: `/v1/projects/${seg(projectId)}`,
|
|
2271
|
+
discardResponse: true
|
|
2272
|
+
});
|
|
2273
|
+
},
|
|
2274
|
+
memberships: {
|
|
2275
|
+
async list(projectId, filter) {
|
|
2276
|
+
return transport.request({
|
|
2277
|
+
method: "GET",
|
|
2278
|
+
path: `/v1/projects/${seg(projectId)}/memberships`,
|
|
2279
|
+
query: {
|
|
2280
|
+
...filter?.limit !== void 0 && { limit: filter.limit },
|
|
2281
|
+
...filter?.cursor !== void 0 && { cursor: filter.cursor }
|
|
2282
|
+
}
|
|
2283
|
+
});
|
|
2284
|
+
},
|
|
2285
|
+
async add(projectId, input, options) {
|
|
2286
|
+
return transport.request({
|
|
2287
|
+
method: "POST",
|
|
2288
|
+
path: `/v1/projects/${seg(projectId)}/memberships`,
|
|
2289
|
+
body: input,
|
|
2290
|
+
...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
|
|
2291
|
+
});
|
|
2292
|
+
},
|
|
2293
|
+
async updateRole(projectId, userId, role, options) {
|
|
2294
|
+
return transport.request({
|
|
2295
|
+
method: "PATCH",
|
|
2296
|
+
path: `/v1/projects/${seg(projectId)}/memberships/${seg(userId)}`,
|
|
2297
|
+
body: { role },
|
|
2298
|
+
discardResponse: true,
|
|
2299
|
+
...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
|
|
2300
|
+
});
|
|
2301
|
+
},
|
|
2302
|
+
async remove(projectId, userId, options) {
|
|
2303
|
+
return transport.request({
|
|
2304
|
+
method: "DELETE",
|
|
2305
|
+
path: `/v1/projects/${seg(projectId)}/memberships/${seg(userId)}`,
|
|
2306
|
+
discardResponse: true,
|
|
2307
|
+
...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
|
|
2308
|
+
});
|
|
2309
|
+
}
|
|
2310
|
+
}
|
|
2311
|
+
};
|
|
2312
|
+
}
|
|
2313
|
+
|
|
2314
|
+
// src/resources/provenance.ts
|
|
2315
|
+
function makeProvenanceClient(transport) {
|
|
2316
|
+
return {
|
|
2317
|
+
async get(runId) {
|
|
2318
|
+
return transport.request({
|
|
2319
|
+
method: "GET",
|
|
2320
|
+
path: `/v1/provenance/${encodeURIComponent(runId)}`
|
|
2321
|
+
});
|
|
2322
|
+
},
|
|
2323
|
+
async query(filter) {
|
|
2324
|
+
const page = await transport.request({
|
|
2325
|
+
method: "GET",
|
|
2326
|
+
path: "/v1/provenance",
|
|
2327
|
+
query: {
|
|
2328
|
+
...filter?.limit !== void 0 && { limit: filter.limit },
|
|
2329
|
+
...filter?.cursor !== void 0 && { cursor: filter.cursor },
|
|
2330
|
+
...filter?.runId !== void 0 && { runId: filter.runId },
|
|
2331
|
+
...filter?.agentId !== void 0 && {
|
|
2332
|
+
agentId: filter.agentId
|
|
2333
|
+
},
|
|
2334
|
+
...filter?.createdAfter !== void 0 && {
|
|
2335
|
+
createdAfter: filter.createdAfter
|
|
2336
|
+
}
|
|
2337
|
+
}
|
|
2338
|
+
});
|
|
2339
|
+
return {
|
|
2340
|
+
items: page.data,
|
|
2341
|
+
...page.nextCursor !== void 0 && { nextCursor: page.nextCursor }
|
|
2342
|
+
};
|
|
2343
|
+
},
|
|
2344
|
+
async export(input) {
|
|
2345
|
+
return transport.request({
|
|
2346
|
+
method: "POST",
|
|
2347
|
+
path: `/v1/provenance/${encodeURIComponent(input.runId)}/export`,
|
|
2348
|
+
body: {
|
|
2349
|
+
signingKeyId: input.signingKeyId,
|
|
2350
|
+
...input.includeMessages !== void 0 && { includeMessages: input.includeMessages }
|
|
2351
|
+
},
|
|
2352
|
+
...input.idempotencyKey !== void 0 && { idempotencyKey: input.idempotencyKey }
|
|
2353
|
+
});
|
|
2354
|
+
},
|
|
2355
|
+
async verify(_exported, _publicKey) {
|
|
2356
|
+
throw new KindgiApiError(
|
|
2357
|
+
notYetWired(
|
|
2358
|
+
"provenance.verify",
|
|
2359
|
+
"client-side ed25519 verification requires the crypto module subpackage to be reachable from the SDK"
|
|
2360
|
+
)
|
|
2361
|
+
);
|
|
2362
|
+
}
|
|
2363
|
+
};
|
|
2364
|
+
}
|
|
2365
|
+
|
|
2366
|
+
// src/resources/providers.ts
|
|
2367
|
+
function makeProvidersClient(transport) {
|
|
2368
|
+
const seg = (s) => encodeURIComponent(s);
|
|
2369
|
+
return {
|
|
2370
|
+
async register(input, options) {
|
|
2371
|
+
return transport.request({
|
|
2372
|
+
method: "POST",
|
|
2373
|
+
path: "/v1/providers",
|
|
2374
|
+
body: input,
|
|
2375
|
+
...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
|
|
2376
|
+
});
|
|
2377
|
+
},
|
|
2378
|
+
async list(filter) {
|
|
2379
|
+
return transport.request({
|
|
2380
|
+
method: "GET",
|
|
2381
|
+
path: "/v1/providers",
|
|
2382
|
+
query: {
|
|
2383
|
+
...filter?.limit !== void 0 && { limit: filter.limit },
|
|
2384
|
+
...filter?.cursor !== void 0 && { cursor: filter.cursor },
|
|
2385
|
+
...filter?.feature !== void 0 && { feature: filter.feature }
|
|
2386
|
+
}
|
|
2387
|
+
});
|
|
2388
|
+
},
|
|
2389
|
+
async get(providerId) {
|
|
2390
|
+
return transport.request({
|
|
2391
|
+
method: "GET",
|
|
2392
|
+
path: `/v1/providers/${seg(providerId)}`
|
|
2393
|
+
});
|
|
2394
|
+
},
|
|
2395
|
+
async capabilities(providerId) {
|
|
2396
|
+
return transport.request({
|
|
2397
|
+
method: "GET",
|
|
2398
|
+
path: `/v1/providers/${seg(providerId)}/capabilities`
|
|
2399
|
+
});
|
|
2400
|
+
},
|
|
2401
|
+
async unregister(providerId, options) {
|
|
2402
|
+
return transport.request({
|
|
2403
|
+
method: "POST",
|
|
2404
|
+
path: `/v1/providers/${seg(providerId)}/unregister`,
|
|
2405
|
+
...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
|
|
2406
|
+
});
|
|
2407
|
+
}
|
|
2408
|
+
};
|
|
2409
|
+
}
|
|
2410
|
+
|
|
2411
|
+
// src/run-follow.ts
|
|
2412
|
+
var MAX_REFRESHES_IN_A_ROW = 3;
|
|
2413
|
+
var TERMINAL_KINDS = /* @__PURE__ */ new Set([
|
|
2414
|
+
"run.completed",
|
|
2415
|
+
"run.failed",
|
|
2416
|
+
"run.cancelled"
|
|
2417
|
+
]);
|
|
2418
|
+
async function* followRun(options) {
|
|
2419
|
+
const state = { lastEventId: void 0, refreshesInARow: 0 };
|
|
2420
|
+
while (options.signal?.aborted !== true) {
|
|
2421
|
+
const outcome = yield* followOnce(options, state);
|
|
2422
|
+
if (outcome === "terminal" || outcome === "aborted") return;
|
|
2423
|
+
if (outcome === "empty") await sleep(options.initialBackoffMs ?? 500, options.signal);
|
|
2424
|
+
}
|
|
2425
|
+
}
|
|
2426
|
+
async function* followOnce(options, state) {
|
|
2427
|
+
let received = 0;
|
|
2428
|
+
try {
|
|
2429
|
+
for await (const event of readSse(connectionOptions(options, state.lastEventId))) {
|
|
2430
|
+
received += 1;
|
|
2431
|
+
state.refreshesInARow = 0;
|
|
2432
|
+
if (event.id !== void 0) state.lastEventId = event.id;
|
|
2433
|
+
yield event.data;
|
|
2434
|
+
if (TERMINAL_KINDS.has(event.data.kind)) return "terminal";
|
|
2435
|
+
}
|
|
2436
|
+
} catch (error) {
|
|
2437
|
+
if (options.signal?.aborted === true) return "aborted";
|
|
2438
|
+
if (!await refreshAfter(error, options, state.refreshesInARow)) throw error;
|
|
2439
|
+
state.refreshesInARow += 1;
|
|
2440
|
+
return "refreshed";
|
|
2441
|
+
}
|
|
2442
|
+
return received === 0 ? "empty" : "closed";
|
|
2443
|
+
}
|
|
2444
|
+
function connectionOptions(options, lastEventId) {
|
|
2445
|
+
return {
|
|
2446
|
+
url: options.url,
|
|
2447
|
+
headers: options.headers,
|
|
2448
|
+
...lastEventId !== void 0 && { lastEventId },
|
|
2449
|
+
...options.fetchImpl !== void 0 && { fetchImpl: options.fetchImpl },
|
|
2450
|
+
...options.signal !== void 0 && { signal: options.signal },
|
|
2451
|
+
...options.initialBackoffMs !== void 0 && { initialBackoffMs: options.initialBackoffMs },
|
|
2452
|
+
...options.maxBackoffMs !== void 0 && { maxBackoffMs: options.maxBackoffMs },
|
|
2453
|
+
// Client errors (401 expired token, 403, 404) don't heal by retrying.
|
|
2454
|
+
shouldRetry: (attempt, error) => !(error instanceof SseHttpError && error.status >= 400 && error.status < 500) && attempt < 10
|
|
2455
|
+
};
|
|
2456
|
+
}
|
|
2457
|
+
async function refreshAfter(error, options, refreshesInARow) {
|
|
2458
|
+
if (!(error instanceof SseHttpError) || error.status !== 401) return false;
|
|
2459
|
+
if (options.onUnauthorized === void 0 || refreshesInARow >= MAX_REFRESHES_IN_A_ROW) {
|
|
2460
|
+
return false;
|
|
2461
|
+
}
|
|
2462
|
+
return options.onUnauthorized();
|
|
2463
|
+
}
|
|
2464
|
+
function subscribeToRun(options) {
|
|
2465
|
+
let token = options.accessToken;
|
|
2466
|
+
const refresh = options.refreshAccessToken;
|
|
2467
|
+
return followRun({
|
|
2468
|
+
url: `${options.apiUrl.replace(/\/+$/, "")}/v1/runs/${encodeURIComponent(options.runId)}/progress/stream`,
|
|
2469
|
+
headers: () => ({ Authorization: `Bearer ${token}` }),
|
|
2470
|
+
...refresh !== void 0 && {
|
|
2471
|
+
onUnauthorized: async () => {
|
|
2472
|
+
token = await refresh();
|
|
2473
|
+
return true;
|
|
2474
|
+
}
|
|
2475
|
+
},
|
|
2476
|
+
...options.fetch !== void 0 && { fetchImpl: options.fetch },
|
|
2477
|
+
...options.signal !== void 0 && { signal: options.signal }
|
|
2478
|
+
});
|
|
2479
|
+
}
|
|
2480
|
+
|
|
2481
|
+
// src/resources/runs.ts
|
|
2482
|
+
function makeRunsClient(transport) {
|
|
2483
|
+
return {
|
|
2484
|
+
async start(input) {
|
|
2485
|
+
const body = "agent" in input ? {
|
|
2486
|
+
agent: input.agent,
|
|
2487
|
+
...input.agentVersion !== void 0 && { agentVersion: input.agentVersion },
|
|
2488
|
+
...input.projectId !== void 0 && { projectId: input.projectId },
|
|
2489
|
+
input: input.input,
|
|
2490
|
+
...input.options !== void 0 && { options: input.options }
|
|
2491
|
+
} : {
|
|
2492
|
+
flow: input.flow,
|
|
2493
|
+
...input.flowVersion !== void 0 && { flowVersion: input.flowVersion },
|
|
2494
|
+
...input.projectId !== void 0 && { projectId: input.projectId },
|
|
2495
|
+
input: input.input,
|
|
2496
|
+
...input.options !== void 0 && { options: input.options }
|
|
2497
|
+
};
|
|
2498
|
+
return transport.request({
|
|
2499
|
+
method: "POST",
|
|
2500
|
+
path: "/v1/runs",
|
|
2501
|
+
body,
|
|
2502
|
+
...input.idempotencyKey !== void 0 && {
|
|
2503
|
+
idempotencyKey: input.idempotencyKey
|
|
2504
|
+
}
|
|
2505
|
+
});
|
|
2506
|
+
},
|
|
2507
|
+
async dryRun(_input) {
|
|
2508
|
+
throw new KindgiApiError(
|
|
2509
|
+
notYetWired(
|
|
2510
|
+
"runs.dryRun",
|
|
2511
|
+
"no dedicated dry-run route on the API \u2014 use runs.start({ ..., options: { dryRun: true } }); the design-drafted DryRunResult (planned nodes / cost estimate) is a distinct preview primitive that has no wire route yet"
|
|
2512
|
+
)
|
|
2513
|
+
);
|
|
2514
|
+
},
|
|
2515
|
+
async progress(runId) {
|
|
2516
|
+
return transport.request({
|
|
2517
|
+
method: "GET",
|
|
2518
|
+
path: `/v1/runs/${encodeURIComponent(runId)}/progress`
|
|
2519
|
+
});
|
|
2520
|
+
},
|
|
2521
|
+
streamProgress(runId, options) {
|
|
2522
|
+
return followRun({
|
|
2523
|
+
url: `${transport.apiUrl}/v1/runs/${encodeURIComponent(runId)}/progress/stream`,
|
|
2524
|
+
headers: () => transport.authHeaders(),
|
|
2525
|
+
fetchImpl: transport.fetchImpl,
|
|
2526
|
+
...options?.signal !== void 0 && { signal: options.signal },
|
|
2527
|
+
...options?.initialBackoffMs !== void 0 && {
|
|
2528
|
+
initialBackoffMs: options.initialBackoffMs
|
|
2529
|
+
},
|
|
2530
|
+
...options?.maxBackoffMs !== void 0 && {
|
|
2531
|
+
maxBackoffMs: options.maxBackoffMs
|
|
2532
|
+
}
|
|
2533
|
+
});
|
|
2534
|
+
},
|
|
2535
|
+
stream(runId, options) {
|
|
2536
|
+
return followRun({
|
|
2537
|
+
url: `${transport.apiUrl}/v1/runs/${encodeURIComponent(runId)}/stream`,
|
|
2538
|
+
headers: () => transport.authHeaders(),
|
|
2539
|
+
fetchImpl: transport.fetchImpl,
|
|
2540
|
+
...options?.signal !== void 0 && { signal: options.signal },
|
|
2541
|
+
...options?.initialBackoffMs !== void 0 && {
|
|
2542
|
+
initialBackoffMs: options.initialBackoffMs
|
|
2543
|
+
},
|
|
2544
|
+
...options?.maxBackoffMs !== void 0 && {
|
|
2545
|
+
maxBackoffMs: options.maxBackoffMs
|
|
2546
|
+
}
|
|
2547
|
+
});
|
|
2548
|
+
},
|
|
2549
|
+
async get(runId) {
|
|
2550
|
+
return transport.request({
|
|
2551
|
+
method: "GET",
|
|
2552
|
+
path: `/v1/runs/${encodeURIComponent(runId)}`
|
|
2553
|
+
});
|
|
2554
|
+
},
|
|
2555
|
+
async resume(input) {
|
|
2556
|
+
return transport.request({
|
|
2557
|
+
method: "POST",
|
|
2558
|
+
path: `/v1/runs/${encodeURIComponent(input.runId)}/resume`,
|
|
2559
|
+
body: {
|
|
2560
|
+
waitpointId: input.waitpointId,
|
|
2561
|
+
...input.value !== void 0 && { value: input.value }
|
|
2562
|
+
},
|
|
2563
|
+
...input.idempotencyKey !== void 0 && {
|
|
2564
|
+
idempotencyKey: input.idempotencyKey
|
|
2565
|
+
}
|
|
2566
|
+
});
|
|
2567
|
+
},
|
|
2568
|
+
async cancel(runId, options) {
|
|
2569
|
+
return transport.request({
|
|
2570
|
+
method: "POST",
|
|
2571
|
+
path: `/v1/runs/${encodeURIComponent(runId)}/cancel`,
|
|
2572
|
+
body: {},
|
|
2573
|
+
...options?.idempotencyKey !== void 0 && {
|
|
2574
|
+
idempotencyKey: options.idempotencyKey
|
|
2575
|
+
}
|
|
2576
|
+
});
|
|
2577
|
+
},
|
|
2578
|
+
async list(filter) {
|
|
2579
|
+
return transport.request({
|
|
2580
|
+
method: "GET",
|
|
2581
|
+
path: "/v1/runs",
|
|
2582
|
+
query: {
|
|
2583
|
+
...filter?.limit !== void 0 && { limit: filter.limit },
|
|
2584
|
+
...filter?.cursor !== void 0 && { cursor: filter.cursor },
|
|
2585
|
+
...filter?.parentRunId !== void 0 && {
|
|
2586
|
+
parentRunId: filter.parentRunId
|
|
2587
|
+
},
|
|
2588
|
+
...filter?.topLevel !== void 0 && { topLevel: String(filter.topLevel) },
|
|
2589
|
+
...filter?.includeOutput === true && { include: "output" }
|
|
2590
|
+
}
|
|
2591
|
+
});
|
|
2592
|
+
},
|
|
2593
|
+
async journal(runId, filter) {
|
|
2594
|
+
return transport.request({
|
|
2595
|
+
method: "GET",
|
|
2596
|
+
path: `/v1/runs/${encodeURIComponent(runId)}/journal`,
|
|
2597
|
+
query: {
|
|
2598
|
+
...filter?.limit !== void 0 && { limit: filter.limit },
|
|
2599
|
+
...filter?.cursor !== void 0 && { cursor: filter.cursor },
|
|
2600
|
+
...filter?.since !== void 0 && { since: filter.since }
|
|
2601
|
+
}
|
|
2602
|
+
});
|
|
2603
|
+
}
|
|
2604
|
+
};
|
|
2605
|
+
}
|
|
2606
|
+
|
|
2607
|
+
// src/resources/schedules.ts
|
|
2608
|
+
function makeSchedulesClient(transport) {
|
|
2609
|
+
return {
|
|
2610
|
+
async register(input, options) {
|
|
2611
|
+
return transport.request({
|
|
2612
|
+
method: "POST",
|
|
2613
|
+
path: "/v1/schedules",
|
|
2614
|
+
body: input,
|
|
2615
|
+
...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
|
|
2616
|
+
});
|
|
2617
|
+
},
|
|
2618
|
+
async list(filter) {
|
|
2619
|
+
return transport.request({
|
|
2620
|
+
method: "GET",
|
|
2621
|
+
path: "/v1/schedules",
|
|
2622
|
+
query: {
|
|
2623
|
+
...filter?.limit !== void 0 && { limit: filter.limit },
|
|
2624
|
+
...filter?.cursor !== void 0 && { cursor: filter.cursor },
|
|
2625
|
+
...filter?.status !== void 0 && { status: filter.status }
|
|
2626
|
+
}
|
|
2627
|
+
});
|
|
2628
|
+
},
|
|
2629
|
+
async get(triggerId) {
|
|
2630
|
+
return transport.request({
|
|
2631
|
+
method: "GET",
|
|
2632
|
+
path: `/v1/schedules/${encodeURIComponent(triggerId)}`
|
|
2633
|
+
});
|
|
2634
|
+
},
|
|
2635
|
+
async update(triggerId, input, options) {
|
|
2636
|
+
return transport.request({
|
|
2637
|
+
method: "PATCH",
|
|
2638
|
+
path: `/v1/schedules/${encodeURIComponent(triggerId)}`,
|
|
2639
|
+
body: input,
|
|
2640
|
+
...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
|
|
2641
|
+
});
|
|
2642
|
+
},
|
|
2643
|
+
async pause(triggerId, options) {
|
|
2644
|
+
return transport.request({
|
|
2645
|
+
method: "POST",
|
|
2646
|
+
path: `/v1/schedules/${encodeURIComponent(triggerId)}/pause`,
|
|
2647
|
+
...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
|
|
2648
|
+
});
|
|
2649
|
+
},
|
|
2650
|
+
async resume(triggerId, options) {
|
|
2651
|
+
return transport.request({
|
|
2652
|
+
method: "POST",
|
|
2653
|
+
path: `/v1/schedules/${encodeURIComponent(triggerId)}/resume`,
|
|
2654
|
+
...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
|
|
2655
|
+
});
|
|
2656
|
+
},
|
|
2657
|
+
async unregister(triggerId, options) {
|
|
2658
|
+
return transport.request({
|
|
2659
|
+
method: "POST",
|
|
2660
|
+
path: `/v1/schedules/${encodeURIComponent(triggerId)}/unregister`,
|
|
2661
|
+
...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
|
|
2662
|
+
});
|
|
2663
|
+
}
|
|
2664
|
+
};
|
|
2665
|
+
}
|
|
2666
|
+
|
|
2667
|
+
// src/resources/secrets.ts
|
|
2668
|
+
var DEFAULT_INITIAL_DELAY_MS = 1e3;
|
|
2669
|
+
var DEFAULT_MAX_DELAY_MS = 3e4;
|
|
2670
|
+
var DEFAULT_CEILING_MS = 15 * 60 * 1e3;
|
|
2671
|
+
var defaultSleep = (ms) => new Promise((resolve) => {
|
|
2672
|
+
setTimeout(resolve, ms);
|
|
2673
|
+
});
|
|
2674
|
+
async function pollForRotationTerminal(transport, input, rotationId) {
|
|
2675
|
+
const overrides = input.pollingOverrides;
|
|
2676
|
+
const initialDelay = overrides?.initialDelayMs ?? DEFAULT_INITIAL_DELAY_MS;
|
|
2677
|
+
const maxDelay = overrides?.maxDelayMs ?? DEFAULT_MAX_DELAY_MS;
|
|
2678
|
+
const ceiling = overrides?.ceilingMs ?? DEFAULT_CEILING_MS;
|
|
2679
|
+
const sleep2 = overrides?.sleep ?? defaultSleep;
|
|
2680
|
+
const q = scopeToQuery(input.scope);
|
|
2681
|
+
const startedAt = Date.now();
|
|
2682
|
+
let nextDelay = initialDelay;
|
|
2683
|
+
const query = {
|
|
2684
|
+
envName: input.envName,
|
|
2685
|
+
scopeKind: q.scopeKind,
|
|
2686
|
+
...q.scopeId !== void 0 && { scopeId: q.scopeId }
|
|
2687
|
+
};
|
|
2688
|
+
const statusPath = `/v1/secrets/${encodeURIComponent(input.name)}/rotations/${encodeURIComponent(rotationId)}`;
|
|
2689
|
+
for (; ; ) {
|
|
2690
|
+
await sleep2(nextDelay);
|
|
2691
|
+
const elapsed = Date.now() - startedAt;
|
|
2692
|
+
if (elapsed >= ceiling) {
|
|
2693
|
+
const statusUrl = `${transport.apiUrl}${statusPath}`;
|
|
2694
|
+
return { kind: "timeout", rotationId, statusUrl };
|
|
2695
|
+
}
|
|
2696
|
+
const status = await transport.request({
|
|
2697
|
+
method: "GET",
|
|
2698
|
+
path: statusPath,
|
|
2699
|
+
query
|
|
2700
|
+
});
|
|
2701
|
+
if (status.status === "succeeded") {
|
|
2702
|
+
if (status.newVersionId === void 0 || status.oldVersionId === void 0) {
|
|
2703
|
+
return {
|
|
2704
|
+
kind: "failed",
|
|
2705
|
+
error: "succeeded status returned without newVersionId/oldVersionId"
|
|
2706
|
+
};
|
|
2707
|
+
}
|
|
2708
|
+
return {
|
|
2709
|
+
kind: "ok",
|
|
2710
|
+
newVersionId: status.newVersionId,
|
|
2711
|
+
oldVersionId: status.oldVersionId
|
|
2712
|
+
};
|
|
2713
|
+
}
|
|
2714
|
+
if (status.status === "failed") {
|
|
2715
|
+
return { kind: "failed", error: status.error ?? "rotation failed" };
|
|
2716
|
+
}
|
|
2717
|
+
if (status.status === "cancelled") {
|
|
2718
|
+
return { kind: "cancelled" };
|
|
2719
|
+
}
|
|
2720
|
+
nextDelay = Math.min(nextDelay * 2, maxDelay);
|
|
2721
|
+
}
|
|
2722
|
+
}
|
|
2723
|
+
function makeSecretsClient(transport) {
|
|
2724
|
+
return {
|
|
2725
|
+
async list(input) {
|
|
2726
|
+
const q = scopeToQuery(input.scope);
|
|
2727
|
+
const page = await transport.request({
|
|
2728
|
+
method: "GET",
|
|
2729
|
+
path: "/v1/secrets",
|
|
2730
|
+
query: {
|
|
2731
|
+
envName: input.envName,
|
|
2732
|
+
scopeKind: q.scopeKind,
|
|
2733
|
+
...q.scopeId !== void 0 && { scopeId: q.scopeId },
|
|
2734
|
+
...input.cursor !== void 0 && { cursor: input.cursor },
|
|
2735
|
+
...input.namePrefix !== void 0 && { namePrefix: input.namePrefix },
|
|
2736
|
+
...input.includeRevoked === true && { includeRevoked: true },
|
|
2737
|
+
...input.limit !== void 0 && { limit: input.limit }
|
|
2738
|
+
}
|
|
2739
|
+
});
|
|
2740
|
+
return {
|
|
2741
|
+
data: page.data,
|
|
2742
|
+
...page.nextCursor !== void 0 && {
|
|
2743
|
+
nextCursor: page.nextCursor
|
|
2744
|
+
}
|
|
2745
|
+
};
|
|
2746
|
+
},
|
|
2747
|
+
async get(input) {
|
|
2748
|
+
const q = scopeToQuery(input.scope);
|
|
2749
|
+
try {
|
|
2750
|
+
return await transport.request({
|
|
2751
|
+
method: "GET",
|
|
2752
|
+
path: `/v1/secrets/${encodeURIComponent(input.name)}`,
|
|
2753
|
+
query: {
|
|
2754
|
+
envName: input.envName,
|
|
2755
|
+
scopeKind: q.scopeKind,
|
|
2756
|
+
...q.scopeId !== void 0 && { scopeId: q.scopeId }
|
|
2757
|
+
}
|
|
2758
|
+
});
|
|
2759
|
+
} catch (err) {
|
|
2760
|
+
if (isKindOfNotFound(err, "secret-not-found", "secret")) return null;
|
|
2761
|
+
throw err;
|
|
2762
|
+
}
|
|
2763
|
+
},
|
|
2764
|
+
async getVersion(input) {
|
|
2765
|
+
const q = scopeToQuery(input.scope);
|
|
2766
|
+
try {
|
|
2767
|
+
return await transport.request({
|
|
2768
|
+
method: "GET",
|
|
2769
|
+
path: `/v1/secrets/${encodeURIComponent(input.name)}/versions/${input.versionId}`,
|
|
2770
|
+
query: {
|
|
2771
|
+
envName: input.envName,
|
|
2772
|
+
scopeKind: q.scopeKind,
|
|
2773
|
+
...q.scopeId !== void 0 && { scopeId: q.scopeId }
|
|
2774
|
+
}
|
|
2775
|
+
});
|
|
2776
|
+
} catch (err) {
|
|
2777
|
+
if (isKindOfNotFound(err, "secret-version-not-found", "secret-version")) return null;
|
|
2778
|
+
throw err;
|
|
2779
|
+
}
|
|
2780
|
+
},
|
|
2781
|
+
async listVersions(input) {
|
|
2782
|
+
const q = scopeToQuery(input.scope);
|
|
2783
|
+
const page = await transport.request({
|
|
2784
|
+
method: "GET",
|
|
2785
|
+
path: `/v1/secrets/${encodeURIComponent(input.name)}/versions`,
|
|
2786
|
+
query: {
|
|
2787
|
+
envName: input.envName,
|
|
2788
|
+
scopeKind: q.scopeKind,
|
|
2789
|
+
...q.scopeId !== void 0 && { scopeId: q.scopeId },
|
|
2790
|
+
...input.cursor !== void 0 && { cursor: input.cursor },
|
|
2791
|
+
...input.limit !== void 0 && { limit: input.limit }
|
|
2792
|
+
}
|
|
2793
|
+
});
|
|
2794
|
+
return {
|
|
2795
|
+
data: page.data,
|
|
2796
|
+
...page.nextCursor !== void 0 && {
|
|
2797
|
+
nextCursor: page.nextCursor
|
|
2798
|
+
}
|
|
2799
|
+
};
|
|
2800
|
+
},
|
|
2801
|
+
async set(input) {
|
|
2802
|
+
try {
|
|
2803
|
+
const ok = await transport.request({
|
|
2804
|
+
method: "POST",
|
|
2805
|
+
path: "/v1/secrets",
|
|
2806
|
+
body: {
|
|
2807
|
+
scope: scopeForBody(input.scope),
|
|
2808
|
+
envName: input.envName,
|
|
2809
|
+
name: input.name,
|
|
2810
|
+
value: input.value,
|
|
2811
|
+
writeMode: input.writeMode,
|
|
2812
|
+
...input.ifVersion !== void 0 && { ifVersion: input.ifVersion },
|
|
2813
|
+
...input.rotationDueAt !== void 0 && { rotationDueAt: input.rotationDueAt },
|
|
2814
|
+
...input.tags !== void 0 && { tags: input.tags }
|
|
2815
|
+
},
|
|
2816
|
+
...input.idempotencyKey !== void 0 && {
|
|
2817
|
+
idempotencyKey: input.idempotencyKey
|
|
2818
|
+
}
|
|
2819
|
+
});
|
|
2820
|
+
return { kind: "ok", record: ok.record, versionId: ok.versionId };
|
|
2821
|
+
} catch (err) {
|
|
2822
|
+
const conflict = tryReadVersionConflict(err);
|
|
2823
|
+
if (conflict !== null) return conflict;
|
|
2824
|
+
throw err;
|
|
2825
|
+
}
|
|
2826
|
+
},
|
|
2827
|
+
async rotate(input) {
|
|
2828
|
+
const q = scopeToQuery(input.scope);
|
|
2829
|
+
const response = await transport.request({
|
|
2830
|
+
method: "POST",
|
|
2831
|
+
path: `/v1/secrets/${encodeURIComponent(input.name)}/rotate`,
|
|
2832
|
+
query: {
|
|
2833
|
+
envName: input.envName,
|
|
2834
|
+
scopeKind: q.scopeKind,
|
|
2835
|
+
...q.scopeId !== void 0 && { scopeId: q.scopeId }
|
|
2836
|
+
},
|
|
2837
|
+
body: {
|
|
2838
|
+
scope: scopeForBody(input.scope),
|
|
2839
|
+
envName: input.envName,
|
|
2840
|
+
...input.newValue !== void 0 && { newValue: input.newValue },
|
|
2841
|
+
...input.revokeOldAfterMs !== void 0 && {
|
|
2842
|
+
revokeOldAfterMs: input.revokeOldAfterMs
|
|
2843
|
+
}
|
|
2844
|
+
},
|
|
2845
|
+
...input.idempotencyKey !== void 0 && {
|
|
2846
|
+
idempotencyKey: input.idempotencyKey
|
|
2847
|
+
}
|
|
2848
|
+
});
|
|
2849
|
+
const mode = input.mode ?? "wait-for-complete";
|
|
2850
|
+
if (mode === "raw") {
|
|
2851
|
+
return { kind: "raw", response };
|
|
2852
|
+
}
|
|
2853
|
+
if (response.kind === "sync") {
|
|
2854
|
+
return {
|
|
2855
|
+
kind: "ok",
|
|
2856
|
+
newVersionId: response.newVersionId,
|
|
2857
|
+
oldVersionId: response.oldVersionId,
|
|
2858
|
+
...response.oldVersionRevokedAt !== void 0 && {
|
|
2859
|
+
oldVersionRevokedAt: response.oldVersionRevokedAt
|
|
2860
|
+
}
|
|
2861
|
+
};
|
|
2862
|
+
}
|
|
2863
|
+
return pollForRotationTerminal(transport, input, response.rotationId);
|
|
2864
|
+
},
|
|
2865
|
+
async revoke(input) {
|
|
2866
|
+
const q = scopeToQuery(input.scope);
|
|
2867
|
+
return transport.request({
|
|
2868
|
+
method: "DELETE",
|
|
2869
|
+
path: `/v1/secrets/${encodeURIComponent(input.name)}`,
|
|
2870
|
+
query: {
|
|
2871
|
+
envName: input.envName,
|
|
2872
|
+
scopeKind: q.scopeKind,
|
|
2873
|
+
...q.scopeId !== void 0 && { scopeId: q.scopeId },
|
|
2874
|
+
...input.hard === true && { hard: true },
|
|
2875
|
+
...input.reason !== void 0 && { reason: input.reason }
|
|
2876
|
+
}
|
|
2877
|
+
});
|
|
2878
|
+
},
|
|
2879
|
+
rotations: {
|
|
2880
|
+
async get(input) {
|
|
2881
|
+
const q = scopeToQuery(input.scope);
|
|
2882
|
+
return transport.request({
|
|
2883
|
+
method: "GET",
|
|
2884
|
+
path: `/v1/secrets/${encodeURIComponent(input.name)}/rotations/${encodeURIComponent(input.rotationId)}`,
|
|
2885
|
+
query: {
|
|
2886
|
+
envName: input.envName,
|
|
2887
|
+
scopeKind: q.scopeKind,
|
|
2888
|
+
...q.scopeId !== void 0 && { scopeId: q.scopeId }
|
|
2889
|
+
}
|
|
2890
|
+
});
|
|
2891
|
+
},
|
|
2892
|
+
events(input, options) {
|
|
2893
|
+
const q = scopeToQuery(input.scope);
|
|
2894
|
+
const params = new URLSearchParams();
|
|
2895
|
+
params.set("envName", input.envName);
|
|
2896
|
+
params.set("scopeKind", q.scopeKind);
|
|
2897
|
+
if (q.scopeId !== void 0) params.set("scopeId", q.scopeId);
|
|
2898
|
+
const url = `${transport.apiUrl}/v1/secrets/${encodeURIComponent(input.name)}/rotations/${encodeURIComponent(input.rotationId)}/events?${params.toString()}`;
|
|
2899
|
+
const source = readSse({
|
|
2900
|
+
url,
|
|
2901
|
+
headers: transport.authHeaders(),
|
|
2902
|
+
fetchImpl: transport.fetchImpl,
|
|
2903
|
+
...options?.signal !== void 0 && { signal: options.signal },
|
|
2904
|
+
...options?.initialBackoffMs !== void 0 && {
|
|
2905
|
+
initialBackoffMs: options.initialBackoffMs
|
|
2906
|
+
},
|
|
2907
|
+
...options?.maxBackoffMs !== void 0 && {
|
|
2908
|
+
maxBackoffMs: options.maxBackoffMs
|
|
2909
|
+
}
|
|
2910
|
+
});
|
|
2911
|
+
return unwrapSseData(source);
|
|
2912
|
+
}
|
|
2913
|
+
}
|
|
2914
|
+
};
|
|
2915
|
+
}
|
|
2916
|
+
function isKindOfNotFound(err, wireCode, resourceKind) {
|
|
2917
|
+
if (err === null || typeof err !== "object") return false;
|
|
2918
|
+
const asAny = err;
|
|
2919
|
+
const inner = asAny.error;
|
|
2920
|
+
if (inner === void 0) return false;
|
|
2921
|
+
const code = inner.code;
|
|
2922
|
+
const serverCode = inner.serverCode;
|
|
2923
|
+
if (code === wireCode) return true;
|
|
2924
|
+
if (code === "server" && serverCode === wireCode) return true;
|
|
2925
|
+
if (code === "not-found" && typeof inner.resource === "object" && inner.resource !== null && inner.resource.kind === resourceKind) {
|
|
2926
|
+
return true;
|
|
2927
|
+
}
|
|
2928
|
+
return false;
|
|
2929
|
+
}
|
|
2930
|
+
function tryReadVersionConflict(err) {
|
|
2931
|
+
if (err === null || typeof err !== "object") return null;
|
|
2932
|
+
const asAny = err;
|
|
2933
|
+
const inner = asAny.error;
|
|
2934
|
+
if (inner === void 0) return null;
|
|
2935
|
+
const isConflict = inner.code === "secret-write-conflict" || inner.code === "conflict" || inner.serverCode === "secret-write-conflict";
|
|
2936
|
+
if (!isConflict) return null;
|
|
2937
|
+
const fromFields = inner.fields?.currentVersion;
|
|
2938
|
+
const current = typeof fromFields === "number" ? fromFields : inner.currentVersion;
|
|
2939
|
+
if (typeof current !== "number") return null;
|
|
2940
|
+
return { kind: "version-conflict", currentVersion: current };
|
|
2941
|
+
}
|
|
2942
|
+
|
|
2943
|
+
// src/resources/signing-keys.ts
|
|
2944
|
+
function makeSigningKeysClient(transport) {
|
|
2945
|
+
return {
|
|
2946
|
+
async trust(input, options) {
|
|
2947
|
+
return transport.request({
|
|
2948
|
+
method: "POST",
|
|
2949
|
+
path: "/v1/signing-keys",
|
|
2950
|
+
body: input,
|
|
2951
|
+
...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
|
|
2952
|
+
});
|
|
2953
|
+
},
|
|
2954
|
+
async list(filter) {
|
|
2955
|
+
return transport.request({
|
|
2956
|
+
method: "GET",
|
|
2957
|
+
path: "/v1/signing-keys",
|
|
2958
|
+
query: {
|
|
2959
|
+
...filter?.limit !== void 0 && { limit: filter.limit },
|
|
2960
|
+
...filter?.cursor !== void 0 && { cursor: filter.cursor },
|
|
2961
|
+
...filter?.includeRevoked === true && { includeRevoked: "true" },
|
|
2962
|
+
...filter?.label !== void 0 && { label: filter.label }
|
|
2963
|
+
}
|
|
2964
|
+
});
|
|
2965
|
+
},
|
|
2966
|
+
async get(keyId) {
|
|
2967
|
+
return transport.request({
|
|
2968
|
+
method: "GET",
|
|
2969
|
+
path: `/v1/signing-keys/${encodeURIComponent(keyId)}`
|
|
2970
|
+
});
|
|
2971
|
+
},
|
|
2972
|
+
async revoke(keyId, input, options) {
|
|
2973
|
+
return transport.request({
|
|
2974
|
+
method: "POST",
|
|
2975
|
+
path: `/v1/signing-keys/${encodeURIComponent(keyId)}/revoke`,
|
|
2976
|
+
body: input ?? {},
|
|
2977
|
+
...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
|
|
2978
|
+
});
|
|
2979
|
+
}
|
|
2980
|
+
};
|
|
2981
|
+
}
|
|
2982
|
+
|
|
2983
|
+
// src/resources/supervisor.ts
|
|
2984
|
+
var REASON_NO_SUPERVISOR_CRUD = "no /v1/supervisors CRUD routes on the API \u2014 supervisor persistence is caller-plugged via SupervisorBinding at deployment boot (framework does NOT own supervisor storage; analogous to the identity-directory pattern for users)";
|
|
2985
|
+
function makeSupervisorClient(transport) {
|
|
2986
|
+
const supervisorHeader = (supervisorId) => ({
|
|
2987
|
+
"X-Supervisor-Id": supervisorId
|
|
2988
|
+
});
|
|
2989
|
+
return {
|
|
2990
|
+
async define(_spec) {
|
|
2991
|
+
throw new KindgiApiError(notYetWired("supervisor.define", REASON_NO_SUPERVISOR_CRUD));
|
|
2992
|
+
},
|
|
2993
|
+
async get(_id) {
|
|
2994
|
+
throw new KindgiApiError(notYetWired("supervisor.get", REASON_NO_SUPERVISOR_CRUD));
|
|
2995
|
+
},
|
|
2996
|
+
async list(_filter) {
|
|
2997
|
+
throw new KindgiApiError(notYetWired("supervisor.list", REASON_NO_SUPERVISOR_CRUD));
|
|
2998
|
+
},
|
|
2999
|
+
async versions(_id) {
|
|
3000
|
+
throw new KindgiApiError(notYetWired("supervisor.versions", REASON_NO_SUPERVISOR_CRUD));
|
|
3001
|
+
},
|
|
3002
|
+
async delete(_id) {
|
|
3003
|
+
throw new KindgiApiError(notYetWired("supervisor.delete", REASON_NO_SUPERVISOR_CRUD));
|
|
3004
|
+
},
|
|
3005
|
+
proposals: {
|
|
3006
|
+
async draft(input) {
|
|
3007
|
+
return transport.request({
|
|
3008
|
+
method: "POST",
|
|
3009
|
+
path: "/v1/proposals",
|
|
3010
|
+
headers: supervisorHeader(input.supervisorId),
|
|
3011
|
+
body: {
|
|
3012
|
+
agentId: input.agentId,
|
|
3013
|
+
agentVersion: input.agentVersion,
|
|
3014
|
+
tier: input.tier,
|
|
3015
|
+
change: input.change,
|
|
3016
|
+
patternRefs: input.patternRefs,
|
|
3017
|
+
hypothesis: input.hypothesis,
|
|
3018
|
+
proposerRuleId: input.proposerRuleId
|
|
3019
|
+
},
|
|
3020
|
+
...input.idempotencyKey !== void 0 && { idempotencyKey: input.idempotencyKey }
|
|
3021
|
+
});
|
|
3022
|
+
},
|
|
3023
|
+
async list(input) {
|
|
3024
|
+
const page = await transport.request({
|
|
3025
|
+
method: "GET",
|
|
3026
|
+
path: "/v1/proposals",
|
|
3027
|
+
headers: supervisorHeader(input.supervisorId),
|
|
3028
|
+
query: {
|
|
3029
|
+
...input.limit !== void 0 && { limit: input.limit },
|
|
3030
|
+
...input.cursor !== void 0 && { cursor: input.cursor },
|
|
3031
|
+
...input.status !== void 0 && { status: input.status },
|
|
3032
|
+
...input.agentId !== void 0 && { agentId: input.agentId },
|
|
3033
|
+
...input.tier !== void 0 && { tier: input.tier }
|
|
3034
|
+
}
|
|
3035
|
+
});
|
|
3036
|
+
return {
|
|
3037
|
+
items: page.data,
|
|
3038
|
+
...page.nextCursor !== void 0 && {
|
|
3039
|
+
nextCursor: page.nextCursor
|
|
3040
|
+
}
|
|
3041
|
+
};
|
|
3042
|
+
},
|
|
3043
|
+
async get(supervisorId, id) {
|
|
3044
|
+
return transport.request({
|
|
3045
|
+
method: "GET",
|
|
3046
|
+
path: `/v1/proposals/${encodeURIComponent(id)}`,
|
|
3047
|
+
headers: supervisorHeader(supervisorId)
|
|
3048
|
+
});
|
|
3049
|
+
},
|
|
3050
|
+
async dryRun(supervisorId, id, input) {
|
|
3051
|
+
return transport.request({
|
|
3052
|
+
method: "POST",
|
|
3053
|
+
path: `/v1/proposals/${encodeURIComponent(id)}/dry-run`,
|
|
3054
|
+
headers: supervisorHeader(supervisorId),
|
|
3055
|
+
body: {
|
|
3056
|
+
datasetId: input.datasetId,
|
|
3057
|
+
datasetVersion: input.datasetVersion,
|
|
3058
|
+
criterion: input.criterion
|
|
3059
|
+
},
|
|
3060
|
+
...input.idempotencyKey !== void 0 && { idempotencyKey: input.idempotencyKey }
|
|
3061
|
+
});
|
|
3062
|
+
},
|
|
3063
|
+
async submitForReview(supervisorId, id, input) {
|
|
3064
|
+
const body = {};
|
|
3065
|
+
if (input?.requiredRole !== void 0) body.requiredRole = input.requiredRole;
|
|
3066
|
+
if (input?.expiresAt !== void 0) body.expiresAt = input.expiresAt;
|
|
3067
|
+
return transport.request({
|
|
3068
|
+
method: "POST",
|
|
3069
|
+
path: `/v1/proposals/${encodeURIComponent(id)}/submit-review`,
|
|
3070
|
+
headers: supervisorHeader(supervisorId),
|
|
3071
|
+
body,
|
|
3072
|
+
...input?.idempotencyKey !== void 0 && { idempotencyKey: input.idempotencyKey }
|
|
3073
|
+
});
|
|
3074
|
+
},
|
|
3075
|
+
async reflectReview(_supervisorId, _id, _input) {
|
|
3076
|
+
throw new KindgiApiError(
|
|
3077
|
+
notYetWired(
|
|
3078
|
+
"supervisor.proposals.reflectReview",
|
|
3079
|
+
"no POST /v1/proposals/{id}/reflect-review route on the API \u2014 review reflection is atomic with POST /v1/approvals/{id}/complete (wire detects the linked proposal + updates status alongside the decision)"
|
|
3080
|
+
)
|
|
3081
|
+
);
|
|
3082
|
+
},
|
|
3083
|
+
async apply(supervisorId, id, input) {
|
|
3084
|
+
const body = {};
|
|
3085
|
+
if (input?.newVersion !== void 0) body.newVersion = input.newVersion;
|
|
3086
|
+
return transport.request({
|
|
3087
|
+
method: "POST",
|
|
3088
|
+
path: `/v1/proposals/${encodeURIComponent(id)}/apply`,
|
|
3089
|
+
headers: supervisorHeader(supervisorId),
|
|
3090
|
+
body,
|
|
3091
|
+
...input?.idempotencyKey !== void 0 && { idempotencyKey: input.idempotencyKey }
|
|
3092
|
+
});
|
|
3093
|
+
},
|
|
3094
|
+
async rollback(supervisorId, id, input) {
|
|
3095
|
+
return transport.request({
|
|
3096
|
+
method: "POST",
|
|
3097
|
+
path: `/v1/proposals/${encodeURIComponent(id)}/rollback`,
|
|
3098
|
+
headers: supervisorHeader(supervisorId),
|
|
3099
|
+
body: { reason: input.reason },
|
|
3100
|
+
...input.idempotencyKey !== void 0 && { idempotencyKey: input.idempotencyKey }
|
|
3101
|
+
});
|
|
3102
|
+
},
|
|
3103
|
+
async withdraw(supervisorId, id, input) {
|
|
3104
|
+
return transport.request({
|
|
3105
|
+
method: "POST",
|
|
3106
|
+
path: `/v1/proposals/${encodeURIComponent(id)}/withdraw`,
|
|
3107
|
+
headers: supervisorHeader(supervisorId),
|
|
3108
|
+
body: { reason: input.reason },
|
|
3109
|
+
...input.idempotencyKey !== void 0 && { idempotencyKey: input.idempotencyKey }
|
|
3110
|
+
});
|
|
3111
|
+
}
|
|
3112
|
+
}
|
|
3113
|
+
};
|
|
3114
|
+
}
|
|
3115
|
+
|
|
3116
|
+
// src/resources/teams.ts
|
|
3117
|
+
function makeTeamsClient(transport) {
|
|
3118
|
+
const seg = (s) => encodeURIComponent(s);
|
|
3119
|
+
return {
|
|
3120
|
+
async create(input, options) {
|
|
3121
|
+
return transport.request({
|
|
3122
|
+
method: "POST",
|
|
3123
|
+
path: "/v1/teams",
|
|
3124
|
+
body: input,
|
|
3125
|
+
...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
|
|
3126
|
+
});
|
|
3127
|
+
},
|
|
3128
|
+
async list(filter) {
|
|
3129
|
+
return transport.request({
|
|
3130
|
+
method: "GET",
|
|
3131
|
+
path: "/v1/teams",
|
|
3132
|
+
query: {
|
|
3133
|
+
...filter?.limit !== void 0 && { limit: filter.limit },
|
|
3134
|
+
...filter?.cursor !== void 0 && { cursor: filter.cursor }
|
|
3135
|
+
}
|
|
3136
|
+
});
|
|
3137
|
+
},
|
|
3138
|
+
async get(teamId) {
|
|
3139
|
+
return transport.request({
|
|
3140
|
+
method: "GET",
|
|
3141
|
+
path: `/v1/teams/${seg(teamId)}`
|
|
3142
|
+
});
|
|
3143
|
+
},
|
|
3144
|
+
async update(teamId, input, options) {
|
|
3145
|
+
return transport.request({
|
|
3146
|
+
method: "PATCH",
|
|
3147
|
+
path: `/v1/teams/${seg(teamId)}`,
|
|
3148
|
+
body: input,
|
|
3149
|
+
...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
|
|
3150
|
+
});
|
|
3151
|
+
},
|
|
3152
|
+
async delete(teamId) {
|
|
3153
|
+
return transport.request({
|
|
3154
|
+
method: "DELETE",
|
|
3155
|
+
path: `/v1/teams/${seg(teamId)}`,
|
|
3156
|
+
discardResponse: true
|
|
3157
|
+
});
|
|
3158
|
+
},
|
|
3159
|
+
memberships: {
|
|
3160
|
+
async list(teamId, filter) {
|
|
3161
|
+
return transport.request({
|
|
3162
|
+
method: "GET",
|
|
3163
|
+
path: `/v1/teams/${seg(teamId)}/memberships`,
|
|
3164
|
+
query: {
|
|
3165
|
+
...filter?.limit !== void 0 && { limit: filter.limit },
|
|
3166
|
+
...filter?.cursor !== void 0 && { cursor: filter.cursor }
|
|
3167
|
+
}
|
|
3168
|
+
});
|
|
3169
|
+
},
|
|
3170
|
+
async add(teamId, input, options) {
|
|
3171
|
+
return transport.request({
|
|
3172
|
+
method: "POST",
|
|
3173
|
+
path: `/v1/teams/${seg(teamId)}/memberships`,
|
|
3174
|
+
body: input,
|
|
3175
|
+
...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
|
|
3176
|
+
});
|
|
3177
|
+
},
|
|
3178
|
+
async updateRole(teamId, userId, role, options) {
|
|
3179
|
+
return transport.request({
|
|
3180
|
+
method: "PATCH",
|
|
3181
|
+
path: `/v1/teams/${seg(teamId)}/memberships/${seg(userId)}`,
|
|
3182
|
+
body: { role },
|
|
3183
|
+
discardResponse: true,
|
|
3184
|
+
...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
|
|
3185
|
+
});
|
|
3186
|
+
},
|
|
3187
|
+
async remove(teamId, userId, options) {
|
|
3188
|
+
return transport.request({
|
|
3189
|
+
method: "DELETE",
|
|
3190
|
+
path: `/v1/teams/${seg(teamId)}/memberships/${seg(userId)}`,
|
|
3191
|
+
discardResponse: true,
|
|
3192
|
+
...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
|
|
3193
|
+
});
|
|
3194
|
+
}
|
|
3195
|
+
}
|
|
3196
|
+
};
|
|
3197
|
+
}
|
|
3198
|
+
|
|
3199
|
+
// src/resources/tenant.ts
|
|
3200
|
+
function makeTenantClient(transport) {
|
|
3201
|
+
return {
|
|
3202
|
+
async get() {
|
|
3203
|
+
return transport.request({
|
|
3204
|
+
method: "GET",
|
|
3205
|
+
path: "/v1/tenant"
|
|
3206
|
+
});
|
|
3207
|
+
},
|
|
3208
|
+
config: {
|
|
3209
|
+
async list(filter) {
|
|
3210
|
+
return transport.request({
|
|
3211
|
+
method: "GET",
|
|
3212
|
+
path: "/v1/tenant/config",
|
|
3213
|
+
query: {
|
|
3214
|
+
...filter?.limit !== void 0 && { limit: filter.limit },
|
|
3215
|
+
...filter?.cursor !== void 0 && { cursor: filter.cursor },
|
|
3216
|
+
...filter?.kind !== void 0 && { kind: filter.kind },
|
|
3217
|
+
...filter?.keyPrefix !== void 0 && { keyPrefix: filter.keyPrefix }
|
|
3218
|
+
}
|
|
3219
|
+
});
|
|
3220
|
+
},
|
|
3221
|
+
async upsert(input, options) {
|
|
3222
|
+
return transport.request({
|
|
3223
|
+
method: "PATCH",
|
|
3224
|
+
path: "/v1/tenant/config",
|
|
3225
|
+
body: input,
|
|
3226
|
+
...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
|
|
3227
|
+
});
|
|
3228
|
+
}
|
|
3229
|
+
}
|
|
3230
|
+
};
|
|
3231
|
+
}
|
|
3232
|
+
|
|
3233
|
+
// src/resources/tokens.ts
|
|
3234
|
+
function fromWire2(wire) {
|
|
3235
|
+
return {
|
|
3236
|
+
id: wire.tokenId,
|
|
3237
|
+
role: wire.role,
|
|
3238
|
+
capabilities: wire.capabilities,
|
|
3239
|
+
...wire.label !== void 0 && { label: wire.label },
|
|
3240
|
+
...wire.projectId !== void 0 && {
|
|
3241
|
+
projectId: wire.projectId
|
|
3242
|
+
},
|
|
3243
|
+
...wire.createdBy !== void 0 && { createdBy: wire.createdBy },
|
|
3244
|
+
createdAt: wire.createdAt,
|
|
3245
|
+
...wire.lastUsedAt !== void 0 && { lastUsedAt: wire.lastUsedAt },
|
|
3246
|
+
...wire.expiresAt !== void 0 && { expiresAt: wire.expiresAt },
|
|
3247
|
+
...wire.revokedAt !== void 0 && { revokedAt: wire.revokedAt }
|
|
3248
|
+
};
|
|
3249
|
+
}
|
|
3250
|
+
function makeTokensClient(transport) {
|
|
3251
|
+
return {
|
|
3252
|
+
async create(spec, options) {
|
|
3253
|
+
const body = {};
|
|
3254
|
+
if (spec?.role !== void 0) body.role = spec.role;
|
|
3255
|
+
if (spec?.capabilities !== void 0) body.capabilities = spec.capabilities;
|
|
3256
|
+
if (spec?.label !== void 0) body.label = spec.label;
|
|
3257
|
+
if (spec?.expiresAt !== void 0) body.expiresAt = spec.expiresAt;
|
|
3258
|
+
if (spec?.projectId !== void 0) body.projectId = spec.projectId;
|
|
3259
|
+
const wire = await transport.request({
|
|
3260
|
+
method: "POST",
|
|
3261
|
+
path: "/v1/tokens",
|
|
3262
|
+
body,
|
|
3263
|
+
...options?.idempotencyKey !== void 0 && {
|
|
3264
|
+
idempotencyKey: options.idempotencyKey
|
|
3265
|
+
}
|
|
3266
|
+
});
|
|
3267
|
+
const { token, ...record } = wire;
|
|
3268
|
+
return { meta: fromWire2(record), secret: token };
|
|
3269
|
+
},
|
|
3270
|
+
async list(filter) {
|
|
3271
|
+
const page = await transport.request({
|
|
3272
|
+
method: "GET",
|
|
3273
|
+
path: "/v1/tokens",
|
|
3274
|
+
query: {
|
|
3275
|
+
...filter?.limit !== void 0 && { limit: filter.limit },
|
|
3276
|
+
...filter?.cursor !== void 0 && { cursor: filter.cursor }
|
|
3277
|
+
}
|
|
3278
|
+
});
|
|
3279
|
+
return {
|
|
3280
|
+
items: page.data.map(fromWire2),
|
|
3281
|
+
...page.nextCursor !== void 0 && { nextCursor: page.nextCursor }
|
|
3282
|
+
};
|
|
3283
|
+
},
|
|
3284
|
+
async get(id) {
|
|
3285
|
+
const wire = await transport.request({
|
|
3286
|
+
method: "GET",
|
|
3287
|
+
path: `/v1/tokens/${encodeURIComponent(id)}`
|
|
3288
|
+
});
|
|
3289
|
+
return fromWire2(wire);
|
|
3290
|
+
},
|
|
3291
|
+
async createPublic(input, options) {
|
|
3292
|
+
return transport.request({
|
|
3293
|
+
method: "POST",
|
|
3294
|
+
path: "/v1/tokens/public",
|
|
3295
|
+
body: input,
|
|
3296
|
+
...options?.idempotencyKey !== void 0 && {
|
|
3297
|
+
idempotencyKey: options.idempotencyKey
|
|
3298
|
+
}
|
|
3299
|
+
});
|
|
3300
|
+
},
|
|
3301
|
+
async revoke(id, options) {
|
|
3302
|
+
await transport.request({
|
|
3303
|
+
method: "POST",
|
|
3304
|
+
path: `/v1/tokens/${encodeURIComponent(id)}/revoke`,
|
|
3305
|
+
body: {},
|
|
3306
|
+
discardResponse: true,
|
|
3307
|
+
...options?.idempotencyKey !== void 0 && {
|
|
3308
|
+
idempotencyKey: options.idempotencyKey
|
|
3309
|
+
}
|
|
3310
|
+
});
|
|
3311
|
+
}
|
|
3312
|
+
};
|
|
3313
|
+
}
|
|
3314
|
+
|
|
3315
|
+
// src/resources/tools.ts
|
|
3316
|
+
function makeToolsClient(transport) {
|
|
3317
|
+
return {
|
|
3318
|
+
async list(filter) {
|
|
3319
|
+
const page = await transport.request({
|
|
3320
|
+
method: "GET",
|
|
3321
|
+
path: "/v1/tools",
|
|
3322
|
+
query: {
|
|
3323
|
+
...filter?.limit !== void 0 && { limit: filter.limit },
|
|
3324
|
+
...filter?.cursor !== void 0 && { cursor: filter.cursor },
|
|
3325
|
+
...filter?.name !== void 0 && { name: filter.name }
|
|
3326
|
+
}
|
|
3327
|
+
});
|
|
3328
|
+
return {
|
|
3329
|
+
items: page.data,
|
|
3330
|
+
...page.nextCursor !== void 0 && { nextCursor: page.nextCursor }
|
|
3331
|
+
};
|
|
3332
|
+
},
|
|
3333
|
+
async get(id) {
|
|
3334
|
+
return transport.request({
|
|
3335
|
+
method: "GET",
|
|
3336
|
+
path: `/v1/tools/${encodeURIComponent(id)}`
|
|
3337
|
+
});
|
|
3338
|
+
},
|
|
3339
|
+
async listVersions(id, filter) {
|
|
3340
|
+
const page = await transport.request({
|
|
3341
|
+
method: "GET",
|
|
3342
|
+
path: `/v1/tools/${encodeURIComponent(id)}/versions`,
|
|
3343
|
+
query: {
|
|
3344
|
+
...filter?.limit !== void 0 && { limit: filter.limit },
|
|
3345
|
+
...filter?.cursor !== void 0 && { cursor: filter.cursor },
|
|
3346
|
+
...filter?.includeTombstoned === true && { includeTombstoned: "true" }
|
|
3347
|
+
}
|
|
3348
|
+
});
|
|
3349
|
+
return {
|
|
3350
|
+
items: page.data,
|
|
3351
|
+
...page.nextCursor !== void 0 && { nextCursor: page.nextCursor }
|
|
3352
|
+
};
|
|
3353
|
+
},
|
|
3354
|
+
async getVersion(id, version) {
|
|
3355
|
+
return transport.request({
|
|
3356
|
+
method: "GET",
|
|
3357
|
+
path: `/v1/tools/${encodeURIComponent(id)}/versions/${encodeURIComponent(version)}`
|
|
3358
|
+
});
|
|
3359
|
+
},
|
|
3360
|
+
async reinstateVersion(id, version, options) {
|
|
3361
|
+
const wire = await transport.request({
|
|
3362
|
+
method: "POST",
|
|
3363
|
+
path: `/v1/tools/${encodeURIComponent(id)}/versions/${encodeURIComponent(version)}/reinstate`,
|
|
3364
|
+
...options?.idempotencyKey !== void 0 && {
|
|
3365
|
+
idempotencyKey: options.idempotencyKey
|
|
3366
|
+
}
|
|
3367
|
+
});
|
|
3368
|
+
return {
|
|
3369
|
+
toolId: wire.toolId,
|
|
3370
|
+
version: wire.version,
|
|
3371
|
+
wasTombstoned: wire.wasTombstoned
|
|
3372
|
+
};
|
|
3373
|
+
},
|
|
3374
|
+
async unregisterVersion(id, version, options) {
|
|
3375
|
+
const wire = await transport.request({
|
|
3376
|
+
method: "POST",
|
|
3377
|
+
path: `/v1/tools/${encodeURIComponent(id)}/versions/${encodeURIComponent(version)}/unregister`,
|
|
3378
|
+
...options?.idempotencyKey !== void 0 && {
|
|
3379
|
+
idempotencyKey: options.idempotencyKey
|
|
3380
|
+
}
|
|
3381
|
+
});
|
|
3382
|
+
return {
|
|
3383
|
+
toolId: wire.toolId,
|
|
3384
|
+
version: wire.version,
|
|
3385
|
+
unregistered: wire.unregistered
|
|
3386
|
+
};
|
|
3387
|
+
},
|
|
3388
|
+
async invoke(_id, _input) {
|
|
3389
|
+
throw new KindgiApiError(
|
|
3390
|
+
notYetWired(
|
|
3391
|
+
"tools.invoke",
|
|
3392
|
+
"no POST /v1/tools/{toolId}/invoke route on the API \u2014 direct invocation surface unrouted"
|
|
3393
|
+
)
|
|
3394
|
+
);
|
|
3395
|
+
},
|
|
3396
|
+
async manifests(_filter) {
|
|
3397
|
+
throw new KindgiApiError(
|
|
3398
|
+
notYetWired(
|
|
3399
|
+
"tools.manifests",
|
|
3400
|
+
"the wire `Tool` is the manifest; the API has no separate manifests endpoint"
|
|
3401
|
+
)
|
|
3402
|
+
);
|
|
3403
|
+
}
|
|
3404
|
+
};
|
|
3405
|
+
}
|
|
3406
|
+
|
|
3407
|
+
// src/resources/users.ts
|
|
3408
|
+
function makeUsersClient(transport) {
|
|
3409
|
+
return {
|
|
3410
|
+
async create(_spec) {
|
|
3411
|
+
throw new KindgiApiError(
|
|
3412
|
+
notYetWired(
|
|
3413
|
+
"users.create",
|
|
3414
|
+
"no user-creation route on the wire \u2014 framework does NOT own user persistence (deployments plug LDAP / SCIM / bespoke stores via IdentityDirectoryBinding)"
|
|
3415
|
+
)
|
|
3416
|
+
);
|
|
3417
|
+
},
|
|
3418
|
+
async get(id) {
|
|
3419
|
+
return transport.request({
|
|
3420
|
+
method: "GET",
|
|
3421
|
+
path: `/v1/identity/users/${encodeURIComponent(id)}`
|
|
3422
|
+
});
|
|
3423
|
+
},
|
|
3424
|
+
async me() {
|
|
3425
|
+
return transport.request({
|
|
3426
|
+
method: "GET",
|
|
3427
|
+
path: "/v1/identity/whoami"
|
|
3428
|
+
});
|
|
3429
|
+
},
|
|
3430
|
+
async list(filter) {
|
|
3431
|
+
const page = await transport.request({
|
|
3432
|
+
method: "GET",
|
|
3433
|
+
path: "/v1/identity/users",
|
|
3434
|
+
query: {
|
|
3435
|
+
...filter?.limit !== void 0 && { limit: filter.limit },
|
|
3436
|
+
...filter?.cursor !== void 0 && { cursor: filter.cursor },
|
|
3437
|
+
...filter?.query !== void 0 && { query: filter.query }
|
|
3438
|
+
}
|
|
3439
|
+
});
|
|
3440
|
+
return {
|
|
3441
|
+
items: page.data,
|
|
3442
|
+
...page.nextCursor !== void 0 && {
|
|
3443
|
+
nextCursor: page.nextCursor
|
|
3444
|
+
}
|
|
3445
|
+
};
|
|
3446
|
+
},
|
|
3447
|
+
async update(_id, _patch) {
|
|
3448
|
+
throw new KindgiApiError(
|
|
3449
|
+
notYetWired(
|
|
3450
|
+
"users.update",
|
|
3451
|
+
"no user-update route on the wire \u2014 framework does NOT own user persistence"
|
|
3452
|
+
)
|
|
3453
|
+
);
|
|
3454
|
+
},
|
|
3455
|
+
async deactivate(_id) {
|
|
3456
|
+
throw new KindgiApiError(
|
|
3457
|
+
notYetWired(
|
|
3458
|
+
"users.deactivate",
|
|
3459
|
+
"no user-deactivate route on the wire \u2014 framework does NOT own user persistence"
|
|
3460
|
+
)
|
|
3461
|
+
);
|
|
3462
|
+
},
|
|
3463
|
+
sessions: {
|
|
3464
|
+
async list(userId) {
|
|
3465
|
+
const page = await transport.request({
|
|
3466
|
+
method: "GET",
|
|
3467
|
+
path: `/v1/identity/users/${encodeURIComponent(userId)}/sessions`
|
|
3468
|
+
});
|
|
3469
|
+
return {
|
|
3470
|
+
items: page.data,
|
|
3471
|
+
...page.nextCursor !== void 0 && {
|
|
3472
|
+
nextCursor: page.nextCursor
|
|
3473
|
+
}
|
|
3474
|
+
};
|
|
3475
|
+
},
|
|
3476
|
+
async revokeAll(userId, options) {
|
|
3477
|
+
return transport.request({
|
|
3478
|
+
method: "POST",
|
|
3479
|
+
path: `/v1/identity/users/${encodeURIComponent(userId)}/revoke-sessions`,
|
|
3480
|
+
body: {},
|
|
3481
|
+
...options?.idempotencyKey !== void 0 && {
|
|
3482
|
+
idempotencyKey: options.idempotencyKey
|
|
3483
|
+
}
|
|
3484
|
+
});
|
|
3485
|
+
},
|
|
3486
|
+
async revoke(_id) {
|
|
3487
|
+
throw new KindgiApiError(
|
|
3488
|
+
notYetWired(
|
|
3489
|
+
"users.sessions.revoke",
|
|
3490
|
+
"no per-session revoke route on the wire \u2014 wire revokes ALL sessions for a user via revokeAll(userId); per-session revoke has design merit but no route yet"
|
|
3491
|
+
)
|
|
3492
|
+
);
|
|
3493
|
+
}
|
|
3494
|
+
}
|
|
3495
|
+
};
|
|
3496
|
+
}
|
|
3497
|
+
|
|
3498
|
+
// src/resources/webhook-endpoints.ts
|
|
3499
|
+
function makeWebhookEndpointsClient(transport) {
|
|
3500
|
+
const idempotency = (options) => options?.idempotencyKey !== void 0 ? { idempotencyKey: options.idempotencyKey } : {};
|
|
3501
|
+
return {
|
|
3502
|
+
async create(input, options) {
|
|
3503
|
+
return transport.request({
|
|
3504
|
+
method: "POST",
|
|
3505
|
+
path: "/v1/webhook-endpoints",
|
|
3506
|
+
body: input,
|
|
3507
|
+
...idempotency(options)
|
|
3508
|
+
});
|
|
3509
|
+
},
|
|
3510
|
+
async generateSecret() {
|
|
3511
|
+
return transport.request({
|
|
3512
|
+
method: "POST",
|
|
3513
|
+
path: "/v1/webhook-endpoints/generate-secret"
|
|
3514
|
+
});
|
|
3515
|
+
},
|
|
3516
|
+
async list(filter) {
|
|
3517
|
+
return transport.request({
|
|
3518
|
+
method: "GET",
|
|
3519
|
+
path: "/v1/webhook-endpoints",
|
|
3520
|
+
query: {
|
|
3521
|
+
...filter?.limit !== void 0 && { limit: filter.limit },
|
|
3522
|
+
...filter?.cursor !== void 0 && { cursor: filter.cursor }
|
|
3523
|
+
}
|
|
3524
|
+
});
|
|
3525
|
+
},
|
|
3526
|
+
async get(endpointId) {
|
|
3527
|
+
return transport.request({
|
|
3528
|
+
method: "GET",
|
|
3529
|
+
path: `/v1/webhook-endpoints/${encodeURIComponent(endpointId)}`
|
|
3530
|
+
});
|
|
3531
|
+
},
|
|
3532
|
+
async update(endpointId, input, options) {
|
|
3533
|
+
return transport.request({
|
|
3534
|
+
method: "PATCH",
|
|
3535
|
+
path: `/v1/webhook-endpoints/${encodeURIComponent(endpointId)}`,
|
|
3536
|
+
body: input,
|
|
3537
|
+
...idempotency(options)
|
|
3538
|
+
});
|
|
3539
|
+
},
|
|
3540
|
+
async unregister(endpointId, options) {
|
|
3541
|
+
return transport.request({
|
|
3542
|
+
method: "POST",
|
|
3543
|
+
path: `/v1/webhook-endpoints/${encodeURIComponent(endpointId)}/unregister`,
|
|
3544
|
+
...idempotency(options)
|
|
3545
|
+
});
|
|
3546
|
+
},
|
|
3547
|
+
async listDeliveries(endpointId, filter) {
|
|
3548
|
+
return transport.request({
|
|
3549
|
+
method: "GET",
|
|
3550
|
+
path: `/v1/webhook-endpoints/${encodeURIComponent(endpointId)}/deliveries`,
|
|
3551
|
+
query: {
|
|
3552
|
+
...filter?.limit !== void 0 && { limit: filter.limit },
|
|
3553
|
+
...filter?.cursor !== void 0 && { cursor: filter.cursor },
|
|
3554
|
+
...filter?.status !== void 0 && { status: filter.status }
|
|
3555
|
+
}
|
|
3556
|
+
});
|
|
3557
|
+
},
|
|
3558
|
+
async redeliver(endpointId, deliveryId, options) {
|
|
3559
|
+
return transport.request({
|
|
3560
|
+
method: "POST",
|
|
3561
|
+
path: `/v1/webhook-endpoints/${encodeURIComponent(endpointId)}/deliveries/${encodeURIComponent(deliveryId)}/redeliver`,
|
|
3562
|
+
...idempotency(options)
|
|
3563
|
+
});
|
|
3564
|
+
},
|
|
3565
|
+
async sendTest(endpointId, options) {
|
|
3566
|
+
return transport.request({
|
|
3567
|
+
method: "POST",
|
|
3568
|
+
path: `/v1/webhook-endpoints/${encodeURIComponent(endpointId)}/test`,
|
|
3569
|
+
...idempotency(options)
|
|
3570
|
+
});
|
|
3571
|
+
}
|
|
3572
|
+
};
|
|
3573
|
+
}
|
|
3574
|
+
|
|
3575
|
+
// src/resources/webhooks.ts
|
|
3576
|
+
function makeWebhooksClient(transport) {
|
|
3577
|
+
return {
|
|
3578
|
+
async register(input, options) {
|
|
3579
|
+
return transport.request({
|
|
3580
|
+
method: "POST",
|
|
3581
|
+
path: "/v1/webhooks",
|
|
3582
|
+
body: input,
|
|
3583
|
+
...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
|
|
3584
|
+
});
|
|
3585
|
+
},
|
|
3586
|
+
async list(filter) {
|
|
3587
|
+
return transport.request({
|
|
3588
|
+
method: "GET",
|
|
3589
|
+
path: "/v1/webhooks",
|
|
3590
|
+
query: {
|
|
3591
|
+
...filter?.limit !== void 0 && { limit: filter.limit },
|
|
3592
|
+
...filter?.cursor !== void 0 && { cursor: filter.cursor },
|
|
3593
|
+
...filter?.status !== void 0 && { status: filter.status }
|
|
3594
|
+
}
|
|
3595
|
+
});
|
|
3596
|
+
},
|
|
3597
|
+
async get(triggerId) {
|
|
3598
|
+
return transport.request({
|
|
3599
|
+
method: "GET",
|
|
3600
|
+
path: `/v1/webhooks/${encodeURIComponent(triggerId)}`
|
|
3601
|
+
});
|
|
3602
|
+
},
|
|
3603
|
+
async update(triggerId, input, options) {
|
|
3604
|
+
return transport.request({
|
|
3605
|
+
method: "PATCH",
|
|
3606
|
+
path: `/v1/webhooks/${encodeURIComponent(triggerId)}`,
|
|
3607
|
+
body: input,
|
|
3608
|
+
...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
|
|
3609
|
+
});
|
|
3610
|
+
},
|
|
3611
|
+
async pause(triggerId, options) {
|
|
3612
|
+
return transport.request({
|
|
3613
|
+
method: "POST",
|
|
3614
|
+
path: `/v1/webhooks/${encodeURIComponent(triggerId)}/pause`,
|
|
3615
|
+
...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
|
|
3616
|
+
});
|
|
3617
|
+
},
|
|
3618
|
+
async resume(triggerId, options) {
|
|
3619
|
+
return transport.request({
|
|
3620
|
+
method: "POST",
|
|
3621
|
+
path: `/v1/webhooks/${encodeURIComponent(triggerId)}/resume`,
|
|
3622
|
+
...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
|
|
3623
|
+
});
|
|
3624
|
+
},
|
|
3625
|
+
async unregister(triggerId, options) {
|
|
3626
|
+
return transport.request({
|
|
3627
|
+
method: "POST",
|
|
3628
|
+
path: `/v1/webhooks/${encodeURIComponent(triggerId)}/unregister`,
|
|
3629
|
+
...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
|
|
3630
|
+
});
|
|
3631
|
+
}
|
|
3632
|
+
};
|
|
3633
|
+
}
|
|
3634
|
+
|
|
3635
|
+
// src/transport.ts
|
|
3636
|
+
var DEFAULT_TIMEOUT_MS = 3e4;
|
|
3637
|
+
var MUTATING = /* @__PURE__ */ new Set([
|
|
3638
|
+
"POST",
|
|
3639
|
+
"PUT",
|
|
3640
|
+
"PATCH",
|
|
3641
|
+
"DELETE"
|
|
3642
|
+
]);
|
|
3643
|
+
function createTransport(options) {
|
|
3644
|
+
const apiUrl = options.apiUrl.replace(/\/+$/u, "");
|
|
3645
|
+
const fetchImpl = options.fetch ?? fetch;
|
|
3646
|
+
const clientTimeoutMs = DEFAULT_TIMEOUT_MS;
|
|
3647
|
+
return {
|
|
3648
|
+
apiUrl,
|
|
3649
|
+
fetchImpl,
|
|
3650
|
+
authHeaders() {
|
|
3651
|
+
return { Authorization: `Bearer ${authTokenFor(options.auth)}` };
|
|
3652
|
+
},
|
|
3653
|
+
async request(input) {
|
|
3654
|
+
const url = buildUrl(apiUrl, input.path, input.query);
|
|
3655
|
+
const headers = buildHeaders(input, options.auth);
|
|
3656
|
+
const timeoutMs = input.timeoutMs ?? clientTimeoutMs;
|
|
3657
|
+
const ac = new AbortController();
|
|
3658
|
+
const timer = setTimeout(
|
|
3659
|
+
() => ac.abort(new Error("timeout")),
|
|
3660
|
+
timeoutMs
|
|
3661
|
+
);
|
|
3662
|
+
let response;
|
|
3663
|
+
try {
|
|
3664
|
+
response = await fetchImpl(url, {
|
|
3665
|
+
method: input.method,
|
|
3666
|
+
headers,
|
|
3667
|
+
...input.body !== void 0 && { body: JSON.stringify(input.body) },
|
|
3668
|
+
signal: ac.signal
|
|
3669
|
+
});
|
|
3670
|
+
} catch (cause) {
|
|
3671
|
+
clearTimeout(timer);
|
|
3672
|
+
const err = {
|
|
3673
|
+
code: "network",
|
|
3674
|
+
message: cause instanceof Error ? cause.message : "network request failed",
|
|
3675
|
+
cause
|
|
3676
|
+
};
|
|
3677
|
+
throw new KindgiApiError(err);
|
|
3678
|
+
}
|
|
3679
|
+
clearTimeout(timer);
|
|
3680
|
+
if (response.ok) {
|
|
3681
|
+
if (input.discardResponse === true || response.status === 204) {
|
|
3682
|
+
try {
|
|
3683
|
+
await response.arrayBuffer();
|
|
3684
|
+
} catch {
|
|
3685
|
+
}
|
|
3686
|
+
return void 0;
|
|
3687
|
+
}
|
|
3688
|
+
try {
|
|
3689
|
+
return await response.json();
|
|
3690
|
+
} catch (cause) {
|
|
3691
|
+
const err = {
|
|
3692
|
+
code: "network",
|
|
3693
|
+
message: "Response body was not valid JSON",
|
|
3694
|
+
cause
|
|
3695
|
+
};
|
|
3696
|
+
throw new KindgiApiError(err);
|
|
3697
|
+
}
|
|
3698
|
+
}
|
|
3699
|
+
let body;
|
|
3700
|
+
try {
|
|
3701
|
+
body = await response.json();
|
|
3702
|
+
} catch {
|
|
3703
|
+
body = void 0;
|
|
3704
|
+
}
|
|
3705
|
+
throw new KindgiApiError(fromWire(unwrapErrorEnvelope(body, response.status)));
|
|
3706
|
+
}
|
|
3707
|
+
};
|
|
3708
|
+
}
|
|
3709
|
+
function buildUrl(apiUrl, path, query) {
|
|
3710
|
+
const normalizedPath = path.startsWith("/") ? path : `/${path}`;
|
|
3711
|
+
const base = `${apiUrl}${normalizedPath}`;
|
|
3712
|
+
if (query === void 0) return base;
|
|
3713
|
+
const params = [];
|
|
3714
|
+
for (const key of Object.keys(query)) {
|
|
3715
|
+
const value = query[key];
|
|
3716
|
+
if (value === void 0) continue;
|
|
3717
|
+
params.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);
|
|
3718
|
+
}
|
|
3719
|
+
return params.length === 0 ? base : `${base}?${params.join("&")}`;
|
|
3720
|
+
}
|
|
3721
|
+
function buildHeaders(input, auth) {
|
|
3722
|
+
const headers = {
|
|
3723
|
+
Accept: "application/json",
|
|
3724
|
+
Authorization: `Bearer ${authTokenFor(auth)}`
|
|
3725
|
+
};
|
|
3726
|
+
if (input.body !== void 0) {
|
|
3727
|
+
headers["Content-Type"] = "application/json; charset=utf-8";
|
|
3728
|
+
}
|
|
3729
|
+
if (input.idempotencyKey !== void 0 && MUTATING.has(input.method)) {
|
|
3730
|
+
headers["Idempotency-Key"] = input.idempotencyKey;
|
|
3731
|
+
}
|
|
3732
|
+
if (input.headers !== void 0) {
|
|
3733
|
+
for (const key of Object.keys(input.headers)) {
|
|
3734
|
+
headers[key] = input.headers[key];
|
|
3735
|
+
}
|
|
3736
|
+
}
|
|
3737
|
+
return headers;
|
|
3738
|
+
}
|
|
3739
|
+
function authTokenFor(auth) {
|
|
3740
|
+
if (auth.kind === "apiToken") return auth.token;
|
|
3741
|
+
return auth.accessToken;
|
|
3742
|
+
}
|
|
3743
|
+
function unwrapErrorEnvelope(body, status) {
|
|
3744
|
+
if (body !== null && typeof body === "object" && !Array.isArray(body)) {
|
|
3745
|
+
const inner = body.error;
|
|
3746
|
+
if (inner !== null && typeof inner === "object" && !Array.isArray(inner)) {
|
|
3747
|
+
return inner;
|
|
3748
|
+
}
|
|
3749
|
+
}
|
|
3750
|
+
return { code: "unknown", message: `HTTP ${status} without recognizable error envelope` };
|
|
3751
|
+
}
|
|
3752
|
+
|
|
3753
|
+
// src/client.ts
|
|
3754
|
+
function createClient(options) {
|
|
3755
|
+
const transport = createTransport(options);
|
|
3756
|
+
return {
|
|
3757
|
+
agents: makeAgentsClient(transport),
|
|
3758
|
+
flows: makeFlowsClient(transport),
|
|
3759
|
+
tools: makeToolsClient(transport),
|
|
3760
|
+
guardrails: makeGuardrailsClient(transport),
|
|
3761
|
+
runs: makeRunsClient(transport),
|
|
3762
|
+
schedules: makeSchedulesClient(transport),
|
|
3763
|
+
conversations: makeConversationsClient(transport),
|
|
3764
|
+
memory: makeMemoryClient(transport),
|
|
3765
|
+
provenance: makeProvenanceClient(transport),
|
|
3766
|
+
supervisor: makeSupervisorClient(transport),
|
|
3767
|
+
observations: makeObservationsClient(transport),
|
|
3768
|
+
approvals: makeApprovalsClient(transport),
|
|
3769
|
+
tenant: makeTenantClient(transport),
|
|
3770
|
+
cost: makeCostClient(transport),
|
|
3771
|
+
capabilities: makeCapabilitiesClient(transport),
|
|
3772
|
+
adapters: makeAdaptersClient(transport),
|
|
3773
|
+
providers: makeProvidersClient(transport),
|
|
3774
|
+
policies: makePoliciesClient(transport),
|
|
3775
|
+
projects: makeProjectsClient(transport),
|
|
3776
|
+
env: makeEnvClient(transport),
|
|
3777
|
+
secrets: makeSecretsClient(transport),
|
|
3778
|
+
deployments: makeDeploymentsClient(transport),
|
|
3779
|
+
compliance: makeComplianceClient(transport),
|
|
3780
|
+
audit: makeAuditClient(transport),
|
|
3781
|
+
evalSuites: makeEvalSuitesClient(transport),
|
|
3782
|
+
evalRuns: makeEvalRunsClient(transport),
|
|
3783
|
+
users: makeUsersClient(transport),
|
|
3784
|
+
identity: makeIdentityClient(transport),
|
|
3785
|
+
auth: makeAuthClient(transport),
|
|
3786
|
+
teams: makeTeamsClient(transport),
|
|
3787
|
+
orgs: makeOrgsClient(transport),
|
|
3788
|
+
signingKeys: makeSigningKeysClient(transport),
|
|
3789
|
+
tokens: makeTokensClient(transport),
|
|
3790
|
+
mcp: makeMcpClient(transport),
|
|
3791
|
+
events: makeEventsClient(),
|
|
3792
|
+
eventTriggers: makeEventTriggersClient(transport),
|
|
3793
|
+
artifacts: makeArtifactsClient(transport),
|
|
3794
|
+
webhooks: makeWebhooksClient(transport),
|
|
3795
|
+
webhookEndpoints: makeWebhookEndpointsClient(transport),
|
|
3796
|
+
packs: makePacksClient()
|
|
3797
|
+
};
|
|
3798
|
+
}
|
|
3799
|
+
|
|
3800
|
+
exports.KindgiApiError = KindgiApiError;
|
|
3801
|
+
exports.SseHttpError = SseHttpError;
|
|
3802
|
+
exports.createClient = createClient;
|
|
3803
|
+
exports.followRun = followRun;
|
|
3804
|
+
exports.fromWire = fromWire;
|
|
3805
|
+
exports.notImplementedInPreview = notImplementedInPreview;
|
|
3806
|
+
exports.notYetWired = notYetWired;
|
|
3807
|
+
exports.readSse = readSse;
|
|
3808
|
+
exports.subscribeToRun = subscribeToRun;
|
|
3809
|
+
exports.unwrapSseData = unwrapSseData;
|
|
3810
|
+
//# sourceMappingURL=index.cjs.map
|
|
3811
|
+
//# sourceMappingURL=index.cjs.map
|