@wayai/cli 0.3.166 → 0.3.167

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
@@ -4797,6 +4797,31 @@ function monitorRuleKeysOffTrigger(monitorConfig) {
4797
4797
  const config = monitorConfig;
4798
4798
  return MONITOR_RULE_KEYS.filter((key) => config[key] !== void 0);
4799
4799
  }
4800
+ function monitorRulesStructuredOutputMessage(trigger) {
4801
+ const [article, consequence] = trigger === "assistant_reply" ? ["an", "every reply is delivered unjudged"] : ["a", "none of their actions runs"];
4802
+ return `${article} ${trigger} monitor with rules needs structured output: its rules read variables only a JSON answer carries, so on text output no rule can match and ${consequence}. Set response_format to json_schema (wayai push), or remove the rules.`;
4803
+ }
4804
+ function monitorRulesStructuredOutputRefusal(agent) {
4805
+ const trigger = refusedRulesTrigger(agent);
4806
+ return trigger === null ? null : monitorRulesStructuredOutputMessage(trigger);
4807
+ }
4808
+ function refusedRulesTrigger(agent) {
4809
+ if (agent.agent_role !== "monitor") return null;
4810
+ const config = decodedMonitorConfig(agent.monitor_config);
4811
+ const trigger = resolveMonitorTrigger(config);
4812
+ if (!MONITOR_RULE_TRIGGERS.includes(trigger)) return null;
4813
+ const rules = config.rules;
4814
+ if (!Array.isArray(rules) || rules.length === 0) return null;
4815
+ return agent.response_format === "json_schema" ? null : trigger;
4816
+ }
4817
+ function decodedMonitorConfig(value) {
4818
+ if (typeof value !== "string") return value;
4819
+ try {
4820
+ return JSON.parse(value);
4821
+ } catch {
4822
+ return null;
4823
+ }
4824
+ }
4800
4825
  function monitorRuleActionKinds(trigger) {
4801
4826
  return trigger === "assistant_reply" ? MONITOR_ASSISTANT_REPLY_ACTION_KINDS : MONITOR_USER_MESSAGE_ACTION_KINDS;
4802
4827
  }
@@ -4945,6 +4970,10 @@ function refineDecisionsModelBinding(body, ctx) {
4945
4970
  ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["agent_settings", "model"], message: refusal2.message });
4946
4971
  }
4947
4972
  }
4973
+ function refineMonitorRulesStructuredOutput(body, ctx) {
4974
+ const refusal2 = monitorRulesStructuredOutputRefusal(body);
4975
+ if (refusal2) ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["response_format"], message: refusal2 });
4976
+ }
4948
4977
  function visibleLength(s) {
4949
4978
  return s.replace(INVISIBLE_NAME_CHARS, "").length;
4950
4979
  }
@@ -5791,7 +5820,7 @@ function refineHubAsCodeDecisionsModel(config, ctx) {
5791
5820
  const refusal2 = checkDecisionsModelBinding({
5792
5821
  model: readAgentSettingsModel(a.settings),
5793
5822
  agent_role: a.role,
5794
- response_format: responseFormat ? "json_schema" : "text",
5823
+ response_format: pushedResponseFormatColumn(responseFormat),
5795
5824
  schema_json: responseFormat?.schema_json ?? null
5796
5825
  });
5797
5826
  if (refusal2) {
@@ -5803,6 +5832,25 @@ function refineHubAsCodeDecisionsModel(config, ctx) {
5803
5832
  }
5804
5833
  });
5805
5834
  }
