branchora-opencode 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +8 -2
  2. package/dist/index.js +1017 -335
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@ var __export = (target, all) => {
8
8
  __defProp(target, name, { get: all[name], enumerable: true });
9
9
  };
10
10
 
11
- // node_modules/zod/v4/core/util.js
11
+ // ../../opt/toolchain/node_modules/zod/v4/core/util.js
12
12
  var util_exports = {};
13
13
  __export(util_exports, {
14
14
  BIGINT_FORMAT_RANGES: () => BIGINT_FORMAT_RANGES,
@@ -754,7 +754,7 @@ function constantCatch(value) {
754
754
  }
755
755
  var Cached, EVALUATING, captureStackTrace, allowsEval, getParsedType, propertyKeyTypes, primitiveTypes, NUMBER_FORMAT_RANGES, BIGINT_FORMAT_RANGES, highSurrogate, Class, installing, broke, breaker, CONSTANT_CATCH;
756
756
  var init_util = __esm({
757
- "node_modules/zod/v4/core/util.js"() {
757
+ "../../opt/toolchain/node_modules/zod/v4/core/util.js"() {
758
758
  init_core();
759
759
  Cached = class {
760
760
  constructor(getter) {
@@ -869,7 +869,7 @@ var init_util = __esm({
869
869
  }
870
870
  });
871
871
 
872
- // node_modules/zod/v4/core/core.js
872
+ // ../../opt/toolchain/node_modules/zod/v4/core/core.js
873
873
  function newError(Definition) {
874
874
  const E = _E;
875
875
  if (E) {
@@ -972,7 +972,7 @@ function config(newConfig) {
972
972
  }
973
973
  var _a, NEVER, _zodDesc, _E, $brand, $ZodAsyncError, $ZodEncodeError, globalConfig;
974
974
  var init_core = __esm({
975
- "node_modules/zod/v4/core/core.js"() {
975
+ "../../opt/toolchain/node_modules/zod/v4/core/core.js"() {
976
976
  init_util();
977
977
  NEVER = /* @__PURE__ */ Object.freeze({
978
978
  status: "aborted"
@@ -996,7 +996,7 @@ var init_core = __esm({
996
996
  }
997
997
  });
998
998
 
999
- // node_modules/zod/v4/core/errors.js
999
+ // ../../opt/toolchain/node_modules/zod/v4/core/errors.js
1000
1000
  function _getMessage() {
1001
1001
  const internals = this._zod;
1002
1002
  internals.message ?? (internals.message = JSON.stringify(internals.def, jsonStringifyReplacer, 2));
@@ -1154,7 +1154,7 @@ function prettifyError(error62) {
1154
1154
  }
1155
1155
  var _messageDesc, _issuesDesc, _installedToString, initializer, $ZodError, $ZodRealError;
1156
1156
  var init_errors = __esm({
1157
- "node_modules/zod/v4/core/errors.js"() {
1157
+ "../../opt/toolchain/node_modules/zod/v4/core/errors.js"() {
1158
1158
  init_core();
1159
1159
  init_util();
1160
1160
  _messageDesc = {
@@ -1195,7 +1195,7 @@ var init_errors = __esm({
1195
1195
  }
1196
1196
  });
1197
1197
 
1198
- // node_modules/zod/v4/core/parse.js
1198
+ // ../../opt/toolchain/node_modules/zod/v4/core/parse.js
1199
1199
  function finalizeParams(callee, params) {
1200
1200
  return { callee: params?.callee ?? callee, Err: params?.Err };
1201
1201
  }
@@ -1235,7 +1235,7 @@ function validateFallback(schema, value, _ctx) {
1235
1235
  }
1236
1236
  var _parse, parse, _parseAsync, parseAsync, _safeParse, safeParse, _safeParseAsync, safeParseAsync, COMPILE_INVALID, COMPILE_FALLBACK, validate, validateAsync, _encode, encode, _decode, decode, _encodeAsync, encodeAsync, _decodeAsync, decodeAsync, _safeEncode, safeEncode, _safeDecode, safeDecode, _safeEncodeAsync, safeEncodeAsync, _safeDecodeAsync, safeDecodeAsync;
1237
1237
  var init_parse = __esm({
1238
- "node_modules/zod/v4/core/parse.js"() {
1238
+ "../../opt/toolchain/node_modules/zod/v4/core/parse.js"() {
1239
1239
  init_core();
1240
1240
  init_errors();
1241
1241
  init_util();
@@ -1363,7 +1363,7 @@ var init_parse = __esm({
1363
1363
  }
1364
1364
  });
1365
1365
 
1366
- // node_modules/zod/v4/core/regexes.js
1366
+ // ../../opt/toolchain/node_modules/zod/v4/core/regexes.js
1367
1367
  var regexes_exports = {};
1368
1368
  __export(regexes_exports, {
1369
1369
  anyString: () => anyString,
@@ -1464,7 +1464,7 @@ function fixedBase64url(length) {
1464
1464
  }
1465
1465
  var cuid, cuid2, ulid, xid, ksuid, nanoid, duration, extendedDuration, guid, uuid, uuid4, uuid6, uuid7, email, html5Email, rfc5322Email, unicodeEmail, idnEmail, browserEmail, _emoji, ipv4, ipv6, mac, cidrv4, cidrv6, base64, base64url, hostname, domain, httpProtocol, e164, creditCard, currencyCode, iban, dateSource, date, anyString, string, bigint, integer, number, boolean, _null, _undefined, lowercase, uppercase, hex, md5_hex, md5_base64, md5_base64url, sha1_hex, sha1_base64, sha1_base64url, sha256_hex, sha256_base64, sha256_base64url, sha384_hex, sha384_base64, sha384_base64url, sha512_hex, sha512_base64, sha512_base64url;
1466
1466
  var init_regexes = __esm({
1467
- "node_modules/zod/v4/core/regexes.js"() {
1467
+ "../../opt/toolchain/node_modules/zod/v4/core/regexes.js"() {
1468
1468
  init_util();
1469
1469
  cuid = /^[cC][0-9a-z]{6,}$/;
1470
1470
  cuid2 = /^[0-9a-z]+$/;
@@ -1541,7 +1541,7 @@ var init_regexes = __esm({
1541
1541
  }
1542
1542
  });
1543
1543
 
1544
- // node_modules/zod/v4/core/checks.js
1544
+ // ../../opt/toolchain/node_modules/zod/v4/core/checks.js
1545
1545
  function handleCheckPropertyResult(result, payload, property) {
1546
1546
  if (result.issues.length) {
1547
1547
  payload.issues.push(...prefixIssues(property, result.issues));
@@ -1549,7 +1549,7 @@ function handleCheckPropertyResult(result, payload, property) {
1549
1549
  }
1550
1550
  var $ZodCheck, _whenHasSize, _whenHasLength, numericOriginMap, $ZodCheckLessThan, $ZodCheckGreaterThan, $ZodCheckMultipleOf, $ZodCheckNumberFormat, $ZodCheckBigIntFormat, $ZodCheckMaxSize, $ZodCheckMinSize, $ZodCheckSizeEquals, $ZodCheckMaxLength, $ZodCheckMinLength, $ZodCheckLengthEquals, $ZodCheckStringFormat, $ZodCheckRegex, $ZodCheckLowerCase, $ZodCheckUpperCase, $ZodCheckIncludes, $ZodCheckStartsWith, $ZodCheckEndsWith, $ZodCheckProperty, $ZodCheckProperties, $ZodCheckMimeType, $ZodCheckOverwrite;
1551
1551
  var init_checks = __esm({
1552
- "node_modules/zod/v4/core/checks.js"() {
1552
+ "../../opt/toolchain/node_modules/zod/v4/core/checks.js"() {
1553
1553
  init_core();
1554
1554
  init_regexes();
1555
1555
  init_util();
@@ -2025,10 +2025,10 @@ var init_checks = __esm({
2025
2025
  }
2026
2026
  });
2027
2027
 
2028
- // node_modules/zod/v4/core/doc.js
2028
+ // ../../opt/toolchain/node_modules/zod/v4/core/doc.js
2029
2029
  var Doc;
2030
2030
  var init_doc = __esm({
2031
- "node_modules/zod/v4/core/doc.js"() {
2031
+ "../../opt/toolchain/node_modules/zod/v4/core/doc.js"() {
2032
2032
  Doc = class {
2033
2033
  constructor(args = [], closed = {}) {
2034
2034
  this.content = [];
@@ -2071,10 +2071,10 @@ ${content.join("\n")}
2071
2071
  }
2072
2072
  });
2073
2073
 
2074
- // node_modules/zod/v4/core/versions.js
2074
+ // ../../opt/toolchain/node_modules/zod/v4/core/versions.js
2075
2075
  var version;
2076
2076
  var init_versions = __esm({
2077
- "node_modules/zod/v4/core/versions.js"() {
2077
+ "../../opt/toolchain/node_modules/zod/v4/core/versions.js"() {
2078
2078
  version = {
2079
2079
  major: 4,
2080
2080
  minor: 6,
@@ -2083,7 +2083,7 @@ var init_versions = __esm({
2083
2083
  }
2084
2084
  });
2085
2085
 
2086
- // node_modules/zod/v4/core/schemas.js
2086
+ // ../../opt/toolchain/node_modules/zod/v4/core/schemas.js
2087
2087
  async function validateAsync2(inst, value) {
2088
2088
  const ctx = { async: true };
2089
2089
  return toStandardResult(await inst._zod.run({ value, issues: [] }, ctx), ctx);
@@ -2764,7 +2764,7 @@ function handleRefineResult(result, payload, input2, inst) {
2764
2764
  }
2765
2765
  var $ZodType, toStandardResult, $ZodString, $ZodStringFormat, $ZodGUID, $ZodUUID, $ZodEmail, URL_BAD_FORMAT, URL_UNPARSEABLE, asciiTabOrNewline, $ZodURL, $ZodEmoji, $ZodNanoID, $ZodCUID, $ZodCUID2, $ZodULID, $ZodXID, $ZodKSUID, $ZodISODateTime, $ZodISODate, $ZodISOTime, $ZodISODuration, $ZodIPv4, ipv6Alphabet, $ZodIPv6, $ZodMAC, $ZodCIDRv4, $ZodCIDRv6, base64Charset, $ZodBase64, base64urlCharset, $ZodBase64URL, $ZodE164, CC_SANITIZE, $ZodCreditCard, $ZodIBAN, $ZodJWT, $ZodCustomStringFormat, $ZodNumber, $ZodNumberFormat, $ZodBoolean, $ZodBigInt, $ZodBigIntFormat, $ZodSymbol, $ZodUndefined, $ZodNull, $ZodAny, $ZodUnknown, $ZodNever, $ZodVoid, $ZodDate, arraySize, mapSize, setSize, $ZodArray, NO_SYMBOL_KEYS, $ZodObject, $ZodObjectJIT, $ZodUnion, $ZodXor, $ZodDiscriminatedUnion, $ZodIntersection, $ZodTuple, $ZodRecord, $ZodMap, $ZodSet, $ZodEnum, $ZodLiteral, $ZodFile, $ZodTransform, $ZodOptional, $ZodExactOptional, $ZodNullable, $ZodDefault, $ZodPrefault, $ZodNonOptional, $ZodSuccess, $ZodCatch, $ZodNaN, $ZodPipe, $ZodCodec, $ZodPreprocess, $ZodReadonly, $ZodTemplateLiteral, $ZodFunction, $ZodPromise, $ZodLazy, $ZodCustom;
2766
2766
  var init_schemas = __esm({
2767
- "node_modules/zod/v4/core/schemas.js"() {
2767
+ "../../opt/toolchain/node_modules/zod/v4/core/schemas.js"() {
2768
2768
  init_checks();
2769
2769
  init_core();
2770
2770
  init_doc();
@@ -4538,7 +4538,7 @@ var init_schemas = __esm({
4538
4538
  }
4539
4539
  });
4540
4540
 
4541
- // node_modules/zod/v4/core/memoizer.js
4541
+ // ../../opt/toolchain/node_modules/zod/v4/core/memoizer.js
4542
4542
  function isRef(value) {
4543
4543
  return value !== null && typeof value === "object";
4544
4544
  }
@@ -4702,7 +4702,7 @@ function isBackEdge(ctx, value) {
4702
4702
  }
4703
4703
  var $ZodCyclicError, STATE, NO_ISSUES, recursive, NONE, ASSUMED, PROVEN, handoff, open, memo;
4704
4704
  var init_memoizer = __esm({
4705
- "node_modules/zod/v4/core/memoizer.js"() {
4705
+ "../../opt/toolchain/node_modules/zod/v4/core/memoizer.js"() {
4706
4706
  init_util();
4707
4707
  $ZodCyclicError = class extends Error {
4708
4708
  constructor() {
@@ -4820,7 +4820,7 @@ var init_memoizer = __esm({
4820
4820
  }
4821
4821
  });
4822
4822
 
4823
- // node_modules/zod/v4/locales/ar.js
4823
+ // ../../opt/toolchain/node_modules/zod/v4/locales/ar.js
4824
4824
  function ar_default() {
4825
4825
  return {
4826
4826
  localeError: error()
@@ -4828,7 +4828,7 @@ function ar_default() {
4828
4828
  }
4829
4829
  var error;
4830
4830
  var init_ar = __esm({
4831
- "node_modules/zod/v4/locales/ar.js"() {
4831
+ "../../opt/toolchain/node_modules/zod/v4/locales/ar.js"() {
4832
4832
  init_util();
4833
4833
  error = () => {
4834
4834
  const Sizable = {
@@ -4938,7 +4938,7 @@ var init_ar = __esm({
4938
4938
  }
4939
4939
  });
4940
4940
 
4941
- // node_modules/zod/v4/locales/az.js
4941
+ // ../../opt/toolchain/node_modules/zod/v4/locales/az.js
4942
4942
  function az_default() {
4943
4943
  return {
4944
4944
  localeError: error2()
@@ -4946,7 +4946,7 @@ function az_default() {
4946
4946
  }
4947
4947
  var error2;
4948
4948
  var init_az = __esm({
4949
- "node_modules/zod/v4/locales/az.js"() {
4949
+ "../../opt/toolchain/node_modules/zod/v4/locales/az.js"() {
4950
4950
  init_util();
4951
4951
  error2 = () => {
4952
4952
  const Sizable = {
@@ -5055,7 +5055,7 @@ var init_az = __esm({
5055
5055
  }
5056
5056
  });
5057
5057
 
5058
- // node_modules/zod/v4/locales/be.js
5058
+ // ../../opt/toolchain/node_modules/zod/v4/locales/be.js
5059
5059
  function getBelarusianPlural(count2, one, few, many) {
5060
5060
  const absCount = Math.abs(count2);
5061
5061
  const lastDigit = absCount % 10;
@@ -5078,7 +5078,7 @@ function be_default() {
5078
5078
  }
5079
5079
  var error3;
5080
5080
  var init_be = __esm({
5081
- "node_modules/zod/v4/locales/be.js"() {
5081
+ "../../opt/toolchain/node_modules/zod/v4/locales/be.js"() {
5082
5082
  init_util();
5083
5083
  error3 = () => {
5084
5084
  const Sizable = {
@@ -5230,7 +5230,7 @@ var init_be = __esm({
5230
5230
  }
5231
5231
  });
5232
5232
 
5233
- // node_modules/zod/v4/locales/bg.js
5233
+ // ../../opt/toolchain/node_modules/zod/v4/locales/bg.js
5234
5234
  function bg_default() {
5235
5235
  return {
5236
5236
  localeError: error4()
@@ -5238,7 +5238,7 @@ function bg_default() {
5238
5238
  }
5239
5239
  var error4;
5240
5240
  var init_bg = __esm({
5241
- "node_modules/zod/v4/locales/bg.js"() {
5241
+ "../../opt/toolchain/node_modules/zod/v4/locales/bg.js"() {
5242
5242
  init_util();
5243
5243
  error4 = () => {
5244
5244
  const Sizable = {
@@ -5362,7 +5362,7 @@ var init_bg = __esm({
5362
5362
  }
5363
5363
  });
5364
5364
 
5365
- // node_modules/zod/v4/locales/bn.js
5365
+ // ../../opt/toolchain/node_modules/zod/v4/locales/bn.js
5366
5366
  function bn_default() {
5367
5367
  return {
5368
5368
  localeError: error5()
@@ -5370,7 +5370,7 @@ function bn_default() {
5370
5370
  }
5371
5371
  var error5;
5372
5372
  var init_bn = __esm({
5373
- "node_modules/zod/v4/locales/bn.js"() {
5373
+ "../../opt/toolchain/node_modules/zod/v4/locales/bn.js"() {
5374
5374
  init_util();
5375
5375
  error5 = () => {
5376
5376
  const Sizable = {
@@ -5482,7 +5482,7 @@ var init_bn = __esm({
5482
5482
  }
5483
5483
  });
5484
5484
 
5485
- // node_modules/zod/v4/locales/ca.js
5485
+ // ../../opt/toolchain/node_modules/zod/v4/locales/ca.js
5486
5486
  function ca_default() {
5487
5487
  return {
5488
5488
  localeError: error6()
@@ -5490,7 +5490,7 @@ function ca_default() {
5490
5490
  }
5491
5491
  var error6;
5492
5492
  var init_ca = __esm({
5493
- "node_modules/zod/v4/locales/ca.js"() {
5493
+ "../../opt/toolchain/node_modules/zod/v4/locales/ca.js"() {
5494
5494
  init_util();
5495
5495
  error6 = () => {
5496
5496
  const Sizable = {
@@ -5602,7 +5602,7 @@ var init_ca = __esm({
5602
5602
  }
5603
5603
  });
5604
5604
 
5605
- // node_modules/zod/v4/locales/ckb.js
5605
+ // ../../opt/toolchain/node_modules/zod/v4/locales/ckb.js
5606
5606
  function ckb_default() {
5607
5607
  return {
5608
5608
  localeError: error7()
@@ -5610,7 +5610,7 @@ function ckb_default() {
5610
5610
  }
5611
5611
  var error7;
5612
5612
  var init_ckb = __esm({
5613
- "node_modules/zod/v4/locales/ckb.js"() {
5613
+ "../../opt/toolchain/node_modules/zod/v4/locales/ckb.js"() {
5614
5614
  init_util();
5615
5615
  error7 = () => {
5616
5616
  const Sizable = {
@@ -5741,7 +5741,7 @@ var init_ckb = __esm({
5741
5741
  }
5742
5742
  });
5743
5743
 
5744
- // node_modules/zod/v4/locales/cs.js
5744
+ // ../../opt/toolchain/node_modules/zod/v4/locales/cs.js
5745
5745
  function cs_default() {
5746
5746
  return {
5747
5747
  localeError: error8()
@@ -5749,7 +5749,7 @@ function cs_default() {
5749
5749
  }
5750
5750
  var error8;
5751
5751
  var init_cs = __esm({
5752
- "node_modules/zod/v4/locales/cs.js"() {
5752
+ "../../opt/toolchain/node_modules/zod/v4/locales/cs.js"() {
5753
5753
  init_util();
5754
5754
  error8 = () => {
5755
5755
  const Sizable = {
@@ -5864,7 +5864,7 @@ var init_cs = __esm({
5864
5864
  }
5865
5865
  });
5866
5866
 
5867
- // node_modules/zod/v4/locales/da.js
5867
+ // ../../opt/toolchain/node_modules/zod/v4/locales/da.js
5868
5868
  function da_default() {
5869
5869
  return {
5870
5870
  localeError: error9()
@@ -5872,7 +5872,7 @@ function da_default() {
5872
5872
  }
5873
5873
  var error9;
5874
5874
  var init_da = __esm({
5875
- "node_modules/zod/v4/locales/da.js"() {
5875
+ "../../opt/toolchain/node_modules/zod/v4/locales/da.js"() {
5876
5876
  init_util();
5877
5877
  error9 = () => {
5878
5878
  const Sizable = {
@@ -5991,7 +5991,7 @@ var init_da = __esm({
5991
5991
  }
5992
5992
  });
5993
5993
 
5994
- // node_modules/zod/v4/locales/de.js
5994
+ // ../../opt/toolchain/node_modules/zod/v4/locales/de.js
5995
5995
  function de_default() {
5996
5996
  return {
5997
5997
  localeError: error10()
@@ -5999,7 +5999,7 @@ function de_default() {
5999
5999
  }
6000
6000
  var error10;
6001
6001
  var init_de = __esm({
6002
- "node_modules/zod/v4/locales/de.js"() {
6002
+ "../../opt/toolchain/node_modules/zod/v4/locales/de.js"() {
6003
6003
  init_util();
6004
6004
  error10 = () => {
6005
6005
  const Sizable = {
@@ -6111,7 +6111,7 @@ var init_de = __esm({
6111
6111
  }
6112
6112
  });
6113
6113
 
6114
- // node_modules/zod/v4/locales/el.js
6114
+ // ../../opt/toolchain/node_modules/zod/v4/locales/el.js
6115
6115
  function el_default() {
6116
6116
  return {
6117
6117
  localeError: error11()
@@ -6119,7 +6119,7 @@ function el_default() {
6119
6119
  }
6120
6120
  var error11;
6121
6121
  var init_el = __esm({
6122
- "node_modules/zod/v4/locales/el.js"() {
6122
+ "../../opt/toolchain/node_modules/zod/v4/locales/el.js"() {
6123
6123
  init_util();
6124
6124
  error11 = () => {
6125
6125
  const Sizable = {
@@ -6230,7 +6230,7 @@ var init_el = __esm({
6230
6230
  }
6231
6231
  });
6232
6232
 
6233
- // node_modules/zod/v4/locales/en.js
6233
+ // ../../opt/toolchain/node_modules/zod/v4/locales/en.js
6234
6234
  function en_default() {
6235
6235
  return {
6236
6236
  localeError: error12()
@@ -6238,7 +6238,7 @@ function en_default() {
6238
6238
  }
6239
6239
  var error12;
6240
6240
  var init_en = __esm({
6241
- "node_modules/zod/v4/locales/en.js"() {
6241
+ "../../opt/toolchain/node_modules/zod/v4/locales/en.js"() {
6242
6242
  init_util();
6243
6243
  error12 = () => {
6244
6244
  const Sizable = {
@@ -6361,7 +6361,7 @@ var init_en = __esm({
6361
6361
  }
6362
6362
  });
6363
6363
 
6364
- // node_modules/zod/v4/locales/eo.js
6364
+ // ../../opt/toolchain/node_modules/zod/v4/locales/eo.js
6365
6365
  function eo_default() {
6366
6366
  return {
6367
6367
  localeError: error13()
@@ -6369,7 +6369,7 @@ function eo_default() {
6369
6369
  }
6370
6370
  var error13;
6371
6371
  var init_eo = __esm({
6372
- "node_modules/zod/v4/locales/eo.js"() {
6372
+ "../../opt/toolchain/node_modules/zod/v4/locales/eo.js"() {
6373
6373
  init_util();
6374
6374
  error13 = () => {
6375
6375
  const Sizable = {
@@ -6482,7 +6482,7 @@ var init_eo = __esm({
6482
6482
  }
6483
6483
  });
6484
6484
 
6485
- // node_modules/zod/v4/locales/es.js
6485
+ // ../../opt/toolchain/node_modules/zod/v4/locales/es.js
6486
6486
  function es_default() {
6487
6487
  return {
6488
6488
  localeError: error14()
@@ -6490,7 +6490,7 @@ function es_default() {
6490
6490
  }
6491
6491
  var error14;
6492
6492
  var init_es = __esm({
6493
- "node_modules/zod/v4/locales/es.js"() {
6493
+ "../../opt/toolchain/node_modules/zod/v4/locales/es.js"() {
6494
6494
  init_util();
6495
6495
  error14 = () => {
6496
6496
  const Sizable = {
@@ -6625,7 +6625,7 @@ var init_es = __esm({
6625
6625
  }
6626
6626
  });
6627
6627
 
6628
- // node_modules/zod/v4/locales/fa.js
6628
+ // ../../opt/toolchain/node_modules/zod/v4/locales/fa.js
6629
6629
  function fa_default() {
6630
6630
  return {
6631
6631
  localeError: error15()
@@ -6633,7 +6633,7 @@ function fa_default() {
6633
6633
  }
6634
6634
  var error15;
6635
6635
  var init_fa = __esm({
6636
- "node_modules/zod/v4/locales/fa.js"() {
6636
+ "../../opt/toolchain/node_modules/zod/v4/locales/fa.js"() {
6637
6637
  init_util();
6638
6638
  error15 = () => {
6639
6639
  const Sizable = {
@@ -6751,7 +6751,7 @@ var init_fa = __esm({
6751
6751
  }
6752
6752
  });
6753
6753
 
6754
- // node_modules/zod/v4/locales/fi.js
6754
+ // ../../opt/toolchain/node_modules/zod/v4/locales/fi.js
6755
6755
  function fi_default() {
6756
6756
  return {
6757
6757
  localeError: error16()
@@ -6759,7 +6759,7 @@ function fi_default() {
6759
6759
  }
6760
6760
  var error16;
6761
6761
  var init_fi = __esm({
6762
- "node_modules/zod/v4/locales/fi.js"() {
6762
+ "../../opt/toolchain/node_modules/zod/v4/locales/fi.js"() {
6763
6763
  init_util();
6764
6764
  error16 = () => {
6765
6765
  const Sizable = {
@@ -6875,7 +6875,7 @@ var init_fi = __esm({
6875
6875
  }
6876
6876
  });
6877
6877
 
6878
- // node_modules/zod/v4/locales/fr.js
6878
+ // ../../opt/toolchain/node_modules/zod/v4/locales/fr.js
6879
6879
  function fr_default() {
6880
6880
  return {
6881
6881
  localeError: error17()
@@ -6883,7 +6883,7 @@ function fr_default() {
6883
6883
  }
6884
6884
  var error17;
6885
6885
  var init_fr = __esm({
6886
- "node_modules/zod/v4/locales/fr.js"() {
6886
+ "../../opt/toolchain/node_modules/zod/v4/locales/fr.js"() {
6887
6887
  init_util();
6888
6888
  error17 = () => {
6889
6889
  const Sizable = {
@@ -7011,7 +7011,7 @@ var init_fr = __esm({
7011
7011
  }
7012
7012
  });
7013
7013
 
7014
- // node_modules/zod/v4/locales/fr-CA.js
7014
+ // ../../opt/toolchain/node_modules/zod/v4/locales/fr-CA.js
7015
7015
  function fr_CA_default() {
7016
7016
  return {
7017
7017
  localeError: error18()
@@ -7019,7 +7019,7 @@ function fr_CA_default() {
7019
7019
  }
7020
7020
  var error18;
7021
7021
  var init_fr_CA = __esm({
7022
- "node_modules/zod/v4/locales/fr-CA.js"() {
7022
+ "../../opt/toolchain/node_modules/zod/v4/locales/fr-CA.js"() {
7023
7023
  init_util();
7024
7024
  error18 = () => {
7025
7025
  const Sizable = {
@@ -7130,7 +7130,7 @@ var init_fr_CA = __esm({
7130
7130
  }
7131
7131
  });
7132
7132
 
7133
- // node_modules/zod/v4/locales/gu.js
7133
+ // ../../opt/toolchain/node_modules/zod/v4/locales/gu.js
7134
7134
  function gu_default() {
7135
7135
  return {
7136
7136
  localeError: error19()
@@ -7138,7 +7138,7 @@ function gu_default() {
7138
7138
  }
7139
7139
  var error19;
7140
7140
  var init_gu = __esm({
7141
- "node_modules/zod/v4/locales/gu.js"() {
7141
+ "../../opt/toolchain/node_modules/zod/v4/locales/gu.js"() {
7142
7142
  init_util();
7143
7143
  error19 = () => {
7144
7144
  const Sizable = {
@@ -7250,7 +7250,7 @@ var init_gu = __esm({
7250
7250
  }
7251
7251
  });
7252
7252
 
7253
- // node_modules/zod/v4/locales/he.js
7253
+ // ../../opt/toolchain/node_modules/zod/v4/locales/he.js
7254
7254
  function he_default() {
7255
7255
  return {
7256
7256
  localeError: error20()
@@ -7258,7 +7258,7 @@ function he_default() {
7258
7258
  }
7259
7259
  var error20;
7260
7260
  var init_he = __esm({
7261
- "node_modules/zod/v4/locales/he.js"() {
7261
+ "../../opt/toolchain/node_modules/zod/v4/locales/he.js"() {
7262
7262
  init_util();
7263
7263
  error20 = () => {
7264
7264
  const TypeNames = {
@@ -7458,7 +7458,7 @@ var init_he = __esm({
7458
7458
  }
7459
7459
  });
7460
7460
 
7461
- // node_modules/zod/v4/locales/hi.js
7461
+ // ../../opt/toolchain/node_modules/zod/v4/locales/hi.js
7462
7462
  function hi_default() {
7463
7463
  return {
7464
7464
  localeError: error21()
@@ -7466,7 +7466,7 @@ function hi_default() {
7466
7466
  }
7467
7467
  var error21;
7468
7468
  var init_hi = __esm({
7469
- "node_modules/zod/v4/locales/hi.js"() {
7469
+ "../../opt/toolchain/node_modules/zod/v4/locales/hi.js"() {
7470
7470
  init_util();
7471
7471
  error21 = () => {
7472
7472
  const Sizable = {
@@ -7576,7 +7576,7 @@ var init_hi = __esm({
7576
7576
  }
7577
7577
  });
7578
7578
 
7579
- // node_modules/zod/v4/locales/hr.js
7579
+ // ../../opt/toolchain/node_modules/zod/v4/locales/hr.js
7580
7580
  function hr_default() {
7581
7581
  return {
7582
7582
  localeError: error22()
@@ -7584,7 +7584,7 @@ function hr_default() {
7584
7584
  }
7585
7585
  var error22;
7586
7586
  var init_hr = __esm({
7587
- "node_modules/zod/v4/locales/hr.js"() {
7587
+ "../../opt/toolchain/node_modules/zod/v4/locales/hr.js"() {
7588
7588
  init_util();
7589
7589
  error22 = () => {
7590
7590
  const Sizable = {
@@ -7709,7 +7709,7 @@ var init_hr = __esm({
7709
7709
  }
7710
7710
  });
7711
7711
 
7712
- // node_modules/zod/v4/locales/hu.js
7712
+ // ../../opt/toolchain/node_modules/zod/v4/locales/hu.js
7713
7713
  function hu_default() {
7714
7714
  return {
7715
7715
  localeError: error23()
@@ -7717,7 +7717,7 @@ function hu_default() {
7717
7717
  }
7718
7718
  var error23;
7719
7719
  var init_hu = __esm({
7720
- "node_modules/zod/v4/locales/hu.js"() {
7720
+ "../../opt/toolchain/node_modules/zod/v4/locales/hu.js"() {
7721
7721
  init_util();
7722
7722
  error23 = () => {
7723
7723
  const Sizable = {
@@ -7829,7 +7829,7 @@ var init_hu = __esm({
7829
7829
  }
7830
7830
  });
7831
7831
 
7832
- // node_modules/zod/v4/locales/hy.js
7832
+ // ../../opt/toolchain/node_modules/zod/v4/locales/hy.js
7833
7833
  function getArmenianPlural(count2, one, many) {
7834
7834
  return Math.abs(count2) === 1 ? one : many;
7835
7835
  }
@@ -7847,7 +7847,7 @@ function hy_default() {
7847
7847
  }
7848
7848
  var error24;
7849
7849
  var init_hy = __esm({
7850
- "node_modules/zod/v4/locales/hy.js"() {
7850
+ "../../opt/toolchain/node_modules/zod/v4/locales/hy.js"() {
7851
7851
  init_util();
7852
7852
  error24 = () => {
7853
7853
  const Sizable = {
@@ -7994,7 +7994,7 @@ var init_hy = __esm({
7994
7994
  }
7995
7995
  });
7996
7996
 
7997
- // node_modules/zod/v4/locales/id.js
7997
+ // ../../opt/toolchain/node_modules/zod/v4/locales/id.js
7998
7998
  function id_default() {
7999
7999
  return {
8000
8000
  localeError: error25()
@@ -8002,7 +8002,7 @@ function id_default() {
8002
8002
  }
8003
8003
  var error25;
8004
8004
  var init_id = __esm({
8005
- "node_modules/zod/v4/locales/id.js"() {
8005
+ "../../opt/toolchain/node_modules/zod/v4/locales/id.js"() {
8006
8006
  init_util();
8007
8007
  error25 = () => {
8008
8008
  const Sizable = {
@@ -8112,7 +8112,7 @@ var init_id = __esm({
8112
8112
  }
8113
8113
  });
8114
8114
 
8115
- // node_modules/zod/v4/locales/is.js
8115
+ // ../../opt/toolchain/node_modules/zod/v4/locales/is.js
8116
8116
  function is_default() {
8117
8117
  return {
8118
8118
  localeError: error26()
@@ -8120,7 +8120,7 @@ function is_default() {
8120
8120
  }
8121
8121
  var error26;
8122
8122
  var init_is = __esm({
8123
- "node_modules/zod/v4/locales/is.js"() {
8123
+ "../../opt/toolchain/node_modules/zod/v4/locales/is.js"() {
8124
8124
  init_util();
8125
8125
  error26 = () => {
8126
8126
  const Sizable = {
@@ -8233,7 +8233,7 @@ var init_is = __esm({
8233
8233
  }
8234
8234
  });
8235
8235
 
8236
- // node_modules/zod/v4/locales/it.js
8236
+ // ../../opt/toolchain/node_modules/zod/v4/locales/it.js
8237
8237
  function it_default() {
8238
8238
  return {
8239
8239
  localeError: error27()
@@ -8241,7 +8241,7 @@ function it_default() {
8241
8241
  }
8242
8242
  var error27;
8243
8243
  var init_it = __esm({
8244
- "node_modules/zod/v4/locales/it.js"() {
8244
+ "../../opt/toolchain/node_modules/zod/v4/locales/it.js"() {
8245
8245
  init_util();
8246
8246
  error27 = () => {
8247
8247
  const Sizable = {
@@ -8353,7 +8353,7 @@ var init_it = __esm({
8353
8353
  }
8354
8354
  });
8355
8355
 
8356
- // node_modules/zod/v4/locales/ja.js
8356
+ // ../../opt/toolchain/node_modules/zod/v4/locales/ja.js
8357
8357
  function ja_default() {
8358
8358
  return {
8359
8359
  localeError: error28()
@@ -8361,7 +8361,7 @@ function ja_default() {
8361
8361
  }
8362
8362
  var error28;
8363
8363
  var init_ja = __esm({
8364
- "node_modules/zod/v4/locales/ja.js"() {
8364
+ "../../opt/toolchain/node_modules/zod/v4/locales/ja.js"() {
8365
8365
  init_util();
8366
8366
  error28 = () => {
8367
8367
  const Sizable = {
@@ -8472,7 +8472,7 @@ var init_ja = __esm({
8472
8472
  }
8473
8473
  });
8474
8474
 
8475
- // node_modules/zod/v4/locales/ka.js
8475
+ // ../../opt/toolchain/node_modules/zod/v4/locales/ka.js
8476
8476
  function ka_default() {
8477
8477
  return {
8478
8478
  localeError: error29()
@@ -8480,7 +8480,7 @@ function ka_default() {
8480
8480
  }
8481
8481
  var error29;
8482
8482
  var init_ka = __esm({
8483
- "node_modules/zod/v4/locales/ka.js"() {
8483
+ "../../opt/toolchain/node_modules/zod/v4/locales/ka.js"() {
8484
8484
  init_util();
8485
8485
  error29 = () => {
8486
8486
  const Sizable = {
@@ -8596,7 +8596,7 @@ var init_ka = __esm({
8596
8596
  }
8597
8597
  });
8598
8598
 
8599
- // node_modules/zod/v4/locales/km.js
8599
+ // ../../opt/toolchain/node_modules/zod/v4/locales/km.js
8600
8600
  function km_default() {
8601
8601
  return {
8602
8602
  localeError: error30()
@@ -8604,7 +8604,7 @@ function km_default() {
8604
8604
  }
8605
8605
  var error30;
8606
8606
  var init_km = __esm({
8607
- "node_modules/zod/v4/locales/km.js"() {
8607
+ "../../opt/toolchain/node_modules/zod/v4/locales/km.js"() {
8608
8608
  init_util();
8609
8609
  error30 = () => {
8610
8610
  const Sizable = {
@@ -8718,17 +8718,17 @@ var init_km = __esm({
8718
8718
  }
8719
8719
  });
8720
8720
 
8721
- // node_modules/zod/v4/locales/kh.js
8721
+ // ../../opt/toolchain/node_modules/zod/v4/locales/kh.js
8722
8722
  function kh_default() {
8723
8723
  return km_default();
8724
8724
  }
8725
8725
  var init_kh = __esm({
8726
- "node_modules/zod/v4/locales/kh.js"() {
8726
+ "../../opt/toolchain/node_modules/zod/v4/locales/kh.js"() {
8727
8727
  init_km();
8728
8728
  }
8729
8729
  });
8730
8730
 
8731
- // node_modules/zod/v4/locales/kn.js
8731
+ // ../../opt/toolchain/node_modules/zod/v4/locales/kn.js
8732
8732
  function kn_default() {
8733
8733
  return {
8734
8734
  localeError: error31()
@@ -8736,7 +8736,7 @@ function kn_default() {
8736
8736
  }
8737
8737
  var error31;
8738
8738
  var init_kn = __esm({
8739
- "node_modules/zod/v4/locales/kn.js"() {
8739
+ "../../opt/toolchain/node_modules/zod/v4/locales/kn.js"() {
8740
8740
  init_util();
8741
8741
  error31 = () => {
8742
8742
  const Sizable = {
@@ -8850,7 +8850,7 @@ var init_kn = __esm({
8850
8850
  }
8851
8851
  });
8852
8852
 
8853
- // node_modules/zod/v4/locales/ko.js
8853
+ // ../../opt/toolchain/node_modules/zod/v4/locales/ko.js
8854
8854
  function ko_default() {
8855
8855
  return {
8856
8856
  localeError: error32()
@@ -8858,7 +8858,7 @@ function ko_default() {
8858
8858
  }
8859
8859
  var error32;
8860
8860
  var init_ko = __esm({
8861
- "node_modules/zod/v4/locales/ko.js"() {
8861
+ "../../opt/toolchain/node_modules/zod/v4/locales/ko.js"() {
8862
8862
  init_util();
8863
8863
  error32 = () => {
8864
8864
  const Sizable = {
@@ -8973,7 +8973,7 @@ var init_ko = __esm({
8973
8973
  }
8974
8974
  });
8975
8975
 
8976
- // node_modules/zod/v4/locales/lt.js
8976
+ // ../../opt/toolchain/node_modules/zod/v4/locales/lt.js
8977
8977
  function getUnitTypeFromNumber(number4) {
8978
8978
  const abs = Math.abs(number4);
8979
8979
  const last = abs % 10;
@@ -8991,7 +8991,7 @@ function lt_default() {
8991
8991
  }
8992
8992
  var capitalizeFirstCharacter, error33;
8993
8993
  var init_lt = __esm({
8994
- "node_modules/zod/v4/locales/lt.js"() {
8994
+ "../../opt/toolchain/node_modules/zod/v4/locales/lt.js"() {
8995
8995
  init_util();
8996
8996
  capitalizeFirstCharacter = (text) => {
8997
8997
  return text.charAt(0).toUpperCase() + text.slice(1);
@@ -9187,7 +9187,7 @@ var init_lt = __esm({
9187
9187
  }
9188
9188
  });
9189
9189
 
9190
- // node_modules/zod/v4/locales/mk.js
9190
+ // ../../opt/toolchain/node_modules/zod/v4/locales/mk.js
9191
9191
  function mk_default() {
9192
9192
  return {
9193
9193
  localeError: error34()
@@ -9195,7 +9195,7 @@ function mk_default() {
9195
9195
  }
9196
9196
  var error34;
9197
9197
  var init_mk = __esm({
9198
- "node_modules/zod/v4/locales/mk.js"() {
9198
+ "../../opt/toolchain/node_modules/zod/v4/locales/mk.js"() {
9199
9199
  init_util();
9200
9200
  error34 = () => {
9201
9201
  const Sizable = {
@@ -9308,7 +9308,7 @@ var init_mk = __esm({
9308
9308
  }
9309
9309
  });
9310
9310
 
9311
- // node_modules/zod/v4/locales/ms.js
9311
+ // ../../opt/toolchain/node_modules/zod/v4/locales/ms.js
9312
9312
  function ms_default() {
9313
9313
  return {
9314
9314
  localeError: error35()
@@ -9316,7 +9316,7 @@ function ms_default() {
9316
9316
  }
9317
9317
  var error35;
9318
9318
  var init_ms = __esm({
9319
- "node_modules/zod/v4/locales/ms.js"() {
9319
+ "../../opt/toolchain/node_modules/zod/v4/locales/ms.js"() {
9320
9320
  init_util();
9321
9321
  error35 = () => {
9322
9322
  const Sizable = {
@@ -9427,7 +9427,7 @@ var init_ms = __esm({
9427
9427
  }
9428
9428
  });
9429
9429
 
9430
- // node_modules/zod/v4/locales/ne.js
9430
+ // ../../opt/toolchain/node_modules/zod/v4/locales/ne.js
9431
9431
  function ne_default() {
9432
9432
  return {
9433
9433
  localeError: error36()
@@ -9435,7 +9435,7 @@ function ne_default() {
9435
9435
  }
9436
9436
  var error36;
9437
9437
  var init_ne = __esm({
9438
- "node_modules/zod/v4/locales/ne.js"() {
9438
+ "../../opt/toolchain/node_modules/zod/v4/locales/ne.js"() {
9439
9439
  init_util();
9440
9440
  error36 = () => {
9441
9441
  const Sizable = {
@@ -9545,7 +9545,7 @@ var init_ne = __esm({
9545
9545
  }
9546
9546
  });
9547
9547
 
9548
- // node_modules/zod/v4/locales/nl.js
9548
+ // ../../opt/toolchain/node_modules/zod/v4/locales/nl.js
9549
9549
  function nl_default() {
9550
9550
  return {
9551
9551
  localeError: error37()
@@ -9553,7 +9553,7 @@ function nl_default() {
9553
9553
  }
9554
9554
  var error37;
9555
9555
  var init_nl = __esm({
9556
- "node_modules/zod/v4/locales/nl.js"() {
9556
+ "../../opt/toolchain/node_modules/zod/v4/locales/nl.js"() {
9557
9557
  init_util();
9558
9558
  error37 = () => {
9559
9559
  const Sizable = {
@@ -9667,7 +9667,7 @@ var init_nl = __esm({
9667
9667
  }
9668
9668
  });
9669
9669
 
9670
- // node_modules/zod/v4/locales/nn.js
9670
+ // ../../opt/toolchain/node_modules/zod/v4/locales/nn.js
9671
9671
  function nn_default() {
9672
9672
  return {
9673
9673
  localeError: error38()
@@ -9675,7 +9675,7 @@ function nn_default() {
9675
9675
  }
9676
9676
  var error38;
9677
9677
  var init_nn = __esm({
9678
- "node_modules/zod/v4/locales/nn.js"() {
9678
+ "../../opt/toolchain/node_modules/zod/v4/locales/nn.js"() {
9679
9679
  init_util();
9680
9680
  error38 = () => {
9681
9681
  const Sizable = {
@@ -9787,7 +9787,7 @@ var init_nn = __esm({
9787
9787
  }
9788
9788
  });
9789
9789
 
9790
- // node_modules/zod/v4/locales/no.js
9790
+ // ../../opt/toolchain/node_modules/zod/v4/locales/no.js
9791
9791
  function no_default() {
9792
9792
  return {
9793
9793
  localeError: error39()
@@ -9795,7 +9795,7 @@ function no_default() {
9795
9795
  }
9796
9796
  var error39;
9797
9797
  var init_no = __esm({
9798
- "node_modules/zod/v4/locales/no.js"() {
9798
+ "../../opt/toolchain/node_modules/zod/v4/locales/no.js"() {
9799
9799
  init_util();
9800
9800
  error39 = () => {
9801
9801
  const Sizable = {
@@ -9907,7 +9907,7 @@ var init_no = __esm({
9907
9907
  }
9908
9908
  });
9909
9909
 
9910
- // node_modules/zod/v4/locales/ota.js
9910
+ // ../../opt/toolchain/node_modules/zod/v4/locales/ota.js
9911
9911
  function ota_default() {
9912
9912
  return {
9913
9913
  localeError: error40()
@@ -9915,7 +9915,7 @@ function ota_default() {
9915
9915
  }
9916
9916
  var error40;
9917
9917
  var init_ota = __esm({
9918
- "node_modules/zod/v4/locales/ota.js"() {
9918
+ "../../opt/toolchain/node_modules/zod/v4/locales/ota.js"() {
9919
9919
  init_util();
9920
9920
  error40 = () => {
9921
9921
  const Sizable = {
@@ -10028,7 +10028,7 @@ var init_ota = __esm({
10028
10028
  }
10029
10029
  });
10030
10030
 
10031
- // node_modules/zod/v4/locales/ps.js
10031
+ // ../../opt/toolchain/node_modules/zod/v4/locales/ps.js
10032
10032
  function ps_default() {
10033
10033
  return {
10034
10034
  localeError: error41()
@@ -10036,7 +10036,7 @@ function ps_default() {
10036
10036
  }
10037
10037
  var error41;
10038
10038
  var init_ps = __esm({
10039
- "node_modules/zod/v4/locales/ps.js"() {
10039
+ "../../opt/toolchain/node_modules/zod/v4/locales/ps.js"() {
10040
10040
  init_util();
10041
10041
  error41 = () => {
10042
10042
  const Sizable = {
@@ -10154,7 +10154,7 @@ var init_ps = __esm({
10154
10154
  }
10155
10155
  });
10156
10156
 
10157
- // node_modules/zod/v4/locales/pl.js
10157
+ // ../../opt/toolchain/node_modules/zod/v4/locales/pl.js
10158
10158
  function pl_default() {
10159
10159
  return {
10160
10160
  localeError: error42()
@@ -10162,7 +10162,7 @@ function pl_default() {
10162
10162
  }
10163
10163
  var error42;
10164
10164
  var init_pl = __esm({
10165
- "node_modules/zod/v4/locales/pl.js"() {
10165
+ "../../opt/toolchain/node_modules/zod/v4/locales/pl.js"() {
10166
10166
  init_util();
10167
10167
  error42 = () => {
10168
10168
  const Sizable = {
@@ -10275,7 +10275,7 @@ var init_pl = __esm({
10275
10275
  }
10276
10276
  });
10277
10277
 
10278
- // node_modules/zod/v4/locales/pt.js
10278
+ // ../../opt/toolchain/node_modules/zod/v4/locales/pt.js
10279
10279
  function pt_default() {
10280
10280
  return {
10281
10281
  localeError: error43()
@@ -10283,7 +10283,7 @@ function pt_default() {
10283
10283
  }
10284
10284
  var error43;
10285
10285
  var init_pt = __esm({
10286
- "node_modules/zod/v4/locales/pt.js"() {
10286
+ "../../opt/toolchain/node_modules/zod/v4/locales/pt.js"() {
10287
10287
  init_util();
10288
10288
  error43 = () => {
10289
10289
  const Sizable = {
@@ -10425,7 +10425,7 @@ var init_pt = __esm({
10425
10425
  }
10426
10426
  });
10427
10427
 
10428
- // node_modules/zod/v4/locales/pt-BR.js
10428
+ // ../../opt/toolchain/node_modules/zod/v4/locales/pt-BR.js
10429
10429
  function pt_BR_default() {
10430
10430
  return {
10431
10431
  localeError: error44()
@@ -10433,7 +10433,7 @@ function pt_BR_default() {
10433
10433
  }
10434
10434
  var error44;
10435
10435
  var init_pt_BR = __esm({
10436
- "node_modules/zod/v4/locales/pt-BR.js"() {
10436
+ "../../opt/toolchain/node_modules/zod/v4/locales/pt-BR.js"() {
10437
10437
  init_util();
10438
10438
  error44 = () => {
10439
10439
  const Sizable = {
@@ -10576,7 +10576,7 @@ var init_pt_BR = __esm({
10576
10576
  }
10577
10577
  });
10578
10578
 
10579
- // node_modules/zod/v4/locales/ro.js
10579
+ // ../../opt/toolchain/node_modules/zod/v4/locales/ro.js
10580
10580
  function ro_default() {
10581
10581
  return {
10582
10582
  localeError: error45()
@@ -10584,7 +10584,7 @@ function ro_default() {
10584
10584
  }
10585
10585
  var error45;
10586
10586
  var init_ro = __esm({
10587
- "node_modules/zod/v4/locales/ro.js"() {
10587
+ "../../opt/toolchain/node_modules/zod/v4/locales/ro.js"() {
10588
10588
  init_util();
10589
10589
  error45 = () => {
10590
10590
  const Sizable = {
@@ -10705,7 +10705,7 @@ var init_ro = __esm({
10705
10705
  }
10706
10706
  });
10707
10707
 
10708
- // node_modules/zod/v4/locales/ru.js
10708
+ // ../../opt/toolchain/node_modules/zod/v4/locales/ru.js
10709
10709
  function getRussianPlural(count2, one, few, many) {
10710
10710
  const absCount = Math.abs(count2);
10711
10711
  const lastDigit = absCount % 10;
@@ -10728,7 +10728,7 @@ function ru_default() {
10728
10728
  }
10729
10729
  var error46;
10730
10730
  var init_ru = __esm({
10731
- "node_modules/zod/v4/locales/ru.js"() {
10731
+ "../../opt/toolchain/node_modules/zod/v4/locales/ru.js"() {
10732
10732
  init_util();
10733
10733
  error46 = () => {
10734
10734
  const Sizable = {
@@ -10880,7 +10880,7 @@ var init_ru = __esm({
10880
10880
  }
10881
10881
  });
10882
10882
 
10883
- // node_modules/zod/v4/locales/sk.js
10883
+ // ../../opt/toolchain/node_modules/zod/v4/locales/sk.js
10884
10884
  function sk_default() {
10885
10885
  return {
10886
10886
  localeError: error47()
@@ -10888,7 +10888,7 @@ function sk_default() {
10888
10888
  }
10889
10889
  var error47;
10890
10890
  var init_sk = __esm({
10891
- "node_modules/zod/v4/locales/sk.js"() {
10891
+ "../../opt/toolchain/node_modules/zod/v4/locales/sk.js"() {
10892
10892
  init_util();
10893
10893
  error47 = () => {
10894
10894
  const Sizable = {
@@ -11003,7 +11003,7 @@ var init_sk = __esm({
11003
11003
  }
11004
11004
  });
11005
11005
 
11006
- // node_modules/zod/v4/locales/sl.js
11006
+ // ../../opt/toolchain/node_modules/zod/v4/locales/sl.js
11007
11007
  function sl_default() {
11008
11008
  return {
11009
11009
  localeError: error48()
@@ -11011,7 +11011,7 @@ function sl_default() {
11011
11011
  }
11012
11012
  var error48;
11013
11013
  var init_sl = __esm({
11014
- "node_modules/zod/v4/locales/sl.js"() {
11014
+ "../../opt/toolchain/node_modules/zod/v4/locales/sl.js"() {
11015
11015
  init_util();
11016
11016
  error48 = () => {
11017
11017
  const Sizable = {
@@ -11124,7 +11124,7 @@ var init_sl = __esm({
11124
11124
  }
11125
11125
  });
11126
11126
 
11127
- // node_modules/zod/v4/locales/sv.js
11127
+ // ../../opt/toolchain/node_modules/zod/v4/locales/sv.js
11128
11128
  function sv_default() {
11129
11129
  return {
11130
11130
  localeError: error49()
@@ -11132,7 +11132,7 @@ function sv_default() {
11132
11132
  }
11133
11133
  var error49;
11134
11134
  var init_sv = __esm({
11135
- "node_modules/zod/v4/locales/sv.js"() {
11135
+ "../../opt/toolchain/node_modules/zod/v4/locales/sv.js"() {
11136
11136
  init_util();
11137
11137
  error49 = () => {
11138
11138
  const Sizable = {
@@ -11246,7 +11246,7 @@ var init_sv = __esm({
11246
11246
  }
11247
11247
  });
11248
11248
 
11249
- // node_modules/zod/v4/locales/ta.js
11249
+ // ../../opt/toolchain/node_modules/zod/v4/locales/ta.js
11250
11250
  function ta_default() {
11251
11251
  return {
11252
11252
  localeError: error50()
@@ -11254,7 +11254,7 @@ function ta_default() {
11254
11254
  }
11255
11255
  var error50;
11256
11256
  var init_ta = __esm({
11257
- "node_modules/zod/v4/locales/ta.js"() {
11257
+ "../../opt/toolchain/node_modules/zod/v4/locales/ta.js"() {
11258
11258
  init_util();
11259
11259
  error50 = () => {
11260
11260
  const Sizable = {
@@ -11368,7 +11368,7 @@ var init_ta = __esm({
11368
11368
  }
11369
11369
  });
11370
11370
 
11371
- // node_modules/zod/v4/locales/tg.js
11371
+ // ../../opt/toolchain/node_modules/zod/v4/locales/tg.js
11372
11372
  function tg_default() {
11373
11373
  return {
11374
11374
  localeError: error51()
@@ -11376,7 +11376,7 @@ function tg_default() {
11376
11376
  }
11377
11377
  var error51;
11378
11378
  var init_tg = __esm({
11379
- "node_modules/zod/v4/locales/tg.js"() {
11379
+ "../../opt/toolchain/node_modules/zod/v4/locales/tg.js"() {
11380
11380
  init_util();
11381
11381
  error51 = () => {
11382
11382
  const Sizable = {
@@ -11491,7 +11491,7 @@ var init_tg = __esm({
11491
11491
  }
11492
11492
  });
11493
11493
 
11494
- // node_modules/zod/v4/locales/th.js
11494
+ // ../../opt/toolchain/node_modules/zod/v4/locales/th.js
11495
11495
  function th_default() {
11496
11496
  return {
11497
11497
  localeError: error52()
@@ -11499,7 +11499,7 @@ function th_default() {
11499
11499
  }
11500
11500
  var error52;
11501
11501
  var init_th = __esm({
11502
- "node_modules/zod/v4/locales/th.js"() {
11502
+ "../../opt/toolchain/node_modules/zod/v4/locales/th.js"() {
11503
11503
  init_util();
11504
11504
  error52 = () => {
11505
11505
  const Sizable = {
@@ -11613,7 +11613,7 @@ var init_th = __esm({
11613
11613
  }
11614
11614
  });
11615
11615
 
11616
- // node_modules/zod/v4/locales/tk.js
11616
+ // ../../opt/toolchain/node_modules/zod/v4/locales/tk.js
11617
11617
  function tk_default() {
11618
11618
  return {
11619
11619
  localeError: error53()
@@ -11621,7 +11621,7 @@ function tk_default() {
11621
11621
  }
11622
11622
  var error53;
11623
11623
  var init_tk = __esm({
11624
- "node_modules/zod/v4/locales/tk.js"() {
11624
+ "../../opt/toolchain/node_modules/zod/v4/locales/tk.js"() {
11625
11625
  init_util();
11626
11626
  error53 = () => {
11627
11627
  const Sizable = {
@@ -11727,7 +11727,7 @@ var init_tk = __esm({
11727
11727
  }
11728
11728
  });
11729
11729
 
11730
- // node_modules/zod/v4/locales/tr.js
11730
+ // ../../opt/toolchain/node_modules/zod/v4/locales/tr.js
11731
11731
  function tr_default() {
11732
11732
  return {
11733
11733
  localeError: error54()
@@ -11735,7 +11735,7 @@ function tr_default() {
11735
11735
  }
11736
11736
  var error54;
11737
11737
  var init_tr = __esm({
11738
- "node_modules/zod/v4/locales/tr.js"() {
11738
+ "../../opt/toolchain/node_modules/zod/v4/locales/tr.js"() {
11739
11739
  init_util();
11740
11740
  error54 = () => {
11741
11741
  const Sizable = {
@@ -11844,7 +11844,7 @@ var init_tr = __esm({
11844
11844
  }
11845
11845
  });
11846
11846
 
11847
- // node_modules/zod/v4/locales/uk.js
11847
+ // ../../opt/toolchain/node_modules/zod/v4/locales/uk.js
11848
11848
  function uk_default() {
11849
11849
  return {
11850
11850
  localeError: error55()
@@ -11852,7 +11852,7 @@ function uk_default() {
11852
11852
  }
11853
11853
  var error55;
11854
11854
  var init_uk = __esm({
11855
- "node_modules/zod/v4/locales/uk.js"() {
11855
+ "../../opt/toolchain/node_modules/zod/v4/locales/uk.js"() {
11856
11856
  init_util();
11857
11857
  error55 = () => {
11858
11858
  const Sizable = {
@@ -11964,17 +11964,17 @@ var init_uk = __esm({
11964
11964
  }
11965
11965
  });
11966
11966
 
11967
- // node_modules/zod/v4/locales/ua.js
11967
+ // ../../opt/toolchain/node_modules/zod/v4/locales/ua.js
11968
11968
  function ua_default() {
11969
11969
  return uk_default();
11970
11970
  }
11971
11971
  var init_ua = __esm({
11972
- "node_modules/zod/v4/locales/ua.js"() {
11972
+ "../../opt/toolchain/node_modules/zod/v4/locales/ua.js"() {
11973
11973
  init_uk();
11974
11974
  }
11975
11975
  });
11976
11976
 
11977
- // node_modules/zod/v4/locales/ur.js
11977
+ // ../../opt/toolchain/node_modules/zod/v4/locales/ur.js
11978
11978
  function ur_default() {
11979
11979
  return {
11980
11980
  localeError: error56()
@@ -11982,7 +11982,7 @@ function ur_default() {
11982
11982
  }
11983
11983
  var error56;
11984
11984
  var init_ur = __esm({
11985
- "node_modules/zod/v4/locales/ur.js"() {
11985
+ "../../opt/toolchain/node_modules/zod/v4/locales/ur.js"() {
11986
11986
  init_util();
11987
11987
  error56 = () => {
11988
11988
  const Sizable = {
@@ -12096,7 +12096,7 @@ var init_ur = __esm({
12096
12096
  }
12097
12097
  });
12098
12098
 
12099
- // node_modules/zod/v4/locales/uz.js
12099
+ // ../../opt/toolchain/node_modules/zod/v4/locales/uz.js
12100
12100
  function uz_default() {
12101
12101
  return {
12102
12102
  localeError: error57()
@@ -12104,7 +12104,7 @@ function uz_default() {
12104
12104
  }
12105
12105
  var error57;
12106
12106
  var init_uz = __esm({
12107
- "node_modules/zod/v4/locales/uz.js"() {
12107
+ "../../opt/toolchain/node_modules/zod/v4/locales/uz.js"() {
12108
12108
  init_util();
12109
12109
  error57 = () => {
12110
12110
  const Sizable = {
@@ -12216,7 +12216,7 @@ var init_uz = __esm({
12216
12216
  }
12217
12217
  });
12218
12218
 
12219
- // node_modules/zod/v4/locales/vi.js
12219
+ // ../../opt/toolchain/node_modules/zod/v4/locales/vi.js
12220
12220
  function vi_default() {
12221
12221
  return {
12222
12222
  localeError: error58()
@@ -12224,7 +12224,7 @@ function vi_default() {
12224
12224
  }
12225
12225
  var error58;
12226
12226
  var init_vi = __esm({
12227
- "node_modules/zod/v4/locales/vi.js"() {
12227
+ "../../opt/toolchain/node_modules/zod/v4/locales/vi.js"() {
12228
12228
  init_util();
12229
12229
  error58 = () => {
12230
12230
  const Sizable = {
@@ -12336,7 +12336,7 @@ var init_vi = __esm({
12336
12336
  }
12337
12337
  });
12338
12338
 
12339
- // node_modules/zod/v4/locales/zh-CN.js
12339
+ // ../../opt/toolchain/node_modules/zod/v4/locales/zh-CN.js
12340
12340
  function zh_CN_default() {
12341
12341
  return {
12342
12342
  localeError: error59()
@@ -12344,7 +12344,7 @@ function zh_CN_default() {
12344
12344
  }
12345
12345
  var error59;
12346
12346
  var init_zh_CN = __esm({
12347
- "node_modules/zod/v4/locales/zh-CN.js"() {
12347
+ "../../opt/toolchain/node_modules/zod/v4/locales/zh-CN.js"() {
12348
12348
  init_util();
12349
12349
  error59 = () => {
12350
12350
  const Sizable = {
@@ -12457,7 +12457,7 @@ var init_zh_CN = __esm({
12457
12457
  }
12458
12458
  });
12459
12459
 
12460
- // node_modules/zod/v4/locales/zh-TW.js
12460
+ // ../../opt/toolchain/node_modules/zod/v4/locales/zh-TW.js
12461
12461
  function zh_TW_default() {
12462
12462
  return {
12463
12463
  localeError: error60()
@@ -12465,7 +12465,7 @@ function zh_TW_default() {
12465
12465
  }
12466
12466
  var error60;
12467
12467
  var init_zh_TW = __esm({
12468
- "node_modules/zod/v4/locales/zh-TW.js"() {
12468
+ "../../opt/toolchain/node_modules/zod/v4/locales/zh-TW.js"() {
12469
12469
  init_util();
12470
12470
  error60 = () => {
12471
12471
  const Sizable = {
@@ -12576,7 +12576,7 @@ var init_zh_TW = __esm({
12576
12576
  }
12577
12577
  });
12578
12578
 
12579
- // node_modules/zod/v4/locales/yo.js
12579
+ // ../../opt/toolchain/node_modules/zod/v4/locales/yo.js
12580
12580
  function yo_default() {
12581
12581
  return {
12582
12582
  localeError: error61()
@@ -12584,7 +12584,7 @@ function yo_default() {
12584
12584
  }
12585
12585
  var error61;
12586
12586
  var init_yo = __esm({
12587
- "node_modules/zod/v4/locales/yo.js"() {
12587
+ "../../opt/toolchain/node_modules/zod/v4/locales/yo.js"() {
12588
12588
  init_util();
12589
12589
  error61 = () => {
12590
12590
  const Sizable = {
@@ -12695,7 +12695,7 @@ var init_yo = __esm({
12695
12695
  }
12696
12696
  });
12697
12697
 
12698
- // node_modules/zod/v4/locales/index.js
12698
+ // ../../opt/toolchain/node_modules/zod/v4/locales/index.js
12699
12699
  var locales_exports = {};
12700
12700
  __export(locales_exports, {
12701
12701
  ar: () => ar_default,
@@ -12763,7 +12763,7 @@ __export(locales_exports, {
12763
12763
  zhTW: () => zh_TW_default
12764
12764
  });
12765
12765
  var init_locales = __esm({
12766
- "node_modules/zod/v4/locales/index.js"() {
12766
+ "../../opt/toolchain/node_modules/zod/v4/locales/index.js"() {
12767
12767
  init_ar();
12768
12768
  init_az();
12769
12769
  init_be();
@@ -12830,13 +12830,13 @@ var init_locales = __esm({
12830
12830
  }
12831
12831
  });
12832
12832
 
12833
- // node_modules/zod/v4/core/registries.js
12833
+ // ../../opt/toolchain/node_modules/zod/v4/core/registries.js
12834
12834
  function registry() {
12835
12835
  return new $ZodRegistry();
12836
12836
  }
12837
12837
  var _a2, $output, $input, $ZodRegistry, globalRegistry;
12838
12838
  var init_registries = __esm({
12839
- "node_modules/zod/v4/core/registries.js"() {
12839
+ "../../opt/toolchain/node_modules/zod/v4/core/registries.js"() {
12840
12840
  $output = /* @__PURE__ */ Symbol("ZodOutput");
12841
12841
  $input = /* @__PURE__ */ Symbol("ZodInput");
12842
12842
  $ZodRegistry = class {
@@ -12884,7 +12884,7 @@ var init_registries = __esm({
12884
12884
  }
12885
12885
  });
12886
12886
 
12887
- // node_modules/zod/v4/core/compile.js
12887
+ // ../../opt/toolchain/node_modules/zod/v4/core/compile.js
12888
12888
  function compileValidator(schema, parser) {
12889
12889
  try {
12890
12890
  return compileFn(schema, { assertOnly: true });
@@ -14446,7 +14446,7 @@ function generateTransformCheck(doc, ctx, schema, accessor) {
14446
14446
  }
14447
14447
  var INVALID, FALLBACK_FLAG, ZodCompileAsyncError, ZodCompileUnsupportedError, WHEN_DEFAULTED_CHECKS, PATTERN_IS_COMPLETE;
14448
14448
  var init_compile = __esm({
14449
- "node_modules/zod/v4/core/compile.js"() {
14449
+ "../../opt/toolchain/node_modules/zod/v4/core/compile.js"() {
14450
14450
  init_core();
14451
14451
  init_doc();
14452
14452
  init_memoizer();
@@ -14505,7 +14505,7 @@ var init_compile = __esm({
14505
14505
  }
14506
14506
  });
14507
14507
 
14508
- // node_modules/zod/v4/core/api.js
14508
+ // ../../opt/toolchain/node_modules/zod/v4/core/api.js
14509
14509
  function snapshotChecks(def) {
14510
14510
  if (def.checks)
14511
14511
  def.checks = [...def.checks];
@@ -15558,7 +15558,7 @@ function _stringFormat(Class2, format, fnOrRegex, _params = {}) {
15558
15558
  }
15559
15559
  var TimePrecision;
15560
15560
  var init_api = __esm({
15561
- "node_modules/zod/v4/core/api.js"() {
15561
+ "../../opt/toolchain/node_modules/zod/v4/core/api.js"() {
15562
15562
  init_checks();
15563
15563
  init_registries();
15564
15564
  init_schemas();
@@ -15573,7 +15573,7 @@ var init_api = __esm({
15573
15573
  }
15574
15574
  });
15575
15575
 
15576
- // node_modules/zod/v4/core/to-json-schema.js
15576
+ // ../../opt/toolchain/node_modules/zod/v4/core/to-json-schema.js
15577
15577
  function assignProps(target, ...sources) {
15578
15578
  for (const source of sources) {
15579
15579
  for (const key of Reflect.ownKeys(source)) {
@@ -16089,7 +16089,7 @@ function isTransforming(_schema, _ctx) {
16089
16089
  }
16090
16090
  var FOLDABLE_KEYS, UNION_KEYS, createToJSONSchemaMethod, createStandardJSONSchemaMethod;
16091
16091
  var init_to_json_schema = __esm({
16092
- "node_modules/zod/v4/core/to-json-schema.js"() {
16092
+ "../../opt/toolchain/node_modules/zod/v4/core/to-json-schema.js"() {
16093
16093
  init_registries();
16094
16094
  init_util();
16095
16095
  FOLDABLE_KEYS = /* @__PURE__ */ new Set(["type", "properties", "required", "additionalProperties"]);
@@ -16110,7 +16110,7 @@ var init_to_json_schema = __esm({
16110
16110
  }
16111
16111
  });
16112
16112
 
16113
- // node_modules/zod/v4/core/json-schema-processors.js
16113
+ // ../../opt/toolchain/node_modules/zod/v4/core/json-schema-processors.js
16114
16114
  function aggregateChecks(schema) {
16115
16115
  const agg = {};
16116
16116
  const def = schema._zod.def;
@@ -16260,7 +16260,7 @@ function toJSONSchema(input2, params) {
16260
16260
  }
16261
16261
  var narrowMin, narrowMax, narrowBoth, addDivisor, addPattern, intersectMime, setFormat, minContributor, maxContributor, formatContributor, contributors, formatMap, exactPatterns, exactPattern, stringProcessor, numberProcessor, booleanProcessor, bigintProcessor, symbolProcessor, nullProcessor, undefinedProcessor, voidProcessor, neverProcessor, anyProcessor, unknownProcessor, dateProcessor, enumProcessor, literalProcessor, nanProcessor, templateLiteralProcessor, fileProcessor, successProcessor, customProcessor, functionProcessor, transformProcessor, mapProcessor, setProcessor, arrayProcessor, objectProcessor, unionProcessor, intersectionProcessor, tupleProcessor, pendingRecords, recordProcessor, nullableProcessor, nonoptionalProcessor, UNREPRESENTABLE_DEFAULT, defaultProcessor, prefaultProcessor, catchProcessor, pipeProcessor, readonlyProcessor, promiseProcessor, optionalProcessor, lazyProcessor, allProcessors;
16262
16262
  var init_json_schema_processors = __esm({
16263
- "node_modules/zod/v4/core/json-schema-processors.js"() {
16263
+ "../../opt/toolchain/node_modules/zod/v4/core/json-schema-processors.js"() {
16264
16264
  init_regexes();
16265
16265
  init_schemas();
16266
16266
  init_to_json_schema();
@@ -16867,10 +16867,10 @@ var init_json_schema_processors = __esm({
16867
16867
  }
16868
16868
  });
16869
16869
 
16870
- // node_modules/zod/v4/core/json-schema-generator.js
16870
+ // ../../opt/toolchain/node_modules/zod/v4/core/json-schema-generator.js
16871
16871
  var JSONSchemaGenerator;
16872
16872
  var init_json_schema_generator = __esm({
16873
- "node_modules/zod/v4/core/json-schema-generator.js"() {
16873
+ "../../opt/toolchain/node_modules/zod/v4/core/json-schema-generator.js"() {
16874
16874
  init_json_schema_processors();
16875
16875
  init_to_json_schema();
16876
16876
  JSONSchemaGenerator = class {
@@ -16952,14 +16952,14 @@ var init_json_schema_generator = __esm({
16952
16952
  }
16953
16953
  });
16954
16954
 
16955
- // node_modules/zod/v4/core/json-schema.js
16955
+ // ../../opt/toolchain/node_modules/zod/v4/core/json-schema.js
16956
16956
  var json_schema_exports = {};
16957
16957
  var init_json_schema = __esm({
16958
- "node_modules/zod/v4/core/json-schema.js"() {
16958
+ "../../opt/toolchain/node_modules/zod/v4/core/json-schema.js"() {
16959
16959
  }
16960
16960
  });
16961
16961
 
16962
- // node_modules/zod/v4/core/index.js
16962
+ // ../../opt/toolchain/node_modules/zod/v4/core/index.js
16963
16963
  var core_exports2 = {};
16964
16964
  __export(core_exports2, {
16965
16965
  $ZodAny: () => $ZodAny,
@@ -17276,7 +17276,7 @@ __export(core_exports2, {
17276
17276
  withParser: () => withParser
17277
17277
  });
17278
17278
  var init_core2 = __esm({
17279
- "node_modules/zod/v4/core/index.js"() {
17279
+ "../../opt/toolchain/node_modules/zod/v4/core/index.js"() {
17280
17280
  init_core();
17281
17281
  init_parse();
17282
17282
  init_errors();
@@ -17299,7 +17299,7 @@ var init_core2 = __esm({
17299
17299
  }
17300
17300
  });
17301
17301
 
17302
- // node_modules/zod/v4/classic/checks.js
17302
+ // ../../opt/toolchain/node_modules/zod/v4/classic/checks.js
17303
17303
  var checks_exports2 = {};
17304
17304
  __export(checks_exports2, {
17305
17305
  endsWith: () => _endsWith,
@@ -17334,12 +17334,12 @@ __export(checks_exports2, {
17334
17334
  uppercase: () => _uppercase
17335
17335
  });
17336
17336
  var init_checks2 = __esm({
17337
- "node_modules/zod/v4/classic/checks.js"() {
17337
+ "../../opt/toolchain/node_modules/zod/v4/classic/checks.js"() {
17338
17338
  init_core2();
17339
17339
  }
17340
17340
  });
17341
17341
 
17342
- // node_modules/zod/v4/classic/errors.js
17342
+ // ../../opt/toolchain/node_modules/zod/v4/classic/errors.js
17343
17343
  function _lazyMethod(proto, key, make) {
17344
17344
  Object.defineProperty(proto, key, {
17345
17345
  configurable: true,
@@ -17356,7 +17356,7 @@ function _lazyMethod(proto, key, make) {
17356
17356
  }
17357
17357
  var _installedErrorProtos, initializer2, ZodError, ZodRealError;
17358
17358
  var init_errors2 = __esm({
17359
- "node_modules/zod/v4/classic/errors.js"() {
17359
+ "../../opt/toolchain/node_modules/zod/v4/classic/errors.js"() {
17360
17360
  init_core2();
17361
17361
  init_core2();
17362
17362
  init_util();
@@ -17393,10 +17393,10 @@ var init_errors2 = __esm({
17393
17393
  }
17394
17394
  });
17395
17395
 
17396
- // node_modules/zod/v4/classic/parse.js
17396
+ // ../../opt/toolchain/node_modules/zod/v4/classic/parse.js
17397
17397
  var parse2, parseAsync2, safeParse2, safeParseAsync2, encode2, decode2, encodeAsync2, decodeAsync2, safeEncode2, safeDecode2, safeEncodeAsync2, safeDecodeAsync2;
17398
17398
  var init_parse2 = __esm({
17399
- "node_modules/zod/v4/classic/parse.js"() {
17399
+ "../../opt/toolchain/node_modules/zod/v4/classic/parse.js"() {
17400
17400
  init_core2();
17401
17401
  init_errors2();
17402
17402
  init_core2();
@@ -17415,7 +17415,7 @@ var init_parse2 = __esm({
17415
17415
  }
17416
17416
  });
17417
17417
 
17418
- // node_modules/zod/v4/classic/schemas.js
17418
+ // ../../opt/toolchain/node_modules/zod/v4/classic/schemas.js
17419
17419
  var schemas_exports2 = {};
17420
17420
  __export(schemas_exports2, {
17421
17421
  ZodAny: () => ZodAny,
@@ -18089,7 +18089,7 @@ function preprocess(fn, schema) {
18089
18089
  }
18090
18090
  var ZodType, _ZodString, ZodString, ZodStringFormat, ZodISODateTime, ZodISODate, ZodISOTime, ZodISODuration, ZodEmail, ZodGUID, ZodUUID, ZodURL, ZodEmoji, ZodNanoID, ZodCUID, ZodCUID2, ZodULID, ZodXID, ZodKSUID, ZodIPv4, ZodMAC, ZodIPv6, ZodCIDRv4, ZodCIDRv6, ZodBase64, ZodBase64URL, ZodE164, ZodCreditCard, ZodIBAN, ZodJWT, ZodCustomStringFormat, ZodNumber, ZodNumberFormat, ZodBoolean, ZodBigInt, ZodBigIntFormat, ZodSymbol, ZodUndefined, ZodNull, ZodAny, ZodUnknown, ZodNever, ZodVoid, ZodDate, ZodArray, ZodObject, ZodUnion, ZodXor, ZodDiscriminatedUnion, ZodIntersection, ZodTuple, ZodRecord, ZodMap, ZodSet, ZodEnum, ZodLiteral, ZodFile, ZodTransform, ZodOptional, ZodExactOptional, ZodNullable, ZodDefault, ZodPrefault, ZodNonOptional, ZodSuccess, ZodCatch, ZodNaN, ZodPipe, ZodCodec, ZodPreprocess, ZodReadonly, ZodTemplateLiteral, ZodLazy, ZodPromise, ZodFunction, ZodCustom, describe2, meta2, ZodInstanceOf, stringbool;
18091
18091
  var init_schemas2 = __esm({
18092
- "node_modules/zod/v4/classic/schemas.js"() {
18092
+ "../../opt/toolchain/node_modules/zod/v4/classic/schemas.js"() {
18093
18093
  init_core2();
18094
18094
  init_core2();
18095
18095
  init_json_schema_processors();
@@ -19072,7 +19072,7 @@ var init_schemas2 = __esm({
19072
19072
  }
19073
19073
  });
19074
19074
 
19075
- // node_modules/zod/v4/classic/compat.js
19075
+ // ../../opt/toolchain/node_modules/zod/v4/classic/compat.js
19076
19076
  function setErrorMap(map2) {
19077
19077
  config({
19078
19078
  customError: map2
@@ -19083,7 +19083,7 @@ function getErrorMap() {
19083
19083
  }
19084
19084
  var ZodIssueCode, ZodFirstPartyTypeKind;
19085
19085
  var init_compat = __esm({
19086
- "node_modules/zod/v4/classic/compat.js"() {
19086
+ "../../opt/toolchain/node_modules/zod/v4/classic/compat.js"() {
19087
19087
  init_core2();
19088
19088
  ZodIssueCode = {
19089
19089
  invalid_type: "invalid_type",
@@ -19103,7 +19103,7 @@ var init_compat = __esm({
19103
19103
  }
19104
19104
  });
19105
19105
 
19106
- // node_modules/zod/v4/classic/iso.js
19106
+ // ../../opt/toolchain/node_modules/zod/v4/classic/iso.js
19107
19107
  var iso_exports = {};
19108
19108
  __export(iso_exports, {
19109
19109
  ZodISODate: () => ZodISODate,
@@ -19128,14 +19128,14 @@ function duration2(params) {
19128
19128
  return _isoDuration(ZodISODuration, params);
19129
19129
  }
19130
19130
  var init_iso = __esm({
19131
- "node_modules/zod/v4/classic/iso.js"() {
19131
+ "../../opt/toolchain/node_modules/zod/v4/classic/iso.js"() {
19132
19132
  init_core2();
19133
19133
  init_schemas2();
19134
19134
  init_schemas2();
19135
19135
  }
19136
19136
  });
19137
19137
 
19138
- // node_modules/zod/v4/classic/from-json-schema.js
19138
+ // ../../opt/toolchain/node_modules/zod/v4/classic/from-json-schema.js
19139
19139
  function detectVersion(schema, defaultTarget) {
19140
19140
  const $schema = schema.$schema;
19141
19141
  if ($schema === "https://json-schema.org/draft/2020-12/schema") {
@@ -19766,7 +19766,7 @@ function fromJSONSchema(schema, params) {
19766
19766
  }
19767
19767
  var z, RECOGNIZED_KEYS, SCHEMA_KEYWORDS, SCHEMA_MAP_KEYWORDS, fullTime;
19768
19768
  var init_from_json_schema = __esm({
19769
- "node_modules/zod/v4/classic/from-json-schema.js"() {
19769
+ "../../opt/toolchain/node_modules/zod/v4/classic/from-json-schema.js"() {
19770
19770
  init_registries();
19771
19771
  init_util();
19772
19772
  init_checks2();
@@ -19878,7 +19878,7 @@ var init_from_json_schema = __esm({
19878
19878
  }
19879
19879
  });
19880
19880
 
19881
- // node_modules/zod/v4/core/visit.js
19881
+ // ../../opt/toolchain/node_modules/zod/v4/core/visit.js
19882
19882
  function visit(schema, fnOrHandlers) {
19883
19883
  const fn = typeof fnOrHandlers === "function" ? fnOrHandlers : (node2, rewritten) => {
19884
19884
  const h = fnOrHandlers[node2._zod.def.type];
@@ -20033,14 +20033,14 @@ function visit(schema, fnOrHandlers) {
20033
20033
  }
20034
20034
  var RESOLVING;
20035
20035
  var init_visit = __esm({
20036
- "node_modules/zod/v4/core/visit.js"() {
20036
+ "../../opt/toolchain/node_modules/zod/v4/core/visit.js"() {
20037
20037
  init_schemas();
20038
20038
  init_util();
20039
20039
  RESOLVING = Symbol("z.visit/resolving");
20040
20040
  }
20041
20041
  });
20042
20042
 
20043
- // node_modules/zod/v4/classic/deep-partial.js
20043
+ // ../../opt/toolchain/node_modules/zod/v4/classic/deep-partial.js
20044
20044
  function deepPartial(schema) {
20045
20045
  return visit(schema, {
20046
20046
  object: (s) => s.partial(),
@@ -20052,13 +20052,13 @@ function deepPartial(schema) {
20052
20052
  });
20053
20053
  }
20054
20054
  var init_deep_partial = __esm({
20055
- "node_modules/zod/v4/classic/deep-partial.js"() {
20055
+ "../../opt/toolchain/node_modules/zod/v4/classic/deep-partial.js"() {
20056
20056
  init_visit();
20057
20057
  init_schemas2();
20058
20058
  }
20059
20059
  });
20060
20060
 
20061
- // node_modules/zod/v4/classic/in-out.js
20061
+ // ../../opt/toolchain/node_modules/zod/v4/classic/in-out.js
20062
20062
  function withChecks(side, checks) {
20063
20063
  if (!checks?.length)
20064
20064
  return side;
@@ -20088,14 +20088,14 @@ function output(schema) {
20088
20088
  });
20089
20089
  }
20090
20090
  var init_in_out = __esm({
20091
- "node_modules/zod/v4/classic/in-out.js"() {
20091
+ "../../opt/toolchain/node_modules/zod/v4/classic/in-out.js"() {
20092
20092
  init_util();
20093
20093
  init_visit();
20094
20094
  init_schemas2();
20095
20095
  }
20096
20096
  });
20097
20097
 
20098
- // node_modules/zod/v4/classic/coerce.js
20098
+ // ../../opt/toolchain/node_modules/zod/v4/classic/coerce.js
20099
20099
  var coerce_exports = {};
20100
20100
  __export(coerce_exports, {
20101
20101
  bigint: () => bigint3,
@@ -20120,13 +20120,13 @@ function date4(params) {
20120
20120
  return _coercedDate(ZodDate, params);
20121
20121
  }
20122
20122
  var init_coerce = __esm({
20123
- "node_modules/zod/v4/classic/coerce.js"() {
20123
+ "../../opt/toolchain/node_modules/zod/v4/classic/coerce.js"() {
20124
20124
  init_core2();
20125
20125
  init_schemas2();
20126
20126
  }
20127
20127
  });
20128
20128
 
20129
- // node_modules/zod/v4/classic/external.js
20129
+ // ../../opt/toolchain/node_modules/zod/v4/classic/external.js
20130
20130
  var external_exports = {};
20131
20131
  __export(external_exports, {
20132
20132
  $brand: () => $brand,
@@ -20389,7 +20389,7 @@ __export(external_exports, {
20389
20389
  xor: () => xor
20390
20390
  });
20391
20391
  var init_external = __esm({
20392
- "node_modules/zod/v4/classic/external.js"() {
20392
+ "../../opt/toolchain/node_modules/zod/v4/classic/external.js"() {
20393
20393
  init_core2();
20394
20394
  init_schemas2();
20395
20395
  init_checks2();
@@ -20408,9 +20408,9 @@ var init_external = __esm({
20408
20408
  }
20409
20409
  });
20410
20410
 
20411
- // node_modules/zod/index.js
20411
+ // ../../opt/toolchain/node_modules/zod/index.js
20412
20412
  var init_zod = __esm({
20413
- "node_modules/zod/index.js"() {
20413
+ "../../opt/toolchain/node_modules/zod/index.js"() {
20414
20414
  init_external();
20415
20415
  init_external();
20416
20416
  }
@@ -20716,7 +20716,7 @@ var init_redaction = __esm({
20716
20716
  SECRET_PATTERNS = [
20717
20717
  /\bsk-[A-Za-z0-9_-]{16,}\b/g,
20718
20718
  /\b(?:ghp|gho|github_pat)_[A-Za-z0-9_]{20,}\b/g,
20719
- /\b(?:tgk|tgs|art_v1)_[A-Za-z0-9_-]{20,}(?:\?expires=\d+)?/g,
20719
+ /\b(?:tgk|tgs|brk|bag|art_v1)_[A-Za-z0-9_-]{20,}(?:\?expires=\d+)?/g,
20720
20720
  /\b(?:AKIA|ASIA)[A-Z0-9]{16}\b/g,
20721
20721
  /\bAIza[A-Za-z0-9_-]{35}\b/g,
20722
20722
  /(?:Bearer\s+)[A-Za-z0-9._~+/-]{16,}=*/gi,
@@ -20762,6 +20762,30 @@ var init_context = __esm({
20762
20762
  }
20763
20763
  });
20764
20764
 
20765
+ // src/core/agent-identity.ts
20766
+ function matchesAgentBranch(branch, patterns) {
20767
+ if (!branchSchema.safeParse(branch).success) return false;
20768
+ return patterns.some(
20769
+ (pattern) => pattern === "*" || (pattern.endsWith("*") ? branch.startsWith(pattern.slice(0, -1)) : branch === pattern)
20770
+ );
20771
+ }
20772
+ var AGENT_CAPABILITIES;
20773
+ var init_agent_identity = __esm({
20774
+ "src/core/agent-identity.ts"() {
20775
+ "use strict";
20776
+ init_schemas3();
20777
+ AGENT_CAPABILITIES = [
20778
+ "git:read",
20779
+ "git:write",
20780
+ "git:review",
20781
+ "git:merge",
20782
+ "git:check",
20783
+ "execution:read",
20784
+ "execution:write"
20785
+ ];
20786
+ }
20787
+ });
20788
+
20765
20789
  // src/sdk/client.ts
20766
20790
  var TraceGitError, TraceGitClient, TraceExecution;
20767
20791
  var init_client = __esm({
@@ -20770,6 +20794,7 @@ var init_client = __esm({
20770
20794
  init_crypto();
20771
20795
  init_context();
20772
20796
  init_schemas3();
20797
+ init_agent_identity();
20773
20798
  TraceGitError = class extends Error {
20774
20799
  constructor(code, message, status, details) {
20775
20800
  super(message);
@@ -20783,6 +20808,8 @@ var init_client = __esm({
20783
20808
  url;
20784
20809
  apiKey;
20785
20810
  transport;
20811
+ authenticatedAgent;
20812
+ pendingIdentity;
20786
20813
  constructor(options) {
20787
20814
  const url2 = new URL(options.url);
20788
20815
  if (url2.username || url2.password || url2.search || url2.hash || url2.protocol !== "https:" && !(url2.protocol === "http:" && ["localhost", "127.0.0.1", "[::1]"].includes(url2.hostname)))
@@ -20793,6 +20820,100 @@ var init_client = __esm({
20793
20820
  this.apiKey = options.apiKey;
20794
20821
  this.transport = options.fetch ?? globalThis.fetch.bind(globalThis);
20795
20822
  }
20823
+ get isAgentCredential() {
20824
+ return this.apiKey.startsWith("bag_") || this.authenticatedAgent !== void 0;
20825
+ }
20826
+ rememberIdentity(principal) {
20827
+ if (principal.source !== "agent") {
20828
+ if (this.isAgentCredential)
20829
+ throw new TraceGitError(
20830
+ "agent_identity_required",
20831
+ "Use an authenticated agent credential.",
20832
+ 403
20833
+ );
20834
+ return;
20835
+ }
20836
+ const identity2 = principal.agent;
20837
+ if (!identity2 || principal.id !== identity2.agentId || principal.role !== "operator" || !idSchema.safeParse(principal.workspaceId).success || !idSchema.safeParse(identity2.agentId).success || !idSchema.safeParse(identity2.projectId).success || !idSchema.safeParse(identity2.credentialId).success || !Number.isSafeInteger(identity2.generation) || identity2.generation < 1 || !Array.isArray(identity2.capabilities) || identity2.capabilities.some((value) => !AGENT_CAPABILITIES.includes(value)) || !Array.isArray(identity2.writeBranches) || identity2.writeBranches.some((value) => typeof value !== "string"))
20838
+ throw new TraceGitError(
20839
+ "invalid_agent_identity",
20840
+ "The service returned an invalid agent identity.",
20841
+ 502
20842
+ );
20843
+ if (this.authenticatedAgent && (this.authenticatedAgent.agentId !== identity2.agentId || this.authenticatedAgent.projectId !== identity2.projectId || this.authenticatedAgent.credentialId !== identity2.credentialId))
20844
+ throw new TraceGitError(
20845
+ "invalid_agent_identity",
20846
+ "The credential identity changed unexpectedly.",
20847
+ 502
20848
+ );
20849
+ this.authenticatedAgent = {
20850
+ ...identity2,
20851
+ capabilities: [...identity2.capabilities],
20852
+ writeBranches: [...identity2.writeBranches]
20853
+ };
20854
+ }
20855
+ /** Resolves machine authority once; every Worker operation still rechecks live authority. */
20856
+ async assignedAgent() {
20857
+ if (!this.authenticatedAgent && this.isAgentCredential) {
20858
+ this.pendingIdentity ??= this.agentIdentity().then((session) => session.principal.agent).catch((error62) => {
20859
+ this.pendingIdentity = void 0;
20860
+ throw error62;
20861
+ });
20862
+ await this.pendingIdentity;
20863
+ }
20864
+ return this.authenticatedAgent ? {
20865
+ ...this.authenticatedAgent,
20866
+ capabilities: [...this.authenticatedAgent.capabilities],
20867
+ writeBranches: [...this.authenticatedAgent.writeBranches]
20868
+ } : void 0;
20869
+ }
20870
+ async assertExecutionAgent(agentId) {
20871
+ const identity2 = await this.assignedAgent();
20872
+ if (identity2 && identity2.agentId !== agentId)
20873
+ throw new TraceGitError(
20874
+ "agent_execution_scope",
20875
+ "Use the authenticated agent identity for execution evidence.",
20876
+ 403
20877
+ );
20878
+ if (identity2 && !identity2.capabilities.includes("execution:write"))
20879
+ throw new TraceGitError(
20880
+ "agent_capability_required",
20881
+ "Execution writes are outside the agent grant.",
20882
+ 403
20883
+ );
20884
+ }
20885
+ assertAdministration() {
20886
+ if (this.isAgentCredential)
20887
+ throw new TraceGitError(
20888
+ "agent_administration_forbidden",
20889
+ "Agent credentials cannot provision identities or administer service grants.",
20890
+ 403
20891
+ );
20892
+ }
20893
+ async authorizeProject(projectId, capability, branch) {
20894
+ idSchema.parse(projectId);
20895
+ const identity2 = await this.assignedAgent();
20896
+ if (!identity2) return;
20897
+ if (projectId !== identity2.projectId)
20898
+ throw new TraceGitError(
20899
+ "agent_project_scope",
20900
+ "The credential is assigned to another project.",
20901
+ 403
20902
+ );
20903
+ if (capability && !identity2.capabilities.includes(capability))
20904
+ throw new TraceGitError(
20905
+ "agent_capability_required",
20906
+ "The operation is outside the agent grant.",
20907
+ 403,
20908
+ { capability }
20909
+ );
20910
+ if (branch !== void 0 && !matchesAgentBranch(branch, identity2.writeBranches))
20911
+ throw new TraceGitError(
20912
+ "agent_branch_scope",
20913
+ "The branch is outside the agent write grant.",
20914
+ 403
20915
+ );
20916
+ }
20796
20917
  async raw(path, init = {}) {
20797
20918
  if (!path.startsWith("/") || path.startsWith("//"))
20798
20919
  throw new Error("Expected an API-relative path");
@@ -20835,10 +20956,13 @@ var init_client = __esm({
20835
20956
  }
20836
20957
  }
20837
20958
  }
20838
- createAgent(options) {
20959
+ async createAgent(options) {
20960
+ this.assertAdministration();
20839
20961
  return this.request("/agents", "POST", { ...options, id: options.id ?? newId("agt") }, true);
20840
20962
  }
20841
20963
  async createRun(options) {
20964
+ await this.authorizeProject(options.projectId, "execution:write", options.branch ?? "main");
20965
+ await this.assertExecutionAgent(options.rootAgentId);
20842
20966
  const run = await this.request(
20843
20967
  "/runs",
20844
20968
  "POST",
@@ -20847,16 +20971,131 @@ var init_client = __esm({
20847
20971
  );
20848
20972
  return new TraceExecution(this, run.id, options.rootAgentId);
20849
20973
  }
20974
+ async createAgentRun(options) {
20975
+ const identity2 = await this.assignedAgent();
20976
+ if (!identity2)
20977
+ throw new TraceGitError(
20978
+ "agent_identity_required",
20979
+ "Use an agent credential to start an assigned execution.",
20980
+ 403
20981
+ );
20982
+ return this.createRun({
20983
+ ...options,
20984
+ projectId: identity2.projectId,
20985
+ rootAgentId: identity2.agentId
20986
+ });
20987
+ }
20850
20988
  execution(runId, agentId) {
20851
20989
  return new TraceExecution(this, runId, agentId);
20852
20990
  }
20853
- events(events) {
20991
+ async events(events) {
20992
+ const identity2 = await this.assignedAgent();
20993
+ if (identity2 && events.some((event) => event.agentId !== identity2.agentId))
20994
+ throw new TraceGitError(
20995
+ "agent_execution_scope",
20996
+ "Events must use the authenticated agent identity.",
20997
+ 403
20998
+ );
20999
+ if (identity2 && !identity2.capabilities.includes("execution:write"))
21000
+ throw new TraceGitError(
21001
+ "agent_capability_required",
21002
+ "Execution writes are outside the agent grant.",
21003
+ 403
21004
+ );
20854
21005
  return this.request("/events", "POST", { events }, true);
20855
21006
  }
20856
- me() {
20857
- return this.request("/me");
21007
+ async me() {
21008
+ const result = await this.request("/me");
21009
+ this.rememberIdentity(result.principal);
21010
+ if (result.principal.source === "agent" && result.workspace.id !== result.principal.workspaceId)
21011
+ throw new TraceGitError(
21012
+ "invalid_agent_identity",
21013
+ "The agent workspace metadata is inconsistent.",
21014
+ 502
21015
+ );
21016
+ return result;
21017
+ }
21018
+ async agentIdentity() {
21019
+ const result = await this.request("/agent/me");
21020
+ if (result.principal.source !== "agent" || result.protocol !== "branchora.agents.v1" || result.headless !== true)
21021
+ throw new TraceGitError(
21022
+ "invalid_agent_identity",
21023
+ "The service did not return the headless agent protocol.",
21024
+ 502
21025
+ );
21026
+ this.rememberIdentity(result.principal);
21027
+ return result;
21028
+ }
21029
+ async repositoryAutomation(projectId) {
21030
+ await this.authorizeProject(projectId, "git:read");
21031
+ return this.request(`/projects/${encodeURIComponent(projectId)}/automation`);
21032
+ }
21033
+ async configureAgentRepository(projectId, expectedVersion = 0) {
21034
+ this.assertAdministration();
21035
+ idSchema.parse(projectId);
21036
+ return this.request(
21037
+ `/projects/${encodeURIComponent(projectId)}/automation`,
21038
+ "PUT",
21039
+ { mode: "agents-only", expectedVersion }
21040
+ );
21041
+ }
21042
+ async listAgentAccess(projectId) {
21043
+ this.assertAdministration();
21044
+ idSchema.parse(projectId);
21045
+ return this.request(`/projects/${encodeURIComponent(projectId)}/agent-access`);
21046
+ }
21047
+ async grantAgentAccess(projectId, agentId, options) {
21048
+ this.assertAdministration();
21049
+ idSchema.parse(projectId);
21050
+ idSchema.parse(agentId);
21051
+ return this.request(
21052
+ `/projects/${encodeURIComponent(projectId)}/agent-access/${encodeURIComponent(agentId)}`,
21053
+ "PUT",
21054
+ { ...options, expectedGeneration: options.expectedGeneration ?? 0 }
21055
+ );
21056
+ }
21057
+ async issueAgentCredential(projectId, agentId, name, expiresInHours = 24) {
21058
+ this.assertAdministration();
21059
+ idSchema.parse(projectId);
21060
+ idSchema.parse(agentId);
21061
+ return this.request(`/projects/${encodeURIComponent(projectId)}/agent-credentials`, "POST", {
21062
+ agentId,
21063
+ name,
21064
+ expiresInHours
21065
+ });
21066
+ }
21067
+ async listAgentCredentials(projectId) {
21068
+ this.assertAdministration();
21069
+ idSchema.parse(projectId);
21070
+ return this.request(`/projects/${encodeURIComponent(projectId)}/agent-credentials`);
21071
+ }
21072
+ async revokeAgentAccess(projectId, agentId) {
21073
+ this.assertAdministration();
21074
+ idSchema.parse(projectId);
21075
+ idSchema.parse(agentId);
21076
+ return this.request(
21077
+ `/projects/${encodeURIComponent(projectId)}/agent-access/${encodeURIComponent(agentId)}`,
21078
+ "DELETE"
21079
+ );
21080
+ }
21081
+ async revokeAgentCredential(projectId, credentialId) {
21082
+ this.assertAdministration();
21083
+ idSchema.parse(projectId);
21084
+ idSchema.parse(credentialId);
21085
+ return this.request(
21086
+ `/projects/${encodeURIComponent(projectId)}/agent-credentials/${encodeURIComponent(credentialId)}`,
21087
+ "DELETE"
21088
+ );
20858
21089
  }
20859
21090
  providerHeaders(runId, agentId, requestId = newId("req")) {
21091
+ if (this.isAgentCredential && !this.authenticatedAgent)
21092
+ throw new Error("Resolve agentIdentity() before creating provider headers.");
21093
+ if (this.authenticatedAgent && agentId !== this.authenticatedAgent.agentId)
21094
+ throw new TraceGitError(
21095
+ "agent_execution_scope",
21096
+ "Provider headers must use the authenticated agent identity.",
21097
+ 403
21098
+ );
20860
21099
  return {
20861
21100
  "x-tracegit-key": this.apiKey,
20862
21101
  "x-tracegit-run-id": runId,
@@ -20865,11 +21104,103 @@ var init_client = __esm({
20865
21104
  };
20866
21105
  }
20867
21106
  gitTransport(projectId) {
21107
+ idSchema.parse(projectId);
21108
+ if (this.isAgentCredential && !this.authenticatedAgent)
21109
+ throw new Error("Resolve agentIdentity() before creating a Git transport.");
21110
+ if (this.authenticatedAgent && projectId !== this.authenticatedAgent.projectId)
21111
+ throw new TraceGitError(
21112
+ "agent_project_scope",
21113
+ "Git transport must use the assigned project.",
21114
+ 403
21115
+ );
20868
21116
  return {
20869
- remote: `${this.url}/git/${projectId}`,
21117
+ remote: `${this.url}/git/${encodeURIComponent(projectId)}`,
20870
21118
  headers: { Authorization: `Bearer ${this.apiKey}` }
20871
21119
  };
20872
21120
  }
21121
+ async repositoryRefs(projectId) {
21122
+ await this.authorizeProject(projectId, "git:read");
21123
+ return this.request(`/projects/${encodeURIComponent(projectId)}/refs`);
21124
+ }
21125
+ async readRepositoryFile(projectId, path, ref) {
21126
+ await this.authorizeProject(projectId, "git:read");
21127
+ pathSchema.parse(path);
21128
+ const query = new URLSearchParams({ path, ...ref === void 0 ? {} : { ref } });
21129
+ return this.request(`/projects/${encodeURIComponent(projectId)}/file?${query}`);
21130
+ }
21131
+ async compareRepository(projectId, base, head) {
21132
+ await this.authorizeProject(projectId, "git:read");
21133
+ const query = new URLSearchParams({ base, head });
21134
+ return this.request(`/projects/${encodeURIComponent(projectId)}/compare?${query}`);
21135
+ }
21136
+ async createBranch(projectId, branch, from, operationId = newId("git")) {
21137
+ branchSchema.parse(branch);
21138
+ await this.authorizeProject(projectId, "git:write", branch);
21139
+ return this.request(
21140
+ `/projects/${encodeURIComponent(projectId)}/branches`,
21141
+ "POST",
21142
+ { operationId, branch, from },
21143
+ true
21144
+ );
21145
+ }
21146
+ async commitFiles(projectId, options) {
21147
+ branchSchema.parse(options.branch);
21148
+ if (options.expectedHead !== null) shaSchema.parse(options.expectedHead);
21149
+ for (const file2 of options.files) pathSchema.parse(file2.path);
21150
+ await this.authorizeProject(projectId, "git:write", options.branch);
21151
+ return this.request(
21152
+ `/projects/${encodeURIComponent(projectId)}/changes`,
21153
+ "POST",
21154
+ { ...options, operationId: options.operationId ?? newId("git") },
21155
+ true
21156
+ );
21157
+ }
21158
+ async listPullRequests(projectId) {
21159
+ await this.authorizeProject(projectId, "git:read");
21160
+ return this.request(`/projects/${encodeURIComponent(projectId)}/pulls`);
21161
+ }
21162
+ async pullRequest(projectId, pullId) {
21163
+ await this.authorizeProject(projectId, "git:read");
21164
+ idSchema.parse(pullId);
21165
+ return this.request(
21166
+ `/projects/${encodeURIComponent(projectId)}/pulls/${encodeURIComponent(pullId)}`
21167
+ );
21168
+ }
21169
+ async openPullRequest(projectId, options) {
21170
+ branchSchema.parse(options.sourceBranch);
21171
+ branchSchema.parse(options.targetBranch);
21172
+ await this.authorizeProject(projectId, "git:write", options.sourceBranch);
21173
+ return this.request(`/projects/${encodeURIComponent(projectId)}/pulls`, "POST", options);
21174
+ }
21175
+ async reviewPullRequest(projectId, pullId, options) {
21176
+ await this.authorizeProject(projectId, "git:review");
21177
+ idSchema.parse(pullId);
21178
+ shaSchema.parse(options.headSha);
21179
+ return this.request(
21180
+ `/projects/${encodeURIComponent(projectId)}/pulls/${encodeURIComponent(pullId)}/reviews`,
21181
+ "POST",
21182
+ options
21183
+ );
21184
+ }
21185
+ async recordCommitCheck(projectId, options) {
21186
+ await this.authorizeProject(projectId, "git:check");
21187
+ shaSchema.parse(options.commitSha);
21188
+ return this.request(`/projects/${encodeURIComponent(projectId)}/checks`, "POST", options);
21189
+ }
21190
+ async mergePullRequest(projectId, pullId, expectedVersion, operationId = newId("git")) {
21191
+ await this.authorizeProject(projectId, "git:merge");
21192
+ idSchema.parse(pullId);
21193
+ return this.request(
21194
+ `/projects/${encodeURIComponent(projectId)}/pulls/${encodeURIComponent(pullId)}/merge`,
21195
+ "POST",
21196
+ { expectedVersion, operationId },
21197
+ true
21198
+ );
21199
+ }
21200
+ publishRun(runId) {
21201
+ idSchema.parse(runId);
21202
+ return this.request(`/runs/${encodeURIComponent(runId)}/publish`, "POST", {});
21203
+ }
20873
21204
  createWallet(options) {
20874
21205
  return this.request(
20875
21206
  "/wallets",
@@ -20996,6 +21327,7 @@ var init_client = __esm({
20996
21327
  this.blocks = [...blocks];
20997
21328
  }
20998
21329
  async decision(options) {
21330
+ await this.client.assertExecutionAgent(this.agentId);
20999
21331
  const result = await this.client.request(
21000
21332
  `/runs/${this.runId}/decisions`,
21001
21333
  "POST",
@@ -21011,6 +21343,7 @@ var init_client = __esm({
21011
21343
  return result;
21012
21344
  }
21013
21345
  async instructions(content, source = "sdk-declared") {
21346
+ await this.client.assertExecutionAgent(this.agentId);
21014
21347
  return this.client.request(
21015
21348
  `/runs/${this.runId}/instructions`,
21016
21349
  "POST",
@@ -21026,6 +21359,7 @@ var init_client = __esm({
21026
21359
  );
21027
21360
  }
21028
21361
  async delegate(options) {
21362
+ await this.client.assertExecutionAgent(this.agentId);
21029
21363
  const agent = await this.client.createAgent(options);
21030
21364
  await this.client.request(
21031
21365
  `/runs/${this.runId}/agents`,
@@ -21040,6 +21374,7 @@ var init_client = __esm({
21040
21374
  return new _TraceExecution(this.client, this.runId, agent.id);
21041
21375
  }
21042
21376
  async generate(options) {
21377
+ await this.client.assertExecutionAgent(this.agentId);
21043
21378
  const shared = await buildSharedContext(this.blocks);
21044
21379
  const messages = [
21045
21380
  ...options.system ? [{ role: "system", content: options.system }] : [],
@@ -21094,6 +21429,7 @@ var init_client = __esm({
21094
21429
  });
21095
21430
  }
21096
21431
  async complete(status, reason) {
21432
+ await this.client.assertExecutionAgent(this.agentId);
21097
21433
  const detail = await this.client.request(`/runs/${this.runId}`);
21098
21434
  await this.client.request(`/runs/${this.runId}`, "PATCH", {
21099
21435
  status,
@@ -21113,6 +21449,7 @@ var init_client = __esm({
21113
21449
  /** Fetch adapter for provider SDKs. Every call goes through the economic gate. */
21114
21450
  instrumentedFetch(provider, providerKey, context = []) {
21115
21451
  return async (input2, init) => {
21452
+ await this.client.assertExecutionAgent(this.agentId);
21116
21453
  const request = new Request(input2, init);
21117
21454
  if (request.method !== "POST")
21118
21455
  throw new Error("Instrumented provider transport only accepts inference POST requests.");
@@ -22158,7 +22495,7 @@ var init_catalog = __esm({
22158
22495
 
22159
22496
  // src/cli/provider-adapters.ts
22160
22497
  import { createHash, createHmac, createPrivateKey, sign } from "node:crypto";
22161
- import { open as open2 } from "node:fs/promises";
22498
+ import { open as open3 } from "node:fs/promises";
22162
22499
  function secret(value, label) {
22163
22500
  if (!value || value.length > 32768 || /[\x00-\x20\x7f]/.test(value))
22164
22501
  throw new ProviderAdapterError(
@@ -22311,7 +22648,7 @@ function createGoogleServiceAccountAssertion(account, now = /* @__PURE__ */ new
22311
22648
  return `${input2}.${sign("RSA-SHA256", Buffer.from(input2), key).toString("base64url")}`;
22312
22649
  }
22313
22650
  async function readGoogleCredentials(path) {
22314
- const handle = await open2(path, "r").catch(() => {
22651
+ const handle = await open3(path, "r").catch(() => {
22315
22652
  throw new ProviderAdapterError(
22316
22653
  "google_credentials_unreadable",
22317
22654
  "GOOGLE_APPLICATION_CREDENTIALS could not be opened."
@@ -23854,6 +24191,24 @@ import { promisify } from "node:util";
23854
24191
  import { mkdir, readFile, realpath, stat, unlink, writeFile } from "node:fs/promises";
23855
24192
  import { resolve, relative, sep } from "node:path";
23856
24193
  var execute = promisify(execFile);
24194
+ function gitTransportEnvironment(transport) {
24195
+ const remote = new URL(transport.remote);
24196
+ if (remote.username || remote.password || remote.search || remote.hash || remote.protocol !== "https:" && !(remote.protocol === "http:" && ["localhost", "127.0.0.1", "[::1]"].includes(remote.hostname)))
24197
+ throw new Error("Expected a credential-free HTTPS or loopback Git remote.");
24198
+ const authorization = new Headers(transport.headers).get("authorization");
24199
+ if (!authorization || /[\r\n\0]/.test(authorization))
24200
+ throw new Error("The Git transport requires a valid authorization header.");
24201
+ return {
24202
+ GIT_CONFIG_COUNT: "3",
24203
+ GIT_CONFIG_KEY_0: `http.${transport.remote.replace(/\/$/, "")}/.extraHeader`,
24204
+ GIT_CONFIG_VALUE_0: `Authorization: ${authorization}`,
24205
+ GIT_CONFIG_KEY_1: "http.followRedirects",
24206
+ GIT_CONFIG_VALUE_1: "false",
24207
+ GIT_CONFIG_KEY_2: "credential.helper",
24208
+ GIT_CONFIG_VALUE_2: "",
24209
+ GIT_TERMINAL_PROMPT: "0"
24210
+ };
24211
+ }
23857
24212
  var GitRepository = class _GitRepository {
23858
24213
  constructor(root) {
23859
24214
  this.root = root;
@@ -24014,21 +24369,18 @@ Run: ${runId}
24014
24369
  };
24015
24370
  }
24016
24371
  async push(remote, token, ref) {
24017
- if (!remote.startsWith("https://") || new URL(remote).username || new URL(remote).password)
24018
- throw new Error("Expected a credential-free HTTPS remote");
24019
24372
  if (!/^(refs\/tracegit\/checkpoints\/|refs\/heads\/|tracegit\/recovery\/|[a-zA-Z0-9])/.test(
24020
24373
  ref
24021
24374
  ) || ref.startsWith("-") || ref.includes(".."))
24022
24375
  throw new Error("Invalid push ref");
24023
24376
  await this.git(["push", remote, ref], {
24024
- env: {
24025
- GIT_CONFIG_COUNT: "1",
24026
- GIT_CONFIG_KEY_0: "http.extraHeader",
24027
- GIT_CONFIG_VALUE_0: `Authorization: Bearer ${token}`,
24028
- GIT_TERMINAL_PROMPT: "0"
24029
- }
24377
+ env: gitTransportEnvironment({ remote, headers: { Authorization: `Bearer ${token}` } })
24030
24378
  });
24031
24379
  }
24380
+ async authenticatedTransport(operation, transport, ref) {
24381
+ branchSchema.parse(ref);
24382
+ await this.git([operation, transport.remote, ref], { env: gitTransportEnvironment(transport) });
24383
+ }
24032
24384
  async installBudgetHook(cliPath, tsxPath) {
24033
24385
  const hookPath = resolve(
24034
24386
  this.root,
@@ -24062,8 +24414,9 @@ import { resolve as resolve3 } from "node:path";
24062
24414
 
24063
24415
  // src/cli/credentials.ts
24064
24416
  init_client();
24417
+ init_schemas3();
24065
24418
  import { homedir } from "node:os";
24066
- import { mkdir as mkdir2, readFile as readFile2, rename, writeFile as writeFile2 } from "node:fs/promises";
24419
+ import { mkdir as mkdir2, open as open2, readFile as readFile2, rename, unlink as unlink2, writeFile as writeFile2 } from "node:fs/promises";
24067
24420
  import { resolve as resolve2 } from "node:path";
24068
24421
  function globalConfigDirectory() {
24069
24422
  return process.env.BRANCHORA_CONFIG_DIR ?? resolve2(process.env.XDG_CONFIG_HOME ?? resolve2(homedir(), ".config"), "branchora");
@@ -24071,12 +24424,12 @@ function globalConfigDirectory() {
24071
24424
  function originKey(url2) {
24072
24425
  return new TraceGitClient({ url: url2, apiKey: "" }).url;
24073
24426
  }
24074
- async function store() {
24427
+ async function store(directory = globalConfigDirectory()) {
24075
24428
  try {
24076
24429
  const value = JSON.parse(
24077
- await readFile2(resolve2(globalConfigDirectory(), "credentials.json"), "utf8")
24430
+ await readFile2(resolve2(directory, "credentials.json"), "utf8")
24078
24431
  );
24079
- if (value.version !== 1 || !value.profiles || typeof value.profiles !== "object")
24432
+ if (value.version !== 1 || !value.profiles || typeof value.profiles !== "object" || Array.isArray(value.profiles) || value.activeProfiles !== void 0 && (!value.activeProfiles || typeof value.activeProfiles !== "object" || Array.isArray(value.activeProfiles)))
24080
24433
  throw new Error("Unsupported Branchora credential store. Sign in again.");
24081
24434
  return value;
24082
24435
  } catch (error62) {
@@ -24084,22 +24437,76 @@ async function store() {
24084
24437
  return { version: 1, profiles: {} };
24085
24438
  }
24086
24439
  }
24087
- async function readCredential(url2) {
24088
- const value = (await store()).profiles[originKey(url2)];
24089
- return value && typeof value.token === "string" ? value : null;
24440
+ function profileKey(url2, identity2) {
24441
+ const base = originKey(url2);
24442
+ if (!identity2) return base;
24443
+ idSchema.parse(identity2.agentId);
24444
+ idSchema.parse(identity2.projectId);
24445
+ return `${base}#agent=${encodeURIComponent(identity2.agentId)}&project=${encodeURIComponent(identity2.projectId)}`;
24446
+ }
24447
+ function credentialAt(value, url2, identity2) {
24448
+ const credential = value.profiles[profileKey(url2, identity2)];
24449
+ if (!credential || credential.url !== originKey(url2) || typeof credential.token !== "string" || !credential.token || credential.token.length > 200 || /[\r\n\0]/.test(credential.token) || credential.agentId !== identity2?.agentId || credential.projectId !== identity2?.projectId || credential.token.startsWith("bag_") !== (identity2 !== void 0))
24450
+ return null;
24451
+ return credential;
24452
+ }
24453
+ async function readCredential(url2, identity2) {
24454
+ return credentialAt(await store(), url2, identity2);
24090
24455
  }
24091
- async function saveCredential(url2, token, workspaceId) {
24092
- const key = originKey(url2);
24456
+ async function readInputToken(tokenFile) {
24457
+ const token = tokenFile !== void 0 ? (await readFile2(tokenFile, "utf8")).trim() : process.env.BRANCHORA_API_KEY ?? process.env.TRACEGIT_API_KEY;
24458
+ if (token !== void 0 && (!token || token.length > 200 || /[\r\n\0]/.test(token)))
24459
+ throw new Error("Invalid Branchora credential.");
24460
+ return token;
24461
+ }
24462
+ async function saveCredential(url2, token, workspaceId, identity2, options = {}) {
24463
+ const key = profileKey(url2, identity2);
24093
24464
  if (!token || token.length > 200 || /[\r\n\0]/.test(token))
24094
24465
  throw new Error("Invalid Branchora credential.");
24095
- const value = await store();
24096
- value.profiles[key] = { url: key, token, workspaceId, savedAt: (/* @__PURE__ */ new Date()).toISOString() };
24466
+ if (token.startsWith("bag_") && !identity2)
24467
+ throw new Error("An agent credential must be stored with its assigned project and agent.");
24468
+ if (identity2 && !token.startsWith("bag_"))
24469
+ throw new Error("Store human credentials in the human profile.");
24097
24470
  const directory = globalConfigDirectory();
24098
24471
  await mkdir2(directory, { recursive: true, mode: 448 });
24099
24472
  const target = resolve2(directory, "credentials.json");
24100
24473
  const temporary = `${target}.${crypto.randomUUID()}.tmp`;
24101
- await writeFile2(temporary, JSON.stringify(value, null, 2), { mode: 384, flag: "wx" });
24102
- await rename(temporary, target);
24474
+ const lockPath = `${target}.lock`;
24475
+ const deadline = Date.now() + 5e3;
24476
+ let lock;
24477
+ for (; ; ) {
24478
+ try {
24479
+ lock = await open2(lockPath, "wx", 384);
24480
+ break;
24481
+ } catch (error62) {
24482
+ if (error62.code !== "EEXIST") throw error62;
24483
+ if (Date.now() >= deadline)
24484
+ throw new Error("The Branchora credential store is busy. Retry the login.");
24485
+ await new Promise((resolve7) => setTimeout(resolve7, 50));
24486
+ }
24487
+ }
24488
+ try {
24489
+ const value = await store(directory);
24490
+ value.profiles[key] = {
24491
+ url: originKey(url2),
24492
+ token,
24493
+ workspaceId,
24494
+ ...identity2,
24495
+ savedAt: (/* @__PURE__ */ new Date()).toISOString()
24496
+ };
24497
+ if (options.activate) {
24498
+ value.activeProfiles ??= {};
24499
+ value.activeProfiles[originKey(url2)] = key;
24500
+ }
24501
+ await writeFile2(temporary, JSON.stringify(value, null, 2), { mode: 384, flag: "wx" });
24502
+ await rename(temporary, target);
24503
+ } finally {
24504
+ await lock.close();
24505
+ await unlink2(lockPath);
24506
+ await unlink2(temporary).catch((error62) => {
24507
+ if (error62.code !== "ENOENT") throw error62;
24508
+ });
24509
+ }
24103
24510
  }
24104
24511
 
24105
24512
  // src/cli/config.ts
@@ -24109,6 +24516,7 @@ var projectConfigSchema = external_exports.object({
24109
24516
  projectId: external_exports.string(),
24110
24517
  agentId: external_exports.string(),
24111
24518
  integrationId: external_exports.string(),
24519
+ credentialSource: external_exports.enum(["human", "agent"]).optional(),
24112
24520
  runId: external_exports.string().optional(),
24113
24521
  budgetMode: external_exports.enum(["enforce", "observe"]).default("observe"),
24114
24522
  maxOutputTokens: external_exports.number().int().positive().max(1e7).optional(),
@@ -24126,35 +24534,54 @@ async function projectConfigPath(root) {
24126
24534
  }
24127
24535
  }
24128
24536
  async function loadConfig(root) {
24129
- const config2 = projectConfigSchema.parse(
24130
- JSON.parse(await readFile3(await projectConfigPath(root), "utf8"))
24131
- );
24132
- let apiKey = process.env.BRANCHORA_API_KEY ?? process.env.TRACEGIT_API_KEY ?? (await readCredential(config2.url))?.token;
24133
- if (!apiKey) {
24537
+ let config2 = await readProjectConfig(root);
24538
+ const identity2 = { agentId: config2.agentId, projectId: config2.projectId };
24539
+ let apiKey = await readInputToken();
24540
+ if (!apiKey && config2.credentialSource !== "human")
24541
+ apiKey = (await readCredential(config2.url, identity2))?.token;
24542
+ if (!apiKey && config2.credentialSource !== "agent")
24543
+ apiKey = (await readCredential(config2.url))?.token;
24544
+ let legacyCredential = false;
24545
+ if (!apiKey && config2.credentialSource !== "agent") {
24134
24546
  try {
24135
24547
  const credentials = JSON.parse(
24136
24548
  await readFile3(resolve3(root, ".tracegit", "credentials.json"), "utf8")
24137
24549
  );
24138
- apiKey = credentials.token ?? (config2.url.includes("localhost") || config2.url.includes("127.0.0.1") ? credentials.local?.token : credentials.production?.token);
24139
- if (apiKey) await saveCredential(config2.url, apiKey, config2.workspaceId);
24550
+ apiKey = credentials.token ?? (["localhost", "127.0.0.1", "[::1]"].includes(new URL(config2.url).hostname) ? credentials.local?.token : credentials.production?.token);
24551
+ legacyCredential = !!apiKey;
24140
24552
  } catch (error62) {
24141
24553
  if (error62.code !== "ENOENT") throw error62;
24142
24554
  }
24143
24555
  }
24144
24556
  if (!apiKey) throw new Error("Run branchora login or set BRANCHORA_API_KEY.");
24145
- return { config: config2, client: new TraceGitClient({ url: config2.url, apiKey }) };
24557
+ const client = new TraceGitClient({ url: config2.url, apiKey });
24558
+ if (client.isAgentCredential || config2.credentialSource === "agent") {
24559
+ const session = await client.agentIdentity();
24560
+ if (session.principal.workspaceId !== config2.workspaceId || session.principal.agent.projectId !== config2.projectId || session.principal.agent.agentId !== config2.agentId)
24561
+ throw new Error(
24562
+ "The agent credential does not match this repository connection. Run branchora init with the assigned identity."
24563
+ );
24564
+ config2 = { ...config2, credentialSource: "agent" };
24565
+ }
24566
+ if (legacyCredential)
24567
+ await saveCredential(
24568
+ config2.url,
24569
+ apiKey,
24570
+ config2.workspaceId,
24571
+ config2.credentialSource === "agent" ? identity2 : void 0
24572
+ );
24573
+ return { config: config2, client };
24574
+ }
24575
+ async function readProjectConfig(root) {
24576
+ return projectConfigSchema.parse(
24577
+ JSON.parse(await readFile3(await projectConfigPath(root), "utf8"))
24578
+ );
24146
24579
  }
24147
24580
 
24148
24581
  // src/integrations/opencode.ts
24149
24582
  init_redaction();
24150
24583
  init_crypto();
24151
24584
 
24152
- // src/integrations/opencode-export.ts
24153
- init_crypto();
24154
- import { execFile as execFile2 } from "node:child_process";
24155
- import { promisify as promisify2 } from "node:util";
24156
- import { resolve as resolve5 } from "node:path";
24157
-
24158
24585
  // src/core/types.ts
24159
24586
  var USD_NANOS = 1e9;
24160
24587
 
@@ -24164,6 +24591,13 @@ function usdToNanos(usd) {
24164
24591
  return Math.round(usd * USD_NANOS);
24165
24592
  }
24166
24593
 
24594
+ // src/integrations/opencode-export.ts
24595
+ init_crypto();
24596
+ import { execFile as execFile2 } from "node:child_process";
24597
+ import { promisify as promisify2 } from "node:util";
24598
+ import { resolve as resolve5 } from "node:path";
24599
+ init_agent_identity();
24600
+
24167
24601
  // src/integrations/context-capture.ts
24168
24602
  init_crypto();
24169
24603
  init_schemas3();
@@ -24275,6 +24709,59 @@ function supportedProvider(value) {
24275
24709
  async function openCodeAgentId(config2, info) {
24276
24710
  return `agt_oc_${(await sha256(`${config2.workspaceId}:${config2.projectId}:${info.providerID}:${info.modelID}:${info.agent ?? info.mode ?? "build"}`)).slice(0, 40)}`;
24277
24711
  }
24712
+ function openCodeSessionScope(config2, sessionId, agentId) {
24713
+ return `${config2.workspaceId}:${config2.projectId}:${agentId ? `${agentId}:` : ""}${sessionId}`;
24714
+ }
24715
+ async function openCodeMachineEvents(config2, exported, agentId) {
24716
+ const scope = openCodeSessionScope(config2, exported.info.id, agentId);
24717
+ const runId = `run_oc_${(await sha256(scope)).slice(0, 40)}`;
24718
+ const events = [];
24719
+ for (const message of exported.messages) {
24720
+ const text = message.info.role === "user" ? visibleText(message.parts) : "";
24721
+ if (text) {
24722
+ const created = message.info.time?.created ?? exported.info.time?.created;
24723
+ events.push({
24724
+ id: `evt_oc_${(await sha256(`${scope}:${message.info.id}:prompt`)).slice(0, 40)}`,
24725
+ runId,
24726
+ agentId,
24727
+ kind: "plan",
24728
+ name: "Prompt del usuario",
24729
+ ...created === void 0 ? {} : { timestamp: new Date(created).toISOString() },
24730
+ payload: {
24731
+ prompt: text.slice(0, 1e5),
24732
+ source: "user-message",
24733
+ externalMessageId: message.info.id
24734
+ }
24735
+ });
24736
+ }
24737
+ for (const part of message.parts) {
24738
+ if (part.type !== "tool" || !part.state?.time?.end || !part.tool) continue;
24739
+ const ended = part.state.time.end;
24740
+ events.push({
24741
+ id: `evt_oc_${(await sha256(`${scope}:${part.id ?? part.callID}`)).slice(0, 40)}`,
24742
+ runId,
24743
+ agentId,
24744
+ kind: part.state.status === "error" ? "error" : "tool.end",
24745
+ name: part.tool,
24746
+ timestamp: new Date(ended).toISOString(),
24747
+ durationMs: Math.max(0, ended - (part.state.time.start ?? ended)),
24748
+ payload: {
24749
+ tool: part.tool,
24750
+ status: part.state.status,
24751
+ title: part.state.title,
24752
+ arguments: toolArguments(part.state.input),
24753
+ source: "opencode-tool-metadata",
24754
+ externalPartId: part.id,
24755
+ outputCaptured: false,
24756
+ provider: message.info.providerID,
24757
+ model: message.info.modelID,
24758
+ opencodeAgent: message.info.agent ?? message.info.mode
24759
+ }
24760
+ });
24761
+ }
24762
+ }
24763
+ return events;
24764
+ }
24278
24765
  async function syncOpenCodeExport(client, config2, repo, exported, options = {}) {
24279
24766
  const normalizePath = (path) => {
24280
24767
  const normalized = resolve5(path).replaceAll("\\", "/");
@@ -24282,32 +24769,45 @@ async function syncOpenCodeExport(client, config2, repo, exported, options = {})
24282
24769
  };
24283
24770
  if (normalizePath(exported.info.directory) !== normalizePath(repo.root))
24284
24771
  throw new Error("Session directory does not match the connected repository");
24772
+ const authority = client.isAgentCredential || config2.credentialSource === "agent" ? await client.agentIdentity() : void 0;
24773
+ const machine = authority?.principal.agent;
24774
+ if (machine) {
24775
+ if (machine.projectId !== config2.projectId)
24776
+ throw new Error("The imported project does not match the authenticated agent repository.");
24777
+ if (authority?.principal.workspaceId !== config2.workspaceId)
24778
+ throw new Error("The imported workspace does not match the authenticated agent identity.");
24779
+ if (machine.agentId !== config2.agentId)
24780
+ throw new Error("The imported agent does not match the authenticated identity.");
24781
+ await client.assertExecutionAgent(machine.agentId);
24782
+ }
24285
24783
  const complete = exported.messages.filter(
24286
24784
  (message) => message.info.role === "assistant" && message.info.time?.completed && message.info.tokens && message.info.providerID && message.info.modelID
24287
24785
  );
24288
24786
  if (!complete.length)
24289
24787
  return { sessionId: exported.info.id, imported: 0, duplicates: 0, pending: true };
24290
24788
  const rootMessage = complete[0].info;
24291
- const rootAgentId = await openCodeAgentId(config2, rootMessage);
24789
+ const rootAgentId = machine?.agentId ?? await openCodeAgentId(config2, rootMessage);
24292
24790
  const agentIds = /* @__PURE__ */ new Set();
24293
24791
  for (const { info } of complete) {
24294
- const id = await openCodeAgentId(config2, info);
24792
+ const id = machine?.agentId ?? await openCodeAgentId(config2, info);
24295
24793
  if (agentIds.has(id)) continue;
24296
- await client.createAgent({
24297
- id,
24298
- name: `OpenCode \xB7 ${info.agent ?? info.mode ?? "build"} \xB7 ${info.modelID}`,
24299
- provider: supportedProvider(info.providerID),
24300
- model: info.modelID,
24301
- description: "Agente observado en una sesi\xF3n real de OpenCode.",
24302
- config: {
24303
- originalProviderId: info.providerID,
24304
- telemetry: "opencode-observer",
24305
- budgetEnforced: false
24306
- }
24307
- });
24794
+ if (!machine)
24795
+ await client.createAgent({
24796
+ id,
24797
+ name: `OpenCode \xB7 ${info.agent ?? info.mode ?? "build"} \xB7 ${info.modelID}`,
24798
+ provider: supportedProvider(info.providerID),
24799
+ model: info.modelID,
24800
+ description: "Agente observado en una sesi\xF3n real de OpenCode.",
24801
+ config: {
24802
+ originalProviderId: info.providerID,
24803
+ telemetry: "opencode-observer",
24804
+ budgetEnforced: false
24805
+ }
24806
+ });
24308
24807
  agentIds.add(id);
24309
24808
  }
24310
- const runId = `run_oc_${(await sha256(`${config2.workspaceId}:${config2.projectId}:${exported.info.id}`)).slice(0, 40)}`;
24809
+ const sessionScope = openCodeSessionScope(config2, exported.info.id, machine?.agentId);
24810
+ const runId = `run_oc_${(await sha256(sessionScope)).slice(0, 40)}`;
24311
24811
  const prompt = exported.messages.filter((message) => message.info.role === "user").map((message) => visibleText(message.parts)).filter(Boolean)[0] ?? exported.info.title;
24312
24812
  let existingRun = null;
24313
24813
  try {
@@ -24315,6 +24815,14 @@ async function syncOpenCodeExport(client, config2, repo, exported, options = {})
24315
24815
  } catch (error62) {
24316
24816
  if (!(error62 instanceof Error) || !("status" in error62) || error62.status !== 404) throw error62;
24317
24817
  }
24818
+ if (machine && existingRun) {
24819
+ if (existingRun.run.project_id !== machine.projectId || existingRun.run.root_agent_id !== machine.agentId || existingRun.run.workspace_id !== void 0 && existingRun.run.workspace_id !== config2.workspaceId)
24820
+ throw new Error("The existing OpenCode execution belongs to another project or agent.");
24821
+ if (existingRun.agents && !existingRun.agents.some((agent) => agent.agent_id === machine.agentId))
24822
+ throw new Error("The authenticated agent is not a participant in this OpenCode execution.");
24823
+ if (!matchesAgentBranch(existingRun.run.branch, machine.writeBranches))
24824
+ throw new Error("The OpenCode execution branch is outside the agent write grant.");
24825
+ }
24318
24826
  if (!existingRun)
24319
24827
  await client.createRun({
24320
24828
  id: runId,
@@ -24323,37 +24831,49 @@ async function syncOpenCodeExport(client, config2, repo, exported, options = {})
24323
24831
  title: exported.info.title,
24324
24832
  prompt: prompt.slice(0, 5e5),
24325
24833
  branch: await repo.branch(),
24326
- recordType: "connected",
24834
+ recordType: machine ? config2.recordType ?? "connected" : "connected",
24327
24835
  externalSessionId: exported.info.id,
24328
24836
  tags: ["opencode", "application-reported", "budget-observation"]
24329
24837
  });
24330
- for (const id of agentIds)
24331
- if (id !== rootAgentId)
24332
- await client.request(
24333
- `/runs/${runId}/agents`,
24334
- "POST",
24335
- { agentId: id, parentAgentId: rootAgentId },
24336
- true
24337
- );
24838
+ if (!machine) {
24839
+ for (const id of agentIds)
24840
+ if (id !== rootAgentId)
24841
+ await client.request(
24842
+ `/runs/${runId}/agents`,
24843
+ "POST",
24844
+ { agentId: id, parentAgentId: rootAgentId },
24845
+ true
24846
+ );
24847
+ }
24338
24848
  const existing = /* @__PURE__ */ new Set();
24339
24849
  const existingContext = /* @__PURE__ */ new Map();
24850
+ const controlledPrompts = /* @__PURE__ */ new Set();
24340
24851
  for (let offset = 0; ; offset += 200) {
24341
24852
  const response = await client.raw(
24342
24853
  `/requests?runId=${runId}&source=all&limit=200&offset=${offset}`
24343
24854
  );
24344
24855
  const page = await response.json();
24345
- for (const request of page.data)
24346
- if (request.external_message_id) {
24856
+ for (const request of page.data) {
24857
+ if (machine && request.agent_id === machine.agentId && request.budget_enforced && ["inflight", "unknown", "settled"].includes(request.status ?? "")) {
24858
+ const native = JSON.parse(request.pricing_json ?? "{}").transport?.native;
24859
+ if (native?.sessionId === exported.info.id && typeof native.promptId === "string")
24860
+ controlledPrompts.add(native.promptId);
24861
+ }
24862
+ if (request.external_message_id && (!machine || request.agent_id === machine.agentId)) {
24347
24863
  existing.add(request.external_message_id);
24348
24864
  existingContext.set(request.external_message_id, request);
24349
24865
  }
24866
+ }
24350
24867
  if (!page.pagination.hasMore || !page.data.length) break;
24351
24868
  }
24352
24869
  let imported = 0, duplicates = 0, enriched = 0;
24870
+ const observedMessages = complete.filter(
24871
+ (message) => !controlledPrompts.has(message.info.parentID ?? "")
24872
+ );
24353
24873
  const byMessage = /* @__PURE__ */ new Map();
24354
24874
  const observations = [];
24355
- for (const message of complete) {
24356
- const info = message.info, agentId = await openCodeAgentId(config2, info);
24875
+ for (const message of observedMessages) {
24876
+ const info = message.info, agentId = machine?.agentId ?? await openCodeAgentId(config2, info);
24357
24877
  byMessage.set(info.id, agentId);
24358
24878
  if (existing.has(info.id)) {
24359
24879
  const previous = existingContext.get(info.id);
@@ -24367,12 +24887,12 @@ async function syncOpenCodeExport(client, config2, repo, exported, options = {})
24367
24887
  );
24368
24888
  enriched++;
24369
24889
  if (enriched % 10 === 0)
24370
- options.onProgress?.({ imported, duplicates, total: complete.length, enriched });
24890
+ options.onProgress?.({ imported, duplicates, total: observedMessages.length, enriched });
24371
24891
  }
24372
24892
  duplicates++;
24373
24893
  continue;
24374
24894
  }
24375
- const requestId = `req_oc_${(await sha256(`${config2.workspaceId}:${config2.projectId}:${exported.info.id}:${info.id}`)).slice(0, 40)}`;
24895
+ const requestId = `req_oc_${(await sha256(`${sessionScope}:${info.id}`)).slice(0, 40)}`;
24376
24896
  observations.push({
24377
24897
  requestId,
24378
24898
  runId,
@@ -24396,10 +24916,10 @@ async function syncOpenCodeExport(client, config2, repo, exported, options = {})
24396
24916
  const batch = observations.slice(index, index + 10);
24397
24917
  await client.request("/observations/opencode/batch", "POST", { observations: batch }, true);
24398
24918
  imported += batch.length;
24399
- options.onProgress?.({ imported, duplicates, total: complete.length });
24919
+ options.onProgress?.({ imported, duplicates, total: observedMessages.length });
24400
24920
  }
24401
- const events = [];
24402
- for (const message of exported.messages) {
24921
+ const events = machine ? await openCodeMachineEvents(config2, exported, machine.agentId) : [];
24922
+ for (const message of machine ? [] : exported.messages) {
24403
24923
  const actor = byMessage.get(message.info.id) ?? rootAgentId;
24404
24924
  if (message.info.role === "user") {
24405
24925
  const text = visibleText(message.parts);
@@ -24473,14 +24993,17 @@ async function syncOpenCodeExport(client, config2, repo, exported, options = {})
24473
24993
  }
24474
24994
  }
24475
24995
  let publication = null;
24476
- const project = await client.request(
24477
- `/projects/${config2.projectId}`
24478
- );
24479
- if (project.project.repository_name && (imported || enriched || pendingEvents.length || commitsLinked || !existingRun))
24480
- publication = await client.request(`/runs/${runId}/publish`, "POST", {}, true);
24996
+ if (!machine || machine.capabilities.includes("git:read") && machine.capabilities.includes("git:write")) {
24997
+ const project = await client.request(
24998
+ `/projects/${config2.projectId}`
24999
+ );
25000
+ if (project.project.repository_name && (imported || enriched || pendingEvents.length || commitsLinked || !existingRun))
25001
+ publication = machine ? await client.publishRun(runId) : await client.request(`/runs/${runId}/publish`, "POST", {}, true);
25002
+ }
24481
25003
  await client.request("/integrations/heartbeat", "POST", {
24482
- id: `int_oc_${(await sha256(`${config2.workspaceId}:${config2.projectId}:${repo.root}`)).slice(0, 40)}`,
25004
+ id: `int_oc_${(await sha256(openCodeSessionScope(config2, repo.root, machine?.agentId))).slice(0, 40)}`,
24483
25005
  projectId: config2.projectId,
25006
+ ...machine ? { agentId: machine.agentId } : {},
24484
25007
  name: "OpenCode \xB7 captura real",
24485
25008
  version: "1.1.0",
24486
25009
  dirty: await repo.dirty(),
@@ -24497,6 +25020,7 @@ async function syncOpenCodeExport(client, config2, repo, exported, options = {})
24497
25020
  ...new Set(complete.map((message) => `${message.info.providerID}/${message.info.modelID}`))
24498
25021
  ],
24499
25022
  runId,
25023
+ ...machine ? { agentId: machine.agentId } : {},
24500
25024
  lastImportAt: (/* @__PURE__ */ new Date()).toISOString(),
24501
25025
  completeMessages: complete.length,
24502
25026
  gitVersion: publication?.ledgerCommit
@@ -24505,15 +25029,17 @@ async function syncOpenCodeExport(client, config2, repo, exported, options = {})
24505
25029
  return {
24506
25030
  sessionId: exported.info.id,
24507
25031
  runId,
25032
+ pending: false,
24508
25033
  imported,
24509
25034
  enriched,
24510
25035
  duplicates,
24511
25036
  completeMessages: complete.length,
25037
+ ...machine ? { controlledMessages: complete.length - observedMessages.length } : {},
24512
25038
  publication,
24513
25039
  models: [
24514
25040
  ...new Set(complete.map((message) => `${message.info.providerID}/${message.info.modelID}`))
24515
25041
  ],
24516
- reportedCostNanos: complete.reduce(
25042
+ reportedCostNanos: observedMessages.reduce(
24517
25043
  (sum, message) => sum + (message.info.cost ? usdToNanos(message.info.cost) : 0),
24518
25044
  0
24519
25045
  ),
@@ -24549,12 +25075,7 @@ async function createCheckpoint(repo, client, projectId, runId, name, agentState
24549
25075
  if (project.project.repository_name) {
24550
25076
  const transport = client.gitTransport(projectId);
24551
25077
  await repo.git(["push", transport.remote, snapshot.gitRef], {
24552
- env: {
24553
- GIT_CONFIG_COUNT: "1",
24554
- GIT_CONFIG_KEY_0: "http.extraHeader",
24555
- GIT_CONFIG_VALUE_0: `Authorization: ${transport.headers.Authorization}`,
24556
- GIT_TERMINAL_PROMPT: "0"
24557
- }
25078
+ env: gitTransportEnvironment(transport)
24558
25079
  });
24559
25080
  }
24560
25081
  await client.request(
@@ -24604,11 +25125,27 @@ async function TraceGitPlugin(input2) {
24604
25125
  let connection;
24605
25126
  try {
24606
25127
  connection = await loadConfig(repo.root);
24607
- } catch {
25128
+ } catch (error62) {
25129
+ const settings = await readProjectConfig(repo.root).catch(() => void 0);
25130
+ if (settings?.budgetMode === "enforce") throw explainTraceGitError(error62, settings.url);
24608
25131
  return {};
24609
25132
  }
24610
25133
  if (!input2.client?.session) return {};
24611
25134
  const { client, config: config2 } = connection, host = input2.client.session, enforceBudget = config2.budgetMode === "enforce";
25135
+ const machine = await client.assignedAgent().catch(async (error62) => {
25136
+ await reportError(error62);
25137
+ if (enforceBudget) throw explainTraceGitError(error62, config2.url);
25138
+ return null;
25139
+ });
25140
+ if (machine === null) return {};
25141
+ if (machine && (machine.projectId !== config2.projectId || machine.agentId !== config2.agentId)) {
25142
+ const error62 = new Error(
25143
+ "The authenticated agent does not match the OpenCode repository connection."
25144
+ );
25145
+ await reportError(error62);
25146
+ if (enforceBudget) throw explainTraceGitError(error62, config2.url);
25147
+ return {};
25148
+ }
24612
25149
  const sessionIds = /* @__PURE__ */ new Set(), timers = /* @__PURE__ */ new Map(), inflight = /* @__PURE__ */ new Map();
24613
25150
  let disposed = false;
24614
25151
  const inputBounds = /* @__PURE__ */ new Map(), systemBounds = /* @__PURE__ */ new Map(), checkpoints = /* @__PURE__ */ new Set();
@@ -24623,70 +25160,93 @@ async function TraceGitPlugin(input2) {
24623
25160
  );
24624
25161
  const toolSchemaBytes = /* @__PURE__ */ new Map();
24625
25162
  const latestMessages = /* @__PURE__ */ new Map(), outputBounds = /* @__PURE__ */ new Map();
24626
- async function ensureExecution(inputModel) {
24627
- sessionExecutions.delete(inputModel.sessionID);
24628
- const [session, messages] = await Promise.all([
24629
- host.get({ path: { id: inputModel.sessionID }, query: { directory: repo.root } }),
24630
- host.messages({ path: { id: inputModel.sessionID }, query: { directory: repo.root } })
24631
- ]);
24632
- if (!session.data || !messages.data)
24633
- throw new Error("Cannot initialize execution without session metadata");
24634
- latestMessages.set(inputModel.sessionID, messages.data);
24635
- const modelInfo = {
24636
- providerID: inputModel.model.providerID,
24637
- modelID: inputModel.model.id,
24638
- agent: inputModel.agent
24639
- };
24640
- const agentId = await openCodeAgentId(config2, modelInfo), runId = `run_oc_${(await sha256(`${config2.workspaceId}:${config2.projectId}:${inputModel.sessionID}`)).slice(0, 40)}`;
24641
- const first = messages.data.find(
25163
+ async function sessionRunId(sessionId) {
25164
+ const scope = openCodeSessionScope(config2, sessionId, machine?.agentId);
25165
+ return `run_oc_${(await sha256(scope)).slice(0, 40)}`;
25166
+ }
25167
+ async function modelAgentId(info) {
25168
+ return machine?.agentId ?? await openCodeAgentId(config2, info);
25169
+ }
25170
+ async function ensureSessionRun(session, messages, modelInfo) {
25171
+ if (machine) {
25172
+ const normalized = (path) => {
25173
+ const value = resolve6(path).replaceAll("\\", "/");
25174
+ return process.platform === "win32" ? value.toLowerCase() : value;
25175
+ };
25176
+ if (normalized(session.directory) !== normalized(repo.root))
25177
+ throw new Error("Session directory does not match the connected repository");
25178
+ }
25179
+ const agentId = await modelAgentId(modelInfo), runId = await sessionRunId(session.id);
25180
+ const first = messages.find(
24642
25181
  (message) => message.info.role === "assistant" && message.info.providerID && message.info.modelID
24643
25182
  )?.info;
24644
- const rootInfo = first ?? modelInfo, rootAgentId = await openCodeAgentId(config2, rootInfo);
24645
- const register = async (id, info) => client.createAgent({
24646
- id,
24647
- name: `OpenCode \xB7 ${info.agent ?? info.mode ?? "build"} \xB7 ${info.modelID}`,
24648
- provider: ["amazon-bedrock", "openai", "anthropic", "google", "workers-ai"].includes(
24649
- info.providerID ?? ""
24650
- ) ? info.providerID : "external",
24651
- model: info.modelID,
24652
- description: "Agente observado en una sesi\xF3n real de OpenCode.",
24653
- config: {
24654
- originalProviderId: info.providerID,
24655
- telemetry: "opencode-observer",
24656
- budgetEnforced: false
24657
- }
24658
- });
24659
- await register(rootAgentId, rootInfo);
24660
- await register(agentId, modelInfo);
25183
+ const rootInfo = first ?? modelInfo, rootAgentId = await modelAgentId(rootInfo);
25184
+ if (!machine) {
25185
+ const register = async (id, info) => client.createAgent({
25186
+ id,
25187
+ name: `OpenCode \xB7 ${info.agent ?? info.mode ?? "build"} \xB7 ${info.modelID}`,
25188
+ provider: ["amazon-bedrock", "openai", "anthropic", "google", "workers-ai"].includes(
25189
+ info.providerID ?? ""
25190
+ ) ? info.providerID : "external",
25191
+ model: info.modelID,
25192
+ description: "Agente observado en una sesi\xF3n real de OpenCode.",
25193
+ config: {
25194
+ originalProviderId: info.providerID,
25195
+ telemetry: "opencode-observer",
25196
+ budgetEnforced: false
25197
+ }
25198
+ });
25199
+ await register(rootAgentId, rootInfo);
25200
+ await register(agentId, modelInfo);
25201
+ }
24661
25202
  let exists = false;
24662
25203
  try {
24663
- await client.request(`/runs/${runId}`);
25204
+ const existing = await client.request(`/runs/${runId}`);
25205
+ if (machine && (existing.run.project_id !== machine.projectId || existing.run.root_agent_id !== machine.agentId))
25206
+ throw new Error("The OpenCode execution belongs to another agent identity.");
24664
25207
  exists = true;
24665
25208
  } catch (error62) {
24666
25209
  if (!error62 || typeof error62 !== "object" || !("status" in error62) || error62.status !== 404)
24667
25210
  throw error62;
24668
25211
  }
24669
25212
  if (!exists) {
24670
- const prompt = messages.data.filter((message) => message.info.role === "user").map((message) => visibleText(message.parts)).filter(Boolean)[0] ?? session.data.title;
25213
+ const prompt = messages.filter((message) => message.info.role === "user").map((message) => visibleText(message.parts)).filter(Boolean)[0] ?? session.title;
24671
25214
  await client.createRun({
24672
25215
  id: runId,
24673
25216
  projectId: config2.projectId,
24674
25217
  rootAgentId,
24675
- title: session.data.title,
24676
- prompt,
25218
+ title: session.title,
25219
+ prompt: prompt.slice(0, 5e5),
24677
25220
  branch: await repo.branch(),
24678
- externalSessionId: inputModel.sessionID,
25221
+ externalSessionId: session.id,
24679
25222
  recordType: config2.recordType ?? "connected",
24680
25223
  tags: ["opencode", "application-reported", "budget-observation"]
24681
25224
  });
24682
25225
  }
24683
- if (agentId !== rootAgentId)
25226
+ if (!machine && agentId !== rootAgentId)
24684
25227
  await client.request(
24685
25228
  `/runs/${runId}/agents`,
24686
25229
  "POST",
24687
25230
  { agentId, parentAgentId: rootAgentId },
24688
25231
  true
24689
25232
  );
25233
+ return { runId, agentId, exists };
25234
+ }
25235
+ async function ensureExecution(inputModel) {
25236
+ sessionExecutions.delete(inputModel.sessionID);
25237
+ const [session, messages] = await Promise.all([
25238
+ host.get({ path: { id: inputModel.sessionID }, query: { directory: repo.root } }),
25239
+ host.messages({ path: { id: inputModel.sessionID }, query: { directory: repo.root } })
25240
+ ]);
25241
+ if (!session.data || !messages.data)
25242
+ throw new Error("Cannot initialize execution without session metadata");
25243
+ latestMessages.set(inputModel.sessionID, messages.data);
25244
+ const modelInfo = {
25245
+ providerID: inputModel.model.providerID,
25246
+ modelID: inputModel.model.id,
25247
+ agent: inputModel.agent
25248
+ };
25249
+ const { runId, agentId } = await ensureSessionRun(session.data, messages.data, modelInfo);
24690
25250
  const taskKey = inputModel.message?.id ?? messages.data.findLast((message) => message.info.role === "user")?.info.id ?? inputModel.sessionID;
24691
25251
  sessionExecutions.set(inputModel.sessionID, { runId, agentId, promptId: taskKey });
24692
25252
  const checkpointKey = `${inputModel.sessionID}:${taskKey}`;
@@ -24700,7 +25260,12 @@ async function TraceGitPlugin(input2) {
24700
25260
  config2.projectId,
24701
25261
  runId,
24702
25262
  "Before native model task",
24703
- { sessionId: inputModel.sessionID, agent: inputModel.agent, promptId: taskKey },
25263
+ {
25264
+ sessionId: inputModel.sessionID,
25265
+ agent: inputModel.agent,
25266
+ currentAgentId: agentId,
25267
+ promptId: taskKey
25268
+ },
24704
25269
  { budgetMode: enforceBudget ? "enforce" : "observe", model: inputModel.model.id },
24705
25270
  { id: `cp_native_${(await sha256(`${runId}:${taskKey}`)).slice(0, 36)}`, taskKey }
24706
25271
  );
@@ -24774,10 +25339,11 @@ async function TraceGitPlugin(input2) {
24774
25339
  for (const message of messages.data)
24775
25340
  if (transport.controlsPrompt(id, message.info.parentID) && message.info.parentID)
24776
25341
  controlledPrompts.add(message.info.parentID);
24777
- const runId = `run_oc_${(await sha256(`${config2.workspaceId}:${config2.projectId}:${id}`)).slice(0, 40)}`;
25342
+ const runId = await sessionRunId(id);
24778
25343
  for (let offset = 0; ; offset += 200) {
24779
25344
  const page = await (await client.raw(`/requests?runId=${runId}&source=all&limit=200&offset=${offset}`)).json();
24780
25345
  for (const record5 of page.data) {
25346
+ if (machine && record5.agent_id !== machine.agentId) continue;
24781
25347
  if (!record5.budget_enforced || !["inflight", "unknown", "settled"].includes(record5.status ?? ""))
24782
25348
  continue;
24783
25349
  const native = JSON.parse(record5.pricing_json ?? "{}").transport?.native;
@@ -24790,14 +25356,16 @@ async function TraceGitPlugin(input2) {
24790
25356
  const controlled = enforceBudget ? messages.data.filter(
24791
25357
  (message) => message.info.role === "assistant" && controlledPrompts.has(message.info.parentID ?? "")
24792
25358
  ) : [];
24793
- if (controlled.length) await synchronizeControlledEvidence(id, session.data, messages.data);
25359
+ if (controlled.length && !machine)
25360
+ await synchronizeControlledEvidence(id, session.data, messages.data);
24794
25361
  const controlledIds = new Set(controlled.map((value) => value.info.id));
24795
- const result = await syncOpenCodeExport(client, config2, repo, {
25362
+ const exported = {
24796
25363
  info: session.data,
24797
25364
  // Provider counters/full tariffs are authoritative for these calls. Application costs
24798
25365
  // must not add a second observation or replace them with a UI-mode estimate.
24799
25366
  messages: controlled.length ? messages.data.filter((value) => !controlledIds.has(value.info.id)) : messages.data
24800
- });
25367
+ };
25368
+ const result = machine ? await synchronizeAgentExport(exported, messages.data, controlled.length > 0) : await syncOpenCodeExport(client, config2, repo, exported);
24801
25369
  await mkdir4(resolve6(repo.root, ".tracegit/reports"), { recursive: true });
24802
25370
  await writeFile4(
24803
25371
  resolve6(repo.root, ".tracegit/reports/opencode-plugin.json"),
@@ -24813,16 +25381,113 @@ async function TraceGitPlugin(input2) {
24813
25381
  inflight.delete(id);
24814
25382
  }
24815
25383
  }
25384
+ async function synchronizeAgentExport(exported, allMessages, hasControlledMessages) {
25385
+ if (!machine) throw new Error("Scoped OpenCode observation requires an agent credential.");
25386
+ const complete = exported.messages.filter(
25387
+ (message) => message.info.role === "assistant" && message.info.time?.completed && message.info.tokens && message.info.providerID && message.info.modelID
25388
+ );
25389
+ if (!complete.length && !hasControlledMessages)
25390
+ return { sessionId: exported.info.id, imported: 0, duplicates: 0, pending: true };
25391
+ const modelInfo = complete[0]?.info ?? allMessages.find((message) => message.info.role === "assistant")?.info ?? {};
25392
+ const { runId, agentId, exists } = await ensureSessionRun(
25393
+ exported.info,
25394
+ allMessages,
25395
+ modelInfo
25396
+ );
25397
+ const existing = /* @__PURE__ */ new Map();
25398
+ for (let offset = 0; ; offset += 200) {
25399
+ const page = await (await client.raw(`/requests?runId=${runId}&source=all&limit=200&offset=${offset}`)).json();
25400
+ for (const request of page.data)
25401
+ if (request.external_message_id && request.agent_id === machine.agentId)
25402
+ existing.set(request.external_message_id, request);
25403
+ if (!page.pagination.hasMore || !page.data.length) break;
25404
+ }
25405
+ let imported = 0, duplicates = 0, enriched = 0;
25406
+ const observations = [];
25407
+ const history = { info: exported.info, messages: allMessages };
25408
+ for (const message of complete) {
25409
+ const info = message.info;
25410
+ const previous = existing.get(info.id);
25411
+ if (previous) {
25412
+ if (!previous.context_revision) {
25413
+ const sources = await captureHistoricalContext(history, info, repo.root);
25414
+ await client.request(
25415
+ `/requests/${previous.id}/context`,
25416
+ "POST",
25417
+ { sources, expectedRevision: previous.context_revision ?? 0 },
25418
+ true
25419
+ );
25420
+ enriched++;
25421
+ }
25422
+ duplicates++;
25423
+ continue;
25424
+ }
25425
+ observations.push({
25426
+ requestId: `req_oc_${(await sha256(`${openCodeSessionScope(config2, exported.info.id, machine.agentId)}:${info.id}`)).slice(0, 40)}`,
25427
+ runId,
25428
+ agentId,
25429
+ provider: info.providerID,
25430
+ model: info.modelID,
25431
+ externalSessionId: exported.info.id,
25432
+ externalMessageId: info.id,
25433
+ parentMessageId: info.parentID,
25434
+ createdAt: new Date(info.time.created).toISOString(),
25435
+ completedAt: new Date(info.time.completed).toISOString(),
25436
+ tokens: info.tokens,
25437
+ reportedCostNanos: typeof info.cost === "number" && info.cost >= 0 ? usdToNanos(info.cost) : null,
25438
+ outputSummary: visibleText(message.parts).slice(0, 1e5),
25439
+ finish: info.finish,
25440
+ connectorVersion: "OpenCode 1.x export",
25441
+ contextSources: await captureHistoricalContext(history, info, repo.root)
25442
+ });
25443
+ }
25444
+ for (let index = 0; index < observations.length; index += 10) {
25445
+ const batch = observations.slice(index, index + 10);
25446
+ await client.request("/observations/opencode/batch", "POST", { observations: batch }, true);
25447
+ imported += batch.length;
25448
+ }
25449
+ const evidence = await synchronizeControlledEvidence(
25450
+ exported.info.id,
25451
+ exported.info,
25452
+ allMessages
25453
+ );
25454
+ let publication = null;
25455
+ if (machine.capabilities.includes("git:read") && machine.capabilities.includes("git:write")) {
25456
+ const project = await client.request(
25457
+ `/projects/${config2.projectId}`
25458
+ );
25459
+ if (project.project.repository_name && (imported || enriched || evidence.eventsInserted || evidence.commitsLinked || !exists))
25460
+ publication = await client.publishRun(runId);
25461
+ }
25462
+ return {
25463
+ sessionId: exported.info.id,
25464
+ runId,
25465
+ imported,
25466
+ enriched,
25467
+ duplicates,
25468
+ completeMessages: complete.length,
25469
+ publication,
25470
+ models: [
25471
+ ...new Set(complete.map((message) => `${message.info.providerID}/${message.info.modelID}`))
25472
+ ],
25473
+ reportedCostNanos: complete.reduce(
25474
+ (sum, message) => sum + (message.info.cost ? usdToNanos(message.info.cost) : 0),
25475
+ 0
25476
+ ),
25477
+ reasoningTextCaptured: false
25478
+ };
25479
+ }
24816
25480
  async function synchronizeControlledEvidence(sessionId, session, messages) {
24817
- const runId = `run_oc_${(await sha256(`${config2.workspaceId}:${config2.projectId}:${sessionId}`)).slice(0, 40)}`;
24818
- const events = [];
24819
- for (const message of messages) {
25481
+ const runId = await sessionRunId(sessionId);
25482
+ const eventScope = `${config2.workspaceId}:${sessionId}`;
25483
+ const events = machine ? await openCodeMachineEvents(config2, { info: session, messages }, machine.agentId) : [];
25484
+ for (const message of machine ? [] : messages) {
24820
25485
  const execution = sessionExecutions.get(sessionId);
24821
- const agentId = message.info.role === "assistant" ? await openCodeAgentId(config2, message.info) : execution?.agentId;
25486
+ const agentId = message.info.role === "assistant" ? await modelAgentId(message.info) : execution?.agentId;
24822
25487
  if (!agentId) continue;
24823
25488
  if (message.info.role === "user")
24824
25489
  events.push({
24825
- id: `evt_oc_${(await sha256(`${config2.workspaceId}:${sessionId}:${message.info.id}:prompt`)).slice(0, 40)}`,
25490
+ id: `evt_oc_${(await sha256(`${eventScope}:${message.info.id}:prompt`)).slice(0, 40)}`,
24826
25491
  runId,
24827
25492
  agentId,
24828
25493
  kind: "plan",
@@ -24837,7 +25502,7 @@ async function TraceGitPlugin(input2) {
24837
25502
  for (const part of message.parts)
24838
25503
  if (part.type === "tool" && part.tool && part.state?.time?.end)
24839
25504
  events.push({
24840
- id: `evt_oc_${(await sha256(`${config2.workspaceId}:${sessionId}:${part.id ?? part.callID}`)).slice(0, 40)}`,
25505
+ id: `evt_oc_${(await sha256(`${eventScope}:${part.id ?? part.callID}`)).slice(0, 40)}`,
24841
25506
  runId,
24842
25507
  agentId,
24843
25508
  kind: part.state.status === "error" ? "error" : "tool.end",
@@ -24874,33 +25539,50 @@ async function TraceGitPlugin(input2) {
24874
25539
  "--reverse",
24875
25540
  "--max-count=200"
24876
25541
  ])).split("\n").filter(Boolean);
25542
+ let commitsLinked = 0;
24877
25543
  for (const sha of commits)
24878
- if (!linked.has(sha))
25544
+ if (!linked.has(sha)) {
24879
25545
  await client.request(
24880
25546
  `/runs/${runId}/commits`,
24881
25547
  "POST",
24882
25548
  await repo.commitMetadata(sha),
24883
25549
  true
24884
25550
  );
25551
+ commitsLinked++;
25552
+ }
24885
25553
  await client.request(
24886
25554
  "/integrations/heartbeat",
24887
25555
  "POST",
24888
25556
  {
24889
25557
  id: config2.integrationId,
24890
25558
  projectId: config2.projectId,
24891
- name: "OpenCode \xB7 native serialized transport",
25559
+ name: enforceBudget ? "OpenCode \xB7 native serialized transport" : "OpenCode \xB7 captura real",
25560
+ dirty: await repo.dirty(),
24892
25561
  version: "1.2.0",
24893
25562
  capabilities: {
24894
25563
  usage: true,
24895
25564
  tools: true,
24896
25565
  prompts: true,
24897
- budgetEnforced: true,
24898
- mode: "serialized-native"
25566
+ budgetEnforced: enforceBudget,
25567
+ mode: enforceBudget ? "serialized-native" : "observer"
24899
25568
  },
24900
- metadata: { sessionId, runId }
25569
+ ...machine ? { agentId: machine.agentId } : {},
25570
+ metadata: {
25571
+ sessionId,
25572
+ runId,
25573
+ ...machine ? {
25574
+ agentId: machine.agentId,
25575
+ models: [
25576
+ ...new Set(
25577
+ messages.filter((message) => message.info.role === "assistant").map((message) => `${message.info.providerID}/${message.info.modelID}`)
25578
+ )
25579
+ ]
25580
+ } : {}
25581
+ }
24901
25582
  },
24902
25583
  true
24903
25584
  );
25585
+ return { eventsInserted: pending.length, commitsLinked };
24904
25586
  }
24905
25587
  function schedule(id) {
24906
25588
  if (disposed || !/^ses_[A-Za-z0-9]+$/.test(id)) return;