aegis-platform-sdk 0.1.0 → 1.3.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/dist/cli.js ADDED
@@ -0,0 +1,3830 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/cli.ts
4
+ import { writeFile } from "fs/promises";
5
+
6
+ // src/errors.ts
7
+ var AegisAPIError = class extends Error {
8
+ statusCode;
9
+ detail;
10
+ payload;
11
+ constructor(statusCode, detail = "", payload = null) {
12
+ super(`HTTP ${statusCode}: ${detail}`);
13
+ this.name = new.target.name;
14
+ this.statusCode = statusCode;
15
+ this.detail = detail;
16
+ this.payload = payload;
17
+ }
18
+ };
19
+ var AuthError = class extends AegisAPIError {
20
+ };
21
+ var PermissionDeniedError = class extends AegisAPIError {
22
+ };
23
+ var NotFoundError = class extends AegisAPIError {
24
+ };
25
+
26
+ // src/transport.ts
27
+ function buildUrl(baseUrl, path, params) {
28
+ const raw = baseUrl.replace(/\/+$/, "") + path;
29
+ let url;
30
+ if (/^[a-z][a-z0-9+.-]*:\/\//i.test(raw)) {
31
+ url = new URL(raw);
32
+ } else {
33
+ const origin = globalThis.location?.origin;
34
+ if (!origin) {
35
+ throw new Error(
36
+ `relative baseUrl "${baseUrl}" requires a browser origin \u2014 use an absolute URL in Node`
37
+ );
38
+ }
39
+ url = new URL(raw, origin);
40
+ }
41
+ if (params) {
42
+ for (const [key, value] of Object.entries(params)) {
43
+ if (value === void 0 || value === null) continue;
44
+ if (Array.isArray(value)) {
45
+ for (const item of value) url.searchParams.append(key, String(item));
46
+ } else {
47
+ url.searchParams.set(key, String(value));
48
+ }
49
+ }
50
+ }
51
+ return url.toString();
52
+ }
53
+ async function handleResponse(res) {
54
+ if (res.status === 204) return null;
55
+ const text = await res.text();
56
+ let payload = text;
57
+ try {
58
+ payload = text ? JSON.parse(text) : null;
59
+ } catch {
60
+ }
61
+ if (res.ok) return payload;
62
+ let detail = "";
63
+ if (payload && typeof payload === "object" && "detail" in payload) {
64
+ detail = String(payload.detail ?? "");
65
+ } else if (typeof payload === "string") {
66
+ detail = payload;
67
+ }
68
+ if (res.status === 401) throw new AuthError(401, detail || "unauthenticated", payload);
69
+ if (res.status === 403) throw new PermissionDeniedError(403, detail || "forbidden", payload);
70
+ if (res.status === 404) throw new NotFoundError(404, detail || "not found", payload);
71
+ throw new AegisAPIError(res.status, detail || text, payload);
72
+ }
73
+
74
+ // src/sse.ts
75
+ async function* parseSseStream(stream) {
76
+ const reader = stream.getReader();
77
+ const decoder = new TextDecoder();
78
+ let buffer = "";
79
+ let event = "";
80
+ let data = [];
81
+ let id;
82
+ let retry;
83
+ const flush = () => {
84
+ if (data.length === 0) {
85
+ event = "";
86
+ return null;
87
+ }
88
+ const ev = { event: event || "message", data: data.join("\n") };
89
+ if (id !== void 0) ev.id = id;
90
+ if (retry !== void 0) ev.retry = retry;
91
+ event = "";
92
+ data = [];
93
+ return ev;
94
+ };
95
+ const handleLine = (line) => {
96
+ if (line === "") return flush();
97
+ if (line.startsWith(":")) return null;
98
+ const colon = line.indexOf(":");
99
+ const field = colon === -1 ? line : line.slice(0, colon);
100
+ let value = colon === -1 ? "" : line.slice(colon + 1);
101
+ if (value.startsWith(" ")) value = value.slice(1);
102
+ switch (field) {
103
+ case "event":
104
+ event = value;
105
+ break;
106
+ case "data":
107
+ data.push(value);
108
+ break;
109
+ case "id":
110
+ id = value;
111
+ break;
112
+ case "retry": {
113
+ const n = Number(value);
114
+ if (Number.isFinite(n)) retry = n;
115
+ break;
116
+ }
117
+ }
118
+ return null;
119
+ };
120
+ try {
121
+ for (; ; ) {
122
+ const { done, value } = await reader.read();
123
+ if (done) break;
124
+ buffer += decoder.decode(value, { stream: true });
125
+ let newline;
126
+ while ((newline = buffer.search(/\r\n|\n|\r/)) !== -1) {
127
+ const line = buffer.slice(0, newline);
128
+ buffer = buffer.slice(newline + (buffer[newline] === "\r" && buffer[newline + 1] === "\n" ? 2 : 1));
129
+ const ev = handleLine(line);
130
+ if (ev) yield ev;
131
+ }
132
+ }
133
+ if (buffer) handleLine(buffer);
134
+ const tail = flush();
135
+ if (tail) yield tail;
136
+ } finally {
137
+ reader.releaseLock();
138
+ }
139
+ }
140
+
141
+ // src/resources/auth.ts
142
+ var AuthResource = class {
143
+ constructor(t, attach) {
144
+ this.t = t;
145
+ this.attach = attach;
146
+ }
147
+ t;
148
+ attach;
149
+ async login(username, password, opts = {}) {
150
+ const body = { username, password };
151
+ if (opts.totpCode) body.totp_code = opts.totpCode;
152
+ const pair = await this.t.request("POST", "/auth/login", { json: body });
153
+ if (opts.attach !== false) this.attach(pair);
154
+ return pair;
155
+ }
156
+ /** Rotate a refresh token explicitly (`POST /auth/refresh`). The client
157
+ * already does this transparently on 401 — call this only for manual
158
+ * flows. Attaches the new pair unless `attach: false`. */
159
+ async refresh(refreshToken, opts = {}) {
160
+ const pair = await this.t.request("POST", "/auth/refresh", {
161
+ json: { refresh_token: refreshToken }
162
+ });
163
+ if (opts.attach !== false) this.attach(pair);
164
+ return pair;
165
+ }
166
+ me() {
167
+ return this.t.request("GET", "/auth/me");
168
+ }
169
+ /** Activate a vendor dev-mode session; requires the `vendor` role. */
170
+ enableDevMode(password) {
171
+ return this.t.request("POST", "/me/dev-mode", { json: { password } });
172
+ }
173
+ };
174
+
175
+ // src/resources/iam.ts
176
+ var UsersResource = class {
177
+ constructor(t) {
178
+ this.t = t;
179
+ }
180
+ t;
181
+ list() {
182
+ return this.t.request("GET", "/iam/users");
183
+ }
184
+ get(userId) {
185
+ return this.t.request("GET", `/iam/users/${userId}`);
186
+ }
187
+ };
188
+ var RolesResource = class {
189
+ constructor(t) {
190
+ this.t = t;
191
+ }
192
+ t;
193
+ list() {
194
+ return this.t.request("GET", "/iam/roles");
195
+ }
196
+ get(roleId) {
197
+ return this.t.request("GET", `/iam/roles/${roleId}`);
198
+ }
199
+ };
200
+ var GroupsResource = class {
201
+ constructor(t) {
202
+ this.t = t;
203
+ }
204
+ t;
205
+ list(opts = {}) {
206
+ return this.t.request("GET", "/iam/groups", { params: opts });
207
+ }
208
+ get(groupId) {
209
+ return this.t.request("GET", `/iam/groups/${groupId}`);
210
+ }
211
+ create(name, description) {
212
+ return this.t.request("POST", "/iam/groups", { json: { name, description } });
213
+ }
214
+ update(groupId, patch) {
215
+ return this.t.request("PATCH", `/iam/groups/${groupId}`, { json: patch });
216
+ }
217
+ delete(groupId) {
218
+ return this.t.request("DELETE", `/iam/groups/${groupId}`);
219
+ }
220
+ listMembers(groupId) {
221
+ return this.t.request("GET", `/iam/groups/${groupId}/members`);
222
+ }
223
+ addMember(groupId, userId) {
224
+ return this.t.request("POST", `/iam/groups/${groupId}/members`, { json: { user_id: userId } });
225
+ }
226
+ removeMember(groupId, userId) {
227
+ return this.t.request("DELETE", `/iam/groups/${groupId}/members/${userId}`);
228
+ }
229
+ listForUser(userId) {
230
+ return this.t.request("GET", `/iam/users/${userId}/groups`);
231
+ }
232
+ };
233
+ var PermissionsResource = class {
234
+ constructor(t) {
235
+ this.t = t;
236
+ }
237
+ t;
238
+ list(resource) {
239
+ return this.t.request("GET", "/iam/permissions", { params: { resource } });
240
+ }
241
+ };
242
+ var NavResource = class {
243
+ constructor(t) {
244
+ this.t = t;
245
+ }
246
+ t;
247
+ tree(asRoleId) {
248
+ return this.t.request("GET", "/iam/nav", { params: { as_role_id: asRoleId } });
249
+ }
250
+ };
251
+ var IamResource = class {
252
+ users;
253
+ roles;
254
+ groups;
255
+ permissions;
256
+ nav;
257
+ constructor(t) {
258
+ this.users = new UsersResource(t);
259
+ this.roles = new RolesResource(t);
260
+ this.groups = new GroupsResource(t);
261
+ this.permissions = new PermissionsResource(t);
262
+ this.nav = new NavResource(t);
263
+ }
264
+ };
265
+
266
+ // src/resources/osdk.ts
267
+ var OsdkResource = class {
268
+ constructor(t) {
269
+ this.t = t;
270
+ }
271
+ t;
272
+ list() {
273
+ return this.t.request("GET", "/governance/tokens");
274
+ }
275
+ get(tokenId) {
276
+ return this.t.request("GET", `/governance/tokens/${tokenId}`);
277
+ }
278
+ /** Returns the plaintext secret ONCE — stash it like any other secret. */
279
+ create(name, scopes, expiresAt) {
280
+ return this.t.request("POST", "/governance/tokens", {
281
+ json: { name, scopes, expires_at: expiresAt }
282
+ });
283
+ }
284
+ rotate(tokenId) {
285
+ return this.t.request("POST", `/governance/tokens/${tokenId}/rotate`);
286
+ }
287
+ revoke(tokenId) {
288
+ return this.t.request("DELETE", `/governance/tokens/${tokenId}`);
289
+ }
290
+ };
291
+
292
+ // src/resources/operator.ts
293
+ var OperatorTasksResource = class {
294
+ constructor(t) {
295
+ this.t = t;
296
+ }
297
+ t;
298
+ list(opts = {}) {
299
+ return this.t.request("GET", "/operator/tasks", { params: { ...opts } });
300
+ }
301
+ get(taskId) {
302
+ return this.t.request("GET", `/operator/tasks/${taskId}`);
303
+ }
304
+ create(input) {
305
+ return this.t.request("POST", "/operator/tasks", { json: input });
306
+ }
307
+ cancel(taskId) {
308
+ return this.t.request("PATCH", `/operator/tasks/${taskId}`, { json: { action: "cancel" } });
309
+ }
310
+ retry(taskId) {
311
+ return this.t.request("PATCH", `/operator/tasks/${taskId}`, { json: { action: "retry" } });
312
+ }
313
+ reprioritize(taskId, priority) {
314
+ return this.t.request("PATCH", `/operator/tasks/${taskId}`, {
315
+ json: { action: "reprioritize", priority }
316
+ });
317
+ }
318
+ };
319
+ var OperatorResource = class {
320
+ tasks;
321
+ constructor(t) {
322
+ this.tasks = new OperatorTasksResource(t);
323
+ }
324
+ };
325
+
326
+ // src/resources/ontology.ts
327
+ var ObjectsResource = class {
328
+ constructor(t) {
329
+ this.t = t;
330
+ }
331
+ t;
332
+ get(objectId) {
333
+ return this.t.request("GET", `/ontology/nodes/${objectId}`);
334
+ }
335
+ list(kind, opts = {}) {
336
+ return this.t.request("GET", "/ontology/nodes", { params: { node_type: kind, ...opts } });
337
+ }
338
+ create(kind, properties, name) {
339
+ return this.t.request("POST", "/ontology/nodes", {
340
+ json: { kind, properties, name }
341
+ });
342
+ }
343
+ createMany(kind, items, markings) {
344
+ return this.t.request("POST", "/ontology/nodes/bulk", { json: { kind, items, markings } });
345
+ }
346
+ delete(objectId) {
347
+ return this.t.request("DELETE", `/ontology/nodes/${objectId}`);
348
+ }
349
+ bulkDelete(opts) {
350
+ return this.t.request("POST", "/ontology/nodes/bulk-delete", { json: opts });
351
+ }
352
+ links(objectId) {
353
+ return this.t.request("GET", `/entities/${objectId}/links`);
354
+ }
355
+ history(objectId) {
356
+ return this.t.request("GET", `/lineage/by-asset/${objectId}`);
357
+ }
358
+ queryTimeseries(objectId, propertyName, opts = {}) {
359
+ return this.t.request(
360
+ "POST",
361
+ `/ontology/nodes/${objectId}/properties/${propertyName}/timeseries-query`,
362
+ { json: opts }
363
+ );
364
+ }
365
+ appendTimeseries(objectId, propertyName, points) {
366
+ return this.t.request(
367
+ "POST",
368
+ `/ontology/nodes/${objectId}/properties/${propertyName}/timeseries/append`,
369
+ { json: { points } }
370
+ );
371
+ }
372
+ };
373
+ var GraphResource = class {
374
+ constructor(t) {
375
+ this.t = t;
376
+ }
377
+ t;
378
+ expand(seedId, opts = {}) {
379
+ return this.t.request("GET", `/entities/${seedId}/graph`, { params: opts });
380
+ }
381
+ };
382
+ var ExplorerResource = class {
383
+ constructor(t) {
384
+ this.t = t;
385
+ }
386
+ t;
387
+ histogram(property, filters) {
388
+ return this.t.request("GET", "/entities/aggregate", {
389
+ params: { property, ...filters }
390
+ });
391
+ }
392
+ timeline(filters, bin) {
393
+ return this.t.request("GET", "/entities/timeline", {
394
+ params: { bin, ...filters }
395
+ });
396
+ }
397
+ };
398
+ var ObjectTypesResource = class {
399
+ constructor(t) {
400
+ this.t = t;
401
+ }
402
+ t;
403
+ get(kind) {
404
+ return this.t.request("GET", `/ontology/object-types/${kind}`);
405
+ }
406
+ create(kind, input) {
407
+ return this.t.request("POST", "/ontology/object-types", { json: { kind, ...input } });
408
+ }
409
+ update(kind, input) {
410
+ return this.t.request("PUT", `/ontology/object-types/${kind}`, { json: input });
411
+ }
412
+ delete(kind) {
413
+ return this.t.request("DELETE", `/ontology/object-types/${kind}`);
414
+ }
415
+ };
416
+ var LinkTypesResource = class {
417
+ constructor(t) {
418
+ this.t = t;
419
+ }
420
+ t;
421
+ declare(input) {
422
+ return this.t.request("POST", "/ontology/link-types", { json: input });
423
+ }
424
+ delete(edgeId) {
425
+ return this.t.request("DELETE", `/ontology/link-types/${edgeId}`);
426
+ }
427
+ };
428
+ var OntologyResource = class {
429
+ constructor(t) {
430
+ this.t = t;
431
+ this.objects = new ObjectsResource(t);
432
+ this.graph = new GraphResource(t);
433
+ this.explorer = new ExplorerResource(t);
434
+ this.objectTypes = new ObjectTypesResource(t);
435
+ this.linkTypes = new LinkTypesResource(t);
436
+ }
437
+ t;
438
+ objects;
439
+ graph;
440
+ explorer;
441
+ objectTypes;
442
+ linkTypes;
443
+ /** Shortcut — same as `objectTypes.get(kind)`. */
444
+ objectType(kind) {
445
+ return this.objectTypes.get(kind);
446
+ }
447
+ osdkManifest() {
448
+ return this.t.request("GET", "/ontology/osdk/manifest");
449
+ }
450
+ osdkFunctions() {
451
+ return this.t.request("GET", "/ontology/osdk/manifest/functions");
452
+ }
453
+ osdkGenerate(lang) {
454
+ return this.t.request("GET", "/ontology/osdk/generate", { params: { lang } });
455
+ }
456
+ };
457
+
458
+ // src/resources/aip.ts
459
+ var FlowsResource = class {
460
+ constructor(t) {
461
+ this.t = t;
462
+ }
463
+ t;
464
+ list() {
465
+ return this.t.request("GET", "/campaign/flows");
466
+ }
467
+ get(flowId) {
468
+ return this.t.request("GET", `/campaign/flows/${flowId}`);
469
+ }
470
+ runs(flowId) {
471
+ return this.t.request("GET", `/campaign/flows/${flowId}/runs`);
472
+ }
473
+ patch(flowId, payload) {
474
+ return this.t.request("PATCH", `/campaign/flows/${flowId}`, { json: payload });
475
+ }
476
+ run(flowId, dryRun) {
477
+ return this.t.request("POST", `/campaign/flows/${flowId}/run`, {
478
+ json: dryRun === void 0 ? {} : { dry_run: dryRun }
479
+ });
480
+ }
481
+ };
482
+ var AgentsResource = class {
483
+ constructor(t) {
484
+ this.t = t;
485
+ }
486
+ t;
487
+ list() {
488
+ return this.t.request("GET", "/campaign/agents");
489
+ }
490
+ get(agentId) {
491
+ return this.t.request("GET", `/campaign/agents/${agentId}`);
492
+ }
493
+ patch(agentId, config) {
494
+ return this.t.request("PATCH", `/campaign/agents/${agentId}`, { json: config });
495
+ }
496
+ manualRun(agentId) {
497
+ return this.t.request("POST", `/campaign/agents/${agentId}/runs`);
498
+ }
499
+ runs(agentId) {
500
+ return this.t.request("GET", `/campaign/agents/${agentId}/runs`);
501
+ }
502
+ };
503
+ var ModelsResource = class {
504
+ constructor(t) {
505
+ this.t = t;
506
+ }
507
+ t;
508
+ catalog(provider) {
509
+ return this.t.request("GET", "/platform/v25/aip/models/catalog", { params: { provider } });
510
+ }
511
+ defaults() {
512
+ return this.t.request("GET", "/platform/v25/aip/models/defaults");
513
+ }
514
+ setDefault(input) {
515
+ return this.t.request("PUT", "/platform/v25/aip/models/defaults", { json: input });
516
+ }
517
+ };
518
+ var BudgetResource = class {
519
+ constructor(t) {
520
+ this.t = t;
521
+ }
522
+ t;
523
+ get() {
524
+ return this.t.request("GET", "/platform/v23/llm-budget");
525
+ }
526
+ set(tokensPerMonth) {
527
+ return this.t.request("PUT", "/platform/v23/llm-budget", {
528
+ json: { tokens_per_month: tokensPerMonth }
529
+ });
530
+ }
531
+ };
532
+ var AipResource = class {
533
+ flows;
534
+ agents;
535
+ models;
536
+ budget;
537
+ constructor(t) {
538
+ this.flows = new FlowsResource(t);
539
+ this.agents = new AgentsResource(t);
540
+ this.models = new ModelsResource(t);
541
+ this.budget = new BudgetResource(t);
542
+ }
543
+ };
544
+
545
+ // src/resources/functions.ts
546
+ var FunctionsResource = class {
547
+ constructor(t) {
548
+ this.t = t;
549
+ }
550
+ t;
551
+ list() {
552
+ return this.t.request("GET", "/platform/v26/functions");
553
+ }
554
+ get(slug) {
555
+ return this.t.request("GET", `/platform/v26/functions/${slug}`);
556
+ }
557
+ create(input) {
558
+ return this.t.request("POST", "/platform/v26/functions", { json: input });
559
+ }
560
+ invoke(slug, inputs, opts = {}) {
561
+ return this.t.request("POST", `/platform/v26/functions/${slug}/invoke`, {
562
+ json: { inputs: inputs ?? {}, ...opts }
563
+ });
564
+ }
565
+ tests(slug) {
566
+ return this.t.request("GET", `/platform/v26/functions/${slug}/tests`);
567
+ }
568
+ addTest(slug, name, inputs, expectedContains) {
569
+ return this.t.request("POST", `/platform/v26/functions/${slug}/tests`, {
570
+ json: { name, inputs, expected_contains: expectedContains }
571
+ });
572
+ }
573
+ runTest(slug, testId) {
574
+ return this.t.request("POST", `/platform/v26/functions/${slug}/tests/${testId}/run`);
575
+ }
576
+ runTests(slug) {
577
+ return this.t.request("POST", `/platform/v26/functions/${slug}/test`);
578
+ }
579
+ publish(slug, branch) {
580
+ return this.t.request("POST", `/platform/v26/functions/${slug}/publish`, {
581
+ json: branch ? { branch } : {}
582
+ });
583
+ }
584
+ versions(slug) {
585
+ return this.t.request("GET", `/platform/v26/functions/${slug}/versions`);
586
+ }
587
+ pullRequests(slug, status) {
588
+ return this.t.request("GET", `/platform/v26/functions/${slug}/pull-requests`, {
589
+ params: { status }
590
+ });
591
+ }
592
+ openPullRequest(slug, input) {
593
+ return this.t.request("POST", `/platform/v26/functions/${slug}/pull-requests`, { json: input });
594
+ }
595
+ updatePullRequest(slug, prId, patch) {
596
+ return this.t.request("PATCH", `/platform/v26/functions/${slug}/pull-requests/${prId}`, {
597
+ json: patch
598
+ });
599
+ }
600
+ runPrCi(slug, prId) {
601
+ return this.t.request("POST", `/platform/v26/functions/${slug}/pull-requests/${prId}/ci`);
602
+ }
603
+ reviewPullRequest(slug, prId, decision, comment) {
604
+ return this.t.request("POST", `/platform/v26/functions/${slug}/pull-requests/${prId}/reviews`, {
605
+ json: { decision, comment }
606
+ });
607
+ }
608
+ mergePullRequest(slug, prId) {
609
+ return this.t.request("POST", `/platform/v26/functions/${slug}/pull-requests/${prId}/merge`);
610
+ }
611
+ };
612
+ var CodeRepositoriesResource = class {
613
+ constructor(t) {
614
+ this.t = t;
615
+ }
616
+ t;
617
+ list() {
618
+ return this.t.request("GET", "/platform/v26/code-repositories");
619
+ }
620
+ create(input) {
621
+ return this.t.request("POST", "/platform/v26/code-repositories", { json: input });
622
+ }
623
+ branches(repoId) {
624
+ return this.t.request("GET", `/platform/v26/code-repositories/${repoId}/branches`);
625
+ }
626
+ createBranch(repoId, name, description) {
627
+ return this.t.request("POST", `/platform/v26/code-repositories/${repoId}/branches`, {
628
+ json: { name, description }
629
+ });
630
+ }
631
+ functions(repoId) {
632
+ return this.t.request("GET", `/platform/v26/code-repositories/${repoId}/functions`);
633
+ }
634
+ assignFunction(repoId, slug) {
635
+ return this.t.request("POST", `/platform/v26/code-repositories/${repoId}/functions`, {
636
+ json: { slug }
637
+ });
638
+ }
639
+ runCi(repoId) {
640
+ return this.t.request("POST", `/platform/v26/code-repositories/${repoId}/ci`);
641
+ }
642
+ mergeBranch(repoId, sourceBranch, into) {
643
+ return this.t.request("POST", `/platform/v26/code-repositories/${repoId}/merge`, {
644
+ json: { source_branch: sourceBranch, into }
645
+ });
646
+ }
647
+ };
648
+
649
+ // src/resources/datasets.ts
650
+ var DatasetsResource = class {
651
+ constructor(t) {
652
+ this.t = t;
653
+ }
654
+ t;
655
+ list() {
656
+ return this.t.request("GET", "/datasets");
657
+ }
658
+ get(name) {
659
+ return this.t.request("GET", `/datasets/${name}`);
660
+ }
661
+ sample(name, limit) {
662
+ return this.t.request("GET", `/datasets/${name}/sample`, { params: { limit } });
663
+ }
664
+ listBranches(name) {
665
+ return this.t.request("GET", `/datasets/${name}/branches`);
666
+ }
667
+ createBranch(name, branchName, opts = {}) {
668
+ return this.t.request("POST", `/datasets/${name}/branches`, {
669
+ json: { branch_name: branchName, ...opts }
670
+ });
671
+ }
672
+ deactivateBranch(name, branchName) {
673
+ return this.t.request("DELETE", `/datasets/${name}/branches/${branchName}`);
674
+ }
675
+ listTransactions(name, branch) {
676
+ return this.t.request("GET", `/datasets/${name}/transactions`, { params: { branch } });
677
+ }
678
+ beginTransaction(name, kind, branch) {
679
+ return this.t.request("POST", `/datasets/${name}/transactions`, { json: { kind, branch } });
680
+ }
681
+ commitTransaction(name, txId, inputPayload) {
682
+ return this.t.request("POST", `/datasets/${name}/transactions/${txId}/commit`, {
683
+ json: inputPayload
684
+ });
685
+ }
686
+ abortTransaction(name, txId, reason) {
687
+ return this.t.request("POST", `/datasets/${name}/transactions/${txId}/abort`, {
688
+ json: { reason }
689
+ });
690
+ }
691
+ mergeFastForward(name, source, into) {
692
+ return this.t.request("POST", `/datasets/${name}/branches/${source}/merge`, {
693
+ json: { into }
694
+ });
695
+ }
696
+ /** 409 responses carry the conflict body in `AegisAPIError.payload`. */
697
+ mergeThreeWay(name, source, into, resolutions) {
698
+ return this.t.request("POST", `/datasets/${name}/branches/${source}/merge3`, {
699
+ json: { into, resolutions }
700
+ });
701
+ }
702
+ getClassification(name) {
703
+ return this.t.request("GET", `/datasets/${name}/classification`);
704
+ }
705
+ setClassification(name, patch) {
706
+ return this.t.request("PATCH", `/datasets/${name}/classification`, { json: patch });
707
+ }
708
+ listMarkings(name) {
709
+ return this.t.request("GET", `/datasets/${name}/markings`);
710
+ }
711
+ applyMarking(name, markingId) {
712
+ return this.t.request("POST", `/datasets/${name}/markings`, { json: { marking_id: markingId } });
713
+ }
714
+ removeMarking(name, markingId) {
715
+ return this.t.request("DELETE", `/datasets/${name}/markings/${markingId}`);
716
+ }
717
+ };
718
+
719
+ // src/resources/reading.ts
720
+ var GeoResource = class {
721
+ constructor(t) {
722
+ this.t = t;
723
+ }
724
+ t;
725
+ nodes(opts = {}) {
726
+ return this.t.request("GET", "/api/v1/geo/nodes", { params: opts });
727
+ }
728
+ nodeTypes() {
729
+ return this.t.request("GET", "/api/v1/geo/node-types");
730
+ }
731
+ sources() {
732
+ return this.t.request("GET", "/api/v1/geo/sources");
733
+ }
734
+ edges(nodeIds, relationTypes) {
735
+ return this.t.request("GET", "/api/v1/geo/edges", {
736
+ params: { node_ids: nodeIds.join(","), relation_types: relationTypes?.join(",") }
737
+ });
738
+ }
739
+ /** Catalog of keyless reference layers (IBGE limits, CNES health, …). */
740
+ referenceLayers() {
741
+ return this.t.request("GET", "/api/v1/geo/reference-layers");
742
+ }
743
+ /** GeoJSON of one reference layer (resilient keyless proxy). */
744
+ referenceLayer(layerId, opts = {}) {
745
+ return this.t.request("GET", `/api/v1/geo/reference-layers/${encodeURIComponent(layerId)}`, {
746
+ params: opts
747
+ });
748
+ }
749
+ zones() {
750
+ return this.t.request("GET", "/api/v1/geo/zones");
751
+ }
752
+ importZones(features, opts = {}) {
753
+ return this.t.request("POST", "/api/v1/geo/zones/import", { json: { features, ...opts } });
754
+ }
755
+ deleteZone(zoneId) {
756
+ return this.t.request("DELETE", `/api/v1/geo/zones/${zoneId}`);
757
+ }
758
+ // ── Reference Layer Builder (the AEGIS "My Maps") ──────────────────────
759
+ //
760
+ // Each layer is one editable dataset + one DAG board + one dedicated
761
+ // node_type. Publishing runs the board; the materialized nodes show up on
762
+ // their own under the map's "Reference layers" tab.
763
+ // Read: `security.geo.view`; write: `security.geo.camada.manage`.
764
+ /** Builder layers of the tenant, grouped by "map" (the project). */
765
+ layers() {
766
+ return this.t.request("GET", "/api/v1/geo/layers");
767
+ }
768
+ /** Creates a layer (empty inline dataset + published board). The
769
+ * `node_type` derives from the name and is IMMUTABLE. */
770
+ createLayer(input) {
771
+ return this.t.request("POST", "/api/v1/geo/layers", { json: input });
772
+ }
773
+ layerFeatures(boardId) {
774
+ return this.t.request("GET", `/api/v1/geo/layers/${boardId}/features`);
775
+ }
776
+ /** Saves the drawing as a versioned SNAPSHOT. `geometry` is GeoJSON
777
+ * `[lng,lat]`; `geo_style` travels PER FEATURE (colour/alpha/extrusion). */
778
+ saveLayerFeatures(boardId, rows) {
779
+ return this.t.request("PUT", `/api/v1/geo/layers/${boardId}/features`, {
780
+ json: { rows }
781
+ });
782
+ }
783
+ /** Runs the board and RECONCILES — a feature deleted in the builder leaves
784
+ * the map (the engine is upsert-only). */
785
+ publishLayer(boardId) {
786
+ return this.t.request("POST", `/api/v1/geo/layers/${boardId}/publish`);
787
+ }
788
+ /** Renames / regroups. Never changes the `node_type`; `mapa: ""` ungroups. */
789
+ patchLayer(boardId, changes) {
790
+ return this.t.request("PATCH", `/api/v1/geo/layers/${boardId}`, { json: changes });
791
+ }
792
+ /** Deletes the whole layer: materialized nodes + dataset + board. */
793
+ deleteLayer(boardId) {
794
+ return this.t.request("DELETE", `/api/v1/geo/layers/${boardId}`);
795
+ }
796
+ };
797
+ var MapTemplatesResource = class {
798
+ constructor(t) {
799
+ this.t = t;
800
+ }
801
+ t;
802
+ async list() {
803
+ const payload = await this.t.request("GET", "/platform/v22/map-templates");
804
+ return payload.items ?? [];
805
+ }
806
+ get(templateId) {
807
+ return this.t.request("GET", `/platform/v22/map-templates/${templateId}`);
808
+ }
809
+ create(name, spec, description = "") {
810
+ return this.t.request("POST", "/platform/v22/map-templates", {
811
+ json: { name, spec, description }
812
+ });
813
+ }
814
+ instantiate(templateId, variables) {
815
+ return this.t.request("POST", `/platform/v22/map-templates/${templateId}/instantiate`, {
816
+ json: { variables: variables ?? {} }
817
+ });
818
+ }
819
+ /** Returns the raw SVG markup (non-JSON body). */
820
+ exportSvg(templateId) {
821
+ return this.t.request("GET", `/platform/v22/map-templates/${templateId}/export.svg`);
822
+ }
823
+ };
824
+ var MediaResource = class {
825
+ constructor(t) {
826
+ this.t = t;
827
+ }
828
+ t;
829
+ listSets() {
830
+ return this.t.request("GET", "/platform/v23/media/sets");
831
+ }
832
+ createSet(input) {
833
+ return this.t.request("POST", "/platform/v23/media/sets", { json: input });
834
+ }
835
+ deleteSet(setId) {
836
+ return this.t.request("DELETE", `/platform/v23/media/sets/${setId}`);
837
+ }
838
+ listItems(setId) {
839
+ return this.t.request("GET", `/platform/v23/media/sets/${setId}/items`);
840
+ }
841
+ /** Metadata only — no file bytes are uploaded (pass a pre-supplied `uri`). */
842
+ addItem(setId, input) {
843
+ return this.t.request("POST", `/platform/v23/media/sets/${setId}/items`, { json: input });
844
+ }
845
+ };
846
+ var DocsResource = class {
847
+ constructor(t) {
848
+ this.t = t;
849
+ }
850
+ t;
851
+ tree() {
852
+ return this.t.request("GET", "/docs/tree");
853
+ }
854
+ read(path) {
855
+ return this.t.request("GET", "/docs/content", { params: { path } });
856
+ }
857
+ };
858
+ var PagesResource = class {
859
+ constructor(t) {
860
+ this.t = t;
861
+ }
862
+ t;
863
+ list(opts = {}) {
864
+ return this.t.request("GET", "/platform/v23/pages", { params: opts });
865
+ }
866
+ get(slug) {
867
+ return this.t.request("GET", `/platform/v23/pages/${slug}`);
868
+ }
869
+ getConfig(slug) {
870
+ return this.t.request("GET", `/platform/v23/pages/${slug}/config`);
871
+ }
872
+ create(input) {
873
+ return this.t.request("POST", "/platform/v23/pages", { json: input });
874
+ }
875
+ update(slug, patch) {
876
+ return this.t.request("PATCH", `/platform/v23/pages/${slug}`, { json: patch });
877
+ }
878
+ /** Soft delete — page moves to status=archived. */
879
+ delete(slug) {
880
+ return this.t.request("DELETE", `/platform/v23/pages/${slug}`);
881
+ }
882
+ duplicate(slug) {
883
+ return this.t.request("POST", `/platform/v23/pages/${slug}/duplicate`);
884
+ }
885
+ putConfig(slug, config) {
886
+ return this.t.request("PUT", `/platform/v23/pages/${slug}/config`, { json: { config } });
887
+ }
888
+ publish(slug) {
889
+ return this.t.request("POST", `/platform/v23/pages/${slug}/publish`);
890
+ }
891
+ };
892
+ var DossierResource = class {
893
+ constructor(t) {
894
+ this.t = t;
895
+ }
896
+ t;
897
+ startGeneric(nodeId, purpose) {
898
+ return this.t.request("POST", `/ontology/nodes/${nodeId}/dossier`, {
899
+ json: purpose ? { purpose } : {}
900
+ });
901
+ }
902
+ /** Requires `anchor_node_id` or `node_ids`. */
903
+ startComposite(input) {
904
+ if (!input.anchor_node_id && !input.node_ids?.length) {
905
+ throw new Error("startComposite requires anchor_node_id or node_ids");
906
+ }
907
+ return this.t.request("POST", "/ontology/dossier/composite", { json: input });
908
+ }
909
+ /** Poll until `status === "done"`; `result` is then populated. */
910
+ get(taskId) {
911
+ return this.t.request("GET", `/ontology/dossier/${taskId}`);
912
+ }
913
+ };
914
+ var TimeSeriesResource = class {
915
+ constructor(t) {
916
+ this.t = t;
917
+ }
918
+ t;
919
+ list() {
920
+ return this.t.request("GET", "/platform/v23/timeseries");
921
+ }
922
+ create(input) {
923
+ return this.t.request("POST", "/platform/v23/timeseries", { json: input });
924
+ }
925
+ delete(chartId) {
926
+ return this.t.request("DELETE", `/platform/v23/timeseries/${chartId}`);
927
+ }
928
+ render(chartId) {
929
+ return this.t.request("POST", `/platform/v23/timeseries/${chartId}/render`);
930
+ }
931
+ };
932
+
933
+ // src/resources/publicGuest.ts
934
+ var PublicGuestResource = class {
935
+ constructor(t) {
936
+ this.t = t;
937
+ }
938
+ t;
939
+ base(token) {
940
+ return `/public/v1/guest/${encodeURIComponent(token)}`;
941
+ }
942
+ /** Menu/resumo do token: label, subject, status, geo, ações permitidas. */
943
+ menu(token) {
944
+ return this.t.request("GET", this.base(token));
945
+ }
946
+ /** Reporta uma posição GPS; o backend avalia cerca/rota/destino. */
947
+ fix(token, body) {
948
+ return this.t.request("POST", `${this.base(token)}/fix`, { json: body });
949
+ }
950
+ /** Invoca uma ação permitida do token (ex.: abrir portão). */
951
+ invoke(token, actionId, input = {}) {
952
+ return this.t.request(
953
+ "POST",
954
+ `${this.base(token)}/actions/${encodeURIComponent(actionId)}`,
955
+ { json: { input } }
956
+ );
957
+ }
958
+ /**
959
+ * Onda 2 — última posição do VISITANTE amarrado a um token de MORADOR
960
+ * (`geo.live_ref`). Sem push: a SPA do morador faz polling desta rota. O
961
+ * morador só vê ESSA visita (least-privilege). Retorna `{available, lat,
962
+ * lng, ts, inside_fence, arrived, deviated, distance_to_target_m,
963
+ * visit_status}`; `available:false` enquanto o visitante não mandou fix.
964
+ */
965
+ position(token) {
966
+ return this.t.request("GET", `${this.base(token)}/position`);
967
+ }
968
+ /** Documento vinculado ao token (se `geo.document_id`). */
969
+ document(token) {
970
+ return this.t.request("GET", `${this.base(token)}/document`);
971
+ }
972
+ /** Consulta um object-set embutido no documento do token. */
973
+ queryObjectSet(token, body) {
974
+ return this.t.request(
975
+ "POST",
976
+ `${this.base(token)}/document/object-sets/query`,
977
+ { json: body }
978
+ );
979
+ }
980
+ /** Um nó da ontologia referenciado pelo documento (mascarado por ABAC). */
981
+ documentNode(token, nodeId) {
982
+ return this.t.request("GET", `${this.base(token)}/document/node`, {
983
+ params: { node_id: nodeId }
984
+ });
985
+ }
986
+ /** Descritor da Page vinculada ao token (`geo.page_slug`). */
987
+ page(token, slug) {
988
+ return this.t.request("GET", `${this.base(token)}/pages/${encodeURIComponent(slug)}`);
989
+ }
990
+ /** Avalia as variáveis da Page (com overrides só de variáveis estáticas). */
991
+ evaluatePage(token, slug, overrides = {}) {
992
+ return this.t.request(
993
+ "POST",
994
+ `${this.base(token)}/pages/${encodeURIComponent(slug)}/evaluate`,
995
+ { json: { overrides } }
996
+ );
997
+ }
998
+ /**
999
+ * URL absoluta de um objeto de mídia do documento (bytes servidos com
1000
+ * `Cache-Control: private`). Retorna string p/ `<img src>`/`<a href>` —
1001
+ * NÃO faz request (o transporte é JSON-cêntrico). A `key` deve começar
1002
+ * com `notepad/{doc_id}/` (validado no backend).
1003
+ */
1004
+ mediaUrl(token, key) {
1005
+ return buildUrl(this.t.baseUrl, `${this.base(token)}/media`, { key });
1006
+ }
1007
+ };
1008
+
1009
+ // src/resources/operational.ts
1010
+ var AlertFeedsResource = class {
1011
+ constructor(t) {
1012
+ this.t = t;
1013
+ }
1014
+ t;
1015
+ list() {
1016
+ return this.t.request("GET", "/alerts/feeds");
1017
+ }
1018
+ create(name, filters, cadenceSeconds = 300) {
1019
+ return this.t.request("POST", "/alerts/feeds", {
1020
+ json: { name, filters, cadence_seconds: cadenceSeconds }
1021
+ });
1022
+ }
1023
+ delete(feedId) {
1024
+ return this.t.request("DELETE", `/alerts/feeds/${feedId}`);
1025
+ }
1026
+ alerts() {
1027
+ return this.t.request("GET", "/alerts/feeds/alerts");
1028
+ }
1029
+ acknowledge(alertId) {
1030
+ return this.t.request("POST", `/alerts/feeds/${alertId}/acknowledge`);
1031
+ }
1032
+ };
1033
+ var AlertWatchesResource = class {
1034
+ constructor(t) {
1035
+ this.t = t;
1036
+ }
1037
+ t;
1038
+ list() {
1039
+ return this.t.request("GET", "/alerts/watches");
1040
+ }
1041
+ create(objectId) {
1042
+ return this.t.request("POST", "/alerts/watches", { json: { object_id: objectId } });
1043
+ }
1044
+ delete(watchId) {
1045
+ return this.t.request("DELETE", `/alerts/watches/${watchId}`);
1046
+ }
1047
+ alerts() {
1048
+ return this.t.request("GET", "/alerts/watches/alerts");
1049
+ }
1050
+ acknowledge(alertId) {
1051
+ return this.t.request("POST", `/alerts/watches/${alertId}/acknowledge`);
1052
+ }
1053
+ };
1054
+ var AlertGeofencesResource = class {
1055
+ constructor(t) {
1056
+ this.t = t;
1057
+ }
1058
+ t;
1059
+ list() {
1060
+ return this.t.request("GET", "/alerts/geofences");
1061
+ }
1062
+ /** `coordinates` is shape-dependent: polygon `[[lon,lat],…]`, circle
1063
+ * `{center, radius_meters}`, corridor/route `{waypoints, width_meters}`. */
1064
+ create(input) {
1065
+ return this.t.request("POST", "/alerts/geofences", { json: input });
1066
+ }
1067
+ update(geofenceId, patch) {
1068
+ return this.t.request("PATCH", `/alerts/geofences/${geofenceId}`, { json: patch });
1069
+ }
1070
+ delete(geofenceId) {
1071
+ return this.t.request("DELETE", `/alerts/geofences/${geofenceId}`);
1072
+ }
1073
+ alerts() {
1074
+ return this.t.request("GET", "/alerts/geofences/alerts");
1075
+ }
1076
+ acknowledge(alertId) {
1077
+ return this.t.request("POST", `/alerts/geofences/${alertId}/acknowledge`);
1078
+ }
1079
+ };
1080
+ var AlertSharesResource = class {
1081
+ constructor(t) {
1082
+ this.t = t;
1083
+ }
1084
+ t;
1085
+ list() {
1086
+ return this.t.request("GET", "/alerts/shares");
1087
+ }
1088
+ acknowledge(alertId) {
1089
+ return this.t.request("POST", `/alerts/shares/${alertId}/ack`);
1090
+ }
1091
+ };
1092
+ var AlertRoutesResource = class {
1093
+ constructor(t) {
1094
+ this.t = t;
1095
+ }
1096
+ t;
1097
+ list() {
1098
+ return this.t.request("GET", "/alerts/routes");
1099
+ }
1100
+ create(input) {
1101
+ return this.t.request("POST", "/alerts/routes", { json: input });
1102
+ }
1103
+ update(routeId, patch) {
1104
+ return this.t.request("PATCH", `/alerts/routes/${routeId}`, { json: patch });
1105
+ }
1106
+ delete(routeId) {
1107
+ return this.t.request("DELETE", `/alerts/routes/${routeId}`);
1108
+ }
1109
+ silence(routeId, minutes) {
1110
+ return this.t.request("POST", `/alerts/routes/${routeId}/silence`, { json: { minutes } });
1111
+ }
1112
+ unsilence(routeId) {
1113
+ return this.silence(routeId, 0);
1114
+ }
1115
+ silenceState(routeId) {
1116
+ return this.t.request("GET", `/alerts/routes/${routeId}/silence`);
1117
+ }
1118
+ async kinds() {
1119
+ const payload = await this.t.request("GET", "/alerts/routes/kinds");
1120
+ return payload.kinds ?? [];
1121
+ }
1122
+ };
1123
+ var AlertInboxResource = class {
1124
+ constructor(t) {
1125
+ this.t = t;
1126
+ }
1127
+ t;
1128
+ list(opts = {}) {
1129
+ return this.t.request("GET", "/alerts/inbox", {
1130
+ params: {
1131
+ kinds: opts.kinds?.join(","),
1132
+ severities: opts.severities?.join(","),
1133
+ status: opts.status,
1134
+ limit: opts.limit,
1135
+ offset: opts.offset
1136
+ }
1137
+ });
1138
+ }
1139
+ async countPending() {
1140
+ const payload = await this.t.request("GET", "/alerts/count_pending");
1141
+ return payload.count ?? 0;
1142
+ }
1143
+ acknowledge(alertId) {
1144
+ return this.t.request("POST", `/alerts/${alertId}/acknowledge`);
1145
+ }
1146
+ };
1147
+ var AlertsResource = class {
1148
+ constructor(t) {
1149
+ this.t = t;
1150
+ this.feeds = new AlertFeedsResource(t);
1151
+ this.watches = new AlertWatchesResource(t);
1152
+ this.geofences = new AlertGeofencesResource(t);
1153
+ this.shares = new AlertSharesResource(t);
1154
+ this.routes = new AlertRoutesResource(t);
1155
+ this.inbox = new AlertInboxResource(t);
1156
+ }
1157
+ t;
1158
+ feeds;
1159
+ watches;
1160
+ geofences;
1161
+ shares;
1162
+ routes;
1163
+ inbox;
1164
+ escalate(alertId) {
1165
+ return this.t.request("POST", `/alerts/escalate/${alertId}`);
1166
+ }
1167
+ channels() {
1168
+ return this.t.request("GET", "/alerts/channels");
1169
+ }
1170
+ /**
1171
+ * `PUT /alerts/channels/{ref}` — point a delivery channel at its
1172
+ * destination.
1173
+ *
1174
+ * Exists so this is a GESTURE: before it, sending alerts to the team's
1175
+ * Discord (or any webhook) meant editing the tenant's JSONB in the
1176
+ * database. Audited as `alert_channel.configured`.
1177
+ *
1178
+ * `ref` is the channel name (`"discord"`) or a named ref
1179
+ * (`"discord-plantao"`, then pass `channel: "discord"`). Fields are open
1180
+ * because the vocabulary belongs to the CHANNEL, not the core.
1181
+ *
1182
+ * The response returns the config MASKED — a webhook URL is the
1183
+ * credential, and reads never hand it back whole.
1184
+ * Perm: `alerts.routes.manage`.
1185
+ */
1186
+ setChannel(ref, config) {
1187
+ return this.t.request("PUT", `/alerts/channels/${encodeURIComponent(ref)}`, {
1188
+ json: config
1189
+ });
1190
+ }
1191
+ /** `DELETE /alerts/channels/{ref}` — audited as `alert_channel.removed`. */
1192
+ deleteChannel(ref) {
1193
+ return this.t.request("DELETE", `/alerts/channels/${encodeURIComponent(ref)}`);
1194
+ }
1195
+ };
1196
+ var AlarmsResource = class {
1197
+ constructor(t) {
1198
+ this.t = t;
1199
+ }
1200
+ t;
1201
+ list() {
1202
+ return this.t.request("GET", "/platform/v26/alarms");
1203
+ }
1204
+ /** `node_id` XOR `node_type`; operator ∈ gt|gte|lt|lte|eq|ne. */
1205
+ create(input) {
1206
+ return this.t.request("POST", "/platform/v26/alarms", { json: input });
1207
+ }
1208
+ update(ruleId, patch) {
1209
+ return this.t.request("PUT", `/platform/v26/alarms/${encodeURIComponent(ruleId)}`, {
1210
+ json: patch
1211
+ });
1212
+ }
1213
+ delete(ruleId) {
1214
+ return this.t.request("DELETE", `/platform/v26/alarms/${encodeURIComponent(ruleId)}`);
1215
+ }
1216
+ events(opts = {}) {
1217
+ return this.t.request("GET", "/platform/v26/alarms/events", { params: opts });
1218
+ }
1219
+ };
1220
+ var EventsResource = class {
1221
+ constructor(t) {
1222
+ this.t = t;
1223
+ }
1224
+ t;
1225
+ pipelineStatus() {
1226
+ return this.t.request("GET", "/api/v1/events/pipeline/status");
1227
+ }
1228
+ dlqList(limit = 50) {
1229
+ return this.t.request("GET", "/api/v1/events/pipeline/dlq", { params: { limit } });
1230
+ }
1231
+ /** Exactly one of `ids` / `all` is required. */
1232
+ dlqRetry(opts) {
1233
+ assertIdsXorAll(opts);
1234
+ return this.t.request("POST", "/api/v1/events/pipeline/dlq/retry", { json: opts });
1235
+ }
1236
+ /** Exactly one of `ids` / `all` is required. */
1237
+ dlqPurge(opts) {
1238
+ assertIdsXorAll(opts);
1239
+ return this.t.request("POST", "/api/v1/events/pipeline/dlq/purge", { json: opts });
1240
+ }
1241
+ };
1242
+ function assertIdsXorAll(opts) {
1243
+ const hasIds = !!opts.ids?.length;
1244
+ if (hasIds === !!opts.all) throw new Error("pass exactly one of ids or all");
1245
+ }
1246
+ var ConnectorsResource = class {
1247
+ constructor(t) {
1248
+ this.t = t;
1249
+ }
1250
+ t;
1251
+ list() {
1252
+ return this.t.request("GET", "/governance/agents");
1253
+ }
1254
+ patch(agentId, patch) {
1255
+ const body = Object.fromEntries(Object.entries(patch).filter(([, v]) => v !== void 0));
1256
+ if (Object.keys(body).length === 0) throw new Error("empty patch");
1257
+ return this.t.request("PATCH", `/governance/agents/${agentId}`, { json: body });
1258
+ }
1259
+ /** status ∈ inactive|active|running|degraded|failed */
1260
+ setStatus(agentId, status) {
1261
+ return this.patch(agentId, { status });
1262
+ }
1263
+ bindings(agentId) {
1264
+ return this.t.request("GET", `/governance/agents/${agentId}/skills`);
1265
+ }
1266
+ /** Two calls: creates the worker agent, then binds the `connector.http` skill. */
1267
+ async register(input) {
1268
+ const agent = await this.t.request("POST", "/governance/agents", {
1269
+ json: {
1270
+ slug: input.slug,
1271
+ display_name: input.display_name,
1272
+ kind: "worker",
1273
+ config: input.cron_preset ? { cron_preset: input.cron_preset } : {}
1274
+ }
1275
+ });
1276
+ await this.t.request("POST", `/governance/agents/${agent.id}/skills`, {
1277
+ json: {
1278
+ skill_key: "connector.http",
1279
+ config: {
1280
+ base_url: input.base_url,
1281
+ path: input.path ?? "",
1282
+ node_type: input.node_type,
1283
+ id_field: input.id_field,
1284
+ name_field: input.name_field ?? "",
1285
+ records_path: input.records_path ?? "",
1286
+ auth: input.auth,
1287
+ pagination: input.pagination
1288
+ }
1289
+ }
1290
+ });
1291
+ return agent;
1292
+ }
1293
+ test(agentId) {
1294
+ return this.t.request("POST", `/governance/agents/${agentId}/skills/connector.http/test`);
1295
+ }
1296
+ run(agentId) {
1297
+ return this.t.request("POST", `/governance/agents/${agentId}/run`, {
1298
+ json: { skill_key: "connector.http" }
1299
+ });
1300
+ }
1301
+ /**
1302
+ * Start/renew QR pairing for a skill with the `pairing` capability (WhatsApp
1303
+ * station). Pass `{ refresh: true }` to force a fresh code.
1304
+ */
1305
+ pairingStart(agentId, skillKey, opts = {}) {
1306
+ const { target, ...json } = opts;
1307
+ return this.t.request("POST", `/governance/agents/${agentId}/skills/${skillKey}/pairing`, {
1308
+ json,
1309
+ params: target ? { target } : void 0
1310
+ });
1311
+ }
1312
+ /** Read-only poll of the pairing state (no side effects). `target` aims a pool number. */
1313
+ pairingPoll(agentId, skillKey, opts = {}) {
1314
+ return this.t.request("GET", `/governance/agents/${agentId}/skills/${skillKey}/pairing`, {
1315
+ params: opts.target ? { target: opts.target } : void 0
1316
+ });
1317
+ }
1318
+ /**
1319
+ * Add / correct / remove a sub-unit administered by a connector that
1320
+ * declares the `inventory` capability — e.g. one number of a WhatsApp
1321
+ * number-station.
1322
+ *
1323
+ * Reading is NOT here: the inventory already reaches callers through the
1324
+ * snapshot the tick publishes on the device mirror (`GET /api/v1/edge/nodes`
1325
+ * → `nodes[].pool`). A second read path would drift between ticks.
1326
+ */
1327
+ applyInventory(agentId, skillKey, op, item) {
1328
+ return this.t.request(
1329
+ "POST",
1330
+ `/governance/agents/${agentId}/skills/${skillKey}/inventory`,
1331
+ { json: { op, item } }
1332
+ );
1333
+ }
1334
+ schedulerTick() {
1335
+ return this.t.request("POST", "/governance/agents/scheduler/tick");
1336
+ }
1337
+ /** source ∈ native|clawhub. Rows carry an additive `capabilities` field. */
1338
+ skillCatalog(source) {
1339
+ return this.t.request("GET", "/governance/agents/skills", { params: { source } });
1340
+ }
1341
+ installOpenclaw(slug) {
1342
+ return this.t.request("POST", "/governance/agents/skills/openclaw/install", {
1343
+ json: { slug: slug.replace(/^openclaw:/, "") }
1344
+ });
1345
+ }
1346
+ refreshOpenclaw() {
1347
+ return this.t.request("POST", "/governance/agents/skills/openclaw/refresh");
1348
+ }
1349
+ };
1350
+ var PipelinesResource = class {
1351
+ constructor(t) {
1352
+ this.t = t;
1353
+ }
1354
+ t;
1355
+ list() {
1356
+ return this.t.request("GET", "/platform/v22/pipelines");
1357
+ }
1358
+ transformPreview(sampleRows, steps) {
1359
+ return this.t.request("POST", "/platform/v23/pipeline/transform/preview", {
1360
+ json: { sample_rows: sampleRows, steps }
1361
+ });
1362
+ }
1363
+ dryRun(boardId) {
1364
+ return this.t.request("POST", `/platform/v23/pipeline/${boardId}/dry-run`);
1365
+ }
1366
+ syncPreview(format, opts = {}) {
1367
+ const body = { format };
1368
+ for (const [k, v] of Object.entries(opts)) if (v !== void 0) body[k] = v;
1369
+ return this.t.request("POST", "/platform/v23/pipeline/sync/preview", { json: body });
1370
+ }
1371
+ create(input) {
1372
+ return this.t.request("POST", "/platform/v22/pipelines", { json: input });
1373
+ }
1374
+ update(pipelineId, patch) {
1375
+ return this.t.request("PUT", `/platform/v22/pipelines/${pipelineId}`, { json: patch });
1376
+ }
1377
+ setSchedule(pipelineId, preset) {
1378
+ return this.update(pipelineId, { schedule_preset: preset || "" });
1379
+ }
1380
+ build(pipelineId, opts = {}) {
1381
+ return this.t.request("POST", `/platform/v22/pipelines/${pipelineId}/build`, {
1382
+ params: {
1383
+ incremental: String(opts.incremental ?? false),
1384
+ branch: opts.branch ?? "main"
1385
+ }
1386
+ });
1387
+ }
1388
+ runs(pipelineId, limit = 50) {
1389
+ return this.t.request("GET", `/platform/v22/pipelines/${pipelineId}/runs`, {
1390
+ params: { limit }
1391
+ });
1392
+ }
1393
+ };
1394
+ var ChatChannelsResource = class {
1395
+ constructor(t) {
1396
+ this.t = t;
1397
+ }
1398
+ t;
1399
+ list() {
1400
+ return this.t.request("GET", "/chat/channels");
1401
+ }
1402
+ get(channelId) {
1403
+ return this.t.request("GET", `/chat/channels/${channelId}`);
1404
+ }
1405
+ create(input) {
1406
+ const body = Object.fromEntries(Object.entries(input).filter(([, v]) => v !== void 0));
1407
+ return this.t.request("POST", "/chat/channels", { json: body });
1408
+ }
1409
+ patch(channelId, payload) {
1410
+ return this.t.request("PATCH", `/chat/channels/${channelId}`, { json: payload });
1411
+ }
1412
+ delete(channelId) {
1413
+ return this.t.request("DELETE", `/chat/channels/${channelId}`);
1414
+ }
1415
+ };
1416
+ var ChatMessagesResource = class {
1417
+ constructor(t) {
1418
+ this.t = t;
1419
+ }
1420
+ t;
1421
+ list(channelId, opts = {}) {
1422
+ return this.t.request("GET", `/chat/channels/${channelId}/messages`, { params: opts });
1423
+ }
1424
+ send(channelId, body, opts = {}) {
1425
+ return this.t.request("POST", `/chat/channels/${channelId}/messages`, {
1426
+ json: { body, classification: opts.classification ?? "U", embeds: opts.embeds }
1427
+ });
1428
+ }
1429
+ };
1430
+ var ChatResource = class {
1431
+ channels;
1432
+ messages;
1433
+ constructor(t) {
1434
+ this.channels = new ChatChannelsResource(t);
1435
+ this.messages = new ChatMessagesResource(t);
1436
+ }
1437
+ };
1438
+ var NotepadResource = class {
1439
+ constructor(t) {
1440
+ this.t = t;
1441
+ }
1442
+ t;
1443
+ list() {
1444
+ return this.t.request("GET", "/platform/v23/notepad");
1445
+ }
1446
+ get(docId) {
1447
+ return this.t.request("GET", `/platform/v23/notepad/${encodeURIComponent(docId)}`);
1448
+ }
1449
+ create(input) {
1450
+ return this.t.request("POST", "/platform/v23/notepad", { json: input });
1451
+ }
1452
+ /** Mirrors Python: all keys are sent (null = unchanged server-side). */
1453
+ update(docId, patch) {
1454
+ return this.t.request("PUT", `/platform/v23/notepad/${encodeURIComponent(docId)}`, {
1455
+ json: {
1456
+ title: patch.title ?? null,
1457
+ body_md: patch.body_md ?? null,
1458
+ markings: patch.markings ?? null,
1459
+ pinned: patch.pinned ?? null
1460
+ }
1461
+ });
1462
+ }
1463
+ delete(docId) {
1464
+ return this.t.request("DELETE", `/platform/v23/notepad/${encodeURIComponent(docId)}`);
1465
+ }
1466
+ };
1467
+
1468
+ // src/resources/governance.ts
1469
+ var LineageResource = class {
1470
+ constructor(t) {
1471
+ this.t = t;
1472
+ }
1473
+ t;
1474
+ graph(opts = {}) {
1475
+ return this.t.request("GET", "/platform/v23/lineage-graph", { params: opts });
1476
+ }
1477
+ events(opts = {}) {
1478
+ return this.t.request("GET", "/lineage/events", { params: opts });
1479
+ }
1480
+ };
1481
+ var AccessAuditResource = class {
1482
+ constructor(t) {
1483
+ this.t = t;
1484
+ }
1485
+ t;
1486
+ list(opts = {}) {
1487
+ return this.t.request("GET", "/governance/access-audit", { params: opts });
1488
+ }
1489
+ };
1490
+ var MarkingCategoriesResource = class {
1491
+ constructor(t) {
1492
+ this.t = t;
1493
+ }
1494
+ t;
1495
+ list(opts = {}) {
1496
+ return this.t.request("GET", "/markings/categories", { params: opts });
1497
+ }
1498
+ create(input) {
1499
+ return this.t.request("POST", "/markings/categories", { json: input });
1500
+ }
1501
+ };
1502
+ var MarkingsResource = class {
1503
+ constructor(t) {
1504
+ this.t = t;
1505
+ this.categories = new MarkingCategoriesResource(t);
1506
+ }
1507
+ t;
1508
+ categories;
1509
+ list(opts = {}) {
1510
+ return this.t.request("GET", "/markings", { params: opts });
1511
+ }
1512
+ get(markingId) {
1513
+ return this.t.request("GET", `/markings/${markingId}`);
1514
+ }
1515
+ create(input) {
1516
+ return this.t.request("POST", "/markings", { json: input });
1517
+ }
1518
+ update(markingId, patch) {
1519
+ return this.t.request("PATCH", `/markings/${markingId}`, { json: patch });
1520
+ }
1521
+ listEligibility(markingId) {
1522
+ return this.t.request("GET", `/markings/${markingId}/eligibility`);
1523
+ }
1524
+ grantEligibility(markingId, userId, canApply = false) {
1525
+ return this.t.request("POST", `/markings/${markingId}/eligibility`, {
1526
+ json: { user_id: userId, can_apply: canApply }
1527
+ });
1528
+ }
1529
+ revokeEligibility(markingId, userId) {
1530
+ return this.t.request("DELETE", `/markings/${markingId}/eligibility/${userId}`);
1531
+ }
1532
+ };
1533
+ var ResourceMarkingsResource = class {
1534
+ constructor(t) {
1535
+ this.t = t;
1536
+ }
1537
+ t;
1538
+ list(resourceKind, resourceId) {
1539
+ return this.t.request("GET", `/resources/${resourceKind}/${resourceId}/markings`);
1540
+ }
1541
+ apply(resourceKind, resourceId, markingId) {
1542
+ return this.t.request("POST", `/resources/${resourceKind}/${resourceId}/markings`, {
1543
+ json: { marking_id: markingId }
1544
+ });
1545
+ }
1546
+ remove(resourceKind, resourceId, markingId) {
1547
+ return this.t.request(
1548
+ "DELETE",
1549
+ `/resources/${resourceKind}/${resourceId}/markings/${markingId}`
1550
+ );
1551
+ }
1552
+ };
1553
+ var PropertyMarkingsResource = class {
1554
+ constructor(t) {
1555
+ this.t = t;
1556
+ }
1557
+ t;
1558
+ listForNode(nodeId) {
1559
+ return this.t.request("GET", `/ontology/nodes/${nodeId}/property-markings`);
1560
+ }
1561
+ listOne(nodeId, propertyKey) {
1562
+ return this.t.request("GET", `/ontology/nodes/${nodeId}/properties/${propertyKey}/markings`);
1563
+ }
1564
+ apply(nodeId, propertyKey, markingId) {
1565
+ return this.t.request("POST", `/ontology/nodes/${nodeId}/properties/${propertyKey}/markings`, {
1566
+ json: { marking_id: markingId }
1567
+ });
1568
+ }
1569
+ remove(nodeId, propertyKey, markingId) {
1570
+ return this.t.request(
1571
+ "DELETE",
1572
+ `/ontology/nodes/${nodeId}/properties/${propertyKey}/markings/${markingId}`
1573
+ );
1574
+ }
1575
+ };
1576
+ var RowPoliciesResource = class {
1577
+ constructor(t) {
1578
+ this.t = t;
1579
+ }
1580
+ t;
1581
+ list() {
1582
+ return this.t.request("GET", "/platform/v26/row-policies");
1583
+ }
1584
+ create(input) {
1585
+ return this.t.request("POST", "/platform/v26/row-policies", { json: input });
1586
+ }
1587
+ delete(policyId) {
1588
+ return this.t.request("DELETE", `/platform/v26/row-policies/${encodeURIComponent(policyId)}`);
1589
+ }
1590
+ };
1591
+ var ErasureResource = class {
1592
+ constructor(t) {
1593
+ this.t = t;
1594
+ }
1595
+ t;
1596
+ /** Dry-run: shows the match radius without mutating anything. */
1597
+ preview(selector) {
1598
+ return this.t.request("POST", "/governance/erasure/preview", { json: selector });
1599
+ }
1600
+ /** Requires `confirm: true`; pass `expected_count` to guard the radius (422 on mismatch). */
1601
+ forget(selector, opts = {}) {
1602
+ return this.t.request("POST", "/governance/erasure/forget", { json: { ...selector, ...opts } });
1603
+ }
1604
+ };
1605
+ var RetentionResource = class {
1606
+ constructor(t) {
1607
+ this.t = t;
1608
+ }
1609
+ t;
1610
+ list() {
1611
+ return this.t.request("GET", "/governance/retention");
1612
+ }
1613
+ set(target, retentionDays, active = true) {
1614
+ return this.t.request("PUT", "/governance/retention", {
1615
+ json: { target, retention_days: retentionDays, active }
1616
+ });
1617
+ }
1618
+ delete(target) {
1619
+ return this.t.request("DELETE", `/governance/retention/${encodeURIComponent(target)}`);
1620
+ }
1621
+ run(target) {
1622
+ return this.t.request("POST", `/governance/retention/${encodeURIComponent(target)}/run`);
1623
+ }
1624
+ };
1625
+ var GuestTokensResource = class {
1626
+ constructor(t) {
1627
+ this.t = t;
1628
+ }
1629
+ t;
1630
+ list() {
1631
+ return this.t.request("GET", "/platform/v23/guest-tokens");
1632
+ }
1633
+ /** Plaintext token appears once in the response — treat as a secret. */
1634
+ issue(input) {
1635
+ return this.t.request("POST", "/platform/v23/guest-tokens", { json: input });
1636
+ }
1637
+ revoke(tokenId) {
1638
+ return this.t.request("POST", `/platform/v23/guest-tokens/${tokenId}/revoke`);
1639
+ }
1640
+ };
1641
+
1642
+ // src/resources/platform.ts
1643
+ var WorkshopBriefingsResource = class {
1644
+ constructor(t) {
1645
+ this.t = t;
1646
+ }
1647
+ t;
1648
+ list() {
1649
+ return this.t.request("GET", "/workshop/apps", { params: { kind: "briefing" } });
1650
+ }
1651
+ get(briefingId) {
1652
+ return this.t.request("GET", `/workshop/apps/${briefingId}`);
1653
+ }
1654
+ create(name) {
1655
+ return this.t.request("POST", "/workshop/apps", { json: { name, kind: "briefing" } });
1656
+ }
1657
+ patch(briefingId, payload) {
1658
+ return this.t.request("PATCH", `/workshop/apps/${briefingId}`, { json: payload });
1659
+ }
1660
+ broadcast(briefingId) {
1661
+ return this.t.request("POST", `/workshop/briefings/${briefingId}/broadcast`);
1662
+ }
1663
+ };
1664
+ var WorkshopDossiersResource = class {
1665
+ constructor(t) {
1666
+ this.t = t;
1667
+ }
1668
+ t;
1669
+ list() {
1670
+ return this.t.request("GET", "/workshop/dossiers");
1671
+ }
1672
+ get(dossierId) {
1673
+ return this.t.request("GET", `/workshop/dossiers/${dossierId}`);
1674
+ }
1675
+ create(title) {
1676
+ return this.t.request("POST", "/workshop/dossiers", { json: { title } });
1677
+ }
1678
+ patch(dossierId, body) {
1679
+ return this.t.request("PATCH", `/workshop/dossiers/${dossierId}`, { json: body });
1680
+ }
1681
+ delete(dossierId) {
1682
+ return this.t.request("DELETE", `/workshop/dossiers/${dossierId}`);
1683
+ }
1684
+ addEmbed(dossierId, kind, sourceRef, nodeId) {
1685
+ return this.t.request("POST", `/workshop/dossiers/${dossierId}/embeds`, {
1686
+ json: { embed_kind: kind, source_ref: sourceRef, node_id: nodeId }
1687
+ });
1688
+ }
1689
+ embeds(dossierId) {
1690
+ return this.t.request("GET", `/workshop/dossiers/${dossierId}/embeds`);
1691
+ }
1692
+ };
1693
+ var WorkshopCovsResource = class {
1694
+ constructor(t) {
1695
+ this.t = t;
1696
+ }
1697
+ t;
1698
+ list(objectType) {
1699
+ return this.t.request("GET", "/workshop/covs", { params: { object_type: objectType } });
1700
+ }
1701
+ get(covId) {
1702
+ return this.t.request("GET", `/workshop/covs/${covId}`);
1703
+ }
1704
+ /** Full-object upsert. */
1705
+ save(cov) {
1706
+ return this.t.request("POST", "/workshop/covs", { json: cov });
1707
+ }
1708
+ delete(covId) {
1709
+ return this.t.request("DELETE", `/workshop/covs/${covId}`);
1710
+ }
1711
+ setTeamDefault(covId) {
1712
+ return this.t.request("POST", `/workshop/covs/${covId}/set-team-default`);
1713
+ }
1714
+ };
1715
+ var WorkshopResource = class {
1716
+ constructor(t) {
1717
+ this.t = t;
1718
+ this.briefings = new WorkshopBriefingsResource(t);
1719
+ this.dossiers = new WorkshopDossiersResource(t);
1720
+ this.covs = new WorkshopCovsResource(t);
1721
+ }
1722
+ t;
1723
+ briefings;
1724
+ dossiers;
1725
+ covs;
1726
+ widgetCatalog(proposableOnly = false) {
1727
+ return this.t.request("GET", "/workshop/widget-catalog", {
1728
+ params: proposableOnly ? { proposable_only: "true" } : {}
1729
+ });
1730
+ }
1731
+ };
1732
+ var ComputeProvidersResource = class {
1733
+ constructor(t) {
1734
+ this.t = t;
1735
+ }
1736
+ t;
1737
+ catalog() {
1738
+ return this.t.request("GET", "/compute/providers/catalog");
1739
+ }
1740
+ list() {
1741
+ return this.t.request("GET", "/compute/providers");
1742
+ }
1743
+ /** `api_key` is write-only — never returned by the API. */
1744
+ create(input) {
1745
+ return this.t.request("POST", "/compute/providers", { json: input });
1746
+ }
1747
+ update(providerId, patch) {
1748
+ const body = Object.fromEntries(Object.entries(patch).filter(([, v]) => v !== void 0));
1749
+ return this.t.request("PUT", `/compute/providers/${providerId}`, { json: body });
1750
+ }
1751
+ delete(providerId) {
1752
+ return this.t.request("DELETE", `/compute/providers/${providerId}`);
1753
+ }
1754
+ test(providerId) {
1755
+ return this.t.request("POST", `/compute/providers/${providerId}/test`);
1756
+ }
1757
+ };
1758
+ var ComputeReleasesResource = class {
1759
+ constructor(t) {
1760
+ this.t = t;
1761
+ }
1762
+ t;
1763
+ list(name) {
1764
+ return this.t.request("GET", "/compute/releases", { params: { name } });
1765
+ }
1766
+ publish(input) {
1767
+ return this.t.request("POST", "/compute/releases", { json: input });
1768
+ }
1769
+ /** 409 if `eval_score` is below the gate. */
1770
+ promote(name, version, minEvalScore = 0.8) {
1771
+ return this.t.request("POST", "/compute/releases/promote", {
1772
+ json: { name, version, min_eval_score: minEvalScore }
1773
+ });
1774
+ }
1775
+ deploy(providerId, name, channel = "production", extra = {}) {
1776
+ return this.t.request("POST", `/compute/providers/${providerId}/releases/deploy`, {
1777
+ json: { name, channel, ...extra }
1778
+ });
1779
+ }
1780
+ };
1781
+ var ComputeControlResource = class {
1782
+ constructor(t, providerId) {
1783
+ this.t = t;
1784
+ this.base = `/compute/providers/${providerId}`;
1785
+ }
1786
+ t;
1787
+ base;
1788
+ listTemplates() {
1789
+ return this.t.request("GET", `${this.base}/templates`);
1790
+ }
1791
+ saveTemplate(name, imageName, extra = {}) {
1792
+ return this.t.request("POST", `${this.base}/templates`, {
1793
+ json: { name, image_name: imageName, ...extra }
1794
+ });
1795
+ }
1796
+ deleteTemplate(templateId) {
1797
+ return this.t.request("DELETE", `${this.base}/templates/${templateId}`);
1798
+ }
1799
+ listEndpoints() {
1800
+ return this.t.request("GET", `${this.base}/endpoints`);
1801
+ }
1802
+ createEndpoint(templateId, name, extra = {}) {
1803
+ return this.t.request("POST", `${this.base}/endpoints`, {
1804
+ json: { template_id: templateId, name, ...extra }
1805
+ });
1806
+ }
1807
+ updateEndpoint(endpointId, patch) {
1808
+ return this.t.request("PATCH", `${this.base}/endpoints/${endpointId}`, {
1809
+ json: { patch }
1810
+ });
1811
+ }
1812
+ deleteEndpoint(endpointId) {
1813
+ return this.t.request("DELETE", `${this.base}/endpoints/${endpointId}`);
1814
+ }
1815
+ endpointHealth(endpointId) {
1816
+ return this.t.request("GET", `${this.base}/endpoints/${endpointId}/health`);
1817
+ }
1818
+ /** `sync: true` long-polls server-side up to `timeout_s` — pass a matching
1819
+ * `signal` (or raise the client `timeoutMs`) for long jobs. */
1820
+ submitJob(endpointId, input, opts = {}) {
1821
+ return this.t.request("POST", `${this.base}/endpoints/${endpointId}/jobs`, {
1822
+ json: { input, sync: opts.sync ?? false, webhook: opts.webhook, timeout_s: opts.timeout_s }
1823
+ });
1824
+ }
1825
+ jobStatus(endpointId, jobId) {
1826
+ return this.t.request("GET", `${this.base}/endpoints/${endpointId}/jobs/${jobId}`);
1827
+ }
1828
+ cancelJob(endpointId, jobId) {
1829
+ return this.t.request("POST", `${this.base}/endpoints/${endpointId}/jobs/${jobId}/cancel`);
1830
+ }
1831
+ listPods() {
1832
+ return this.t.request("GET", `${this.base}/pods`);
1833
+ }
1834
+ createPod(name, imageName, extra = {}) {
1835
+ return this.t.request("POST", `${this.base}/pods`, {
1836
+ json: { name, image_name: imageName, ...extra }
1837
+ });
1838
+ }
1839
+ stopPod(podId) {
1840
+ return this.t.request("POST", `${this.base}/pods/${podId}/stop`);
1841
+ }
1842
+ terminatePod(podId) {
1843
+ return this.t.request("DELETE", `${this.base}/pods/${podId}`);
1844
+ }
1845
+ };
1846
+ var ComputeResource = class {
1847
+ constructor(t) {
1848
+ this.t = t;
1849
+ this.providers = new ComputeProvidersResource(t);
1850
+ this.releases = new ComputeReleasesResource(t);
1851
+ }
1852
+ t;
1853
+ providers;
1854
+ releases;
1855
+ selectModel(objective, opts = {}) {
1856
+ return this.t.request("POST", "/compute/vision/select-model", {
1857
+ json: { objective, ...opts }
1858
+ });
1859
+ }
1860
+ generateSpec(objective, opts = {}) {
1861
+ return this.t.request("POST", "/compute/spec/generate", {
1862
+ json: { objective, base_image: opts.base_image ?? "python:3.11-slim", ...opts }
1863
+ });
1864
+ }
1865
+ visionCount(imageUrl, instruction, opts = {}) {
1866
+ return this.t.request("POST", "/compute/vision/count", {
1867
+ json: { image_url: imageUrl, instruction, ...opts }
1868
+ });
1869
+ }
1870
+ /** Factory (no HTTP) — control plane scoped to one provider. */
1871
+ control(providerId) {
1872
+ return new ComputeControlResource(this.t, providerId);
1873
+ }
1874
+ };
1875
+ var InferenceResource = class {
1876
+ constructor(t) {
1877
+ this.t = t;
1878
+ }
1879
+ t;
1880
+ complete(prompt, opts = {}) {
1881
+ return this.t.request("POST", "/inference/complete", {
1882
+ json: {
1883
+ prompt,
1884
+ provider: opts.provider ?? "groq",
1885
+ model: opts.model ?? "llama-3.3-70b-versatile",
1886
+ system_prompt: opts.system_prompt,
1887
+ temperature: opts.temperature ?? 0,
1888
+ max_tokens: opts.max_tokens ?? 4096
1889
+ }
1890
+ });
1891
+ }
1892
+ chat(messages, opts = {}) {
1893
+ const body = {
1894
+ messages,
1895
+ provider: opts.provider ?? "groq",
1896
+ model: opts.model ?? "llama-3.3-70b-versatile",
1897
+ temperature: opts.temperature ?? 0,
1898
+ max_tokens: opts.max_tokens ?? 4096
1899
+ };
1900
+ if (opts.rag_sources) {
1901
+ body.rag_sources = opts.rag_sources;
1902
+ body.rag_limit = opts.rag_limit ?? 5;
1903
+ }
1904
+ return this.t.request("POST", "/inference/chat", { json: body });
1905
+ }
1906
+ models() {
1907
+ return this.t.request("GET", "/inference/models");
1908
+ }
1909
+ collections() {
1910
+ return this.t.request("GET", "/inference/collections");
1911
+ }
1912
+ async chatWithRag(query, opts = {}) {
1913
+ const payload = await this.t.request("POST", "/mcp/tools/call", {
1914
+ json: {
1915
+ name: "chat_with_rag",
1916
+ arguments: {
1917
+ query,
1918
+ sources: opts.sources ?? ["all"],
1919
+ limit: opts.limit ?? 6,
1920
+ provider: opts.provider ?? "groq",
1921
+ model: opts.model ?? "llama-3.3-70b-versatile",
1922
+ temperature: opts.temperature ?? 0.2,
1923
+ max_tokens: opts.max_tokens ?? 512,
1924
+ system: opts.system
1925
+ }
1926
+ }
1927
+ });
1928
+ return payload.result ?? payload;
1929
+ }
1930
+ auditTrail(opts = {}) {
1931
+ return this.t.request("GET", "/inference/audit-trail", {
1932
+ params: { limit: opts.limit ?? 50, provider: opts.provider }
1933
+ });
1934
+ }
1935
+ };
1936
+ var CodegenResource = class {
1937
+ constructor(t) {
1938
+ this.t = t;
1939
+ }
1940
+ t;
1941
+ /** kind ∈ transform|script */
1942
+ generate(objective, kind = "transform", context) {
1943
+ return this.t.request("POST", "/codegen/generate", { json: { objective, kind, context } });
1944
+ }
1945
+ };
1946
+ var CorrelationResource = class {
1947
+ constructor(t) {
1948
+ this.t = t;
1949
+ }
1950
+ t;
1951
+ quickLinks(value, kind) {
1952
+ return this.t.request("POST", "/correlation/quick-links", { json: { value, kind } });
1953
+ }
1954
+ startChain(value, opts = {}) {
1955
+ return this.t.request("POST", "/correlation/chain", { json: { value, ...opts } });
1956
+ }
1957
+ /** Poll until `status === "done"`. */
1958
+ getChain(taskId) {
1959
+ return this.t.request("GET", `/correlation/chain/${taskId}`);
1960
+ }
1961
+ /** Opt-in: materializes the chain graph into the ontology. */
1962
+ saveChain(taskId, nodeIds) {
1963
+ return this.t.request("POST", `/correlation/chain/${taskId}/save`, {
1964
+ json: nodeIds ? { node_ids: nodeIds } : {}
1965
+ });
1966
+ }
1967
+ };
1968
+ var SituationalResource = class {
1969
+ constructor(t) {
1970
+ this.t = t;
1971
+ }
1972
+ t;
1973
+ nearby(nodeId, opts = {}) {
1974
+ return this.t.request("GET", "/api/v1/situational/nearby", {
1975
+ params: { node_id: nodeId, ...opts, kinds: opts.kinds?.join(",") }
1976
+ });
1977
+ }
1978
+ correlations(nodeId) {
1979
+ return this.t.request("GET", "/api/v1/situational/correlations", {
1980
+ params: { node_id: nodeId }
1981
+ });
1982
+ }
1983
+ correlate(anchorNodeId, opts = {}) {
1984
+ return this.t.request("POST", "/api/v1/situational/correlations", {
1985
+ json: { anchor_node_id: anchorNodeId, ...opts }
1986
+ });
1987
+ }
1988
+ /** Reversible — removes the correlation edge. */
1989
+ cut(edgeId) {
1990
+ return this.t.request("DELETE", `/api/v1/situational/correlations/${edgeId}`);
1991
+ }
1992
+ };
1993
+ var MergeResource = class {
1994
+ constructor(t) {
1995
+ this.t = t;
1996
+ }
1997
+ t;
1998
+ suggestTarget(nodeType, canonical) {
1999
+ return this.t.request("POST", "/ontology/merge/suggest-target", {
2000
+ json: { node_type: nodeType, canonical }
2001
+ });
2002
+ }
2003
+ /** Pass `result_payload` (raw) OR `properties` (ready). */
2004
+ preview(target, opts = {}) {
2005
+ return this.t.request("POST", "/ontology/merge/preview", { json: { target, ...opts } });
2006
+ }
2007
+ /** `field_resolutions`: `{field: "keep"|"replace"|"append"}`;
2008
+ * `link`: `{target_object_id, relation_type, metadata?}`. */
2009
+ apply(target, opts = {}) {
2010
+ return this.t.request("POST", "/ontology/merge/apply", { json: { target, ...opts } });
2011
+ }
2012
+ };
2013
+
2014
+ // src/resources/domain.ts
2015
+ var AtlasLayersResource = class {
2016
+ constructor(t) {
2017
+ this.t = t;
2018
+ }
2019
+ t;
2020
+ list() {
2021
+ return this.t.request("GET", "/atlas/layers");
2022
+ }
2023
+ create(name, kind, extra = {}) {
2024
+ const body = { name, kind };
2025
+ for (const [k, v] of Object.entries(extra)) if (v !== void 0 && v !== null) body[k] = v;
2026
+ return this.t.request("POST", "/atlas/layers", { json: body });
2027
+ }
2028
+ delete(layerId) {
2029
+ return this.t.request("DELETE", `/atlas/layers/${layerId}`);
2030
+ }
2031
+ /** KML content travels inside the JSON body (not multipart) — same as Python. */
2032
+ importKml(layerId, kmlText) {
2033
+ return this.t.request("POST", `/atlas/layers/${layerId}/import`, {
2034
+ json: { _kml_bytes_b64: kmlText }
2035
+ });
2036
+ }
2037
+ };
2038
+ var AtlasEvaluationResource = class {
2039
+ constructor(t) {
2040
+ this.t = t;
2041
+ }
2042
+ t;
2043
+ status() {
2044
+ return this.t.request("GET", "/atlas/evaluation/status");
2045
+ }
2046
+ runOnce() {
2047
+ return this.t.request("POST", "/atlas/evaluation/run-once");
2048
+ }
2049
+ };
2050
+ var AtlasResource = class {
2051
+ layers;
2052
+ evaluation;
2053
+ constructor(t) {
2054
+ this.layers = new AtlasLayersResource(t);
2055
+ this.evaluation = new AtlasEvaluationResource(t);
2056
+ }
2057
+ };
2058
+ var BriefingResource = class {
2059
+ constructor(t) {
2060
+ this.t = t;
2061
+ }
2062
+ t;
2063
+ get(slug) {
2064
+ return this.t.request("GET", `/campaign/home-briefing/${slug}`);
2065
+ }
2066
+ refresh(slug) {
2067
+ return this.t.request("POST", `/campaign/home-briefing/${slug}/refresh`);
2068
+ }
2069
+ crisisPlan(slug) {
2070
+ return this.t.request("POST", `/campaign/home-briefing/${slug}/crisis-plan`);
2071
+ }
2072
+ };
2073
+ var CctvBookmarksResource = class {
2074
+ constructor(t) {
2075
+ this.t = t;
2076
+ }
2077
+ t;
2078
+ create(streamId, input) {
2079
+ return this.t.request("POST", `/api/v1/cctv/streams/${streamId}/bookmarks`, { json: input });
2080
+ }
2081
+ list(streamId, opts = {}) {
2082
+ return this.t.request("GET", `/api/v1/cctv/streams/${streamId}/bookmarks`, { params: opts });
2083
+ }
2084
+ delete(bookmarkId) {
2085
+ return this.t.request("DELETE", `/api/v1/cctv/bookmarks/${bookmarkId}`);
2086
+ }
2087
+ };
2088
+ var CctvGcpsResource = class {
2089
+ constructor(t) {
2090
+ this.t = t;
2091
+ }
2092
+ t;
2093
+ put(streamId, gcps) {
2094
+ return this.t.request("PUT", `/api/v1/cctv/streams/${streamId}/gcps`, { json: { gcps } });
2095
+ }
2096
+ get(streamId) {
2097
+ return this.t.request("GET", `/api/v1/cctv/streams/${streamId}/gcps`);
2098
+ }
2099
+ delete(streamId) {
2100
+ return this.t.request("DELETE", `/api/v1/cctv/streams/${streamId}/gcps`);
2101
+ }
2102
+ };
2103
+ var CctvHotlistResource = class {
2104
+ constructor(t) {
2105
+ this.t = t;
2106
+ }
2107
+ t;
2108
+ list(activeOnly) {
2109
+ return this.t.request("GET", "/api/v1/cctv/hotlist", { params: { active_only: activeOnly } });
2110
+ }
2111
+ add(plate, opts = {}) {
2112
+ return this.t.request("POST", "/api/v1/cctv/hotlist", {
2113
+ json: { plate, reason: opts.reason, severity: opts.severity ?? "medium" }
2114
+ });
2115
+ }
2116
+ remove(watchedId) {
2117
+ return this.t.request("DELETE", `/api/v1/cctv/hotlist/${watchedId}`);
2118
+ }
2119
+ };
2120
+ var CctvResource = class {
2121
+ constructor(t) {
2122
+ this.t = t;
2123
+ this.bookmarks = new CctvBookmarksResource(t);
2124
+ this.gcps = new CctvGcpsResource(t);
2125
+ this.hotlist = new CctvHotlistResource(t);
2126
+ }
2127
+ t;
2128
+ bookmarks;
2129
+ gcps;
2130
+ hotlist;
2131
+ streamsPage(opts = {}) {
2132
+ return this.t.request("GET", "/api/v1/cctv/streams/page", { params: opts });
2133
+ }
2134
+ detections(streamId, opts = {}) {
2135
+ return this.t.request("GET", `/api/v1/cctv/streams/${streamId}/detections`, { params: opts });
2136
+ }
2137
+ detectorClasses() {
2138
+ return this.t.request("GET", "/api/v1/cctv/detector/classes");
2139
+ }
2140
+ presets() {
2141
+ return this.t.request("GET", "/api/v1/cctv/presets");
2142
+ }
2143
+ bridgeBackfill() {
2144
+ return this.t.request("POST", "/api/v1/cctv/bridge/backfill");
2145
+ }
2146
+ /** 202 — returns a provider job to poll. */
2147
+ detectNow(streamId, opts = {}) {
2148
+ return this.t.request("POST", `/api/v1/cctv/streams/${streamId}/detect-now`, { json: opts });
2149
+ }
2150
+ /** 202 — export job; poll with `exportStatus`. */
2151
+ exportClip(streamId, opts = {}) {
2152
+ return this.t.request("POST", `/api/v1/cctv/streams/${streamId}/export`, { json: opts });
2153
+ }
2154
+ exportStatus(jobId) {
2155
+ return this.t.request("GET", `/api/v1/cctv/exports/${jobId}`);
2156
+ }
2157
+ recordings(streamId, opts = {}) {
2158
+ return this.t.request("GET", `/api/v1/cctv/streams/${streamId}/recordings`, { params: opts });
2159
+ }
2160
+ recordingStatus(streamId) {
2161
+ return this.t.request("GET", `/api/v1/cctv/streams/${streamId}/recording`);
2162
+ }
2163
+ /** action ∈ start|stop */
2164
+ recordingControl(streamId, action, cadence) {
2165
+ return this.t.request("POST", `/api/v1/cctv/streams/${streamId}/recording`, {
2166
+ json: { action, cadence }
2167
+ });
2168
+ }
2169
+ /** Returns the raw HLS VOD playlist text (m3u8), not JSON. */
2170
+ recordingsPlaylist(streamId, opts = {}) {
2171
+ return this.t.request("GET", `/api/v1/cctv/streams/${streamId}/recordings/playlist.m3u8`, {
2172
+ params: opts
2173
+ });
2174
+ }
2175
+ };
2176
+ var EdgeResource = class {
2177
+ constructor(t) {
2178
+ this.t = t;
2179
+ }
2180
+ t;
2181
+ /**
2182
+ * Issue a single-use pairing code (short TTL). The plaintext `code` appears
2183
+ * ONLY in this response (hash at rest).
2184
+ *
2185
+ * `grants` GRANTS gestures to whichever device redeems the code (allowlist;
2186
+ * today `["retry"]`, so a desk app can ask the station to reconnect a
2187
+ * number). Empty — the default — is **read only**: least privilege, and
2188
+ * granting has to be a choice. The grant travels from the code to the node
2189
+ * and dies with it on `revoke`.
2190
+ *
2191
+ * Even when granted, the device never receives the gesture's ADDRESS
2192
+ * (`agent_id`/`skill_key`): it sends the verb and the server routes it.
2193
+ * Perm: `connectors.manage`.
2194
+ */
2195
+ createPairingCode(opts = {}) {
2196
+ return this.t.request("POST", "/api/v1/edge/pairing-codes", { json: opts });
2197
+ }
2198
+ /** Nodes carry an additive `kind` field — see {@link EdgeNode}. */
2199
+ listNodes() {
2200
+ return this.t.request("GET", "/api/v1/edge/nodes");
2201
+ }
2202
+ listDiscovered() {
2203
+ return this.t.request("GET", "/api/v1/edge/discovered");
2204
+ }
2205
+ revoke(edgeId) {
2206
+ return this.t.request("POST", `/api/v1/edge/${edgeId}/revoke`);
2207
+ }
2208
+ setExpectedVersion(version) {
2209
+ return this.t.request("PUT", "/api/v1/edge/expected-version", { json: { version } });
2210
+ }
2211
+ getExpectedVersion() {
2212
+ return this.t.request("GET", "/api/v1/edge/expected-version");
2213
+ }
2214
+ };
2215
+ var VideoStreamsResource = class {
2216
+ constructor(t) {
2217
+ this.t = t;
2218
+ }
2219
+ t;
2220
+ list() {
2221
+ return this.t.request("GET", "/video/streams");
2222
+ }
2223
+ create(input) {
2224
+ return this.t.request("POST", "/video/streams", { json: input });
2225
+ }
2226
+ delete(streamId) {
2227
+ return this.t.request("DELETE", `/video/streams/${streamId}`);
2228
+ }
2229
+ };
2230
+ var VideoResource = class {
2231
+ constructor(t) {
2232
+ this.t = t;
2233
+ this.streams = new VideoStreamsResource(t);
2234
+ }
2235
+ t;
2236
+ streams;
2237
+ listDetections(streamId, opts = {}) {
2238
+ return this.t.request("GET", "/video/detections", {
2239
+ params: { stream_id: streamId, ...opts }
2240
+ });
2241
+ }
2242
+ submitDetection(detection) {
2243
+ return this.t.request("POST", "/video/detections", { json: detection });
2244
+ }
2245
+ listTags(streamId) {
2246
+ return this.t.request("GET", "/video/tags", { params: { stream_id: streamId } });
2247
+ }
2248
+ submitTag(tag) {
2249
+ return this.t.request("POST", "/video/tags", { json: tag });
2250
+ }
2251
+ soakHeatmap(streamId, from, to, precision) {
2252
+ return this.t.request("GET", "/video/soak", {
2253
+ params: { stream_id: streamId, from, to, precision }
2254
+ });
2255
+ }
2256
+ createExport(streamId, frameRange, redactions) {
2257
+ return this.t.request("POST", "/video/exports", {
2258
+ json: { stream_id: streamId, frame_range: frameRange, redactions }
2259
+ });
2260
+ }
2261
+ getExport(exportId) {
2262
+ return this.t.request("GET", `/video/exports/${exportId}`);
2263
+ }
2264
+ };
2265
+ var ComunicadosResource = class {
2266
+ constructor(t) {
2267
+ this.t = t;
2268
+ }
2269
+ t;
2270
+ list(opts = {}) {
2271
+ return this.t.request("GET", "/platform/v23/comunicados", { params: opts });
2272
+ }
2273
+ listActive() {
2274
+ return this.t.request("GET", "/platform/v23/comunicados/active");
2275
+ }
2276
+ create(input) {
2277
+ return this.t.request("POST", "/platform/v23/comunicados", { json: input });
2278
+ }
2279
+ /** Sparse patch — only provided keys are sent. */
2280
+ patch(comunicadoId, patch) {
2281
+ const body = Object.fromEntries(Object.entries(patch).filter(([, v]) => v !== void 0));
2282
+ return this.t.request("PATCH", `/platform/v23/comunicados/${comunicadoId}`, { json: body });
2283
+ }
2284
+ /** Soft delete. */
2285
+ delete(comunicadoId) {
2286
+ return this.t.request("DELETE", `/platform/v23/comunicados/${comunicadoId}`);
2287
+ }
2288
+ /** Idempotent per-user dismissal. */
2289
+ dismissMe(comunicadoId) {
2290
+ return this.t.request("POST", `/platform/v23/comunicados/${comunicadoId}/dismiss/me`, {
2291
+ json: {}
2292
+ });
2293
+ }
2294
+ };
2295
+ var CampaignBriefingResource = class {
2296
+ constructor(t) {
2297
+ this.t = t;
2298
+ }
2299
+ t;
2300
+ refresh(opts = {}) {
2301
+ return this.t.request("POST", "/campaign/home-briefing/refresh", {
2302
+ json: { default_modo_inicial: "B", ...opts }
2303
+ });
2304
+ }
2305
+ get(candidatoSlug, includeHeadline) {
2306
+ return this.t.request("GET", "/campaign/home-briefing", {
2307
+ params: {
2308
+ candidato_slug: candidatoSlug,
2309
+ include_headline: includeHeadline === void 0 ? void 0 : String(includeHeadline)
2310
+ }
2311
+ });
2312
+ }
2313
+ /** 409 when the briefing is in crisis mode. */
2314
+ regenerateHeadline(candidatoSlug) {
2315
+ return this.t.request("POST", "/campaign/home-briefing/headline/regenerate", {
2316
+ json: { candidato_slug: candidatoSlug }
2317
+ });
2318
+ }
2319
+ /** duration_hours ∈ 1..168 (default 24). */
2320
+ overrideModo(candidatoSlug, novoModo, durationHours = 24) {
2321
+ return this.t.request("POST", "/campaign/home-briefing/modo/override", {
2322
+ json: { candidato_slug: candidatoSlug, novo_modo: novoModo, duration_hours: durationHours }
2323
+ });
2324
+ }
2325
+ };
2326
+ var CampaignResource = class {
2327
+ briefing;
2328
+ constructor(t) {
2329
+ this.briefing = new CampaignBriefingResource(t);
2330
+ }
2331
+ };
2332
+
2333
+ // src/resources/collab.ts
2334
+ var FormsResource = class {
2335
+ constructor(t) {
2336
+ this.t = t;
2337
+ }
2338
+ t;
2339
+ submit(formKey, payload, opts = {}) {
2340
+ return this.t.request("POST", "/platform/v23/forms/submit", {
2341
+ json: {
2342
+ form_key: formKey,
2343
+ payload,
2344
+ visibility_policy: opts.visibility_policy ?? "requires_auth",
2345
+ ...opts
2346
+ }
2347
+ });
2348
+ }
2349
+ listSubmissions(opts = {}) {
2350
+ return this.t.request("GET", "/platform/v23/forms/submissions", { params: opts });
2351
+ }
2352
+ };
2353
+ var AppShellSection = class {
2354
+ constructor(t, path) {
2355
+ this.t = t;
2356
+ this.path = path;
2357
+ }
2358
+ t;
2359
+ path;
2360
+ get() {
2361
+ return this.t.request("GET", this.path);
2362
+ }
2363
+ put(value) {
2364
+ return this.t.request("PUT", this.path, { json: value });
2365
+ }
2366
+ };
2367
+ var AppShellResource = class {
2368
+ constructor(t) {
2369
+ this.t = t;
2370
+ this.banner = new AppShellSection(t, "/platform/v23/app-shell/banner");
2371
+ this.footer = new AppShellSection(t, "/platform/v23/app-shell/footer");
2372
+ this.userMenu = new AppShellSection(t, "/platform/v23/app-shell/user-menu");
2373
+ this.sidenav = new AppShellSection(t, "/platform/v23/app-shell/sidenav");
2374
+ this.homepage = new AppShellSection(t, "/platform/v23/app-shell/homepage");
2375
+ }
2376
+ t;
2377
+ banner;
2378
+ footer;
2379
+ userMenu;
2380
+ sidenav;
2381
+ homepage;
2382
+ getMe() {
2383
+ return this.t.request("GET", "/platform/v23/app-shell/me");
2384
+ }
2385
+ putMe(config) {
2386
+ return this.t.request("PUT", "/platform/v23/app-shell/me", { json: config });
2387
+ }
2388
+ getTenant() {
2389
+ return this.t.request("GET", "/platform/v23/app-shell/tenant");
2390
+ }
2391
+ putTenant(config) {
2392
+ return this.t.request("PUT", "/platform/v23/app-shell/tenant", { json: config });
2393
+ }
2394
+ };
2395
+ var ProjectConstraintsResource = class {
2396
+ constructor(t) {
2397
+ this.t = t;
2398
+ }
2399
+ t;
2400
+ get(projectId) {
2401
+ return this.t.request("GET", `/projects/${projectId}/constraints`);
2402
+ }
2403
+ put(projectId, opts = {}) {
2404
+ return this.t.request("PUT", `/projects/${projectId}/constraints`, {
2405
+ json: { mode: opts.mode ?? "none", ...opts }
2406
+ });
2407
+ }
2408
+ clear(projectId) {
2409
+ return this.t.request("DELETE", `/projects/${projectId}/constraints`);
2410
+ }
2411
+ /** Report-only — deletes nothing. */
2412
+ revalidate(projectId) {
2413
+ return this.t.request("POST", `/projects/${projectId}/constraints/revalidate`);
2414
+ }
2415
+ };
2416
+ var ProjectsResource = class {
2417
+ constructor(t) {
2418
+ this.t = t;
2419
+ this.constraints = new ProjectConstraintsResource(t);
2420
+ }
2421
+ t;
2422
+ constraints;
2423
+ /** `spaceId: null` removes the project from its Space. */
2424
+ move(projectId, spaceId) {
2425
+ return this.t.request("PATCH", `/projects/${projectId}/move`, {
2426
+ json: { space_id: spaceId }
2427
+ });
2428
+ }
2429
+ };
2430
+ var OrganizationsResource = class {
2431
+ constructor(t) {
2432
+ this.t = t;
2433
+ }
2434
+ t;
2435
+ list(opts = {}) {
2436
+ return this.t.request("GET", "/organizations", { params: opts });
2437
+ }
2438
+ get(organizationId) {
2439
+ return this.t.request("GET", `/organizations/${organizationId}`);
2440
+ }
2441
+ listGuests(organizationId, includeRevoked = false) {
2442
+ return this.t.request("GET", `/organizations/${organizationId}/guests`, {
2443
+ params: { include_revoked: includeRevoked }
2444
+ });
2445
+ }
2446
+ inviteGuest(organizationId, userId, expiresAt) {
2447
+ return this.t.request("POST", `/organizations/${organizationId}/guests`, {
2448
+ json: { user_id: userId, expires_at: expiresAt }
2449
+ });
2450
+ }
2451
+ revokeGuest(organizationId, userId) {
2452
+ return this.t.request("DELETE", `/organizations/${organizationId}/guests/${userId}`);
2453
+ }
2454
+ };
2455
+ var SpacesResource = class {
2456
+ constructor(t) {
2457
+ this.t = t;
2458
+ }
2459
+ t;
2460
+ list(opts = {}) {
2461
+ return this.t.request("GET", "/spaces", { params: opts });
2462
+ }
2463
+ get(spaceId) {
2464
+ return this.t.request("GET", `/spaces/${spaceId}`);
2465
+ }
2466
+ create(slug, displayName, description) {
2467
+ return this.t.request("POST", "/spaces", {
2468
+ json: { slug, display_name: displayName, description }
2469
+ });
2470
+ }
2471
+ update(spaceId, patch) {
2472
+ return this.t.request("PATCH", `/spaces/${spaceId}`, { json: patch });
2473
+ }
2474
+ addOrganization(spaceId, tenantId) {
2475
+ return this.t.request("POST", `/spaces/${spaceId}/organizations`, {
2476
+ json: { tenant_id: tenantId }
2477
+ });
2478
+ }
2479
+ removeOrganization(spaceId, tenantId) {
2480
+ return this.t.request("DELETE", `/spaces/${spaceId}/organizations/${tenantId}`);
2481
+ }
2482
+ };
2483
+ var SolutionsResource = class {
2484
+ constructor(t) {
2485
+ this.t = t;
2486
+ }
2487
+ t;
2488
+ design(problem, opts = {}) {
2489
+ return this.t.request("POST", "/platform/v23/solutions/design", {
2490
+ json: { problem, ...opts }
2491
+ });
2492
+ }
2493
+ /** Accept-flags travel nested under `accept`; blueprint/diagram_id/app_id/linked_sources stay top-level. */
2494
+ materialize(blueprint, accept = {}, opts = {}) {
2495
+ return this.t.request("POST", "/platform/v23/solutions/materialize", {
2496
+ json: { blueprint, accept, ...opts }
2497
+ });
2498
+ }
2499
+ /** depth ∈ lean|full */
2500
+ designGraph(problem, opts = {}) {
2501
+ return this.t.request("POST", "/platform/v23/solutions/design-graph", {
2502
+ json: { problem, depth: opts.depth ?? "lean", wizard: opts.wizard }
2503
+ });
2504
+ }
2505
+ mergeGraph(currentGraph, baseBlueprint, incomingBlueprint) {
2506
+ return this.t.request("POST", "/platform/v23/solutions/merge-graph", {
2507
+ json: {
2508
+ current_graph: currentGraph,
2509
+ base_blueprint: baseBlueprint,
2510
+ incoming_blueprint: incomingBlueprint
2511
+ }
2512
+ });
2513
+ }
2514
+ listPatterns() {
2515
+ return this.t.request("GET", "/platform/v23/solutions/patterns");
2516
+ }
2517
+ listDiagrams(opts = {}) {
2518
+ return this.t.request("GET", "/platform/v23/solutions/diagrams", { params: opts });
2519
+ }
2520
+ get(diagramId) {
2521
+ return this.t.request("GET", `/platform/v23/solutions/diagrams/${diagramId}`);
2522
+ }
2523
+ create(input) {
2524
+ return this.t.request("POST", "/platform/v23/solutions/diagrams", { json: input });
2525
+ }
2526
+ /** Save == publish. */
2527
+ save(diagramId, input) {
2528
+ return this.t.request("PATCH", `/platform/v23/solutions/diagrams/${diagramId}`, {
2529
+ json: input
2530
+ });
2531
+ }
2532
+ delete(diagramId) {
2533
+ return this.t.request("DELETE", `/platform/v23/solutions/diagrams/${diagramId}`);
2534
+ }
2535
+ versions(diagramId) {
2536
+ return this.t.request("GET", `/platform/v23/solutions/diagrams/${diagramId}/versions`);
2537
+ }
2538
+ walkthrough(diagramId) {
2539
+ return this.t.request("POST", `/platform/v23/solutions/diagrams/${diagramId}/walkthrough`, {
2540
+ json: {}
2541
+ });
2542
+ }
2543
+ implementations(graph, nodeId, opts = {}) {
2544
+ return this.t.request("POST", "/platform/v23/solutions/implementations", {
2545
+ json: { graph, node_id: nodeId, problem: opts.problem ?? "", wizard: opts.wizard }
2546
+ });
2547
+ }
2548
+ expandNode(graph, nodeId, planId, wizard) {
2549
+ return this.t.request("POST", "/platform/v23/solutions/expand-node", {
2550
+ json: { graph, node_id: nodeId, plan_id: planId, wizard }
2551
+ });
2552
+ }
2553
+ ontologyModel(prompt) {
2554
+ return this.t.request("POST", "/platform/v23/solutions/ontology-model", { json: { prompt } });
2555
+ }
2556
+ fromLineage(events) {
2557
+ return this.t.request("POST", "/platform/v23/solutions/from-lineage", {
2558
+ json: events ? { events } : {}
2559
+ });
2560
+ }
2561
+ teardownPlan(appId) {
2562
+ return this.t.request("GET", `/workshop/apps/${appId}/teardown-plan`);
2563
+ }
2564
+ teardown(appId) {
2565
+ return this.t.request("DELETE", `/workshop/apps/${appId}`, {
2566
+ params: { teardown_build: "true" }
2567
+ });
2568
+ }
2569
+ marketplaceListings(opts = {}) {
2570
+ return this.t.request("GET", "/solutions/marketplace/listings", {
2571
+ params: { status: opts.status ?? "published", q: opts.q, tag: opts.tag, category: opts.category }
2572
+ });
2573
+ }
2574
+ marketplaceDetail(listingId) {
2575
+ return this.t.request("GET", `/solutions/marketplace/listings/${listingId}`);
2576
+ }
2577
+ marketplacePublish(diagramId, opts = {}) {
2578
+ return this.t.request("POST", "/solutions/marketplace/listings", {
2579
+ json: { diagram_id: diagramId, category: opts.category ?? "", ...opts }
2580
+ });
2581
+ }
2582
+ /** Re-materializes the listing in the caller's tenant. */
2583
+ marketplaceInstall(listingId) {
2584
+ return this.t.request("POST", `/solutions/marketplace/listings/${listingId}/install`);
2585
+ }
2586
+ marketplacePatch(listingId, fields) {
2587
+ return this.t.request("PATCH", `/solutions/marketplace/listings/${listingId}`, {
2588
+ json: fields
2589
+ });
2590
+ }
2591
+ };
2592
+
2593
+ // src/resources/workspaces.ts
2594
+ var WorkspaceVersionsResource = class {
2595
+ constructor(t) {
2596
+ this.t = t;
2597
+ }
2598
+ t;
2599
+ list(workspaceId) {
2600
+ return this.t.request("GET", `/workspaces/${workspaceId}/versions`);
2601
+ }
2602
+ get(workspaceId, versionNumber) {
2603
+ return this.t.request("GET", `/workspaces/${workspaceId}/versions/${versionNumber}`);
2604
+ }
2605
+ republish(workspaceId, versionNumber, message) {
2606
+ return this.t.request(
2607
+ "POST",
2608
+ `/workspaces/${workspaceId}/versions/${versionNumber}/republish`,
2609
+ { json: message ? { message } : {} }
2610
+ );
2611
+ }
2612
+ };
2613
+ var WorkspacesResource = class {
2614
+ constructor(t) {
2615
+ this.t = t;
2616
+ this.versions = new WorkspaceVersionsResource(t);
2617
+ }
2618
+ t;
2619
+ versions;
2620
+ list(opts = {}) {
2621
+ return this.t.request("GET", "/workspaces", { params: opts });
2622
+ }
2623
+ get(workspaceId) {
2624
+ return this.t.request("GET", `/workspaces/${workspaceId}`);
2625
+ }
2626
+ create(input) {
2627
+ return this.t.request("POST", "/workspaces", { json: input });
2628
+ }
2629
+ /** Save == immediate publish — bumps version + snapshot. */
2630
+ publish(workspaceId, config, message) {
2631
+ return this.t.request("PATCH", `/workspaces/${workspaceId}`, { json: { config, message } });
2632
+ }
2633
+ /** Soft delete (`active=false`). */
2634
+ delete(workspaceId) {
2635
+ return this.t.request("DELETE", `/workspaces/${workspaceId}`);
2636
+ }
2637
+ getNavigation(workspaceId) {
2638
+ return this.t.request("GET", `/workspaces/${workspaceId}/navigation`);
2639
+ }
2640
+ setNavigation(workspaceId, opts = {}) {
2641
+ return this.t.request("PUT", `/workspaces/${workspaceId}/navigation`, {
2642
+ json: { navigate_out_allowed: opts.navigate_out_allowed ?? true, ...opts }
2643
+ });
2644
+ }
2645
+ listPromotions(workspaceId) {
2646
+ return this.t.request("GET", `/workspaces/${workspaceId}/promotions`);
2647
+ }
2648
+ /** Idempotent. */
2649
+ promote(workspaceId, organizationId, ordering = 0) {
2650
+ return this.t.request("POST", `/workspaces/${workspaceId}/promotions`, {
2651
+ json: { organization_id: organizationId, ordering }
2652
+ });
2653
+ }
2654
+ unpromote(workspaceId, organizationId) {
2655
+ return this.t.request("DELETE", `/workspaces/${workspaceId}/promotions/${organizationId}`);
2656
+ }
2657
+ listPromotedForOrganization(organizationId) {
2658
+ return this.t.request("GET", `/organizations/${organizationId}/promoted-workspaces`);
2659
+ }
2660
+ getKiosk(workspaceId) {
2661
+ return this.t.request("GET", `/workspaces/${workspaceId}/kiosk`);
2662
+ }
2663
+ setKiosk(workspaceId, opts = {}) {
2664
+ return this.t.request("PUT", `/workspaces/${workspaceId}/kiosk`, {
2665
+ json: {
2666
+ hide_chrome: opts.hide_chrome ?? true,
2667
+ allow_exit: opts.allow_exit ?? true,
2668
+ auto_fullscreen: opts.auto_fullscreen ?? true,
2669
+ message: opts.message
2670
+ }
2671
+ });
2672
+ }
2673
+ startKioskSession(workspaceId, clientInfo) {
2674
+ return this.t.request("POST", `/workspaces/${workspaceId}/kiosk/sessions`, {
2675
+ json: clientInfo ? { client_info: clientInfo } : {}
2676
+ });
2677
+ }
2678
+ endKioskSession(workspaceId, sessionId) {
2679
+ return this.t.request("POST", `/workspaces/${workspaceId}/kiosk/sessions/${sessionId}/end`);
2680
+ }
2681
+ listKioskSessions(workspaceId, opts = {}) {
2682
+ return this.t.request("GET", `/workspaces/${workspaceId}/kiosk/sessions`, { params: opts });
2683
+ }
2684
+ };
2685
+ var WorkspaceUpdatesResource = class {
2686
+ constructor(t) {
2687
+ this.t = t;
2688
+ }
2689
+ t;
2690
+ list(workspaceId, includeArchived = false) {
2691
+ return this.t.request("GET", `/workspaces/${workspaceId}/updates`, {
2692
+ params: { include_archived: includeArchived }
2693
+ });
2694
+ }
2695
+ /** Active updates not yet seen by the caller. */
2696
+ listUnseen(workspaceId) {
2697
+ return this.t.request("GET", `/workspaces/${workspaceId}/updates/unseen`);
2698
+ }
2699
+ get(workspaceId, updateId) {
2700
+ return this.t.request("GET", `/workspaces/${workspaceId}/updates/${updateId}`);
2701
+ }
2702
+ create(workspaceId, input) {
2703
+ return this.t.request("POST", `/workspaces/${workspaceId}/updates`, { json: input });
2704
+ }
2705
+ patch(workspaceId, updateId, patch) {
2706
+ return this.t.request("PATCH", `/workspaces/${workspaceId}/updates/${updateId}`, {
2707
+ json: patch
2708
+ });
2709
+ }
2710
+ archive(workspaceId, updateId) {
2711
+ return this.t.request("POST", `/workspaces/${workspaceId}/updates/${updateId}/archive`);
2712
+ }
2713
+ /** Hard delete — cascades pages + views. */
2714
+ delete(workspaceId, updateId) {
2715
+ return this.t.request("DELETE", `/workspaces/${workspaceId}/updates/${updateId}`);
2716
+ }
2717
+ markSeen(workspaceId, updateId, dismissed = false) {
2718
+ return this.t.request("POST", `/workspaces/${workspaceId}/updates/${updateId}/seen`, {
2719
+ json: { dismissed }
2720
+ });
2721
+ }
2722
+ };
2723
+
2724
+ // src/resources/platformVersions.ts
2725
+ var V22ActionLogResource = class {
2726
+ constructor(t) {
2727
+ this.t = t;
2728
+ }
2729
+ t;
2730
+ record(input) {
2731
+ return this.t.request("POST", "/platform/v22/action-log", { json: input });
2732
+ }
2733
+ list(opts = {}) {
2734
+ return this.t.request("GET", "/platform/v22/action-log", { params: opts });
2735
+ }
2736
+ };
2737
+ var V22NotepadResource = class {
2738
+ constructor(t) {
2739
+ this.t = t;
2740
+ }
2741
+ t;
2742
+ create(title, opts = {}) {
2743
+ return this.t.request("POST", "/platform/v22/notepad", { json: { title, ...opts } });
2744
+ }
2745
+ freeze(docId) {
2746
+ return this.t.request("POST", `/platform/v22/notepad/${docId}/freeze`);
2747
+ }
2748
+ instantiate(templateId, title, variables) {
2749
+ return this.t.request("POST", `/platform/v22/notepad/${templateId}/instantiate`, {
2750
+ json: { title, variables }
2751
+ });
2752
+ }
2753
+ };
2754
+ var V22QuiverResource = class {
2755
+ constructor(t) {
2756
+ this.t = t;
2757
+ }
2758
+ t;
2759
+ create(input) {
2760
+ return this.t.request("POST", "/platform/v22/quiver", { json: input });
2761
+ }
2762
+ render(dashId, opts = {}) {
2763
+ return this.t.request("POST", `/platform/v22/quiver/${dashId}/render`, { json: opts });
2764
+ }
2765
+ };
2766
+ var PlatformV22Resource = class {
2767
+ constructor(t) {
2768
+ this.t = t;
2769
+ this.actionLog = new V22ActionLogResource(t);
2770
+ this.notepad = new V22NotepadResource(t);
2771
+ this.quiver = new V22QuiverResource(t);
2772
+ }
2773
+ t;
2774
+ actionLog;
2775
+ notepad;
2776
+ quiver;
2777
+ /** Returns the transformed value (unwraps the response's `value` field). */
2778
+ async applyVariableTransform(kind, inputs) {
2779
+ const payload = await this.t.request("POST", "/platform/v22/variable-transforms/apply", {
2780
+ json: { kind, inputs }
2781
+ });
2782
+ return payload.value;
2783
+ }
2784
+ recordUsage(input) {
2785
+ return this.t.request("POST", "/platform/v22/ontology-usage/record", { json: input });
2786
+ }
2787
+ queryUsage(opts = {}) {
2788
+ return this.t.request("GET", "/platform/v22/ontology-usage", {
2789
+ params: { days: 30, ...opts }
2790
+ });
2791
+ }
2792
+ };
2793
+ var V23LogicResource = class {
2794
+ constructor(t) {
2795
+ this.t = t;
2796
+ }
2797
+ t;
2798
+ list() {
2799
+ return this.t.request("GET", "/platform/v23/aip-logic");
2800
+ }
2801
+ get(fid) {
2802
+ return this.t.request("GET", `/platform/v23/aip-logic/${fid}`);
2803
+ }
2804
+ create(input) {
2805
+ return this.t.request("POST", "/platform/v23/aip-logic", { json: input });
2806
+ }
2807
+ update(fid, patch) {
2808
+ return this.t.request("PUT", `/platform/v23/aip-logic/${fid}`, { json: patch });
2809
+ }
2810
+ delete(fid) {
2811
+ return this.t.request("DELETE", `/platform/v23/aip-logic/${fid}`);
2812
+ }
2813
+ invoke(fid, inputs) {
2814
+ return this.t.request("POST", `/platform/v23/aip-logic/${fid}/invoke`, {
2815
+ json: { inputs: inputs ?? {} }
2816
+ });
2817
+ }
2818
+ addTest(fid, input) {
2819
+ return this.t.request("POST", `/platform/v23/aip-logic/${fid}/tests`, { json: input });
2820
+ }
2821
+ runTest(fid, testId) {
2822
+ return this.t.request("POST", `/platform/v23/aip-logic/${fid}/tests/${testId}/run`);
2823
+ }
2824
+ };
2825
+ var V23ActionsResource = class {
2826
+ constructor(t) {
2827
+ this.t = t;
2828
+ }
2829
+ t;
2830
+ list() {
2831
+ return this.t.request("GET", "/platform/v23/action-types");
2832
+ }
2833
+ get(aid) {
2834
+ return this.t.request("GET", `/platform/v23/action-types/${aid}`);
2835
+ }
2836
+ create(input) {
2837
+ return this.t.request("POST", "/platform/v23/action-types", { json: input });
2838
+ }
2839
+ update(aid, patch) {
2840
+ return this.t.request("PUT", `/platform/v23/action-types/${aid}`, { json: patch });
2841
+ }
2842
+ delete(aid) {
2843
+ return this.t.request("DELETE", `/platform/v23/action-types/${aid}`);
2844
+ }
2845
+ execute(aid, inputs, note) {
2846
+ return this.t.request("POST", `/platform/v23/action-types/${aid}/execute`, {
2847
+ json: { input: inputs ?? {}, note }
2848
+ });
2849
+ }
2850
+ plan(steps) {
2851
+ return this.t.request("POST", "/platform/v23/action-types/plan", { json: { steps } });
2852
+ }
2853
+ executions(aid) {
2854
+ return this.t.request("GET", `/platform/v23/action-types/${aid}/executions`);
2855
+ }
2856
+ };
2857
+ var V23AssistResource = class {
2858
+ constructor(t) {
2859
+ this.t = t;
2860
+ }
2861
+ t;
2862
+ list(opts = {}) {
2863
+ return this.t.request("GET", "/platform/v23/aip-assist", { params: opts });
2864
+ }
2865
+ create(input) {
2866
+ return this.t.request("POST", "/platform/v23/aip-assist", { json: input });
2867
+ }
2868
+ delete(cid) {
2869
+ return this.t.request("DELETE", `/platform/v23/aip-assist/${cid}`);
2870
+ }
2871
+ suggest(input) {
2872
+ return this.t.request("POST", "/platform/v23/aip-assist/suggest", { json: input });
2873
+ }
2874
+ };
2875
+ var V23PipelineResource = class {
2876
+ constructor(t) {
2877
+ this.t = t;
2878
+ }
2879
+ t;
2880
+ list() {
2881
+ return this.t.request("GET", "/platform/v23/pipeline");
2882
+ }
2883
+ create(input) {
2884
+ return this.t.request("POST", "/platform/v23/pipeline", { json: input });
2885
+ }
2886
+ update(pid, patch) {
2887
+ return this.t.request("PUT", `/platform/v23/pipeline/${pid}`, { json: patch });
2888
+ }
2889
+ delete(pid) {
2890
+ return this.t.request("DELETE", `/platform/v23/pipeline/${pid}`);
2891
+ }
2892
+ run(pid, opts = {}) {
2893
+ return this.t.request("POST", `/platform/v23/pipeline/${pid}/run`, { json: opts });
2894
+ }
2895
+ runs(pid, limit = 50) {
2896
+ return this.t.request("GET", `/platform/v23/pipeline/${pid}/runs`, { params: { limit } });
2897
+ }
2898
+ };
2899
+ var V23StylesBrandResource = class {
2900
+ constructor(t) {
2901
+ this.t = t;
2902
+ }
2903
+ t;
2904
+ get() {
2905
+ return this.t.request("GET", "/platform/v23/styles/brand");
2906
+ }
2907
+ update(patch) {
2908
+ return this.t.request("PUT", "/platform/v23/styles/brand", { json: patch });
2909
+ }
2910
+ /** Unauthenticated-safe read. */
2911
+ getPublic(tenant) {
2912
+ return this.t.request("GET", "/platform/v23/styles/brand/public", { params: { tenant } });
2913
+ }
2914
+ };
2915
+ var V23StylesResource = class {
2916
+ constructor(t) {
2917
+ this.t = t;
2918
+ this.brand = new V23StylesBrandResource(t);
2919
+ }
2920
+ t;
2921
+ brand;
2922
+ get() {
2923
+ return this.t.request("GET", "/platform/v23/styles");
2924
+ }
2925
+ update(tokens, message) {
2926
+ return this.t.request("PUT", "/platform/v23/styles", { json: { tokens, message } });
2927
+ }
2928
+ getRegionColors() {
2929
+ return this.t.request("GET", "/platform/v23/styles/region-colors");
2930
+ }
2931
+ updateRegionColors(patch) {
2932
+ return this.t.request("PUT", "/platform/v23/styles/region-colors", { json: patch });
2933
+ }
2934
+ /** Multipart upload (the only non-JSON write in the v2x surfaces). */
2935
+ uploadLogo(file, filename = "logo.png") {
2936
+ const form = new FormData();
2937
+ form.append("file", file, filename);
2938
+ return this.t.request("POST", "/platform/v23/styles/upload/logo", { form });
2939
+ }
2940
+ };
2941
+ function crudFactory(t, base) {
2942
+ return {
2943
+ list: () => t.request("GET", base),
2944
+ create: (input) => t.request("POST", base, { json: input }),
2945
+ delete: (id) => t.request("DELETE", `${base}/${id}`)
2946
+ };
2947
+ }
2948
+ var PlatformV23Resource = class {
2949
+ constructor(t) {
2950
+ this.t = t;
2951
+ this.logic = new V23LogicResource(t);
2952
+ this.actions = new V23ActionsResource(t);
2953
+ this.assist = new V23AssistResource(t);
2954
+ this.pipeline = new V23PipelineResource(t);
2955
+ this.styles = new V23StylesResource(t);
2956
+ const quiverBase = "/platform/v23/quiver";
2957
+ this.quiver = {
2958
+ ...crudFactory(t, quiverBase),
2959
+ update: (id, patch) => t.request("PUT", `${quiverBase}/${id}`, { json: patch }),
2960
+ run: (id) => t.request("POST", `${quiverBase}/${id}/run`)
2961
+ };
2962
+ const connectorsBase = "/platform/v23/connectors";
2963
+ this.connectors = {
2964
+ list: () => t.request("GET", connectorsBase),
2965
+ register: (input) => t.request("POST", connectorsBase, { json: input }),
2966
+ delete: (id) => t.request("DELETE", `${connectorsBase}/${id}`),
2967
+ heartbeat: (id, status = "connected", error) => t.request("POST", `${connectorsBase}/${id}/heartbeat`, { json: { status, error } })
2968
+ };
2969
+ const automateBase = "/platform/v23/automate";
2970
+ this.automate = {
2971
+ ...crudFactory(t, automateBase),
2972
+ fire: (id) => t.request("POST", `${automateBase}/${id}/fire`),
2973
+ runs: (id) => t.request("GET", `${automateBase}/${id}/runs`)
2974
+ };
2975
+ const healthBase = "/platform/v23/health";
2976
+ this.health = {
2977
+ ...crudFactory(t, healthBase),
2978
+ run: (id) => t.request("POST", `${healthBase}/${id}/run`)
2979
+ };
2980
+ const contourBase = "/platform/v23/contour";
2981
+ this.contour = {
2982
+ ...crudFactory(t, contourBase),
2983
+ evaluate: (id, limit = 50) => t.request("POST", `${contourBase}/${id}/evaluate`, { json: { limit } })
2984
+ };
2985
+ this.vertex = crudFactory(t, "/platform/v23/vertex");
2986
+ const reposBase = "/platform/v23/repos";
2987
+ this.repos = {
2988
+ ...crudFactory(t, reposBase),
2989
+ commit: (id, input) => t.request("POST", `${reposBase}/${id}/commits`, { json: input }),
2990
+ commits: (id, branch) => t.request("GET", `${reposBase}/${id}/commits`, { params: { branch } }),
2991
+ show: (id, commitId) => t.request("GET", `${reposBase}/${id}/commits/${commitId}`)
2992
+ };
2993
+ const objectSetsBase = "/platform/v23/object-sets";
2994
+ this.objectSets = {
2995
+ ...crudFactory(t, objectSetsBase),
2996
+ materialize: (id, limit = 200) => t.request("POST", `${objectSetsBase}/${id}/materialize`, { json: { limit } })
2997
+ };
2998
+ }
2999
+ t;
3000
+ logic;
3001
+ actions;
3002
+ assist;
3003
+ pipeline;
3004
+ styles;
3005
+ quiver;
3006
+ connectors;
3007
+ automate;
3008
+ health;
3009
+ contour;
3010
+ vertex;
3011
+ repos;
3012
+ objectSets;
3013
+ carbonValidate(config) {
3014
+ return this.t.request("POST", "/platform/v23/carbon/validate", { json: config });
3015
+ }
3016
+ catalog() {
3017
+ return this.t.request("GET", "/platform/v23");
3018
+ }
3019
+ };
3020
+ var MarketplaceResource = class {
3021
+ constructor(t) {
3022
+ this.t = t;
3023
+ }
3024
+ t;
3025
+ storefront(opts = {}) {
3026
+ return this.t.request("GET", "/platform/v23/marketplace", {
3027
+ params: { sort: opts.sort ?? "popular", category: opts.category, search: opts.search, tags: opts.tags }
3028
+ });
3029
+ }
3030
+ products(publishedOnly = false) {
3031
+ return this.t.request("GET", "/platform/v23/marketplace/products", {
3032
+ params: { published_only: publishedOnly }
3033
+ });
3034
+ }
3035
+ create(input) {
3036
+ return this.t.request("POST", "/platform/v23/marketplace/products", { json: input });
3037
+ }
3038
+ publish(pid) {
3039
+ return this.t.request("POST", `/platform/v23/marketplace/products/${pid}/publish`);
3040
+ }
3041
+ details(pid) {
3042
+ return this.t.request("GET", `/platform/v23/marketplace/${pid}`);
3043
+ }
3044
+ ontologyImpact(pid) {
3045
+ return this.t.request("GET", `/platform/v23/marketplace/${pid}/ontology-impact`);
3046
+ }
3047
+ installPrecheck(pid) {
3048
+ return this.t.request("GET", `/platform/v23/marketplace/${pid}/install-precheck`);
3049
+ }
3050
+ /** 422 with `{ok:false, gaps}` in the error payload when modules are missing. */
3051
+ install(pid, opts = {}) {
3052
+ return this.t.request("POST", `/platform/v23/marketplace/${pid}/install`, {
3053
+ json: { confirm_text: opts.confirm_text ?? "instalar", config: opts.config, notes: opts.notes }
3054
+ });
3055
+ }
3056
+ installed() {
3057
+ return this.t.request("GET", "/platform/v23/marketplace/installed");
3058
+ }
3059
+ uninstall(installId) {
3060
+ return this.t.request("POST", `/platform/v23/marketplace/installs/${installId}/uninstall`);
3061
+ }
3062
+ /** Admin, idempotent. */
3063
+ seed() {
3064
+ return this.t.request("POST", "/platform/v23/marketplace/seed");
3065
+ }
3066
+ };
3067
+ var PlatformV24Resource = class {
3068
+ constructor(t) {
3069
+ this.t = t;
3070
+ }
3071
+ t;
3072
+ createLogicFunction(input) {
3073
+ return this.t.request("POST", "/platform/v24/logic/functions", { json: input });
3074
+ }
3075
+ listLogicFunctions() {
3076
+ return this.t.request("GET", "/platform/v24/logic/functions");
3077
+ }
3078
+ invokeLogicFunction(fnId, inputs) {
3079
+ return this.t.request("POST", `/platform/v24/logic/functions/${fnId}/invoke`, {
3080
+ json: { inputs }
3081
+ });
3082
+ }
3083
+ openAssistSession(surface, context) {
3084
+ return this.t.request("POST", "/platform/v24/assist/sessions", {
3085
+ json: { surface, context }
3086
+ });
3087
+ }
3088
+ assistTurn(sessionId, content) {
3089
+ return this.t.request("POST", `/platform/v24/assist/sessions/${sessionId}/turn`, {
3090
+ json: { content }
3091
+ });
3092
+ }
3093
+ createView(input) {
3094
+ return this.t.request("POST", "/platform/v24/views", { json: input });
3095
+ }
3096
+ materializeView(viewId) {
3097
+ return this.t.request("POST", `/platform/v24/views/${viewId}/materialize`);
3098
+ }
3099
+ listTemplates() {
3100
+ return this.t.request("GET", "/platform/v24/marketplace/templates");
3101
+ }
3102
+ installTemplate(templateId, config) {
3103
+ return this.t.request("POST", "/platform/v24/marketplace/install", {
3104
+ json: { template_id: templateId, config }
3105
+ });
3106
+ }
3107
+ createRule(input) {
3108
+ return this.t.request("POST", "/platform/v24/rules", { json: input });
3109
+ }
3110
+ evaluateRules(trigger, subject) {
3111
+ return this.t.request("POST", "/platform/v24/rules/evaluate", {
3112
+ json: { trigger, subject }
3113
+ });
3114
+ }
3115
+ recordCheckpoint(pipeline, step, opts = {}) {
3116
+ return this.t.request("POST", "/platform/v24/checkpoints", {
3117
+ json: { pipeline, step, status: opts.status ?? "OK", state: opts.state }
3118
+ });
3119
+ }
3120
+ resumePipeline(pipeline) {
3121
+ return this.t.request("GET", `/platform/v24/checkpoints/${pipeline}/resume`);
3122
+ }
3123
+ createExpectation(input) {
3124
+ return this.t.request("POST", "/platform/v24/expectations", { json: input });
3125
+ }
3126
+ runExpectation(expId) {
3127
+ return this.t.request("POST", `/platform/v24/expectations/${expId}/run`);
3128
+ }
3129
+ submitChangeRequest(input) {
3130
+ return this.t.request("POST", "/platform/v24/change-requests", { json: input });
3131
+ }
3132
+ reviewChangeRequest(crId, status, note) {
3133
+ return this.t.request("POST", `/platform/v24/change-requests/${crId}/review`, {
3134
+ json: { status, note }
3135
+ });
3136
+ }
3137
+ createScenario(input) {
3138
+ return this.t.request("POST", "/platform/v24/scenarios", { json: input });
3139
+ }
3140
+ simulateScenario(scenarioId) {
3141
+ return this.t.request("POST", `/platform/v24/scenarios/${scenarioId}/simulate`);
3142
+ }
3143
+ createNotebook(input) {
3144
+ return this.t.request("POST", "/platform/v24/quiver/notebooks", { json: input });
3145
+ }
3146
+ createAgent(input) {
3147
+ return this.t.request("POST", "/platform/v24/agent-studio/agents", { json: input });
3148
+ }
3149
+ createEvalDashboard(input) {
3150
+ return this.t.request("POST", "/platform/v24/eval-dashboards", { json: input });
3151
+ }
3152
+ renderEvalDashboard(dashId) {
3153
+ return this.t.request("GET", `/platform/v24/eval-dashboards/${dashId}/render`);
3154
+ }
3155
+ addVerticalTab(input) {
3156
+ return this.t.request("POST", "/platform/v24/vertical-tabs", { json: input });
3157
+ }
3158
+ createAggregation(input) {
3159
+ return this.t.request("POST", "/platform/v24/aggregations", { json: input });
3160
+ }
3161
+ runAggregation(aggId) {
3162
+ return this.t.request("POST", `/platform/v24/aggregations/${aggId}/run`);
3163
+ }
3164
+ /** Multi-hop object-set traversal (gate `workshop.apps.read`). */
3165
+ searchAround(input) {
3166
+ return this.t.request("POST", "/workshop/object-set/search-around", { json: input });
3167
+ }
3168
+ /** On-the-fly aggregation: count/sum/avg/min/max/distinct_count/cardinality. */
3169
+ aggregateObjectSet(input) {
3170
+ return this.t.request("POST", "/workshop/object-set/aggregate", { json: input });
3171
+ }
3172
+ createOsdkToken(name, scopes) {
3173
+ return this.t.request("POST", "/platform/v24/osdk-tokens", { json: { name, scopes } });
3174
+ }
3175
+ verifyOsdkToken(token) {
3176
+ return this.t.request("POST", "/platform/v24/osdk-tokens/verify", { json: { token } });
3177
+ }
3178
+ createAutomation(input) {
3179
+ return this.t.request("POST", "/platform/v24/automations", { json: input });
3180
+ }
3181
+ runAutomation(autoId) {
3182
+ return this.t.request("POST", `/platform/v24/automations/${autoId}/run`);
3183
+ }
3184
+ computeOntologyMetrics() {
3185
+ return this.t.request("POST", "/platform/v24/metrics/compute");
3186
+ }
3187
+ forkThread(parentSessionId, branchName, forkAtMessage = 0) {
3188
+ return this.t.request("POST", "/platform/v24/thread-branches", {
3189
+ json: {
3190
+ parent_session_id: parentSessionId,
3191
+ branch_name: branchName,
3192
+ fork_at_message: forkAtMessage
3193
+ }
3194
+ });
3195
+ }
3196
+ };
3197
+ var PlatformV25Resource = class {
3198
+ constructor(t) {
3199
+ this.t = t;
3200
+ }
3201
+ t;
3202
+ // machinery
3203
+ listProcesses() {
3204
+ return this.t.request("GET", "/platform/v25/machinery/processes");
3205
+ }
3206
+ createProcess(input) {
3207
+ return this.t.request("POST", "/platform/v25/machinery/processes", { json: input });
3208
+ }
3209
+ startProcessInstance(processId, opts = {}) {
3210
+ return this.t.request("POST", `/platform/v25/machinery/processes/${processId}/instances`, {
3211
+ json: opts
3212
+ });
3213
+ }
3214
+ transitionProcessInstance(instanceId, to, reason) {
3215
+ return this.t.request("POST", `/platform/v25/machinery/instances/${instanceId}/transition`, {
3216
+ json: { to, reason }
3217
+ });
3218
+ }
3219
+ // branch protection
3220
+ setBranchProtection(dataset, branch, opts = {}) {
3221
+ return this.t.request("PUT", `/platform/v25/branch-protection/${dataset}/${branch}`, {
3222
+ json: {
3223
+ require_approvals: opts.require_approvals ?? 1,
3224
+ block_direct_commit: opts.block_direct_commit ?? true,
3225
+ required_clearances: opts.required_clearances,
3226
+ required_reviewers: opts.required_reviewers
3227
+ }
3228
+ });
3229
+ }
3230
+ evaluateBranchProtection(dataset, branch, opts = {}) {
3231
+ return this.t.request("POST", "/platform/v25/branch-protection/evaluate", {
3232
+ json: { dataset, branch, ...opts }
3233
+ });
3234
+ }
3235
+ // kiosk
3236
+ mintKioskSession(appId, opts = {}) {
3237
+ return this.t.request("POST", "/platform/v25/kiosk/sessions", {
3238
+ json: {
3239
+ app_id: appId,
3240
+ display_name: opts.display_name ?? "kiosk",
3241
+ allowed_markings: opts.allowed_markings,
3242
+ ttl_hours: opts.ttl_hours ?? 24
3243
+ }
3244
+ });
3245
+ }
3246
+ verifyKioskToken(token) {
3247
+ return this.t.request("POST", "/platform/v25/kiosk/verify", { json: { token } });
3248
+ }
3249
+ // analyst threads
3250
+ newAnalystThread(title = "Analyst thread") {
3251
+ return this.t.request("POST", "/platform/v25/aip/analyst/threads", { json: { title } });
3252
+ }
3253
+ postAnalystMessage(threadId, input) {
3254
+ return this.t.request("POST", `/platform/v25/aip/analyst/threads/${threadId}/messages`, {
3255
+ json: input
3256
+ });
3257
+ }
3258
+ // dataset ops
3259
+ rollbackDataset(dataset, toAssetId, opts = {}) {
3260
+ return this.t.request("POST", `/platform/v25/datasets/${dataset}/rollback`, {
3261
+ json: { branch: opts.branch ?? "main", to_asset_id: toAssetId, reason: opts.reason ?? "" }
3262
+ });
3263
+ }
3264
+ queueSnapshot(dataset, branch = "main") {
3265
+ return this.t.request("POST", `/platform/v25/datasets/${dataset}/queue-snapshot`, {
3266
+ json: { branch }
3267
+ });
3268
+ }
3269
+ peekSnapshotQueue(dataset, branch = "main") {
3270
+ return this.t.request("GET", `/platform/v25/datasets/${dataset}/queue-snapshot`, {
3271
+ params: { branch }
3272
+ });
3273
+ }
3274
+ setTransactionLimits(dataset, opts = {}) {
3275
+ return this.t.request("PUT", `/platform/v25/datasets/${dataset}/transaction-limits`, {
3276
+ json: { branch: "main", max_rows: 0, max_bytes: 0, max_open: 0, ...opts }
3277
+ });
3278
+ }
3279
+ /** Repeated `dataset` query params. */
3280
+ checkFreshness(datasets) {
3281
+ return this.t.request("GET", "/platform/v25/workshop/widgets/data-freshness", {
3282
+ params: { dataset: datasets }
3283
+ });
3284
+ }
3285
+ // code scan
3286
+ raiseCodeScanFinding(input) {
3287
+ return this.t.request("POST", "/platform/v25/code-scan/findings", { json: input });
3288
+ }
3289
+ codeScanSummary(repoRef) {
3290
+ return this.t.request("GET", `/platform/v25/code-scan/summary/${repoRef}`);
3291
+ }
3292
+ // evals
3293
+ generateEvals(subjectFunction, opts = {}) {
3294
+ return this.t.request("POST", "/platform/v25/evals/generate", {
3295
+ json: {
3296
+ subject_function: subjectFunction,
3297
+ description: opts.description ?? "",
3298
+ count: opts.count ?? 5
3299
+ }
3300
+ });
3301
+ }
3302
+ analyzeEvals(evalRunId, failures) {
3303
+ return this.t.request("POST", "/platform/v25/evals/analyze", {
3304
+ json: { eval_run_id: evalRunId, failures }
3305
+ });
3306
+ }
3307
+ };
3308
+ var PlatformV26Resource = class {
3309
+ constructor(t) {
3310
+ this.t = t;
3311
+ }
3312
+ t;
3313
+ listPromotions() {
3314
+ return this.t.request("GET", "/platform/v26/promotions");
3315
+ }
3316
+ promoteObjectType(objectType, opts = {}) {
3317
+ return this.t.request("POST", "/platform/v26/promotions", {
3318
+ json: { object_type: objectType, status: opts.status ?? "verified", justification: opts.justification }
3319
+ });
3320
+ }
3321
+ listObjectViews(objectType) {
3322
+ return this.t.request("GET", "/platform/v26/object-views", {
3323
+ params: { object_type: objectType }
3324
+ });
3325
+ }
3326
+ createObjectView(objectType, branch, opts = {}) {
3327
+ return this.t.request("POST", "/platform/v26/object-views", {
3328
+ json: {
3329
+ object_type: objectType,
3330
+ branch,
3331
+ parent_branch: opts.parent_branch ?? "main",
3332
+ view_spec: opts.view_spec
3333
+ }
3334
+ });
3335
+ }
3336
+ publishObjectView(branchId) {
3337
+ return this.t.request("POST", `/platform/v26/object-views/${branchId}/publish`);
3338
+ }
3339
+ generateCoreView(objectType, topN = 8) {
3340
+ return this.t.request("POST", `/platform/v26/core-views/generate/${objectType}`, {
3341
+ params: { top_n: topN }
3342
+ });
3343
+ }
3344
+ getCoreView(objectType) {
3345
+ return this.t.request("GET", `/platform/v26/core-views/${objectType}`);
3346
+ }
3347
+ reserveCapacity(provider, model, opts = {}) {
3348
+ return this.t.request("POST", "/platform/v26/capacity/reservations", {
3349
+ json: { provider, model, reserved_tpm: 0, reserved_rpm: 0, ...opts }
3350
+ });
3351
+ }
3352
+ consumeCapacity(provider, model, opts = {}) {
3353
+ return this.t.request("POST", "/platform/v26/capacity/consume", {
3354
+ json: { provider, model, tokens: opts.tokens ?? 0, requests: opts.requests ?? 1 }
3355
+ });
3356
+ }
3357
+ /** Webhook listener — the secret is returned once. */
3358
+ createListener(slug, opts = {}) {
3359
+ return this.t.request("POST", "/platform/v26/listeners", {
3360
+ json: { slug, integration: opts.integration ?? "generic", ...opts }
3361
+ });
3362
+ }
3363
+ listenerEvents(listenerId) {
3364
+ return this.t.request("GET", `/platform/v26/listeners/${listenerId}/events`);
3365
+ }
3366
+ /** mode ∈ report_only|hash|redact */
3367
+ scanSensitive(payload, opts = {}) {
3368
+ return this.t.request("POST", "/platform/v26/scanner/scan", {
3369
+ json: { payload, mode: opts.mode ?? "report_only", scope: opts.scope ?? "inline", scope_ref: opts.scope_ref }
3370
+ });
3371
+ }
3372
+ scanHistory(limit = 50) {
3373
+ return this.t.request("GET", "/platform/v26/scanner/scans", { params: { limit } });
3374
+ }
3375
+ createMonitoringView(slug, displayName, opts = {}) {
3376
+ return this.t.request("POST", "/platform/v26/monitoring", {
3377
+ json: {
3378
+ slug,
3379
+ display_name: displayName,
3380
+ project_scope: opts.project_scope,
3381
+ resource_kinds: opts.resource_kinds ?? ["object_type", "action"]
3382
+ }
3383
+ });
3384
+ }
3385
+ monitoringRollup(slug) {
3386
+ return this.t.request("GET", `/platform/v26/monitoring/${slug}/rollup`);
3387
+ }
3388
+ createHealthCheck(datasetName, name, checkType, spec) {
3389
+ return this.t.request("POST", "/platform/v26/health/checks", {
3390
+ json: { dataset_name: datasetName, name, check_type: checkType, spec }
3391
+ });
3392
+ }
3393
+ runHealthCheck(checkId, branch = "main") {
3394
+ return this.t.request("POST", `/platform/v26/health/checks/${checkId}/run`, {
3395
+ params: { branch }
3396
+ });
3397
+ }
3398
+ healthRuns(checkId, limit = 50) {
3399
+ return this.t.request("GET", `/platform/v26/health/checks/${checkId}/runs`, {
3400
+ params: { limit }
3401
+ });
3402
+ }
3403
+ /** Hash-referenced version metadata — no binary body. */
3404
+ uploadMediaVersion(mediaSet, path, input) {
3405
+ return this.t.request("POST", "/platform/v26/media/upload", {
3406
+ json: { media_set: mediaSet, path, size_bytes: 0, ...input }
3407
+ });
3408
+ }
3409
+ mediaHistory(mediaSet, path) {
3410
+ return this.t.request("GET", "/platform/v26/media/items/history", {
3411
+ params: { media_set: mediaSet, path }
3412
+ });
3413
+ }
3414
+ createInsight(slug, input) {
3415
+ return this.t.request("POST", "/platform/v26/insight", { json: { slug, ...input } });
3416
+ }
3417
+ executeInsight(analysisId) {
3418
+ return this.t.request("POST", `/platform/v26/insight/${analysisId}/execute`);
3419
+ }
3420
+ createPeer(slug, displayName, remoteUrl, authToken) {
3421
+ return this.t.request("POST", "/platform/v26/peers", {
3422
+ json: { slug, display_name: displayName, remote_url: remoteUrl, auth_token: authToken }
3423
+ });
3424
+ }
3425
+ syncPeer(peerId, input) {
3426
+ return this.t.request("POST", `/platform/v26/peers/${peerId}/sync`, { json: input });
3427
+ }
3428
+ listPeerMirrors(peerId) {
3429
+ return this.t.request("GET", `/platform/v26/peers/${peerId}/mirrors`);
3430
+ }
3431
+ runHistory(opts = {}) {
3432
+ return this.t.request("GET", "/platform/v26/run-history", {
3433
+ params: { limit: 200, ...opts }
3434
+ });
3435
+ }
3436
+ };
3437
+
3438
+ // src/client.ts
3439
+ var RETRIABLE_STATUS = /* @__PURE__ */ new Set([429, 502, 503, 504]);
3440
+ function isRetriableError(err) {
3441
+ if (err instanceof AegisAPIError) return RETRIABLE_STATUS.has(err.statusCode);
3442
+ if (err instanceof TypeError) return true;
3443
+ return err instanceof Error && err.name === "TimeoutError";
3444
+ }
3445
+ function backoffDelay(attempt, base, max) {
3446
+ const exp = Math.min(max, base * 2 ** (attempt - 1));
3447
+ return exp * (0.5 + Math.random() * 0.5);
3448
+ }
3449
+ var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
3450
+ function envVar(name) {
3451
+ if (typeof process !== "undefined" && process.env) return process.env[name];
3452
+ return void 0;
3453
+ }
3454
+ var AegisClient = class {
3455
+ baseUrl;
3456
+ _token;
3457
+ timeoutMs;
3458
+ _fetchOverride;
3459
+ _fetchInit;
3460
+ _refreshToken;
3461
+ _retry;
3462
+ _refreshInFlight = null;
3463
+ auth;
3464
+ iam;
3465
+ osdk;
3466
+ operator;
3467
+ ontology;
3468
+ aip;
3469
+ functions;
3470
+ codeRepositories;
3471
+ datasets;
3472
+ // Reading / consumption
3473
+ geo;
3474
+ mapTemplates;
3475
+ media;
3476
+ docs;
3477
+ pages;
3478
+ dossier;
3479
+ timeseries;
3480
+ /** Public guest-token consumer surface (`/public/v1/guest/{token}/*`). */
3481
+ publicGuest;
3482
+ // Operational
3483
+ alerts;
3484
+ alarms;
3485
+ events;
3486
+ connectors;
3487
+ pipelines;
3488
+ chat;
3489
+ notepad;
3490
+ // Governance
3491
+ lineage;
3492
+ accessAudit;
3493
+ markings;
3494
+ resourceMarkings;
3495
+ propertyMarkings;
3496
+ rowPolicies;
3497
+ erasure;
3498
+ retention;
3499
+ guestTokens;
3500
+ // Domain
3501
+ atlas;
3502
+ briefing;
3503
+ campaign;
3504
+ cctv;
3505
+ comunicados;
3506
+ edge;
3507
+ video;
3508
+ // Collaboration / apps
3509
+ appShell;
3510
+ forms;
3511
+ /** Alias of `iam.groups` (mirrors Python's standalone `client.groups`). */
3512
+ groups;
3513
+ organizations;
3514
+ projects;
3515
+ solutions;
3516
+ spaces;
3517
+ workspaces;
3518
+ workspaceUpdates;
3519
+ marketplace;
3520
+ // Versioned platform surfaces
3521
+ platformV22;
3522
+ platformV23;
3523
+ platformV24;
3524
+ platformV25;
3525
+ platformV26;
3526
+ // Platform
3527
+ workshop;
3528
+ compute;
3529
+ inference;
3530
+ codegen;
3531
+ correlation;
3532
+ situational;
3533
+ merge;
3534
+ constructor(options = {}) {
3535
+ const baseUrl = options.baseUrl ?? envVar("AEGIS_API_URL") ?? "http://localhost:8002";
3536
+ this.baseUrl = baseUrl.replace(/\/+$/, "");
3537
+ this._token = options.token ?? envVar("AEGIS_TOKEN") ?? null;
3538
+ this.timeoutMs = options.timeoutMs ?? 15e3;
3539
+ this._fetchOverride = options.fetch;
3540
+ this._fetchInit = options.fetchInit ?? {};
3541
+ this._refreshToken = options.refreshToken ?? null;
3542
+ this._retry = {
3543
+ retries: options.retry?.retries ?? 2,
3544
+ baseDelayMs: options.retry?.baseDelayMs ?? 250,
3545
+ maxDelayMs: options.retry?.maxDelayMs ?? 4e3,
3546
+ retryPost: options.retry?.retryPost ?? false
3547
+ };
3548
+ this.auth = new AuthResource(this, (pair) => {
3549
+ this.setToken(pair.access_token);
3550
+ if (pair.refresh_token) this.setRefreshToken(pair.refresh_token);
3551
+ });
3552
+ this.iam = new IamResource(this);
3553
+ this.osdk = new OsdkResource(this);
3554
+ this.operator = new OperatorResource(this);
3555
+ this.ontology = new OntologyResource(this);
3556
+ this.aip = new AipResource(this);
3557
+ this.functions = new FunctionsResource(this);
3558
+ this.codeRepositories = new CodeRepositoriesResource(this);
3559
+ this.datasets = new DatasetsResource(this);
3560
+ this.geo = new GeoResource(this);
3561
+ this.mapTemplates = new MapTemplatesResource(this);
3562
+ this.media = new MediaResource(this);
3563
+ this.docs = new DocsResource(this);
3564
+ this.pages = new PagesResource(this);
3565
+ this.dossier = new DossierResource(this);
3566
+ this.timeseries = new TimeSeriesResource(this);
3567
+ this.publicGuest = new PublicGuestResource(this);
3568
+ this.alerts = new AlertsResource(this);
3569
+ this.alarms = new AlarmsResource(this);
3570
+ this.events = new EventsResource(this);
3571
+ this.connectors = new ConnectorsResource(this);
3572
+ this.pipelines = new PipelinesResource(this);
3573
+ this.chat = new ChatResource(this);
3574
+ this.notepad = new NotepadResource(this);
3575
+ this.lineage = new LineageResource(this);
3576
+ this.accessAudit = new AccessAuditResource(this);
3577
+ this.markings = new MarkingsResource(this);
3578
+ this.resourceMarkings = new ResourceMarkingsResource(this);
3579
+ this.propertyMarkings = new PropertyMarkingsResource(this);
3580
+ this.rowPolicies = new RowPoliciesResource(this);
3581
+ this.erasure = new ErasureResource(this);
3582
+ this.retention = new RetentionResource(this);
3583
+ this.guestTokens = new GuestTokensResource(this);
3584
+ this.atlas = new AtlasResource(this);
3585
+ this.briefing = new BriefingResource(this);
3586
+ this.campaign = new CampaignResource(this);
3587
+ this.cctv = new CctvResource(this);
3588
+ this.comunicados = new ComunicadosResource(this);
3589
+ this.edge = new EdgeResource(this);
3590
+ this.video = new VideoResource(this);
3591
+ this.appShell = new AppShellResource(this);
3592
+ this.forms = new FormsResource(this);
3593
+ this.groups = this.iam.groups;
3594
+ this.organizations = new OrganizationsResource(this);
3595
+ this.projects = new ProjectsResource(this);
3596
+ this.solutions = new SolutionsResource(this);
3597
+ this.spaces = new SpacesResource(this);
3598
+ this.workspaces = new WorkspacesResource(this);
3599
+ this.workspaceUpdates = new WorkspaceUpdatesResource(this);
3600
+ this.marketplace = new MarketplaceResource(this);
3601
+ this.platformV22 = new PlatformV22Resource(this);
3602
+ this.platformV23 = new PlatformV23Resource(this);
3603
+ this.platformV24 = new PlatformV24Resource(this);
3604
+ this.platformV25 = new PlatformV25Resource(this);
3605
+ this.platformV26 = new PlatformV26Resource(this);
3606
+ this.workshop = new WorkshopResource(this);
3607
+ this.compute = new ComputeResource(this);
3608
+ this.inference = new InferenceResource(this);
3609
+ this.codegen = new CodegenResource(this);
3610
+ this.correlation = new CorrelationResource(this);
3611
+ this.situational = new SituationalResource(this);
3612
+ this.merge = new MergeResource(this);
3613
+ }
3614
+ /** Replace the active bearer token (or clear with `null`). */
3615
+ setToken(token) {
3616
+ this._token = token;
3617
+ }
3618
+ /** Replace the refresh token used for automatic 401 recovery. */
3619
+ setRefreshToken(token) {
3620
+ this._refreshToken = token;
3621
+ }
3622
+ get token() {
3623
+ return this._token;
3624
+ }
3625
+ get _fetch() {
3626
+ if (this._fetchOverride) return this._fetchOverride;
3627
+ const globalFetch = globalThis.fetch;
3628
+ if (!globalFetch) {
3629
+ throw new Error("no fetch available \u2014 Node >= 18, a browser, or pass options.fetch");
3630
+ }
3631
+ return globalFetch.bind(globalThis);
3632
+ }
3633
+ /** Generic escape hatch — call any AEGIS endpoint not yet wrapped.
3634
+ * Transient failures are retried with backoff (see `RetryOptions`);
3635
+ * a 401 triggers one transparent `POST /auth/refresh` + retry when a
3636
+ * refresh token is held. */
3637
+ async request(method, path, opts = {}) {
3638
+ try {
3639
+ return await this._requestWithRetry(method, path, opts);
3640
+ } catch (err) {
3641
+ const refreshable = err instanceof AuthError && this._refreshToken !== null && !path.startsWith("/auth/");
3642
+ if (!refreshable) throw err;
3643
+ await this._refreshOnce();
3644
+ return this._requestWithRetry(method, path, opts);
3645
+ }
3646
+ }
3647
+ /** Rotate the refresh token (single-flight) and attach the new pair. */
3648
+ _refreshOnce() {
3649
+ this._refreshInFlight ??= (async () => {
3650
+ try {
3651
+ const pair = await this._requestWithRetry("POST", "/auth/refresh", {
3652
+ json: { refresh_token: this._refreshToken }
3653
+ });
3654
+ this._token = pair.access_token;
3655
+ this._refreshToken = pair.refresh_token ?? this._refreshToken;
3656
+ } catch (err) {
3657
+ if (err instanceof AuthError) this._refreshToken = null;
3658
+ throw err;
3659
+ } finally {
3660
+ this._refreshInFlight = null;
3661
+ }
3662
+ })();
3663
+ return this._refreshInFlight;
3664
+ }
3665
+ async _requestWithRetry(method, path, opts) {
3666
+ const idempotent = method === "GET" || method === "HEAD" || this._retry.retryPost;
3667
+ for (let attempt = 0; ; attempt++) {
3668
+ try {
3669
+ return await this._doRequest(method, path, opts);
3670
+ } catch (err) {
3671
+ if (!idempotent || attempt >= this._retry.retries || !isRetriableError(err)) throw err;
3672
+ await sleep(backoffDelay(attempt + 1, this._retry.baseDelayMs, this._retry.maxDelayMs));
3673
+ }
3674
+ }
3675
+ }
3676
+ async _doRequest(method, path, opts) {
3677
+ const url = buildUrl(this.baseUrl, path, opts.params);
3678
+ const headers = {};
3679
+ if (this._token) headers.Authorization = `Bearer ${this._token}`;
3680
+ const init = { ...this._fetchInit, method, headers };
3681
+ if (opts.form !== void 0) {
3682
+ init.body = opts.form;
3683
+ } else if (opts.json !== void 0) {
3684
+ headers["Content-Type"] = "application/json";
3685
+ init.body = JSON.stringify(opts.json);
3686
+ }
3687
+ if (opts.signal) {
3688
+ init.signal = opts.signal;
3689
+ } else if (typeof AbortSignal !== "undefined" && "timeout" in AbortSignal) {
3690
+ init.signal = AbortSignal.timeout(this.timeoutMs);
3691
+ }
3692
+ const res = await this._fetch(url, init);
3693
+ return handleResponse(res);
3694
+ }
3695
+ /**
3696
+ * Open a server-sent-events endpoint and iterate its events. Long-lived:
3697
+ * no default timeout is applied — pass `signal` to cancel.
3698
+ *
3699
+ * ```ts
3700
+ * for await (const ev of client.stream("/operator/tasks/t1/events")) { … }
3701
+ * ```
3702
+ */
3703
+ async *stream(path, opts = {}) {
3704
+ const url = buildUrl(this.baseUrl, path, opts.params);
3705
+ const headers = { Accept: "text/event-stream" };
3706
+ if (this._token) headers.Authorization = `Bearer ${this._token}`;
3707
+ const init = { ...this._fetchInit, method: opts.method ?? "GET", headers };
3708
+ if (opts.json !== void 0) {
3709
+ headers["Content-Type"] = "application/json";
3710
+ init.body = JSON.stringify(opts.json);
3711
+ init.method = opts.method ?? "POST";
3712
+ }
3713
+ if (opts.signal) init.signal = opts.signal;
3714
+ const res = await this._fetch(url, init);
3715
+ if (!res.ok || !res.body) {
3716
+ await handleResponse(res);
3717
+ throw new AegisAPIError(res.status, "stream endpoint returned no body");
3718
+ }
3719
+ yield* parseSseStream(res.body);
3720
+ }
3721
+ };
3722
+
3723
+ // src/cli-core.ts
3724
+ var CliUsageError = class extends Error {
3725
+ };
3726
+ var USAGE = `aegis-osdk \u2014 typed OSDK codegen from a live AEGIS ontology
3727
+
3728
+ Usage:
3729
+ aegis-osdk generate [--lang typescript|python] [--out <file>]
3730
+ [--base-url <url>] [--token <token>]
3731
+ aegis-osdk manifest [--base-url <url>] [--token <token>]
3732
+
3733
+ Auth/URL resolution: --base-url/--token flags, else AEGIS_API_URL/AEGIS_TOKEN env.
3734
+
3735
+ Commands:
3736
+ generate Fetch GET /ontology/osdk/generate and write the typed module
3737
+ (default --lang typescript, default --out = server filename,
3738
+ e.g. ./aegis_osdk.ts). Prints the contract version.
3739
+ manifest Print the ontology OSDK manifest (JSON) to stdout.
3740
+ `;
3741
+ function parseArgs(argv) {
3742
+ const [command, ...rest] = argv;
3743
+ if (!command || command === "help" || command === "--help" || command === "-h") {
3744
+ return { command: "help", lang: "typescript" };
3745
+ }
3746
+ if (command !== "generate" && command !== "manifest") {
3747
+ throw new CliUsageError(`unknown command: ${command}
3748
+
3749
+ ${USAGE}`);
3750
+ }
3751
+ const opts = { command, lang: "typescript" };
3752
+ for (let i = 0; i < rest.length; i++) {
3753
+ const flag = rest[i];
3754
+ const value = rest[i + 1];
3755
+ const need = () => {
3756
+ if (value === void 0 || value.startsWith("--")) {
3757
+ throw new CliUsageError(`missing value for ${flag}`);
3758
+ }
3759
+ i++;
3760
+ return value;
3761
+ };
3762
+ switch (flag) {
3763
+ case "--lang":
3764
+ opts.lang = need();
3765
+ break;
3766
+ case "--out":
3767
+ opts.out = need();
3768
+ break;
3769
+ case "--base-url":
3770
+ opts.baseUrl = need();
3771
+ break;
3772
+ case "--token":
3773
+ opts.token = need();
3774
+ break;
3775
+ default:
3776
+ throw new CliUsageError(`unknown flag: ${flag}
3777
+
3778
+ ${USAGE}`);
3779
+ }
3780
+ }
3781
+ return opts;
3782
+ }
3783
+ async function run(opts, io) {
3784
+ if (opts.command === "help") {
3785
+ io.log(USAGE);
3786
+ return 0;
3787
+ }
3788
+ const client = new AegisClient({
3789
+ baseUrl: opts.baseUrl,
3790
+ token: opts.token,
3791
+ ...io.fetch ? { fetch: io.fetch } : {}
3792
+ });
3793
+ if (opts.command === "manifest") {
3794
+ const manifest = await client.ontology.osdkManifest();
3795
+ io.log(JSON.stringify(manifest, null, 2));
3796
+ return 0;
3797
+ }
3798
+ const payload = await client.ontology.osdkGenerate(opts.lang);
3799
+ const outPath = opts.out ?? `./${payload.filename}`;
3800
+ await io.writeFile(outPath, payload.source);
3801
+ io.log(
3802
+ `wrote ${outPath} (lang=${payload.lang}` + (payload.contract_version ? `, contract=${payload.contract_version}` : "") + `)`
3803
+ );
3804
+ return 0;
3805
+ }
3806
+
3807
+ // src/cli.ts
3808
+ async function main() {
3809
+ try {
3810
+ const opts = parseArgs(process.argv.slice(2));
3811
+ const code = await run(opts, {
3812
+ writeFile: (path, content) => writeFile(path, content, "utf8"),
3813
+ log: (line) => console.log(line)
3814
+ });
3815
+ process.exitCode = code;
3816
+ } catch (err) {
3817
+ if (err instanceof CliUsageError) {
3818
+ console.error(err.message);
3819
+ process.exitCode = 2;
3820
+ } else if (err instanceof AegisAPIError) {
3821
+ console.error(`AEGIS API error ${err.statusCode}: ${err.detail}`);
3822
+ process.exitCode = 1;
3823
+ } else {
3824
+ console.error(err instanceof Error ? err.message : String(err));
3825
+ process.exitCode = 1;
3826
+ }
3827
+ }
3828
+ }
3829
+ void main();
3830
+ //# sourceMappingURL=cli.js.map