5835
+ function pushedResponseFormatColumn(responseFormat) {
5836
+ return responseFormat ? "json_schema" : "text";
5837
+ }
5838
+ function refineHubAsCodeMonitorRulesOutput(config, ctx) {
5839
+ const agents = config?.agents;
5840
+ if (!Array.isArray(agents)) return;
5841
+ agents.forEach((agent, agentIndex) => {
5842
+ const a = agent;
5843
+ if (!a) return;
5844
+ const refusal2 = monitorRulesStructuredOutputRefusal({
5845
+ agent_role: a.role,
5846
+ response_format: pushedResponseFormatColumn(a.response_format),
5847
+ monitor_config: a.monitor_config
5848
+ });
5849
+ if (refusal2) {
5850
+ ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["agents", agentIndex, "response_format"], message: refusal2 });
5851
+ }
5852
+ });
5853
+ }
5806
5854
  var 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, AUTH_TYPE, ORG_CREDENTIAL_AUTH_TYPES, AUTH_TYPE_DISPLAY, LEGACY_AUTH_TYPE_MAP, VALID_AUTH_TYPES, AGENT_ROLES, SAFE_USER_ID_REGEX, SUPPORTED_LOCALES, SUMMARIZATION_THRESHOLD_MIN, SUMMARIZATION_THRESHOLD_MAX, PREVIOUS_CONVERSATIONS_MAX, FLAG_CONDITION_OPERATORS, DECISION_SCORE_MIN_LEVELS, DECISION_SCORE_MAX_LEVELS, DECISIONS_MODEL_PREFIXES, DECISION_CAPABLE_AGENT_ROLES, NATIVE_TOOL_SCHEMAS, WAYAI_CONNECTOR, BASE_NATIVE_TOOLS, NATIVE_TOOLS, NATIVE_TOOL_NAMES, previousConversationsCountField, summarizationThresholdField, flagConditionSchema, MONITOR_TRIGGERS, monitorTriggerSchema, MONITOR_FIRING_TRIGGERS, MONITOR_DELAY_SECONDS_MIN, MONITOR_IDLE_DELAY_REQUIRED_MESSAGE, MONITOR_HISTORY_MESSAGES_MAX, monitorHistoryMessagesSchema, monitorIncludeToolResultsSchema, MONITOR_INPUT_SHAPING_KEYS, MONITOR_INPUT_SHAPING_SCHEMAS, MONITOR_INPUT_SHAPING_IDLE_MESSAGE, monitorArgumentSourceSchema, MONITOR_NOTE_TEMPLATE_MAX, monitorActionSchema, monitorRuleSchema, MONITOR_RULE_KEYS, MONITOR_RULE_SCHEMAS, MONITOR_RULE_TRIGGERS, MONITOR_RULE_TRIGGER_MESSAGE, MONITOR_USER_MESSAGE_ACTION_KINDS, MONITOR_ASSISTANT_REPLY_ACTION_KINDS, INSERT_NOTE_TOOL_NAME, RUN_MONITOR_TOOL_NAME, MONITOR_RULE_ALLOWED_NATIVE_TOOLS, MONITOR_RULE_REENTRY_TOOLS, MONITOR_RULE_REENTRY_TRACKS, monitorConfigField, flagConditionsField, 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, followupTypeSchema, EVENT_RELATIVE_FOLLOWUP_TYPES, followupTimeUnitSchema, followupIdSchema, SELECTABLE_FOLLOWUP_TYPES, MAX_LINKED_FOLLOWUP_TARGETS_PER_STATUS, 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, MAX_EVAL_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, ORG_TAG_NAME_REGEX, ORG_TAG_NAME_MAX_LENGTH, createOrgTagBody, updateOrgTagBody, orgCredentialIdParam, listOrgCredentialsQuery, createOrgCredentialBody, updateOrgCredentialBody, BASE_CREDENTIAL_MANAGED_BY, BASE_CREDENTIAL_NAME_MAX, baseCredentialNameSchema, createBaseCredentialLinkBody, baseCredentialLinkParams, baseCredentialLinkQuery, 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, analyticsSqlTable, analyticsSqlSchemaQuery, EVAL_PACING_PRESET_NAMES, PACING_INTERVAL_MIN_MS, PACING_INTERVAL_MAX_MS, EVAL_MAX_RUNS_PER_SCENARIO, EVAL_RUN_DEADLINE_MIN_MS, EVAL_RUN_DEADLINE_MAX_MS, ISO_UTC_RE, paginationSchema2, evalIdParam, sessionIdParam, scenarioSetIdParam, hubIdQuery, evalDateContextSchema, EVAL_FIXTURE_NAME_MAX_LENGTH, evalFixtureOverrideSchema, runSessionQuery, EVAL_INPUT_ROLES, EVAL_INPUT_ROLE_LIST, ROLE_ECHO_MAX, EVAL_INITIAL_STATE_SCOPES, MAX_INITIAL_STATE_ENTRIES, evalInitialStateEntry, createEvalBody, updateEvalBody, EVAL_LIST_MAX_LIMIT, evalListLimit, getEvalsQuery, toggleEvalBody, bulkToggleEvalsBody, pacingConfigSchema, EVAL_MAX_SELECTED_SCENARIOS, evalScenarioSelectionEntrySchema, evalScenarioSelectionSchema, sessionConfigSchema, createSessionBody, getSessionsQuery, getSessionResultsQuery, getSessionRunsQuery, evalAnalyticsQuery, getSessionCostQuery, compareSessionsQuery, evalsSqlBody, evalsSqlSchemaQuery, exportResultsQuery, validateEvalBody, hubAgentsQuery, createScenarioSetBody, updateScenarioSetBody, scenarioSetsHubQuery, createScenarioFromConversationBody, createJourneyFromConversationBody, EVAL_ATTACHMENT_HASH_REGEX, evalAttachmentRef, turnMayCarryAttachments, ATTACHMENTS_USER_ONLY_MESSAGE, journeyIdParam, journeyToolCallSchema, journeyTurnSchema, journeyStepOverrideSchema, fixtureField, createJourneyBody, updateJourneyBody, evalSessionConfigResponseSchema, evalSessionResponseSchema, evalSessionListConfigSchema, evalSessionListItemSchema, seedReleaseStatusSchema, EVAL_SESSION_NOT_QUIESCENT, getConversationsQuery, getMessagesQuery, appMessageSenderType, appMessageReceiverType, apiChannelMessage, apiChannelMessageBody, appMessageBody, appMessageResponse, updateUserBody, updateProfileBody, pathnameRegex, updatePreferencesBody, registerPushTokenBody, deletePushTokenQuery, activityQuery, deletionModeSchema, deletionRequestBody, archiveHubIdParam, archiveConversationParams, archiveListQuery, archiveMessageObservabilityParams, conversationIdParam, claimBody, releaseBody, transferBody, closeBody, additionalContextPayloadSchema, kanbanUpdateBody, annotateConversationBody, observabilityParams, observabilityListParams, deleteUserConversationsBody, deleteUserConversationsResponse, sendMessageBody, listConversationsQuery, flagSourceSchema, getConversationsResponse, getConversationDetailParams, getConversationDetailQuery, getConversationDetailResponse, 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, planKeySchema, billingStatusSchema, billingPlanTypeSchema, dataUsageCountersSchema, REKOR_ENTITLEMENT_CONTRACT_VERSION, entitlementProjectionSchema, rekorEntitlementRefreshMessageSchema, 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, hubAsCodeStateSchema, hubAsCodeResourceFileSchema, hubAsCodeResourceSchema, uuidPattern, ciUuidSchema, boundedHubAsCodeResourcesSchema, hubAsCodeConfigSchema, ciPullHubIdParam, ciBranchParam, ciPullQuery, ciHubsQuery, ciLookupQuery, ciBranchesQuery, ciSyncBody, ciPushBody, ciDiffBody, ciPublishBody, ciPublishPreviewBody, ciSyncMcpBody, ciOrgResourcesParam, orgResourcesConfigSchema, ciOrgResourcesPushBody, ciOrgResourcesDiffBody, CI_APPLY_ENTITY_KINDS, CI_APPLY_OPERATIONS, ciApplyErrorBaseSchema, ciApplyErrorSchema, ciSyncCountSchema, ciSyncChangesSchema, ciSyncWarningSchema, ciSyncResponseSchema, adminOrgIdParam, adminOrgAdminIdParam, adminUserIdParam, PRICING_PLAN_ID_RE, adminPlanIdParam, adminOrganizationsQuery, adminUserSearchQuery, kanbanSlugMigrationQuery, adjustQuotaBody, updatePlanBody, addAdminUserBody, updatePlatformConfigBody, updateFreeOrgLimitBody, adminScopedTargetBody, adminRepairLegacyOrgGrantsBody, adminRepairCompedPlansBody, updatePricingPlanBody, dataExplorerSearchQuery, dataExplorerOrgIdParam, dataExplorerHubIdParam, dataExplorerConvIdParam, dataExplorerDoInstancesQuery, dataExplorerNsIdParam, dataExplorerKvKeysBody, dataExplorerKvKeyBody, uuidOrHexId, dataExplorerDeleteOrgParam, dataExplorerDeleteHubParam, dataExplorerDeleteConvParam, dataExplorerDeleteUserParam, dataExplorerDeleteQuery, dataExplorerKvDeleteBody, 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, META_ENTITY_ID_PATTERN, metaEntityId, 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, 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, REKOR_ACTOR_TYPE_HEADER, REKOR_ACTOR_ID_HEADER, REKOR_ACTOR_LABEL_HEADER, REKOR_ACTOR_ORG_HEADER, REKOR_ACTOR_ADMIN_HEADER, REKOR_CLIENT_HEADER, REKOR_TOOL_ID_HEADER, REKOR_CLIENTS, rekorClientSchema, MAX_REKOR_TOOL_ID_LENGTH, rekorToolIdSchema, DATA_PROXY_MOUNT, DATA_PROXY_PREFIX, REKOR_V1_PREFIX, DATA_PROXY_ORG_QUERY_PARAM, MAX_PROVISIONING_BODY_BYTES, dataProxyQuery, rekorAttestation, REQUIRED_REKOR_ATTESTATION_HEADERS, BASE_DESTRUCTION_MOUNT, BASE_DESTRUCTION_PREFIX, BASE_DESTRUCTION_CONFIRM_PATH, baseDestructionConfirmBody, BASE_DESTRUCTION_GRACE_MS, BASE_DESTRUCTION_CONFIRM_TTL_MS, BASE_DESTRUCTION_ORG_QUERY_PARAM, baseDestructionQuery, baseDestructionParam, baseDestructionInitiateBody, baseDestructionStatus, baseDestructionRequest, baseDestructionListResponse, baseDestructionInitiateResponse, baseDestructionConfirmResponse, baseDestructionCancelResponse, rekorBaseChangeMessageSchema;
