@wayai/cli 0.3.313 → 0.3.315

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -239,8 +239,8 @@ var init_mask_secrets = __esm({
239
239
  FULLY_MASKED_VALUE_RE = /^(?:(?:Bearer|Basic)\s+)?(?:way_|wst_|rec_)?\[REDACTED(?:_JWT|_BASE64)?\]$/;
240
240
  isCredentialKey = (key) => CREDENTIAL_KEY_RE.test(key);
241
241
  isBase64UrlChar = (char) => {
242
- const code = char.charCodeAt(0);
243
- return code >= 48 && code <= 57 || code >= 65 && code <= 90 || code >= 97 && code <= 122 || char === "-" || char === "_";
242
+ const code2 = char.charCodeAt(0);
243
+ return code2 >= 48 && code2 <= 57 || code2 >= 65 && code2 <= 90 || code2 >= 97 && code2 <= 122 || char === "-" || char === "_";
244
244
  };
245
245
  SHAPE_PATTERNS = [
246
246
  // way_ scoped API tokens (keyring/CI credentials). Leading \b avoids
@@ -328,16 +328,16 @@ var init_mask_secrets = __esm({
328
328
  // src/lib/network-error.ts
329
329
  function errorCode(value) {
330
330
  if (value && typeof value === "object" && "code" in value) {
331
- const code = value.code;
332
- if (typeof code === "string") return code;
331
+ const code2 = value.code;
332
+ if (typeof code2 === "string") return code2;
333
333
  }
334
334
  return void 0;
335
335
  }
336
336
  function isNetworkError(err) {
337
337
  if (err instanceof TypeError && err.message === "fetch failed") return true;
338
338
  if (!err || typeof err !== "object") return false;
339
- const code = errorCode(err) ?? errorCode(err.cause);
340
- return code !== void 0 && NETWORK_ERROR_CODES.has(code);
339
+ const code2 = errorCode(err) ?? errorCode(err.cause);
340
+ return code2 !== void 0 && NETWORK_ERROR_CODES.has(code2);
341
341
  }
342
342
  var NETWORK_ERROR_CODES;
343
343
  var init_network_error = __esm({
@@ -588,9 +588,9 @@ var init_chunk_ICYO56QW = __esm({
588
588
  init_chunk_WFQDSQJK();
589
589
  APP_ERROR_BRAND = /* @__PURE__ */ Symbol.for("wayai.AppError");
590
590
  AppError = class extends Error {
591
- constructor(message, code, statusCode = 500, details) {
591
+ constructor(message, code2, statusCode = 500, details) {
592
592
  super(message);
593
- this.code = code;
593
+ this.code = code2;
594
594
  this.statusCode = statusCode;
595
595
  this.details = details;
596
596
  this.name = "AppError";
@@ -5489,7 +5489,7 @@ var init_chunk_MF2VVXBR = __esm({
5489
5489
  }
5490
5490
  });
5491
5491
 
5492
- // ../../packages/core/dist/chunk-YROEDMVZ.js
5492
+ // ../../packages/core/dist/chunk-NYNOISIG.js
5493
5493
  function normalizeAuthType(raw) {
5494
5494
  if (VALID_AUTH_TYPES.has(raw)) return raw;
5495
5495
  return LEGACY_AUTH_TYPE_MAP[raw] ?? raw;
@@ -5497,9 +5497,9 @@ function normalizeAuthType(raw) {
5497
5497
  function isCustomerFacingAgentRole(role) {
5498
5498
  return typeof role === "string" && CUSTOMER_FACING_AGENT_ROLES.includes(role);
5499
5499
  }
5500
- var AUTH_TYPE, ORG_CREDENTIAL_AUTH_TYPES, AUTH_TYPE_DISPLAY, LEGACY_AUTH_TYPE_MAP, VALID_AUTH_TYPES, AGENT_ROLES, PILOT_TRACK_ROLES, COPILOT_TRACK_ROLES, CUSTOMER_FACING_AGENT_ROLES, AGENT_ROLE_DISPLAY, SAFE_USER_ID_REGEX, SUPPORTED_LOCALES, SKILL_INSTALL_COMMAND;
5501
- var init_chunk_YROEDMVZ = __esm({
5502
- "../../packages/core/dist/chunk-YROEDMVZ.js"() {
5500
+ var AUTH_TYPE, ORG_CREDENTIAL_AUTH_TYPES, AUTH_TYPE_DISPLAY, LEGACY_AUTH_TYPE_MAP, VALID_AUTH_TYPES, AGENT_ROLES, PILOT_TRACK_ROLES, COPILOT_TRACK_ROLES, CUSTOMER_FACING_AGENT_ROLES, AGENT_ROLE_DISPLAY, SAFE_USER_ID_REGEX, SUPPORTED_LOCALES, SKILL_INSTALL_COMMAND, CASE_TYPE_ABBREVIATION_PATTERN;
5501
+ var init_chunk_NYNOISIG = __esm({
5502
+ "../../packages/core/dist/chunk-NYNOISIG.js"() {
5503
5503
  "use strict";
5504
5504
  AUTH_TYPE = {
5505
5505
  OAUTH: "oauth",
@@ -5564,16 +5564,17 @@ var init_chunk_YROEDMVZ = __esm({
5564
5564
  SAFE_USER_ID_REGEX = /^[A-Za-z0-9_-]{1,64}$/;
5565
5565
  SUPPORTED_LOCALES = ["en", "pt", "es"];
5566
5566
  SKILL_INSTALL_COMMAND = "mkdir -p .claude && npx skills add wayai-pro/wayai-skill -y";
5567
+ CASE_TYPE_ABBREVIATION_PATTERN = /^[A-Z]{2,6}$/;
5567
5568
  }
5568
5569
  });
5569
5570
 
5570
- // ../../packages/core/dist/chunk-WL5QGKHN.js
5571
+ // ../../packages/core/dist/chunk-6JOESMU5.js
5571
5572
  var orgCredentialIdParam, listOrgCredentialsQuery, createOrgCredentialBody, updateOrgCredentialBody;
5572
- var init_chunk_WL5QGKHN = __esm({
5573
- "../../packages/core/dist/chunk-WL5QGKHN.js"() {
5573
+ var init_chunk_6JOESMU5 = __esm({
5574
+ "../../packages/core/dist/chunk-6JOESMU5.js"() {
5574
5575
  "use strict";
5575
5576
  init_chunk_MF2VVXBR();
5576
- init_chunk_YROEDMVZ();
5577
+ init_chunk_NYNOISIG();
5577
5578
  init_zod();
5578
5579
  orgCredentialIdParam = external_exports.object({
5579
5580
  id: external_exports.string().uuid()
@@ -5971,7 +5972,7 @@ var init_chunk_SDOG6762 = __esm({
5971
5972
  }
5972
5973
  });
5973
5974
 
5974
- // ../../packages/core/dist/chunk-T6D3YZ6B.js
5975
+ // ../../packages/core/dist/chunk-P74ESVOL.js
5975
5976
  function isPersonAccessAll(lists) {
5976
5977
  return lists !== void 0 && lists.read.length === 1 && lists.read[0] === ACCESS_UNRESTRICTED && lists.write.length === 1 && lists.write[0] === ACCESS_UNRESTRICTED;
5977
5978
  }
@@ -6009,12 +6010,12 @@ function assignmentHasUnrestricted(assignment) {
6009
6010
  return Object.values(assignment).some((lists) => lists.read.includes(ACCESS_UNRESTRICTED) || lists.write.includes(ACCESS_UNRESTRICTED));
6010
6011
  }
6011
6012
  var ACCESS_UNRESTRICTED, ACCESS_ID_REGEX, ACCESS_ID_MAX_LENGTH, MAX_ACCESS_DIMENSIONS_PER_ORG, MAX_ACCESS_VALUES_PER_DIMENSION, ACCESS_LABEL_MAX_LENGTH, accessIdSchema, accessLabelSchema, accessValueListSchema, accessListsSchema, accessAssignmentSchema, PERSON_ACCESS_KEY, heldAccessKeySchema, heldAccessAssignmentSchema, AGENT_PERSON_ACCESS_REFUSAL, accessSetSchema, accessDimensionParam, accessValueParam, orgMemberParam, orgHubParam, createAccessDimensionBody, updateAccessDimensionBody, createAccessValueBody, updateAccessValueBody, setMemberAccessValuesBody, HUB_PERSON_KINDS, ACCESS_PERSON_KINDS, setHubUserAccessValuesBody, setHubAccessValuesBody, setAgentAccessValuesBody;
6012
- var init_chunk_T6D3YZ6B = __esm({
6013
- "../../packages/core/dist/chunk-T6D3YZ6B.js"() {
6013
+ var init_chunk_P74ESVOL = __esm({
6014
+ "../../packages/core/dist/chunk-P74ESVOL.js"() {
6014
6015
  "use strict";
6015
6016
  init_chunk_SDOG6762();
6016
6017
  init_chunk_HZ6CADSY();
6017
- init_chunk_YROEDMVZ();
6018
+ init_chunk_NYNOISIG();
6018
6019
  init_zod();
6019
6020
  ACCESS_UNRESTRICTED = "*";
6020
6021
  ACCESS_ID_REGEX = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
@@ -6103,7 +6104,7 @@ var init_chunk_T6D3YZ6B = __esm({
6103
6104
  }
6104
6105
  });
6105
6106
 
6106
- // ../../packages/core/dist/chunk-U6S4MZGT.js
6107
+ // ../../packages/core/dist/chunk-SGQ5NQ5K.js
6107
6108
  function boundCustomerPartyIsValid(audience, parties, customer) {
6108
6109
  return audience !== REKOR_PERSON_AUDIENCE_STAFF && customer < parties.length && Array.isArray(parties[customer]);
6109
6110
  }
@@ -6117,10 +6118,10 @@ function isEncodedBoundPerson(raw) {
6117
6118
  return rekorBoundPersonSchema.safeParse(parsed).success;
6118
6119
  }
6119
6120
  var TOOLSET_SLUG_PATTERN, REKOR_STRUCTURAL_ID_PATTERN, baseEnvironmentSchema, toolsetFileToolSchema, toolsetSurfaceSchema, toolsetConnectionBindingSchema, seedConnectionBindingSchema, rekorSeedBindingSchema, rekorToolsetToolsSchema, rekorPersonIdSchema, rekorPersonAudienceSchema, rekorBoundPersonSchema, STATED_GENERATION_PATTERN, rekorBoundAttestation, rekorSeedAttestation, rekorResolvedToolsetSchema, REKOR_TOOL_KINDS_PARAM, REKOR_TOOL_KINDS_RESOLVE_SEARCH, resolvedRecordTypeSchema, reviewWritersSchema, sharedScopeSchema, resolvedFileToolSchema, rekorToolsetFileSchema, rekorToolsetFileUrlAnswerSchema, rekorToolsetFileListSchema, rekorToolsetFileGetSchema, rekorToolsetFilePutSchema, TOOLSET_CUSTOMER_FACING_REFUSAL_MARK, TOOLSET_CUSTOMER_FACING_REFUSAL, BASE_TOOLSET_ONLY_FOR_CUSTOMER_FACING, GENERIC_DATA_MCP_CUSTOMER_FACING_REFUSAL, GENERIC_DATA_API_CUSTOMER_FACING_REFUSAL;
6120
- var init_chunk_U6S4MZGT = __esm({
6121
- "../../packages/core/dist/chunk-U6S4MZGT.js"() {
6121
+ var init_chunk_SGQ5NQ5K = __esm({
6122
+ "../../packages/core/dist/chunk-SGQ5NQ5K.js"() {
6122
6123
  "use strict";
6123
- init_chunk_T6D3YZ6B();
6124
+ init_chunk_P74ESVOL();
6124
6125
  init_chunk_SDOG6762();
6125
6126
  init_zod();
6126
6127
  TOOLSET_SLUG_PATTERN = /^[A-Za-z0-9_-]{1,128}$/;
@@ -6408,12 +6409,12 @@ var init_chunk_U6S4MZGT = __esm({
6408
6409
  }
6409
6410
  });
6410
6411
 
6411
- // ../../packages/core/dist/chunk-JW6QQD5K.js
6412
+ // ../../packages/core/dist/chunk-HE5RU7KY.js
6412
6413
  var TOOLSET_ANSWER_PERSON_PARTIES, toolsetAnswerPersonSchema, toolsetAnswerPersonsSchema;
6413
- var init_chunk_JW6QQD5K = __esm({
6414
- "../../packages/core/dist/chunk-JW6QQD5K.js"() {
6414
+ var init_chunk_HE5RU7KY = __esm({
6415
+ "../../packages/core/dist/chunk-HE5RU7KY.js"() {
6415
6416
  "use strict";
6416
- init_chunk_U6S4MZGT();
6417
+ init_chunk_SGQ5NQ5K();
6417
6418
  init_chunk_SDOG6762();
6418
6419
  init_zod();
6419
6420
  TOOLSET_ANSWER_PERSON_PARTIES = ["requester", "originator", "initiator", "delegator"];
@@ -6559,7 +6560,7 @@ var init_chunk_UAOHHCW5 = __esm({
6559
6560
  });
6560
6561
  contactEmail = external_exports.string().trim().toLowerCase().max(CONTACT_EMAIL_MAX).email();
6561
6562
  contactInstagramSid = external_exports.string().trim().min(1).max(CONTACT_INSTAGRAM_SID_MAX);
6562
- contactLabel = external_exports.string().max(CONTACT_LABEL_MAX).transform(normalizeContactLabel).refine((label2) => label2.length > 0, "A label cannot be empty").refine((label2) => !label2.includes(","), "A label cannot contain a comma");
6563
+ contactLabel = external_exports.string().max(CONTACT_LABEL_MAX).transform(normalizeContactLabel).refine((label3) => label3.length > 0, "A label cannot be empty").refine((label3) => !label3.includes(","), "A label cannot contain a comma");
6563
6564
  contactLabels = external_exports.array(contactLabel).max(CONTACT_LABELS_MAX).transform((labels) => [...new Set(labels)]);
6564
6565
  contactMetadata = external_exports.record(external_exports.unknown()).refine((metadata) => {
6565
6566
  try {
@@ -7858,10 +7859,10 @@ var init_chunk_WEXVYJ5H = __esm({
7858
7859
  function utf8ByteLength(text4) {
7859
7860
  let bytes = 0;
7860
7861
  for (let i = 0; i < text4.length; i++) {
7861
- const code = text4.charCodeAt(i);
7862
- if (code < 128) bytes += 1;
7863
- else if (code < 2048) bytes += 2;
7864
- else if (code >= 55296 && code <= 56319 && i + 1 < text4.length) {
7862
+ const code2 = text4.charCodeAt(i);
7863
+ if (code2 < 128) bytes += 1;
7864
+ else if (code2 < 2048) bytes += 2;
7865
+ else if (code2 >= 55296 && code2 <= 56319 && i + 1 < text4.length) {
7865
7866
  const next = text4.charCodeAt(i + 1);
7866
7867
  if (next >= 56320 && next <= 57343) {
7867
7868
  bytes += 4;
@@ -8026,12 +8027,12 @@ var init_chunk_FBV7NLKO = __esm({
8026
8027
  }
8027
8028
  });
8028
8029
 
8029
- // ../../packages/core/dist/chunk-TSIH4Y2H.js
8030
+ // ../../packages/core/dist/chunk-MI4UV5EU.js
8030
8031
  var hubPageWatchParam, pageWatchedBaseSchema, hubPageWatchResponseSchema;
8031
- var init_chunk_TSIH4Y2H = __esm({
8032
- "../../packages/core/dist/chunk-TSIH4Y2H.js"() {
8032
+ var init_chunk_MI4UV5EU = __esm({
8033
+ "../../packages/core/dist/chunk-MI4UV5EU.js"() {
8033
8034
  "use strict";
8034
- init_chunk_U6S4MZGT();
8035
+ init_chunk_SGQ5NQ5K();
8035
8036
  init_chunk_FBV7NLKO();
8036
8037
  init_chunk_HZ6CADSY();
8037
8038
  init_zod();
@@ -9113,7 +9114,7 @@ var init_chunk_C2UEA2KW = __esm({
9113
9114
  }
9114
9115
  });
9115
9116
 
9116
- // ../../packages/core/dist/chunk-JHUTFQDO.js
9117
+ // ../../packages/core/dist/chunk-4IXIQQ2A.js
9117
9118
  function isNativeToolName(name) {
9118
9119
  return NATIVE_TOOL_NAMES.has(name);
9119
9120
  }
@@ -9132,10 +9133,10 @@ function idempotencyHeaderRefusal(value) {
9132
9133
  return null;
9133
9134
  }
9134
9135
  var NATIVE_TOOL_SCHEMAS, WAYAI_CONNECTOR, SANDBOX_AGENT_ROLES, BASE_NATIVE_TOOLS, NATIVE_TOOLS, NATIVE_TOOL_NAMES, CATALOG_SIDE_EFFECTS, CATALOG_REPLAY, REPLAY_OVERRIDES, RESERVED_HEADERS;
9135
- var init_chunk_JHUTFQDO = __esm({
9136
- "../../packages/core/dist/chunk-JHUTFQDO.js"() {
9136
+ var init_chunk_4IXIQQ2A = __esm({
9137
+ "../../packages/core/dist/chunk-4IXIQQ2A.js"() {
9137
9138
  "use strict";
9138
- init_chunk_YROEDMVZ();
9139
+ init_chunk_NYNOISIG();
9139
9140
  NATIVE_TOOL_SCHEMAS = {
9140
9141
  "close_conversation": {
9141
9142
  "tool_config": {
@@ -10156,8 +10157,8 @@ var init_chunk_JHUTFQDO = __esm({
10156
10157
  });
10157
10158
 
10158
10159
  // ../../packages/core/dist/chunk-7IKO675N.js
10159
- function spokenLineField(label2, description2) {
10160
- return { type: "text", label: label2, maxLength: SPOKEN_LINE_MAX_CHARS, default: "", description: description2 };
10160
+ function spokenLineField(label3, description2) {
10161
+ return { type: "text", label: label3, maxLength: SPOKEN_LINE_MAX_CHARS, default: "", description: description2 };
10161
10162
  }
10162
10163
  function byLowercaseName(a, b) {
10163
10164
  const x = a.connector_name.toLowerCase();
@@ -11184,12 +11185,12 @@ var init_chunk_7IKO675N = __esm({
11184
11185
  }
11185
11186
  });
11186
11187
 
11187
- // ../../packages/core/dist/chunk-55RZ7YIF.js
11188
+ // ../../packages/core/dist/chunk-IEEMZR55.js
11188
11189
  var COUNTER_KEYS, STT_PRICING, CONTAINER_PRICING, connectorById, nativeToolById;
11189
- var init_chunk_55RZ7YIF = __esm({
11190
- "../../packages/core/dist/chunk-55RZ7YIF.js"() {
11190
+ var init_chunk_IEEMZR55 = __esm({
11191
+ "../../packages/core/dist/chunk-IEEMZR55.js"() {
11191
11192
  "use strict";
11192
- init_chunk_JHUTFQDO();
11193
+ init_chunk_4IXIQQ2A();
11193
11194
  init_chunk_7IKO675N();
11194
11195
  init_chunk_MIWZOSPI();
11195
11196
  COUNTER_KEYS = Object.keys({
@@ -11313,7 +11314,7 @@ var init_chunk_L5F7ZOUJ = __esm({
11313
11314
  }
11314
11315
  });
11315
11316
 
11316
- // ../../packages/core/dist/chunk-7IXDF53E.js
11317
+ // ../../packages/core/dist/chunk-JOOVAYGO.js
11317
11318
  function normalizeDecisionsModelId(modelId) {
11318
11319
  return modelId.trim().toLowerCase();
11319
11320
  }
@@ -11384,10 +11385,10 @@ function readAgentSettingsModel(agentSettings) {
11384
11385
  return typeof model === "string" ? model : null;
11385
11386
  }
11386
11387
  var DECISIONS_MODEL_PREFIXES, DECISION_CAPABLE_AGENT_ROLES;
11387
- var init_chunk_7IXDF53E = __esm({
11388
- "../../packages/core/dist/chunk-7IXDF53E.js"() {
11388
+ var init_chunk_JOOVAYGO = __esm({
11389
+ "../../packages/core/dist/chunk-JOOVAYGO.js"() {
11389
11390
  "use strict";
11390
- init_chunk_55RZ7YIF();
11391
+ init_chunk_IEEMZR55();
11391
11392
  init_chunk_L5F7ZOUJ();
11392
11393
  DECISIONS_MODEL_PREFIXES = ["typesafe/jev-", "jev-"];
11393
11394
  DECISION_CAPABLE_AGENT_ROLES = [
@@ -11398,7 +11399,7 @@ var init_chunk_7IXDF53E = __esm({
11398
11399
  }
11399
11400
  });
11400
11401
 
11401
- // ../../packages/core/dist/chunk-L4YFOZGK.js
11402
+ // ../../packages/core/dist/chunk-LYB5XDDT.js
11402
11403
  function resolveMonitorTrigger(monitorConfig) {
11403
11404
  if (!monitorConfig || typeof monitorConfig !== "object") return "idle";
11404
11405
  const raw = monitorConfig.trigger;
@@ -11704,16 +11705,16 @@ function refineMonitorRulesStructuredOutput(body, ctx) {
11704
11705
  if (refusal2) ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["response_format"], message: refusal2 });
11705
11706
  }
11706
11707
  var previousConversationsCountField, summarizationThresholdField, flagConditionSchema, MONITOR_TRIGGERS, monitorTriggerSchema, AUTOMATION_GATE_TRIGGERS, NON_FIRING_TRIGGERS, MONITOR_FIRING_TRIGGERS, MONITOR_DELAY_SECONDS_MIN, MONITOR_IDLE_DELAY_REQUIRED_MESSAGE, MONITOR_HISTORY_MESSAGES_MAX, monitorHistoryMessagesSchema, monitorIncludeToolResultsSchema, MONITOR_INPUT_SHAPING_KEYS, MONITOR_INPUT_SHAPING_SCHEMAS, MONITOR_INPUT_SHAPING_IDLE_MESSAGE, monitorArgumentSourceSchema, MONITOR_NOTE_TEMPLATE_MAX, MONITOR_STEER_NOTE_MAX, MONITOR_GATE_AGENT_NAME_MAX, monitorActionSchema, monitorRuleSchema, MONITOR_RULE_KEYS, MONITOR_RULE_SCHEMAS, MONITOR_RULE_TRIGGERS, MONITOR_RULE_TRIGGER_MESSAGE, CALL_UTTERANCE_SPEAKERS, callUtteranceSpeakerSchema, MONITOR_CALL_KEYS, MONITOR_CALL_SCHEMAS, MONITOR_CALL_KEY_MESSAGE, CALL_STEERING_MIN_CONFIDENCE, CALL_UTTERANCE_RULE_NOT_CONFIDENT_MESSAGE, CALL_UTTERANCE_FALLBACK_MESSAGE, CALL_UTTERANCE_FLAG_CONDITIONS_MESSAGE, CALL_STEER_NOTE_BLANK_MESSAGE, MONITOR_USER_MESSAGE_ACTION_KINDS, MONITOR_ASSISTANT_REPLY_ACTION_KINDS, MONITOR_CALL_UTTERANCE_ACTION_KINDS, MONITOR_AUTOMATION_FIRE_ACTION_KINDS, MONITOR_AUTOMATION_ITEM_ACTION_KINDS, INSERT_NOTE_TOOL_NAME, RUN_MONITOR_TOOL_NAME, MONITOR_RULE_ALLOWED_NATIVE_TOOLS, MONITOR_RULE_REENTRY_TOOLS, MONITOR_RULE_REENTRY_TRACKS, AUTOMATION_FIRE_FLAG_CONDITIONS_MESSAGE, AUTOMATION_FIRE_INPUT_SHAPING_MESSAGE, AUTOMATION_ITEM_FLAG_CONDITIONS_MESSAGE, AUTOMATION_ITEM_INPUT_SHAPING_MESSAGE, AUTOMATION_GATE_KEY_MESSAGES, monitorConfigField, flagConditionsField, agentIdParam, listAgentsQuery, agentConnectionsQuery, createAgentBody, updateAgentBody, AGENT_PARAMETER_TYPES, AGENT_PARAMETER_NAME_REGEX, agentParameterCreateSchema, MAX_AGENT_PARAMETERS_PER_REQUEST, createAgentParametersBody;
11707
- var init_chunk_L4YFOZGK = __esm({
11708
- "../../packages/core/dist/chunk-L4YFOZGK.js"() {
11708
+ var init_chunk_LYB5XDDT = __esm({
11709
+ "../../packages/core/dist/chunk-LYB5XDDT.js"() {
11709
11710
  "use strict";
11710
11711
  init_chunk_IBL7FANV();
11711
11712
  init_chunk_KB5RK3RP();
11712
11713
  init_chunk_C2UEA2KW();
11713
11714
  init_chunk_HZ6CADSY();
11714
- init_chunk_7IXDF53E();
11715
- init_chunk_JHUTFQDO();
11716
- init_chunk_YROEDMVZ();
11715
+ init_chunk_JOOVAYGO();
11716
+ init_chunk_4IXIQQ2A();
11717
+ init_chunk_NYNOISIG();
11717
11718
  init_chunk_L5F7ZOUJ();
11718
11719
  init_zod();
11719
11720
  previousConversationsCountField = external_exports.number().int().min(0).max(PREVIOUS_CONVERSATIONS_MAX).nullable().optional();
@@ -11929,14 +11930,14 @@ var init_chunk_L4YFOZGK = __esm({
11929
11930
  }
11930
11931
  });
11931
11932
 
11932
- // ../../packages/core/dist/chunk-65MH4JRN.js
11933
+ // ../../packages/core/dist/chunk-4B7VQDLJ.js
11933
11934
  var conversationIdParam, conversationHubQuery, claimBody, releaseBody, transferBody, closeBody, additionalContextPayloadSchema, kanbanUpdateBody, annotateConversationBody, observabilityParams, observabilityListParams, deleteUserConversationsBody, deleteUserConversationsResponse, sendMessageBody, listConversationsQuery, flagSourceSchema, getConversationsResponse, getConversationDetailParams, getConversationDetailQuery, getConversationDetailResponse, listWhatsAppTemplatesQuery, sendWhatsAppTemplateBody;
11934
- var init_chunk_65MH4JRN = __esm({
11935
- "../../packages/core/dist/chunk-65MH4JRN.js"() {
11935
+ var init_chunk_4B7VQDLJ = __esm({
11936
+ "../../packages/core/dist/chunk-4B7VQDLJ.js"() {
11936
11937
  "use strict";
11937
- init_chunk_L4YFOZGK();
11938
+ init_chunk_LYB5XDDT();
11938
11939
  init_chunk_HZ6CADSY();
11939
- init_chunk_YROEDMVZ();
11940
+ init_chunk_NYNOISIG();
11940
11941
  init_zod();
11941
11942
  conversationIdParam = external_exports.object({
11942
11943
  id: external_exports.string().uuid()
@@ -12737,89 +12738,143 @@ var init_chunk_ACGAI25T = __esm({
12737
12738
  }
12738
12739
  });
12739
12740
 
12740
- // ../../packages/core/dist/chunk-PZPOUXJR.js
12741
- var navItemSchema, hubCountResetBody, navItemCountResetBody, typingBody;
12742
- var init_chunk_PZPOUXJR = __esm({
12743
- "../../packages/core/dist/chunk-PZPOUXJR.js"() {
12744
- "use strict";
12745
- init_zod();
12746
- navItemSchema = external_exports.enum(["chat", "support", "task"]);
12747
- hubCountResetBody = external_exports.object({
12748
- hub_id: external_exports.string().uuid(),
12749
- nav_item: navItemSchema,
12750
- conversation_id: external_exports.string().uuid().optional(),
12751
- hub_user_id: external_exports.string().optional(),
12752
- current_team_user_id: external_exports.string().optional()
12753
- });
12754
- navItemCountResetBody = external_exports.object({
12755
- nav_item: navItemSchema
12756
- });
12757
- typingBody = external_exports.object({
12758
- conversationId: external_exports.string().uuid(),
12759
- hubId: external_exports.string().uuid(),
12760
- action: external_exports.enum(["start", "stop"])
12761
- });
12741
+ // ../../packages/core/dist/chunk-FOFCV4SW.js
12742
+ function isCaseAttributeDate(text4) {
12743
+ const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(text4);
12744
+ if (!match) return false;
12745
+ const [year, month, day] = [Number(match[1]), Number(match[2]), Number(match[3])];
12746
+ const leap = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
12747
+ const days = [31, leap ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month - 1];
12748
+ return days !== void 0 && day >= 1 && day <= days;
12749
+ }
12750
+ function valueProblem(property, value) {
12751
+ switch (property.type) {
12752
+ case "string":
12753
+ if (typeof value !== "string") return "attribute_wrong_type";
12754
+ break;
12755
+ case "number":
12756
+ if (typeof value !== "number" || !Number.isFinite(value)) return "attribute_wrong_type";
12757
+ break;
12758
+ case "integer":
12759
+ if (typeof value !== "number" || !Number.isInteger(value)) return "attribute_wrong_type";
12760
+ break;
12761
+ case "boolean":
12762
+ if (typeof value !== "boolean") return "attribute_wrong_type";
12763
+ break;
12764
+ default:
12765
+ break;
12762
12766
  }
12763
- });
12764
-
12765
- // ../../packages/core/dist/chunk-YWZFB34T.js
12766
- function cacheReconcileIdCount(body) {
12767
- return body.conversations.length + body.histories.reduce((n, history) => n + history.conversation_ids.length, 0) + body.threads.length;
12767
+ if (property.format === "date" && typeof value === "string" && !isCaseAttributeDate(value)) return "attribute_not_a_date";
12768
+ return null;
12768
12769
  }
12769
- var CACHE_RECONCILE_MAX_IDS, CACHE_RECONCILE_MAX_HUBS, cacheReconcileScopeSchema, cachedConversationPageSchema, cachedHistoryThreadSchema, cachedPeopleThreadSchema, cacheReconcileBody;
12770
- var init_chunk_YWZFB34T = __esm({
12771
- "../../packages/core/dist/chunk-YWZFB34T.js"() {
12770
+ function propertiesOf(schema) {
12771
+ return Object.entries(schema.properties ?? {});
12772
+ }
12773
+ function caseAttributesSchemaProblem(schema) {
12774
+ for (const [key, property] of propertiesOf(schema)) {
12775
+ if (property.type === void 0 && property.enum === void 0) return { reason: "attribute_type_missing", at: key };
12776
+ if (property.format !== void 0 && property.type !== "string") return { reason: "attribute_format_unexpected", at: key };
12777
+ if (property.enum) {
12778
+ if (new Set(property.enum).size !== property.enum.length) return { reason: "attribute_option_repeated", at: key };
12779
+ if (property.enum.some((option) => valueProblem(property, option) !== null)) return { reason: "attribute_option_mismatch", at: key };
12780
+ }
12781
+ }
12782
+ const required = schema.required ?? [];
12783
+ if (new Set(required).size !== required.length) return { reason: "attribute_required_repeated", at: "required" };
12784
+ const unknown = required.find((key) => !Object.hasOwn(schema.properties ?? {}, key));
12785
+ if (unknown !== void 0) return { reason: "attribute_required_unknown", at: unknown };
12786
+ return null;
12787
+ }
12788
+ var CASE_ATTRIBUTE_KEY_PATTERN, CASE_ATTRIBUTE_KEY_MAX_LENGTH, CASE_ATTRIBUTE_TYPES, CASE_ATTRIBUTE_FORMATS, CASE_ATTRIBUTE_PROPERTIES_MAX, CASE_ATTRIBUTE_OPTIONS_MAX, CASE_ATTRIBUTE_TITLE_MAX_LENGTH, CASE_ATTRIBUTE_DESCRIPTION_MAX_LENGTH, CASE_ATTRIBUTE_OPTION_MAX_LENGTH, CASE_ATTRIBUTES_MAX_CHARS, EMPTY_CASE_ATTRIBUTES_SCHEMA, caseAttributePropertySchema, attributeKey, caseAttributesSchemaSchema;
12789
+ var init_chunk_FOFCV4SW = __esm({
12790
+ "../../packages/core/dist/chunk-FOFCV4SW.js"() {
12772
12791
  "use strict";
12773
- init_chunk_PZPOUXJR();
12774
- init_chunk_HZ6CADSY();
12775
12792
  init_zod();
12776
- CACHE_RECONCILE_MAX_IDS = 300;
12777
- CACHE_RECONCILE_MAX_HUBS = 15;
12778
- cacheReconcileScopeSchema = navItemSchema;
12779
- cachedConversationPageSchema = external_exports.object({
12780
- conversation_id: uuidSchema,
12781
- hub_id: uuidSchema,
12782
- scope: cacheReconcileScopeSchema
12793
+ CASE_ATTRIBUTE_KEY_PATTERN = /^[a-z][a-z0-9_]*$/;
12794
+ CASE_ATTRIBUTE_KEY_MAX_LENGTH = 64;
12795
+ CASE_ATTRIBUTE_TYPES = ["string", "number", "integer", "boolean"];
12796
+ CASE_ATTRIBUTE_FORMATS = ["date"];
12797
+ CASE_ATTRIBUTE_PROPERTIES_MAX = 100;
12798
+ CASE_ATTRIBUTE_OPTIONS_MAX = 100;
12799
+ CASE_ATTRIBUTE_TITLE_MAX_LENGTH = 200;
12800
+ CASE_ATTRIBUTE_DESCRIPTION_MAX_LENGTH = 2e3;
12801
+ CASE_ATTRIBUTE_OPTION_MAX_LENGTH = 200;
12802
+ CASE_ATTRIBUTES_MAX_CHARS = 16 * 1024;
12803
+ EMPTY_CASE_ATTRIBUTES_SCHEMA = { type: "object" };
12804
+ caseAttributePropertySchema = external_exports.object({
12805
+ type: external_exports.enum(CASE_ATTRIBUTE_TYPES).optional(),
12806
+ title: external_exports.string().min(1).max(CASE_ATTRIBUTE_TITLE_MAX_LENGTH).optional(),
12807
+ description: external_exports.string().max(CASE_ATTRIBUTE_DESCRIPTION_MAX_LENGTH).optional(),
12808
+ /** The values it may take, shown as a list to pick from. */
12809
+ enum: external_exports.array(external_exports.union([external_exports.string().max(CASE_ATTRIBUTE_OPTION_MAX_LENGTH), external_exports.number().finite()])).min(1).max(CASE_ATTRIBUTE_OPTIONS_MAX).optional(),
12810
+ /** `date`: a calendar date, `YYYY-MM-DD`. */
12811
+ format: external_exports.enum(CASE_ATTRIBUTE_FORMATS).optional()
12783
12812
  }).strict();
12784
- cachedHistoryThreadSchema = external_exports.object({
12785
- hub_id: uuidSchema,
12786
- hub_user_id: external_exports.string().min(1).max(128),
12787
- nav: cacheReconcileScopeSchema,
12788
- conversation_ids: external_exports.array(uuidSchema).min(1).max(CACHE_RECONCILE_MAX_IDS)
12813
+ attributeKey = external_exports.string().max(CASE_ATTRIBUTE_KEY_MAX_LENGTH).regex(CASE_ATTRIBUTE_KEY_PATTERN);
12814
+ caseAttributesSchemaSchema = external_exports.object({
12815
+ type: external_exports.literal("object"),
12816
+ properties: external_exports.record(attributeKey, caseAttributePropertySchema).refine((properties) => Object.keys(properties).length <= CASE_ATTRIBUTE_PROPERTIES_MAX, "Too many properties").optional(),
12817
+ required: external_exports.array(attributeKey).max(CASE_ATTRIBUTE_PROPERTIES_MAX).optional()
12789
12818
  }).strict();
12790
- cachedPeopleThreadSchema = external_exports.object({ thread_id: uuidSchema }).strict();
12791
- cacheReconcileBody = external_exports.object({
12792
- conversations: external_exports.array(cachedConversationPageSchema).max(CACHE_RECONCILE_MAX_IDS).default([]),
12793
- histories: external_exports.array(cachedHistoryThreadSchema).max(CACHE_RECONCILE_MAX_IDS).default([]),
12794
- threads: external_exports.array(cachedPeopleThreadSchema).max(CACHE_RECONCILE_MAX_IDS).default([])
12795
- }).strict().superRefine((body, ctx) => {
12796
- if (cacheReconcileIdCount(body) > CACHE_RECONCILE_MAX_IDS) {
12797
- ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: `At most ${CACHE_RECONCILE_MAX_IDS} ids in all` });
12798
- }
12799
- const hubs = new Set([...body.conversations, ...body.histories].map((entry) => entry.hub_id));
12800
- if (hubs.size > CACHE_RECONCILE_MAX_HUBS) {
12801
- ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: `At most ${CACHE_RECONCILE_MAX_HUBS} distinct hubs` });
12802
- }
12819
+ }
12820
+ });
12821
+
12822
+ // ../../packages/core/dist/chunk-VYINA6YP.js
12823
+ function formatterOf(zone) {
12824
+ const held = formatters.get(zone);
12825
+ if (held) return held;
12826
+ if (zone.length === 0 || zone.length > TIME_ZONE_NAME_MAX_LENGTH) return null;
12827
+ let formatter;
12828
+ try {
12829
+ formatter = new Intl.DateTimeFormat("en-US", {
12830
+ timeZone: zone,
12831
+ calendar: "iso8601",
12832
+ numberingSystem: "latn",
12833
+ year: "numeric",
12834
+ month: "2-digit",
12835
+ day: "2-digit"
12803
12836
  });
12837
+ } catch {
12838
+ return null;
12839
+ }
12840
+ const resolved = formatter.resolvedOptions().timeZone;
12841
+ if (!/^[A-Za-z]/.test(resolved)) return null;
12842
+ if (resolved === zone) formatters.set(zone, formatter);
12843
+ return formatter;
12844
+ }
12845
+ function isTimeZone(zone) {
12846
+ return formatterOf(zone) !== null;
12847
+ }
12848
+ var TIME_ZONE_NAME_MAX_LENGTH, formatters;
12849
+ var init_chunk_VYINA6YP = __esm({
12850
+ "../../packages/core/dist/chunk-VYINA6YP.js"() {
12851
+ "use strict";
12852
+ TIME_ZONE_NAME_MAX_LENGTH = 64;
12853
+ formatters = /* @__PURE__ */ new Map();
12804
12854
  }
12805
12855
  });
12806
12856
 
12807
- // ../../packages/core/dist/chunk-GAANFFN7.js
12808
- var CASE_SPACE_NAME_MAX_LENGTH, CASE_TEAM_NAME_MAX_LENGTH, CASE_TEAM_MEMBERS_MAX, CASE_MEMBERS_PAGE_MAX, CASE_PAGE_CURSOR_MAX_LENGTH, CASE_LEVELS, CASE_REGISTRY_CLOSED_REASON, caseSpaceNameSchema, adminCreateCaseSpaceBody, caseOrgParam, caseSpaceParam, caseMemberParam, caseAdministratorParam, caseTeamParam, casePageQuery, saveCaseMemberBody, caseTeamScopeSchema, caseTeamMemberInput, caseTeamFields, createCaseTeamBody, updateCaseTeamBody;
12809
- var init_chunk_GAANFFN7 = __esm({
12810
- "../../packages/core/dist/chunk-GAANFFN7.js"() {
12857
+ // ../../packages/core/dist/chunk-6IDXKJKK.js
12858
+ var CASE_SPACE_NAME_MAX_LENGTH, CASE_TEAM_NAME_MAX_LENGTH, CASE_TEAM_MEMBERS_MAX, CASE_TEAM_SCOPES_MAX, CASE_MEMBERS_PAGE_MAX, CASE_PAGE_CURSOR_MAX_LENGTH, CASE_LEVELS, CASE_TEAM_TARGET_KINDS, CASE_REGISTRY_CLOSED_REASON, caseSpaceNameSchema, caseSpaceTimeZoneSchema, updateCaseSpaceSettingsBody, adminCreateCaseSpaceBody, caseOrgParam, caseSpaceParam, caseMemberParam, caseAdministratorParam, caseTeamParam, casePageQuery, saveCaseMemberBody, caseTeamScopeSchema, caseTeamMemberInput, caseTeamFields, createCaseTeamBody, updateCaseTeamBody;
12859
+ var init_chunk_6IDXKJKK = __esm({
12860
+ "../../packages/core/dist/chunk-6IDXKJKK.js"() {
12811
12861
  "use strict";
12862
+ init_chunk_VYINA6YP();
12812
12863
  init_chunk_ZVXO3XL6();
12813
12864
  init_chunk_HZ6CADSY();
12814
12865
  init_zod();
12815
12866
  CASE_SPACE_NAME_MAX_LENGTH = 200;
12816
12867
  CASE_TEAM_NAME_MAX_LENGTH = 200;
12817
12868
  CASE_TEAM_MEMBERS_MAX = 1e3;
12869
+ CASE_TEAM_SCOPES_MAX = 200;
12818
12870
  CASE_MEMBERS_PAGE_MAX = 200;
12819
12871
  CASE_PAGE_CURSOR_MAX_LENGTH = 2048;
12820
12872
  CASE_LEVELS = ["read", "edit", "conduct"];
12873
+ CASE_TEAM_TARGET_KINDS = ["party_group", "party", "instrument", "case_type"];
12821
12874
  CASE_REGISTRY_CLOSED_REASON = "case_registry_closed";
12822
12875
  caseSpaceNameSchema = external_exports.string().trim().min(1).max(CASE_SPACE_NAME_MAX_LENGTH);
12876
+ caseSpaceTimeZoneSchema = external_exports.string().trim().min(1).max(TIME_ZONE_NAME_MAX_LENGTH).refine(isTimeZone, "Not a time zone (an IANA name such as America/Sao_Paulo)");
12877
+ updateCaseSpaceSettingsBody = external_exports.object({ timezone: caseSpaceTimeZoneSchema }).strict();
12823
12878
  adminCreateCaseSpaceBody = external_exports.object({ org_id: uuidSchema, name: caseSpaceNameSchema }).strict();
12824
12879
  caseOrgParam = external_exports.object({ org_id: uuidSchema });
12825
12880
  caseSpaceParam = caseOrgParam.extend({ space_id: uuidSchema });
@@ -12833,9 +12888,13 @@ var init_chunk_GAANFFN7 = __esm({
12833
12888
  saveCaseMemberBody = external_exports.object({
12834
12889
  user_id: peopleUserIdSchema,
12835
12890
  guest: external_exports.boolean().default(false),
12836
- registry: external_exports.boolean().default(false)
12891
+ registry: external_exports.boolean().default(false),
12892
+ existing: external_exports.boolean().optional()
12837
12893
  }).strict().refine((body) => !(body.guest && body.registry), { message: "A guest cannot hold the Registry flag", path: ["registry"] });
12838
- caseTeamScopeSchema = external_exports.object({ kind: external_exports.literal("space"), target_id: external_exports.null() }).strict();
12894
+ caseTeamScopeSchema = external_exports.discriminatedUnion("kind", [
12895
+ external_exports.object({ kind: external_exports.literal("space"), target_id: external_exports.null() }).strict(),
12896
+ external_exports.object({ kind: external_exports.enum(CASE_TEAM_TARGET_KINDS), target_id: uuidSchema }).strict()
12897
+ ]);
12839
12898
  caseTeamMemberInput = external_exports.object({
12840
12899
  person_id: uuidSchema,
12841
12900
  level: external_exports.enum(CASE_LEVELS),
@@ -12845,7 +12904,7 @@ var init_chunk_GAANFFN7 = __esm({
12845
12904
  caseTeamFields = {
12846
12905
  name: external_exports.string().trim().min(1).max(CASE_TEAM_NAME_MAX_LENGTH),
12847
12906
  active: external_exports.boolean(),
12848
- scopes: external_exports.array(caseTeamScopeSchema).max(1),
12907
+ scopes: external_exports.array(caseTeamScopeSchema).max(CASE_TEAM_SCOPES_MAX),
12849
12908
  members: external_exports.array(caseTeamMemberInput).max(CASE_TEAM_MEMBERS_MAX)
12850
12909
  };
12851
12910
  createCaseTeamBody = external_exports.object(caseTeamFields).strict();
@@ -12853,6 +12912,557 @@ var init_chunk_GAANFFN7 = __esm({
12853
12912
  }
12854
12913
  });
12855
12914
 
12915
+ // ../../packages/core/dist/chunk-NB5PNVSF.js
12916
+ function withProblem(shape, problemOf) {
12917
+ return shape.superRefine((value, ctx) => {
12918
+ const found = problemOf(value);
12919
+ if (found) {
12920
+ ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: found.reason, path: found.at.split("."), params: { case_registry_reason: found.reason } });
12921
+ }
12922
+ });
12923
+ }
12924
+ function caseRegistryTypeProblem(type) {
12925
+ const found = caseAttributesSchemaProblem(type.attributes);
12926
+ if (found) return { reason: found.reason, at: `attributes.${found.at}` };
12927
+ if (JSON.stringify(type.attributes).length > CASE_REGISTRY_TYPE_SCHEMA_MAX_CHARS) return { reason: "attributes_schema_too_large", at: "attributes" };
12928
+ return null;
12929
+ }
12930
+ function casePartyProblem(party) {
12931
+ if (party.document_kind === null !== (party.document_number === null)) return { reason: "document_incomplete", at: "document_number" };
12932
+ if (party.document_kind === "cpf" || party.document_kind === "cnpj") {
12933
+ if (party.person_kind !== (party.document_kind === "cpf" ? "natural" : "legal")) return { reason: "document_person_mismatch", at: "document_kind" };
12934
+ if (!(party.document_kind === "cpf" ? /^[0-9]{11}$/ : /^[0-9]{14}$/).test(party.document_number ?? "")) {
12935
+ return { reason: "document_digits", at: "document_number" };
12936
+ }
12937
+ }
12938
+ return null;
12939
+ }
12940
+ function casePartyGroupProblem(group) {
12941
+ return new Set(group.party_ids).size === group.party_ids.length ? null : { reason: "party_repeated", at: "party_ids" };
12942
+ }
12943
+ function caseInstrumentProblem(instrument) {
12944
+ if (instrument.effective_from !== null && instrument.effective_until !== null && instrument.effective_until < instrument.effective_from) {
12945
+ return { reason: "effective_dates_reversed", at: "effective_until" };
12946
+ }
12947
+ const keys = instrument.parties.map((party) => `${party.party_id}
12948
+ ${party.role}`);
12949
+ return new Set(keys).size === keys.length ? null : { reason: "instrument_party_repeated", at: "parties" };
12950
+ }
12951
+ var CASE_REGISTRY_TYPE_CODE_PATTERN, CASE_REGISTRY_TYPE_CODE_MAX_LENGTH, CASE_REGISTRY_NAME_MAX_LENGTH, CASE_REGISTRY_TYPE_SCHEMA_MAX_CHARS, CASE_PARTY_ABBREVIATION_PATTERN, CASE_PARTY_PERSON_KINDS, CASE_PARTY_DOCUMENT_KINDS, CASE_PARTY_DOCUMENT_MAX_LENGTH, CASE_PARTY_GROUP_MEMBERS_MAX, CASE_INSTRUMENT_NUMBER_MAX_LENGTH, CASE_INSTRUMENT_ROLE_MAX_LENGTH, CASE_INSTRUMENT_PARTIES_MAX, CASE_REGISTRY_PAGE_MAX, CASE_REGISTRY_QUERY_MAX_LENGTH, trimmedName, dateSchema, attributesValues, registryTypeFields, createCaseRegistryTypeShape, updateCaseRegistryTypeShape, createCaseRegistryTypeBody, updateCaseRegistryTypeBody, saveCasePartyShape, saveCasePartyBody, saveCasePartyGroupShape, saveCasePartyGroupBody, caseInstrumentPartyInput, saveCaseInstrumentShape, saveCaseInstrumentBody, registryPage, searchText, casePartiesQuery, casePartyGroupsQuery, caseInstrumentsQuery, caseRegistryTypeParam, casePartyParam, casePartyGroupParam, caseInstrumentParam;
12952
+ var init_chunk_NB5PNVSF = __esm({
12953
+ "../../packages/core/dist/chunk-NB5PNVSF.js"() {
12954
+ "use strict";
12955
+ init_chunk_FOFCV4SW();
12956
+ init_chunk_6IDXKJKK();
12957
+ init_chunk_HZ6CADSY();
12958
+ init_zod();
12959
+ CASE_REGISTRY_TYPE_CODE_PATTERN = /^[a-z0-9]+(_[a-z0-9]+)*$/;
12960
+ CASE_REGISTRY_TYPE_CODE_MAX_LENGTH = 64;
12961
+ CASE_REGISTRY_NAME_MAX_LENGTH = 200;
12962
+ CASE_REGISTRY_TYPE_SCHEMA_MAX_CHARS = 64 * 1024;
12963
+ CASE_PARTY_ABBREVIATION_PATTERN = /^[A-Z0-9]{2,12}$/;
12964
+ CASE_PARTY_PERSON_KINDS = ["natural", "legal"];
12965
+ CASE_PARTY_DOCUMENT_KINDS = ["cpf", "cnpj", "other"];
12966
+ CASE_PARTY_DOCUMENT_MAX_LENGTH = 64;
12967
+ CASE_PARTY_GROUP_MEMBERS_MAX = 2e3;
12968
+ CASE_INSTRUMENT_NUMBER_MAX_LENGTH = 200;
12969
+ CASE_INSTRUMENT_ROLE_MAX_LENGTH = 200;
12970
+ CASE_INSTRUMENT_PARTIES_MAX = 50;
12971
+ CASE_REGISTRY_PAGE_MAX = 100;
12972
+ CASE_REGISTRY_QUERY_MAX_LENGTH = 200;
12973
+ trimmedName = external_exports.string().trim().min(1).max(CASE_REGISTRY_NAME_MAX_LENGTH);
12974
+ dateSchema = external_exports.string().refine(isCaseAttributeDate, "Not a date (YYYY-MM-DD)");
12975
+ attributesValues = external_exports.record(external_exports.string(), external_exports.unknown()).default({});
12976
+ registryTypeFields = {
12977
+ name: trimmedName,
12978
+ attributes: caseAttributesSchemaSchema.default(EMPTY_CASE_ATTRIBUTES_SCHEMA),
12979
+ active: external_exports.boolean().default(true)
12980
+ };
12981
+ createCaseRegistryTypeShape = external_exports.object({
12982
+ code: external_exports.string().trim().max(CASE_REGISTRY_TYPE_CODE_MAX_LENGTH).regex(CASE_REGISTRY_TYPE_CODE_PATTERN),
12983
+ ...registryTypeFields
12984
+ }).strict();
12985
+ updateCaseRegistryTypeShape = external_exports.object({
12986
+ ...registryTypeFields,
12987
+ expected_updated_at: timestampSchema.optional()
12988
+ }).strict();
12989
+ createCaseRegistryTypeBody = withProblem(createCaseRegistryTypeShape, caseRegistryTypeProblem);
12990
+ updateCaseRegistryTypeBody = withProblem(updateCaseRegistryTypeShape, caseRegistryTypeProblem);
12991
+ saveCasePartyShape = external_exports.object({
12992
+ type_id: uuidSchema,
12993
+ name: trimmedName,
12994
+ abbreviation: external_exports.string().trim().transform((value) => value.toUpperCase()).pipe(external_exports.string().regex(CASE_PARTY_ABBREVIATION_PATTERN)).nullable().default(null),
12995
+ person_kind: external_exports.enum(CASE_PARTY_PERSON_KINDS),
12996
+ document_kind: external_exports.enum(CASE_PARTY_DOCUMENT_KINDS).nullable().default(null),
12997
+ document_number: external_exports.string().trim().min(1).max(CASE_PARTY_DOCUMENT_MAX_LENGTH).nullable().default(null),
12998
+ attributes: attributesValues,
12999
+ active: external_exports.boolean().default(true),
13000
+ expected_updated_at: timestampSchema.optional()
13001
+ }).strict();
13002
+ saveCasePartyBody = withProblem(saveCasePartyShape, casePartyProblem);
13003
+ saveCasePartyGroupShape = external_exports.object({
13004
+ name: trimmedName,
13005
+ party_ids: external_exports.array(uuidSchema).max(CASE_PARTY_GROUP_MEMBERS_MAX).default([]),
13006
+ expected_updated_at: timestampSchema.optional()
13007
+ }).strict();
13008
+ saveCasePartyGroupBody = withProblem(saveCasePartyGroupShape, casePartyGroupProblem);
13009
+ caseInstrumentPartyInput = external_exports.object({
13010
+ party_id: uuidSchema,
13011
+ role: external_exports.string().trim().min(1).max(CASE_INSTRUMENT_ROLE_MAX_LENGTH)
13012
+ }).strict();
13013
+ saveCaseInstrumentShape = external_exports.object({
13014
+ type_id: uuidSchema,
13015
+ number: external_exports.string().trim().min(1).max(CASE_INSTRUMENT_NUMBER_MAX_LENGTH),
13016
+ signed_on: dateSchema.nullable().default(null),
13017
+ effective_from: dateSchema.nullable().default(null),
13018
+ effective_until: dateSchema.nullable().default(null),
13019
+ attributes: attributesValues,
13020
+ /** Each party in a role; one party may hold several roles. */
13021
+ parties: external_exports.array(caseInstrumentPartyInput).max(CASE_INSTRUMENT_PARTIES_MAX).default([]),
13022
+ expected_updated_at: timestampSchema.optional()
13023
+ }).strict();
13024
+ saveCaseInstrumentBody = withProblem(saveCaseInstrumentShape, caseInstrumentProblem);
13025
+ registryPage = casePageQuery.extend({
13026
+ limit: external_exports.coerce.number().int().min(1).max(CASE_REGISTRY_PAGE_MAX).optional()
13027
+ });
13028
+ searchText = external_exports.string().trim().min(1).max(CASE_REGISTRY_QUERY_MAX_LENGTH).optional();
13029
+ casePartiesQuery = registryPage.extend({
13030
+ q: searchText,
13031
+ type_id: uuidSchema.optional(),
13032
+ active: external_exports.enum(["true", "false"]).transform((value) => value === "true").optional()
13033
+ });
13034
+ casePartyGroupsQuery = registryPage.extend({ q: searchText });
13035
+ caseInstrumentsQuery = registryPage.extend({
13036
+ q: searchText,
13037
+ type_id: uuidSchema.optional(),
13038
+ party_id: uuidSchema.optional()
13039
+ });
13040
+ caseRegistryTypeParam = caseSpaceParam.extend({ type_id: uuidSchema });
13041
+ casePartyParam = caseSpaceParam.extend({ party_id: uuidSchema });
13042
+ casePartyGroupParam = caseSpaceParam.extend({ group_id: uuidSchema });
13043
+ caseInstrumentParam = caseSpaceParam.extend({ instrument_id: uuidSchema });
13044
+ }
13045
+ });
13046
+
13047
+ // ../../packages/core/dist/chunk-CXKQ2DHH.js
13048
+ var NEVER2;
13049
+ var init_chunk_CXKQ2DHH = __esm({
13050
+ "../../packages/core/dist/chunk-CXKQ2DHH.js"() {
13051
+ "use strict";
13052
+ init_chunk_MIWZOSPI();
13053
+ NEVER2 = Number.POSITIVE_INFINITY;
13054
+ }
13055
+ });
13056
+
13057
+ // ../../packages/core/dist/chunk-BGOBDSII.js
13058
+ function resolveItemLink(phaseFolder, target) {
13059
+ const slash = target.lastIndexOf("/");
13060
+ const folder = slash < 0 ? phaseFolder : target.slice(0, slash);
13061
+ const code2 = target.slice(slash + 1);
13062
+ return { folder, code: code2, key: `${folder}/${code2}` };
13063
+ }
13064
+ function caseTypeDefinitionRows(definition) {
13065
+ let rows = 1 + definition.type_party_roles.length + definition.type_outcomes.length;
13066
+ for (const phase of definition.type_phases) {
13067
+ rows += 1 + phase.depends_on.length + phase.phase_inputs.length;
13068
+ for (const task of phase.type_tasks) rows += 1 + task.depends_on.length;
13069
+ for (const group of phase.agenda_groups) rows += 1 + group.approving_team_ids.length + group.agenda_decisions.length;
13070
+ for (const output of phase.phase_outputs) {
13071
+ rows += 1;
13072
+ for (const item of output.output_items) {
13073
+ const { inputs, calculations, decisions } = item.item_requirements;
13074
+ rows += 1 + inputs.length + calculations.length + decisions.length + item.item_links.depends_on.length + (item.item_links.reflects ? 1 : 0);
13075
+ }
13076
+ }
13077
+ }
13078
+ return rows;
13079
+ }
13080
+ function caseTaskRequired(phase, task) {
13081
+ if (task.output !== null) return phase.phase_outputs.find((output) => output.code === task.output)?.required ?? false;
13082
+ if (task.input !== null) return phase.phase_inputs.find((input) => input.key === task.input)?.required ?? false;
13083
+ if (task.agenda_group !== null) return phase.agenda_groups.find((group) => group.code === task.agenda_group)?.required ?? false;
13084
+ return task.required;
13085
+ }
13086
+ function decisionProblem(decision) {
13087
+ if (decision.type === "choice") {
13088
+ if (decision.options.length < 2) return "decision_options_missing";
13089
+ if (repeated(decision.options.map((option) => option.code))) return "decision_option_code_repeated";
13090
+ } else if (decision.options.length > 0) {
13091
+ return "decision_options_unexpected";
13092
+ }
13093
+ const numeric = CASE_NUMERIC_DECISION_TYPES.includes(decision.type);
13094
+ if (!numeric && (decision.min !== null || decision.max !== null)) return "decision_bounds_unexpected";
13095
+ if (!numeric && decision.decimals !== null) return "decision_decimals_unexpected";
13096
+ if (decision.min !== null && decision.max !== null && decision.min > decision.max) return "decision_bounds_inverted";
13097
+ return null;
13098
+ }
13099
+ function cycleIn(nodes, edges) {
13100
+ const state = /* @__PURE__ */ new Map();
13101
+ const visit = (node) => {
13102
+ if (state.get(node) === "done") return false;
13103
+ if (state.get(node) === "open") return true;
13104
+ state.set(node, "open");
13105
+ for (const next of edges.get(node) ?? []) if (visit(next)) return true;
13106
+ state.set(node, "done");
13107
+ return false;
13108
+ };
13109
+ return nodes.find((node) => visit(node)) ?? null;
13110
+ }
13111
+ function fixedTextProblem(text4) {
13112
+ if (text4.includes("<!--")) return "item_fixed_text_comment";
13113
+ const lines = text4.replace(/\r\n?/g, "\n").split("\n");
13114
+ let fence = null;
13115
+ let closedAt = -1;
13116
+ for (let i = 0; i < lines.length; i++) {
13117
+ const line = lines[i];
13118
+ const mark = /^ {0,3}(`{3,}|~{3,})/.exec(line)?.[1];
13119
+ if (fence !== null) {
13120
+ if (mark && mark[0] === fence[0] && mark.length >= fence.length && line.trim() === mark) {
13121
+ fence = null;
13122
+ closedAt = i;
13123
+ }
13124
+ continue;
13125
+ }
13126
+ if (mark) {
13127
+ fence = mark;
13128
+ continue;
13129
+ }
13130
+ const setext = i > 0 && /^ {0,3}(=+|-+)[ \t]*$/.test(line) && lines[i - 1].trim() !== "" && closedAt !== i - 1 && (i === 1 || lines[i - 2].trim() === "");
13131
+ if (/^ {0,3}#{1,6}([ \t]|$)/.test(line) || setext) return "item_fixed_text_heading";
13132
+ }
13133
+ return null;
13134
+ }
13135
+ function pathsOverlap(a, b) {
13136
+ return a === b || a.endsWith("/") && b.startsWith(a) || b.endsWith("/") && a.startsWith(b);
13137
+ }
13138
+ function caseTypeDefinitionProblem(definition) {
13139
+ const problem = (reason, at) => ({ reason, at });
13140
+ if (JSON.stringify(definition).length > CASE_TYPE_DEFINITION_MAX_CHARS || caseTypeDefinitionRows(definition) > CASE_TYPE_DEFINITION_ROWS_MAX) {
13141
+ return problem("definition_too_large", "definition");
13142
+ }
13143
+ const attributes = caseAttributesSchemaProblem(definition.attributes);
13144
+ if (attributes) return problem(attributes.reason, `attributes.${attributes.at}`);
13145
+ if (repeated(definition.type_party_roles.map((role) => role.code))) return problem("party_role_code_repeated", "type_party_roles");
13146
+ if (repeated(definition.type_outcomes.map((outcome) => outcome.code))) return problem("outcome_code_repeated", "type_outcomes");
13147
+ const phases = definition.type_phases;
13148
+ if (repeated(phases.map((phase) => phase.code))) return problem("phase_code_repeated", "type_phases");
13149
+ if (repeated(phases.map((phase) => phase.folder))) return problem("phase_folder_repeated", "type_phases");
13150
+ if (repeated(phases.map((phase) => phase.folder.slice(0, 2)))) return problem("phase_position_repeated", "type_phases");
13151
+ const phaseCodes = new Set(phases.map((phase) => phase.code));
13152
+ const itemsByFolder = new Map(phases.map((phase) => [
13153
+ phase.folder,
13154
+ new Set(phase.phase_outputs.flatMap((output) => output.output_items.map((item) => item.code)))
13155
+ ]));
13156
+ const paths = [];
13157
+ const decisionCodes = phases.flatMap((phase) => phase.agenda_groups.flatMap((group) => group.agenda_decisions.map((decision) => decision.code)));
13158
+ if (repeated(decisionCodes)) return problem("decision_code_repeated", "type_phases");
13159
+ const versionDecisions = new Set(decisionCodes);
13160
+ const caseDecisionsAllowed = phases.some((phase) => phase.agenda_groups.some((group) => group.case_decisions_allowed));
13161
+ for (const phase of phases) {
13162
+ const at = `type_phases.${phase.folder}`;
13163
+ for (const dependency of phase.depends_on) {
13164
+ if (dependency === phase.code) return problem("phase_dependency_self", at);
13165
+ if (!phaseCodes.has(dependency)) return problem("phase_dependency_unknown", at);
13166
+ }
13167
+ if (phase.review_mode === "team" !== (phase.review_team_id !== null)) {
13168
+ return problem(phase.review_mode === "team" ? "review_team_missing" : "review_team_unexpected", at);
13169
+ }
13170
+ const outputs = phase.phase_outputs;
13171
+ if (repeated(outputs.map((output) => output.code))) return problem("output_code_repeated", at);
13172
+ if (repeated(outputs.map((output) => output.document_type.toLowerCase()))) return problem("output_document_type_repeated", at);
13173
+ const inputKeys = new Set(phase.phase_inputs.map((input) => input.key));
13174
+ if (inputKeys.size !== phase.phase_inputs.length) return problem("input_key_repeated", at);
13175
+ const tasks = phase.type_tasks;
13176
+ const taskCodes = new Set(tasks.map((task) => task.code));
13177
+ if (taskCodes.size !== tasks.length) return problem("task_code_repeated", at);
13178
+ const groups = phase.agenda_groups;
13179
+ const groupCodes = new Set(groups.map((group) => group.code));
13180
+ if (groupCodes.size !== groups.length) return problem("agenda_group_code_repeated", at);
13181
+ for (const output of outputs) {
13182
+ const outputAt = `${at}.phase_outputs.${output.code}`;
13183
+ if (output.format === "file" && output.output_items.length > 0) return problem("file_output_with_items", outputAt);
13184
+ if (output.format === "file" && output.case_items_allowed) return problem("file_output_with_case_items", outputAt);
13185
+ if (repeated(output.approving_team_ids)) return problem("approving_team_repeated", outputAt);
13186
+ for (const path45 of output.file_paths) {
13187
+ if (!path45.startsWith(`${phase.folder}/`)) return problem("file_path_outside_phase", outputAt);
13188
+ if (output.format === "file" && path45.endsWith("/")) return problem("file_path_folder_for_file", outputAt);
13189
+ if (paths.some((held) => pathsOverlap(held, path45))) return problem("file_path_overlaps", outputAt);
13190
+ paths.push(path45);
13191
+ }
13192
+ }
13193
+ if (phase.joint_delivery) {
13194
+ const teamsOf = (output) => [...output.approving_team_ids].sort().join(",");
13195
+ if (new Set(outputs.map(teamsOf)).size > 1) return problem("joint_approving_teams_differ", at);
13196
+ }
13197
+ for (const group of groups) {
13198
+ const groupAt = `${at}.agenda_groups.${group.code}`;
13199
+ if (group.approving_team_ids.length === 0) return problem("approving_teams_missing", groupAt);
13200
+ if (repeated(group.approving_team_ids)) return problem("approving_team_repeated", groupAt);
13201
+ if (group.agenda_decisions.length === 0 && !group.case_decisions_allowed) return problem("agenda_group_without_decisions", groupAt);
13202
+ for (const decision of group.agenda_decisions) {
13203
+ const reason = decisionProblem(decision);
13204
+ if (reason) return problem(reason, `${groupAt}.agenda_decisions.${decision.code}`);
13205
+ }
13206
+ if (group.required && !outputs.some((output) => output.required) && !tasks.some((task) => task.agenda_group === group.code)) {
13207
+ return problem("agenda_group_unbound", groupAt);
13208
+ }
13209
+ }
13210
+ const outputCodes = new Set(outputs.map((output) => output.code));
13211
+ for (const task of tasks) {
13212
+ const taskAt = `${at}.type_tasks.${task.code}`;
13213
+ if ([task.output, task.input, task.agenda_group].filter((link) => link !== null).length > 1) return problem("task_link_ambiguous", taskAt);
13214
+ if (task.output !== null && !outputCodes.has(task.output)) return problem("task_output_unknown", taskAt);
13215
+ if (task.input !== null && !inputKeys.has(task.input)) return problem("task_input_unknown", taskAt);
13216
+ if (task.agenda_group !== null && !groupCodes.has(task.agenda_group)) return problem("task_agenda_group_unknown", taskAt);
13217
+ for (const dependency of task.depends_on) {
13218
+ if (dependency === task.code) return problem("task_dependency_self", taskAt);
13219
+ if (!taskCodes.has(dependency)) return problem("task_dependency_unknown", taskAt);
13220
+ }
13221
+ }
13222
+ const taskCycle = cycleIn(tasks.map((task) => task.code), new Map(tasks.map((task) => [task.code, task.depends_on])));
13223
+ if (taskCycle) return problem("task_dependency_cycle", `${at}.type_tasks.${taskCycle}`);
13224
+ const items = outputs.flatMap((output) => output.output_items);
13225
+ if (repeated(items.map((item) => item.code))) return problem("item_code_repeated", at);
13226
+ for (const item of items) {
13227
+ const itemAt = `${at}.output_items.${item.code}`;
13228
+ if (item.task !== null && !taskCodes.has(item.task)) return problem("item_task_unknown", itemAt);
13229
+ if (item.template_mode === "fixed") {
13230
+ if (!item.fixed_text?.trim()) return problem("item_fixed_text_missing", itemAt);
13231
+ if (item.grouping) return problem("item_grouping_fixed", itemAt);
13232
+ const textProblem = fixedTextProblem(item.fixed_text);
13233
+ if (textProblem) return problem(textProblem, itemAt);
13234
+ } else if (item.fixed_text !== null) {
13235
+ return problem("item_fixed_text_unexpected", itemAt);
13236
+ }
13237
+ const { inputs, calculations, decisions } = item.item_requirements;
13238
+ if (repeated(inputs) || repeated(calculations) || repeated(decisions)) return problem("item_requirement_repeated", itemAt);
13239
+ if (inputs.some((key) => !inputKeys.has(key))) return problem("item_input_unknown", itemAt);
13240
+ if (!caseDecisionsAllowed && decisions.some((decision) => !versionDecisions.has(decision))) return problem("item_decision_unknown", itemAt);
13241
+ const targets = item.item_links.depends_on;
13242
+ if (repeated(targets.map((target) => resolveItemLink(phase.folder, target).key))) return problem("item_link_repeated", itemAt);
13243
+ for (const target of targets) {
13244
+ const { folder, code: targetCode } = resolveItemLink(phase.folder, target);
13245
+ if (!itemsByFolder.get(folder)?.has(targetCode)) return problem("item_link_unknown", itemAt);
13246
+ if (folder === phase.folder && targetCode === item.code) return problem("item_link_self", itemAt);
13247
+ }
13248
+ }
13249
+ if (outputs.length === 0 && !tasks.some((task) => caseTaskRequired(phase, task))) return problem("phase_without_work", at);
13250
+ }
13251
+ const phaseCycle = cycleIn(phases.map((phase) => phase.code), new Map(phases.map((phase) => [phase.code, phase.depends_on])));
13252
+ if (phaseCycle) return problem("phase_dependency_cycle", `type_phases.${phaseCycle}`);
13253
+ return null;
13254
+ }
13255
+ var CASE_CODE_PATTERN, CASE_PHASE_CODE_PATTERN, CASE_PHASE_FOLDER_PATTERN, CASE_INPUT_KEY_PATTERN, CASE_CALCULATION_CODE_PATTERN, CASE_AGENDA_GROUP_CODE_PATTERN, CASE_DECISION_CODE_PATTERN, CASE_DECISION_OPTION_CODE_PATTERN, CASE_DECISION_EFFECT_PATTERN, FILE_PATH_SEGMENT_PATTERN, CASE_REVIEW_MODES, CASE_OUTPUT_FORMATS, CASE_INPUT_ORIGINS, CASE_TEMPLATE_MODES, CASE_AGENDA_QUORUMS, CASE_DECISION_TYPES, CASE_NUMERIC_DECISION_TYPES, CASE_TYPE_NAME_MAX_LENGTH, CASE_CODE_MAX_LENGTH, CASE_FILE_PATH_MAX_LENGTH, CASE_FIXED_TEXT_MAX_LENGTH, CASE_TYPE_DEFINITION_MAX_CHARS, CASE_TYPE_DEFINITION_ROWS_MAX, CASE_TYPE_VERSIONS_MAX, CASE_TYPES_PAGE_MAX, code, phaseCode, inputKey, agendaGroupCode, decisionCode, label2, optionalText, itemLinkTarget, filePath, caseTypePartyRoleSchema, caseTypeOutcomeSchema, caseItemRequirementsSchema, caseItemLinksSchema, caseOutputItemSchema, casePhaseOutputSchema, casePhaseInputSchema, caseDecisionOptionSchema, decisionBound, caseAgendaDecisionSchema, caseAgendaGroupSchema, caseTypeTaskSchema, caseTypePhaseSchema, caseTypeDefinitionShape, repeated, caseTypeDefinitionSchema, caseTypeAbbreviationSchema, caseTypeNameSchema, createCaseTypeBody, publishCaseTypeVersionBody, setCaseTypeActiveBody, caseTypeParam, caseTypesPageQuery, caseTypeVersionQuery;
13256
+ var init_chunk_BGOBDSII = __esm({
13257
+ "../../packages/core/dist/chunk-BGOBDSII.js"() {
13258
+ "use strict";
13259
+ init_chunk_FOFCV4SW();
13260
+ init_chunk_6IDXKJKK();
13261
+ init_chunk_HZ6CADSY();
13262
+ init_chunk_NYNOISIG();
13263
+ init_zod();
13264
+ CASE_CODE_PATTERN = /^[a-z0-9]+(_[a-z0-9]+)*$/;
13265
+ CASE_PHASE_CODE_PATTERN = /^[a-z0-9_]+$/;
13266
+ CASE_PHASE_FOLDER_PATTERN = /^[0-9]{2}-[a-z0-9-]+$/;
13267
+ CASE_INPUT_KEY_PATTERN = /^[a-z0-9]+(-[a-z0-9]+)*$/;
13268
+ CASE_CALCULATION_CODE_PATTERN = /^[a-z][a-z0-9_]*$/;
13269
+ CASE_AGENDA_GROUP_CODE_PATTERN = /^[a-z0-9]+(-[a-z0-9]+)*$/;
13270
+ CASE_DECISION_CODE_PATTERN = /^[a-z][a-z0-9_]*$/;
13271
+ CASE_DECISION_OPTION_CODE_PATTERN = /^[a-z0-9]+([_-][a-z0-9]+)*$/;
13272
+ CASE_DECISION_EFFECT_PATTERN = new RegExp(`^calc:${CASE_CALCULATION_CODE_PATTERN.source.slice(1)}`);
13273
+ FILE_PATH_SEGMENT_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,99}$/;
13274
+ CASE_REVIEW_MODES = ["none", "edit", "conduct", "team"];
13275
+ CASE_OUTPUT_FORMATS = ["document", "file"];
13276
+ CASE_INPUT_ORIGINS = ["collection", "previous_output", "received"];
13277
+ CASE_TEMPLATE_MODES = ["guide", "fixed"];
13278
+ CASE_AGENDA_QUORUMS = ["one", "all"];
13279
+ CASE_DECISION_TYPES = ["percent", "currency", "number", "date", "choice", "yes_no", "text"];
13280
+ CASE_NUMERIC_DECISION_TYPES = ["percent", "currency", "number"];
13281
+ CASE_TYPE_NAME_MAX_LENGTH = 200;
13282
+ CASE_CODE_MAX_LENGTH = 64;
13283
+ CASE_FILE_PATH_MAX_LENGTH = 256;
13284
+ CASE_FIXED_TEXT_MAX_LENGTH = 16 * 1024;
13285
+ CASE_TYPE_DEFINITION_MAX_CHARS = 256 * 1024;
13286
+ CASE_TYPE_DEFINITION_ROWS_MAX = 2e3;
13287
+ CASE_TYPE_VERSIONS_MAX = 200;
13288
+ CASE_TYPES_PAGE_MAX = 100;
13289
+ code = external_exports.string().max(CASE_CODE_MAX_LENGTH).regex(CASE_CODE_PATTERN);
13290
+ phaseCode = external_exports.string().max(CASE_CODE_MAX_LENGTH).regex(CASE_PHASE_CODE_PATTERN);
13291
+ inputKey = external_exports.string().max(CASE_CODE_MAX_LENGTH).regex(CASE_INPUT_KEY_PATTERN);
13292
+ agendaGroupCode = external_exports.string().max(CASE_CODE_MAX_LENGTH).regex(CASE_AGENDA_GROUP_CODE_PATTERN);
13293
+ decisionCode = external_exports.string().max(CASE_CODE_MAX_LENGTH).regex(CASE_DECISION_CODE_PATTERN);
13294
+ label2 = (max) => external_exports.string().trim().min(1).max(max);
13295
+ optionalText = (max) => external_exports.string().trim().max(max).nullable().default(null).transform((text4) => text4 || null);
13296
+ itemLinkTarget = external_exports.string().max(CASE_CODE_MAX_LENGTH * 2 + 1).refine((target) => {
13297
+ const { folder, code: targetCode } = resolveItemLink("", target);
13298
+ return (!target.includes("/") || CASE_PHASE_FOLDER_PATTERN.test(folder)) && CASE_CODE_PATTERN.test(targetCode);
13299
+ }, "An item is named by its code, or by its phase folder and code");
13300
+ filePath = external_exports.string().min(1).max(CASE_FILE_PATH_MAX_LENGTH).refine((path45) => {
13301
+ const segments = (path45.endsWith("/") ? path45.slice(0, -1) : path45).split("/");
13302
+ return segments.length >= 2 && segments.length <= 8 && CASE_PHASE_FOLDER_PATTERN.test(segments[0]) && segments.slice(1).every((segment) => FILE_PATH_SEGMENT_PATTERN.test(segment));
13303
+ }, "A file path is the phase folder, then letters, digits, dots, dashes and underscores");
13304
+ caseTypePartyRoleSchema = external_exports.object({
13305
+ code,
13306
+ name: label2(200),
13307
+ required: external_exports.boolean().default(false),
13308
+ multiple: external_exports.boolean().default(false)
13309
+ }).strict();
13310
+ caseTypeOutcomeSchema = external_exports.object({ code, name: label2(200) }).strict();
13311
+ caseItemRequirementsSchema = external_exports.object({
13312
+ /** Keys of the phase's inputs the item must cite. */
13313
+ inputs: external_exports.array(inputKey).max(50).default([]),
13314
+ /** Names in `analysis/results.csv` the item must cite. */
13315
+ calculations: external_exports.array(external_exports.string().max(CASE_CODE_MAX_LENGTH).regex(CASE_CALCULATION_CODE_PATTERN)).max(50).default([]),
13316
+ /** Codes of the version's agenda decisions the item must cite. */
13317
+ decisions: external_exports.array(decisionCode).max(50).default([])
13318
+ }).strict();
13319
+ caseItemLinksSchema = external_exports.object({
13320
+ /** Items of this version this one depends on, in any phase. Cycles are allowed: graph review's stop rule closes them. */
13321
+ depends_on: external_exports.array(itemLinkTarget).max(50).default([]),
13322
+ /** `all`: the item reflects every other item of its output (Rito's `reflete: todos`). */
13323
+ reflects: external_exports.literal("all").nullable().default(null)
13324
+ }).strict();
13325
+ caseOutputItemSchema = external_exports.object({
13326
+ code,
13327
+ title: label2(200),
13328
+ /** A heading that holds other items and has no text of its own. */
13329
+ grouping: external_exports.boolean().default(false),
13330
+ required: external_exports.boolean().default(true),
13331
+ waivable: external_exports.boolean().default(true),
13332
+ /** The code of the phase's task that writes it. */
13333
+ task: code.nullable().default(null),
13334
+ legal_basis: optionalText(2e3),
13335
+ template_mode: external_exports.enum(CASE_TEMPLATE_MODES).default("guide"),
13336
+ /** The item's text in `fixed` mode, and only there. */
13337
+ fixed_text: external_exports.string().max(CASE_FIXED_TEXT_MAX_LENGTH).nullable().default(null),
13338
+ item_requirements: caseItemRequirementsSchema.default({}),
13339
+ item_links: caseItemLinksSchema.default({})
13340
+ }).strict();
13341
+ casePhaseOutputSchema = external_exports.object({
13342
+ code,
13343
+ document_type: label2(200),
13344
+ required: external_exports.boolean().default(true),
13345
+ executive_approval: external_exports.boolean().default(false),
13346
+ /** `document` is written in Markdown and rendered; `file` (.xlsx, .pdf, .dwg, .dxf) is hashed as it came. */
13347
+ format: external_exports.enum(CASE_OUTPUT_FORMATS).default("document"),
13348
+ /** The piece's place in its phase's set. */
13349
+ position: external_exports.number().int().min(0).max(9999).default(0),
13350
+ /** How the piece is shown in its set, as `Annex I`. */
13351
+ label: optionalText(100),
13352
+ case_items_allowed: external_exports.boolean().default(false),
13353
+ /** The paths a file must have to be this output (or the same path under `conf/`: F5). */
13354
+ file_paths: external_exports.array(filePath).min(1).max(10),
13355
+ /** The teams whose Approve holders may approve it; none means any Approve holder reaching the case (F8). */
13356
+ approving_team_ids: external_exports.array(uuidSchema).max(20).default([]),
13357
+ output_items: external_exports.array(caseOutputItemSchema).max(200).default([])
13358
+ }).strict();
13359
+ casePhaseInputSchema = external_exports.object({
13360
+ key: inputKey,
13361
+ name: label2(200),
13362
+ origin: external_exports.enum(CASE_INPUT_ORIGINS),
13363
+ document_type: optionalText(200),
13364
+ required: external_exports.boolean().default(true)
13365
+ }).strict();
13366
+ caseDecisionOptionSchema = external_exports.object({
13367
+ code: external_exports.string().max(CASE_CODE_MAX_LENGTH).regex(CASE_DECISION_OPTION_CODE_PATTERN),
13368
+ name: label2(200),
13369
+ /** `calc:{name}`: the result the option leads to, shown beside it. */
13370
+ effect: external_exports.string().max(CASE_CODE_MAX_LENGTH + 5).regex(CASE_DECISION_EFFECT_PATTERN).nullable().default(null)
13371
+ }).strict();
13372
+ decisionBound = external_exports.number().finite().min(-1e15).max(1e15).nullable().default(null);
13373
+ caseAgendaDecisionSchema = external_exports.object({
13374
+ code: decisionCode,
13375
+ question: label2(1e3),
13376
+ why: external_exports.string().trim().max(2e3).default(""),
13377
+ type: external_exports.enum(CASE_DECISION_TYPES),
13378
+ decimals: external_exports.number().int().min(0).max(6).nullable().default(null),
13379
+ unit: optionalText(50),
13380
+ min: decisionBound,
13381
+ max: decisionBound,
13382
+ options: external_exports.array(caseDecisionOptionSchema).max(50).default([]),
13383
+ required: external_exports.boolean().default(true)
13384
+ }).strict().transform((decision) => decision.decimals === null && (decision.type === "percent" || decision.type === "currency") ? { ...decision, decimals: 2 } : decision);
13385
+ caseAgendaGroupSchema = external_exports.object({
13386
+ code: agendaGroupCode,
13387
+ name: label2(200),
13388
+ /** The teams whose Approve holders approve the group, and dispense it (the plan keeps that with them). */
13389
+ approving_team_ids: external_exports.array(uuidSchema).max(20).default([]),
13390
+ quorum: external_exports.enum(CASE_AGENDA_QUORUMS).default("one"),
13391
+ required: external_exports.boolean().default(true),
13392
+ confidential: external_exports.boolean().default(false),
13393
+ case_decisions_allowed: external_exports.boolean().default(false),
13394
+ agenda_decisions: external_exports.array(caseAgendaDecisionSchema).max(100).default([])
13395
+ }).strict();
13396
+ caseTypeTaskSchema = external_exports.object({
13397
+ code,
13398
+ name: label2(200),
13399
+ /** A task linked to an output, an input or an agenda group takes that one's `required` instead (Rito). */
13400
+ required: external_exports.boolean().default(false),
13401
+ /** The phase's output it completes with, by code. */
13402
+ output: code.nullable().default(null),
13403
+ /** The phase's input it completes with, by key. */
13404
+ input: inputKey.nullable().default(null),
13405
+ /** The phase's agenda group it completes with, by code: approved or dispensed. */
13406
+ agenda_group: agendaGroupCode.nullable().default(null),
13407
+ /** Tasks of the same phase it waits for, by code. */
13408
+ depends_on: external_exports.array(code).max(50).default([])
13409
+ }).strict();
13410
+ caseTypePhaseSchema = external_exports.object({
13411
+ code: phaseCode,
13412
+ folder: external_exports.string().max(CASE_CODE_MAX_LENGTH).regex(CASE_PHASE_FOLDER_PATTERN),
13413
+ name: label2(200),
13414
+ expected_documents: external_exports.string().trim().max(2e3).default(""),
13415
+ /** The phases it waits for, by code: delivered or dispensed. */
13416
+ depends_on: external_exports.array(phaseCode).max(50),
13417
+ optional: external_exports.boolean().default(false),
13418
+ on_demand: external_exports.boolean().default(false),
13419
+ joint_delivery: external_exports.boolean().default(false),
13420
+ review_mode: external_exports.enum(CASE_REVIEW_MODES).default("conduct"),
13421
+ /** The team that signs off, in `team` mode and only there. */
13422
+ review_team_id: uuidSchema.nullable().default(null),
13423
+ case_inputs_allowed: external_exports.boolean().default(false),
13424
+ phase_outputs: external_exports.array(casePhaseOutputSchema).max(30).default([]),
13425
+ phase_inputs: external_exports.array(casePhaseInputSchema).max(50).default([]),
13426
+ type_tasks: external_exports.array(caseTypeTaskSchema).max(100).default([]),
13427
+ agenda_groups: external_exports.array(caseAgendaGroupSchema).max(20).default([])
13428
+ }).strict();
13429
+ caseTypeDefinitionShape = external_exports.object({
13430
+ type_party_roles: external_exports.array(caseTypePartyRoleSchema).max(50).default([]),
13431
+ type_outcomes: external_exports.array(caseTypeOutcomeSchema).max(50).default([]),
13432
+ type_phases: external_exports.array(caseTypePhaseSchema).min(1).max(50),
13433
+ /** The JSON Schema of its cases' `attributes`: their custom fields. Absent, none. */
13434
+ attributes: caseAttributesSchemaSchema.default(() => ({ ...EMPTY_CASE_ATTRIBUTES_SCHEMA }))
13435
+ }).strict();
13436
+ repeated = (values) => new Set(values).size !== values.length;
13437
+ caseTypeDefinitionSchema = caseTypeDefinitionShape.superRefine((definition, ctx) => {
13438
+ const found = caseTypeDefinitionProblem(definition);
13439
+ if (found) {
13440
+ ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: found.reason, path: found.at.split("."), params: { case_type_reason: found.reason } });
13441
+ }
13442
+ });
13443
+ caseTypeAbbreviationSchema = external_exports.string().trim().transform((value) => value.toUpperCase()).pipe(external_exports.string().regex(CASE_TYPE_ABBREVIATION_PATTERN));
13444
+ caseTypeNameSchema = external_exports.string().trim().min(1).max(CASE_TYPE_NAME_MAX_LENGTH);
13445
+ createCaseTypeBody = external_exports.object({
13446
+ abbreviation: caseTypeAbbreviationSchema,
13447
+ name: caseTypeNameSchema,
13448
+ definition: caseTypeDefinitionSchema
13449
+ }).strict();
13450
+ publishCaseTypeVersionBody = external_exports.object({
13451
+ expected_version: external_exports.number().int().min(1).max(CASE_TYPE_VERSIONS_MAX),
13452
+ name: caseTypeNameSchema,
13453
+ definition: caseTypeDefinitionSchema
13454
+ }).strict();
13455
+ setCaseTypeActiveBody = external_exports.object({ active: external_exports.boolean() }).strict();
13456
+ caseTypeParam = caseSpaceParam.extend({ type_id: uuidSchema });
13457
+ caseTypesPageQuery = casePageQuery.extend({
13458
+ limit: external_exports.coerce.number().int().min(1).max(CASE_TYPES_PAGE_MAX).optional()
13459
+ });
13460
+ caseTypeVersionQuery = external_exports.object({
13461
+ version: external_exports.coerce.number().int().min(1).max(CASE_TYPE_VERSIONS_MAX).optional()
13462
+ });
13463
+ }
13464
+ });
13465
+
12856
13466
  // ../../packages/core/dist/chunk-7CYHPF35.js
12857
13467
  var appMessageSenderType, appMessageReceiverType, apiChannelMessage, apiChannelMessageBody, appMessageBody, appMessageResponse;
12858
13468
  var init_chunk_7CYHPF35 = __esm({
@@ -13029,7 +13639,7 @@ var init_chunk_NETRUHZF = __esm({
13029
13639
  }
13030
13640
  });
13031
13641
 
13032
- // ../../packages/core/dist/chunk-YI3ORIXJ.js
13642
+ // ../../packages/core/dist/chunk-CZS5NGTA.js
13033
13643
  function toolParametersViolations(params) {
13034
13644
  try {
13035
13645
  if (containsKanbanPlaceholders(params)) return [];
@@ -13086,12 +13696,12 @@ function refineToolConfig(value, ctx) {
13086
13696
  }
13087
13697
  }
13088
13698
  var nonBlank, DEFAULT_TOOL_CONFIG_DESCRIPTION, MAX_CUSTOM_TOOL_CONFIG_TEXT_LAYERS, toolIdParam, listToolsQuery, toolAgentQuery, deleteToolQuery, toolConnectionsQuery, nativeToolIdSchema, CONTEXT_BOUNDARIES, contextBoundarySchema, addNativeToolBody, addMcpToolBody, toolReplaySettingsFields, toolReplaySettingsSchema, createCustomToolBody, updateCustomToolBody, updateToolExecutionConfigBody;
13089
- var init_chunk_YI3ORIXJ = __esm({
13090
- "../../packages/core/dist/chunk-YI3ORIXJ.js"() {
13699
+ var init_chunk_CZS5NGTA = __esm({
13700
+ "../../packages/core/dist/chunk-CZS5NGTA.js"() {
13091
13701
  "use strict";
13092
13702
  init_chunk_WEXVYJ5H();
13093
13703
  init_chunk_HZ6CADSY();
13094
- init_chunk_JHUTFQDO();
13704
+ init_chunk_4IXIQQ2A();
13095
13705
  init_zod();
13096
13706
  nonBlank = (text4) => typeof text4 === "string" && text4.trim() !== "" ? text4 : void 0;
13097
13707
  DEFAULT_TOOL_CONFIG_DESCRIPTION = "Function description";
@@ -13161,7 +13771,7 @@ var init_chunk_4LXDRTO4 = __esm({
13161
13771
  }
13162
13772
  });
13163
13773
 
13164
- // ../../packages/core/dist/chunk-WTOA3ANF.js
13774
+ // ../../packages/core/dist/chunk-7DLTG7J5.js
13165
13775
  function isIanaTimezone(timezone) {
13166
13776
  try {
13167
13777
  new Intl.DateTimeFormat("en-US", { timeZone: timezone }).format(0);
@@ -13171,13 +13781,13 @@ function isIanaTimezone(timezone) {
13171
13781
  }
13172
13782
  }
13173
13783
  var evalDateContextSchema;
13174
- var init_chunk_WTOA3ANF = __esm({
13175
- "../../packages/core/dist/chunk-WTOA3ANF.js"() {
13784
+ var init_chunk_7DLTG7J5 = __esm({
13785
+ "../../packages/core/dist/chunk-7DLTG7J5.js"() {
13176
13786
  "use strict";
13177
13787
  init_chunk_KB5RK3RP();
13178
13788
  init_chunk_HZ6CADSY();
13179
13789
  init_chunk_MIWZOSPI();
13180
- init_chunk_YROEDMVZ();
13790
+ init_chunk_NYNOISIG();
13181
13791
  init_zod();
13182
13792
  evalDateContextSchema = external_exports.object({
13183
13793
  base_time: timestampSchema.refine(isIsoTimestamp, "Expected a canonical ISO timestamp"),
@@ -13201,7 +13811,7 @@ var init_chunk_2ISUBJG7 = __esm({
13201
13811
  }
13202
13812
  });
13203
13813
 
13204
- // ../../packages/core/dist/chunk-66EZQ7Y7.js
13814
+ // ../../packages/core/dist/chunk-JKOMP2G3.js
13205
13815
  function describeRole(role) {
13206
13816
  if (typeof role === "string") {
13207
13817
  return JSON.stringify(role.length > ROLE_ECHO_MAX ? `${role.slice(0, ROLE_ECHO_MAX)}\u2026` : role);
@@ -13380,13 +13990,13 @@ function terminalRunCount(counts) {
13380
13990
  return counts.successful_runs + counts.failed_runs;
13381
13991
  }
13382
13992
  var evalIdParam, sessionIdParam, scenarioSetIdParam, hubIdQuery, EVAL_FIXTURE_NAME_MAX_LENGTH, evalFixtureOverrideSchema, runSessionQuery, runJourneyQuery, EVAL_INPUT_ROLES, EVAL_INPUT_ROLE_LIST, ROLE_ECHO_MAX, EVAL_INITIAL_STATE_SCOPES, MAX_INITIAL_STATE_ENTRIES, evalInitialStateEntry, EVAL_PERSON_MAX, evalPersonSchema, EVAL_PERSON_ALIAS_RETIRED, EVAL_PERSON_ALIAS_REFUSED, evalBody, EVAL_LIST_MAX_LIMIT, evalListLimit, getEvalsQuery, toggleEvalBody, bulkToggleEvalsBody, pacingConfigSchema, EVAL_MAX_SELECTED_SCENARIOS, evalScenarioSelectionEntrySchema, evalScenarioSelectionSchema, sessionConfigSchema, createSessionBody, getSessionsQuery, getSessionResultsQuery, getSessionRunsQuery, evalAnalyticsQuery, getSessionCostQuery, compareSessionsQuery, evalsSqlBody, evalsSqlSchemaQuery, exportResultsQuery, validateEvalBody, hubAgentsQuery, createScenarioSetBody, updateScenarioSetBody, scenarioSetsHubQuery, createScenarioFromConversationBody, createJourneyFromConversationBody, evalAttachmentRef, turnMayCarryAttachments, ATTACHMENTS_USER_ONLY_MESSAGE, journeyIdParam, journeyToolCallSchema, journeyTurnSchema, journeyStepOverrideSchema, fixtureField, createJourneyBody, updateJourneyBody, evalSessionConfigResponseSchema, evalSessionResponseSchema, evalSessionListConfigSchema, evalSessionListItemSchema, seedReleaseStatusSchema, EVAL_SESSION_NOT_QUIESCENT;
13383
- var init_chunk_66EZQ7Y7 = __esm({
13384
- "../../packages/core/dist/chunk-66EZQ7Y7.js"() {
13993
+ var init_chunk_JKOMP2G3 = __esm({
13994
+ "../../packages/core/dist/chunk-JKOMP2G3.js"() {
13385
13995
  "use strict";
13386
13996
  init_chunk_SDOG6762();
13387
13997
  init_chunk_2YEGUQR7();
13388
13998
  init_chunk_4LXDRTO4();
13389
- init_chunk_WTOA3ANF();
13999
+ init_chunk_7DLTG7J5();
13390
14000
  init_chunk_2ISUBJG7();
13391
14001
  init_chunk_HZ6CADSY();
13392
14002
  init_zod();
@@ -13802,7 +14412,7 @@ var init_chunk_D3EP4TDU = __esm({
13802
14412
  function isEventRelativeFollowupType(type) {
13803
14413
  return typeof type === "string" && EVENT_RELATIVE_FOLLOWUP_TYPES.includes(type);
13804
14414
  }
13805
- function validateFollowupLinks(followups, label2, ctx) {
14415
+ function validateFollowupLinks(followups, label3, ctx) {
13806
14416
  const linkTargets = /* @__PURE__ */ new Set();
13807
14417
  followups.forEach((followup, i) => {
13808
14418
  const ref = followup?.after_followup_id;
@@ -13812,7 +14422,7 @@ function validateFollowupLinks(followups, label2, ctx) {
13812
14422
  ctx.addIssue({
13813
14423
  code: external_exports.ZodIssueCode.custom,
13814
14424
  path: path45,
13815
- message: `kanban status ${label2}: after_followup_id is only valid on inactivity_after_before_event followups (this one is ${followup?.type})`
14425
+ message: `kanban status ${label3}: after_followup_id is only valid on inactivity_after_before_event followups (this one is ${followup?.type})`
13816
14426
  });
13817
14427
  }
13818
14428
  return;
@@ -13821,7 +14431,7 @@ function validateFollowupLinks(followups, label2, ctx) {
13821
14431
  ctx.addIssue({
13822
14432
  code: external_exports.ZodIssueCode.custom,
13823
14433
  path: path45,
13824
- message: `kanban status ${label2}: inactivity_after_before_event requires after_followup_id naming the id of a before_event followup in the same status`
14434
+ message: `kanban status ${label3}: inactivity_after_before_event requires after_followup_id naming the id of a before_event followup in the same status`
13825
14435
  });
13826
14436
  return;
13827
14437
  }
@@ -13831,7 +14441,7 @@ function validateFollowupLinks(followups, label2, ctx) {
13831
14441
  ctx.addIssue({
13832
14442
  code: external_exports.ZodIssueCode.custom,
13833
14443
  path: path45,
13834
- message: `kanban status ${label2}: after_followup_id "${ref}" matches ${matches.length} followups \u2014 a link must name exactly one`
14444
+ message: `kanban status ${label3}: after_followup_id "${ref}" matches ${matches.length} followups \u2014 a link must name exactly one`
13835
14445
  });
13836
14446
  return;
13837
14447
  }
@@ -13843,7 +14453,7 @@ function validateFollowupLinks(followups, label2, ctx) {
13843
14453
  ctx.addIssue({
13844
14454
  code: external_exports.ZodIssueCode.custom,
13845
14455
  path: path45,
13846
- message: hasIdlessBeforeEvent ? `kanban status ${label2}: after_followup_id "${ref}" matches no followup \u2014 a link target must declare an explicit id, and this status has before_event followups without one` : `kanban status ${label2}: after_followup_id "${ref}" matches no followup in this status`
14456
+ message: hasIdlessBeforeEvent ? `kanban status ${label3}: after_followup_id "${ref}" matches no followup \u2014 a link target must declare an explicit id, and this status has before_event followups without one` : `kanban status ${label3}: after_followup_id "${ref}" matches no followup in this status`
13847
14457
  });
13848
14458
  return;
13849
14459
  }
@@ -13851,7 +14461,7 @@ function validateFollowupLinks(followups, label2, ctx) {
13851
14461
  ctx.addIssue({
13852
14462
  code: external_exports.ZodIssueCode.custom,
13853
14463
  path: path45,
13854
- message: `kanban status ${label2}: after_followup_id "${ref}" points at a ${target.type} followup \u2014 only before_event followups can anchor a chain`
14464
+ message: `kanban status ${label3}: after_followup_id "${ref}" points at a ${target.type} followup \u2014 only before_event followups can anchor a chain`
13855
14465
  });
13856
14466
  }
13857
14467
  });
@@ -13859,7 +14469,7 @@ function validateFollowupLinks(followups, label2, ctx) {
13859
14469
  ctx.addIssue({
13860
14470
  code: external_exports.ZodIssueCode.custom,
13861
14471
  path: ["followups"],
13862
- message: `kanban status ${label2}: at most ${MAX_LINKED_FOLLOWUP_TARGETS_PER_STATUS} distinct after_followup_id targets per status (found ${linkTargets.size}) \u2014 each one rebuilds a chain on every inbound message`
14472
+ message: `kanban status ${label3}: at most ${MAX_LINKED_FOLLOWUP_TARGETS_PER_STATUS} distinct after_followup_id targets per status (found ${linkTargets.size}) \u2014 each one rebuilds a chain on every inbound message`
13863
14473
  });
13864
14474
  }
13865
14475
  }
@@ -13874,18 +14484,18 @@ function validateLaneReferences(lanes, statuses) {
13874
14484
  if (s === null) return;
13875
14485
  const lane = s.lane_slug;
13876
14486
  if (typeof lane !== "string" || lane.length === 0) return;
13877
- const label2 = s.slug ? `"${printableName(s.slug)}"` : `[${i}]`;
14487
+ const label3 = s.slug ? `"${printableName(s.slug)}"` : `[${i}]`;
13878
14488
  if (s.isInitialStatus === true) {
13879
14489
  issues.push({
13880
14490
  path: [i, "lane_slug"],
13881
- message: `kanban status ${label2}: the initial status cannot belong to a lane (it is the shared entry point)`
14491
+ message: `kanban status ${label3}: the initial status cannot belong to a lane (it is the shared entry point)`
13882
14492
  });
13883
14493
  return;
13884
14494
  }
13885
14495
  if (!declared.has(lane)) {
13886
14496
  issues.push({
13887
14497
  path: [i, "lane_slug"],
13888
- message: `kanban status ${label2}: lane_slug references unknown lane "${lane}"`
14498
+ message: `kanban status ${label3}: lane_slug references unknown lane "${lane}"`
13889
14499
  });
13890
14500
  }
13891
14501
  });
@@ -14008,13 +14618,13 @@ var init_chunk_X5PZZVTS = __esm({
14008
14618
  * `isTerminalStatus === true` (enforced in the superRefine below). */
14009
14619
  outcomes: external_exports.array(kanbanOutcomeSchema).max(MAX_OUTCOMES_PER_STATUS, `outcomes must have at most ${MAX_OUTCOMES_PER_STATUS} entries`).optional()
14010
14620
  }).passthrough().superRefine((status, ctx) => {
14011
- const label2 = status.name ? `"${status.name}"` : status.slug ? `"${status.slug}"` : "<unnamed>";
14621
+ const label3 = status.name ? `"${status.name}"` : status.slug ? `"${status.slug}"` : "<unnamed>";
14012
14622
  for (const [a, b] of EXCLUSIVE_FLAG_PAIRS) {
14013
14623
  if (status[a] === true && status[b] === true) {
14014
14624
  ctx.addIssue({
14015
14625
  code: external_exports.ZodIssueCode.custom,
14016
14626
  path: [b],
14017
- message: `kanban status ${label2}: ${a} and ${b} cannot both be true`
14627
+ message: `kanban status ${label3}: ${a} and ${b} cannot both be true`
14018
14628
  });
14019
14629
  }
14020
14630
  }
@@ -14022,14 +14632,14 @@ var init_chunk_X5PZZVTS = __esm({
14022
14632
  ctx.addIssue({
14023
14633
  code: external_exports.ZodIssueCode.custom,
14024
14634
  path: ["eventName"],
14025
- message: `kanban status ${label2}: eventName is required when isSchedulingStatus=true`
14635
+ message: `kanban status ${label3}: eventName is required when isSchedulingStatus=true`
14026
14636
  });
14027
14637
  }
14028
14638
  if (status.event_due_delay_minutes !== void 0 && status.isSchedulingStatus !== true) {
14029
14639
  ctx.addIssue({
14030
14640
  code: external_exports.ZodIssueCode.custom,
14031
14641
  path: ["event_due_delay_minutes"],
14032
- message: `kanban status ${label2}: event_due_delay_minutes requires isSchedulingStatus=true`
14642
+ message: `kanban status ${label3}: event_due_delay_minutes requires isSchedulingStatus=true`
14033
14643
  });
14034
14644
  }
14035
14645
  if (Array.isArray(status.followups) && status.isSchedulingStatus !== true) {
@@ -14040,12 +14650,12 @@ var init_chunk_X5PZZVTS = __esm({
14040
14650
  ctx.addIssue({
14041
14651
  code: external_exports.ZodIssueCode.custom,
14042
14652
  path: ["followups"],
14043
- message: `kanban status ${label2}: ${offending.type} followups require isSchedulingStatus=true on the parent status`
14653
+ message: `kanban status ${label3}: ${offending.type} followups require isSchedulingStatus=true on the parent status`
14044
14654
  });
14045
14655
  }
14046
14656
  }
14047
14657
  if (Array.isArray(status.followups)) {
14048
- validateFollowupLinks(status.followups, label2, ctx);
14658
+ validateFollowupLinks(status.followups, label3, ctx);
14049
14659
  }
14050
14660
  if (status.additional_context_schema && typeof status.additional_context_schema === "object") {
14051
14661
  const schema = status.additional_context_schema;
@@ -14054,7 +14664,7 @@ var init_chunk_X5PZZVTS = __esm({
14054
14664
  ctx.addIssue({
14055
14665
  code: external_exports.ZodIssueCode.custom,
14056
14666
  path: ["additional_context_schema", "properties", RESERVED_TEMPLATE_DUMP_NAME],
14057
- message: `kanban status ${label2}: "${RESERVED_TEMPLATE_DUMP_NAME}" is a reserved template placeholder name and cannot be used as a top-level schema property`
14667
+ message: `kanban status ${label3}: "${RESERVED_TEMPLATE_DUMP_NAME}" is a reserved template placeholder name and cannot be used as a top-level schema property`
14058
14668
  });
14059
14669
  }
14060
14670
  }
@@ -14063,7 +14673,7 @@ var init_chunk_X5PZZVTS = __esm({
14063
14673
  ctx.addIssue({
14064
14674
  code: external_exports.ZodIssueCode.custom,
14065
14675
  path: ["outcomes"],
14066
- message: `kanban status ${label2}: outcomes are only allowed on the terminal status (set isTerminalStatus=true)`
14676
+ message: `kanban status ${label3}: outcomes are only allowed on the terminal status (set isTerminalStatus=true)`
14067
14677
  });
14068
14678
  }
14069
14679
  const seen = /* @__PURE__ */ new Map();
@@ -14079,7 +14689,7 @@ var init_chunk_X5PZZVTS = __esm({
14079
14689
  ctx.addIssue({
14080
14690
  code: external_exports.ZodIssueCode.custom,
14081
14691
  path: ["outcomes", j, "slug"],
14082
- message: `kanban status ${label2}: duplicate outcome slug "${slug}"`
14692
+ message: `kanban status ${label3}: duplicate outcome slug "${slug}"`
14083
14693
  });
14084
14694
  }
14085
14695
  }
@@ -14196,7 +14806,7 @@ var init_chunk_X5PZZVTS = __esm({
14196
14806
  }
14197
14807
  });
14198
14808
 
14199
- // ../../packages/core/dist/chunk-K5UAZWFF.js
14809
+ // ../../packages/core/dist/chunk-BCN7SKBT.js
14200
14810
  function byLocale(entry) {
14201
14811
  const shape = Object.fromEntries(SUPPORTED_LOCALES.map((locale) => [locale, entry.optional()]));
14202
14812
  return external_exports.object(shape).strict();
@@ -14207,10 +14817,10 @@ function writeField(map) {
14207
14817
  );
14208
14818
  }
14209
14819
  var HUB_DISPLAY_NAME_MAX_CHARS, HUB_WELCOME_MESSAGE_MAX_CHARS, HUB_STARTER_QUESTIONS_MAX, HUB_STARTER_QUESTION_MAX_CHARS, displayName, welcomeMessage, starterQuestions, hubDisplayNamesSchema, hubWelcomeMessagesSchema, hubStarterQuestionsSchema, hubDisplayNamesField, hubWelcomeMessagesField, hubStarterQuestionsField, HUB_PRESENTATION_FIELDS, HUB_PRESENTATION_SCHEMAS;
14210
- var init_chunk_K5UAZWFF = __esm({
14211
- "../../packages/core/dist/chunk-K5UAZWFF.js"() {
14820
+ var init_chunk_BCN7SKBT = __esm({
14821
+ "../../packages/core/dist/chunk-BCN7SKBT.js"() {
14212
14822
  "use strict";
14213
- init_chunk_YROEDMVZ();
14823
+ init_chunk_NYNOISIG();
14214
14824
  init_zod();
14215
14825
  HUB_DISPLAY_NAME_MAX_CHARS = 120;
14216
14826
  HUB_WELCOME_MESSAGE_MAX_CHARS = 1e3;
@@ -14234,7 +14844,7 @@ var init_chunk_K5UAZWFF = __esm({
14234
14844
  }
14235
14845
  });
14236
14846
 
14237
- // ../../packages/core/dist/chunk-7NQZRSSJ.js
14847
+ // ../../packages/core/dist/chunk-CMCATTHI.js
14238
14848
  function refineLaneReferences(val, ctx) {
14239
14849
  const lanes = val.lanes;
14240
14850
  const statuses = val.kanban_statuses;
@@ -14244,9 +14854,9 @@ function refineLaneReferences(val, ctx) {
14244
14854
  }
14245
14855
  }
14246
14856
  function describeSyncWarning(warning) {
14247
- const label2 = `Toolset "${warning.toolset}" (connection "${warning.connection_name}")`;
14857
+ const label3 = `Toolset "${warning.toolset}" (connection "${warning.connection_name}")`;
14248
14858
  if (warning.kind === "toolset_tools_unverified") {
14249
- return `${label2}: its tools could not be compared with production's. Check that production's toolset publishes the tools the preview uses.`;
14859
+ return `${label3}: its tools could not be compared with production's. Check that production's toolset publishes the tools the preview uses.`;
14250
14860
  }
14251
14861
  const parts = [];
14252
14862
  if (warning.missing_in_production.length > 0) {
@@ -14255,15 +14865,15 @@ function describeSyncWarning(warning) {
14255
14865
  if (warning.only_in_production.length > 0) {
14256
14866
  parts.push(`only production has ${warning.only_in_production.join(", ")}`);
14257
14867
  }
14258
- return `${label2}: ${parts.join("; ")}. Promote the base so production's tools match the preview's.`;
14868
+ return `${label3}: ${parts.join("; ")}. Promote the base so production's tools match the preview's.`;
14259
14869
  }
14260
14870
  var hubIdParam, hubAdminIdParam, hubUserIdParam, hubAgentIdParam, hubIdentityIdParam, hubTeamIdParam, hubTeamUserDeleteParam, hubSchemaQuery, HUB_USERS_PAGE_SIZE_MAX, HUB_USERS_SEARCH_MAX, HUB_USERS_CHANNEL_TYPES, getHubUsersQuery, PREVIEW_LABEL_MAX_LENGTH, MAX_ENDED_INDEX_RETENTION_DAYS, MAX_EVAL_RETENTION_DAYS, MAX_END_USER_DAILY_MESSAGE_LIMIT, endUserDailyMessageLimitField, previewLabelField, hubTagsField, createHubBody, updateHubBody, HUB_TAG_CHANGE_REFUSED, hubTagChangeRefusalSchema, addHubAdminBody, addHubIdentityAuthorizationBody, contactDecisionBody, approveContactBody, CONTACT_ACCESS_PAGE_SIZE_MAX, listContactAccessQuery, createHubTeamBody, updateHubTeamBody, addHubTeamUserBody, reassignHubUserBody, replicatePreviewBody, HUB_DIFF_SECTION_SET, HUB_DIFF_SECTIONS, updateChannelTestIdentitiesBody, claimCodeChannelParam, claimCodeDeleteParam;
14261
- var init_chunk_7NQZRSSJ = __esm({
14262
- "../../packages/core/dist/chunk-7NQZRSSJ.js"() {
14871
+ var init_chunk_CMCATTHI = __esm({
14872
+ "../../packages/core/dist/chunk-CMCATTHI.js"() {
14263
14873
  "use strict";
14264
14874
  init_chunk_D3EP4TDU();
14265
14875
  init_chunk_X5PZZVTS();
14266
- init_chunk_K5UAZWFF();
14876
+ init_chunk_BCN7SKBT();
14267
14877
  init_chunk_HZ6CADSY();
14268
14878
  init_zod();
14269
14879
  hubIdParam = external_exports.object({ id: uuidSchema });
@@ -14458,7 +15068,7 @@ var init_chunk_7NQZRSSJ = __esm({
14458
15068
  }
14459
15069
  });
14460
15070
 
14461
- // ../../packages/core/dist/chunk-Z6H7PHIF.js
15071
+ // ../../packages/core/dist/chunk-BAVTYKY7.js
14462
15072
  function declaresNoConnection(agent) {
14463
15073
  return agent.connection === null && !agent.connection_id;
14464
15074
  }
@@ -14809,10 +15419,10 @@ function refineHubAsCodeCallOpenings(config, ctx) {
14809
15419
  function utf8ByteLength2(value) {
14810
15420
  let bytes = 0;
14811
15421
  for (let i = 0; i < value.length; i++) {
14812
- const code = value.charCodeAt(i);
14813
- if (code < 128) bytes += 1;
14814
- else if (code < 2048) bytes += 2;
14815
- else if (code >= 55296 && code <= 56319 && i + 1 < value.length && value.charCodeAt(i + 1) >= 56320 && value.charCodeAt(i + 1) <= 57343) {
15422
+ const code2 = value.charCodeAt(i);
15423
+ if (code2 < 128) bytes += 1;
15424
+ else if (code2 < 2048) bytes += 2;
15425
+ else if (code2 >= 55296 && code2 <= 56319 && i + 1 < value.length && value.charCodeAt(i + 1) >= 56320 && value.charCodeAt(i + 1) <= 57343) {
14816
15426
  bytes += 4;
14817
15427
  i++;
14818
15428
  } else bytes += 3;
@@ -15190,25 +15800,25 @@ function skillSectionsAsResources(scope) {
15190
15800
  };
15191
15801
  }
15192
15802
  var MAX_10MB_BASE64_ENCODED_BYTES, MAX_EVAL_ATTACHMENT_ENCODED_BYTES, MAX_EVAL_ATTACHMENT_CARRIERS, MAX_EVAL_ATTACHMENT_AGGREGATE_ENCODED_BYTES, MAX_RESOURCE_ENCODED_BYTES, MAX_HUB_AS_CODE_RESOURCES, MAX_HUB_AS_CODE_RESOURCE_FILES, MAX_RESOURCE_AGGREGATE_ENCODED_BYTES, MAX_CI_CONFIG_BODY_BYTES, MAX_HUB_AS_CODE_PAGE_MANIFEST_CHARS, hubAsCodePagesSchema, MAX_CALL_OPENING_CARRIERS, MAX_CALL_OPENING_AGGREGATE_ENCODED_BYTES, HUB_AS_CODE_AGENT_TOOL_KEYS, hubAsCodeStateSchema, hubAsCodeResourceFileSchema, hubAsCodeResourceSchema, uuidPattern, ciUuidSchema, flagEntriesOf, boundedHubAsCodeResourcesSchema, isPlainObject, MIN_SKILLS_LAYOUT_CLI, MAX_HUB_AS_CODE_DEPTH, NAMED_DEPTH_SEGMENTS, NAMED_DEPTH_KEY_CHARS, fieldName, hubAsCodeConfigSchema, ciPullHubIdParam, ciBranchParam, ciPullQuery, ciHubsQuery, ciLookupQuery, ciBranchesQuery, ciSyncBody, ciPushBody, ciDiffBody, ciPublishBody, ciPublishPreviewBody, ciSyncMcpBody, ciOrgResourcesParam, orgResourcesConfigSchema, ciOrgResourcesPushBody, ciOrgResourcesDiffBody, CI_APPLY_ENTITY_KINDS, CI_APPLY_OPERATIONS, ciApplyErrorBaseSchema, ciApplyErrorSchema, ciSyncCountSchema, ciSyncChangesSchema, ciSyncWarningSchema, ciSyncResponseSchema;
15193
- var init_chunk_Z6H7PHIF = __esm({
15194
- "../../packages/core/dist/chunk-Z6H7PHIF.js"() {
15803
+ var init_chunk_BAVTYKY7 = __esm({
15804
+ "../../packages/core/dist/chunk-BAVTYKY7.js"() {
15195
15805
  "use strict";
15196
- init_chunk_YI3ORIXJ();
15197
- init_chunk_T6D3YZ6B();
15198
- init_chunk_66EZQ7Y7();
15806
+ init_chunk_CZS5NGTA();
15807
+ init_chunk_P74ESVOL();
15808
+ init_chunk_JKOMP2G3();
15199
15809
  init_chunk_LBDH7LCG();
15200
15810
  init_chunk_4LXDRTO4();
15201
- init_chunk_7NQZRSSJ();
15811
+ init_chunk_CMCATTHI();
15202
15812
  init_chunk_X5PZZVTS();
15203
- init_chunk_K5UAZWFF();
15204
- init_chunk_L4YFOZGK();
15813
+ init_chunk_BCN7SKBT();
15814
+ init_chunk_LYB5XDDT();
15205
15815
  init_chunk_S4VDZ7PZ();
15206
15816
  init_chunk_C2UEA2KW();
15207
15817
  init_chunk_FBV7NLKO();
15208
15818
  init_chunk_WEXVYJ5H();
15209
15819
  init_chunk_HZ6CADSY();
15210
- init_chunk_7IXDF53E();
15211
- init_chunk_YROEDMVZ();
15820
+ init_chunk_JOOVAYGO();
15821
+ init_chunk_NYNOISIG();
15212
15822
  init_zod();
15213
15823
  MAX_10MB_BASE64_ENCODED_BYTES = Math.ceil(MAX_RESOURCE_FILE_SIZE / 3) * 4 + 16;
15214
15824
  MAX_EVAL_ATTACHMENT_ENCODED_BYTES = MAX_10MB_BASE64_ENCODED_BYTES;
@@ -15525,6 +16135,217 @@ var init_chunk_JDJ4EUOL = __esm({
15525
16135
  }
15526
16136
  });
15527
16137
 
16138
+ // ../../packages/core/dist/chunk-PZPOUXJR.js
16139
+ var navItemSchema, hubCountResetBody, navItemCountResetBody, typingBody;
16140
+ var init_chunk_PZPOUXJR = __esm({
16141
+ "../../packages/core/dist/chunk-PZPOUXJR.js"() {
16142
+ "use strict";
16143
+ init_zod();
16144
+ navItemSchema = external_exports.enum(["chat", "support", "task"]);
16145
+ hubCountResetBody = external_exports.object({
16146
+ hub_id: external_exports.string().uuid(),
16147
+ nav_item: navItemSchema,
16148
+ conversation_id: external_exports.string().uuid().optional(),
16149
+ hub_user_id: external_exports.string().optional(),
16150
+ current_team_user_id: external_exports.string().optional()
16151
+ });
16152
+ navItemCountResetBody = external_exports.object({
16153
+ nav_item: navItemSchema
16154
+ });
16155
+ typingBody = external_exports.object({
16156
+ conversationId: external_exports.string().uuid(),
16157
+ hubId: external_exports.string().uuid(),
16158
+ action: external_exports.enum(["start", "stop"])
16159
+ });
16160
+ }
16161
+ });
16162
+
16163
+ // ../../packages/core/dist/chunk-YWZFB34T.js
16164
+ function cacheReconcileIdCount(body) {
16165
+ return body.conversations.length + body.histories.reduce((n, history) => n + history.conversation_ids.length, 0) + body.threads.length;
16166
+ }
16167
+ var CACHE_RECONCILE_MAX_IDS, CACHE_RECONCILE_MAX_HUBS, cacheReconcileScopeSchema, cachedConversationPageSchema, cachedHistoryThreadSchema, cachedPeopleThreadSchema, cacheReconcileBody;
16168
+ var init_chunk_YWZFB34T = __esm({
16169
+ "../../packages/core/dist/chunk-YWZFB34T.js"() {
16170
+ "use strict";
16171
+ init_chunk_PZPOUXJR();
16172
+ init_chunk_HZ6CADSY();
16173
+ init_zod();
16174
+ CACHE_RECONCILE_MAX_IDS = 300;
16175
+ CACHE_RECONCILE_MAX_HUBS = 15;
16176
+ cacheReconcileScopeSchema = navItemSchema;
16177
+ cachedConversationPageSchema = external_exports.object({
16178
+ conversation_id: uuidSchema,
16179
+ hub_id: uuidSchema,
16180
+ scope: cacheReconcileScopeSchema
16181
+ }).strict();
16182
+ cachedHistoryThreadSchema = external_exports.object({
16183
+ hub_id: uuidSchema,
16184
+ hub_user_id: external_exports.string().min(1).max(128),
16185
+ nav: cacheReconcileScopeSchema,
16186
+ conversation_ids: external_exports.array(uuidSchema).min(1).max(CACHE_RECONCILE_MAX_IDS)
16187
+ }).strict();
16188
+ cachedPeopleThreadSchema = external_exports.object({ thread_id: uuidSchema }).strict();
16189
+ cacheReconcileBody = external_exports.object({
16190
+ conversations: external_exports.array(cachedConversationPageSchema).max(CACHE_RECONCILE_MAX_IDS).default([]),
16191
+ histories: external_exports.array(cachedHistoryThreadSchema).max(CACHE_RECONCILE_MAX_IDS).default([]),
16192
+ threads: external_exports.array(cachedPeopleThreadSchema).max(CACHE_RECONCILE_MAX_IDS).default([])
16193
+ }).strict().superRefine((body, ctx) => {
16194
+ if (cacheReconcileIdCount(body) > CACHE_RECONCILE_MAX_IDS) {
16195
+ ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: `At most ${CACHE_RECONCILE_MAX_IDS} ids in all` });
16196
+ }
16197
+ const hubs = new Set([...body.conversations, ...body.histories].map((entry) => entry.hub_id));
16198
+ if (hubs.size > CACHE_RECONCILE_MAX_HUBS) {
16199
+ ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: `At most ${CACHE_RECONCILE_MAX_HUBS} distinct hubs` });
16200
+ }
16201
+ });
16202
+ }
16203
+ });
16204
+
16205
+ // ../../packages/core/dist/chunk-CVMCLWDN.js
16206
+ function openCaseProblem(body) {
16207
+ const pairs = /* @__PURE__ */ new Set();
16208
+ for (const [index, party] of body.parties.entries()) {
16209
+ const key = `${party.party_id}
16210
+ ${party.role}`;
16211
+ if (pairs.has(key)) return { reason: "party_role_repeated", at: `parties.${index}` };
16212
+ pairs.add(key);
16213
+ }
16214
+ if (new Set(body.instrument_ids).size !== body.instrument_ids.length) return { reason: "instrument_repeated", at: "instrument_ids" };
16215
+ return null;
16216
+ }
16217
+ var CASE_RECORD_CODE_PATTERN, CASE_RECORD_CODE_MAX_LENGTH, CASE_RECORD_PARTIES_MAX, CASE_RECORD_INSTRUMENTS_MAX, CASE_RECORD_ROLE_MAX_LENGTH, CASE_RECORDS_PAGE_MAX, CASE_RECORDS_QUERY_MAX_LENGTH, caseRecordPartySchema, openCaseShape, openCaseBody, caseRecordParam, caseRecordsQuery;
16218
+ var init_chunk_CVMCLWDN = __esm({
16219
+ "../../packages/core/dist/chunk-CVMCLWDN.js"() {
16220
+ "use strict";
16221
+ init_chunk_6IDXKJKK();
16222
+ init_chunk_HZ6CADSY();
16223
+ init_chunk_NYNOISIG();
16224
+ init_zod();
16225
+ CASE_RECORD_CODE_PATTERN = new RegExp(`^${CASE_TYPE_ABBREVIATION_PATTERN.source.slice(1, -1)}-[0-9]{4}-[0-9]{4,}$`);
16226
+ CASE_RECORD_CODE_MAX_LENGTH = 32;
16227
+ CASE_RECORD_PARTIES_MAX = 50;
16228
+ CASE_RECORD_INSTRUMENTS_MAX = 50;
16229
+ CASE_RECORD_ROLE_MAX_LENGTH = 64;
16230
+ CASE_RECORDS_PAGE_MAX = 100;
16231
+ CASE_RECORDS_QUERY_MAX_LENGTH = 32;
16232
+ caseRecordPartySchema = external_exports.object({
16233
+ party_id: uuidSchema,
16234
+ role: external_exports.string().min(1).max(CASE_RECORD_ROLE_MAX_LENGTH)
16235
+ }).strict();
16236
+ openCaseShape = external_exports.object({
16237
+ type_id: uuidSchema,
16238
+ /** The year in its code: within a year of today's year in the space's time zone. */
16239
+ year: external_exports.number().int().min(2e3).max(2100),
16240
+ parties: external_exports.array(caseRecordPartySchema).max(CASE_RECORD_PARTIES_MAX).default([]),
16241
+ instrument_ids: external_exports.array(uuidSchema).max(CASE_RECORD_INSTRUMENTS_MAX).default([]),
16242
+ /** The custom field values, checked against the version's schema in the space. */
16243
+ attributes: external_exports.record(external_exports.string(), external_exports.unknown()).default({}),
16244
+ confidential: external_exports.boolean().default(false),
16245
+ /** The code the opener was shown: another case holding it opens nothing. */
16246
+ expected_code: external_exports.string().max(CASE_RECORD_CODE_MAX_LENGTH).regex(CASE_RECORD_CODE_PATTERN).optional()
16247
+ }).strict();
16248
+ openCaseBody = openCaseShape.superRefine((body, ctx) => {
16249
+ const found = openCaseProblem(body);
16250
+ if (found) {
16251
+ ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: found.reason, path: found.at.split("."), params: { case_record_reason: found.reason } });
16252
+ }
16253
+ });
16254
+ caseRecordParam = caseSpaceParam.extend({
16255
+ code: external_exports.string().max(CASE_RECORD_CODE_MAX_LENGTH).regex(CASE_RECORD_CODE_PATTERN)
16256
+ });
16257
+ caseRecordsQuery = casePageQuery.extend({
16258
+ limit: external_exports.coerce.number().int().min(1).max(CASE_RECORDS_PAGE_MAX).optional(),
16259
+ type_id: uuidSchema.optional(),
16260
+ q: external_exports.string().trim().min(1).max(CASE_RECORDS_QUERY_MAX_LENGTH).optional()
16261
+ });
16262
+ }
16263
+ });
16264
+
16265
+ // ../../packages/core/dist/chunk-J2XPTNU3.js
16266
+ var CASE_RELATION_TYPE_CODE_PATTERN, CASE_RELATION_TYPE_CODE_MAX_LENGTH, CASE_RELATION_TYPE_NAME_MAX_LENGTH, CASE_RELATION_TYPES_PER_SPACE_MAX, CASE_RELATION_DESCRIPTION_MAX_LENGTH, CASE_RELATION_SIDES, CASE_EXTERNAL_SYSTEM_PATTERN, CASE_EXTERNAL_NUMBER_MAX_LENGTH, CASE_EXTERNAL_URL_MAX_LENGTH, trimmedName2, relationTypeFields, createCaseRelationTypeBody, updateCaseRelationTypeBody, relateCasesBody, addCaseExternalReferenceBody, caseRelationTypeParam, caseRelationParam, caseExternalReferenceParam, caseRelationTypesQuery;
16267
+ var init_chunk_J2XPTNU3 = __esm({
16268
+ "../../packages/core/dist/chunk-J2XPTNU3.js"() {
16269
+ "use strict";
16270
+ init_chunk_CVMCLWDN();
16271
+ init_chunk_6IDXKJKK();
16272
+ init_chunk_HZ6CADSY();
16273
+ init_zod();
16274
+ CASE_RELATION_TYPE_CODE_PATTERN = /^[a-z0-9]+(_[a-z0-9]+)*$/;
16275
+ CASE_RELATION_TYPE_CODE_MAX_LENGTH = 64;
16276
+ CASE_RELATION_TYPE_NAME_MAX_LENGTH = 200;
16277
+ CASE_RELATION_TYPES_PER_SPACE_MAX = 100;
16278
+ CASE_RELATION_DESCRIPTION_MAX_LENGTH = 500;
16279
+ CASE_RELATION_SIDES = ["origin", "destination"];
16280
+ CASE_EXTERNAL_SYSTEM_PATTERN = /^[A-Za-z0-9][A-Za-z0-9 ._-]{0,30}$/;
16281
+ CASE_EXTERNAL_NUMBER_MAX_LENGTH = 120;
16282
+ CASE_EXTERNAL_URL_MAX_LENGTH = 2048;
16283
+ trimmedName2 = external_exports.string().trim().min(1).max(CASE_RELATION_TYPE_NAME_MAX_LENGTH);
16284
+ relationTypeFields = { name: trimmedName2, inverse_name: trimmedName2, active: external_exports.boolean().default(true) };
16285
+ createCaseRelationTypeBody = external_exports.object({
16286
+ code: external_exports.string().trim().max(CASE_RELATION_TYPE_CODE_MAX_LENGTH).regex(CASE_RELATION_TYPE_CODE_PATTERN),
16287
+ ...relationTypeFields
16288
+ }).strict();
16289
+ updateCaseRelationTypeBody = external_exports.object({ ...relationTypeFields, expected_updated_at: timestampSchema.optional() }).strict();
16290
+ relateCasesBody = external_exports.object({
16291
+ relation_type_id: uuidSchema,
16292
+ other_code: external_exports.string().max(CASE_RECORD_CODE_MAX_LENGTH).regex(CASE_RECORD_CODE_PATTERN),
16293
+ /** This case's side: `origin` reads the type's name ("continues"), `destination` its inverse. */
16294
+ side: external_exports.enum(CASE_RELATION_SIDES).default("origin"),
16295
+ description: external_exports.string().trim().min(1).max(CASE_RELATION_DESCRIPTION_MAX_LENGTH).nullable().default(null)
16296
+ }).strict();
16297
+ addCaseExternalReferenceBody = external_exports.object({
16298
+ system: external_exports.string().trim().regex(CASE_EXTERNAL_SYSTEM_PATTERN),
16299
+ number: external_exports.string().trim().min(1).max(CASE_EXTERNAL_NUMBER_MAX_LENGTH),
16300
+ url: external_exports.string().trim().max(CASE_EXTERNAL_URL_MAX_LENGTH).url().refine((url) => url.startsWith("https://"), "An https link").nullable().default(null)
16301
+ }).strict();
16302
+ caseRelationTypeParam = caseSpaceParam.extend({ relation_type_id: uuidSchema });
16303
+ caseRelationParam = caseRecordParam.extend({ relation_id: uuidSchema });
16304
+ caseExternalReferenceParam = caseRecordParam.extend({ reference_id: uuidSchema });
16305
+ caseRelationTypesQuery = casePageQuery.extend({
16306
+ limit: external_exports.coerce.number().int().min(1).max(CASE_RELATION_TYPES_PER_SPACE_MAX).optional()
16307
+ });
16308
+ }
16309
+ });
16310
+
16311
+ // ../../packages/core/dist/chunk-VYEEXMLB.js
16312
+ function addCaseNoteProblem(note) {
16313
+ return note.origin !== null && note.kind !== "contribution" ? { reason: "origin_not_contribution", at: "origin" } : null;
16314
+ }
16315
+ var CASE_NOTE_KINDS, CASE_NOTE_TEXT_MAX_LENGTH, CASE_NOTE_ORIGIN_MAX_LENGTH, CASE_NOTES_PAGE_MAX, addCaseNoteShape, addCaseNoteBody, caseNoteParam, caseTaskParam, caseNotesQuery;
16316
+ var init_chunk_VYEEXMLB = __esm({
16317
+ "../../packages/core/dist/chunk-VYEEXMLB.js"() {
16318
+ "use strict";
16319
+ init_chunk_CVMCLWDN();
16320
+ init_chunk_6IDXKJKK();
16321
+ init_chunk_HZ6CADSY();
16322
+ init_zod();
16323
+ CASE_NOTE_KINDS = ["observation", "next_step", "pending", "contribution"];
16324
+ CASE_NOTE_TEXT_MAX_LENGTH = 64 * 1024;
16325
+ CASE_NOTE_ORIGIN_MAX_LENGTH = 200;
16326
+ CASE_NOTES_PAGE_MAX = 100;
16327
+ addCaseNoteShape = external_exports.object({
16328
+ kind: external_exports.enum(CASE_NOTE_KINDS),
16329
+ text: external_exports.string().trim().min(1).max(CASE_NOTE_TEXT_MAX_LENGTH),
16330
+ /** A contribution's external author. */
16331
+ origin: external_exports.string().trim().min(1).max(CASE_NOTE_ORIGIN_MAX_LENGTH).nullable().default(null),
16332
+ /** A phase of the case (its version's phase id). */
16333
+ phase_id: uuidSchema.nullable().default(null),
16334
+ /** A task of the case, whose phase the note takes. */
16335
+ case_task_id: uuidSchema.nullable().default(null)
16336
+ }).strict();
16337
+ addCaseNoteBody = addCaseNoteShape.superRefine((note, ctx) => {
16338
+ const found = addCaseNoteProblem(note);
16339
+ if (found) ctx.addIssue({ code: external_exports.ZodIssueCode.custom, message: found.reason, path: [found.at], params: { case_note_reason: found.reason } });
16340
+ });
16341
+ caseNoteParam = caseRecordParam.extend({ note_id: uuidSchema });
16342
+ caseTaskParam = caseRecordParam.extend({ case_task_id: uuidSchema });
16343
+ caseNotesQuery = casePageQuery.extend({
16344
+ limit: external_exports.coerce.number().int().min(1).max(CASE_NOTES_PAGE_MAX).optional()
16345
+ });
16346
+ }
16347
+ });
16348
+
15528
16349
  // ../../packages/core/dist/chunk-NVKU5PPQ.js
15529
16350
  var ADMIN_SKILL_NAME_REGEX, adminSkillNameParam;
15530
16351
  var init_chunk_NVKU5PPQ = __esm({
@@ -15688,7 +16509,7 @@ var init_chunk_OMPT4ZHR = __esm({
15688
16509
  }
15689
16510
  });
15690
16511
 
15691
- // ../../packages/core/dist/chunk-4KGSO7DL.js
16512
+ // ../../packages/core/dist/chunk-B6GNOJ6J.js
15692
16513
  function refineScopedTarget(data, ctx) {
15693
16514
  if (data.scope === "org") {
15694
16515
  if (!data.org_id) {
@@ -15714,13 +16535,13 @@ function refineScopedTarget(data, ctx) {
15714
16535
  }
15715
16536
  }
15716
16537
  var adminOrgIdParam, adminOrgAdminIdParam, adminUserIdParam, PRICING_PLAN_ID_RE, adminPlanIdParam, adminOrganizationsQuery, adminUserSearchQuery, kanbanSlugMigrationQuery, adjustQuotaBody, updatePlanBody, addAdminUserBody, MAX_VOICE_CALL_MINUTE_OPS, voiceCallMinuteOps, AUTOMATION_GATE_EVALUATIONS_PER_OPERATION_BOUND, automationGateEvaluationsPerOperation, AUTOMATION_RUN_RETENTION_DAYS_MAX, automationRunRetentionDays, turnDeadlineSeconds, casesLimit, updatePlatformConfigBody, updateFreeOrgLimitBody, adminScopedTargetShape, adminScopedTargetBody, adminDryRunByDefaultTargetBody, WAYAI_HOST_TOKEN_TARGET_KINDS, WAYAI_HOST_TOKEN_MAX_TARGETS, adminClearWayaiHostTokensBody, BRANCHING_ORPHAN_ENTITY_TYPES, BRANCHING_ORPHAN_MAX_TARGETS, adminRepairBranchingOrphansBody, adminRepairLegacyOrgGrantsBody, adminRepairCompedPlansBody, updatePricingPlanBody, dataExplorerSearchQuery, dataExplorerOrgIdParam, dataExplorerHubIdParam, dataExplorerConvIdParam, dataExplorerDoInstancesQuery, dataExplorerNsIdParam, dataExplorerKvKeysBody, dataExplorerKvKeyBody, uuidOrHexId, dataExplorerDeleteOrgParam, dataExplorerDeleteHubParam, dataExplorerDeleteConvParam, dataExplorerDeleteUserParam, dataExplorerDeleteQuery, dataExplorerKvDeleteBody, pitrDoNamespace, pitrBookmarkParam, pitrRestoreBody, healthSamplingTriggerBody, DEBUG_DO_HEX_PREFIX, debugDoEntityId, debugTableName, dataExplorerDebugTablesParam, dataExplorerDebugRowsParam, dataExplorerDebugRowsQuery, dataExplorerDebugAnalyticsTable, debugUuid, dataExplorerDebugAnalyticsRowsParam, dataExplorerDebugAnalyticsRowsQuery, dataExplorerDebugCountsDoType, dataExplorerDebugCountsParam, debugHubConvParam, debugMessageIdQuery;
15717
- var init_chunk_4KGSO7DL = __esm({
15718
- "../../packages/core/dist/chunk-4KGSO7DL.js"() {
16538
+ var init_chunk_B6GNOJ6J = __esm({
16539
+ "../../packages/core/dist/chunk-B6GNOJ6J.js"() {
15719
16540
  "use strict";
15720
16541
  init_chunk_FECLIZTY();
15721
16542
  init_chunk_BFG4ZWR4();
15722
16543
  init_chunk_2R5D4TEX();
15723
- init_chunk_7NQZRSSJ();
16544
+ init_chunk_CMCATTHI();
15724
16545
  init_chunk_OMPT4ZHR();
15725
16546
  init_chunk_HZ6CADSY();
15726
16547
  init_chunk_MIWZOSPI();
@@ -16268,17 +17089,17 @@ var init_chunk_R6Y377AW = __esm({
16268
17089
  }
16269
17090
  });
16270
17091
 
16271
- // ../../packages/core/dist/chunk-FXIVKOSV.js
17092
+ // ../../packages/core/dist/chunk-YHQXIL22.js
16272
17093
  var AUTOMATION_TRIGGER_TYPES, AUTOMATION_EVENT_TYPES, AUTOMATION_TARGET_TYPES, AUTOMATION_ACTION_TYPES, AUTOMATION_CHANNEL_TYPES, AUTOMATION_PURPOSES, AUTOMATION_NAME_MAX, AUTOMATION_DESCRIPTION_MAX, AUTOMATION_INSTRUCTIONS_MAX, AUTOMATION_TEXT_MAX, AUTOMATION_CRON_MAX, AUTOMATION_WEBHOOK_AUTHS, AUTOMATION_WEBHOOK_HEADERS, AUTOMATION_WEBHOOK_BODY_MAX_BYTES, AUTOMATION_WEBHOOK_HEADER_NAME_MAX, WEBHOOK_RESERVED_HEADERS, automationTriggerSchema, automationTargetSchema, automationActionSchema, automationGateSchema, automationName, automationDescription, automationIdParam, automationHubQuery, automationWebhookParams, AUTOMATION_RUNS_PAGE_MAX, listAutomationRunsQuery, createAutomationBody, updateAutomationBody, AUTOMATION_ALERT_CATEGORIES, AUTOMATION_BLOCKED_ALERT_CATEGORY, automationEventSubscriberParam;
16273
- var init_chunk_FXIVKOSV = __esm({
16274
- "../../packages/core/dist/chunk-FXIVKOSV.js"() {
17094
+ var init_chunk_YHQXIL22 = __esm({
17095
+ "../../packages/core/dist/chunk-YHQXIL22.js"() {
16275
17096
  "use strict";
16276
17097
  init_chunk_R6Y377AW();
16277
17098
  init_chunk_UAOHHCW5();
16278
- init_chunk_L4YFOZGK();
17099
+ init_chunk_LYB5XDDT();
16279
17100
  init_chunk_5FO3GNKP();
16280
- init_chunk_7IXDF53E();
16281
- init_chunk_YROEDMVZ();
17101
+ init_chunk_JOOVAYGO();
17102
+ init_chunk_NYNOISIG();
16282
17103
  init_zod();
16283
17104
  AUTOMATION_TRIGGER_TYPES = ["schedule", "event", "webhook"];
16284
17105
  AUTOMATION_EVENT_TYPES = ["conversation.flagged", "conversation.closed"];
@@ -16512,7 +17333,7 @@ var init_contracts = __esm({
16512
17333
  init_chunk_Q7KIQHAZ();
16513
17334
  init_chunk_IPXBFWUU();
16514
17335
  init_chunk_NKLVUTFO();
16515
- init_chunk_WL5QGKHN();
17336
+ init_chunk_6JOESMU5();
16516
17337
  init_chunk_YVY2TZK2();
16517
17338
  init_chunk_VXEAR36B();
16518
17339
  init_chunk_HIGKBEPF();
@@ -16520,7 +17341,7 @@ var init_contracts = __esm({
16520
17341
  init_chunk_MF2VVXBR();
16521
17342
  init_chunk_WE4KMHZK();
16522
17343
  init_chunk_P5GJNS5R();
16523
- init_chunk_JW6QQD5K();
17344
+ init_chunk_HE5RU7KY();
16524
17345
  init_chunk_ZC6YGHNX();
16525
17346
  init_chunk_MGBAXT5Y();
16526
17347
  init_chunk_5DGHIY7L();
@@ -16528,8 +17349,8 @@ var init_contracts = __esm({
16528
17349
  init_chunk_IPDOHAZ5();
16529
17350
  init_chunk_PFGVH2CX();
16530
17351
  init_chunk_FPSDNS2E();
16531
- init_chunk_TSIH4Y2H();
16532
- init_chunk_U6S4MZGT();
17352
+ init_chunk_MI4UV5EU();
17353
+ init_chunk_SGQ5NQ5K();
16533
17354
  init_chunk_ZXK6N2HN();
16534
17355
  init_chunk_Y7CFCYX4();
16535
17356
  init_chunk_YUZFHVB2();
@@ -16541,7 +17362,7 @@ var init_contracts = __esm({
16541
17362
  init_chunk_SY6PLCPK();
16542
17363
  init_chunk_KMAC3O3L();
16543
17364
  init_chunk_MH4O3YEX();
16544
- init_chunk_65MH4JRN();
17365
+ init_chunk_4B7VQDLJ();
16545
17366
  init_chunk_KSTYTQ7I();
16546
17367
  init_chunk_LKBSHANA();
16547
17368
  init_chunk_I2EVH3FR();
@@ -16552,42 +17373,50 @@ var init_contracts = __esm({
16552
17373
  init_chunk_V4FRPRH5();
16553
17374
  init_chunk_LWMLR2WI();
16554
17375
  init_chunk_ACGAI25T();
16555
- init_chunk_YWZFB34T();
16556
- init_chunk_PZPOUXJR();
16557
- init_chunk_E4DIIOOE();
16558
- init_chunk_GAANFFN7();
17376
+ init_chunk_NB5PNVSF();
17377
+ init_chunk_CXKQ2DHH();
17378
+ init_chunk_BGOBDSII();
16559
17379
  init_chunk_7CYHPF35();
16560
17380
  init_chunk_NETRUHZF();
16561
- init_chunk_Z6H7PHIF();
16562
- init_chunk_YI3ORIXJ();
16563
- init_chunk_T6D3YZ6B();
16564
- init_chunk_66EZQ7Y7();
17381
+ init_chunk_BAVTYKY7();
17382
+ init_chunk_CZS5NGTA();
17383
+ init_chunk_P74ESVOL();
17384
+ init_chunk_JKOMP2G3();
16565
17385
  init_chunk_SDOG6762();
16566
17386
  init_chunk_2YEGUQR7();
17387
+ init_chunk_JDJ4EUOL();
17388
+ init_chunk_YWZFB34T();
17389
+ init_chunk_PZPOUXJR();
16567
17390
  init_chunk_LBDH7LCG();
16568
17391
  init_chunk_4LXDRTO4();
16569
- init_chunk_JDJ4EUOL();
17392
+ init_chunk_E4DIIOOE();
17393
+ init_chunk_FOFCV4SW();
17394
+ init_chunk_J2XPTNU3();
17395
+ init_chunk_VYEEXMLB();
17396
+ init_chunk_CVMCLWDN();
17397
+ init_chunk_6IDXKJKK();
16570
17398
  init_chunk_NVKU5PPQ();
16571
- init_chunk_4KGSO7DL();
17399
+ init_chunk_B6GNOJ6J();
16572
17400
  init_chunk_FECLIZTY();
16573
17401
  init_chunk_BFG4ZWR4();
16574
17402
  init_chunk_2R5D4TEX();
16575
- init_chunk_7NQZRSSJ();
17403
+ init_chunk_CMCATTHI();
16576
17404
  init_chunk_D3EP4TDU();
16577
17405
  init_chunk_X5PZZVTS();
16578
- init_chunk_K5UAZWFF();
17406
+ init_chunk_BCN7SKBT();
17407
+ init_chunk_OMPT4ZHR();
16579
17408
  init_chunk_2PZIF56U();
16580
17409
  init_chunk_UEJOG2Q7();
16581
17410
  init_chunk_KEN2DASI();
16582
- init_chunk_FXIVKOSV();
17411
+ init_chunk_YHQXIL22();
16583
17412
  init_chunk_R6Y377AW();
16584
17413
  init_chunk_UAOHHCW5();
16585
- init_chunk_L4YFOZGK();
17414
+ init_chunk_LYB5XDDT();
16586
17415
  init_chunk_ULQGJUXZ();
16587
- init_chunk_OMPT4ZHR();
17416
+ init_chunk_VYINA6YP();
16588
17417
  init_chunk_EJRDF5B6();
16589
17418
  init_chunk_SOJMWM63();
16590
- init_chunk_WTOA3ANF();
17419
+ init_chunk_7DLTG7J5();
16591
17420
  init_chunk_5FO3GNKP();
16592
17421
  init_chunk_IBL7FANV();
16593
17422
  init_chunk_S4VDZ7PZ();
@@ -16605,12 +17434,12 @@ var init_contracts = __esm({
16605
17434
  init_chunk_WEXVYJ5H();
16606
17435
  init_chunk_6TSQ5HXC();
16607
17436
  init_chunk_HZ6CADSY();
16608
- init_chunk_7IXDF53E();
16609
- init_chunk_55RZ7YIF();
16610
- init_chunk_JHUTFQDO();
17437
+ init_chunk_JOOVAYGO();
17438
+ init_chunk_IEEMZR55();
17439
+ init_chunk_4IXIQQ2A();
16611
17440
  init_chunk_7IKO675N();
16612
17441
  init_chunk_MIWZOSPI();
16613
- init_chunk_YROEDMVZ();
17442
+ init_chunk_NYNOISIG();
16614
17443
  init_chunk_L5F7ZOUJ();
16615
17444
  init_chunk_ICYO56QW();
16616
17445
  init_chunk_WFQDSQJK();
@@ -16751,7 +17580,7 @@ var init_dist = __esm({
16751
17580
  "use strict";
16752
17581
  init_chunk_EJRDF5B6();
16753
17582
  init_chunk_SOJMWM63();
16754
- init_chunk_WTOA3ANF();
17583
+ init_chunk_7DLTG7J5();
16755
17584
  init_chunk_5FO3GNKP();
16756
17585
  init_chunk_IBL7FANV();
16757
17586
  init_chunk_S4VDZ7PZ();
@@ -16768,12 +17597,12 @@ var init_dist = __esm({
16768
17597
  init_chunk_6TSQ5HXC();
16769
17598
  init_chunk_HZ6CADSY();
16770
17599
  init_chunk_FZ7BJJW7();
16771
- init_chunk_7IXDF53E();
16772
- init_chunk_55RZ7YIF();
16773
- init_chunk_JHUTFQDO();
17600
+ init_chunk_JOOVAYGO();
17601
+ init_chunk_IEEMZR55();
17602
+ init_chunk_4IXIQQ2A();
16774
17603
  init_chunk_7IKO675N();
16775
17604
  init_chunk_MIWZOSPI();
16776
- init_chunk_YROEDMVZ();
17605
+ init_chunk_NYNOISIG();
16777
17606
  init_chunk_L5F7ZOUJ();
16778
17607
  init_chunk_ICYO56QW();
16779
17608
  init_chunk_WFQDSQJK();
@@ -18266,17 +19095,17 @@ function writeResourceFileTree(resDir, files, root, log) {
18266
19095
  }
18267
19096
  const writtenPaths = /* @__PURE__ */ new Set();
18268
19097
  for (const file of files) {
18269
- const filePath2 = path8.join(resDir, file.path);
18270
- if (!filePath2.startsWith(resDir + path8.sep) && filePath2 !== resDir) {
19098
+ const filePath3 = path8.join(resDir, file.path);
19099
+ if (!filePath3.startsWith(resDir + path8.sep) && filePath3 !== resDir) {
18271
19100
  console.warn(` Warning: skipping ${file.path} (path traversal detected)`);
18272
19101
  continue;
18273
19102
  }
18274
19103
  writtenPaths.add(file.path);
18275
19104
  const buf = file.content !== void 0 ? Buffer.from(file.content, "utf-8") : file.content_base64 ? Buffer.from(file.content_base64, "base64") : void 0;
18276
19105
  if (buf === void 0) continue;
18277
- if (fileHasBytes(filePath2, buf)) continue;
18278
- if (writeFileNoFollow(resDir, filePath2, buf)) {
18279
- log?.changed.push(path8.relative(root, filePath2));
19106
+ if (fileHasBytes(filePath3, buf)) continue;
19107
+ if (writeFileNoFollow(resDir, filePath3, buf)) {
19108
+ log?.changed.push(path8.relative(root, filePath3));
18280
19109
  } else {
18281
19110
  console.warn(` Warning: skipping ${file.path} (destination escapes the skill folder via a symlink)`);
18282
19111
  writtenPaths.delete(file.path);
@@ -18307,15 +19136,15 @@ async function downloadBinaryFiles(resDir, files, root, log) {
18307
19136
  for (const file of files) {
18308
19137
  if (!file.download_url || file.content !== void 0) continue;
18309
19138
  try {
18310
- const filePath2 = path8.join(resDir, file.path);
18311
- if (!filePath2.startsWith(resDir + path8.sep) && filePath2 !== resDir) {
19139
+ const filePath3 = path8.join(resDir, file.path);
19140
+ if (!filePath3.startsWith(resDir + path8.sep) && filePath3 !== resDir) {
18312
19141
  console.warn(` Warning: skipping ${file.path} (path traversal detected)`);
18313
19142
  continue;
18314
19143
  }
18315
19144
  if (file.hash) {
18316
19145
  try {
18317
- const st = fs6.lstatSync(filePath2);
18318
- if (st.isFile() && !st.isSymbolicLink() && computeHash(fs6.readFileSync(filePath2)) === file.hash) continue;
19146
+ const st = fs6.lstatSync(filePath3);
19147
+ if (st.isFile() && !st.isSymbolicLink() && computeHash(fs6.readFileSync(filePath3)) === file.hash) continue;
18319
19148
  } catch {
18320
19149
  }
18321
19150
  }
@@ -18325,10 +19154,10 @@ async function downloadBinaryFiles(resDir, files, root, log) {
18325
19154
  continue;
18326
19155
  }
18327
19156
  const buffer = Buffer.from(await response.arrayBuffer());
18328
- if (fileHasBytes(filePath2, buffer)) continue;
18329
- if (writeFileNoFollow(resDir, filePath2, buffer)) {
19157
+ if (fileHasBytes(filePath3, buffer)) continue;
19158
+ if (writeFileNoFollow(resDir, filePath3, buffer)) {
18330
19159
  count++;
18331
- log?.changed.push(path8.relative(root, filePath2));
19160
+ log?.changed.push(path8.relative(root, filePath3));
18332
19161
  } else {
18333
19162
  console.warn(` Warning: skipping ${file.path} (destination escapes the skill folder via a symlink)`);
18334
19163
  }
@@ -18639,8 +19468,8 @@ var init_api_client = __esm({
18639
19468
  async createAccessDimension(orgId, body) {
18640
19469
  return this.request("POST", accessDimensions(orgId), body);
18641
19470
  }
18642
- async relabelAccessDimension(orgId, dimensionId, label2) {
18643
- return this.request("PATCH", accessDimensions(orgId, dimensionId), { label: label2 });
19471
+ async relabelAccessDimension(orgId, dimensionId, label3) {
19472
+ return this.request("PATCH", accessDimensions(orgId, dimensionId), { label: label3 });
18644
19473
  }
18645
19474
  async createAccessValue(orgId, dimensionId, body) {
18646
19475
  return this.request("POST", `${accessDimensions(orgId, dimensionId)}/values`, body);
@@ -18792,8 +19621,8 @@ var init_api_client = __esm({
18792
19621
  async me() {
18793
19622
  return this.request("GET", "/api/auth/me");
18794
19623
  }
18795
- async verifySecondFactor(code) {
18796
- return this.request("POST", "/api/auth/second-factor/verify", { code });
19624
+ async verifySecondFactor(code2) {
19625
+ return this.request("POST", "/api/auth/second-factor/verify", { code: code2 });
18797
19626
  }
18798
19627
  async useSecondFactorRecoveryCode(recoveryCode) {
18799
19628
  return this.request("POST", "/api/auth/second-factor/recovery", { recovery_code: recoveryCode });
@@ -19524,11 +20353,11 @@ function friendlyHint(err) {
19524
20353
  return "Couldn't reach WayAI \u2014 check your network connection and try again.";
19525
20354
  }
19526
20355
  if (!(err instanceof ApiError)) return null;
19527
- const code = extractApiErrorCode(err);
19528
- if (code === SECOND_FACTOR_REQUIRED_CODE) {
20356
+ const code2 = extractApiErrorCode(err);
20357
+ if (code2 === SECOND_FACTOR_REQUIRED_CODE) {
19529
20358
  return "This action needs a two-step verification code. Run `wayai 2fa verify`, then try again.";
19530
20359
  }
19531
- if (code === SECOND_FACTOR_ENROLLMENT_REQUIRED_CODE) {
20360
+ if (code2 === SECOND_FACTOR_ENROLLMENT_REQUIRED_CODE) {
19532
20361
  return "This organization requires two-step verification. Turn it on in your WayAI account settings, then try again.";
19533
20362
  }
19534
20363
  if (err.body.includes("FREE_PLAN_RESTRICTION")) {
@@ -20332,13 +21161,13 @@ function generateState() {
20332
21161
  function expiresInToIso(expiresInSeconds) {
20333
21162
  return new Date(Date.now() + expiresInSeconds * 1e3).toISOString();
20334
21163
  }
20335
- async function exchangeCodeForTokens(authkitDomain, clientId, code, codeVerifier, redirectUri) {
21164
+ async function exchangeCodeForTokens(authkitDomain, clientId, code2, codeVerifier, redirectUri) {
20336
21165
  const response = await fetch(`${authkitDomain}/oauth2/token`, {
20337
21166
  method: "POST",
20338
21167
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
20339
21168
  body: new URLSearchParams({
20340
21169
  grant_type: "authorization_code",
20341
- code,
21170
+ code: code2,
20342
21171
  code_verifier: codeVerifier,
20343
21172
  redirect_uri: redirectUri,
20344
21173
  client_id: clientId
@@ -20389,7 +21218,7 @@ function startCallbackServer(port, expectedState, timeoutMs = 12e4) {
20389
21218
  const server = http.createServer((req, res) => {
20390
21219
  const url = new URL(req.url || "/", `http://127.0.0.1:${port}`);
20391
21220
  if (url.pathname === "/callback") {
20392
- const code = url.searchParams.get("code");
21221
+ const code2 = url.searchParams.get("code");
20393
21222
  const state = url.searchParams.get("state");
20394
21223
  const error = url.searchParams.get("error");
20395
21224
  const errorDescription = url.searchParams.get("error_description");
@@ -20407,11 +21236,11 @@ function startCallbackServer(port, expectedState, timeoutMs = 12e4) {
20407
21236
  reject(new Error("OAuth state mismatch \u2014 possible CSRF attack"));
20408
21237
  return;
20409
21238
  }
20410
- if (code) {
21239
+ if (code2) {
20411
21240
  res.writeHead(200, { "Content-Type": "text/html" });
20412
21241
  res.end("<html><body><h2>Login successful!</h2><p>You can close this tab and return to your terminal.</p></body></html>");
20413
21242
  server.close();
20414
- resolve13({ code, port });
21243
+ resolve13({ code: code2, port });
20415
21244
  } else {
20416
21245
  res.writeHead(400, { "Content-Type": "text/html" });
20417
21246
  res.end("<html><body><h2>Login failed</h2><p>No authorization code received</p></body></html>");
@@ -20720,12 +21549,12 @@ Open this URL in your browser to log in:
20720
21549
  } else {
20721
21550
  console.log("Opening browser for login...");
20722
21551
  }
20723
- const { code } = await callbackPromise;
21552
+ const { code: code2 } = await callbackPromise;
20724
21553
  console.log("Exchanging authorization code...");
20725
21554
  const tokens2 = await exchangeCodeForTokens(
20726
21555
  authkitDomain,
20727
21556
  clientId,
20728
- code,
21557
+ code2,
20729
21558
  codeVerifier,
20730
21559
  redirectUri
20731
21560
  );
@@ -21023,13 +21852,13 @@ function describeAxis(axis, ids) {
21023
21852
  function describeScope(scope) {
21024
21853
  return AXIS_ORDER.filter((axis) => scope[axis].length > 0).map((axis) => describeAxis(axis, scope[axis])).join("; ");
21025
21854
  }
21026
- function assertInScope(axis, resolvedId, label2) {
21855
+ function assertInScope(axis, resolvedId, label3) {
21027
21856
  const scoped = readScope()[axis];
21028
21857
  if (scoped.length === 0) return;
21029
21858
  if (scoped.includes(resolvedId)) return;
21030
21859
  const { noun, selectorFor } = AXES[axis];
21031
21860
  const selector = selectorFor(resolvedId);
21032
- const target = label2 ? `${label2} (${resolvedId})` : resolvedId;
21861
+ const target = label3 ? `${label3} (${resolvedId})` : resolvedId;
21033
21862
  console.error(
21034
21863
  [
21035
21864
  `This worktree is scoped to ${describeAxis(axis, scoped)}, but the command resolved to ${target}.`,
@@ -21349,7 +22178,7 @@ var init_whoami = __esm({
21349
22178
  var init_constants = __esm({
21350
22179
  "../../packages/core/dist/constants.js"() {
21351
22180
  "use strict";
21352
- init_chunk_YROEDMVZ();
22181
+ init_chunk_NYNOISIG();
21353
22182
  }
21354
22183
  });
21355
22184
 
@@ -21535,7 +22364,7 @@ function listCommunityFolders(communitiesDir) {
21535
22364
  }
21536
22365
  function resolveCommunityTarget(gitRoot, selector, cwd = process.cwd()) {
21537
22366
  const { communitiesDir } = resolveLayout(gitRoot);
21538
- const label2 = communitiesDirLabel(gitRoot);
22367
+ const label3 = communitiesDirLabel(gitRoot);
21539
22368
  if (selector === void 0) {
21540
22369
  const here = path13.resolve(cwd);
21541
22370
  const name = isUnder(communitiesDir, here) ? path13.relative(communitiesDir, here).split(path13.sep)[0] : "";
@@ -21544,7 +22373,7 @@ function resolveCommunityTarget(gitRoot, selector, cwd = process.cwd()) {
21544
22373
  throw expected(
21545
22374
  [
21546
22375
  `Name the community: ${COMMUNITY_SELECTOR_FORMS}.`,
21547
- ...folders.length > 0 ? [`Folders in ${label2}/:`, ...folders.map((f) => ` ${path13.basename(f.folder)} (${f.communityId})`)] : []
22376
+ ...folders.length > 0 ? [`Folders in ${label3}/:`, ...folders.map((f) => ` ${path13.basename(f.folder)} (${f.communityId})`)] : []
21548
22377
  ].join("\n")
21549
22378
  );
21550
22379
  }
@@ -21563,7 +22392,7 @@ function resolveCommunityTarget(gitRoot, selector, cwd = process.cwd()) {
21563
22392
  return match ? { folder: match.folder } : { folder: null, communityId: selector };
21564
22393
  }
21565
22394
  throw expected(
21566
- `No community folder ${JSON.stringify(selector)} in ${label2}/. To pull a community for the first time, name it by its id (\`wayai communities list\` shows them): wayai pull ${WAYAI_LAYOUT.communitiesSubdir}/<community_id>`
22395
+ `No community folder ${JSON.stringify(selector)} in ${label3}/. To pull a community for the first time, name it by its id (\`wayai communities list\` shows them): wayai pull ${WAYAI_LAYOUT.communitiesSubdir}/<community_id>`
21567
22396
  );
21568
22397
  }
21569
22398
  function resolveCommunitySelectorToId(gitRoot, selector) {
@@ -21611,25 +22440,25 @@ var init_community_workspace = __esm({
21611
22440
  // src/lib/eval-attachments.ts
21612
22441
  import * as fs11 from "fs";
21613
22442
  import * as path14 from "path";
21614
- function resolveTurnAttachments(hubFolder, turn, label2, bytesByHash) {
22443
+ function resolveTurnAttachments(hubFolder, turn, label3, bytesByHash) {
21615
22444
  const raw = turn.attachments;
21616
22445
  if (raw === void 0 || raw === null) return void 0;
21617
22446
  if (!Array.isArray(raw) || raw.length === 0) {
21618
22447
  if (Array.isArray(raw)) return void 0;
21619
- throw expected(`${label2}: "attachments" must be a list of file paths.`);
22448
+ throw expected(`${label3}: "attachments" must be a list of file paths.`);
21620
22449
  }
21621
22450
  if (turn.role !== "user") {
21622
- throw expected(`${label2}: attachments are only allowed on user turns (this turn is "${String(turn.role)}").`);
22451
+ throw expected(`${label3}: attachments are only allowed on user turns (this turn is "${String(turn.role)}").`);
21623
22452
  }
21624
22453
  const refs = [];
21625
22454
  for (const entry of raw) {
21626
22455
  if (typeof entry !== "string" || !entry.trim()) {
21627
- throw expected(`${label2}: each attachment must be a hub-relative file path string.`);
22456
+ throw expected(`${label3}: each attachment must be a hub-relative file path string.`);
21628
22457
  }
21629
22458
  const abs = path14.resolve(hubFolder, entry);
21630
22459
  const root = path14.resolve(hubFolder);
21631
22460
  if (abs !== root && !abs.startsWith(root + path14.sep)) {
21632
- throw expected(`${label2}: attachment "${entry}" escapes the hub folder.`);
22461
+ throw expected(`${label3}: attachment "${entry}" escapes the hub folder.`);
21633
22462
  }
21634
22463
  let stat2;
21635
22464
  try {
@@ -21637,14 +22466,14 @@ function resolveTurnAttachments(hubFolder, turn, label2, bytesByHash) {
21637
22466
  } catch {
21638
22467
  }
21639
22468
  if (!stat2?.isFile()) {
21640
- throw expected(`${label2}: attachment "${entry}" not found.`);
22469
+ throw expected(`${label3}: attachment "${entry}" not found.`);
21641
22470
  }
21642
22471
  if (!realpathContained(root, abs)) {
21643
- throw expected(`${label2}: attachment "${entry}" resolves outside the hub folder (symlinks are not allowed).`);
22472
+ throw expected(`${label3}: attachment "${entry}" resolves outside the hub folder (symlinks are not allowed).`);
21644
22473
  }
21645
22474
  if (stat2.size > MAX_RESOURCE_FILE_SIZE2) {
21646
22475
  throw expected(
21647
- `${label2}: attachment "${entry}" is ${(stat2.size / 1024 / 1024).toFixed(1)}MB, over the 10MB limit.`
22476
+ `${label3}: attachment "${entry}" is ${(stat2.size / 1024 / 1024).toFixed(1)}MB, over the 10MB limit.`
21648
22477
  );
21649
22478
  }
21650
22479
  const data = fs11.readFileSync(abs);
@@ -21664,18 +22493,18 @@ function resolveTurnAttachments(hubFolder, turn, label2, bytesByHash) {
21664
22493
  }
21665
22494
  return refs;
21666
22495
  }
21667
- function applyTurnAttachments(hubFolder, turn, label2, bytesByHash) {
21668
- const refs = resolveTurnAttachments(hubFolder, turn, label2, bytesByHash);
22496
+ function applyTurnAttachments(hubFolder, turn, label3, bytesByHash) {
22497
+ const refs = resolveTurnAttachments(hubFolder, turn, label3, bytesByHash);
21669
22498
  if (refs) turn.attachments = refs;
21670
22499
  else delete turn.attachments;
21671
22500
  }
21672
- function assertAttachmentsAreLocalPaths(turn, label2) {
22501
+ function assertAttachmentsAreLocalPaths(turn, label3) {
21673
22502
  const attachments = turn?.attachments;
21674
22503
  if (!Array.isArray(attachments)) return;
21675
22504
  for (const entry of attachments) {
21676
22505
  if (entry !== null && typeof entry === "object" && "hash" in entry) {
21677
22506
  throw new Error(
21678
- `wire-shape attachment ref reached YAML serialization \u2014 CLI bug (${label2}): the payload was not run through materializeHubFolder before writing.`
22507
+ `wire-shape attachment ref reached YAML serialization \u2014 CLI bug (${label3}): the payload was not run through materializeHubFolder before writing.`
21679
22508
  );
21680
22509
  }
21681
22510
  }
@@ -21814,22 +22643,22 @@ function applyCallOpeningFiles(hubFolder, payload) {
21814
22643
  if (!openings || typeof openings !== "object") continue;
21815
22644
  for (const [language, opening] of Object.entries(openings)) {
21816
22645
  if (!opening || typeof opening !== "object" || typeof opening.file !== "string") continue;
21817
- const label2 = `Agent "${agent.name}" call_openings.${language}`;
22646
+ const label3 = `Agent "${agent.name}" call_openings.${language}`;
21818
22647
  const abs = path15.resolve(root, opening.file);
21819
22648
  if (!isUnder(root, abs)) {
21820
- throw expected(`${label2}: file "${opening.file}" escapes the hub folder.`);
22649
+ throw expected(`${label3}: file "${opening.file}" escapes the hub folder.`);
21821
22650
  }
21822
22651
  let stat2;
21823
22652
  try {
21824
22653
  stat2 = fs12.statSync(abs);
21825
22654
  } catch {
21826
22655
  }
21827
- if (!stat2?.isFile()) throw expected(`${label2}: file "${opening.file}" not found.`);
22656
+ if (!stat2?.isFile()) throw expected(`${label3}: file "${opening.file}" not found.`);
21828
22657
  if (!realpathContained(root, abs)) {
21829
- throw expected(`${label2}: file "${opening.file}" resolves outside the hub folder (symlinks are not allowed).`);
22658
+ throw expected(`${label3}: file "${opening.file}" resolves outside the hub folder (symlinks are not allowed).`);
21830
22659
  }
21831
22660
  if (stat2.size > CALL_OPENING_MAX_BYTES) {
21832
- throw expected(`${label2}: file "${opening.file}" is ${(stat2.size / 1024 / 1024).toFixed(1)} MB, over the ${CALL_OPENING_MAX_BYTES / 1024 / 1024} MB limit.`);
22661
+ throw expected(`${label3}: file "${opening.file}" is ${(stat2.size / 1024 / 1024).toFixed(1)} MB, over the ${CALL_OPENING_MAX_BYTES / 1024 / 1024} MB limit.`);
21833
22662
  }
21834
22663
  const bytes = fs12.readFileSync(abs);
21835
22664
  const hash = computeHash(bytes);
@@ -21985,16 +22814,16 @@ var init_pages2 = __esm({
21985
22814
  var init_evals = __esm({
21986
22815
  "../../packages/core/dist/contracts/evals.js"() {
21987
22816
  "use strict";
21988
- init_chunk_66EZQ7Y7();
22817
+ init_chunk_JKOMP2G3();
21989
22818
  init_chunk_SDOG6762();
21990
22819
  init_chunk_2YEGUQR7();
21991
22820
  init_chunk_4LXDRTO4();
21992
- init_chunk_WTOA3ANF();
22821
+ init_chunk_7DLTG7J5();
21993
22822
  init_chunk_KB5RK3RP();
21994
22823
  init_chunk_2ISUBJG7();
21995
22824
  init_chunk_HZ6CADSY();
21996
22825
  init_chunk_MIWZOSPI();
21997
- init_chunk_YROEDMVZ();
22826
+ init_chunk_NYNOISIG();
21998
22827
  }
21999
22828
  });
22000
22829
 
@@ -22166,8 +22995,8 @@ function scanEvalYamlFiles(hubFolder, bytesByHash, unreadable) {
22166
22995
  }
22167
22996
  return evals;
22168
22997
  }
22169
- function collectEval(evals, seen, filePath2, relPath, setName, hubFolder, bytesByHash, unreadable) {
22170
- const evalEntry = parseEvalYaml(filePath2, relPath, setName, hubFolder, bytesByHash);
22998
+ function collectEval(evals, seen, filePath3, relPath, setName, hubFolder, bytesByHash, unreadable) {
22999
+ const evalEntry = parseEvalYaml(filePath3, relPath, setName, hubFolder, bytesByHash);
22171
23000
  if (!evalEntry) {
22172
23001
  unreadable(relPath, NOT_A_YAML_OBJECT);
22173
23002
  return;
@@ -22176,14 +23005,14 @@ function collectEval(evals, seen, filePath2, relPath, setName, hubFolder, bytesB
22176
23005
  if (seen.has(key)) {
22177
23006
  const where = setName ? `scenario set "${setName}"` : "root";
22178
23007
  throw expected(
22179
- `Duplicate eval at ${where}: "${evalEntry.name}" (in ${path17.basename(filePath2)}). Each (name, scenario set) pair must be unique.`
23008
+ `Duplicate eval at ${where}: "${evalEntry.name}" (in ${path17.basename(filePath3)}). Each (name, scenario set) pair must be unique.`
22180
23009
  );
22181
23010
  }
22182
23011
  seen.add(key);
22183
23012
  evals.push(evalEntry);
22184
23013
  }
22185
- function parseEvalYaml(filePath2, relPath, setName, hubFolder, bytesByHash) {
22186
- const content = fs14.readFileSync(filePath2, "utf-8");
23014
+ function parseEvalYaml(filePath3, relPath, setName, hubFolder, bytesByHash) {
23015
+ const content = fs14.readFileSync(filePath3, "utf-8");
22187
23016
  let raw;
22188
23017
  try {
22189
23018
  raw = yaml8.load(content);
@@ -22195,7 +23024,7 @@ function parseEvalYaml(filePath2, relPath, setName, hubFolder, bytesByHash) {
22195
23024
  }
22196
23025
  if (!raw || typeof raw !== "object" || Array.isArray(raw)) return null;
22197
23026
  const data = raw;
22198
- const fileSlug = path17.basename(filePath2, ".yaml");
23027
+ const fileSlug = path17.basename(filePath3, ".yaml");
22199
23028
  const evalName = typeof data.name === "string" && data.name.trim().length > 0 ? data.name : fileSlug;
22200
23029
  if (typeof data.agent !== "string" || data.agent.trim().length === 0) {
22201
23030
  throw expected(`Eval "${evalName}" in ${relPath}: missing required field "agent" (string).`);
@@ -22240,55 +23069,55 @@ function parseEvalYaml(filePath2, relPath, setName, hubFolder, bytesByHash) {
22240
23069
  Object.assign(evalEntry, parsePersonFields(data, `Eval "${evalName}" in ${relPath}`));
22241
23070
  return evalEntry;
22242
23071
  }
22243
- function parseInitialStateField(raw, label2) {
23072
+ function parseInitialStateField(raw, label3) {
22244
23073
  if (raw === void 0 || raw === null) return void 0;
22245
23074
  if (!Array.isArray(raw)) {
22246
- throw expected(`${label2}: "initial_state" must be a list of { slug, value } entries.`);
23075
+ throw expected(`${label3}: "initial_state" must be a list of { slug, value } entries.`);
22247
23076
  }
22248
23077
  if (raw.length === 0) return void 0;
22249
23078
  const out = [];
22250
23079
  for (const entry of raw) {
22251
23080
  if (!entry || typeof entry !== "object" || Array.isArray(entry)) {
22252
- throw expected(`${label2}: each "initial_state" entry must be an object with "slug" and "value".`);
23081
+ throw expected(`${label3}: each "initial_state" entry must be an object with "slug" and "value".`);
22253
23082
  }
22254
23083
  const e = entry;
22255
23084
  if (typeof e.slug !== "string" || !e.slug.trim()) {
22256
- throw expected(`${label2}: an "initial_state" entry is missing a non-empty "slug".`);
23085
+ throw expected(`${label3}: an "initial_state" entry is missing a non-empty "slug".`);
22257
23086
  }
22258
23087
  if (e.scope !== void 0 && e.scope !== "user") {
22259
- throw expected(`${label2}: "initial_state" entry "${e.slug}" has unsupported scope "${String(e.scope)}" (only "user").`);
23088
+ throw expected(`${label3}: "initial_state" entry "${e.slug}" has unsupported scope "${String(e.scope)}" (only "user").`);
22260
23089
  }
22261
23090
  if (!e.value || typeof e.value !== "object" || Array.isArray(e.value)) {
22262
- throw expected(`${label2}: "initial_state" entry "${e.slug}" must have a "value" object.`);
23091
+ throw expected(`${label3}: "initial_state" entry "${e.slug}" must have a "value" object.`);
22263
23092
  }
22264
23093
  out.push({ slug: e.slug.trim(), scope: "user", value: e.value });
22265
23094
  }
22266
23095
  return out;
22267
23096
  }
22268
- function parseVariablesMap(raw, label2) {
23097
+ function parseVariablesMap(raw, label3) {
22269
23098
  if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
22270
23099
  const vars = raw;
22271
23100
  if (Object.keys(vars).length === 0) return void 0;
22272
23101
  if (!Object.values(vars).every((v) => Array.isArray(v))) {
22273
- throw expected(`${label2}: "variables" must be a map of arrays (variables.<name>: [ ... ]).`);
23102
+ throw expected(`${label3}: "variables" must be a map of arrays (variables.<name>: [ ... ]).`);
22274
23103
  }
22275
23104
  return vars;
22276
23105
  }
22277
- function parseFixtureField(raw, label2, key) {
23106
+ function parseFixtureField(raw, label3, key) {
22278
23107
  if (raw === void 0 || raw === null) return void 0;
22279
23108
  if (typeof raw !== "string") {
22280
- throw expected(`${label2}: "${key}" must be a string (the Rekor fixture name).`);
23109
+ throw expected(`${label3}: "${key}" must be a string (the Rekor fixture name).`);
22281
23110
  }
22282
23111
  const trimmed = raw.trim();
22283
23112
  return trimmed.length > 0 ? trimmed : void 0;
22284
23113
  }
22285
- function parsePersonFields(data, label2) {
23114
+ function parsePersonFields(data, label3) {
22286
23115
  if (data.customer_contact_id !== void 0) {
22287
- throw expected(`${label2}: ${EVAL_PERSON_ALIAS_RETIRED}.`);
23116
+ throw expected(`${label3}: ${EVAL_PERSON_ALIAS_RETIRED}.`);
22288
23117
  }
22289
23118
  if (data.person === void 0 || data.person === null) return {};
22290
23119
  if (!Array.isArray(data.person) || !data.person.every((id) => typeof id === "string")) {
22291
- throw expected(`${label2}: "person" must be a list of ids (person ids or contact ids).`);
23120
+ throw expected(`${label3}: "person" must be a list of ids (person ids or contact ids).`);
22292
23121
  }
22293
23122
  return { person: data.person };
22294
23123
  }
@@ -22321,8 +23150,8 @@ function scanJourneyYamlFiles(hubFolder, bytesByHash, unreadable) {
22321
23150
  }
22322
23151
  return journeys;
22323
23152
  }
22324
- function parseJourneyYaml(filePath2, relPath, hubFolder, bytesByHash) {
22325
- const content = fs14.readFileSync(filePath2, "utf-8");
23153
+ function parseJourneyYaml(filePath3, relPath, hubFolder, bytesByHash) {
23154
+ const content = fs14.readFileSync(filePath3, "utf-8");
22326
23155
  let raw;
22327
23156
  try {
22328
23157
  raw = yaml8.load(content);
@@ -22334,7 +23163,7 @@ function parseJourneyYaml(filePath2, relPath, hubFolder, bytesByHash) {
22334
23163
  }
22335
23164
  if (!raw || typeof raw !== "object" || Array.isArray(raw)) return null;
22336
23165
  const data = raw;
22337
- const fileSlug = path17.basename(filePath2, ".yaml");
23166
+ const fileSlug = path17.basename(filePath3, ".yaml");
22338
23167
  const journeyName = typeof data.name === "string" && data.name.trim().length > 0 ? data.name : fileSlug;
22339
23168
  if (typeof data.agent !== "string" || data.agent.trim().length === 0) {
22340
23169
  throw expected(`Journey "${journeyName}" in ${relPath}: missing required field "agent" (string).`);
@@ -22381,8 +23210,8 @@ function scanAgentYamlFiles(hubFolder, unreadable) {
22381
23210
  if (yamlFiles.length === 0) return [];
22382
23211
  const agents = [];
22383
23212
  for (const file of yamlFiles) {
22384
- const filePath2 = path17.join(agentsDir, file);
22385
- const content = readRealFileOrThrow(hubFolder, filePath2) ?? "";
23213
+ const filePath3 = path17.join(agentsDir, file);
23214
+ const content = readRealFileOrThrow(hubFolder, filePath3) ?? "";
22386
23215
  let agent;
22387
23216
  try {
22388
23217
  agent = yaml8.load(content);
@@ -22526,8 +23355,8 @@ function perHubAgentsMd(hubFolderName) {
22526
23355
  ""
22527
23356
  ].join("\n");
22528
23357
  }
22529
- function writeIfAbsent(root, filePath2, content) {
22530
- return createFileNoFollow(root, filePath2, Buffer.from(content, "utf-8")) === "created" ? path18.basename(filePath2) : null;
23358
+ function writeIfAbsent(root, filePath3, content) {
23359
+ return createFileNoFollow(root, filePath3, Buffer.from(content, "utf-8")) === "created" ? path18.basename(filePath3) : null;
22531
23360
  }
22532
23361
  var init_workspace_files = __esm({
22533
23362
  "src/lib/workspace-files.ts"() {
@@ -22662,12 +23491,12 @@ function writeHubFolder(hubFolder, payload, options = {}) {
22662
23491
  writePageFiles(hubFolder, payload.pages, log);
22663
23492
  return log;
22664
23493
  }
22665
- function setPreviewLabelInHubYaml(hubFolder, label2) {
23494
+ function setPreviewLabelInHubYaml(hubFolder, label3) {
22666
23495
  requireRealHubFolder(hubFolder, false);
22667
23496
  const yamlPath = resolveHubYamlPath(hubFolder);
22668
23497
  if (!yamlPath) return;
22669
23498
  const obj = yaml9.load(readRealFileOrThrow(hubFolder, yamlPath) ?? "") ?? {};
22670
- if (label2) obj.preview_label = label2;
23499
+ if (label3) obj.preview_label = label3;
22671
23500
  else delete obj.preview_label;
22672
23501
  writeFileNoFollow(hubFolder, yamlPath, Buffer.from(yaml9.dump(obj, YAML_DUMP_OPTIONS), "utf-8"));
22673
23502
  }
@@ -23013,20 +23842,20 @@ var init_hub_materializer = __esm({
23013
23842
  var init_ci = __esm({
23014
23843
  "../../packages/core/dist/contracts/ci.js"() {
23015
23844
  "use strict";
23016
- init_chunk_Z6H7PHIF();
23017
- init_chunk_YI3ORIXJ();
23018
- init_chunk_T6D3YZ6B();
23019
- init_chunk_66EZQ7Y7();
23845
+ init_chunk_BAVTYKY7();
23846
+ init_chunk_CZS5NGTA();
23847
+ init_chunk_P74ESVOL();
23848
+ init_chunk_JKOMP2G3();
23020
23849
  init_chunk_SDOG6762();
23021
23850
  init_chunk_2YEGUQR7();
23022
23851
  init_chunk_LBDH7LCG();
23023
23852
  init_chunk_4LXDRTO4();
23024
- init_chunk_7NQZRSSJ();
23853
+ init_chunk_CMCATTHI();
23025
23854
  init_chunk_D3EP4TDU();
23026
23855
  init_chunk_X5PZZVTS();
23027
- init_chunk_K5UAZWFF();
23028
- init_chunk_L4YFOZGK();
23029
- init_chunk_WTOA3ANF();
23856
+ init_chunk_BCN7SKBT();
23857
+ init_chunk_LYB5XDDT();
23858
+ init_chunk_7DLTG7J5();
23030
23859
  init_chunk_IBL7FANV();
23031
23860
  init_chunk_S4VDZ7PZ();
23032
23861
  init_chunk_KB5RK3RP();
@@ -23037,12 +23866,12 @@ var init_ci = __esm({
23037
23866
  init_chunk_WEXVYJ5H();
23038
23867
  init_chunk_6TSQ5HXC();
23039
23868
  init_chunk_HZ6CADSY();
23040
- init_chunk_7IXDF53E();
23041
- init_chunk_55RZ7YIF();
23042
- init_chunk_JHUTFQDO();
23869
+ init_chunk_JOOVAYGO();
23870
+ init_chunk_IEEMZR55();
23871
+ init_chunk_4IXIQQ2A();
23043
23872
  init_chunk_7IKO675N();
23044
23873
  init_chunk_MIWZOSPI();
23045
- init_chunk_YROEDMVZ();
23874
+ init_chunk_NYNOISIG();
23046
23875
  init_chunk_L5F7ZOUJ();
23047
23876
  init_chunk_ICYO56QW();
23048
23877
  init_chunk_WFQDSQJK();
@@ -23462,15 +24291,15 @@ function resolveBaseTarget(gitRoot, selector, cwd = process.cwd()) {
23462
24291
  if (editable.length === 1) {
23463
24292
  return { folder: editable[0].folder, exists: true, meta: editable[0].meta };
23464
24293
  }
23465
- const label2 = basesDirLabel(gitRoot);
24294
+ const label3 = basesDirLabel(gitRoot);
23466
24295
  if (editable.length === 0) {
23467
24296
  throw expected(
23468
- `No base folders found in ${label2}/. Pass a base id to fetch one for the first time (e.g. \`wayai pull bases/<base>\`).`
24297
+ `No base folders found in ${label3}/. Pass a base id to fetch one for the first time (e.g. \`wayai pull bases/<base>\`).`
23469
24298
  );
23470
24299
  }
23471
24300
  throw expected(
23472
24301
  [
23473
- `Multiple bases found in ${label2}/. Pass --base <id|folder-name> to choose, or run from inside a base folder:`,
24302
+ `Multiple bases found in ${label3}/. Pass --base <id|folder-name> to choose, or run from inside a base folder:`,
23474
24303
  ...editable.map((b) => ` ${path21.basename(b.folder)} (${b.meta.base_id ?? "not created yet"})`)
23475
24304
  ].join("\n")
23476
24305
  );
@@ -23555,10 +24384,10 @@ function parseRoutingTokens(args2) {
23555
24384
  return tokens2;
23556
24385
  }
23557
24386
  function repeatedFlagWithNoTargetRefusal(verb, tokens2) {
23558
- const repeated = SUBTREE_FLAGS.find(
24387
+ const repeated2 = SUBTREE_FLAGS.find(
23559
24388
  ({ flag, token }) => tokens2.trailingFlag === flag && tokens2[token] !== void 0 || tokens2.extraFlags?.some((extra) => extra.flag === flag && (extra.value === "" || extra.value.startsWith("-"))) === true
23560
24389
  );
23561
- return repeated ? `\`wayai ${verb} ${repeated.flag}\` was typed again with no target after it, so it is refused rather than run on the first one alone: name one target per run.` : null;
24390
+ return repeated2 ? `\`wayai ${verb} ${repeated2.flag}\` was typed again with no target after it, so it is refused rather than run on the first one alone: name one target per run.` : null;
23562
24391
  }
23563
24392
  function extraTargetRefusal(verb, tokens2) {
23564
24393
  const flag = SUBTREE_FLAGS.find(({ token }) => tokens2[token] !== void 0);
@@ -23691,8 +24520,8 @@ function routeToSubtree(options) {
23691
24520
  refusal: `\`wayai ${verb} ${by}\` took \`${flag2}\` as its value, so \`${flag2}\` is not read. Give ${by} a value, or leave it out.`
23692
24521
  };
23693
24522
  }
23694
- const repeated = repeatedFlagWithNoTargetRefusal(verb, tokens2);
23695
- if (repeated) return { ok: false, refusal: repeated };
24523
+ const repeated2 = repeatedFlagWithNoTargetRefusal(verb, tokens2);
24524
+ if (repeated2) return { ok: false, refusal: repeated2 };
23696
24525
  const empty = SUBTREE_FLAGS.find(({ flag: flag2, token }) => tokens2[token] === "" || tokens2.trailingFlag === flag2);
23697
24526
  if (empty) {
23698
24527
  return {
@@ -23900,8 +24729,8 @@ function dataErrorEnvelope(err) {
23900
24729
  }
23901
24730
  }
23902
24731
  function dataErrorCode(err) {
23903
- const code = dataErrorEnvelope(err)?.code;
23904
- return typeof code === "string" && code ? code : null;
24732
+ const code2 = dataErrorEnvelope(err)?.code;
24733
+ return typeof code2 === "string" && code2 ? code2 : null;
23905
24734
  }
23906
24735
  function dataErrorDetails(err) {
23907
24736
  const details = dataErrorEnvelope(err)?.details;
@@ -23923,26 +24752,26 @@ var init_client = __esm({
23923
24752
 
23924
24753
  // src/data/helpers.ts
23925
24754
  import { readFileSync as readFileSync14 } from "fs";
23926
- function pathSegment(id, label2 = "id") {
24755
+ function pathSegment(id, label3 = "id") {
23927
24756
  if (!isPathSafeId(id)) {
23928
- throw expected(`Invalid ${label2}: ${JSON.stringify(id)}. An id may use ${PATH_SAFE_ID_RULE}.`);
24757
+ throw expected(`Invalid ${label3}: ${JSON.stringify(id)}. An id may use ${PATH_SAFE_ID_RULE}.`);
23929
24758
  }
23930
24759
  return encodeURIComponent(id);
23931
24760
  }
23932
- function basePathSegment(id, label2 = "base id") {
24761
+ function basePathSegment(id, label3 = "base id") {
23933
24762
  if (!isValidBaseId(id)) {
23934
- throw expected(`Invalid ${label2}: ${JSON.stringify(id)}. Base ids are slugs \u2014 ${BASE_ID_RULE}.`);
24763
+ throw expected(`Invalid ${label3}: ${JSON.stringify(id)}. Base ids are slugs \u2014 ${BASE_ID_RULE}.`);
23935
24764
  }
23936
24765
  return encodeURIComponent(id);
23937
24766
  }
23938
- function foreignSegment(value, label2 = "id") {
24767
+ function foreignSegment(value, label3 = "id") {
23939
24768
  if (value === "." || value === "..") {
23940
- throw expected(`Invalid ${label2}: ${JSON.stringify(value)} is a path traversal segment.`);
24769
+ throw expected(`Invalid ${label3}: ${JSON.stringify(value)} is a path traversal segment.`);
23941
24770
  }
23942
24771
  return encodeURIComponent(value);
23943
24772
  }
23944
- function pathSegments(value, label2 = "path") {
23945
- return value.split("/").map((segment) => foreignSegment(segment, label2)).join("/");
24773
+ function pathSegments(value, label3 = "path") {
24774
+ return value.split("/").map((segment) => foreignSegment(segment, label3)).join("/");
23946
24775
  }
23947
24776
  function parseData(data, flag) {
23948
24777
  const prefix = flag ? `${flag}: ` : "";
@@ -24011,9 +24840,9 @@ function parseByteCount(flag, value) {
24011
24840
  }
24012
24841
  return n;
24013
24842
  }
24014
- async function readSecret(source, label2) {
24015
- const value = resolveSecretSource(source) === "stdin" ? (await readStdin()).trim() : (await promptSecret(`${label2}: `)).trim();
24016
- if (!value) throw expected(`${label2} is required.`);
24843
+ async function readSecret(source, label3) {
24844
+ const value = resolveSecretSource(source) === "stdin" ? (await readStdin()).trim() : (await promptSecret(`${label3}: `)).trim();
24845
+ if (!value) throw expected(`${label3} is required.`);
24017
24846
  return value;
24018
24847
  }
24019
24848
  function isInteractive() {
@@ -24767,7 +25596,7 @@ async function stopEvalSessionWithRetries(stop, opts = {}) {
24767
25596
  throw lastError;
24768
25597
  }
24769
25598
  function installEvalSignalHandlers(input) {
24770
- const exit = input.exit ?? ((code) => process.exit(code));
25599
+ const exit = input.exit ?? ((code2) => process.exit(code2));
24771
25600
  const manualStopCommand = formatEvalSessionStopCommand(input.sessionId, input.hubId);
24772
25601
  let signalCount = 0;
24773
25602
  let disposed = false;
@@ -24890,7 +25719,7 @@ var init_api2 = __esm({
24890
25719
  init_errors3();
24891
25720
  init_expected();
24892
25721
  init_token_store();
24893
- communityNotFound = (label2) => `Community ${label2} not found, or you are not an owner or admin of its organization.`;
25722
+ communityNotFound = (label3) => `Community ${label3} not found, or you are not an owner or admin of its organization.`;
24894
25723
  orgNotFound = (orgId) => `Organization ${orgId} not found, or you are not an owner or admin of it.`;
24895
25724
  }
24896
25725
  });
@@ -26397,9 +27226,9 @@ function coursesChangedSince(before, after) {
26397
27226
  out.set("courses", { label: "courses order", rev: server.ids.join() });
26398
27227
  for (const course of server.courses) {
26399
27228
  const courseId = course.course.course_id;
26400
- const label2 = `course ${show(course.course.title)}`;
26401
- out.set(courseId, { label: label2, rev: serverCourse(course.course).rev });
26402
- out.set(`modules:${courseId}`, { label: label2, rev: course.modules.map((m) => m.module_id).join() });
27229
+ const label3 = `course ${show(course.course.title)}`;
27230
+ out.set(courseId, { label: label3, rev: serverCourse(course.course).rev });
27231
+ out.set(`modules:${courseId}`, { label: label3, rev: course.modules.map((m) => m.module_id).join() });
26403
27232
  for (const module of course.modules) {
26404
27233
  const moduleLabel = `module ${show(module.title)}`;
26405
27234
  out.set(module.module_id, { label: moduleLabel, rev: serverModule(module).rev });
@@ -27355,8 +28184,8 @@ async function pushCommunity(gitRootOrNull, selector, args2) {
27355
28184
  throw expected("Push changes the live community and asks first: pass -y when not running in a terminal, or --dry-run to only list the changes.");
27356
28185
  }
27357
28186
  const { organization_id: orgId } = requireRepoConfig(gitRoot);
27358
- const label2 = path29.basename(folder);
27359
- assertInScope("communities", files.community_id, label2);
28187
+ const label3 = path29.basename(folder);
28188
+ assertInScope("communities", files.community_id, label3);
27360
28189
  warnUnlisted(files);
27361
28190
  const remote = await openRemote(files.community_id);
27362
28191
  const server = await remote.read(orgId);
@@ -27744,16 +28573,16 @@ import * as path30 from "path";
27744
28573
  import * as yaml15 from "js-yaml";
27745
28574
  function parseArgs7(args2) {
27746
28575
  let autoConfirm = false;
27747
- let label2;
28576
+ let label3;
27748
28577
  for (let i = 0; i < args2.length; i++) {
27749
28578
  const arg = args2[i];
27750
28579
  if (arg === "--yes" || arg === "-y") {
27751
28580
  autoConfirm = true;
27752
28581
  } else if (arg === "--label" && args2[i + 1]) {
27753
- label2 = args2[++i];
28582
+ label3 = args2[++i];
27754
28583
  }
27755
28584
  }
27756
- return { autoConfirm, label: label2 };
28585
+ return { autoConfirm, label: label3 };
27757
28586
  }
27758
28587
  function shouldWarnIgnoredPreviewLabel(localLabel, serverLabel) {
27759
28588
  return Boolean(localLabel) && serverLabel !== void 0 && localLabel !== serverLabel;
@@ -28228,7 +29057,7 @@ async function pushCommand(args2) {
28228
29057
  await pushCommunity2(gitRoot, route.selector, args2);
28229
29058
  return;
28230
29059
  }
28231
- const { autoConfirm, label: label2 } = parseArgs7(args2);
29060
+ const { autoConfirm, label: label3 } = parseArgs7(args2);
28232
29061
  const hubSelector = route.selector;
28233
29062
  const repoConfig = requireRepoConfig();
28234
29063
  const { organization_id: organizationId } = repoConfig;
@@ -28255,7 +29084,7 @@ async function pushCommand(args2) {
28255
29084
  console.log("This is a read-only production mirror \u2014 production hubs cannot be pushed. Edit the linked preview hub instead.");
28256
29085
  return;
28257
29086
  }
28258
- if (label2) {
29087
+ if (label3) {
28259
29088
  console.warn("Note: --label is only used when creating a new hub. To change an existing hub's label, use `wayai relabel`.");
28260
29089
  }
28261
29090
  console.log(`Target hub: ${path30.basename(existing.hubFolder)} (${existing.hubId})`);
@@ -28264,7 +29093,7 @@ async function pushCommand(args2) {
28264
29093
  return;
28265
29094
  }
28266
29095
  assertScopeAllowsCreation("hubs", resolution.target.hub.hubName);
28267
- await createAndPushNewHub(client, resolution.target.hub, { autoConfirm, label: label2, organizationId });
29096
+ await createAndPushNewHub(client, resolution.target.hub, { autoConfirm, label: label3, organizationId });
28268
29097
  }
28269
29098
  var LOCAL_CHANGE_LIST_CAP, nativeEntryName, entryId, SKIPPABLE_ENTRY_IDENTITY;
28270
29099
  var init_push = __esm({
@@ -28568,18 +29397,18 @@ import * as fs23 from "fs";
28568
29397
  function parseArgs9(args2) {
28569
29398
  let autoConfirm = false;
28570
29399
  let folderSelector;
28571
- let label2;
29400
+ let label3;
28572
29401
  for (let i = 0; i < args2.length; i++) {
28573
29402
  const arg = args2[i];
28574
29403
  if (arg === "--yes" || arg === "-y") {
28575
29404
  autoConfirm = true;
28576
29405
  } else if (arg === "--label") {
28577
- label2 = args2[++i];
29406
+ label3 = args2[++i];
28578
29407
  } else if (!arg.startsWith("-") && folderSelector === void 0) {
28579
29408
  folderSelector = arg;
28580
29409
  }
28581
29410
  }
28582
- return { autoConfirm, folderSelector, label: label2 };
29411
+ return { autoConfirm, folderSelector, label: label3 };
28583
29412
  }
28584
29413
  function reportNoNewHub(enclosing, existingHubs, wsLabel) {
28585
29414
  const created = enclosing ? [] : filterPreviewHubs(existingHubs);
@@ -28595,7 +29424,7 @@ function reportNoNewHub(enclosing, existingHubs, wsLabel) {
28595
29424
  process.exit(1);
28596
29425
  }
28597
29426
  async function createCommand(args2) {
28598
- const { autoConfirm, folderSelector, label: label2 } = parseArgs9(args2);
29427
+ const { autoConfirm, folderSelector, label: label3 } = parseArgs9(args2);
28599
29428
  const repoConfig = requireRepoConfig();
28600
29429
  const { organization_id: organizationId } = repoConfig;
28601
29430
  const { config, accessToken } = await requireAuth();
@@ -28629,7 +29458,7 @@ async function createCommand(args2) {
28629
29458
  process.exit(1);
28630
29459
  }
28631
29460
  assertScopeAllowsCreation("hubs", resolution.hub.hubName);
28632
- await createAndPushNewHub(client, resolution.hub, { autoConfirm, label: label2, organizationId });
29461
+ await createAndPushNewHub(client, resolution.hub, { autoConfirm, label: label3, organizationId });
28633
29462
  }
28634
29463
  var init_create = __esm({
28635
29464
  "src/commands/create.ts"() {
@@ -28680,7 +29509,7 @@ async function diffCommand(args2) {
28680
29509
  console.log("Parsing local configuration...");
28681
29510
  const localConfig = parseHubFolder(hubFolder);
28682
29511
  let targetHubId = previewHubId;
28683
- let label2 = "preview";
29512
+ let label3 = "preview";
28684
29513
  if (production) {
28685
29514
  if (localConfig.hub_environment === "production") {
28686
29515
  console.log("This is a read-only production mirror \u2014 run `wayai diff --production` from the preview workspace instead.");
@@ -28694,9 +29523,9 @@ async function diffCommand(args2) {
28694
29523
  return;
28695
29524
  }
28696
29525
  targetHubId = productionHubId;
28697
- label2 = "production";
29526
+ label3 = "production";
28698
29527
  }
28699
- console.log(`Computing diff against ${label2}...`);
29528
+ console.log(`Computing diff against ${label3}...`);
28700
29529
  let diffPayload = localConfig;
28701
29530
  try {
28702
29531
  diffPayload = prepareResourcePayload(localConfig, await client.pull(targetHubId, organizationId));
@@ -28707,11 +29536,11 @@ async function diffCommand(args2) {
28707
29536
  printWarnings([...result.warnings, ...pageDesignWarnings(localConfig.pages)]);
28708
29537
  if (!result.has_changes) {
28709
29538
  console.log(`
28710
- No differences \u2014 local files match ${label2}.`);
29539
+ No differences \u2014 local files match ${label3}.`);
28711
29540
  return;
28712
29541
  }
28713
29542
  console.log(`
28714
- Local files vs ${label2.toUpperCase()}:`);
29543
+ Local files vs ${label3.toUpperCase()}:`);
28715
29544
  printDiff(result.summary);
28716
29545
  }
28717
29546
  var init_diff = __esm({
@@ -29192,13 +30021,13 @@ __export(replicate_exports, {
29192
30021
  import * as fs25 from "fs";
29193
30022
  import * as path34 from "path";
29194
30023
  function parseArgs12(args2) {
29195
- let label2;
30024
+ let label3;
29196
30025
  let hubFlag;
29197
30026
  let positional;
29198
30027
  for (let i = 0; i < args2.length; i++) {
29199
30028
  const arg = args2[i];
29200
30029
  if (arg === "--label") {
29201
- label2 = args2[++i];
30030
+ label3 = args2[++i];
29202
30031
  } else if (arg === "--hub" && args2[i + 1]) {
29203
30032
  hubFlag = args2[++i];
29204
30033
  } else if (!arg.startsWith("-") && positional === void 0) {
@@ -29210,11 +30039,11 @@ function parseArgs12(args2) {
29210
30039
  `\`wayai replicate\` clones one hub, and was given 2: \`--hub ${shownArgument(hubFlag)}\` and \`${shownArgument(positional)}\`. It is refused rather than clone one of them alone: name the source hub once.`
29211
30040
  );
29212
30041
  }
29213
- return { label: label2, hubSelector: hubFlag ?? positional };
30042
+ return { label: label3, hubSelector: hubFlag ?? positional };
29214
30043
  }
29215
30044
  async function replicateCommand(args2) {
29216
- const { label: label2, hubSelector } = parseArgs12(args2);
29217
- const normalizedLabel = label2?.trim() || void 0;
30045
+ const { label: label3, hubSelector } = parseArgs12(args2);
30046
+ const normalizedLabel = label3?.trim() || void 0;
29218
30047
  if (normalizedLabel && normalizedLabel.length > PREVIEW_LABEL_MAX_LENGTH) {
29219
30048
  console.error(`--label must be ${PREVIEW_LABEL_MAX_LENGTH} characters or fewer.`);
29220
30049
  process.exit(1);
@@ -29294,7 +30123,7 @@ __export(relabel_exports, {
29294
30123
  });
29295
30124
  import * as path35 from "path";
29296
30125
  function parseArgs13(args2) {
29297
- let label2;
30126
+ let label3;
29298
30127
  let clear = false;
29299
30128
  let hubSelector;
29300
30129
  for (let i = 0; i < args2.length; i++) {
@@ -29303,24 +30132,24 @@ function parseArgs13(args2) {
29303
30132
  clear = true;
29304
30133
  } else if (arg === "--hub" && args2[i + 1]) {
29305
30134
  hubSelector = args2[++i];
29306
- } else if (!arg.startsWith("-") && label2 === void 0) {
29307
- label2 = arg;
30135
+ } else if (!arg.startsWith("-") && label3 === void 0) {
30136
+ label3 = arg;
29308
30137
  }
29309
30138
  }
29310
- if (clear && label2 !== void 0) {
30139
+ if (clear && label3 !== void 0) {
29311
30140
  throw expected(
29312
- `\`wayai relabel\` was given both a label (\`${shownArgument(label2)}\`) and \`--clear\`, which removes the label. It is refused rather than run on one of them alone: give the label or \`--clear\`, not both.`
30141
+ `\`wayai relabel\` was given both a label (\`${shownArgument(label3)}\`) and \`--clear\`, which removes the label. It is refused rather than run on one of them alone: give the label or \`--clear\`, not both.`
29313
30142
  );
29314
30143
  }
29315
- return { label: label2, clear, hubSelector };
30144
+ return { label: label3, clear, hubSelector };
29316
30145
  }
29317
30146
  async function relabelCommand(args2) {
29318
- const { label: label2, clear, hubSelector } = parseArgs13(args2);
29319
- if (!clear && (label2 === void 0 || label2.trim() === "")) {
30147
+ const { label: label3, clear, hubSelector } = parseArgs13(args2);
30148
+ if (!clear && (label3 === void 0 || label3.trim() === "")) {
29320
30149
  console.error("Usage: wayai relabel <label> [--hub <uuid|folder>] (or --clear to remove the label)");
29321
30150
  process.exit(1);
29322
30151
  }
29323
- const normalizedLabel = clear ? null : label2.trim();
30152
+ const normalizedLabel = clear ? null : label3.trim();
29324
30153
  if (normalizedLabel && normalizedLabel.length > PREVIEW_LABEL_MAX_LENGTH) {
29325
30154
  console.error(`preview_label must be ${PREVIEW_LABEL_MAX_LENGTH} characters or fewer.`);
29326
30155
  process.exit(1);
@@ -29574,8 +30403,8 @@ function resolveScopeSelector(verb, args2) {
29574
30403
  assertFlagWasGivenAValue(verb, "--hub", args2, hubFlag);
29575
30404
  assertFlagWasGivenAValue(verb, "--base", args2, baseFlag);
29576
30405
  assertFlagWasGivenAValue(verb, "--community", args2, communityFlag);
29577
- const repeated = repeatedFlagWithNoTargetRefusal(verb, tokens2);
29578
- if (repeated) throw expected(repeated);
30406
+ const repeated2 = repeatedFlagWithNoTargetRefusal(verb, tokens2);
30407
+ if (repeated2) throw expected(repeated2);
29579
30408
  const extra = extraTargetRefusal(verb, tokens2);
29580
30409
  if (extra) {
29581
30410
  throw expected(verb === "use" ? `${extra} To scope several, add each with \`wayai use --add <selector>\`.` : extra);
@@ -29915,26 +30744,26 @@ __export(send_message_exports, {
29915
30744
  });
29916
30745
  import * as fs27 from "fs";
29917
30746
  import * as path39 from "path";
29918
- function statAttachment(filePath2) {
30747
+ function statAttachment(filePath3) {
29919
30748
  let stat2;
29920
30749
  try {
29921
- stat2 = fs27.statSync(filePath2);
30750
+ stat2 = fs27.statSync(filePath3);
29922
30751
  } catch {
29923
- console.error(`Error: file not found: ${filePath2}`);
30752
+ console.error(`Error: file not found: ${filePath3}`);
29924
30753
  process.exit(1);
29925
30754
  }
29926
30755
  if (stat2.isDirectory()) {
29927
- console.error(`Error: not a file: ${filePath2}`);
30756
+ console.error(`Error: not a file: ${filePath3}`);
29928
30757
  process.exit(1);
29929
30758
  }
29930
- return { filePath: filePath2, size: stat2.size };
30759
+ return { filePath: filePath3, size: stat2.size };
29931
30760
  }
29932
- function readAttachment(filePath2, size) {
29933
- const fileName = path39.basename(filePath2);
30761
+ function readAttachment(filePath3, size) {
30762
+ const fileName = path39.basename(filePath3);
29934
30763
  const ext = path39.extname(fileName).replace(/^\./, "");
29935
30764
  return {
29936
30765
  file_name: fileName,
29937
- file_binary: fs27.readFileSync(filePath2).toString("base64"),
30766
+ file_binary: fs27.readFileSync(filePath3).toString("base64"),
29938
30767
  file_size: size,
29939
30768
  ...ext && { file_extension: ext }
29940
30769
  };
@@ -29964,12 +30793,12 @@ async function sendMessageCommand(args2) {
29964
30793
  if (arg === "-c" || arg === "--conversation") {
29965
30794
  conversationId = args2[++i];
29966
30795
  } else if (arg === "-f" || arg === "--file") {
29967
- const filePath2 = args2[++i];
29968
- if (!filePath2) {
30796
+ const filePath3 = args2[++i];
30797
+ if (!filePath3) {
29969
30798
  console.error("Error: --file requires a path");
29970
30799
  process.exit(1);
29971
30800
  }
29972
- filePaths.push(filePath2);
30801
+ filePaths.push(filePath3);
29973
30802
  } else if (!arg.startsWith("-")) {
29974
30803
  message = arg;
29975
30804
  }
@@ -30594,8 +31423,8 @@ async function conversationsCommand(args2) {
30594
31423
  console.log(JSON.stringify(meta.arguments, null, 2));
30595
31424
  }
30596
31425
  } else if (isToolResult) {
30597
- const label2 = meta.is_error === true ? "tool_error" : "tool_result";
30598
- console.log(`[${label2}: ${toolName}] (${time})`);
31426
+ const label3 = meta.is_error === true ? "tool_error" : "tool_result";
31427
+ console.log(`[${label3}: ${toolName}] (${time})`);
30599
31428
  if (meta.result !== void 0) {
30600
31429
  console.log(typeof meta.result === "string" ? meta.result : JSON.stringify(meta.result, null, 2));
30601
31430
  } else if (msg.message_text) {
@@ -30912,11 +31741,11 @@ function summarizeActiveAlertsForReport(alerts) {
30912
31741
  const active = activeAlerts(alerts);
30913
31742
  if (active.length === 0) return null;
30914
31743
  const lines = active.map((a) => {
30915
- const { label: label2 } = describeCategory(a.category);
31744
+ const { label: label3 } = describeCategory(a.category);
30916
31745
  const target = formatAlertTarget(a);
30917
31746
  const providerBits = formatProviderBits(a);
30918
31747
  const detailBit = a.detail ? ` \xB7 ${a.detail}` : "";
30919
- return `- [${a.severity}] ${a.category} (${label2}) \xB7 ${target}${providerBits ? ` \xB7 ${providerBits}` : ""}${detailBit} \xB7 seen ${a.count}\xD7`;
31748
+ return `- [${a.severity}] ${a.category} (${label3}) \xB7 ${target}${providerBits ? ` \xB7 ${providerBits}` : ""}${detailBit} \xB7 seen ${a.count}\xD7`;
30920
31749
  });
30921
31750
  return `Active hub alerts at report time (${active.length}):
30922
31751
  ${lines.join("\n")}`;
@@ -31002,10 +31831,10 @@ async function alertsCommand(args2) {
31002
31831
  console.log(`Hub ${hubId} \u2014 ${active.length} active ${noun}
31003
31832
  `);
31004
31833
  for (const a of active) {
31005
- const { label: label2, hint } = describeCategory(a.category);
31834
+ const { label: label3, hint } = describeCategory(a.category);
31006
31835
  const target = formatAlertTarget(a, (id) => connLabels.get(id));
31007
31836
  const providerBits = formatProviderBits(a);
31008
- console.log(`${severityGlyph(a.severity)} ${a.severity} ${a.category} \u2014 ${label2}`);
31837
+ console.log(`${severityGlyph(a.severity)} ${a.severity} ${a.category} \u2014 ${label3}`);
31009
31838
  console.log(` ${target}${providerBits ? ` \xB7 ${providerBits}` : ""}${a.detail ? ` \xB7 ${a.detail}` : ""}`);
31010
31839
  console.log(` ${hint}`);
31011
31840
  if (a.org_credential_id) {
@@ -31379,8 +32208,8 @@ var init_evals2 = __esm({
31379
32208
 
31380
32209
  // src/lib/eval-fixture-queue.ts
31381
32210
  function isQueueableLaunchError(err) {
31382
- const code = extractApiErrorCode(err);
31383
- return code !== null && QUEUEABLE_LAUNCH_ERRORS.has(code);
32211
+ const code2 = extractApiErrorCode(err);
32212
+ return code2 !== null && QUEUEABLE_LAUNCH_ERRORS.has(code2);
31384
32213
  }
31385
32214
  async function runWithFixtureQueue(opts) {
31386
32215
  let delay2 = FIXTURE_QUEUE_INITIAL_DELAY_MS;
@@ -32725,8 +33554,8 @@ function readbackCandidate(text4, kind) {
32725
33554
  return digitRuns(text4).find((r) => r.length >= 9 && r.length <= 13) ?? null;
32726
33555
  }
32727
33556
  if (kind === "digits") {
32728
- const code = extractFacts(text4).find((f) => (f.kind === "digits" || f.kind === "cpf") && f.key.length >= 5);
32729
- if (code) return code.key;
33557
+ const code2 = extractFacts(text4).find((f) => (f.kind === "digits" || f.kind === "cpf") && f.key.length >= 5);
33558
+ if (code2) return code2.key;
32730
33559
  return digitRuns(text4).find((r) => r.length >= 5) ?? null;
32731
33560
  }
32732
33561
  return extractFacts(text4).find((f) => f.kind === kind)?.key ?? null;
@@ -33678,7 +34507,7 @@ function chooseAudioSource(options, plan, env = process.env) {
33678
34507
  }
33679
34508
  return new OpenAiTtsSource({ apiKey, voice: options.ttsVoice, model: options.ttsModel });
33680
34509
  }
33681
- function installInterruptHandlers(exit = (code) => process.exit(code)) {
34510
+ function installInterruptHandlers(exit = (code2) => process.exit(code2)) {
33682
34511
  let first = null;
33683
34512
  const listeners = /* @__PURE__ */ new Map();
33684
34513
  const dispose = () => {
@@ -34487,8 +35316,8 @@ Available metrics:
34487
35316
  console.log(JSON.stringify(result, null, 2));
34488
35317
  return;
34489
35318
  }
34490
- const label2 = from && to ? `${from} to ${to}` : `last ${period || "7d"}`;
34491
- console.log(`Hub Analytics (${label2})
35319
+ const label3 = from && to ? `${from} to ${to}` : `last ${period || "7d"}`;
35320
+ console.log(`Hub Analytics (${label3})
34492
35321
  `);
34493
35322
  if (result.summary) {
34494
35323
  const s = result.summary;
@@ -35724,8 +36553,8 @@ ${org.name} (${org.id})`);
35724
36553
  continue;
35725
36554
  }
35726
36555
  for (const hub of hubs) {
35727
- const label2 = hub.preview_label ? ` (${hub.preview_label})` : "";
35728
- console.log(` ${hub.hub_name}${label2} ${hub.hub_id}`);
36556
+ const label3 = hub.preview_label ? ` (${hub.preview_label})` : "";
36557
+ console.log(` ${hub.hub_name}${label3} ${hub.hub_id}`);
35729
36558
  }
35730
36559
  }
35731
36560
  }
@@ -35815,9 +36644,9 @@ function summarizeBatchResult(r) {
35815
36644
  if (entity && typeof entity === "object") {
35816
36645
  const e = entity;
35817
36646
  const id = typeof e.id === "string" ? e.id : void 0;
35818
- const label2 = typeof e.record_type === "string" ? e.record_type : typeof e.rel_type === "string" ? e.rel_type : typeof e.name === "string" ? e.name : void 0;
36647
+ const label3 = typeof e.record_type === "string" ? e.record_type : typeof e.rel_type === "string" ? e.rel_type : typeof e.name === "string" ? e.name : void 0;
35819
36648
  const version = e.version != null ? ` v${String(e.version)}` : "";
35820
- if (id && label2) return `${label2}/${id}${version}`;
36649
+ if (id && label3) return `${label3}/${id}${version}`;
35821
36650
  if (id) return `${id}${version}`;
35822
36651
  }
35823
36652
  return JSON.stringify(r);
@@ -35967,16 +36796,16 @@ async function runList(orgId, json) {
35967
36796
  }
35968
36797
  async function runJoinLink(action, target, { json, yes }) {
35969
36798
  const api = await communitiesClient();
35970
- const { id, label: label2 } = await resolveCommunity(api, target);
35971
- const notFound = communityNotFound(label2);
36799
+ const { id, label: label3 } = await resolveCommunity(api, target);
36800
+ const notFound = communityNotFound(label3);
35972
36801
  if (action === "get") {
35973
36802
  const { data: data2 } = await callCommunities(api.getCommunityJoinLink(id), notFound);
35974
- printLink(data2, label2, json);
36803
+ printLink(data2, label3, json);
35975
36804
  return;
35976
36805
  }
35977
36806
  await warnThenAsk(
35978
36807
  [
35979
- action === "rotate" ? `This replaces the join link of ${label2} with a new one and turns it on.` : `This turns off the join link of ${label2}.`,
36808
+ action === "rotate" ? `This replaces the join link of ${label3} with a new one and turns it on.` : `This turns off the join link of ${label3}.`,
35980
36809
  "Every link shared before stops working."
35981
36810
  ],
35982
36811
  yes,
@@ -35986,39 +36815,39 @@ async function runJoinLink(action, target, { json, yes }) {
35986
36815
  action === "rotate" ? api.replaceCommunityJoinLink(id) : api.disableCommunityJoinLink(id),
35987
36816
  notFound
35988
36817
  );
35989
- printLink(data, label2, json);
36818
+ printLink(data, label3, json);
35990
36819
  }
35991
36820
  async function warnThenAsk(warning, yes, aborted) {
35992
36821
  for (const line of warning) console.error(line);
35993
36822
  if (!yes && !await confirm("Proceed?")) throw expected(aborted);
35994
36823
  }
35995
- function printLink(link, label2, json) {
36824
+ function printLink(link, label3, json) {
35996
36825
  if (json) {
35997
36826
  console.log(JSON.stringify(link, null, 2));
35998
36827
  return;
35999
36828
  }
36000
36829
  if (link.enabled && link.url) {
36001
- console.log(`The join link of ${label2} is on:`);
36830
+ console.log(`The join link of ${label3} is on:`);
36002
36831
  console.log(sanitizeTerminalText(link.url));
36003
36832
  return;
36004
36833
  }
36005
- console.log(`The join link of ${label2} is off. \`wayai communities join-link rotate\` makes a new one.`);
36834
+ console.log(`The join link of ${label3} is off. \`wayai communities join-link rotate\` makes a new one.`);
36006
36835
  }
36007
36836
  async function runStats(target, json) {
36008
36837
  const api = await communitiesClient();
36009
- const { id, label: label2 } = await resolveCommunity(api, target);
36010
- const { data } = await callCommunities(api.getCommunityStats(id), communityNotFound(label2));
36838
+ const { id, label: label3 } = await resolveCommunity(api, target);
36839
+ const { data } = await callCommunities(api.getCommunityStats(id), communityNotFound(label3));
36011
36840
  if (json) {
36012
36841
  console.log(JSON.stringify(data, null, 2));
36013
36842
  return;
36014
36843
  }
36015
- printStats(data, label2);
36844
+ printStats(data, label3);
36016
36845
  }
36017
- function printStats(stats, label2) {
36846
+ function printStats(stats, label3) {
36018
36847
  const { members, joins } = stats;
36019
36848
  const sum = (key) => stats.days.reduce((total, day) => total + day[key], 0);
36020
36849
  const [chat, posts, replies] = [sum("messages"), sum("posts"), sum("replies")];
36021
- console.log(`Stats of ${label2}
36850
+ console.log(`Stats of ${label3}
36022
36851
  `);
36023
36852
  console.log(`Members ${COMMUNITY_MEMBER_STATUSES.map((status) => `${members[status]} ${status}`).join(" \xB7 ")}`);
36024
36853
  console.log(`Active ${stats.active_members_7d} in the last 7 days`);
@@ -36064,14 +36893,14 @@ function accessEmails(raw) {
36064
36893
  }
36065
36894
  return [...emails];
36066
36895
  }
36067
- async function callAccess(request, notFound, label2) {
36896
+ async function callAccess(request, notFound, label3) {
36068
36897
  try {
36069
36898
  return await callCommunities(request, notFound);
36070
36899
  } catch (err) {
36071
36900
  if (err instanceof ApiError && err.status === 409) {
36072
36901
  const reason = extractApiErrorReason(err);
36073
36902
  if (reason === COMMUNITY_ACCESS_FULL_REASON) {
36074
- throw expected(`Nothing was added: the access list of ${label2} would hold more than ${COMMUNITY_ACCESS_MAX} emails.`);
36903
+ throw expected(`Nothing was added: the access list of ${label3} would hold more than ${COMMUNITY_ACCESS_MAX} emails.`);
36075
36904
  }
36076
36905
  if (reason === PEOPLE_SUSPENDED_REASON) {
36077
36906
  throw expected("WayAI has suspended this account, so it cannot change a community's access list.");
@@ -36090,57 +36919,57 @@ async function* accessPages(api, id, notFound) {
36090
36919
  }
36091
36920
  async function runAccessList(target, json) {
36092
36921
  const api = await communitiesClient();
36093
- const { id, label: label2 } = await resolveCommunity(api, target);
36922
+ const { id, label: label3 } = await resolveCommunity(api, target);
36094
36923
  const entries = [];
36095
- for await (const page of accessPages(api, id, communityNotFound(label2))) entries.push(...page);
36924
+ for await (const page of accessPages(api, id, communityNotFound(label3))) entries.push(...page);
36096
36925
  if (json) {
36097
36926
  console.log(JSON.stringify(entries, null, 2));
36098
36927
  return;
36099
36928
  }
36100
36929
  if (entries.length === 0) {
36101
- console.log(`The access list of ${label2} is empty.`);
36930
+ console.log(`The access list of ${label3} is empty.`);
36102
36931
  return;
36103
36932
  }
36104
- console.log(`The access list of ${label2}: ${entries.length} email(s), oldest first
36933
+ console.log(`The access list of ${label3}: ${entries.length} email(s), oldest first
36105
36934
  `);
36106
36935
  printRows(entries.map((entry) => ({ email: entry.email, added: entry.created_at })));
36107
36936
  }
36108
36937
  async function runAccessAdd(target, emails, json) {
36109
36938
  const api = await communitiesClient();
36110
- const { id, label: label2 } = await resolveCommunity(api, target);
36111
- const { data } = await callAccess(api.addCommunityAccess(id, { emails }), communityNotFound(label2), label2);
36939
+ const { id, label: label3 } = await resolveCommunity(api, target);
36940
+ const { data } = await callAccess(api.addCommunityAccess(id, { emails }), communityNotFound(label3), label3);
36112
36941
  if (json) {
36113
36942
  console.log(JSON.stringify(data, null, 2));
36114
36943
  return;
36115
36944
  }
36116
36945
  const { added, already_listed: already } = data;
36117
36946
  const listed2 = already === 0 ? "" : `; ${already} ${already === 1 ? "was" : "were"} already on it`;
36118
- console.log(`Added ${added.length} email(s) to the access list of ${label2}${listed2}.`);
36947
+ console.log(`Added ${added.length} email(s) to the access list of ${label3}${listed2}.`);
36119
36948
  }
36120
36949
  async function runAccessRemove(target, email, { json, yes }) {
36121
36950
  const api = await communitiesClient();
36122
- const { id, label: label2 } = await resolveCommunity(api, target);
36951
+ const { id, label: label3 } = await resolveCommunity(api, target);
36123
36952
  let entry;
36124
- for await (const page of accessPages(api, id, communityNotFound(label2))) {
36953
+ for await (const page of accessPages(api, id, communityNotFound(label3))) {
36125
36954
  entry = page.find((e) => e.email === email);
36126
36955
  if (entry) break;
36127
36956
  }
36128
- if (!entry) throw expected(`${email} is not on the access list of ${label2}. Nothing was removed.`);
36957
+ if (!entry) throw expected(`${email} is not on the access list of ${label3}. Nothing was removed.`);
36129
36958
  await warnThenAsk(
36130
- [`This takes ${email} off the access list of ${label2}.`, "Anyone this email let in is removed from the community now."],
36959
+ [`This takes ${email} off the access list of ${label3}.`, "Anyone this email let in is removed from the community now."],
36131
36960
  yes,
36132
36961
  "Aborted: the access list is unchanged."
36133
36962
  );
36134
36963
  await callAccess(
36135
36964
  api.removeCommunityAccess(id, entry.access_id),
36136
- `${email} is no longer on the access list of ${label2}, or you are not an owner or admin of its organization. Nothing was removed.`,
36137
- label2
36965
+ `${email} is no longer on the access list of ${label3}, or you are not an owner or admin of its organization. Nothing was removed.`,
36966
+ label3
36138
36967
  );
36139
36968
  if (json) {
36140
36969
  console.log(JSON.stringify(entry, null, 2));
36141
36970
  return;
36142
36971
  }
36143
- console.log(`Removed ${email} from the access list of ${label2}, and from the community anyone it let in.`);
36972
+ console.log(`Removed ${email} from the access list of ${label3}, and from the community anyone it let in.`);
36144
36973
  }
36145
36974
  var USAGE3, SUBCOMMANDS, JOIN_LINK_ACTIONS, ACCESS_ACTIONS;
36146
36975
  var init_communities = __esm({
@@ -36465,7 +37294,7 @@ async function dimensionsCommand(args2) {
36465
37294
  if (!shape.label && values.label !== void 0) throw usageError4(`--label does not apply to ${sub}.`);
36466
37295
  const orgId = resolveOrgId3(values.org);
36467
37296
  const [dimensionId, valueId] = ids;
36468
- const label2 = values.label;
37297
+ const label3 = values.label;
36469
37298
  const { config, accessToken } = await requireAuth();
36470
37299
  const api = new ApiClient({ apiUrl: config.api_url, accessToken, onUnauthorized: () => getAccessToken(config) });
36471
37300
  let data;
@@ -36492,19 +37321,19 @@ async function dimensionsCommand(args2) {
36492
37321
  return;
36493
37322
  }
36494
37323
  case "create":
36495
- ({ data } = await api.createAccessDimension(orgId, { dimension_id: dimensionId, label: label2 }));
37324
+ ({ data } = await api.createAccessDimension(orgId, { dimension_id: dimensionId, label: label3 }));
36496
37325
  done = `Created dimension ${dimensionId}.`;
36497
37326
  break;
36498
37327
  case "relabel":
36499
- ({ data } = await api.relabelAccessDimension(orgId, dimensionId, label2));
37328
+ ({ data } = await api.relabelAccessDimension(orgId, dimensionId, label3));
36500
37329
  done = `Relabelled dimension ${dimensionId}.`;
36501
37330
  break;
36502
37331
  case "add-value":
36503
- ({ data } = await api.createAccessValue(orgId, dimensionId, { value_id: valueId, label: label2 }));
37332
+ ({ data } = await api.createAccessValue(orgId, dimensionId, { value_id: valueId, label: label3 }));
36504
37333
  done = `Added value ${valueId} to dimension ${dimensionId}.`;
36505
37334
  break;
36506
37335
  case "relabel-value":
36507
- ({ data } = await api.updateAccessValue(orgId, dimensionId, valueId, { label: label2 }));
37336
+ ({ data } = await api.updateAccessValue(orgId, dimensionId, valueId, { label: label3 }));
36508
37337
  done = `Relabelled value ${valueId} of dimension ${dimensionId}.`;
36509
37338
  break;
36510
37339
  case "retire-value":
@@ -37266,7 +38095,7 @@ async function openRemote2() {
37266
38095
  function filesRoot(t) {
37267
38096
  return `/v1/${pathSegment(t.base, "--base")}/files/${pathSegment(t.file_type, "file_type")}`;
37268
38097
  }
37269
- function filePath(t, rel) {
38098
+ function filePath2(t, rel) {
37270
38099
  return `${filesRoot(t)}/${pathSegments(remotePath(t.folder, rel))}`;
37271
38100
  }
37272
38101
  function pullCommand2(t, dir, overwrite = false) {
@@ -37393,7 +38222,7 @@ async function pullFiles(opts) {
37393
38222
  conflicts.push({ rel: w.rel, ...clash });
37394
38223
  continue;
37395
38224
  }
37396
- const path45 = filePath(target, w.rel);
38225
+ const path45 = filePath2(target, w.rel);
37397
38226
  let bytes;
37398
38227
  let version = w.remote.version;
37399
38228
  try {
@@ -37463,7 +38292,7 @@ async function describeSteps(client, t, dir, steps) {
37463
38292
  }
37464
38293
  let bytes;
37465
38294
  try {
37466
- bytes = (await client.download(filePath(t, step.rel))).bytes;
38295
+ bytes = (await client.download(filePath2(t, step.rel))).bytes;
37467
38296
  } catch (err) {
37468
38297
  if (!isNotFound(err)) throw err;
37469
38298
  lines.push(" (deleted on the base since it was listed)");
@@ -37483,7 +38312,7 @@ function printPushNotes(plan) {
37483
38312
  printSection("Deleted in your files \u2014 kept on the base; push with --prune to delete it:", plan.keptOnBase.map(safe));
37484
38313
  }
37485
38314
  async function pushFiles(opts) {
37486
- const label2 = opts.label === void 0 ? void 0 : labelValue(opts.label);
38315
+ const label3 = opts.label === void 0 ? void 0 : labelValue(opts.label);
37487
38316
  const { target, dir, existing } = resolveSync(opts);
37488
38317
  if (!existing) {
37489
38318
  throw expected(
@@ -37528,7 +38357,7 @@ Push ${n} change${n === 1 ? "" : "s"} to ${describeSync(target)}?`, opts.yes)) {
37528
38357
  let pushed = 0;
37529
38358
  const refusedDeletes = /* @__PURE__ */ new Set();
37530
38359
  for (const step of plan.steps) {
37531
- const path45 = filePath(target, step.rel);
38360
+ const path45 = filePath2(target, step.rel);
37532
38361
  const blockedBy = step.op === "create" ? step.after?.find((d) => refusedDeletes.has(d.rel)) : void 0;
37533
38362
  if (blockedBy !== void 0) {
37534
38363
  const conflict = { rel: step.rel, reason: blockedBy.reason, other: blockedBy.rel };
@@ -37550,7 +38379,7 @@ Push ${n} change${n === 1 ? "" : "s"} to ${describeSync(target)}?`, opts.yes)) {
37550
38379
  path45,
37551
38380
  bytes,
37552
38381
  contentType,
37553
- fileWriteHeaders({ ...step.op === "update" ? { ifMatch: step.ifMatch } : { createOnly: true }, label: label2 })
38382
+ fileWriteHeaders({ ...step.op === "update" ? { ifMatch: step.ifMatch } : { createOnly: true }, label: label3 })
37554
38383
  );
37555
38384
  record.files[step.rel] = {
37556
38385
  version: typeof row?.version === "number" ? row.version : 0,
@@ -37899,7 +38728,7 @@ var init_vault_import = __esm({
37899
38728
  });
37900
38729
 
37901
38730
  // ../../packages/core/dist/contracts/vault.js
37902
- var vaultIdSchema, vaultFailureOutcomeSchema, vaultRefreshCategorySchema, vaultFailureBodySchema, vaultSendEnvelopeSchema, vaultVerifyEnvelopeSchema, vaultAutomationHmacEnvelopeSchema, vaultAutomationStaticEnvelopeSchema, AUTOMATION_WEBHOOK_VAULT_GATE_ID, vaultVerifyResponseSchema, vaultVersionSchema, vaultPutResponseSchema, vaultMetaResponseSchema, vaultDeleteResponseSchema, vaultInstantSchema, vaultRefreshResponseSchema;
38731
+ var vaultIdSchema, vaultFailureOutcomeSchema, vaultRefreshCategorySchema, vaultFailureBodySchema, vaultSendEnvelopeSchema, vaultVerifyEnvelopeSchema, vaultAutomationHmacEnvelopeSchema, vaultAutomationStaticEnvelopeSchema, AUTOMATION_WEBHOOK_VAULT_GATE_ID, GITHUB_APP_VAULT_GATE_ID, vaultVerifyResponseSchema, vaultVersionSchema, vaultPutResponseSchema, vaultMetaResponseSchema, vaultDeleteResponseSchema, vaultInstantSchema, vaultRefreshResponseSchema, vaultMintResponseSchema;
37903
38732
  var init_vault = __esm({
37904
38733
  "../../packages/core/dist/contracts/vault.js"() {
37905
38734
  "use strict";
@@ -37957,6 +38786,7 @@ var init_vault = __esm({
37957
38786
  }).strict();
37958
38787
  vaultAutomationStaticEnvelopeSchema = external_exports.object({}).strict();
37959
38788
  AUTOMATION_WEBHOOK_VAULT_GATE_ID = "c2d6f1a4-7e3b-4f1a-9b8d-6a1f4e7c3b20";
38789
+ GITHUB_APP_VAULT_GATE_ID = "fff3a999-e46a-483d-a50b-ab9d01bcb707";
37960
38790
  vaultVerifyResponseSchema = external_exports.object({});
37961
38791
  vaultVersionSchema = external_exports.number().int().positive();
37962
38792
  vaultPutResponseSchema = external_exports.object({ version: vaultVersionSchema });
@@ -37964,6 +38794,7 @@ var init_vault = __esm({
37964
38794
  vaultDeleteResponseSchema = external_exports.object({});
37965
38795
  vaultInstantSchema = external_exports.string().regex(ISO_UTC_RE);
37966
38796
  vaultRefreshResponseSchema = external_exports.object({ version: vaultVersionSchema, expires_at: vaultInstantSchema.nullable() });
38797
+ vaultMintResponseSchema = external_exports.object({ token: external_exports.string().min(1), expires_at: vaultInstantSchema });
37967
38798
  }
37968
38799
  });
37969
38800
 
@@ -38734,8 +39565,8 @@ function parseScopedTargetFlags(flagArgs, usage3, opts = {}) {
38734
39565
  process.exit(1);
38735
39566
  }
38736
39567
  if (all) {
38737
- const label2 = opts.allLabel ?? "ALL hubs (platform-wide)";
38738
- return { body: { scope: "all", dry_run: dryRun }, targetLabel: label2, dryRun, yes, jsonOutput };
39568
+ const label3 = opts.allLabel ?? "ALL hubs (platform-wide)";
39569
+ return { body: { scope: "all", dry_run: dryRun }, targetLabel: label3, dryRun, yes, jsonOutput };
38739
39570
  }
38740
39571
  if (orgId) {
38741
39572
  return { body: { scope: "org", org_id: orgId, dry_run: dryRun }, targetLabel: `org ${orgId}`, dryRun, yes, jsonOutput };
@@ -39933,8 +40764,8 @@ function requireFlagValue(flagArgs, index, flag) {
39933
40764
  }
39934
40765
  function errorCodeOf(body) {
39935
40766
  try {
39936
- const code = JSON.parse(body)?.error;
39937
- return typeof code === "string" ? code : null;
40767
+ const code2 = JSON.parse(body)?.error;
40768
+ return typeof code2 === "string" ? code2 : null;
39938
40769
  } catch {
39939
40770
  return null;
39940
40771
  }
@@ -40814,7 +41645,9 @@ var init_admin = __esm({
40814
41645
  ]],
40815
41646
  ["typesafe", ["0da558b0-e4b6-43f4-b945-aeaf432965e2"]],
40816
41647
  ["automation_webhook", [AUTOMATION_WEBHOOK_VAULT_GATE_ID]],
40817
- ["resend", ["a1b2c3d4-e5f6-4a89-b012-3e5e0d000001"]]
41648
+ ["resend", ["a1b2c3d4-e5f6-4a89-b012-3e5e0d000001"]],
41649
+ ["claude_managed_agents", ["4b8eeecf-a835-444a-abed-516d0a29cee2"]],
41650
+ ["github_app", [GITHUB_APP_VAULT_GATE_ID]]
40818
41651
  ]);
40819
41652
  VAULT_GATE_BY_ID_ONLY = /* @__PURE__ */ new Map([
40820
41653
  ["01e7b19c-bc94-43f4-a780-ad5a22fb7127", "openai"]
@@ -41499,8 +42332,8 @@ import { Command as Command4 } from "commander";
41499
42332
  function isRetryable(err) {
41500
42333
  if (isNetworkError(err)) return true;
41501
42334
  if (!(err instanceof ApiError)) return false;
41502
- const code = dataErrorCode(err);
41503
- if (code && RETRYABLE_CODES.has(code)) return true;
42335
+ const code2 = dataErrorCode(err);
42336
+ if (code2 && RETRYABLE_CODES.has(code2)) return true;
41504
42337
  return err.status >= 500 && err.status !== 501;
41505
42338
  }
41506
42339
  function isExpiredSession(err) {
@@ -41516,8 +42349,8 @@ async function withRetry(state, fn, what) {
41516
42349
  } catch (err) {
41517
42350
  lastErr = err;
41518
42351
  if (!isRetryable(err) || attempt === MAX_ATTEMPTS) throw err;
41519
- const code = err instanceof ApiError ? dataErrorCode(err) : null;
41520
- if (!code || !RETRYABLE_CODES.has(code)) state.sawAmbiguous = true;
42352
+ const code2 = err instanceof ApiError ? dataErrorCode(err) : null;
42353
+ if (!code2 || !RETRYABLE_CODES.has(code2)) state.sawAmbiguous = true;
41521
42354
  const delay2 = BASE_BACKOFF_MS * 2 ** (attempt - 1);
41522
42355
  console.error(
41523
42356
  ` ${what}: ${err.message} \u2014 retrying in ${delay2}ms (${attempt}/${MAX_ATTEMPTS - 1})`
@@ -41903,7 +42736,7 @@ function withValueSourceOptions(cmd, what) {
41903
42736
  `Read ${what} from a file and base64-encode it (certificates, keystores, service-account JSON)`
41904
42737
  ).option("--value-stdin", `Read ${what} from stdin (recommended for CI)`).option("--value-prompt", `Prompt for ${what}, masked`);
41905
42738
  }
41906
- async function resolveValue(opts, label2) {
42739
+ async function resolveValue(opts, label3) {
41907
42740
  if (opts.file !== void 0) {
41908
42741
  if (opts.valueStdin || opts.valuePrompt) {
41909
42742
  throw expected("--file cannot be combined with --value-stdin or --value-prompt \u2014 pass one.");
@@ -41921,7 +42754,7 @@ async function resolveValue(opts, label2) {
41921
42754
  stdinFlag: "--value-stdin",
41922
42755
  promptHint: "--value-prompt"
41923
42756
  },
41924
- label2
42757
+ label3
41925
42758
  );
41926
42759
  }
41927
42760
  function credentialPath(base, id) {
@@ -42757,8 +43590,8 @@ var init_file_types = __esm({
42757
43590
  import { Command as Command11 } from "commander";
42758
43591
  import { readFileSync as readFileSync23, writeFileSync as writeFileSync11 } from "fs";
42759
43592
  import { basename as basename29 } from "path";
42760
- function renderFileDiff(fileType, filePath2, from, to, d) {
42761
- console.log(sanitizeTerminalText(`${fileType}/${filePath2}: v${from} \u2192 v${to}`));
43593
+ function renderFileDiff(fileType, filePath3, from, to, d) {
43594
+ console.log(sanitizeTerminalText(`${fileType}/${filePath3}: v${from} \u2192 v${to}`));
42762
43595
  const md = d.metadata_delta;
42763
43596
  if (md) {
42764
43597
  for (const f of ["path", "size", "content_type", "label"]) {
@@ -42805,7 +43638,7 @@ function buildFilesCommand() {
42805
43638
  ).requiredOption("--file <local>", "Local file to upload").option("--content-type <type>", "MIME type", "application/octet-stream").option(
42806
43639
  "--if-match <hash>",
42807
43640
  "Write only if the file's content hash is still this one (its ETag, or content_sha256 from get --meta); refused with a conflict otherwise"
42808
- ).option("--label <text>", "Label for the content version this upload creates (printable ASCII)").option("--metadata <json>", "The file's metadata, a JSON object (inline or @filename)").action(async function(fileType, filePath2, opts) {
43641
+ ).option("--label <text>", "Label for the content version this upload creates (printable ASCII)").option("--metadata <json>", "The file's metadata, a JSON object (inline or @filename)").action(async function(fileType, filePath3, opts) {
42809
43642
  const base = pathSegment(requireBase(this), "--base");
42810
43643
  const headers = fileWriteHeaders({
42811
43644
  ifMatch: opts.ifMatch,
@@ -42816,7 +43649,7 @@ function buildFilesCommand() {
42816
43649
  const client = await createDataClient();
42817
43650
  printOutput(
42818
43651
  await client.upload(
42819
- `/v1/${base}/files/${pathSegment(fileType, "file_type")}/${pathSegments(filePath2)}`,
43652
+ `/v1/${base}/files/${pathSegment(fileType, "file_type")}/${pathSegments(filePath3)}`,
42820
43653
  body,
42821
43654
  opts.contentType,
42822
43655
  headers
@@ -42826,8 +43659,8 @@ function buildFilesCommand() {
42826
43659
  });
42827
43660
  files.command("get <file_type> <path>").description(
42828
43661
  "Download a file (or --meta for metadata only). --version N reads a specific retained content version."
42829
- ).option("--to <local>", "Local file to save to (defaults to the file basename)").option("--meta", "Print metadata JSON instead of downloading the content").option("--version <n>", "Read a specific content version (default: latest)").action(async function(fileType, filePath2, opts) {
42830
- const encoded = pathSegments(filePath2);
43662
+ ).option("--to <local>", "Local file to save to (defaults to the file basename)").option("--meta", "Print metadata JSON instead of downloading the content").option("--version <n>", "Read a specific content version (default: latest)").action(async function(fileType, filePath3, opts) {
43663
+ const encoded = pathSegments(filePath3);
42831
43664
  const versionQs = opts.version !== void 0 ? `version=${encodeURIComponent(opts.version)}` : "";
42832
43665
  const base = pathSegment(requireBase(this), "--base");
42833
43666
  if (opts.meta) {
@@ -42839,7 +43672,7 @@ function buildFilesCommand() {
42839
43672
  );
42840
43673
  return;
42841
43674
  }
42842
- const out = downloadTarget(filePath2, opts.to);
43675
+ const out = downloadTarget(filePath3, opts.to);
42843
43676
  const client = await createDataClient();
42844
43677
  const { bytes } = await client.download(
42845
43678
  `/v1/${base}/files/${pathSegment(fileType, "file_type")}/${encoded}${versionQs ? `?${versionQs}` : ""}`
@@ -42847,7 +43680,7 @@ function buildFilesCommand() {
42847
43680
  writeFileSync11(out, bytes);
42848
43681
  console.log(`Downloaded to ${out}`);
42849
43682
  });
42850
- files.command("history <file_type> <path>").description("List the content versions of a file (newest first)").option("--limit <n>", "Max versions to return").option("--offset <n>", "Pagination offset").action(async function(fileType, filePath2, opts) {
43683
+ files.command("history <file_type> <path>").description("List the content versions of a file (newest first)").option("--limit <n>", "Max versions to return").option("--offset <n>", "Pagination offset").action(async function(fileType, filePath3, opts) {
42851
43684
  const base = pathSegment(requireBase(this), "--base");
42852
43685
  const client = await createDataClient();
42853
43686
  const qs = new URLSearchParams({ history: "1" });
@@ -42856,24 +43689,24 @@ function buildFilesCommand() {
42856
43689
  printOutput(
42857
43690
  await client.request(
42858
43691
  "GET",
42859
- `/v1/${base}/files/${pathSegment(fileType, "file_type")}/${pathSegments(filePath2)}?${qs}`
43692
+ `/v1/${base}/files/${pathSegment(fileType, "file_type")}/${pathSegments(filePath3)}?${qs}`
42860
43693
  ),
42861
43694
  outputFormat(this)
42862
43695
  );
42863
43696
  });
42864
- files.command("diff <file_type> <path>").description("Diff two content versions of a file \u2014 metadata delta plus a text content diff").requiredOption("--from <n>", "Base version number").requiredOption("--to <n>", "Target version number").action(async function(fileType, filePath2, opts) {
43697
+ files.command("diff <file_type> <path>").description("Diff two content versions of a file \u2014 metadata delta plus a text content diff").requiredOption("--from <n>", "Base version number").requiredOption("--to <n>", "Target version number").action(async function(fileType, filePath3, opts) {
42865
43698
  const base = pathSegment(requireBase(this), "--base");
42866
43699
  const client = await createDataClient();
42867
43700
  const qs = new URLSearchParams({ diff: "1", from: opts.from, to: opts.to });
42868
43701
  const data = await client.request(
42869
43702
  "GET",
42870
- `/v1/${base}/files/${pathSegment(fileType, "file_type")}/${pathSegments(filePath2)}?${qs}`
43703
+ `/v1/${base}/files/${pathSegment(fileType, "file_type")}/${pathSegments(filePath3)}?${qs}`
42871
43704
  );
42872
43705
  if (outputFormat(this) === "json") {
42873
43706
  printOutput(data, "json");
42874
43707
  return;
42875
43708
  }
42876
- renderFileDiff(fileType, filePath2, opts.from, opts.to, data);
43709
+ renderFileDiff(fileType, filePath3, opts.from, opts.to, data);
42877
43710
  });
42878
43711
  files.command("list <file_type>").description("List files by path prefix").option("--prefix <path>", "Path prefix filter (e.g. q3/)").option("--depth <n>", "Max folder depth below the prefix (1 = immediate children)").option("--limit <n>", "Max results").option("--offset <n>", "Pagination offset").action(async function(fileType, opts) {
42879
43712
  const base = pathSegment(requireBase(this), "--base");
@@ -42902,9 +43735,9 @@ function buildFilesCommand() {
42902
43735
  files.command("rm <file_type> <path>").description("Delete a file").option("-y, --yes", "Skip confirmation prompt").option(
42903
43736
  "--if-match <hash>",
42904
43737
  "Delete only if the file's content hash is still this one; refused with a conflict otherwise"
42905
- ).action(async function(fileType, filePath2, opts) {
43738
+ ).action(async function(fileType, filePath3, opts) {
42906
43739
  const headers = fileWriteHeaders({ ifMatch: opts.ifMatch });
42907
- if (!opts.yes && !await confirm(`Delete file "${fileType}/${filePath2}"? This cannot be undone.`)) {
43740
+ if (!opts.yes && !await confirm(`Delete file "${fileType}/${filePath3}"? This cannot be undone.`)) {
42908
43741
  console.log("Aborted");
42909
43742
  return;
42910
43743
  }
@@ -42912,7 +43745,7 @@ function buildFilesCommand() {
42912
43745
  const client = await createDataClient();
42913
43746
  await client.request(
42914
43747
  "DELETE",
42915
- `/v1/${base}/files/${pathSegment(fileType, "file_type")}/${pathSegments(filePath2)}`,
43748
+ `/v1/${base}/files/${pathSegment(fileType, "file_type")}/${pathSegments(filePath3)}`,
42916
43749
  void 0,
42917
43750
  headers
42918
43751
  );
@@ -43822,13 +44655,13 @@ function routeErrorsToCli(command2) {
43822
44655
  return command2;
43823
44656
  }
43824
44657
  function handleParserExit(err) {
43825
- const { code, exitCode } = err ?? {};
43826
- if (code === "commander.helpDisplayed" || code === "commander.version") return;
43827
- if (code === "commander.help") {
44658
+ const { code: code2, exitCode } = err ?? {};
44659
+ if (code2 === "commander.helpDisplayed" || code2 === "commander.version") return;
44660
+ if (code2 === "commander.help") {
43828
44661
  process.exitCode = exitCode || 1;
43829
44662
  return;
43830
44663
  }
43831
- if (typeof code === "string" && code.startsWith("commander.")) {
44664
+ if (typeof code2 === "string" && code2.startsWith("commander.")) {
43832
44665
  throw expected(err instanceof Error ? err.message : String(err));
43833
44666
  }
43834
44667
  throw err;