@wayai/cli 0.3.301 → 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,80 +16111,6 @@ var init_chunk_UEJOG2Q7 = __esm({
15796
16111
  }
15797
16112
  });
15798
16113
 
15799
- // ../../packages/core/dist/chunk-JO53JB35.js
15800
- var META_ENTITY_ID_PATTERN, metaEntityId, whatsappCallbackBody, authMeResponse, wsTicketResponse, sessionCheckResponse, logoutResponse, magicCodeSendBody, magicCodeSendResponse, magicCodeVerifyBody, magicCodeVerifyResponse, passwordLoginBody, normalizeEmail, REVIEW_ACCOUNT_EMAILS;
15801
- var init_chunk_JO53JB35 = __esm({
15802
- "../../packages/core/dist/chunk-JO53JB35.js"() {
15803
- "use strict";
15804
- init_zod();
15805
- META_ENTITY_ID_PATTERN = /^\d{1,32}$/;
15806
- metaEntityId = external_exports.string().regex(META_ENTITY_ID_PATTERN, "must be a numeric Meta entity id");
15807
- whatsappCallbackBody = external_exports.object({
15808
- state: external_exports.string().min(1, "state is required"),
15809
- code: external_exports.string().optional(),
15810
- access_token: external_exports.string().optional(),
15811
- user_id: external_exports.string().optional(),
15812
- /**
15813
- * The phone number and WABA the operator actually picked in Meta's Embedded
15814
- * Signup popup (posted to the opener as `WA_EMBEDDED_SIGNUP`). Optional:
15815
- * older clients, and the redirect-based flow, never see that event and fall
15816
- * back to discovery.
15817
- */
15818
- phone_number_id: metaEntityId.optional(),
15819
- waba_id: metaEntityId.optional()
15820
- }).refine(
15821
- (data) => !!data.access_token || !!data.code,
15822
- { message: "Missing required parameters: state and either access_token or code" }
15823
- );
15824
- authMeResponse = external_exports.object({
15825
- user_id: external_exports.string(),
15826
- email: external_exports.string(),
15827
- org_id: external_exports.string().nullable(),
15828
- is_platform_admin: external_exports.boolean()
15829
- });
15830
- wsTicketResponse = external_exports.object({
15831
- ticket: external_exports.string(),
15832
- /** Seconds until the ticket expires if unconsumed. */
15833
- expires_in: external_exports.number()
15834
- });
15835
- sessionCheckResponse = external_exports.object({
15836
- valid: external_exports.literal(true)
15837
- });
15838
- logoutResponse = external_exports.object({
15839
- success: external_exports.literal(true)
15840
- });
15841
- magicCodeSendBody = external_exports.object({
15842
- email: external_exports.string().email("Invalid email").max(254)
15843
- // RFC 5321 max; bounds the request payload
15844
- });
15845
- magicCodeSendResponse = external_exports.object({
15846
- success: external_exports.literal(true)
15847
- });
15848
- magicCodeVerifyBody = external_exports.object({
15849
- email: external_exports.string().email("Invalid email").max(254),
15850
- // RFC 5321 max; bounds the request payload
15851
- code: external_exports.string().min(1, "Code is required").max(12)
15852
- // WorkOS sends a 6-digit code; bound the input
15853
- });
15854
- magicCodeVerifyResponse = external_exports.object({
15855
- access_token: external_exports.string(),
15856
- refresh_token: external_exports.string()
15857
- });
15858
- passwordLoginBody = external_exports.object({
15859
- email: external_exports.string().email("Invalid email").max(254),
15860
- // RFC 5321 max; bounds the request payload
15861
- password: external_exports.string().min(1, "Password is required").max(128)
15862
- // bound the payload; WorkOS validates
15863
- });
15864
- normalizeEmail = (email) => email.trim().toLowerCase();
15865
- REVIEW_ACCOUNT_EMAILS = new Set(
15866
- ["apple.review@wayai.pro", "play.review@wayai.pro", "microsoft.review@wayai.pro", "meta.review@wayai.pro"].map(
15867
- normalizeEmail
15868
- )
15869
- );
15870
- }
15871
- });
15872
-
15873
16114
  // ../../packages/core/dist/chunk-R6Y377AW.js
15874
16115
  function filterNamesAnything(filter) {
15875
16116
  return filter.labels.length + filter.scope_tag_ids.length > 0;
@@ -16140,221 +16381,16 @@ var init_chunk_B6PT7ZSX = __esm({
16140
16381
  }
16141
16382
  });
16142
16383
 