5807
5855
  var init_contracts = __esm({
5808
5856
  "../../packages/core/dist/contracts/index.js"() {
@@ -6985,7 +7033,10 @@ var init_contracts = __esm({
6985
7033
  previous_conversations_count: previousConversationsCountField,
6986
7034
  monitor_config: monitorConfigField,
6987
7035
  flag_conditions: flagConditionsField
6988
- }).passthrough().superRefine(refineDecisionsModelBinding);
7036
+ }).passthrough().superRefine((body, ctx) => {
7037
+ refineDecisionsModelBinding(body, ctx);
7038
+ refineMonitorRulesStructuredOutput(body, ctx);
7039
+ });
6989
7040
  updateAgentBody = external_exports.object({
6990
7041
  additional_context_template: external_exports.string().max(2e4).optional(),
6991
7042
  summarization_threshold_tokens: summarizationThresholdField,
@@ -8498,8 +8549,12 @@ var init_contracts = __esm({
8498
8549
  name: clientOptionalString
8499
8550
  }).optional(),
8500
8551
  message: apiChannelMessage,
8501
- // Idempotency key: maps to channel_message_sid; a retried POST echoes the original
8502
- // message_id and skips billing / turn dispatch (dedupe in ConversationDO.storeMessage).
8552
+ // Idempotency key: maps to channel_message_sid, deduped within one conversation
8553
+ // (ConversationDO.storeMessage). A retried POST resolves to the same conversation (a chat
8554
+ // hub's user, the external_ref, the conversation_id, or on a task hub with neither, this key
8555
+ // scoped by the sender), so it echoes the original message_id and skips billing / turn
8556
+ // dispatch. A failed store answers a retryable 503 only when this key is set; without it a
8557
+ // retry could store the message twice, so it answers 400.
8503
8558
  client_message_id: external_exports.string().min(1).max(256).optional()
8504
8559
  }).refine((b) => !(b.external_ref && b.conversation_id), {
8505
8560
  message: "provide external_ref or conversation_id, not both",
@@ -9276,6 +9331,7 @@ var init_contracts = __esm({
9276
9331
  refineHubAsCodeFlagConditions(config, ctx);
9277
9332
  refineHubAsCodeMonitorConfig(config, ctx);
9278
9333
  refineHubAsCodeDecisionsModel(config, ctx);
9334
+ refineHubAsCodeMonitorRulesOutput(config, ctx);
9279
9335
  });
9280
9336
  ciPullHubIdParam = external_exports.object({
9281
9337
  hub_id: ciUuidSchema
@@ -11437,6 +11493,31 @@ function monitorRuleKeysOffTrigger2(monitorConfig) {
11437
11493
  const config = monitorConfig;
11438
11494
  return MONITOR_RULE_KEYS2.filter((key) => config[key] !== void 0);
11439
11495
  }
11496
+ function monitorRulesStructuredOutputMessage2(trigger) {
11497
+ const [article, consequence] = trigger === "assistant_reply" ? ["an", "every reply is delivered unjudged"] : ["a", "none of their actions runs"];
11498
+ return `${article} ${trigger} monitor with rules needs structured output: its rules read variables only a JSON answer carries, so on text output no rule can match and ${consequence}. Set response_format to json_schema (wayai push), or remove the rules.`;
11499
+ }
11500
+ function monitorRulesStructuredOutputRefusal2(agent) {
11501
+ const trigger = refusedRulesTrigger2(agent);
11502
+ return trigger === null ? null : monitorRulesStructuredOutputMessage2(trigger);
11503
+ }
11504
+ function refusedRulesTrigger2(agent) {
11505
+ if (agent.agent_role !== "monitor") return null;
11506
+ const config = decodedMonitorConfig2(agent.monitor_config);
11507
+ const trigger = resolveMonitorTrigger2(config);
11508
+ if (!MONITOR_RULE_TRIGGERS2.includes(trigger)) return null;
11509
+ const rules = config.rules;
11510
+ if (!Array.isArray(rules) || rules.length === 0) return null;
11511
+ return agent.response_format === "json_schema" ? null : trigger;
11512
+ }
11513
+ function decodedMonitorConfig2(value) {
11514
+ if (typeof value !== "string") return value;
11515
+ try {
11516
+ return JSON.parse(value);
11517
+ } catch {
11518
+ return null;
11519
+ }
11520
+ }
11440
11521
  function monitorRuleActionKinds2(trigger) {
11441
11522
  return trigger === "assistant_reply" ? MONITOR_ASSISTANT_REPLY_ACTION_KINDS2 : MONITOR_USER_MESSAGE_ACTION_KINDS2;
11442
11523
  }
@@ -11585,6 +11666,10 @@ function refineDecisionsModelBinding2(body, ctx) {
11585
11666
  ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["agent_settings", "model"], message: refusal2.message });
11586
11667
  }
11587
11668
  }
11669
+ function refineMonitorRulesStructuredOutput2(body, ctx) {
11670
+ const refusal2 = monitorRulesStructuredOutputRefusal2(body);
11671
+ if (refusal2) ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["response_format"], message: refusal2 });
11672
+ }
11588
11673
  function visibleLength2(s) {
11589
11674
  return s.replace(INVISIBLE_NAME_CHARS2, "").length;
11590
11675
  }
