@oxagen/cli 5.5.1-244 → 5.5.1-251

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 +1 -1
  2. package/oxagen.mjs +1075 -660
  3. package/package.json +1 -1
package/oxagen.mjs CHANGED
@@ -418,26 +418,26 @@ var init_util = __esm({
418
418
  }
419
419
  util2.assertNever = assertNever3;
420
420
  util2.arrayToEnum = (items) => {
421
- const obj2 = {};
421
+ const obj3 = {};
422
422
  for (const item of items) {
423
- obj2[item] = item;
423
+ obj3[item] = item;
424
424
  }
425
- return obj2;
425
+ return obj3;
426
426
  };
427
- util2.getValidEnumValues = (obj2) => {
428
- const validKeys = util2.objectKeys(obj2).filter((k) => typeof obj2[obj2[k]] !== "number");
427
+ util2.getValidEnumValues = (obj3) => {
428
+ const validKeys = util2.objectKeys(obj3).filter((k) => typeof obj3[obj3[k]] !== "number");
429
429
  const filtered = {};
430
430
  for (const k of validKeys) {
431
- filtered[k] = obj2[k];
431
+ filtered[k] = obj3[k];
432
432
  }
433
433
  return util2.objectValues(filtered);
434
434
  };
435
- util2.objectValues = (obj2) => {
436
- return util2.objectKeys(obj2).map(function(e) {
437
- return obj2[e];
435
+ util2.objectValues = (obj3) => {
436
+ return util2.objectKeys(obj3).map(function(e) {
437
+ return obj3[e];
438
438
  });
439
439
  };
440
- util2.objectKeys = typeof Object.keys === "function" ? (obj2) => Object.keys(obj2) : (object3) => {
440
+ util2.objectKeys = typeof Object.keys === "function" ? (obj3) => Object.keys(obj3) : (object3) => {
441
441
  const keys = [];
442
442
  for (const key in object3) {
443
443
  if (Object.prototype.hasOwnProperty.call(object3, key)) {
@@ -563,8 +563,8 @@ var init_ZodError = __esm({
563
563
  "not_multiple_of",
564
564
  "not_finite"
565
565
  ]);
566
- quotelessJson = (obj2) => {
567
- const json3 = JSON.stringify(obj2, null, 2);
566
+ quotelessJson = (obj3) => {
567
+ const json3 = JSON.stringify(obj3, null, 2);
568
568
  return json3.replace(/"([^"]+)":/g, "$1:");
569
569
  };
570
570
  ZodError = class _ZodError extends Error {
@@ -5752,7 +5752,7 @@ function bundleSkillChars(skill) {
5752
5752
  chars += file2.path.length + file2.content.length;
5753
5753
  return chars;
5754
5754
  }
5755
- var protocolTimestampSchema, machineGroupSchema, TACHO_BATCH_SCHEMA, TACHO_BUNDLE_SCHEMA, TACHO_COMMANDS_SCHEMA, TACHO_ENROLLMENT_CLAIMS_SCHEMA, TACHO_ENROLLMENT_CERTIFICATE_DOMAIN, ENROLLMENT_KEY_SET_SCHEMA, ENROLLMENT_KEY_SET_DOMAIN, TACHO_ENFORCEMENT_TIER_ATTR, TACHO_GATEWAY_TIER, TACHO_GATEWAY_SESSION_HEADER, TACHO_GATEWAY_GENESIS_HEADER, TACHO_GATEWAY_HARNESS_HEADER, REFUSAL_META_KEY, DECISION_META_KEY, MCP_STREAMABLE_HTTP_ACCEPT, TACHO_METERING_ATTR, TACHO_METERING_OBSERVED, TACHO_MODEL_SESSION_HEADER, TACHO_CREDENTIAL_BASIS_ATTR, TACHO_CREDENTIAL_GATEWAY_BROKERED, TACHO_CREDENTIAL_HARNESS_HELD, TACHO_CREDENTIAL_BASES, TACHO_RUN_TOKEN_ATTR, BUNDLE_FEATURE_GATEWAY_TOOLS, BUNDLE_FEATURE_MODEL_PRICES, BUNDLE_FEATURE_MODEL_PRICES_LONG_CONTEXT, BUNDLE_FEATURE_MODEL_ALLOWLIST, BUNDLE_FEATURE_INDEPENDENT_MODELS, BUNDLE_FEATURE_HOOK_FAIL_OPEN, BUNDLE_FEATURE_STEERING_MANIFEST, BUNDLE_FEATURE_STEERING_INCOMPLETE, BUNDLE_FEATURE_STEERING_LOAD, BUNDLE_FEATURE_CONTAINMENT, BUNDLE_FEATURE_DAILY_BUDGET, BUNDLE_FEATURE_STEER_NEXT_STEP, BUNDLE_FEATURE_UNBOUND_REPO, BUNDLE_FEATURE_CEDAR, BUNDLE_FEATURE_CEDAR_TOOLBELT, BUNDLE_FEATURE_SKILLS, BUNDLE_FEATURE_CACHE_KEEP_ALIVE, BUNDLE_FEATURE_WORK_ORDERS, BUNDLE_FEATURE_WORK_ORDER_START, BUNDLE_FEATURE_WORK_ORDER_STAFFING, BUNDLE_FEATURE_CREDENTIAL_REAUTH, BUNDLE_FEATURE_MCP_RULE_SETS, BUNDLE_FEATURE_GATEWAY_POLICY, BUNDLE_FEATURE_TENANT_SCOPE, BUNDLE_FEATURE_MEMORY_SCOPE, MEMORY_SCOPE_DIGESTS_MAX, GATEWAY_MIN_TIERS, SENSITIVE_SCREEN_ACTIONS, PROMPT_REDACTION_PATTERNS_MAX, PROMPT_REDACTION_PATTERN_MAX, gatewayPolicySchema, BUNDLE_FEATURE_GATEWAY_HARNESS, TACHO_BUNDLE_FEATURES, bundleFeaturesSchema, hostEnrollmentIdSchema, MEMBER_PUBLIC_ID, tachoPlatformSchema, tachoHarnessSchema, TACHO_HARNESS_LABELS, TACHO_HARNESS_TIERS, WRAPPED_HARNESSES, CONNECTED_HARNESSES, HARNESS_BINARY, MODEL_HARNESS_ROUTES, MODEL_ROUTED_HARNESSES, BROKERABLE_HARNESSES, BROKERABLE_HARNESS_PROVIDER, TACHO_TIER_SUMMARY, CUSTOM_AGENT_NAME_PATTERN, RESERVED_AGENT_NAMES, tachoHostStatusSchema, tachoBundleModeSchema, tachoCommandSchema, tachoCommandStatusSchema, tachoCommandAckStatusSchema, tachoDeliveryModeSchema, denyGenerationSchema, deliveredCommandSchema, deliveredCommandResponseSchema, WORK_ORDER_ID_PATTERN, WORK_ORDER_TOKEN_PATTERN, WORK_ITEM_ID_PATTERN, workOrderCommandPayloadSchema, hostConnectionStateSchema, hostConnectionSchema, HOST_CONNECTION_PATH, hostConnectionRequestSchema, hostConnectionChangeResponseSchema, HOST_WORK_ORDERS_PATH, WORK_ORDER_CLAIM_PATH, CERTIFICATE_RENEW_PATH, ENROLLMENT_KEYS_PATH, WORK_ORDER_REJECT_PATH, HOST_MODEL_CREDENTIALS_PATH, HOST_MODEL_CREDENTIAL_STATE_PATH, VAULT_CREDENTIAL_ID_PATTERN, hostModelCredentialSchema, hostModelCredentialsResponseSchema, hostModelCredentialStateResponseSchema, reauthCommandPayloadSchema, connectWorkspaceCommandPayloadSchema, workspaceConnectionRedeemRequestSchema, workspaceConnectionRedeemResponseSchema, REAUTH_PROOF_DOMAIN, workOrderClaimResponseSchema, workOrderRejectResponseSchema, WORK_CRITERION_CLAIM_PATH, WORK_CRITERION_ID_PATTERN, WORK_HEAD_SHA_PATTERN, WORK_CRITERION_CLAIM_TEXT_MAX, workCriterionClaimResponseSchema, WORK_ORDER_PROGRESS_PATH, WORK_PROGRESS_TEXT_MAX, WORK_PROGRESS_STEP_MAX, workProgressResponseSchema, WORK_ORDER_ENV, WORK_ORDER_TOKEN_ENV, WORK_ORDER_TOKEN_HEADER, WORK_ORDER_ATTR, steeringForceSchema, steeringItemKindSchema, steeringCutReasonSchema, steeringHeldLoadSchema, steeringManifestItemSchema, STEERING_MANIFEST_SCHEMA, steeringManifestSchema, steeringManifestFrameSchema, workOrderSteeringReasonSchema, workOrderSteeringItemSchema, workOrderSteeringManifestSchema, cedarIdSchema, cedarPrincipalSchema, cedarToolSchema, cedarBundleSchema, BUNDLE_SKILLS_MAX, BUNDLE_SKILL_FILES_MAX, BUNDLE_SKILLS_CHARS_MAX, BASE64_PATTERN, bundleSkillFileSchema, bundleSkillSchema, policyBundleSchema, enrollmentClaimsSchema, ed25519SignatureSchema, enrollmentCertificateSchema, enrollmentKeySchema, enrollmentKeySetSchema, tachoEventWireSchema, TACHO_MAX_HELD_SESSIONS, daemonHealthSchema, TACHO_MAX_BATCH, TACHO_MAX_BODY_BYTES, TACHO_MAX_REQUEST_BYTES, TACHO_REQUEST_ENVELOPE_BYTES, SANDBOX_GIT_RELAY_PATH, SANDBOX_GITLAB_RELAY_PATH, SANDBOX_GIT_RELAY_MAX_REQUEST_BYTES, SANDBOX_GIT_RELAY_TIMEOUT_MS, tachoBodySchema, tachoBatchSchema, agentDaySpendSchema, controlEnvelopeSchema, ingestResponseSchema, bundleResponseSchema, commandAcknowledgementSchema, commandsResponseSchema, certificateRenewalResponseSchema, enrollmentKeysResponseSchema, enrollmentResponseSchema, tokenEnrollmentResponseSchema;
5755
+ var protocolTimestampSchema, machineGroupSchema, TACHO_BATCH_SCHEMA, TACHO_BUNDLE_SCHEMA, TACHO_COMMANDS_SCHEMA, TACHO_ENROLLMENT_CLAIMS_SCHEMA, TACHO_ENROLLMENT_CERTIFICATE_DOMAIN, ENROLLMENT_KEY_SET_SCHEMA, ENROLLMENT_KEY_SET_DOMAIN, TACHO_ENFORCEMENT_TIER_ATTR, TACHO_GATEWAY_TIER, TACHO_GATEWAY_SESSION_HEADER, TACHO_GATEWAY_GENESIS_HEADER, TACHO_GATEWAY_HARNESS_HEADER, REFUSAL_META_KEY, DECISION_META_KEY, MCP_STREAMABLE_HTTP_ACCEPT, TACHO_METERING_ATTR, TACHO_METERING_OBSERVED, TACHO_SPAWNED_BY_ATTR, TACHO_MODEL_SESSION_HEADER, TACHO_CREDENTIAL_BASIS_ATTR, TACHO_CREDENTIAL_GATEWAY_BROKERED, TACHO_CREDENTIAL_HARNESS_HELD, TACHO_CREDENTIAL_BASES, TACHO_RUN_TOKEN_ATTR, BUNDLE_FEATURE_GATEWAY_TOOLS, BUNDLE_FEATURE_MODEL_PRICES, BUNDLE_FEATURE_MODEL_PRICES_LONG_CONTEXT, BUNDLE_FEATURE_MODEL_ALLOWLIST, BUNDLE_FEATURE_INDEPENDENT_MODELS, BUNDLE_FEATURE_HOOK_FAIL_OPEN, BUNDLE_FEATURE_STEERING_MANIFEST, BUNDLE_FEATURE_STEERING_INCOMPLETE, BUNDLE_FEATURE_STEERING_LOAD, BUNDLE_FEATURE_CONTAINMENT, BUNDLE_FEATURE_DAILY_BUDGET, BUNDLE_FEATURE_STEER_NEXT_STEP, BUNDLE_FEATURE_UNBOUND_REPO, BUNDLE_FEATURE_CEDAR, BUNDLE_FEATURE_CEDAR_TOOLBELT, BUNDLE_FEATURE_SKILLS, BUNDLE_FEATURE_CACHE_KEEP_ALIVE, BUNDLE_FEATURE_WORK_ORDERS, BUNDLE_FEATURE_WORK_ORDER_START, BUNDLE_FEATURE_WORK_ORDER_STAFFING, BUNDLE_FEATURE_CREDENTIAL_REAUTH, BUNDLE_FEATURE_MCP_RULE_SETS, BUNDLE_FEATURE_GATEWAY_POLICY, BUNDLE_FEATURE_TENANT_SCOPE, BUNDLE_FEATURE_MEMORY_SCOPE, MEMORY_SCOPE_DIGESTS_MAX, GATEWAY_MIN_TIERS, SENSITIVE_SCREEN_ACTIONS, PROMPT_REDACTION_PATTERNS_MAX, PROMPT_REDACTION_PATTERN_MAX, gatewayPolicySchema, BUNDLE_FEATURE_GATEWAY_HARNESS, TACHO_BUNDLE_FEATURES, bundleFeaturesSchema, hostEnrollmentIdSchema, MEMBER_PUBLIC_ID, tachoPlatformSchema, tachoHarnessSchema, TACHO_HARNESS_LABELS, TACHO_HARNESS_TIERS, WRAPPED_HARNESSES, CONNECTED_HARNESSES, HARNESS_BINARY, MODEL_HARNESS_ROUTES, MODEL_ROUTED_HARNESSES, BROKERABLE_HARNESSES, BROKERABLE_HARNESS_PROVIDER, TACHO_TIER_SUMMARY, CUSTOM_AGENT_NAME_PATTERN, RESERVED_AGENT_NAMES, tachoHostStatusSchema, tachoBundleModeSchema, tachoCommandSchema, tachoCommandStatusSchema, tachoCommandAckStatusSchema, tachoDeliveryModeSchema, denyGenerationSchema, deliveredCommandSchema, deliveredCommandResponseSchema, WORK_ORDER_ID_PATTERN, WORK_ORDER_TOKEN_PATTERN, WORK_ITEM_ID_PATTERN, workOrderCommandPayloadSchema, hostConnectionStateSchema, hostConnectionSchema, HOST_CONNECTION_PATH, hostConnectionRequestSchema, hostConnectionChangeResponseSchema, HOST_WORK_ORDERS_PATH, WORK_ORDER_CLAIM_PATH, CERTIFICATE_RENEW_PATH, ENROLLMENT_KEYS_PATH, WORK_ORDER_REJECT_PATH, HOST_MODEL_CREDENTIALS_PATH, HOST_MODEL_CREDENTIAL_STATE_PATH, VAULT_CREDENTIAL_ID_PATTERN, hostModelCredentialSchema, hostModelCredentialsResponseSchema, hostModelCredentialStateResponseSchema, reauthCommandPayloadSchema, connectWorkspaceCommandPayloadSchema, workspaceConnectionRedeemRequestSchema, workspaceConnectionRedeemResponseSchema, REAUTH_PROOF_DOMAIN, workOrderClaimResponseSchema, workOrderRejectResponseSchema, WORK_CRITERION_CLAIM_PATH, WORK_CRITERION_ID_PATTERN, WORK_HEAD_SHA_PATTERN, WORK_CRITERION_CLAIM_TEXT_MAX, workCriterionClaimResponseSchema, WORK_ORDER_PROGRESS_PATH, WORK_PROGRESS_TEXT_MAX, WORK_PROGRESS_STEP_MAX, workProgressResponseSchema, WORK_ORDER_ENV, WORK_ORDER_TOKEN_ENV, WORK_ORDER_TOKEN_HEADER, WORK_ORDER_ATTR, steeringForceSchema, steeringItemKindSchema, steeringCutReasonSchema, steeringHeldLoadSchema, steeringManifestItemSchema, STEERING_MANIFEST_SCHEMA, steeringManifestSchema, steeringManifestFrameSchema, workOrderSteeringReasonSchema, workOrderSteeringItemSchema, workOrderSteeringManifestSchema, cedarIdSchema, cedarPrincipalSchema, cedarToolSchema, cedarBundleSchema, BUNDLE_SKILLS_MAX, BUNDLE_SKILL_FILES_MAX, BUNDLE_SKILLS_CHARS_MAX, BASE64_PATTERN, bundleSkillFileSchema, bundleSkillSchema, policyBundleSchema, enrollmentClaimsSchema, ed25519SignatureSchema, enrollmentCertificateSchema, enrollmentKeySchema, enrollmentKeySetSchema, tachoEventWireSchema, TACHO_MAX_HELD_SESSIONS, daemonHealthSchema, TACHO_MAX_BATCH, TACHO_MAX_BODY_BYTES, TACHO_MAX_REQUEST_BYTES, TACHO_REQUEST_ENVELOPE_BYTES, SANDBOX_GIT_RELAY_PATH, SANDBOX_GITLAB_RELAY_PATH, SANDBOX_GIT_RELAY_MAX_REQUEST_BYTES, SANDBOX_GIT_RELAY_TIMEOUT_MS, tachoBodySchema, tachoBatchSchema, agentDaySpendSchema, controlEnvelopeSchema, ingestResponseSchema, bundleResponseSchema, commandAcknowledgementSchema, commandsResponseSchema, certificateRenewalResponseSchema, enrollmentKeysResponseSchema, enrollmentResponseSchema, tokenEnrollmentResponseSchema;
5756
5756
  var init_wire = __esm({
5757
5757
  "../../packages/tacho/src/wire.ts"() {
5758
5758
  "use strict";
@@ -5786,6 +5786,7 @@ var init_wire = __esm({
5786
5786
  MCP_STREAMABLE_HTTP_ACCEPT = "application/json, text/event-stream";
5787
5787
  TACHO_METERING_ATTR = "oxagen.metering";
5788
5788
  TACHO_METERING_OBSERVED = "observed";
5789
+ TACHO_SPAWNED_BY_ATTR = "oxagen.spawned_by";
5789
5790
  TACHO_MODEL_SESSION_HEADER = "x-oxagen-session";
5790
5791
  TACHO_CREDENTIAL_BASIS_ATTR = "oxagen.credential_basis";
5791
5792
  TACHO_CREDENTIAL_GATEWAY_BROKERED = "gateway_brokered";
@@ -8245,6 +8246,40 @@ var init_redaction = __esm({
8245
8246
  reason: "oxagen_work_order_token",
8246
8247
  pattern: new RegExp(`(?<!${B64URL})oxwo_${B64URL}{43}(?!${B64URL})`, "g")
8247
8248
  },
8249
+ {
8250
+ // `oxe_1time_` and 26 Crockford base32 characters: the single-use token
8251
+ // a machine presents to `enroll_host` to become an agent's host. The
8252
+ // length is exact, as for an API key. It is spendable until a machine
8253
+ // presents it or its 30 minutes run out.
8254
+ reason: "oxagen_enrollment_token",
8255
+ pattern: new RegExp(
8256
+ `(?<!${B64URL})oxe_1time_[0-9a-hjkmnp-tv-z]{26}(?!${B64URL})`,
8257
+ "g"
8258
+ )
8259
+ },
8260
+ {
8261
+ // A Modal token secret where its name says what it is: the
8262
+ // `MODAL_TOKEN_SECRET` variable, `token_secret` in `~/.modal.toml`,
8263
+ // `tokenSecret` in JSON, or the `--token-secret` flag. Only the secret
8264
+ // is removed, so the name beside it stays readable.
8265
+ reason: "modal_token",
8266
+ pattern: new RegExp(
8267
+ `(?:MODAL_TOKEN_SECRET|token[-_]?secret)(?:${JSON_QUOTE}|')?(?:\\s*[:=]\\s*|\\s+)(?:${JSON_QUOTE}|')?(as-${B64URL}{13,256})(?!${B64URL})`,
8268
+ "gi"
8269
+ ),
8270
+ group: 1
8271
+ },
8272
+ {
8273
+ // A Modal token secret with no name beside it: `as-` and 20 or more
8274
+ // letters and digits. Modal issues 22 of them. English writes `as-` too
8275
+ // ("infrastructure-as-a-service-provider"), and its words are joined by
8276
+ // hyphens, so the first 20 characters after the prefix may hold none.
8277
+ reason: "modal_token",
8278
+ pattern: new RegExp(
8279
+ `(?<!${B64URL})as-(?=[A-Za-z0-9]{20})${B64URL}{20,256}`,
8280
+ "g"
8281
+ )
8282
+ },
8248
8283
  {
8249
8284
  // The scheme is case-insensitive (RFC 9110 §11.1), and RFC 6750's
8250
8285
  // b64token includes `_`: without it a token was cut at its first `_`
@@ -14145,8 +14180,8 @@ function __wbg_get_imports() {
14145
14180
  return ret;
14146
14181
  },
14147
14182
  __wbg___wbindgen_string_get_914df97fcfa788f2: function(arg0, arg1) {
14148
- const obj2 = arg1;
14149
- const ret = typeof obj2 === "string" ? obj2 : void 0;
14183
+ const obj3 = arg1;
14184
+ const ret = typeof obj3 === "string" ? obj3 : void 0;
14150
14185
  var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
14151
14186
  var len1 = WASM_VECTOR_LEN;
14152
14187
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
@@ -14182,9 +14217,9 @@ function __wbg_get_imports() {
14182
14217
  "./cedar_wasm_bg.js": import0
14183
14218
  };
14184
14219
  }
14185
- function addToExternrefTable0(obj2) {
14220
+ function addToExternrefTable0(obj3) {
14186
14221
  const idx = wasm.__externref_table_alloc();
14187
- wasm.__wbindgen_externrefs.set(idx, obj2);
14222
+ wasm.__wbindgen_externrefs.set(idx, obj3);
14188
14223
  return idx;
14189
14224
  }
14190
14225
  function getDataViewMemory0() {
@@ -33126,7 +33161,7 @@ import { readFileSync as readFileSync12 } from "node:fs";
33126
33161
  import { dirname as dirname14, resolve as resolve3 } from "node:path";
33127
33162
  import { fileURLToPath } from "node:url";
33128
33163
  function readVersion() {
33129
- if (true) return "5.5.1-244";
33164
+ if (true) return "5.5.1-251";
33130
33165
  try {
33131
33166
  const here = dirname14(fileURLToPath(import.meta.url));
33132
33167
  const pkg = JSON.parse(
@@ -62834,8 +62869,266 @@ var init_context_window = __esm({
62834
62869
  }
62835
62870
  });
62836
62871
 
62837
- // ../../packages/tacho/src/collector/cache-keep-alive.ts
62872
+ // ../../packages/tacho/src/collector/spawn-attribution.ts
62838
62873
  import { createHash as createHash17 } from "node:crypto";
62874
+ function obj(value) {
62875
+ return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
62876
+ }
62877
+ function promptDigest(text6) {
62878
+ return `sha256:${createHash17("sha256").update(text6, "utf8").digest("hex")}`;
62879
+ }
62880
+ function openingDigests(request4) {
62881
+ const messages = request4?.["messages"];
62882
+ if (!Array.isArray(messages)) return [];
62883
+ const first = messages.map(obj).find((message2) => message2?.["role"] === "user");
62884
+ if (first === void 0) return [];
62885
+ const content = first["content"];
62886
+ const texts = [];
62887
+ if (typeof content === "string") texts.push(content);
62888
+ else if (Array.isArray(content)) {
62889
+ for (const block of content) {
62890
+ if (texts.length >= OPENING_BLOCKS_MAX) break;
62891
+ const text6 = obj(block);
62892
+ if (text6?.["type"] === "text" && typeof text6["text"] === "string")
62893
+ texts.push(text6["text"]);
62894
+ }
62895
+ }
62896
+ return [...new Set(texts.filter((text6) => text6 !== "").map(promptDigest))];
62897
+ }
62898
+ function spawnOf(name2, id2, input2) {
62899
+ if (typeof name2 !== "string" || !SPAWN_TOOL_NAMES.has(name2)) return void 0;
62900
+ if (typeof id2 !== "string" || id2 === "") return void 0;
62901
+ const prompt = obj(input2)?.["prompt"];
62902
+ if (typeof prompt !== "string" || prompt === "") return void 0;
62903
+ return { toolUseId: id2, promptDigest: promptDigest(prompt) };
62904
+ }
62905
+ var SPAWN_TOOL_NAMES, OPENING_BLOCKS_MAX, SPAWN_INPUT_BYTES_MAX, SPAWN_LINE_BYTES_MAX, SPAWN_DOCUMENT_BYTES_MAX, SESSION_SPAWNS_MAX, SESSION_OPENINGS_MAX, DATA_PREFIX, BLOCK_START_MARKER, BLOCK_STOP_MARKER, INPUT_DELTA_MARKER, TOOL_USE_MARKER, SpawnObserver, SpawnLedger;
62906
+ var init_spawn_attribution = __esm({
62907
+ "../../packages/tacho/src/collector/spawn-attribution.ts"() {
62908
+ "use strict";
62909
+ SPAWN_TOOL_NAMES = /* @__PURE__ */ new Set(["Agent", "Task"]);
62910
+ OPENING_BLOCKS_MAX = 32;
62911
+ SPAWN_INPUT_BYTES_MAX = 1024 * 1024;
62912
+ SPAWN_LINE_BYTES_MAX = 2 * 1024 * 1024;
62913
+ SPAWN_DOCUMENT_BYTES_MAX = 8 * 1024 * 1024;
62914
+ SESSION_SPAWNS_MAX = 2048;
62915
+ SESSION_OPENINGS_MAX = 8192;
62916
+ DATA_PREFIX = Buffer.from("data:");
62917
+ BLOCK_START_MARKER = Buffer.from('"content_block_start"');
62918
+ BLOCK_STOP_MARKER = Buffer.from('"content_block_stop"');
62919
+ INPUT_DELTA_MARKER = Buffer.from('"input_json_delta"');
62920
+ TOOL_USE_MARKER = Buffer.from('"tool_use"');
62921
+ SpawnObserver = class {
62922
+ onSpawn;
62923
+ streaming;
62924
+ sniffed;
62925
+ line = [];
62926
+ lineBytes = 0;
62927
+ lineOverflow = false;
62928
+ document = [];
62929
+ documentBytes = 0;
62930
+ documentOverflow = false;
62931
+ open = /* @__PURE__ */ new Map();
62932
+ constructor(contentType, onSpawn) {
62933
+ this.onSpawn = onSpawn;
62934
+ this.streaming = (contentType ?? "").includes("text/event-stream");
62935
+ this.sniffed = this.streaming;
62936
+ }
62937
+ write(chunk) {
62938
+ if (!this.sniffed && chunk.length > 0) {
62939
+ this.sniffed = true;
62940
+ const head3 = chunk.subarray(0, 64).toString("latin1").trimStart();
62941
+ if (/^(event|data|id|retry)?:/.test(head3)) this.streaming = true;
62942
+ }
62943
+ if (!this.streaming) {
62944
+ if (this.documentOverflow) return;
62945
+ this.documentBytes += chunk.length;
62946
+ if (this.documentBytes > SPAWN_DOCUMENT_BYTES_MAX) {
62947
+ this.documentOverflow = true;
62948
+ this.document = [];
62949
+ return;
62950
+ }
62951
+ this.document.push(chunk);
62952
+ return;
62953
+ }
62954
+ let start = 0;
62955
+ for (; ; ) {
62956
+ const newline2 = chunk.indexOf(10, start);
62957
+ if (newline2 === -1) {
62958
+ this.holdLine(chunk.subarray(start));
62959
+ return;
62960
+ }
62961
+ this.holdLine(chunk.subarray(start, newline2));
62962
+ this.finishLine();
62963
+ start = newline2 + 1;
62964
+ }
62965
+ }
62966
+ /** Read a response that was not streamed. A stream needs no ending. */
62967
+ end() {
62968
+ if (this.streaming) {
62969
+ if (this.lineBytes > 0) this.finishLine();
62970
+ return;
62971
+ }
62972
+ if (this.documentOverflow || this.documentBytes === 0) return;
62973
+ const bytes = Buffer.concat(this.document);
62974
+ this.document = [];
62975
+ this.documentBytes = 0;
62976
+ if (bytes.indexOf(TOOL_USE_MARKER) === -1) return;
62977
+ let content;
62978
+ try {
62979
+ content = obj(JSON.parse(bytes.toString("utf8")))?.["content"];
62980
+ } catch {
62981
+ return;
62982
+ }
62983
+ if (!Array.isArray(content)) return;
62984
+ for (const entry2 of content) {
62985
+ const block = obj(entry2);
62986
+ if (block?.["type"] !== "tool_use") continue;
62987
+ const spawn10 = spawnOf(block["name"], block["id"], block["input"]);
62988
+ if (spawn10 !== void 0) this.onSpawn(spawn10);
62989
+ }
62990
+ }
62991
+ holdLine(part) {
62992
+ if (part.length === 0 || this.lineOverflow) return;
62993
+ this.lineBytes += part.length;
62994
+ if (this.lineBytes > SPAWN_LINE_BYTES_MAX) {
62995
+ this.lineOverflow = true;
62996
+ this.line = [];
62997
+ return;
62998
+ }
62999
+ this.line.push(part);
63000
+ }
63001
+ finishLine() {
63002
+ const overflow = this.lineOverflow;
63003
+ const line = this.line.length === 1 ? this.line[0] : Buffer.concat(this.line);
63004
+ this.line = [];
63005
+ this.lineBytes = 0;
63006
+ this.lineOverflow = false;
63007
+ if (overflow) {
63008
+ this.open.clear();
63009
+ return;
63010
+ }
63011
+ if (line === void 0 || line.length < 6) return;
63012
+ if (!line.subarray(0, 5).equals(DATA_PREFIX)) return;
63013
+ const opens = line.indexOf(BLOCK_START_MARKER) !== -1 && line.indexOf(TOOL_USE_MARKER) !== -1;
63014
+ const continues = this.open.size > 0 && (line.indexOf(INPUT_DELTA_MARKER) !== -1 || line.indexOf(BLOCK_STOP_MARKER) !== -1);
63015
+ if (!opens && !continues) return;
63016
+ let event;
63017
+ try {
63018
+ event = obj(JSON.parse(line.subarray(5).toString("utf8")));
63019
+ } catch {
63020
+ return;
63021
+ }
63022
+ if (event === void 0) return;
63023
+ const index = event["index"];
63024
+ if (typeof index !== "number") return;
63025
+ const type = event["type"];
63026
+ if (type === "content_block_start") {
63027
+ const block2 = obj(event["content_block"]);
63028
+ if (block2?.["type"] !== "tool_use") return;
63029
+ const name2 = block2["name"];
63030
+ const id2 = block2["id"];
63031
+ if (typeof name2 !== "string" || !SPAWN_TOOL_NAMES.has(name2)) return;
63032
+ if (typeof id2 !== "string" || id2 === "") return;
63033
+ this.open.set(index, {
63034
+ id: id2,
63035
+ name: name2,
63036
+ initial: block2["input"],
63037
+ parts: [],
63038
+ bytes: 0
63039
+ });
63040
+ return;
63041
+ }
63042
+ const block = this.open.get(index);
63043
+ if (block === void 0) return;
63044
+ if (type === "content_block_delta") {
63045
+ const delta = obj(event["delta"]);
63046
+ const part = delta?.["partial_json"];
63047
+ if (delta?.["type"] !== "input_json_delta" || typeof part !== "string")
63048
+ return;
63049
+ block.bytes += Buffer.byteLength(part, "utf8");
63050
+ if (block.bytes > SPAWN_INPUT_BYTES_MAX) {
63051
+ this.open.delete(index);
63052
+ return;
63053
+ }
63054
+ block.parts.push(part);
63055
+ return;
63056
+ }
63057
+ if (type !== "content_block_stop") return;
63058
+ this.open.delete(index);
63059
+ let input2 = block.initial;
63060
+ if (block.parts.length > 0) {
63061
+ try {
63062
+ input2 = JSON.parse(block.parts.join(""));
63063
+ } catch {
63064
+ return;
63065
+ }
63066
+ }
63067
+ const spawn10 = spawnOf(block.name, block.id, input2);
63068
+ if (spawn10 !== void 0) this.onSpawn(spawn10);
63069
+ }
63070
+ };
63071
+ SpawnLedger = class {
63072
+ sessions = /* @__PURE__ */ new Map();
63073
+ of(sessionKey) {
63074
+ let session = this.sessions.get(sessionKey);
63075
+ if (session === void 0) {
63076
+ session = { spawns: /* @__PURE__ */ new Map(), openings: /* @__PURE__ */ new Set(), full: false };
63077
+ this.sessions.set(sessionKey, session);
63078
+ }
63079
+ return session;
63080
+ }
63081
+ /**
63082
+ * Record a spawn the proxy read off a vendor's answer on `sessionKey`.
63083
+ * Ignored when the prompt's text already opened a conversation there, and
63084
+ * when the session is at a memory limit. The first tool call to carry a
63085
+ * prompt keeps it.
63086
+ */
63087
+ noteSpawn(sessionKey, spawn10) {
63088
+ const session = this.of(sessionKey);
63089
+ if (session.full) return;
63090
+ if (session.openings.has(spawn10.promptDigest)) return;
63091
+ if (session.spawns.has(spawn10.promptDigest)) return;
63092
+ if (session.spawns.size >= SESSION_SPAWNS_MAX) {
63093
+ session.full = true;
63094
+ return;
63095
+ }
63096
+ session.spawns.set(spawn10.promptDigest, spawn10.toolUseId);
63097
+ }
63098
+ /**
63099
+ * The tool call that spawned the conversation a request on `sessionKey`
63100
+ * belongs to, by its `openingDigests`, or undefined when the proxy saw no
63101
+ * such spawn. A request with no spawn has its opening hashes remembered,
63102
+ * so no later tool call can claim them.
63103
+ */
63104
+ attribute(sessionKey, openings) {
63105
+ if (openings.length === 0) return void 0;
63106
+ const session = this.of(sessionKey);
63107
+ for (const digest6 of openings) {
63108
+ const toolUseId = session.spawns.get(digest6);
63109
+ if (toolUseId !== void 0) return toolUseId;
63110
+ }
63111
+ for (const digest6 of openings) {
63112
+ if (session.openings.size >= SESSION_OPENINGS_MAX) {
63113
+ session.full = true;
63114
+ break;
63115
+ }
63116
+ session.openings.add(digest6);
63117
+ }
63118
+ return void 0;
63119
+ }
63120
+ /** Drop every session `held` does not name. */
63121
+ keepOnly(held) {
63122
+ for (const sessionKey of this.sessions.keys()) {
63123
+ if (!held.has(sessionKey)) this.sessions.delete(sessionKey);
63124
+ }
63125
+ }
63126
+ };
63127
+ }
63128
+ });
63129
+
63130
+ // ../../packages/tacho/src/collector/cache-keep-alive.ts
63131
+ import { createHash as createHash18 } from "node:crypto";
62839
63132
  function isObject2(value) {
62840
63133
  return typeof value === "object" && value !== null && !Array.isArray(value);
62841
63134
  }
@@ -62872,7 +63165,7 @@ function conversationOf2(request4, model) {
62872
63165
  withoutCacheMarkers(request4["tools"] ?? null),
62873
63166
  withoutCacheMarkers(first ?? null)
62874
63167
  ]);
62875
- return `sha256:${createHash17("sha256").update(text6).digest("hex")}`;
63168
+ return `sha256:${createHash18("sha256").update(text6).digest("hex")}`;
62876
63169
  }
62877
63170
  function ttlOf(usage3, previous) {
62878
63171
  const oneHour = usage3.cacheCreation1hTokens ?? 0;
@@ -63291,7 +63584,7 @@ var init_model_pricing = __esm({
63291
63584
  });
63292
63585
 
63293
63586
  // ../../packages/tacho/src/model-steering.ts
63294
- import { createHash as createHash18 } from "node:crypto";
63587
+ import { createHash as createHash19 } from "node:crypto";
63295
63588
  function withSteeringDelivery(manifest, request4, transformations) {
63296
63589
  return {
63297
63590
  ...manifest,
@@ -63302,7 +63595,7 @@ function withSteeringDelivery(manifest, request4, transformations) {
63302
63595
  };
63303
63596
  }
63304
63597
  function steeringTextHash(text6) {
63305
- return `sha256:${createHash18("sha256").update(text6.trim(), "utf8").digest("hex")}`;
63598
+ return `sha256:${createHash19("sha256").update(text6.trim(), "utf8").digest("hex")}`;
63306
63599
  }
63307
63600
  function* instructionParts2(text6, boundary) {
63308
63601
  let start = 0;
@@ -63653,7 +63946,7 @@ import {
63653
63946
  function hasTokenCounts(usage3) {
63654
63947
  return usage3.inputTokens !== void 0 || usage3.outputTokens !== void 0 || usage3.cacheReadTokens !== void 0 || usage3.cacheCreationTokens !== void 0;
63655
63948
  }
63656
- function obj(value) {
63949
+ function obj2(value) {
63657
63950
  return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
63658
63951
  }
63659
63952
  function count6(value) {
@@ -63674,7 +63967,7 @@ function foldAnthropicUsage(into, usage3) {
63674
63967
  "cacheCreationTokens",
63675
63968
  count6(usage3["cache_creation_input_tokens"])
63676
63969
  );
63677
- const creation = obj(usage3["cache_creation"]);
63970
+ const creation = obj2(usage3["cache_creation"]);
63678
63971
  if (creation !== void 0) {
63679
63972
  assign(
63680
63973
  into,
@@ -63692,8 +63985,8 @@ function foldAnthropicUsage(into, usage3) {
63692
63985
  function foldOpenAiUsage(into, usage3) {
63693
63986
  const input2 = count6(usage3["input_tokens"]) ?? count6(usage3["prompt_tokens"]);
63694
63987
  const output2 = count6(usage3["output_tokens"]) ?? count6(usage3["completion_tokens"]);
63695
- const inputDetails = obj(usage3["input_tokens_details"]) ?? obj(usage3["prompt_tokens_details"]);
63696
- const outputDetails = obj(usage3["output_tokens_details"]) ?? obj(usage3["completion_tokens_details"]);
63988
+ const inputDetails = obj2(usage3["input_tokens_details"]) ?? obj2(usage3["prompt_tokens_details"]);
63989
+ const outputDetails = obj2(usage3["output_tokens_details"]) ?? obj2(usage3["completion_tokens_details"]);
63697
63990
  const cached4 = count6(inputDetails?.["cached_tokens"]);
63698
63991
  if (input2 !== void 0)
63699
63992
  into.inputTokens = Math.max(0, input2 - (cached4 ?? 0));
@@ -63705,34 +63998,34 @@ function errorKind(value) {
63705
63998
  return typeof value === "string" && value.length > 0 ? value.replace(/[^A-Za-z0-9_.-]/g, "_").slice(0, 64) : void 0;
63706
63999
  }
63707
64000
  function foldUsageDocument(into, api, doc) {
63708
- const root = obj(doc);
64001
+ const root = obj2(doc);
63709
64002
  if (root === void 0) return false;
63710
64003
  if (api === "anthropic.messages") {
63711
64004
  const type = root["type"];
63712
64005
  if (type === "error") {
63713
- into.streamError = errorKind(obj(root["error"])?.["type"]) ?? "error";
64006
+ into.streamError = errorKind(obj2(root["error"])?.["type"]) ?? "error";
63714
64007
  return true;
63715
64008
  }
63716
64009
  if (type === "message_start") {
63717
- const message2 = obj(root["message"]);
64010
+ const message2 = obj2(root["message"]);
63718
64011
  if (message2 === void 0) return false;
63719
64012
  assign(into, "model", text3(message2["model"]));
63720
64013
  assign(into, "responseId", text3(message2["id"]));
63721
- const usage3 = obj(message2["usage"]);
64014
+ const usage3 = obj2(message2["usage"]);
63722
64015
  if (usage3 !== void 0) foldAnthropicUsage(into, usage3);
63723
64016
  return false;
63724
64017
  }
63725
64018
  if (type === "message_delta") {
63726
- const usage3 = obj(root["usage"]);
64019
+ const usage3 = obj2(root["usage"]);
63727
64020
  if (usage3 !== void 0) foldAnthropicUsage(into, usage3);
63728
- assign(into, "stopReason", text3(obj(root["delta"])?.["stop_reason"]));
64021
+ assign(into, "stopReason", text3(obj2(root["delta"])?.["stop_reason"]));
63729
64022
  return true;
63730
64023
  }
63731
64024
  if (type === "message" || type === void 0) {
63732
64025
  assign(into, "model", text3(root["model"]));
63733
64026
  assign(into, "responseId", text3(root["id"]));
63734
64027
  assign(into, "stopReason", text3(root["stop_reason"]));
63735
- const usage3 = obj(root["usage"]);
64028
+ const usage3 = obj2(root["usage"]);
63736
64029
  if (usage3 !== void 0) foldAnthropicUsage(into, usage3);
63737
64030
  return true;
63738
64031
  }
@@ -63741,23 +64034,23 @@ function foldUsageDocument(into, api, doc) {
63741
64034
  if (api === "openai.responses") {
63742
64035
  const type = root["type"];
63743
64036
  if (type === "error") {
63744
- const error2 = obj(root["error"]);
64037
+ const error2 = obj2(root["error"]);
63745
64038
  into.streamError = errorKind(root["code"]) ?? errorKind(error2?.["code"]) ?? errorKind(error2?.["type"]) ?? "error";
63746
64039
  return true;
63747
64040
  }
63748
- const response = obj(root["response"]) ?? root;
64041
+ const response = obj2(root["response"]) ?? root;
63749
64042
  assign(into, "model", text3(response["model"]));
63750
64043
  assign(into, "responseId", text3(response["id"]));
63751
64044
  assign(into, "stopReason", text3(response["status"]));
63752
64045
  assign(into, "serviceTier", text3(response["service_tier"]));
63753
64046
  if (type === "response.failed")
63754
- into.streamError = errorKind(obj(response["error"])?.["code"]) ?? "response_failed";
63755
- const usage3 = obj(response["usage"]);
64047
+ into.streamError = errorKind(obj2(response["error"])?.["code"]) ?? "response_failed";
64048
+ const usage3 = obj2(response["usage"]);
63756
64049
  if (usage3 !== void 0) foldOpenAiUsage(into, usage3);
63757
64050
  return typeof type === "string" ? RESPONSES_ENDINGS.has(type) : usage3 !== void 0;
63758
64051
  }
63759
64052
  if (api === "openai.chat") {
63760
- const usage3 = obj(root["usage"]);
64053
+ const usage3 = obj2(root["usage"]);
63761
64054
  if (usage3 === void 0) return false;
63762
64055
  foldOpenAiUsage(into, usage3);
63763
64056
  assign(into, "model", text3(root["model"]));
@@ -63793,7 +64086,7 @@ function decoderFor(encoding) {
63793
64086
  if (name2 === "zstd") return createZstdDecompress();
63794
64087
  return void 0;
63795
64088
  }
63796
- var RESPONSES_ENDINGS, MAX_LINE_BYTES2, MAX_DOCUMENT_BYTES, USAGE_MARKER, ERROR_MARKERS, DATA_PREFIX, DONE_MARKER, DELTA_MARKERS, BYTES_PER_TOKEN, UsageMeter;
64089
+ var RESPONSES_ENDINGS, MAX_LINE_BYTES2, MAX_DOCUMENT_BYTES, USAGE_MARKER, ERROR_MARKERS, DATA_PREFIX2, DONE_MARKER, DELTA_MARKERS, BYTES_PER_TOKEN, UsageMeter;
63797
64090
  var init_model_usage = __esm({
63798
64091
  "../../packages/tacho/src/collector/model-usage.ts"() {
63799
64092
  "use strict";
@@ -63809,7 +64102,7 @@ var init_model_usage = __esm({
63809
64102
  Buffer.from('"type":"error"'),
63810
64103
  Buffer.from('"response.failed"')
63811
64104
  ];
63812
- DATA_PREFIX = Buffer.from("data:");
64105
+ DATA_PREFIX2 = Buffer.from("data:");
63813
64106
  DONE_MARKER = Buffer.from("[DONE]");
63814
64107
  DELTA_MARKERS = {
63815
64108
  "anthropic.messages": ['"text":"', '"partial_json":"', '"thinking":"'].map(
@@ -63911,7 +64204,7 @@ var init_model_usage = __esm({
63911
64204
  this.lineOverflow = false;
63912
64205
  if (overflow || line === void 0) return;
63913
64206
  if (line.length < 6 || line[0] !== 100) return;
63914
- if (!line.subarray(0, 5).equals(DATA_PREFIX)) return;
64207
+ if (!line.subarray(0, 5).equals(DATA_PREFIX2)) return;
63915
64208
  for (const marker of DELTA_MARKERS[this.api]) {
63916
64209
  const at2 = line.indexOf(marker);
63917
64210
  if (at2 !== -1) this.deltaBytes += stringBytes(line, at2 + marker.length);
@@ -63959,7 +64252,7 @@ var init_model_usage = __esm({
63959
64252
  });
63960
64253
 
63961
64254
  // ../../packages/tacho/src/collector/model-proxy.ts
63962
- import { createHash as createHash19 } from "node:crypto";
64255
+ import { createHash as createHash20 } from "node:crypto";
63963
64256
  import {
63964
64257
  request as httpRequest2,
63965
64258
  Agent as HttpAgent
@@ -64250,6 +64543,7 @@ function createModelProxy(deps) {
64250
64543
  });
64251
64544
  const observed = /* @__PURE__ */ new Map();
64252
64545
  const priors = new RequestPrefixMemory();
64546
+ const spawns = new SpawnLedger();
64253
64547
  let callsObserved = 0;
64254
64548
  let refused3 = 0;
64255
64549
  const handoffs = /* @__PURE__ */ new WeakMap();
@@ -64293,6 +64587,7 @@ function createModelProxy(deps) {
64293
64587
  map2.delete(sessionUuid2);
64294
64588
  }
64295
64589
  }
64590
+ spawns.keepOnly(held2);
64296
64591
  }
64297
64592
  function spendFor(sessionUuid2) {
64298
64593
  let value = spent.get(sessionUuid2);
@@ -64955,7 +65250,7 @@ function createModelProxy(deps) {
64955
65250
  const status2 = response.statusCode ?? 502;
64956
65251
  const firstByteAt = deps.now();
64957
65252
  const chunks = [];
64958
- const hash5 = createHash19("sha256");
65253
+ const hash5 = createHash20("sha256");
64959
65254
  let bytes = 0;
64960
65255
  let over = false;
64961
65256
  response.on("data", (chunk) => {
@@ -65541,6 +65836,7 @@ function createModelProxy(deps) {
65541
65836
  return void 0;
65542
65837
  return keepAliveCandidateOf(request4, conversation);
65543
65838
  })();
65839
+ const spawnedBy = metered && route.api === "anthropic.messages" && record2 !== void 0 ? spawns.attribute(sessionKey, openingDigests(json3())) : void 0;
65544
65840
  decoded = void 0;
65545
65841
  parsed2 = void 0;
65546
65842
  const target = upstreamUrlFor(
@@ -65564,9 +65860,21 @@ function createModelProxy(deps) {
65564
65860
  let requestId;
65565
65861
  let responseType;
65566
65862
  let responseBytes = 0;
65567
- const responseHash = createHash19("sha256");
65863
+ const responseHash = createHash20("sha256");
65568
65864
  const responseBody = new BodyCapture();
65569
65865
  let meter;
65866
+ let spawnObserver;
65867
+ const observeSpawns = (step) => {
65868
+ if (spawnObserver === void 0) return;
65869
+ try {
65870
+ step(spawnObserver);
65871
+ } catch (error2) {
65872
+ spawnObserver = void 0;
65873
+ deps.log(
65874
+ `model proxy: reading subagent spawns off the answer failed: ${error2 instanceof Error ? error2.message : String(error2)} session=${sessionKey}`
65875
+ );
65876
+ }
65877
+ };
65570
65878
  let settledUsage;
65571
65879
  let currentAttach = credential.attach;
65572
65880
  let currentMember = credential.member;
@@ -65592,6 +65900,7 @@ function createModelProxy(deps) {
65592
65900
  attempt.done = true;
65593
65901
  set2.delete(entry2);
65594
65902
  if (set2.size === 0) inFlight.delete(sessionKey);
65903
+ observeSpawns((observer) => observer.end());
65595
65904
  let metering;
65596
65905
  try {
65597
65906
  metering = meterCall(errorClass2);
@@ -65779,6 +66088,7 @@ function createModelProxy(deps) {
65779
66088
  } : {},
65780
66089
  ...sessionSighting?.attrs,
65781
66090
  [TACHO_METERING_ATTR]: TACHO_METERING_OBSERVED,
66091
+ ...spawnedBy !== void 0 ? { [TACHO_SPAWNED_BY_ATTR]: spawnedBy } : {},
65782
66092
  "oxagen.request_digest": requestDigest,
65783
66093
  "oxagen.request_bytes": String(requestBytes),
65784
66094
  ...requestWindow !== null ? { [CONTEXT_WINDOW_ATTR]: encodeWindowAttr(requestWindow) } : {},
@@ -65847,6 +66157,10 @@ function createModelProxy(deps) {
65847
66157
  metered && status2 < 400 ? route.api : "other",
65848
66158
  typeof contentType === "string" ? contentType : void 0
65849
66159
  );
66160
+ spawnObserver = metered && status2 < 400 && route.api === "anthropic.messages" && record2 !== void 0 ? new SpawnObserver(
66161
+ typeof contentType === "string" ? contentType : void 0,
66162
+ (spawn10) => spawns.noteSpawn(sessionKey, spawn10)
66163
+ ) : void 0;
65850
66164
  const contentEncoding = upstream.headers["content-encoding"];
65851
66165
  const decoder4 = decoderFor(
65852
66166
  typeof contentEncoding === "string" ? contentEncoding : void 0
@@ -65855,6 +66169,7 @@ function createModelProxy(deps) {
65855
66169
  decoder4?.on("data", (chunk) => {
65856
66170
  if (settled2) return;
65857
66171
  meter?.write(chunk);
66172
+ observeSpawns((observer) => observer.write(chunk));
65858
66173
  responseBody.write(chunk);
65859
66174
  });
65860
66175
  decoder4?.on("error", () => {
@@ -65884,6 +66199,7 @@ function createModelProxy(deps) {
65884
66199
  if (decoder4 !== void 0) decoder4.write(chunk);
65885
66200
  else if (!compressed) {
65886
66201
  meter?.write(chunk);
66202
+ observeSpawns((observer) => observer.write(chunk));
65887
66203
  responseBody.write(chunk);
65888
66204
  }
65889
66205
  });
@@ -66309,6 +66625,7 @@ var init_model_proxy = __esm({
66309
66625
  init_model_failure();
66310
66626
  init_run_token();
66311
66627
  init_wire();
66628
+ init_spawn_attribution();
66312
66629
  init_cache_keep_alive();
66313
66630
  init_loopback_guard();
66314
66631
  init_day_spend();
@@ -80552,7 +80869,7 @@ var init_package = __esm({
80552
80869
  "package.json"() {
80553
80870
  package_default = {
80554
80871
  name: "@oxagen/cli",
80555
- version: "5.5.1-244",
80872
+ version: "5.5.1-251",
80556
80873
  description: "Oxagen governance CLI: spend, source tracking, grounding, credentials, and audit (agentic coding lives in the stella CLI)",
80557
80874
  type: "module",
80558
80875
  main: "./dist/index.js",
@@ -83366,9 +83683,9 @@ var init_status2 = __esm({
83366
83683
  });
83367
83684
 
83368
83685
  // ../../packages/codegraph/src/hash.ts
83369
- import { createHash as createHash20 } from "node:crypto";
83686
+ import { createHash as createHash21 } from "node:crypto";
83370
83687
  function sha256Hex2(input2) {
83371
- return createHash20("sha256").update(input2).digest("hex");
83688
+ return createHash21("sha256").update(input2).digest("hex");
83372
83689
  }
83373
83690
  var init_hash = __esm({
83374
83691
  "../../packages/codegraph/src/hash.ts"() {
@@ -86051,7 +86368,7 @@ var require_anchors = __commonJS({
86051
86368
  var require_applyReviver = __commonJS({
86052
86369
  "../../node_modules/.pnpm/yaml@2.9.1/node_modules/yaml/dist/doc/applyReviver.js"(exports) {
86053
86370
  "use strict";
86054
- function applyReviver(reviver, obj2, key, val) {
86371
+ function applyReviver(reviver, obj3, key, val) {
86055
86372
  if (val && typeof val === "object") {
86056
86373
  if (Array.isArray(val)) {
86057
86374
  for (let i2 = 0, len = val.length; i2 < len; ++i2) {
@@ -86091,7 +86408,7 @@ var require_applyReviver = __commonJS({
86091
86408
  }
86092
86409
  }
86093
86410
  }
86094
- return reviver.call(obj2, key, val);
86411
+ return reviver.call(obj3, key, val);
86095
86412
  }
86096
86413
  exports.applyReviver = applyReviver;
86097
86414
  }
@@ -87027,10 +87344,10 @@ var require_stringify = __commonJS({
87027
87344
  return match.find((t) => t.format === item.format) ?? match[0];
87028
87345
  }
87029
87346
  let tagObj = void 0;
87030
- let obj2;
87347
+ let obj3;
87031
87348
  if (identity.isScalar(item)) {
87032
- obj2 = item.value;
87033
- let match = tags.filter((t) => t.identify?.(obj2));
87349
+ obj3 = item.value;
87350
+ let match = tags.filter((t) => t.identify?.(obj3));
87034
87351
  if (match.length > 1) {
87035
87352
  const testMatch = match.filter((t) => t.test);
87036
87353
  if (testMatch.length > 0)
@@ -87038,11 +87355,11 @@ var require_stringify = __commonJS({
87038
87355
  }
87039
87356
  tagObj = match.find((t) => t.format === item.format) ?? match.find((t) => !t.format);
87040
87357
  } else {
87041
- obj2 = item;
87042
- tagObj = tags.find((t) => t.nodeClass && obj2 instanceof t.nodeClass);
87358
+ obj3 = item;
87359
+ tagObj = tags.find((t) => t.nodeClass && obj3 instanceof t.nodeClass);
87043
87360
  }
87044
87361
  if (!tagObj) {
87045
- const name2 = obj2?.constructor?.name ?? (obj2 === null ? "null" : typeof obj2);
87362
+ const name2 = obj3?.constructor?.name ?? (obj3 === null ? "null" : typeof obj3);
87046
87363
  throw new Error(`Tag not resolved for ${name2} value`);
87047
87364
  }
87048
87365
  return tagObj;
@@ -87598,23 +87915,23 @@ var require_YAMLMap = __commonJS({
87598
87915
  * A generic collection parsing method that can be extended
87599
87916
  * to other node classes that inherit from YAMLMap
87600
87917
  */
87601
- static from(schema, obj2, ctx2) {
87918
+ static from(schema, obj3, ctx2) {
87602
87919
  const { keepUndefined, replacer } = ctx2;
87603
87920
  const map2 = new this(schema);
87604
87921
  const add2 = (key, value) => {
87605
87922
  if (typeof replacer === "function")
87606
- value = replacer.call(obj2, key, value);
87923
+ value = replacer.call(obj3, key, value);
87607
87924
  else if (Array.isArray(replacer) && !replacer.includes(key))
87608
87925
  return;
87609
87926
  if (value !== void 0 || keepUndefined)
87610
87927
  map2.items.push(Pair.createPair(key, value, ctx2));
87611
87928
  };
87612
- if (obj2 instanceof Map) {
87613
- for (const [key, value] of obj2)
87929
+ if (obj3 instanceof Map) {
87930
+ for (const [key, value] of obj3)
87614
87931
  add2(key, value);
87615
- } else if (obj2 && typeof obj2 === "object") {
87616
- for (const key of Object.keys(obj2))
87617
- add2(key, obj2[key]);
87932
+ } else if (obj3 && typeof obj3 === "object") {
87933
+ for (const key of Object.keys(obj3))
87934
+ add2(key, obj3[key]);
87618
87935
  }
87619
87936
  if (typeof schema.sortMapEntries === "function") {
87620
87937
  map2.items.sort(schema.sortMapEntries);
@@ -87724,7 +88041,7 @@ var require_map = __commonJS({
87724
88041
  onError("Expected a mapping for this tag");
87725
88042
  return map3;
87726
88043
  },
87727
- createNode: (schema, obj2, ctx2) => YAMLMap.YAMLMap.from(schema, obj2, ctx2)
88044
+ createNode: (schema, obj3, ctx2) => YAMLMap.YAMLMap.from(schema, obj3, ctx2)
87728
88045
  };
87729
88046
  exports.map = map2;
87730
88047
  }
@@ -87820,15 +88137,15 @@ var require_YAMLSeq = __commonJS({
87820
88137
  onComment
87821
88138
  });
87822
88139
  }
87823
- static from(schema, obj2, ctx2) {
88140
+ static from(schema, obj3, ctx2) {
87824
88141
  const { replacer } = ctx2;
87825
88142
  const seq2 = new this(schema);
87826
- if (obj2 && Symbol.iterator in Object(obj2)) {
88143
+ if (obj3 && Symbol.iterator in Object(obj3)) {
87827
88144
  let i2 = 0;
87828
- for (let it of obj2) {
88145
+ for (let it of obj3) {
87829
88146
  if (typeof replacer === "function") {
87830
- const key = obj2 instanceof Set ? it : String(i2++);
87831
- it = replacer.call(obj2, key, it);
88147
+ const key = obj3 instanceof Set ? it : String(i2++);
88148
+ it = replacer.call(obj3, key, it);
87832
88149
  }
87833
88150
  seq2.items.push(createNode.createNode(it, void 0, ctx2));
87834
88151
  }
@@ -87862,7 +88179,7 @@ var require_seq = __commonJS({
87862
88179
  onError("Expected a sequence for this tag");
87863
88180
  return seq3;
87864
88181
  },
87865
- createNode: (schema, obj2, ctx2) => YAMLSeq.YAMLSeq.from(schema, obj2, ctx2)
88182
+ createNode: (schema, obj3, ctx2) => YAMLSeq.YAMLSeq.from(schema, obj3, ctx2)
87866
88183
  };
87867
88184
  exports.seq = seq2;
87868
88185
  }
@@ -93969,6 +94286,190 @@ var init_codegraph_catalogue = __esm({
93969
94286
  }
93970
94287
  });
93971
94288
 
94289
+ // ../../packages/oxagen/src/secret-fields.ts
94290
+ function defOf(schema) {
94291
+ if (typeof schema !== "object" || schema === null) return null;
94292
+ const def = schema._def;
94293
+ return typeof def === "object" && def !== null ? def : null;
94294
+ }
94295
+ function secretField(schema) {
94296
+ const def = defOf(schema);
94297
+ if (def === null) {
94298
+ throw new TypeError("secretField() marks a zod schema, and got none");
94299
+ }
94300
+ const Schema = schema.constructor;
94301
+ return new Schema({ ...def, [SECRET_MARK]: true });
94302
+ }
94303
+ function callDefFunction(value) {
94304
+ if (typeof value !== "function") return void 0;
94305
+ return value();
94306
+ }
94307
+ function isMarked(def) {
94308
+ return def[SECRET_MARK] === true;
94309
+ }
94310
+ function isRecord8(value) {
94311
+ return typeof value === "object" && value !== null && !Array.isArray(value);
94312
+ }
94313
+ function childrenOf(def) {
94314
+ const same = (schema) => ({ step: SAME, schema });
94315
+ switch (def["typeName"]) {
94316
+ case "ZodObject": {
94317
+ const shape = callDefFunction(def["shape"]);
94318
+ const children = isRecord8(shape) ? Object.entries(shape).map(
94319
+ ([key, schema]) => ({ step: { kind: "key", key }, schema })
94320
+ ) : [];
94321
+ const named2 = new Set(isRecord8(shape) ? Object.keys(shape) : []);
94322
+ children.push({
94323
+ step: { kind: "entry", skip: named2 },
94324
+ schema: def["catchall"]
94325
+ });
94326
+ return children;
94327
+ }
94328
+ case "ZodOptional":
94329
+ case "ZodNullable":
94330
+ case "ZodDefault":
94331
+ case "ZodCatch":
94332
+ case "ZodReadonly":
94333
+ return [same(def["innerType"])];
94334
+ case "ZodEffects":
94335
+ return [same(def["schema"])];
94336
+ case "ZodBranded":
94337
+ case "ZodPromise":
94338
+ return [same(def["type"])];
94339
+ case "ZodPipeline":
94340
+ return [same(def["in"]), same(def["out"])];
94341
+ case "ZodLazy":
94342
+ return [same(callDefFunction(def["getter"]))];
94343
+ case "ZodUnion":
94344
+ case "ZodDiscriminatedUnion": {
94345
+ const options = def["options"];
94346
+ return Array.isArray(options) ? options.map((option) => same(option)) : [];
94347
+ }
94348
+ case "ZodIntersection":
94349
+ return [same(def["left"]), same(def["right"])];
94350
+ case "ZodArray":
94351
+ return [{ step: ELEMENT, schema: def["type"] }];
94352
+ case "ZodSet":
94353
+ return [{ step: ELEMENT, schema: def["valueType"] }];
94354
+ case "ZodTuple": {
94355
+ const items = def["items"];
94356
+ const children = Array.isArray(items) ? items.map(
94357
+ (schema, index) => ({
94358
+ step: { kind: "index", index },
94359
+ schema
94360
+ })
94361
+ ) : [];
94362
+ children.push({ step: ELEMENT, schema: def["rest"] });
94363
+ return children;
94364
+ }
94365
+ case "ZodRecord":
94366
+ case "ZodMap":
94367
+ return [{ step: { kind: "entry" }, schema: def["valueType"] }];
94368
+ default:
94369
+ return [];
94370
+ }
94371
+ }
94372
+ function pathStep(path2, step) {
94373
+ switch (step.kind) {
94374
+ case "same":
94375
+ return path2;
94376
+ case "key":
94377
+ return path2 === "" ? step.key : `${path2}.${step.key}`;
94378
+ case "index":
94379
+ return `${path2}[${step.index}]`;
94380
+ case "element":
94381
+ return `${path2}[]`;
94382
+ case "entry":
94383
+ return path2 === "" ? "*" : `${path2}.*`;
94384
+ }
94385
+ }
94386
+ function walkSchema(schema, enter) {
94387
+ const open8 = /* @__PURE__ */ new Set();
94388
+ const walk2 = (node3, path2, step) => {
94389
+ const def = defOf(node3);
94390
+ if (def === null || open8.has(node3)) return;
94391
+ if (open8.size >= MAX_DEPTH) {
94392
+ throw new Error(
94393
+ `A schema nests deeper than ${MAX_DEPTH} levels at "${path2}", so its secret fields cannot be read`
94394
+ );
94395
+ }
94396
+ if (!enter(def, path2, step)) return;
94397
+ open8.add(node3);
94398
+ for (const child of childrenOf(def)) {
94399
+ walk2(child.schema, pathStep(path2, child.step), child.step);
94400
+ }
94401
+ open8.delete(node3);
94402
+ };
94403
+ walk2(schema, "", null);
94404
+ }
94405
+ function secretFieldPaths(schema) {
94406
+ const found = /* @__PURE__ */ new Set();
94407
+ walkSchema(schema, (def, path2) => {
94408
+ if (!isMarked(def)) return true;
94409
+ found.add(path2 === "" ? "(the whole value)" : path2);
94410
+ return false;
94411
+ });
94412
+ return [...found].sort();
94413
+ }
94414
+ function hasSecretField(schema) {
94415
+ if (typeof schema !== "object" || schema === null) return false;
94416
+ const known = HAS_SECRET.get(schema);
94417
+ if (known !== void 0) return known;
94418
+ const seen = /* @__PURE__ */ new Set();
94419
+ const reaches2 = (node3, depth) => {
94420
+ const def = defOf(node3);
94421
+ if (def === null || seen.has(node3)) return false;
94422
+ if (depth >= MAX_DEPTH) {
94423
+ throw new Error(
94424
+ `A schema nests deeper than ${MAX_DEPTH} levels, so its secret fields cannot be read`
94425
+ );
94426
+ }
94427
+ seen.add(node3);
94428
+ return isMarked(def) || childrenOf(def).some((child) => reaches2(child.schema, depth + 1));
94429
+ };
94430
+ const answer = reaches2(schema, 0);
94431
+ HAS_SECRET.set(schema, answer);
94432
+ return answer;
94433
+ }
94434
+ function isModelSurface(surface) {
94435
+ return MODEL_SURFACES.some((modelSurface) => modelSurface === surface);
94436
+ }
94437
+ function secretSurfaceProblem(cap) {
94438
+ const surfaces = getSurfaces(cap).filter(isModelSurface);
94439
+ if (surfaces.length === 0) return null;
94440
+ const on = surfaces.map((surface) => `"${surface}"`).join(" and ");
94441
+ if (hasSecretField(cap.output)) {
94442
+ return `"${cap.name}" returns a secret (${secretFieldPaths(cap.output).join(", ")}) and is on the ${on} surface. A tool result lands in the model's transcript. Take the capability off that surface: a secret is read through the API or the CLI.`;
94443
+ }
94444
+ if (cap.modelInput === void 0) {
94445
+ if (!hasSecretField(cap.input)) return null;
94446
+ return `"${cap.name}" takes a secret (${secretFieldPaths(cap.input).join(", ")}) and is on the ${on} surface with no modelInput. A tool argument lands in the model's transcript. Declare a modelInput that leaves the secret out, or take the capability off that surface.`;
94447
+ }
94448
+ if (hasSecretField(cap.modelInput)) {
94449
+ return `"${cap.name}" declares a modelInput that still takes a secret (${secretFieldPaths(cap.modelInput).join(", ")}). A modelInput is the input with every secret left out.`;
94450
+ }
94451
+ if (!hasSecretField(cap.input)) {
94452
+ return `"${cap.name}" declares a modelInput, and its input marks no secret. Mark the secret with secretField(), or remove the modelInput.`;
94453
+ }
94454
+ return null;
94455
+ }
94456
+ var SECRET_MARK, SAME, ELEMENT, MAX_DEPTH, HAS_SECRET, MODEL_SURFACES;
94457
+ var init_secret_fields = __esm({
94458
+ "../../packages/oxagen/src/secret-fields.ts"() {
94459
+ "use strict";
94460
+ init_types4();
94461
+ SECRET_MARK = /* @__PURE__ */ Symbol.for("@oxagen/oxagen.secretField");
94462
+ SAME = { kind: "same" };
94463
+ ELEMENT = { kind: "element" };
94464
+ MAX_DEPTH = 200;
94465
+ HAS_SECRET = /* @__PURE__ */ new WeakMap();
94466
+ MODEL_SURFACES = [
94467
+ "mcp",
94468
+ "agent"
94469
+ ];
94470
+ }
94471
+ });
94472
+
93972
94473
  // ../../packages/oxagen/src/registry.ts
93973
94474
  function capabilitySignature(cap) {
93974
94475
  return JSON.stringify(cap, (_key, value) => {
@@ -93983,6 +94484,10 @@ function registerCapability(cap) {
93983
94484
  if (surfaceProblem !== null) {
93984
94485
  throw new Error(`code_graph_surface_mismatch: ${surfaceProblem}`);
93985
94486
  }
94487
+ const secretProblem = secretSurfaceProblem(cap);
94488
+ if (secretProblem !== null) {
94489
+ throw new Error(`secret_on_model_surface: ${secretProblem}`);
94490
+ }
93986
94491
  const existing = registry.get(cap.name);
93987
94492
  if (existing) {
93988
94493
  if (capabilitySignature(existing) === capabilitySignature(cap)) {
@@ -94003,6 +94508,7 @@ var init_registry4 = __esm({
94003
94508
  "../../packages/oxagen/src/registry.ts"() {
94004
94509
  "use strict";
94005
94510
  init_codegraph_catalogue();
94511
+ init_secret_fields();
94006
94512
  REGISTRY_KEY = /* @__PURE__ */ Symbol.for("@oxagen/oxagen.capabilityRegistry");
94007
94513
  globalRef = globalThis;
94008
94514
  registry = globalRef[REGISTRY_KEY] ?? (globalRef[REGISTRY_KEY] = /* @__PURE__ */ new Map());
@@ -95541,9 +96047,12 @@ var init_work_order_shared = __esm({
95541
96047
  "../../packages/oxagen/src/contracts/work.order.shared.ts"() {
95542
96048
  "use strict";
95543
96049
  init_zod();
96050
+ init_secret_fields();
95544
96051
  init_work_intake_shared();
95545
96052
  workOrderIdSchema = external_exports.string().regex(/^wo_[0-9a-z]+$/, "a work order id starts with wo_");
95546
- workOrderTokenSchema = external_exports.string().regex(/^oxwo_[A-Za-z0-9_-]{43}$/, "a work order token starts with oxwo_");
96053
+ workOrderTokenSchema = secretField(
96054
+ external_exports.string().regex(/^oxwo_[A-Za-z0-9_-]{43}$/, "a work order token starts with oxwo_")
96055
+ );
95547
96056
  workAgentIdSchema = external_exports.string().regex(/^agt_[0-9a-z]+$/, "an agent id starts with agt_");
95548
96057
  workItemVersionSchema = external_exports.number().int().nonnegative();
95549
96058
  workDodKeySchema = external_exports.string().regex(/^c[1-9][0-9]{0,5}$/, "a key is c and a number, such as c1");
@@ -96780,7 +97289,7 @@ var init_guardrails_delete = __esm({
96780
97289
  guardrailsDelete = registerCapability({
96781
97290
  name: "delete_guardrails",
96782
97291
  domain: "guardrails",
96783
- description: "Delete one or up to 100 auto-approval rules, off switches, mandates or spend budgets. Each stops applying at once and leaves its list, and every one is kept marked deleted so the runs and approvals that name it still resolve it.",
97292
+ description: "Delete one or up to 100 auto-approval rules, off switches, mandates or spend budgets. Each stops applying at once and leaves its list, and every one is kept marked deleted so the runs and approvals that name it still resolve it. Only a person clears an off switch or deletes a spend budget. Oxagen refuses those two items to every API key with person_required, the oxagen CLI's own key included.",
96784
97293
  mode: "sync",
96785
97294
  surfaces: ["api", "mcp", "cli", "agent"],
96786
97295
  agent: { requiresApproval: true, riskLevel: "high", category: "write" },
@@ -96790,6 +97299,11 @@ var init_guardrails_delete = __esm({
96790
97299
  sensitivity: "high",
96791
97300
  mutates: true,
96792
97301
  defaultEffect: "deny",
97302
+ // Each item runs its own capability through the kernel, which applies the
97303
+ // workspace role rule to that capability. The rule leaves this one, so an
97304
+ // organization's spend ceiling is still deleted from any workspace (#6889,
97305
+ // iam/workspace-authority.ts).
97306
+ workspaceRoleRule: "exempt",
96793
97307
  // Each item also runs its own type's role check. Compliance and Billing
96794
97308
  // may call it because a spend budget's own delete admits them, and every
96795
97309
  // other type's check refuses them.
@@ -97353,7 +97867,7 @@ var init_remote_digests = __esm({
97353
97867
  });
97354
97868
 
97355
97869
  // ../../packages/tacho/src/evidence/merkle.ts
97356
- import { createHash as createHash21 } from "node:crypto";
97870
+ import { createHash as createHash22 } from "node:crypto";
97357
97871
  function digestToBytes(digest6) {
97358
97872
  if (!SHA256_DIGEST_PATTERN.test(digest6)) {
97359
97873
  throw new TypeError(`not a sha256 hash: ${digest6}`);
@@ -97361,7 +97875,7 @@ function digestToBytes(digest6) {
97361
97875
  return Buffer.from(digest6.slice("sha256:".length), "hex");
97362
97876
  }
97363
97877
  function hash2(...parts) {
97364
- const h = createHash21("sha256");
97878
+ const h = createHash22("sha256");
97365
97879
  for (const part of parts) h.update(part);
97366
97880
  return h.digest();
97367
97881
  }
@@ -98299,7 +98813,7 @@ function encodeCbor(value) {
98299
98813
  function member3(value, key) {
98300
98814
  return value instanceof Map ? value.get(key) : void 0;
98301
98815
  }
98302
- var CborTag, CborError, MAX_DEPTH, Reader;
98816
+ var CborTag, CborError, MAX_DEPTH2, Reader;
98303
98817
  var init_cbor = __esm({
98304
98818
  "../../packages/tacho/src/evidence/claim/cbor.ts"() {
98305
98819
  "use strict";
@@ -98313,7 +98827,7 @@ var init_cbor = __esm({
98313
98827
  };
98314
98828
  CborError = class extends Error {
98315
98829
  };
98316
- MAX_DEPTH = 32;
98830
+ MAX_DEPTH2 = 32;
98317
98831
  Reader = class {
98318
98832
  constructor(bytes) {
98319
98833
  this.bytes = bytes;
@@ -98358,7 +98872,7 @@ var init_cbor = __esm({
98358
98872
  return n2;
98359
98873
  }
98360
98874
  item(depth) {
98361
- if (depth > MAX_DEPTH) throw new CborError("CBOR nests too deep");
98875
+ if (depth > MAX_DEPTH2) throw new CborError("CBOR nests too deep");
98362
98876
  const initial = this.byte();
98363
98877
  const major = initial >> 5;
98364
98878
  const info = initial & 31;
@@ -98413,7 +98927,7 @@ var init_cbor = __esm({
98413
98927
 
98414
98928
  // ../../packages/tacho/src/evidence/claim/cose.ts
98415
98929
  import {
98416
- createHash as createHash22,
98930
+ createHash as createHash23,
98417
98931
  createPublicKey as createPublicKey6,
98418
98932
  sign as sign5,
98419
98933
  verify as verify7
@@ -98534,7 +99048,7 @@ function coseKeyOf(key) {
98534
99048
  }
98535
99049
  function coseKeyThumbprint(key) {
98536
99050
  const publicKey = key.type === "private" ? createPublicKey6(key) : key;
98537
- const digest6 = createHash22("sha256").update(encodeCbor(coseKeyOf(publicKey))).digest("hex");
99051
+ const digest6 = createHash23("sha256").update(encodeCbor(coseKeyOf(publicKey))).digest("hex");
98538
99052
  return `sha256:${digest6}`;
98539
99053
  }
98540
99054
  function kidBytes(thumbprint) {
@@ -98590,9 +99104,9 @@ var init_cose = __esm({
98590
99104
  });
98591
99105
 
98592
99106
  // ../../packages/tacho/src/evidence/claim/inclusion.ts
98593
- import { createHash as createHash23 } from "node:crypto";
99107
+ import { createHash as createHash24 } from "node:crypto";
98594
99108
  function sha256(...parts) {
98595
- const h = createHash23("sha256");
99109
+ const h = createHash24("sha256");
98596
99110
  for (const part of parts) h.update(part);
98597
99111
  return new Uint8Array(h.digest());
98598
99112
  }
@@ -98789,7 +99303,7 @@ function parseDer(bytes) {
98789
99303
  return node3;
98790
99304
  }
98791
99305
  function parseAt(bytes, start, depth) {
98792
- if (depth > MAX_DEPTH2) throw new DerError("DER nests too deep");
99306
+ if (depth > MAX_DEPTH3) throw new DerError("DER nests too deep");
98793
99307
  const tag = bytes[start];
98794
99308
  if (tag === void 0) throw new DerError("DER ends early");
98795
99309
  if ((tag & 31) === 31)
@@ -98939,13 +99453,13 @@ function utcTime(date5) {
98939
99453
  const text6 = `${digits(date5.getUTCFullYear() % 100, 2)}${digits(date5.getUTCMonth() + 1, 2)}${digits(date5.getUTCDate(), 2)}${digits(date5.getUTCHours(), 2)}${digits(date5.getUTCMinutes(), 2)}${digits(date5.getUTCSeconds(), 2)}Z`;
98940
99454
  return der(TAG.UTC_TIME, new TextEncoder().encode(text6));
98941
99455
  }
98942
- var DerError, MAX_DEPTH2, TAG, seq, setOf, ctx, octets, nullValue, bool3, utf8, bitString;
99456
+ var DerError, MAX_DEPTH3, TAG, seq, setOf, ctx, octets, nullValue, bool3, utf8, bitString;
98943
99457
  var init_der = __esm({
98944
99458
  "../../packages/tacho/src/evidence/claim/der.ts"() {
98945
99459
  "use strict";
98946
99460
  DerError = class extends Error {
98947
99461
  };
98948
- MAX_DEPTH2 = 24;
99462
+ MAX_DEPTH3 = 24;
98949
99463
  TAG = {
98950
99464
  BOOLEAN: 1,
98951
99465
  INTEGER: 2,
@@ -98984,7 +99498,7 @@ var init_der = __esm({
98984
99498
  });
98985
99499
 
98986
99500
  // ../../packages/tacho/src/evidence/claim/timestamp-token.ts
98987
- import { createHash as createHash24, verify as verify8, X509Certificate } from "node:crypto";
99501
+ import { createHash as createHash25, verify as verify8, X509Certificate } from "node:crypto";
98988
99502
  function signatureHash(sigOid, digestHash) {
98989
99503
  switch (sigOid) {
98990
99504
  case OID.RSA:
@@ -99005,10 +99519,10 @@ function equalBytes(a, b3) {
99005
99519
  return a.length === b3.length && a.every((v, i2) => v === b3[i2]);
99006
99520
  }
99007
99521
  function hash3(name2, bytes) {
99008
- return new Uint8Array(createHash24(name2).update(bytes).digest());
99522
+ return new Uint8Array(createHash25(name2).update(bytes).digest());
99009
99523
  }
99010
99524
  function certificateFingerprint(cert) {
99011
- return `sha256:${createHash24("sha256").update(cert.raw).digest("hex")}`;
99525
+ return `sha256:${createHash25("sha256").update(cert.raw).digest("hex")}`;
99012
99526
  }
99013
99527
  function certificatesFromPem(text6) {
99014
99528
  const blocks = text6.match(
@@ -99305,7 +99819,7 @@ var init_timestamp_token = __esm({
99305
99819
 
99306
99820
  // ../../packages/tacho/src/evidence/claim/sample-pki.ts
99307
99821
  import {
99308
- createHash as createHash25,
99822
+ createHash as createHash26,
99309
99823
  generateKeyPairSync as generateKeyPairSync2,
99310
99824
  randomBytes as randomBytes13,
99311
99825
  sign as sign6,
@@ -99401,7 +99915,7 @@ function samplePki(at2) {
99401
99915
  };
99402
99916
  }
99403
99917
  function sha2562(bytes) {
99404
- return new Uint8Array(createHash25("sha256").update(bytes).digest());
99918
+ return new Uint8Array(createHash26("sha256").update(bytes).digest());
99405
99919
  }
99406
99920
  function issueTimestampToken(input2) {
99407
99921
  const tstInfo = seq(
@@ -99470,7 +99984,7 @@ var init_sample_pki = __esm({
99470
99984
 
99471
99985
  // ../../packages/tacho/src/evidence/claim/sample.ts
99472
99986
  import {
99473
- createHash as createHash26,
99987
+ createHash as createHash27,
99474
99988
  createPublicKey as createPublicKey7,
99475
99989
  generateKeyPairSync as generateKeyPairSync3
99476
99990
  } from "node:crypto";
@@ -99658,7 +100172,7 @@ function buildClaimBundle(record2, keys, tamper = (_, b3) => b3) {
99658
100172
  gaps: notReceived
99659
100173
  })
99660
100174
  );
99661
- const imprint = createHash26("sha256").update(files2.get(`${base2}.json`)).digest();
100175
+ const imprint = createHash27("sha256").update(files2.get(`${base2}.json`)).digest();
99662
100176
  put(
99663
100177
  `${base2}.tst`,
99664
100178
  issueTimestampToken({
@@ -99808,7 +100322,7 @@ function agentEvent(session, seq2, ts2, kind, path2, body2 = {}, extra = {}) {
99808
100322
  return {
99809
100323
  v: "tacho/1.0",
99810
100324
  event_id: `evt_${session.slice(0, 8)}_${seq2}`,
99811
- event_id_idem: `evt_${createHash26("sha256").update(`${session}:${seq2}`).digest("hex")}`,
100325
+ event_id_idem: `evt_${createHash27("sha256").update(`${session}:${seq2}`).digest("hex")}`,
99812
100326
  session_id: `ses_${session.slice(0, 8)}`,
99813
100327
  session_uuid: session,
99814
100328
  root_session_uuid: SESSION,
@@ -99919,7 +100433,7 @@ function sampleClaimInput() {
99919
100433
  agentEvent(SUBAGENT, 3, t(19, 58), "agent_stop", "ambient/hook")
99920
100434
  ]);
99921
100435
  const cti = new Uint8Array(
99922
- createHash26("sha256").update("sample scope token").digest().subarray(0, 16)
100436
+ createHash27("sha256").update("sample scope token").digest().subarray(0, 16)
99923
100437
  );
99924
100438
  const scope = { cti: Buffer.from(cti).toString("base64url"), token_hash: "" };
99925
100439
  const actor = { principal: "insurer:northwind-mutual", key_thumbprint: null };
@@ -100118,7 +100632,7 @@ var init_sample = __esm({
100118
100632
  init_inclusion();
100119
100633
  init_sample_pki();
100120
100634
  encoder6 = new TextEncoder();
100121
- sha256Hex4 = (bytes) => `sha256:${createHash26("sha256").update(bytes).digest("hex")}`;
100635
+ sha256Hex4 = (bytes) => `sha256:${createHash27("sha256").update(bytes).digest("hex")}`;
100122
100636
  pem = (key) => createPublicKey7(key).export({ type: "spki", format: "pem" }).toString();
100123
100637
  certPem = (der2) => `-----BEGIN CERTIFICATE-----
100124
100638
  ${Buffer.from(der2).toString("base64").replace(/(.{64})/g, "$1\n").replace(/\n$/, "")}
@@ -100145,7 +100659,7 @@ var init_verifier_script_generated = __esm({
100145
100659
 
100146
100660
  // ../../packages/tacho/src/evidence/claim/verify.ts
100147
100661
  import {
100148
- createHash as createHash27,
100662
+ createHash as createHash28,
100149
100663
  createPublicKey as createPublicKey8,
100150
100664
  X509Certificate as X509Certificate3
100151
100665
  } from "node:crypto";
@@ -100173,7 +100687,7 @@ function isObj(value) {
100173
100687
  return value !== null && typeof value === "object" && !Array.isArray(value);
100174
100688
  }
100175
100689
  function sha256Hex5(bytes) {
100176
- return `sha256:${createHash27("sha256").update(bytes).digest("hex")}`;
100690
+ return `sha256:${createHash28("sha256").update(bytes).digest("hex")}`;
100177
100691
  }
100178
100692
  function text5(bytes) {
100179
100693
  if (!bytes) return null;
@@ -100697,7 +101211,7 @@ function verifyClaimBundle(files2, pins = {}) {
100697
101211
  "the export carries no frame at or before this head to date it by"
100698
101212
  );
100699
101213
  } else {
100700
- const imprint = createHash27("sha256").update(stamped2).digest();
101214
+ const imprint = createHash28("sha256").update(stamped2).digest();
100701
101215
  const result2 = verifyTimestampToken({
100702
101216
  token,
100703
101217
  imprint: new Uint8Array(imprint),
@@ -101746,7 +102260,7 @@ var init_harnesses = __esm({
101746
102260
 
101747
102261
  // src/lib/working-copy.ts
101748
102262
  import { execFile as execFile6 } from "node:child_process";
101749
- import { createHash as createHash28, randomBytes as randomBytes14 } from "node:crypto";
102263
+ import { createHash as createHash29, randomBytes as randomBytes14 } from "node:crypto";
101750
102264
  import {
101751
102265
  existsSync as existsSync32,
101752
102266
  lstatSync as lstatSync13,
@@ -101854,7 +102368,7 @@ function machineId(configDir = getConfigDir()) {
101854
102368
  } catch {
101855
102369
  secret = `fallback:${osHostname3()}:${homedir13()}`;
101856
102370
  }
101857
- return createHash28("sha256").update(secret).digest("hex");
102371
+ return createHash29("sha256").update(secret).digest("hex");
101858
102372
  }
101859
102373
  function cliVersion() {
101860
102374
  const v = package_default.version;
@@ -104344,23 +104858,84 @@ var init_cost = __esm({
104344
104858
  }
104345
104859
  });
104346
104860
 
104861
+ // src/auth/open-browser.ts
104862
+ import { spawn as spawn8 } from "node:child_process";
104863
+ function openBrowser(url2) {
104864
+ try {
104865
+ let cmd;
104866
+ let args;
104867
+ switch (process.platform) {
104868
+ case "darwin":
104869
+ cmd = "open";
104870
+ args = [url2];
104871
+ break;
104872
+ case "win32":
104873
+ cmd = "cmd";
104874
+ args = ["/c", "start", "", url2];
104875
+ break;
104876
+ default:
104877
+ cmd = "xdg-open";
104878
+ args = [url2];
104879
+ }
104880
+ const child = spawn8(cmd, args, { detached: true, stdio: "ignore" });
104881
+ child.on("error", () => {
104882
+ });
104883
+ child.unref();
104884
+ } catch {
104885
+ }
104886
+ }
104887
+ var init_open_browser = __esm({
104888
+ "src/auth/open-browser.ts"() {
104889
+ }
104890
+ });
104891
+
104892
+ // src/lib/app-handoff.ts
104893
+ function appPageUrl(handoff2, deps) {
104894
+ const origin = deps.appUrl.replace(/\/+$/, "");
104895
+ if (!deps.org || !deps.workspace) return origin;
104896
+ return `${origin}/${encodeURIComponent(deps.org)}/${encodeURIComponent(deps.workspace)}/${handoff2.workspacePath}`;
104897
+ }
104898
+ function handOffToApp(handoff2, opts = {}, writer = stdoutWriter, overrides = {}) {
104899
+ const deps = { ...liveDeps(), ...overrides };
104900
+ const url2 = appPageUrl(handoff2, deps);
104901
+ const out = createOutput({ json: opts.json }, writer);
104902
+ out.error(
104903
+ `Only a person signed in to Oxagen can ${handoff2.change}, so this command made no change. The CLI holds a key, and an agent on this machine could send the same key. Make the change in Oxagen, under ${handoff2.where}: ${url2}`,
104904
+ PERSON_REQUIRED
104905
+ );
104906
+ if (deps.isTTY && !out.isJson) {
104907
+ out.info("Opening that page in your browser.");
104908
+ deps.open(url2);
104909
+ }
104910
+ }
104911
+ var PERSON_REQUIRED, liveDeps;
104912
+ var init_app_handoff = __esm({
104913
+ "src/lib/app-handoff.ts"() {
104914
+ init_open_browser();
104915
+ init_capture_writer();
104916
+ init_config();
104917
+ init_output();
104918
+ PERSON_REQUIRED = "person_required";
104919
+ liveDeps = () => ({
104920
+ appUrl: getAppUrl(),
104921
+ org: getOrgId(),
104922
+ workspace: getWorkspaceId(),
104923
+ isTTY: process.stdout.isTTY === true,
104924
+ open: openBrowser
104925
+ });
104926
+ }
104927
+ });
104928
+
104347
104929
  // src/commands/budget.ts
104348
104930
  var budget_exports = {};
104349
104931
  __export(budget_exports, {
104932
+ BUDGET_HANDOFF: () => BUDGET_HANDOFF,
104350
104933
  budgetSet: () => budgetSet,
104351
104934
  budgetShow: () => budgetShow
104352
104935
  });
104353
104936
  function formatMoney(money2) {
104354
104937
  return formatUsd(Number(money2.micros) / 1e6);
104355
104938
  }
104356
- function usdFlagToMicros(raw) {
104357
- const m = /^(\d+)(?:\.(\d{1,6}))?$/.exec(raw.trim());
104358
- if (!m) return null;
104359
- const whole2 = m[1];
104360
- const frac = (m[2] ?? "").padEnd(6, "0");
104361
- const micros2 = `${whole2}${frac}`.replace(/^0+(?=\d)/, "");
104362
- return micros2 === "0" ? null : micros2;
104363
- }
104364
104939
  function periodCell(b3) {
104365
104940
  return b3.period === "rolling" ? `rolling (${b3.windowDays}d)` : "monthly";
104366
104941
  }
@@ -104415,8 +104990,14 @@ async function budgetShow(opts = {}, writer = stdoutWriter) {
104415
104990
  return;
104416
104991
  }
104417
104992
  if (result2.budgets.length === 0) {
104993
+ const page = appPageUrl(BUDGET_HANDOFF, {
104994
+ appUrl: getAppUrl(),
104995
+ org: getOrgId(),
104996
+ workspace: getWorkspaceId()
104997
+ });
104418
104998
  writer.write(
104419
- "No spend ceilings configured. Set one with:\n oxagen budget set --scope <org|workspace> --period <monthly|rolling> --limit <usd>"
104999
+ `No spend ceilings configured. Set one in Oxagen, under ${BUDGET_HANDOFF.where}:
105000
+ ${page}`
104420
105001
  );
104421
105002
  return;
104422
105003
  }
@@ -104424,101 +105005,24 @@ async function budgetShow(opts = {}, writer = stdoutWriter) {
104424
105005
  writer.write("");
104425
105006
  renderBudgetsTable(result2.budgets, writer);
104426
105007
  }
104427
- function isSpendScope(v) {
104428
- return v === "org" || v === "workspace";
104429
- }
104430
- function isSpendPeriod(v) {
104431
- return v === "monthly" || v === "rolling";
104432
- }
104433
- function parseBool(v) {
104434
- if (v === "true" || v === "yes") return true;
104435
- if (v === "false" || v === "no") return false;
104436
- return void 0;
104437
- }
104438
- async function budgetSet(opts, writer = stdoutWriter) {
104439
- const out = createOutput({ json: opts.json }, writer);
104440
- if (!opts.scope || !isSpendScope(opts.scope)) {
104441
- process.exitCode = 2;
104442
- out.error(
104443
- `Invalid --scope "${opts.scope ?? ""}". Use "org" or "workspace".`,
104444
- "usage"
104445
- );
104446
- return;
104447
- }
104448
- if (!opts.period || !isSpendPeriod(opts.period)) {
104449
- process.exitCode = 2;
104450
- out.error(
104451
- `Invalid --period "${opts.period ?? ""}". Use "monthly" or "rolling".`,
104452
- "usage"
104453
- );
104454
- return;
104455
- }
104456
- const limitMicros = opts.limit === void 0 ? null : usdFlagToMicros(opts.limit);
104457
- if (limitMicros === null) {
104458
- process.exitCode = 2;
104459
- out.error(
104460
- `Invalid --limit "${opts.limit ?? ""}". Provide a positive USD amount with at most six decimals.`,
104461
- "usage"
104462
- );
104463
- return;
104464
- }
104465
- const limit = { micros: limitMicros, currency: "USD" };
104466
- let windowDays;
104467
- if (opts.period === "rolling") {
104468
- const parsed2 = opts.windowDays === void 0 ? NaN : Number(opts.windowDays);
104469
- if (!Number.isInteger(parsed2) || parsed2 <= 0) {
104470
- process.exitCode = 2;
104471
- out.error(
104472
- `--window-days is required (and > 0) for --period rolling. Got "${opts.windowDays ?? ""}".`,
104473
- "usage"
104474
- );
104475
- return;
104476
- }
104477
- windowDays = parsed2;
104478
- } else if (opts.windowDays !== void 0) {
104479
- process.exitCode = 2;
104480
- out.error(`--window-days must be omitted for --period monthly.`, "usage");
104481
- return;
104482
- }
104483
- const enabled = opts.enabled === void 0 ? true : parseBool(opts.enabled);
104484
- if (enabled === void 0) {
104485
- process.exitCode = 2;
104486
- out.error(
104487
- `Invalid --enabled "${opts.enabled ?? ""}". Use "true" or "false".`,
104488
- "usage"
104489
- );
104490
- return;
104491
- }
104492
- let result2;
104493
- try {
104494
- result2 = await apiPutOrThrow("billing/budget", {
104495
- scope: opts.scope,
104496
- enabled,
104497
- period: opts.period,
104498
- windowDays,
104499
- limit
104500
- });
104501
- } catch (err2) {
104502
- out.error(err2, "api");
104503
- return;
104504
- }
104505
- if (out.isJson) {
104506
- out.data(result2);
104507
- return;
104508
- }
104509
- writer.write(
104510
- `\u2713 ${result2.scope} spend ceiling set to ${formatMoney(limit)} (${periodCell(result2)}).`
104511
- );
104512
- writer.write("");
104513
- renderBudgetsTable([result2], writer);
105008
+ function budgetSet(opts = {}, writer = stdoutWriter, deps = {}) {
105009
+ handOffToApp(BUDGET_HANDOFF, { json: opts.json }, writer, deps);
105010
+ return Promise.resolve();
104514
105011
  }
104515
- var pct, STATE_LABEL;
105012
+ var BUDGET_HANDOFF, pct, STATE_LABEL;
104516
105013
  var init_budget2 = __esm({
104517
105014
  "src/commands/budget.ts"() {
104518
105015
  init_api();
104519
105016
  init_rate_card();
105017
+ init_app_handoff();
105018
+ init_config();
104520
105019
  init_output();
104521
105020
  init_capture_writer();
105021
+ BUDGET_HANDOFF = {
105022
+ change: "set a spend ceiling",
105023
+ workspacePath: "guardrails?tab=budgets",
105024
+ where: "Guardrails, then Budgets"
105025
+ };
104522
105026
  pct = (ratio) => `${Math.round(ratio * 100)}%`;
104523
105027
  STATE_LABEL = {
104524
105028
  ok: "ok",
@@ -108241,7 +108745,7 @@ __export(steering_findings_exports, {
108241
108745
  steeringFindings: () => steeringFindings,
108242
108746
  usageError: () => usageError
108243
108747
  });
108244
- function isRecord8(value) {
108748
+ function isRecord9(value) {
108245
108749
  return typeof value === "object" && value !== null && !Array.isArray(value);
108246
108750
  }
108247
108751
  function textOrNull(value) {
@@ -108254,7 +108758,7 @@ function apiRefusal(err2) {
108254
108758
  if (start >= 0 && end > start) {
108255
108759
  try {
108256
108760
  const body2 = JSON.parse(message2.slice(start, end + 1));
108257
- const error2 = isRecord8(body2) && isRecord8(body2.error) ? body2.error : null;
108761
+ const error2 = isRecord9(body2) && isRecord9(body2.error) ? body2.error : null;
108258
108762
  const said = error2 === null ? null : textOrNull(error2.message);
108259
108763
  if (error2 !== null && said !== null) {
108260
108764
  return {
@@ -108365,6 +108869,7 @@ var init_steering_findings = __esm({
108365
108869
  // src/commands/repo.ts
108366
108870
  var repo_exports = {};
108367
108871
  __export(repo_exports, {
108872
+ GOVERNANCE_HANDOFF: () => GOVERNANCE_HANDOFF,
108368
108873
  parseRepositoryRef: () => parseRepositoryRef,
108369
108874
  repoBranch: () => repoBranch,
108370
108875
  repoGovernance: () => repoGovernance,
@@ -108578,73 +109083,25 @@ async function repoBranch(bindingId, branch, opts = {}, writer = stdoutWriter) {
108578
109083
  result2.changed ? `${result2.fullName}: production branch ${result2.previousBranch} \u2192 ${result2.productionBranch} \xB7 ${result2.bindingId}` : `${result2.fullName}: production branch is already ${result2.productionBranch}; nothing was written`
108579
109084
  );
108580
109085
  }
108581
- async function repoGovernance(opts = {}, writer = stdoutWriter) {
108582
- const line = "oxagen repo governance --mode solo|team|regulated [--workspace <wrk_\u2026>] [--apply-now] [--json]";
108583
- const mode = opts.mode;
108584
- if (mode === void 0 || !GOVERNANCE_MODES.includes(mode)) {
108585
- return usageError(
108586
- writer,
108587
- `expected a mode of solo, team or regulated, got ${JSON.stringify(opts.mode)}`,
108588
- line
108589
- );
108590
- }
108591
- const out = createOutput({ json: opts.json }, writer);
108592
- let result2;
108593
- try {
108594
- result2 = await apiPostOrThrow(
108595
- "context/governance-mode",
108596
- {
108597
- mode,
108598
- applyImmediately: opts.applyNow === true,
108599
- ...opts.workspace === void 0 ? {} : { workspaceId: opts.workspace }
108600
- }
108601
- );
108602
- } catch (err2) {
108603
- out.error(err2, "api");
108604
- return;
108605
- }
108606
- if (out.isJson) {
108607
- out.data(result2);
108608
- return;
108609
- }
108610
- if (result2.outcome === "unchanged") {
108611
- writer.write(
108612
- `${result2.fullName} already runs under ${result2.requestedMode}; nothing was written.`
108613
- );
108614
- return;
108615
- }
108616
- if (result2.outcome === "applied") {
108617
- writer.write(
108618
- `${result2.fullName} now runs under ${result2.requestedMode} (${result2.productionBranch}, ${result2.commitSha ?? "committed"}).`
108619
- );
108620
- if (result2.overrodeReview) {
108621
- writer.write(
108622
- `Committed without review, which ${result2.previousMode ?? "the mode in force"} asks for. Recorded as steering.governance_overridden.`
108623
- );
108624
- }
108625
- return;
108626
- }
108627
- writer.write(
108628
- result2.pullRequest?.reused === true ? `Updated the open pull request on ${result2.fullName}: ${result2.pullRequest.htmlUrl}` : `Opened ${result2.pullRequest?.htmlUrl ?? "a pull request"} on ${result2.fullName}.`
108629
- );
108630
- writer.write(
108631
- `${result2.fullName} still runs under ${result2.effectiveMode ?? "an unreadable governance.toml"} until a person merges it. Pass --apply-now to commit instead.`
108632
- );
109086
+ function repoGovernance(opts = {}, writer = stdoutWriter, deps = {}) {
109087
+ handOffToApp(GOVERNANCE_HANDOFF, { json: opts.json }, writer, deps);
109088
+ return Promise.resolve();
108633
109089
  }
108634
- var GOVERNANCE_MODES, connectionState, GITLAB_PROJECT_PATH;
109090
+ var connectionState, GITLAB_PROJECT_PATH, GOVERNANCE_HANDOFF;
108635
109091
  var init_repo = __esm({
108636
109092
  "src/commands/repo.ts"() {
108637
109093
  init_api();
109094
+ init_app_handoff();
108638
109095
  init_output();
108639
109096
  init_capture_writer();
108640
109097
  init_steering_findings();
108641
- GOVERNANCE_MODES = [
108642
- "solo",
108643
- "team",
108644
- "regulated"
108645
- ];
108646
109098
  connectionState = (live) => live ? "live" : "retired";
108647
109099
  GITLAB_PROJECT_PATH = /^[A-Za-z0-9_][A-Za-z0-9_.-]*(\/[A-Za-z0-9_][A-Za-z0-9_.-]*)+$/;
109100
+ GOVERNANCE_HANDOFF = {
109101
+ change: "change the steering governance mode",
109102
+ workspacePath: "settings",
109103
+ where: "Workspace settings, then General"
109104
+ };
108648
109105
  }
108649
109106
  });
108650
109107
 
@@ -111149,7 +111606,7 @@ function checkRecordClassification(record2, ctx2, paths = {
111149
111606
  });
111150
111607
  }
111151
111608
  }
111152
- var recordKindSchema3, steeringPrKindSchema, proposalKindSchema, RECORD_KINDS2, STEERING_PR_KINDS, GOVERNANCE_LINEAGE, recordForceSchema2, constraintEffectSchema, publishedSharingScopeSchema, appendKindSchema, proposalStatusSchema, proposalStateSchema, repositoryProviderSchema, governanceModeSchema, GOVERNANCE_MODES2, checkNameSchema, CHECK_NAMES, steeringCheckNameSchema, STEERING_CHECK_NAMES, instant4, checkResultSchema, checkFindingSchema, RECORD_LINEAGE_ID, lineageIdSchema, proposedRecordSchema, proposalSupportSchema, proposalIdSchema, proposalViewSchema, pendingRemovalSchema, publishedRecordSchema;
111609
+ var recordKindSchema3, steeringPrKindSchema, proposalKindSchema, RECORD_KINDS2, STEERING_PR_KINDS, GOVERNANCE_LINEAGE, recordForceSchema2, constraintEffectSchema, publishedSharingScopeSchema, appendKindSchema, proposalStatusSchema, proposalStateSchema, repositoryProviderSchema, governanceModeSchema, GOVERNANCE_MODES, checkNameSchema, CHECK_NAMES, steeringCheckNameSchema, STEERING_CHECK_NAMES, instant4, checkResultSchema, checkFindingSchema, RECORD_LINEAGE_ID, lineageIdSchema, proposedRecordSchema, proposalSupportSchema, proposalIdSchema, proposalViewSchema, pendingRemovalSchema, publishedRecordSchema;
111153
111610
  var init_context_steering_shared = __esm({
111154
111611
  "../../packages/oxagen/src/contracts/context.steering.shared.ts"() {
111155
111612
  "use strict";
@@ -111209,7 +111666,7 @@ var init_context_steering_shared = __esm({
111209
111666
  proposalStateSchema = external_exports.enum(["open", "merged", "closed"]);
111210
111667
  repositoryProviderSchema = external_exports.enum(["github", "gitlab"]);
111211
111668
  governanceModeSchema = external_exports.enum(["solo", "team", "regulated"]);
111212
- GOVERNANCE_MODES2 = governanceModeSchema.options;
111669
+ GOVERNANCE_MODES = governanceModeSchema.options;
111213
111670
  checkNameSchema = external_exports.enum([
111214
111671
  "schema",
111215
111672
  "lineage_uniqueness",
@@ -112687,7 +113144,7 @@ var init_json_text = __esm({
112687
113144
  });
112688
113145
 
112689
113146
  // ../../packages/run-evidence/src/digest.ts
112690
- import { createHash as createHash29 } from "node:crypto";
113147
+ import { createHash as createHash30 } from "node:crypto";
112691
113148
  function intrinsicHashMethod(name2) {
112692
113149
  const method = Object.getOwnPropertyDescriptor(
112693
113150
  intrinsicHashPrototype,
@@ -112710,7 +113167,7 @@ function sha256Digest(bytes) {
112710
113167
  if (!(bytes instanceof intrinsicUint8ArrayConstructor)) {
112711
113168
  throw new TypeError("sha256Digest requires exact bytes");
112712
113169
  }
112713
- const hash5 = createHash29("sha256");
113170
+ const hash5 = createHash30("sha256");
112714
113171
  Reflect.apply(intrinsicHashUpdate, hash5, [bytes]);
112715
113172
  const hex3 = Reflect.apply(intrinsicHashDigest, hash5, ["hex"]);
112716
113173
  return `sha256:${hex3}`;
@@ -112728,7 +113185,7 @@ var init_digest3 = __esm({
112728
113185
  intrinsicTextEncoderEncode = TextEncoder.prototype.encode;
112729
113186
  intrinsicUint8ArrayConstructor = Uint8Array;
112730
113187
  intrinsicHashPrototype = Object.getPrototypeOf(
112731
- createHash29("sha256")
113188
+ createHash30("sha256")
112732
113189
  );
112733
113190
  intrinsicHashUpdate = intrinsicHashMethod("update");
112734
113191
  intrinsicHashDigest = intrinsicHashMethod("digest");
@@ -116131,7 +116588,7 @@ var init_steering_repo = __esm({
116131
116588
  });
116132
116589
 
116133
116590
  // ../../packages/steering-check/src/repo.ts
116134
- function isRecord9(value) {
116591
+ function isRecord10(value) {
116135
116592
  return typeof value === "object" && value !== null && !Array.isArray(value);
116136
116593
  }
116137
116594
  function isString(value) {
@@ -116269,7 +116726,7 @@ function parseTomlLoose(text6) {
116269
116726
  if (text6 === void 0) return null;
116270
116727
  try {
116271
116728
  const value = parse(text6);
116272
- return isRecord9(value) ? value : null;
116729
+ return isRecord10(value) ? value : null;
116273
116730
  } catch {
116274
116731
  return null;
116275
116732
  }
@@ -116277,7 +116734,7 @@ function parseTomlLoose(text6) {
116277
116734
  function canonicalJson(value) {
116278
116735
  if (Array.isArray(value))
116279
116736
  return `[${value.map(canonicalJson).join(",")}]`;
116280
- if (isRecord9(value)) {
116737
+ if (isRecord10(value)) {
116281
116738
  const keys = Object.keys(value).sort();
116282
116739
  return `{${keys.map((key) => `${JSON.stringify(key)}:${canonicalJson(value[key])}`).join(",")}}`;
116283
116740
  }
@@ -116287,7 +116744,7 @@ function parseJsonLoose(text6) {
116287
116744
  if (text6 === void 0) return null;
116288
116745
  try {
116289
116746
  const value = JSON.parse(text6);
116290
- return isRecord9(value) ? value : null;
116747
+ return isRecord10(value) ? value : null;
116291
116748
  } catch {
116292
116749
  return null;
116293
116750
  }
@@ -116301,9 +116758,9 @@ function workspaceRepositories(tree) {
116301
116758
  }
116302
116759
  function entries(value) {
116303
116760
  const found = /* @__PURE__ */ new Map();
116304
- if (!isRecord9(value)) return found;
116761
+ if (!isRecord10(value)) return found;
116305
116762
  for (const [key, entry2] of Object.entries(value)) {
116306
- if (isRecord9(entry2)) found.set(key, entry2);
116763
+ if (isRecord10(entry2)) found.set(key, entry2);
116307
116764
  }
116308
116765
  return found;
116309
116766
  }
@@ -116463,7 +116920,7 @@ function alwaysOnBlocks(tree, files2 = recordFiles(tree), options = {}) {
116463
116920
  for (const [name2, folder] of folders) {
116464
116921
  for (const key of folder.tools.keys()) imported.push(toolName3(name2, key));
116465
116922
  const exposure = folder.server?.exposure;
116466
- if (isRecord9(exposure) && (exposure.mode === "search" || exposure.mode === "direct")) {
116923
+ if (isRecord10(exposure) && (exposure.mode === "search" || exposure.mode === "direct")) {
116467
116924
  modes.set(name2, exposure.mode);
116468
116925
  }
116469
116926
  }
@@ -116493,7 +116950,7 @@ function isPositiveInteger(value) {
116493
116950
  }
116494
116951
  function alwaysOnBudget(tree) {
116495
116952
  const steering = parseTomlLoose(tree?.get(GOVERNANCE_TOML_PATH))?.steering;
116496
- const value = isRecord9(steering) ? steering.always_on_tokens : void 0;
116953
+ const value = isRecord10(steering) ? steering.always_on_tokens : void 0;
116497
116954
  if (value === "off") return "off";
116498
116955
  if (isPositiveInteger(value))
116499
116956
  return { tokens: value, source: "governance.toml" };
@@ -116501,7 +116958,7 @@ function alwaysOnBudget(tree) {
116501
116958
  }
116502
116959
  function definitionBudget(tree) {
116503
116960
  const tools = parseTomlLoose(tree?.get(WORKSPACE_TOML_PATH))?.tools;
116504
- const value = isRecord9(tools) ? tools.definition_budget : void 0;
116961
+ const value = isRecord10(tools) ? tools.definition_budget : void 0;
116505
116962
  return isPositiveInteger(value) ? { tokens: value, source: "workspace.toml" } : {
116506
116963
  tokens: DEFAULT_WORKSPACE_DEFINITION_BUDGET,
116507
116964
  source: "Oxagen's default"
@@ -116656,12 +117113,12 @@ function directDefinitions(tree) {
116656
117113
  const servers = [];
116657
117114
  for (const [name2, folder] of serverFolders(tree)) {
116658
117115
  const exposure = folder.server?.exposure;
116659
- if (!isRecord9(exposure) || exposure.mode !== "direct") continue;
117116
+ if (!isRecord10(exposure) || exposure.mode !== "direct") continue;
116660
117117
  let tokens = 0;
116661
117118
  let tools = 0;
116662
117119
  for (const [key, entry2] of folder.tools) {
116663
117120
  const upstream = folder.locked.get(key)?.upstream;
116664
- if (!isRecord9(upstream)) continue;
117121
+ if (!isRecord10(upstream)) continue;
116665
117122
  const description = isString(entry2.description) ? entry2.description : upstream.description;
116666
117123
  const definition = {
116667
117124
  name: `${name2}__${key}`,
@@ -117489,7 +117946,7 @@ function credentialFields(value, prefix = "") {
117489
117946
  (item, n2) => credentialFields(item, prefix === "" ? String(n2) : `${prefix}.${n2}`)
117490
117947
  );
117491
117948
  }
117492
- if (!isRecord9(value)) return [];
117949
+ if (!isRecord10(value)) return [];
117493
117950
  return Object.entries(value).flatMap(
117494
117951
  ([key, item]) => credentialFields(item, prefix === "" ? key : `${prefix}.${key}`)
117495
117952
  );
@@ -117531,7 +117988,7 @@ function groupFindings(tree, context) {
117531
117988
  const lineOf = tomlLocator(text6);
117532
117989
  const findings = [];
117533
117990
  reviewers.forEach((entry2, n2) => {
117534
- if (!isRecord9(entry2) || !isString(entry2.group) || context.groups.includes(entry2.group))
117991
+ if (!isRecord10(entry2) || !isString(entry2.group) || context.groups.includes(entry2.group))
117535
117992
  return;
117536
117993
  const field = `reviewers.${n2}.group`;
117537
117994
  findings.push(
@@ -120523,7 +120980,7 @@ __export(run_exports, {
120523
120980
  runTurns: () => runTurns,
120524
120981
  writeColumns: () => writeColumns
120525
120982
  });
120526
- import { createHash as createHash30 } from "node:crypto";
120983
+ import { createHash as createHash31 } from "node:crypto";
120527
120984
  import { createWriteStream, renameSync as renameSync8, rmSync as rmSync14 } from "node:fs";
120528
120985
  import { resolve as resolve26 } from "node:path";
120529
120986
  import { Readable as Readable2 } from "node:stream";
@@ -120625,7 +121082,7 @@ async function runDownload(exportId, opts = {}, writer = stdoutWriter) {
120625
121082
  const url2 = resolveDownloadUrl(status2.download.url, getApiUrl());
120626
121083
  const path2 = resolve26(opts.out ?? `${status2.runId}-${exportId}.zip`);
120627
121084
  const partial2 = `${path2}.${process.pid}.partial`;
120628
- const hash5 = createHash30("sha256");
121085
+ const hash5 = createHash31("sha256");
120629
121086
  let size = 0;
120630
121087
  let headerDigest;
120631
121088
  const controller = new AbortController();
@@ -121819,7 +122276,7 @@ __export(credentials_exports, {
121819
122276
  readSecret: () => readSecret,
121820
122277
  runHarnessLogin: () => runHarnessLogin
121821
122278
  });
121822
- import { spawn as spawn8 } from "node:child_process";
122279
+ import { spawn as spawn9 } from "node:child_process";
121823
122280
  import { homedir as homedir15 } from "node:os";
121824
122281
  import { join as join73 } from "node:path";
121825
122282
  function sharedBody(opts) {
@@ -121978,7 +122435,7 @@ function createSetupTokenHider(write) {
121978
122435
  }
121979
122436
  function spawnCodexLogin(codex) {
121980
122437
  return new Promise((resolve29, reject2) => {
121981
- const child = spawn8(codex, ["login"], {
122438
+ const child = spawn9(codex, ["login"], {
121982
122439
  stdio: ["inherit", 2, "inherit"],
121983
122440
  env: process.env
121984
122441
  });
@@ -124600,8 +125057,8 @@ function defineLazy(object3, key, getter) {
124600
125057
  configurable: true
124601
125058
  });
124602
125059
  }
124603
- function objectClone(obj2) {
124604
- return Object.create(Object.getPrototypeOf(obj2), Object.getOwnPropertyDescriptors(obj2));
125060
+ function objectClone(obj3) {
125061
+ return Object.create(Object.getPrototypeOf(obj3), Object.getOwnPropertyDescriptors(obj3));
124605
125062
  }
124606
125063
  function assignProp(target, prop, value) {
124607
125064
  Object.defineProperty(target, prop, {
@@ -124672,10 +125129,10 @@ function mergeDefs(...defs) {
124672
125129
  function cloneDef(schema) {
124673
125130
  return mergeDefs(schema._zod.def);
124674
125131
  }
124675
- function getElementAtPath(obj2, path2) {
125132
+ function getElementAtPath(obj3, path2) {
124676
125133
  if (!path2)
124677
- return obj2;
124678
- return path2.reduce((acc, key) => acc?.[key], obj2);
125134
+ return obj3;
125135
+ return path2.reduce((acc, key) => acc?.[key], obj3);
124679
125136
  }
124680
125137
  function promiseAllObject(promisesObj) {
124681
125138
  const keys = Object.keys(promisesObj);
@@ -125017,9 +125474,9 @@ function parsedType(data) {
125017
125474
  if (Array.isArray(data)) {
125018
125475
  return "array";
125019
125476
  }
125020
- const obj2 = data;
125021
- if (obj2 && Object.getPrototypeOf(obj2) !== Object.prototype && "constructor" in obj2 && obj2.constructor) {
125022
- return obj2.constructor.name;
125477
+ const obj3 = data;
125478
+ if (obj3 && Object.getPrototypeOf(obj3) !== Object.prototype && "constructor" in obj3 && obj3.constructor) {
125479
+ return obj3.constructor.name;
125023
125480
  }
125024
125481
  }
125025
125482
  }
@@ -125037,8 +125494,8 @@ function issue(...args) {
125037
125494
  }
125038
125495
  return { ...iss };
125039
125496
  }
125040
- function cleanEnum(obj2) {
125041
- return Object.entries(obj2).filter(([k, _]) => {
125497
+ function cleanEnum(obj3) {
125498
+ return Object.entries(obj3).filter(([k, _]) => {
125042
125499
  return Number.isNaN(Number.parseInt(k, 10));
125043
125500
  }).map((el) => el[1]);
125044
125501
  }
@@ -125434,15 +125891,15 @@ function _getMessage() {
125434
125891
  function _setMessage(value) {
125435
125892
  this._zod.message = value;
125436
125893
  }
125437
- function node(obj2, key, make) {
125438
- if (!Object.prototype.hasOwnProperty.call(obj2, key)) {
125894
+ function node(obj3, key, make) {
125895
+ if (!Object.prototype.hasOwnProperty.call(obj3, key)) {
125439
125896
  if (key === "__proto__") {
125440
- Object.defineProperty(obj2, key, { value: make(), writable: true, enumerable: true, configurable: true });
125897
+ Object.defineProperty(obj3, key, { value: make(), writable: true, enumerable: true, configurable: true });
125441
125898
  } else {
125442
- obj2[key] = make();
125899
+ obj3[key] = make();
125443
125900
  }
125444
125901
  }
125445
- return obj2[key];
125902
+ return obj3[key];
125446
125903
  }
125447
125904
  function flattenError(error2, mapper = (issue2) => issue2.message) {
125448
125905
  const fieldErrors = {};
@@ -139658,7 +140115,7 @@ var init_src_CeKsbNLO = __esm({
139658
140115
  var index = header2.indexOf(";");
139659
140116
  var type = index !== -1 ? header2.slice(0, index).trim() : header2.trim();
139660
140117
  if (!TYPE_REGEXP.test(type)) throw new TypeError("invalid media type");
139661
- var obj2 = new ContentType(type.toLowerCase());
140118
+ var obj3 = new ContentType(type.toLowerCase());
139662
140119
  if (index !== -1) {
139663
140120
  var key;
139664
140121
  var match;
@@ -139673,16 +140130,16 @@ var init_src_CeKsbNLO = __esm({
139673
140130
  value = value.slice(1, -1);
139674
140131
  if (value.indexOf("\\") !== -1) value = value.replace(QESC_REGEXP, "$1");
139675
140132
  }
139676
- obj2.parameters[key] = value;
140133
+ obj3.parameters[key] = value;
139677
140134
  }
139678
140135
  if (index !== header2.length) throw new TypeError("invalid parameter format");
139679
140136
  }
139680
- return obj2;
140137
+ return obj3;
139681
140138
  }
139682
- function getcontenttype(obj2) {
140139
+ function getcontenttype(obj3) {
139683
140140
  var header2;
139684
- if (typeof obj2.getHeader === "function") header2 = obj2.getHeader("content-type");
139685
- else if (typeof obj2.headers === "object") header2 = obj2.headers && obj2.headers["content-type"];
140141
+ if (typeof obj3.getHeader === "function") header2 = obj3.getHeader("content-type");
140142
+ else if (typeof obj3.headers === "object") header2 = obj3.headers && obj3.headers["content-type"];
139686
140143
  if (typeof header2 !== "string") throw new TypeError("content-type header is missing from object");
139687
140144
  return header2;
139688
140145
  }
@@ -140508,10 +140965,10 @@ var init_ajvProvider_BIwGVY6G = __esm({
140508
140965
  }
140509
140966
  return this._for(new ForIter("of", varKind, name2, iterable), () => forBody(name2));
140510
140967
  }
140511
- forIn(nameOrPrefix, obj2, forBody, varKind = this.opts.es5 ? scope_1.varKinds.var : scope_1.varKinds.const) {
140512
- if (this.opts.ownProperties) return this.forOf(nameOrPrefix, (0, code_1._)`Object.keys(${obj2})`, forBody);
140968
+ forIn(nameOrPrefix, obj3, forBody, varKind = this.opts.es5 ? scope_1.varKinds.var : scope_1.varKinds.const) {
140969
+ if (this.opts.ownProperties) return this.forOf(nameOrPrefix, (0, code_1._)`Object.keys(${obj3})`, forBody);
140513
140970
  const name2 = this._scope.toName(nameOrPrefix);
140514
- return this._for(new ForIter("in", varKind, name2, obj2), () => forBody(name2));
140971
+ return this._for(new ForIter("in", varKind, name2, obj3), () => forBody(name2));
140515
140972
  }
140516
140973
  endFor() {
140517
140974
  return this._endBlockNode(For);
@@ -142039,9 +142496,9 @@ var init_ajvProvider_BIwGVY6G = __esm({
142039
142496
  ok(cond) {
142040
142497
  if (!this.allErrors) this.gen.if(cond);
142041
142498
  }
142042
- setParams(obj2, assign2) {
142043
- if (assign2) Object.assign(this.params, obj2);
142044
- else this.params = obj2;
142499
+ setParams(obj3, assign2) {
142500
+ if (assign2) Object.assign(this.params, obj3);
142501
+ else this.params = obj3;
142045
142502
  }
142046
142503
  block$data(valid, codeBlock, $dataValid = codegen_1.nil) {
142047
142504
  this.gen.block(() => {
@@ -148213,12 +148670,12 @@ function serverInfoFromDiscover(discover2) {
148213
148670
  function applyElicitationDefaults(schema, data) {
148214
148671
  if (!schema || data === null || typeof data !== "object") return;
148215
148672
  if (schema.type === "object" && schema.properties && typeof schema.properties === "object") {
148216
- const obj2 = data;
148673
+ const obj3 = data;
148217
148674
  const props = schema.properties;
148218
148675
  for (const key of Object.keys(props)) {
148219
148676
  const propSchema = props[key];
148220
- if (obj2[key] === void 0 && Object.prototype.hasOwnProperty.call(propSchema, "default")) obj2[key] = propSchema.default;
148221
- if (obj2[key] !== void 0) applyElicitationDefaults(propSchema, obj2[key]);
148677
+ if (obj3[key] === void 0 && Object.prototype.hasOwnProperty.call(propSchema, "default")) obj3[key] = propSchema.default;
148678
+ if (obj3[key] !== void 0) applyElicitationDefaults(propSchema, obj3[key]);
148222
148679
  }
148223
148680
  }
148224
148681
  if (Array.isArray(schema.anyOf)) {
@@ -152188,37 +152645,6 @@ var init_config3 = __esm({
152188
152645
  }
152189
152646
  });
152190
152647
 
152191
- // src/auth/open-browser.ts
152192
- import { spawn as spawn9 } from "node:child_process";
152193
- function openBrowser(url2) {
152194
- try {
152195
- let cmd;
152196
- let args;
152197
- switch (process.platform) {
152198
- case "darwin":
152199
- cmd = "open";
152200
- args = [url2];
152201
- break;
152202
- case "win32":
152203
- cmd = "cmd";
152204
- args = ["/c", "start", "", url2];
152205
- break;
152206
- default:
152207
- cmd = "xdg-open";
152208
- args = [url2];
152209
- }
152210
- const child = spawn9(cmd, args, { detached: true, stdio: "ignore" });
152211
- child.on("error", () => {
152212
- });
152213
- child.unref();
152214
- } catch {
152215
- }
152216
- }
152217
- var init_open_browser = __esm({
152218
- "src/auth/open-browser.ts"() {
152219
- }
152220
- });
152221
-
152222
152648
  // src/commands/init.ts
152223
152649
  var init_exports = {};
152224
152650
  __export(init_exports, {
@@ -155175,7 +155601,7 @@ var init_local_discovery_envelope = __esm({
155175
155601
  function messageOf6(error2) {
155176
155602
  return error2 instanceof Error ? error2.message : String(error2);
155177
155603
  }
155178
- function isRecord10(value) {
155604
+ function isRecord11(value) {
155179
155605
  return typeof value === "object" && value !== null && !Array.isArray(value);
155180
155606
  }
155181
155607
  function isList(value) {
@@ -155189,7 +155615,7 @@ function jsonEqual2(a, b3) {
155189
155615
  if (Array.isArray(a)) {
155190
155616
  return Array.isArray(b3) && a.length === b3.length && a.every((item, index) => jsonEqual2(item, b3[index]));
155191
155617
  }
155192
- if (isRecord10(a) && isRecord10(b3)) {
155618
+ if (isRecord11(a) && isRecord11(b3)) {
155193
155619
  const keys = definedKeys(a);
155194
155620
  return keys.length === definedKeys(b3).length && keys.every((key) => Object.hasOwn(b3, key) && jsonEqual2(a[key], b3[key]));
155195
155621
  }
@@ -155201,7 +155627,7 @@ function utf8Length(text6) {
155201
155627
  function valueAt2(value, path2) {
155202
155628
  let current = value;
155203
155629
  for (const step of path2.split(".")) {
155204
- if (step.endsWith("[]") || !isRecord10(current) || !Object.hasOwn(current, step))
155630
+ if (step.endsWith("[]") || !isRecord11(current) || !Object.hasOwn(current, step))
155205
155631
  return void 0;
155206
155632
  current = current[step];
155207
155633
  }
@@ -155209,9 +155635,9 @@ function valueAt2(value, path2) {
155209
155635
  }
155210
155636
  function withValueAt(value, path2, replacement) {
155211
155637
  const [step, ...rest] = path2.split(".");
155212
- if (step === void 0 || !isRecord10(value)) return value;
155638
+ if (step === void 0 || !isRecord11(value)) return value;
155213
155639
  const inner = Object.hasOwn(value, step) ? value[step] : void 0;
155214
- if (rest.length > 0 && !isRecord10(inner)) return value;
155640
+ if (rest.length > 0 && !isRecord11(inner)) return value;
155215
155641
  const next = rest.length === 0 ? replacement : withValueAt(inner, rest.join("."), replacement);
155216
155642
  return { ...value, [step]: next };
155217
155643
  }
@@ -157131,9 +157557,9 @@ function toMessage(field, value) {
157131
157557
  function toU8Arr(value) {
157132
157558
  return Array.isArray(value) ? new Uint8Array(value) : value;
157133
157559
  }
157134
- function convertObjectValues(obj2, fn) {
157560
+ function convertObjectValues(obj3, fn) {
157135
157561
  const ret = {};
157136
- for (const entry2 of Object.entries(obj2)) {
157562
+ for (const entry2 of Object.entries(obj3)) {
157137
157563
  ret[entry2[0]] = fn(entry2[1]);
157138
157564
  }
157139
157565
  return ret;
@@ -162682,8 +163108,8 @@ var require_umd = __commonJS({
162682
163108
  Object.defineProperty(Long.prototype, "__isLong__", {
162683
163109
  value: true
162684
163110
  });
162685
- function isLong2(obj2) {
162686
- return (obj2 && obj2["__isLong__"]) === true;
163111
+ function isLong2(obj3) {
163112
+ return (obj3 && obj3["__isLong__"]) === true;
162687
163113
  }
162688
163114
  function ctz32(value) {
162689
163115
  var c = Math.clz32(value & -value);
@@ -162693,25 +163119,25 @@ var require_umd = __commonJS({
162693
163119
  var INT_CACHE = {};
162694
163120
  var UINT_CACHE = {};
162695
163121
  function fromInt(value, unsigned) {
162696
- var obj2, cachedObj, cache;
163122
+ var obj3, cachedObj, cache;
162697
163123
  if (unsigned) {
162698
163124
  value >>>= 0;
162699
163125
  if (cache = 0 <= value && value < 256) {
162700
163126
  cachedObj = UINT_CACHE[value];
162701
163127
  if (cachedObj) return cachedObj;
162702
163128
  }
162703
- obj2 = fromBits(value, 0, true);
162704
- if (cache) UINT_CACHE[value] = obj2;
162705
- return obj2;
163129
+ obj3 = fromBits(value, 0, true);
163130
+ if (cache) UINT_CACHE[value] = obj3;
163131
+ return obj3;
162706
163132
  } else {
162707
163133
  value |= 0;
162708
163134
  if (cache = -128 <= value && value < 128) {
162709
163135
  cachedObj = INT_CACHE[value];
162710
163136
  if (cachedObj) return cachedObj;
162711
163137
  }
162712
- obj2 = fromBits(value, value < 0 ? -1 : 0, false);
162713
- if (cache) INT_CACHE[value] = obj2;
162714
- return obj2;
163138
+ obj3 = fromBits(value, value < 0 ? -1 : 0, false);
163139
+ if (cache) INT_CACHE[value] = obj3;
163140
+ return obj3;
162715
163141
  }
162716
163142
  }
162717
163143
  Long.fromInt = fromInt;
@@ -163337,9 +163763,9 @@ var require_minimal = __commonJS({
163337
163763
  * @param {string} prop Property name
163338
163764
  * @returns {boolean} `true` if considered to be present, otherwise `false`
163339
163765
  */
163340
- util2.isSet = function isSet(obj2, prop) {
163341
- var value = obj2[prop];
163342
- if (value != null && Object.hasOwnProperty.call(obj2, prop))
163766
+ util2.isSet = function isSet(obj3, prop) {
163767
+ var value = obj3[prop];
163768
+ if (value != null && Object.hasOwnProperty.call(obj3, prop))
163343
163769
  return typeof value !== "object" || (Array.isArray(value) ? value.length : Object.keys(value).length) > 0;
163344
163770
  return false;
163345
163771
  };
@@ -163399,8 +163825,8 @@ var require_minimal = __commonJS({
163399
163825
  util2.merge = merge2;
163400
163826
  util2.nestingLimit = 32;
163401
163827
  util2.recursionLimit = 100;
163402
- util2.makeProp = function makeProp(obj2, key) {
163403
- Object.defineProperty(obj2, key, {
163828
+ util2.makeProp = function makeProp(obj3, key) {
163829
+ Object.defineProperty(obj3, key, {
163404
163830
  enumerable: true,
163405
163831
  configurable: true,
163406
163832
  writable: true
@@ -164348,10 +164774,10 @@ var require_namespace = __commonJS({
164348
164774
  function arrayToJSON(array2, toJSONOptions) {
164349
164775
  if (!(array2 && array2.length))
164350
164776
  return void 0;
164351
- var obj2 = {};
164777
+ var obj3 = {};
164352
164778
  for (var i2 = 0; i2 < array2.length; ++i2)
164353
- obj2[array2[i2].name] = array2[i2].toJSON(toJSONOptions);
164354
- return obj2;
164779
+ obj3[array2[i2].name] = array2[i2].toJSON(toJSONOptions);
164780
+ return obj3;
164355
164781
  }
164356
164782
  Namespace.arrayToJSON = arrayToJSON;
164357
164783
  Namespace.isReservedId = function isReservedId(reserved, id2) {
@@ -165485,8 +165911,8 @@ var require_type = __commonJS({
165485
165911
  "oneofs",
165486
165912
  Namespace.arrayToJSON(this.oneofsArray, toJSONOptions),
165487
165913
  "fields",
165488
- Namespace.arrayToJSON(this.fieldsArray.filter(function(obj2) {
165489
- return !obj2.declaringField;
165914
+ Namespace.arrayToJSON(this.fieldsArray.filter(function(obj3) {
165915
+ return !obj3.declaringField;
165490
165916
  }), toJSONOptions) || {},
165491
165917
  "extensions",
165492
165918
  this.extensions && this.extensions.length ? this.extensions : void 0,
@@ -167228,11 +167654,11 @@ var require_parse = __commonJS({
167228
167654
  return name2;
167229
167655
  } : util2.camelCase;
167230
167656
  function resolveFileFeatures() {
167231
- topLevelObjects.forEach((obj2) => {
167232
- obj2._edition = edition;
167657
+ topLevelObjects.forEach((obj3) => {
167658
+ obj3._edition = edition;
167233
167659
  Object.keys(topLevelOptions).forEach((opt) => {
167234
- if (obj2.getOption(opt) !== void 0) return;
167235
- obj2.setOption(opt, topLevelOptions[opt], true);
167660
+ if (obj3.getOption(opt) !== void 0) return;
167661
+ obj3.setOption(opt, topLevelOptions[opt], true);
167236
167662
  });
167237
167663
  });
167238
167664
  }
@@ -167433,13 +167859,13 @@ var require_parse = __commonJS({
167433
167859
  }
167434
167860
  return false;
167435
167861
  }
167436
- function ifBlock(obj2, fnIf, fnElse) {
167862
+ function ifBlock(obj3, fnIf, fnElse) {
167437
167863
  var trailingLine = tn.line;
167438
- if (obj2) {
167439
- if (typeof obj2.comment !== "string") {
167440
- obj2.comment = cmnt();
167864
+ if (obj3) {
167865
+ if (typeof obj3.comment !== "string") {
167866
+ obj3.comment = cmnt();
167441
167867
  }
167442
- obj2.filename = parse4.filename;
167868
+ obj3.filename = parse4.filename;
167443
167869
  }
167444
167870
  if (skip2("{", true)) {
167445
167871
  var token2;
@@ -167450,8 +167876,8 @@ var require_parse = __commonJS({
167450
167876
  if (fnElse)
167451
167877
  fnElse();
167452
167878
  skip2(";");
167453
- if (obj2 && (typeof obj2.comment !== "string" || preferTrailingComment))
167454
- obj2.comment = cmnt(trailingLine) || obj2.comment;
167879
+ if (obj3 && (typeof obj3.comment !== "string" || preferTrailingComment))
167880
+ obj3.comment = cmnt(trailingLine) || obj3.comment;
167455
167881
  }
167456
167882
  }
167457
167883
  function parseType(parent, token2, depth) {
@@ -171093,7 +171519,7 @@ var init_lock2 = __esm({
171093
171519
 
171094
171520
  // ../../packages/mcp-studio/src/compile/json-schema.ts
171095
171521
  function propertiesOf(schema) {
171096
- return isRecord10(schema.properties) ? schema.properties : {};
171522
+ return isRecord11(schema.properties) ? schema.properties : {};
171097
171523
  }
171098
171524
  function requiredOf(schema) {
171099
171525
  if (!Array.isArray(schema.required)) return [];
@@ -171254,7 +171680,7 @@ function shapeInput(key, entry2, upstream, supplied, issues) {
171254
171680
  for (const [name2, value] of defaults) {
171255
171681
  if (!usable("defaults", name2)) continue;
171256
171682
  const property = shaped[name2];
171257
- shaped[name2] = { ...isRecord10(property) ? property : {}, default: value };
171683
+ shaped[name2] = { ...isRecord11(property) ? property : {}, default: value };
171258
171684
  required2 = required2.filter((other) => other !== name2);
171259
171685
  }
171260
171686
  const renamed = /* @__PURE__ */ new Map();
@@ -171307,7 +171733,7 @@ function selectTree(paths) {
171307
171733
  return root;
171308
171734
  }
171309
171735
  function trimObject(schema, children) {
171310
- if (!isRecord10(schema.properties)) return schema;
171736
+ if (!isRecord11(schema.properties)) return schema;
171311
171737
  const properties = schema.properties;
171312
171738
  const kept = {};
171313
171739
  for (const [name2, node3] of children) {
@@ -171322,9 +171748,9 @@ function trimObject(schema, children) {
171322
171748
  return out;
171323
171749
  }
171324
171750
  function trimNode(schema, node3) {
171325
- if (node3.whole || !isRecord10(schema)) return schema;
171751
+ if (node3.whole || !isRecord11(schema)) return schema;
171326
171752
  if (!node3.array) return trimObject(schema, node3.children);
171327
- return isRecord10(schema.items) ? { ...schema, items: trimObject(schema.items, node3.children) } : schema;
171753
+ return isRecord11(schema.items) ? { ...schema, items: trimObject(schema.items, node3.children) } : schema;
171328
171754
  }
171329
171755
  function selectOutput(outputSchema, select) {
171330
171756
  if (select.length === 0) return outputSchema;
@@ -172133,17 +172559,17 @@ var init_server3 = __esm({
172133
172559
  function walkSchemas(root, at2, visit3) {
172134
172560
  const above = /* @__PURE__ */ new Set();
172135
172561
  const walk2 = (node3, path2, depth) => {
172136
- if (depth > MAX_DEPTH3) return;
172562
+ if (depth > MAX_DEPTH4) return;
172137
172563
  if (Array.isArray(node3)) {
172138
172564
  node3.forEach((item, index) => walk2(item, `${path2}[${index}]`, depth + 1));
172139
172565
  return;
172140
172566
  }
172141
- if (!isRecord10(node3) || above.has(node3)) return;
172567
+ if (!isRecord11(node3) || above.has(node3)) return;
172142
172568
  visit3(node3, path2);
172143
172569
  above.add(node3);
172144
172570
  for (const [key, value] of Object.entries(node3)) {
172145
172571
  if (DATA.has(key)) continue;
172146
- if (SCHEMA_MAPS.has(key) && isRecord10(value)) {
172572
+ if (SCHEMA_MAPS.has(key) && isRecord11(value)) {
172147
172573
  for (const [name2, child] of Object.entries(value))
172148
172574
  walk2(child, `${path2}.${key}.${name2}`, depth + 1);
172149
172575
  } else {
@@ -172155,7 +172581,7 @@ function walkSchemas(root, at2, visit3) {
172155
172581
  walk2(root, at2, 0);
172156
172582
  }
172157
172583
  function tagOf(schema) {
172158
- if (!isRecord10(schema)) return void 0;
172584
+ if (!isRecord11(schema)) return void 0;
172159
172585
  if (Object.hasOwn(schema, "const")) return JSON.stringify(schema.const);
172160
172586
  if (Array.isArray(schema.enum) && schema.enum.length === 1)
172161
172587
  return JSON.stringify(schema.enum[0]);
@@ -172163,7 +172589,7 @@ function tagOf(schema) {
172163
172589
  }
172164
172590
  function distinguishable(branches) {
172165
172591
  if (branches.length < 2) return true;
172166
- const records = branches.filter(isRecord10);
172592
+ const records = branches.filter(isRecord11);
172167
172593
  const [first] = records;
172168
172594
  if (first === void 0 || records.length < branches.length) return false;
172169
172595
  const types = records.map((branch) => branch.type);
@@ -172200,7 +172626,7 @@ function selectionDepth(selection) {
172200
172626
  }
172201
172627
  return deepest;
172202
172628
  }
172203
- var SCHEMA_MAPS, DATA, MAX_DEPTH3, SELECTION_TOKEN;
172629
+ var SCHEMA_MAPS, DATA, MAX_DEPTH4, SELECTION_TOKEN;
172204
172630
  var init_schema5 = __esm({
172205
172631
  "../../packages/mcp-studio/src/lint/schema.ts"() {
172206
172632
  "use strict";
@@ -172214,7 +172640,7 @@ var init_schema5 = __esm({
172214
172640
  "dependentSchemas"
172215
172641
  ]);
172216
172642
  DATA = /* @__PURE__ */ new Set(["enum", "const", "default", "examples", "example"]);
172217
- MAX_DEPTH3 = 64;
172643
+ MAX_DEPTH4 = 64;
172218
172644
  SELECTION_TOKEN = /"(?:[^"\\]|\\.)*"|\.\.\.|[_A-Za-z][_0-9A-Za-z]*|[{}()@]/g;
172219
172645
  }
172220
172646
  });
@@ -172273,11 +172699,11 @@ function quoted2(values) {
172273
172699
  return orList2(values.map((value) => JSON.stringify(value)));
172274
172700
  }
172275
172701
  function isArraySchema(schema) {
172276
- if (!isRecord10(schema)) return false;
172702
+ if (!isRecord11(schema)) return false;
172277
172703
  return schema.type === "array" || Array.isArray(schema.type) && schema.type.includes("array");
172278
172704
  }
172279
172705
  function hasDescription(schema) {
172280
- return isRecord10(schema) && typeof schema.description === "string" && schema.description.trim() !== "";
172706
+ return isRecord11(schema) && typeof schema.description === "string" && schema.description.trim() !== "";
172281
172707
  }
172282
172708
  function refTarget(root, ref) {
172283
172709
  if (ref === "#") return root;
@@ -172290,7 +172716,7 @@ function refTarget(root, ref) {
172290
172716
  } catch {
172291
172717
  return void 0;
172292
172718
  }
172293
- if (!isRecord10(node3) || !Object.hasOwn(node3, name2)) return void 0;
172719
+ if (!isRecord11(node3) || !Object.hasOwn(node3, name2)) return void 0;
172294
172720
  node3 = node3[name2];
172295
172721
  }
172296
172722
  return node3;
@@ -172299,7 +172725,7 @@ function isDescribed(schema, root) {
172299
172725
  const seen = /* @__PURE__ */ new Set();
172300
172726
  let node3 = schema;
172301
172727
  while (!hasDescription(node3)) {
172302
- const ref = isRecord10(node3) ? node3.$ref : void 0;
172728
+ const ref = isRecord11(node3) ? node3.$ref : void 0;
172303
172729
  if (typeof ref !== "string") return false;
172304
172730
  if (seen.has(ref)) return true;
172305
172731
  seen.add(ref);
@@ -172589,7 +173015,7 @@ function lintUpstream(folder, context, key, entry2, upstream, apply, report) {
172589
173015
  });
172590
173016
  }
172591
173017
  const oneOf4 = (node3, at2) => {
172592
- if (!Array.isArray(node3.oneOf) || isRecord10(node3.discriminator) || distinguishable(node3.oneOf))
173018
+ if (!Array.isArray(node3.oneOf) || isRecord11(node3.discriminator) || distinguishable(node3.oneOf))
172593
173019
  return;
172594
173020
  report("undiscriminated_one_of", {
172595
173021
  tool: key,
@@ -173440,7 +173866,7 @@ function upstreamError(response, bytes) {
173440
173866
  let problem2;
173441
173867
  if (text6 !== "" && isJsonMediaType(headerValue(response.headers, "content-type"))) {
173442
173868
  const parsed2 = parseJson4(text6);
173443
- if (parsed2.ok && isRecord10(parsed2.value)) problem2 = parsed2.value;
173869
+ if (parsed2.ok && isRecord11(parsed2.value)) problem2 = parsed2.value;
173444
173870
  }
173445
173871
  const title = problem2 === void 0 ? void 0 : firstText(problem2, ["title"]);
173446
173872
  const detail = problem2 === void 0 ? text6.trim() === "" ? void 0 : text6 : firstText(problem2, ["detail", "message", "error_description", "error"]);
@@ -173627,7 +174053,7 @@ function isModernVersion2(version3) {
173627
174053
  function modernRequest(message2, options) {
173628
174054
  const version3 = options.version ?? MCP_MODERN_PROTOCOL_VERSION2;
173629
174055
  const params = message2.params ?? {};
173630
- const meta3 = isRecord10(params._meta) ? params._meta : {};
174056
+ const meta3 = isRecord11(params._meta) ? params._meta : {};
173631
174057
  const body2 = {
173632
174058
  ...message2,
173633
174059
  params: {
@@ -173671,7 +174097,7 @@ function encodeHeaderValue(text6) {
173671
174097
  function valueAt4(root, path2) {
173672
174098
  let node3 = root;
173673
174099
  for (const key of path2) {
173674
- if (!isRecord10(node3) || !Object.hasOwn(node3, key)) return void 0;
174100
+ if (!isRecord11(node3) || !Object.hasOwn(node3, key)) return void 0;
173675
174101
  node3 = node3[key];
173676
174102
  }
173677
174103
  return node3;
@@ -173700,9 +174126,9 @@ function paramHeaderEntries(headers, args) {
173700
174126
  function rpcErrorIn(bytes) {
173701
174127
  if (bytes.byteLength === 0) return void 0;
173702
174128
  const parsed2 = parseJson4(decodeText2(bytes));
173703
- if (!parsed2.ok || !isRecord10(parsed2.value)) return void 0;
174129
+ if (!parsed2.ok || !isRecord11(parsed2.value)) return void 0;
173704
174130
  const error2 = parsed2.value.error;
173705
- if (!isRecord10(error2) || !Number.isInteger(error2.code)) return void 0;
174131
+ if (!isRecord11(error2) || !Number.isInteger(error2.code)) return void 0;
173706
174132
  return {
173707
174133
  code: error2.code,
173708
174134
  message: typeof error2.message === "string" ? error2.message : void 0,
@@ -173710,7 +174136,7 @@ function rpcErrorIn(bytes) {
173710
174136
  };
173711
174137
  }
173712
174138
  function supportedVersionsIn(data) {
173713
- if (!isRecord10(data) || !isList(data.supported)) return void 0;
174139
+ if (!isRecord11(data) || !isList(data.supported)) return void 0;
173714
174140
  const versions = data.supported.filter(
173715
174141
  (version3) => typeof version3 === "string"
173716
174142
  );
@@ -173751,20 +174177,20 @@ function inputRequiredOf(result2) {
173751
174177
  const state = result2.requestState;
173752
174178
  let input_requests;
173753
174179
  if (requests !== void 0) {
173754
- if (!isRecord10(requests))
174180
+ if (!isRecord11(requests))
173755
174181
  return {
173756
174182
  ok: false,
173757
174183
  detail: "The input_required result's inputRequests is not an object."
173758
174184
  };
173759
174185
  input_requests = {};
173760
174186
  for (const [key, request4] of Object.entries(requests)) {
173761
- if (!isRecord10(request4) || typeof request4.method !== "string")
174187
+ if (!isRecord11(request4) || typeof request4.method !== "string")
173762
174188
  return {
173763
174189
  ok: false,
173764
174190
  detail: `The input_required result's request ${JSON.stringify(key)} has no method.`
173765
174191
  };
173766
174192
  const entry2 = { method: request4.method };
173767
- if (isRecord10(request4.params)) entry2.params = request4.params;
174193
+ if (isRecord11(request4.params)) entry2.params = request4.params;
173768
174194
  input_requests[key] = entry2;
173769
174195
  }
173770
174196
  }
@@ -173821,13 +174247,13 @@ var init_mcp_modern = __esm({
173821
174247
 
173822
174248
  // ../../packages/mcp-studio/src/execute/mcp.ts
173823
174249
  function toolResult(value) {
173824
- if (!isRecord10(value))
174250
+ if (!isRecord11(value))
173825
174251
  return { ok: false, detail: "The tools/call result is not an object." };
173826
174252
  if (!isList(value.content))
173827
174253
  return { ok: false, detail: "The tools/call result has no content list." };
173828
174254
  const content = [];
173829
174255
  for (const [index, item] of value.content.entries()) {
173830
- if (!isRecord10(item) || typeof item.type !== "string") {
174256
+ if (!isRecord11(item) || typeof item.type !== "string") {
173831
174257
  return {
173832
174258
  ok: false,
173833
174259
  detail: `Content item ${index} is not an object with a string type.`
@@ -173838,7 +174264,7 @@ function toolResult(value) {
173838
174264
  const result2 = { content };
173839
174265
  const structured = value.structuredContent;
173840
174266
  if (structured !== void 0 && structured !== null) {
173841
- if (!isRecord10(structured))
174267
+ if (!isRecord11(structured))
173842
174268
  return {
173843
174269
  ok: false,
173844
174270
  detail: "The tools/call result's structuredContent is not an object."
@@ -173864,7 +174290,7 @@ function carriesJson2(content, value) {
173864
174290
  });
173865
174291
  }
173866
174292
  function modernToolResult(value) {
173867
- if (!isRecord10(value) || !Object.hasOwn(value, "structuredContent") || isRecord10(value.structuredContent))
174293
+ if (!isRecord11(value) || !Object.hasOwn(value, "structuredContent") || isRecord11(value.structuredContent))
173868
174294
  return toolResult(value);
173869
174295
  const { structuredContent: structured, ...rest } = value;
173870
174296
  const checked2 = toolResult(rest);
@@ -174014,7 +174440,7 @@ function rejectedAttempt(response, failure5) {
174014
174440
  function findResponse(value, id2) {
174015
174441
  const messages = isList(value) ? value : [value];
174016
174442
  for (const message2 of messages) {
174017
- if (isRecord10(message2) && message2.id === id2 && !Object.hasOwn(message2, "method"))
174443
+ if (isRecord11(message2) && message2.id === id2 && !Object.hasOwn(message2, "method"))
174018
174444
  return message2;
174019
174445
  }
174020
174446
  return void 0;
@@ -174087,8 +174513,8 @@ async function readReply(session, response, id2, what) {
174087
174513
  return { ok: true, value: message2 };
174088
174514
  }
174089
174515
  function rpcError2(error2) {
174090
- const message2 = isRecord10(error2) && typeof error2.message === "string" ? error2.message : JSON.stringify(error2);
174091
- const code = isRecord10(error2) && typeof error2.code === "number" ? ` (code ${error2.code})` : "";
174516
+ const message2 = isRecord11(error2) && typeof error2.message === "string" ? error2.message : JSON.stringify(error2);
174517
+ const code = isRecord11(error2) && typeof error2.code === "number" ? ` (code ${error2.code})` : "";
174092
174518
  return {
174093
174519
  title: "MCP error",
174094
174520
  detail: cutDetail(`${message2}${code}`),
@@ -174134,7 +174560,7 @@ async function initialize(session) {
174134
174560
  if (Object.hasOwn(reply3.value, "error"))
174135
174561
  return { ok: false, error: rpcError2(reply3.value.error) };
174136
174562
  const result2 = reply3.value.result;
174137
- if (!isRecord10(result2))
174563
+ if (!isRecord11(result2))
174138
174564
  return invalidResponse(
174139
174565
  "The MCP server's initialize result is not an object.",
174140
174566
  response.status
@@ -174280,8 +174706,8 @@ async function modernCall(session, version3) {
174280
174706
  }
174281
174707
  };
174282
174708
  const value = reply3.value.result;
174283
- const type = isRecord10(value) ? resultTypeOf(value) : "complete";
174284
- if (type === "input_required" && isRecord10(value)) {
174709
+ const type = isRecord11(value) ? resultTypeOf(value) : "complete";
174710
+ if (type === "input_required" && isRecord11(value)) {
174285
174711
  const input2 = inputRequiredOf(value);
174286
174712
  return {
174287
174713
  legacy: false,
@@ -174540,8 +174966,8 @@ function firstPosition(paging, args, options) {
174540
174966
  if (paging.style === "offset") return 0;
174541
174967
  const properties = options.inputSchema.properties;
174542
174968
  const name2 = options.agentName(paging.input);
174543
- const property = isRecord10(properties) && Object.hasOwn(properties, name2) ? properties[name2] : void 0;
174544
- if (isRecord10(property)) {
174969
+ const property = isRecord11(properties) && Object.hasOwn(properties, name2) ? properties[name2] : void 0;
174970
+ if (isRecord11(property)) {
174545
174971
  const fallback = wholeNumber2(property.default) ?? wholeNumber2(property.minimum);
174546
174972
  if (fallback !== void 0) return fallback;
174547
174973
  }
@@ -174724,7 +175150,7 @@ function graphqlDocument(template, args) {
174724
175150
  }
174725
175151
  function errorMessages(errors) {
174726
175152
  return errors.map(
174727
- (entry2) => isRecord10(entry2) && typeof entry2.message === "string" ? entry2.message : JSON.stringify(entry2)
175153
+ (entry2) => isRecord11(entry2) && typeof entry2.message === "string" ? entry2.message : JSON.stringify(entry2)
174728
175154
  ).join("; ");
174729
175155
  }
174730
175156
  function invalidResponse2(detail, status2) {
@@ -174736,7 +175162,7 @@ function interpret(template) {
174736
175162
  const status2 = response.status;
174737
175163
  const parsed2 = bytes.byteLength === 0 ? void 0 : parseJson4(decodeText2(bytes));
174738
175164
  const body2 = parsed2?.ok === true ? parsed2.value : void 0;
174739
- if (isRecord10(body2) && isList(body2.errors) && body2.errors.length > 0) {
175165
+ if (isRecord11(body2) && isList(body2.errors) && body2.errors.length > 0) {
174740
175166
  return {
174741
175167
  ok: false,
174742
175168
  error: {
@@ -174758,8 +175184,8 @@ function interpret(template) {
174758
175184
  `The upstream answered ${status2} with JSON that does not parse: ${parsed2.message}`,
174759
175185
  status2
174760
175186
  );
174761
- const data = isRecord10(body2) ? body2.data : void 0;
174762
- if (!isRecord10(data))
175187
+ const data = isRecord11(body2) ? body2.data : void 0;
175188
+ if (!isRecord11(data))
174763
175189
  return invalidResponse2(
174764
175190
  `The upstream answered ${status2} with no data object.`,
174765
175191
  status2
@@ -175432,7 +175858,7 @@ function exchangesFor(call2, ending) {
175432
175858
  ];
175433
175859
  }
175434
175860
  function isJsonObject2(value) {
175435
- return isRecord10(value);
175861
+ return isRecord11(value);
175436
175862
  }
175437
175863
  var DEFAULT_MAX_STREAM_BYTES, RETRIED_LEVELS, CANCELLED2, grpcSender, TRANSPORT_TITLES2;
175438
175864
  var init_sender = __esm({
@@ -175496,7 +175922,7 @@ function scalarText(value, name2) {
175496
175922
  function shapeOf(value, name2) {
175497
175923
  if (isList(value))
175498
175924
  return { kind: "list", items: value.map((item) => scalarText(item, name2)) };
175499
- if (isRecord10(value)) {
175925
+ if (isRecord11(value)) {
175500
175926
  return {
175501
175927
  kind: "object",
175502
175928
  entries: Object.entries(value).filter(([, item]) => item !== void 0).map(([key, item]) => [key, scalarText(item, name2)])
@@ -175689,7 +176115,7 @@ function formText(value) {
175689
176115
  throw invalidArguments(`A form body cannot carry a ${typeof value} value.`);
175690
176116
  }
175691
176117
  function formBody(value) {
175692
- if (!isRecord10(value)) throw invalidArguments("A form body takes an object.");
176118
+ if (!isRecord11(value)) throw invalidArguments("A form body takes an object.");
175693
176119
  const form = new URLSearchParams();
175694
176120
  for (const [key, item] of Object.entries(value)) {
175695
176121
  const items = (isList(item) ? item : [item]).filter(
@@ -175957,7 +176383,7 @@ function project(value, at2) {
175957
176383
  const each = at2.each;
175958
176384
  return value.map((item) => project(item, each)).filter((item) => item !== ABSENT);
175959
176385
  }
175960
- if (isRecord10(value) && at2.fields.size > 0) {
176386
+ if (isRecord11(value) && at2.fields.size > 0) {
175961
176387
  const kept = [];
175962
176388
  for (const [name2, child] of at2.fields) {
175963
176389
  if (!Object.hasOwn(value, name2)) continue;
@@ -175974,7 +176400,7 @@ function remove(value, at2) {
175974
176400
  const each = at2.each;
175975
176401
  return value.map((item) => remove(item, each)).filter((item) => item !== ABSENT);
175976
176402
  }
175977
- if (isRecord10(value) && at2.fields.size > 0) {
176403
+ if (isRecord11(value) && at2.fields.size > 0) {
175978
176404
  const kept = [];
175979
176405
  for (const [name2, item] of Object.entries(value)) {
175980
176406
  const child = at2.fields.get(name2);
@@ -176010,14 +176436,14 @@ function shapeRecord(value, rules, isError) {
176010
176436
  let out = value;
176011
176437
  if (rules.select !== void 0 && !isError) out = project(out, rules.select);
176012
176438
  if (rules.redact !== void 0) out = remove(out, rules.redact);
176013
- return isRecord10(out) ? out : {};
176439
+ return isRecord11(out) ? out : {};
176014
176440
  }
176015
176441
  function redactReachesList(redact) {
176016
176442
  const items = redact.fields.get(LIST_FIELD);
176017
176443
  return items !== void 0 && (items.end || items.each !== void 0);
176018
176444
  }
176019
176445
  function shapeAny(value, rules) {
176020
- if (isRecord10(value)) return shapeRecord(value, rules, false);
176446
+ if (isRecord11(value)) return shapeRecord(value, rules, false);
176021
176447
  if (!isList(value)) return value;
176022
176448
  if (rules.redact !== void 0 && !redactReachesList(rules.redact))
176023
176449
  return WITHHELD;
@@ -176050,12 +176476,12 @@ function resultBytes(content, structured) {
176050
176476
  }
176051
176477
  function jsonResult(value, text6) {
176052
176478
  const result2 = { content: [textItem(text6)] };
176053
- if (isRecord10(value)) result2.structuredContent = value;
176479
+ if (isRecord11(value)) result2.structuredContent = value;
176054
176480
  return result2;
176055
176481
  }
176056
176482
  function jsonResultBytes(value, text6) {
176057
176483
  const bytes = utf8Length(text6);
176058
- return isRecord10(value) ? 2 * bytes : bytes;
176484
+ return isRecord11(value) ? 2 * bytes : bytes;
176059
176485
  }
176060
176486
  function cutList(value, rules) {
176061
176487
  const list2 = valueAt2(value, rules.list);
@@ -176120,7 +176546,7 @@ function shapeText(text6, rules, isError, structured) {
176120
176546
  if (typeof text6 !== "string") return void 0;
176121
176547
  const parsed2 = parseJson4(text6);
176122
176548
  if (!parsed2.ok) return void 0;
176123
- if (isRecord10(parsed2.value))
176549
+ if (isRecord11(parsed2.value))
176124
176550
  return JSON.stringify(shapeRecord(parsed2.value, rules, isError));
176125
176551
  if (!isList(parsed2.value) || rules.redact === void 0) return void 0;
176126
176552
  if (redactReachesList(rules.redact)) {
@@ -176134,7 +176560,7 @@ function shapeItem(item, rules, isError, structured) {
176134
176560
  const text6 = shapeText(item.text, rules, isError, structured);
176135
176561
  return text6 === void 0 ? item : { ...item, text: text6 };
176136
176562
  }
176137
- if (item.type === "resource" && isRecord10(item.resource)) {
176563
+ if (item.type === "resource" && isRecord11(item.resource)) {
176138
176564
  const text6 = shapeText(item.resource.text, rules, isError, structured);
176139
176565
  return text6 === void 0 ? item : { ...item, resource: { ...item.resource, text: text6 } };
176140
176566
  }
@@ -176252,7 +176678,7 @@ function hasType(type, value) {
176252
176678
  case "boolean":
176253
176679
  return typeof value === "boolean";
176254
176680
  case "object":
176255
- return isRecord10(value);
176681
+ return isRecord11(value);
176256
176682
  case "array":
176257
176683
  return isList(value);
176258
176684
  default:
@@ -176328,7 +176754,7 @@ function resolveRef(root, ref) {
176328
176754
  if (!Number.isInteger(index) || index < 0 || index >= current.length)
176329
176755
  return void 0;
176330
176756
  current = current[index];
176331
- } else if (isRecord10(current) && Object.hasOwn(current, token)) {
176757
+ } else if (isRecord11(current) && Object.hasOwn(current, token)) {
176332
176758
  current = current[token];
176333
176759
  } else {
176334
176760
  return void 0;
@@ -176338,7 +176764,7 @@ function resolveRef(root, ref) {
176338
176764
  }
176339
176765
  function canonical2(value) {
176340
176766
  if (isList(value)) return `[${value.map(canonical2).join(",")}]`;
176341
- if (isRecord10(value)) {
176767
+ if (isRecord11(value)) {
176342
176768
  const keys = Object.keys(value).sort();
176343
176769
  return `{${keys.map((key) => `${JSON.stringify(key)}:${canonical2(value[key])}`).join(",")}}`;
176344
176770
  }
@@ -176355,12 +176781,12 @@ function listOf3(values) {
176355
176781
  function plural8(count15, one, many = `${one}s`) {
176356
176782
  return count15 === 1 ? one : many;
176357
176783
  }
176358
- var MAX_DEPTH4, MAX_STEPS, MAX_ISSUES, REJECTED_INPUT_MAX, ROOT, PATTERNS, PATH_STEP, SURROGATE, TYPE_NAMES, Checker;
176784
+ var MAX_DEPTH5, MAX_STEPS, MAX_ISSUES, REJECTED_INPUT_MAX, ROOT, PATTERNS, PATH_STEP, SURROGATE, TYPE_NAMES, Checker;
176359
176785
  var init_validate = __esm({
176360
176786
  "../../packages/mcp-studio/src/execute/validate.ts"() {
176361
176787
  "use strict";
176362
176788
  init_util5();
176363
- MAX_DEPTH4 = 64;
176789
+ MAX_DEPTH5 = 64;
176364
176790
  MAX_STEPS = 1e5;
176365
176791
  MAX_ISSUES = 10;
176366
176792
  REJECTED_INPUT_MAX = 200;
@@ -176414,12 +176840,12 @@ var init_validate = __esm({
176414
176840
  }
176415
176841
  check(schema, value, path2, depth) {
176416
176842
  this.steps += 1;
176417
- if (depth > MAX_DEPTH4 || this.steps > MAX_STEPS) {
176843
+ if (depth > MAX_DEPTH5 || this.steps > MAX_STEPS) {
176418
176844
  this.gaveUp = true;
176419
176845
  return [];
176420
176846
  }
176421
176847
  if (schema === false) return [{ path: path2, message: `${path2} is not allowed.` }];
176422
- if (!isRecord10(schema)) return [];
176848
+ if (!isRecord11(schema)) return [];
176423
176849
  if (value === null && schema.nullable === true) return [];
176424
176850
  const issues = [];
176425
176851
  if (typeof schema.$ref === "string") {
@@ -176447,7 +176873,7 @@ var init_validate = __esm({
176447
176873
  issues.push(...checkNumber2(schema, value, path2));
176448
176874
  else if (isList(value))
176449
176875
  issues.push(...this.checkArray(schema, value, path2, depth));
176450
- else if (isRecord10(value))
176876
+ else if (isRecord11(value))
176451
176877
  issues.push(...this.checkObject(schema, value, path2, depth));
176452
176878
  issues.push(...this.checkCombinators(schema, value, path2, depth));
176453
176879
  return issues;
@@ -176573,8 +176999,8 @@ var init_validate = __esm({
176573
176999
  message: `${path2} must have at most ${schema.maxProperties} ${plural8(schema.maxProperties, "property", "properties")}.`
176574
177000
  });
176575
177001
  }
176576
- const properties = isRecord10(schema.properties) ? schema.properties : {};
176577
- const patterns = isRecord10(schema.patternProperties) ? Object.entries(schema.patternProperties) : [];
177002
+ const properties = isRecord11(schema.properties) ? schema.properties : {};
177003
+ const patterns = isRecord11(schema.patternProperties) ? Object.entries(schema.patternProperties) : [];
176578
177004
  for (const key of present) {
176579
177005
  const at2 = propertyPath(path2, key);
176580
177006
  let known = false;
@@ -177667,8 +178093,8 @@ var require_channel_credentials = __commonJS({
177667
178093
  var resolver_1 = require_resolver();
177668
178094
  var logging_1 = require_logging();
177669
178095
  var constants_1 = require_constants();
177670
- function verifyIsBufferOrNull(obj2, friendlyName) {
177671
- if (obj2 && !(obj2 instanceof Buffer)) {
178096
+ function verifyIsBufferOrNull(obj3, friendlyName) {
178097
+ if (obj3 && !(obj3 instanceof Buffer)) {
177672
178098
  throw new TypeError(`${friendlyName}, if provided, must be a Buffer.`);
177673
178099
  }
177674
178100
  }
@@ -178152,51 +178578,51 @@ var require_service_config = __commonJS({
178152
178578
  var constants_1 = require_constants();
178153
178579
  var DURATION_REGEX = /^\d+(\.\d{1,9})?s$/;
178154
178580
  var CLIENT_LANGUAGE_STRING = "node";
178155
- function validateName(obj2) {
178156
- if ("service" in obj2 && obj2.service !== "") {
178157
- if (typeof obj2.service !== "string") {
178158
- throw new Error(`Invalid method config name: invalid service: expected type string, got ${typeof obj2.service}`);
178581
+ function validateName(obj3) {
178582
+ if ("service" in obj3 && obj3.service !== "") {
178583
+ if (typeof obj3.service !== "string") {
178584
+ throw new Error(`Invalid method config name: invalid service: expected type string, got ${typeof obj3.service}`);
178159
178585
  }
178160
- if ("method" in obj2 && obj2.method !== "") {
178161
- if (typeof obj2.method !== "string") {
178162
- throw new Error(`Invalid method config name: invalid method: expected type string, got ${typeof obj2.service}`);
178586
+ if ("method" in obj3 && obj3.method !== "") {
178587
+ if (typeof obj3.method !== "string") {
178588
+ throw new Error(`Invalid method config name: invalid method: expected type string, got ${typeof obj3.service}`);
178163
178589
  }
178164
178590
  return {
178165
- service: obj2.service,
178166
- method: obj2.method
178591
+ service: obj3.service,
178592
+ method: obj3.method
178167
178593
  };
178168
178594
  } else {
178169
178595
  return {
178170
- service: obj2.service
178596
+ service: obj3.service
178171
178597
  };
178172
178598
  }
178173
178599
  } else {
178174
- if ("method" in obj2 && obj2.method !== void 0) {
178600
+ if ("method" in obj3 && obj3.method !== void 0) {
178175
178601
  throw new Error(`Invalid method config name: method set with empty or unset service`);
178176
178602
  }
178177
178603
  return {};
178178
178604
  }
178179
178605
  }
178180
- function validateRetryPolicy(obj2) {
178181
- if (!("maxAttempts" in obj2) || !Number.isInteger(obj2.maxAttempts) || obj2.maxAttempts < 2) {
178606
+ function validateRetryPolicy(obj3) {
178607
+ if (!("maxAttempts" in obj3) || !Number.isInteger(obj3.maxAttempts) || obj3.maxAttempts < 2) {
178182
178608
  throw new Error("Invalid method config retry policy: maxAttempts must be an integer at least 2");
178183
178609
  }
178184
- if (!("initialBackoff" in obj2) || typeof obj2.initialBackoff !== "string" || !DURATION_REGEX.test(obj2.initialBackoff)) {
178610
+ if (!("initialBackoff" in obj3) || typeof obj3.initialBackoff !== "string" || !DURATION_REGEX.test(obj3.initialBackoff)) {
178185
178611
  throw new Error("Invalid method config retry policy: initialBackoff must be a string consisting of a positive integer or decimal followed by s");
178186
178612
  }
178187
- if (!("maxBackoff" in obj2) || typeof obj2.maxBackoff !== "string" || !DURATION_REGEX.test(obj2.maxBackoff)) {
178613
+ if (!("maxBackoff" in obj3) || typeof obj3.maxBackoff !== "string" || !DURATION_REGEX.test(obj3.maxBackoff)) {
178188
178614
  throw new Error("Invalid method config retry policy: maxBackoff must be a string consisting of a positive integer or decimal followed by s");
178189
178615
  }
178190
- if (!("backoffMultiplier" in obj2) || typeof obj2.backoffMultiplier !== "number" || obj2.backoffMultiplier <= 0) {
178616
+ if (!("backoffMultiplier" in obj3) || typeof obj3.backoffMultiplier !== "number" || obj3.backoffMultiplier <= 0) {
178191
178617
  throw new Error("Invalid method config retry policy: backoffMultiplier must be a number greater than 0");
178192
178618
  }
178193
- if (!("retryableStatusCodes" in obj2 && Array.isArray(obj2.retryableStatusCodes))) {
178619
+ if (!("retryableStatusCodes" in obj3 && Array.isArray(obj3.retryableStatusCodes))) {
178194
178620
  throw new Error("Invalid method config retry policy: retryableStatusCodes is required");
178195
178621
  }
178196
- if (obj2.retryableStatusCodes.length === 0) {
178622
+ if (obj3.retryableStatusCodes.length === 0) {
178197
178623
  throw new Error("Invalid method config retry policy: retryableStatusCodes must be non-empty");
178198
178624
  }
178199
- for (const value of obj2.retryableStatusCodes) {
178625
+ for (const value of obj3.retryableStatusCodes) {
178200
178626
  if (typeof value === "number") {
178201
178627
  if (!Object.values(constants_1.Status).includes(value)) {
178202
178628
  throw new Error("Invalid method config retry policy: retryableStatusCodes value not in status code range");
@@ -178210,22 +178636,22 @@ var require_service_config = __commonJS({
178210
178636
  }
178211
178637
  }
178212
178638
  return {
178213
- maxAttempts: obj2.maxAttempts,
178214
- initialBackoff: obj2.initialBackoff,
178215
- maxBackoff: obj2.maxBackoff,
178216
- backoffMultiplier: obj2.backoffMultiplier,
178217
- retryableStatusCodes: obj2.retryableStatusCodes
178639
+ maxAttempts: obj3.maxAttempts,
178640
+ initialBackoff: obj3.initialBackoff,
178641
+ maxBackoff: obj3.maxBackoff,
178642
+ backoffMultiplier: obj3.backoffMultiplier,
178643
+ retryableStatusCodes: obj3.retryableStatusCodes
178218
178644
  };
178219
178645
  }
178220
- function validateHedgingPolicy(obj2) {
178221
- if (!("maxAttempts" in obj2) || !Number.isInteger(obj2.maxAttempts) || obj2.maxAttempts < 2) {
178646
+ function validateHedgingPolicy(obj3) {
178647
+ if (!("maxAttempts" in obj3) || !Number.isInteger(obj3.maxAttempts) || obj3.maxAttempts < 2) {
178222
178648
  throw new Error("Invalid method config hedging policy: maxAttempts must be an integer at least 2");
178223
178649
  }
178224
- if ("hedgingDelay" in obj2 && (typeof obj2.hedgingDelay !== "string" || !DURATION_REGEX.test(obj2.hedgingDelay))) {
178650
+ if ("hedgingDelay" in obj3 && (typeof obj3.hedgingDelay !== "string" || !DURATION_REGEX.test(obj3.hedgingDelay))) {
178225
178651
  throw new Error("Invalid method config hedging policy: hedgingDelay must be a string consisting of a positive integer followed by s");
178226
178652
  }
178227
- if ("nonFatalStatusCodes" in obj2 && Array.isArray(obj2.nonFatalStatusCodes)) {
178228
- for (const value of obj2.nonFatalStatusCodes) {
178653
+ if ("nonFatalStatusCodes" in obj3 && Array.isArray(obj3.nonFatalStatusCodes)) {
178654
+ for (const value of obj3.nonFatalStatusCodes) {
178229
178655
  if (typeof value === "number") {
178230
178656
  if (!Object.values(constants_1.Status).includes(value)) {
178231
178657
  throw new Error("Invalid method config hedging policy: nonFatalStatusCodes value not in status code range");
@@ -178240,44 +178666,44 @@ var require_service_config = __commonJS({
178240
178666
  }
178241
178667
  }
178242
178668
  const result2 = {
178243
- maxAttempts: obj2.maxAttempts
178669
+ maxAttempts: obj3.maxAttempts
178244
178670
  };
178245
- if (obj2.hedgingDelay) {
178246
- result2.hedgingDelay = obj2.hedgingDelay;
178671
+ if (obj3.hedgingDelay) {
178672
+ result2.hedgingDelay = obj3.hedgingDelay;
178247
178673
  }
178248
- if (obj2.nonFatalStatusCodes) {
178249
- result2.nonFatalStatusCodes = obj2.nonFatalStatusCodes;
178674
+ if (obj3.nonFatalStatusCodes) {
178675
+ result2.nonFatalStatusCodes = obj3.nonFatalStatusCodes;
178250
178676
  }
178251
178677
  return result2;
178252
178678
  }
178253
- function validateMethodConfig(obj2) {
178679
+ function validateMethodConfig(obj3) {
178254
178680
  var _a4;
178255
178681
  const result2 = {
178256
178682
  name: []
178257
178683
  };
178258
- if (!("name" in obj2) || !Array.isArray(obj2.name)) {
178684
+ if (!("name" in obj3) || !Array.isArray(obj3.name)) {
178259
178685
  throw new Error("Invalid method config: invalid name array");
178260
178686
  }
178261
- for (const name2 of obj2.name) {
178687
+ for (const name2 of obj3.name) {
178262
178688
  result2.name.push(validateName(name2));
178263
178689
  }
178264
- if ("waitForReady" in obj2) {
178265
- if (typeof obj2.waitForReady !== "boolean") {
178690
+ if ("waitForReady" in obj3) {
178691
+ if (typeof obj3.waitForReady !== "boolean") {
178266
178692
  throw new Error("Invalid method config: invalid waitForReady");
178267
178693
  }
178268
- result2.waitForReady = obj2.waitForReady;
178694
+ result2.waitForReady = obj3.waitForReady;
178269
178695
  }
178270
- if ("timeout" in obj2) {
178271
- if (typeof obj2.timeout === "object") {
178272
- if (!("seconds" in obj2.timeout) || !(typeof obj2.timeout.seconds === "number")) {
178696
+ if ("timeout" in obj3) {
178697
+ if (typeof obj3.timeout === "object") {
178698
+ if (!("seconds" in obj3.timeout) || !(typeof obj3.timeout.seconds === "number")) {
178273
178699
  throw new Error("Invalid method config: invalid timeout.seconds");
178274
178700
  }
178275
- if (!("nanos" in obj2.timeout) || !(typeof obj2.timeout.nanos === "number")) {
178701
+ if (!("nanos" in obj3.timeout) || !(typeof obj3.timeout.nanos === "number")) {
178276
178702
  throw new Error("Invalid method config: invalid timeout.nanos");
178277
178703
  }
178278
- result2.timeout = obj2.timeout;
178279
- } else if (typeof obj2.timeout === "string" && DURATION_REGEX.test(obj2.timeout)) {
178280
- const timeoutParts = obj2.timeout.substring(0, obj2.timeout.length - 1).split(".");
178704
+ result2.timeout = obj3.timeout;
178705
+ } else if (typeof obj3.timeout === "string" && DURATION_REGEX.test(obj3.timeout)) {
178706
+ const timeoutParts = obj3.timeout.substring(0, obj3.timeout.length - 1).split(".");
178281
178707
  result2.timeout = {
178282
178708
  seconds: timeoutParts[0] | 0,
178283
178709
  nanos: ((_a4 = timeoutParts[1]) !== null && _a4 !== void 0 ? _a4 : 0) | 0
@@ -178286,46 +178712,46 @@ var require_service_config = __commonJS({
178286
178712
  throw new Error("Invalid method config: invalid timeout");
178287
178713
  }
178288
178714
  }
178289
- if ("maxRequestBytes" in obj2) {
178290
- if (typeof obj2.maxRequestBytes !== "number") {
178715
+ if ("maxRequestBytes" in obj3) {
178716
+ if (typeof obj3.maxRequestBytes !== "number") {
178291
178717
  throw new Error("Invalid method config: invalid maxRequestBytes");
178292
178718
  }
178293
- result2.maxRequestBytes = obj2.maxRequestBytes;
178719
+ result2.maxRequestBytes = obj3.maxRequestBytes;
178294
178720
  }
178295
- if ("maxResponseBytes" in obj2) {
178296
- if (typeof obj2.maxResponseBytes !== "number") {
178721
+ if ("maxResponseBytes" in obj3) {
178722
+ if (typeof obj3.maxResponseBytes !== "number") {
178297
178723
  throw new Error("Invalid method config: invalid maxRequestBytes");
178298
178724
  }
178299
- result2.maxResponseBytes = obj2.maxResponseBytes;
178725
+ result2.maxResponseBytes = obj3.maxResponseBytes;
178300
178726
  }
178301
- if ("retryPolicy" in obj2) {
178302
- if ("hedgingPolicy" in obj2) {
178727
+ if ("retryPolicy" in obj3) {
178728
+ if ("hedgingPolicy" in obj3) {
178303
178729
  throw new Error("Invalid method config: retryPolicy and hedgingPolicy cannot both be specified");
178304
178730
  } else {
178305
- result2.retryPolicy = validateRetryPolicy(obj2.retryPolicy);
178731
+ result2.retryPolicy = validateRetryPolicy(obj3.retryPolicy);
178306
178732
  }
178307
- } else if ("hedgingPolicy" in obj2) {
178308
- result2.hedgingPolicy = validateHedgingPolicy(obj2.hedgingPolicy);
178733
+ } else if ("hedgingPolicy" in obj3) {
178734
+ result2.hedgingPolicy = validateHedgingPolicy(obj3.hedgingPolicy);
178309
178735
  }
178310
178736
  return result2;
178311
178737
  }
178312
- function validateRetryThrottling(obj2) {
178313
- if (!("maxTokens" in obj2) || typeof obj2.maxTokens !== "number" || obj2.maxTokens <= 0 || obj2.maxTokens > 1e3) {
178738
+ function validateRetryThrottling(obj3) {
178739
+ if (!("maxTokens" in obj3) || typeof obj3.maxTokens !== "number" || obj3.maxTokens <= 0 || obj3.maxTokens > 1e3) {
178314
178740
  throw new Error("Invalid retryThrottling: maxTokens must be a number in (0, 1000]");
178315
178741
  }
178316
- if (!("tokenRatio" in obj2) || typeof obj2.tokenRatio !== "number" || obj2.tokenRatio <= 0) {
178742
+ if (!("tokenRatio" in obj3) || typeof obj3.tokenRatio !== "number" || obj3.tokenRatio <= 0) {
178317
178743
  throw new Error("Invalid retryThrottling: tokenRatio must be a number greater than 0");
178318
178744
  }
178319
178745
  return {
178320
- maxTokens: +obj2.maxTokens.toFixed(3),
178321
- tokenRatio: +obj2.tokenRatio.toFixed(3)
178746
+ maxTokens: +obj3.maxTokens.toFixed(3),
178747
+ tokenRatio: +obj3.tokenRatio.toFixed(3)
178322
178748
  };
178323
178749
  }
178324
- function validateLoadBalancingConfig(obj2) {
178325
- if (!(typeof obj2 === "object" && obj2 !== null)) {
178326
- throw new Error(`Invalid loadBalancingConfig: unexpected type ${typeof obj2}`);
178750
+ function validateLoadBalancingConfig(obj3) {
178751
+ if (!(typeof obj3 === "object" && obj3 !== null)) {
178752
+ throw new Error(`Invalid loadBalancingConfig: unexpected type ${typeof obj3}`);
178327
178753
  }
178328
- const keys = Object.keys(obj2);
178754
+ const keys = Object.keys(obj3);
178329
178755
  if (keys.length > 1) {
178330
178756
  throw new Error(`Invalid loadBalancingConfig: unexpected multiple keys ${keys}`);
178331
178757
  }
@@ -178333,39 +178759,39 @@ var require_service_config = __commonJS({
178333
178759
  throw new Error("Invalid loadBalancingConfig: load balancing policy name required");
178334
178760
  }
178335
178761
  return {
178336
- [keys[0]]: obj2[keys[0]]
178762
+ [keys[0]]: obj3[keys[0]]
178337
178763
  };
178338
178764
  }
178339
- function validateServiceConfig(obj2) {
178765
+ function validateServiceConfig(obj3) {
178340
178766
  const result2 = {
178341
178767
  loadBalancingConfig: [],
178342
178768
  methodConfig: []
178343
178769
  };
178344
- if ("loadBalancingPolicy" in obj2) {
178345
- if (typeof obj2.loadBalancingPolicy === "string") {
178346
- result2.loadBalancingPolicy = obj2.loadBalancingPolicy;
178770
+ if ("loadBalancingPolicy" in obj3) {
178771
+ if (typeof obj3.loadBalancingPolicy === "string") {
178772
+ result2.loadBalancingPolicy = obj3.loadBalancingPolicy;
178347
178773
  } else {
178348
178774
  throw new Error("Invalid service config: invalid loadBalancingPolicy");
178349
178775
  }
178350
178776
  }
178351
- if ("loadBalancingConfig" in obj2) {
178352
- if (Array.isArray(obj2.loadBalancingConfig)) {
178353
- for (const config2 of obj2.loadBalancingConfig) {
178777
+ if ("loadBalancingConfig" in obj3) {
178778
+ if (Array.isArray(obj3.loadBalancingConfig)) {
178779
+ for (const config2 of obj3.loadBalancingConfig) {
178354
178780
  result2.loadBalancingConfig.push(validateLoadBalancingConfig(config2));
178355
178781
  }
178356
178782
  } else {
178357
178783
  throw new Error("Invalid service config: invalid loadBalancingConfig");
178358
178784
  }
178359
178785
  }
178360
- if ("methodConfig" in obj2) {
178361
- if (Array.isArray(obj2.methodConfig)) {
178362
- for (const methodConfig of obj2.methodConfig) {
178786
+ if ("methodConfig" in obj3) {
178787
+ if (Array.isArray(obj3.methodConfig)) {
178788
+ for (const methodConfig of obj3.methodConfig) {
178363
178789
  result2.methodConfig.push(validateMethodConfig(methodConfig));
178364
178790
  }
178365
178791
  }
178366
178792
  }
178367
- if ("retryThrottling" in obj2) {
178368
- result2.retryThrottling = validateRetryThrottling(obj2.retryThrottling);
178793
+ if ("retryThrottling" in obj3) {
178794
+ result2.retryThrottling = validateRetryThrottling(obj3.retryThrottling);
178369
178795
  }
178370
178796
  const seenMethodNames = [];
178371
178797
  for (const methodConfig of result2.methodConfig) {
@@ -178380,17 +178806,17 @@ var require_service_config = __commonJS({
178380
178806
  }
178381
178807
  return result2;
178382
178808
  }
178383
- function validateCanaryConfig(obj2) {
178384
- if (!("serviceConfig" in obj2)) {
178809
+ function validateCanaryConfig(obj3) {
178810
+ if (!("serviceConfig" in obj3)) {
178385
178811
  throw new Error("Invalid service config choice: missing service config");
178386
178812
  }
178387
178813
  const result2 = {
178388
- serviceConfig: validateServiceConfig(obj2.serviceConfig)
178814
+ serviceConfig: validateServiceConfig(obj3.serviceConfig)
178389
178815
  };
178390
- if ("clientLanguage" in obj2) {
178391
- if (Array.isArray(obj2.clientLanguage)) {
178816
+ if ("clientLanguage" in obj3) {
178817
+ if (Array.isArray(obj3.clientLanguage)) {
178392
178818
  result2.clientLanguage = [];
178393
- for (const lang of obj2.clientLanguage) {
178819
+ for (const lang of obj3.clientLanguage) {
178394
178820
  if (typeof lang === "string") {
178395
178821
  result2.clientLanguage.push(lang);
178396
178822
  } else {
@@ -178401,10 +178827,10 @@ var require_service_config = __commonJS({
178401
178827
  throw new Error("Invalid service config choice: invalid clientLanguage");
178402
178828
  }
178403
178829
  }
178404
- if ("clientHostname" in obj2) {
178405
- if (Array.isArray(obj2.clientHostname)) {
178830
+ if ("clientHostname" in obj3) {
178831
+ if (Array.isArray(obj3.clientHostname)) {
178406
178832
  result2.clientHostname = [];
178407
- for (const lang of obj2.clientHostname) {
178833
+ for (const lang of obj3.clientHostname) {
178408
178834
  if (typeof lang === "string") {
178409
178835
  result2.clientHostname.push(lang);
178410
178836
  } else {
@@ -178415,9 +178841,9 @@ var require_service_config = __commonJS({
178415
178841
  throw new Error("Invalid service config choice: invalid clientHostname");
178416
178842
  }
178417
178843
  }
178418
- if ("percentage" in obj2) {
178419
- if (typeof obj2.percentage === "number" && 0 <= obj2.percentage && obj2.percentage <= 100) {
178420
- result2.percentage = obj2.percentage;
178844
+ if ("percentage" in obj3) {
178845
+ if (typeof obj3.percentage === "number" && 0 <= obj3.percentage && obj3.percentage <= 100) {
178846
+ result2.percentage = obj3.percentage;
178421
178847
  } else {
178422
178848
  throw new Error("Invalid service config choice: invalid percentage");
178423
178849
  }
@@ -178428,18 +178854,18 @@ var require_service_config = __commonJS({
178428
178854
  "clientHostname",
178429
178855
  "serviceConfig"
178430
178856
  ];
178431
- for (const field in obj2) {
178857
+ for (const field in obj3) {
178432
178858
  if (!allowedFields.includes(field)) {
178433
178859
  throw new Error(`Invalid service config choice: unexpected field ${field}`);
178434
178860
  }
178435
178861
  }
178436
178862
  return result2;
178437
178863
  }
178438
- function validateAndSelectCanaryConfig(obj2, percentage) {
178439
- if (!Array.isArray(obj2)) {
178864
+ function validateAndSelectCanaryConfig(obj3, percentage) {
178865
+ if (!Array.isArray(obj3)) {
178440
178866
  throw new Error("Invalid service config list");
178441
178867
  }
178442
- for (const config2 of obj2) {
178868
+ for (const config2 of obj3) {
178443
178869
  const validatedConfig = validateCanaryConfig(config2);
178444
178870
  if (typeof validatedConfig.percentage === "number" && percentage > validatedConfig.percentage) {
178445
178871
  continue;
@@ -181164,8 +181590,8 @@ var require_make_client = __commonJS({
181164
181590
  return fn.call(this, path2, serialize2, deserialize, ...args);
181165
181591
  };
181166
181592
  }
181167
- function isProtobufTypeDefinition(obj2) {
181168
- return "format" in obj2;
181593
+ function isProtobufTypeDefinition(obj3) {
181594
+ return "format" in obj3;
181169
181595
  }
181170
181596
  function loadPackageDefinition(packageDef) {
181171
181597
  const result2 = {};
@@ -183455,18 +183881,18 @@ var require_descriptor2 = __commonJS({
183455
183881
  return delimited ? 10 : 11;
183456
183882
  throw Error("illegal type: " + type);
183457
183883
  }
183458
- function fromDescriptorOptionsRecursive(obj2, type) {
183884
+ function fromDescriptorOptionsRecursive(obj3, type) {
183459
183885
  var val = {};
183460
183886
  for (var i2 = 0, field, key; i2 < type.fieldsArray.length; ++i2) {
183461
183887
  if ((key = (field = type._fieldsArray[i2]).name) === "uninterpretedOption") continue;
183462
- if (!Object.prototype.hasOwnProperty.call(obj2, key)) continue;
183888
+ if (!Object.prototype.hasOwnProperty.call(obj3, key)) continue;
183463
183889
  var newKey = underScore(key);
183464
183890
  if (field.resolvedType instanceof Type) {
183465
- val[newKey] = fromDescriptorOptionsRecursive(obj2[key], field.resolvedType);
183891
+ val[newKey] = fromDescriptorOptionsRecursive(obj3[key], field.resolvedType);
183466
183892
  } else if (field.resolvedType instanceof Enum) {
183467
- val[newKey] = field.resolvedType.valuesById[obj2[key]];
183893
+ val[newKey] = field.resolvedType.valuesById[obj3[key]];
183468
183894
  } else {
183469
- val[newKey] = obj2[key];
183895
+ val[newKey] = obj3[key];
183470
183896
  }
183471
183897
  }
183472
183898
  return val;
@@ -183476,18 +183902,18 @@ var require_descriptor2 = __commonJS({
183476
183902
  return void 0;
183477
183903
  return fromDescriptorOptionsRecursive(type.toObject(options), type);
183478
183904
  }
183479
- function toDescriptorOptionsRecursive(obj2, type) {
183905
+ function toDescriptorOptionsRecursive(obj3, type) {
183480
183906
  var val = {};
183481
- var keys = Object.keys(obj2);
183907
+ var keys = Object.keys(obj3);
183482
183908
  for (var i2 = 0; i2 < keys.length; ++i2) {
183483
183909
  var key = keys[i2];
183484
183910
  var newKey = $protobuf.util.camelCase(key);
183485
183911
  if (!Object.prototype.hasOwnProperty.call(type.fields, newKey)) continue;
183486
183912
  var field = type.fields[newKey];
183487
183913
  if (field.resolvedType instanceof Type) {
183488
- val[newKey] = toDescriptorOptionsRecursive(obj2[key], field.resolvedType);
183914
+ val[newKey] = toDescriptorOptionsRecursive(obj3[key], field.resolvedType);
183489
183915
  } else {
183490
- val[newKey] = obj2[key];
183916
+ val[newKey] = obj3[key];
183491
183917
  }
183492
183918
  if (field.repeated && !Array.isArray(val[newKey])) {
183493
183919
  val[newKey] = [val[newKey]];
@@ -183990,8 +184416,8 @@ var require_src2 = __commonJS({
183990
184416
  var util_1 = require_util3();
183991
184417
  var Long = require_umd();
183992
184418
  exports.Long = Long;
183993
- function isAnyExtension(obj2) {
183994
- return "@type" in obj2 && typeof obj2["@type"] === "string";
184419
+ function isAnyExtension(obj3) {
184420
+ return "@type" in obj3 && typeof obj3["@type"] === "string";
183995
184421
  }
183996
184422
  exports.isAnyExtension = isAnyExtension;
183997
184423
  var IdempotencyLevel;
@@ -184015,20 +184441,20 @@ var require_src2 = __commonJS({
184015
184441
  return baseName + "." + name2;
184016
184442
  }
184017
184443
  }
184018
- function isHandledReflectionObject(obj2) {
184019
- return obj2 instanceof Protobuf.Service || obj2 instanceof Protobuf.Type || obj2 instanceof Protobuf.Enum;
184444
+ function isHandledReflectionObject(obj3) {
184445
+ return obj3 instanceof Protobuf.Service || obj3 instanceof Protobuf.Type || obj3 instanceof Protobuf.Enum;
184020
184446
  }
184021
- function isNamespaceBase(obj2) {
184022
- return obj2 instanceof Protobuf.Namespace || obj2 instanceof Protobuf.Root;
184447
+ function isNamespaceBase(obj3) {
184448
+ return obj3 instanceof Protobuf.Namespace || obj3 instanceof Protobuf.Root;
184023
184449
  }
184024
- function getAllHandledReflectionObjects(obj2, parentName) {
184025
- const objName = joinName(parentName, obj2.name);
184026
- if (isHandledReflectionObject(obj2)) {
184027
- return [[objName, obj2]];
184450
+ function getAllHandledReflectionObjects(obj3, parentName) {
184451
+ const objName = joinName(parentName, obj3.name);
184452
+ if (isHandledReflectionObject(obj3)) {
184453
+ return [[objName, obj3]];
184028
184454
  } else {
184029
- if (isNamespaceBase(obj2) && typeof obj2.nested !== "undefined") {
184030
- return Object.keys(obj2.nested).map((name2) => {
184031
- return getAllHandledReflectionObjects(obj2.nested[name2], objName);
184455
+ if (isNamespaceBase(obj3) && typeof obj3.nested !== "undefined") {
184456
+ return Object.keys(obj3.nested).map((name2) => {
184457
+ return getAllHandledReflectionObjects(obj3.nested[name2], objName);
184032
184458
  }).reduce((accumulator, currentValue2) => accumulator.concat(currentValue2), []);
184033
184459
  }
184034
184460
  }
@@ -184049,17 +184475,17 @@ var require_src2 = __commonJS({
184049
184475
  };
184050
184476
  }
184051
184477
  function mapMethodOptions(options) {
184052
- return (options || []).reduce((obj2, item) => {
184478
+ return (options || []).reduce((obj3, item) => {
184053
184479
  for (const [key, value] of Object.entries(item)) {
184054
184480
  switch (key) {
184055
184481
  case "uninterpreted_option":
184056
- obj2.uninterpreted_option.push(item.uninterpreted_option);
184482
+ obj3.uninterpreted_option.push(item.uninterpreted_option);
184057
184483
  break;
184058
184484
  default:
184059
- obj2[key] = value;
184485
+ obj3[key] = value;
184060
184486
  }
184061
184487
  }
184062
- return obj2;
184488
+ return obj3;
184063
184489
  }, {
184064
184490
  deprecated: false,
184065
184491
  idempotency_level: IdempotencyLevel.IDEMPOTENCY_UNKNOWN,
@@ -184109,13 +184535,13 @@ var require_src2 = __commonJS({
184109
184535
  fileDescriptorProtos: fileDescriptors
184110
184536
  };
184111
184537
  }
184112
- function createDefinition(obj2, name2, options, fileDescriptors) {
184113
- if (obj2 instanceof Protobuf.Service) {
184114
- return createServiceDefinition(obj2, name2, options, fileDescriptors);
184115
- } else if (obj2 instanceof Protobuf.Type) {
184116
- return createMessageDefinition(obj2, options, fileDescriptors);
184117
- } else if (obj2 instanceof Protobuf.Enum) {
184118
- return createEnumDefinition(obj2, fileDescriptors);
184538
+ function createDefinition(obj3, name2, options, fileDescriptors) {
184539
+ if (obj3 instanceof Protobuf.Service) {
184540
+ return createServiceDefinition(obj3, name2, options, fileDescriptors);
184541
+ } else if (obj3 instanceof Protobuf.Type) {
184542
+ return createMessageDefinition(obj3, options, fileDescriptors);
184543
+ } else if (obj3 instanceof Protobuf.Enum) {
184544
+ return createEnumDefinition(obj3, fileDescriptors);
184119
184545
  } else {
184120
184546
  throw new Error("Type mismatch in reflection object handling");
184121
184547
  }
@@ -184125,8 +184551,8 @@ var require_src2 = __commonJS({
184125
184551
  root.resolveAll();
184126
184552
  const descriptorList = root.toDescriptor("proto3").file;
184127
184553
  const bufferList = descriptorList.map((value) => Buffer.from(descriptor.FileDescriptorProto.encode(value).finish()));
184128
- for (const [name2, obj2] of getAllHandledReflectionObjects(root, "")) {
184129
- def[name2] = createDefinition(obj2, name2, options, bufferList);
184554
+ for (const [name2, obj3] of getAllHandledReflectionObjects(root, "")) {
184555
+ def[name2] = createDefinition(obj3, name2, options, bufferList);
184130
184556
  }
184131
184557
  return def;
184132
184558
  }
@@ -192326,7 +192752,7 @@ var require_server = __commonJS({
192326
192752
  }, (() => {
192327
192753
  const _metadata = typeof Symbol === "function" && Symbol.metadata ? /* @__PURE__ */ Object.create(null) : void 0;
192328
192754
  _start_decorators = [deprecate("Calling start() is no longer necessary. It can be safely omitted.")];
192329
- __esDecorate(_a4, null, _start_decorators, { kind: "method", name: "start", static: false, private: false, access: { has: (obj2) => "start" in obj2, get: (obj2) => obj2.start }, metadata: _metadata }, null, _instanceExtraInitializers);
192755
+ __esDecorate(_a4, null, _start_decorators, { kind: "method", name: "start", static: false, private: false, access: { has: (obj3) => "start" in obj3, get: (obj3) => obj3.start }, metadata: _metadata }, null, _instanceExtraInitializers);
192330
192756
  if (_metadata) Object.defineProperty(_a4, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
192331
192757
  })(), _a4;
192332
192758
  })();
@@ -192638,11 +193064,11 @@ var require_load_balancer_pick_first = __commonJS({
192638
193064
  return this.shuffleAddressList;
192639
193065
  }
192640
193066
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
192641
- static createFromJson(obj2) {
192642
- if ("shuffleAddressList" in obj2 && !(typeof obj2.shuffleAddressList === "boolean")) {
193067
+ static createFromJson(obj3) {
193068
+ if ("shuffleAddressList" in obj3 && !(typeof obj3.shuffleAddressList === "boolean")) {
192643
193069
  throw new Error("pick_first config field shuffleAddressList must be a boolean if provided");
192644
193070
  }
192645
- return new _PickFirstLoadBalancingConfig(obj2.shuffleAddressList === true);
193071
+ return new _PickFirstLoadBalancingConfig(obj3.shuffleAddressList === true);
192646
193072
  }
192647
193073
  };
192648
193074
  exports.PickFirstLoadBalancingConfig = PickFirstLoadBalancingConfig;
@@ -193434,7 +193860,7 @@ var require_load_balancer_round_robin = __commonJS({
193434
193860
  };
193435
193861
  }
193436
193862
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
193437
- static createFromJson(obj2) {
193863
+ static createFromJson(obj3) {
193438
193864
  return new _RoundRobinLoadBalancingConfig();
193439
193865
  }
193440
193866
  };
@@ -193614,27 +194040,27 @@ var require_load_balancer_outlier_detection = __commonJS({
193614
194040
  minimum_hosts: 5,
193615
194041
  request_volume: 50
193616
194042
  };
193617
- function validateFieldType(obj2, fieldName2, expectedType, objectName) {
193618
- if (fieldName2 in obj2 && obj2[fieldName2] !== void 0 && typeof obj2[fieldName2] !== expectedType) {
194043
+ function validateFieldType(obj3, fieldName2, expectedType, objectName) {
194044
+ if (fieldName2 in obj3 && obj3[fieldName2] !== void 0 && typeof obj3[fieldName2] !== expectedType) {
193619
194045
  const fullFieldName = objectName ? `${objectName}.${fieldName2}` : fieldName2;
193620
- throw new Error(`outlier detection config ${fullFieldName} parse error: expected ${expectedType}, got ${typeof obj2[fieldName2]}`);
194046
+ throw new Error(`outlier detection config ${fullFieldName} parse error: expected ${expectedType}, got ${typeof obj3[fieldName2]}`);
193621
194047
  }
193622
194048
  }
193623
- function validatePositiveDuration(obj2, fieldName2, objectName) {
194049
+ function validatePositiveDuration(obj3, fieldName2, objectName) {
193624
194050
  const fullFieldName = objectName ? `${objectName}.${fieldName2}` : fieldName2;
193625
- if (fieldName2 in obj2 && obj2[fieldName2] !== void 0) {
193626
- if (!(0, duration_1.isDuration)(obj2[fieldName2])) {
193627
- throw new Error(`outlier detection config ${fullFieldName} parse error: expected Duration, got ${typeof obj2[fieldName2]}`);
194051
+ if (fieldName2 in obj3 && obj3[fieldName2] !== void 0) {
194052
+ if (!(0, duration_1.isDuration)(obj3[fieldName2])) {
194053
+ throw new Error(`outlier detection config ${fullFieldName} parse error: expected Duration, got ${typeof obj3[fieldName2]}`);
193628
194054
  }
193629
- if (!(obj2[fieldName2].seconds >= 0 && obj2[fieldName2].seconds <= 315576e6 && obj2[fieldName2].nanos >= 0 && obj2[fieldName2].nanos <= 999999999)) {
194055
+ if (!(obj3[fieldName2].seconds >= 0 && obj3[fieldName2].seconds <= 315576e6 && obj3[fieldName2].nanos >= 0 && obj3[fieldName2].nanos <= 999999999)) {
193630
194056
  throw new Error(`outlier detection config ${fullFieldName} parse error: values out of range for non-negative Duaration`);
193631
194057
  }
193632
194058
  }
193633
194059
  }
193634
- function validatePercentage(obj2, fieldName2, objectName) {
194060
+ function validatePercentage(obj3, fieldName2, objectName) {
193635
194061
  const fullFieldName = objectName ? `${objectName}.${fieldName2}` : fieldName2;
193636
- validateFieldType(obj2, fieldName2, "number", objectName);
193637
- if (fieldName2 in obj2 && obj2[fieldName2] !== void 0 && !(obj2[fieldName2] >= 0 && obj2[fieldName2] <= 100)) {
194062
+ validateFieldType(obj3, fieldName2, "number", objectName);
194063
+ if (fieldName2 in obj3 && obj3[fieldName2] !== void 0 && !(obj3[fieldName2] >= 0 && obj3[fieldName2] <= 100)) {
193638
194064
  throw new Error(`outlier detection config ${fullFieldName} parse error: value out of range for percentage (0-100)`);
193639
194065
  }
193640
194066
  }
@@ -193689,38 +194115,38 @@ var require_load_balancer_outlier_detection = __commonJS({
193689
194115
  getChildPolicy() {
193690
194116
  return this.childPolicy;
193691
194117
  }
193692
- static createFromJson(obj2) {
194118
+ static createFromJson(obj3) {
193693
194119
  var _a5;
193694
- validatePositiveDuration(obj2, "interval");
193695
- validatePositiveDuration(obj2, "base_ejection_time");
193696
- validatePositiveDuration(obj2, "max_ejection_time");
193697
- validatePercentage(obj2, "max_ejection_percent");
193698
- if ("success_rate_ejection" in obj2 && obj2.success_rate_ejection !== void 0) {
193699
- if (typeof obj2.success_rate_ejection !== "object") {
194120
+ validatePositiveDuration(obj3, "interval");
194121
+ validatePositiveDuration(obj3, "base_ejection_time");
194122
+ validatePositiveDuration(obj3, "max_ejection_time");
194123
+ validatePercentage(obj3, "max_ejection_percent");
194124
+ if ("success_rate_ejection" in obj3 && obj3.success_rate_ejection !== void 0) {
194125
+ if (typeof obj3.success_rate_ejection !== "object") {
193700
194126
  throw new Error("outlier detection config success_rate_ejection must be an object");
193701
194127
  }
193702
- validateFieldType(obj2.success_rate_ejection, "stdev_factor", "number", "success_rate_ejection");
193703
- validatePercentage(obj2.success_rate_ejection, "enforcement_percentage", "success_rate_ejection");
193704
- validateFieldType(obj2.success_rate_ejection, "minimum_hosts", "number", "success_rate_ejection");
193705
- validateFieldType(obj2.success_rate_ejection, "request_volume", "number", "success_rate_ejection");
194128
+ validateFieldType(obj3.success_rate_ejection, "stdev_factor", "number", "success_rate_ejection");
194129
+ validatePercentage(obj3.success_rate_ejection, "enforcement_percentage", "success_rate_ejection");
194130
+ validateFieldType(obj3.success_rate_ejection, "minimum_hosts", "number", "success_rate_ejection");
194131
+ validateFieldType(obj3.success_rate_ejection, "request_volume", "number", "success_rate_ejection");
193706
194132
  }
193707
- if ("failure_percentage_ejection" in obj2 && obj2.failure_percentage_ejection !== void 0) {
193708
- if (typeof obj2.failure_percentage_ejection !== "object") {
194133
+ if ("failure_percentage_ejection" in obj3 && obj3.failure_percentage_ejection !== void 0) {
194134
+ if (typeof obj3.failure_percentage_ejection !== "object") {
193709
194135
  throw new Error("outlier detection config failure_percentage_ejection must be an object");
193710
194136
  }
193711
- validatePercentage(obj2.failure_percentage_ejection, "threshold", "failure_percentage_ejection");
193712
- validatePercentage(obj2.failure_percentage_ejection, "enforcement_percentage", "failure_percentage_ejection");
193713
- validateFieldType(obj2.failure_percentage_ejection, "minimum_hosts", "number", "failure_percentage_ejection");
193714
- validateFieldType(obj2.failure_percentage_ejection, "request_volume", "number", "failure_percentage_ejection");
194137
+ validatePercentage(obj3.failure_percentage_ejection, "threshold", "failure_percentage_ejection");
194138
+ validatePercentage(obj3.failure_percentage_ejection, "enforcement_percentage", "failure_percentage_ejection");
194139
+ validateFieldType(obj3.failure_percentage_ejection, "minimum_hosts", "number", "failure_percentage_ejection");
194140
+ validateFieldType(obj3.failure_percentage_ejection, "request_volume", "number", "failure_percentage_ejection");
193715
194141
  }
193716
- if (!("child_policy" in obj2) || !Array.isArray(obj2.child_policy)) {
194142
+ if (!("child_policy" in obj3) || !Array.isArray(obj3.child_policy)) {
193717
194143
  throw new Error("outlier detection config child_policy must be an array");
193718
194144
  }
193719
- const childPolicy = (0, load_balancer_1.selectLbConfigFromList)(obj2.child_policy);
194145
+ const childPolicy = (0, load_balancer_1.selectLbConfigFromList)(obj3.child_policy);
193720
194146
  if (!childPolicy) {
193721
194147
  throw new Error("outlier detection config child_policy: no valid recognized policy found");
193722
194148
  }
193723
- return new _OutlierDetectionLoadBalancingConfig(obj2.interval ? (0, duration_1.durationToMs)(obj2.interval) : null, obj2.base_ejection_time ? (0, duration_1.durationToMs)(obj2.base_ejection_time) : null, obj2.max_ejection_time ? (0, duration_1.durationToMs)(obj2.max_ejection_time) : null, (_a5 = obj2.max_ejection_percent) !== null && _a5 !== void 0 ? _a5 : null, obj2.success_rate_ejection, obj2.failure_percentage_ejection, childPolicy);
194149
+ return new _OutlierDetectionLoadBalancingConfig(obj3.interval ? (0, duration_1.durationToMs)(obj3.interval) : null, obj3.base_ejection_time ? (0, duration_1.durationToMs)(obj3.base_ejection_time) : null, obj3.max_ejection_time ? (0, duration_1.durationToMs)(obj3.max_ejection_time) : null, (_a5 = obj3.max_ejection_percent) !== null && _a5 !== void 0 ? _a5 : null, obj3.success_rate_ejection, obj3.failure_percentage_ejection, childPolicy);
193724
194150
  }
193725
194151
  };
193726
194152
  exports.OutlierDetectionLoadBalancingConfig = OutlierDetectionLoadBalancingConfig;
@@ -194206,26 +194632,26 @@ var require_load_balancer_weighted_round_robin = __commonJS({
194206
194632
  var DEFAULT_WEIGHT_EXPIRATION_PERIOD_MS = 3 * 6e4;
194207
194633
  var DEFAULT_WEIGHT_UPDATE_PERIOD_MS = 1e3;
194208
194634
  var DEFAULT_ERROR_UTILIZATION_PENALTY = 1;
194209
- function validateFieldType(obj2, fieldName2, expectedType) {
194210
- if (fieldName2 in obj2 && obj2[fieldName2] !== void 0 && typeof obj2[fieldName2] !== expectedType) {
194211
- throw new Error(`weighted round robin config ${fieldName2} parse error: expected ${expectedType}, got ${typeof obj2[fieldName2]}`);
194635
+ function validateFieldType(obj3, fieldName2, expectedType) {
194636
+ if (fieldName2 in obj3 && obj3[fieldName2] !== void 0 && typeof obj3[fieldName2] !== expectedType) {
194637
+ throw new Error(`weighted round robin config ${fieldName2} parse error: expected ${expectedType}, got ${typeof obj3[fieldName2]}`);
194212
194638
  }
194213
194639
  }
194214
- function parseDurationField(obj2, fieldName2) {
194215
- if (fieldName2 in obj2 && obj2[fieldName2] !== void 0 && obj2[fieldName2] !== null) {
194640
+ function parseDurationField(obj3, fieldName2) {
194641
+ if (fieldName2 in obj3 && obj3[fieldName2] !== void 0 && obj3[fieldName2] !== null) {
194216
194642
  let durationObject;
194217
- if ((0, duration_1.isDuration)(obj2[fieldName2])) {
194218
- durationObject = obj2[fieldName2];
194219
- } else if ((0, duration_1.isDurationMessage)(obj2[fieldName2])) {
194220
- durationObject = (0, duration_1.durationMessageToDuration)(obj2[fieldName2]);
194221
- } else if (typeof obj2[fieldName2] === "string") {
194222
- const parsedDuration = (0, duration_1.parseDuration)(obj2[fieldName2]);
194643
+ if ((0, duration_1.isDuration)(obj3[fieldName2])) {
194644
+ durationObject = obj3[fieldName2];
194645
+ } else if ((0, duration_1.isDurationMessage)(obj3[fieldName2])) {
194646
+ durationObject = (0, duration_1.durationMessageToDuration)(obj3[fieldName2]);
194647
+ } else if (typeof obj3[fieldName2] === "string") {
194648
+ const parsedDuration = (0, duration_1.parseDuration)(obj3[fieldName2]);
194223
194649
  if (!parsedDuration) {
194224
- throw new Error(`weighted round robin config ${fieldName2}: failed to parse duration string ${obj2[fieldName2]}`);
194650
+ throw new Error(`weighted round robin config ${fieldName2}: failed to parse duration string ${obj3[fieldName2]}`);
194225
194651
  }
194226
194652
  durationObject = parsedDuration;
194227
194653
  } else {
194228
- throw new Error(`weighted round robin config ${fieldName2}: expected duration, got ${typeof obj2[fieldName2]}`);
194654
+ throw new Error(`weighted round robin config ${fieldName2}: expected duration, got ${typeof obj3[fieldName2]}`);
194229
194655
  }
194230
194656
  return (0, duration_1.durationToMs)(durationObject);
194231
194657
  }
@@ -194253,13 +194679,13 @@ var require_load_balancer_weighted_round_robin = __commonJS({
194253
194679
  error_utilization_penalty: this.errorUtilizationPenalty
194254
194680
  };
194255
194681
  }
194256
- static createFromJson(obj2) {
194257
- validateFieldType(obj2, "enable_oob_load_report", "boolean");
194258
- validateFieldType(obj2, "error_utilization_penalty", "number");
194259
- if (obj2.error_utilization_penalty < 0) {
194682
+ static createFromJson(obj3) {
194683
+ validateFieldType(obj3, "enable_oob_load_report", "boolean");
194684
+ validateFieldType(obj3, "error_utilization_penalty", "number");
194685
+ if (obj3.error_utilization_penalty < 0) {
194260
194686
  throw new Error("weighted round robin config error_utilization_penalty < 0");
194261
194687
  }
194262
- return new _WeightedRoundRobinLoadBalancingConfig(obj2.enable_oob_load_report, parseDurationField(obj2, "oob_load_reporting_period"), parseDurationField(obj2, "blackout_period"), parseDurationField(obj2, "weight_expiration_period"), parseDurationField(obj2, "weight_update_period"), obj2.error_utilization_penalty);
194688
+ return new _WeightedRoundRobinLoadBalancingConfig(obj3.enable_oob_load_report, parseDurationField(obj3, "oob_load_reporting_period"), parseDurationField(obj3, "blackout_period"), parseDurationField(obj3, "weight_expiration_period"), parseDurationField(obj3, "weight_update_period"), obj3.error_utilization_penalty);
194263
194689
  }
194264
194690
  getEnableOobLoadReport() {
194265
194691
  return this.enableOobLoadReport;
@@ -194872,7 +195298,7 @@ function differenceAt(path2, expected, actual) {
194872
195298
  actual: actual[shared]
194873
195299
  };
194874
195300
  }
194875
- if (isRecord10(expected) && isRecord10(actual)) {
195301
+ if (isRecord11(expected) && isRecord11(actual)) {
194876
195302
  for (const key of Object.keys(expected)) {
194877
195303
  const found = differenceAt(
194878
195304
  keyPath(path2, key),
@@ -194967,7 +195393,7 @@ function rpcMessage(request4) {
194967
195393
  const parsed2 = parseJson4(decodeText2(request4.body));
194968
195394
  if (!parsed2.ok) return void 0;
194969
195395
  const value = isList(parsed2.value) ? parsed2.value[0] : parsed2.value;
194970
- return isRecord10(value) ? value : void 0;
195396
+ return isRecord11(value) ? value : void 0;
194971
195397
  }
194972
195398
  function replayTransport(exchanges, route) {
194973
195399
  let next = 0;
@@ -195830,7 +196256,7 @@ function importedEntries(tree) {
195830
196256
  for (const [server, folder] of serverFolders(tree)) {
195831
196257
  for (const [key, entry2] of folder.tools) {
195832
196258
  const upstream = folder.locked.get(key)?.upstream;
195833
- const pinned2 = isRecord9(upstream) ? upstream.description : void 0;
196259
+ const pinned2 = isRecord10(upstream) ? upstream.description : void 0;
195834
196260
  const own2 = entry2.description;
195835
196261
  imported.push({
195836
196262
  server,
@@ -197390,12 +197816,12 @@ var init_src8 = __esm({
197390
197816
  });
197391
197817
 
197392
197818
  // ../../packages/steering-bundle/src/tree.ts
197393
- import { createHash as createHash31 } from "node:crypto";
197819
+ import { createHash as createHash32 } from "node:crypto";
197394
197820
  function gitBlobId(text6) {
197395
197821
  return gitBlobIdOfBytes(Buffer.from(text6, "utf8"));
197396
197822
  }
197397
197823
  function gitBlobIdOfBytes(bytes) {
197398
- return createHash31("sha1").update(`blob ${bytes.length}\0`).update(bytes).digest("hex");
197824
+ return createHash32("sha1").update(`blob ${bytes.length}\0`).update(bytes).digest("hex");
197399
197825
  }
197400
197826
  function treeFromFiles(files2) {
197401
197827
  return {
@@ -197935,7 +198361,7 @@ __export(check_exports, {
197935
198361
  readHead: () => readHead2
197936
198362
  });
197937
198363
  import { execFileSync } from "node:child_process";
197938
- import { createHash as createHash32 } from "node:crypto";
198364
+ import { createHash as createHash33 } from "node:crypto";
197939
198365
  import {
197940
198366
  lstatSync as lstatSync14,
197941
198367
  mkdirSync as mkdirSync15,
@@ -198154,9 +198580,9 @@ function cacheFile(cacheDir, root) {
198154
198580
  const identity = {
198155
198581
  api: getApiUrl(),
198156
198582
  ...targetOf(root),
198157
- key: token === void 0 ? null : createHash32("sha256").update(token).digest("hex").slice(0, 16)
198583
+ key: token === void 0 ? null : createHash33("sha256").update(token).digest("hex").slice(0, 16)
198158
198584
  };
198159
- const key = createHash32("sha256").update(JSON.stringify([root, identity])).digest("hex").slice(0, 32);
198585
+ const key = createHash33("sha256").update(JSON.stringify([root, identity])).digest("hex").slice(0, 32);
198160
198586
  return join75(cacheDir, `${key}.json`);
198161
198587
  }
198162
198588
  function readCache(file2, now) {
@@ -198846,12 +199272,12 @@ var init_telemetry = __esm({
198846
199272
  });
198847
199273
 
198848
199274
  // src/auth/pkce.ts
198849
- import { createHash as createHash33, randomBytes as randomBytes15 } from "node:crypto";
199275
+ import { createHash as createHash34, randomBytes as randomBytes15 } from "node:crypto";
198850
199276
  function generateCodeVerifier() {
198851
199277
  return randomBytes15(32).toString("base64url");
198852
199278
  }
198853
199279
  function codeChallengeS256(codeVerifier) {
198854
- return createHash33("sha256").update(codeVerifier, "ascii").digest("base64url");
199280
+ return createHash34("sha256").update(codeVerifier, "ascii").digest("base64url");
198855
199281
  }
198856
199282
  function generateState() {
198857
199283
  return randomBytes15(16).toString("base64url");
@@ -199575,6 +200001,7 @@ var init_agent_register = __esm({
199575
200001
  "use strict";
199576
200002
  init_zod();
199577
200003
  init_registry4();
200004
+ init_secret_fields();
199578
200005
  init_agent_list();
199579
200006
  init_runtime_shared();
199580
200007
  init_toolbelt_shared();
@@ -199587,10 +200014,11 @@ var init_agent_register = __esm({
199587
200014
  description: "Register an agent in this workspace: one operator on one runtime with one harness, carrying a toolbelt. Mints its principal, default role, first version and a long-lived credential shown once.",
199588
200015
  mode: "sync",
199589
200016
  // The handler acts as the signed-in user or the API key's creator
199590
- // (resolveActingUserId, assertOrgRole, INV-29). It ships on the API, CLI,
199591
- // and MCP. It stays off the agent surface because it returns a credential.
199592
- surfaces: ["api", "cli", "mcp"],
199593
- layers: ["schema", "api", "unit", "docs", "app", "mcp"],
200017
+ // (resolveActingUserId, assertOrgRole, INV-29). It ships on the API and the
200018
+ // CLI. It stays off the mcp and agent surfaces because it returns a
200019
+ // credential, and a tool result lands in a model's transcript (ADR-9277).
200020
+ surfaces: ["api", "cli"],
200021
+ layers: ["schema", "api", "unit", "docs", "app"],
199594
200022
  scoped: true,
199595
200023
  noBillingGate: true,
199596
200024
  mutates: true,
@@ -199626,7 +200054,7 @@ var init_agent_register = __esm({
199626
200054
  credential: external_exports.object({
199627
200055
  id: external_exports.string().regex(/^aky_[0-9a-z]+$/),
199628
200056
  /** Shown once. Never recoverable. */
199629
- secret: external_exports.string().min(1),
200057
+ secret: secretField(external_exports.string().min(1)),
199630
200058
  expiresAt: external_exports.string().datetime({ offset: true })
199631
200059
  }).strict()
199632
200060
  }).strict()
@@ -200981,7 +201409,7 @@ function addRemovalCommands(program2) {
200981
201409
  {
200982
201410
  noun: "guardrails",
200983
201411
  description: "Auto-approval rules, off switches, mandates and spend budgets",
200984
- deleteDescription: "Delete auto-approval rules, off switches, mandates or spend budgets. Each stops applying at once and is kept for the runs that name it",
201412
+ deleteDescription: "Delete auto-approval rules and mandates. Each stops applying at once and is kept for the runs that name it. An off switch or a spend budget is refused here, because only a person signed in to Oxagen deletes those, on the Guardrails page",
200985
201413
  types: "approval_rule, kill_switch, mandate or spend_budget",
200986
201414
  run: "guardrailsRemove",
200987
201415
  merges: false
@@ -201214,15 +201642,8 @@ function buildProgram() {
201214
201642
  await budgetShow2(opts);
201215
201643
  });
201216
201644
  budgetCmd.command("set").description(
201217
- "Set (create or replace) a spend ceiling (Owner/Admin/Billing only)"
201218
- ).requiredOption("--scope <scope>", "org | workspace").requiredOption("--period <period>", "monthly | rolling").requiredOption("--limit <usd>", "Hard USD ceiling (> 0)").option(
201219
- "--window-days <n>",
201220
- "Trailing window in days: required for --period rolling, omit for monthly"
201221
- ).option(
201222
- "--enabled <bool>",
201223
- "Whether the ceiling is enforced (true/false)",
201224
- "true"
201225
- ).option("--json", "Output JSON").action(
201645
+ "Open the Oxagen page that sets a spend ceiling. Only a signed-in person can set one, so this command makes no change"
201646
+ ).option("--scope <scope>", "No longer read").option("--period <period>", "No longer read").option("--limit <usd>", "No longer read").option("--window-days <n>", "No longer read").option("--enabled <bool>", "No longer read").option("--json", "Output JSON").action(
201226
201647
  async (opts) => {
201227
201648
  const { budgetSet: budgetSet2 } = await Promise.resolve().then(() => (init_budget2(), budget_exports));
201228
201649
  await budgetSet2(opts);
@@ -201562,14 +201983,8 @@ function buildProgram() {
201562
201983
  }
201563
201984
  );
201564
201985
  repoCmd.command("governance").description(
201565
- "Set the steering governance mode: who may merge a steering PR in this workspace"
201566
- ).requiredOption("--mode <mode>", "solo | team | regulated").option(
201567
- "--workspace <id>",
201568
- "The wrk_\u2026 workspace to change; the scoped workspace when omitted"
201569
- ).option(
201570
- "--apply-now",
201571
- "Commit to the production branch although the mode in force asks for a reviewed pull request; recorded as steering.governance_overridden"
201572
- ).option("--json", "Output JSON").action(
201986
+ "Open the Oxagen page that sets the steering governance mode. Only a signed-in person can change it, so this command makes no change"
201987
+ ).option("--mode <mode>", "No longer read").option("--workspace <id>", "No longer read").option("--apply-now", "No longer read").option("--json", "Output JSON").action(
201573
201988
  async (opts) => {
201574
201989
  const { repoGovernance: repoGovernance2 } = await Promise.resolve().then(() => (init_repo(), repo_exports));
201575
201990
  await repoGovernance2(opts);