16143
- // ../../packages/core/dist/chunk-WFQDSQJK.js
16144
- function isPublicIdentifier(value) {
16145
- return UUID_RE.test(value) || HEX_RE.test(value) || WORKOS_ID_RE.test(value) || TRACE_HEADER_RE.test(value);
16146
- }
16147
- function redactTokenShapes(input) {
16148
- 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}`);
16149
- }
16150
- function redactSecrets(value) {
16151
- if (isPublicIdentifier(value)) {
16152
- return value;
16153
- }
16154
- if (OPAQUE_SECRET_RE.test(value)) {
16155
- return REDACTED;
16156
- }
16157
- if (BASE64_SECRET_RE.test(value) && BASE64_MARKER_RE.test(value)) {
16158
- return REDACTED;
16159
- }
16160
- return redactTokenShapes(value);
16161
- }
16162
- 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;
16163
- var init_chunk_WFQDSQJK = __esm({
16164
- "../../packages/core/dist/chunk-WFQDSQJK.js"() {
16165
- "use strict";
16166
- UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
16167
- HEX_RE = /^[0-9a-f]{16,}$/;
16168
- WORKOS_ID_RE = /^(?:user|org)_[0-9A-HJKMNP-TV-Z]{26}$/;
16169
- 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])?)$/;
16170
- OPAQUE_SECRET_RE = /^[A-Za-z0-9_-]{21,}$/;
16171
- BASE64_SECRET_RE = /^[A-Za-z0-9+/]{20,}={0,2}$/;
16172
- BASE64_MARKER_RE = /[+=]/;
16173
- TOKEN_RE = new RegExp(
16174
- [
16175
- // WayAI API tokens and WebSocket tickets.
16176
- "(?:way|wst)_[A-Za-z0-9._-]{8,}",
16177
- // Authorization header values, including base64 Basic credentials.
16178
- "(?:Bearer|Basic)\\s+[A-Za-z0-9._~+/=-]{8,}",
16179
- // JWTs — WorkOS session/access tokens. `eyJ` is base64 for `{"`.
16180
- "eyJ[A-Za-z0-9._-]{10,}",
16181
- // Stripe secret/publishable/restricted keys and webhook signing secrets.
16182
- "(?:sk|pk|rk)_(?:live|test)_[A-Za-z0-9]{8,}",
16183
- "whsec_[A-Za-z0-9]{8,}",
16184
- // Telegram bot tokens as the Bot API takes them, in the URL path: `/bot<id>:<secret>/`.
16185
- "bot[0-9]{5,}:[A-Za-z0-9_-]{30,}"
16186
- // NOTE: LLM provider keys are NOT here — they need a delimiter-preserving
16187
- // boundary, so they live in PROVIDER_TOKEN_RE below.
16188
- ].join("|"),
16189
- "g"
16190
- );
16191
- SENSITIVE_FIELDS = [
16192
- "password",
16193
- "token",
16194
- "secret",
16195
- "api_key",
16196
- "apikey",
16197
- "api-key",
16198
- "authorization",
16199
- "auth",
16200
- "credential",
16201
- "private_key",
16202
- "privatekey",
16203
- "access_token",
16204
- "refresh_token",
16205
- "session_id",
16206
- "sessionid",
16207
- "cookie",
16208
- "jwt"
16209
- ];
16210
- SENSITIVE_KEY_ALTERNATION = SENSITIVE_FIELDS.map(
16211
- (field) => field.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")
16212
- ).join("|");
16213
- SENSITIVE_KEY_PATTERN = `[A-Za-z0-9_.-]*(?:${SENSITIVE_KEY_ALTERNATION})[A-Za-z0-9_.-]*`;
16214
- JSON_CREDENTIAL_RE = new RegExp(
16215
- `("${SENSITIVE_KEY_PATTERN}"\\s*:\\s*)"(?:[^"\\\\]|\\\\.)*"`,
16216
- "gi"
16217
- );
16218
- QUERY_CREDENTIAL_RE = new RegExp(
16219
- `((?:^|[?&#;\\s])${SENSITIVE_KEY_PATTERN}=)[^&;\\s"']+`,
16220
- "gi"
16221
- );
16222
- REDACTED = "[REDACTED]";
16223
- PROVIDER_TOKEN_RE = new RegExp(
16224
- "(^|[^A-Za-z0-9])(?:" + [
16225
- "sk-[A-Za-z0-9_-]{16,}",
16226
- "AIza[A-Za-z0-9_-]{16,}",
16227
- "xai-[A-Za-z0-9_-]{16,}"
16228
- ].join("|") + ")",
16229
- "g"
16230
- );
16231
- FILE_URL_TOKEN_RE = /v[0-9]+\.[gp]\.[0-9]+\.[A-Za-z0-9_-]{43}\.[A-Za-z0-9_-]{43}/g;
16232
- }
16233
- });
16234
-
16235
- // ../../packages/core/dist/chunk-HLOSHCSS.js
16236
- 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;
16237
- var init_chunk_HLOSHCSS = __esm({
16238
- "../../packages/core/dist/chunk-HLOSHCSS.js"() {
16239
- "use strict";
16240
- init_chunk_WFQDSQJK();
16241
- APP_ERROR_BRAND = /* @__PURE__ */ Symbol.for("wayai.AppError");
16242
- AppError = class extends Error {
16243
- constructor(message, code, statusCode = 500, details) {
16244
- super(message);
16245
- this.code = code;
16246
- this.statusCode = statusCode;
16247
- this.details = details;
16248
- this.name = "AppError";
16249
- }
16250
- [APP_ERROR_BRAND] = true;
16251
- toJSON() {
16252
- return {
16253
- error: this.code,
16254
- message: this.message,
16255
- ...this.details && { details: this.details }
16256
- };
16257
- }
16258
- };
16259
- PAGE_CUSTOMER_UNAVAILABLE_CODE = "PAGE_CUSTOMER_UNAVAILABLE";
16260
- LLM_RATE_LIMIT_BRAND = /* @__PURE__ */ Symbol.for("wayai.LlmRateLimitError");
16261
- LlmRateLimitError = class extends Error {
16262
- constructor(provider, retryAfterMs) {
16263
- super(`${provider} rate limited; retry after ${retryAfterMs}ms`);
16264
- this.provider = provider;
16265
- this.retryAfterMs = retryAfterMs;
16266
- this.name = "LlmRateLimitError";
16267
- }
16268
- [LLM_RATE_LIMIT_BRAND] = true;
16269
- };
16270
- LLM_PROVIDER_HTTP_BRAND = /* @__PURE__ */ Symbol.for("wayai.LlmProviderHttpError");
16271
- LlmProviderHttpError = class extends Error {
16272
- constructor(message, status, provider, providerError) {
16273
- super(redactSecrets(message));
16274
- this.status = status;
16275
- this.provider = provider;
16276
- this.providerError = providerError;
16277
- this.name = "LlmProviderHttpError";
16278
- }
16279
- [LLM_PROVIDER_HTTP_BRAND] = true;
16280
- };
16281
- LLM_PROVIDER_CONTENT_BRAND = /* @__PURE__ */ Symbol.for("wayai.LlmProviderContentError");
16282
- LlmProviderContentError = class extends Error {
16283
- constructor(message, provider, providerError) {
16284
- super(redactSecrets(message));
16285
- this.provider = provider;
16286
- this.providerError = providerError;
16287
- this.name = "LlmProviderContentError";
16288
- }
16289
- [LLM_PROVIDER_CONTENT_BRAND] = true;
16290
- };
16291
- LLM_PROVIDER_TIMEOUT_BRAND = /* @__PURE__ */ Symbol.for("wayai.LlmProviderTimeoutError");
16292
- LlmProviderTimeoutError = class extends Error {
16293
- constructor(message, provider) {
16294
- super(message);
16295
- this.provider = provider;
16296
- this.name = "LlmProviderTimeoutError";
16297
- }
16298
- [LLM_PROVIDER_TIMEOUT_BRAND] = true;
16299
- };
16300
- ExternalServiceError = class extends AppError {
16301
- constructor(service, originalError) {
16302
- super(`External service error: ${service}`, "EXTERNAL_SERVICE_ERROR", 502, {
16303
- service,
16304
- originalMessage: originalError?.message
16305
- });
16306
- this.name = "ExternalServiceError";
16307
- }
16308
- };
16309
- CHANNEL_PROVIDER_HTTP_BRAND = /* @__PURE__ */ Symbol.for("wayai.ChannelProviderHttpError");
16310
- ChannelProviderHttpError = class extends ExternalServiceError {
16311
- [CHANNEL_PROVIDER_HTTP_BRAND] = true;
16312
- status;
16313
- provider;
16314
- /** Provider numeric error code (Meta `error.code`) — body-free. */
16315
- providerCode;
16316
- /** Provider numeric error subcode (Meta `error.error_subcode`) — body-free. */
16317
- providerSubcode;
16318
- constructor(provider, status, providerCode, providerSubcode) {
16319
- super(provider);
16320
- this.name = "ChannelProviderHttpError";
16321
- this.status = status;
16322
- this.provider = provider;
16323
- this.providerCode = providerCode;
16324
- this.providerSubcode = providerSubcode;
16325
- }
16326
- };
16327
- MEDIA_PROVIDER_HTTP_BRAND = /* @__PURE__ */ Symbol.for("wayai.MediaProviderHttpError");
16328
- MediaProviderHttpError = class extends Error {
16329
- constructor(provider, status, options = {}) {
16330
- super(`${provider} API error (${status})`);
16331
- this.provider = provider;
16332
- this.status = status;
16333
- this.name = "MediaProviderHttpError";
16334
- this.credentialRejected = options.credentialRejected ?? false;
16335
- }
16336
- [MEDIA_PROVIDER_HTTP_BRAND] = true;
16337
- /**
16338
- * The provider said the credential itself was rejected, under a status that does not say so
16339
- * (Google answers an invalid or expired key with 400 `API_KEY_INVALID`, not 401). Read off
16340
- * the body at the throw site, which carries only this flag on. Alerting keys on it so the
16341
- * admin is told to re-enter the key, not that the key is fine.
16342
- */
16343
- credentialRejected;
16344
- };
16345
- }
16346
- });
16347
-
16348
16384
  // ../../packages/core/dist/contracts/index.js
