@wayai/cli 0.3.302 → 0.3.303

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
@@ -488,6 +488,222 @@ var init_sentry = __esm({
488
488
  }
489
489
  });
490
490
 
491
+ // ../../packages/core/dist/chunk-WFQDSQJK.js
492
+ function isPublicIdentifier(value) {
493
+ return UUID_RE.test(value) || HEX_RE.test(value) || WORKOS_ID_RE.test(value) || TRACE_HEADER_RE.test(value);
494
+ }
495
+ function redactTokenShapes(input) {
496
+ return input.replace(FILE_URL_TOKEN_RE, REDACTED).replace(TOKEN_RE, REDACTED).replace(PROVIDER_TOKEN_RE, `$1${REDACTED}`).replace(JSON_CREDENTIAL_RE, `$1"${REDACTED}"`).replace(QUERY_CREDENTIAL_RE, `$1${REDACTED}`);
497
+ }
498
+ function redactSecrets(value) {
499
+ if (isPublicIdentifier(value)) {
500
+ return value;
501
+ }
502
+ if (OPAQUE_SECRET_RE.test(value)) {
503
+ return REDACTED;
504
+ }
505
+ if (BASE64_SECRET_RE.test(value) && BASE64_MARKER_RE.test(value)) {
506
+ return REDACTED;
507
+ }
508
+ return redactTokenShapes(value);
509
+ }
510
+ var UUID_RE, HEX_RE, WORKOS_ID_RE, TRACE_HEADER_RE, OPAQUE_SECRET_RE, BASE64_SECRET_RE, BASE64_MARKER_RE, TOKEN_RE, SENSITIVE_FIELDS, SENSITIVE_KEY_ALTERNATION, SENSITIVE_KEY_PATTERN, JSON_CREDENTIAL_RE, QUERY_CREDENTIAL_RE, REDACTED, PROVIDER_TOKEN_RE, FILE_URL_TOKEN_RE;
511
+ var init_chunk_WFQDSQJK = __esm({
512
+ "../../packages/core/dist/chunk-WFQDSQJK.js"() {
513
+ "use strict";
514
+ UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
515
+ HEX_RE = /^[0-9a-f]{16,}$/;
516
+ WORKOS_ID_RE = /^(?:user|org)_[0-9A-HJKMNP-TV-Z]{26}$/;
517
+ TRACE_HEADER_RE = /^(?:[0-9a-f]{2}-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}|[0-9a-f]{32}-[0-9a-f]{16}(?:-[01])?)$/;
518
+ OPAQUE_SECRET_RE = /^[A-Za-z0-9_-]{21,}$/;
519
+ BASE64_SECRET_RE = /^[A-Za-z0-9+/]{20,}={0,2}$/;
520
+ BASE64_MARKER_RE = /[+=]/;
521
+ TOKEN_RE = new RegExp(
522
+ [
523
+ // WayAI API tokens and WebSocket tickets.
524
+ "(?:way|wst)_[A-Za-z0-9._-]{8,}",
525
+ // Authorization header values, including base64 Basic credentials.
526
+ "(?:Bearer|Basic)\\s+[A-Za-z0-9._~+/=-]{8,}",
527
+ // JWTs — WorkOS session/access tokens. `eyJ` is base64 for `{"`.
528
+ "eyJ[A-Za-z0-9._-]{10,}",
529
+ // Stripe secret/publishable/restricted keys and webhook signing secrets.
530
+ "(?:sk|pk|rk)_(?:live|test)_[A-Za-z0-9]{8,}",
531
+ "whsec_[A-Za-z0-9]{8,}",
532
+ // Telegram bot tokens as the Bot API takes them, in the URL path: `/bot<id>:<secret>/`.
533
+ "bot[0-9]{5,}:[A-Za-z0-9_-]{30,}"
534
+ // NOTE: LLM provider keys are NOT here — they need a delimiter-preserving
535
+ // boundary, so they live in PROVIDER_TOKEN_RE below.
536
+ ].join("|"),
537
+ "g"
538
+ );
539
+ SENSITIVE_FIELDS = [
540
+ "password",
541
+ "token",
542
+ "secret",
543
+ "api_key",
544
+ "apikey",
545
+ "api-key",
546
+ "authorization",
547
+ "auth",
548
+ "credential",
549
+ "private_key",
550
+ "privatekey",
551
+ "access_token",
552
+ "refresh_token",
553
+ "session_id",
554
+ "sessionid",
555
+ "cookie",
556
+ "jwt"
557
+ ];
558
+ SENSITIVE_KEY_ALTERNATION = SENSITIVE_FIELDS.map(
559
+ (field) => field.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")
560
+ ).join("|");
561
+ SENSITIVE_KEY_PATTERN = `[A-Za-z0-9_.-]*(?:${SENSITIVE_KEY_ALTERNATION})[A-Za-z0-9_.-]*`;
562
+ JSON_CREDENTIAL_RE = new RegExp(
563
+ `("${SENSITIVE_KEY_PATTERN}"\\s*:\\s*)"(?:[^"\\\\]|\\\\.)*"`,
564
+ "gi"
565
+ );
566
+ QUERY_CREDENTIAL_RE = new RegExp(
567
+ `((?:^|[?&#;\\s])${SENSITIVE_KEY_PATTERN}=)[^&;\\s"']+`,
568
+ "gi"
569
+ );
570
+ REDACTED = "[REDACTED]";
571
+ PROVIDER_TOKEN_RE = new RegExp(
572
+ "(^|[^A-Za-z0-9])(?:" + [
573
+ "sk-[A-Za-z0-9_-]{16,}",
574
+ "AIza[A-Za-z0-9_-]{16,}",
575
+ "xai-[A-Za-z0-9_-]{16,}"
576
+ ].join("|") + ")",
577
+ "g"
578
+ );
579
+ FILE_URL_TOKEN_RE = /v[0-9]+\.[gp]\.[0-9]+\.[A-Za-z0-9_-]{43}\.[A-Za-z0-9_-]{43}/g;
580
+ }
581
+ });
582
+
583
+ // ../../packages/core/dist/chunk-ICYO56QW.js
584
+ var APP_ERROR_BRAND, AppError, SECOND_FACTOR_REQUIRED_CODE, SECOND_FACTOR_ENROLLMENT_REQUIRED_CODE, PAGE_CUSTOMER_UNAVAILABLE_CODE, LLM_RATE_LIMIT_BRAND, LlmRateLimitError, LLM_PROVIDER_HTTP_BRAND, LlmProviderHttpError, LLM_PROVIDER_CONTENT_BRAND, LlmProviderContentError, LLM_PROVIDER_TIMEOUT_BRAND, LlmProviderTimeoutError, ExternalServiceError, CHANNEL_PROVIDER_HTTP_BRAND, ChannelProviderHttpError, MEDIA_PROVIDER_HTTP_BRAND, MediaProviderHttpError;
585
+ var init_chunk_ICYO56QW = __esm({
586
+ "../../packages/core/dist/chunk-ICYO56QW.js"() {
587
+ "use strict";
588
+ init_chunk_WFQDSQJK();
589
+ APP_ERROR_BRAND = /* @__PURE__ */ Symbol.for("wayai.AppError");
590
+ AppError = class extends Error {
591
+ constructor(message, code, statusCode = 500, details) {
592
+ super(message);
593
+ this.code = code;
594
+ this.statusCode = statusCode;
595
+ this.details = details;
596
+ this.name = "AppError";
597
+ }
598
+ [APP_ERROR_BRAND] = true;
599
+ toJSON() {
600
+ return {
601
+ error: this.code,
602
+ message: this.message,
603
+ ...this.details && { details: this.details }
604
+ };
605
+ }
606
+ };
607
+ SECOND_FACTOR_REQUIRED_CODE = "SECOND_FACTOR_REQUIRED";
608
+ SECOND_FACTOR_ENROLLMENT_REQUIRED_CODE = "SECOND_FACTOR_ENROLLMENT_REQUIRED";
609
+ PAGE_CUSTOMER_UNAVAILABLE_CODE = "PAGE_CUSTOMER_UNAVAILABLE";
610
+ LLM_RATE_LIMIT_BRAND = /* @__PURE__ */ Symbol.for("wayai.LlmRateLimitError");
611
+ LlmRateLimitError = class extends Error {
612
+ constructor(provider, retryAfterMs) {
613
+ super(`${provider} rate limited; retry after ${retryAfterMs}ms`);
614
+ this.provider = provider;
615
+ this.retryAfterMs = retryAfterMs;
616
+ this.name = "LlmRateLimitError";
617
+ }
618
+ [LLM_RATE_LIMIT_BRAND] = true;
619
+ };
620
+ LLM_PROVIDER_HTTP_BRAND = /* @__PURE__ */ Symbol.for("wayai.LlmProviderHttpError");
621
+ LlmProviderHttpError = class extends Error {
622
+ constructor(message, status, provider, providerError) {
623
+ super(redactSecrets(message));
624
+ this.status = status;
625
+ this.provider = provider;
626
+ this.providerError = providerError;
627
+ this.name = "LlmProviderHttpError";
628
+ }
629
+ [LLM_PROVIDER_HTTP_BRAND] = true;
630
+ };
631
+ LLM_PROVIDER_CONTENT_BRAND = /* @__PURE__ */ Symbol.for("wayai.LlmProviderContentError");
632
+ LlmProviderContentError = class extends Error {
633
+ constructor(message, provider, providerError) {
634
+ super(redactSecrets(message));
635
+ this.provider = provider;
636
+ this.providerError = providerError;
637
+ this.name = "LlmProviderContentError";
638
+ }
639
+ [LLM_PROVIDER_CONTENT_BRAND] = true;
640
+ };
641
+ LLM_PROVIDER_TIMEOUT_BRAND = /* @__PURE__ */ Symbol.for("wayai.LlmProviderTimeoutError");
642
+ LlmProviderTimeoutError = class extends Error {
643
+ constructor(message, provider) {
644
+ super(message);
645
+ this.provider = provider;
646
+ this.name = "LlmProviderTimeoutError";
647
+ }
648
+ [LLM_PROVIDER_TIMEOUT_BRAND] = true;
649
+ };
650
+ ExternalServiceError = class extends AppError {
651
+ constructor(service, originalError) {
652
+ super(`External service error: ${service}`, "EXTERNAL_SERVICE_ERROR", 502, {
653
+ service,
654
+ originalMessage: originalError?.message
655
+ });
656
+ this.name = "ExternalServiceError";
657
+ }
658
+ };
659
+ CHANNEL_PROVIDER_HTTP_BRAND = /* @__PURE__ */ Symbol.for("wayai.ChannelProviderHttpError");
660
+ ChannelProviderHttpError = class extends ExternalServiceError {
661
+ [CHANNEL_PROVIDER_HTTP_BRAND] = true;
662
+ status;
663
+ provider;
664
+ /** Provider numeric error code (Meta `error.code`) — body-free. */
665
+ providerCode;
666
+ /** Provider numeric error subcode (Meta `error.error_subcode`) — body-free. */
667
+ providerSubcode;
668
+ constructor(provider, status, providerCode, providerSubcode) {
669
+ super(provider);
670
+ this.name = "ChannelProviderHttpError";
671
+ this.status = status;
672
+ this.provider = provider;
673
+ this.providerCode = providerCode;
674
+ this.providerSubcode = providerSubcode;
675
+ }
676
+ };
677
+ MEDIA_PROVIDER_HTTP_BRAND = /* @__PURE__ */ Symbol.for("wayai.MediaProviderHttpError");
678
+ MediaProviderHttpError = class extends Error {
679
+ constructor(provider, status, options = {}) {
680
+ super(`${provider} API error (${status})`);
681
+ this.provider = provider;
682
+ this.status = status;
683
+ this.name = "MediaProviderHttpError";
684
+ this.credentialRejected = options.credentialRejected ?? false;
685
+ }
686
+ [MEDIA_PROVIDER_HTTP_BRAND] = true;
687
+ /**
688
+ * The provider said the credential itself was rejected, under a status that does not say so
689
+ * (Google answers an invalid or expired key with 400 `API_KEY_INVALID`, not 401). Read off
690
+ * the body at the throw site, which carries only this flag on. Alerting keys on it so the
691
+ * admin is told to re-enter the key, not that the key is fine.
692
+ */
693
+ credentialRejected;
694
+ };
695
+ }
696
+ });
697
+
698
+ // ../../packages/core/dist/errors.js
699
+ var init_errors = __esm({
700
+ "../../packages/core/dist/errors.js"() {
701
+ "use strict";
702
+ init_chunk_ICYO56QW();
703
+ init_chunk_WFQDSQJK();
704
+ }
705
+ });
706
+
491
707
  // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/util.js
492
708
  var util, objectUtil, ZodParsedType, getParsedType;
