@wayai/cli 0.3.115 → 0.3.117

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
@@ -5937,6 +5937,50 @@ function refineHubAsCodeResources(config, ctx) {
5937
5937
  });
5938
5938
  }
5939
5939
  }
5940
+ function refineHubAsCodeDelegation(config, ctx) {
5941
+ const agents = config?.agents;
5942
+ if (!Array.isArray(agents)) return;
5943
+ agents.forEach((agent, agentIndex) => {
5944
+ const delegation = agent?.tools?.delegation;
5945
+ if (!Array.isArray(delegation)) return;
5946
+ delegation.forEach((entry, delIndex) => {
5947
+ const del = entry;
5948
+ if (del.allow_consultant_chain !== void 0) {
5949
+ const chainPath = ["agents", agentIndex, "tools", "delegation", delIndex, "allow_consultant_chain"];
5950
+ if (typeof del.allow_consultant_chain !== "boolean") {
5951
+ ctx.addIssue({
5952
+ code: external_exports.ZodIssueCode.custom,
5953
+ path: chainPath,
5954
+ message: "allow_consultant_chain must be a boolean"
5955
+ });
5956
+ } else if (del.tool !== "start_consult_thread") {
5957
+ ctx.addIssue({
5958
+ code: external_exports.ZodIssueCode.custom,
5959
+ path: chainPath,
5960
+ message: `allow_consultant_chain applies only to \`tool: start_consult_thread\` (got "${String(del.tool)}")`
5961
+ });
5962
+ }
5963
+ }
5964
+ if (del.context_boundary === void 0) return;
5965
+ const path31 = ["agents", agentIndex, "tools", "delegation", delIndex, "context_boundary"];
5966
+ if (del.type !== "hub") {
5967
+ ctx.addIssue({
5968
+ code: external_exports.ZodIssueCode.custom,
5969
+ path: path31,
5970
+ message: `context_boundary applies only to \`type: hub\` delegations (got type "${String(del.type)}")`
5971
+ });
5972
+ return;
5973
+ }
5974
+ if (!CONTEXT_BOUNDARIES.includes(del.context_boundary)) {
5975
+ ctx.addIssue({
5976
+ code: external_exports.ZodIssueCode.custom,
5977
+ path: path31,
5978
+ message: `context_boundary must be one of: ${CONTEXT_BOUNDARIES.join(", ")}`
5979
+ });
5980
+ }
5981
+ });
5982
+ });
5983
+ }
5940
5984
  function identifyTokenType(token) {
5941
5985
  if (token.startsWith("way_")) return "way_token";
5942
5986
  if (token.startsWith("eyJ")) return "jwt";
@@ -5976,7 +6020,7 @@ function findStepBoundaries(transcript) {
5976
6020
  }
5977
6021
  return out;
5978
6022
  }