16349
16385
  var init_contracts = __esm({
16350
16386
  "../../packages/core/dist/contracts/index.js"() {
16351
16387
  "use strict";
16388
+ init_chunk_RACEDHG6();
16352
16389
  init_chunk_Q7KIQHAZ();
16353
16390
  init_chunk_NKLVUTFO();
16354
16391
  init_chunk_WL5QGKHN();
16355
16392
  init_chunk_YVY2TZK2();
16356
16393
  init_chunk_VXEAR36B();
16357
- init_chunk_RACEDHG6();
16358
16394
  init_chunk_HIGKBEPF();
16359
16395
  init_chunk_HA7CRZMX();
16360
16396
  init_chunk_MF2VVXBR();
@@ -16363,8 +16399,9 @@ var init_contracts = __esm({
16363
16399
  init_chunk_5YNUTCJ2();
16364
16400
  init_chunk_ZC6YGHNX();
16365
16401
  init_chunk_5DGHIY7L();
16366
- init_chunk_LQ37IULI();
16402
+ init_chunk_UVGO72D6();
16367
16403
  init_chunk_IPDOHAZ5();
16404
+ init_chunk_PFGVH2CX();
16368
16405
  init_chunk_GPM7PE44();
16369
16406
  init_chunk_NZ6RQW6R();
16370
16407
  init_chunk_2DXRB6DR();
@@ -16417,14 +16454,14 @@ var init_contracts = __esm({
16417
16454
  init_chunk_K5UAZWFF();
16418
16455
  init_chunk_2PZIF56U();
16419
16456
  init_chunk_UEJOG2Q7();
16420
- init_chunk_JO53JB35();
16457
+ init_chunk_KEN2DASI();
16421
16458
  init_chunk_ELBFOFQD();
16422
16459
  init_chunk_R6Y377AW();
16423
16460
  init_chunk_UAOHHCW5();
16424
16461
  init_chunk_FGNMHILL();
16425
16462
  init_chunk_IG6QBZMA();
16426
16463
  init_chunk_OMPT4ZHR();
16427
- init_chunk_WWLNKL2W();
16464
+ init_chunk_DWJOFJEA();
16428
16465
  init_chunk_SOJMWM63();
16429
16466
  init_chunk_WTOA3ANF();
16430
16467
  init_chunk_5FO3GNKP();
@@ -16451,7 +16488,7 @@ var init_contracts = __esm({
16451
16488
  init_chunk_MIWZOSPI();
16452
16489
  init_chunk_YROEDMVZ();
16453
16490
  init_chunk_L5F7ZOUJ();
16454
- init_chunk_HLOSHCSS();
16491
+ init_chunk_ICYO56QW();
16455
16492
  init_chunk_WFQDSQJK();
16456
16493
  }
16457
16494
  });
@@ -16588,7 +16625,7 @@ var UUID_RE2, WAYAI_WORKSPACE_LAYOUT;
16588
16625
  var init_dist = __esm({
16589
16626
  "../../packages/core/dist/index.js"() {
16590
16627
  "use strict";
16591
- init_chunk_WWLNKL2W();
16628
+ init_chunk_DWJOFJEA();
16592
16629
  init_chunk_SOJMWM63();
16593
16630
  init_chunk_WTOA3ANF();
16594
16631
  init_chunk_5FO3GNKP();
@@ -16614,7 +16651,7 @@ var init_dist = __esm({
16614
16651
  init_chunk_MIWZOSPI();
16615
16652
  init_chunk_YROEDMVZ();
16616
16653
  init_chunk_L5F7ZOUJ();
16617
- init_chunk_HLOSHCSS();
16654
+ init_chunk_ICYO56QW();
16618
16655
  init_chunk_WFQDSQJK();
16619
16656
  UUID_RE2 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
16620
16657
  WAYAI_WORKSPACE_LAYOUT = {
@@ -17704,6 +17741,7 @@ var init_utils = __esm({
17704
17741
  ["logout", { positionals: 0 }],
17705
17742
  ["status", { positionals: 0 }],
17706
17743
  ["whoami", { positionals: 0 }],
17744
+ ["2fa", "all"],
17707
17745
  ["init", { positionals: 0, values: ["--org"] }],
17708
17746
  ["create", { positionals: 1, values: ["--label"] }],
17709
17747
  ["diff", { positionals: 0, values: ["--hub"] }],
@@ -17802,6 +17840,7 @@ var init_utils = __esm({
17802
17840
  ["admin archive", { positionals: 2, values: ["--message-id"] }],
17803
17841
  ["admin observability", { positionals: 2, values: ["--message-id"] }],
17804
17842
  ["admin do tables", { positionals: 2 }],
17843
+ ["admin second-factor-reset", { positionals: 1 }],
17805
17844
  ["admin do read", { positionals: 3, values: ["--limit", "--id"] }],
17806
17845
  ["admin do counts", { positionals: 2 }],
17807
17846
  ["admin analytics tables", { positionals: 0 }],
@@ -18614,6 +18653,15 @@ var init_api_client = __esm({
18614
18653
  async me() {
18615
18654
  return this.request("GET", "/api/auth/me");
18616
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
+ }
18617
18665
  async syncSkills(hubId, connectionId) {
18618
18666
  return this.request("POST", "/api/setup/skills/sync-skills", {
18619
18667
  hub_id: hubId,
@@ -19330,6 +19378,13 @@ function friendlyHint(err) {
19330
19378
  return "Couldn't reach WayAI \u2014 check your network connection and try again.";
19331
19379
  }
19332
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
+ }
19333
19388
  if (err.body.includes("FREE_PLAN_RESTRICTION")) {
19334
19389
  return "Publishing to production requires a paid plan. Upgrade your organization to publish or sync.";
19335
19390
  }
@@ -19343,9 +19398,10 @@ function friendlyHint(err) {
19343
19398
  if (status >= 500) return "WayAI server error \u2014 likely temporary. Try again shortly.";
19344
19399
  return null;
19345
19400
  }
19346
- var init_errors2 = __esm({
19401
+ var init_errors3 = __esm({
19347
19402
  "src/lib/errors.ts"() {
19348
19403
  "use strict";
19404
+ init_errors();
19349
19405
  init_api_client();
19350
19406
  init_network_error();
19351
19407
  }
@@ -20355,6 +20411,43 @@ var init_skill_symlink = __esm({
20355
20411
  }
20356
20412
  });
20357
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
+
20358
20451
  // src/lib/report-inbox.ts
20359
20452
  async function nudgeReportActions(apiUrl, accessToken) {
20360
20453
  if (!process.stdout.isTTY || process.env.CI) return;
@@ -20882,10 +20975,10 @@ var init_worktree_scope = __esm({
20882
20975
  // src/commands/status.ts
20883
20976
  var status_exports = {};
20884
20977
  __export(status_exports, {
20885
- parseArgs: () => parseArgs,
20978
+ parseArgs: () => parseArgs2,
20886
20979
  statusCommand: () => statusCommand
20887
20980
  });
20888
- function parseArgs(args2) {
20981
+ function parseArgs2(args2) {
20889
20982
  return { json: args2.includes("--json") };
20890
20983
  }
20891
20984
  function buildSkillState() {
@@ -20916,7 +21009,7 @@ function buildWorkspaceState(resolved) {
20916
21009
  return { scoped: true, path: resolved.path, hub_count: hubCount };
20917
21010
  }
20918
21011
  async function statusCommand(args2, pkg2) {
20919
- const { json } = parseArgs(args2);
21012
+ const { json } = parseArgs2(args2);
20920
21013
  const config = readConfig();
20921
21014
  const resolvedRepo = resolveRepoConfig();
20922
21015
  const repoConfig = resolvedRepo?.config ?? null;
@@ -21075,14 +21168,14 @@ var init_status = __esm({
21075
21168
  // src/commands/whoami.ts
21076
21169
  var whoami_exports = {};
21077
21170
  __export(whoami_exports, {
21078
- parseArgs: () => parseArgs2,
21171
+ parseArgs: () => parseArgs3,
21079
21172
  whoamiCommand: () => whoamiCommand
21080
21173
  });
21081
- function parseArgs2(args2) {
21174
+ function parseArgs3(args2) {
21082
21175
  return { json: args2.includes("--json") };
21083
21176
  }
21084
21177
  async function whoamiCommand(args2) {
21085
- const { json } = parseArgs2(args2);
21178
+ const { json } = parseArgs3(args2);
21086
21179
  const { config, accessToken } = await requireAuth();
21087
21180
  const client = new ApiClient({ apiUrl: config.api_url, accessToken });
21088
21181
  const me = await client.me();
@@ -21120,7 +21213,7 @@ __export(init_exports, {
21120
21213
  SKILL_INSTALL_CMD: () => SKILL_INSTALL_CMD,
21121
21214
  ensureHubsDir: () => ensureHubsDir,
21122
21215
  initCommand: () => initCommand,
21123
- parseArgs: () => parseArgs3
21216
+ parseArgs: () => parseArgs4
21124
21217
  });
21125
21218
  import { mkdirSync as mkdirSync6 } from "fs";
21126
21219
  import path12 from "path";
@@ -21130,7 +21223,7 @@ function ensureHubsDir(gitRoot) {
21130
21223
  mkdirSync6(hubsDir, { recursive: true });
21131
21224
  return `${path12.relative(gitRoot, hubsDir)}/`;
21132
21225
  }
21133
- function parseArgs3(args2) {
21226
+ function parseArgs4(args2) {
21134
21227
  let orgId;
21135
21228
  let autoConfirm = false;
21136
21229
  const orgIdx = args2.indexOf("--org");
@@ -21145,7 +21238,7 @@ function parseArgs3(args2) {
21145
21238
  return { orgId, autoConfirm };
21146
21239
  }
21147
21240
  async function initCommand(args2) {
21148
- const { orgId: directOrgId, autoConfirm } = parseArgs3(args2);
21241
+ const { orgId: directOrgId, autoConfirm } = parseArgs4(args2);
21149
21242
  const existing = readRepoConfig();
21150
21243
  if (existing) {
21151
21244
  const scopeLabel = existing.organization_name ? `${existing.organization_name} (${existing.organization_id})` : existing.organization_id;
@@ -21680,7 +21773,7 @@ var init_pages = __esm({
21680
21773
  init_chunk_FBV7NLKO();
21681
21774
  init_chunk_WEXVYJ5H();
21682
21775
  init_chunk_HZ6CADSY();
21683
- init_chunk_HLOSHCSS();
21776
+ init_chunk_ICYO56QW();
21684
21777
  init_chunk_WFQDSQJK();
21685
21778
  }
21686
21779
  });
@@ -22805,7 +22898,7 @@ var init_ci = __esm({
22805
22898
  init_chunk_MIWZOSPI();
22806
22899
  init_chunk_YROEDMVZ();
22807
22900
  init_chunk_L5F7ZOUJ();
22808
- init_chunk_HLOSHCSS();
22901
+ init_chunk_ICYO56QW();
22809
22902
  init_chunk_WFQDSQJK();
22810
22903
  }
22811
22904
  });
@@ -24244,7 +24337,7 @@ __export(sync_exports, {
24244
24337
  pushBase: () => pushBase
24245
24338
  });
24246
24339
  import * as path25 from "path";
24247
- function parseArgs4(args2) {
24340
+ function parseArgs5(args2) {
24248
24341
  return {
24249
24342
  autoConfirm: args2.includes("--yes") || args2.includes("-y"),
24250
24343
  dryRun: args2.includes("--dry-run"),
@@ -24279,7 +24372,7 @@ async function mirrorLinkedProduction(client, basesDir, originId) {
24279
24372
  }
24280
24373
  }
24281
24374
  async function pullBase(gitRootOrNull, selector, args2) {
24282
- const { autoConfirm } = parseArgs4(args2);
24375
+ const { autoConfirm } = parseArgs5(args2);
24283
24376
  const gitRoot = requireGitRoot(gitRootOrNull);
24284
24377
  const target = resolveBaseTarget(gitRoot, selector);
24285
24378
  const basesDir = resolveBasesDir(gitRoot);
@@ -24364,7 +24457,7 @@ async function createDeclaredPreview(client, target, parsed, autoConfirm) {
24364
24457
  return id;
24365
24458
  }
24366
24459
  async function pushBase(gitRootOrNull, selector, args2) {
24367
- const { autoConfirm, dryRun, prune } = parseArgs4(args2);
24460
+ const { autoConfirm, dryRun, prune } = parseArgs5(args2);
24368
24461
  const gitRoot = requireGitRoot(gitRootOrNull);
24369
24462
  const target = resolveBaseTarget(gitRoot, selector);
24370
24463
  if (!target.exists) {
@@ -24596,7 +24689,7 @@ var init_eval_session_control = __esm({
24596
24689
  "src/lib/eval-session-control.ts"() {
24597
24690
  "use strict";
24598
24691
  init_api_client();
24599
- init_errors2();
24692
+ init_errors3();
24600
24693
  SIGNAL_EXIT_CODE = { SIGINT: 130, SIGTERM: 143, SIGHUP: 129 };
24601
24694
  HANDLED_SIGNALS = Object.keys(SIGNAL_EXIT_CODE);
24602
24695
  STOP_ATTEMPTS = 3;
@@ -24648,7 +24741,7 @@ var init_api2 = __esm({
24648
24741
  "use strict";
24649
24742
  init_auth();
24650
24743
  init_api_client();
24651
- init_errors2();
24744
+ init_errors3();
24652
24745
  init_expected();
24653
24746
  init_token_store();
24654
24747
  communityNotFound = (label2) => `Community ${label2} not found, or you are not an owner or admin of its organization.`;
@@ -26181,7 +26274,7 @@ var init_courses = __esm({
26181
26274
  "use strict";
26182
26275
  init_contracts();
26183
26276
  init_community_workspace();
26184
- init_errors2();
26277
+ init_errors3();
26185
26278
  init_expected();
26186
26279
  init_course_files();
26187
26280
  init_listing();
@@ -26781,7 +26874,7 @@ __export(sync_exports2, {
26781
26874
  });
26782
26875
  import * as fs20 from "fs";
26783
26876
  import * as path29 from "path";
26784
- function parseArgs5(args2) {
26877
+ function parseArgs6(args2) {
26785
26878
  return {
26786
26879
  autoConfirm: args2.includes("--yes") || args2.includes("-y"),
26787
26880
  dryRun: args2.includes("--dry-run"),
@@ -27101,7 +27194,7 @@ function pushListing(plan, courses) {
27101
27194
  return listing;
27102
27195
  }
27103
27196
  async function pushCommunity(gitRootOrNull, selector, args2) {
27104
- const { autoConfirm, dryRun, theirs } = parseArgs5(args2);
27197
+ const { autoConfirm, dryRun, theirs } = parseArgs6(args2);
27105
27198
  if (theirs) throw expected("`--theirs` is a pull option: `wayai pull communities/<folder> --theirs` takes the server's side of a conflict.");
27106
27199
  const gitRoot = requireGitRoot2(gitRootOrNull);
27107
27200
  const target = resolveCommunityTarget(gitRoot, selector);
@@ -27320,7 +27413,7 @@ function pullMerge(files, server, plan, theirs) {
27320
27413
  return listing;
27321
27414
  }
27322
27415
  async function pullCommunity(gitRootOrNull, selector, args2) {
27323
- const { dryRun, theirs } = parseArgs5(args2);
27416
+ const { dryRun, theirs } = parseArgs6(args2);
27324
27417
  const gitRoot = requireGitRoot2(gitRootOrNull);
27325
27418
  const target = resolveCommunityTarget(gitRoot, selector);
27326
27419
  let existing = null;
@@ -27390,7 +27483,7 @@ var init_sync2 = __esm({
27390
27483
  "src/communities/sync.ts"() {
27391
27484
  "use strict";
27392
27485
  init_contracts();
27393
- init_errors2();
27486
+ init_errors3();
27394
27487
  init_expected();
27395
27488
  init_fs_safety();
27396
27489
  init_layout();
@@ -27503,7 +27596,7 @@ __export(push_exports, {
27503
27596
  import * as fs21 from "fs";
27504
27597
  import * as path30 from "path";
27505
27598
  import * as yaml15 from "js-yaml";
27506
- function parseArgs6(args2) {
27599
+ function parseArgs7(args2) {
27507
27600
  let autoConfirm = false;
27508
27601
  let label2;
27509
27602
  for (let i = 0; i < args2.length; i++) {
@@ -27989,7 +28082,7 @@ async function pushCommand(args2) {
27989
28082
  await pushCommunity2(gitRoot, route.selector, args2);
27990
28083
  return;
27991
28084
  }
27992
- const { autoConfirm, label: label2 } = parseArgs6(args2);
28085
+ const { autoConfirm, label: label2 } = parseArgs7(args2);
27993
28086
  const hubSelector = route.selector;
27994
28087
  const repoConfig = requireRepoConfig();
27995
28088
  const { organization_id: organizationId } = repoConfig;
@@ -28088,7 +28181,7 @@ __export(pull_exports, {
28088
28181
  });
28089
28182
  import * as fs22 from "fs";
28090
28183
  import * as path31 from "path";
28091
- function parseArgs7(args2) {
28184
+ function parseArgs8(args2) {
28092
28185
  return { autoConfirm: args2.includes("--yes") || args2.includes("-y") };
28093
28186
  }
28094
28187
  function resolveHubTarget(workspaceDir, selector) {
@@ -28134,7 +28227,7 @@ async function pullCommand(args2) {
28134
28227
  await pullCommunity2(gitRoot, route.selector, args2);
28135
28228
  return;
28136
28229
  }
28137
- const { autoConfirm } = parseArgs7(args2);
28230
+ const { autoConfirm } = parseArgs8(args2);
28138
28231
  const hubSelector = route.selector;
28139
28232
  const repoConfig = requireRepoConfig();
28140
28233
  const { organization_id: organizationId } = repoConfig;
@@ -28321,12 +28414,12 @@ var init_pull = __esm({
28321
28414
  var create_exports = {};
28322
28415
  __export(create_exports, {
28323
28416
  createCommand: () => createCommand,
28324
- parseArgs: () => parseArgs8,
28417
+ parseArgs: () => parseArgs9,
28325
28418
  reportNoNewHub: () => reportNoNewHub
28326
28419
  });
28327
28420
  import * as path32 from "path";
28328
28421
  import * as fs23 from "fs";
28329
- function parseArgs8(args2) {
28422
+ function parseArgs9(args2) {
28330
28423
  let autoConfirm = false;
28331
28424
  let folderSelector;
28332
28425
  let label2;
@@ -28356,7 +28449,7 @@ function reportNoNewHub(enclosing, existingHubs, wsLabel) {
28356
28449
  process.exit(1);
28357
28450
  }
28358
28451
  async function createCommand(args2) {
28359
- const { autoConfirm, folderSelector, label: label2 } = parseArgs8(args2);
28452
+ const { autoConfirm, folderSelector, label: label2 } = parseArgs9(args2);
28360
28453
  const repoConfig = requireRepoConfig();
28361
28454
  const { organization_id: organizationId } = repoConfig;
28362
28455
  const { config, accessToken } = await requireAuth();
@@ -28409,9 +28502,9 @@ var init_create = __esm({
28409
28502
  var diff_exports = {};
28410
28503
  __export(diff_exports, {
28411
28504
  diffCommand: () => diffCommand,
28412
- parseArgs: () => parseArgs9
28505
+ parseArgs: () => parseArgs10
28413
28506
  });
28414
- function parseArgs9(args2) {
28507
+ function parseArgs10(args2) {
28415
28508
  let production = false;
28416
28509
  let hubSelector;
28417
28510
  for (let i = 0; i < args2.length; i++) {
@@ -28425,7 +28518,7 @@ function parseArgs9(args2) {
28425
28518
  return { production, hubSelector };
28426
28519
  }
28427
28520
  async function diffCommand(args2) {
28428
- const { production, hubSelector } = parseArgs9(args2);
28521
+ const { production, hubSelector } = parseArgs10(args2);
28429
28522
  const repoConfig = requireRepoConfig();
28430
28523
  const { organization_id: organizationId } = repoConfig;
28431
28524
  const { config, accessToken } = await requireAuth();
@@ -28826,7 +28919,7 @@ __export(page_exports, {
28826
28919
  });
28827
28920
  import * as fs24 from "fs";
28828
28921
  import * as path33 from "path";
28829
- import { parseArgs as parseArgs10 } from "util";
28922
+ import { parseArgs as parseArgs11 } from "util";
28830
28923
  function usageError(message) {
28831
28924
  return expected(`${message}
28832
28925
  ${USAGE}`);
@@ -28834,7 +28927,7 @@ ${USAGE}`);
28834
28927
  function parsePageArgs(args2) {
28835
28928
  let parsed;
28836
28929
  try {
28837
- parsed = parseArgs10({ args: args2, options: OPTIONS, allowPositionals: true, strict: true });
28930
+ parsed = parseArgs11({ args: args2, options: OPTIONS, allowPositionals: true, strict: true });
28838
28931
  } catch (err) {
28839
28932
  throw usageError(err instanceof Error ? err.message : String(err));
28840
28933
  }
@@ -28947,12 +29040,12 @@ new: write a starter page, pages/<slug>/page.yaml and pages/<slug>/index.html, i
28947
29040
  // src/commands/replicate.ts
28948
29041
  var replicate_exports = {};
28949
29042
  __export(replicate_exports, {
28950
- parseArgs: () => parseArgs11,
29043
+ parseArgs: () => parseArgs12,
28951
29044
  replicateCommand: () => replicateCommand
28952
29045
  });
28953
29046
  import * as fs25 from "fs";
28954
29047
  import * as path34 from "path";
28955
- function parseArgs11(args2) {
29048
+ function parseArgs12(args2) {
28956
29049
  let label2;
28957
29050
  let hubFlag;
28958
29051
  let positional;
@@ -28974,7 +29067,7 @@ function parseArgs11(args2) {
28974
29067
  return { label: label2, hubSelector: hubFlag ?? positional };
28975
29068
  }
28976
29069
  async function replicateCommand(args2) {
28977
- const { label: label2, hubSelector } = parseArgs11(args2);
29070
+ const { label: label2, hubSelector } = parseArgs12(args2);
28978
29071
  const normalizedLabel = label2?.trim() || void 0;
28979
29072
  if (normalizedLabel && normalizedLabel.length > PREVIEW_LABEL_MAX_LENGTH) {
28980
29073
  console.error(`--label must be ${PREVIEW_LABEL_MAX_LENGTH} characters or fewer.`);
@@ -29050,11 +29143,11 @@ var init_replicate = __esm({
29050
29143
  // src/commands/relabel.ts
29051
29144
  var relabel_exports = {};
29052
29145
  __export(relabel_exports, {
29053
- parseArgs: () => parseArgs12,
29146
+ parseArgs: () => parseArgs13,
29054
29147
  relabelCommand: () => relabelCommand
29055
29148
  });
29056
29149
  import * as path35 from "path";
29057
- function parseArgs12(args2) {
29150
+ function parseArgs13(args2) {
29058
29151
  let label2;
29059
29152
  let clear = false;
29060
29153
  let hubSelector;
@@ -29076,7 +29169,7 @@ function parseArgs12(args2) {
29076
29169
  return { label: label2, clear, hubSelector };
29077
29170
  }
29078
29171
  async function relabelCommand(args2) {
29079
- const { label: label2, clear, hubSelector } = parseArgs12(args2);
29172
+ const { label: label2, clear, hubSelector } = parseArgs13(args2);
29080
29173
  if (!clear && (label2 === void 0 || label2.trim() === "")) {
29081
29174
  console.error("Usage: wayai relabel <label> [--hub <uuid|folder>] (or --clear to remove the label)");
29082
29175
  process.exit(1);
@@ -29150,13 +29243,13 @@ var init_relabel = __esm({
29150
29243
  // src/commands/publish.ts
29151
29244
  var publish_exports = {};
29152
29245
  __export(publish_exports, {
29153
- parseArgs: () => parseArgs13,
29246
+ parseArgs: () => parseArgs14,
29154
29247
  publishCommand: () => publishCommand,
29155
29248
  renderHubDiff: () => renderHubDiff,
29156
29249
  runPublish: () => runPublish
29157
29250
  });
29158
29251
  import * as path36 from "path";
29159
- function parseArgs13(args2) {
29252
+ function parseArgs14(args2) {
29160
29253
  let autoConfirm = false;
29161
29254
  let hubSelector;
29162
29255
  for (let i = 0; i < args2.length; i++) {
@@ -29246,7 +29339,7 @@ Published. Production hub: ${data2.production_hub_id}`);
29246
29339
  return "synced";
29247
29340
  }
29248
29341
  async function publishCommand(args2) {
29249
- const { autoConfirm, hubSelector } = parseArgs13(args2);
29342
+ const { autoConfirm, hubSelector } = parseArgs14(args2);
29250
29343
  const repoConfig = requireRepoConfig();
29251
29344
  const { organization_id: organizationId } = repoConfig;
29252
29345
  const { config, accessToken } = await requireAuth();
@@ -29949,7 +30042,7 @@ var init_cross_hub_conversations = __esm({
29949
30042
  "src/lib/cross-hub-conversations.ts"() {
29950
30043
  "use strict";
29951
30044
  init_api_client();
29952
- init_errors2();
30045
+ init_errors3();
29953
30046
  init_expected();
29954
30047
  MAX_CROSS_HUB_HUBS = 100;
29955
30048
  CROSS_HUB_CONCURRENCY = 6;
@@ -30838,10 +30931,10 @@ var init_delete_history = __esm({
30838
30931
  // src/commands/sync-skills.ts
30839
30932
  var sync_skills_exports = {};
30840
30933
  __export(sync_skills_exports, {
30841
- parseArgs: () => parseArgs14,
30934
+ parseArgs: () => parseArgs15,
30842
30935
  syncSkillsCommand: () => syncSkillsCommand
30843
30936
  });
30844
- function parseArgs14(args2) {
30937
+ function parseArgs15(args2) {
30845
30938
  let connectionId;
30846
30939
  const idx = args2.indexOf("--connection-id");
30847
30940
  if (idx !== -1 && args2[idx + 1]) {
@@ -30864,7 +30957,7 @@ function printSyncResults(response) {
30864
30957
  }
30865
30958
  async function syncSkillsCommand(args2) {
30866
30959
  const hubId = resolveActiveHubId(args2);
30867
- const { connectionId } = parseArgs14(args2);
30960
+ const { connectionId } = parseArgs15(args2);
30868
30961
  requireRepoConfig();
30869
30962
  const { config, accessToken } = await requireAuth();
30870
30963
  const client = new ApiClient({ apiUrl: config.api_url, accessToken });
@@ -30889,10 +30982,10 @@ var init_sync_skills = __esm({
30889
30982
  // src/commands/sync-mcp.ts
30890
30983
  var sync_mcp_exports = {};
30891
30984
  __export(sync_mcp_exports, {
30892
- parseArgs: () => parseArgs15,
30985
+ parseArgs: () => parseArgs16,
30893
30986
  syncMcpCommand: () => syncMcpCommand
30894
30987
  });
30895
- function parseArgs15(args2) {
30988
+ function parseArgs16(args2) {
30896
30989
  let connection;
30897
30990
  let check = false;
30898
30991
  for (let i = 0; i < args2.length; i++) {
@@ -30907,7 +31000,7 @@ function parseArgs15(args2) {
30907
31000
  }
30908
31001
  async function syncMcpCommand(args2) {
30909
31002
  const hubId = resolveActiveHubId(args2);
30910
- const { connection, check } = parseArgs15(args2);
31003
+ const { connection, check } = parseArgs16(args2);
30911
31004
  if (!connection) {
30912
31005
  console.error("Usage: wayai sync-mcp --connection <name> [--hub <uuid|folder-name>] [--check]");
30913
31006
  console.error("");
@@ -31167,7 +31260,7 @@ var FIXTURE_QUEUE_INITIAL_DELAY_MS, FIXTURE_QUEUE_MAX_DELAY_MS, QUEUEABLE_LAUNCH
31167
31260
  var init_eval_fixture_queue = __esm({
31168
31261
  "src/lib/eval-fixture-queue.ts"() {
31169
31262
  "use strict";
31170
- init_errors2();
31263
+ init_errors3();
31171
31264
  FIXTURE_QUEUE_INITIAL_DELAY_MS = 5e3;
31172
31265
  FIXTURE_QUEUE_MAX_DELAY_MS = 3e4;
31173
31266
  QUEUEABLE_LAUNCH_ERRORS = /* @__PURE__ */ new Set([
@@ -31505,7 +31598,7 @@ var init_run_eval = __esm({
31505
31598
  init_repo_config();
31506
31599
  init_workspace();
31507
31600
  init_api_client();
31508
- init_errors2();
31601
+ init_errors3();
31509
31602
  init_eval_format();
31510
31603
  init_dist();
31511
31604
  init_contracts();
@@ -33199,7 +33292,7 @@ var init_runner = __esm({
33199
33292
  "use strict";
33200
33293
  init_dist();
33201
33294
  init_contracts();
33202
- init_errors2();
33295
+ init_errors3();
33203
33296
  init_caller_audio();
33204
33297
  init_cost_cap();
33205
33298
  init_score();
@@ -33605,7 +33698,7 @@ var init_eval_call = __esm({
33605
33698
  init_workspace();
33606
33699
  init_api_client();
33607
33700
  init_utils();
33608
- init_errors2();
33701
+ init_errors3();
33609
33702
  init_terminal_output();
33610
33703
  init_eval_session_control();
33611
33704
  init_caller_audio();
@@ -33634,7 +33727,7 @@ function isValidSetName(name) {
33634
33727
  if (name.startsWith(".")) return false;
33635
33728
  return !/[\/\\\0]/.test(name);
33636
33729
  }
33637
- function parseArgs16(args2) {
33730
+ function parseArgs17(args2) {
33638
33731
  if (args2.length === 0 || args2[0].startsWith("-")) {
33639
33732
  console.error("Usage: wayai eval capture <conversation_id> [--set <name>] [--name <eval_name>] [--instructions <text>]");
33640
33733
  process.exit(1);
@@ -33680,7 +33773,7 @@ function parseArgs16(args2) {
33680
33773
  }
33681
33774
  async function evalCaptureCommand(args2) {
33682
33775
  const hubId = resolveActiveHubId(args2);
33683
- const parsed = parseArgs16(args2);
33776
+ const parsed = parseArgs17(args2);
33684
33777
  const { config, accessToken } = await requireAuth();
33685
33778
  requireRepoConfig();
33686
33779
  const client = new ApiClient({ apiUrl: config.api_url, accessToken });
@@ -33773,7 +33866,7 @@ var journey_capture_exports = {};
33773
33866
  __export(journey_capture_exports, {
33774
33867
  journeyCaptureCommand: () => journeyCaptureCommand
33775
33868
  });
33776
- function parseArgs17(args2) {
33869
+ function parseArgs18(args2) {
33777
33870
  if (args2.length === 0 || args2[0].startsWith("-")) {
33778
33871
  console.error("Usage: wayai eval journey capture <conversation_id> [--name <journey_name>] [--instructions <text>]");
33779
33872
  process.exit(1);
@@ -33808,7 +33901,7 @@ function parseArgs17(args2) {
33808
33901
  }
33809
33902
  async function journeyCaptureCommand(args2) {
33810
33903
  const hubId = resolveActiveHubId(args2);
33811
- const parsed = parseArgs17(args2);
33904
+ const parsed = parseArgs18(args2);
33812
33905
  const { config, accessToken } = await requireAuth();
33813
33906
  requireRepoConfig();
33814
33907
  const client = new ApiClient({ apiUrl: config.api_url, accessToken });
@@ -33971,7 +34064,7 @@ var init_eval_session_delete = __esm({
33971
34064
  init_repo_config();
33972
34065
  init_workspace();
33973
34066
  init_api_client();
33974
- init_errors2();
34067
+ init_errors3();
33975
34068
  init_contracts();
33976
34069
  init_utils();
33977
34070
  }
@@ -34753,9 +34846,9 @@ var init_credential_utils = __esm({
34753
34846
  var create_credential_exports = {};
34754
34847
  __export(create_credential_exports, {
34755
34848
  createCredentialCommand: () => createCredentialCommand,
34756
- parseArgs: () => parseArgs18
34849
+ parseArgs: () => parseArgs19
34757
34850
  });
34758
- function parseArgs18(args2) {
34851
+ function parseArgs19(args2) {
34759
34852
  let name;
34760
34853
  let type;
34761
34854
  let orgId;
@@ -34783,7 +34876,7 @@ function parseArgs18(args2) {
34783
34876
  return { name, type, orgId, description: description2, tags: splitTagRefs(tags), environment, stdin };
34784
34877
  }
34785
34878
  async function createCredentialCommand(args2) {
34786
- const parsed = parseArgs18(args2);
34879
+ const parsed = parseArgs19(args2);
34787
34880
  if (!parsed.name) {
34788
34881
  console.error("Missing required flag: --name <credential-name>");
34789
34882
  console.error('Usage: wayai create-credential --name "openai-key" --type "Bearer Token"');
@@ -34890,10 +34983,10 @@ var init_create_credential = __esm({
34890
34983
  // src/commands/update-credential.ts
34891
34984
  var update_credential_exports = {};
34892
34985
  __export(update_credential_exports, {
34893
- parseArgs: () => parseArgs19,
34986
+ parseArgs: () => parseArgs20,
34894
34987
  updateCredentialCommand: () => updateCredentialCommand
34895
34988
  });
34896
- function parseArgs19(args2) {
34989
+ function parseArgs20(args2) {
34897
34990
  let name;
34898
34991
  let rename;
34899
34992
  let orgId;
@@ -34926,7 +35019,7 @@ function parseArgs19(args2) {
34926
35019
  return { name, rename, orgId, description: description2, tags: splitTagRefs(tags), hasTagFlag, environment, stdin, secretPrompt };
34927
35020
  }
34928
35021
  async function updateCredentialCommand(args2) {
34929
- const parsed = parseArgs19(args2);
35022
+ const parsed = parseArgs20(args2);
34930
35023
  if (!parsed.name) {
34931
35024
  console.error("Missing required flag: --name <credential-name>");
34932
35025
  console.error('Usage: wayai update-credential --name "my-key" --stdin');
@@ -35039,10 +35132,10 @@ var init_update_credential = __esm({
35039
35132
  // src/commands/set-connection-credential.ts
35040
35133
  var set_connection_credential_exports = {};
35041
35134
  __export(set_connection_credential_exports, {
35042
- parseArgs: () => parseArgs20,
35135
+ parseArgs: () => parseArgs21,
35043
35136
  setConnectionCredentialCommand: () => setConnectionCredentialCommand
35044
35137
  });
35045
- function parseArgs20(args2) {
35138
+ function parseArgs21(args2) {
35046
35139
  let connection;
35047
35140
  let orgCredential;
35048
35141
  let field;
@@ -35065,7 +35158,7 @@ function usage2(msg) {
35065
35158
  }
35066
35159
  async function setConnectionCredentialCommand(args2) {
35067
35160
  const hubId = resolveActiveHubId(args2);
35068
- const parsed = parseArgs20(args2);
35161
+ const parsed = parseArgs21(args2);
35069
35162
  if (!parsed.connection) usage2("Missing required flag: --connection <name|id>");
35070
35163
  const orgMode = !!parsed.orgCredential;
35071
35164
  const directMode = !!parsed.field;
@@ -35422,7 +35515,7 @@ var init_org = __esm({
35422
35515
  init_layout();
35423
35516
  init_utils();
35424
35517
  init_diff_display();
35425
- init_errors2();
35518
+ init_errors3();
35426
35519
  init_org_workspace();
35427
35520
  }
35428
35521
  });
@@ -35431,9 +35524,9 @@ var init_org = __esm({
35431
35524
  var list_exports = {};
35432
35525
  __export(list_exports, {
35433
35526
  listCommand: () => listCommand,
35434
- parseArgs: () => parseArgs21
35527
+ parseArgs: () => parseArgs22
35435
35528
  });
35436
- function parseArgs21(args2) {
35529
+ function parseArgs22(args2) {
35437
35530
  let orgId;
35438
35531
  let json = false;
35439
35532
  for (let i = 0; i < args2.length; i++) {
@@ -35446,7 +35539,7 @@ function parseArgs21(args2) {
35446
35539
  return { orgId, json };
35447
35540
  }
35448
35541
  async function listCommand(args2) {
35449
- const { orgId, json } = parseArgs21(args2);
35542
+ const { orgId, json } = parseArgs22(args2);
35450
35543
  const { config, accessToken } = await requireAuth();
35451
35544
  const client = new ApiClient({ apiUrl: config.api_url, accessToken });
35452
35545
  const { organizations } = await client.organizations();
@@ -35603,10 +35696,10 @@ var communities_exports = {};
35603
35696
  __export(communities_exports, {
35604
35697
  communitiesCommand: () => communitiesCommand
35605
35698
  });
35606
- import { parseArgs as parseArgs22 } from "util";
35699
+ import { parseArgs as parseArgs23 } from "util";
35607
35700
  function parse(args2) {
35608
35701
  try {
35609
- const { values, positionals } = parseArgs22({
35702
+ const { values, positionals } = parseArgs23({
35610
35703
  args: args2,
35611
35704
  options: { org: { type: "string" }, json: { type: "boolean" }, yes: { type: "boolean", short: "y" } },
35612
35705
  allowPositionals: true,
@@ -35909,7 +36002,7 @@ var init_communities = __esm({
35909
36002
  "use strict";
35910
36003
  init_contracts();
35911
36004
  init_api_client();
35912
- init_errors2();
36005
+ init_errors3();
35913
36006
  init_expected();
35914
36007
  init_repo_config();
35915
36008
  init_terminal_output();
@@ -35963,7 +36056,7 @@ var contacts_exports = {};
35963
36056
  __export(contacts_exports, {
35964
36057
  contactsCommand: () => contactsCommand
35965
36058
  });
35966
- import { parseArgs as parseArgs23 } from "util";
36059
+ import { parseArgs as parseArgs24 } from "util";
35967
36060
  function usageError3(message) {
35968
36061
  return expected(`${message}
35969
36062
 
@@ -35971,7 +36064,7 @@ ${USAGE4}`);
35971
36064
  }
35972
36065
  function parse2(args2) {
35973
36066
  try {
35974
- return parseArgs23({
36067
+ return parseArgs24({
35975
36068
  args: args2,
35976
36069
  options: {
35977
36070
  org: { type: "string" },
@@ -36116,7 +36209,7 @@ var init_contacts = __esm({
36116
36209
  "use strict";
36117
36210
  init_auth();
36118
36211
  init_api_client();
36119
- init_errors2();
36212
+ init_errors3();
36120
36213
  init_expected();
36121
36214
  init_repo_config();
36122
36215
  init_terminal_output();
@@ -36175,7 +36268,7 @@ var dimensions_exports = {};
36175
36268
  __export(dimensions_exports, {
36176
36269
  dimensionsCommand: () => dimensionsCommand
36177
36270
  });
36178
- import { parseArgs as parseArgs24 } from "util";
36271
+ import { parseArgs as parseArgs25 } from "util";
36179
36272
  function usageError4(message) {
36180
36273
  return expected(`${message}
36181
36274
 
@@ -36183,7 +36276,7 @@ ${USAGE5}`);
36183
36276
  }
36184
36277
  function parse3(args2) {
36185
36278
  try {
36186
- return parseArgs24({
36279
+ return parseArgs25({
36187
36280
  args: args2,
36188
36281
  options: {
36189
36282
  org: { type: "string" },
@@ -36288,7 +36381,7 @@ var init_dimensions = __esm({
36288
36381
  "use strict";
36289
36382
  init_auth();
36290
36383
  init_api_client();
36291
- init_errors2();
36384
+ init_errors3();
36292
36385
  init_expected();
36293
36386
  init_repo_config();
36294
36387
  init_terminal_output();
@@ -36337,7 +36430,7 @@ __export(access_exports, {
36337
36430
  accessCommand: () => accessCommand,
36338
36431
  formatExplanation: () => formatExplanation
36339
36432
  });
36340
- import { parseArgs as parseArgs25 } from "util";
36433
+ import { parseArgs as parseArgs26 } from "util";
36341
36434
  function usageError5(message) {
36342
36435
  return expected(`${message}
36343
36436
 
@@ -36345,7 +36438,7 @@ ${USAGE6}`);
36345
36438
  }
36346
36439
  function parse4(args2) {
36347
36440
  try {
36348
- return parseArgs25({
36441
+ return parseArgs26({
36349
36442
  args: args2,
36350
36443
  options: {
36351
36444
  hub: { type: "string" },
@@ -36458,7 +36551,7 @@ var init_access = __esm({
36458
36551
  "use strict";
36459
36552
  init_auth();
36460
36553
  init_api_client();
36461
- init_errors2();
36554
+ init_errors3();
36462
36555
  init_expected();
36463
36556
  init_terminal_output();
36464
36557
  init_utils();
@@ -37500,20 +37593,20 @@ __export(knowledge_exports, {
37500
37593
  knowledgeCommand: () => knowledgeCommand,
37501
37594
  parseKnowledgeArgs: () => parseKnowledgeArgs
37502
37595
  });
37503
- import { parseArgs as parseArgs26 } from "util";
37596
+ import { parseArgs as parseArgs27 } from "util";
37504
37597
  function usageError6(message) {
37505
37598
  return expected(`${message}
37506
37599
  ${USAGE7}`);
37507
37600
  }
37508
37601
  function readArgs(args2) {
37509
37602
  try {
37510
- return parseArgs26({ args: args2, options: OPTIONS2, allowPositionals: true, strict: true });
37603
+ return parseArgs27({ args: args2, options: OPTIONS2, allowPositionals: true, strict: true });
37511
37604
  } catch (err) {
37512
37605
  throw usageError6(err instanceof Error ? err.message : String(err));
37513
37606
  }
37514
37607
  }
37515
37608
  function parseKnowledgeArgs(args2) {
37516
- 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;
37517
37610
  if (retired !== void 0 && RETIRED_VERBS.has(retired)) {
37518
37611
  throw expected(
37519
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\`).`
@@ -37629,6 +37722,10 @@ async function adminCommand(args2) {
37629
37722
  }
37630
37723
  const [sub, ...rest] = afterGroup;
37631
37724
  const { positional, flagArgs } = splitArgs(rest);
37725
+ if (group === "second-factor-reset") {
37726
+ await runSecondFactorReset(sub);
37727
+ return;
37728
+ }
37632
37729
  if (group === "do") {
37633
37730
  if (!sub) {
37634
37731
  printHelp2();
@@ -37974,6 +38071,16 @@ function splitArgs(args2) {
37974
38071
  }
37975
38072
  return { positional, flagArgs };
37976
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
+ }
37977
38084
  async function runDoTables(positional) {
37978
38085
  if (positional.length < 2) {
37979
38086
  console.error("wayai admin do tables <type> <id>");
@@ -39807,6 +39914,7 @@ function printHelp2() {
39807
39914
  wayai admin \u2014 platform-admin diagnostic commands
39808
39915
 
39809
39916
  Usage:
39917
+ wayai admin second-factor-reset <user_id> Remove a person's two-step verification (confirm who is asking first)
39810
39918
  wayai admin do tables <type> <id>
39811
39919
  wayai admin do read <type> <id> <table> [--limit N] [--id X] [--json]
39812
39920
  wayai admin do counts <hub|org> <id> [--json] Numbers, no text: a hub's toolset connections, knowledge placeholders per stored
@@ -40059,7 +40167,7 @@ var init_admin = __esm({
40059
40167
  init_workspace();
40060
40168
  init_skill_version();
40061
40169
  init_file_map();
40062
- init_errors2();
40170
+ init_errors3();
40063
40171
  init_contracts();
40064
40172
  VALID_TYPES = dataExplorerDebugDoType.options;
40065
40173
  VALID_ANALYTICS_TABLES = dataExplorerDebugAnalyticsTable.options;
@@ -40114,7 +40222,8 @@ var init_admin = __esm({
40114
40222
  ["elevenlabs", [
40115
40223
  "8a1a1917-3559-4858-bdef-313991341277",
40116
40224
  "a1b2c3d4-e5f6-4789-a012-3456789abcde"
40117
- ]]
40225
+ ]],
40226
+ ["typesafe", ["0da558b0-e4b6-43f4-b945-aeaf432965e2"]]
40118
40227
  ]);
40119
40228
  VAULT_GATE_BY_ID_ONLY = /* @__PURE__ */ new Map([
40120
40229
  ["01e7b19c-bc94-43f4-a780-ad5a22fb7127", "openai"]
@@ -43193,7 +43302,7 @@ var init_program = __esm({
43193
43302
 
43194
43303
  // src/index.ts
43195
43304
  init_sentry();
43196
- init_errors2();
43305
+ init_errors3();
43197
43306
  init_mask_secrets();
43198
43307
  init_utils();
43199
43308
  init_registry();
@@ -43379,6 +43488,11 @@ async function main() {
43379
43488
  }
43380
43489
  }
43381
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
+ }
43382
43496
  case "login": {
43383
43497
  const { loginCommand: loginCommand2 } = await Promise.resolve().then(() => (init_login(), login_exports));
43384
43498
  await loginCommand2(args);
@@ -43625,6 +43739,7 @@ Commands:
43625
43739
  logout Clear stored credentials
43626
43740
  status Show current auth and config status
43627
43741
  whoami Show the authenticated identity (supports --json)
43742
+ 2fa verify Enter a two-step code for this session (--recovery for a recovery code)
43628
43743
  init Scope this repo to an organization (pick one)
43629
43744
  create-credential Create an organization credential (API key, token, etc.)
43630
43745
  update-credential Update / rotate an organization credential (by name)