@kindgi/client 0.1.4-rc.5 → 0.1.5-rc.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/index.js CHANGED
@@ -47,6 +47,8 @@ function classify(body, status) {
47
47
  case "auth-revoked":
48
48
  return { code: "auth", message, reason: "unauthenticated" };
49
49
  case "permission-denied":
50
+ case "role-exceeds-principal":
51
+ case "key-project-mismatch":
50
52
  return { code: "auth", message, reason: "forbidden" };
51
53
  case "rate-limited":
52
54
  case "rate-limit-exceeded":
@@ -75,11 +77,15 @@ function classify(body, status) {
75
77
  case "token-not-found":
76
78
  case "agent-version-not-found":
77
79
  case "promotion-not-found":
80
+ case "principal-not-found":
81
+ case "service-account-not-found":
78
82
  return notFound(code, message, details);
79
83
  case "conflict":
80
84
  case "already-terminal":
81
85
  case "run-already-terminal":
82
86
  case "idempotency-key-body-mismatch":
87
+ case "idempotency-key-in-flight":
88
+ case "idempotency-key-replay-withheld":
83
89
  case "hitl-required":
84
90
  case "agent-already-registered":
85
91
  case "tool-already-registered":
@@ -111,8 +117,18 @@ function classify(body, status) {
111
117
  case "gate-policy-scope-changed":
112
118
  case "gate-policy-scope-unpinned":
113
119
  case "gate-policy-needs-pin":
120
+ case "fact-changed":
121
+ case "legal-hold":
122
+ case "erasure-in-progress":
114
123
  case "gate-policy-descendant-unpinned":
115
- return { code: "conflict", message, reason: code };
124
+ case "service-account-name-taken":
125
+ case "service-account-unregistered":
126
+ case "identity-user-email-taken":
127
+ case "last-tenant-admin":
128
+ case "seed-user-admin":
129
+ case "identity-user-unregister-refused":
130
+ case "identity-user-unregistered":
131
+ return conflict(code, message, details);
116
132
  case "invalid-request":
117
133
  case "validation-failed":
118
134
  case "unknown-field":
@@ -126,8 +142,11 @@ function classify(body, status) {
126
142
  case "unknown-effect":
127
143
  case "invalid-guardrail":
128
144
  case "invalid-provider":
145
+ case "guardrail-config-invalid":
146
+ case "provider-config-invalid":
129
147
  case "supervisor-header-missing":
130
148
  case "scope-invalid":
149
+ case "artifact-too-large":
131
150
  return invalidRequest(message, obj, details);
132
151
  case "guardrail-violation":
133
152
  return {
@@ -140,13 +159,24 @@ function classify(body, status) {
140
159
  return byStatus(status, code, message, obj, details);
141
160
  }
142
161
  }
162
+ function conflict(code, message, details) {
163
+ return {
164
+ code: "conflict",
165
+ message,
166
+ reason: code,
167
+ ...details !== void 0 ? { fields: details } : {}
168
+ };
169
+ }
143
170
  function byStatus(status, code, message, obj, details) {
144
171
  switch (status) {
145
172
  case 404:
146
173
  case 410:
147
174
  return notFound(code, message, details);
148
175
  case 400:
176
+ case 413:
149
177
  return invalidRequest(message, obj, details);
178
+ case 409:
179
+ return conflict(code, message, details);
150
180
  case 401:
151
181
  return { code: "auth", message, reason: "unauthenticated" };
152
182
  case 403:
@@ -210,10 +240,10 @@ function readStringField(obj, ...keys) {
210
240
  function asRecord(value) {
211
241
  return value !== null && typeof value === "object" ? value : void 0;
212
242
  }
213
- function readGuardrailViolations(raw) {
214
- if (!Array.isArray(raw)) return [];
243
+ function readGuardrailViolations(raw2) {
244
+ if (!Array.isArray(raw2)) return [];
215
245
  const out = [];
216
- for (const entry of raw) {
246
+ for (const entry of raw2) {
217
247
  const v = asRecord(entry);
218
248
  if (v === void 0 || typeof v.guardrailId !== "string") continue;
219
249
  const reason = asRecord(v.result)?.reason;
@@ -226,10 +256,10 @@ function readGuardrailViolations(raw) {
226
256
  }
227
257
  return out;
228
258
  }
229
- function readEvaluationErrors(raw) {
230
- if (!Array.isArray(raw)) return [];
259
+ function readEvaluationErrors(raw2) {
260
+ if (!Array.isArray(raw2)) return [];
231
261
  const out = [];
232
- for (const entry of raw) {
262
+ for (const entry of raw2) {
233
263
  const e = asRecord(entry);
234
264
  if (e === void 0 || typeof e.guardrailId !== "string") continue;
235
265
  out.push({
@@ -330,9 +360,9 @@ async function* parseSseStream(body) {
330
360
  newlineIdx = buffer.indexOf("\n");
331
361
  if (line === "") {
332
362
  if (dataLines.length > 0) {
333
- const raw = dataLines.join("\n");
363
+ const raw2 = dataLines.join("\n");
334
364
  try {
335
- const data = JSON.parse(raw);
365
+ const data = JSON.parse(raw2);
336
366
  yield { event: eventName, data, ...eventId !== void 0 ? { id: eventId } : {} };
337
367
  } catch {
338
368
  }
@@ -470,12 +500,12 @@ function makeAdaptersClient(transport) {
470
500
 
471
501
  // src/resources/agents.ts
472
502
  function makeAgentsClient(transport) {
473
- const seg = (s) => encodeURIComponent(s);
503
+ const seg2 = (s) => encodeURIComponent(s);
474
504
  const versions = {
475
505
  async list(agentId, filter) {
476
506
  return transport.request({
477
507
  method: "GET",
478
- path: `/v1/agents/${seg(agentId)}/versions`,
508
+ path: `/v1/agents/${seg2(agentId)}/versions`,
479
509
  query: {
480
510
  ...filter?.limit !== void 0 && { limit: filter.limit },
481
511
  ...filter?.cursor !== void 0 && { cursor: filter.cursor }
@@ -485,13 +515,13 @@ function makeAgentsClient(transport) {
485
515
  async get(agentId, version) {
486
516
  return transport.request({
487
517
  method: "GET",
488
- path: `/v1/agents/${seg(agentId)}/versions/${seg(version)}`
518
+ path: `/v1/agents/${seg2(agentId)}/versions/${seg2(version)}`
489
519
  });
490
520
  },
491
521
  async unregister(agentId, version, options) {
492
522
  return transport.request({
493
523
  method: "POST",
494
- path: `/v1/agents/${seg(agentId)}/versions/${seg(version)}/unregister`,
524
+ path: `/v1/agents/${seg2(agentId)}/versions/${seg2(version)}/unregister`,
495
525
  ...options?.idempotencyKey !== void 0 && {
496
526
  idempotencyKey: options.idempotencyKey
497
527
  }
@@ -500,7 +530,7 @@ function makeAgentsClient(transport) {
500
530
  async derive(agentId, input, options) {
501
531
  return transport.request({
502
532
  method: "POST",
503
- path: `/v1/agents/${seg(agentId)}/versions`,
533
+ path: `/v1/agents/${seg2(agentId)}/versions`,
504
534
  body: input,
505
535
  ...options?.idempotencyKey !== void 0 && {
506
536
  idempotencyKey: options.idempotencyKey
@@ -510,7 +540,7 @@ function makeAgentsClient(transport) {
510
540
  async reinstate(agentId, version, options) {
511
541
  const wire = await transport.request({
512
542
  method: "POST",
513
- path: `/v1/agents/${seg(agentId)}/versions/${seg(version)}/reinstate`,
543
+ path: `/v1/agents/${seg2(agentId)}/versions/${seg2(version)}/reinstate`,
514
544
  ...options?.idempotencyKey !== void 0 && {
515
545
  idempotencyKey: options.idempotencyKey
516
546
  }
@@ -548,7 +578,7 @@ function makeAgentsClient(transport) {
548
578
  async get(agentId) {
549
579
  return transport.request({
550
580
  method: "GET",
551
- path: `/v1/agents/${seg(agentId)}`
581
+ path: `/v1/agents/${seg2(agentId)}`
552
582
  });
553
583
  },
554
584
  versions,
@@ -557,7 +587,7 @@ function makeAgentsClient(transport) {
557
587
  async resolve(agentId, where) {
558
588
  return transport.request({
559
589
  method: "GET",
560
- path: `/v1/agents/${seg(agentId)}/live`,
590
+ path: `/v1/agents/${seg2(agentId)}/live`,
561
591
  query: {
562
592
  ...where?.projectId !== void 0 && { projectId: where.projectId },
563
593
  ...where?.segments !== void 0 && { segment: where.segments.map(segmentParam) }
@@ -567,13 +597,13 @@ function makeAgentsClient(transport) {
567
597
  async list(agentId) {
568
598
  return transport.request({
569
599
  method: "GET",
570
- path: `/v1/agents/${seg(agentId)}/live-versions`
600
+ path: `/v1/agents/${seg2(agentId)}/live-versions`
571
601
  });
572
602
  },
573
603
  async rollback(agentId, input, options) {
574
604
  return transport.request({
575
605
  method: "POST",
576
- path: `/v1/agents/${seg(agentId)}/live/rollback`,
606
+ path: `/v1/agents/${seg2(agentId)}/live/rollback`,
577
607
  body: input,
578
608
  ...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
579
609
  });
@@ -581,7 +611,7 @@ function makeAgentsClient(transport) {
581
611
  async unpin(agentId, input, options) {
582
612
  return transport.request({
583
613
  method: "POST",
584
- path: `/v1/agents/${seg(agentId)}/live/unpin`,
614
+ path: `/v1/agents/${seg2(agentId)}/live/unpin`,
585
615
  body: input,
586
616
  ...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
587
617
  });
@@ -591,7 +621,7 @@ function makeAgentsClient(transport) {
591
621
  async create(agentId, input, options) {
592
622
  return transport.request({
593
623
  method: "POST",
594
- path: `/v1/agents/${seg(agentId)}/promotions`,
624
+ path: `/v1/agents/${seg2(agentId)}/promotions`,
595
625
  body: input,
596
626
  ...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
597
627
  });
@@ -599,14 +629,14 @@ function makeAgentsClient(transport) {
599
629
  async check(agentId, input) {
600
630
  return transport.request({
601
631
  method: "POST",
602
- path: `/v1/agents/${seg(agentId)}/promotions/check`,
632
+ path: `/v1/agents/${seg2(agentId)}/promotions/check`,
603
633
  body: input
604
634
  });
605
635
  },
606
636
  async list(agentId, filter) {
607
637
  return transport.request({
608
638
  method: "GET",
609
- path: `/v1/agents/${seg(agentId)}/promotions`,
639
+ path: `/v1/agents/${seg2(agentId)}/promotions`,
610
640
  query: {
611
641
  ...filter?.scope !== void 0 && scopeQuery(filter.scope),
612
642
  ...filter?.limit !== void 0 && { limit: filter.limit },
@@ -617,7 +647,7 @@ function makeAgentsClient(transport) {
617
647
  async get(agentId, promotionId) {
618
648
  return transport.request({
619
649
  method: "GET",
620
- path: `/v1/agents/${seg(agentId)}/promotions/${seg(promotionId)}`
650
+ path: `/v1/agents/${seg2(agentId)}/promotions/${seg2(promotionId)}`
621
651
  });
622
652
  }
623
653
  },
@@ -625,7 +655,7 @@ function makeAgentsClient(transport) {
625
655
  async resolve(agentId, scope) {
626
656
  return transport.request({
627
657
  method: "GET",
628
- path: `/v1/agents/${seg(agentId)}/gate-policy`,
658
+ path: `/v1/agents/${seg2(agentId)}/gate-policy`,
629
659
  query: scopeQuery(scope)
630
660
  });
631
661
  }
@@ -680,6 +710,106 @@ function singleStatusQuery(method, status) {
680
710
  throw new KindgiApiError(error);
681
711
  }
682
712
 
713
+ // src/verify-export.ts
714
+ var ALGORITHMS = {
715
+ ed25519: { key: { name: "Ed25519" }, verify: { name: "Ed25519" } },
716
+ "ecdsa-p256-sha256": {
717
+ key: { name: "ECDSA", namedCurve: "P-256" },
718
+ verify: { name: "ECDSA", hash: "SHA-256" }
719
+ }
720
+ };
721
+ var SIGNED_EXPORT_ALGORITHMS = Object.keys(
722
+ ALGORITHMS
723
+ );
724
+ async function verifySignedExport(envelope, options = {}) {
725
+ const issues = [];
726
+ const checkedAgainst = options.trustedKeys !== void 0 ? "trusted-keys" : "its-own-key";
727
+ const fail = () => ({
728
+ valid: false,
729
+ issues,
730
+ checkedAgainst,
731
+ signingKeyId: envelope.signingKeyId
732
+ });
733
+ const algorithm = Object.hasOwn(ALGORITHMS, envelope.algorithm) ? ALGORITHMS[envelope.algorithm] : void 0;
734
+ if (algorithm === void 0) {
735
+ issues.push(
736
+ `algorithm "${envelope.algorithm}" isn't one this verifier knows (${SIGNED_EXPORT_ALGORITHMS.join(", ")}): a newer verifier may check it`
737
+ );
738
+ }
739
+ if (envelope.canonicalization !== "sorted-key-json") {
740
+ issues.push(`canonicalization "${envelope.canonicalization}" isn't sorted-key-json`);
741
+ }
742
+ if (options.trustedKeys !== void 0 && !options.trustedKeys.some((pem) => samePem(pem, envelope.publicKey))) {
743
+ issues.push(`it was signed with key "${envelope.signingKeyId}", which isn't one you trust`);
744
+ }
745
+ if (issues.length > 0 || algorithm === void 0) return fail();
746
+ let bytes;
747
+ let signed;
748
+ try {
749
+ bytes = fromBase64(envelope.bundle);
750
+ const key = await crypto.subtle.importKey(
751
+ "spki",
752
+ toArrayBuffer(fromPem(envelope.publicKey)),
753
+ algorithm.key,
754
+ false,
755
+ ["verify"]
756
+ );
757
+ signed = await crypto.subtle.verify(
758
+ algorithm.verify,
759
+ key,
760
+ toArrayBuffer(fromBase64(envelope.signature)),
761
+ toArrayBuffer(bytes)
762
+ );
763
+ } catch (cause) {
764
+ issues.push(`it can't be checked: ${cause instanceof Error ? cause.message : String(cause)}`);
765
+ return fail();
766
+ }
767
+ if (!signed) {
768
+ issues.push(
769
+ "the signature doesn't match the bundle: it was changed, or signed with another key"
770
+ );
771
+ return fail();
772
+ }
773
+ const body = JSON.parse(new TextDecoder().decode(bytes));
774
+ const notes = [];
775
+ if (body.exportedAt !== void 0 && body.exportedAt !== envelope.exportedAt) {
776
+ if (!madeByKindgi014(envelope, body)) {
777
+ issues.push(
778
+ `the envelope's exportedAt (${envelope.exportedAt}) isn't the signed one (${String(body.exportedAt)})`
779
+ );
780
+ return fail();
781
+ }
782
+ notes.push(
783
+ `made by Kindgi 0.1.4, which stamped the envelope's exportedAt separately: the signed export time is ${String(body.exportedAt)} (the envelope says ${envelope.exportedAt})`
784
+ );
785
+ }
786
+ return {
787
+ valid: true,
788
+ checkedAgainst,
789
+ body,
790
+ signingKeyId: envelope.signingKeyId,
791
+ ...notes.length > 0 && { notes }
792
+ };
793
+ }
794
+ function madeByKindgi014(envelope, body) {
795
+ return envelope.bundleSchemaVersion === 1 && body.bundleVersion === 1 && body.bundleSchemaVersion === void 0;
796
+ }
797
+ function samePem(a, b) {
798
+ return a.replace(/\s+/g, "") === b.replace(/\s+/g, "");
799
+ }
800
+ function fromPem(pem) {
801
+ return fromBase64(pem.replace(/-----(BEGIN|END) [A-Z ]+-----/g, "").replace(/\s+/g, ""));
802
+ }
803
+ function fromBase64(b64) {
804
+ const binary = atob(b64);
805
+ const out = new Uint8Array(binary.length);
806
+ for (let i = 0; i < binary.length; i += 1) out[i] = binary.charCodeAt(i);
807
+ return out;
808
+ }
809
+ function toArrayBuffer(bytes) {
810
+ return bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
811
+ }
812
+
683
813
  // src/resources/approvals.ts
684
814
  function makeApprovalsClient(transport) {
685
815
  return {
@@ -801,7 +931,7 @@ function makeApprovalsClient(transport) {
801
931
  method: "POST",
802
932
  path: `/v1/approvals/${encodeURIComponent(input.approvalId)}/audit-bundle`,
803
933
  body: {
804
- signingKeyId: input.signingKeyId,
934
+ ...input.signingKeyId !== void 0 && { signingKeyId: input.signingKeyId },
805
935
  ...input.includeMessages !== void 0 && {
806
936
  includeMessages: input.includeMessages
807
937
  }
@@ -825,26 +955,231 @@ function makeApprovalsClient(transport) {
825
955
  )
826
956
  );
827
957
  },
828
- async verify(_bundle, _publicKey) {
829
- throw new KindgiApiError(
830
- notYetWired(
831
- "approvals.audit.verify",
832
- "client-side verifier requires the crypto module reachability from the SDK bundle \u2014 not yet vendored (same constraint as provenance.verify + webhooks.verify)"
833
- )
834
- );
958
+ async verify(bundle, publicKey) {
959
+ const checked = await verifySignedExport(bundle, { trustedKeys: [publicKey] });
960
+ return checked.valid ? { valid: true } : { valid: false, issues: checked.issues ?? [] };
961
+ }
962
+ }
963
+ };
964
+ }
965
+
966
+ // src/transport.ts
967
+ var DEFAULT_TIMEOUT_MS = 3e4;
968
+ var MUTATING = /* @__PURE__ */ new Set([
969
+ "POST",
970
+ "PUT",
971
+ "PATCH",
972
+ "DELETE"
973
+ ]);
974
+ function createTransport(options) {
975
+ const apiUrl = options.apiUrl.replace(/\/+$/u, "");
976
+ const fetchImpl = options.fetch ?? fetch;
977
+ const clientTimeoutMs = checkedTimeoutMs(
978
+ options.timeoutMs ?? DEFAULT_TIMEOUT_MS,
979
+ "ClientOptions.timeoutMs"
980
+ );
981
+ return {
982
+ apiUrl,
983
+ fetchImpl,
984
+ authHeaders() {
985
+ return { Authorization: `Bearer ${authTokenFor(options.auth)}` };
986
+ },
987
+ async request(input) {
988
+ const url = buildUrl(apiUrl, input.path, input.query);
989
+ const headers = buildHeaders(input, options.auth);
990
+ const timeoutMs = input.timeoutMs === void 0 ? clientTimeoutMs : checkedTimeoutMs(input.timeoutMs, "timeoutMs");
991
+ const ac = new AbortController();
992
+ let timedOut = false;
993
+ const timer = setTimeout(() => {
994
+ timedOut = true;
995
+ ac.abort(new Error("timeout"));
996
+ }, timeoutMs);
997
+ let response;
998
+ try {
999
+ response = await fetchImpl(url, {
1000
+ method: input.method,
1001
+ headers,
1002
+ ...input.body !== void 0 && { body: JSON.stringify(input.body) },
1003
+ signal: ac.signal
1004
+ });
1005
+ } catch (cause) {
1006
+ clearTimeout(timer);
1007
+ const err = timedOut ? {
1008
+ code: "network",
1009
+ message: `No answer within ${seconds(timeoutMs)}, the client's timeout (timeoutMs).`,
1010
+ cause,
1011
+ timeoutMs
1012
+ } : {
1013
+ code: "network",
1014
+ message: cause instanceof Error ? cause.message : "network request failed",
1015
+ cause
1016
+ };
1017
+ throw new KindgiApiError(err);
1018
+ }
1019
+ clearTimeout(timer);
1020
+ if (response.ok) {
1021
+ if (input.discardResponse === true || response.status === 204) {
1022
+ try {
1023
+ await response.arrayBuffer();
1024
+ } catch {
1025
+ }
1026
+ return void 0;
1027
+ }
1028
+ try {
1029
+ return await response.json();
1030
+ } catch (cause) {
1031
+ const err = {
1032
+ code: "network",
1033
+ message: "Response body was not valid JSON",
1034
+ cause
1035
+ };
1036
+ throw new KindgiApiError(err);
1037
+ }
1038
+ }
1039
+ let body;
1040
+ try {
1041
+ body = await response.json();
1042
+ } catch {
1043
+ body = void 0;
835
1044
  }
1045
+ throw new KindgiApiError(
1046
+ fromWire(unwrapErrorEnvelope(body, response.status), response.status)
1047
+ );
836
1048
  }
837
1049
  };
838
1050
  }
1051
+ function checkedTimeoutMs(value, name) {
1052
+ if (!Number.isFinite(value) || value <= 0) {
1053
+ throw new TypeError(`${name} must be a positive number of milliseconds. Got ${String(value)}.`);
1054
+ }
1055
+ return value;
1056
+ }
1057
+ function seconds(ms) {
1058
+ return `${ms / 1e3} s`;
1059
+ }
1060
+ function buildUrl(apiUrl, path, query) {
1061
+ const normalizedPath = path.startsWith("/") ? path : `/${path}`;
1062
+ const base = `${apiUrl}${normalizedPath}`;
1063
+ if (query === void 0) return base;
1064
+ const params = [];
1065
+ for (const key of Object.keys(query)) {
1066
+ const value = query[key];
1067
+ if (value === void 0) continue;
1068
+ const values = typeof value === "object" ? value : [String(value)];
1069
+ for (const v of values) params.push(`${encodeURIComponent(key)}=${encodeURIComponent(v)}`);
1070
+ }
1071
+ return params.length === 0 ? base : `${base}?${params.join("&")}`;
1072
+ }
1073
+ function buildHeaders(input, auth) {
1074
+ const headers = {
1075
+ Accept: "application/json",
1076
+ Authorization: `Bearer ${authTokenFor(auth)}`
1077
+ };
1078
+ if (input.body !== void 0) {
1079
+ headers["Content-Type"] = "application/json; charset=utf-8";
1080
+ }
1081
+ if (input.idempotencyKey !== void 0 && MUTATING.has(input.method)) {
1082
+ headers["Idempotency-Key"] = input.idempotencyKey;
1083
+ }
1084
+ if (input.headers !== void 0) {
1085
+ for (const key of Object.keys(input.headers)) {
1086
+ headers[key] = input.headers[key];
1087
+ }
1088
+ }
1089
+ return headers;
1090
+ }
1091
+ function authTokenFor(auth) {
1092
+ if (auth.kind === "apiToken") return auth.token;
1093
+ return auth.accessToken;
1094
+ }
1095
+ function unwrapErrorEnvelope(body, status) {
1096
+ if (body !== null && typeof body === "object" && !Array.isArray(body)) {
1097
+ const inner = body.error;
1098
+ if (inner !== null && typeof inner === "object" && !Array.isArray(inner)) {
1099
+ return inner;
1100
+ }
1101
+ }
1102
+ return { code: "unknown", message: `HTTP ${status} without recognizable error envelope` };
1103
+ }
839
1104
 
840
1105
  // src/resources/artifacts.ts
1106
+ async function raw(transport, req) {
1107
+ const res = await transport.fetchImpl(`${transport.apiUrl}${req.path}`, {
1108
+ method: req.method,
1109
+ headers: { ...transport.authHeaders(), ...req.headers ?? {} },
1110
+ ...req.body !== void 0 && { body: req.body }
1111
+ });
1112
+ if (!res.ok) {
1113
+ const body = req.method === "HEAD" ? {
1114
+ error: {
1115
+ code: res.status === 404 ? "blob-not-found" : "unknown",
1116
+ message: res.status === 404 ? "No such artifact, or it's in a project you can't read" : `HTTP ${res.status}`
1117
+ }
1118
+ } : await res.json().catch(() => null);
1119
+ throw new KindgiApiError(fromWire(unwrapErrorEnvelope(body, res.status), res.status));
1120
+ }
1121
+ return res;
1122
+ }
1123
+ function headOf(blobId, res) {
1124
+ const name = res.headers.get("X-Kindgi-Blob-Name");
1125
+ return {
1126
+ blobId,
1127
+ name: name !== null ? decodeURIComponent(name) : "",
1128
+ contentType: res.headers.get("Content-Type") ?? "application/octet-stream",
1129
+ size: Number(res.headers.get("Content-Length") ?? "0"),
1130
+ hash: res.headers.get("X-Kindgi-Blob-Hash") ?? ""
1131
+ };
1132
+ }
1133
+ function uploadForm(input) {
1134
+ const contentType = input.contentType ?? (input.body instanceof Blob && input.body.type !== "" ? input.body.type : "application/octet-stream");
1135
+ const blob = input.body instanceof Blob ? input.body : new Blob([input.body], {
1136
+ type: contentType
1137
+ });
1138
+ const form = new FormData();
1139
+ form.set("file", blob, input.name ?? "file");
1140
+ form.set("contentType", contentType);
1141
+ if (input.name !== void 0) form.set("name", input.name);
1142
+ if (input.tags !== void 0) form.set("tags", JSON.stringify(input.tags));
1143
+ if (input.ownerRunId !== void 0) form.set("ownerRunId", input.ownerRunId);
1144
+ if (input.projectId !== void 0) form.set("projectId", input.projectId);
1145
+ if (input.expectedHash !== void 0) form.set("expectedHash", input.expectedHash);
1146
+ return form;
1147
+ }
841
1148
  function makeArtifactsClient(transport) {
842
1149
  return {
1150
+ async upload(input, options) {
1151
+ const res = await raw(transport, {
1152
+ method: "POST",
1153
+ path: "/v1/artifacts",
1154
+ body: uploadForm(input),
1155
+ ...options?.idempotencyKey !== void 0 && {
1156
+ headers: { "Idempotency-Key": options.idempotencyKey }
1157
+ }
1158
+ });
1159
+ return await res.json();
1160
+ },
1161
+ async download(blobId) {
1162
+ const res = await raw(transport, {
1163
+ method: "GET",
1164
+ path: `/v1/artifacts/${encodeURIComponent(blobId)}`
1165
+ });
1166
+ return {
1167
+ ...headOf(blobId, res),
1168
+ body: res.body ?? new Response("").body
1169
+ };
1170
+ },
1171
+ async head(blobId) {
1172
+ const res = await raw(transport, {
1173
+ method: "HEAD",
1174
+ path: `/v1/artifacts/${encodeURIComponent(blobId)}`
1175
+ });
1176
+ return headOf(blobId, res);
1177
+ },
843
1178
  async put(_input) {
844
1179
  throw new KindgiApiError(
845
1180
  notYetWired(
846
1181
  "artifacts.put",
847
- "POST /v1/artifacts is a multipart-form upload; the SDK transport is JSON-only. Multipart / raw-stream body support is a planned follow-up"
1182
+ "no route takes a content-addressed BlobRef: use artifacts.upload, which returns the artifact metadata"
848
1183
  )
849
1184
  );
850
1185
  },
@@ -852,7 +1187,7 @@ function makeArtifactsClient(transport) {
852
1187
  throw new KindgiApiError(
853
1188
  notYetWired(
854
1189
  "artifacts.get",
855
- "GET /v1/artifacts/{blobId} streams binary bytes; the SDK transport hydrates JSON only. Raw-stream response support is a planned follow-up"
1190
+ "no route takes a content-addressed BlobRef: use artifacts.download(blobId)"
856
1191
  )
857
1192
  );
858
1193
  },
@@ -866,7 +1201,8 @@ function makeArtifactsClient(transport) {
866
1201
  ...filter?.ownerRunId !== void 0 && {
867
1202
  ownerRunId: filter.ownerRunId
868
1203
  },
869
- ...filter?.contentType !== void 0 && { contentType: filter.contentType }
1204
+ ...filter?.contentType !== void 0 && { contentType: filter.contentType },
1205
+ ...filter?.projectId !== void 0 && { projectId: filter.projectId }
870
1206
  }
871
1207
  });
872
1208
  return listPage(page);
@@ -928,7 +1264,7 @@ function makeAuditClient(transport) {
928
1264
 
929
1265
  // src/resources/auth.ts
930
1266
  function makeAuthClient(transport) {
931
- const seg = (s) => encodeURIComponent(s);
1267
+ const seg2 = (s) => encodeURIComponent(s);
932
1268
  return {
933
1269
  providers: {
934
1270
  async list() {
@@ -949,15 +1285,43 @@ function makeAuthClient(transport) {
949
1285
  async unregister(providerId, options) {
950
1286
  return transport.request({
951
1287
  method: "POST",
952
- path: `/v1/auth/providers/${seg(providerId)}/unregister`,
1288
+ path: `/v1/auth/providers/${seg2(providerId)}/unregister`,
1289
+ ...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
1290
+ });
1291
+ },
1292
+ async get(providerId) {
1293
+ return transport.request({
1294
+ method: "GET",
1295
+ path: `/v1/auth/providers/${seg2(providerId)}`
1296
+ });
1297
+ },
1298
+ async signIn(providerId, input) {
1299
+ return transport.request({
1300
+ method: "GET",
1301
+ path: `/v1/auth/providers/${seg2(providerId)}/sign-in`,
1302
+ ...input?.kind !== void 0 && { query: { kind: input.kind } }
1303
+ });
1304
+ },
1305
+ async update(providerId, changes, options) {
1306
+ return transport.request({
1307
+ method: "PATCH",
1308
+ path: `/v1/auth/providers/${seg2(providerId)}`,
1309
+ body: changes,
953
1310
  ...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
954
1311
  });
955
1312
  }
956
1313
  },
1314
+ async signInOptions(input) {
1315
+ return transport.request({
1316
+ method: "GET",
1317
+ path: "/v1/auth/sign-in-options",
1318
+ ...input?.email !== void 0 && { query: { email: input.email } }
1319
+ });
1320
+ },
957
1321
  async login(providerId, input, options) {
958
1322
  return transport.request({
959
1323
  method: "POST",
960
- path: `/v1/auth/login/${seg(providerId)}`,
1324
+ path: `/v1/auth/login/${seg2(providerId)}`,
961
1325
  ...input !== void 0 && { body: input },
962
1326
  ...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
963
1327
  });
@@ -965,7 +1329,7 @@ function makeAuthClient(transport) {
965
1329
  async callback(providerId, input) {
966
1330
  return transport.request({
967
1331
  method: "POST",
968
- path: `/v1/auth/callback/${seg(providerId)}`,
1332
+ path: `/v1/auth/callback/${seg2(providerId)}`,
969
1333
  body: input
970
1334
  });
971
1335
  },
@@ -976,6 +1340,12 @@ function makeAuthClient(transport) {
976
1340
  ...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
977
1341
  });
978
1342
  },
1343
+ async tokenSignIn() {
1344
+ return transport.request({
1345
+ method: "POST",
1346
+ path: "/v1/auth/token-sign-in"
1347
+ });
1348
+ },
979
1349
  async logout(options) {
980
1350
  return transport.request({
981
1351
  method: "POST",
@@ -988,7 +1358,7 @@ function makeAuthClient(transport) {
988
1358
 
989
1359
  // src/resources/blocks.ts
990
1360
  function makeBlocksClient(transport) {
991
- const seg = (s) => encodeURIComponent(s);
1361
+ const seg2 = (s) => encodeURIComponent(s);
992
1362
  return {
993
1363
  async publish(input, options) {
994
1364
  return transport.request({
@@ -1012,13 +1382,13 @@ function makeBlocksClient(transport) {
1012
1382
  });
1013
1383
  },
1014
1384
  async get(blockId) {
1015
- return transport.request({ method: "GET", path: `/v1/blocks/${seg(blockId)}` });
1385
+ return transport.request({ method: "GET", path: `/v1/blocks/${seg2(blockId)}` });
1016
1386
  },
1017
1387
  versions: {
1018
1388
  async list(blockId, filter) {
1019
1389
  return transport.request({
1020
1390
  method: "GET",
1021
- path: `/v1/blocks/${seg(blockId)}/versions`,
1391
+ path: `/v1/blocks/${seg2(blockId)}/versions`,
1022
1392
  query: {
1023
1393
  ...filter?.limit !== void 0 && { limit: filter.limit },
1024
1394
  ...filter?.cursor !== void 0 && { cursor: filter.cursor },
@@ -1031,20 +1401,20 @@ function makeBlocksClient(transport) {
1031
1401
  async get(blockId, version) {
1032
1402
  return transport.request({
1033
1403
  method: "GET",
1034
- path: `/v1/blocks/${seg(blockId)}/versions/${seg(version)}`
1404
+ path: `/v1/blocks/${seg2(blockId)}/versions/${seg2(version)}`
1035
1405
  });
1036
1406
  },
1037
1407
  async unregister(blockId, version, options) {
1038
1408
  return transport.request({
1039
1409
  method: "POST",
1040
- path: `/v1/blocks/${seg(blockId)}/versions/${seg(version)}/unregister`,
1410
+ path: `/v1/blocks/${seg2(blockId)}/versions/${seg2(version)}/unregister`,
1041
1411
  ...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
1042
1412
  });
1043
1413
  },
1044
1414
  async reinstate(blockId, version, options) {
1045
1415
  return transport.request({
1046
1416
  method: "POST",
1047
- path: `/v1/blocks/${seg(blockId)}/versions/${seg(version)}/reinstate`,
1417
+ path: `/v1/blocks/${seg2(blockId)}/versions/${seg2(version)}/reinstate`,
1048
1418
  ...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
1049
1419
  });
1050
1420
  }
@@ -1180,7 +1550,8 @@ function makeComplianceClient(transport) {
1180
1550
  body: input,
1181
1551
  ...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
1182
1552
  });
1183
- }
1553
+ },
1554
+ verify: (bundle, publicKey) => verifySignedExport(bundle, { trustedKeys: [publicKey] })
1184
1555
  }
1185
1556
  };
1186
1557
  }
@@ -1238,6 +1609,16 @@ function makeConversationsClient(transport) {
1238
1609
  }
1239
1610
  });
1240
1611
  },
1612
+ async unregister(id, options) {
1613
+ return transport.request({
1614
+ method: "POST",
1615
+ path: `/v1/conversations/${encodeURIComponent(id)}/unregister`,
1616
+ body: {},
1617
+ ...options?.idempotencyKey !== void 0 && {
1618
+ idempotencyKey: options.idempotencyKey
1619
+ }
1620
+ });
1621
+ },
1241
1622
  async messages(id, filter) {
1242
1623
  const page = await transport.request({
1243
1624
  method: "GET",
@@ -1448,9 +1829,9 @@ function makeEnvClient(transport) {
1448
1829
  });
1449
1830
  return { kind: "ok", record };
1450
1831
  } catch (err) {
1451
- const conflict = tryReadRevisionConflict(err);
1452
- if (conflict !== null) {
1453
- return { kind: "revision-conflict", currentRevision: conflict };
1832
+ const conflict2 = tryReadRevisionConflict(err);
1833
+ if (conflict2 !== null) {
1834
+ return { kind: "revision-conflict", currentRevision: conflict2 };
1454
1835
  }
1455
1836
  throw err;
1456
1837
  }
@@ -1503,12 +1884,12 @@ function comparisonOf(run) {
1503
1884
  return run.kind === "judged" && result?.summary !== void 0 && Array.isArray(result.perCase) ? result : void 0;
1504
1885
  }
1505
1886
  function makeEvalRunsClient(transport) {
1506
- const seg = (s) => encodeURIComponent(s);
1887
+ const seg2 = (s) => encodeURIComponent(s);
1507
1888
  return {
1508
1889
  async start(suiteId, input, options) {
1509
1890
  return transport.request({
1510
1891
  method: "POST",
1511
- path: `/v1/eval-suites/${seg(suiteId)}/runs`,
1892
+ path: `/v1/eval-suites/${seg2(suiteId)}/runs`,
1512
1893
  body: { ...input, projectId: options.projectId },
1513
1894
  ...options.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
1514
1895
  });
@@ -1529,17 +1910,17 @@ function makeEvalRunsClient(transport) {
1529
1910
  async get(runId) {
1530
1911
  return transport.request({
1531
1912
  method: "GET",
1532
- path: `/v1/eval-runs/${seg(runId)}`
1913
+ path: `/v1/eval-runs/${seg2(runId)}`
1533
1914
  });
1534
1915
  },
1535
1916
  async cancel(runId) {
1536
1917
  return transport.request({
1537
1918
  method: "POST",
1538
- path: `/v1/eval-runs/${seg(runId)}/cancel`
1919
+ path: `/v1/eval-runs/${seg2(runId)}/cancel`
1539
1920
  });
1540
1921
  },
1541
1922
  events(runId, options) {
1542
- const url = `${transport.apiUrl}/v1/eval-runs/${seg(runId)}/events`;
1923
+ const url = `${transport.apiUrl}/v1/eval-runs/${seg2(runId)}/events`;
1543
1924
  const source = readSse({
1544
1925
  url,
1545
1926
  headers: transport.authHeaders(),
@@ -1559,7 +1940,7 @@ function makeEvalRunsClient(transport) {
1559
1940
 
1560
1941
  // src/resources/eval-suites.ts
1561
1942
  function makeEvalSuitesClient(transport) {
1562
- const seg = (s) => encodeURIComponent(s);
1943
+ const seg2 = (s) => encodeURIComponent(s);
1563
1944
  return {
1564
1945
  async publish(input, options) {
1565
1946
  return transport.request({
@@ -1587,13 +1968,13 @@ function makeEvalSuitesClient(transport) {
1587
1968
  async get(suiteId) {
1588
1969
  return transport.request({
1589
1970
  method: "GET",
1590
- path: `/v1/eval-suites/${seg(suiteId)}`
1971
+ path: `/v1/eval-suites/${seg2(suiteId)}`
1591
1972
  });
1592
1973
  },
1593
1974
  async buildFromJudgments(suiteId, input, options) {
1594
1975
  return transport.request({
1595
1976
  method: "POST",
1596
- path: `/v1/eval-suites/${seg(suiteId)}/versions/from-judgments`,
1977
+ path: `/v1/eval-suites/${seg2(suiteId)}/versions/from-judgments`,
1597
1978
  body: input,
1598
1979
  ...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
1599
1980
  });
@@ -1601,7 +1982,7 @@ function makeEvalSuitesClient(transport) {
1601
1982
  async listCases(suiteId, version, query) {
1602
1983
  return transport.request({
1603
1984
  method: "GET",
1604
- path: `/v1/eval-suites/${seg(suiteId)}/versions/${seg(version)}/cases`,
1985
+ path: `/v1/eval-suites/${seg2(suiteId)}/versions/${seg2(version)}/cases`,
1605
1986
  query: {
1606
1987
  ...query?.limit !== void 0 && { limit: query.limit },
1607
1988
  ...query?.cursor !== void 0 && { cursor: query.cursor }
@@ -1612,7 +1993,7 @@ function makeEvalSuitesClient(transport) {
1612
1993
  async list(suiteId, filter) {
1613
1994
  return transport.request({
1614
1995
  method: "GET",
1615
- path: `/v1/eval-suites/${seg(suiteId)}/versions`,
1996
+ path: `/v1/eval-suites/${seg2(suiteId)}/versions`,
1616
1997
  query: {
1617
1998
  ...filter?.limit !== void 0 && { limit: filter.limit },
1618
1999
  ...filter?.cursor !== void 0 && { cursor: filter.cursor }
@@ -1622,20 +2003,20 @@ function makeEvalSuitesClient(transport) {
1622
2003
  async get(suiteId, version) {
1623
2004
  return transport.request({
1624
2005
  method: "GET",
1625
- path: `/v1/eval-suites/${seg(suiteId)}/versions/${seg(version)}`
2006
+ path: `/v1/eval-suites/${seg2(suiteId)}/versions/${seg2(version)}`
1626
2007
  });
1627
2008
  },
1628
2009
  async unregister(suiteId, version, options) {
1629
2010
  return transport.request({
1630
2011
  method: "POST",
1631
- path: `/v1/eval-suites/${seg(suiteId)}/versions/${seg(version)}/unregister`,
2012
+ path: `/v1/eval-suites/${seg2(suiteId)}/versions/${seg2(version)}/unregister`,
1632
2013
  ...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
1633
2014
  });
1634
2015
  },
1635
2016
  async reinstate(suiteId, version, options) {
1636
2017
  return transport.request({
1637
2018
  method: "POST",
1638
- path: `/v1/eval-suites/${seg(suiteId)}/versions/${seg(version)}/reinstate`,
2019
+ path: `/v1/eval-suites/${seg2(suiteId)}/versions/${seg2(version)}/reinstate`,
1639
2020
  ...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
1640
2021
  });
1641
2022
  }
@@ -1758,7 +2139,7 @@ function makeEventsClient(_transport) {
1758
2139
  new KindgiApiError(
1759
2140
  notYetWired(
1760
2141
  "events.stream",
1761
- "no GET /v1/events/subscriptions/{id}/stream route on the API \u2014 subscription-scoped SSE surface has not landed (runtime event bus is live; SDK-side SSE reader is ready via readSse; HTTP route pending). Use client.runs.stream(runId) for live run-scoped events."
2142
+ "no GET /v1/events/subscriptions/{id}/stream route on the API \u2014 subscription-scoped SSE surface has not landed (runtime event bus is live; SDK-side SSE reader is ready via readSse; HTTP route pending). Use client.runs.follow(runId) for live run-scoped events."
1762
2143
  )
1763
2144
  )
1764
2145
  );
@@ -1779,6 +2160,19 @@ function makeEventsClient(_transport) {
1779
2160
  };
1780
2161
  }
1781
2162
 
2163
+ // src/resources/export-signing-keys.ts
2164
+ function makeExportSigningKeysClient(transport) {
2165
+ return {
2166
+ async list() {
2167
+ const page = await transport.request({
2168
+ method: "GET",
2169
+ path: "/v1/export-signing-keys"
2170
+ });
2171
+ return page.data;
2172
+ }
2173
+ };
2174
+ }
2175
+
1782
2176
  // src/resources/flows.ts
1783
2177
  function makeFlowsClient(transport) {
1784
2178
  const list = async (id, filter) => {
@@ -1885,7 +2279,7 @@ function makeFlowsClient(transport) {
1885
2279
 
1886
2280
  // src/resources/gate-policies.ts
1887
2281
  function makeGatePoliciesClient(transport) {
1888
- const seg = (s) => encodeURIComponent(s);
2282
+ const seg2 = (s) => encodeURIComponent(s);
1889
2283
  return {
1890
2284
  async list(filter) {
1891
2285
  return transport.request({
@@ -1902,7 +2296,7 @@ function makeGatePoliciesClient(transport) {
1902
2296
  async get(policyId) {
1903
2297
  return transport.request({
1904
2298
  method: "GET",
1905
- path: `/v1/gate-policies/${seg(policyId)}`
2299
+ path: `/v1/gate-policies/${seg2(policyId)}`
1906
2300
  });
1907
2301
  },
1908
2302
  async publish(input, options) {
@@ -1917,25 +2311,25 @@ function makeGatePoliciesClient(transport) {
1917
2311
  async list(policyId) {
1918
2312
  return transport.request({
1919
2313
  method: "GET",
1920
- path: `/v1/gate-policies/${seg(policyId)}/versions`
2314
+ path: `/v1/gate-policies/${seg2(policyId)}/versions`
1921
2315
  });
1922
2316
  },
1923
2317
  async get(policyId, version) {
1924
2318
  return transport.request({
1925
2319
  method: "GET",
1926
- path: `/v1/gate-policies/${seg(policyId)}/versions/${seg(version)}`
2320
+ path: `/v1/gate-policies/${seg2(policyId)}/versions/${seg2(version)}`
1927
2321
  });
1928
2322
  },
1929
2323
  async unregister(policyId, version) {
1930
2324
  return transport.request({
1931
2325
  method: "POST",
1932
- path: `/v1/gate-policies/${seg(policyId)}/versions/${seg(version)}/unregister`
2326
+ path: `/v1/gate-policies/${seg2(policyId)}/versions/${seg2(version)}/unregister`
1933
2327
  });
1934
2328
  },
1935
2329
  async reinstate(policyId, version) {
1936
2330
  return transport.request({
1937
2331
  method: "POST",
1938
- path: `/v1/gate-policies/${seg(policyId)}/versions/${seg(version)}/reinstate`
2332
+ path: `/v1/gate-policies/${seg2(policyId)}/versions/${seg2(version)}/reinstate`
1939
2333
  });
1940
2334
  }
1941
2335
  }
@@ -2008,7 +2402,7 @@ function makeGuardrailsClient(transport) {
2008
2402
 
2009
2403
  // src/resources/identity.ts
2010
2404
  function makeIdentityClient(transport) {
2011
- const seg = (s) => encodeURIComponent(s);
2405
+ const seg2 = (s) => encodeURIComponent(s);
2012
2406
  return {
2013
2407
  async whoami() {
2014
2408
  return transport.request({
@@ -2031,19 +2425,19 @@ function makeIdentityClient(transport) {
2031
2425
  async get(userId) {
2032
2426
  return transport.request({
2033
2427
  method: "GET",
2034
- path: `/v1/identity/users/${seg(userId)}`
2428
+ path: `/v1/identity/users/${seg2(userId)}`
2035
2429
  });
2036
2430
  },
2037
2431
  async listSessions(userId) {
2038
2432
  return transport.request({
2039
2433
  method: "GET",
2040
- path: `/v1/identity/users/${seg(userId)}/sessions`
2434
+ path: `/v1/identity/users/${seg2(userId)}/sessions`
2041
2435
  });
2042
2436
  },
2043
2437
  async revokeSessions(userId, options) {
2044
2438
  return transport.request({
2045
2439
  method: "POST",
2046
- path: `/v1/identity/users/${seg(userId)}/revoke-sessions`,
2440
+ path: `/v1/identity/users/${seg2(userId)}/revoke-sessions`,
2047
2441
  ...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
2048
2442
  });
2049
2443
  }
@@ -2051,6 +2445,38 @@ function makeIdentityClient(transport) {
2051
2445
  };
2052
2446
  }
2053
2447
 
2448
+ // src/resources/improvement-passes.ts
2449
+ function makeImprovementPassesClient(transport) {
2450
+ return {
2451
+ async list(input = {}) {
2452
+ const page = await transport.request({
2453
+ method: "GET",
2454
+ path: "/v1/improvement-passes",
2455
+ query: {
2456
+ ...input.limit !== void 0 && { limit: input.limit },
2457
+ ...input.cursor !== void 0 && { cursor: input.cursor },
2458
+ ...input.agentId !== void 0 && { agentId: input.agentId }
2459
+ }
2460
+ });
2461
+ return listPage(page);
2462
+ },
2463
+ async get(passId) {
2464
+ return transport.request({
2465
+ method: "GET",
2466
+ path: `/v1/improvement-passes/${encodeURIComponent(passId)}`
2467
+ });
2468
+ },
2469
+ async cancel(passId, input = {}) {
2470
+ return transport.request({
2471
+ method: "POST",
2472
+ path: `/v1/improvement-passes/${encodeURIComponent(passId)}/cancel`,
2473
+ body: {},
2474
+ ...input.idempotencyKey !== void 0 && { idempotencyKey: input.idempotencyKey }
2475
+ });
2476
+ }
2477
+ };
2478
+ }
2479
+
2054
2480
  // src/resources/judge-classes.ts
2055
2481
  function scopeQuery2(scope) {
2056
2482
  if (scope.kind === "tenant") return { scopeKind: "tenant" };
@@ -2278,49 +2704,132 @@ function makeMcpClient(transport) {
2278
2704
  // src/resources/memory.ts
2279
2705
  function makeMemoryClient(transport) {
2280
2706
  return {
2281
- facts: {
2282
- async write(input, options) {
2707
+ erasures: {
2708
+ async create(selector, options) {
2283
2709
  return transport.request({
2284
2710
  method: "POST",
2285
- path: "/v1/memory/facts",
2286
- body: input,
2711
+ path: "/v1/memory/erasures",
2712
+ body: selector,
2287
2713
  ...options?.idempotencyKey !== void 0 && {
2288
2714
  idempotencyKey: options.idempotencyKey
2289
2715
  }
2290
2716
  });
2291
2717
  },
2292
- async read(id) {
2718
+ async get(id) {
2293
2719
  return transport.request({
2294
2720
  method: "GET",
2295
- path: `/v1/memory/facts/${encodeURIComponent(id)}`
2721
+ path: `/v1/memory/erasures/${encodeURIComponent(id)}`
2296
2722
  });
2297
2723
  },
2298
2724
  async list(filter) {
2299
2725
  const page = await transport.request({
2300
2726
  method: "GET",
2301
- path: "/v1/memory/facts",
2727
+ path: "/v1/memory/erasures",
2302
2728
  query: {
2303
2729
  ...filter?.limit !== void 0 && { limit: filter.limit },
2304
- ...filter?.cursor !== void 0 && { cursor: filter.cursor },
2305
- ...filter?.type !== void 0 && { type: filter.type },
2306
- ...filter?.scope !== void 0 && { scope: JSON.stringify(filter.scope) }
2730
+ ...filter?.cursor !== void 0 && { cursor: filter.cursor }
2307
2731
  }
2308
2732
  });
2309
2733
  return listPage(page);
2310
2734
  },
2311
- async delete(id, options) {
2735
+ async resume(id, options) {
2312
2736
  return transport.request({
2313
2737
  method: "POST",
2314
- path: `/v1/memory/facts/${encodeURIComponent(id)}/supersede`,
2315
- body: {},
2738
+ path: `/v1/memory/erasures/${encodeURIComponent(id)}/resume`,
2739
+ body: { ...options?.force === true && { force: true } }
2740
+ });
2741
+ },
2742
+ async export() {
2743
+ const ledger = await transport.request({ method: "GET", path: "/v1/memory/erasures/export" });
2744
+ return ledger.data;
2745
+ },
2746
+ async replay(erasures, options) {
2747
+ return transport.request({
2748
+ method: "POST",
2749
+ path: "/v1/memory/erasures/replay",
2750
+ body: { erasures },
2316
2751
  ...options?.idempotencyKey !== void 0 && {
2317
2752
  idempotencyKey: options.idempotencyKey
2318
2753
  }
2319
2754
  });
2320
2755
  }
2321
2756
  },
2322
- logs: {
2323
- async append(_input) {
2757
+ facts: {
2758
+ async write(input, options) {
2759
+ return transport.request({
2760
+ method: "POST",
2761
+ path: "/v1/memory/facts",
2762
+ body: input,
2763
+ ...options?.idempotencyKey !== void 0 && {
2764
+ idempotencyKey: options.idempotencyKey
2765
+ }
2766
+ });
2767
+ },
2768
+ async read(id, options) {
2769
+ return transport.request({
2770
+ method: "GET",
2771
+ path: `/v1/memory/facts/${encodeURIComponent(id)}`,
2772
+ query: {
2773
+ ...options?.version !== void 0 && { version: options.version },
2774
+ ...options?.asOf !== void 0 && { asOf: options.asOf }
2775
+ }
2776
+ });
2777
+ },
2778
+ async revisions(id) {
2779
+ const envelope = await transport.request({
2780
+ method: "GET",
2781
+ path: `/v1/memory/facts/${encodeURIComponent(id)}/revisions`
2782
+ });
2783
+ return envelope.data;
2784
+ },
2785
+ async list(filter) {
2786
+ const page = await transport.request({
2787
+ method: "GET",
2788
+ path: "/v1/memory/facts",
2789
+ query: {
2790
+ ...filter?.limit !== void 0 && { limit: filter.limit },
2791
+ ...filter?.cursor !== void 0 && { cursor: filter.cursor },
2792
+ ...filter?.type !== void 0 && { type: filter.type },
2793
+ ...filter?.scope !== void 0 && { scope: JSON.stringify(filter.scope) },
2794
+ ...filter?.asOf !== void 0 && { asOf: filter.asOf }
2795
+ }
2796
+ });
2797
+ return listPage(page);
2798
+ },
2799
+ async supersede(id, input, options) {
2800
+ return transport.request({
2801
+ method: "POST",
2802
+ path: `/v1/memory/facts/${encodeURIComponent(id)}/supersede`,
2803
+ body: input,
2804
+ ...options?.idempotencyKey !== void 0 && {
2805
+ idempotencyKey: options.idempotencyKey
2806
+ }
2807
+ });
2808
+ },
2809
+ async delete(id, options) {
2810
+ return transport.request({
2811
+ method: "DELETE",
2812
+ path: `/v1/memory/facts/${encodeURIComponent(id)}`,
2813
+ query: {
2814
+ ...options?.expectVersion !== void 0 && { expectVersion: options.expectVersion }
2815
+ }
2816
+ });
2817
+ },
2818
+ async verify(id, options) {
2819
+ return transport.request({
2820
+ method: "POST",
2821
+ path: `/v1/memory/facts/${encodeURIComponent(id)}/verify`,
2822
+ body: {
2823
+ ...options?.expectVersion !== void 0 && { expectVersion: options.expectVersion }
2824
+ },
2825
+ ...options?.idempotencyKey !== void 0 && {
2826
+ idempotencyKey: options.idempotencyKey
2827
+ }
2828
+ });
2829
+ }
2830
+ },
2831
+ logs: {
2832
+ async append(_input) {
2324
2833
  throw new KindgiApiError(
2325
2834
  notYetWired(
2326
2835
  "memory.logs.append",
@@ -2402,7 +2911,7 @@ function makeObservationsClient(transport) {
2402
2911
 
2403
2912
  // src/resources/orgs.ts
2404
2913
  function makeOrgsClient(transport) {
2405
- const seg = (s) => encodeURIComponent(s);
2914
+ const seg2 = (s) => encodeURIComponent(s);
2406
2915
  return {
2407
2916
  async create(input, options) {
2408
2917
  return transport.request({
@@ -2425,13 +2934,13 @@ function makeOrgsClient(transport) {
2425
2934
  async get(orgId) {
2426
2935
  return transport.request({
2427
2936
  method: "GET",
2428
- path: `/v1/orgs/${seg(orgId)}`
2937
+ path: `/v1/orgs/${seg2(orgId)}`
2429
2938
  });
2430
2939
  },
2431
2940
  async update(orgId, input, options) {
2432
2941
  return transport.request({
2433
2942
  method: "PATCH",
2434
- path: `/v1/orgs/${seg(orgId)}`,
2943
+ path: `/v1/orgs/${seg2(orgId)}`,
2435
2944
  body: input,
2436
2945
  ...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
2437
2946
  });
@@ -2439,7 +2948,7 @@ function makeOrgsClient(transport) {
2439
2948
  async delete(orgId) {
2440
2949
  return transport.request({
2441
2950
  method: "DELETE",
2442
- path: `/v1/orgs/${seg(orgId)}`,
2951
+ path: `/v1/orgs/${seg2(orgId)}`,
2443
2952
  discardResponse: true
2444
2953
  });
2445
2954
  }
@@ -2606,7 +3115,7 @@ function makePoliciesClient(transport) {
2606
3115
 
2607
3116
  // src/resources/projects.ts
2608
3117
  function makeProjectsClient(transport) {
2609
- const seg = (s) => encodeURIComponent(s);
3118
+ const seg2 = (s) => encodeURIComponent(s);
2610
3119
  return {
2611
3120
  async create(input, options) {
2612
3121
  return transport.request({
@@ -2635,13 +3144,13 @@ function makeProjectsClient(transport) {
2635
3144
  async get(projectId) {
2636
3145
  return transport.request({
2637
3146
  method: "GET",
2638
- path: `/v1/projects/${seg(projectId)}`
3147
+ path: `/v1/projects/${seg2(projectId)}`
2639
3148
  });
2640
3149
  },
2641
3150
  async update(projectId, input, options) {
2642
3151
  return transport.request({
2643
3152
  method: "PATCH",
2644
- path: `/v1/projects/${seg(projectId)}`,
3153
+ path: `/v1/projects/${seg2(projectId)}`,
2645
3154
  body: input,
2646
3155
  ...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
2647
3156
  });
@@ -2649,7 +3158,7 @@ function makeProjectsClient(transport) {
2649
3158
  async delete(projectId) {
2650
3159
  return transport.request({
2651
3160
  method: "DELETE",
2652
- path: `/v1/projects/${seg(projectId)}`,
3161
+ path: `/v1/projects/${seg2(projectId)}`,
2653
3162
  discardResponse: true
2654
3163
  });
2655
3164
  },
@@ -2657,7 +3166,7 @@ function makeProjectsClient(transport) {
2657
3166
  async list(projectId, filter) {
2658
3167
  return transport.request({
2659
3168
  method: "GET",
2660
- path: `/v1/projects/${seg(projectId)}/memberships`,
3169
+ path: `/v1/projects/${seg2(projectId)}/memberships`,
2661
3170
  query: {
2662
3171
  ...filter?.limit !== void 0 && { limit: filter.limit },
2663
3172
  ...filter?.cursor !== void 0 && { cursor: filter.cursor }
@@ -2667,7 +3176,7 @@ function makeProjectsClient(transport) {
2667
3176
  async add(projectId, input, options) {
2668
3177
  return transport.request({
2669
3178
  method: "POST",
2670
- path: `/v1/projects/${seg(projectId)}/memberships`,
3179
+ path: `/v1/projects/${seg2(projectId)}/memberships`,
2671
3180
  body: input,
2672
3181
  ...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
2673
3182
  });
@@ -2675,7 +3184,7 @@ function makeProjectsClient(transport) {
2675
3184
  async updateRole(projectId, userId, role, options) {
2676
3185
  return transport.request({
2677
3186
  method: "PATCH",
2678
- path: `/v1/projects/${seg(projectId)}/memberships/${seg(userId)}`,
3187
+ path: `/v1/projects/${seg2(projectId)}/memberships/${seg2(userId)}`,
2679
3188
  body: { role },
2680
3189
  discardResponse: true,
2681
3190
  ...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
@@ -2684,7 +3193,7 @@ function makeProjectsClient(transport) {
2684
3193
  async remove(projectId, userId, options) {
2685
3194
  return transport.request({
2686
3195
  method: "DELETE",
2687
- path: `/v1/projects/${seg(projectId)}/memberships/${seg(userId)}`,
3196
+ path: `/v1/projects/${seg2(projectId)}/memberships/${seg2(userId)}`,
2688
3197
  discardResponse: true,
2689
3198
  ...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
2690
3199
  });
@@ -2693,6 +3202,71 @@ function makeProjectsClient(transport) {
2693
3202
  };
2694
3203
  }
2695
3204
 
3205
+ // src/resources/proposals.ts
3206
+ var seg = (id) => encodeURIComponent(id);
3207
+ function makeProposalsClient(transport) {
3208
+ const post = (req) => transport.request({
3209
+ method: "POST",
3210
+ path: req.path,
3211
+ body: req.body,
3212
+ ...req.idempotencyKey !== void 0 && { idempotencyKey: req.idempotencyKey }
3213
+ });
3214
+ return {
3215
+ async list(input = {}) {
3216
+ const page = await transport.request({
3217
+ method: "GET",
3218
+ path: "/v1/proposals",
3219
+ query: {
3220
+ ...input.limit !== void 0 && { limit: input.limit },
3221
+ ...input.cursor !== void 0 && { cursor: input.cursor },
3222
+ ...input.agentId !== void 0 && { agentId: input.agentId },
3223
+ ...input.tier !== void 0 && { tier: input.tier },
3224
+ ...input.status !== void 0 && { status: input.status },
3225
+ ...input.scope !== void 0 && scopeQuery(input.scope)
3226
+ }
3227
+ });
3228
+ return listPage(page);
3229
+ },
3230
+ async get(id) {
3231
+ return transport.request({ method: "GET", path: `/v1/proposals/${seg(id)}` });
3232
+ },
3233
+ async create(input) {
3234
+ const { idempotencyKey, ...body } = input;
3235
+ return transport.request({
3236
+ method: "POST",
3237
+ path: "/v1/proposals",
3238
+ body,
3239
+ ...idempotencyKey !== void 0 && { idempotencyKey }
3240
+ });
3241
+ },
3242
+ async evaluate(id, input) {
3243
+ const { idempotencyKey, ...body } = input;
3244
+ return post({ path: `/v1/proposals/${seg(id)}/evaluate`, body, idempotencyKey });
3245
+ },
3246
+ async request(id, input = {}) {
3247
+ const { idempotencyKey, ...body } = input;
3248
+ return post({ path: `/v1/proposals/${seg(id)}/request`, body, idempotencyKey });
3249
+ },
3250
+ async rollback(id, input = {}) {
3251
+ const { idempotencyKey, ...body } = input;
3252
+ return post({ path: `/v1/proposals/${seg(id)}/rollback`, body, idempotencyKey });
3253
+ },
3254
+ async withdraw(id, input) {
3255
+ const { idempotencyKey, ...body } = input;
3256
+ return post({ path: `/v1/proposals/${seg(id)}/withdraw`, body, idempotencyKey });
3257
+ },
3258
+ async improve(input) {
3259
+ const { idempotencyKey, ...body } = input;
3260
+ return transport.request({
3261
+ method: "POST",
3262
+ path: "/v1/proposals/improve",
3263
+ body,
3264
+ ...idempotencyKey !== void 0 && { idempotencyKey }
3265
+ });
3266
+ }
3267
+ };
3268
+ }
3269
+
2696
3270
  // src/resources/provenance.ts
2697
3271
  function makeProvenanceClient(transport) {
2698
3272
  return {
@@ -2726,26 +3300,22 @@ function makeProvenanceClient(transport) {
2726
3300
  method: "POST",
2727
3301
  path: `/v1/provenance/${encodeURIComponent(input.runId)}/export`,
2728
3302
  body: {
2729
- signingKeyId: input.signingKeyId,
3303
+ ...input.signingKeyId !== void 0 && { signingKeyId: input.signingKeyId },
2730
3304
  ...input.includeMessages !== void 0 && { includeMessages: input.includeMessages }
2731
3305
  },
2732
3306
  ...input.idempotencyKey !== void 0 && { idempotencyKey: input.idempotencyKey }
2733
3307
  });
2734
3308
  },
2735
- async verify(_exported, _publicKey) {
2736
- throw new KindgiApiError(
2737
- notYetWired(
2738
- "provenance.verify",
2739
- "client-side ed25519 verification requires the crypto module subpackage to be reachable from the SDK"
2740
- )
2741
- );
3309
+ async verify(exported, publicKey) {
3310
+ const checked = await verifySignedExport(exported, { trustedKeys: [publicKey] });
3311
+ return checked.valid ? { valid: true } : { valid: false, issues: checked.issues ?? [] };
2742
3312
  }
2743
3313
  };
2744
3314
  }
2745
3315
 
2746
3316
  // src/resources/providers.ts
2747
3317
  function makeProvidersClient(transport) {
2748
- const seg = (s) => encodeURIComponent(s);
3318
+ const seg2 = (s) => encodeURIComponent(s);
2749
3319
  return {
2750
3320
  async register(input, options) {
2751
3321
  return transport.request({
@@ -2769,19 +3339,25 @@ function makeProvidersClient(transport) {
2769
3339
  async get(providerId) {
2770
3340
  return transport.request({
2771
3341
  method: "GET",
2772
- path: `/v1/providers/${seg(providerId)}`
3342
+ path: `/v1/providers/${seg2(providerId)}`
2773
3343
  });
2774
3344
  },
2775
3345
  async capabilities(providerId) {
2776
3346
  return transport.request({
2777
3347
  method: "GET",
2778
- path: `/v1/providers/${seg(providerId)}/capabilities`
3348
+ path: `/v1/providers/${seg2(providerId)}/capabilities`
3349
+ });
3350
+ },
3351
+ async check(providerId) {
3352
+ return transport.request({
3353
+ method: "GET",
3354
+ path: `/v1/providers/${seg2(providerId)}/check`
2779
3355
  });
2780
3356
  },
2781
3357
  async unregister(providerId, options) {
2782
3358
  return transport.request({
2783
3359
  method: "POST",
2784
- path: `/v1/providers/${seg(providerId)}/unregister`,
3360
+ path: `/v1/providers/${seg2(providerId)}/unregister`,
2785
3361
  ...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
2786
3362
  });
2787
3363
  }
@@ -2893,7 +3469,42 @@ function subscribeToRun(options) {
2893
3469
  }
2894
3470
 
2895
3471
  // src/resources/runs.ts
3472
+ function waitedStartTimeout(e) {
3473
+ if (!(e instanceof KindgiApiError) || e.error.code !== "network") return e;
3474
+ const { timeoutMs } = e.error;
3475
+ if (timeoutMs === void 0) return e;
3476
+ return new KindgiApiError({
3477
+ code: "network",
3478
+ message: `The run didn't end within ${seconds(timeoutMs)}, the client's timeout (timeoutMs). A waited start answers only when the run ends, so the run may still be going, and its id didn't arrive. Start a run that can take longer with \`options: { wait: false }\`: the answer carries its id at once. Then follow it with \`runs.stream(runId)\` or \`runs.get(runId)\`. Or raise \`timeoutMs\`.`,
3479
+ cause: e.error.cause,
3480
+ timeoutMs
3481
+ });
3482
+ }
2896
3483
  function makeRunsClient(transport) {
3484
+ const followEvents = (runId, options) => followRun({
3485
+ url: `${transport.apiUrl}/v1/runs/${encodeURIComponent(runId)}/stream`,
3486
+ headers: () => transport.authHeaders(),
3487
+ fetchImpl: transport.fetchImpl,
3488
+ ...options?.signal !== void 0 && { signal: options.signal },
3489
+ ...options?.initialBackoffMs !== void 0 && {
3490
+ initialBackoffMs: options.initialBackoffMs
3491
+ },
3492
+ ...options?.maxBackoffMs !== void 0 && {
3493
+ maxBackoffMs: options.maxBackoffMs
3494
+ }
3495
+ });
3496
+ const followProgressEvents = (runId, options) => followRun({
3497
+ url: `${transport.apiUrl}/v1/runs/${encodeURIComponent(runId)}/progress/stream`,
3498
+ headers: () => transport.authHeaders(),
3499
+ fetchImpl: transport.fetchImpl,
3500
+ ...options?.signal !== void 0 && { signal: options.signal },
3501
+ ...options?.initialBackoffMs !== void 0 && {
3502
+ initialBackoffMs: options.initialBackoffMs
3503
+ },
3504
+ ...options?.maxBackoffMs !== void 0 && {
3505
+ maxBackoffMs: options.maxBackoffMs
3506
+ }
3507
+ });
2897
3508
  return {
2898
3509
  async start(input) {
2899
3510
  const body = "agent" in input ? {
@@ -2911,14 +3522,19 @@ function makeRunsClient(transport) {
2911
3522
  input: input.input,
2912
3523
  ...input.options !== void 0 && { options: input.options }
2913
3524
  };
2914
- return transport.request({
2915
- method: "POST",
2916
- path: "/v1/runs",
2917
- body,
2918
- ...input.idempotencyKey !== void 0 && {
2919
- idempotencyKey: input.idempotencyKey
2920
- }
2921
- });
3525
+ try {
3526
+ return await transport.request({
3527
+ method: "POST",
3528
+ path: "/v1/runs",
3529
+ body,
3530
+ ...input.idempotencyKey !== void 0 && {
3531
+ idempotencyKey: input.idempotencyKey
3532
+ },
3533
+ ...input.timeoutMs !== void 0 && { timeoutMs: input.timeoutMs }
3534
+ });
3535
+ } catch (e) {
3536
+ throw input.options?.wait === false ? e : waitedStartTimeout(e);
3537
+ }
2922
3538
  },
2923
3539
  async dryRun(_input) {
2924
3540
  throw new KindgiApiError(
@@ -2934,34 +3550,10 @@ function makeRunsClient(transport) {
2934
3550
  path: `/v1/runs/${encodeURIComponent(runId)}/progress`
2935
3551
  });
2936
3552
  },
2937
- streamProgress(runId, options) {
2938
- return followRun({
2939
- url: `${transport.apiUrl}/v1/runs/${encodeURIComponent(runId)}/progress/stream`,
2940
- headers: () => transport.authHeaders(),
2941
- fetchImpl: transport.fetchImpl,
2942
- ...options?.signal !== void 0 && { signal: options.signal },
2943
- ...options?.initialBackoffMs !== void 0 && {
2944
- initialBackoffMs: options.initialBackoffMs
2945
- },
2946
- ...options?.maxBackoffMs !== void 0 && {
2947
- maxBackoffMs: options.maxBackoffMs
2948
- }
2949
- });
2950
- },
2951
- stream(runId, options) {
2952
- return followRun({
2953
- url: `${transport.apiUrl}/v1/runs/${encodeURIComponent(runId)}/stream`,
2954
- headers: () => transport.authHeaders(),
2955
- fetchImpl: transport.fetchImpl,
2956
- ...options?.signal !== void 0 && { signal: options.signal },
2957
- ...options?.initialBackoffMs !== void 0 && {
2958
- initialBackoffMs: options.initialBackoffMs
2959
- },
2960
- ...options?.maxBackoffMs !== void 0 && {
2961
- maxBackoffMs: options.maxBackoffMs
2962
- }
2963
- });
2964
- },
3553
+ followProgress: followProgressEvents,
3554
+ follow: followEvents,
3555
+ streamProgress: followProgressEvents,
3556
+ stream: followEvents,
2965
3557
  async get(runId) {
2966
3558
  return transport.request({
2967
3559
  method: "GET",
@@ -3006,6 +3598,7 @@ function makeRunsClient(transport) {
3006
3598
  ...filter?.agentId !== void 0 && { agentId: filter.agentId },
3007
3599
  ...filter?.replays !== void 0 && { replays: filter.replays },
3008
3600
  ...filter?.evalRunId !== void 0 && { evalRunId: filter.evalRunId },
3601
+ ...filter?.triggerId !== void 0 && { triggerId: filter.triggerId },
3009
3602
  ...filter?.includeOutput === true && { include: "output" }
3010
3603
  }
3011
3604
  });
@@ -3046,10 +3639,11 @@ function makeSchedulesClient(transport) {
3046
3639
  }
3047
3640
  });
3048
3641
  },
3049
- async get(triggerId) {
3642
+ async get(triggerId, options) {
3050
3643
  return transport.request({
3051
3644
  method: "GET",
3052
- path: `/v1/schedules/${encodeURIComponent(triggerId)}`
3645
+ path: `/v1/schedules/${encodeURIComponent(triggerId)}`,
3646
+ ...options?.upcoming !== void 0 && { query: { upcoming: options.upcoming } }
3053
3647
  });
3054
3648
  },
3055
3649
  async update(triggerId, input, options) {
@@ -3080,6 +3674,30 @@ function makeSchedulesClient(transport) {
3080
3674
  path: `/v1/schedules/${encodeURIComponent(triggerId)}/unregister`,
3081
3675
  ...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
3082
3676
  });
3677
+ },
3678
+ async fires(triggerId, filter) {
3679
+ return transport.request({
3680
+ method: "GET",
3681
+ path: `/v1/schedules/${encodeURIComponent(triggerId)}/fires`,
3682
+ query: {
3683
+ ...filter?.limit !== void 0 && { limit: filter.limit },
3684
+ ...filter?.cursor !== void 0 && { cursor: filter.cursor }
3685
+ }
3686
+ });
3687
+ },
3688
+ async runNow(triggerId, options) {
3689
+ return transport.request({
3690
+ method: "POST",
3691
+ path: `/v1/schedules/${encodeURIComponent(triggerId)}/run-now`,
3692
+ ...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
3693
+ });
3694
+ },
3695
+ async takeOwnership(triggerId, options) {
3696
+ return transport.request({
3697
+ method: "POST",
3698
+ path: `/v1/schedules/${encodeURIComponent(triggerId)}/owner`,
3699
+ ...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
3700
+ });
3083
3701
  }
3084
3702
  };
3085
3703
  }
@@ -3241,8 +3859,8 @@ function makeSecretsClient(transport) {
3241
3859
  });
3242
3860
  return { kind: "ok", record: ok.record, versionId: ok.versionId };
3243
3861
  } catch (err) {
3244
- const conflict = tryReadVersionConflict(err);
3245
- if (conflict !== null) return conflict;
3862
+ const conflict2 = tryReadVersionConflict(err);
3863
+ if (conflict2 !== null) return conflict2;
3246
3864
  throw err;
3247
3865
  }
3248
3866
  },
@@ -3362,6 +3980,63 @@ function tryReadVersionConflict(err) {
3362
3980
  return { kind: "version-conflict", currentVersion: current };
3363
3981
  }
3364
3982
 
3983
+ // src/resources/service-accounts.ts
3984
+ function makeServiceAccountsClient(transport) {
3985
+ const withKey = (options) => options?.idempotencyKey !== void 0 ? { idempotencyKey: options.idempotencyKey } : {};
3986
+ return {
3987
+ async create(input, options) {
3988
+ return transport.request({
3989
+ method: "POST",
3990
+ path: "/v1/service-accounts",
3991
+ body: input,
3992
+ ...withKey(options)
3993
+ });
3994
+ },
3995
+ async list(filter) {
3996
+ const page = await transport.request({
3997
+ method: "GET",
3998
+ path: "/v1/service-accounts",
3999
+ query: {
4000
+ ...filter?.limit !== void 0 && { limit: filter.limit },
4001
+ ...filter?.cursor !== void 0 && { cursor: filter.cursor },
4002
+ ...filter?.includeUnregistered === true && { includeUnregistered: "true" }
4003
+ }
4004
+ });
4005
+ return listPage(page);
4006
+ },
4007
+ async get(serviceAccountId) {
4008
+ return transport.request({
4009
+ method: "GET",
4010
+ path: `/v1/service-accounts/${encodeURIComponent(serviceAccountId)}`
4011
+ });
4012
+ },
4013
+ async grant(serviceAccountId, grant, options) {
4014
+ return transport.request({
4015
+ method: "POST",
4016
+ path: `/v1/service-accounts/${encodeURIComponent(serviceAccountId)}/grant`,
4017
+ body: grant,
4018
+ ...withKey(options)
4019
+ });
4020
+ },
4021
+ async ungrant(serviceAccountId, grant, options) {
4022
+ return transport.request({
4023
+ method: "POST",
4024
+ path: `/v1/service-accounts/${encodeURIComponent(serviceAccountId)}/ungrant`,
4025
+ body: grant,
4026
+ ...withKey(options)
4027
+ });
4028
+ },
4029
+ async unregister(serviceAccountId, options) {
4030
+ return transport.request({
4031
+ method: "POST",
4032
+ path: `/v1/service-accounts/${encodeURIComponent(serviceAccountId)}/unregister`,
4033
+ body: {},
4034
+ ...withKey(options)
4035
+ });
4036
+ }
4037
+ };
4038
+ }
4039
+
3365
4040
  // src/resources/signing-keys.ts
3366
4041
  function makeSigningKeysClient(transport) {
3367
4042
  return {
@@ -3404,10 +4079,17 @@ function makeSigningKeysClient(transport) {
3404
4079
 
3405
4080
  // src/resources/supervisor.ts
3406
4081
  var REASON_NO_SUPERVISOR_CRUD = "no /v1/supervisors CRUD routes on the API \u2014 supervisor persistence is caller-plugged via SupervisorBinding at deployment boot (framework does NOT own supervisor storage; analogous to the identity-directory pattern for users)";
3407
- function makeSupervisorClient(transport) {
3408
- const supervisorHeader = (supervisorId) => ({
3409
- "X-Supervisor-Id": supervisorId
3410
- });
4082
+ function removed(method, replacement) {
4083
+ return async () => {
4084
+ throw new KindgiApiError(
4085
+ notYetWired(
4086
+ `supervisor.proposals.${method}`,
4087
+ `removed in 0.1.5: proposals now change data blocks; use client.proposals.${replacement} (see client.proposals.create, evaluate and request)`
4088
+ )
4089
+ );
4090
+ };
4091
+ }
4092
+ function makeSupervisorClient(_transport) {
3411
4093
  return {
3412
4094
  async define(_spec) {
3413
4095
  throw new KindgiApiError(notYetWired("supervisor.define", REASON_NO_SUPERVISOR_CRUD));
@@ -3425,114 +4107,22 @@ function makeSupervisorClient(transport) {
3425
4107
  throw new KindgiApiError(notYetWired("supervisor.delete", REASON_NO_SUPERVISOR_CRUD));
3426
4108
  },
3427
4109
  proposals: {
3428
- async draft(input) {
3429
- return transport.request({
3430
- method: "POST",
3431
- path: "/v1/proposals",
3432
- headers: supervisorHeader(input.supervisorId),
3433
- body: {
3434
- agentId: input.agentId,
3435
- agentVersion: input.agentVersion,
3436
- tier: input.tier,
3437
- change: input.change,
3438
- patternRefs: input.patternRefs,
3439
- hypothesis: input.hypothesis,
3440
- proposerRuleId: input.proposerRuleId
3441
- },
3442
- ...input.idempotencyKey !== void 0 && { idempotencyKey: input.idempotencyKey }
3443
- });
3444
- },
3445
- async list(input) {
3446
- const page = await transport.request({
3447
- method: "GET",
3448
- path: "/v1/proposals",
3449
- headers: supervisorHeader(input.supervisorId),
3450
- query: {
3451
- ...input.limit !== void 0 && { limit: input.limit },
3452
- ...input.cursor !== void 0 && { cursor: input.cursor },
3453
- ...input.status !== void 0 && { status: input.status },
3454
- ...input.agentId !== void 0 && { agentId: input.agentId },
3455
- ...input.tier !== void 0 && { tier: input.tier }
3456
- }
3457
- });
3458
- return listPage(page);
3459
- },
3460
- async get(supervisorId, id) {
3461
- return transport.request({
3462
- method: "GET",
3463
- path: `/v1/proposals/${encodeURIComponent(id)}`,
3464
- headers: supervisorHeader(supervisorId)
3465
- });
3466
- },
3467
- async dryRun(supervisorId, id, input) {
3468
- return transport.request({
3469
- method: "POST",
3470
- path: `/v1/proposals/${encodeURIComponent(id)}/dry-run`,
3471
- headers: supervisorHeader(supervisorId),
3472
- body: {
3473
- datasetId: input.datasetId,
3474
- datasetVersion: input.datasetVersion,
3475
- criterion: input.criterion
3476
- },
3477
- ...input.idempotencyKey !== void 0 && { idempotencyKey: input.idempotencyKey }
3478
- });
3479
- },
3480
- async submitForReview(supervisorId, id, input) {
3481
- const body = {};
3482
- if (input?.requiredRole !== void 0) body.requiredRole = input.requiredRole;
3483
- if (input?.expiresAt !== void 0) body.expiresAt = input.expiresAt;
3484
- return transport.request({
3485
- method: "POST",
3486
- path: `/v1/proposals/${encodeURIComponent(id)}/submit-review`,
3487
- headers: supervisorHeader(supervisorId),
3488
- body,
3489
- ...input?.idempotencyKey !== void 0 && { idempotencyKey: input.idempotencyKey }
3490
- });
3491
- },
3492
- async reflectReview(_supervisorId, _id, _input) {
3493
- throw new KindgiApiError(
3494
- notYetWired(
3495
- "supervisor.proposals.reflectReview",
3496
- "no POST /v1/proposals/{id}/reflect-review route on the API \u2014 review reflection is atomic with POST /v1/approvals/{id}/complete (wire detects the linked proposal + updates status alongside the decision)"
3497
- )
3498
- );
3499
- },
3500
- async apply(supervisorId, id, input) {
3501
- const body = {};
3502
- if (input?.newVersion !== void 0) body.newVersion = input.newVersion;
3503
- return transport.request({
3504
- method: "POST",
3505
- path: `/v1/proposals/${encodeURIComponent(id)}/apply`,
3506
- headers: supervisorHeader(supervisorId),
3507
- body,
3508
- ...input?.idempotencyKey !== void 0 && { idempotencyKey: input.idempotencyKey }
3509
- });
3510
- },
3511
- async rollback(supervisorId, id, input) {
3512
- return transport.request({
3513
- method: "POST",
3514
- path: `/v1/proposals/${encodeURIComponent(id)}/rollback`,
3515
- headers: supervisorHeader(supervisorId),
3516
- body: { reason: input.reason },
3517
- ...input.idempotencyKey !== void 0 && { idempotencyKey: input.idempotencyKey }
3518
- });
3519
- },
3520
- async withdraw(supervisorId, id, input) {
3521
- return transport.request({
3522
- method: "POST",
3523
- path: `/v1/proposals/${encodeURIComponent(id)}/withdraw`,
3524
- headers: supervisorHeader(supervisorId),
3525
- body: { reason: input.reason },
3526
- ...input.idempotencyKey !== void 0 && { idempotencyKey: input.idempotencyKey }
3527
- });
3528
- }
4110
+ draft: removed("draft", "create"),
4111
+ list: removed("list", "list"),
4112
+ get: removed("get", "get"),
4113
+ dryRun: removed("dryRun", "evaluate"),
4114
+ submitForReview: removed("submitForReview", "request"),
4115
+ reflectReview: removed("reflectReview", "request"),
4116
+ apply: removed("apply", "request"),
4117
+ rollback: removed("rollback", "rollback"),
4118
+ withdraw: removed("withdraw", "withdraw")
3529
4119
  }
3530
4120
  };
3531
4121
  }
3532
4122
 
3533
4123
  // src/resources/teams.ts
3534
4124
  function makeTeamsClient(transport) {
3535
- const seg = (s) => encodeURIComponent(s);
4125
+ const seg2 = (s) => encodeURIComponent(s);
3536
4126
  return {
3537
4127
  async create(input, options) {
3538
4128
  return transport.request({
@@ -3555,13 +4145,13 @@ function makeTeamsClient(transport) {
3555
4145
  async get(teamId) {
3556
4146
  return transport.request({
3557
4147
  method: "GET",
3558
- path: `/v1/teams/${seg(teamId)}`
4148
+ path: `/v1/teams/${seg2(teamId)}`
3559
4149
  });
3560
4150
  },
3561
4151
  async update(teamId, input, options) {
3562
4152
  return transport.request({
3563
4153
  method: "PATCH",
3564
- path: `/v1/teams/${seg(teamId)}`,
4154
+ path: `/v1/teams/${seg2(teamId)}`,
3565
4155
  body: input,
3566
4156
  ...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
3567
4157
  });
@@ -3569,7 +4159,7 @@ function makeTeamsClient(transport) {
3569
4159
  async delete(teamId) {
3570
4160
  return transport.request({
3571
4161
  method: "DELETE",
3572
- path: `/v1/teams/${seg(teamId)}`,
4162
+ path: `/v1/teams/${seg2(teamId)}`,
3573
4163
  discardResponse: true
3574
4164
  });
3575
4165
  },
@@ -3577,7 +4167,7 @@ function makeTeamsClient(transport) {
3577
4167
  async list(teamId, filter) {
3578
4168
  return transport.request({
3579
4169
  method: "GET",
3580
- path: `/v1/teams/${seg(teamId)}/memberships`,
4170
+ path: `/v1/teams/${seg2(teamId)}/memberships`,
3581
4171
  query: {
3582
4172
  ...filter?.limit !== void 0 && { limit: filter.limit },
3583
4173
  ...filter?.cursor !== void 0 && { cursor: filter.cursor }
@@ -3587,7 +4177,7 @@ function makeTeamsClient(transport) {
3587
4177
  async add(teamId, input, options) {
3588
4178
  return transport.request({
3589
4179
  method: "POST",
3590
- path: `/v1/teams/${seg(teamId)}/memberships`,
4180
+ path: `/v1/teams/${seg2(teamId)}/memberships`,
3591
4181
  body: input,
3592
4182
  ...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
3593
4183
  });
@@ -3595,7 +4185,7 @@ function makeTeamsClient(transport) {
3595
4185
  async updateRole(teamId, userId, role, options) {
3596
4186
  return transport.request({
3597
4187
  method: "PATCH",
3598
- path: `/v1/teams/${seg(teamId)}/memberships/${seg(userId)}`,
4188
+ path: `/v1/teams/${seg2(teamId)}/memberships/${seg2(userId)}`,
3599
4189
  body: { role },
3600
4190
  discardResponse: true,
3601
4191
  ...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
@@ -3604,7 +4194,7 @@ function makeTeamsClient(transport) {
3604
4194
  async remove(teamId, userId, options) {
3605
4195
  return transport.request({
3606
4196
  method: "DELETE",
3607
- path: `/v1/teams/${seg(teamId)}/memberships/${seg(userId)}`,
4197
+ path: `/v1/teams/${seg2(teamId)}/memberships/${seg2(userId)}`,
3608
4198
  discardResponse: true,
3609
4199
  ...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
3610
4200
  });
@@ -3651,6 +4241,7 @@ function makeTenantClient(transport) {
3651
4241
  function fromWire2(wire) {
3652
4242
  return {
3653
4243
  id: wire.tokenId,
4244
+ ...wire.principal !== void 0 && { principal: wire.principal },
3654
4245
  role: wire.role,
3655
4246
  capabilities: wire.capabilities,
3656
4247
  ...wire.label !== void 0 && { label: wire.label },
@@ -3668,6 +4259,7 @@ function makeTokensClient(transport) {
3668
4259
  return {
3669
4260
  async create(spec, options) {
3670
4261
  const body = {};
4262
+ if (spec?.for !== void 0) body.for = { kind: spec.for.kind, id: spec.for.id };
3671
4263
  if (spec?.role !== void 0) body.role = spec.role;
3672
4264
  if (spec?.capabilities !== void 0) body.capabilities = spec.capabilities;
3673
4265
  if (spec?.label !== void 0) body.label = spec.label;
@@ -3690,7 +4282,10 @@ function makeTokensClient(transport) {
3690
4282
  path: "/v1/tokens",
3691
4283
  query: {
3692
4284
  ...filter?.limit !== void 0 && { limit: filter.limit },
3693
- ...filter?.cursor !== void 0 && { cursor: filter.cursor }
4285
+ ...filter?.cursor !== void 0 && { cursor: filter.cursor },
4286
+ ...filter?.principal !== void 0 && {
4287
+ principal: `${filter.principal.kind}:${filter.principal.id}`
4288
+ }
3694
4289
  }
3695
4290
  });
3696
4291
  return listPage({ ...page, data: page.data.map(fromWire2) });
@@ -3833,13 +4428,24 @@ function makeToolsClient(transport) {
3833
4428
  // src/resources/users.ts
3834
4429
  function makeUsersClient(transport) {
3835
4430
  return {
3836
- async create(_spec) {
3837
- throw new KindgiApiError(
3838
- notYetWired(
3839
- "users.create",
3840
- "no user-creation route on the wire \u2014 framework does NOT own user persistence (deployments plug LDAP / SCIM / bespoke stores via IdentityDirectoryBinding)"
3841
- )
3842
- );
4431
+ async create(spec, options) {
4432
+ if (spec.orgId !== void 0 || spec.metadata !== void 0) {
4433
+ throw new KindgiApiError(
4434
+ notYetWired("users.create", "`orgId` and `metadata` are not on the wire")
4435
+ );
4436
+ }
4437
+ const created = await transport.request({
4438
+ method: "POST",
4439
+ path: "/v1/identity/users",
4440
+ body: {
4441
+ displayName: spec.displayName,
4442
+ ...spec.email !== void 0 && { primaryEmail: spec.email }
4443
+ },
4444
+ ...options?.idempotencyKey !== void 0 && {
4445
+ idempotencyKey: options.idempotencyKey
4446
+ }
4447
+ });
4448
+ return created.userId;
3843
4449
  },
3844
4450
  async get(id) {
3845
4451
  return transport.request({
@@ -3860,11 +4466,42 @@ function makeUsersClient(transport) {
3860
4466
  query: {
3861
4467
  ...filter?.limit !== void 0 && { limit: filter.limit },
3862
4468
  ...filter?.cursor !== void 0 && { cursor: filter.cursor },
3863
- ...filter?.query !== void 0 && { query: filter.query }
4469
+ ...filter?.query !== void 0 && { query: filter.query },
4470
+ ...filter?.includeUnregistered === true && { includeUnregistered: "true" }
3864
4471
  }
3865
4472
  });
3866
4473
  return listPage(page);
3867
4474
  },
4475
+ async grants(id) {
4476
+ return transport.request({
4477
+ method: "GET",
4478
+ path: `/v1/identity/users/${encodeURIComponent(id)}/grants`
4479
+ });
4480
+ },
4481
+ async grant(id, grant, options) {
4482
+ return transport.request({
4483
+ method: "POST",
4484
+ path: `/v1/identity/users/${encodeURIComponent(id)}/grant`,
4485
+ body: grant,
4486
+ ...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
4487
+ });
4488
+ },
4489
+ async ungrant(id, grant, options) {
4490
+ return transport.request({
4491
+ method: "POST",
4492
+ path: `/v1/identity/users/${encodeURIComponent(id)}/ungrant`,
4493
+ body: grant,
4494
+ ...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
4495
+ });
4496
+ },
4497
+ async unregister(id, options) {
4498
+ return transport.request({
4499
+ method: "POST",
4500
+ path: `/v1/identity/users/${encodeURIComponent(id)}/unregister`,
4501
+ body: {},
4502
+ ...options?.idempotencyKey !== void 0 && { idempotencyKey: options.idempotencyKey }
4503
+ });
4504
+ },
3868
4505
  async update(_id, _patch) {
3869
4506
  throw new KindgiApiError(
3870
4507
  notYetWired(
@@ -4048,127 +4685,6 @@ function makeWebhooksClient(transport) {
4048
4685
  };
4049
4686
  }
4050
4687
 
4051
- // src/transport.ts
4052
- var DEFAULT_TIMEOUT_MS = 3e4;
4053
- var MUTATING = /* @__PURE__ */ new Set([
4054
- "POST",
4055
- "PUT",
4056
- "PATCH",
4057
- "DELETE"
4058
- ]);
4059
- function createTransport(options) {
4060
- const apiUrl = options.apiUrl.replace(/\/+$/u, "");
4061
- const fetchImpl = options.fetch ?? fetch;
4062
- const clientTimeoutMs = DEFAULT_TIMEOUT_MS;
4063
- return {
4064
- apiUrl,
4065
- fetchImpl,
4066
- authHeaders() {
4067
- return { Authorization: `Bearer ${authTokenFor(options.auth)}` };
4068
- },
4069
- async request(input) {
4070
- const url = buildUrl(apiUrl, input.path, input.query);
4071
- const headers = buildHeaders(input, options.auth);
4072
- const timeoutMs = input.timeoutMs ?? clientTimeoutMs;
4073
- const ac = new AbortController();
4074
- const timer = setTimeout(
4075
- () => ac.abort(new Error("timeout")),
4076
- timeoutMs
4077
- );
4078
- let response;
4079
- try {
4080
- response = await fetchImpl(url, {
4081
- method: input.method,
4082
- headers,
4083
- ...input.body !== void 0 && { body: JSON.stringify(input.body) },
4084
- signal: ac.signal
4085
- });
4086
- } catch (cause) {
4087
- clearTimeout(timer);
4088
- const err = {
4089
- code: "network",
4090
- message: cause instanceof Error ? cause.message : "network request failed",
4091
- cause
4092
- };
4093
- throw new KindgiApiError(err);
4094
- }
4095
- clearTimeout(timer);
4096
- if (response.ok) {
4097
- if (input.discardResponse === true || response.status === 204) {
4098
- try {
4099
- await response.arrayBuffer();
4100
- } catch {
4101
- }
4102
- return void 0;
4103
- }
4104
- try {
4105
- return await response.json();
4106
- } catch (cause) {
4107
- const err = {
4108
- code: "network",
4109
- message: "Response body was not valid JSON",
4110
- cause
4111
- };
4112
- throw new KindgiApiError(err);
4113
- }
4114
- }
4115
- let body;
4116
- try {
4117
- body = await response.json();
4118
- } catch {
4119
- body = void 0;
4120
- }
4121
- throw new KindgiApiError(
4122
- fromWire(unwrapErrorEnvelope(body, response.status), response.status)
4123
- );
4124
- }
4125
- };
4126
- }
4127
- function buildUrl(apiUrl, path, query) {
4128
- const normalizedPath = path.startsWith("/") ? path : `/${path}`;
4129
- const base = `${apiUrl}${normalizedPath}`;
4130
- if (query === void 0) return base;
4131
- const params = [];
4132
- for (const key of Object.keys(query)) {
4133
- const value = query[key];
4134
- if (value === void 0) continue;
4135
- const values = typeof value === "object" ? value : [String(value)];
4136
- for (const v of values) params.push(`${encodeURIComponent(key)}=${encodeURIComponent(v)}`);
4137
- }
4138
- return params.length === 0 ? base : `${base}?${params.join("&")}`;
4139
- }
4140
- function buildHeaders(input, auth) {
4141
- const headers = {
4142
- Accept: "application/json",
4143
- Authorization: `Bearer ${authTokenFor(auth)}`
4144
- };
4145
- if (input.body !== void 0) {
4146
- headers["Content-Type"] = "application/json; charset=utf-8";
4147
- }
4148
- if (input.idempotencyKey !== void 0 && MUTATING.has(input.method)) {
4149
- headers["Idempotency-Key"] = input.idempotencyKey;
4150
- }
4151
- if (input.headers !== void 0) {
4152
- for (const key of Object.keys(input.headers)) {
4153
- headers[key] = input.headers[key];
4154
- }
4155
- }
4156
- return headers;
4157
- }
4158
- function authTokenFor(auth) {
4159
- if (auth.kind === "apiToken") return auth.token;
4160
- return auth.accessToken;
4161
- }
4162
- function unwrapErrorEnvelope(body, status) {
4163
- if (body !== null && typeof body === "object" && !Array.isArray(body)) {
4164
- const inner = body.error;
4165
- if (inner !== null && typeof inner === "object" && !Array.isArray(inner)) {
4166
- return inner;
4167
- }
4168
- }
4169
- return { code: "unknown", message: `HTTP ${status} without recognizable error envelope` };
4170
- }
4171
-
4172
4688
  // src/client.ts
4173
4689
  function createClient(options) {
4174
4690
  const transport = createTransport(options);
@@ -4182,7 +4698,9 @@ function createClient(options) {
4182
4698
  conversations: makeConversationsClient(transport),
4183
4699
  memory: makeMemoryClient(transport),
4184
4700
  provenance: makeProvenanceClient(transport),
4185
- supervisor: makeSupervisorClient(transport),
4701
+ supervisor: makeSupervisorClient(),
4702
+ proposals: makeProposalsClient(transport),
4703
+ improvementPasses: makeImprovementPassesClient(transport),
4186
4704
  observations: makeObservationsClient(transport),
4187
4705
  approvals: makeApprovalsClient(transport),
4188
4706
  tenant: makeTenantClient(transport),
@@ -4210,7 +4728,9 @@ function createClient(options) {
4210
4728
  teams: makeTeamsClient(transport),
4211
4729
  orgs: makeOrgsClient(transport),
4212
4730
  signingKeys: makeSigningKeysClient(transport),
4731
+ exportSigningKeys: makeExportSigningKeysClient(transport),
4213
4732
  tokens: makeTokensClient(transport),
4733
+ serviceAccounts: makeServiceAccountsClient(transport),
4214
4734
  mcp: makeMcpClient(transport),
4215
4735
  events: makeEventsClient(),
4216
4736
  eventTriggers: makeEventTriggersClient(transport),
@@ -4221,6 +4741,6 @@ function createClient(options) {
4221
4741
  };
4222
4742
  }
4223
4743
 
4224
- export { KindgiApiError, SseHttpError, comparisonOf, createClient, followRun, fromWire, notImplementedInPreview, notYetWired, readSse, subscribeToRun, unwrapSseData };
4744
+ export { KindgiApiError, SIGNED_EXPORT_ALGORITHMS, SseHttpError, comparisonOf, createClient, followRun, fromWire, notImplementedInPreview, notYetWired, readSse, subscribeToRun, unwrapSseData, verifySignedExport };
4225
4745
  //# sourceMappingURL=index.js.map
4226
4746
  //# sourceMappingURL=index.js.map