493
709
  var init_util = __esm({
@@ -870,7 +1086,7 @@ function getErrorMap() {
870
1086
  return overrideErrorMap;
871
1087
  }
872
1088
  var overrideErrorMap;
873
- var init_errors = __esm({
1089
+ var init_errors2 = __esm({
874
1090
  "../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/errors.js"() {
875
1091
  "use strict";
876
1092
  init_en();
@@ -902,7 +1118,7 @@ var makeIssue, EMPTY_PATH, ParseStatus, INVALID, DIRTY, OK, isAborted, isDirty,
902
1118
  var init_parseUtil = __esm({
903
1119
  "../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js"() {
904
1120
  "use strict";
905
- init_errors();
1121
+ init_errors2();
906
1122
  init_en();
907
1123
  makeIssue = (params) => {
908
1124
  const { data, path: path45, errorMaps, issueData } = params;
@@ -1212,7 +1428,7 @@ var init_types = __esm({
1212
1428
  "../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js"() {
1213
1429
  "use strict";
1214
1430
  init_ZodError();
1215
- init_errors();
1431
+ init_errors2();
1216
1432
  init_errorUtil();
1217
1433
  init_parseUtil();
1218
1434
  init_util();
@@ -4586,7 +4802,7 @@ __export(external_exports, {
4586
4802
  var init_external = __esm({
4587
4803
  "../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/external.js"() {
4588
4804
  "use strict";
4589
- init_errors();
4805
+ init_errors2();
4590
4806
  init_parseUtil();
4591
4807
  init_typeAliases();
4592
4808
  init_util();
@@ -4888,85 +5104,6 @@ var init_fs_safety = __esm({
4888
5104
  }
4889
5105
  });
4890
5106
 
4891
- // ../../packages/core/dist/chunk-Q7KIQHAZ.js
4892
- var initialValueCreateSchema, initialValueUpdateSchema, stateIdParam, listStatesQuery, stateNameSchema, createStateBody, updateStateBody, reorderStatesBody;
4893
- var init_chunk_Q7KIQHAZ = __esm({
4894
- "../../packages/core/dist/chunk-Q7KIQHAZ.js"() {
4895
- "use strict";
4896
- init_chunk_6TSQ5HXC();
4897
- init_zod();
4898
- initialValueCreateSchema = external_exports.record(external_exports.unknown()).nullish().transform((v) => v && Object.keys(v).length > 0 ? v : null);
4899
- initialValueUpdateSchema = external_exports.record(external_exports.unknown()).nullish().transform((v) => v === void 0 ? void 0 : v && Object.keys(v).length > 0 ? v : null);
4900
- stateIdParam = external_exports.object({
4901
- id: external_exports.string().uuid()
4902
- });
4903
- listStatesQuery = external_exports.object({
4904
- hub_id: external_exports.string().uuid()
4905
- });
4906
- stateNameSchema = external_exports.string().min(1, "state_name is required").max(100, "state_name must be 100 characters or fewer").refine((v) => visibleLength(v) > 0, "state_name must not be blank");
4907
- createStateBody = external_exports.object({
4908
- hub_id: external_exports.string().uuid(),
4909
- state_slug: slugSchema,
4910
- state_name: stateNameSchema,
4911
- state_scope: external_exports.enum(["conversation", "user"]),
4912
- state_description: external_exports.string().max(1e3).nullish(),
4913
- json_schema: external_exports.record(external_exports.unknown()).default({}),
4914
- initial_value: initialValueCreateSchema,
4915
- display_order: external_exports.number().int().nonnegative().optional(),
4916
- is_enabled: external_exports.boolean().default(true),
4917
- inject_in_last_message: external_exports.boolean().default(true)
4918
- });
4919
- updateStateBody = external_exports.object({
4920
- // state_slug is immutable after first persist — not accepted here.
4921
- state_name: stateNameSchema.optional(),
4922
- state_scope: external_exports.enum(["conversation", "user"]).optional(),
4923
- state_description: external_exports.string().max(1e3).nullish(),
4924
- json_schema: external_exports.record(external_exports.unknown()).optional(),
4925
- initial_value: initialValueUpdateSchema,
4926
- display_order: external_exports.number().int().nonnegative().optional(),
4927
- is_enabled: external_exports.boolean().optional(),
4928
- inject_in_last_message: external_exports.boolean().optional()
4929
- });
4930
- reorderStatesBody = external_exports.object({
4931
- states: external_exports.array(external_exports.object({
4932
- state_id: external_exports.string().uuid(),
4933
- display_order: external_exports.number().int().nonnegative()
4934
- })).min(1)
4935
- });
4936
- }
4937
- });
4938
-
4939
- // ../../packages/core/dist/chunk-NKLVUTFO.js
4940
- var BASE_CREDENTIAL_MANAGED_BY, BASE_CREDENTIAL_NAME_MAX, BASE_CREDENTIAL_NAME_PATTERN, BASE_CREDENTIAL_NAME_CHARSET, baseCredentialNameSchema, createBaseCredentialLinkBody, baseCredentialLinkParams, baseCredentialLinkQuery;
4941
- var init_chunk_NKLVUTFO = __esm({
4942
- "../../packages/core/dist/chunk-NKLVUTFO.js"() {
4943
- "use strict";
4944
- init_zod();
4945
- BASE_CREDENTIAL_MANAGED_BY = {
4946
- DIRECT: "direct",
4947
- ORG_LINK: "org-link"
4948
- };
4949
- BASE_CREDENTIAL_NAME_MAX = 100;
4950
- BASE_CREDENTIAL_NAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._:@+~=-]*$/;
4951
- BASE_CREDENTIAL_NAME_CHARSET = "letters, digits and '. _ : @ + ~ = -', starting with a letter or digit";
4952
- baseCredentialNameSchema = external_exports.string().min(1).max(BASE_CREDENTIAL_NAME_MAX).regex(BASE_CREDENTIAL_NAME_PATTERN, `name must use ${BASE_CREDENTIAL_NAME_CHARSET}`);
4953
- createBaseCredentialLinkBody = external_exports.object({
4954
- organization_id: external_exports.string().uuid(),
4955
- base_id: external_exports.string().min(1),
4956
- /** Defaults to a slug derived from the credential's display name. */
4957
- name: baseCredentialNameSchema.optional()
4958
- });
4959
- baseCredentialLinkParams = external_exports.object({
4960
- id: external_exports.string().uuid(),
4961
- base_credential_id: external_exports.string().min(1)
4962
- });
4963
- baseCredentialLinkQuery = external_exports.object({
4964
- organization_id: external_exports.string().uuid(),
4965
- base_id: external_exports.string().min(1)
4966
- });
4967
- }
4968
- });
4969
-
4970
5107
  // ../../packages/core/dist/chunk-HZ6CADSY.js
4971
5108
  function optionalTrimmedText(max) {
4972
5109
  return external_exports.string().trim().max(max).optional().transform((value) => value ? value : void 0);
@@ -5026,6 +5163,228 @@ var init_chunk_HZ6CADSY = __esm({
5026
5163
  }
5027
5164
  });
5028
5165
 
5166
+ // ../../packages/core/dist/chunk-RACEDHG6.js
5167
+ var resourceIdParam, listResourcesQuery, createResourceBody, updateResourceBody, syncSkillsBody, resourceFileIdParam, listResourceFilesQuery, createResourceFileBody, updateResourceFileBody, uploadResourceFileBody, uploadSkillZipBody, resourceFolderIdParam, listResourceFoldersQuery, createResourceFolderBody, updateResourceFolderBody, agentResourceQuery, hubResourceQuery, linkAgentResourceBody, updateAgentResourceBody, unlinkAgentResourceQuery;
5168
+ var init_chunk_RACEDHG6 = __esm({
5169
+ "../../packages/core/dist/chunk-RACEDHG6.js"() {
5170
+ "use strict";
5171
+ init_chunk_HZ6CADSY();
5172
+ init_zod();
5173
+ resourceIdParam = external_exports.object({ id: uuidSchema });
5174
+ listResourcesQuery = external_exports.object({
5175
+ hub_id: uuidSchema,
5176
+ enabled: external_exports.enum(["true", "false"]).optional(),
5177
+ search: external_exports.string().optional(),
5178
+ limit: external_exports.string().regex(/^\d+$/).optional(),
5179
+ offset: external_exports.string().regex(/^\d+$/).optional()
5180
+ });
5181
+ createResourceBody = external_exports.object({
5182
+ hub_id: uuidSchema,
5183
+ resource_name: external_exports.string().min(1),
5184
+ resource_description: external_exports.string().optional(),
5185
+ enabled: external_exports.boolean().optional(),
5186
+ skill_name: external_exports.string().optional(),
5187
+ skill_version: external_exports.string().optional()
5188
+ });
5189
+ updateResourceBody = external_exports.object({
5190
+ resource_name: external_exports.string().min(1).optional(),
5191
+ resource_description: external_exports.string().optional(),
5192
+ enabled: external_exports.boolean().optional(),
5193
+ skill_name: external_exports.string().optional(),
5194
+ skill_version: external_exports.string().optional()
5195
+ // No `anthropic_skill_id`/`anthropic_version`: `resource` has neither column.
5196
+ // The provider link lives on `resource_provider_sync.provider_skill_id`,
5197
+ // written by `skillSync.ts` — never through this body.
5198
+ });
5199
+ syncSkillsBody = external_exports.object({
5200
+ hub_id: uuidSchema,
5201
+ connection_id: uuidSchema.optional()
5202
+ });
5203
+ resourceFileIdParam = external_exports.object({ id: uuidSchema });
5204
+ listResourceFilesQuery = external_exports.object({
5205
+ hub_id: uuidSchema,
5206
+ resource_id: uuidSchema.optional(),
5207
+ folder_id: external_exports.string().optional(),
5208
+ // 'null' for root, UUID for specific folder
5209
+ search: external_exports.string().optional(),
5210
+ tags: external_exports.string().optional(),
5211
+ // comma-separated
5212
+ enabled: external_exports.enum(["true", "false"]).optional(),
5213
+ limit: external_exports.string().regex(/^\d+$/).optional(),
5214
+ offset: external_exports.string().regex(/^\d+$/).optional(),
5215
+ include_root_files: external_exports.enum(["true", "false"]).optional()
5216
+ });
5217
+ createResourceFileBody = external_exports.object({
5218
+ hub_id: uuidSchema,
5219
+ resource_id: uuidSchema,
5220
+ file_id: uuidSchema,
5221
+ folder_id: uuidSchema.nullable().optional(),
5222
+ resource_file_title: external_exports.string().optional(),
5223
+ resource_file_tags: external_exports.array(external_exports.string()).optional(),
5224
+ order_index: external_exports.number().optional(),
5225
+ enabled: external_exports.boolean().optional(),
5226
+ metadata: external_exports.record(external_exports.unknown()).optional()
5227
+ });
5228
+ updateResourceFileBody = external_exports.object({
5229
+ resource_file_title: external_exports.string().optional(),
5230
+ resource_file_tags: external_exports.array(external_exports.string()).optional(),
5231
+ folder_id: uuidSchema.nullable().optional(),
5232
+ order_index: external_exports.number().optional(),
5233
+ enabled: external_exports.boolean().optional(),
5234
+ metadata: external_exports.record(external_exports.unknown()).optional()
5235
+ });
5236
+ uploadResourceFileBody = external_exports.object({
5237
+ hub_id: uuidSchema,
5238
+ resource_id: uuidSchema,
5239
+ folder_id: uuidSchema.nullable().optional(),
5240
+ file_name: external_exports.string().min(1),
5241
+ file_data: external_exports.string().min(1),
5242
+ mime_type: external_exports.string().optional(),
5243
+ file_size: external_exports.number().optional(),
5244
+ tags: external_exports.array(external_exports.string()).optional()
5245
+ });
5246
+ uploadSkillZipBody = external_exports.object({
5247
+ hub_id: uuidSchema,
5248
+ resource_id: uuidSchema,
5249
+ zip_data: external_exports.string().min(1),
5250
+ replace_existing: external_exports.boolean().optional()
5251
+ });
5252
+ resourceFolderIdParam = external_exports.object({ id: uuidSchema });
5253
+ listResourceFoldersQuery = external_exports.object({
5254
+ hub_id: uuidSchema,
5255
+ resource_id: uuidSchema,
5256
+ parent_folder_id: external_exports.string().optional(),
5257
+ // 'null' for root folders
5258
+ enabled: external_exports.enum(["true", "false"]).optional()
5259
+ });
5260
+ createResourceFolderBody = external_exports.object({
5261
+ hub_id: uuidSchema,
5262
+ resource_id: uuidSchema,
5263
+ folder_name: external_exports.string().min(1),
5264
+ folder_description: external_exports.string().optional(),
5265
+ parent_folder_id: uuidSchema.nullable().optional(),
5266
+ order_index: external_exports.number().optional(),
5267
+ enabled: external_exports.boolean().optional(),
5268
+ metadata: external_exports.record(external_exports.unknown()).optional()
5269
+ });
5270
+ updateResourceFolderBody = external_exports.object({
5271
+ folder_name: external_exports.string().min(1).optional(),
5272
+ folder_description: external_exports.string().optional(),
5273
+ parent_folder_id: uuidSchema.nullable().optional(),
5274
+ order_index: external_exports.number().optional(),
5275
+ enabled: external_exports.boolean().optional(),
5276
+ metadata: external_exports.record(external_exports.unknown()).optional()
5277
+ });
5278
+ agentResourceQuery = external_exports.object({
5279
+ hub_id: uuidSchema,
5280
+ agent_id: uuidSchema.optional(),
5281
+ resource_id: uuidSchema.optional()
5282
+ }).refine((data) => data.agent_id || data.resource_id, {
5283
+ message: "Either agent_id or resource_id is required"
5284
+ });
5285
+ hubResourceQuery = external_exports.object({ hub_id: uuidSchema });
5286
+ linkAgentResourceBody = external_exports.object({
5287
+ hub_id: uuidSchema,
5288
+ resource_id: uuidSchema,
5289
+ agent_id: uuidSchema,
5290
+ priority: external_exports.number().optional(),
5291
+ use_native_integration: external_exports.boolean().optional()
5292
+ });
5293
+ updateAgentResourceBody = external_exports.object({
5294
+ hub_id: uuidSchema,
5295
+ resource_id: uuidSchema,
5296
+ agent_id: uuidSchema,
5297
+ use_native_integration: external_exports.boolean().optional(),
5298
+ enabled: external_exports.boolean().optional(),
5299
+ priority: external_exports.number().optional()
5300
+ });
5301
+ unlinkAgentResourceQuery = external_exports.object({
5302
+ hub_id: uuidSchema,
5303
+ resource_id: uuidSchema,
5304
+ agent_id: uuidSchema
5305
+ });
5306
+ }
5307
+ });
5308
+
5309
+ // ../../packages/core/dist/chunk-Q7KIQHAZ.js
5310
+ var initialValueCreateSchema, initialValueUpdateSchema, stateIdParam, listStatesQuery, stateNameSchema, createStateBody, updateStateBody, reorderStatesBody;
5311
+ var init_chunk_Q7KIQHAZ = __esm({
5312
+ "../../packages/core/dist/chunk-Q7KIQHAZ.js"() {
5313
+ "use strict";
5314
+ init_chunk_6TSQ5HXC();
5315
+ init_zod();
5316
+ initialValueCreateSchema = external_exports.record(external_exports.unknown()).nullish().transform((v) => v && Object.keys(v).length > 0 ? v : null);
5317
+ initialValueUpdateSchema = external_exports.record(external_exports.unknown()).nullish().transform((v) => v === void 0 ? void 0 : v && Object.keys(v).length > 0 ? v : null);
5318
+ stateIdParam = external_exports.object({
5319
+ id: external_exports.string().uuid()
5320
+ });
5321
+ listStatesQuery = external_exports.object({
5322
+ hub_id: external_exports.string().uuid()
5323
+ });
5324
+ stateNameSchema = external_exports.string().min(1, "state_name is required").max(100, "state_name must be 100 characters or fewer").refine((v) => visibleLength(v) > 0, "state_name must not be blank");
5325
+ createStateBody = external_exports.object({
5326
+ hub_id: external_exports.string().uuid(),
5327
+ state_slug: slugSchema,
5328
+ state_name: stateNameSchema,
5329
+ state_scope: external_exports.enum(["conversation", "user"]),
5330
+ state_description: external_exports.string().max(1e3).nullish(),
5331
+ json_schema: external_exports.record(external_exports.unknown()).default({}),
5332
+ initial_value: initialValueCreateSchema,
5333
+ display_order: external_exports.number().int().nonnegative().optional(),
5334
+ is_enabled: external_exports.boolean().default(true),
5335
+ inject_in_last_message: external_exports.boolean().default(true)
5336
+ });
5337
+ updateStateBody = external_exports.object({
5338
+ // state_slug is immutable after first persist — not accepted here.
5339
+ state_name: stateNameSchema.optional(),
5340
+ state_scope: external_exports.enum(["conversation", "user"]).optional(),
5341
+ state_description: external_exports.string().max(1e3).nullish(),
5342
+ json_schema: external_exports.record(external_exports.unknown()).optional(),
5343
+ initial_value: initialValueUpdateSchema,
5344
+ display_order: external_exports.number().int().nonnegative().optional(),
5345
+ is_enabled: external_exports.boolean().optional(),
5346
+ inject_in_last_message: external_exports.boolean().optional()
5347
+ });
5348
+ reorderStatesBody = external_exports.object({
5349
+ states: external_exports.array(external_exports.object({
5350
+ state_id: external_exports.string().uuid(),
5351
+ display_order: external_exports.number().int().nonnegative()
5352
+ })).min(1)
5353
+ });
5354
+ }
5355
+ });
5356
+
5357
+ // ../../packages/core/dist/chunk-NKLVUTFO.js
5358
+ var BASE_CREDENTIAL_MANAGED_BY, BASE_CREDENTIAL_NAME_MAX, BASE_CREDENTIAL_NAME_PATTERN, BASE_CREDENTIAL_NAME_CHARSET, baseCredentialNameSchema, createBaseCredentialLinkBody, baseCredentialLinkParams, baseCredentialLinkQuery;
5359
+ var init_chunk_NKLVUTFO = __esm({
5360
+ "../../packages/core/dist/chunk-NKLVUTFO.js"() {
5361
+ "use strict";
5362
+ init_zod();
5363
+ BASE_CREDENTIAL_MANAGED_BY = {
5364
+ DIRECT: "direct",
5365
+ ORG_LINK: "org-link"
5366
+ };
5367
+ BASE_CREDENTIAL_NAME_MAX = 100;
5368
+ BASE_CREDENTIAL_NAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._:@+~=-]*$/;
5369
+ BASE_CREDENTIAL_NAME_CHARSET = "letters, digits and '. _ : @ + ~ = -', starting with a letter or digit";
5370
+ baseCredentialNameSchema = external_exports.string().min(1).max(BASE_CREDENTIAL_NAME_MAX).regex(BASE_CREDENTIAL_NAME_PATTERN, `name must use ${BASE_CREDENTIAL_NAME_CHARSET}`);
5371
+ createBaseCredentialLinkBody = external_exports.object({
5372
+ organization_id: external_exports.string().uuid(),
5373
+ base_id: external_exports.string().min(1),
5374
+ /** Defaults to a slug derived from the credential's display name. */
5375
+ name: baseCredentialNameSchema.optional()
5376
+ });
5377
+ baseCredentialLinkParams = external_exports.object({
5378
+ id: external_exports.string().uuid(),
5379
+ base_credential_id: external_exports.string().min(1)
5380
+ });
5381
+ baseCredentialLinkQuery = external_exports.object({
5382
+ organization_id: external_exports.string().uuid(),
5383
+ base_id: external_exports.string().min(1)
5384
+ });
5385
+ }
5386
+ });
5387
+
5029
5388
  // ../../packages/core/dist/chunk-MIWZOSPI.js
5030
5389
  function toIso(epochMs) {
5031
5390
  return new Date(epochMs).toISOString();
@@ -5304,149 +5663,6 @@ var init_chunk_VXEAR36B = __esm({
5304
5663
  }
5305
5664
  });
5306
5665
 
5307
- // ../../packages/core/dist/chunk-RACEDHG6.js
5308
- var resourceIdParam, listResourcesQuery, createResourceBody, updateResourceBody, syncSkillsBody, resourceFileIdParam, listResourceFilesQuery, createResourceFileBody, updateResourceFileBody, uploadResourceFileBody, uploadSkillZipBody, resourceFolderIdParam, listResourceFoldersQuery, createResourceFolderBody, updateResourceFolderBody, agentResourceQuery, hubResourceQuery, linkAgentResourceBody, updateAgentResourceBody, unlinkAgentResourceQuery;
5309
- var init_chunk_RACEDHG6 = __esm({
5310
- "../../packages/core/dist/chunk-RACEDHG6.js"() {
5311
- "use strict";
5312
- init_chunk_HZ6CADSY();
5313
- init_zod();
5314
- resourceIdParam = external_exports.object({ id: uuidSchema });
5315
- listResourcesQuery = external_exports.object({
5316
- hub_id: uuidSchema,
5317
- enabled: external_exports.enum(["true", "false"]).optional(),
5318
- search: external_exports.string().optional(),
5319
- limit: external_exports.string().regex(/^\d+$/).optional(),
5320
- offset: external_exports.string().regex(/^\d+$/).optional()
5321
- });
5322
- createResourceBody = external_exports.object({
5323
- hub_id: uuidSchema,
5324
- resource_name: external_exports.string().min(1),
5325
- resource_description: external_exports.string().optional(),
5326
- enabled: external_exports.boolean().optional(),
5327
- skill_name: external_exports.string().optional(),
5328
- skill_version: external_exports.string().optional()
5329
- });
5330
- updateResourceBody = external_exports.object({
5331
- resource_name: external_exports.string().min(1).optional(),
5332
- resource_description: external_exports.string().optional(),
5333
- enabled: external_exports.boolean().optional(),
5334
- skill_name: external_exports.string().optional(),
5335
- skill_version: external_exports.string().optional()
5336
- // No `anthropic_skill_id`/`anthropic_version`: `resource` has neither column.
5337
- // The provider link lives on `resource_provider_sync.provider_skill_id`,
5338
- // written by `skillSync.ts` — never through this body.
5339
- });
5340
- syncSkillsBody = external_exports.object({
5341
- hub_id: uuidSchema,
5342
- connection_id: uuidSchema.optional()
5343
- });
5344
- resourceFileIdParam = external_exports.object({ id: uuidSchema });
5345
- listResourceFilesQuery = external_exports.object({
5346
- hub_id: uuidSchema,
5347
- resource_id: uuidSchema.optional(),
5348
- folder_id: external_exports.string().optional(),
5349
- // 'null' for root, UUID for specific folder
5350
- search: external_exports.string().optional(),
5351
- tags: external_exports.string().optional(),
5352
- // comma-separated
5353
- enabled: external_exports.enum(["true", "false"]).optional(),
5354
- limit: external_exports.string().regex(/^\d+$/).optional(),
5355
- offset: external_exports.string().regex(/^\d+$/).optional(),
5356
- include_root_files: external_exports.enum(["true", "false"]).optional()
5357
- });
5358
- createResourceFileBody = external_exports.object({
5359
- hub_id: uuidSchema,
5360
- resource_id: uuidSchema,
5361
- file_id: uuidSchema,
5362
- folder_id: uuidSchema.nullable().optional(),
5363
- resource_file_title: external_exports.string().optional(),
5364
- resource_file_tags: external_exports.array(external_exports.string()).optional(),
5365
- order_index: external_exports.number().optional(),
5366
- enabled: external_exports.boolean().optional(),
5367
- metadata: external_exports.record(external_exports.unknown()).optional()
5368
- });
5369
- updateResourceFileBody = external_exports.object({
5370
- resource_file_title: external_exports.string().optional(),
5371
- resource_file_tags: external_exports.array(external_exports.string()).optional(),
5372
- folder_id: uuidSchema.nullable().optional(),
5373
- order_index: external_exports.number().optional(),
5374
- enabled: external_exports.boolean().optional(),
5375
- metadata: external_exports.record(external_exports.unknown()).optional()
5376
- });
5377
- uploadResourceFileBody = external_exports.object({
5378
- hub_id: uuidSchema,
5379
- resource_id: uuidSchema,
5380
- folder_id: uuidSchema.nullable().optional(),
5381
- file_name: external_exports.string().min(1),
5382
- file_data: external_exports.string().min(1),
5383
- mime_type: external_exports.string().optional(),
5384
- file_size: external_exports.number().optional(),
5385
- tags: external_exports.array(external_exports.string()).optional()
5386
- });
5387
- uploadSkillZipBody = external_exports.object({
5388
- hub_id: uuidSchema,
5389
- resource_id: uuidSchema,
5390
- zip_data: external_exports.string().min(1),
5391
- replace_existing: external_exports.boolean().optional()
5392
- });
5393
- resourceFolderIdParam = external_exports.object({ id: uuidSchema });
5394
- listResourceFoldersQuery = external_exports.object({
5395
- hub_id: uuidSchema,
5396
- resource_id: uuidSchema,
5397
- parent_folder_id: external_exports.string().optional(),
5398
- // 'null' for root folders
5399
- enabled: external_exports.enum(["true", "false"]).optional()
5400
- });
5401
- createResourceFolderBody = external_exports.object({
5402
- hub_id: uuidSchema,
5403
- resource_id: uuidSchema,
5404
- folder_name: external_exports.string().min(1),
5405
- folder_description: external_exports.string().optional(),
5406
- parent_folder_id: uuidSchema.nullable().optional(),
5407
- order_index: external_exports.number().optional(),
5408
- enabled: external_exports.boolean().optional(),
5409
- metadata: external_exports.record(external_exports.unknown()).optional()
5410
- });
5411
- updateResourceFolderBody = external_exports.object({
5412
- folder_name: external_exports.string().min(1).optional(),
5413
- folder_description: external_exports.string().optional(),
5414
- parent_folder_id: uuidSchema.nullable().optional(),
5415
- order_index: external_exports.number().optional(),
5416
- enabled: external_exports.boolean().optional(),
5417
- metadata: external_exports.record(external_exports.unknown()).optional()
5418
- });
5419
- agentResourceQuery = external_exports.object({
5420
- hub_id: uuidSchema,
5421
- agent_id: uuidSchema.optional(),
5422
- resource_id: uuidSchema.optional()
5423
- }).refine((data) => data.agent_id || data.resource_id, {
5424
- message: "Either agent_id or resource_id is required"
5425
- });
5426
- hubResourceQuery = external_exports.object({ hub_id: uuidSchema });
5427
- linkAgentResourceBody = external_exports.object({
5428
- hub_id: uuidSchema,
5429
- resource_id: uuidSchema,
5430
- agent_id: uuidSchema,
5431
- priority: external_exports.number().optional(),
5432
- use_native_integration: external_exports.boolean().optional()
5433
- });
5434
- updateAgentResourceBody = external_exports.object({
5435
- hub_id: uuidSchema,
5436
- resource_id: uuidSchema,
5437
- agent_id: uuidSchema,
5438
- use_native_integration: external_exports.boolean().optional(),
5439
- enabled: external_exports.boolean().optional(),
5440
- priority: external_exports.number().optional()
5441
- });
5442
- unlinkAgentResourceQuery = external_exports.object({
5443
- hub_id: uuidSchema,
5444
- resource_id: uuidSchema,
5445
- agent_id: uuidSchema
5446
- });
5447
- }
5448
- });
5449
-
5450
5666
  // ../../packages/core/dist/chunk-HIGKBEPF.js
5451
5667
  var accessExplainQuery;
5452
5668
  var init_chunk_HIGKBEPF = __esm({
@@ -6273,7 +6489,7 @@ var init_chunk_5FO3GNKP = __esm({
6273
6489
  }
6274
6490
  });
6275
6491
 
6276
- // ../../packages/core/dist/chunk-WWLNKL2W.js
6492
+ // ../../packages/core/dist/chunk-DWJOFJEA.js
6277
6493
  function matchPath(pattern, path45) {
6278
6494
  const pathSegments2 = path45.replace(/\/$/, "").split("/");
6279
6495
  const isPrefix = pattern.endsWith("/*");
@@ -6302,8 +6518,8 @@ function getEndpointConfig(path45) {
6302
6518
  return { tier: "STANDARD" };
6303
6519
  }
6304
6520
  var ENDPOINT_CONFIGS, EXCLUDED_PATHS;
6305
- var init_chunk_WWLNKL2W = __esm({
6306
- "../../packages/core/dist/chunk-WWLNKL2W.js"() {
6521
+ var init_chunk_DWJOFJEA = __esm({
6522
+ "../../packages/core/dist/chunk-DWJOFJEA.js"() {
6307
6523
  "use strict";
6308
6524
  init_chunk_5FO3GNKP();
6309
6525
  ENDPOINT_CONFIGS = {
@@ -6321,6 +6537,10 @@ var init_chunk_WWLNKL2W = __esm({
6321
6537
  // authenticated caller). The fail-CLOSED brute-force guarantee for the static credential comes
6322
6538
  // from the route's per-email caps (burst + cumulative hourly), not this flag.
6323
6539
  "/api/auth/password/*": { tier: "STRICT", failClosed: true },
6540
+ // Attempts at a two-step code. STRICT per IP; the routes add a per-user cap, the one that matters
6541
+ // against guessing. The status read's exact key keeps it off that budget, which sign-in shares.
6542
+ "/api/auth/second-factor": { tier: "STANDARD" },
6543
+ "/api/auth/second-factor/*": { tier: "STRICT", failClosed: true },
6324
6544
  // Every `/api/*` group whose paths carry ids pins `userLimitKey` (gh #4756), held there by
6325
6545
  // `security/endpoint-invariants.test.ts`.
6326
6546
  // Billing - moderate, fail-closed with user limits
@@ -6788,7 +7008,7 @@ var init_chunk_WWLNKL2W = __esm({
6788
7008
  }
6789
7009
  });
6790
7010
 
6791
- // ../../packages/core/dist/chunk-LQ37IULI.js
7011
+ // ../../packages/core/dist/chunk-UVGO72D6.js
6792
7012
  function fileSnapshotChanged(run) {
6793
7013
  return run.written + run.removed > 0;
6794
7014
  }
@@ -6829,10 +7049,10 @@ async function sendWithRetry(opts, cursor) {
6829
7049
  }
6830
7050
  }
6831
7051
  var rekorFileSnapshotAnswerSchema, FILE_SNAPSHOT_MAX_PAGES, FILE_SNAPSHOT_CONFLICT_ATTEMPTS, FILE_SNAPSHOT_PAGE_SPACING_MS, FILE_SNAPSHOT_CONFLICT_STATUS;
6832
- var init_chunk_LQ37IULI = __esm({
6833
- "../../packages/core/dist/chunk-LQ37IULI.js"() {
7052
+ var init_chunk_UVGO72D6 = __esm({
7053
+ "../../packages/core/dist/chunk-UVGO72D6.js"() {
6834
7054
  "use strict";
6835
- init_chunk_WWLNKL2W();
7055
+ init_chunk_DWJOFJEA();
6836
7056
  init_chunk_5FO3GNKP();
6837
7057
  init_zod();
6838
7058
  rekorFileSnapshotAnswerSchema = external_exports.object({
@@ -6998,6 +7218,101 @@ var init_chunk_IPDOHAZ5 = __esm({
6998
7218
  }
6999
7219
  });
7000
7220
 
7221
+ // ../../packages/core/dist/chunk-KEN2DASI.js
7222
+ var SECOND_FACTOR_TIERS, secondFactorTier, META_ENTITY_ID_PATTERN, metaEntityId, whatsappCallbackBody, authMeResponse, wsTicketResponse, sessionCheckResponse, logoutResponse, magicCodeSendBody, magicCodeSendResponse, magicCodeVerifyBody, magicCodeVerifyResponse, passwordLoginBody, normalizeEmail, REVIEW_ACCOUNT_EMAILS;
7223
+ var init_chunk_KEN2DASI = __esm({
7224
+ "../../packages/core/dist/chunk-KEN2DASI.js"() {
7225
+ "use strict";
7226
+ init_zod();
7227
+ SECOND_FACTOR_TIERS = ["off", "settings"];
7228
+ secondFactorTier = external_exports.enum(SECOND_FACTOR_TIERS);
7229
+ META_ENTITY_ID_PATTERN = /^\d{1,32}$/;
7230
+ metaEntityId = external_exports.string().regex(META_ENTITY_ID_PATTERN, "must be a numeric Meta entity id");
7231
+ whatsappCallbackBody = external_exports.object({
7232
+ state: external_exports.string().min(1, "state is required"),
7233
+ code: external_exports.string().optional(),
7234
+ access_token: external_exports.string().optional(),
7235
+ user_id: external_exports.string().optional(),
7236
+ /**
7237
+ * The phone number and WABA the operator actually picked in Meta's Embedded
7238
+ * Signup popup (posted to the opener as `WA_EMBEDDED_SIGNUP`). Optional:
7239
+ * older clients, and the redirect-based flow, never see that event and fall
7240
+ * back to discovery.
7241
+ */
7242
+ phone_number_id: metaEntityId.optional(),
7243
+ waba_id: metaEntityId.optional()
7244
+ }).refine(
7245
+ (data) => !!data.access_token || !!data.code,
7246
+ { message: "Missing required parameters: state and either access_token or code" }
7247
+ );
7248
+ authMeResponse = external_exports.object({
7249
+ user_id: external_exports.string(),
7250
+ email: external_exports.string(),
7251
+ org_id: external_exports.string().nullable(),
7252
+ is_platform_admin: external_exports.boolean()
7253
+ });
7254
+ wsTicketResponse = external_exports.object({
7255
+ ticket: external_exports.string(),
7256
+ /** Seconds until the ticket expires if unconsumed. */
7257
+ expires_in: external_exports.number()
7258
+ });
7259
+ sessionCheckResponse = external_exports.object({
7260
+ valid: external_exports.literal(true)
7261
+ });
7262
+ logoutResponse = external_exports.object({
7263
+ success: external_exports.literal(true)
7264
+ });
7265
+ magicCodeSendBody = external_exports.object({
7266
+ email: external_exports.string().email("Invalid email").max(254)
7267
+ // RFC 5321 max; bounds the request payload
7268
+ });
7269
+ magicCodeSendResponse = external_exports.object({
7270
+ success: external_exports.literal(true)
7271
+ });
7272
+ magicCodeVerifyBody = external_exports.object({
7273
+ email: external_exports.string().email("Invalid email").max(254),
7274
+ // RFC 5321 max; bounds the request payload
7275
+ code: external_exports.string().min(1, "Code is required").max(12)
7276
+ // WorkOS sends a 6-digit code; bound the input
7277
+ });
7278
+ magicCodeVerifyResponse = external_exports.object({
7279
+ access_token: external_exports.string(),
7280
+ refresh_token: external_exports.string()
7281
+ });
7282
+ passwordLoginBody = external_exports.object({
7283
+ email: external_exports.string().email("Invalid email").max(254),
7284
+ // RFC 5321 max; bounds the request payload
7285
+ password: external_exports.string().min(1, "Password is required").max(128)
7286
+ // bound the payload; WorkOS validates
7287
+ });
7288
+ normalizeEmail = (email) => email.trim().toLowerCase();
7289
+ REVIEW_ACCOUNT_EMAILS = new Set(
7290
+ ["apple.review@wayai.pro", "play.review@wayai.pro", "microsoft.review@wayai.pro", "meta.review@wayai.pro"].map(
7291
+ normalizeEmail
7292
+ )
7293
+ );
7294
+ }
7295
+ });
7296
+
7297
+ // ../../packages/core/dist/chunk-PFGVH2CX.js
7298
+ var secondFactorCode, secondFactorRecoveryCode, secondFactorCodeBody, secondFactorRecoveryBody, secondFactorDisableBody, setOrgSecondFactorBody;
7299
+ var init_chunk_PFGVH2CX = __esm({
7300
+ "../../packages/core/dist/chunk-PFGVH2CX.js"() {
7301
+ "use strict";
7302
+ init_chunk_KEN2DASI();
7303
+ init_zod();
7304
+ secondFactorCode = external_exports.string().regex(/^\d{6}$/, "Enter the 6-digit code");
7305
+ secondFactorRecoveryCode = external_exports.string().min(1, "Enter a recovery code").max(64);
7306
+ secondFactorCodeBody = external_exports.object({ code: secondFactorCode });
7307
+ secondFactorRecoveryBody = external_exports.object({ recovery_code: secondFactorRecoveryCode });
7308
+ secondFactorDisableBody = external_exports.union([
7309
+ external_exports.object({ code: secondFactorCode, recovery_code: external_exports.undefined().optional() }),
7310
+ external_exports.object({ recovery_code: secondFactorRecoveryCode, code: external_exports.undefined().optional() })
7311
+ ]);
7312
+ setOrgSecondFactorBody = external_exports.object({ tier: secondFactorTier });
7313
+ }
7314
+ });
7315
+
7001
7316
  // ../../packages/core/dist/chunk-GPM7PE44.js
7002
7317
  var bootstrapQuery;
7003
7318
  var init_chunk_GPM7PE44 = __esm({
@@ -15796,82 +16111,6 @@ var init_chunk_UEJOG2Q7 = __esm({
15796
16111
  }
15797
16112
  });
15798
16113
 
15799
- // ../../packages/core/dist/chunk-AD7U6ICB.js
15800
- var SECOND_FACTOR_TIERS, secondFactorTier, META_ENTITY_ID_PATTERN, metaEntityId, whatsappCallbackBody, authMeResponse, wsTicketResponse, sessionCheckResponse, logoutResponse, magicCodeSendBody, magicCodeSendResponse, magicCodeVerifyBody, magicCodeVerifyResponse, passwordLoginBody, normalizeEmail, REVIEW_ACCOUNT_EMAILS;
15801
- var init_chunk_AD7U6ICB = __esm({
15802
- "../../packages/core/dist/chunk-AD7U6ICB.js"() {
15803
- "use strict";
15804
- init_zod();
15805
- SECOND_FACTOR_TIERS = ["off", "settings"];
15806
- secondFactorTier = external_exports.enum(SECOND_FACTOR_TIERS);
15807
- META_ENTITY_ID_PATTERN = /^\d{1,32}$/;
15808
- metaEntityId = external_exports.string().regex(META_ENTITY_ID_PATTERN, "must be a numeric Meta entity id");
15809
- whatsappCallbackBody = external_exports.object({
15810
- state: external_exports.string().min(1, "state is required"),
15811
- code: external_exports.string().optional(),
15812
- access_token: external_exports.string().optional(),
15813
- user_id: external_exports.string().optional(),
15814
- /**
15815
- * The phone number and WABA the operator actually picked in Meta's Embedded
15816
- * Signup popup (posted to the opener as `WA_EMBEDDED_SIGNUP`). Optional:
15817
- * older clients, and the redirect-based flow, never see that event and fall
15818
- * back to discovery.
15819
- */
15820
- phone_number_id: metaEntityId.optional(),
15821
- waba_id: metaEntityId.optional()
15822
- }).refine(
15823
- (data) => !!data.access_token || !!data.code,
15824
- { message: "Missing required parameters: state and either access_token or code" }
15825
- );
15826
- authMeResponse = external_exports.object({
15827
- user_id: external_exports.string(),
15828
- email: external_exports.string(),
15829
- org_id: external_exports.string().nullable(),
15830
- is_platform_admin: external_exports.boolean()
15831
- });
15832
- wsTicketResponse = external_exports.object({
15833
- ticket: external_exports.string(),
15834
- /** Seconds until the ticket expires if unconsumed. */
15835
- expires_in: external_exports.number()
15836
- });
15837
- sessionCheckResponse = external_exports.object({
15838
- valid: external_exports.literal(true)
15839
- });
15840
- logoutResponse = external_exports.object({
15841
- success: external_exports.literal(true)
15842
- });
15843
- magicCodeSendBody = external_exports.object({
15844
- email: external_exports.string().email("Invalid email").max(254)
15845
- // RFC 5321 max; bounds the request payload
15846
- });
15847
- magicCodeSendResponse = external_exports.object({
15848
- success: external_exports.literal(true)
15849
- });
15850
- magicCodeVerifyBody = external_exports.object({
15851
- email: external_exports.string().email("Invalid email").max(254),
15852
- // RFC 5321 max; bounds the request payload
15853
- code: external_exports.string().min(1, "Code is required").max(12)
15854
- // WorkOS sends a 6-digit code; bound the input
15855
- });
15856
- magicCodeVerifyResponse = external_exports.object({
15857
- access_token: external_exports.string(),
15858
- refresh_token: external_exports.string()
15859
- });
15860
- passwordLoginBody = external_exports.object({
15861
- email: external_exports.string().email("Invalid email").max(254),
15862
- // RFC 5321 max; bounds the request payload
15863
- password: external_exports.string().min(1, "Password is required").max(128)
15864
- // bound the payload; WorkOS validates
15865
- });
15866
- normalizeEmail = (email) => email.trim().toLowerCase();
15867
- REVIEW_ACCOUNT_EMAILS = new Set(
15868
- ["apple.review@wayai.pro", "play.review@wayai.pro", "microsoft.review@wayai.pro", "meta.review@wayai.pro"].map(
15869
- normalizeEmail
15870
- )
15871
- );
15872
- }
15873
- });
15874
-
15875
16114
  // ../../packages/core/dist/chunk-R6Y377AW.js
15876
16115
  function filterNamesAnything(filter) {
15877
16116
  return filter.labels.length + filter.scope_tag_ids.length > 0;
@@ -16142,221 +16381,16 @@ var init_chunk_B6PT7ZSX = __esm({
16142
16381
  }
16143
16382
  });
16144
16383
 
16145
- // ../../packages/core/dist/chunk-WFQDSQJK.js
16146
- function isPublicIdentifier(value) {
16147
- return UUID_RE.test(value) || HEX_RE.test(value) || WORKOS_ID_RE.test(value) || TRACE_HEADER_RE.test(value);
16148
- }
16149
- function redactTokenShapes(input) {
16150
- return input.replace(FILE_URL_TOKEN_RE, REDACTED).replace(TOKEN_RE, REDACTED).replace(PROVIDER_TOKEN_RE, `$1${REDACTED}`).replace(JSON_CREDENTIAL_RE, `$1"${REDACTED}"`).replace(QUERY_CREDENTIAL_RE, `$1${REDACTED}`);
16151
- }
16152
- function redactSecrets(value) {
16153
- if (isPublicIdentifier(value)) {
16154
- return value;
16155
- }
16156
- if (OPAQUE_SECRET_RE.test(value)) {
16157
- return REDACTED;
16158
- }
16159
- if (BASE64_SECRET_RE.test(value) && BASE64_MARKER_RE.test(value)) {
16160
- return REDACTED;
16161
- }
16162
- return redactTokenShapes(value);
16163
- }
16164
- var UUID_RE, HEX_RE, WORKOS_ID_RE, TRACE_HEADER_RE, OPAQUE_SECRET_RE, BASE64_SECRET_RE, BASE64_MARKER_RE, TOKEN_RE, SENSITIVE_FIELDS, SENSITIVE_KEY_ALTERNATION, SENSITIVE_KEY_PATTERN, JSON_CREDENTIAL_RE, QUERY_CREDENTIAL_RE, REDACTED, PROVIDER_TOKEN_RE, FILE_URL_TOKEN_RE;
16165
- var init_chunk_WFQDSQJK = __esm({
16166
- "../../packages/core/dist/chunk-WFQDSQJK.js"() {
16167
- "use strict";
16168
- UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
16169
- HEX_RE = /^[0-9a-f]{16,}$/;
16170
- WORKOS_ID_RE = /^(?:user|org)_[0-9A-HJKMNP-TV-Z]{26}$/;
16171
- TRACE_HEADER_RE = /^(?:[0-9a-f]{2}-[0-9a-f]{32}-[0-9a-f]{16}-[0-9a-f]{2}|[0-9a-f]{32}-[0-9a-f]{16}(?:-[01])?)$/;
16172
- OPAQUE_SECRET_RE = /^[A-Za-z0-9_-]{21,}$/;
16173
- BASE64_SECRET_RE = /^[A-Za-z0-9+/]{20,}={0,2}$/;
16174
- BASE64_MARKER_RE = /[+=]/;
16175
- TOKEN_RE = new RegExp(
16176
- [
16177
- // WayAI API tokens and WebSocket tickets.
16178
- "(?:way|wst)_[A-Za-z0-9._-]{8,}",
16179
- // Authorization header values, including base64 Basic credentials.
16180
- "(?:Bearer|Basic)\\s+[A-Za-z0-9._~+/=-]{8,}",
16181
- // JWTs — WorkOS session/access tokens. `eyJ` is base64 for `{"`.
16182
- "eyJ[A-Za-z0-9._-]{10,}",
16183
- // Stripe secret/publishable/restricted keys and webhook signing secrets.
16184
- "(?:sk|pk|rk)_(?:live|test)_[A-Za-z0-9]{8,}",
16185
- "whsec_[A-Za-z0-9]{8,}",
16186
- // Telegram bot tokens as the Bot API takes them, in the URL path: `/bot<id>:<secret>/`.
16187
- "bot[0-9]{5,}:[A-Za-z0-9_-]{30,}"
16188
- // NOTE: LLM provider keys are NOT here — they need a delimiter-preserving
16189
- // boundary, so they live in PROVIDER_TOKEN_RE below.
16190
- ].join("|"),
16191
- "g"
16192
- );
16193
- SENSITIVE_FIELDS = [
16194
- "password",
16195
- "token",
16196
- "secret",
16197
- "api_key",
16198
- "apikey",
16199
- "api-key",
16200
- "authorization",
16201
- "auth",
16202
- "credential",
16203
- "private_key",
16204
- "privatekey",
16205
- "access_token",
16206
- "refresh_token",
16207
- "session_id",
16208
- "sessionid",
16209
- "cookie",
16210
- "jwt"
16211
- ];
16212
- SENSITIVE_KEY_ALTERNATION = SENSITIVE_FIELDS.map(
16213
- (field) => field.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")
16214
- ).join("|");
16215
- SENSITIVE_KEY_PATTERN = `[A-Za-z0-9_.-]*(?:${SENSITIVE_KEY_ALTERNATION})[A-Za-z0-9_.-]*`;
16216
- JSON_CREDENTIAL_RE = new RegExp(
16217
- `("${SENSITIVE_KEY_PATTERN}"\\s*:\\s*)"(?:[^"\\\\]|\\\\.)*"`,
16218
- "gi"
16219
- );
16220
- QUERY_CREDENTIAL_RE = new RegExp(
16221
- `((?:^|[?&#;\\s])${SENSITIVE_KEY_PATTERN}=)[^&;\\s"']+`,
16222
- "gi"
16223
- );
16224
- REDACTED = "[REDACTED]";
16225
- PROVIDER_TOKEN_RE = new RegExp(
16226
- "(^|[^A-Za-z0-9])(?:" + [
16227
- "sk-[A-Za-z0-9_-]{16,}",
16228
- "AIza[A-Za-z0-9_-]{16,}",
16229
- "xai-[A-Za-z0-9_-]{16,}"
16230
- ].join("|") + ")",
16231
- "g"
16232
- );
16233
- FILE_URL_TOKEN_RE = /v[0-9]+\.[gp]\.[0-9]+\.[A-Za-z0-9_-]{43}\.[A-Za-z0-9_-]{43}/g;
16234
- }
16235
- });
16236
-
16237
- // ../../packages/core/dist/chunk-HLOSHCSS.js
16238
- var APP_ERROR_BRAND, AppError, PAGE_CUSTOMER_UNAVAILABLE_CODE, LLM_RATE_LIMIT_BRAND, LlmRateLimitError, LLM_PROVIDER_HTTP_BRAND, LlmProviderHttpError, LLM_PROVIDER_CONTENT_BRAND, LlmProviderContentError, LLM_PROVIDER_TIMEOUT_BRAND, LlmProviderTimeoutError, ExternalServiceError, CHANNEL_PROVIDER_HTTP_BRAND, ChannelProviderHttpError, MEDIA_PROVIDER_HTTP_BRAND, MediaProviderHttpError;
16239
- var init_chunk_HLOSHCSS = __esm({
16240
- "../../packages/core/dist/chunk-HLOSHCSS.js"() {
16241
- "use strict";
16242
- init_chunk_WFQDSQJK();
16243
- APP_ERROR_BRAND = /* @__PURE__ */ Symbol.for("wayai.AppError");
16244
- AppError = class extends Error {
16245
- constructor(message, code, statusCode = 500, details) {
16246
- super(message);
16247
- this.code = code;
16248
- this.statusCode = statusCode;
16249
- this.details = details;
16250
- this.name = "AppError";
16251
- }
16252
- [APP_ERROR_BRAND] = true;
16253
- toJSON() {
16254
- return {
16255
- error: this.code,
16256
- message: this.message,
16257
- ...this.details && { details: this.details }
16258
- };
16259
- }
16260
- };
16261
- PAGE_CUSTOMER_UNAVAILABLE_CODE = "PAGE_CUSTOMER_UNAVAILABLE";
16262
- LLM_RATE_LIMIT_BRAND = /* @__PURE__ */ Symbol.for("wayai.LlmRateLimitError");
16263
- LlmRateLimitError = class extends Error {
16264
- constructor(provider, retryAfterMs) {
16265
- super(`${provider} rate limited; retry after ${retryAfterMs}ms`);
16266
- this.provider = provider;
16267
- this.retryAfterMs = retryAfterMs;
16268
- this.name = "LlmRateLimitError";
16269
- }
16270
- [LLM_RATE_LIMIT_BRAND] = true;
16271
- };
16272
- LLM_PROVIDER_HTTP_BRAND = /* @__PURE__ */ Symbol.for("wayai.LlmProviderHttpError");
16273
- LlmProviderHttpError = class extends Error {
16274
- constructor(message, status, provider, providerError) {
16275
- super(redactSecrets(message));
16276
- this.status = status;
16277
- this.provider = provider;
16278
- this.providerError = providerError;
16279
- this.name = "LlmProviderHttpError";
16280
- }
16281
- [LLM_PROVIDER_HTTP_BRAND] = true;
16282
- };
16283
- LLM_PROVIDER_CONTENT_BRAND = /* @__PURE__ */ Symbol.for("wayai.LlmProviderContentError");
16284
- LlmProviderContentError = class extends Error {
16285
- constructor(message, provider, providerError) {
16286
- super(redactSecrets(message));
16287
- this.provider = provider;
16288
- this.providerError = providerError;
16289
- this.name = "LlmProviderContentError";
16290
- }
16291
- [LLM_PROVIDER_CONTENT_BRAND] = true;
16292
- };
16293
- LLM_PROVIDER_TIMEOUT_BRAND = /* @__PURE__ */ Symbol.for("wayai.LlmProviderTimeoutError");
16294
- LlmProviderTimeoutError = class extends Error {
16295
- constructor(message, provider) {
16296
- super(message);
16297
- this.provider = provider;
16298
- this.name = "LlmProviderTimeoutError";
16299
- }
16300
- [LLM_PROVIDER_TIMEOUT_BRAND] = true;
16301
- };
16302
- ExternalServiceError = class extends AppError {
16303
- constructor(service, originalError) {
16304
- super(`External service error: ${service}`, "EXTERNAL_SERVICE_ERROR", 502, {
16305
- service,
16306
- originalMessage: originalError?.message
16307
- });
16308
- this.name = "ExternalServiceError";
16309
- }
16310
- };
16311
- CHANNEL_PROVIDER_HTTP_BRAND = /* @__PURE__ */ Symbol.for("wayai.ChannelProviderHttpError");
16312
- ChannelProviderHttpError = class extends ExternalServiceError {
16313
- [CHANNEL_PROVIDER_HTTP_BRAND] = true;
16314
- status;
16315
- provider;
16316
- /** Provider numeric error code (Meta `error.code`) — body-free. */
16317
- providerCode;
16318
- /** Provider numeric error subcode (Meta `error.error_subcode`) — body-free. */
16319
- providerSubcode;
16320
- constructor(provider, status, providerCode, providerSubcode) {
16321
- super(provider);
16322
- this.name = "ChannelProviderHttpError";
16323
- this.status = status;
16324
- this.provider = provider;
16325
- this.providerCode = providerCode;
16326
- this.providerSubcode = providerSubcode;
16327
- }
16328
- };
16329
- MEDIA_PROVIDER_HTTP_BRAND = /* @__PURE__ */ Symbol.for("wayai.MediaProviderHttpError");
16330
- MediaProviderHttpError = class extends Error {
16331
- constructor(provider, status, options = {}) {
16332
- super(`${provider} API error (${status})`);
16333
- this.provider = provider;
16334
- this.status = status;
16335
- this.name = "MediaProviderHttpError";
16336
- this.credentialRejected = options.credentialRejected ?? false;
16337
- }
16338
- [MEDIA_PROVIDER_HTTP_BRAND] = true;
16339
- /**
16340
- * The provider said the credential itself was rejected, under a status that does not say so
16341
- * (Google answers an invalid or expired key with 400 `API_KEY_INVALID`, not 401). Read off
16342
- * the body at the throw site, which carries only this flag on. Alerting keys on it so the
16343
- * admin is told to re-enter the key, not that the key is fine.
16344
- */
16345
- credentialRejected;
16346
- };
16347
- }
16348
- });
16349
-
16350
16384
  // ../../packages/core/dist/contracts/index.js
16351
16385
  var init_contracts = __esm({
16352
16386
  "../../packages/core/dist/contracts/index.js"() {
16353
16387
  "use strict";
16388
+ init_chunk_RACEDHG6();
16354
16389
  init_chunk_Q7KIQHAZ();
16355
16390
  init_chunk_NKLVUTFO();
16356
16391
  init_chunk_WL5QGKHN();
16357
16392
  init_chunk_YVY2TZK2();
16358
16393
  init_chunk_VXEAR36B();
16359
- init_chunk_RACEDHG6();
16360
16394
  init_chunk_HIGKBEPF();
16361
16395
  init_chunk_HA7CRZMX();
16362
16396
  init_chunk_MF2VVXBR();
@@ -16365,8 +16399,9 @@ var init_contracts = __esm({
16365
16399
  init_chunk_5YNUTCJ2();
16366
16400
  init_chunk_ZC6YGHNX();
16367
16401
  init_chunk_5DGHIY7L();
16368
- init_chunk_LQ37IULI();
16402
+ init_chunk_UVGO72D6();
16369
16403
  init_chunk_IPDOHAZ5();
16404
+ init_chunk_PFGVH2CX();
16370
16405
  init_chunk_GPM7PE44();
16371
16406
  init_chunk_NZ6RQW6R();
16372
16407
  init_chunk_2DXRB6DR();
@@ -16419,14 +16454,14 @@ var init_contracts = __esm({
16419
16454
  init_chunk_K5UAZWFF();
16420
16455
  init_chunk_2PZIF56U();
16421
16456
  init_chunk_UEJOG2Q7();
16422
- init_chunk_AD7U6ICB();
16457
+ init_chunk_KEN2DASI();
16423
16458
  init_chunk_ELBFOFQD();
16424
16459
  init_chunk_R6Y377AW();
16425
16460
  init_chunk_UAOHHCW5();
16426
16461
  init_chunk_FGNMHILL();
16427
16462
  init_chunk_IG6QBZMA();
16428
16463
  init_chunk_OMPT4ZHR();
16429
- init_chunk_WWLNKL2W();
16464
+ init_chunk_DWJOFJEA();
16430
16465
  init_chunk_SOJMWM63();
16431
16466
  init_chunk_WTOA3ANF();
16432
16467
  init_chunk_5FO3GNKP();
@@ -16453,7 +16488,7 @@ var init_contracts = __esm({
16453
16488
  init_chunk_MIWZOSPI();
16454
16489
  init_chunk_YROEDMVZ();
16455
16490
  init_chunk_L5F7ZOUJ();
16456
- init_chunk_HLOSHCSS();
16491
+ init_chunk_ICYO56QW();
16457
16492
  init_chunk_WFQDSQJK();
16458
16493
  }
16459
16494
  });
@@ -16590,7 +16625,7 @@ var UUID_RE2, WAYAI_WORKSPACE_LAYOUT;
16590
16625
  var init_dist = __esm({
16591
16626
  "../../packages/core/dist/index.js"() {
16592
16627
  "use strict";
16593
- init_chunk_WWLNKL2W();
16628
+ init_chunk_DWJOFJEA();
16594
16629
  init_chunk_SOJMWM63();
16595
16630
  init_chunk_WTOA3ANF();
16596
16631
  init_chunk_5FO3GNKP();
@@ -16616,7 +16651,7 @@ var init_dist = __esm({
16616
16651
  init_chunk_MIWZOSPI();
16617
16652
  init_chunk_YROEDMVZ();
16618
16653
  init_chunk_L5F7ZOUJ();
16619
- init_chunk_HLOSHCSS();
16654
+ init_chunk_ICYO56QW();
16620
16655
  init_chunk_WFQDSQJK();
16621
16656
  UUID_RE2 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
16622
16657
  WAYAI_WORKSPACE_LAYOUT = {
@@ -17706,6 +17741,7 @@ var init_utils = __esm({
17706
17741
  ["logout", { positionals: 0 }],
17707
17742
  ["status", { positionals: 0 }],
17708
17743
  ["whoami", { positionals: 0 }],
17744
+ ["2fa", "all"],
17709
17745
  ["init", { positionals: 0, values: ["--org"] }],
17710
17746
  ["create", { positionals: 1, values: ["--label"] }],
17711
17747
  ["diff", { positionals: 0, values: ["--hub"] }],
@@ -17804,6 +17840,7 @@ var init_utils = __esm({
17804
17840
  ["admin archive", { positionals: 2, values: ["--message-id"] }],
17805
17841
  ["admin observability", { positionals: 2, values: ["--message-id"] }],
17806
17842
  ["admin do tables", { positionals: 2 }],
17843
+ ["admin second-factor-reset", { positionals: 1 }],
17807
17844
  ["admin do read", { positionals: 3, values: ["--limit", "--id"] }],
17808
17845
  ["admin do counts", { positionals: 2 }],
17809
17846
  ["admin analytics tables", { positionals: 0 }],
@@ -18616,6 +18653,15 @@ var init_api_client = __esm({
18616
18653
  async me() {
18617
18654
  return this.request("GET", "/api/auth/me");
18618
18655
  }
18656
+ async verifySecondFactor(code) {
18657
+ return this.request("POST", "/api/auth/second-factor/verify", { code });
18658
+ }
18659
+ async useSecondFactorRecoveryCode(recoveryCode) {
18660
+ return this.request("POST", "/api/auth/second-factor/recovery", { recovery_code: recoveryCode });
18661
+ }
18662
+ async resetUserSecondFactor(userId) {
18663
+ return this.request("POST", `/api/admin/second-factor/${encodeURIComponent(userId)}/reset`);
18664
+ }
18619
18665
  async syncSkills(hubId, connectionId) {
18620
18666
  return this.request("POST", "/api/setup/skills/sync-skills", {
18621
18667
  hub_id: hubId,
@@ -19332,6 +19378,13 @@ function friendlyHint(err) {
19332
19378
  return "Couldn't reach WayAI \u2014 check your network connection and try again.";
19333
19379
  }
19334
19380
  if (!(err instanceof ApiError)) return null;
19381
+ const code = extractApiErrorCode(err);
19382
+ if (code === SECOND_FACTOR_REQUIRED_CODE) {
19383
+ return "This action needs a two-step verification code. Run `wayai 2fa verify`, then try again.";
19384
+ }
19385
+ if (code === SECOND_FACTOR_ENROLLMENT_REQUIRED_CODE) {
19386
+ return "This organization requires two-step verification. Turn it on in your WayAI account settings, then try again.";
19387
+ }
19335
19388
  if (err.body.includes("FREE_PLAN_RESTRICTION")) {
19336
19389
  return "Publishing to production requires a paid plan. Upgrade your organization to publish or sync.";
19337
19390
  }
@@ -19345,9 +19398,10 @@ function friendlyHint(err) {
19345
19398
  if (status >= 500) return "WayAI server error \u2014 likely temporary. Try again shortly.";
19346
19399
  return null;
19347
19400
  }
19348
- var init_errors2 = __esm({
19401
+ var init_errors3 = __esm({
19349
19402
  "src/lib/errors.ts"() {
19350
19403
  "use strict";
19404
+ init_errors();
19351
19405
  init_api_client();
19352
19406
  init_network_error();
19353
19407
  }
@@ -20357,6 +20411,43 @@ var init_skill_symlink = __esm({
20357
20411
  }
20358
20412
  });
20359
20413
 
20414
+ // src/commands/second-factor.ts
20415
+ var second_factor_exports = {};
20416
+ __export(second_factor_exports, {
20417
+ parseArgs: () => parseArgs,
20418
+ secondFactorCommand: () => secondFactorCommand
20419
+ });
20420
+ function parseArgs(args2) {
20421
+ const positional = args2.filter((arg) => !arg.startsWith("--"));
20422
+ return {
20423
+ subcommand: positional[0],
20424
+ recovery: args2.includes("--recovery"),
20425
+ value: positional[1],
20426
+ unknownFlag: args2.find((arg) => arg.startsWith("--") && arg !== "--recovery")
20427
+ };
20428
+ }
20429
+ async function secondFactorCommand(args2) {
20430
+ const { subcommand, recovery, value, unknownFlag } = parseArgs(args2);
20431
+ if (subcommand !== "verify" || unknownFlag) {
20432
+ console.error("Usage: wayai 2fa verify [code] [--recovery]");
20433
+ process.exit(1);
20434
+ }
20435
+ const { config, accessToken } = await requireAuth();
20436
+ const client = new ApiClient({ apiUrl: config.api_url, accessToken });
20437
+ const entered = (value ?? await prompt(recovery ? "Recovery code: " : "6-digit code: ")).trim();
20438
+ if (recovery) await client.useSecondFactorRecoveryCode(entered);
20439
+ else await client.verifySecondFactor(entered);
20440
+ console.log("Verified. You can run the command again now.");
20441
+ }
20442
+ var init_second_factor = __esm({
20443
+ "src/commands/second-factor.ts"() {
20444
+ "use strict";
20445
+ init_auth();
20446
+ init_api_client();
20447
+ init_utils();
20448
+ }
20449
+ });
20450
+
20360
20451
  // src/lib/report-inbox.ts
20361
20452
  async function nudgeReportActions(apiUrl, accessToken) {
20362
20453
  if (!process.stdout.isTTY || process.env.CI) return;
@@ -20884,10 +20975,10 @@ var init_worktree_scope = __esm({
20884
20975
  // src/commands/status.ts
20885
20976
  var status_exports = {};
20886
20977
  __export(status_exports, {
20887
- parseArgs: () => parseArgs,
20978
+ parseArgs: () => parseArgs2,
20888
20979
  statusCommand: () => statusCommand
20889
20980
  });
20890
- function parseArgs(args2) {
20981
+ function parseArgs2(args2) {
20891
20982
  return { json: args2.includes("--json") };
20892
20983
  }
20893
20984
  function buildSkillState() {
@@ -20918,7 +21009,7 @@ function buildWorkspaceState(resolved) {
20918
21009
  return { scoped: true, path: resolved.path, hub_count: hubCount };
20919
21010
  }
20920
21011
  async function statusCommand(args2, pkg2) {
20921
- const { json } = parseArgs(args2);
21012
+ const { json } = parseArgs2(args2);
20922
21013
  const config = readConfig();
20923
21014
  const resolvedRepo = resolveRepoConfig();
20924
21015
  const repoConfig = resolvedRepo?.config ?? null;
@@ -21077,14 +21168,14 @@ var init_status = __esm({
21077
21168
  // src/commands/whoami.ts
21078
21169
  var whoami_exports = {};
21079
21170
  __export(whoami_exports, {
21080
- parseArgs: () => parseArgs2,
21171
+ parseArgs: () => parseArgs3,
21081
21172
  whoamiCommand: () => whoamiCommand
21082
21173
  });
21083
- function parseArgs2(args2) {
21174
+ function parseArgs3(args2) {
21084
21175
  return { json: args2.includes("--json") };
21085
21176
  }
21086
21177
  async function whoamiCommand(args2) {
21087
- const { json } = parseArgs2(args2);
21178
+ const { json } = parseArgs3(args2);
21088
21179
  const { config, accessToken } = await requireAuth();
21089
21180
  const client = new ApiClient({ apiUrl: config.api_url, accessToken });
21090
21181
  const me = await client.me();
@@ -21122,7 +21213,7 @@ __export(init_exports, {
21122
21213
  SKILL_INSTALL_CMD: () => SKILL_INSTALL_CMD,
21123
21214
  ensureHubsDir: () => ensureHubsDir,
21124
21215
  initCommand: () => initCommand,
21125
- parseArgs: () => parseArgs3
21216
+ parseArgs: () => parseArgs4
21126
21217
  });
21127
21218
  import { mkdirSync as mkdirSync6 } from "fs";
21128
21219
  import path12 from "path";
@@ -21132,7 +21223,7 @@ function ensureHubsDir(gitRoot) {
21132
21223
  mkdirSync6(hubsDir, { recursive: true });
21133
21224
  return `${path12.relative(gitRoot, hubsDir)}/`;
21134
21225
  }
21135
- function parseArgs3(args2) {
21226
+ function parseArgs4(args2) {
21136
21227
  let orgId;
21137
21228
  let autoConfirm = false;
21138
21229
  const orgIdx = args2.indexOf("--org");
@@ -21147,7 +21238,7 @@ function parseArgs3(args2) {
21147
21238
  return { orgId, autoConfirm };
21148
21239
  }
21149
21240
  async function initCommand(args2) {
21150
- const { orgId: directOrgId, autoConfirm } = parseArgs3(args2);
21241
+ const { orgId: directOrgId, autoConfirm } = parseArgs4(args2);
21151
21242
  const existing = readRepoConfig();
21152
21243
  if (existing) {
21153
21244
  const scopeLabel = existing.organization_name ? `${existing.organization_name} (${existing.organization_id})` : existing.organization_id;
@@ -21682,7 +21773,7 @@ var init_pages = __esm({
21682
21773
  init_chunk_FBV7NLKO();
21683
21774
  init_chunk_WEXVYJ5H();
21684
21775
  init_chunk_HZ6CADSY();
21685
- init_chunk_HLOSHCSS();
21776
+ init_chunk_ICYO56QW();
21686
21777
  init_chunk_WFQDSQJK();
21687
21778
  }
21688
21779
  });
@@ -22807,7 +22898,7 @@ var init_ci = __esm({
22807
22898
  init_chunk_MIWZOSPI();
22808
22899
  init_chunk_YROEDMVZ();
22809
22900
  init_chunk_L5F7ZOUJ();
22810
- init_chunk_HLOSHCSS();
22901
+ init_chunk_ICYO56QW();
22811
22902
  init_chunk_WFQDSQJK();
22812
22903
  }
22813
22904
  });
@@ -24246,7 +24337,7 @@ __export(sync_exports, {
24246
24337
  pushBase: () => pushBase
24247
24338
  });
24248
24339
  import * as path25 from "path";
24249
- function parseArgs4(args2) {
24340
+ function parseArgs5(args2) {
24250
24341
  return {
24251
24342
  autoConfirm: args2.includes("--yes") || args2.includes("-y"),
24252
24343
  dryRun: args2.includes("--dry-run"),
@@ -24281,7 +24372,7 @@ async function mirrorLinkedProduction(client, basesDir, originId) {
24281
24372
  }
24282
24373
  }
24283
24374
  async function pullBase(gitRootOrNull, selector, args2) {
24284
- const { autoConfirm } = parseArgs4(args2);
24375
+ const { autoConfirm } = parseArgs5(args2);
24285
24376
  const gitRoot = requireGitRoot(gitRootOrNull);
24286
24377
  const target = resolveBaseTarget(gitRoot, selector);
24287
24378
  const basesDir = resolveBasesDir(gitRoot);
@@ -24366,7 +24457,7 @@ async function createDeclaredPreview(client, target, parsed, autoConfirm) {
24366
24457
  return id;
24367
24458
  }
24368
24459
  async function pushBase(gitRootOrNull, selector, args2) {
24369
- const { autoConfirm, dryRun, prune } = parseArgs4(args2);
24460
+ const { autoConfirm, dryRun, prune } = parseArgs5(args2);
24370
24461
  const gitRoot = requireGitRoot(gitRootOrNull);
24371
24462
  const target = resolveBaseTarget(gitRoot, selector);
24372
24463
  if (!target.exists) {
@@ -24598,7 +24689,7 @@ var init_eval_session_control = __esm({
24598
24689
  "src/lib/eval-session-control.ts"() {
24599
24690
  "use strict";
24600
24691
  init_api_client();
24601
- init_errors2();
24692
+ init_errors3();
24602
24693
  SIGNAL_EXIT_CODE = { SIGINT: 130, SIGTERM: 143, SIGHUP: 129 };
24603
24694
  HANDLED_SIGNALS = Object.keys(SIGNAL_EXIT_CODE);
24604
24695
  STOP_ATTEMPTS = 3;
@@ -24650,7 +24741,7 @@ var init_api2 = __esm({
24650
24741
  "use strict";
24651
24742
  init_auth();
24652
24743
  init_api_client();
24653
- init_errors2();
24744
+ init_errors3();
24654
24745
  init_expected();
24655
24746
  init_token_store();
24656
24747
  communityNotFound = (label2) => `Community ${label2} not found, or you are not an owner or admin of its organization.`;
@@ -26183,7 +26274,7 @@ var init_courses = __esm({
26183
26274
  "use strict";
26184
26275
  init_contracts();
26185
26276
  init_community_workspace();
26186
- init_errors2();
26277
+ init_errors3();
26187
26278
  init_expected();
26188
26279
  init_course_files();
26189
26280
  init_listing();
@@ -26783,7 +26874,7 @@ __export(sync_exports2, {
26783
26874
  });
26784
26875
  import * as fs20 from "fs";
26785
26876
  import * as path29 from "path";
26786
- function parseArgs5(args2) {
26877
+ function parseArgs6(args2) {
26787
26878
  return {
26788
26879
  autoConfirm: args2.includes("--yes") || args2.includes("-y"),
26789
26880
  dryRun: args2.includes("--dry-run"),
@@ -27103,7 +27194,7 @@ function pushListing(plan, courses) {
27103
27194
  return listing;
27104
27195
  }
27105
27196
  async function pushCommunity(gitRootOrNull, selector, args2) {
27106
- const { autoConfirm, dryRun, theirs } = parseArgs5(args2);
27197
+ const { autoConfirm, dryRun, theirs } = parseArgs6(args2);
27107
27198
  if (theirs) throw expected("`--theirs` is a pull option: `wayai pull communities/<folder> --theirs` takes the server's side of a conflict.");
27108
27199
  const gitRoot = requireGitRoot2(gitRootOrNull);
27109
27200
  const target = resolveCommunityTarget(gitRoot, selector);
@@ -27322,7 +27413,7 @@ function pullMerge(files, server, plan, theirs) {
27322
27413
  return listing;
27323
27414
  }
27324
27415
  async function pullCommunity(gitRootOrNull, selector, args2) {
27325
- const { dryRun, theirs } = parseArgs5(args2);
27416
+ const { dryRun, theirs } = parseArgs6(args2);
27326
27417
  const gitRoot = requireGitRoot2(gitRootOrNull);
27327
27418
  const target = resolveCommunityTarget(gitRoot, selector);
27328
27419
  let existing = null;
@@ -27392,7 +27483,7 @@ var init_sync2 = __esm({
27392
27483
  "src/communities/sync.ts"() {
27393
27484
  "use strict";
27394
27485
  init_contracts();
27395
- init_errors2();
27486
+ init_errors3();
27396
27487
  init_expected();
27397
27488
  init_fs_safety();
27398
27489
  init_layout();
@@ -27505,7 +27596,7 @@ __export(push_exports, {
27505
27596
  import * as fs21 from "fs";
27506
27597
  import * as path30 from "path";
27507
27598
  import * as yaml15 from "js-yaml";
27508
- function parseArgs6(args2) {
27599
+ function parseArgs7(args2) {
27509
27600
  let autoConfirm = false;
27510
27601
  let label2;
27511
27602
  for (let i = 0; i < args2.length; i++) {
@@ -27991,7 +28082,7 @@ async function pushCommand(args2) {
27991
28082
  await pushCommunity2(gitRoot, route.selector, args2);
27992
28083
  return;
27993
28084
  }
27994
- const { autoConfirm, label: label2 } = parseArgs6(args2);
28085
+ const { autoConfirm, label: label2 } = parseArgs7(args2);
27995
28086
  const hubSelector = route.selector;
27996
28087
  const repoConfig = requireRepoConfig();
27997
28088
  const { organization_id: organizationId } = repoConfig;
@@ -28090,7 +28181,7 @@ __export(pull_exports, {
28090
28181
  });
28091
28182
  import * as fs22 from "fs";
28092
28183
  import * as path31 from "path";
28093
- function parseArgs7(args2) {
28184
+ function parseArgs8(args2) {
28094
28185
  return { autoConfirm: args2.includes("--yes") || args2.includes("-y") };
28095
28186
  }
28096
28187
  function resolveHubTarget(workspaceDir, selector) {
@@ -28136,7 +28227,7 @@ async function pullCommand(args2) {
28136
28227
  await pullCommunity2(gitRoot, route.selector, args2);
28137
28228
  return;
28138
28229
  }
28139
- const { autoConfirm } = parseArgs7(args2);
28230
+ const { autoConfirm } = parseArgs8(args2);
28140
28231
  const hubSelector = route.selector;
28141
28232
  const repoConfig = requireRepoConfig();
28142
28233
  const { organization_id: organizationId } = repoConfig;
@@ -28323,12 +28414,12 @@ var init_pull = __esm({
28323
28414
  var create_exports = {};
28324
28415
  __export(create_exports, {
28325
28416
  createCommand: () => createCommand,
28326
- parseArgs: () => parseArgs8,
28417
+ parseArgs: () => parseArgs9,
28327
28418
  reportNoNewHub: () => reportNoNewHub
28328
28419
  });
28329
28420
  import * as path32 from "path";
28330
28421
  import * as fs23 from "fs";
28331
- function parseArgs8(args2) {
28422
+ function parseArgs9(args2) {
28332
28423
  let autoConfirm = false;
28333
28424
  let folderSelector;
28334
28425
  let label2;
@@ -28358,7 +28449,7 @@ function reportNoNewHub(enclosing, existingHubs, wsLabel) {
28358
28449
  process.exit(1);
28359
28450
  }
28360
28451
  async function createCommand(args2) {
28361
- const { autoConfirm, folderSelector, label: label2 } = parseArgs8(args2);
28452
+ const { autoConfirm, folderSelector, label: label2 } = parseArgs9(args2);
28362
28453
  const repoConfig = requireRepoConfig();
28363
28454
  const { organization_id: organizationId } = repoConfig;
28364
28455
  const { config, accessToken } = await requireAuth();
@@ -28411,9 +28502,9 @@ var init_create = __esm({
28411
28502
  var diff_exports = {};
28412
28503
  __export(diff_exports, {
28413
28504
  diffCommand: () => diffCommand,
28414
- parseArgs: () => parseArgs9
28505
+ parseArgs: () => parseArgs10
28415
28506
  });
28416
- function parseArgs9(args2) {
28507
+ function parseArgs10(args2) {
28417
28508
  let production = false;
28418
28509
  let hubSelector;
28419
28510
  for (let i = 0; i < args2.length; i++) {
@@ -28427,7 +28518,7 @@ function parseArgs9(args2) {
28427
28518
  return { production, hubSelector };
28428
28519
  }
28429
28520
  async function diffCommand(args2) {
28430
- const { production, hubSelector } = parseArgs9(args2);
28521
+ const { production, hubSelector } = parseArgs10(args2);
28431
28522
  const repoConfig = requireRepoConfig();
28432
28523
  const { organization_id: organizationId } = repoConfig;
28433
28524
  const { config, accessToken } = await requireAuth();
@@ -28828,7 +28919,7 @@ __export(page_exports, {
28828
28919
  });
28829
28920
  import * as fs24 from "fs";
28830
28921
  import * as path33 from "path";
28831
- import { parseArgs as parseArgs10 } from "util";
28922
+ import { parseArgs as parseArgs11 } from "util";
28832
28923
  function usageError(message) {
28833
28924
  return expected(`${message}
28834
28925
  ${USAGE}`);
@@ -28836,7 +28927,7 @@ ${USAGE}`);
28836
28927
  function parsePageArgs(args2) {
28837
28928
  let parsed;
28838
28929
  try {
28839
- parsed = parseArgs10({ args: args2, options: OPTIONS, allowPositionals: true, strict: true });
28930
+ parsed = parseArgs11({ args: args2, options: OPTIONS, allowPositionals: true, strict: true });
28840
28931
  } catch (err) {
28841
28932
  throw usageError(err instanceof Error ? err.message : String(err));
28842
28933
  }
@@ -28949,12 +29040,12 @@ new: write a starter page, pages/<slug>/page.yaml and pages/<slug>/index.html, i
28949
29040
  // src/commands/replicate.ts
28950
29041
  var replicate_exports = {};
28951
29042
  __export(replicate_exports, {
28952
- parseArgs: () => parseArgs11,
29043
+ parseArgs: () => parseArgs12,
28953
29044
  replicateCommand: () => replicateCommand
28954
29045
  });
28955
29046
  import * as fs25 from "fs";
28956
29047
  import * as path34 from "path";
28957
- function parseArgs11(args2) {
29048
+ function parseArgs12(args2) {
28958
29049
  let label2;
28959
29050
  let hubFlag;
28960
29051
  let positional;
@@ -28976,7 +29067,7 @@ function parseArgs11(args2) {
28976
29067
  return { label: label2, hubSelector: hubFlag ?? positional };
28977
29068
  }
28978
29069
  async function replicateCommand(args2) {
28979
- const { label: label2, hubSelector } = parseArgs11(args2);
29070
+ const { label: label2, hubSelector } = parseArgs12(args2);
28980
29071
  const normalizedLabel = label2?.trim() || void 0;
28981
29072
  if (normalizedLabel && normalizedLabel.length > PREVIEW_LABEL_MAX_LENGTH) {
28982
29073
  console.error(`--label must be ${PREVIEW_LABEL_MAX_LENGTH} characters or fewer.`);
@@ -29052,11 +29143,11 @@ var init_replicate = __esm({
29052
29143
  // src/commands/relabel.ts
29053
29144
  var relabel_exports = {};
29054
29145
  __export(relabel_exports, {
29055
- parseArgs: () => parseArgs12,
29146
+ parseArgs: () => parseArgs13,
29056
29147
  relabelCommand: () => relabelCommand
29057
29148
  });
29058
29149
  import * as path35 from "path";
29059
- function parseArgs12(args2) {
29150
+ function parseArgs13(args2) {
29060
29151
  let label2;
29061
29152
  let clear = false;
29062
29153
  let hubSelector;
@@ -29078,7 +29169,7 @@ function parseArgs12(args2) {
29078
29169
  return { label: label2, clear, hubSelector };
29079
29170
  }
29080
29171
  async function relabelCommand(args2) {
29081
- const { label: label2, clear, hubSelector } = parseArgs12(args2);
29172
+ const { label: label2, clear, hubSelector } = parseArgs13(args2);
29082
29173
  if (!clear && (label2 === void 0 || label2.trim() === "")) {
29083
29174
  console.error("Usage: wayai relabel <label> [--hub <uuid|folder>] (or --clear to remove the label)");
29084
29175
  process.exit(1);
@@ -29152,13 +29243,13 @@ var init_relabel = __esm({
29152
29243
  // src/commands/publish.ts
29153
29244
  var publish_exports = {};
29154
29245
  __export(publish_exports, {
29155
- parseArgs: () => parseArgs13,
29246
+ parseArgs: () => parseArgs14,
29156
29247
  publishCommand: () => publishCommand,
29157
29248
  renderHubDiff: () => renderHubDiff,
29158
29249
  runPublish: () => runPublish
29159
29250
  });
29160
29251
  import * as path36 from "path";
29161
- function parseArgs13(args2) {
29252
+ function parseArgs14(args2) {
29162
29253
  let autoConfirm = false;
29163
29254
  let hubSelector;
29164
29255
  for (let i = 0; i < args2.length; i++) {
@@ -29248,7 +29339,7 @@ Published. Production hub: ${data2.production_hub_id}`);
29248
29339
  return "synced";
29249
29340
  }
29250
29341
  async function publishCommand(args2) {
29251
- const { autoConfirm, hubSelector } = parseArgs13(args2);
29342
+ const { autoConfirm, hubSelector } = parseArgs14(args2);
29252
29343
  const repoConfig = requireRepoConfig();
29253
29344
  const { organization_id: organizationId } = repoConfig;
29254
29345
  const { config, accessToken } = await requireAuth();
@@ -29951,7 +30042,7 @@ var init_cross_hub_conversations = __esm({
29951
30042
  "src/lib/cross-hub-conversations.ts"() {
29952
30043
  "use strict";
29953
30044
  init_api_client();
29954
- init_errors2();
30045
+ init_errors3();
29955
30046
  init_expected();
29956
30047
  MAX_CROSS_HUB_HUBS = 100;
29957
30048
  CROSS_HUB_CONCURRENCY = 6;
@@ -30840,10 +30931,10 @@ var init_delete_history = __esm({
30840
30931
  // src/commands/sync-skills.ts
30841
30932
  var sync_skills_exports = {};
30842
30933
  __export(sync_skills_exports, {
30843
- parseArgs: () => parseArgs14,
30934
+ parseArgs: () => parseArgs15,
30844
30935
  syncSkillsCommand: () => syncSkillsCommand
30845
30936
  });
30846
- function parseArgs14(args2) {
30937
+ function parseArgs15(args2) {
30847
30938
  let connectionId;
30848
30939
  const idx = args2.indexOf("--connection-id");
30849
30940
  if (idx !== -1 && args2[idx + 1]) {
@@ -30866,7 +30957,7 @@ function printSyncResults(response) {
30866
30957
  }
30867
30958
  async function syncSkillsCommand(args2) {
30868
30959
  const hubId = resolveActiveHubId(args2);
30869
- const { connectionId } = parseArgs14(args2);
30960
+ const { connectionId } = parseArgs15(args2);
30870
30961
  requireRepoConfig();
30871
30962
  const { config, accessToken } = await requireAuth();
30872
30963
  const client = new ApiClient({ apiUrl: config.api_url, accessToken });
@@ -30891,10 +30982,10 @@ var init_sync_skills = __esm({
30891
30982
  // src/commands/sync-mcp.ts
30892
30983
  var sync_mcp_exports = {};
30893
30984
  __export(sync_mcp_exports, {
30894
- parseArgs: () => parseArgs15,
30985
+ parseArgs: () => parseArgs16,
30895
30986
  syncMcpCommand: () => syncMcpCommand
30896
30987
  });
30897
- function parseArgs15(args2) {
30988
+ function parseArgs16(args2) {
30898
30989
  let connection;
30899
30990
  let check = false;
30900
30991
  for (let i = 0; i < args2.length; i++) {
@@ -30909,7 +31000,7 @@ function parseArgs15(args2) {
30909
31000
  }
30910
31001
  async function syncMcpCommand(args2) {
30911
31002
  const hubId = resolveActiveHubId(args2);
30912
- const { connection, check } = parseArgs15(args2);
31003
+ const { connection, check } = parseArgs16(args2);
30913
31004
  if (!connection) {
30914
31005
  console.error("Usage: wayai sync-mcp --connection <name> [--hub <uuid|folder-name>] [--check]");
30915
31006
  console.error("");
@@ -31169,7 +31260,7 @@ var FIXTURE_QUEUE_INITIAL_DELAY_MS, FIXTURE_QUEUE_MAX_DELAY_MS, QUEUEABLE_LAUNCH
31169
31260
  var init_eval_fixture_queue = __esm({
31170
31261
  "src/lib/eval-fixture-queue.ts"() {
31171
31262
  "use strict";
31172
- init_errors2();
31263
+ init_errors3();
31173
31264
  FIXTURE_QUEUE_INITIAL_DELAY_MS = 5e3;
31174
31265
  FIXTURE_QUEUE_MAX_DELAY_MS = 3e4;
31175
31266
  QUEUEABLE_LAUNCH_ERRORS = /* @__PURE__ */ new Set([
@@ -31507,7 +31598,7 @@ var init_run_eval = __esm({
31507
31598
  init_repo_config();
31508
31599
  init_workspace();
31509
31600
  init_api_client();
31510
- init_errors2();
31601
+ init_errors3();
31511
31602
  init_eval_format();
31512
31603
  init_dist();
31513
31604
  init_contracts();
@@ -33201,7 +33292,7 @@ var init_runner = __esm({
33201
33292
  "use strict";
33202
33293
  init_dist();
33203
33294
  init_contracts();
33204
- init_errors2();
33295
+ init_errors3();
33205
33296
  init_caller_audio();
33206
33297
  init_cost_cap();
33207
33298
  init_score();
@@ -33607,7 +33698,7 @@ var init_eval_call = __esm({
33607
33698
  init_workspace();
33608
33699
  init_api_client();
33609
33700
  init_utils();
33610
- init_errors2();
33701
+ init_errors3();
33611
33702
  init_terminal_output();
33612
33703
  init_eval_session_control();
33613
33704
  init_caller_audio();
@@ -33636,7 +33727,7 @@ function isValidSetName(name) {
33636
33727
  if (name.startsWith(".")) return false;
33637
33728
  return !/[\/\\\0]/.test(name);
33638
33729
  }
33639
- function parseArgs16(args2) {
33730
+ function parseArgs17(args2) {
33640
33731
  if (args2.length === 0 || args2[0].startsWith("-")) {
33641
33732
  console.error("Usage: wayai eval capture <conversation_id> [--set <name>] [--name <eval_name>] [--instructions <text>]");
33642
33733
  process.exit(1);
@@ -33682,7 +33773,7 @@ function parseArgs16(args2) {
33682
33773
  }
33683
33774
  async function evalCaptureCommand(args2) {
33684
33775
  const hubId = resolveActiveHubId(args2);
33685
- const parsed = parseArgs16(args2);
33776
+ const parsed = parseArgs17(args2);
33686
33777
  const { config, accessToken } = await requireAuth();
33687
33778
  requireRepoConfig();
33688
33779
  const client = new ApiClient({ apiUrl: config.api_url, accessToken });
@@ -33775,7 +33866,7 @@ var journey_capture_exports = {};
33775
33866
  __export(journey_capture_exports, {
33776
33867
  journeyCaptureCommand: () => journeyCaptureCommand
33777
33868
  });
33778
- function parseArgs17(args2) {
33869
+ function parseArgs18(args2) {
33779
33870
  if (args2.length === 0 || args2[0].startsWith("-")) {
33780
33871
  console.error("Usage: wayai eval journey capture <conversation_id> [--name <journey_name>] [--instructions <text>]");
33781
33872
  process.exit(1);
@@ -33810,7 +33901,7 @@ function parseArgs17(args2) {
33810
33901
  }
33811
33902
  async function journeyCaptureCommand(args2) {
33812
33903
  const hubId = resolveActiveHubId(args2);
33813
- const parsed = parseArgs17(args2);
33904
+ const parsed = parseArgs18(args2);
33814
33905
  const { config, accessToken } = await requireAuth();
33815
33906
  requireRepoConfig();
33816
33907
  const client = new ApiClient({ apiUrl: config.api_url, accessToken });
@@ -33973,7 +34064,7 @@ var init_eval_session_delete = __esm({
33973
34064
  init_repo_config();
33974
34065
  init_workspace();
33975
34066
  init_api_client();
33976
- init_errors2();
34067
+ init_errors3();
33977
34068
  init_contracts();
33978
34069
  init_utils();
33979
34070
  }
@@ -34755,9 +34846,9 @@ var init_credential_utils = __esm({
34755
34846
  var create_credential_exports = {};
34756
34847
  __export(create_credential_exports, {
34757
34848
  createCredentialCommand: () => createCredentialCommand,
34758
- parseArgs: () => parseArgs18
34849
+ parseArgs: () => parseArgs19
34759
34850
  });
34760
- function parseArgs18(args2) {
34851
+ function parseArgs19(args2) {
34761
34852
  let name;
34762
34853
  let type;
34763
34854
  let orgId;
@@ -34785,7 +34876,7 @@ function parseArgs18(args2) {
34785
34876
  return { name, type, orgId, description: description2, tags: splitTagRefs(tags), environment, stdin };
34786
34877
  }
34787
34878
  async function createCredentialCommand(args2) {
34788
- const parsed = parseArgs18(args2);
34879
+ const parsed = parseArgs19(args2);
34789
34880
  if (!parsed.name) {
34790
34881
  console.error("Missing required flag: --name <credential-name>");
34791
34882
  console.error('Usage: wayai create-credential --name "openai-key" --type "Bearer Token"');
@@ -34892,10 +34983,10 @@ var init_create_credential = __esm({
34892
34983
  // src/commands/update-credential.ts
34893
34984
  var update_credential_exports = {};
34894
34985
  __export(update_credential_exports, {
34895
- parseArgs: () => parseArgs19,
34986
+ parseArgs: () => parseArgs20,
34896
34987
  updateCredentialCommand: () => updateCredentialCommand
34897
34988
  });
34898
- function parseArgs19(args2) {
34989
+ function parseArgs20(args2) {
34899
34990
  let name;
34900
34991
  let rename;
34901
34992
  let orgId;
@@ -34928,7 +35019,7 @@ function parseArgs19(args2) {
34928
35019
  return { name, rename, orgId, description: description2, tags: splitTagRefs(tags), hasTagFlag, environment, stdin, secretPrompt };
34929
35020
  }
34930
35021
  async function updateCredentialCommand(args2) {
34931
- const parsed = parseArgs19(args2);
35022
+ const parsed = parseArgs20(args2);
34932
35023
  if (!parsed.name) {
34933
35024
  console.error("Missing required flag: --name <credential-name>");
34934
35025
  console.error('Usage: wayai update-credential --name "my-key" --stdin');
@@ -35041,10 +35132,10 @@ var init_update_credential = __esm({
35041
35132
  // src/commands/set-connection-credential.ts
35042
35133
  var set_connection_credential_exports = {};
35043
35134
  __export(set_connection_credential_exports, {
35044
- parseArgs: () => parseArgs20,
35135
+ parseArgs: () => parseArgs21,
35045
35136
  setConnectionCredentialCommand: () => setConnectionCredentialCommand
35046
35137
  });
35047
- function parseArgs20(args2) {
35138
+ function parseArgs21(args2) {
35048
35139
  let connection;
35049
35140
  let orgCredential;
35050
35141
  let field;
@@ -35067,7 +35158,7 @@ function usage2(msg) {
35067
35158
  }
35068
35159
  async function setConnectionCredentialCommand(args2) {
35069
35160
  const hubId = resolveActiveHubId(args2);
35070
- const parsed = parseArgs20(args2);
35161
+ const parsed = parseArgs21(args2);
35071
35162
  if (!parsed.connection) usage2("Missing required flag: --connection <name|id>");
35072
35163
  const orgMode = !!parsed.orgCredential;
35073
35164
  const directMode = !!parsed.field;
@@ -35424,7 +35515,7 @@ var init_org = __esm({
35424
35515
  init_layout();
35425
35516
  init_utils();
35426
35517
  init_diff_display();
35427
- init_errors2();
35518
+ init_errors3();
35428
35519
  init_org_workspace();
35429
35520
  }
35430
35521
  });
@@ -35433,9 +35524,9 @@ var init_org = __esm({
35433
35524
  var list_exports = {};
35434
35525
  __export(list_exports, {
35435
35526
  listCommand: () => listCommand,
35436
- parseArgs: () => parseArgs21
35527
+ parseArgs: () => parseArgs22
35437
35528
  });
35438
- function parseArgs21(args2) {
35529
+ function parseArgs22(args2) {
35439
35530
  let orgId;
35440
35531
  let json = false;
35441
35532
  for (let i = 0; i < args2.length; i++) {
@@ -35448,7 +35539,7 @@ function parseArgs21(args2) {
35448
35539
  return { orgId, json };
35449
35540
  }
35450
35541
  async function listCommand(args2) {
35451
- const { orgId, json } = parseArgs21(args2);
35542
+ const { orgId, json } = parseArgs22(args2);
35452
35543
  const { config, accessToken } = await requireAuth();
35453
35544
  const client = new ApiClient({ apiUrl: config.api_url, accessToken });
35454
35545
  const { organizations } = await client.organizations();
@@ -35605,10 +35696,10 @@ var communities_exports = {};
35605
35696
  __export(communities_exports, {
35606
35697
  communitiesCommand: () => communitiesCommand
35607
35698
  });
35608
- import { parseArgs as parseArgs22 } from "util";
35699
+ import { parseArgs as parseArgs23 } from "util";
35609
35700
  function parse(args2) {
35610
35701
  try {
35611
- const { values, positionals } = parseArgs22({
35702
+ const { values, positionals } = parseArgs23({
35612
35703
  args: args2,
35613
35704
  options: { org: { type: "string" }, json: { type: "boolean" }, yes: { type: "boolean", short: "y" } },
35614
35705
  allowPositionals: true,
@@ -35911,7 +36002,7 @@ var init_communities = __esm({
35911
36002
  "use strict";
35912
36003
  init_contracts();
35913
36004
  init_api_client();
35914
- init_errors2();
36005
+ init_errors3();
35915
36006
  init_expected();
35916
36007
  init_repo_config();
35917
36008
  init_terminal_output();
@@ -35965,7 +36056,7 @@ var contacts_exports = {};
35965
36056
  __export(contacts_exports, {
35966
36057
  contactsCommand: () => contactsCommand
35967
36058
  });
35968
- import { parseArgs as parseArgs23 } from "util";
36059
+ import { parseArgs as parseArgs24 } from "util";
35969
36060
  function usageError3(message) {
35970
36061
  return expected(`${message}
35971
36062
 
@@ -35973,7 +36064,7 @@ ${USAGE4}`);
35973
36064
  }
35974
36065
  function parse2(args2) {
35975
36066
  try {
35976
- return parseArgs23({
36067
+ return parseArgs24({
35977
36068
  args: args2,
35978
36069
  options: {
35979
36070
  org: { type: "string" },
@@ -36118,7 +36209,7 @@ var init_contacts = __esm({
36118
36209
  "use strict";
36119
36210
  init_auth();
36120
36211
  init_api_client();
36121
- init_errors2();
36212
+ init_errors3();
36122
36213
  init_expected();
36123
36214
  init_repo_config();
36124
36215
  init_terminal_output();
@@ -36177,7 +36268,7 @@ var dimensions_exports = {};
36177
36268
  __export(dimensions_exports, {
36178
36269
  dimensionsCommand: () => dimensionsCommand
36179
36270
  });
36180
- import { parseArgs as parseArgs24 } from "util";
36271
+ import { parseArgs as parseArgs25 } from "util";
36181
36272
  function usageError4(message) {
36182
36273
  return expected(`${message}
36183
36274
 
@@ -36185,7 +36276,7 @@ ${USAGE5}`);
36185
36276
  }
36186
36277
  function parse3(args2) {
36187
36278
  try {
36188
- return parseArgs24({
36279
+ return parseArgs25({
36189
36280
  args: args2,
36190
36281
  options: {
36191
36282
  org: { type: "string" },
@@ -36290,7 +36381,7 @@ var init_dimensions = __esm({
36290
36381
  "use strict";
36291
36382
  init_auth();
36292
36383
  init_api_client();
36293
- init_errors2();
36384
+ init_errors3();
36294
36385
  init_expected();
36295
36386
  init_repo_config();
36296
36387
  init_terminal_output();
@@ -36339,7 +36430,7 @@ __export(access_exports, {
36339
36430
  accessCommand: () => accessCommand,
36340
36431
  formatExplanation: () => formatExplanation
36341
36432
  });
36342
- import { parseArgs as parseArgs25 } from "util";
36433
+ import { parseArgs as parseArgs26 } from "util";
36343
36434
  function usageError5(message) {
36344
36435
  return expected(`${message}
36345
36436
 
@@ -36347,7 +36438,7 @@ ${USAGE6}`);
36347
36438
  }
36348
36439
  function parse4(args2) {
36349
36440
  try {
36350
- return parseArgs25({
36441
+ return parseArgs26({
36351
36442
  args: args2,
36352
36443
  options: {
36353
36444
  hub: { type: "string" },
@@ -36460,7 +36551,7 @@ var init_access = __esm({
36460
36551
  "use strict";
36461
36552
  init_auth();
36462
36553
  init_api_client();
36463
- init_errors2();
36554
+ init_errors3();
36464
36555
  init_expected();
36465
36556
  init_terminal_output();
36466
36557
  init_utils();
@@ -37502,20 +37593,20 @@ __export(knowledge_exports, {
37502
37593
  knowledgeCommand: () => knowledgeCommand,
37503
37594
  parseKnowledgeArgs: () => parseKnowledgeArgs
37504
37595
  });
37505
- import { parseArgs as parseArgs26 } from "util";
37596
+ import { parseArgs as parseArgs27 } from "util";
37506
37597
  function usageError6(message) {
37507
37598
  return expected(`${message}
37508
37599
  ${USAGE7}`);
37509
37600
  }
37510
37601
  function readArgs(args2) {
37511
37602
  try {
37512
- return parseArgs26({ args: args2, options: OPTIONS2, allowPositionals: true, strict: true });
37603
+ return parseArgs27({ args: args2, options: OPTIONS2, allowPositionals: true, strict: true });
37513
37604
  } catch (err) {
37514
37605
  throw usageError6(err instanceof Error ? err.message : String(err));
37515
37606
  }
37516
37607
  }
37517
37608
  function parseKnowledgeArgs(args2) {
37518
- const [retired] = parseArgs26({ args: args2, options: OPTIONS2, allowPositionals: true, strict: false }).positionals;
37609
+ const [retired] = parseArgs27({ args: args2, options: OPTIONS2, allowPositionals: true, strict: false }).positionals;
37519
37610
  if (retired !== void 0 && RETIRED_VERBS.has(retired)) {
37520
37611
  throw expected(
37521
37612
  `\`wayai knowledge ${retired}\` is retired: knowledge resources are gone, and an organization's documents live in its knowledge base as files (\`wayai files pull\` and \`push\`).`
@@ -37631,6 +37722,10 @@ async function adminCommand(args2) {
37631
37722
  }
37632
37723
  const [sub, ...rest] = afterGroup;
37633
37724
  const { positional, flagArgs } = splitArgs(rest);
37725
+ if (group === "second-factor-reset") {
37726
+ await runSecondFactorReset(sub);
37727
+ return;
37728
+ }
37634
37729
  if (group === "do") {
37635
37730
  if (!sub) {
37636
37731
  printHelp2();
@@ -37976,6 +38071,16 @@ function splitArgs(args2) {
37976
38071
  }
37977
38072
  return { positional, flagArgs };
37978
38073
  }
38074
+ async function runSecondFactorReset(userId) {
38075
+ if (!userId) {
38076
+ console.error("wayai admin second-factor-reset <user_id>");
38077
+ process.exit(1);
38078
+ }
38079
+ const { config, accessToken } = await requireAuth();
38080
+ const client = new ApiClient({ apiUrl: config.api_url, accessToken });
38081
+ const { data } = await client.resetUserSecondFactor(userId);
38082
+ console.log(data.cleared ? "Two-step verification removed. Ending their sessions and emailing them is best effort: failures are in the backend logs." : "That person has no two-step verification.");
38083
+ }
37979
38084
  async function runDoTables(positional) {
37980
38085
  if (positional.length < 2) {
37981
38086
  console.error("wayai admin do tables <type> <id>");
@@ -39809,6 +39914,7 @@ function printHelp2() {
39809
39914
  wayai admin \u2014 platform-admin diagnostic commands
39810
39915
 
39811
39916
  Usage:
39917
+ wayai admin second-factor-reset <user_id> Remove a person's two-step verification (confirm who is asking first)
39812
39918
  wayai admin do tables <type> <id>
39813
39919
  wayai admin do read <type> <id> <table> [--limit N] [--id X] [--json]
39814
39920
  wayai admin do counts <hub|org> <id> [--json] Numbers, no text: a hub's toolset connections, knowledge placeholders per stored
@@ -40061,7 +40167,7 @@ var init_admin = __esm({
40061
40167
  init_workspace();
40062
40168
  init_skill_version();
40063
40169
  init_file_map();
40064
- init_errors2();
40170
+ init_errors3();
40065
40171
  init_contracts();
40066
40172
  VALID_TYPES = dataExplorerDebugDoType.options;
40067
40173
  VALID_ANALYTICS_TABLES = dataExplorerDebugAnalyticsTable.options;
@@ -43196,7 +43302,7 @@ var init_program = __esm({
43196
43302
 
43197
43303
  // src/index.ts
43198
43304
  init_sentry();
43199
- init_errors2();
43305
+ init_errors3();
43200
43306
  init_mask_secrets();
43201
43307
  init_utils();
43202
43308
  init_registry();
@@ -43382,6 +43488,11 @@ async function main() {
43382
43488
  }
43383
43489
  }
43384
43490
  switch (command) {
43491
+ case "2fa": {
43492
+ const { secondFactorCommand: secondFactorCommand2 } = await Promise.resolve().then(() => (init_second_factor(), second_factor_exports));
43493
+ await secondFactorCommand2(args);
43494
+ break;
43495
+ }
43385
43496
  case "login": {
43386
43497
  const { loginCommand: loginCommand2 } = await Promise.resolve().then(() => (init_login(), login_exports));
43387
43498
  await loginCommand2(args);
@@ -43628,6 +43739,7 @@ Commands:
43628
43739
  logout Clear stored credentials
43629
43740
  status Show current auth and config status
43630
43741
  whoami Show the authenticated identity (supports --json)
43742
+ 2fa verify Enter a two-step code for this session (--recovery for a recovery code)
43631
43743
  init Scope this repo to an organization (pick one)
43632
43744
  create-credential Create an organization credential (API key, token, etc.)
43633
43745
  update-credential Update / rotate an organization credential (by name)