5979
- var UUID_RE, HEX_RE, WORKOS_ID_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, APP_ERROR_BRAND, AppError, 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, AUTH_TYPE, ORG_CREDENTIAL_AUTH_TYPES, AUTH_TYPE_DISPLAY, LEGACY_AUTH_TYPE_MAP, VALID_AUTH_TYPES, AGENT_ROLES, SAFE_USER_ID_REGEX, SUPPORTED_LOCALES, uuidSchema, paginationSchema, timestampSchema, idParamSchema, clientOptionalString, clientOptionalBoolean, clientOptionalNumber, messageAttachment, MAX_MESSAGE_BODY_BYTES, MAX_ATTACHMENTS_PER_MESSAGE, MAX_AUDIO_FILE_BASE64_BYTES, primaryRegionSchema, placementSourceSchema, orgIdParam, orgAdminIdParam, createOrganizationBody, updateOrganizationBody, addOrgAdminBody, SUMMARIZATION_THRESHOLD_MIN, SUMMARIZATION_THRESHOLD_MAX, summarizationThresholdField, monitorConfigField, agentIdParam, listAgentsQuery, agentConnectionsQuery, createAgentBody, updateAgentBody, AGENT_PARAMETER_TYPES, AGENT_PARAMETER_NAME_REGEX, agentParameterCreateSchema, MAX_AGENT_PARAMETERS_PER_REQUEST, createAgentParametersBody, SLUG_REGEX, slugSchema, INVISIBLE_NAME_CHARS, MAX_KANBAN_STATUSES, MAX_FOLLOWUPS_PER_STATUS, MAX_LANES, MAX_ADDITIONAL_CONTEXT_SCHEMA_BYTES, RESERVED_TEMPLATE_DUMP_NAME, kanbanStatusSlugSchema, followupSchema, MAX_OUTCOMES_PER_STATUS, kanbanOutcomeSchema, EXCLUSIVE_FLAG_PAIRS, kanbanStatusSchema, kanbanStatusesArraySchema, laneSchema, lanesArraySchema, hubIdParam, hubAdminIdParam, hubUserIdParam, hubIdentityIdParam, hubTeamIdParam, hubTeamUserDeleteParam, hubSchemaQuery, PREVIEW_LABEL_MAX_LENGTH, MAX_ENDED_INDEX_RETENTION_DAYS, previewLabelField, createHubBody, updateHubBody, addHubAdminBody, addHubIdentityAuthorizationBody, contactDecisionBody, approveContactBody, listContactAccessQuery, createHubTeamBody, updateHubTeamBody, addHubTeamUserBody, reassignHubUserBody, replicatePreviewBody, updateChannelTestIdentitiesBody, claimCodeChannelParam, claimCodeDeleteParam, connectionIdParam, connectorIdParam, listConnectionsQuery, deleteConnectionQuery, addConnectionBody, editConnectionBody, PRODUCTION_DIRECT_FIELDS, setProductionCredentialBody, registerWhatsappQuery, registerWhatsappBody, retryProvisioningQuery, resendDomainStatusQuery, PLACEHOLDER_TOKENS, ALLOWED_TYPES, SUBSCHEMA_OBJECT_KEYWORDS, SUBSCHEMA_LIST_KEYWORDS, SUBSCHEMA_MAP_KEYWORDS, MAX_SCHEMA_DEPTH, toolIdParam, listToolsQuery, toolAgentQuery, deleteToolQuery, toolConnectionsQuery, nativeToolIdSchema, addNativeToolBody, addMcpToolBody, createCustomToolBody, updateCustomToolBody, updateToolExecutionConfigBody, initialValueCreateSchema, initialValueUpdateSchema, stateIdParam, listStatesQuery, stateNameSchema, createStateBody, updateStateBody, reorderStatesBody, variantAiModeSchema, experimentStatusSchema, overlayUpdateSchema, experimentIdParam, variantIdParam, listExperimentsQuery, listVariantsQuery, listOverridesQuery, deleteOverrideQuery, createExperimentBody, updateExperimentBody, setExperimentStatusBody, createVariantBody, updateVariantBody, upsertOverrideBody, orgTagIdParam, listOrgTagsQuery, createOrgTagBody, updateOrgTagBody, orgCredentialIdParam, listOrgCredentialsQuery, createOrgCredentialBody, updateOrgCredentialBody, orgResourceIdParam, orgResourceFileIdParam, orgResourceFolderIdParam, hubOrgResourceParam, listOrgResourcesQuery, orgIdQuery, createOrgResourceBody, updateOrgResourceBody, createOrgResourceFolderBody, updateOrgResourceFolderBody, uploadOrgResourceFileBody, updateOrgResourceFileBody, uploadOrgSkillZipBody, linkOrgResourceBody, resourceIdParam, listResourcesQuery, createResourceBody, updateResourceBody, syncSkillsBody, resourceFileIdParam, listResourceFilesQuery, createResourceFileBody, updateResourceFileBody, uploadResourceFileBody, uploadSkillZipBody, resourceFolderIdParam, listResourceFoldersQuery, createResourceFolderBody, updateResourceFolderBody, agentResourceQuery, hubResourceQuery, linkAgentResourceBody, updateAgentResourceBody, unlinkAgentResourceQuery, navItemSchema, hubCountResetBody, navItemCountResetBody, typingBody, analyticsHubIdParam, analyticsVariableIdParam, updateVariablePinBody, updateAnalyticsViewBody, NUMERIC_FILTER_OPS, TEXT_FILTER_OPS, CATEGORICAL_FILTER_OPS, VARIABLE_FILTER_OPS, STRUCTURED_QUERY_OPS, STRUCTURED_QUERY_AGGREGATIONS, filterValueSchema, conversationsBody, analyticsConversationIdParam, messagesQuery, conversationDetailDataQuery, analyticsDataBody, structuredQueryBody, analyticsSqlBody, analyticsSqlSchemaQuery, EVAL_PACING_PRESET_NAMES, PACING_INTERVAL_MIN_MS, PACING_INTERVAL_MAX_MS, EVAL_RUN_DEADLINE_MIN_MS, EVAL_RUN_DEADLINE_MAX_MS, paginationSchema2, evalIdParam, sessionIdParam, scenarioSetIdParam, hubIdQuery, EVAL_INPUT_ROLES, EVAL_INPUT_ROLE_LIST, ROLE_ECHO_MAX, EVAL_INITIAL_STATE_SCOPES, MAX_INITIAL_STATE_ENTRIES, evalInitialStateEntry, createEvalBody, updateEvalBody, getEvalsQuery, toggleEvalBody, bulkToggleEvalsBody, pacingConfigSchema, sessionConfigSchema, createSessionBody, getSessionsQuery, getSessionResultsQuery, getSessionRunsQuery, evalAnalyticsQuery, getSessionCostQuery, compareSessionsQuery, evalsSqlBody, evalsSqlSchemaQuery, exportResultsQuery, validateEvalBody, hubAgentsQuery, createScenarioSetBody, updateScenarioSetBody, scenarioSetsHubQuery, createScenarioFromConversationBody, createJourneyFromConversationBody, EVAL_ATTACHMENT_HASH_REGEX, evalAttachmentRef, turnMayCarryAttachments, ATTACHMENTS_USER_ONLY_MESSAGE, journeyIdParam, journeyToolCallSchema, journeyTurnSchema, journeyStepOverrideSchema, fixtureField, createJourneyBody, updateJourneyBody, getConversationsQuery, getMessagesQuery, appMessageSenderType, appMessageReceiverType, apiChannelMessage, apiChannelMessageBody, appMessageBody, updateUserBody, updateProfileBody, pathnameRegex, updatePreferencesBody, registerPushTokenBody, deletePushTokenQuery, activityQuery, deletionModeSchema, deletionRequestBody, templateLocaleSchema, TEMPLATE_SLUG_REGEX, templateSlugSchema, templateStatusSchema, templateFileMapSchema, templateTextSchema, templateUsesEntrySchema, templateUsesSchema, templateYamlLocaleEntry, templateYamlWayaiBlock, templateTagsSchema, templateYamlSchema, templateHeroSchema, templatePushLocaleSchema, templatePushBody, templateListQuery, templateSlugParam, templateDetailQuery, courseQuizScoreSchema, upsertCourseLessonBody, linkCourseCapstoneBody, archiveHubIdParam, archiveConversationParams, archiveListQuery, archiveMessageObservabilityParams, conversationIdParam, claimBody, releaseBody, transferBody, closeBody, additionalContextPayloadSchema, kanbanUpdateBody, annotateConversationBody, observabilityParams, observabilityListParams, deleteUserConversationsBody, sendMessageBody, listConversationsQuery, getConversationDetailParams, getConversationDetailQuery, listWhatsAppTemplatesQuery, sendWhatsAppTemplateBody, billingOrgIdParam, subscriptionItemParams, spendCapBody, growthPacksBody, portalSessionBody, checkoutSessionBody, updateBillingCurrencyBody, invoicesQuery, downloadBody, uploadQuery, signUrlBody, outboundSchemaQuery, templateIdParam, listTemplatesQuery, deleteTemplateQuery, templateStatusQuery, createTemplateBody, updateTemplateBody, submitTemplateBody, testTemplateBody, contactIdParam, listContactsQuery, createContactBody, updateContactBody, listIdParam, listListsQuery, listListContactsQuery, createListBody, updateListBody, addListContactsBody, removeListContactsBody, scheduleIdParam, listSchedulesQuery, listExecutionsQuery, createScheduleBody, updateScheduleBody, MAX_RESOURCE_FILE_SIZE, MAX_10MB_BASE64_ENCODED_BYTES, MAX_EVAL_ATTACHMENT_ENCODED_BYTES, MAX_EVAL_ATTACHMENT_CARRIERS, MAX_EVAL_ATTACHMENT_AGGREGATE_ENCODED_BYTES, MAX_RESOURCE_ENCODED_BYTES, MAX_HUB_AS_CODE_RESOURCES, MAX_HUB_AS_CODE_RESOURCE_FILES, MAX_RESOURCE_AGGREGATE_ENCODED_BYTES, MAX_CI_CONFIG_BODY_BYTES, hubAsCodeResourceFileSchema, hubAsCodeResourceSchema, uuidPattern, ciUuidSchema, boundedHubAsCodeResourcesSchema, hubAsCodeConfigSchema, ciPullHubIdParam, ciBranchParam, ciPullQuery, ciHubsQuery, ciLookupQuery, ciBranchesQuery, ciSyncBody, ciPushBody, ciDiffBody, ciPublishBody, ciPublishPreviewBody, ciSyncMcpBody, ciOrgResourcesParam, orgResourcesConfigSchema, ciOrgResourcesPushBody, ciOrgResourcesDiffBody, adminOrgIdParam, adminOrgAdminIdParam, adminUserIdParam, adminPlanIdParam, adminOrganizationsQuery, adminUserSearchQuery, kanbanSlugMigrationQuery, adjustQuotaBody, updatePlanBody, addAdminUserBody, updatePlatformConfigBody, updateFreeOrgLimitBody, adminScopedTargetBody, updatePricingPlanBody, dataExplorerSearchQuery, dataExplorerOrgIdParam, dataExplorerHubIdParam, dataExplorerConvIdParam, dataExplorerDoInstancesQuery, dataExplorerNsIdParam, dataExplorerKvKeysQuery, dataExplorerKvKeyParam, uuidOrHexId, dataExplorerDeleteOrgParam, dataExplorerDeleteHubParam, dataExplorerDeleteConvParam, dataExplorerDeleteUserParam, dataExplorerDeleteQuery, dataExplorerKvDeleteQuery, pitrDoNamespace, pitrBookmarkParam, pitrRestoreBody, healthSamplingTriggerBody, dataExplorerDebugDoType, DEBUG_READ_MAX_LIMIT, DEBUG_READ_DEFAULT_LIMIT, DEBUG_DO_HEX_PREFIX, debugDoEntityId, debugTableName, dataExplorerDebugTablesParam, dataExplorerDebugRowsParam, dataExplorerDebugRowsQuery, dataExplorerDebugAnalyticsTable, debugUuid, dataExplorerDebugAnalyticsRowsParam, dataExplorerDebugAnalyticsRowsQuery, debugHubConvParam, debugMessageIdQuery, sandboxEgressPolicy, SANDBOX_EXEC_MAX_CMD_LENGTH, SANDBOX_EXEC_MAX_ALLOWLIST, SANDBOX_EXEC_MAX_TIMEOUT_MS, adminSandboxExecBody, whatsappCallbackBody, authMeResponse, wsTicketResponse, sessionCheckResponse, logoutResponse, magicCodeSendBody, magicCodeSendResponse, magicCodeVerifyBody, magicCodeVerifyResponse, passwordLoginBody, browserParams, browserFoldersQuery, browserFilesQuery, stateOperationBody, conversationListResourcesQuery, conversationReadResourceQuery, listPendingSchedulesQuery, listHubAggregateSchedulesQuery, reportSourceSchema, intakeReportSourceSchema, reportClassificationSchema, reportStatusSchema, reportLocaleSchema, reportMessageAuthorRoleSchema, reportMessageSchema, sentryRefStatusSchema, createReportBody, editReportBody, reporterReportSummarySchema, reporterListResponseSchema, getReportResponseSchema, reporterTransitionResponseSchema, contestReportBody, reporterListQuery, listReportsQuery, GITHUB_ISSUE_URL_REGEX, githubIssueUrlSchema, transitionReportBody, groupReportsBody, holdReportBody, clickhouseReadyResponse, bootstrapQuery, requestSnapshotChunkMessage, MAX_NAME_LENGTH, MAX_VALUE_LENGTH, MAX_TAGS, MAX_TAG_LENGTH, MAX_SCOPE_HUBS, MAX_SCOPE_TAGS, vaultSecretScopeSchema, vaultCreateBody, vaultUpdateBody, PERMISSIONS, MAX_NAME_LENGTH2, MAX_HUBS_PER_GRANT, MAX_HUB_TAGS_PER_GRANT, MAX_GRANTS, permissionEnum, grantScopeSchema, grantSchema, createTokenBody, tokenOrgIdParam, tokenGrantScopeSchema, tokenGrantSchema, tokenMetadataSchema, listTokensResponse, createTokenResponse, orgTokenSummarySchema, listOrgTokensResponse, invitePreviewQuery, invitePreviewResponse, discordTier, discordBillingCycle, discordMetadata, discordOAuthStartResponse, discordOAuthFinalizeBody, discordOAuthFinalizeResponse, discordDisconnectResponse, jsonSchemaSchema, hubUserIdentity, stateValueEntry, getHubUserContextResponse, updateHubUserBody, updateHubUserResponse, unlockHubUserNameResponse, stateResetParams, stateResetResponse, hubAlertsParam, hubAlertSeverity, hubAlert, hubAlertsListResponse, noticeSeveritySchema, noticeStatusSchema, NOTICE_SCOPE_REGEX, noticeScopeSchema, noticeLinkSchema, createNoticeBody, updateNoticeBody, listNoticesQuery, noticeIdParamSchema, ADMIN_SKILL_NAME_REGEX, adminSkillNameParam, WAYAI_WORKSPACE_LAYOUT;
6023
+ var UUID_RE, HEX_RE, WORKOS_ID_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, APP_ERROR_BRAND, AppError, 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, AUTH_TYPE, ORG_CREDENTIAL_AUTH_TYPES, AUTH_TYPE_DISPLAY, LEGACY_AUTH_TYPE_MAP, VALID_AUTH_TYPES, AGENT_ROLES, SAFE_USER_ID_REGEX, SUPPORTED_LOCALES, uuidSchema, paginationSchema, timestampSchema, idParamSchema, clientOptionalString, clientOptionalBoolean, clientOptionalNumber, messageAttachment, MAX_MESSAGE_BODY_BYTES, MAX_ATTACHMENTS_PER_MESSAGE, MAX_AUDIO_FILE_BASE64_BYTES, primaryRegionSchema, placementSourceSchema, orgIdParam, orgAdminIdParam, createOrganizationBody, updateOrganizationBody, addOrgAdminBody, SUMMARIZATION_THRESHOLD_MIN, SUMMARIZATION_THRESHOLD_MAX, summarizationThresholdField, monitorConfigField, agentIdParam, listAgentsQuery, agentConnectionsQuery, createAgentBody, updateAgentBody, AGENT_PARAMETER_TYPES, AGENT_PARAMETER_NAME_REGEX, agentParameterCreateSchema, MAX_AGENT_PARAMETERS_PER_REQUEST, createAgentParametersBody, SLUG_REGEX, slugSchema, INVISIBLE_NAME_CHARS, MAX_KANBAN_STATUSES, MAX_FOLLOWUPS_PER_STATUS, MAX_LANES, MAX_ADDITIONAL_CONTEXT_SCHEMA_BYTES, RESERVED_TEMPLATE_DUMP_NAME, kanbanStatusSlugSchema, followupSchema, MAX_OUTCOMES_PER_STATUS, kanbanOutcomeSchema, EXCLUSIVE_FLAG_PAIRS, kanbanStatusSchema, kanbanStatusesArraySchema, laneSchema, lanesArraySchema, hubIdParam, hubAdminIdParam, hubUserIdParam, hubIdentityIdParam, hubTeamIdParam, hubTeamUserDeleteParam, hubSchemaQuery, PREVIEW_LABEL_MAX_LENGTH, MAX_ENDED_INDEX_RETENTION_DAYS, previewLabelField, createHubBody, updateHubBody, addHubAdminBody, addHubIdentityAuthorizationBody, contactDecisionBody, approveContactBody, listContactAccessQuery, createHubTeamBody, updateHubTeamBody, addHubTeamUserBody, reassignHubUserBody, replicatePreviewBody, updateChannelTestIdentitiesBody, claimCodeChannelParam, claimCodeDeleteParam, connectionIdParam, connectorIdParam, listConnectionsQuery, deleteConnectionQuery, addConnectionBody, editConnectionBody, PRODUCTION_DIRECT_FIELDS, setProductionCredentialBody, registerWhatsappQuery, registerWhatsappBody, retryProvisioningQuery, resendDomainStatusQuery, PLACEHOLDER_TOKENS, ALLOWED_TYPES, SUBSCHEMA_OBJECT_KEYWORDS, SUBSCHEMA_LIST_KEYWORDS, SUBSCHEMA_MAP_KEYWORDS, MAX_SCHEMA_DEPTH, toolIdParam, listToolsQuery, toolAgentQuery, deleteToolQuery, toolConnectionsQuery, nativeToolIdSchema, CONTEXT_BOUNDARIES, contextBoundarySchema, addNativeToolBody, addMcpToolBody, createCustomToolBody, updateCustomToolBody, updateToolExecutionConfigBody, initialValueCreateSchema, initialValueUpdateSchema, stateIdParam, listStatesQuery, stateNameSchema, createStateBody, updateStateBody, reorderStatesBody, variantAiModeSchema, experimentStatusSchema, overlayUpdateSchema, experimentIdParam, variantIdParam, listExperimentsQuery, listVariantsQuery, listOverridesQuery, deleteOverrideQuery, createExperimentBody, updateExperimentBody, setExperimentStatusBody, createVariantBody, updateVariantBody, upsertOverrideBody, orgTagIdParam, listOrgTagsQuery, createOrgTagBody, updateOrgTagBody, orgCredentialIdParam, listOrgCredentialsQuery, createOrgCredentialBody, updateOrgCredentialBody, orgResourceIdParam, orgResourceFileIdParam, orgResourceFolderIdParam, hubOrgResourceParam, listOrgResourcesQuery, orgIdQuery, createOrgResourceBody, updateOrgResourceBody, createOrgResourceFolderBody, updateOrgResourceFolderBody, uploadOrgResourceFileBody, updateOrgResourceFileBody, uploadOrgSkillZipBody, linkOrgResourceBody, resourceIdParam, listResourcesQuery, createResourceBody, updateResourceBody, syncSkillsBody, resourceFileIdParam, listResourceFilesQuery, createResourceFileBody, updateResourceFileBody, uploadResourceFileBody, uploadSkillZipBody, resourceFolderIdParam, listResourceFoldersQuery, createResourceFolderBody, updateResourceFolderBody, agentResourceQuery, hubResourceQuery, linkAgentResourceBody, updateAgentResourceBody, unlinkAgentResourceQuery, navItemSchema, hubCountResetBody, navItemCountResetBody, typingBody, analyticsHubIdParam, analyticsVariableIdParam, updateVariablePinBody, updateAnalyticsViewBody, NUMERIC_FILTER_OPS, TEXT_FILTER_OPS, CATEGORICAL_FILTER_OPS, VARIABLE_FILTER_OPS, STRUCTURED_QUERY_OPS, STRUCTURED_QUERY_AGGREGATIONS, filterValueSchema, conversationsBody, analyticsConversationIdParam, messagesQuery, conversationDetailDataQuery, analyticsDataBody, structuredQueryBody, analyticsSqlBody, analyticsSqlSchemaQuery, EVAL_PACING_PRESET_NAMES, PACING_INTERVAL_MIN_MS, PACING_INTERVAL_MAX_MS, EVAL_RUN_DEADLINE_MIN_MS, EVAL_RUN_DEADLINE_MAX_MS, paginationSchema2, evalIdParam, sessionIdParam, scenarioSetIdParam, hubIdQuery, EVAL_INPUT_ROLES, EVAL_INPUT_ROLE_LIST, ROLE_ECHO_MAX, EVAL_INITIAL_STATE_SCOPES, MAX_INITIAL_STATE_ENTRIES, evalInitialStateEntry, createEvalBody, updateEvalBody, getEvalsQuery, toggleEvalBody, bulkToggleEvalsBody, pacingConfigSchema, sessionConfigSchema, createSessionBody, getSessionsQuery, getSessionResultsQuery, getSessionRunsQuery, evalAnalyticsQuery, getSessionCostQuery, compareSessionsQuery, evalsSqlBody, evalsSqlSchemaQuery, exportResultsQuery, validateEvalBody, hubAgentsQuery, createScenarioSetBody, updateScenarioSetBody, scenarioSetsHubQuery, createScenarioFromConversationBody, createJourneyFromConversationBody, EVAL_ATTACHMENT_HASH_REGEX, evalAttachmentRef, turnMayCarryAttachments, ATTACHMENTS_USER_ONLY_MESSAGE, journeyIdParam, journeyToolCallSchema, journeyTurnSchema, journeyStepOverrideSchema, fixtureField, createJourneyBody, updateJourneyBody, getConversationsQuery, getMessagesQuery, appMessageSenderType, appMessageReceiverType, apiChannelMessage, apiChannelMessageBody, appMessageBody, updateUserBody, updateProfileBody, pathnameRegex, updatePreferencesBody, registerPushTokenBody, deletePushTokenQuery, activityQuery, deletionModeSchema, deletionRequestBody, templateLocaleSchema, TEMPLATE_SLUG_REGEX, templateSlugSchema, templateStatusSchema, templateFileMapSchema, templateTextSchema, templateUsesEntrySchema, templateUsesSchema, templateYamlLocaleEntry, templateYamlWayaiBlock, templateTagsSchema, templateYamlSchema, templateHeroSchema, templatePushLocaleSchema, templatePushBody, templateListQuery, templateSlugParam, templateDetailQuery, courseQuizScoreSchema, upsertCourseLessonBody, linkCourseCapstoneBody, archiveHubIdParam, archiveConversationParams, archiveListQuery, archiveMessageObservabilityParams, conversationIdParam, claimBody, releaseBody, transferBody, closeBody, additionalContextPayloadSchema, kanbanUpdateBody, annotateConversationBody, observabilityParams, observabilityListParams, deleteUserConversationsBody, sendMessageBody, listConversationsQuery, getConversationDetailParams, getConversationDetailQuery, listWhatsAppTemplatesQuery, sendWhatsAppTemplateBody, copilotSuggestBody, copilotSuggestResponse, CONSULT_THREAD_STATUSES, consultThreadStatus, CONSULT_THREAD_TITLE_MAX, consultThreadTitle, consultThreadSummary, listConsultThreadsQuery, listConsultThreadsResponse, createConsultThreadBody, createConsultThreadResponse, consultThreadIdParam, updateConsultThreadBody, updateConsultThreadResponse, CONSULT_AWAIT_TIMEOUT_MS, billingOrgIdParam, subscriptionItemParams, spendCapBody, growthPacksBody, portalSessionBody, checkoutSessionBody, updateBillingCurrencyBody, invoicesQuery, downloadBody, uploadQuery, signUrlBody, outboundSchemaQuery, templateIdParam, listTemplatesQuery, deleteTemplateQuery, templateStatusQuery, createTemplateBody, updateTemplateBody, submitTemplateBody, testTemplateBody, contactIdParam, listContactsQuery, createContactBody, updateContactBody, listIdParam, listListsQuery, listListContactsQuery, createListBody, updateListBody, addListContactsBody, removeListContactsBody, scheduleIdParam, listSchedulesQuery, listExecutionsQuery, createScheduleBody, updateScheduleBody, MAX_RESOURCE_FILE_SIZE, MAX_10MB_BASE64_ENCODED_BYTES, MAX_EVAL_ATTACHMENT_ENCODED_BYTES, MAX_EVAL_ATTACHMENT_CARRIERS, MAX_EVAL_ATTACHMENT_AGGREGATE_ENCODED_BYTES, MAX_RESOURCE_ENCODED_BYTES, MAX_HUB_AS_CODE_RESOURCES, MAX_HUB_AS_CODE_RESOURCE_FILES, MAX_RESOURCE_AGGREGATE_ENCODED_BYTES, MAX_CI_CONFIG_BODY_BYTES, hubAsCodeResourceFileSchema, hubAsCodeResourceSchema, uuidPattern, ciUuidSchema, boundedHubAsCodeResourcesSchema, hubAsCodeConfigSchema, ciPullHubIdParam, ciBranchParam, ciPullQuery, ciHubsQuery, ciLookupQuery, ciBranchesQuery, ciSyncBody, ciPushBody, ciDiffBody, ciPublishBody, ciPublishPreviewBody, ciSyncMcpBody, ciOrgResourcesParam, orgResourcesConfigSchema, ciOrgResourcesPushBody, ciOrgResourcesDiffBody, adminOrgIdParam, adminOrgAdminIdParam, adminUserIdParam, adminPlanIdParam, adminOrganizationsQuery, adminUserSearchQuery, kanbanSlugMigrationQuery, adjustQuotaBody, updatePlanBody, addAdminUserBody, updatePlatformConfigBody, updateFreeOrgLimitBody, adminScopedTargetBody, updatePricingPlanBody, dataExplorerSearchQuery, dataExplorerOrgIdParam, dataExplorerHubIdParam, dataExplorerConvIdParam, dataExplorerDoInstancesQuery, dataExplorerNsIdParam, dataExplorerKvKeysQuery, dataExplorerKvKeyParam, uuidOrHexId, dataExplorerDeleteOrgParam, dataExplorerDeleteHubParam, dataExplorerDeleteConvParam, dataExplorerDeleteUserParam, dataExplorerDeleteQuery, dataExplorerKvDeleteQuery, pitrDoNamespace, pitrBookmarkParam, pitrRestoreBody, healthSamplingTriggerBody, dataExplorerDebugDoType, DEBUG_READ_MAX_LIMIT, DEBUG_READ_DEFAULT_LIMIT, DEBUG_DO_HEX_PREFIX, debugDoEntityId, debugTableName, dataExplorerDebugTablesParam, dataExplorerDebugRowsParam, dataExplorerDebugRowsQuery, dataExplorerDebugAnalyticsTable, debugUuid, dataExplorerDebugAnalyticsRowsParam, dataExplorerDebugAnalyticsRowsQuery, debugHubConvParam, debugMessageIdQuery, sandboxEgressPolicy, SANDBOX_EXEC_MAX_CMD_LENGTH, SANDBOX_EXEC_MAX_ALLOWLIST, SANDBOX_EXEC_MAX_TIMEOUT_MS, adminSandboxExecBody, whatsappCallbackBody, authMeResponse, wsTicketResponse, sessionCheckResponse, logoutResponse, magicCodeSendBody, magicCodeSendResponse, magicCodeVerifyBody, magicCodeVerifyResponse, passwordLoginBody, browserParams, browserFoldersQuery, browserFilesQuery, stateOperationBody, conversationListResourcesQuery, conversationReadResourceQuery, listPendingSchedulesQuery, listHubAggregateSchedulesQuery, reportSourceSchema, intakeReportSourceSchema, reportClassificationSchema, reportStatusSchema, reportLocaleSchema, reportMessageAuthorRoleSchema, reportMessageSchema, sentryRefStatusSchema, createReportBody, editReportBody, reporterReportSummarySchema, reporterListResponseSchema, getReportResponseSchema, reporterTransitionResponseSchema, contestReportBody, reporterListQuery, listReportsQuery, GITHUB_ISSUE_URL_REGEX, githubIssueUrlSchema, transitionReportBody, groupReportsBody, holdReportBody, clickhouseReadyResponse, bootstrapQuery, requestSnapshotChunkMessage, MAX_NAME_LENGTH, MAX_VALUE_LENGTH, MAX_TAGS, MAX_TAG_LENGTH, MAX_SCOPE_HUBS, MAX_SCOPE_TAGS, vaultSecretScopeSchema, vaultCreateBody, vaultUpdateBody, PERMISSIONS, MAX_NAME_LENGTH2, MAX_HUBS_PER_GRANT, MAX_HUB_TAGS_PER_GRANT, MAX_GRANTS, permissionEnum, grantScopeSchema, grantSchema, createTokenBody, tokenOrgIdParam, tokenGrantScopeSchema, tokenGrantSchema, tokenMetadataSchema, listTokensResponse, createTokenResponse, orgTokenSummarySchema, listOrgTokensResponse, invitePreviewQuery, invitePreviewResponse, discordTier, discordBillingCycle, discordMetadata, discordOAuthStartResponse, discordOAuthFinalizeBody, discordOAuthFinalizeResponse, discordDisconnectResponse, jsonSchemaSchema, hubUserIdentity, stateValueEntry, getHubUserContextResponse, updateHubUserBody, updateHubUserResponse, unlockHubUserNameResponse, stateResetParams, stateResetResponse, hubAlertsParam, hubAlertSeverity, hubAlert, hubAlertsListResponse, noticeSeveritySchema, noticeStatusSchema, NOTICE_SCOPE_REGEX, noticeScopeSchema, noticeLinkSchema, createNoticeBody, updateNoticeBody, listNoticesQuery, noticeIdParamSchema, ADMIN_SKILL_NAME_REGEX, adminSkillNameParam, WAYAI_WORKSPACE_LAYOUT;
5980
6024
  var init_dist = __esm({
5981
6025
  "../../packages/core/dist/index.js"() {
5982
6026
  "use strict";
@@ -6029,6 +6073,8 @@ var init_dist = __esm({
6029
6073
  init_zod();
6030
6074
  init_zod();
6031
6075
  init_zod();
6076
+ init_zod();
6077
+ init_zod();
6032
6078
  UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
6033
6079
  HEX_RE = /^[0-9a-f]{16,}$/;
6034
6080
  WORKOS_ID_RE = /^(?:user|org)_[0-9A-HJKMNP-TV-Z]{26}$/;
@@ -6225,7 +6271,8 @@ var init_dist = __esm({
6225
6271
  "monitor",
6226
6272
  "conversation_evaluator",
6227
6273
  "message_evaluator",
6228
- "summarizer"
6274
+ "summarizer",
6275
+ "consultant"
6229
6276
  ];
6230
6277
  SAFE_USER_ID_REGEX = /^[A-Za-z0-9_-]{1,64}$/;
6231
6278
  SUPPORTED_LOCALES = ["en", "pt", "es"];
@@ -6797,13 +6844,19 @@ var init_dist = __esm({
6797
6844
  deleteToolQuery = external_exports.object({ agent_id: uuidSchema.optional(), hub_id: uuidSchema });
6798
6845
  toolConnectionsQuery = external_exports.object({ hub_id: uuidSchema });
6799
6846
  nativeToolIdSchema = external_exports.string().regex(/^nt-\d{3,}$/, "Invalid native tool id");
6847
+ CONTEXT_BOUNDARIES = ["instruction", "summary", "transcript"];
6848
+ contextBoundarySchema = external_exports.enum(CONTEXT_BOUNDARIES);
6800
6849
  addNativeToolBody = external_exports.object({
6801
6850
  agent_id: uuidSchema,
6802
6851
  hub_id: uuidSchema,
6803
6852
  tool_native_id: nativeToolIdSchema,
6804
- delegation_type: external_exports.enum(["team", "agent"]).optional(),
6853
+ delegation_type: external_exports.enum(["team", "agent", "hub"]).optional(),
6805
6854
  delegation_id: external_exports.string().optional(),
6806
6855
  delegation_name: external_exports.string().optional(),
6856
+ /** Only meaningful for a `hub` delegation (`delegate_to_hub`); ignored otherwise.
6857
+ * Defaults to `summary` when omitted. Admin-set — the link and boundary require
6858
+ * hub-admin (`hub:write`), never derived from any end user's grants. */
6859
+ delegation_context_boundary: contextBoundarySchema.optional(),
6807
6860
  resource_config: external_exports.object({
6808
6861
  access_mode: external_exports.enum(["all", "selected", "none"]),
6809
6862
  enabled_resources: external_exports.array(external_exports.string()).optional()
@@ -7662,6 +7715,19 @@ var init_dist = __esm({
7662
7715
  // caller may send to this receiver. The end-user branch ignores it — see the
7663
7716
  // receiver derivation in the route.
7664
7717
  user_receiver_id: clientOptionalString,
7718
+ // ── Internal consult (consultant-agents PR 2 — H1.0) ──────────────────────
7719
+ // A team member handling a customer conversation can tag a `consultant`-role
7720
+ // agent for a PRIVATE, team-only exchange that never reaches the customer. A
7721
+ // consult send is a team send with `receiver_type: 'agent'` targeting the
7722
+ // consultant; the still-required `user_receiver_id` identifies the customer whose
7723
+ // conversation this is (and is authorized by `validateAppTeamSendContext`, exactly
7724
+ // as a team→user send is). The consultant is resolved from `agent_receiver_id`
7725
+ // when supplied, else from an `@mention` parsed out of the message text against
7726
+ // the hub's consultant agents. `consult_thread_id` continues an existing thread;
7727
+ // absent, the route creates/reuses the single implicit thread. These fields are
7728
+ // inert on every non-consult send (end-user send, team→user send).
7729
+ agent_receiver_id: clientOptionalString,
7730
+ consult_thread_id: clientOptionalString,
7665
7731
  is_first_message: clientOptionalBoolean,
7666
7732
  end_conversation: clientOptionalBoolean,
7667
7733
  // Pre-generated by the client so the optimistic bubble and the stored row share
@@ -7987,6 +8053,59 @@ var init_dist = __esm({
7987
8053
  external_exports.record(external_exports.string().max(128), external_exports.string().max(2048)).refine((r) => Object.keys(r).length <= 50, "too many variables")
7988
8054
  ]).optional()
7989
8055
  });
8056
+ copilotSuggestBody = external_exports.object({
8057
+ hub_id: external_exports.string().uuid()
8058
+ });
8059
+ copilotSuggestResponse = external_exports.object({
8060
+ status: external_exports.enum(["processing", "skipped"]),
8061
+ reason: external_exports.string().optional()
8062
+ });
8063
+ CONSULT_THREAD_STATUSES = ["open", "awaiting", "resolved", "cancelled_at_close"];
8064
+ consultThreadStatus = external_exports.enum(CONSULT_THREAD_STATUSES);
8065
+ CONSULT_THREAD_TITLE_MAX = 120;
8066
+ consultThreadTitle = external_exports.string().trim().min(1).max(CONSULT_THREAD_TITLE_MAX);
8067
+ consultThreadSummary = external_exports.object({
8068
+ consult_thread_id: external_exports.string(),
8069
+ conversation_id: external_exports.string(),
8070
+ initiator_type: external_exports.enum(["team", "agent"]),
8071
+ initiator_id: external_exports.string(),
8072
+ engaged_agent_id: external_exports.string().nullable(),
8073
+ engaged_agent_name: external_exports.string().nullable(),
8074
+ title: external_exports.string().nullable(),
8075
+ status: consultThreadStatus,
8076
+ created_at: external_exports.string()
8077
+ });
8078
+ listConsultThreadsQuery = external_exports.object({
8079
+ hub_id: external_exports.string().uuid()
8080
+ });
8081
+ listConsultThreadsResponse = external_exports.object({
8082
+ threads: external_exports.array(consultThreadSummary)
8083
+ });
8084
+ createConsultThreadBody = external_exports.object({
8085
+ hub_id: external_exports.string().uuid(),
8086
+ title: consultThreadTitle.optional(),
8087
+ // Optionally engage a consultant on creation. Validated server-side against the
8088
+ // hub's `consultant`-role agents; a non-consultant / unknown id is rejected.
8089
+ engaged_agent_id: external_exports.string().uuid().optional()
8090
+ });
8091
+ createConsultThreadResponse = external_exports.object({
8092
+ thread: consultThreadSummary
8093
+ });
8094
+ consultThreadIdParam = external_exports.object({
8095
+ id: external_exports.string().uuid(),
8096
+ threadId: external_exports.string().uuid()
8097
+ });
8098
+ updateConsultThreadBody = external_exports.object({
8099
+ hub_id: external_exports.string().uuid(),
8100
+ title: consultThreadTitle.optional(),
8101
+ engaged_agent_id: external_exports.string().uuid().optional()
8102
+ }).refine((v) => v.title !== void 0 || v.engaged_agent_id !== void 0, {
8103
+ message: "Provide a title and/or an engaged_agent_id to update"
8104
+ });
8105
+ updateConsultThreadResponse = external_exports.object({
8106
+ thread: consultThreadSummary
8107
+ });
8108
+ CONSULT_AWAIT_TIMEOUT_MS = 15 * 6e4;
7990
8109
  billingOrgIdParam = external_exports.object({
7991
8110
  organizationId: external_exports.string().uuid()
7992
8111
  });
@@ -8234,6 +8353,7 @@ var init_dist = __esm({
8234
8353
  refineHubAsCodeEvals(config, ctx);
8235
8354
  refineHubAsCodeEvalAttachments(config, ctx);
8236
8355
  refineHubAsCodeResources(config, ctx);
8356
+ refineHubAsCodeDelegation(config, ctx);
8237
8357
  });
8238
8358
  ciPullHubIdParam = external_exports.object({
8239
8359
  hub_id: ciUuidSchema
@@ -10239,6 +10359,18 @@ var init_token_store = __esm({
10239
10359
  }
10240
10360
  });
10241
10361
 
10362
+ // src/lib/expected.ts
10363
+ function expected(message) {
10364
+ const err = new Error(message);
10365
+ err.isExpected = true;
10366
+ return err;
10367
+ }
10368
+ var init_expected = __esm({
10369
+ "src/lib/expected.ts"() {
10370
+ "use strict";
10371
+ }
10372
+ });
10373
+
10242
10374
  // src/lib/auth.ts
10243
10375
  var auth_exports = {};
10244
10376
  __export(auth_exports, {
@@ -10387,7 +10519,7 @@ async function getAccessToken(config) {
10387
10519
  await migrateLegacyTokens();
10388
10520
  const resolved = await getToken();
10389
10521
  if (!resolved) {
10390
- throw new Error("No token found. Run `wayai login` to authenticate.");
10522
+ throw expected("No token found. Run `wayai login` to authenticate.");
10391
10523
  }
10392
10524
  if (resolved.kind === "way") {
10393
10525
  return resolved.token;
@@ -10400,7 +10532,7 @@ async function getAccessToken(config) {
10400
10532
  return resolved.access_token;
10401
10533
  }
10402
10534
  if (!resolved.refresh_token) {
10403
- throw new Error("Access token expired and no refresh token available. Run `wayai login` again.");
10535
+ throw expected("Access token expired and no refresh token available. Run `wayai login` again.");
10404
10536
  }
10405
10537
  try {
10406
10538
  const result = await refreshAccessToken(
@@ -10415,7 +10547,7 @@ async function getAccessToken(config) {
10415
10547
  if (err instanceof Error && err.message === "SESSION_EXPIRED") {
10416
10548
  await clearTokens();
10417
10549
  writeConfig({ api_url: config.api_url });
10418
- throw new Error("Session expired. Please run `wayai login` again.");
10550
+ throw expected("Session expired. Please run `wayai login` again.");
10419
10551
  }
10420
10552
  throw err;
10421
10553
  }
@@ -10442,6 +10574,7 @@ var init_auth = __esm({
10442
10574
  "use strict";
10443
10575
  init_config();
10444
10576
  init_token_store();
10577
+ init_expected();
10445
10578
  init_sentry();
10446
10579
  init_mask_secrets();
10447
10580
  OAUTH_CALLBACK_PORT = 3829;
@@ -12095,7 +12228,51 @@ function refineHubAsCodeResources2(config, ctx) {
12095
12228
  });
12096
12229
  }
12097
12230
  }
12098
- var uuidSchema2, paginationSchema3, timestampSchema2, idParamSchema2, clientOptionalString2, clientOptionalBoolean2, clientOptionalNumber2, messageAttachment2, MAX_MESSAGE_BODY_BYTES2, MAX_ATTACHMENTS_PER_MESSAGE2, MAX_AUDIO_FILE_BASE64_BYTES2, primaryRegionSchema2, placementSourceSchema2, orgIdParam2, orgAdminIdParam2, createOrganizationBody2, updateOrganizationBody2, addOrgAdminBody2, AUTH_TYPE3, ORG_CREDENTIAL_AUTH_TYPES3, AUTH_TYPE_DISPLAY3, LEGACY_AUTH_TYPE_MAP3, VALID_AUTH_TYPES3, AGENT_ROLES2, SAFE_USER_ID_REGEX2, SUPPORTED_LOCALES2, SUMMARIZATION_THRESHOLD_MIN2, SUMMARIZATION_THRESHOLD_MAX2, summarizationThresholdField2, monitorConfigField2, agentIdParam2, listAgentsQuery2, agentConnectionsQuery2, createAgentBody2, updateAgentBody2, AGENT_PARAMETER_TYPES2, AGENT_PARAMETER_NAME_REGEX2, agentParameterCreateSchema2, MAX_AGENT_PARAMETERS_PER_REQUEST2, createAgentParametersBody2, SLUG_REGEX2, slugSchema2, INVISIBLE_NAME_CHARS2, MAX_KANBAN_STATUSES2, MAX_FOLLOWUPS_PER_STATUS2, MAX_LANES2, MAX_ADDITIONAL_CONTEXT_SCHEMA_BYTES2, RESERVED_TEMPLATE_DUMP_NAME2, kanbanStatusSlugSchema2, followupSchema2, MAX_OUTCOMES_PER_STATUS2, kanbanOutcomeSchema2, EXCLUSIVE_FLAG_PAIRS2, kanbanStatusSchema2, kanbanStatusesArraySchema2, laneSchema2, lanesArraySchema2, hubIdParam2, hubAdminIdParam2, hubUserIdParam2, hubIdentityIdParam2, hubTeamIdParam2, hubTeamUserDeleteParam2, hubSchemaQuery2, PREVIEW_LABEL_MAX_LENGTH2, MAX_ENDED_INDEX_RETENTION_DAYS2, previewLabelField2, createHubBody2, updateHubBody2, addHubAdminBody2, addHubIdentityAuthorizationBody2, contactDecisionBody2, approveContactBody2, listContactAccessQuery2, createHubTeamBody2, updateHubTeamBody2, addHubTeamUserBody2, reassignHubUserBody2, replicatePreviewBody2, updateChannelTestIdentitiesBody2, claimCodeChannelParam2, claimCodeDeleteParam2, connectionIdParam2, connectorIdParam2, listConnectionsQuery2, deleteConnectionQuery2, addConnectionBody2, editConnectionBody2, PRODUCTION_DIRECT_FIELDS2, setProductionCredentialBody2, registerWhatsappQuery2, registerWhatsappBody2, retryProvisioningQuery2, resendDomainStatusQuery2, PLACEHOLDER_TOKENS2, ALLOWED_TYPES2, SUBSCHEMA_OBJECT_KEYWORDS2, SUBSCHEMA_LIST_KEYWORDS2, SUBSCHEMA_MAP_KEYWORDS2, MAX_SCHEMA_DEPTH2, toolIdParam2, listToolsQuery2, toolAgentQuery2, deleteToolQuery2, toolConnectionsQuery2, nativeToolIdSchema2, addNativeToolBody2, addMcpToolBody2, createCustomToolBody2, updateCustomToolBody2, updateToolExecutionConfigBody2, initialValueCreateSchema2, initialValueUpdateSchema2, stateIdParam2, listStatesQuery2, stateNameSchema2, createStateBody2, updateStateBody2, reorderStatesBody2, variantAiModeSchema2, experimentStatusSchema2, overlayUpdateSchema2, experimentIdParam2, variantIdParam2, listExperimentsQuery2, listVariantsQuery2, listOverridesQuery2, deleteOverrideQuery2, createExperimentBody2, updateExperimentBody2, setExperimentStatusBody2, createVariantBody2, updateVariantBody2, upsertOverrideBody2, orgTagIdParam2, listOrgTagsQuery2, createOrgTagBody2, updateOrgTagBody2, orgCredentialIdParam2, listOrgCredentialsQuery2, createOrgCredentialBody2, updateOrgCredentialBody2, orgResourceIdParam2, orgResourceFileIdParam2, orgResourceFolderIdParam2, hubOrgResourceParam2, listOrgResourcesQuery2, orgIdQuery2, createOrgResourceBody2, updateOrgResourceBody2, createOrgResourceFolderBody2, updateOrgResourceFolderBody2, uploadOrgResourceFileBody2, updateOrgResourceFileBody2, uploadOrgSkillZipBody2, linkOrgResourceBody2, resourceIdParam2, listResourcesQuery2, createResourceBody2, updateResourceBody2, syncSkillsBody2, resourceFileIdParam2, listResourceFilesQuery2, createResourceFileBody2, updateResourceFileBody2, uploadResourceFileBody2, uploadSkillZipBody2, resourceFolderIdParam2, listResourceFoldersQuery2, createResourceFolderBody2, updateResourceFolderBody2, agentResourceQuery2, hubResourceQuery2, linkAgentResourceBody2, updateAgentResourceBody2, unlinkAgentResourceQuery2, navItemSchema2, hubCountResetBody2, navItemCountResetBody2, typingBody2, analyticsHubIdParam2, analyticsVariableIdParam2, updateVariablePinBody2, updateAnalyticsViewBody2, NUMERIC_FILTER_OPS2, TEXT_FILTER_OPS2, CATEGORICAL_FILTER_OPS2, VARIABLE_FILTER_OPS2, STRUCTURED_QUERY_OPS2, STRUCTURED_QUERY_AGGREGATIONS2, filterValueSchema2, conversationsBody2, analyticsConversationIdParam2, messagesQuery2, conversationDetailDataQuery2, analyticsDataBody2, structuredQueryBody2, analyticsSqlBody2, analyticsSqlSchemaQuery2, EVAL_PACING_PRESET_NAMES2, PACING_INTERVAL_MIN_MS2, PACING_INTERVAL_MAX_MS2, EVAL_RUN_DEADLINE_MIN_MS2, EVAL_RUN_DEADLINE_MAX_MS2, paginationSchema22, evalIdParam2, sessionIdParam2, scenarioSetIdParam2, hubIdQuery2, EVAL_INPUT_ROLES2, EVAL_INPUT_ROLE_LIST2, ROLE_ECHO_MAX2, EVAL_INITIAL_STATE_SCOPES2, MAX_INITIAL_STATE_ENTRIES2, evalInitialStateEntry2, createEvalBody2, updateEvalBody2, getEvalsQuery2, toggleEvalBody2, bulkToggleEvalsBody2, pacingConfigSchema2, sessionConfigSchema2, createSessionBody2, getSessionsQuery2, getSessionResultsQuery2, getSessionRunsQuery2, evalAnalyticsQuery2, getSessionCostQuery2, compareSessionsQuery2, evalsSqlBody2, evalsSqlSchemaQuery2, exportResultsQuery2, validateEvalBody2, hubAgentsQuery2, createScenarioSetBody2, updateScenarioSetBody2, scenarioSetsHubQuery2, createScenarioFromConversationBody2, createJourneyFromConversationBody2, EVAL_ATTACHMENT_HASH_REGEX2, evalAttachmentRef2, turnMayCarryAttachments2, ATTACHMENTS_USER_ONLY_MESSAGE2, journeyIdParam2, journeyToolCallSchema2, journeyTurnSchema2, journeyStepOverrideSchema2, fixtureField2, createJourneyBody2, updateJourneyBody2, getConversationsQuery2, getMessagesQuery2, appMessageSenderType2, appMessageReceiverType2, apiChannelMessage2, apiChannelMessageBody2, appMessageBody2, updateUserBody2, updateProfileBody2, pathnameRegex2, updatePreferencesBody2, registerPushTokenBody2, deletePushTokenQuery2, activityQuery2, deletionModeSchema2, deletionRequestBody2, templateLocaleSchema2, TEMPLATE_SLUG_REGEX2, templateSlugSchema2, templateStatusSchema2, templateFileMapSchema2, TEMPLATE_INSTANCE_ID_KEYS, TEMPLATE_OPAQUE_BLOB_KEYS, TEMPLATE_AUTHOR_DATA_KEYS, templateTextSchema2, templateUsesEntrySchema2, templateUsesSchema2, templateYamlLocaleEntry2, templateYamlWayaiBlock2, templateTagsSchema2, templateYamlSchema2, templateHeroSchema2, templatePushLocaleSchema2, templatePushBody2, templateListQuery2, templateSlugParam2, templateDetailQuery2, courseQuizScoreSchema2, upsertCourseLessonBody2, linkCourseCapstoneBody2, archiveHubIdParam2, archiveConversationParams2, archiveListQuery2, archiveMessageObservabilityParams2, conversationIdParam2, claimBody2, releaseBody2, transferBody2, closeBody2, additionalContextPayloadSchema2, kanbanUpdateBody2, annotateConversationBody2, observabilityParams2, observabilityListParams2, deleteUserConversationsBody2, sendMessageBody2, listConversationsQuery2, getConversationDetailParams2, getConversationDetailQuery2, listWhatsAppTemplatesQuery2, sendWhatsAppTemplateBody2, billingOrgIdParam2, subscriptionItemParams2, spendCapBody2, growthPacksBody2, portalSessionBody2, checkoutSessionBody2, updateBillingCurrencyBody2, invoicesQuery2, downloadBody2, uploadQuery2, signUrlBody2, outboundSchemaQuery2, templateIdParam2, listTemplatesQuery2, deleteTemplateQuery2, templateStatusQuery2, createTemplateBody2, updateTemplateBody2, submitTemplateBody2, testTemplateBody2, contactIdParam2, listContactsQuery2, createContactBody2, updateContactBody2, listIdParam2, listListsQuery2, listListContactsQuery2, createListBody2, updateListBody2, addListContactsBody2, removeListContactsBody2, scheduleIdParam2, listSchedulesQuery2, listExecutionsQuery2, createScheduleBody2, updateScheduleBody2, MAX_RESOURCE_FILE_SIZE2, MAX_10MB_BASE64_ENCODED_BYTES2, MAX_EVAL_ATTACHMENT_ENCODED_BYTES2, MAX_EVAL_ATTACHMENT_CARRIERS2, MAX_EVAL_ATTACHMENT_AGGREGATE_ENCODED_BYTES2, MAX_RESOURCE_ENCODED_BYTES2, MAX_HUB_AS_CODE_RESOURCES2, MAX_HUB_AS_CODE_RESOURCE_FILES2, MAX_RESOURCE_AGGREGATE_ENCODED_BYTES2, MAX_CI_CONFIG_BODY_BYTES2, hubAsCodeResourceFileSchema2, hubAsCodeResourceSchema2, uuidPattern2, ciUuidSchema2, boundedHubAsCodeResourcesSchema2, hubAsCodeConfigSchema2, ciPullHubIdParam2, ciBranchParam2, ciPullQuery2, ciHubsQuery2, ciLookupQuery2, ciBranchesQuery2, ciSyncBody2, ciPushBody2, ciDiffBody2, ciPublishBody2, ciPublishPreviewBody2, ciSyncMcpBody2, ciOrgResourcesParam2, orgResourcesConfigSchema2, ciOrgResourcesPushBody2, ciOrgResourcesDiffBody2, adminOrgIdParam2, adminOrgAdminIdParam2, adminUserIdParam2, adminPlanIdParam2, adminOrganizationsQuery2, adminUserSearchQuery2, kanbanSlugMigrationQuery2, adjustQuotaBody2, updatePlanBody2, addAdminUserBody2, updatePlatformConfigBody2, updateFreeOrgLimitBody2, adminScopedTargetBody2, updatePricingPlanBody2, dataExplorerSearchQuery2, dataExplorerOrgIdParam2, dataExplorerHubIdParam2, dataExplorerConvIdParam2, dataExplorerDoInstancesQuery2, dataExplorerNsIdParam2, dataExplorerKvKeysQuery2, dataExplorerKvKeyParam2, uuidOrHexId2, dataExplorerDeleteOrgParam2, dataExplorerDeleteHubParam2, dataExplorerDeleteConvParam2, dataExplorerDeleteUserParam2, dataExplorerDeleteQuery2, dataExplorerKvDeleteQuery2, pitrDoNamespace2, pitrBookmarkParam2, pitrRestoreBody2, healthSamplingTriggerBody2, dataExplorerDebugDoType2, DEBUG_READ_MAX_LIMIT2, DEBUG_READ_DEFAULT_LIMIT2, DEBUG_DO_HEX_PREFIX2, debugDoEntityId2, debugTableName2, dataExplorerDebugTablesParam2, dataExplorerDebugRowsParam2, dataExplorerDebugRowsQuery2, dataExplorerDebugAnalyticsTable2, debugUuid2, dataExplorerDebugAnalyticsRowsParam2, dataExplorerDebugAnalyticsRowsQuery2, debugHubConvParam2, debugMessageIdQuery2, sandboxEgressPolicy2, SANDBOX_EXEC_MAX_CMD_LENGTH2, SANDBOX_EXEC_MAX_ALLOWLIST2, SANDBOX_EXEC_MAX_TIMEOUT_MS2, adminSandboxExecBody2, whatsappCallbackBody2, authMeResponse2, wsTicketResponse2, sessionCheckResponse2, logoutResponse2, magicCodeSendBody2, magicCodeSendResponse2, magicCodeVerifyBody2, magicCodeVerifyResponse2, passwordLoginBody2, browserParams2, browserFoldersQuery2, browserFilesQuery2, stateOperationBody2, conversationListResourcesQuery2, conversationReadResourceQuery2, listPendingSchedulesQuery2, listHubAggregateSchedulesQuery2, reportSourceSchema2, intakeReportSourceSchema2, reportClassificationSchema2, reportStatusSchema2, reportLocaleSchema2, reportMessageAuthorRoleSchema2, reportMessageSchema2, sentryRefStatusSchema2, createReportBody2, editReportBody2, reporterReportSummarySchema2, reporterListResponseSchema2, getReportResponseSchema2, reporterTransitionResponseSchema2, contestReportBody2, reporterListQuery2, listReportsQuery2, GITHUB_ISSUE_URL_REGEX2, githubIssueUrlSchema2, transitionReportBody2, groupReportsBody2, holdReportBody2, clickhouseReadyResponse2, bootstrapQuery2, requestSnapshotChunkMessage2, MAX_NAME_LENGTH3, MAX_VALUE_LENGTH2, MAX_TAGS2, MAX_TAG_LENGTH2, MAX_SCOPE_HUBS2, MAX_SCOPE_TAGS2, vaultSecretScopeSchema2, vaultCreateBody2, vaultUpdateBody2, PERMISSIONS2, MAX_NAME_LENGTH22, MAX_HUBS_PER_GRANT2, MAX_HUB_TAGS_PER_GRANT2, MAX_GRANTS2, permissionEnum2, grantScopeSchema2, grantSchema2, createTokenBody2, tokenOrgIdParam2, tokenGrantScopeSchema2, tokenGrantSchema2, tokenMetadataSchema2, listTokensResponse2, createTokenResponse2, orgTokenSummarySchema2, listOrgTokensResponse2, invitePreviewQuery2, invitePreviewResponse2, discordTier2, discordBillingCycle2, discordMetadata2, discordOAuthStartResponse2, discordOAuthFinalizeBody2, discordOAuthFinalizeResponse2, discordDisconnectResponse2, jsonSchemaSchema2, hubUserIdentity2, stateValueEntry2, getHubUserContextResponse2, updateHubUserBody2, updateHubUserResponse2, unlockHubUserNameResponse2, stateResetParams2, stateResetResponse2, hubAlertsParam2, hubAlertSeverity2, hubAlert2, hubAlertsListResponse2, noticeSeveritySchema2, noticeStatusSchema2, NOTICE_SCOPE_REGEX2, noticeScopeSchema2, noticeLinkSchema2, createNoticeBody2, updateNoticeBody2, listNoticesQuery2, noticeIdParamSchema2, ADMIN_SKILL_NAME_REGEX2, adminSkillNameParam2;
12231
+ function refineHubAsCodeDelegation2(config, ctx) {
12232
+ const agents = config?.agents;
12233
+ if (!Array.isArray(agents)) return;
12234
+ agents.forEach((agent, agentIndex) => {
12235
+ const delegation = agent?.tools?.delegation;
12236
+ if (!Array.isArray(delegation)) return;
12237
+ delegation.forEach((entry, delIndex) => {
12238
+ const del = entry;
12239
+ if (del.allow_consultant_chain !== void 0) {
12240
+ const chainPath = ["agents", agentIndex, "tools", "delegation", delIndex, "allow_consultant_chain"];
12241
+ if (typeof del.allow_consultant_chain !== "boolean") {
12242
+ ctx.addIssue({
12243
+ code: external_exports.ZodIssueCode.custom,
12244
+ path: chainPath,
12245
+ message: "allow_consultant_chain must be a boolean"
12246
+ });
12247
+ } else if (del.tool !== "start_consult_thread") {
12248
+ ctx.addIssue({
12249
+ code: external_exports.ZodIssueCode.custom,
12250
+ path: chainPath,
12251
+ message: `allow_consultant_chain applies only to \`tool: start_consult_thread\` (got "${String(del.tool)}")`
12252
+ });
12253
+ }
12254
+ }
12255
+ if (del.context_boundary === void 0) return;
12256
+ const path31 = ["agents", agentIndex, "tools", "delegation", delIndex, "context_boundary"];
12257
+ if (del.type !== "hub") {
12258
+ ctx.addIssue({
12259
+ code: external_exports.ZodIssueCode.custom,
12260
+ path: path31,
12261
+ message: `context_boundary applies only to \`type: hub\` delegations (got type "${String(del.type)}")`
12262
+ });
12263
+ return;
12264
+ }
12265
+ if (!CONTEXT_BOUNDARIES2.includes(del.context_boundary)) {
12266
+ ctx.addIssue({
12267
+ code: external_exports.ZodIssueCode.custom,
12268
+ path: path31,
12269
+ message: `context_boundary must be one of: ${CONTEXT_BOUNDARIES2.join(", ")}`
12270
+ });
12271
+ }
12272
+ });
12273
+ });
12274
+ }
12275
+ var uuidSchema2, paginationSchema3, timestampSchema2, idParamSchema2, clientOptionalString2, clientOptionalBoolean2, clientOptionalNumber2, messageAttachment2, MAX_MESSAGE_BODY_BYTES2, MAX_ATTACHMENTS_PER_MESSAGE2, MAX_AUDIO_FILE_BASE64_BYTES2, primaryRegionSchema2, placementSourceSchema2, orgIdParam2, orgAdminIdParam2, createOrganizationBody2, updateOrganizationBody2, addOrgAdminBody2, AUTH_TYPE3, ORG_CREDENTIAL_AUTH_TYPES3, AUTH_TYPE_DISPLAY3, LEGACY_AUTH_TYPE_MAP3, VALID_AUTH_TYPES3, AGENT_ROLES2, SAFE_USER_ID_REGEX2, SUPPORTED_LOCALES2, SUMMARIZATION_THRESHOLD_MIN2, SUMMARIZATION_THRESHOLD_MAX2, summarizationThresholdField2, monitorConfigField2, agentIdParam2, listAgentsQuery2, agentConnectionsQuery2, createAgentBody2, updateAgentBody2, AGENT_PARAMETER_TYPES2, AGENT_PARAMETER_NAME_REGEX2, agentParameterCreateSchema2, MAX_AGENT_PARAMETERS_PER_REQUEST2, createAgentParametersBody2, SLUG_REGEX2, slugSchema2, INVISIBLE_NAME_CHARS2, MAX_KANBAN_STATUSES2, MAX_FOLLOWUPS_PER_STATUS2, MAX_LANES2, MAX_ADDITIONAL_CONTEXT_SCHEMA_BYTES2, RESERVED_TEMPLATE_DUMP_NAME2, kanbanStatusSlugSchema2, followupSchema2, MAX_OUTCOMES_PER_STATUS2, kanbanOutcomeSchema2, EXCLUSIVE_FLAG_PAIRS2, kanbanStatusSchema2, kanbanStatusesArraySchema2, laneSchema2, lanesArraySchema2, hubIdParam2, hubAdminIdParam2, hubUserIdParam2, hubIdentityIdParam2, hubTeamIdParam2, hubTeamUserDeleteParam2, hubSchemaQuery2, PREVIEW_LABEL_MAX_LENGTH2, MAX_ENDED_INDEX_RETENTION_DAYS2, previewLabelField2, createHubBody2, updateHubBody2, addHubAdminBody2, addHubIdentityAuthorizationBody2, contactDecisionBody2, approveContactBody2, listContactAccessQuery2, createHubTeamBody2, updateHubTeamBody2, addHubTeamUserBody2, reassignHubUserBody2, replicatePreviewBody2, updateChannelTestIdentitiesBody2, claimCodeChannelParam2, claimCodeDeleteParam2, connectionIdParam2, connectorIdParam2, listConnectionsQuery2, deleteConnectionQuery2, addConnectionBody2, editConnectionBody2, PRODUCTION_DIRECT_FIELDS2, setProductionCredentialBody2, registerWhatsappQuery2, registerWhatsappBody2, retryProvisioningQuery2, resendDomainStatusQuery2, PLACEHOLDER_TOKENS2, ALLOWED_TYPES2, SUBSCHEMA_OBJECT_KEYWORDS2, SUBSCHEMA_LIST_KEYWORDS2, SUBSCHEMA_MAP_KEYWORDS2, MAX_SCHEMA_DEPTH2, toolIdParam2, listToolsQuery2, toolAgentQuery2, deleteToolQuery2, toolConnectionsQuery2, nativeToolIdSchema2, CONTEXT_BOUNDARIES2, contextBoundarySchema2, addNativeToolBody2, addMcpToolBody2, createCustomToolBody2, updateCustomToolBody2, updateToolExecutionConfigBody2, initialValueCreateSchema2, initialValueUpdateSchema2, stateIdParam2, listStatesQuery2, stateNameSchema2, createStateBody2, updateStateBody2, reorderStatesBody2, variantAiModeSchema2, experimentStatusSchema2, overlayUpdateSchema2, experimentIdParam2, variantIdParam2, listExperimentsQuery2, listVariantsQuery2, listOverridesQuery2, deleteOverrideQuery2, createExperimentBody2, updateExperimentBody2, setExperimentStatusBody2, createVariantBody2, updateVariantBody2, upsertOverrideBody2, orgTagIdParam2, listOrgTagsQuery2, createOrgTagBody2, updateOrgTagBody2, orgCredentialIdParam2, listOrgCredentialsQuery2, createOrgCredentialBody2, updateOrgCredentialBody2, orgResourceIdParam2, orgResourceFileIdParam2, orgResourceFolderIdParam2, hubOrgResourceParam2, listOrgResourcesQuery2, orgIdQuery2, createOrgResourceBody2, updateOrgResourceBody2, createOrgResourceFolderBody2, updateOrgResourceFolderBody2, uploadOrgResourceFileBody2, updateOrgResourceFileBody2, uploadOrgSkillZipBody2, linkOrgResourceBody2, resourceIdParam2, listResourcesQuery2, createResourceBody2, updateResourceBody2, syncSkillsBody2, resourceFileIdParam2, listResourceFilesQuery2, createResourceFileBody2, updateResourceFileBody2, uploadResourceFileBody2, uploadSkillZipBody2, resourceFolderIdParam2, listResourceFoldersQuery2, createResourceFolderBody2, updateResourceFolderBody2, agentResourceQuery2, hubResourceQuery2, linkAgentResourceBody2, updateAgentResourceBody2, unlinkAgentResourceQuery2, navItemSchema2, hubCountResetBody2, navItemCountResetBody2, typingBody2, analyticsHubIdParam2, analyticsVariableIdParam2, updateVariablePinBody2, updateAnalyticsViewBody2, NUMERIC_FILTER_OPS2, TEXT_FILTER_OPS2, CATEGORICAL_FILTER_OPS2, VARIABLE_FILTER_OPS2, STRUCTURED_QUERY_OPS2, STRUCTURED_QUERY_AGGREGATIONS2, filterValueSchema2, conversationsBody2, analyticsConversationIdParam2, messagesQuery2, conversationDetailDataQuery2, analyticsDataBody2, structuredQueryBody2, analyticsSqlBody2, analyticsSqlSchemaQuery2, EVAL_PACING_PRESET_NAMES2, PACING_INTERVAL_MIN_MS2, PACING_INTERVAL_MAX_MS2, EVAL_RUN_DEADLINE_MIN_MS2, EVAL_RUN_DEADLINE_MAX_MS2, paginationSchema22, evalIdParam2, sessionIdParam2, scenarioSetIdParam2, hubIdQuery2, EVAL_INPUT_ROLES2, EVAL_INPUT_ROLE_LIST2, ROLE_ECHO_MAX2, EVAL_INITIAL_STATE_SCOPES2, MAX_INITIAL_STATE_ENTRIES2, evalInitialStateEntry2, createEvalBody2, updateEvalBody2, getEvalsQuery2, toggleEvalBody2, bulkToggleEvalsBody2, pacingConfigSchema2, sessionConfigSchema2, createSessionBody2, getSessionsQuery2, getSessionResultsQuery2, getSessionRunsQuery2, evalAnalyticsQuery2, getSessionCostQuery2, compareSessionsQuery2, evalsSqlBody2, evalsSqlSchemaQuery2, exportResultsQuery2, validateEvalBody2, hubAgentsQuery2, createScenarioSetBody2, updateScenarioSetBody2, scenarioSetsHubQuery2, createScenarioFromConversationBody2, createJourneyFromConversationBody2, EVAL_ATTACHMENT_HASH_REGEX2, evalAttachmentRef2, turnMayCarryAttachments2, ATTACHMENTS_USER_ONLY_MESSAGE2, journeyIdParam2, journeyToolCallSchema2, journeyTurnSchema2, journeyStepOverrideSchema2, fixtureField2, createJourneyBody2, updateJourneyBody2, getConversationsQuery2, getMessagesQuery2, appMessageSenderType2, appMessageReceiverType2, apiChannelMessage2, apiChannelMessageBody2, appMessageBody2, updateUserBody2, updateProfileBody2, pathnameRegex2, updatePreferencesBody2, registerPushTokenBody2, deletePushTokenQuery2, activityQuery2, deletionModeSchema2, deletionRequestBody2, templateLocaleSchema2, TEMPLATE_SLUG_REGEX2, templateSlugSchema2, templateStatusSchema2, templateFileMapSchema2, TEMPLATE_INSTANCE_ID_KEYS, TEMPLATE_OPAQUE_BLOB_KEYS, TEMPLATE_AUTHOR_DATA_KEYS, templateTextSchema2, templateUsesEntrySchema2, templateUsesSchema2, templateYamlLocaleEntry2, templateYamlWayaiBlock2, templateTagsSchema2, templateYamlSchema2, templateHeroSchema2, templatePushLocaleSchema2, templatePushBody2, templateListQuery2, templateSlugParam2, templateDetailQuery2, courseQuizScoreSchema2, upsertCourseLessonBody2, linkCourseCapstoneBody2, archiveHubIdParam2, archiveConversationParams2, archiveListQuery2, archiveMessageObservabilityParams2, conversationIdParam2, claimBody2, releaseBody2, transferBody2, closeBody2, additionalContextPayloadSchema2, kanbanUpdateBody2, annotateConversationBody2, observabilityParams2, observabilityListParams2, deleteUserConversationsBody2, sendMessageBody2, listConversationsQuery2, getConversationDetailParams2, getConversationDetailQuery2, listWhatsAppTemplatesQuery2, sendWhatsAppTemplateBody2, copilotSuggestBody2, copilotSuggestResponse2, CONSULT_THREAD_STATUSES2, consultThreadStatus2, CONSULT_THREAD_TITLE_MAX2, consultThreadTitle2, consultThreadSummary2, listConsultThreadsQuery2, listConsultThreadsResponse2, createConsultThreadBody2, createConsultThreadResponse2, consultThreadIdParam2, updateConsultThreadBody2, updateConsultThreadResponse2, CONSULT_AWAIT_TIMEOUT_MS2, billingOrgIdParam2, subscriptionItemParams2, spendCapBody2, growthPacksBody2, portalSessionBody2, checkoutSessionBody2, updateBillingCurrencyBody2, invoicesQuery2, downloadBody2, uploadQuery2, signUrlBody2, outboundSchemaQuery2, templateIdParam2, listTemplatesQuery2, deleteTemplateQuery2, templateStatusQuery2, createTemplateBody2, updateTemplateBody2, submitTemplateBody2, testTemplateBody2, contactIdParam2, listContactsQuery2, createContactBody2, updateContactBody2, listIdParam2, listListsQuery2, listListContactsQuery2, createListBody2, updateListBody2, addListContactsBody2, removeListContactsBody2, scheduleIdParam2, listSchedulesQuery2, listExecutionsQuery2, createScheduleBody2, updateScheduleBody2, MAX_RESOURCE_FILE_SIZE2, MAX_10MB_BASE64_ENCODED_BYTES2, MAX_EVAL_ATTACHMENT_ENCODED_BYTES2, MAX_EVAL_ATTACHMENT_CARRIERS2, MAX_EVAL_ATTACHMENT_AGGREGATE_ENCODED_BYTES2, MAX_RESOURCE_ENCODED_BYTES2, MAX_HUB_AS_CODE_RESOURCES2, MAX_HUB_AS_CODE_RESOURCE_FILES2, MAX_RESOURCE_AGGREGATE_ENCODED_BYTES2, MAX_CI_CONFIG_BODY_BYTES2, hubAsCodeResourceFileSchema2, hubAsCodeResourceSchema2, uuidPattern2, ciUuidSchema2, boundedHubAsCodeResourcesSchema2, hubAsCodeConfigSchema2, ciPullHubIdParam2, ciBranchParam2, ciPullQuery2, ciHubsQuery2, ciLookupQuery2, ciBranchesQuery2, ciSyncBody2, ciPushBody2, ciDiffBody2, ciPublishBody2, ciPublishPreviewBody2, ciSyncMcpBody2, ciOrgResourcesParam2, orgResourcesConfigSchema2, ciOrgResourcesPushBody2, ciOrgResourcesDiffBody2, adminOrgIdParam2, adminOrgAdminIdParam2, adminUserIdParam2, adminPlanIdParam2, adminOrganizationsQuery2, adminUserSearchQuery2, kanbanSlugMigrationQuery2, adjustQuotaBody2, updatePlanBody2, addAdminUserBody2, updatePlatformConfigBody2, updateFreeOrgLimitBody2, adminScopedTargetBody2, updatePricingPlanBody2, dataExplorerSearchQuery2, dataExplorerOrgIdParam2, dataExplorerHubIdParam2, dataExplorerConvIdParam2, dataExplorerDoInstancesQuery2, dataExplorerNsIdParam2, dataExplorerKvKeysQuery2, dataExplorerKvKeyParam2, uuidOrHexId2, dataExplorerDeleteOrgParam2, dataExplorerDeleteHubParam2, dataExplorerDeleteConvParam2, dataExplorerDeleteUserParam2, dataExplorerDeleteQuery2, dataExplorerKvDeleteQuery2, pitrDoNamespace2, pitrBookmarkParam2, pitrRestoreBody2, healthSamplingTriggerBody2, dataExplorerDebugDoType2, DEBUG_READ_MAX_LIMIT2, DEBUG_READ_DEFAULT_LIMIT2, DEBUG_DO_HEX_PREFIX2, debugDoEntityId2, debugTableName2, dataExplorerDebugTablesParam2, dataExplorerDebugRowsParam2, dataExplorerDebugRowsQuery2, dataExplorerDebugAnalyticsTable2, debugUuid2, dataExplorerDebugAnalyticsRowsParam2, dataExplorerDebugAnalyticsRowsQuery2, debugHubConvParam2, debugMessageIdQuery2, sandboxEgressPolicy2, SANDBOX_EXEC_MAX_CMD_LENGTH2, SANDBOX_EXEC_MAX_ALLOWLIST2, SANDBOX_EXEC_MAX_TIMEOUT_MS2, adminSandboxExecBody2, whatsappCallbackBody2, authMeResponse2, wsTicketResponse2, sessionCheckResponse2, logoutResponse2, magicCodeSendBody2, magicCodeSendResponse2, magicCodeVerifyBody2, magicCodeVerifyResponse2, passwordLoginBody2, browserParams2, browserFoldersQuery2, browserFilesQuery2, stateOperationBody2, conversationListResourcesQuery2, conversationReadResourceQuery2, listPendingSchedulesQuery2, listHubAggregateSchedulesQuery2, reportSourceSchema2, intakeReportSourceSchema2, reportClassificationSchema2, reportStatusSchema2, reportLocaleSchema2, reportMessageAuthorRoleSchema2, reportMessageSchema2, sentryRefStatusSchema2, createReportBody2, editReportBody2, reporterReportSummarySchema2, reporterListResponseSchema2, getReportResponseSchema2, reporterTransitionResponseSchema2, contestReportBody2, reporterListQuery2, listReportsQuery2, GITHUB_ISSUE_URL_REGEX2, githubIssueUrlSchema2, transitionReportBody2, groupReportsBody2, holdReportBody2, clickhouseReadyResponse2, bootstrapQuery2, requestSnapshotChunkMessage2, MAX_NAME_LENGTH3, MAX_VALUE_LENGTH2, MAX_TAGS2, MAX_TAG_LENGTH2, MAX_SCOPE_HUBS2, MAX_SCOPE_TAGS2, vaultSecretScopeSchema2, vaultCreateBody2, vaultUpdateBody2, PERMISSIONS2, MAX_NAME_LENGTH22, MAX_HUBS_PER_GRANT2, MAX_HUB_TAGS_PER_GRANT2, MAX_GRANTS2, permissionEnum2, grantScopeSchema2, grantSchema2, createTokenBody2, tokenOrgIdParam2, tokenGrantScopeSchema2, tokenGrantSchema2, tokenMetadataSchema2, listTokensResponse2, createTokenResponse2, orgTokenSummarySchema2, listOrgTokensResponse2, invitePreviewQuery2, invitePreviewResponse2, discordTier2, discordBillingCycle2, discordMetadata2, discordOAuthStartResponse2, discordOAuthFinalizeBody2, discordOAuthFinalizeResponse2, discordDisconnectResponse2, jsonSchemaSchema2, hubUserIdentity2, stateValueEntry2, getHubUserContextResponse2, updateHubUserBody2, updateHubUserResponse2, unlockHubUserNameResponse2, stateResetParams2, stateResetResponse2, hubAlertsParam2, hubAlertSeverity2, hubAlert2, hubAlertsListResponse2, noticeSeveritySchema2, noticeStatusSchema2, NOTICE_SCOPE_REGEX2, noticeScopeSchema2, noticeLinkSchema2, createNoticeBody2, updateNoticeBody2, listNoticesQuery2, noticeIdParamSchema2, ADMIN_SKILL_NAME_REGEX2, adminSkillNameParam2;
12099
12276
  var init_contracts = __esm({
12100
12277
  "../../packages/core/dist/contracts/index.js"() {
12101
12278
  "use strict";
@@ -12148,6 +12325,8 @@ var init_contracts = __esm({
12148
12325
  init_zod();
12149
12326
  init_zod();
12150
12327
  init_zod();
12328
+ init_zod();
12329
+ init_zod();
12151
12330
  uuidSchema2 = external_exports.string().uuid();
12152
12331
  paginationSchema3 = external_exports.object({
12153
12332
  limit: external_exports.coerce.number().int().min(1).max(100).default(50),
@@ -12261,7 +12440,8 @@ var init_contracts = __esm({
12261
12440
  "monitor",
12262
12441
  "conversation_evaluator",
12263
12442
  "message_evaluator",
12264
- "summarizer"
12443
+ "summarizer",
12444
+ "consultant"
12265
12445
  ];
12266
12446
  SAFE_USER_ID_REGEX2 = /^[A-Za-z0-9_-]{1,64}$/;
12267
12447
  SUPPORTED_LOCALES2 = ["en", "pt", "es"];
@@ -12759,13 +12939,19 @@ var init_contracts = __esm({
12759
12939
  deleteToolQuery2 = external_exports.object({ agent_id: uuidSchema2.optional(), hub_id: uuidSchema2 });
12760
12940
  toolConnectionsQuery2 = external_exports.object({ hub_id: uuidSchema2 });
12761
12941
  nativeToolIdSchema2 = external_exports.string().regex(/^nt-\d{3,}$/, "Invalid native tool id");
12942
+ CONTEXT_BOUNDARIES2 = ["instruction", "summary", "transcript"];
12943
+ contextBoundarySchema2 = external_exports.enum(CONTEXT_BOUNDARIES2);
12762
12944
  addNativeToolBody2 = external_exports.object({
12763
12945
  agent_id: uuidSchema2,
12764
12946
  hub_id: uuidSchema2,
12765
12947
  tool_native_id: nativeToolIdSchema2,
12766
- delegation_type: external_exports.enum(["team", "agent"]).optional(),
12948
+ delegation_type: external_exports.enum(["team", "agent", "hub"]).optional(),
12767
12949
  delegation_id: external_exports.string().optional(),
12768
12950
  delegation_name: external_exports.string().optional(),
12951
+ /** Only meaningful for a `hub` delegation (`delegate_to_hub`); ignored otherwise.
12952
+ * Defaults to `summary` when omitted. Admin-set — the link and boundary require
12953
+ * hub-admin (`hub:write`), never derived from any end user's grants. */
12954
+ delegation_context_boundary: contextBoundarySchema2.optional(),
12769
12955
  resource_config: external_exports.object({
12770
12956
  access_mode: external_exports.enum(["all", "selected", "none"]),
12771
12957
  enabled_resources: external_exports.array(external_exports.string()).optional()
@@ -13624,6 +13810,19 @@ var init_contracts = __esm({
13624
13810
  // caller may send to this receiver. The end-user branch ignores it — see the
13625
13811
  // receiver derivation in the route.
13626
13812
  user_receiver_id: clientOptionalString2,
13813
+ // ── Internal consult (consultant-agents PR 2 — H1.0) ──────────────────────
13814
+ // A team member handling a customer conversation can tag a `consultant`-role
13815
+ // agent for a PRIVATE, team-only exchange that never reaches the customer. A
13816
+ // consult send is a team send with `receiver_type: 'agent'` targeting the
13817
+ // consultant; the still-required `user_receiver_id` identifies the customer whose
13818
+ // conversation this is (and is authorized by `validateAppTeamSendContext`, exactly
13819
+ // as a team→user send is). The consultant is resolved from `agent_receiver_id`
13820
+ // when supplied, else from an `@mention` parsed out of the message text against
13821
+ // the hub's consultant agents. `consult_thread_id` continues an existing thread;
13822
+ // absent, the route creates/reuses the single implicit thread. These fields are
13823
+ // inert on every non-consult send (end-user send, team→user send).
13824
+ agent_receiver_id: clientOptionalString2,
13825
+ consult_thread_id: clientOptionalString2,
13627
13826
  is_first_message: clientOptionalBoolean2,
13628
13827
  end_conversation: clientOptionalBoolean2,
13629
13828
  // Pre-generated by the client so the optimistic bubble and the stored row share
@@ -14007,6 +14206,59 @@ var init_contracts = __esm({
14007
14206
  external_exports.record(external_exports.string().max(128), external_exports.string().max(2048)).refine((r) => Object.keys(r).length <= 50, "too many variables")
14008
14207
  ]).optional()
14009
14208
  });
14209
+ copilotSuggestBody2 = external_exports.object({
14210
+ hub_id: external_exports.string().uuid()
14211
+ });
14212
+ copilotSuggestResponse2 = external_exports.object({
14213
+ status: external_exports.enum(["processing", "skipped"]),
14214
+ reason: external_exports.string().optional()
14215
+ });
14216
+ CONSULT_THREAD_STATUSES2 = ["open", "awaiting", "resolved", "cancelled_at_close"];
14217
+ consultThreadStatus2 = external_exports.enum(CONSULT_THREAD_STATUSES2);
14218
+ CONSULT_THREAD_TITLE_MAX2 = 120;
14219
+ consultThreadTitle2 = external_exports.string().trim().min(1).max(CONSULT_THREAD_TITLE_MAX2);
14220
+ consultThreadSummary2 = external_exports.object({
14221
+ consult_thread_id: external_exports.string(),
14222
+ conversation_id: external_exports.string(),
14223
+ initiator_type: external_exports.enum(["team", "agent"]),
14224
+ initiator_id: external_exports.string(),
14225
+ engaged_agent_id: external_exports.string().nullable(),
14226
+ engaged_agent_name: external_exports.string().nullable(),
14227
+ title: external_exports.string().nullable(),
14228
+ status: consultThreadStatus2,
14229
+ created_at: external_exports.string()
14230
+ });
14231
+ listConsultThreadsQuery2 = external_exports.object({
14232
+ hub_id: external_exports.string().uuid()
14233
+ });
14234
+ listConsultThreadsResponse2 = external_exports.object({
14235
+ threads: external_exports.array(consultThreadSummary2)
14236
+ });
14237
+ createConsultThreadBody2 = external_exports.object({
14238
+ hub_id: external_exports.string().uuid(),
14239
+ title: consultThreadTitle2.optional(),
14240
+ // Optionally engage a consultant on creation. Validated server-side against the
14241
+ // hub's `consultant`-role agents; a non-consultant / unknown id is rejected.
14242
+ engaged_agent_id: external_exports.string().uuid().optional()
14243
+ });
14244
+ createConsultThreadResponse2 = external_exports.object({
14245
+ thread: consultThreadSummary2
14246
+ });
14247
+ consultThreadIdParam2 = external_exports.object({
14248
+ id: external_exports.string().uuid(),
14249
+ threadId: external_exports.string().uuid()
14250
+ });
14251
+ updateConsultThreadBody2 = external_exports.object({
14252
+ hub_id: external_exports.string().uuid(),
14253
+ title: consultThreadTitle2.optional(),
14254
+ engaged_agent_id: external_exports.string().uuid().optional()
14255
+ }).refine((v) => v.title !== void 0 || v.engaged_agent_id !== void 0, {
14256
+ message: "Provide a title and/or an engaged_agent_id to update"
14257
+ });
14258
+ updateConsultThreadResponse2 = external_exports.object({
14259
+ thread: consultThreadSummary2
14260
+ });
14261
+ CONSULT_AWAIT_TIMEOUT_MS2 = 15 * 6e4;
14010
14262
  billingOrgIdParam2 = external_exports.object({
14011
14263
  organizationId: external_exports.string().uuid()
14012
14264
  });
@@ -14254,6 +14506,7 @@ var init_contracts = __esm({
14254
14506
  refineHubAsCodeEvals2(config, ctx);
14255
14507
  refineHubAsCodeEvalAttachments2(config, ctx);
14256
14508
  refineHubAsCodeResources2(config, ctx);
14509
+ refineHubAsCodeDelegation2(config, ctx);
14257
14510
  });
14258
14511
  ciPullHubIdParam2 = external_exports.object({
14259
14512
  hub_id: ciUuidSchema2
@@ -15468,7 +15721,7 @@ var init_eval_attachments = __esm({
15468
15721
  "use strict";
15469
15722
  init_resource_files();
15470
15723
  init_fs_safety();
15471
- init_parser();
15724
+ init_expected();
15472
15725
  ATTACHMENTS_DIR = "attachments";
15473
15726
  }
15474
15727
  });
@@ -15477,17 +15730,10 @@ var init_eval_attachments = __esm({
15477
15730
  import * as fs12 from "fs";
15478
15731
  import * as path14 from "path";
15479
15732
  import * as yaml4 from "js-yaml";
15480
- function expected(message) {
15481
- const err = new Error(message);
15482
- err.isExpected = true;
15483
- return err;
15484
- }
15485
15733
  function parseHubFolder(hubFolder, opts) {
15486
15734
  const yamlPath = resolveHubYamlPath(hubFolder);
15487
15735
  if (!yamlPath) {
15488
- const err = new Error(`hub.yaml not found in ${hubFolder}`);
15489
- err.isExpected = true;
15490
- throw err;
15736
+ throw expected(`hub.yaml not found in ${hubFolder}`);
15491
15737
  }
15492
15738
  const yamlContent = fs12.readFileSync(yamlPath, "utf-8");
15493
15739
  let config;
@@ -15495,27 +15741,19 @@ function parseHubFolder(hubFolder, opts) {
15495
15741
  config = yaml4.load(yamlContent);
15496
15742
  } catch (err) {
15497
15743
  if (err instanceof yaml4.YAMLException) {
15498
- const userError = new Error(`Invalid YAML in ${yamlPath}: ${err.message}`);
15499
- userError.isExpected = true;
15500
- throw userError;
15744
+ throw expected(`Invalid YAML in ${yamlPath}: ${err.message}`);
15501
15745
  }
15502
15746
  throw err;
15503
15747
  }
15504
15748
  if (!config || typeof config !== "object") {
15505
- const invalidError = new Error(`Invalid YAML in ${yamlPath}`);
15506
- invalidError.isExpected = true;
15507
- throw invalidError;
15749
+ throw expected(`Invalid YAML in ${yamlPath}`);
15508
15750
  }
15509
15751
  if (!opts?.allowNewHub) {
15510
15752
  if (!config.hub_id) {
15511
- const err = new Error(`Missing hub_id in ${yamlPath}`);
15512
- err.isExpected = true;
15513
- throw err;
15753
+ throw expected(`Missing hub_id in ${yamlPath}`);
15514
15754
  }
15515
15755
  if (!config.hub_environment) {
15516
- const err = new Error(`Missing hub_environment in ${yamlPath}`);
15517
- err.isExpected = true;
15518
- throw err;
15756
+ throw expected(`Missing hub_environment in ${yamlPath}`);
15519
15757
  }
15520
15758
  }
15521
15759
  const agentYamlFiles = scanAgentYamlFiles(hubFolder);
@@ -15528,11 +15766,9 @@ function parseHubFolder(hubFolder, opts) {
15528
15766
  if (fs12.existsSync(instructionsPath)) {
15529
15767
  resolved.instructions = fs12.readFileSync(instructionsPath, "utf-8");
15530
15768
  } else {
15531
- const err = new Error(
15769
+ throw expected(
15532
15770
  `Agent instructions file not found: ${instructionsPath} (referenced by agent "${agent.name}")`
15533
15771
  );
15534
- err.isExpected = true;
15535
- throw err;
15536
15772
  }
15537
15773
  } else if (resolved.instructions === void 0 && typeof agent.name === "string") {
15538
15774
  const conventionPath = path14.join(hubFolder, "agents", `${slugify(agent.name)}.md`);
@@ -15826,9 +16062,7 @@ function scanAgentYamlFiles(hubFolder) {
15826
16062
  agent = yaml4.load(content);
15827
16063
  } catch (err) {
15828
16064
  if (err instanceof yaml4.YAMLException) {
15829
- const userError = new Error(`Invalid YAML in agents/${file}: ${err.message}`);
15830
- userError.isExpected = true;
15831
- throw userError;
16065
+ throw expected(`Invalid YAML in agents/${file}: ${err.message}`);
15832
16066
  }
15833
16067
  throw err;
15834
16068
  }
@@ -15850,7 +16084,7 @@ function parseResources(hubFolder, configResources) {
15850
16084
  };
15851
16085
  if (res.id) resource.id = res.id;
15852
16086
  if (res.type === "knowledge" || res.type === "skill") resource.type = res.type;
15853
- else if (res.type !== void 0) throw new Error(`Invalid resource type for "${resource.name}": expected knowledge or skill`);
16087
+ else if (res.type !== void 0) throw expected(`Invalid resource type for "${resource.name}": expected knowledge or skill`);
15854
16088
  if (res.description) resource.description = res.description;
15855
16089
  if (res.enabled === false) resource.enabled = false;
15856
16090
  if (res.user_browsable) resource.user_browsable = res.user_browsable;
@@ -15873,6 +16107,7 @@ var init_parser = __esm({
15873
16107
  init_utils();
15874
16108
  init_resource_files();
15875
16109
  init_eval_attachments();
16110
+ init_expected();
15876
16111
  }
15877
16112
  });
15878
16113
 
@@ -16336,7 +16571,7 @@ function shouldWarnIgnoredPreviewLabel(localLabel, serverLabel) {
16336
16571
  function printSyncResult(result) {
16337
16572
  if (result.errors && result.errors.length > 0) {
16338
16573
  printErrors(result.errors);
16339
- throw new Error(`Sync failed with ${result.errors.length} error(s). No completion was reported; inspect the errors above.`);
16574
+ throw expected(`Sync failed with ${result.errors.length} error(s). No completion was reported; inspect the errors above.`);
16340
16575
  }
16341
16576
  console.log(`
16342
16577
  Sync complete. Preview hub: ${result.preview_hub_id}`);
@@ -16749,6 +16984,7 @@ var init_push = __esm({
16749
16984
  "use strict";
16750
16985
  init_auth();
16751
16986
  init_api_client();
16987
+ init_expected();
16752
16988
  init_parser();
16753
16989
  init_hub_materializer();
16754
16990
  init_resource_files();
@@ -18157,6 +18393,14 @@ async function conversationsCommand(args2) {
18157
18393
  }
18158
18394
  console.log("");
18159
18395
  }
18396
+ const prevId = result.conversation.previous_conversation_id;
18397
+ const nextId = result.conversation.next_conversation_id;
18398
+ if (prevId || nextId) {
18399
+ if (prevId) console.log(`Previous conversation: ${prevId}`);
18400
+ if (nextId) console.log(`Next conversation: ${nextId}`);
18401
+ console.log("(Neighbours by closing time. Ones past the conversation retention window are listed but can no longer be opened here.)");
18402
+ console.log("");
18403
+ }
18160
18404
  console.log("Diagnosing agent behavior? The transcript shows what was sent \u2014 not what the model received.");
18161
18405
  console.log(`Drill in: wayai conversations ${conversationId} observability (per-turn resolved prompt, tool calls, latency)`);
18162
18406
  } else if (hasAnalyticsFlags) {