@@ -12454,7 +12539,7 @@ function refineHubAsCodeDecisionsModel2(config, ctx) {
12454
12539
  const refusal2 = checkDecisionsModelBinding2({
12455
12540
  model: readAgentSettingsModel2(a.settings),
12456
12541
  agent_role: a.role,
12457
- response_format: responseFormat ? "json_schema" : "text",
12542
+ response_format: pushedResponseFormatColumn2(responseFormat),
12458
12543
  schema_json: responseFormat?.schema_json ?? null
12459
12544
  });
12460
12545
  if (refusal2) {
@@ -12466,6 +12551,25 @@ function refineHubAsCodeDecisionsModel2(config, ctx) {
12466
12551
  }
12467
12552
  });
12468
12553
  }
12554
+ function pushedResponseFormatColumn2(responseFormat) {
12555
+ return responseFormat ? "json_schema" : "text";
12556
+ }
12557
+ function refineHubAsCodeMonitorRulesOutput2(config, ctx) {
12558
+ const agents = config?.agents;
12559
+ if (!Array.isArray(agents)) return;
12560
+ agents.forEach((agent, agentIndex) => {
12561
+ const a = agent;
12562
+ if (!a) return;
12563
+ const refusal2 = monitorRulesStructuredOutputRefusal2({
12564
+ agent_role: a.role,
12565
+ response_format: pushedResponseFormatColumn2(a.response_format),
12566
+ monitor_config: a.monitor_config
12567
+ });
12568
+ if (refusal2) {
12569
+ ctx.addIssue({ code: external_exports.ZodIssueCode.custom, path: ["agents", agentIndex, "response_format"], message: refusal2 });
12570
+ }
12571
+ });
12572
+ }
12469
12573
  function identifyTokenType(token) {
12470
12574
  if (token.startsWith("way_")) return "way_token";
12471
12575
  if (token.startsWith("eyJ")) return "jwt";
@@ -14142,7 +14246,10 @@ var init_dist = __esm({
14142
14246
  previous_conversations_count: previousConversationsCountField2,
14143
14247
  monitor_config: monitorConfigField2,
14144
14248
  flag_conditions: flagConditionsField2
14145
- }).passthrough().superRefine(refineDecisionsModelBinding2);
14249
+ }).passthrough().superRefine((body, ctx) => {
14250
+ refineDecisionsModelBinding2(body, ctx);
14251
+ refineMonitorRulesStructuredOutput2(body, ctx);
14252
+ });
14146
14253
  updateAgentBody2 = external_exports.object({
14147
14254
  additional_context_template: external_exports.string().max(2e4).optional(),
14148
14255
  summarization_threshold_tokens: summarizationThresholdField2,
@@ -15650,8 +15757,12 @@ var init_dist = __esm({
15650
15757
  name: clientOptionalString2
15651
15758
  }).optional(),
15652
15759
  message: apiChannelMessage2,
15653
- // Idempotency key: maps to channel_message_sid; a retried POST echoes the original
15654
- // message_id and skips billing / turn dispatch (dedupe in ConversationDO.storeMessage).
15760
+ // Idempotency key: maps to channel_message_sid, deduped within one conversation
15761
+ // (ConversationDO.storeMessage). A retried POST resolves to the same conversation (a chat
15762
+ // hub's user, the external_ref, the conversation_id, or on a task hub with neither, this key
15763
+ // scoped by the sender), so it echoes the original message_id and skips billing / turn
15764
+ // dispatch. A failed store answers a retryable 503 only when this key is set; without it a
15765
+ // retry could store the message twice, so it answers 400.
15655
15766
  client_message_id: external_exports.string().min(1).max(256).optional()
15656
15767
  }).refine((b) => !(b.external_ref && b.conversation_id), {
15657
15768
  message: "provide external_ref or conversation_id, not both",
@@ -16428,6 +16539,7 @@ var init_dist = __esm({
16428
16539
  refineHubAsCodeFlagConditions2(config, ctx);
16429
16540
  refineHubAsCodeMonitorConfig2(config, ctx);
16430
16541
  refineHubAsCodeDecisionsModel2(config, ctx);
16542
+ refineHubAsCodeMonitorRulesOutput2(config, ctx);
16431
16543
  });
16432
16544
  ciPullHubIdParam2 = external_exports.object({
16433
16545
  hub_id: ciUuidSchema2