UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 4.91 kB
import{t as closedObject}from"./closed-object-CP71yugl.mjs";import{t as stringLiteralUnion}from"./string-literal-union-BSVDXlo3.mjs";import{a as NonEmptyString}from"./primitives-CYTMtVCE.mjs";import{i as ErrorCodes}from"./missing-scope-error-CkgBgh6d.mjs";import{n as GatewayErrorDetailCodes}from"./gateway-error-details-CMG6VuUF.mjs";import{Type}from"typebox"; //!packages/gateway-protocol/src/schema/error-codes.ts const CronJobNotFoundErrorDetailsSchema=closedObject({code:Type.Literal(GatewayErrorDetailCodes.CRON_JOB_NOT_FOUND),jobId:NonEmptyString});const MissingScopeErrorDetailsSchema=closedObject({code:Type.Literal(GatewayErrorDetailCodes.MISSING_SCOPE),missingScope:NonEmptyString,requiredScopes:Type.Array(NonEmptyString,{minItems:1})});const McpAppViewExpiredErrorDetailsSchema=closedObject({code:Type.Literal(GatewayErrorDetailCodes.MCP_APP_VIEW_EXPIRED)});const OutboundDeliveryQueuedErrorDetailsSchema=closedObject({code:Type.Literal(GatewayErrorDetailCodes.OUTBOUND_DELIVERY_QUEUED)});const UserPrefsLimitExceededErrorDetailsSchema=closedObject({code:Type.Literal(GatewayErrorDetailCodes.USER_PREFS_LIMIT_EXCEEDED),limit:Type.Integer({minimum:1}),currentCount:Type.Integer({minimum:0})});const UnknownAgentIdErrorDetailsSchema=closedObject({code:Type.Literal(GatewayErrorDetailCodes.UNKNOWN_AGENT_ID),agentId:NonEmptyString});const SetupAdmissionBusyErrorDetailsSchema=closedObject({code:Type.Literal(GatewayErrorDetailCodes.SETUP_ADMISSION_BUSY)});const GitHubPublicationSelectionRejectedErrorDetailsSchema=closedObject({code:Type.Literal(GatewayErrorDetailCodes.GITHUB_PUBLICATION_SELECTION_REJECTED),idempotencyKey:NonEmptyString});const WizardNotFoundErrorDetailsSchema=closedObject({code:Type.Literal(GatewayErrorDetailCodes.WIZARD_NOT_FOUND)});const ProjectCloneErrorDetailsSchema=closedObject({code:Type.Literal(GatewayErrorDetailCodes.PROJECT_CLONE_FAILED),cause:Type.String({enum:[`invalid_url`,`auth_required`,`not_found`,`network`,`target_exists`,`clone_failed`]})});const SessionWorkspaceRecoveryRequiredErrorDetailsSchema=closedObject({code:Type.Literal(GatewayErrorDetailCodes.SESSION_WORKSPACE_RECOVERY_REQUIRED),cause:Type.Literal(`device_offline`),recoveryAction:Type.Literal(`continue_on_gateway`),sessionId:NonEmptyString,source:closedObject({generation:Type.Integer({minimum:0}),environmentId:NonEmptyString,ownerEpoch:Type.Integer({minimum:1})})});const TaskWorktreeSourceRequiredErrorDetailsSchema=closedObject({code:Type.Literal(GatewayErrorDetailCodes.TASK_WORKTREE_SOURCE_REQUIRED),cwd:NonEmptyString});const ClawHubRiskAcknowledgementRequiredErrorDetailsSchema=closedObject({code:Type.Literal(GatewayErrorDetailCodes.CLAWHUB_RISK_ACKNOWLEDGEMENT_REQUIRED),warning:NonEmptyString});const TemplateReviewRequiredErrorDetailsSchema=closedObject({code:Type.Literal(GatewayErrorDetailCodes.TEMPLATE_REVIEW_REQUIRED),kind:stringLiteralUnion([`plugin`,`skill`])});const PendingInputNotRetiredErrorDetailsSchema=closedObject({code:Type.Literal(GatewayErrorDetailCodes.PENDING_INPUT_NOT_RETIRED),inputIds:Type.Array(NonEmptyString,{minItems:1,maxItems:100})});const GatewayErrorDetailsSchema=Type.Union([CronJobNotFoundErrorDetailsSchema,MissingScopeErrorDetailsSchema,McpAppViewExpiredErrorDetailsSchema,OutboundDeliveryQueuedErrorDetailsSchema,UserPrefsLimitExceededErrorDetailsSchema,ProjectCloneErrorDetailsSchema,UnknownAgentIdErrorDetailsSchema,WizardNotFoundErrorDetailsSchema,SetupAdmissionBusyErrorDetailsSchema,GitHubPublicationSelectionRejectedErrorDetailsSchema,SessionWorkspaceRecoveryRequiredErrorDetailsSchema,TaskWorktreeSourceRequiredErrorDetailsSchema,ClawHubRiskAcknowledgementRequiredErrorDetailsSchema,TemplateReviewRequiredErrorDetailsSchema,PendingInputNotRetiredErrorDetailsSchema,closedObject({code:Type.Literal(GatewayErrorDetailCodes.TASK_HISTORY_PREVIEW_CAPACITY)}),closedObject({code:Type.Literal(GatewayErrorDetailCodes.OPENCLAW_CONFIG_READONLY)})]);function errorShape(e,t,n){return{code:e,message:t,...n}}function buildMissingScopeErrorDetails(e){const t=e.requiredScopes.length>0?[...e.requiredScopes]:[e.missingScope];return{code:GatewayErrorDetailCodes.MISSING_SCOPE,missingScope:e.missingScope,requiredScopes:t}}function missingScopeErrorShape(e){const t=buildMissingScopeErrorDetails(e);return errorShape(ErrorCodes.FORBIDDEN,`missing scope: ${e.missingScope}`,{details:t})}export{OutboundDeliveryQueuedErrorDetailsSchema as a,SetupAdmissionBusyErrorDetailsSchema as c,WizardNotFoundErrorDetailsSchema as d,buildMissingScopeErrorDetails as f,MissingScopeErrorDetailsSchema as i,TemplateReviewRequiredErrorDetailsSchema as l,missingScopeErrorShape as m,CronJobNotFoundErrorDetailsSchema as n,ProjectCloneErrorDetailsSchema as o,errorShape as p,GatewayErrorDetailsSchema as r,SessionWorkspaceRecoveryRequiredErrorDetailsSchema as s,ClawHubRiskAcknowledgementRequiredErrorDetailsSchema as t,UserPrefsLimitExceededErrorDetailsSchema as u};