@ablehi/server-execution-contract 0.2.0 → 0.3.0
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/edge.d.ts +1 -1
- package/dist/edge.js +1 -1
- package/dist/index.d.ts +103 -3
- package/dist/index.js +1 -1
- package/package.json +3 -3
package/dist/edge.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { AcquireExecutionLeaseData, AcquireExecutionLeaseRequest, COMPLETE_EVENT_WAIT_ROUTE_SUBPATH, CONTEXT_STATE_CLEANUP_ROUTE_PATH, CompleteFlowRunWaitBody, CompleteFlowRunWaitData, ContextStateCleanupRequestBody, ContextStateCleanupResponseData, ContextStateScope, CreateHumanInputRequestBody, DEPLOYMENT_HANDSHAKE_DISPATCHER_CAPABILITIES, DEPLOYMENT_HANDSHAKE_REQUIRED_CAPABILITIES, DEPLOYMENT_HANDSHAKE_ROUTE, DISCOVERY_INVOCATION_EGRESS_GRANT_ROUTE_SUBPATH, DISCOVERY_INVOCATION_RUNTIME_CREDENTIAL_ROUTE_SUBPATH, DeploymentHandshakeData, DeploymentHandshakeRequestBody, DeploymentHandshakeResponse, DiscoveryDispatchBody, DiscoveryEgressGrantBinding, DiscoveryExecutionBinding, DiscoveryGrantBody, DiscoveryInvokeRequest, DiscoveryRuntimeCredentialBinding, EGRESS_GRANT_AUDIT_ROUTE_SUBPATH, EGRESS_GRANT_CONSUME_ROUTE_SUBPATH, EGRESS_GRANT_SCOPE_KINDS, EXECUTION_CONTEXT_ROUTE_SUBPATH, EXECUTION_LEASE_INVALID, EXECUTION_LEASE_ROUTE_SUBPATH, EXECUTION_LEASE_SUPERSEDED, EgressGrant, EgressGrantAuditBody, EgressGrantBodyParseResult, EgressGrantConsumeBody, EgressGrantCredentialMaterial, EgressGrantFileRuntime, EgressGrantScopeKind, ExecutionAnchor, ExecutionBinding, ExecutionBindingConnection, ExecutionContextCompiled, ExecutionContextData, ExecutionLease, ExecutionWriteScope, FILE_ACCESS_ROUTE_SUBPATH, FILE_COMPLETE_ROUTE_SUBPATH, FILE_CONTENT_ROUTE_SUBPATH, FILE_STAT_ROUTE_SUBPATH, FILE_UPLOAD_SESSION_ROUTE_SUBPATH, FLOW_RUN_EGRESS_GRANT_ROUTE_SUBPATH, FLOW_RUN_EXECUTION_EVENTS_ROUTE_SUBPATH, FLOW_RUN_EXECUTION_EVENT_TYPES, FLOW_RUN_RESULT_ROUTE_SUBPATH, FLOW_RUN_RUNTIME_CREDENTIAL_ROUTE_SUBPATH, FileMetadataData, FileRefData, FileRuntimeLimits, FileRuntimeScope, FileRuntimeScopeKind, FileUploadSessionData, FlowActionGrantBody, FlowExecutionContextFileRuntime, FlowExecutionScope, FlowRunExecutionEventBody, FlowRunExecutionEventData, FlowRunExecutionEventType, FlowRunInputFactBody, FlowRunResultData, FlowRunResultRequestBody, FlowRuntimeCredentialBody, FlowWaitResolvedEvent, GenerationCallbackErrorCode, HANDLER_BUNDLES_ROUTE_SUBPATH, HANDSHAKE_CAPABILITY_MISSING, HANDSHAKE_CONTRACT_VERSION_MISMATCH, HANDSHAKE_DISPATCH_NAMESPACE_MISMATCH, HANDSHAKE_REQUEST_INVALID, HANDSHAKE_SECRET_MISMATCH, HANDSHAKE_SECRET_UNCONFIGURED, HUMAN_INPUTS_ROUTE_SUBPATH, HUMAN_INPUT_ACKNOWLEDGE_ROUTE_SUBPATH, HUMAN_INPUT_CANCELLED_BY_RESET, HUMAN_INPUT_EXPIRE_ROUTE_SUBPATH, HUMAN_INPUT_REQUEST_ROUTE_SUBPATH, HUMAN_INPUT_RESOLVED_EVENT_PREFIX, HandlerBundle, HandlerBundleModule, HandlerBundlesData, HandlerBundlesParseResult, HumanInputActor, HumanInputOutput, HumanInputRequestView, HumanInputResolvedEvent, HumanInputResponse, INTERNAL_DISCOVERY_INVOCATIONS_ROUTE_PREFIX, INTERNAL_EGRESS_GRANTS_ROUTE_PREFIX, INTERNAL_FILES_ROUTE_PREFIX, INTERNAL_FLOW_RUNS_ROUTE_PREFIX, INTERNAL_FLOW_VERSIONS_ROUTE_PREFIX, INTERNAL_INSTALLATIONS_ROUTE_PREFIX, INTERNAL_POLLING_TRIGGER_INSTANCES_ROUTE_PREFIX, INTERNAL_TOOL_INVOCATIONS_ROUTE_PREFIX, INTERNAL_WEBHOOK_TRIGGER_INSTANCES_ROUTE_PREFIX, IntegrationDiscoverySubject, InternalFileAccessData, InternalFileAccessIntent, POLLING_TRIGGER_CONTEXT_ROUTE_SUBPATH, POLLING_TRIGGER_EGRESS_GRANT_ROUTE_SUBPATH, POLLING_TRIGGER_HANDLER_BUNDLES_ROUTE_SUBPATH, POLLING_TRIGGER_RUNTIME_CREDENTIAL_ROUTE_SUBPATH, POLLING_TRIGGER_TICK_EVENTS_ROUTE_SUBPATH, PackageInputDiscoveryDescriptor, PackageInputDiscoveryKind, PackagePollingTriggerRuntimeDescriptor, PackageTriggerFileOutput, PackageWebhookTriggerRuntimeDescriptor, ParsedFlowRunResultBody, PartiallyRenderedHumanInputDelivery, PartiallyRenderedMapping, PartiallyRenderedTemplatePart, PartiallyRenderedValue, PollingPublishBody, PollingPublishEvent, PollingRuntimeCredentialBody, PollingTriggerContext, PollingTriggerDispatchData, PollingTriggerGrantBody, PresignedFileUrlData, PublishPollingTickEventResult, PublishPollingTickEventsData, REGISTER_EVENT_WAIT_ROUTE_SUBPATH, RUNTIME_CREDENTIAL_SESSION_SCOPE_KINDS, RUN_DISPATCH_UNAVAILABLE, RegisterFlowRunWaitBody, RegisterFlowRunWaitData, RenderedHumanInputPrompt, RuntimeCredentialSession, RuntimeCredentialSessionNetwork, RuntimeCredentialSessionScopeKind, RuntimeNetwork, RuntimeNetworkModel, SERVER_EXECUTION_CONTRACT_VERSION, STEP_RESULT_ROUTE_SUBPATH, ServerExecutionContractVersion, SingleToolGrantBody, StepRecordBody, StepRecordBodyParseResult, StepRecordData, StepRecordResult, TOOL_HANDLER_BUNDLES_ROUTE_SUBPATH, TOOL_INVOCATION_EGRESS_GRANT_ROUTE_SUBPATH, TOOL_INVOCATION_RUNTIME_CREDENTIAL_ROUTE_SUBPATH, ToolHandlerBundlesData, TriggerConnectionInfo, TriggerFileRuntimeDispatch, TriggerHandlerBundlesData, TriggerHandlerModule, WAIT_EXECUTION_SUPERSEDED, WEBHOOK_PROTOCOL_ADAPTER_BUNDLE_ROUTE_SUBPATH, WEBHOOK_PROTOCOL_ADAPTER_MODULE, WEBHOOK_TRIGGER_CONTEXT_ROUTE_SUBPATH, WEBHOOK_TRIGGER_DELIVERY_ROUTE_SUBPATH, WEBHOOK_TRIGGER_EGRESS_GRANT_ROUTE_SUBPATH, WEBHOOK_TRIGGER_EVENTS_ROUTE_SUBPATH, WEBHOOK_TRIGGER_HANDLER_BUNDLES_ROUTE_SUBPATH, WEBHOOK_TRIGGER_REARM_ROUTE_SUBPATH, WEBHOOK_TRIGGER_RUNTIME_CREDENTIAL_ROUTE_SUBPATH, WFP_USER_RUNTIME_MANIFEST_FORMAT_VERSION, WFP_USER_RUNTIME_UNKNOWN_SOURCE_REVISION, WORKFLOW_RESTART_INSTANCE_UNAVAILABLE, WORKFLOW_RESTART_REJECTED, WORKFLOW_RESTART_REQUEST_INVALID, WORKFLOW_RESTART_ROUTE, WebhookDelivery, WebhookDeliveryDispatchData, WebhookProtocolAdapterBundleData, WebhookProtocolAdapterModule, WebhookPublishEvent, WebhookPublishEventsBody, WebhookPublishEventsData, WebhookRearmBody, WebhookRearmData, WebhookRuntimeCredentialBody, WebhookTriggerGrantBody, WebhookTriggerVerificationMethod, WebhookWatcherContext, WfpUserRuntimeManifest, WorkflowDispatchRestartRequest, WorkflowDispatchRestartResponse, WorkflowRestartErrorCode, acquireExecutionLeasePath, completeEventWaitPath, deploymentHandshakeProbePayload, deploymentHandshakeResponseProofPayload, discoveryInvocationEgressGrantPath, discoveryInvocationRuntimeCredentialPath, egressGrantAuditPath, egressGrantConsumePath, executionContextPath, flowRunEgressGrantPath, flowRunExecutionEventsPath, flowRunResultPath, flowRunRuntimeCredentialPath, flowScriptProtocolAdapterModuleName, handlerBundlesPath, humanInputAcknowledgePath, humanInputExpirePath, humanInputRequestPath, humanInputResolvedEventType, humanInputsPath, internalFileAccessPath, internalFileCompletePath, internalFileContentPath, internalFileStatPath, internalFileUploadSessionPath, internalFilesPath, isValidRequestDigest, parseAcquireExecutionLeaseData, parseAcquireExecutionLeaseRequest, parseCompleteFlowRunWaitBody, parseCompleteFlowRunWaitData, parseContextStateCleanupRequestBody, parseContextStateCleanupResponseData, parseContextStateScope, parseCreateHumanInputBody, parseDiscoveryGrantBody, parseDiscoveryRuntimeCredentialBody, parseEgressGrantAuditBody, parseEgressGrantConsumeBody, parseEgressGrantConsumeData, parseEgressGrantData, parseExecutionAnchor, parseExecutionContextData, parseExecutionLease, parseExecutionWriteScope, parseFileMetadataData, parseFileRefData, parseFileRuntimeLimits, parseFileUploadSessionData, parseFlowActionGrantBody, parseFlowExecutionScope, parseFlowRunExecutionEventBody, parseFlowRunExecutionEventData, parseFlowRunResultBody, parseFlowRunResultData, parseFlowRuntimeCredentialBody, parseFlowWaitResolvedEvent, parseHandlerBundle, parseHandlerBundlesData, parseHumanInputAcknowledgeData, parseHumanInputCreateData, parseHumanInputRequestViewData, parseHumanInputResolvedEvent, parseInternalFileAccessData, parsePollingPublishBody, parsePollingRuntimeCredentialBody, parsePollingTriggerContext, parsePollingTriggerDispatchData, parsePollingTriggerGrantBody, parsePublishPollingTickEventsData, parseRegisterFlowRunWaitBody, parseRegisterFlowRunWaitData, parseRuntimeCredentialSessionCredential, parseRuntimeNetwork, parseSingleToolGrantBody, parseSingleToolRuntimeCredentialBody, parseStepRecordBody, parseStepRecordData, parseToolHandlerBundlesData, parseTriggerFileRuntimeDispatch, parseTriggerHandlerBundlesData, parseWebhookDelivery, parseWebhookDeliveryDispatchData, parseWebhookPublishEventsBody, parseWebhookRearmBody, parseWebhookRuntimeCredentialBody, parseWebhookTriggerGrantBody, parseWebhookWatcherContext, parseWorkflowDispatchRestartRequest, parseWorkflowDispatchRestartResponse, pollingTriggerContextPath, pollingTriggerEgressGrantPath, pollingTriggerHandlerBundlesPath, pollingTriggerRuntimeCredentialPath, pollingTriggerTickEventsPath, registerEventWaitPath, requestHasMultipartFileParts, stepResultPath, toolHandlerBundlesPath, toolInvocationEgressGrantPath, toolInvocationRuntimeCredentialPath, webhookProtocolAdapterBundlePath, webhookTriggerContextPath, webhookTriggerDeliveryPath, webhookTriggerEgressGrantPath, webhookTriggerEventsPath, webhookTriggerHandlerBundlesPath, webhookTriggerRearmPath, webhookTriggerRuntimeCredentialPath, wfpUserRuntimeManifestPath } from './index.js';
|
|
1
|
+
export { AcquireExecutionLeaseData, AcquireExecutionLeaseRequest, COMPLETE_EVENT_WAIT_ROUTE_SUBPATH, CONTEXT_STATE_CLEANUP_ROUTE_PATH, CompleteFlowRunWaitBody, CompleteFlowRunWaitData, ContextStateCleanupRequestBody, ContextStateCleanupResponseData, ContextStateScope, CreateHumanInputRequestBody, DEPLOYMENT_HANDSHAKE_DISPATCHER_CAPABILITIES, DEPLOYMENT_HANDSHAKE_REQUIRED_CAPABILITIES, DEPLOYMENT_HANDSHAKE_ROUTE, DISCOVERY_INVOCATION_EGRESS_GRANT_ROUTE_SUBPATH, DISCOVERY_INVOCATION_RUNTIME_CREDENTIAL_ROUTE_SUBPATH, DeploymentHandshakeData, DeploymentHandshakeRequestBody, DeploymentHandshakeResponse, DiscoveryDispatchBody, DiscoveryEgressGrantBinding, DiscoveryExecutionBinding, DiscoveryGrantBody, DiscoveryInvokeRequest, DiscoveryRuntimeCredentialBinding, EGRESS_GRANT_AUDIT_ROUTE_SUBPATH, EGRESS_GRANT_CONSUME_ROUTE_SUBPATH, EGRESS_GRANT_SCOPE_KINDS, EXECUTION_CONTEXT_ROUTE_SUBPATH, EXECUTION_LEASE_INVALID, EXECUTION_LEASE_ROUTE_SUBPATH, EXECUTION_LEASE_SUPERSEDED, EgressGrant, EgressGrantAuditBody, EgressGrantBodyParseResult, EgressGrantConsumeBody, EgressGrantCredentialMaterial, EgressGrantFileRuntime, EgressGrantScopeKind, EmitInboxMessageData, EmitInboxMessageRequest, ExecutionAnchor, ExecutionBinding, ExecutionBindingConnection, ExecutionContextCompiled, ExecutionContextData, ExecutionLease, ExecutionWriteScope, FILE_ACCESS_ROUTE_SUBPATH, FILE_COMPLETE_ROUTE_SUBPATH, FILE_CONTENT_ROUTE_SUBPATH, FILE_STAT_ROUTE_SUBPATH, FILE_UPLOAD_SESSION_ROUTE_SUBPATH, FLOW_RUN_EGRESS_GRANT_ROUTE_SUBPATH, FLOW_RUN_EXECUTION_EVENTS_ROUTE_SUBPATH, FLOW_RUN_EXECUTION_EVENT_TYPES, FLOW_RUN_RESULT_ROUTE_SUBPATH, FLOW_RUN_RUNTIME_CREDENTIAL_ROUTE_SUBPATH, FileMetadataData, FileRefData, FileRuntimeLimits, FileRuntimeScope, FileRuntimeScopeKind, FileUploadSessionData, FlowActionGrantBody, FlowExecutionContextFileRuntime, FlowExecutionScope, FlowRunExecutionEventBody, FlowRunExecutionEventData, FlowRunExecutionEventType, FlowRunInputFactBody, FlowRunResultData, FlowRunResultRequestBody, FlowRuntimeCredentialBody, FlowWaitResolvedEvent, GenerationCallbackErrorCode, HANDLER_BUNDLES_ROUTE_SUBPATH, HANDSHAKE_CAPABILITY_MISSING, HANDSHAKE_CONTRACT_VERSION_MISMATCH, HANDSHAKE_DISPATCH_NAMESPACE_MISMATCH, HANDSHAKE_REQUEST_INVALID, HANDSHAKE_SECRET_MISMATCH, HANDSHAKE_SECRET_UNCONFIGURED, HUMAN_INPUTS_ROUTE_SUBPATH, HUMAN_INPUT_ACKNOWLEDGE_ROUTE_SUBPATH, HUMAN_INPUT_CANCELLED_BY_RESET, HUMAN_INPUT_EXPIRE_ROUTE_SUBPATH, HUMAN_INPUT_PROMPT_BODY_MAX_CODE_POINTS, HUMAN_INPUT_PROMPT_TITLE_MAX_CODE_POINTS, HUMAN_INPUT_REQUEST_ROUTE_SUBPATH, HUMAN_INPUT_RESOLVED_EVENT_PREFIX, HandlerBundle, HandlerBundleModule, HandlerBundlesData, HandlerBundlesParseResult, HumanInputActor, HumanInputOutput, HumanInputRequestView, HumanInputResolvedEvent, HumanInputResponse, INBOX_MESSAGE_EMISSION_ROUTE_SUBPATH, INBOX_MESSAGE_EXECUTION_ERROR_REGISTRY, INTERNAL_DISCOVERY_INVOCATIONS_ROUTE_PREFIX, INTERNAL_EGRESS_GRANTS_ROUTE_PREFIX, INTERNAL_FILES_ROUTE_PREFIX, INTERNAL_FLOW_RUNS_ROUTE_PREFIX, INTERNAL_FLOW_VERSIONS_ROUTE_PREFIX, INTERNAL_INSTALLATIONS_ROUTE_PREFIX, INTERNAL_POLLING_TRIGGER_INSTANCES_ROUTE_PREFIX, INTERNAL_TOOL_INVOCATIONS_ROUTE_PREFIX, INTERNAL_WEBHOOK_TRIGGER_INSTANCES_ROUTE_PREFIX, InboxMessageExecutionErrorCode, IntegrationDiscoverySubject, InternalFileAccessData, InternalFileAccessIntent, POLLING_TRIGGER_CONTEXT_ROUTE_SUBPATH, POLLING_TRIGGER_EGRESS_GRANT_ROUTE_SUBPATH, POLLING_TRIGGER_HANDLER_BUNDLES_ROUTE_SUBPATH, POLLING_TRIGGER_RUNTIME_CREDENTIAL_ROUTE_SUBPATH, POLLING_TRIGGER_TICK_EVENTS_ROUTE_SUBPATH, PackageInputDiscoveryDescriptor, PackageInputDiscoveryKind, PackagePollingTriggerRuntimeDescriptor, PackageTriggerFileOutput, PackageWebhookTriggerRuntimeDescriptor, ParsedFlowRunResultBody, PartiallyRenderedHumanInputDelivery, PartiallyRenderedMapping, PartiallyRenderedTemplatePart, PartiallyRenderedValue, PollingPublishBody, PollingPublishEvent, PollingRuntimeCredentialBody, PollingTriggerContext, PollingTriggerDispatchData, PollingTriggerGrantBody, PresignedFileUrlData, PublishPollingTickEventResult, PublishPollingTickEventsData, REGISTER_EVENT_WAIT_ROUTE_SUBPATH, RUNTIME_CREDENTIAL_SESSION_SCOPE_KINDS, RUN_DISPATCH_UNAVAILABLE, RegisterFlowRunWaitBody, RegisterFlowRunWaitData, RenderedHumanInputPrompt, RuntimeCredentialSession, RuntimeCredentialSessionNetwork, RuntimeCredentialSessionScopeKind, RuntimeNetwork, RuntimeNetworkModel, SERVER_EXECUTION_CONTRACT_VERSION, STEP_RESULT_ROUTE_SUBPATH, ServerExecutionContractVersion, ServerExecutionError, ServerExecutionErrorEnvelope, SingleToolGrantBody, StepRecordBody, StepRecordBodyParseResult, StepRecordData, StepRecordResult, TOOL_HANDLER_BUNDLES_ROUTE_SUBPATH, TOOL_INVOCATION_EGRESS_GRANT_ROUTE_SUBPATH, TOOL_INVOCATION_RUNTIME_CREDENTIAL_ROUTE_SUBPATH, ToolHandlerBundlesData, TriggerConnectionInfo, TriggerFileRuntimeDispatch, TriggerHandlerBundlesData, TriggerHandlerModule, WAIT_EXECUTION_SUPERSEDED, WEBHOOK_PROTOCOL_ADAPTER_BUNDLE_ROUTE_SUBPATH, WEBHOOK_PROTOCOL_ADAPTER_MODULE, WEBHOOK_TRIGGER_CONTEXT_ROUTE_SUBPATH, WEBHOOK_TRIGGER_DELIVERY_ROUTE_SUBPATH, WEBHOOK_TRIGGER_EGRESS_GRANT_ROUTE_SUBPATH, WEBHOOK_TRIGGER_EVENTS_ROUTE_SUBPATH, WEBHOOK_TRIGGER_HANDLER_BUNDLES_ROUTE_SUBPATH, WEBHOOK_TRIGGER_REARM_ROUTE_SUBPATH, WEBHOOK_TRIGGER_RUNTIME_CREDENTIAL_ROUTE_SUBPATH, WFP_USER_RUNTIME_MANIFEST_FORMAT_VERSION, WFP_USER_RUNTIME_UNKNOWN_SOURCE_REVISION, WORKFLOW_RESTART_INSTANCE_UNAVAILABLE, WORKFLOW_RESTART_REJECTED, WORKFLOW_RESTART_REQUEST_INVALID, WORKFLOW_RESTART_ROUTE, WebhookDelivery, WebhookDeliveryDispatchData, WebhookProtocolAdapterBundleData, WebhookProtocolAdapterModule, WebhookPublishEvent, WebhookPublishEventsBody, WebhookPublishEventsData, WebhookRearmBody, WebhookRearmData, WebhookRuntimeCredentialBody, WebhookTriggerGrantBody, WebhookTriggerVerificationMethod, WebhookWatcherContext, WfpUserRuntimeManifest, WorkflowDispatchRestartRequest, WorkflowDispatchRestartResponse, WorkflowRestartErrorCode, acquireExecutionLeasePath, completeEventWaitPath, deploymentHandshakeProbePayload, deploymentHandshakeResponseProofPayload, discoveryInvocationEgressGrantPath, discoveryInvocationRuntimeCredentialPath, egressGrantAuditPath, egressGrantConsumePath, executionContextPath, flowRunEgressGrantPath, flowRunExecutionEventsPath, flowRunResultPath, flowRunRuntimeCredentialPath, flowScriptProtocolAdapterModuleName, handlerBundlesPath, humanInputAcknowledgePath, humanInputExpirePath, humanInputRequestPath, humanInputResolvedEventType, humanInputsPath, inboxMessageEmissionPath, internalFileAccessPath, internalFileCompletePath, internalFileContentPath, internalFileStatPath, internalFileUploadSessionPath, internalFilesPath, isValidRequestDigest, parseAcquireExecutionLeaseData, parseAcquireExecutionLeaseRequest, parseCompleteFlowRunWaitBody, parseCompleteFlowRunWaitData, parseContextStateCleanupRequestBody, parseContextStateCleanupResponseData, parseContextStateScope, parseCreateHumanInputBody, parseDiscoveryGrantBody, parseDiscoveryRuntimeCredentialBody, parseEgressGrantAuditBody, parseEgressGrantConsumeBody, parseEgressGrantConsumeData, parseEgressGrantData, parseEmitInboxMessageData, parseEmitInboxMessageRequest, parseExecutionAnchor, parseExecutionContextData, parseExecutionLease, parseExecutionWriteScope, parseFileMetadataData, parseFileRefData, parseFileRuntimeLimits, parseFileUploadSessionData, parseFlowActionGrantBody, parseFlowExecutionScope, parseFlowRunExecutionEventBody, parseFlowRunExecutionEventData, parseFlowRunResultBody, parseFlowRunResultData, parseFlowRuntimeCredentialBody, parseFlowWaitResolvedEvent, parseHandlerBundle, parseHandlerBundlesData, parseHumanInputAcknowledgeData, parseHumanInputCreateData, parseHumanInputRequestViewData, parseHumanInputResolvedEvent, parseHumanInputResponse, parseHumanInputResponseForSpec, parseHumanInputSpec, parseInternalFileAccessData, parsePollingPublishBody, parsePollingRuntimeCredentialBody, parsePollingTriggerContext, parsePollingTriggerDispatchData, parsePollingTriggerGrantBody, parsePublishPollingTickEventsData, parseRegisterFlowRunWaitBody, parseRegisterFlowRunWaitData, parseRenderedHumanInputPrompt, parseRuntimeCredentialSessionCredential, parseRuntimeNetwork, parseServerExecutionErrorEnvelope, parseSingleToolGrantBody, parseSingleToolRuntimeCredentialBody, parseStepRecordBody, parseStepRecordData, parseToolHandlerBundlesData, parseTriggerFileRuntimeDispatch, parseTriggerHandlerBundlesData, parseWebhookDelivery, parseWebhookDeliveryDispatchData, parseWebhookPublishEventsBody, parseWebhookRearmBody, parseWebhookRuntimeCredentialBody, parseWebhookTriggerGrantBody, parseWebhookWatcherContext, parseWorkflowDispatchRestartRequest, parseWorkflowDispatchRestartResponse, pollingTriggerContextPath, pollingTriggerEgressGrantPath, pollingTriggerHandlerBundlesPath, pollingTriggerRuntimeCredentialPath, pollingTriggerTickEventsPath, registerEventWaitPath, requestHasMultipartFileParts, stepResultPath, toolHandlerBundlesPath, toolInvocationEgressGrantPath, toolInvocationRuntimeCredentialPath, webhookProtocolAdapterBundlePath, webhookTriggerContextPath, webhookTriggerDeliveryPath, webhookTriggerEgressGrantPath, webhookTriggerEventsPath, webhookTriggerHandlerBundlesPath, webhookTriggerRearmPath, webhookTriggerRuntimeCredentialPath, wfpUserRuntimeManifestPath } from './index.js';
|
|
2
2
|
import '@ablehi/flow-contract';
|
|
3
3
|
import '@ablehi/error-contract';
|
package/dist/edge.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var de="0.3.0";function u(e){return{ok:!0,value:e}}function r(e){return{ok:!1,reason:e}}function i(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var dt="/cleanup-state-scopes";function x(e){if(!i(e)||typeof e.kind!="string")return r("context state scope surface shape is invalid");switch(e.kind){case"webhook-trigger":return pe(e);case"polling-trigger":return le(e);case"flow-action":return fe(e);default:return r("context state scope kind is invalid")}}function pt(e){if(!i(e))return r("cleanup request body must be a JSON object");let t=U(e,["scopes"]);if(t!==void 0)return r(`cleanup request does not accept the "${t}" field`);if(!Array.isArray(e.scopes))return r("cleanup request scopes must be an array");let n=[];for(let o of e.scopes){let s=x(o);if(!s.ok)return s;n.push(s.value)}return u({scopes:n})}function lt(e){return!i(e)||typeof e.deleted!="number"||!Number.isSafeInteger(e.deleted)||e.deleted<0?r("cleanup response data surface shape is invalid"):u({deleted:e.deleted})}function pe(e){let t=U(e,["kind","workspaceId","triggerInstanceId"]);return t!==void 0?r(`webhook trigger scope does not accept "${t}"`):e.kind!=="webhook-trigger"||!E(e.workspaceId)||!E(e.triggerInstanceId)?r("webhook trigger state scope is invalid"):u({kind:"webhook-trigger",workspaceId:e.workspaceId,triggerInstanceId:e.triggerInstanceId})}function le(e){let t=U(e,["kind","workspaceId","pollingInstanceId"]);return t!==void 0?r(`polling trigger scope does not accept "${t}"`):e.kind!=="polling-trigger"||!E(e.workspaceId)||!E(e.pollingInstanceId)?r("polling trigger state scope is invalid"):u({kind:"polling-trigger",workspaceId:e.workspaceId,pollingInstanceId:e.pollingInstanceId})}function fe(e){let t=U(e,["kind","workspaceId","flowId","nodeId","connectionId"]);if(t!==void 0)return r(`flow action scope does not accept "${t}"`);let n=e.connectionId;return e.kind!=="flow-action"||!E(e.workspaceId)||!E(e.flowId)||!E(e.nodeId)||n!==null&&!E(n)?r("flow action state scope is invalid"):u({kind:"flow-action",workspaceId:e.workspaceId,flowId:e.flowId,nodeId:e.nodeId,connectionId:n})}function E(e){return typeof e=="string"&&e.length>0}function U(e,t){return Object.keys(e).find(n=>!t.includes(n))}import{parseFlowDefinition as Ie}from"@ablehi/flow-contract";var mt="/:flowRunId/execution-leases",It="/restart",yt="WORKFLOW_RESTART_REQUEST_INVALID",kt="WORKFLOW_RESTART_INSTANCE_UNAVAILABLE",Et="WORKFLOW_RESTART_REJECTED",_t="RUN_DISPATCH_UNAVAILABLE",xt="EXECUTION_LEASE_INVALID",ht="EXECUTION_LEASE_SUPERSEDED",wt="WAIT_EXECUTION_SUPERSEDED",Tt="HUMAN_INPUT_CANCELLED_BY_RESET";function St(e){return`${g}/${encodeURIComponent(e)}/execution-leases`}var ge=/^generation:[A-Za-z0-9][A-Za-z0-9._:-]{0,239}$/;function Y(e){return!i(e)||!y(e,e.kind==="standalone"?["kind"]:["kind","productRunId"])?r("execution scope shape is invalid"):e.kind==="standalone"?u({kind:"standalone"}):e.kind==="automation_app"&&I(e.productRunId)?u({kind:"automation_app",productRunId:e.productRunId}):r("execution scope discriminator is invalid")}function Q(e){return i(e)?e.kind==="terminal"&&y(e,["kind"])?u({kind:"terminal"}):e.kind==="node"&&y(e,["kind","nodeId"])&&I(e.nodeId)?u({kind:"node",nodeId:e.nodeId}):r("execution anchor shape is invalid"):r("execution anchor must be an object")}function Re(e){if(!i(e)||!y(e,["productRunId","flowRunId","generationId","generationNumber","anchor","leaseId"])||!I(e.productRunId)||!I(e.flowRunId)||!I(e.generationId)||!me(e.generationNumber)||!I(e.leaseId))return r("execution lease shape is invalid");let t=Q(e.anchor);return t.ok?u({productRunId:e.productRunId,flowRunId:e.flowRunId,generationId:e.generationId,generationNumber:e.generationNumber,anchor:t.value,leaseId:e.leaseId}):r(t.reason)}function k(e){if(!i(e))return r("execution write scope must be an object");if(e.kind==="standalone"&&y(e,["kind"]))return u({kind:"standalone"});if(e.kind==="automation_app"&&y(e,["kind","lease"])){let t=Re(e.lease);return t.ok?u({kind:"automation_app",lease:t.value}):r(t.reason)}return r("execution write scope shape is invalid")}function Pt(e){if(!i(e)||!y(e,["anchor"]))return r("lease request shape is invalid");let t=Q(e.anchor);return t.ok?u({anchor:t.value}):r(t.reason)}function At(e){if(!i(e)||!y(e,["executionScope"]))return r("lease response shape is invalid");let t=k(e.executionScope);return t.ok?u({executionScope:t.value}):r(t.reason)}function Ct(e){return!i(e)||!y(e,["instanceId","flowRunId","commandId","generationId","from"])||!I(e.instanceId)||!I(e.flowRunId)||!I(e.commandId)||!I(e.generationId)||!i(e.from)||!y(e.from,["name","count","type"])||typeof e.from.name!="string"||!ge.test(e.from.name)||e.from.name==="generation:terminal"||e.from.count!==1||e.from.type!=="do"?r("restart request shape is invalid"):u(e)}function bt(e){return!i(e)||!y(e,["ok","data"])||e.ok!==!0||!i(e.data)||!y(e.data,["accepted","instanceId","commandId","generationId"])||e.data.accepted!==!0||!I(e.data.instanceId)||!I(e.data.commandId)||!I(e.data.generationId)?r("restart response shape is invalid"):u(e)}function y(e,t){let n=Object.keys(e).sort(),o=[...t].sort();return n.length===o.length&&n.every((s,a)=>s===o[a])}function I(e){return typeof e=="string"&&e.length>0}function me(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0}var g="/internal/flow-runs",Ft="/:flowRunId/execution-context";function Bt(e){return`${g}/${encodeURIComponent(e)}/execution-context`}function $(e){return!i(e)||!L(e.fileMaxBytes)||!L(e.fileReadMaxBytes)||!L(e.inlineMultipartBytesMax)?r("file runtime limits must carry three positive integer bounds"):u({fileMaxBytes:e.fileMaxBytes,fileReadMaxBytes:e.fileReadMaxBytes,inlineMultipartBytesMax:e.inlineMultipartBytesMax})}function Ht(e){if(!i(e))return r("execution context must be a JSON object");let t=z(e,["flowRunId","workspaceId","input","executionScope","compiled","executionBindings","fileRuntime"]);if(t!==void 0)return r(`execution context does not accept the "${t}" field`);let n=e.compiled;if(typeof e.flowRunId!="string"||typeof e.workspaceId!="string"||!i(e.input)||!i(n)||z(n,["irSchemaVersion","interpreterContractVersion","ir","compiledArtifactId"])!==void 0||typeof n.irSchemaVersion!="string"||typeof n.interpreterContractVersion!="string"||typeof n.compiledArtifactId!="string"||!ke(e.executionBindings))return r("execution context surface shape is invalid");let o=Ie(n.ir);if(!o.ok)return r(o.reason);let s=Y(e.executionScope);if(!s.ok)return r(s.reason);let a=ye(e.fileRuntime);return a.ok?u({...e,compiled:{...n,ir:o.value},executionScope:s.value,fileRuntime:a.value}):r(a.reason)}function ye(e){if(e===null)return u(null);if(!i(e))return r("fileRuntime must be null or an object");let t=$(e.limits);return t.ok?u({limits:t.value}):r(t.reason)}function ke(e){return Array.isArray(e)?e.every(t=>{if(!i(t))return!1;let n=t.connection,o=x(t.stateScope);return typeof t.nodeId=="string"&&typeof t.toolRef=="string"&&i(t.toolDescriptor)&&i(t.integrationDescriptor)&&i(n)&&typeof n.installationId=="string"&&typeof n.connectionRef=="string"&&typeof n.connectionId=="string"&&typeof n.authProfileRef=="string"&&typeof n.authType=="string"&&o.ok}):!1}function L(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0}function z(e,t){return Object.keys(e).find(n=>!t.includes(n))}import{parseAblehiErrorDigest as W}from"@ablehi/error-contract";var qt="/:flowRunId/steps/:nodeId/result",Mt="/:flowRunId/result",Vt="/:flowRunId/execution-events",jt="/:flowRunId/waits/:nodeId/register",Xt="/:flowRunId/waits/:nodeId/complete";function Jt(e,t){return`${g}/${encodeURIComponent(e)}/steps/${encodeURIComponent(t)}/result`}function Yt(e){return`${g}/${encodeURIComponent(e)}/result`}function Qt(e){return`${g}/${encodeURIComponent(e)}/execution-events`}function zt(e,t){return`${g}/${encodeURIComponent(e)}/waits/${encodeURIComponent(t)}/register`}function Zt(e,t){return`${g}/${encodeURIComponent(e)}/waits/${encodeURIComponent(t)}/complete`}function en(e){if(!i(e))return{ok:!1,kind:"validation",reason:"step record body must be a JSON object"};let t=R(e,["executionScope","attempt","result","durationMs"]);if(t!==void 0)return{ok:!1,kind:"validation",reason:`step record does not accept the "${t}" field`};let n=k(e.executionScope);if(!n.ok)return{ok:!1,kind:"validation",reason:n.reason};let o=e.attempt;if(typeof o!="number"||!Number.isInteger(o)||o<=0)return{ok:!1,kind:"validation",reason:"attempt must be a positive integer"};let s=Ee(e.result);if(!s.ok)return s;let a={executionScope:n.value,attempt:o,result:s.value};if(e.durationMs!==void 0){let c=e.durationMs;if(typeof c!="number"||!Number.isFinite(c)||c<0)return{ok:!1,kind:"validation",reason:"durationMs must be a non-negative number"};a.durationMs=c}return{ok:!0,value:a}}function Ee(e){if(!i(e))return{ok:!1,kind:"step_result_invalid",reason:"result must be a JSON object"};let t=e.status;if(t==="succeeded"){let n=R(e,["status","output"]);return n!==void 0?{ok:!1,kind:"validation",reason:`step record result does not accept the "${n}" field`}:"output"in e?{ok:!0,value:{status:"succeeded",output:e.output}}:{ok:!1,kind:"step_result_invalid",reason:"a succeeded result must carry output"}}if(t==="failed"){let n=R(e,["status","error"]);if(n!==void 0)return{ok:!1,kind:"validation",reason:`step record result does not accept the "${n}" field`};let o=W(e.error);return o.ok?{ok:!0,value:{status:"failed",error:o.value}}:{ok:!1,kind:"step_result_invalid",reason:`a failed result must carry an AblehiErrorDigest: ${o.reason}`}}if(t==="skipped"){let n=R(e,["status","reason"]);return n!==void 0?{ok:!1,kind:"validation",reason:`step record result does not accept the "${n}" field`}:e.reason!=="run_if_false"?{ok:!1,kind:"step_result_invalid",reason:'a skipped result reason must be "run_if_false"'}:{ok:!0,value:{status:"skipped",reason:"run_if_false"}}}if(t==="timed_out"){let n=R(e,["status","error"]);if(n!==void 0)return{ok:!1,kind:"validation",reason:`step record result does not accept the "${n}" field`};let o=W(e.error);return o.ok?{ok:!0,value:{status:"timed_out",error:o.value}}:{ok:!1,kind:"step_result_invalid",reason:`a timed_out result must carry an AblehiErrorDigest: ${o.reason}`}}return{ok:!1,kind:"step_result_invalid",reason:'result status must be "succeeded", "failed", "skipped", or "timed_out"'}}function tn(e){return!i(e)||typeof e.flowRunId!="string"||typeof e.nodeId!="string"||!_e(e.recorded)?r("step record data surface shape is invalid"):u({flowRunId:e.flowRunId,nodeId:e.nodeId,recorded:e.recorded})}function _e(e){return e==="succeeded"||e==="failed"||e==="skipped"||e==="timed_out"}function nn(e){if(!i(e))return r("result body must be a JSON object");let t=R(e,["executionScope","status","output","error"]);if(t!==void 0)return r(`result does not accept the "${t}" field`);let n=k(e.executionScope);if(!n.ok)return r(n.reason);let o=e.status;if(o!=="succeeded"&&o!=="failed")return r('result status must be "succeeded" or "failed"');let s={executionScope:n.value,status:o};if(e.output!==void 0){if(o!=="succeeded")return r("output is only allowed on a succeeded result");s.output=e.output}if(e.error!==void 0){if(o!=="failed")return r("error is only allowed on a failed result");let a=W(e.error);if(!a.ok)return r(`result error must be an AblehiErrorDigest: ${a.reason}`);s.error=a.value}return o==="failed"&&s.error===void 0?r("a failed result must carry an AblehiErrorDigest"):u(s)}function rn(e){return i(e)?u(e):r("flow run result data must be a JSON object")}var xe=["flow_run_started","step_started","step_retry_scheduled","wait_registered","wait_event_received","wait_event_timed_out","human_input_created","human_input_submitted","human_input_expired","flow_run_succeeded","flow_run_failed","flow_run_interrupted","flow_run_cancelled"];function on(e){if(!i(e))return r("execution event data must be a JSON object");let t=R(e,["flowRunId","eventId","accepted"]);return t!==void 0?r(`execution event data does not accept the "${t}" field`):typeof e.flowRunId!="string"||e.flowRunId.length===0?r("flowRunId must be a non-empty string"):typeof e.eventId!="string"||e.eventId.length===0?r("eventId must be a non-empty string"):e.accepted!==!0?r("accepted must be true"):u({flowRunId:e.flowRunId,eventId:e.eventId,accepted:!0})}function sn(e){if(!i(e))return r("execution event body must be a JSON object");let t=R(e,["executionScope","eventId","eventType","nodeId","stepRunId","attempt","durationMs","occurredAt","errorId","payloadRef","inputFact"]);if(t!==void 0)return r(`execution event does not accept the "${t}" field`);let n=k(e.executionScope);if(!n.ok)return r(n.reason);let o=e.eventId;if(typeof o!="string"||o.length===0)return r("eventId must be a non-empty string");let s=e.eventType;if(!he(s))return r("eventType is not a known flow execution event type");let a=e.occurredAt;if(typeof a!="string"||a.length===0)return r("occurredAt must be a non-empty string");let c={executionScope:n.value,eventId:o,eventType:s,occurredAt:a};for(let d of["nodeId","stepRunId","errorId","payloadRef"]){let f=e[d];if(f!==void 0){if(typeof f!="string"||f.length===0)return r(`${d} must be a non-empty string`);c[d]=f}}for(let d of["attempt","durationMs"]){let f=e[d];if(f!==void 0){if(typeof f!="number"||!Number.isFinite(f)||!Number.isInteger(f)||f<0)return r(`${d} must be a non-negative integer`);c[d]=f}}if(e.inputFact!==void 0){if(s!=="step_started")return r("inputFact is only allowed on step_started events");if(c.attempt===void 0)return r("inputFact requires attempt");let d=we(e.inputFact);if(!d.ok)return d;c.inputFact=d.value}return u(c)}function he(e){return typeof e=="string"&&xe.includes(e)}function we(e){if(!i(e))return r("inputFact must be a JSON object");let t=R(e,["digestAlgorithm","digest","domain"]);if(t!==void 0)return r(`inputFact does not accept the "${t}" field`);if(e.digestAlgorithm!=="sha256")return r('inputFact.digestAlgorithm must be "sha256"');let n=e.digest;if(typeof n!="string"||!/^[0-9a-f]{64}$/.test(n))return r("inputFact.digest must be a sha256 hex string");let o=e.domain;if(!i(o))return r("inputFact.domain must be a JSON object");let s=R(o,["irSchemaVersion","interpreterContractVersion","compiledArtifactId","nodeId","algorithmVersion"]);return s!==void 0?r(`inputFact.domain does not accept the "${s}" field`):typeof o.irSchemaVersion!="string"||o.irSchemaVersion.length===0||typeof o.interpreterContractVersion!="string"||o.interpreterContractVersion.length===0||typeof o.compiledArtifactId!="string"||o.compiledArtifactId.length===0||typeof o.nodeId!="string"||o.nodeId.length===0?r("inputFact.domain string fields must be non-empty strings"):o.algorithmVersion!=="flow_input_digest.v1"?r('inputFact.domain.algorithmVersion must be "flow_input_digest.v1"'):u({digestAlgorithm:"sha256",digest:n,domain:{irSchemaVersion:o.irSchemaVersion,interpreterContractVersion:o.interpreterContractVersion,compiledArtifactId:o.compiledArtifactId,nodeId:o.nodeId,algorithmVersion:"flow_input_digest.v1"}})}var Te=/^[A-Za-z0-9_-]{1,100}$/;function un(e){if(!i(e))return r("register body must be a JSON object");let t=R(e,["executionScope","eventType","correlationKey"]);if(t!==void 0)return r(`register wait does not accept the "${t}" field`);let n=k(e.executionScope);if(!n.ok)return r(n.reason);let o=Z(e.eventType);if(!o.ok)return r(o.reason);let s=e.correlationKey;return typeof s!="string"||s.length===0?r("correlationKey must be a non-empty string"):u({executionScope:n.value,eventType:o.value,correlationKey:s})}function an(e){if(!i(e))return r("complete body must be a JSON object");let t=R(e,["executionScope","waitExecutionId","outcome","eventId"]);if(t!==void 0)return r(`complete wait does not accept the "${t}" field`);let n=k(e.executionScope);if(!n.ok)return r(n.reason);let o=e.waitExecutionId;if(typeof o!="string"||o.length===0)return r("waitExecutionId must be a non-empty string");let s=e.outcome;if(s!=="received"&&s!=="timed_out")return r('outcome must be "received" or "timed_out"');let a={executionScope:n.value,waitExecutionId:o,outcome:s};if(e.eventId!==void 0){if(typeof e.eventId!="string"||e.eventId.length===0)return r("eventId must be a non-empty string");a.eventId=e.eventId}return u(a)}function cn(e){if(!i(e)||R(e,["waitExecutionId","workflowEventType"])!==void 0||typeof e.waitExecutionId!="string"||e.waitExecutionId.length===0)return r("register wait data surface shape is invalid");let t=Z(e.workflowEventType);return t.ok?u({waitExecutionId:e.waitExecutionId,workflowEventType:t.value}):r(t.reason)}function dn(e){return!i(e)||R(e,["completed"])!==void 0||e.completed!==!0?r("complete wait data surface shape is invalid"):u({completed:!0})}function pn(e){return!i(e)||R(e,["waitExecutionId","eventId","payload"])!==void 0||typeof e.waitExecutionId!="string"||e.waitExecutionId.length===0||typeof e.eventId!="string"||e.eventId.length===0||!Object.hasOwn(e,"payload")?r("Wait resolved event surface shape is invalid"):u({waitExecutionId:e.waitExecutionId,eventId:e.eventId,payload:e.payload})}function Z(e){return typeof e!="string"||e.length===0?r("eventType must be a non-empty string"):Te.test(e)?u(e):r("eventType must match ^[A-Za-z0-9_-]{1,100}$")}function R(e,t){return Object.keys(e).find(n=>!t.includes(n))}var Se="/internal/flow-versions",fn="/:flowVersionId/handler-bundles",K="/internal/installations",gn="/:installationId/handler-bundles";function Rn(e,t){return`${Se}/${encodeURIComponent(e)}/handler-bundles?compiledArtifactId=${encodeURIComponent(t)}`}function mn(e){return`${K}/${encodeURIComponent(e.installationId)}/handler-bundles?workspaceId=${encodeURIComponent(e.workspaceId)}&artifactDigest=${encodeURIComponent(e.artifactDigest)}`}var Pe=new Set(["managed_only","managed_plus_unmanaged_sdk"]);function F(e){if(!h(e))return G("runtimeNetwork must be a JSON object");let t=e.networkModel;return typeof t!="string"||!Pe.has(t)?G("runtimeNetwork.networkModel is unknown"):!ee(e.apiHosts)||!ee(e.authHosts)||typeof e.httpsOnly!="boolean"?G("runtimeNetwork host/https fields are invalid"):{ok:!0,value:{networkModel:t,apiHosts:e.apiHosts,authHosts:e.authHosts,httpsOnly:e.httpsOnly}}}function In(e){if(!h(e)||typeof e.flowVersionId!="string"||typeof e.compiledArtifactId!="string"||!Array.isArray(e.bundles))return A("handler bundles data surface shape is invalid");let t=te(e.bundles);return t.ok?{ok:!0,value:{flowVersionId:e.flowVersionId,compiledArtifactId:e.compiledArtifactId,bundles:t.value}}:t}function yn(e){if(!h(e)||typeof e.installationId!="string"||typeof e.artifactDigest!="string"||!Array.isArray(e.bundles))return A("tool handler bundles data surface shape is invalid");let t=te(e.bundles);return t.ok?{ok:!0,value:{installationId:e.installationId,artifactDigest:e.artifactDigest,bundles:t.value}}:t}function te(e){let t=[];for(let n of e){let o=Ae(n);if(!o.ok)return o;t.push(o.value)}return{ok:!0,value:t}}function Ae(e){if(!h(e)||typeof e.toolRef!="string"||e.kind!=="handler"&&e.kind!=="request")return A("handler bundle entry shape is invalid");if(e.kind==="request"){if(e.module!==void 0)return A("a request bundle must not carry a module");let o=F(e.runtimeNetwork);return o.ok?{ok:!0,value:{toolRef:e.toolRef,kind:"request",runtimeNetwork:o.value}}:o}let t=e.module;if(!h(t)||typeof t.entry!="string"||t.entry.length===0||!Ce(t.files))return A("a handler bundle must carry a { entry, files } module");let n=F(e.runtimeNetwork);return n.ok?{ok:!0,value:{toolRef:e.toolRef,kind:"handler",module:{entry:t.entry,files:t.files},runtimeNetwork:n.value}}:n}function A(e){return{ok:!1,kind:"shape",reason:e}}function G(e){return{ok:!1,kind:"runtime_network",reason:e}}function h(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ee(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function Ce(e){return h(e)&&Object.values(e).every(t=>typeof t=="string")}var C="/internal/webhook-trigger-instances",Tn="/:triggerInstanceId/context",Sn="/:triggerInstanceId/handler-bundles",Pn="/:triggerInstanceId/deliveries/:deliveryId",An="/:triggerInstanceId/events",Cn="/:triggerInstanceId/rearm",b=e=>`${C}/${encodeURIComponent(e)}`;function bn(e,t){return`${b(e)}/context?artifactDigest=${encodeURIComponent(t)}`}function Nn(e,t){return`${b(e)}/handler-bundles?artifactDigest=${encodeURIComponent(t)}`}function vn(e,t){return`${b(e)}/deliveries/${encodeURIComponent(t)}`}function On(e){return`${b(e)}/events`}function Dn(e){return`${b(e)}/rearm`}var Un="/:installationId/webhook-protocol-adapter-bundle";function Fn(e){return`${K}/${encodeURIComponent(e.installationId)}/webhook-protocol-adapter-bundle?workspaceId=${encodeURIComponent(e.workspaceId)}&artifactDigest=${encodeURIComponent(e.artifactDigest)}`}var Bn="modules/webhook/protocol-adapter.js";function Hn(e){return`modules/webhook/protocol-adapter-${e}.js`}function Ln(e){let t=i(e)?x(e.stateScope):r("webhook watcher context state scope is invalid");return!i(e)||typeof e.artifactDigest!="string"||typeof e.triggerRef!="string"||typeof e.triggerName!="string"||typeof e.integrationRef!="string"||!i(e.inputs)||e.connection!==null&&!be(e.connection)||!Ne(e.runtime)||!t.ok||t.value.kind!=="webhook-trigger"?r("webhook watcher context surface shape is invalid"):u(e)}function be(e){return i(e)&&typeof e.connectionId=="string"&&typeof e.connectionRef=="string"&&typeof e.integrationRef=="string"&&typeof e.authProfileRef=="string"&&typeof e.authType=="string"}function Ne(e){if(!i(e)||e.type!=="webhook"||typeof e.trigger_ref!="string")return!1;let t=e.webhook;return i(t)&&typeof t.event_handler_module=="string"&&typeof t.enable_handler_module=="string"&&typeof t.disable_handler_module=="string"}function ve(e){if(!i(e)||typeof e.deliveryId!="string"||typeof e.receivedAt!="string"||!i(e.request))return r("webhook delivery surface shape is invalid");let t=e.request;return t.method!=="POST"||!i(t.headers)||typeof t.rawBody!="string"?r("webhook delivery request shape is invalid"):u(e)}function q(e){if(!i(e)||typeof e.token!="string"||typeof e.expiresAt!="string")return r("trigger file runtime dispatch shape is invalid");let t=$(e.limits);return t.ok?u({token:e.token,expiresAt:e.expiresAt,limits:t.value}):r(t.reason)}function $n(e){if(!i(e))return r("webhook delivery dispatch data is invalid");let t=ve(e.delivery);if(!t.ok)return r(t.reason);let n=e.fileRuntime;if(n===null)return u({delivery:t.value,fileRuntime:null});let o=q(n);return o.ok?u({delivery:t.value,fileRuntime:o.value}):r(o.reason)}function Wn(e){if(!i(e)||typeof e.triggerRef!="string"||typeof e.artifactDigest!="string"||!Array.isArray(e.modules)||!e.modules.every(Oe))return{ok:!1,kind:"shape",reason:"trigger handler bundles data surface shape is invalid"};let t=F(e.runtimeNetwork);return t.ok?{ok:!0,value:{triggerRef:e.triggerRef,artifactDigest:e.artifactDigest,modules:e.modules,runtimeNetwork:t.value}}:t}function Oe(e){return i(e)&&typeof e.specifier=="string"&&e.specifier.length>0&&typeof e.source=="string"}function Gn(e){if(!i(e))return r("publish events body must be a JSON object");let t=M(e,["deliveryId","events"]);if(t!==void 0)return r(`publish events does not accept the "${t}" field`);let n=e.deliveryId;if(typeof n!="string"||n.length===0)return r("deliveryId must be a non-empty string");let o=e.events;if(!Array.isArray(o))return r("events must be an array");let s=[];for(let a of o){let c=De(a);if(!c.ok)return c;s.push(c.value)}return u({deliveryId:n,events:s})}function De(e){if(!i(e))return r("each event must be a JSON object");let t=M(e,["eventId","occurredAt","dedupeKey","payload"]);if(t!==void 0)return r(`event does not accept the "${t}" field`);let n=e.eventId;if(typeof n!="string"||n.length===0)return r("eventId must be a non-empty string");let o=e.occurredAt;if(typeof o!="string"||o.length===0)return r("occurredAt must be a non-empty string");if(!i(e.payload))return r("event payload must be a JSON object");let s={eventId:n,occurredAt:o,payload:e.payload};if(e.dedupeKey!==void 0){if(typeof e.dedupeKey!="string"||e.dedupeKey.length===0)return r("dedupeKey must be a non-empty string");s.dedupeKey=e.dedupeKey}return u(s)}function Kn(e){if(!i(e))return r("rearm body must be a JSON object");let t=M(e,["expectedWatcherInstanceId"]);if(t!==void 0)return r(`rearm does not accept the "${t}" field`);let n=e.expectedWatcherInstanceId;return typeof n!="string"||n.length===0?r("expectedWatcherInstanceId must be a non-empty string"):u({expectedWatcherInstanceId:n})}function M(e,t){return Object.keys(e).find(n=>!t.includes(n))}var N="/internal/polling-trigger-instances",Xn="/:pollingInstanceId/context",Jn="/:pollingInstanceId/handler-bundles",Yn="/:pollingInstanceId/ticks/:tickId/events",V=e=>`${N}/${encodeURIComponent(e)}`;function Qn(e,t,n){return`${V(e)}/context?artifactDigest=${encodeURIComponent(t)}&tickId=${encodeURIComponent(n)}`}function zn(e,t){return`${V(e)}/handler-bundles?artifactDigest=${encodeURIComponent(t)}`}function Zn(e,t){return`${V(e)}/ticks/${encodeURIComponent(t)}/events`}function Ue(e){let t=i(e)?x(e.stateScope):r("polling trigger context state scope is invalid");return!i(e)||typeof e.artifactDigest!="string"||typeof e.triggerRef!="string"||typeof e.triggerName!="string"||typeof e.integrationRef!="string"||!i(e.inputs)||e.connection!==null&&!Fe(e.connection)||!Be(e.runtime)||!t.ok||t.value.kind!=="polling-trigger"||!Le(e.tick)||!$e(e.limits)?r("polling trigger context surface shape is invalid"):u(e)}function er(e){if(!i(e))return r("polling trigger dispatch data is invalid");let t=Ue(e.context);if(!t.ok)return r(t.reason);let n=e.fileRuntime;if(n===null)return u({context:t.value,fileRuntime:null});let o=q(n);return o.ok?u({context:t.value,fileRuntime:o.value}):r(o.reason)}function Fe(e){return i(e)&&typeof e.connectionId=="string"&&typeof e.connectionRef=="string"&&typeof e.integrationRef=="string"&&typeof e.authProfileRef=="string"&&typeof e.authType=="string"}function Be(e){if(!i(e)||e.type!=="polling"||typeof e.trigger_id!="string"||typeof e.trigger_ref!="string"||!He(e.file_outputs))return!1;let t=e.polling;if(!i(t)||typeof t.run_handler_module!="string")return!1;let n=t.schedule;if(!i(n)||n.type!=="interval"||typeof n.every_seconds!="number")return!1;let o=t.dedup;return i(o)&&(o.strategy==="cursor"||o.strategy==="hash"||o.strategy==="id_field")}function He(e){return e===void 0?!0:Array.isArray(e)&&e.length>0&&e.every(t=>i(t)&&typeof t.field=="string"&&t.field.length>0)}function Le(e){return i(e)&&typeof e.tickId=="string"&&typeof e.scheduledAt=="string"&&typeof e.attempt=="number"}function $e(e){return i(e)&&typeof e.maxEventsPerTick=="number"}function tr(e){if(!i(e))return r("publish body must be a JSON object");let t=ne(e,["events","nextCursor"]);if(t!==void 0)return r(`publish does not accept the "${t}" field`);let n=e.events;if(!Array.isArray(n))return r("events must be an array");let o=[];for(let a of n){let c=We(a);if(!c.ok)return c;o.push(c.value)}let s={events:o};if("nextCursor"in e){let a=e.nextCursor;if(a!==null&&typeof a!="string")return r("nextCursor must be a string, null, or omitted");s.nextCursor=a}return u(s)}function We(e){if(!i(e))return r("each event must be a JSON object");let t=ne(e,["eventId","occurredAt","dedupeKey","payload"]);if(t!==void 0)return r(`event does not accept the "${t}" field`);if(typeof e.eventId!="string"||e.eventId.length===0)return r("event eventId must be a non-empty string");if(!i(e.payload))return r("event payload must be a JSON object");let n={eventId:e.eventId,payload:e.payload};if(e.occurredAt!==void 0){if(typeof e.occurredAt!="string"||e.occurredAt.length===0)return r("event occurredAt must be a non-empty string");n.occurredAt=e.occurredAt}if(e.dedupeKey!==void 0){if(typeof e.dedupeKey!="string"||e.dedupeKey.length===0)return r("event dedupeKey must be a non-empty string");n.dedupeKey=e.dedupeKey}return u(n)}function nr(e){return!i(e)||typeof e.tickId!="string"||typeof e.cursorUpdated!="boolean"||!Array.isArray(e.results)||!e.results.every(Ge)?r("publish polling tick events data surface shape is invalid"):u(e)}function Ge(e){return i(e)&&typeof e.eventId=="string"&&typeof e.dedupeKey=="string"&&typeof e.duplicate=="boolean"&&(e.flowRunId===null||typeof e.flowRunId=="string")}function ne(e,t){return Object.keys(e).find(n=>!t.includes(n))}var re="/internal/egress-grants",j="/internal/tool-invocations",X="/internal/discovery-invocations",ar="/:flowRunId/egress-grant",cr="/:invocationId/egress-grant",dr="/:discoveryInvocationId/egress-grant",pr="/:pollingInstanceId/egress-grant",lr="/:triggerInstanceId/egress-grant",fr="/:grantId/consume",gr="/:grantId/audit",Rr=e=>`${g}/${encodeURIComponent(e)}/egress-grant`,mr=e=>`${j}/${encodeURIComponent(e)}/egress-grant`,Ir=e=>`${X}/${encodeURIComponent(e)}/egress-grant`,yr=e=>`${N}/${encodeURIComponent(e)}/egress-grant`,kr=e=>`${C}/${encodeURIComponent(e)}/egress-grant`,Er=e=>`${re}/${encodeURIComponent(e)}/consume`,_r=e=>`${re}/${encodeURIComponent(e)}/audit`,Ke=["flow_action","single_tool","discovery","polling_trigger","webhook_trigger"],qe=/^[A-Za-z0-9][A-Za-z0-9:_+/=.-]{15,1023}$/;function w(e){return typeof e=="string"&&qe.test(e)}function Me(e){if(!i(e)||e.body_type!=="multipart")return!1;let t=e.body;if(!i(t))return!1;let n=t.parts;return Array.isArray(n)?n.some(o=>i(o)?o.kind==="file"&&typeof o.file_id=="string"&&o.file_id.length>0:!1):!1}function p(e){return{ok:!1,kind:"shape",reason:e}}function T(){return{ok:!1,kind:"request_digest",reason:"request digest is missing or malformed"}}function v(e,t){if(!i(e))return{ok:!1,reason:"grant request body must be a JSON object"};for(let n of Object.keys(e))if(!t.includes(n))return{ok:!1,reason:`grant request does not accept the "${n}" field`};return{ok:!0,record:e}}function O(e){if(!i(e))return"request must be a JSON object"}function xr(e){let t=v(e,["nodeId","request","requestDigest"]);if(!t.ok)return p(t.reason);let n=t.record.nodeId;if(typeof n!="string"||n.length===0)return p("nodeId is required");let o=O(t.record.request);if(o!==void 0)return p(o);let s=t.record.requestDigest;return w(s)?{ok:!0,value:{nodeId:n,requestDigest:s,requestHasMultipartFiles:Me(t.record.request)}}:T()}function hr(e){let t=v(e,["request","requestDigest"]);if(!t.ok)return p(t.reason);let n=O(t.record.request);if(n!==void 0)return p(n);let o=t.record.requestDigest;return w(o)?{ok:!0,value:{requestDigest:o}}:T()}function wr(e){let t=v(e,["request","requestDigest"]);if(!t.ok)return p(t.reason);let n=O(t.record.request);if(n!==void 0)return p(n);let o=t.record.requestDigest;return w(o)?{ok:!0,value:{requestDigest:o}}:T()}function Tr(e){let t=v(e,["tickId","request","requestDigest"]);if(!t.ok)return p(t.reason);let n=t.record.tickId;if(typeof n!="string"||n.length===0)return p("tickId is required");let o=O(t.record.request);if(o!==void 0)return p(o);let s=t.record.requestDigest;return w(s)?{ok:!0,value:{tickId:n,requestDigest:s}}:T()}function Sr(e){let t=v(e,["phase","lifecycle","deliveryId","request","requestDigest"]);if(!t.ok)return p(t.reason);let n=t.record.phase;if(n!=="lifecycle"&&n!=="handler")return p('phase must be "lifecycle" or "handler"');let o=t.record.lifecycle,s;if(o!==void 0){if(o!=="enable"&&o!=="disable"&&o!=="renew")return p('lifecycle must be "enable", "disable", or "renew"');s=o}if(n==="lifecycle"&&s===void 0)return p("lifecycle is required for the lifecycle phase");let a=t.record.deliveryId,c;if(a!==void 0){if(typeof a!="string"||a.length===0)return p("deliveryId must be a non-empty string");c=a}if(n==="handler"&&c===void 0)return p("deliveryId is required for the handler phase");let d=O(t.record.request);if(d!==void 0)return p(d);let f=t.record.requestDigest;return w(f)?{ok:!0,value:{phase:n,...s!==void 0?{lifecycle:s}:{},...c!==void 0?{deliveryId:c}:{},requestDigest:f}}:T()}function oe(e){return Ke.includes(e)?e:void 0}var Ve=["scopeKind","scopeId","requestDigest"];function Pr(e){if(!i(e))return p("consume body must be a JSON object");for(let s of Object.keys(e))if(!Ve.includes(s))return p(`consume does not accept the "${s}" field`);let t=oe(e.scopeKind);if(t===void 0)return p("scopeKind is invalid");let n=e.scopeId;if(typeof n!="string"||n.length===0)return p("scopeId is required");let o=e.requestDigest;return w(o)?{ok:!0,value:{scopeKind:t,scopeId:n,requestDigest:o}}:T()}var je=["scopeKind","scopeId","providerHost","status","durationMs","requestBytes","responseBytes","errorCode"];function B(e,t){return typeof e!="number"||!Number.isInteger(e)||e<0?{ok:!1,reason:`${t} must be a non-negative integer`}:{ok:!0,value:e}}function Ar(e){if(!i(e))return p("audit body must be a JSON object");for(let l of Object.keys(e))if(!je.includes(l))return p(`audit does not accept the "${l}" field`);let t=oe(e.scopeKind);if(t===void 0)return p("scopeKind is invalid");let n=e.scopeId;if(typeof n!="string"||n.length===0)return p("scopeId is required");let o=e.providerHost;if(typeof o!="string"||o.length===0)return p("providerHost is required");let s=B(e.durationMs,"durationMs");if(!s.ok)return p(s.reason);let a;if(e.status!==void 0){let l=B(e.status,"status");if(!l.ok)return p(l.reason);a=l.value}let c;if(e.requestBytes!==void 0){let l=B(e.requestBytes,"requestBytes");if(!l.ok)return p(l.reason);c=l.value}let d;if(e.responseBytes!==void 0){let l=B(e.responseBytes,"responseBytes");if(!l.ok)return p(l.reason);d=l.value}let f;if(e.errorCode!==void 0){let l=e.errorCode;if(typeof l!="string"||l.length===0)return p("errorCode must be a non-empty string");f=l}return{ok:!0,value:{scopeKind:t,scopeId:n,providerHost:o,...a!==void 0?{status:a}:{},durationMs:s.value,...c!==void 0?{requestBytes:c}:{},...d!==void 0?{responseBytes:d}:{},...f!==void 0?{errorCode:f}:{}}}}function Cr(e){return!i(e)||!i(e.grant)?r("egress grant envelope must carry a grant object"):u(e.grant)}function br(e){return!i(e)||e.consumed!==!0?r("egress grant consume data must carry consumed:true"):u({consumed:!0})}var Br="/:flowRunId/runtime-credential",Hr="/:invocationId/runtime-credential",Lr="/:discoveryInvocationId/runtime-credential",$r="/:pollingInstanceId/runtime-credential",Wr="/:triggerInstanceId/runtime-credential",Gr=e=>`${g}/${encodeURIComponent(e)}/runtime-credential`,Kr=e=>`${j}/${encodeURIComponent(e)}/runtime-credential`,qr=e=>`${X}/${encodeURIComponent(e)}/runtime-credential`,Mr=e=>`${N}/${encodeURIComponent(e)}/runtime-credential`,Vr=e=>`${C}/${encodeURIComponent(e)}/runtime-credential`,jr=["flow_action","tool_invoke","discovery","polling_trigger","webhook_trigger"];function D(e,t){if(!i(e))return{ok:!1,reason:"runtime credential request body must be a JSON object"};for(let n of Object.keys(e))if(!t.includes(n))return{ok:!1,reason:`runtime credential request does not accept the "${n}" field`};return{ok:!0,record:e}}function Xr(e){let t=D(e,["nodeId"]);if(!t.ok)return r(t.reason);let n=t.record.nodeId;return typeof n!="string"||n.length===0?r("nodeId is required"):u({nodeId:n})}function Jr(e){let t=D(e??{},[]);return t.ok?u(null):r(t.reason)}function Yr(e){let t=D(e??{},[]);return t.ok?u(null):r(t.reason)}function Qr(e){let t=D(e,["tickId"]);if(!t.ok)return r(t.reason);let n=t.record.tickId;return typeof n!="string"||n.length===0?r("tickId is required"):u({tickId:n})}function zr(e){let t=D(e,["executionKind","deliveryId","lifecycleOperation"]);if(!t.ok)return r(t.reason);let n=t.record.executionKind;if(n!=="event_handler"&&n!=="lifecycle")return r('executionKind must be "event_handler" or "lifecycle"');let o,s=t.record.deliveryId;if(s!==void 0){if(typeof s!="string"||s.length===0)return r("deliveryId must be a non-empty string");o=s}let a,c=t.record.lifecycleOperation;if(c!==void 0){if(c!=="enable"&&c!=="disable"&&c!=="renew")return r('lifecycleOperation must be "enable", "disable", or "renew"');a=c}return n==="lifecycle"&&a===void 0?r("lifecycleOperation is required for the lifecycle execution kind"):u({executionKind:n,...o!==void 0?{deliveryId:o}:{},...a!==void 0?{lifecycleOperation:a}:{}})}function Zr(e){return!i(e)||typeof e.sessionId!="string"||typeof e.connectionId!="string"||typeof e.authProfileRef!="string"||typeof e.authType!="string"||!i(e.credential)?r("runtime credential session must carry sessionId, connectionId, auth profile facts and a credential object"):u(e.credential)}function H(e){return!i(e)||typeof e.file_id!="string"||typeof e.name!="string"||typeof e.size_bytes!="number"||typeof e.created_at!="string"||typeof e.expires_at!="string"||e.mime_type!==void 0&&typeof e.mime_type!="string"||e.sha256!==void 0&&typeof e.sha256!="string"||e.source!==void 0&&typeof e.source!="string"?r("file ref data does not match the AIS file-ref shape"):u(e)}function J(e){return!i(e)||e.method!=="GET"&&e.method!=="PUT"||typeof e.url!="string"||typeof e.expires_at!="string"||!Ye(e.headers)?r("presigned file URL data is invalid"):u(e)}function Xe(e){if(!i(e))return r("file upload session data is invalid");let t=H(e.file);if(!t.ok)return r(t.reason);let n=J(e.upload);return n.ok?u({file:t.value,upload:n.value}):r(n.reason)}function Je(e){if(!i(e))return r("file metadata data is invalid");let t=H(e.file);return t.ok?u({file:t.value}):r(t.reason)}function Ye(e){return i(e)?Object.values(e).every(t=>typeof t=="string"):!1}var S="/internal/files",io="/upload-session",so="/:fileId/complete",uo="/:fileId/access",ao="/:fileId/stat",co="/:fileId/content",po=()=>S,lo=()=>`${S}/upload-session`,fo=e=>`${S}/${encodeURIComponent(e)}/complete`,go=(e,t)=>`${S}/${encodeURIComponent(e)}/access?intent=${encodeURIComponent(t)}`,ie=e=>`?scope_kind=${encodeURIComponent(e.scopeKind)}&scope_id=${encodeURIComponent(e.scopeId)}`,Ro=(e,t)=>`${S}/${encodeURIComponent(e)}/stat${ie(t)}`,mo=(e,t)=>`${S}/${encodeURIComponent(e)}/content${ie(t)}`;function Io(e){if(!i(e))return r("internal file access data is invalid");if(e.intent==="runtime_read"||e.intent==="provider_multipart"){let t=H(e.file);if(!t.ok)return r(t.reason);let n=J(e.access);return n.ok?u({file:t.value,access:n.value,intent:e.intent}):r(n.reason)}return r("internal file access intent is invalid")}var xo="/:flowRunId/human-inputs",ho="/:flowRunId/human-inputs/:requestId",wo="/:flowRunId/human-inputs/:requestId/expire",To="/:flowRunId/human-inputs/:requestId/acknowledge",Qe=e=>`${g}/${encodeURIComponent(e)}/human-inputs`,se=(e,t)=>`${Qe(e)}/${encodeURIComponent(t)}`,So=(e,t)=>`${se(e,t)}/expire`,Po=(e,t)=>`${se(e,t)}/acknowledge`,ze="human_input_resolved";function Ao(e){return`${ze}_${e}`}function Co(e){return!i(e)||Object.keys(e).length!==4||!Object.hasOwn(e,"requestId")||!Object.hasOwn(e,"flowRunId")||!Object.hasOwn(e,"nodeId")||!Object.hasOwn(e,"status")||typeof e.requestId!="string"||e.requestId.length===0||typeof e.flowRunId!="string"||e.flowRunId.length===0||typeof e.nodeId!="string"||e.nodeId.length===0||e.status!=="submitted"&&e.status!=="expired"?r("Human Input resolved event shape is invalid"):u({requestId:e.requestId,flowRunId:e.flowRunId,nodeId:e.nodeId,status:e.status})}function m(e){return{ok:!1,reason:e}}function _(e,t){return i(e)?{ok:!0,value:e}:m(`${t} must be an object`)}function P(e,t){return typeof e!="string"||e.length===0?m(`${t} must be a non-empty string`):{ok:!0,value:e}}var Ze=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?(?:Z|[+-]\d{2}:\d{2})$/;function et(e,t){return typeof e!="string"||!Ze.test(e)||Number.isNaN(Date.parse(e))?m(`${t} must be an ISO-8601 timestamp`):{ok:!0,value:e}}function tt(e){let t=_(e,"renderedPrompt");if(!t.ok)return t;let n=P(t.value.title,"renderedPrompt.title");if(!n.ok)return n;let o={title:n.value};if(t.value.body!==void 0){if(typeof t.value.body!="string")return m("renderedPrompt.body must be a string");o.body=t.value.body}if(t.value.format!==void 0){if(t.value.format!=="plain"&&t.value.format!=="markdown")return m("renderedPrompt.format is invalid");o.format=t.value.format}return{ok:!0,value:o}}function nt(e){let t=_(e,"input");if(!t.ok)return t;let n=t.value.kind;if(n==="choice"){if(!Array.isArray(t.value.choices))return m("input.choices must be an array")}else if(n!=="text")if(n==="form"){if(!Array.isArray(t.value.fields))return m("input.fields must be an array")}else return m("input.kind is invalid");return{ok:!0,value:t.value}}function rt(e){if(e==null)return{ok:!0,value:void 0};let t=_(e,"partiallyRenderedDelivery");if(!t.ok)return t;let n=t.value.actions;if(n===void 0)return{ok:!0,value:{}};if(!Array.isArray(n))return m("partiallyRenderedDelivery.actions must be an array");let o=[];for(let s of n){let a=_(s,"delivery action");if(!a.ok)return a;let c=P(a.value.id,"delivery action id");if(!c.ok)return c;let d=ue(a.value.inputs,`delivery action '${c.value}' inputs`);if(!d.ok)return d;o.push({id:c.value,inputs:d.value})}return{ok:!0,value:{actions:o}}}function ue(e,t){let n=_(e,t);if(!n.ok)return n;let o={};for(let[s,a]of Object.entries(n.value)){let c=ae(a,`${t}.${s}`);if(!c.ok)return c;o[s]=c.value}return{ok:!0,value:o}}function ae(e,t){let n=_(e,t);if(!n.ok)return n;switch(n.value.kind){case"literal":return{ok:!0,value:{kind:"literal",value:n.value.value}};case"human_input_ref":{let s=P(n.value.path,`${t}.path`);return s.ok?{ok:!0,value:{kind:"human_input_ref",path:s.value}}:s}case"array":{if(!Array.isArray(n.value.items))return m(`${t}.items must be an array`);let s=[];for(let[a,c]of n.value.items.entries()){let d=ae(c,`${t}[${a}]`);if(!d.ok)return d;s.push(d.value)}return{ok:!0,value:{kind:"array",items:s}}}case"object":{let s=ue(n.value.entries,`${t}.entries`);return s.ok?{ok:!0,value:{kind:"object",entries:s.value}}:s}case"template":{if(!Array.isArray(n.value.parts))return m(`${t}.parts must be an array`);let s=[];for(let[a,c]of n.value.parts.entries()){let d=ot(c,`${t}.parts[${a}]`);if(!d.ok)return d;s.push(d.value)}return{ok:!0,value:{kind:"template",parts:s}}}default:return m(`${t}.kind is invalid`)}}function ot(e,t){let n=_(e,t);if(!n.ok)return n;let o=n.value.kind;if(o==="literal")return typeof n.value.value!="string"?m(`${t}.value must be a string`):{ok:!0,value:{kind:"literal",value:n.value.value}};if(o==="human_input_ref"){let s=P(n.value.path,`${t}.path`);return s.ok?{ok:!0,value:{kind:"human_input_ref",path:s.value}}:s}return m(`${t}.kind is invalid`)}function bo(e){let t=_(e,"request body");if(!t.ok)return r(t.reason);let n=Object.keys(t.value).find(ce=>!["executionScope","nodeId","renderedPrompt","input","partiallyRenderedDelivery","timeout","expiresAt"].includes(ce));if(n!==void 0)return r(`human input body does not accept the "${n}" field`);let o=k(t.value.executionScope);if(!o.ok)return r(o.reason);let s=P(t.value.nodeId,"nodeId");if(!s.ok)return r(s.reason);let a=tt(t.value.renderedPrompt);if(!a.ok)return r(a.reason);let c=nt(t.value.input);if(!c.ok)return r(c.reason);let d=P(t.value.timeout,"timeout");if(!d.ok)return r(d.reason);let f=et(t.value.expiresAt,"expiresAt");if(!f.ok)return r(f.reason);let l=rt(t.value.partiallyRenderedDelivery);return l.ok?u({executionScope:o.value,nodeId:s.value,renderedPrompt:a.value,input:c.value,timeout:d.value,expiresAt:f.value,...l.value!==void 0?{partiallyRenderedDelivery:l.value}:{}}):r(l.reason)}function it(e){return!i(e)||typeof e.id!="string"||e.id.length===0||typeof e.nodeId!="string"||typeof e.status!="string"||!(e.output===null||i(e.output))?r("human input request view must carry id, nodeId, status and output"):u(e)}function No(e){if(!i(e)||typeof e.created!="boolean")return r("human input create data must carry created:boolean");let t=it(e.request);return t.ok?u({created:e.created,request:t.value}):t}function vo(e){return!i(e)||e.acknowledged!==!0?r("human input acknowledge data must carry acknowledged:true"):u({acknowledged:!0})}var Do="ablehi-wfp-user-runtime-manifest/v1",Uo="unknown";function Fo(e){return e.endsWith(".js")?`${e.slice(0,-3)}.manifest.json`:`${e}.manifest.json`}var Ho="/internal/deployment-handshake",st=["start","terminate","send-event","start-webhook-watcher","run-polling-tick","invoke-tool","invoke-discovery","invoke-trigger-handler","invoke-webhook-protocol-adapter","deployment-handshake"],Lo=st,$o="HANDSHAKE_REQUEST_INVALID",Wo="HANDSHAKE_SECRET_UNCONFIGURED",Go="HANDSHAKE_SECRET_MISMATCH",Ko="HANDSHAKE_CONTRACT_VERSION_MISMATCH",qo="HANDSHAKE_DISPATCH_NAMESPACE_MISMATCH",Mo="HANDSHAKE_CAPABILITY_MISSING";function Vo(e){return[e.nonce,e.timestamp,e.contractVersion,e.dispatchNamespace].map(n=>`${n.length}:${n}`).join(".")}function jo(e){return["response",e.nonce,e.contractVersion,e.dispatchNamespace,...e.capabilities].map(n=>`${n.length}:${n}`).join(".")}export{Xt as COMPLETE_EVENT_WAIT_ROUTE_SUBPATH,dt as CONTEXT_STATE_CLEANUP_ROUTE_PATH,st as DEPLOYMENT_HANDSHAKE_DISPATCHER_CAPABILITIES,Lo as DEPLOYMENT_HANDSHAKE_REQUIRED_CAPABILITIES,Ho as DEPLOYMENT_HANDSHAKE_ROUTE,dr as DISCOVERY_INVOCATION_EGRESS_GRANT_ROUTE_SUBPATH,Lr as DISCOVERY_INVOCATION_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,gr as EGRESS_GRANT_AUDIT_ROUTE_SUBPATH,fr as EGRESS_GRANT_CONSUME_ROUTE_SUBPATH,Ke as EGRESS_GRANT_SCOPE_KINDS,Ft as EXECUTION_CONTEXT_ROUTE_SUBPATH,xt as EXECUTION_LEASE_INVALID,mt as EXECUTION_LEASE_ROUTE_SUBPATH,ht as EXECUTION_LEASE_SUPERSEDED,uo as FILE_ACCESS_ROUTE_SUBPATH,so as FILE_COMPLETE_ROUTE_SUBPATH,co as FILE_CONTENT_ROUTE_SUBPATH,ao as FILE_STAT_ROUTE_SUBPATH,io as FILE_UPLOAD_SESSION_ROUTE_SUBPATH,ar as FLOW_RUN_EGRESS_GRANT_ROUTE_SUBPATH,Vt as FLOW_RUN_EXECUTION_EVENTS_ROUTE_SUBPATH,xe as FLOW_RUN_EXECUTION_EVENT_TYPES,Mt as FLOW_RUN_RESULT_ROUTE_SUBPATH,Br as FLOW_RUN_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,fn as HANDLER_BUNDLES_ROUTE_SUBPATH,Mo as HANDSHAKE_CAPABILITY_MISSING,Ko as HANDSHAKE_CONTRACT_VERSION_MISMATCH,qo as HANDSHAKE_DISPATCH_NAMESPACE_MISMATCH,$o as HANDSHAKE_REQUEST_INVALID,Go as HANDSHAKE_SECRET_MISMATCH,Wo as HANDSHAKE_SECRET_UNCONFIGURED,xo as HUMAN_INPUTS_ROUTE_SUBPATH,To as HUMAN_INPUT_ACKNOWLEDGE_ROUTE_SUBPATH,Tt as HUMAN_INPUT_CANCELLED_BY_RESET,wo as HUMAN_INPUT_EXPIRE_ROUTE_SUBPATH,ho as HUMAN_INPUT_REQUEST_ROUTE_SUBPATH,ze as HUMAN_INPUT_RESOLVED_EVENT_PREFIX,X as INTERNAL_DISCOVERY_INVOCATIONS_ROUTE_PREFIX,re as INTERNAL_EGRESS_GRANTS_ROUTE_PREFIX,S as INTERNAL_FILES_ROUTE_PREFIX,g as INTERNAL_FLOW_RUNS_ROUTE_PREFIX,Se as INTERNAL_FLOW_VERSIONS_ROUTE_PREFIX,K as INTERNAL_INSTALLATIONS_ROUTE_PREFIX,N as INTERNAL_POLLING_TRIGGER_INSTANCES_ROUTE_PREFIX,j as INTERNAL_TOOL_INVOCATIONS_ROUTE_PREFIX,C as INTERNAL_WEBHOOK_TRIGGER_INSTANCES_ROUTE_PREFIX,Xn as POLLING_TRIGGER_CONTEXT_ROUTE_SUBPATH,pr as POLLING_TRIGGER_EGRESS_GRANT_ROUTE_SUBPATH,Jn as POLLING_TRIGGER_HANDLER_BUNDLES_ROUTE_SUBPATH,$r as POLLING_TRIGGER_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,Yn as POLLING_TRIGGER_TICK_EVENTS_ROUTE_SUBPATH,jt as REGISTER_EVENT_WAIT_ROUTE_SUBPATH,jr as RUNTIME_CREDENTIAL_SESSION_SCOPE_KINDS,_t as RUN_DISPATCH_UNAVAILABLE,de as SERVER_EXECUTION_CONTRACT_VERSION,qt as STEP_RESULT_ROUTE_SUBPATH,gn as TOOL_HANDLER_BUNDLES_ROUTE_SUBPATH,cr as TOOL_INVOCATION_EGRESS_GRANT_ROUTE_SUBPATH,Hr as TOOL_INVOCATION_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,wt as WAIT_EXECUTION_SUPERSEDED,Un as WEBHOOK_PROTOCOL_ADAPTER_BUNDLE_ROUTE_SUBPATH,Bn as WEBHOOK_PROTOCOL_ADAPTER_MODULE,Tn as WEBHOOK_TRIGGER_CONTEXT_ROUTE_SUBPATH,Pn as WEBHOOK_TRIGGER_DELIVERY_ROUTE_SUBPATH,lr as WEBHOOK_TRIGGER_EGRESS_GRANT_ROUTE_SUBPATH,An as WEBHOOK_TRIGGER_EVENTS_ROUTE_SUBPATH,Sn as WEBHOOK_TRIGGER_HANDLER_BUNDLES_ROUTE_SUBPATH,Cn as WEBHOOK_TRIGGER_REARM_ROUTE_SUBPATH,Wr as WEBHOOK_TRIGGER_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,Do as WFP_USER_RUNTIME_MANIFEST_FORMAT_VERSION,Uo as WFP_USER_RUNTIME_UNKNOWN_SOURCE_REVISION,kt as WORKFLOW_RESTART_INSTANCE_UNAVAILABLE,Et as WORKFLOW_RESTART_REJECTED,yt as WORKFLOW_RESTART_REQUEST_INVALID,It as WORKFLOW_RESTART_ROUTE,St as acquireExecutionLeasePath,Zt as completeEventWaitPath,Vo as deploymentHandshakeProbePayload,jo as deploymentHandshakeResponseProofPayload,Ir as discoveryInvocationEgressGrantPath,qr as discoveryInvocationRuntimeCredentialPath,_r as egressGrantAuditPath,Er as egressGrantConsumePath,Bt as executionContextPath,Rr as flowRunEgressGrantPath,Qt as flowRunExecutionEventsPath,Yt as flowRunResultPath,Gr as flowRunRuntimeCredentialPath,Hn as flowScriptProtocolAdapterModuleName,Rn as handlerBundlesPath,Po as humanInputAcknowledgePath,So as humanInputExpirePath,se as humanInputRequestPath,Ao as humanInputResolvedEventType,Qe as humanInputsPath,go as internalFileAccessPath,fo as internalFileCompletePath,mo as internalFileContentPath,Ro as internalFileStatPath,lo as internalFileUploadSessionPath,po as internalFilesPath,w as isValidRequestDigest,At as parseAcquireExecutionLeaseData,Pt as parseAcquireExecutionLeaseRequest,an as parseCompleteFlowRunWaitBody,dn as parseCompleteFlowRunWaitData,pt as parseContextStateCleanupRequestBody,lt as parseContextStateCleanupResponseData,x as parseContextStateScope,bo as parseCreateHumanInputBody,wr as parseDiscoveryGrantBody,Yr as parseDiscoveryRuntimeCredentialBody,Ar as parseEgressGrantAuditBody,Pr as parseEgressGrantConsumeBody,br as parseEgressGrantConsumeData,Cr as parseEgressGrantData,Q as parseExecutionAnchor,Ht as parseExecutionContextData,Re as parseExecutionLease,k as parseExecutionWriteScope,Je as parseFileMetadataData,H as parseFileRefData,$ as parseFileRuntimeLimits,Xe as parseFileUploadSessionData,xr as parseFlowActionGrantBody,Y as parseFlowExecutionScope,sn as parseFlowRunExecutionEventBody,on as parseFlowRunExecutionEventData,nn as parseFlowRunResultBody,rn as parseFlowRunResultData,Xr as parseFlowRuntimeCredentialBody,pn as parseFlowWaitResolvedEvent,Ae as parseHandlerBundle,In as parseHandlerBundlesData,vo as parseHumanInputAcknowledgeData,No as parseHumanInputCreateData,it as parseHumanInputRequestViewData,Co as parseHumanInputResolvedEvent,Io as parseInternalFileAccessData,tr as parsePollingPublishBody,Qr as parsePollingRuntimeCredentialBody,Ue as parsePollingTriggerContext,er as parsePollingTriggerDispatchData,Tr as parsePollingTriggerGrantBody,nr as parsePublishPollingTickEventsData,un as parseRegisterFlowRunWaitBody,cn as parseRegisterFlowRunWaitData,Zr as parseRuntimeCredentialSessionCredential,F as parseRuntimeNetwork,hr as parseSingleToolGrantBody,Jr as parseSingleToolRuntimeCredentialBody,en as parseStepRecordBody,tn as parseStepRecordData,yn as parseToolHandlerBundlesData,q as parseTriggerFileRuntimeDispatch,Wn as parseTriggerHandlerBundlesData,ve as parseWebhookDelivery,$n as parseWebhookDeliveryDispatchData,Gn as parseWebhookPublishEventsBody,Kn as parseWebhookRearmBody,zr as parseWebhookRuntimeCredentialBody,Sr as parseWebhookTriggerGrantBody,Ln as parseWebhookWatcherContext,Ct as parseWorkflowDispatchRestartRequest,bt as parseWorkflowDispatchRestartResponse,Qn as pollingTriggerContextPath,yr as pollingTriggerEgressGrantPath,zn as pollingTriggerHandlerBundlesPath,Mr as pollingTriggerRuntimeCredentialPath,Zn as pollingTriggerTickEventsPath,zt as registerEventWaitPath,Me as requestHasMultipartFileParts,Jt as stepResultPath,mn as toolHandlerBundlesPath,mr as toolInvocationEgressGrantPath,Kr as toolInvocationRuntimeCredentialPath,Fn as webhookProtocolAdapterBundlePath,bn as webhookTriggerContextPath,vn as webhookTriggerDeliveryPath,kr as webhookTriggerEgressGrantPath,On as webhookTriggerEventsPath,Nn as webhookTriggerHandlerBundlesPath,Dn as webhookTriggerRearmPath,Vr as webhookTriggerRuntimeCredentialPath,Fo as wfpUserRuntimeManifestPath};
|
|
1
|
+
var Ie="0.4.0";function u(e){return{ok:!0,value:e}}function r(e){return{ok:!1,reason:e}}function s(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var wt="/cleanup-state-scopes";function x(e){if(!s(e)||typeof e.kind!="string")return r("context state scope surface shape is invalid");switch(e.kind){case"webhook-trigger":return ye(e);case"polling-trigger":return Ee(e);case"flow-action":return ke(e);default:return r("context state scope kind is invalid")}}function Tt(e){if(!s(e))return r("cleanup request body must be a JSON object");let t=B(e,["scopes"]);if(t!==void 0)return r(`cleanup request does not accept the "${t}" field`);if(!Array.isArray(e.scopes))return r("cleanup request scopes must be an array");let n=[];for(let o of e.scopes){let i=x(o);if(!i.ok)return i;n.push(i.value)}return u({scopes:n})}function At(e){return!s(e)||typeof e.deleted!="number"||!Number.isSafeInteger(e.deleted)||e.deleted<0?r("cleanup response data surface shape is invalid"):u({deleted:e.deleted})}function ye(e){let t=B(e,["kind","workspaceId","triggerInstanceId"]);return t!==void 0?r(`webhook trigger scope does not accept "${t}"`):e.kind!=="webhook-trigger"||!_(e.workspaceId)||!_(e.triggerInstanceId)?r("webhook trigger state scope is invalid"):u({kind:"webhook-trigger",workspaceId:e.workspaceId,triggerInstanceId:e.triggerInstanceId})}function Ee(e){let t=B(e,["kind","workspaceId","pollingInstanceId"]);return t!==void 0?r(`polling trigger scope does not accept "${t}"`):e.kind!=="polling-trigger"||!_(e.workspaceId)||!_(e.pollingInstanceId)?r("polling trigger state scope is invalid"):u({kind:"polling-trigger",workspaceId:e.workspaceId,pollingInstanceId:e.pollingInstanceId})}function ke(e){let t=B(e,["kind","workspaceId","flowId","nodeId","connectionId"]);if(t!==void 0)return r(`flow action scope does not accept "${t}"`);let n=e.connectionId;return e.kind!=="flow-action"||!_(e.workspaceId)||!_(e.flowId)||!_(e.nodeId)||n!==null&&!_(n)?r("flow action state scope is invalid"):u({kind:"flow-action",workspaceId:e.workspaceId,flowId:e.flowId,nodeId:e.nodeId,connectionId:n})}function _(e){return typeof e=="string"&&e.length>0}function B(e,t){return Object.keys(e).find(n=>!t.includes(n))}import{parseFlowDefinition as Se}from"@ablehi/flow-contract";var Ot="/:flowRunId/execution-leases",Ct="/restart",Dt="WORKFLOW_RESTART_REQUEST_INVALID",vt="WORKFLOW_RESTART_INSTANCE_UNAVAILABLE",Ut="WORKFLOW_RESTART_REJECTED",Bt="RUN_DISPATCH_UNAVAILABLE",Ft="EXECUTION_LEASE_INVALID",Ht="EXECUTION_LEASE_SUPERSEDED",Lt="WAIT_EXECUTION_SUPERSEDED",Mt="HUMAN_INPUT_CANCELLED_BY_RESET";function $t(e){return`${g}/${encodeURIComponent(e)}/execution-leases`}var _e=/^generation:[A-Za-z0-9][A-Za-z0-9._:-]{0,239}$/;function Q(e){return!s(e)||!E(e,e.kind==="standalone"?["kind"]:["kind","productRunId"])?r("execution scope shape is invalid"):e.kind==="standalone"?u({kind:"standalone"}):e.kind==="automation_app"&&y(e.productRunId)?u({kind:"automation_app",productRunId:e.productRunId}):r("execution scope discriminator is invalid")}function Z(e){return s(e)?e.kind==="terminal"&&E(e,["kind"])?u({kind:"terminal"}):e.kind==="node"&&E(e,["kind","nodeId"])&&y(e.nodeId)?u({kind:"node",nodeId:e.nodeId}):r("execution anchor shape is invalid"):r("execution anchor must be an object")}function xe(e){if(!s(e)||!E(e,["productRunId","flowRunId","generationId","generationNumber","anchor","leaseId"])||!y(e.productRunId)||!y(e.flowRunId)||!y(e.generationId)||!he(e.generationNumber)||!y(e.leaseId))return r("execution lease shape is invalid");let t=Z(e.anchor);return t.ok?u({productRunId:e.productRunId,flowRunId:e.flowRunId,generationId:e.generationId,generationNumber:e.generationNumber,anchor:t.value,leaseId:e.leaseId}):r(t.reason)}function k(e){if(!s(e))return r("execution write scope must be an object");if(e.kind==="standalone"&&E(e,["kind"]))return u({kind:"standalone"});if(e.kind==="automation_app"&&E(e,["kind","lease"])){let t=xe(e.lease);return t.ok?u({kind:"automation_app",lease:t.value}):r(t.reason)}return r("execution write scope shape is invalid")}function Wt(e){if(!s(e)||!E(e,["anchor"]))return r("lease request shape is invalid");let t=Z(e.anchor);return t.ok?u({anchor:t.value}):r(t.reason)}function Gt(e){if(!s(e)||!E(e,["executionScope"]))return r("lease response shape is invalid");let t=k(e.executionScope);return t.ok?u({executionScope:t.value}):r(t.reason)}function Kt(e){return!s(e)||!E(e,["instanceId","flowRunId","commandId","generationId","from"])||!y(e.instanceId)||!y(e.flowRunId)||!y(e.commandId)||!y(e.generationId)||!s(e.from)||!E(e.from,["name","count","type"])||typeof e.from.name!="string"||!_e.test(e.from.name)||e.from.name==="generation:terminal"||e.from.count!==1||e.from.type!=="do"?r("restart request shape is invalid"):u(e)}function qt(e){return!s(e)||!E(e,["ok","data"])||e.ok!==!0||!s(e.data)||!E(e.data,["accepted","instanceId","commandId","generationId"])||e.data.accepted!==!0||!y(e.data.instanceId)||!y(e.data.commandId)||!y(e.data.generationId)?r("restart response shape is invalid"):u(e)}function E(e,t){let n=Object.keys(e).sort(),o=[...t].sort();return n.length===o.length&&n.every((i,a)=>i===o[a])}function y(e){return typeof e=="string"&&e.length>0}function he(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0}var g="/internal/flow-runs",zt="/:flowRunId/execution-context";function Qt(e){return`${g}/${encodeURIComponent(e)}/execution-context`}function W(e){return!s(e)||!$(e.fileMaxBytes)||!$(e.fileReadMaxBytes)||!$(e.inlineMultipartBytesMax)?r("file runtime limits must carry three positive integer bounds"):u({fileMaxBytes:e.fileMaxBytes,fileReadMaxBytes:e.fileReadMaxBytes,inlineMultipartBytesMax:e.inlineMultipartBytesMax})}function Zt(e){if(!s(e))return r("execution context must be a JSON object");let t=ee(e,["flowRunId","workspaceId","input","executionScope","compiled","executionBindings","fileRuntime"]);if(t!==void 0)return r(`execution context does not accept the "${t}" field`);let n=e.compiled;if(typeof e.flowRunId!="string"||typeof e.workspaceId!="string"||!s(e.input)||!s(n)||ee(n,["irSchemaVersion","interpreterContractVersion","ir","compiledArtifactId"])!==void 0||typeof n.irSchemaVersion!="string"||typeof n.interpreterContractVersion!="string"||typeof n.compiledArtifactId!="string"||!Te(e.executionBindings))return r("execution context surface shape is invalid");let o=Se(n.ir);if(!o.ok)return r(o.reason);let i=Q(e.executionScope);if(!i.ok)return r(i.reason);let a=we(e.fileRuntime);return a.ok?u({...e,compiled:{...n,ir:o.value},executionScope:i.value,fileRuntime:a.value}):r(a.reason)}function we(e){if(e===null)return u(null);if(!s(e))return r("fileRuntime must be null or an object");let t=W(e.limits);return t.ok?u({limits:t.value}):r(t.reason)}function Te(e){return Array.isArray(e)?e.every(t=>{if(!s(t))return!1;let n=t.connection,o=x(t.stateScope);return typeof t.nodeId=="string"&&typeof t.toolRef=="string"&&s(t.toolDescriptor)&&s(t.integrationDescriptor)&&s(n)&&typeof n.installationId=="string"&&typeof n.connectionRef=="string"&&typeof n.connectionId=="string"&&typeof n.authProfileRef=="string"&&typeof n.authType=="string"&&o.ok}):!1}function $(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0}function ee(e,t){return Object.keys(e).find(n=>!t.includes(n))}import{parseAblehiErrorDigest as G}from"@ablehi/error-contract";var sn="/:flowRunId/steps/:nodeId/result",un="/:flowRunId/result",an="/:flowRunId/execution-events",cn="/:flowRunId/waits/:nodeId/register",dn="/:flowRunId/waits/:nodeId/complete";function pn(e,t){return`${g}/${encodeURIComponent(e)}/steps/${encodeURIComponent(t)}/result`}function ln(e){return`${g}/${encodeURIComponent(e)}/result`}function fn(e){return`${g}/${encodeURIComponent(e)}/execution-events`}function gn(e,t){return`${g}/${encodeURIComponent(e)}/waits/${encodeURIComponent(t)}/register`}function mn(e,t){return`${g}/${encodeURIComponent(e)}/waits/${encodeURIComponent(t)}/complete`}function Rn(e){if(!s(e))return{ok:!1,kind:"validation",reason:"step record body must be a JSON object"};let t=R(e,["executionScope","attempt","result","durationMs"]);if(t!==void 0)return{ok:!1,kind:"validation",reason:`step record does not accept the "${t}" field`};let n=k(e.executionScope);if(!n.ok)return{ok:!1,kind:"validation",reason:n.reason};let o=e.attempt;if(typeof o!="number"||!Number.isInteger(o)||o<=0)return{ok:!1,kind:"validation",reason:"attempt must be a positive integer"};let i=Ae(e.result);if(!i.ok)return i;let a={executionScope:n.value,attempt:o,result:i.value};if(e.durationMs!==void 0){let c=e.durationMs;if(typeof c!="number"||!Number.isFinite(c)||c<0)return{ok:!1,kind:"validation",reason:"durationMs must be a non-negative number"};a.durationMs=c}return{ok:!0,value:a}}function Ae(e){if(!s(e))return{ok:!1,kind:"step_result_invalid",reason:"result must be a JSON object"};let t=e.status;if(t==="succeeded"){let n=R(e,["status","output"]);return n!==void 0?{ok:!1,kind:"validation",reason:`step record result does not accept the "${n}" field`}:"output"in e?{ok:!0,value:{status:"succeeded",output:e.output}}:{ok:!1,kind:"step_result_invalid",reason:"a succeeded result must carry output"}}if(t==="failed"){let n=R(e,["status","error"]);if(n!==void 0)return{ok:!1,kind:"validation",reason:`step record result does not accept the "${n}" field`};let o=G(e.error);return o.ok?{ok:!0,value:{status:"failed",error:o.value}}:{ok:!1,kind:"step_result_invalid",reason:`a failed result must carry an AblehiErrorDigest: ${o.reason}`}}if(t==="skipped"){let n=R(e,["status","reason"]);return n!==void 0?{ok:!1,kind:"validation",reason:`step record result does not accept the "${n}" field`}:e.reason!=="run_if_false"?{ok:!1,kind:"step_result_invalid",reason:'a skipped result reason must be "run_if_false"'}:{ok:!0,value:{status:"skipped",reason:"run_if_false"}}}if(t==="timed_out"){let n=R(e,["status","error"]);if(n!==void 0)return{ok:!1,kind:"validation",reason:`step record result does not accept the "${n}" field`};let o=G(e.error);return o.ok?{ok:!0,value:{status:"timed_out",error:o.value}}:{ok:!1,kind:"step_result_invalid",reason:`a timed_out result must carry an AblehiErrorDigest: ${o.reason}`}}return{ok:!1,kind:"step_result_invalid",reason:'result status must be "succeeded", "failed", "skipped", or "timed_out"'}}function In(e){return!s(e)||typeof e.flowRunId!="string"||typeof e.nodeId!="string"||!Pe(e.recorded)?r("step record data surface shape is invalid"):u({flowRunId:e.flowRunId,nodeId:e.nodeId,recorded:e.recorded})}function Pe(e){return e==="succeeded"||e==="failed"||e==="skipped"||e==="timed_out"}function yn(e){if(!s(e))return r("result body must be a JSON object");let t=R(e,["executionScope","status","output","error"]);if(t!==void 0)return r(`result does not accept the "${t}" field`);let n=k(e.executionScope);if(!n.ok)return r(n.reason);let o=e.status;if(o!=="succeeded"&&o!=="failed")return r('result status must be "succeeded" or "failed"');let i={executionScope:n.value,status:o};if(e.output!==void 0){if(o!=="succeeded")return r("output is only allowed on a succeeded result");i.output=e.output}if(e.error!==void 0){if(o!=="failed")return r("error is only allowed on a failed result");let a=G(e.error);if(!a.ok)return r(`result error must be an AblehiErrorDigest: ${a.reason}`);i.error=a.value}return o==="failed"&&i.error===void 0?r("a failed result must carry an AblehiErrorDigest"):u(i)}function En(e){return s(e)?u(e):r("flow run result data must be a JSON object")}var be=["flow_run_started","step_started","step_retry_scheduled","wait_registered","wait_event_received","wait_event_timed_out","human_input_created","human_input_submitted","human_input_expired","flow_run_succeeded","flow_run_failed","flow_run_interrupted","flow_run_cancelled"];function kn(e){if(!s(e))return r("execution event data must be a JSON object");let t=R(e,["flowRunId","eventId","accepted"]);return t!==void 0?r(`execution event data does not accept the "${t}" field`):typeof e.flowRunId!="string"||e.flowRunId.length===0?r("flowRunId must be a non-empty string"):typeof e.eventId!="string"||e.eventId.length===0?r("eventId must be a non-empty string"):e.accepted!==!0?r("accepted must be true"):u({flowRunId:e.flowRunId,eventId:e.eventId,accepted:!0})}function _n(e){if(!s(e))return r("execution event body must be a JSON object");let t=R(e,["executionScope","eventId","eventType","nodeId","stepRunId","attempt","durationMs","occurredAt","errorId","payloadRef","inputFact"]);if(t!==void 0)return r(`execution event does not accept the "${t}" field`);let n=k(e.executionScope);if(!n.ok)return r(n.reason);let o=e.eventId;if(typeof o!="string"||o.length===0)return r("eventId must be a non-empty string");let i=e.eventType;if(!Ne(i))return r("eventType is not a known flow execution event type");let a=e.occurredAt;if(typeof a!="string"||a.length===0)return r("occurredAt must be a non-empty string");let c={executionScope:n.value,eventId:o,eventType:i,occurredAt:a};for(let d of["nodeId","stepRunId","errorId","payloadRef"]){let l=e[d];if(l!==void 0){if(typeof l!="string"||l.length===0)return r(`${d} must be a non-empty string`);c[d]=l}}for(let d of["attempt","durationMs"]){let l=e[d];if(l!==void 0){if(typeof l!="number"||!Number.isFinite(l)||!Number.isInteger(l)||l<0)return r(`${d} must be a non-negative integer`);c[d]=l}}if(e.inputFact!==void 0){if(i!=="step_started")return r("inputFact is only allowed on step_started events");if(c.attempt===void 0)return r("inputFact requires attempt");let d=Oe(e.inputFact);if(!d.ok)return d;c.inputFact=d.value}return u(c)}function Ne(e){return typeof e=="string"&&be.includes(e)}function Oe(e){if(!s(e))return r("inputFact must be a JSON object");let t=R(e,["digestAlgorithm","digest","domain"]);if(t!==void 0)return r(`inputFact does not accept the "${t}" field`);if(e.digestAlgorithm!=="sha256")return r('inputFact.digestAlgorithm must be "sha256"');let n=e.digest;if(typeof n!="string"||!/^[0-9a-f]{64}$/.test(n))return r("inputFact.digest must be a sha256 hex string");let o=e.domain;if(!s(o))return r("inputFact.domain must be a JSON object");let i=R(o,["irSchemaVersion","interpreterContractVersion","compiledArtifactId","nodeId","algorithmVersion"]);return i!==void 0?r(`inputFact.domain does not accept the "${i}" field`):typeof o.irSchemaVersion!="string"||o.irSchemaVersion.length===0||typeof o.interpreterContractVersion!="string"||o.interpreterContractVersion.length===0||typeof o.compiledArtifactId!="string"||o.compiledArtifactId.length===0||typeof o.nodeId!="string"||o.nodeId.length===0?r("inputFact.domain string fields must be non-empty strings"):o.algorithmVersion!=="flow_input_digest.v1"?r('inputFact.domain.algorithmVersion must be "flow_input_digest.v1"'):u({digestAlgorithm:"sha256",digest:n,domain:{irSchemaVersion:o.irSchemaVersion,interpreterContractVersion:o.interpreterContractVersion,compiledArtifactId:o.compiledArtifactId,nodeId:o.nodeId,algorithmVersion:"flow_input_digest.v1"}})}var Ce=/^[A-Za-z0-9_-]{1,100}$/;function xn(e){if(!s(e))return r("register body must be a JSON object");let t=R(e,["executionScope","eventType","correlationKey"]);if(t!==void 0)return r(`register wait does not accept the "${t}" field`);let n=k(e.executionScope);if(!n.ok)return r(n.reason);let o=te(e.eventType);if(!o.ok)return r(o.reason);let i=e.correlationKey;return typeof i!="string"||i.length===0?r("correlationKey must be a non-empty string"):u({executionScope:n.value,eventType:o.value,correlationKey:i})}function hn(e){if(!s(e))return r("complete body must be a JSON object");let t=R(e,["executionScope","waitExecutionId","outcome","eventId"]);if(t!==void 0)return r(`complete wait does not accept the "${t}" field`);let n=k(e.executionScope);if(!n.ok)return r(n.reason);let o=e.waitExecutionId;if(typeof o!="string"||o.length===0)return r("waitExecutionId must be a non-empty string");let i=e.outcome;if(i!=="received"&&i!=="timed_out")return r('outcome must be "received" or "timed_out"');let a={executionScope:n.value,waitExecutionId:o,outcome:i};if(e.eventId!==void 0){if(typeof e.eventId!="string"||e.eventId.length===0)return r("eventId must be a non-empty string");a.eventId=e.eventId}return u(a)}function Sn(e){if(!s(e)||R(e,["waitExecutionId","workflowEventType"])!==void 0||typeof e.waitExecutionId!="string"||e.waitExecutionId.length===0)return r("register wait data surface shape is invalid");let t=te(e.workflowEventType);return t.ok?u({waitExecutionId:e.waitExecutionId,workflowEventType:t.value}):r(t.reason)}function wn(e){return!s(e)||R(e,["completed"])!==void 0||e.completed!==!0?r("complete wait data surface shape is invalid"):u({completed:!0})}function Tn(e){return!s(e)||R(e,["waitExecutionId","eventId","payload"])!==void 0||typeof e.waitExecutionId!="string"||e.waitExecutionId.length===0||typeof e.eventId!="string"||e.eventId.length===0||!Object.hasOwn(e,"payload")?r("Wait resolved event surface shape is invalid"):u({waitExecutionId:e.waitExecutionId,eventId:e.eventId,payload:e.payload})}function te(e){return typeof e!="string"||e.length===0?r("eventType must be a non-empty string"):Ce.test(e)?u(e):r("eventType must match ^[A-Za-z0-9_-]{1,100}$")}function R(e,t){return Object.keys(e).find(n=>!t.includes(n))}var De="/internal/flow-versions",Pn="/:flowVersionId/handler-bundles",q="/internal/installations",bn="/:installationId/handler-bundles";function Nn(e,t){return`${De}/${encodeURIComponent(e)}/handler-bundles?compiledArtifactId=${encodeURIComponent(t)}`}function On(e){return`${q}/${encodeURIComponent(e.installationId)}/handler-bundles?workspaceId=${encodeURIComponent(e.workspaceId)}&artifactDigest=${encodeURIComponent(e.artifactDigest)}`}var ve=new Set(["managed_only","managed_plus_unmanaged_sdk"]);function F(e){if(!S(e))return K("runtimeNetwork must be a JSON object");let t=e.networkModel;return typeof t!="string"||!ve.has(t)?K("runtimeNetwork.networkModel is unknown"):!ne(e.apiHosts)||!ne(e.authHosts)||typeof e.httpsOnly!="boolean"?K("runtimeNetwork host/https fields are invalid"):{ok:!0,value:{networkModel:t,apiHosts:e.apiHosts,authHosts:e.authHosts,httpsOnly:e.httpsOnly}}}function Cn(e){if(!S(e)||typeof e.flowVersionId!="string"||typeof e.compiledArtifactId!="string"||!Array.isArray(e.bundles))return b("handler bundles data surface shape is invalid");let t=re(e.bundles);return t.ok?{ok:!0,value:{flowVersionId:e.flowVersionId,compiledArtifactId:e.compiledArtifactId,bundles:t.value}}:t}function Dn(e){if(!S(e)||typeof e.installationId!="string"||typeof e.artifactDigest!="string"||!Array.isArray(e.bundles))return b("tool handler bundles data surface shape is invalid");let t=re(e.bundles);return t.ok?{ok:!0,value:{installationId:e.installationId,artifactDigest:e.artifactDigest,bundles:t.value}}:t}function re(e){let t=[];for(let n of e){let o=Ue(n);if(!o.ok)return o;t.push(o.value)}return{ok:!0,value:t}}function Ue(e){if(!S(e)||typeof e.toolRef!="string"||e.kind!=="handler"&&e.kind!=="request")return b("handler bundle entry shape is invalid");if(e.kind==="request"){if(e.module!==void 0)return b("a request bundle must not carry a module");let o=F(e.runtimeNetwork);return o.ok?{ok:!0,value:{toolRef:e.toolRef,kind:"request",runtimeNetwork:o.value}}:o}let t=e.module;if(!S(t)||typeof t.entry!="string"||t.entry.length===0||!Be(t.files))return b("a handler bundle must carry a { entry, files } module");let n=F(e.runtimeNetwork);return n.ok?{ok:!0,value:{toolRef:e.toolRef,kind:"handler",module:{entry:t.entry,files:t.files},runtimeNetwork:n.value}}:n}function b(e){return{ok:!1,kind:"shape",reason:e}}function K(e){return{ok:!1,kind:"runtime_network",reason:e}}function S(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ne(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function Be(e){return S(e)&&Object.values(e).every(t=>typeof t=="string")}var N="/internal/webhook-trigger-instances",Mn="/:triggerInstanceId/context",$n="/:triggerInstanceId/handler-bundles",Wn="/:triggerInstanceId/deliveries/:deliveryId",Gn="/:triggerInstanceId/events",Kn="/:triggerInstanceId/rearm",O=e=>`${N}/${encodeURIComponent(e)}`;function qn(e,t){return`${O(e)}/context?artifactDigest=${encodeURIComponent(t)}`}function Vn(e,t){return`${O(e)}/handler-bundles?artifactDigest=${encodeURIComponent(t)}`}function jn(e,t){return`${O(e)}/deliveries/${encodeURIComponent(t)}`}function Xn(e){return`${O(e)}/events`}function Jn(e){return`${O(e)}/rearm`}var Yn="/:installationId/webhook-protocol-adapter-bundle";function zn(e){return`${q}/${encodeURIComponent(e.installationId)}/webhook-protocol-adapter-bundle?workspaceId=${encodeURIComponent(e.workspaceId)}&artifactDigest=${encodeURIComponent(e.artifactDigest)}`}var Qn="modules/webhook/protocol-adapter.js";function Zn(e){return`modules/webhook/protocol-adapter-${e}.js`}function er(e){let t=s(e)?x(e.stateScope):r("webhook watcher context state scope is invalid");return!s(e)||typeof e.artifactDigest!="string"||typeof e.triggerRef!="string"||typeof e.triggerName!="string"||typeof e.integrationRef!="string"||!s(e.inputs)||e.connection!==null&&!Fe(e.connection)||!He(e.runtime)||!t.ok||t.value.kind!=="webhook-trigger"?r("webhook watcher context surface shape is invalid"):u(e)}function Fe(e){return s(e)&&typeof e.connectionId=="string"&&typeof e.connectionRef=="string"&&typeof e.integrationRef=="string"&&typeof e.authProfileRef=="string"&&typeof e.authType=="string"}function He(e){if(!s(e)||e.type!=="webhook"||typeof e.trigger_ref!="string")return!1;let t=e.webhook;return s(t)&&typeof t.event_handler_module=="string"&&typeof t.enable_handler_module=="string"&&typeof t.disable_handler_module=="string"}function Le(e){if(!s(e)||typeof e.deliveryId!="string"||typeof e.receivedAt!="string"||!s(e.request))return r("webhook delivery surface shape is invalid");let t=e.request;return t.method!=="POST"||!s(t.headers)||typeof t.rawBody!="string"?r("webhook delivery request shape is invalid"):u(e)}function V(e){if(!s(e)||typeof e.token!="string"||typeof e.expiresAt!="string")return r("trigger file runtime dispatch shape is invalid");let t=W(e.limits);return t.ok?u({token:e.token,expiresAt:e.expiresAt,limits:t.value}):r(t.reason)}function tr(e){if(!s(e))return r("webhook delivery dispatch data is invalid");let t=Le(e.delivery);if(!t.ok)return r(t.reason);let n=e.fileRuntime;if(n===null)return u({delivery:t.value,fileRuntime:null});let o=V(n);return o.ok?u({delivery:t.value,fileRuntime:o.value}):r(o.reason)}function nr(e){if(!s(e)||typeof e.triggerRef!="string"||typeof e.artifactDigest!="string"||!Array.isArray(e.modules)||!e.modules.every(Me))return{ok:!1,kind:"shape",reason:"trigger handler bundles data surface shape is invalid"};let t=F(e.runtimeNetwork);return t.ok?{ok:!0,value:{triggerRef:e.triggerRef,artifactDigest:e.artifactDigest,modules:e.modules,runtimeNetwork:t.value}}:t}function Me(e){return s(e)&&typeof e.specifier=="string"&&e.specifier.length>0&&typeof e.source=="string"}function rr(e){if(!s(e))return r("publish events body must be a JSON object");let t=j(e,["deliveryId","events"]);if(t!==void 0)return r(`publish events does not accept the "${t}" field`);let n=e.deliveryId;if(typeof n!="string"||n.length===0)return r("deliveryId must be a non-empty string");let o=e.events;if(!Array.isArray(o))return r("events must be an array");let i=[];for(let a of o){let c=$e(a);if(!c.ok)return c;i.push(c.value)}return u({deliveryId:n,events:i})}function $e(e){if(!s(e))return r("each event must be a JSON object");let t=j(e,["eventId","occurredAt","dedupeKey","payload"]);if(t!==void 0)return r(`event does not accept the "${t}" field`);let n=e.eventId;if(typeof n!="string"||n.length===0)return r("eventId must be a non-empty string");let o=e.occurredAt;if(typeof o!="string"||o.length===0)return r("occurredAt must be a non-empty string");if(!s(e.payload))return r("event payload must be a JSON object");let i={eventId:n,occurredAt:o,payload:e.payload};if(e.dedupeKey!==void 0){if(typeof e.dedupeKey!="string"||e.dedupeKey.length===0)return r("dedupeKey must be a non-empty string");i.dedupeKey=e.dedupeKey}return u(i)}function or(e){if(!s(e))return r("rearm body must be a JSON object");let t=j(e,["expectedWatcherInstanceId"]);if(t!==void 0)return r(`rearm does not accept the "${t}" field`);let n=e.expectedWatcherInstanceId;return typeof n!="string"||n.length===0?r("expectedWatcherInstanceId must be a non-empty string"):u({expectedWatcherInstanceId:n})}function j(e,t){return Object.keys(e).find(n=>!t.includes(n))}var C="/internal/polling-trigger-instances",cr="/:pollingInstanceId/context",dr="/:pollingInstanceId/handler-bundles",pr="/:pollingInstanceId/ticks/:tickId/events",X=e=>`${C}/${encodeURIComponent(e)}`;function lr(e,t,n){return`${X(e)}/context?artifactDigest=${encodeURIComponent(t)}&tickId=${encodeURIComponent(n)}`}function fr(e,t){return`${X(e)}/handler-bundles?artifactDigest=${encodeURIComponent(t)}`}function gr(e,t){return`${X(e)}/ticks/${encodeURIComponent(t)}/events`}function We(e){let t=s(e)?x(e.stateScope):r("polling trigger context state scope is invalid");return!s(e)||typeof e.artifactDigest!="string"||typeof e.triggerRef!="string"||typeof e.triggerName!="string"||typeof e.integrationRef!="string"||!s(e.inputs)||e.connection!==null&&!Ge(e.connection)||!Ke(e.runtime)||!t.ok||t.value.kind!=="polling-trigger"||!Ve(e.tick)||!je(e.limits)?r("polling trigger context surface shape is invalid"):u(e)}function mr(e){if(!s(e))return r("polling trigger dispatch data is invalid");let t=We(e.context);if(!t.ok)return r(t.reason);let n=e.fileRuntime;if(n===null)return u({context:t.value,fileRuntime:null});let o=V(n);return o.ok?u({context:t.value,fileRuntime:o.value}):r(o.reason)}function Ge(e){return s(e)&&typeof e.connectionId=="string"&&typeof e.connectionRef=="string"&&typeof e.integrationRef=="string"&&typeof e.authProfileRef=="string"&&typeof e.authType=="string"}function Ke(e){if(!s(e)||e.type!=="polling"||typeof e.trigger_id!="string"||typeof e.trigger_ref!="string"||!qe(e.file_outputs))return!1;let t=e.polling;if(!s(t)||typeof t.run_handler_module!="string")return!1;let n=t.schedule;if(!s(n)||n.type!=="interval"||typeof n.every_seconds!="number")return!1;let o=t.dedup;return s(o)&&(o.strategy==="cursor"||o.strategy==="hash"||o.strategy==="id_field")}function qe(e){return e===void 0?!0:Array.isArray(e)&&e.length>0&&e.every(t=>s(t)&&typeof t.field=="string"&&t.field.length>0)}function Ve(e){return s(e)&&typeof e.tickId=="string"&&typeof e.scheduledAt=="string"&&typeof e.attempt=="number"}function je(e){return s(e)&&typeof e.maxEventsPerTick=="number"}function Rr(e){if(!s(e))return r("publish body must be a JSON object");let t=oe(e,["events","nextCursor"]);if(t!==void 0)return r(`publish does not accept the "${t}" field`);let n=e.events;if(!Array.isArray(n))return r("events must be an array");let o=[];for(let a of n){let c=Xe(a);if(!c.ok)return c;o.push(c.value)}let i={events:o};if("nextCursor"in e){let a=e.nextCursor;if(a!==null&&typeof a!="string")return r("nextCursor must be a string, null, or omitted");i.nextCursor=a}return u(i)}function Xe(e){if(!s(e))return r("each event must be a JSON object");let t=oe(e,["eventId","occurredAt","dedupeKey","payload"]);if(t!==void 0)return r(`event does not accept the "${t}" field`);if(typeof e.eventId!="string"||e.eventId.length===0)return r("event eventId must be a non-empty string");if(!s(e.payload))return r("event payload must be a JSON object");let n={eventId:e.eventId,payload:e.payload};if(e.occurredAt!==void 0){if(typeof e.occurredAt!="string"||e.occurredAt.length===0)return r("event occurredAt must be a non-empty string");n.occurredAt=e.occurredAt}if(e.dedupeKey!==void 0){if(typeof e.dedupeKey!="string"||e.dedupeKey.length===0)return r("event dedupeKey must be a non-empty string");n.dedupeKey=e.dedupeKey}return u(n)}function Ir(e){return!s(e)||typeof e.tickId!="string"||typeof e.cursorUpdated!="boolean"||!Array.isArray(e.results)||!e.results.every(Je)?r("publish polling tick events data surface shape is invalid"):u(e)}function Je(e){return s(e)&&typeof e.eventId=="string"&&typeof e.dedupeKey=="string"&&typeof e.duplicate=="boolean"&&(e.flowRunId===null||typeof e.flowRunId=="string")}function oe(e,t){return Object.keys(e).find(n=>!t.includes(n))}var ie="/internal/egress-grants",J="/internal/tool-invocations",Y="/internal/discovery-invocations",hr="/:flowRunId/egress-grant",Sr="/:invocationId/egress-grant",wr="/:discoveryInvocationId/egress-grant",Tr="/:pollingInstanceId/egress-grant",Ar="/:triggerInstanceId/egress-grant",Pr="/:grantId/consume",br="/:grantId/audit",Nr=e=>`${g}/${encodeURIComponent(e)}/egress-grant`,Or=e=>`${J}/${encodeURIComponent(e)}/egress-grant`,Cr=e=>`${Y}/${encodeURIComponent(e)}/egress-grant`,Dr=e=>`${C}/${encodeURIComponent(e)}/egress-grant`,vr=e=>`${N}/${encodeURIComponent(e)}/egress-grant`,Ur=e=>`${ie}/${encodeURIComponent(e)}/consume`,Br=e=>`${ie}/${encodeURIComponent(e)}/audit`,Ye=["flow_action","single_tool","discovery","polling_trigger","webhook_trigger"],ze=/^[A-Za-z0-9][A-Za-z0-9:_+/=.-]{15,1023}$/;function w(e){return typeof e=="string"&&ze.test(e)}function Qe(e){if(!s(e)||e.body_type!=="multipart")return!1;let t=e.body;if(!s(t))return!1;let n=t.parts;return Array.isArray(n)?n.some(o=>s(o)?o.kind==="file"&&typeof o.file_id=="string"&&o.file_id.length>0:!1):!1}function p(e){return{ok:!1,kind:"shape",reason:e}}function T(){return{ok:!1,kind:"request_digest",reason:"request digest is missing or malformed"}}function D(e,t){if(!s(e))return{ok:!1,reason:"grant request body must be a JSON object"};for(let n of Object.keys(e))if(!t.includes(n))return{ok:!1,reason:`grant request does not accept the "${n}" field`};return{ok:!0,record:e}}function v(e){if(!s(e))return"request must be a JSON object"}function Fr(e){let t=D(e,["nodeId","request","requestDigest"]);if(!t.ok)return p(t.reason);let n=t.record.nodeId;if(typeof n!="string"||n.length===0)return p("nodeId is required");let o=v(t.record.request);if(o!==void 0)return p(o);let i=t.record.requestDigest;return w(i)?{ok:!0,value:{nodeId:n,requestDigest:i,requestHasMultipartFiles:Qe(t.record.request)}}:T()}function Hr(e){let t=D(e,["request","requestDigest"]);if(!t.ok)return p(t.reason);let n=v(t.record.request);if(n!==void 0)return p(n);let o=t.record.requestDigest;return w(o)?{ok:!0,value:{requestDigest:o}}:T()}function Lr(e){let t=D(e,["request","requestDigest"]);if(!t.ok)return p(t.reason);let n=v(t.record.request);if(n!==void 0)return p(n);let o=t.record.requestDigest;return w(o)?{ok:!0,value:{requestDigest:o}}:T()}function Mr(e){let t=D(e,["tickId","request","requestDigest"]);if(!t.ok)return p(t.reason);let n=t.record.tickId;if(typeof n!="string"||n.length===0)return p("tickId is required");let o=v(t.record.request);if(o!==void 0)return p(o);let i=t.record.requestDigest;return w(i)?{ok:!0,value:{tickId:n,requestDigest:i}}:T()}function $r(e){let t=D(e,["phase","lifecycle","deliveryId","request","requestDigest"]);if(!t.ok)return p(t.reason);let n=t.record.phase;if(n!=="lifecycle"&&n!=="handler")return p('phase must be "lifecycle" or "handler"');let o=t.record.lifecycle,i;if(o!==void 0){if(o!=="enable"&&o!=="disable"&&o!=="renew")return p('lifecycle must be "enable", "disable", or "renew"');i=o}if(n==="lifecycle"&&i===void 0)return p("lifecycle is required for the lifecycle phase");let a=t.record.deliveryId,c;if(a!==void 0){if(typeof a!="string"||a.length===0)return p("deliveryId must be a non-empty string");c=a}if(n==="handler"&&c===void 0)return p("deliveryId is required for the handler phase");let d=v(t.record.request);if(d!==void 0)return p(d);let l=t.record.requestDigest;return w(l)?{ok:!0,value:{phase:n,...i!==void 0?{lifecycle:i}:{},...c!==void 0?{deliveryId:c}:{},requestDigest:l}}:T()}function se(e){return Ye.includes(e)?e:void 0}var Ze=["scopeKind","scopeId","requestDigest"];function Wr(e){if(!s(e))return p("consume body must be a JSON object");for(let i of Object.keys(e))if(!Ze.includes(i))return p(`consume does not accept the "${i}" field`);let t=se(e.scopeKind);if(t===void 0)return p("scopeKind is invalid");let n=e.scopeId;if(typeof n!="string"||n.length===0)return p("scopeId is required");let o=e.requestDigest;return w(o)?{ok:!0,value:{scopeKind:t,scopeId:n,requestDigest:o}}:T()}var et=["scopeKind","scopeId","providerHost","status","durationMs","requestBytes","responseBytes","errorCode"];function H(e,t){return typeof e!="number"||!Number.isInteger(e)||e<0?{ok:!1,reason:`${t} must be a non-negative integer`}:{ok:!0,value:e}}function Gr(e){if(!s(e))return p("audit body must be a JSON object");for(let f of Object.keys(e))if(!et.includes(f))return p(`audit does not accept the "${f}" field`);let t=se(e.scopeKind);if(t===void 0)return p("scopeKind is invalid");let n=e.scopeId;if(typeof n!="string"||n.length===0)return p("scopeId is required");let o=e.providerHost;if(typeof o!="string"||o.length===0)return p("providerHost is required");let i=H(e.durationMs,"durationMs");if(!i.ok)return p(i.reason);let a;if(e.status!==void 0){let f=H(e.status,"status");if(!f.ok)return p(f.reason);a=f.value}let c;if(e.requestBytes!==void 0){let f=H(e.requestBytes,"requestBytes");if(!f.ok)return p(f.reason);c=f.value}let d;if(e.responseBytes!==void 0){let f=H(e.responseBytes,"responseBytes");if(!f.ok)return p(f.reason);d=f.value}let l;if(e.errorCode!==void 0){let f=e.errorCode;if(typeof f!="string"||f.length===0)return p("errorCode must be a non-empty string");l=f}return{ok:!0,value:{scopeKind:t,scopeId:n,providerHost:o,...a!==void 0?{status:a}:{},durationMs:i.value,...c!==void 0?{requestBytes:c}:{},...d!==void 0?{responseBytes:d}:{},...l!==void 0?{errorCode:l}:{}}}}function Kr(e){return!s(e)||!s(e.grant)?r("egress grant envelope must carry a grant object"):u(e.grant)}function qr(e){return!s(e)||e.consumed!==!0?r("egress grant consume data must carry consumed:true"):u({consumed:!0})}var Qr="/:flowRunId/runtime-credential",Zr="/:invocationId/runtime-credential",eo="/:discoveryInvocationId/runtime-credential",to="/:pollingInstanceId/runtime-credential",no="/:triggerInstanceId/runtime-credential",ro=e=>`${g}/${encodeURIComponent(e)}/runtime-credential`,oo=e=>`${J}/${encodeURIComponent(e)}/runtime-credential`,io=e=>`${Y}/${encodeURIComponent(e)}/runtime-credential`,so=e=>`${C}/${encodeURIComponent(e)}/runtime-credential`,uo=e=>`${N}/${encodeURIComponent(e)}/runtime-credential`,ao=["flow_action","tool_invoke","discovery","polling_trigger","webhook_trigger"];function U(e,t){if(!s(e))return{ok:!1,reason:"runtime credential request body must be a JSON object"};for(let n of Object.keys(e))if(!t.includes(n))return{ok:!1,reason:`runtime credential request does not accept the "${n}" field`};return{ok:!0,record:e}}function co(e){let t=U(e,["nodeId"]);if(!t.ok)return r(t.reason);let n=t.record.nodeId;return typeof n!="string"||n.length===0?r("nodeId is required"):u({nodeId:n})}function po(e){let t=U(e??{},[]);return t.ok?u(null):r(t.reason)}function lo(e){let t=U(e??{},[]);return t.ok?u(null):r(t.reason)}function fo(e){let t=U(e,["tickId"]);if(!t.ok)return r(t.reason);let n=t.record.tickId;return typeof n!="string"||n.length===0?r("tickId is required"):u({tickId:n})}function go(e){let t=U(e,["executionKind","deliveryId","lifecycleOperation"]);if(!t.ok)return r(t.reason);let n=t.record.executionKind;if(n!=="event_handler"&&n!=="lifecycle")return r('executionKind must be "event_handler" or "lifecycle"');let o,i=t.record.deliveryId;if(i!==void 0){if(typeof i!="string"||i.length===0)return r("deliveryId must be a non-empty string");o=i}let a,c=t.record.lifecycleOperation;if(c!==void 0){if(c!=="enable"&&c!=="disable"&&c!=="renew")return r('lifecycleOperation must be "enable", "disable", or "renew"');a=c}return n==="lifecycle"&&a===void 0?r("lifecycleOperation is required for the lifecycle execution kind"):u({executionKind:n,...o!==void 0?{deliveryId:o}:{},...a!==void 0?{lifecycleOperation:a}:{}})}function mo(e){return!s(e)||typeof e.sessionId!="string"||typeof e.connectionId!="string"||typeof e.authProfileRef!="string"||typeof e.authType!="string"||!s(e.credential)?r("runtime credential session must carry sessionId, connectionId, auth profile facts and a credential object"):u(e.credential)}function L(e){return!s(e)||typeof e.file_id!="string"||typeof e.name!="string"||typeof e.size_bytes!="number"||typeof e.created_at!="string"||typeof e.expires_at!="string"||e.mime_type!==void 0&&typeof e.mime_type!="string"||e.sha256!==void 0&&typeof e.sha256!="string"||e.source!==void 0&&typeof e.source!="string"?r("file ref data does not match the AIS file-ref shape"):u(e)}function z(e){return!s(e)||e.method!=="GET"&&e.method!=="PUT"||typeof e.url!="string"||typeof e.expires_at!="string"||!rt(e.headers)?r("presigned file URL data is invalid"):u(e)}function tt(e){if(!s(e))return r("file upload session data is invalid");let t=L(e.file);if(!t.ok)return r(t.reason);let n=z(e.upload);return n.ok?u({file:t.value,upload:n.value}):r(n.reason)}function nt(e){if(!s(e))return r("file metadata data is invalid");let t=L(e.file);return t.ok?u({file:t.value}):r(t.reason)}function rt(e){return s(e)?Object.values(e).every(t=>typeof t=="string"):!1}var A="/internal/files",_o="/upload-session",xo="/:fileId/complete",ho="/:fileId/access",So="/:fileId/stat",wo="/:fileId/content",To=()=>A,Ao=()=>`${A}/upload-session`,Po=e=>`${A}/${encodeURIComponent(e)}/complete`,bo=(e,t)=>`${A}/${encodeURIComponent(e)}/access?intent=${encodeURIComponent(t)}`,ue=e=>`?scope_kind=${encodeURIComponent(e.scopeKind)}&scope_id=${encodeURIComponent(e.scopeId)}`,No=(e,t)=>`${A}/${encodeURIComponent(e)}/stat${ue(t)}`,Oo=(e,t)=>`${A}/${encodeURIComponent(e)}/content${ue(t)}`;function Co(e){if(!s(e))return r("internal file access data is invalid");if(e.intent==="runtime_read"||e.intent==="provider_multipart"){let t=L(e.file);if(!t.ok)return r(t.reason);let n=z(e.access);return n.ok?u({file:t.value,access:n.value,intent:e.intent}):r(n.reason)}return r("internal file access intent is invalid")}import{isHumanInputSpec as ot}from"@ablehi/flow-contract";var Ho="/:flowRunId/human-inputs",Lo="/:flowRunId/human-inputs/:requestId",Mo="/:flowRunId/human-inputs/:requestId/expire",$o="/:flowRunId/human-inputs/:requestId/acknowledge",it=e=>`${g}/${encodeURIComponent(e)}/human-inputs`,pe=(e,t)=>`${it(e)}/${encodeURIComponent(t)}`,Wo=(e,t)=>`${pe(e,t)}/expire`,Go=(e,t)=>`${pe(e,t)}/acknowledge`,st="human_input_resolved";function Ko(e){return`${st}_${e}`}function qo(e){return!s(e)||Object.keys(e).length!==4||!Object.hasOwn(e,"requestId")||!Object.hasOwn(e,"flowRunId")||!Object.hasOwn(e,"nodeId")||!Object.hasOwn(e,"status")||typeof e.requestId!="string"||e.requestId.length===0||typeof e.flowRunId!="string"||e.flowRunId.length===0||typeof e.nodeId!="string"||e.nodeId.length===0||e.status!=="submitted"&&e.status!=="expired"?r("Human Input resolved event shape is invalid"):u({requestId:e.requestId,flowRunId:e.flowRunId,nodeId:e.nodeId,status:e.status})}var ae=160,ce=500;function ut(e){return s(e)?e.kind==="choice"?!M(e,["kind","choiceId","comment"])||typeof e.choiceId!="string"||e.choiceId.length===0||e.comment!==void 0&&typeof e.comment!="string"?r("Human Input choice response is invalid"):u({kind:"choice",choiceId:e.choiceId,...e.comment!==void 0?{comment:e.comment}:{}}):e.kind==="text"&&M(e,["kind","text"])&&typeof e.text=="string"?u({kind:"text",text:e.text}):e.kind==="form"&&M(e,["kind","values"])&&s(e.values)?u({kind:"form",values:e.values}):r("Human Input response is invalid"):r("Human Input response must be an object")}function Vo(e,t){let n=ut(e);if(!n.ok||n.value.kind!==t.kind)return r("Human Input response does not match its input spec");switch(t.kind){case"choice":{let o=n.value;return o.kind!=="choice"?r("Human Input choice response does not match its spec"):!t.choices.some(i=>i.id===o.choiceId)||o.comment!==void 0&&t.allowComment!==!0?r("Human Input choice response does not match its spec"):n}case"text":return n.value.kind!=="text"||t.required===!0&&n.value.text.trim().length===0?r("Human Input text response does not match its spec"):n;case"form":{if(n.value.kind!=="form")return r("Human Input form response does not match its spec");let o=new Map(t.fields.map(i=>[i.id,i]));if(Object.keys(n.value.values).some(i=>!o.has(i)))return r("Human Input form response contains an unknown field");for(let i of t.fields){let a=n.value.values[i.id];if(!Object.hasOwn(n.value.values,i.id)){if(i.required===!0)return r(`Human Input form response is missing required field '${i.id}'`);continue}if(a==null||!at(i,a))return r(`Human Input form response field '${i.id}' does not match its spec`)}return n}}}function at(e,t){switch(e.type){case"text":case"textarea":return typeof t=="string";case"number":return typeof t=="number"&&Number.isFinite(t);case"boolean":return typeof t=="boolean";case"select":return typeof t=="string"&&(e.options??[]).some(n=>n.id===t)}}function m(e){return{ok:!1,reason:e}}function h(e,t){return s(e)?{ok:!0,value:e}:m(`${t} must be an object`)}function M(e,t){return Object.keys(e).every(n=>t.includes(n))}function P(e,t){return typeof e!="string"||e.length===0?m(`${t} must be a non-empty string`):{ok:!0,value:e}}var ct=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?(?:Z|[+-]\d{2}:\d{2})$/;function dt(e,t){return typeof e!="string"||!ct.test(e)||Number.isNaN(Date.parse(e))?m(`${t} must be an ISO-8601 timestamp`):{ok:!0,value:e}}function le(e){let t=h(e,"renderedPrompt");if(!t.ok)return t;if(!M(t.value,["title","body","format"]))return m("renderedPrompt contains an unknown field");let n=P(t.value.title,"renderedPrompt.title");if(!n.ok)return n;if(!/[^\p{White_Space}]/u.test(n.value))return m("renderedPrompt.title must contain non-whitespace text");if(!de(n.value,ae))return m(`renderedPrompt.title must contain at most ${ae} code points`);let o={title:n.value};if(t.value.body!==void 0){if(typeof t.value.body!="string")return m("renderedPrompt.body must be a string");if(!de(t.value.body,ce))return m(`renderedPrompt.body must contain at most ${ce} code points`);o.body=t.value.body}if(t.value.format!==void 0){if(t.value.format!=="plain"&&t.value.format!=="markdown")return m("renderedPrompt.format is invalid");o.format=t.value.format}return{ok:!0,value:o}}function de(e,t){let n=0,o=e[Symbol.iterator]();for(;!o.next().done;)if(n+=1,n>t)return!1;return!0}function jo(e){let t=le(e);return t.ok?u(t.value):r(t.reason)}function pt(e){try{return ot(e)?u(e):r("Human Input spec shape is invalid")}catch{return r("Human Input spec shape is invalid")}}function lt(e){let t=pt(e);return t.ok?t:m(t.reason)}function ft(e){if(e==null)return{ok:!0,value:void 0};let t=h(e,"partiallyRenderedDelivery");if(!t.ok)return t;let n=t.value.actions;if(n===void 0)return{ok:!0,value:{}};if(!Array.isArray(n))return m("partiallyRenderedDelivery.actions must be an array");let o=[];for(let i of n){let a=h(i,"delivery action");if(!a.ok)return a;let c=P(a.value.id,"delivery action id");if(!c.ok)return c;let d=fe(a.value.inputs,`delivery action '${c.value}' inputs`);if(!d.ok)return d;o.push({id:c.value,inputs:d.value})}return{ok:!0,value:{actions:o}}}function fe(e,t){let n=h(e,t);if(!n.ok)return n;let o={};for(let[i,a]of Object.entries(n.value)){let c=ge(a,`${t}.${i}`);if(!c.ok)return c;o[i]=c.value}return{ok:!0,value:o}}function ge(e,t){let n=h(e,t);if(!n.ok)return n;switch(n.value.kind){case"literal":return{ok:!0,value:{kind:"literal",value:n.value.value}};case"human_input_ref":{let i=P(n.value.path,`${t}.path`);return i.ok?{ok:!0,value:{kind:"human_input_ref",path:i.value}}:i}case"array":{if(!Array.isArray(n.value.items))return m(`${t}.items must be an array`);let i=[];for(let[a,c]of n.value.items.entries()){let d=ge(c,`${t}[${a}]`);if(!d.ok)return d;i.push(d.value)}return{ok:!0,value:{kind:"array",items:i}}}case"object":{let i=fe(n.value.entries,`${t}.entries`);return i.ok?{ok:!0,value:{kind:"object",entries:i.value}}:i}case"template":{if(!Array.isArray(n.value.parts))return m(`${t}.parts must be an array`);let i=[];for(let[a,c]of n.value.parts.entries()){let d=gt(c,`${t}.parts[${a}]`);if(!d.ok)return d;i.push(d.value)}return{ok:!0,value:{kind:"template",parts:i}}}default:return m(`${t}.kind is invalid`)}}function gt(e,t){let n=h(e,t);if(!n.ok)return n;let o=n.value.kind;if(o==="literal")return typeof n.value.value!="string"?m(`${t}.value must be a string`):{ok:!0,value:{kind:"literal",value:n.value.value}};if(o==="human_input_ref"){let i=P(n.value.path,`${t}.path`);return i.ok?{ok:!0,value:{kind:"human_input_ref",path:i.value}}:i}return m(`${t}.kind is invalid`)}function Xo(e){let t=h(e,"request body");if(!t.ok)return r(t.reason);let n=Object.keys(t.value).find(Re=>!["executionScope","nodeId","renderedPrompt","input","partiallyRenderedDelivery","timeout","expiresAt"].includes(Re));if(n!==void 0)return r(`human input body does not accept the "${n}" field`);let o=k(t.value.executionScope);if(!o.ok)return r(o.reason);let i=P(t.value.nodeId,"nodeId");if(!i.ok)return r(i.reason);let a=le(t.value.renderedPrompt);if(!a.ok)return r(a.reason);let c=lt(t.value.input);if(!c.ok)return r(c.reason);let d=P(t.value.timeout,"timeout");if(!d.ok)return r(d.reason);let l=dt(t.value.expiresAt,"expiresAt");if(!l.ok)return r(l.reason);let f=ft(t.value.partiallyRenderedDelivery);return f.ok?u({executionScope:o.value,nodeId:i.value,renderedPrompt:a.value,input:c.value,timeout:d.value,expiresAt:l.value,...f.value!==void 0?{partiallyRenderedDelivery:f.value}:{}}):r(f.reason)}function mt(e){return!s(e)||typeof e.id!="string"||e.id.length===0||typeof e.nodeId!="string"||typeof e.status!="string"||!(e.output===null||s(e.output))?r("human input request view must carry id, nodeId, status and output"):u(e)}function Jo(e){if(!s(e)||typeof e.created!="boolean")return r("human input create data must carry created:boolean");let t=mt(e.request);return t.ok?u({created:e.created,request:t.value}):t}function Yo(e){return!s(e)||e.acknowledged!==!0?r("human input acknowledge data must carry acknowledged:true"):u({acknowledged:!0})}var Qo="ablehi-wfp-user-runtime-manifest/v1",Zo="unknown";function ei(e){return e.endsWith(".js")?`${e.slice(0,-3)}.manifest.json`:`${e}.manifest.json`}var ni="/internal/deployment-handshake",Rt=["start","terminate","send-event","start-webhook-watcher","run-polling-tick","invoke-tool","invoke-discovery","invoke-trigger-handler","invoke-webhook-protocol-adapter","deployment-handshake"],ri=Rt,oi="HANDSHAKE_REQUEST_INVALID",ii="HANDSHAKE_SECRET_UNCONFIGURED",si="HANDSHAKE_SECRET_MISMATCH",ui="HANDSHAKE_CONTRACT_VERSION_MISMATCH",ai="HANDSHAKE_DISPATCH_NAMESPACE_MISMATCH",ci="HANDSHAKE_CAPABILITY_MISSING";function di(e){return[e.nonce,e.timestamp,e.contractVersion,e.dispatchNamespace].map(n=>`${n.length}:${n}`).join(".")}function pi(e){return["response",e.nonce,e.contractVersion,e.dispatchNamespace,...e.capabilities].map(n=>`${n.length}:${n}`).join(".")}function gi(e){if(!s(e)||e.ok!==!1||!s(e.error))return r("Server execution error envelope is invalid");let t=Object.keys(e).find(i=>i!=="ok"&&i!=="error"&&i!=="guidance"),n=e.error,o=Object.keys(n).find(i=>i!=="code"&&i!=="message"&&i!=="retryable"&&i!=="issues"&&i!=="details");return t!==void 0||o!==void 0||typeof n.code!="string"||n.code.length===0||typeof n.message!="string"||typeof n.retryable!="boolean"||n.issues!==void 0&&!Array.isArray(n.issues)||n.details!==void 0&&!s(n.details)?r("Server execution error must carry code, message, and boolean retryable"):u(e)}import{lookupErrorRegistryEntry as It}from"@ablehi/error-contract";var ki="/:flowRunId/inbox-message-emissions/:nodeId";function _i(e,t){return`${g}/${encodeURIComponent(e)}/inbox-message-emissions/${encodeURIComponent(t)}`}function I(e){let t=It(e);if(t.code!==e)throw new Error(`Inbox message execution error code is not registered: ${e}`);return t.retryable}var xi=_t({INBOX_MESSAGE_IDEMPOTENCY_KEY_INVALID:{httpStatus:422,retryable:I("INBOX_MESSAGE_IDEMPOTENCY_KEY_INVALID")},INBOX_MESSAGE_PAYLOAD_INVALID:{httpStatus:422,retryable:I("INBOX_MESSAGE_PAYLOAD_INVALID")},INBOX_MESSAGE_PAYLOAD_TOO_LARGE:{httpStatus:413,retryable:I("INBOX_MESSAGE_PAYLOAD_TOO_LARGE")},INBOX_MESSAGE_RENDER_INVALID:{httpStatus:422,retryable:I("INBOX_MESSAGE_RENDER_INVALID")},INBOX_MESSAGE_CONTENT_TOO_LARGE:{httpStatus:413,retryable:I("INBOX_MESSAGE_CONTENT_TOO_LARGE")},INBOX_MESSAGE_ATTACHMENT_INVALID:{httpStatus:422,retryable:I("INBOX_MESSAGE_ATTACHMENT_INVALID")},INBOX_MESSAGE_ATTACHMENT_UNAVAILABLE:{httpStatus:409,retryable:I("INBOX_MESSAGE_ATTACHMENT_UNAVAILABLE")},FLOW_INBOX_MESSAGE_INVALID:{httpStatus:422,retryable:I("FLOW_INBOX_MESSAGE_INVALID")},EXECUTION_LEASE_INVALID:{httpStatus:409,retryable:I("EXECUTION_LEASE_INVALID")},EXECUTION_LEASE_SUPERSEDED:{httpStatus:409,retryable:I("EXECUTION_LEASE_SUPERSEDED")},AUTOMATION_APP_INSTALLATION_DISABLED:{httpStatus:409,retryable:I("AUTOMATION_APP_INSTALLATION_DISABLED")},INBOX_MESSAGE_EMISSION_WINDOW_CLOSED:{httpStatus:409,retryable:I("INBOX_MESSAGE_EMISSION_WINDOW_CLOSED")},INBOX_MESSAGE_EMISSION_CONFLICT:{httpStatus:409,retryable:I("INBOX_MESSAGE_EMISSION_CONFLICT")},INBOX_MESSAGE_EMISSION_UNAVAILABLE:{httpStatus:503,retryable:I("INBOX_MESSAGE_EMISSION_UNAVAILABLE")}});function hi(e){if(!s(e)||!me(e,["executionScope","idempotencyKey","payload"])||typeof e.idempotencyKey!="string"||!yt(e.payload))return r("Inbox message Emission request shape is invalid");let t=k(e.executionScope);return t.ok?u({executionScope:t.value,idempotencyKey:e.idempotencyKey,payload:e.payload}):r(t.reason)}function Si(e){return!s(e)||!me(e,["emissionId","outcome","occurredAt"])||typeof e.emissionId!="string"||e.emissionId.length===0||e.outcome!=="created"&&e.outcome!=="replayed"||typeof e.occurredAt!="string"||e.occurredAt.length===0?r("Inbox message Emission response shape is invalid"):u(e)}function me(e,t){let n=Object.keys(e).sort(),o=[...t].sort();return n.length===o.length&&n.every((i,a)=>i===o[a])}function yt(e){return s(e)&&Et(e)}function Et(e){let n=new WeakSet,o=[{value:e}],i=0;for(;o.length>0;){let a=o.pop();if(a.exiting){n.delete(a.value);continue}let c=a.value;if(c===null||typeof c=="string"||typeof c=="boolean"||typeof c=="number"&&Number.isFinite(c))continue;if(typeof c!="object"||n.has(c)||(i+=1,i>1e5))return!1;let d=Array.isArray(c)?c:s(c)&&kt(c)?Object.values(c):void 0;if(d===void 0)return!1;n.add(c),o.push({value:c,exiting:!0});for(let l=d.length-1;l>=0;l-=1)o.push({value:d[l]})}return!0}function kt(e){let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function _t(e){for(let t of Object.values(e))Object.freeze(t);return Object.freeze(e)}export{dn as COMPLETE_EVENT_WAIT_ROUTE_SUBPATH,wt as CONTEXT_STATE_CLEANUP_ROUTE_PATH,Rt as DEPLOYMENT_HANDSHAKE_DISPATCHER_CAPABILITIES,ri as DEPLOYMENT_HANDSHAKE_REQUIRED_CAPABILITIES,ni as DEPLOYMENT_HANDSHAKE_ROUTE,wr as DISCOVERY_INVOCATION_EGRESS_GRANT_ROUTE_SUBPATH,eo as DISCOVERY_INVOCATION_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,br as EGRESS_GRANT_AUDIT_ROUTE_SUBPATH,Pr as EGRESS_GRANT_CONSUME_ROUTE_SUBPATH,Ye as EGRESS_GRANT_SCOPE_KINDS,zt as EXECUTION_CONTEXT_ROUTE_SUBPATH,Ft as EXECUTION_LEASE_INVALID,Ot as EXECUTION_LEASE_ROUTE_SUBPATH,Ht as EXECUTION_LEASE_SUPERSEDED,ho as FILE_ACCESS_ROUTE_SUBPATH,xo as FILE_COMPLETE_ROUTE_SUBPATH,wo as FILE_CONTENT_ROUTE_SUBPATH,So as FILE_STAT_ROUTE_SUBPATH,_o as FILE_UPLOAD_SESSION_ROUTE_SUBPATH,hr as FLOW_RUN_EGRESS_GRANT_ROUTE_SUBPATH,an as FLOW_RUN_EXECUTION_EVENTS_ROUTE_SUBPATH,be as FLOW_RUN_EXECUTION_EVENT_TYPES,un as FLOW_RUN_RESULT_ROUTE_SUBPATH,Qr as FLOW_RUN_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,Pn as HANDLER_BUNDLES_ROUTE_SUBPATH,ci as HANDSHAKE_CAPABILITY_MISSING,ui as HANDSHAKE_CONTRACT_VERSION_MISMATCH,ai as HANDSHAKE_DISPATCH_NAMESPACE_MISMATCH,oi as HANDSHAKE_REQUEST_INVALID,si as HANDSHAKE_SECRET_MISMATCH,ii as HANDSHAKE_SECRET_UNCONFIGURED,Ho as HUMAN_INPUTS_ROUTE_SUBPATH,$o as HUMAN_INPUT_ACKNOWLEDGE_ROUTE_SUBPATH,Mt as HUMAN_INPUT_CANCELLED_BY_RESET,Mo as HUMAN_INPUT_EXPIRE_ROUTE_SUBPATH,ce as HUMAN_INPUT_PROMPT_BODY_MAX_CODE_POINTS,ae as HUMAN_INPUT_PROMPT_TITLE_MAX_CODE_POINTS,Lo as HUMAN_INPUT_REQUEST_ROUTE_SUBPATH,st as HUMAN_INPUT_RESOLVED_EVENT_PREFIX,ki as INBOX_MESSAGE_EMISSION_ROUTE_SUBPATH,xi as INBOX_MESSAGE_EXECUTION_ERROR_REGISTRY,Y as INTERNAL_DISCOVERY_INVOCATIONS_ROUTE_PREFIX,ie as INTERNAL_EGRESS_GRANTS_ROUTE_PREFIX,A as INTERNAL_FILES_ROUTE_PREFIX,g as INTERNAL_FLOW_RUNS_ROUTE_PREFIX,De as INTERNAL_FLOW_VERSIONS_ROUTE_PREFIX,q as INTERNAL_INSTALLATIONS_ROUTE_PREFIX,C as INTERNAL_POLLING_TRIGGER_INSTANCES_ROUTE_PREFIX,J as INTERNAL_TOOL_INVOCATIONS_ROUTE_PREFIX,N as INTERNAL_WEBHOOK_TRIGGER_INSTANCES_ROUTE_PREFIX,cr as POLLING_TRIGGER_CONTEXT_ROUTE_SUBPATH,Tr as POLLING_TRIGGER_EGRESS_GRANT_ROUTE_SUBPATH,dr as POLLING_TRIGGER_HANDLER_BUNDLES_ROUTE_SUBPATH,to as POLLING_TRIGGER_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,pr as POLLING_TRIGGER_TICK_EVENTS_ROUTE_SUBPATH,cn as REGISTER_EVENT_WAIT_ROUTE_SUBPATH,ao as RUNTIME_CREDENTIAL_SESSION_SCOPE_KINDS,Bt as RUN_DISPATCH_UNAVAILABLE,Ie as SERVER_EXECUTION_CONTRACT_VERSION,sn as STEP_RESULT_ROUTE_SUBPATH,bn as TOOL_HANDLER_BUNDLES_ROUTE_SUBPATH,Sr as TOOL_INVOCATION_EGRESS_GRANT_ROUTE_SUBPATH,Zr as TOOL_INVOCATION_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,Lt as WAIT_EXECUTION_SUPERSEDED,Yn as WEBHOOK_PROTOCOL_ADAPTER_BUNDLE_ROUTE_SUBPATH,Qn as WEBHOOK_PROTOCOL_ADAPTER_MODULE,Mn as WEBHOOK_TRIGGER_CONTEXT_ROUTE_SUBPATH,Wn as WEBHOOK_TRIGGER_DELIVERY_ROUTE_SUBPATH,Ar as WEBHOOK_TRIGGER_EGRESS_GRANT_ROUTE_SUBPATH,Gn as WEBHOOK_TRIGGER_EVENTS_ROUTE_SUBPATH,$n as WEBHOOK_TRIGGER_HANDLER_BUNDLES_ROUTE_SUBPATH,Kn as WEBHOOK_TRIGGER_REARM_ROUTE_SUBPATH,no as WEBHOOK_TRIGGER_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,Qo as WFP_USER_RUNTIME_MANIFEST_FORMAT_VERSION,Zo as WFP_USER_RUNTIME_UNKNOWN_SOURCE_REVISION,vt as WORKFLOW_RESTART_INSTANCE_UNAVAILABLE,Ut as WORKFLOW_RESTART_REJECTED,Dt as WORKFLOW_RESTART_REQUEST_INVALID,Ct as WORKFLOW_RESTART_ROUTE,$t as acquireExecutionLeasePath,mn as completeEventWaitPath,di as deploymentHandshakeProbePayload,pi as deploymentHandshakeResponseProofPayload,Cr as discoveryInvocationEgressGrantPath,io as discoveryInvocationRuntimeCredentialPath,Br as egressGrantAuditPath,Ur as egressGrantConsumePath,Qt as executionContextPath,Nr as flowRunEgressGrantPath,fn as flowRunExecutionEventsPath,ln as flowRunResultPath,ro as flowRunRuntimeCredentialPath,Zn as flowScriptProtocolAdapterModuleName,Nn as handlerBundlesPath,Go as humanInputAcknowledgePath,Wo as humanInputExpirePath,pe as humanInputRequestPath,Ko as humanInputResolvedEventType,it as humanInputsPath,_i as inboxMessageEmissionPath,bo as internalFileAccessPath,Po as internalFileCompletePath,Oo as internalFileContentPath,No as internalFileStatPath,Ao as internalFileUploadSessionPath,To as internalFilesPath,w as isValidRequestDigest,Gt as parseAcquireExecutionLeaseData,Wt as parseAcquireExecutionLeaseRequest,hn as parseCompleteFlowRunWaitBody,wn as parseCompleteFlowRunWaitData,Tt as parseContextStateCleanupRequestBody,At as parseContextStateCleanupResponseData,x as parseContextStateScope,Xo as parseCreateHumanInputBody,Lr as parseDiscoveryGrantBody,lo as parseDiscoveryRuntimeCredentialBody,Gr as parseEgressGrantAuditBody,Wr as parseEgressGrantConsumeBody,qr as parseEgressGrantConsumeData,Kr as parseEgressGrantData,Si as parseEmitInboxMessageData,hi as parseEmitInboxMessageRequest,Z as parseExecutionAnchor,Zt as parseExecutionContextData,xe as parseExecutionLease,k as parseExecutionWriteScope,nt as parseFileMetadataData,L as parseFileRefData,W as parseFileRuntimeLimits,tt as parseFileUploadSessionData,Fr as parseFlowActionGrantBody,Q as parseFlowExecutionScope,_n as parseFlowRunExecutionEventBody,kn as parseFlowRunExecutionEventData,yn as parseFlowRunResultBody,En as parseFlowRunResultData,co as parseFlowRuntimeCredentialBody,Tn as parseFlowWaitResolvedEvent,Ue as parseHandlerBundle,Cn as parseHandlerBundlesData,Yo as parseHumanInputAcknowledgeData,Jo as parseHumanInputCreateData,mt as parseHumanInputRequestViewData,qo as parseHumanInputResolvedEvent,ut as parseHumanInputResponse,Vo as parseHumanInputResponseForSpec,pt as parseHumanInputSpec,Co as parseInternalFileAccessData,Rr as parsePollingPublishBody,fo as parsePollingRuntimeCredentialBody,We as parsePollingTriggerContext,mr as parsePollingTriggerDispatchData,Mr as parsePollingTriggerGrantBody,Ir as parsePublishPollingTickEventsData,xn as parseRegisterFlowRunWaitBody,Sn as parseRegisterFlowRunWaitData,jo as parseRenderedHumanInputPrompt,mo as parseRuntimeCredentialSessionCredential,F as parseRuntimeNetwork,gi as parseServerExecutionErrorEnvelope,Hr as parseSingleToolGrantBody,po as parseSingleToolRuntimeCredentialBody,Rn as parseStepRecordBody,In as parseStepRecordData,Dn as parseToolHandlerBundlesData,V as parseTriggerFileRuntimeDispatch,nr as parseTriggerHandlerBundlesData,Le as parseWebhookDelivery,tr as parseWebhookDeliveryDispatchData,rr as parseWebhookPublishEventsBody,or as parseWebhookRearmBody,go as parseWebhookRuntimeCredentialBody,$r as parseWebhookTriggerGrantBody,er as parseWebhookWatcherContext,Kt as parseWorkflowDispatchRestartRequest,qt as parseWorkflowDispatchRestartResponse,lr as pollingTriggerContextPath,Dr as pollingTriggerEgressGrantPath,fr as pollingTriggerHandlerBundlesPath,so as pollingTriggerRuntimeCredentialPath,gr as pollingTriggerTickEventsPath,gn as registerEventWaitPath,Qe as requestHasMultipartFileParts,pn as stepResultPath,On as toolHandlerBundlesPath,Or as toolInvocationEgressGrantPath,oo as toolInvocationRuntimeCredentialPath,zn as webhookProtocolAdapterBundlePath,qn as webhookTriggerContextPath,jn as webhookTriggerDeliveryPath,vr as webhookTriggerEgressGrantPath,Xn as webhookTriggerEventsPath,Vn as webhookTriggerHandlerBundlesPath,Jn as webhookTriggerRearmPath,uo as webhookTriggerRuntimeCredentialPath,ei as wfpUserRuntimeManifestPath};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { PublishedFlowDefinition, RuntimeHumanInputSpec } from '@ablehi/flow-contract';
|
|
1
|
+
import { PublishedFlowDefinition, RuntimeHumanInputSpec, JsonObject } from '@ablehi/flow-contract';
|
|
2
2
|
import { AblehiErrorDigest } from '@ablehi/error-contract';
|
|
3
3
|
|
|
4
|
-
declare const SERVER_EXECUTION_CONTRACT_VERSION = "0.
|
|
4
|
+
declare const SERVER_EXECUTION_CONTRACT_VERSION = "0.4.0";
|
|
5
5
|
type ServerExecutionContractVersion = typeof SERVER_EXECUTION_CONTRACT_VERSION;
|
|
6
6
|
|
|
7
7
|
type ContractParseResult<T> = {
|
|
@@ -836,6 +836,8 @@ type HumanInputResolvedEvent = {
|
|
|
836
836
|
status: "submitted" | "expired";
|
|
837
837
|
};
|
|
838
838
|
declare function parseHumanInputResolvedEvent(value: unknown): ContractParseResult<HumanInputResolvedEvent>;
|
|
839
|
+
declare const HUMAN_INPUT_PROMPT_TITLE_MAX_CODE_POINTS = 160;
|
|
840
|
+
declare const HUMAN_INPUT_PROMPT_BODY_MAX_CODE_POINTS = 500;
|
|
839
841
|
type RenderedHumanInputPrompt = {
|
|
840
842
|
title: string;
|
|
841
843
|
body?: string;
|
|
@@ -891,6 +893,8 @@ type HumanInputResponse = {
|
|
|
891
893
|
kind: "form";
|
|
892
894
|
values: Record<string, unknown>;
|
|
893
895
|
};
|
|
896
|
+
declare function parseHumanInputResponse(value: unknown): ContractParseResult<HumanInputResponse>;
|
|
897
|
+
declare function parseHumanInputResponseForSpec(value: unknown, spec: RuntimeHumanInputSpec): ContractParseResult<HumanInputResponse>;
|
|
894
898
|
type HumanInputActor = {
|
|
895
899
|
type: "user";
|
|
896
900
|
userId: string;
|
|
@@ -934,6 +938,8 @@ type HumanInputRequestView = {
|
|
|
934
938
|
updatedAt: string;
|
|
935
939
|
output: HumanInputOutput | null;
|
|
936
940
|
};
|
|
941
|
+
declare function parseRenderedHumanInputPrompt(value: unknown): ContractParseResult<RenderedHumanInputPrompt>;
|
|
942
|
+
declare function parseHumanInputSpec(value: unknown): ContractParseResult<RuntimeHumanInputSpec>;
|
|
937
943
|
declare function parseCreateHumanInputBody(body: unknown): ContractParseResult<CreateHumanInputRequestBody>;
|
|
938
944
|
declare function parseHumanInputRequestViewData(data: unknown): ContractParseResult<HumanInputRequestView>;
|
|
939
945
|
declare function parseHumanInputCreateData(data: unknown): ContractParseResult<{
|
|
@@ -1000,4 +1006,98 @@ declare function deploymentHandshakeResponseProofPayload(input: {
|
|
|
1000
1006
|
capabilities: string[];
|
|
1001
1007
|
}): string;
|
|
1002
1008
|
|
|
1003
|
-
|
|
1009
|
+
/** Machine-readable error returned by every v0.4.0 execution endpoint. */
|
|
1010
|
+
type ServerExecutionError = {
|
|
1011
|
+
code: string;
|
|
1012
|
+
message: string;
|
|
1013
|
+
retryable: boolean;
|
|
1014
|
+
issues?: unknown[];
|
|
1015
|
+
details?: Record<string, unknown>;
|
|
1016
|
+
};
|
|
1017
|
+
type ServerExecutionErrorEnvelope = {
|
|
1018
|
+
ok: false;
|
|
1019
|
+
error: ServerExecutionError;
|
|
1020
|
+
guidance?: unknown;
|
|
1021
|
+
};
|
|
1022
|
+
/**
|
|
1023
|
+
* Parses the common execution error core without inventing retryability from
|
|
1024
|
+
* HTTP status. Additional error fields are rejected so a consumer cannot
|
|
1025
|
+
* silently depend on a producer extension outside this contract.
|
|
1026
|
+
*/
|
|
1027
|
+
declare function parseServerExecutionErrorEnvelope(value: unknown): ContractParseResult<ServerExecutionErrorEnvelope>;
|
|
1028
|
+
|
|
1029
|
+
declare const INBOX_MESSAGE_EMISSION_ROUTE_SUBPATH = "/:flowRunId/inbox-message-emissions/:nodeId";
|
|
1030
|
+
declare function inboxMessageEmissionPath(flowRunId: string, nodeId: string): string;
|
|
1031
|
+
type EmitInboxMessageRequest = {
|
|
1032
|
+
executionScope: ExecutionWriteScope;
|
|
1033
|
+
idempotencyKey: string;
|
|
1034
|
+
payload: JsonObject;
|
|
1035
|
+
};
|
|
1036
|
+
type EmitInboxMessageData = {
|
|
1037
|
+
emissionId: string;
|
|
1038
|
+
outcome: "created" | "replayed";
|
|
1039
|
+
occurredAt: string;
|
|
1040
|
+
};
|
|
1041
|
+
declare const INBOX_MESSAGE_EXECUTION_ERROR_REGISTRY: Readonly<{
|
|
1042
|
+
readonly INBOX_MESSAGE_IDEMPOTENCY_KEY_INVALID: {
|
|
1043
|
+
readonly httpStatus: 422;
|
|
1044
|
+
readonly retryable: boolean;
|
|
1045
|
+
};
|
|
1046
|
+
readonly INBOX_MESSAGE_PAYLOAD_INVALID: {
|
|
1047
|
+
readonly httpStatus: 422;
|
|
1048
|
+
readonly retryable: boolean;
|
|
1049
|
+
};
|
|
1050
|
+
readonly INBOX_MESSAGE_PAYLOAD_TOO_LARGE: {
|
|
1051
|
+
readonly httpStatus: 413;
|
|
1052
|
+
readonly retryable: boolean;
|
|
1053
|
+
};
|
|
1054
|
+
readonly INBOX_MESSAGE_RENDER_INVALID: {
|
|
1055
|
+
readonly httpStatus: 422;
|
|
1056
|
+
readonly retryable: boolean;
|
|
1057
|
+
};
|
|
1058
|
+
readonly INBOX_MESSAGE_CONTENT_TOO_LARGE: {
|
|
1059
|
+
readonly httpStatus: 413;
|
|
1060
|
+
readonly retryable: boolean;
|
|
1061
|
+
};
|
|
1062
|
+
readonly INBOX_MESSAGE_ATTACHMENT_INVALID: {
|
|
1063
|
+
readonly httpStatus: 422;
|
|
1064
|
+
readonly retryable: boolean;
|
|
1065
|
+
};
|
|
1066
|
+
readonly INBOX_MESSAGE_ATTACHMENT_UNAVAILABLE: {
|
|
1067
|
+
readonly httpStatus: 409;
|
|
1068
|
+
readonly retryable: boolean;
|
|
1069
|
+
};
|
|
1070
|
+
readonly FLOW_INBOX_MESSAGE_INVALID: {
|
|
1071
|
+
readonly httpStatus: 422;
|
|
1072
|
+
readonly retryable: boolean;
|
|
1073
|
+
};
|
|
1074
|
+
readonly EXECUTION_LEASE_INVALID: {
|
|
1075
|
+
readonly httpStatus: 409;
|
|
1076
|
+
readonly retryable: boolean;
|
|
1077
|
+
};
|
|
1078
|
+
readonly EXECUTION_LEASE_SUPERSEDED: {
|
|
1079
|
+
readonly httpStatus: 409;
|
|
1080
|
+
readonly retryable: boolean;
|
|
1081
|
+
};
|
|
1082
|
+
readonly AUTOMATION_APP_INSTALLATION_DISABLED: {
|
|
1083
|
+
readonly httpStatus: 409;
|
|
1084
|
+
readonly retryable: boolean;
|
|
1085
|
+
};
|
|
1086
|
+
readonly INBOX_MESSAGE_EMISSION_WINDOW_CLOSED: {
|
|
1087
|
+
readonly httpStatus: 409;
|
|
1088
|
+
readonly retryable: boolean;
|
|
1089
|
+
};
|
|
1090
|
+
readonly INBOX_MESSAGE_EMISSION_CONFLICT: {
|
|
1091
|
+
readonly httpStatus: 409;
|
|
1092
|
+
readonly retryable: boolean;
|
|
1093
|
+
};
|
|
1094
|
+
readonly INBOX_MESSAGE_EMISSION_UNAVAILABLE: {
|
|
1095
|
+
readonly httpStatus: 503;
|
|
1096
|
+
readonly retryable: boolean;
|
|
1097
|
+
};
|
|
1098
|
+
}>;
|
|
1099
|
+
type InboxMessageExecutionErrorCode = keyof typeof INBOX_MESSAGE_EXECUTION_ERROR_REGISTRY;
|
|
1100
|
+
declare function parseEmitInboxMessageRequest(value: unknown): ContractParseResult<EmitInboxMessageRequest>;
|
|
1101
|
+
declare function parseEmitInboxMessageData(value: unknown): ContractParseResult<EmitInboxMessageData>;
|
|
1102
|
+
|
|
1103
|
+
export { type AcquireExecutionLeaseData, type AcquireExecutionLeaseRequest, COMPLETE_EVENT_WAIT_ROUTE_SUBPATH, CONTEXT_STATE_CLEANUP_ROUTE_PATH, type CompleteFlowRunWaitBody, type CompleteFlowRunWaitData, type ContextStateCleanupRequestBody, type ContextStateCleanupResponseData, type ContextStateScope, type CreateHumanInputRequestBody, DEPLOYMENT_HANDSHAKE_DISPATCHER_CAPABILITIES, DEPLOYMENT_HANDSHAKE_REQUIRED_CAPABILITIES, DEPLOYMENT_HANDSHAKE_ROUTE, DISCOVERY_INVOCATION_EGRESS_GRANT_ROUTE_SUBPATH, DISCOVERY_INVOCATION_RUNTIME_CREDENTIAL_ROUTE_SUBPATH, type DeploymentHandshakeData, type DeploymentHandshakeRequestBody, type DeploymentHandshakeResponse, type DiscoveryDispatchBody, type DiscoveryEgressGrantBinding, type DiscoveryExecutionBinding, type DiscoveryGrantBody, type DiscoveryInvokeRequest, type DiscoveryRuntimeCredentialBinding, EGRESS_GRANT_AUDIT_ROUTE_SUBPATH, EGRESS_GRANT_CONSUME_ROUTE_SUBPATH, EGRESS_GRANT_SCOPE_KINDS, EXECUTION_CONTEXT_ROUTE_SUBPATH, EXECUTION_LEASE_INVALID, EXECUTION_LEASE_ROUTE_SUBPATH, EXECUTION_LEASE_SUPERSEDED, type EgressGrant, type EgressGrantAuditBody, type EgressGrantBodyParseResult, type EgressGrantConsumeBody, type EgressGrantCredentialMaterial, type EgressGrantFileRuntime, type EgressGrantScopeKind, type EmitInboxMessageData, type EmitInboxMessageRequest, type ExecutionAnchor, type ExecutionBinding, type ExecutionBindingConnection, type ExecutionContextCompiled, type ExecutionContextData, type ExecutionLease, type ExecutionWriteScope, FILE_ACCESS_ROUTE_SUBPATH, FILE_COMPLETE_ROUTE_SUBPATH, FILE_CONTENT_ROUTE_SUBPATH, FILE_STAT_ROUTE_SUBPATH, FILE_UPLOAD_SESSION_ROUTE_SUBPATH, FLOW_RUN_EGRESS_GRANT_ROUTE_SUBPATH, FLOW_RUN_EXECUTION_EVENTS_ROUTE_SUBPATH, FLOW_RUN_EXECUTION_EVENT_TYPES, FLOW_RUN_RESULT_ROUTE_SUBPATH, FLOW_RUN_RUNTIME_CREDENTIAL_ROUTE_SUBPATH, type FileMetadataData, type FileRefData, type FileRuntimeLimits, type FileRuntimeScope, type FileRuntimeScopeKind, type FileUploadSessionData, type FlowActionGrantBody, type FlowExecutionContextFileRuntime, type FlowExecutionScope, type FlowRunExecutionEventBody, type FlowRunExecutionEventData, type FlowRunExecutionEventType, type FlowRunInputFactBody, type FlowRunResultData, type FlowRunResultRequestBody, type FlowRuntimeCredentialBody, type FlowWaitResolvedEvent, type GenerationCallbackErrorCode, HANDLER_BUNDLES_ROUTE_SUBPATH, HANDSHAKE_CAPABILITY_MISSING, HANDSHAKE_CONTRACT_VERSION_MISMATCH, HANDSHAKE_DISPATCH_NAMESPACE_MISMATCH, HANDSHAKE_REQUEST_INVALID, HANDSHAKE_SECRET_MISMATCH, HANDSHAKE_SECRET_UNCONFIGURED, HUMAN_INPUTS_ROUTE_SUBPATH, HUMAN_INPUT_ACKNOWLEDGE_ROUTE_SUBPATH, HUMAN_INPUT_CANCELLED_BY_RESET, HUMAN_INPUT_EXPIRE_ROUTE_SUBPATH, HUMAN_INPUT_PROMPT_BODY_MAX_CODE_POINTS, HUMAN_INPUT_PROMPT_TITLE_MAX_CODE_POINTS, HUMAN_INPUT_REQUEST_ROUTE_SUBPATH, HUMAN_INPUT_RESOLVED_EVENT_PREFIX, type HandlerBundle, type HandlerBundleModule, type HandlerBundlesData, type HandlerBundlesParseResult, type HumanInputActor, type HumanInputOutput, type HumanInputRequestView, type HumanInputResolvedEvent, type HumanInputResponse, INBOX_MESSAGE_EMISSION_ROUTE_SUBPATH, INBOX_MESSAGE_EXECUTION_ERROR_REGISTRY, INTERNAL_DISCOVERY_INVOCATIONS_ROUTE_PREFIX, INTERNAL_EGRESS_GRANTS_ROUTE_PREFIX, INTERNAL_FILES_ROUTE_PREFIX, INTERNAL_FLOW_RUNS_ROUTE_PREFIX, INTERNAL_FLOW_VERSIONS_ROUTE_PREFIX, INTERNAL_INSTALLATIONS_ROUTE_PREFIX, INTERNAL_POLLING_TRIGGER_INSTANCES_ROUTE_PREFIX, INTERNAL_TOOL_INVOCATIONS_ROUTE_PREFIX, INTERNAL_WEBHOOK_TRIGGER_INSTANCES_ROUTE_PREFIX, type InboxMessageExecutionErrorCode, type IntegrationDiscoverySubject, type InternalFileAccessData, type InternalFileAccessIntent, POLLING_TRIGGER_CONTEXT_ROUTE_SUBPATH, POLLING_TRIGGER_EGRESS_GRANT_ROUTE_SUBPATH, POLLING_TRIGGER_HANDLER_BUNDLES_ROUTE_SUBPATH, POLLING_TRIGGER_RUNTIME_CREDENTIAL_ROUTE_SUBPATH, POLLING_TRIGGER_TICK_EVENTS_ROUTE_SUBPATH, type PackageInputDiscoveryDescriptor, type PackageInputDiscoveryKind, type PackagePollingTriggerRuntimeDescriptor, type PackageTriggerFileOutput, type PackageWebhookTriggerRuntimeDescriptor, type ParsedFlowRunResultBody, type PartiallyRenderedHumanInputDelivery, type PartiallyRenderedMapping, type PartiallyRenderedTemplatePart, type PartiallyRenderedValue, type PollingPublishBody, type PollingPublishEvent, type PollingRuntimeCredentialBody, type PollingTriggerContext, type PollingTriggerDispatchData, type PollingTriggerGrantBody, type PresignedFileUrlData, type PublishPollingTickEventResult, type PublishPollingTickEventsData, REGISTER_EVENT_WAIT_ROUTE_SUBPATH, RUNTIME_CREDENTIAL_SESSION_SCOPE_KINDS, RUN_DISPATCH_UNAVAILABLE, type RegisterFlowRunWaitBody, type RegisterFlowRunWaitData, type RenderedHumanInputPrompt, type RuntimeCredentialSession, type RuntimeCredentialSessionNetwork, type RuntimeCredentialSessionScopeKind, type RuntimeNetwork, type RuntimeNetworkModel, SERVER_EXECUTION_CONTRACT_VERSION, STEP_RESULT_ROUTE_SUBPATH, type ServerExecutionContractVersion, type ServerExecutionError, type ServerExecutionErrorEnvelope, type SingleToolGrantBody, type StepRecordBody, type StepRecordBodyParseResult, type StepRecordData, type StepRecordResult, TOOL_HANDLER_BUNDLES_ROUTE_SUBPATH, TOOL_INVOCATION_EGRESS_GRANT_ROUTE_SUBPATH, TOOL_INVOCATION_RUNTIME_CREDENTIAL_ROUTE_SUBPATH, type ToolHandlerBundlesData, type TriggerConnectionInfo, type TriggerFileRuntimeDispatch, type TriggerHandlerBundlesData, type TriggerHandlerModule, WAIT_EXECUTION_SUPERSEDED, WEBHOOK_PROTOCOL_ADAPTER_BUNDLE_ROUTE_SUBPATH, WEBHOOK_PROTOCOL_ADAPTER_MODULE, WEBHOOK_TRIGGER_CONTEXT_ROUTE_SUBPATH, WEBHOOK_TRIGGER_DELIVERY_ROUTE_SUBPATH, WEBHOOK_TRIGGER_EGRESS_GRANT_ROUTE_SUBPATH, WEBHOOK_TRIGGER_EVENTS_ROUTE_SUBPATH, WEBHOOK_TRIGGER_HANDLER_BUNDLES_ROUTE_SUBPATH, WEBHOOK_TRIGGER_REARM_ROUTE_SUBPATH, WEBHOOK_TRIGGER_RUNTIME_CREDENTIAL_ROUTE_SUBPATH, WFP_USER_RUNTIME_MANIFEST_FORMAT_VERSION, WFP_USER_RUNTIME_UNKNOWN_SOURCE_REVISION, WORKFLOW_RESTART_INSTANCE_UNAVAILABLE, WORKFLOW_RESTART_REJECTED, WORKFLOW_RESTART_REQUEST_INVALID, WORKFLOW_RESTART_ROUTE, type WebhookDelivery, type WebhookDeliveryDispatchData, type WebhookProtocolAdapterBundleData, type WebhookProtocolAdapterModule, type WebhookPublishEvent, type WebhookPublishEventsBody, type WebhookPublishEventsData, type WebhookRearmBody, type WebhookRearmData, type WebhookRuntimeCredentialBody, type WebhookTriggerGrantBody, type WebhookTriggerVerificationMethod, type WebhookWatcherContext, type WfpUserRuntimeManifest, type WorkflowDispatchRestartRequest, type WorkflowDispatchRestartResponse, type WorkflowRestartErrorCode, acquireExecutionLeasePath, completeEventWaitPath, deploymentHandshakeProbePayload, deploymentHandshakeResponseProofPayload, discoveryInvocationEgressGrantPath, discoveryInvocationRuntimeCredentialPath, egressGrantAuditPath, egressGrantConsumePath, executionContextPath, flowRunEgressGrantPath, flowRunExecutionEventsPath, flowRunResultPath, flowRunRuntimeCredentialPath, flowScriptProtocolAdapterModuleName, handlerBundlesPath, humanInputAcknowledgePath, humanInputExpirePath, humanInputRequestPath, humanInputResolvedEventType, humanInputsPath, inboxMessageEmissionPath, internalFileAccessPath, internalFileCompletePath, internalFileContentPath, internalFileStatPath, internalFileUploadSessionPath, internalFilesPath, isValidRequestDigest, parseAcquireExecutionLeaseData, parseAcquireExecutionLeaseRequest, parseCompleteFlowRunWaitBody, parseCompleteFlowRunWaitData, parseContextStateCleanupRequestBody, parseContextStateCleanupResponseData, parseContextStateScope, parseCreateHumanInputBody, parseDiscoveryGrantBody, parseDiscoveryRuntimeCredentialBody, parseEgressGrantAuditBody, parseEgressGrantConsumeBody, parseEgressGrantConsumeData, parseEgressGrantData, parseEmitInboxMessageData, parseEmitInboxMessageRequest, parseExecutionAnchor, parseExecutionContextData, parseExecutionLease, parseExecutionWriteScope, parseFileMetadataData, parseFileRefData, parseFileRuntimeLimits, parseFileUploadSessionData, parseFlowActionGrantBody, parseFlowExecutionScope, parseFlowRunExecutionEventBody, parseFlowRunExecutionEventData, parseFlowRunResultBody, parseFlowRunResultData, parseFlowRuntimeCredentialBody, parseFlowWaitResolvedEvent, parseHandlerBundle, parseHandlerBundlesData, parseHumanInputAcknowledgeData, parseHumanInputCreateData, parseHumanInputRequestViewData, parseHumanInputResolvedEvent, parseHumanInputResponse, parseHumanInputResponseForSpec, parseHumanInputSpec, parseInternalFileAccessData, parsePollingPublishBody, parsePollingRuntimeCredentialBody, parsePollingTriggerContext, parsePollingTriggerDispatchData, parsePollingTriggerGrantBody, parsePublishPollingTickEventsData, parseRegisterFlowRunWaitBody, parseRegisterFlowRunWaitData, parseRenderedHumanInputPrompt, parseRuntimeCredentialSessionCredential, parseRuntimeNetwork, parseServerExecutionErrorEnvelope, parseSingleToolGrantBody, parseSingleToolRuntimeCredentialBody, parseStepRecordBody, parseStepRecordData, parseToolHandlerBundlesData, parseTriggerFileRuntimeDispatch, parseTriggerHandlerBundlesData, parseWebhookDelivery, parseWebhookDeliveryDispatchData, parseWebhookPublishEventsBody, parseWebhookRearmBody, parseWebhookRuntimeCredentialBody, parseWebhookTriggerGrantBody, parseWebhookWatcherContext, parseWorkflowDispatchRestartRequest, parseWorkflowDispatchRestartResponse, pollingTriggerContextPath, pollingTriggerEgressGrantPath, pollingTriggerHandlerBundlesPath, pollingTriggerRuntimeCredentialPath, pollingTriggerTickEventsPath, registerEventWaitPath, requestHasMultipartFileParts, stepResultPath, toolHandlerBundlesPath, toolInvocationEgressGrantPath, toolInvocationRuntimeCredentialPath, webhookProtocolAdapterBundlePath, webhookTriggerContextPath, webhookTriggerDeliveryPath, webhookTriggerEgressGrantPath, webhookTriggerEventsPath, webhookTriggerHandlerBundlesPath, webhookTriggerRearmPath, webhookTriggerRuntimeCredentialPath, wfpUserRuntimeManifestPath };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var de="0.3.0";function u(e){return{ok:!0,value:e}}function r(e){return{ok:!1,reason:e}}function i(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var dt="/cleanup-state-scopes";function x(e){if(!i(e)||typeof e.kind!="string")return r("context state scope surface shape is invalid");switch(e.kind){case"webhook-trigger":return pe(e);case"polling-trigger":return le(e);case"flow-action":return fe(e);default:return r("context state scope kind is invalid")}}function pt(e){if(!i(e))return r("cleanup request body must be a JSON object");let t=U(e,["scopes"]);if(t!==void 0)return r(`cleanup request does not accept the "${t}" field`);if(!Array.isArray(e.scopes))return r("cleanup request scopes must be an array");let n=[];for(let o of e.scopes){let s=x(o);if(!s.ok)return s;n.push(s.value)}return u({scopes:n})}function lt(e){return!i(e)||typeof e.deleted!="number"||!Number.isSafeInteger(e.deleted)||e.deleted<0?r("cleanup response data surface shape is invalid"):u({deleted:e.deleted})}function pe(e){let t=U(e,["kind","workspaceId","triggerInstanceId"]);return t!==void 0?r(`webhook trigger scope does not accept "${t}"`):e.kind!=="webhook-trigger"||!E(e.workspaceId)||!E(e.triggerInstanceId)?r("webhook trigger state scope is invalid"):u({kind:"webhook-trigger",workspaceId:e.workspaceId,triggerInstanceId:e.triggerInstanceId})}function le(e){let t=U(e,["kind","workspaceId","pollingInstanceId"]);return t!==void 0?r(`polling trigger scope does not accept "${t}"`):e.kind!=="polling-trigger"||!E(e.workspaceId)||!E(e.pollingInstanceId)?r("polling trigger state scope is invalid"):u({kind:"polling-trigger",workspaceId:e.workspaceId,pollingInstanceId:e.pollingInstanceId})}function fe(e){let t=U(e,["kind","workspaceId","flowId","nodeId","connectionId"]);if(t!==void 0)return r(`flow action scope does not accept "${t}"`);let n=e.connectionId;return e.kind!=="flow-action"||!E(e.workspaceId)||!E(e.flowId)||!E(e.nodeId)||n!==null&&!E(n)?r("flow action state scope is invalid"):u({kind:"flow-action",workspaceId:e.workspaceId,flowId:e.flowId,nodeId:e.nodeId,connectionId:n})}function E(e){return typeof e=="string"&&e.length>0}function U(e,t){return Object.keys(e).find(n=>!t.includes(n))}import{parseFlowDefinition as Ie}from"@ablehi/flow-contract";var mt="/:flowRunId/execution-leases",It="/restart",yt="WORKFLOW_RESTART_REQUEST_INVALID",kt="WORKFLOW_RESTART_INSTANCE_UNAVAILABLE",Et="WORKFLOW_RESTART_REJECTED",_t="RUN_DISPATCH_UNAVAILABLE",xt="EXECUTION_LEASE_INVALID",ht="EXECUTION_LEASE_SUPERSEDED",wt="WAIT_EXECUTION_SUPERSEDED",Tt="HUMAN_INPUT_CANCELLED_BY_RESET";function St(e){return`${g}/${encodeURIComponent(e)}/execution-leases`}var ge=/^generation:[A-Za-z0-9][A-Za-z0-9._:-]{0,239}$/;function Y(e){return!i(e)||!y(e,e.kind==="standalone"?["kind"]:["kind","productRunId"])?r("execution scope shape is invalid"):e.kind==="standalone"?u({kind:"standalone"}):e.kind==="automation_app"&&I(e.productRunId)?u({kind:"automation_app",productRunId:e.productRunId}):r("execution scope discriminator is invalid")}function Q(e){return i(e)?e.kind==="terminal"&&y(e,["kind"])?u({kind:"terminal"}):e.kind==="node"&&y(e,["kind","nodeId"])&&I(e.nodeId)?u({kind:"node",nodeId:e.nodeId}):r("execution anchor shape is invalid"):r("execution anchor must be an object")}function Re(e){if(!i(e)||!y(e,["productRunId","flowRunId","generationId","generationNumber","anchor","leaseId"])||!I(e.productRunId)||!I(e.flowRunId)||!I(e.generationId)||!me(e.generationNumber)||!I(e.leaseId))return r("execution lease shape is invalid");let t=Q(e.anchor);return t.ok?u({productRunId:e.productRunId,flowRunId:e.flowRunId,generationId:e.generationId,generationNumber:e.generationNumber,anchor:t.value,leaseId:e.leaseId}):r(t.reason)}function k(e){if(!i(e))return r("execution write scope must be an object");if(e.kind==="standalone"&&y(e,["kind"]))return u({kind:"standalone"});if(e.kind==="automation_app"&&y(e,["kind","lease"])){let t=Re(e.lease);return t.ok?u({kind:"automation_app",lease:t.value}):r(t.reason)}return r("execution write scope shape is invalid")}function Pt(e){if(!i(e)||!y(e,["anchor"]))return r("lease request shape is invalid");let t=Q(e.anchor);return t.ok?u({anchor:t.value}):r(t.reason)}function At(e){if(!i(e)||!y(e,["executionScope"]))return r("lease response shape is invalid");let t=k(e.executionScope);return t.ok?u({executionScope:t.value}):r(t.reason)}function Ct(e){return!i(e)||!y(e,["instanceId","flowRunId","commandId","generationId","from"])||!I(e.instanceId)||!I(e.flowRunId)||!I(e.commandId)||!I(e.generationId)||!i(e.from)||!y(e.from,["name","count","type"])||typeof e.from.name!="string"||!ge.test(e.from.name)||e.from.name==="generation:terminal"||e.from.count!==1||e.from.type!=="do"?r("restart request shape is invalid"):u(e)}function bt(e){return!i(e)||!y(e,["ok","data"])||e.ok!==!0||!i(e.data)||!y(e.data,["accepted","instanceId","commandId","generationId"])||e.data.accepted!==!0||!I(e.data.instanceId)||!I(e.data.commandId)||!I(e.data.generationId)?r("restart response shape is invalid"):u(e)}function y(e,t){let n=Object.keys(e).sort(),o=[...t].sort();return n.length===o.length&&n.every((s,a)=>s===o[a])}function I(e){return typeof e=="string"&&e.length>0}function me(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0}var g="/internal/flow-runs",Ft="/:flowRunId/execution-context";function Bt(e){return`${g}/${encodeURIComponent(e)}/execution-context`}function $(e){return!i(e)||!L(e.fileMaxBytes)||!L(e.fileReadMaxBytes)||!L(e.inlineMultipartBytesMax)?r("file runtime limits must carry three positive integer bounds"):u({fileMaxBytes:e.fileMaxBytes,fileReadMaxBytes:e.fileReadMaxBytes,inlineMultipartBytesMax:e.inlineMultipartBytesMax})}function Ht(e){if(!i(e))return r("execution context must be a JSON object");let t=z(e,["flowRunId","workspaceId","input","executionScope","compiled","executionBindings","fileRuntime"]);if(t!==void 0)return r(`execution context does not accept the "${t}" field`);let n=e.compiled;if(typeof e.flowRunId!="string"||typeof e.workspaceId!="string"||!i(e.input)||!i(n)||z(n,["irSchemaVersion","interpreterContractVersion","ir","compiledArtifactId"])!==void 0||typeof n.irSchemaVersion!="string"||typeof n.interpreterContractVersion!="string"||typeof n.compiledArtifactId!="string"||!ke(e.executionBindings))return r("execution context surface shape is invalid");let o=Ie(n.ir);if(!o.ok)return r(o.reason);let s=Y(e.executionScope);if(!s.ok)return r(s.reason);let a=ye(e.fileRuntime);return a.ok?u({...e,compiled:{...n,ir:o.value},executionScope:s.value,fileRuntime:a.value}):r(a.reason)}function ye(e){if(e===null)return u(null);if(!i(e))return r("fileRuntime must be null or an object");let t=$(e.limits);return t.ok?u({limits:t.value}):r(t.reason)}function ke(e){return Array.isArray(e)?e.every(t=>{if(!i(t))return!1;let n=t.connection,o=x(t.stateScope);return typeof t.nodeId=="string"&&typeof t.toolRef=="string"&&i(t.toolDescriptor)&&i(t.integrationDescriptor)&&i(n)&&typeof n.installationId=="string"&&typeof n.connectionRef=="string"&&typeof n.connectionId=="string"&&typeof n.authProfileRef=="string"&&typeof n.authType=="string"&&o.ok}):!1}function L(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0}function z(e,t){return Object.keys(e).find(n=>!t.includes(n))}import{parseAblehiErrorDigest as W}from"@ablehi/error-contract";var qt="/:flowRunId/steps/:nodeId/result",Mt="/:flowRunId/result",Vt="/:flowRunId/execution-events",jt="/:flowRunId/waits/:nodeId/register",Xt="/:flowRunId/waits/:nodeId/complete";function Jt(e,t){return`${g}/${encodeURIComponent(e)}/steps/${encodeURIComponent(t)}/result`}function Yt(e){return`${g}/${encodeURIComponent(e)}/result`}function Qt(e){return`${g}/${encodeURIComponent(e)}/execution-events`}function zt(e,t){return`${g}/${encodeURIComponent(e)}/waits/${encodeURIComponent(t)}/register`}function Zt(e,t){return`${g}/${encodeURIComponent(e)}/waits/${encodeURIComponent(t)}/complete`}function en(e){if(!i(e))return{ok:!1,kind:"validation",reason:"step record body must be a JSON object"};let t=R(e,["executionScope","attempt","result","durationMs"]);if(t!==void 0)return{ok:!1,kind:"validation",reason:`step record does not accept the "${t}" field`};let n=k(e.executionScope);if(!n.ok)return{ok:!1,kind:"validation",reason:n.reason};let o=e.attempt;if(typeof o!="number"||!Number.isInteger(o)||o<=0)return{ok:!1,kind:"validation",reason:"attempt must be a positive integer"};let s=Ee(e.result);if(!s.ok)return s;let a={executionScope:n.value,attempt:o,result:s.value};if(e.durationMs!==void 0){let c=e.durationMs;if(typeof c!="number"||!Number.isFinite(c)||c<0)return{ok:!1,kind:"validation",reason:"durationMs must be a non-negative number"};a.durationMs=c}return{ok:!0,value:a}}function Ee(e){if(!i(e))return{ok:!1,kind:"step_result_invalid",reason:"result must be a JSON object"};let t=e.status;if(t==="succeeded"){let n=R(e,["status","output"]);return n!==void 0?{ok:!1,kind:"validation",reason:`step record result does not accept the "${n}" field`}:"output"in e?{ok:!0,value:{status:"succeeded",output:e.output}}:{ok:!1,kind:"step_result_invalid",reason:"a succeeded result must carry output"}}if(t==="failed"){let n=R(e,["status","error"]);if(n!==void 0)return{ok:!1,kind:"validation",reason:`step record result does not accept the "${n}" field`};let o=W(e.error);return o.ok?{ok:!0,value:{status:"failed",error:o.value}}:{ok:!1,kind:"step_result_invalid",reason:`a failed result must carry an AblehiErrorDigest: ${o.reason}`}}if(t==="skipped"){let n=R(e,["status","reason"]);return n!==void 0?{ok:!1,kind:"validation",reason:`step record result does not accept the "${n}" field`}:e.reason!=="run_if_false"?{ok:!1,kind:"step_result_invalid",reason:'a skipped result reason must be "run_if_false"'}:{ok:!0,value:{status:"skipped",reason:"run_if_false"}}}if(t==="timed_out"){let n=R(e,["status","error"]);if(n!==void 0)return{ok:!1,kind:"validation",reason:`step record result does not accept the "${n}" field`};let o=W(e.error);return o.ok?{ok:!0,value:{status:"timed_out",error:o.value}}:{ok:!1,kind:"step_result_invalid",reason:`a timed_out result must carry an AblehiErrorDigest: ${o.reason}`}}return{ok:!1,kind:"step_result_invalid",reason:'result status must be "succeeded", "failed", "skipped", or "timed_out"'}}function tn(e){return!i(e)||typeof e.flowRunId!="string"||typeof e.nodeId!="string"||!_e(e.recorded)?r("step record data surface shape is invalid"):u({flowRunId:e.flowRunId,nodeId:e.nodeId,recorded:e.recorded})}function _e(e){return e==="succeeded"||e==="failed"||e==="skipped"||e==="timed_out"}function nn(e){if(!i(e))return r("result body must be a JSON object");let t=R(e,["executionScope","status","output","error"]);if(t!==void 0)return r(`result does not accept the "${t}" field`);let n=k(e.executionScope);if(!n.ok)return r(n.reason);let o=e.status;if(o!=="succeeded"&&o!=="failed")return r('result status must be "succeeded" or "failed"');let s={executionScope:n.value,status:o};if(e.output!==void 0){if(o!=="succeeded")return r("output is only allowed on a succeeded result");s.output=e.output}if(e.error!==void 0){if(o!=="failed")return r("error is only allowed on a failed result");let a=W(e.error);if(!a.ok)return r(`result error must be an AblehiErrorDigest: ${a.reason}`);s.error=a.value}return o==="failed"&&s.error===void 0?r("a failed result must carry an AblehiErrorDigest"):u(s)}function rn(e){return i(e)?u(e):r("flow run result data must be a JSON object")}var xe=["flow_run_started","step_started","step_retry_scheduled","wait_registered","wait_event_received","wait_event_timed_out","human_input_created","human_input_submitted","human_input_expired","flow_run_succeeded","flow_run_failed","flow_run_interrupted","flow_run_cancelled"];function on(e){if(!i(e))return r("execution event data must be a JSON object");let t=R(e,["flowRunId","eventId","accepted"]);return t!==void 0?r(`execution event data does not accept the "${t}" field`):typeof e.flowRunId!="string"||e.flowRunId.length===0?r("flowRunId must be a non-empty string"):typeof e.eventId!="string"||e.eventId.length===0?r("eventId must be a non-empty string"):e.accepted!==!0?r("accepted must be true"):u({flowRunId:e.flowRunId,eventId:e.eventId,accepted:!0})}function sn(e){if(!i(e))return r("execution event body must be a JSON object");let t=R(e,["executionScope","eventId","eventType","nodeId","stepRunId","attempt","durationMs","occurredAt","errorId","payloadRef","inputFact"]);if(t!==void 0)return r(`execution event does not accept the "${t}" field`);let n=k(e.executionScope);if(!n.ok)return r(n.reason);let o=e.eventId;if(typeof o!="string"||o.length===0)return r("eventId must be a non-empty string");let s=e.eventType;if(!he(s))return r("eventType is not a known flow execution event type");let a=e.occurredAt;if(typeof a!="string"||a.length===0)return r("occurredAt must be a non-empty string");let c={executionScope:n.value,eventId:o,eventType:s,occurredAt:a};for(let d of["nodeId","stepRunId","errorId","payloadRef"]){let f=e[d];if(f!==void 0){if(typeof f!="string"||f.length===0)return r(`${d} must be a non-empty string`);c[d]=f}}for(let d of["attempt","durationMs"]){let f=e[d];if(f!==void 0){if(typeof f!="number"||!Number.isFinite(f)||!Number.isInteger(f)||f<0)return r(`${d} must be a non-negative integer`);c[d]=f}}if(e.inputFact!==void 0){if(s!=="step_started")return r("inputFact is only allowed on step_started events");if(c.attempt===void 0)return r("inputFact requires attempt");let d=we(e.inputFact);if(!d.ok)return d;c.inputFact=d.value}return u(c)}function he(e){return typeof e=="string"&&xe.includes(e)}function we(e){if(!i(e))return r("inputFact must be a JSON object");let t=R(e,["digestAlgorithm","digest","domain"]);if(t!==void 0)return r(`inputFact does not accept the "${t}" field`);if(e.digestAlgorithm!=="sha256")return r('inputFact.digestAlgorithm must be "sha256"');let n=e.digest;if(typeof n!="string"||!/^[0-9a-f]{64}$/.test(n))return r("inputFact.digest must be a sha256 hex string");let o=e.domain;if(!i(o))return r("inputFact.domain must be a JSON object");let s=R(o,["irSchemaVersion","interpreterContractVersion","compiledArtifactId","nodeId","algorithmVersion"]);return s!==void 0?r(`inputFact.domain does not accept the "${s}" field`):typeof o.irSchemaVersion!="string"||o.irSchemaVersion.length===0||typeof o.interpreterContractVersion!="string"||o.interpreterContractVersion.length===0||typeof o.compiledArtifactId!="string"||o.compiledArtifactId.length===0||typeof o.nodeId!="string"||o.nodeId.length===0?r("inputFact.domain string fields must be non-empty strings"):o.algorithmVersion!=="flow_input_digest.v1"?r('inputFact.domain.algorithmVersion must be "flow_input_digest.v1"'):u({digestAlgorithm:"sha256",digest:n,domain:{irSchemaVersion:o.irSchemaVersion,interpreterContractVersion:o.interpreterContractVersion,compiledArtifactId:o.compiledArtifactId,nodeId:o.nodeId,algorithmVersion:"flow_input_digest.v1"}})}var Te=/^[A-Za-z0-9_-]{1,100}$/;function un(e){if(!i(e))return r("register body must be a JSON object");let t=R(e,["executionScope","eventType","correlationKey"]);if(t!==void 0)return r(`register wait does not accept the "${t}" field`);let n=k(e.executionScope);if(!n.ok)return r(n.reason);let o=Z(e.eventType);if(!o.ok)return r(o.reason);let s=e.correlationKey;return typeof s!="string"||s.length===0?r("correlationKey must be a non-empty string"):u({executionScope:n.value,eventType:o.value,correlationKey:s})}function an(e){if(!i(e))return r("complete body must be a JSON object");let t=R(e,["executionScope","waitExecutionId","outcome","eventId"]);if(t!==void 0)return r(`complete wait does not accept the "${t}" field`);let n=k(e.executionScope);if(!n.ok)return r(n.reason);let o=e.waitExecutionId;if(typeof o!="string"||o.length===0)return r("waitExecutionId must be a non-empty string");let s=e.outcome;if(s!=="received"&&s!=="timed_out")return r('outcome must be "received" or "timed_out"');let a={executionScope:n.value,waitExecutionId:o,outcome:s};if(e.eventId!==void 0){if(typeof e.eventId!="string"||e.eventId.length===0)return r("eventId must be a non-empty string");a.eventId=e.eventId}return u(a)}function cn(e){if(!i(e)||R(e,["waitExecutionId","workflowEventType"])!==void 0||typeof e.waitExecutionId!="string"||e.waitExecutionId.length===0)return r("register wait data surface shape is invalid");let t=Z(e.workflowEventType);return t.ok?u({waitExecutionId:e.waitExecutionId,workflowEventType:t.value}):r(t.reason)}function dn(e){return!i(e)||R(e,["completed"])!==void 0||e.completed!==!0?r("complete wait data surface shape is invalid"):u({completed:!0})}function pn(e){return!i(e)||R(e,["waitExecutionId","eventId","payload"])!==void 0||typeof e.waitExecutionId!="string"||e.waitExecutionId.length===0||typeof e.eventId!="string"||e.eventId.length===0||!Object.hasOwn(e,"payload")?r("Wait resolved event surface shape is invalid"):u({waitExecutionId:e.waitExecutionId,eventId:e.eventId,payload:e.payload})}function Z(e){return typeof e!="string"||e.length===0?r("eventType must be a non-empty string"):Te.test(e)?u(e):r("eventType must match ^[A-Za-z0-9_-]{1,100}$")}function R(e,t){return Object.keys(e).find(n=>!t.includes(n))}var Se="/internal/flow-versions",fn="/:flowVersionId/handler-bundles",K="/internal/installations",gn="/:installationId/handler-bundles";function Rn(e,t){return`${Se}/${encodeURIComponent(e)}/handler-bundles?compiledArtifactId=${encodeURIComponent(t)}`}function mn(e){return`${K}/${encodeURIComponent(e.installationId)}/handler-bundles?workspaceId=${encodeURIComponent(e.workspaceId)}&artifactDigest=${encodeURIComponent(e.artifactDigest)}`}var Pe=new Set(["managed_only","managed_plus_unmanaged_sdk"]);function F(e){if(!h(e))return G("runtimeNetwork must be a JSON object");let t=e.networkModel;return typeof t!="string"||!Pe.has(t)?G("runtimeNetwork.networkModel is unknown"):!ee(e.apiHosts)||!ee(e.authHosts)||typeof e.httpsOnly!="boolean"?G("runtimeNetwork host/https fields are invalid"):{ok:!0,value:{networkModel:t,apiHosts:e.apiHosts,authHosts:e.authHosts,httpsOnly:e.httpsOnly}}}function In(e){if(!h(e)||typeof e.flowVersionId!="string"||typeof e.compiledArtifactId!="string"||!Array.isArray(e.bundles))return A("handler bundles data surface shape is invalid");let t=te(e.bundles);return t.ok?{ok:!0,value:{flowVersionId:e.flowVersionId,compiledArtifactId:e.compiledArtifactId,bundles:t.value}}:t}function yn(e){if(!h(e)||typeof e.installationId!="string"||typeof e.artifactDigest!="string"||!Array.isArray(e.bundles))return A("tool handler bundles data surface shape is invalid");let t=te(e.bundles);return t.ok?{ok:!0,value:{installationId:e.installationId,artifactDigest:e.artifactDigest,bundles:t.value}}:t}function te(e){let t=[];for(let n of e){let o=Ae(n);if(!o.ok)return o;t.push(o.value)}return{ok:!0,value:t}}function Ae(e){if(!h(e)||typeof e.toolRef!="string"||e.kind!=="handler"&&e.kind!=="request")return A("handler bundle entry shape is invalid");if(e.kind==="request"){if(e.module!==void 0)return A("a request bundle must not carry a module");let o=F(e.runtimeNetwork);return o.ok?{ok:!0,value:{toolRef:e.toolRef,kind:"request",runtimeNetwork:o.value}}:o}let t=e.module;if(!h(t)||typeof t.entry!="string"||t.entry.length===0||!Ce(t.files))return A("a handler bundle must carry a { entry, files } module");let n=F(e.runtimeNetwork);return n.ok?{ok:!0,value:{toolRef:e.toolRef,kind:"handler",module:{entry:t.entry,files:t.files},runtimeNetwork:n.value}}:n}function A(e){return{ok:!1,kind:"shape",reason:e}}function G(e){return{ok:!1,kind:"runtime_network",reason:e}}function h(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ee(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function Ce(e){return h(e)&&Object.values(e).every(t=>typeof t=="string")}var C="/internal/webhook-trigger-instances",Tn="/:triggerInstanceId/context",Sn="/:triggerInstanceId/handler-bundles",Pn="/:triggerInstanceId/deliveries/:deliveryId",An="/:triggerInstanceId/events",Cn="/:triggerInstanceId/rearm",b=e=>`${C}/${encodeURIComponent(e)}`;function bn(e,t){return`${b(e)}/context?artifactDigest=${encodeURIComponent(t)}`}function Nn(e,t){return`${b(e)}/handler-bundles?artifactDigest=${encodeURIComponent(t)}`}function vn(e,t){return`${b(e)}/deliveries/${encodeURIComponent(t)}`}function On(e){return`${b(e)}/events`}function Dn(e){return`${b(e)}/rearm`}var Un="/:installationId/webhook-protocol-adapter-bundle";function Fn(e){return`${K}/${encodeURIComponent(e.installationId)}/webhook-protocol-adapter-bundle?workspaceId=${encodeURIComponent(e.workspaceId)}&artifactDigest=${encodeURIComponent(e.artifactDigest)}`}var Bn="modules/webhook/protocol-adapter.js";function Hn(e){return`modules/webhook/protocol-adapter-${e}.js`}function Ln(e){let t=i(e)?x(e.stateScope):r("webhook watcher context state scope is invalid");return!i(e)||typeof e.artifactDigest!="string"||typeof e.triggerRef!="string"||typeof e.triggerName!="string"||typeof e.integrationRef!="string"||!i(e.inputs)||e.connection!==null&&!be(e.connection)||!Ne(e.runtime)||!t.ok||t.value.kind!=="webhook-trigger"?r("webhook watcher context surface shape is invalid"):u(e)}function be(e){return i(e)&&typeof e.connectionId=="string"&&typeof e.connectionRef=="string"&&typeof e.integrationRef=="string"&&typeof e.authProfileRef=="string"&&typeof e.authType=="string"}function Ne(e){if(!i(e)||e.type!=="webhook"||typeof e.trigger_ref!="string")return!1;let t=e.webhook;return i(t)&&typeof t.event_handler_module=="string"&&typeof t.enable_handler_module=="string"&&typeof t.disable_handler_module=="string"}function ve(e){if(!i(e)||typeof e.deliveryId!="string"||typeof e.receivedAt!="string"||!i(e.request))return r("webhook delivery surface shape is invalid");let t=e.request;return t.method!=="POST"||!i(t.headers)||typeof t.rawBody!="string"?r("webhook delivery request shape is invalid"):u(e)}function q(e){if(!i(e)||typeof e.token!="string"||typeof e.expiresAt!="string")return r("trigger file runtime dispatch shape is invalid");let t=$(e.limits);return t.ok?u({token:e.token,expiresAt:e.expiresAt,limits:t.value}):r(t.reason)}function $n(e){if(!i(e))return r("webhook delivery dispatch data is invalid");let t=ve(e.delivery);if(!t.ok)return r(t.reason);let n=e.fileRuntime;if(n===null)return u({delivery:t.value,fileRuntime:null});let o=q(n);return o.ok?u({delivery:t.value,fileRuntime:o.value}):r(o.reason)}function Wn(e){if(!i(e)||typeof e.triggerRef!="string"||typeof e.artifactDigest!="string"||!Array.isArray(e.modules)||!e.modules.every(Oe))return{ok:!1,kind:"shape",reason:"trigger handler bundles data surface shape is invalid"};let t=F(e.runtimeNetwork);return t.ok?{ok:!0,value:{triggerRef:e.triggerRef,artifactDigest:e.artifactDigest,modules:e.modules,runtimeNetwork:t.value}}:t}function Oe(e){return i(e)&&typeof e.specifier=="string"&&e.specifier.length>0&&typeof e.source=="string"}function Gn(e){if(!i(e))return r("publish events body must be a JSON object");let t=M(e,["deliveryId","events"]);if(t!==void 0)return r(`publish events does not accept the "${t}" field`);let n=e.deliveryId;if(typeof n!="string"||n.length===0)return r("deliveryId must be a non-empty string");let o=e.events;if(!Array.isArray(o))return r("events must be an array");let s=[];for(let a of o){let c=De(a);if(!c.ok)return c;s.push(c.value)}return u({deliveryId:n,events:s})}function De(e){if(!i(e))return r("each event must be a JSON object");let t=M(e,["eventId","occurredAt","dedupeKey","payload"]);if(t!==void 0)return r(`event does not accept the "${t}" field`);let n=e.eventId;if(typeof n!="string"||n.length===0)return r("eventId must be a non-empty string");let o=e.occurredAt;if(typeof o!="string"||o.length===0)return r("occurredAt must be a non-empty string");if(!i(e.payload))return r("event payload must be a JSON object");let s={eventId:n,occurredAt:o,payload:e.payload};if(e.dedupeKey!==void 0){if(typeof e.dedupeKey!="string"||e.dedupeKey.length===0)return r("dedupeKey must be a non-empty string");s.dedupeKey=e.dedupeKey}return u(s)}function Kn(e){if(!i(e))return r("rearm body must be a JSON object");let t=M(e,["expectedWatcherInstanceId"]);if(t!==void 0)return r(`rearm does not accept the "${t}" field`);let n=e.expectedWatcherInstanceId;return typeof n!="string"||n.length===0?r("expectedWatcherInstanceId must be a non-empty string"):u({expectedWatcherInstanceId:n})}function M(e,t){return Object.keys(e).find(n=>!t.includes(n))}var N="/internal/polling-trigger-instances",Xn="/:pollingInstanceId/context",Jn="/:pollingInstanceId/handler-bundles",Yn="/:pollingInstanceId/ticks/:tickId/events",V=e=>`${N}/${encodeURIComponent(e)}`;function Qn(e,t,n){return`${V(e)}/context?artifactDigest=${encodeURIComponent(t)}&tickId=${encodeURIComponent(n)}`}function zn(e,t){return`${V(e)}/handler-bundles?artifactDigest=${encodeURIComponent(t)}`}function Zn(e,t){return`${V(e)}/ticks/${encodeURIComponent(t)}/events`}function Ue(e){let t=i(e)?x(e.stateScope):r("polling trigger context state scope is invalid");return!i(e)||typeof e.artifactDigest!="string"||typeof e.triggerRef!="string"||typeof e.triggerName!="string"||typeof e.integrationRef!="string"||!i(e.inputs)||e.connection!==null&&!Fe(e.connection)||!Be(e.runtime)||!t.ok||t.value.kind!=="polling-trigger"||!Le(e.tick)||!$e(e.limits)?r("polling trigger context surface shape is invalid"):u(e)}function er(e){if(!i(e))return r("polling trigger dispatch data is invalid");let t=Ue(e.context);if(!t.ok)return r(t.reason);let n=e.fileRuntime;if(n===null)return u({context:t.value,fileRuntime:null});let o=q(n);return o.ok?u({context:t.value,fileRuntime:o.value}):r(o.reason)}function Fe(e){return i(e)&&typeof e.connectionId=="string"&&typeof e.connectionRef=="string"&&typeof e.integrationRef=="string"&&typeof e.authProfileRef=="string"&&typeof e.authType=="string"}function Be(e){if(!i(e)||e.type!=="polling"||typeof e.trigger_id!="string"||typeof e.trigger_ref!="string"||!He(e.file_outputs))return!1;let t=e.polling;if(!i(t)||typeof t.run_handler_module!="string")return!1;let n=t.schedule;if(!i(n)||n.type!=="interval"||typeof n.every_seconds!="number")return!1;let o=t.dedup;return i(o)&&(o.strategy==="cursor"||o.strategy==="hash"||o.strategy==="id_field")}function He(e){return e===void 0?!0:Array.isArray(e)&&e.length>0&&e.every(t=>i(t)&&typeof t.field=="string"&&t.field.length>0)}function Le(e){return i(e)&&typeof e.tickId=="string"&&typeof e.scheduledAt=="string"&&typeof e.attempt=="number"}function $e(e){return i(e)&&typeof e.maxEventsPerTick=="number"}function tr(e){if(!i(e))return r("publish body must be a JSON object");let t=ne(e,["events","nextCursor"]);if(t!==void 0)return r(`publish does not accept the "${t}" field`);let n=e.events;if(!Array.isArray(n))return r("events must be an array");let o=[];for(let a of n){let c=We(a);if(!c.ok)return c;o.push(c.value)}let s={events:o};if("nextCursor"in e){let a=e.nextCursor;if(a!==null&&typeof a!="string")return r("nextCursor must be a string, null, or omitted");s.nextCursor=a}return u(s)}function We(e){if(!i(e))return r("each event must be a JSON object");let t=ne(e,["eventId","occurredAt","dedupeKey","payload"]);if(t!==void 0)return r(`event does not accept the "${t}" field`);if(typeof e.eventId!="string"||e.eventId.length===0)return r("event eventId must be a non-empty string");if(!i(e.payload))return r("event payload must be a JSON object");let n={eventId:e.eventId,payload:e.payload};if(e.occurredAt!==void 0){if(typeof e.occurredAt!="string"||e.occurredAt.length===0)return r("event occurredAt must be a non-empty string");n.occurredAt=e.occurredAt}if(e.dedupeKey!==void 0){if(typeof e.dedupeKey!="string"||e.dedupeKey.length===0)return r("event dedupeKey must be a non-empty string");n.dedupeKey=e.dedupeKey}return u(n)}function nr(e){return!i(e)||typeof e.tickId!="string"||typeof e.cursorUpdated!="boolean"||!Array.isArray(e.results)||!e.results.every(Ge)?r("publish polling tick events data surface shape is invalid"):u(e)}function Ge(e){return i(e)&&typeof e.eventId=="string"&&typeof e.dedupeKey=="string"&&typeof e.duplicate=="boolean"&&(e.flowRunId===null||typeof e.flowRunId=="string")}function ne(e,t){return Object.keys(e).find(n=>!t.includes(n))}var re="/internal/egress-grants",j="/internal/tool-invocations",X="/internal/discovery-invocations",ar="/:flowRunId/egress-grant",cr="/:invocationId/egress-grant",dr="/:discoveryInvocationId/egress-grant",pr="/:pollingInstanceId/egress-grant",lr="/:triggerInstanceId/egress-grant",fr="/:grantId/consume",gr="/:grantId/audit",Rr=e=>`${g}/${encodeURIComponent(e)}/egress-grant`,mr=e=>`${j}/${encodeURIComponent(e)}/egress-grant`,Ir=e=>`${X}/${encodeURIComponent(e)}/egress-grant`,yr=e=>`${N}/${encodeURIComponent(e)}/egress-grant`,kr=e=>`${C}/${encodeURIComponent(e)}/egress-grant`,Er=e=>`${re}/${encodeURIComponent(e)}/consume`,_r=e=>`${re}/${encodeURIComponent(e)}/audit`,Ke=["flow_action","single_tool","discovery","polling_trigger","webhook_trigger"],qe=/^[A-Za-z0-9][A-Za-z0-9:_+/=.-]{15,1023}$/;function w(e){return typeof e=="string"&&qe.test(e)}function Me(e){if(!i(e)||e.body_type!=="multipart")return!1;let t=e.body;if(!i(t))return!1;let n=t.parts;return Array.isArray(n)?n.some(o=>i(o)?o.kind==="file"&&typeof o.file_id=="string"&&o.file_id.length>0:!1):!1}function p(e){return{ok:!1,kind:"shape",reason:e}}function T(){return{ok:!1,kind:"request_digest",reason:"request digest is missing or malformed"}}function v(e,t){if(!i(e))return{ok:!1,reason:"grant request body must be a JSON object"};for(let n of Object.keys(e))if(!t.includes(n))return{ok:!1,reason:`grant request does not accept the "${n}" field`};return{ok:!0,record:e}}function O(e){if(!i(e))return"request must be a JSON object"}function xr(e){let t=v(e,["nodeId","request","requestDigest"]);if(!t.ok)return p(t.reason);let n=t.record.nodeId;if(typeof n!="string"||n.length===0)return p("nodeId is required");let o=O(t.record.request);if(o!==void 0)return p(o);let s=t.record.requestDigest;return w(s)?{ok:!0,value:{nodeId:n,requestDigest:s,requestHasMultipartFiles:Me(t.record.request)}}:T()}function hr(e){let t=v(e,["request","requestDigest"]);if(!t.ok)return p(t.reason);let n=O(t.record.request);if(n!==void 0)return p(n);let o=t.record.requestDigest;return w(o)?{ok:!0,value:{requestDigest:o}}:T()}function wr(e){let t=v(e,["request","requestDigest"]);if(!t.ok)return p(t.reason);let n=O(t.record.request);if(n!==void 0)return p(n);let o=t.record.requestDigest;return w(o)?{ok:!0,value:{requestDigest:o}}:T()}function Tr(e){let t=v(e,["tickId","request","requestDigest"]);if(!t.ok)return p(t.reason);let n=t.record.tickId;if(typeof n!="string"||n.length===0)return p("tickId is required");let o=O(t.record.request);if(o!==void 0)return p(o);let s=t.record.requestDigest;return w(s)?{ok:!0,value:{tickId:n,requestDigest:s}}:T()}function Sr(e){let t=v(e,["phase","lifecycle","deliveryId","request","requestDigest"]);if(!t.ok)return p(t.reason);let n=t.record.phase;if(n!=="lifecycle"&&n!=="handler")return p('phase must be "lifecycle" or "handler"');let o=t.record.lifecycle,s;if(o!==void 0){if(o!=="enable"&&o!=="disable"&&o!=="renew")return p('lifecycle must be "enable", "disable", or "renew"');s=o}if(n==="lifecycle"&&s===void 0)return p("lifecycle is required for the lifecycle phase");let a=t.record.deliveryId,c;if(a!==void 0){if(typeof a!="string"||a.length===0)return p("deliveryId must be a non-empty string");c=a}if(n==="handler"&&c===void 0)return p("deliveryId is required for the handler phase");let d=O(t.record.request);if(d!==void 0)return p(d);let f=t.record.requestDigest;return w(f)?{ok:!0,value:{phase:n,...s!==void 0?{lifecycle:s}:{},...c!==void 0?{deliveryId:c}:{},requestDigest:f}}:T()}function oe(e){return Ke.includes(e)?e:void 0}var Ve=["scopeKind","scopeId","requestDigest"];function Pr(e){if(!i(e))return p("consume body must be a JSON object");for(let s of Object.keys(e))if(!Ve.includes(s))return p(`consume does not accept the "${s}" field`);let t=oe(e.scopeKind);if(t===void 0)return p("scopeKind is invalid");let n=e.scopeId;if(typeof n!="string"||n.length===0)return p("scopeId is required");let o=e.requestDigest;return w(o)?{ok:!0,value:{scopeKind:t,scopeId:n,requestDigest:o}}:T()}var je=["scopeKind","scopeId","providerHost","status","durationMs","requestBytes","responseBytes","errorCode"];function B(e,t){return typeof e!="number"||!Number.isInteger(e)||e<0?{ok:!1,reason:`${t} must be a non-negative integer`}:{ok:!0,value:e}}function Ar(e){if(!i(e))return p("audit body must be a JSON object");for(let l of Object.keys(e))if(!je.includes(l))return p(`audit does not accept the "${l}" field`);let t=oe(e.scopeKind);if(t===void 0)return p("scopeKind is invalid");let n=e.scopeId;if(typeof n!="string"||n.length===0)return p("scopeId is required");let o=e.providerHost;if(typeof o!="string"||o.length===0)return p("providerHost is required");let s=B(e.durationMs,"durationMs");if(!s.ok)return p(s.reason);let a;if(e.status!==void 0){let l=B(e.status,"status");if(!l.ok)return p(l.reason);a=l.value}let c;if(e.requestBytes!==void 0){let l=B(e.requestBytes,"requestBytes");if(!l.ok)return p(l.reason);c=l.value}let d;if(e.responseBytes!==void 0){let l=B(e.responseBytes,"responseBytes");if(!l.ok)return p(l.reason);d=l.value}let f;if(e.errorCode!==void 0){let l=e.errorCode;if(typeof l!="string"||l.length===0)return p("errorCode must be a non-empty string");f=l}return{ok:!0,value:{scopeKind:t,scopeId:n,providerHost:o,...a!==void 0?{status:a}:{},durationMs:s.value,...c!==void 0?{requestBytes:c}:{},...d!==void 0?{responseBytes:d}:{},...f!==void 0?{errorCode:f}:{}}}}function Cr(e){return!i(e)||!i(e.grant)?r("egress grant envelope must carry a grant object"):u(e.grant)}function br(e){return!i(e)||e.consumed!==!0?r("egress grant consume data must carry consumed:true"):u({consumed:!0})}var Br="/:flowRunId/runtime-credential",Hr="/:invocationId/runtime-credential",Lr="/:discoveryInvocationId/runtime-credential",$r="/:pollingInstanceId/runtime-credential",Wr="/:triggerInstanceId/runtime-credential",Gr=e=>`${g}/${encodeURIComponent(e)}/runtime-credential`,Kr=e=>`${j}/${encodeURIComponent(e)}/runtime-credential`,qr=e=>`${X}/${encodeURIComponent(e)}/runtime-credential`,Mr=e=>`${N}/${encodeURIComponent(e)}/runtime-credential`,Vr=e=>`${C}/${encodeURIComponent(e)}/runtime-credential`,jr=["flow_action","tool_invoke","discovery","polling_trigger","webhook_trigger"];function D(e,t){if(!i(e))return{ok:!1,reason:"runtime credential request body must be a JSON object"};for(let n of Object.keys(e))if(!t.includes(n))return{ok:!1,reason:`runtime credential request does not accept the "${n}" field`};return{ok:!0,record:e}}function Xr(e){let t=D(e,["nodeId"]);if(!t.ok)return r(t.reason);let n=t.record.nodeId;return typeof n!="string"||n.length===0?r("nodeId is required"):u({nodeId:n})}function Jr(e){let t=D(e??{},[]);return t.ok?u(null):r(t.reason)}function Yr(e){let t=D(e??{},[]);return t.ok?u(null):r(t.reason)}function Qr(e){let t=D(e,["tickId"]);if(!t.ok)return r(t.reason);let n=t.record.tickId;return typeof n!="string"||n.length===0?r("tickId is required"):u({tickId:n})}function zr(e){let t=D(e,["executionKind","deliveryId","lifecycleOperation"]);if(!t.ok)return r(t.reason);let n=t.record.executionKind;if(n!=="event_handler"&&n!=="lifecycle")return r('executionKind must be "event_handler" or "lifecycle"');let o,s=t.record.deliveryId;if(s!==void 0){if(typeof s!="string"||s.length===0)return r("deliveryId must be a non-empty string");o=s}let a,c=t.record.lifecycleOperation;if(c!==void 0){if(c!=="enable"&&c!=="disable"&&c!=="renew")return r('lifecycleOperation must be "enable", "disable", or "renew"');a=c}return n==="lifecycle"&&a===void 0?r("lifecycleOperation is required for the lifecycle execution kind"):u({executionKind:n,...o!==void 0?{deliveryId:o}:{},...a!==void 0?{lifecycleOperation:a}:{}})}function Zr(e){return!i(e)||typeof e.sessionId!="string"||typeof e.connectionId!="string"||typeof e.authProfileRef!="string"||typeof e.authType!="string"||!i(e.credential)?r("runtime credential session must carry sessionId, connectionId, auth profile facts and a credential object"):u(e.credential)}function H(e){return!i(e)||typeof e.file_id!="string"||typeof e.name!="string"||typeof e.size_bytes!="number"||typeof e.created_at!="string"||typeof e.expires_at!="string"||e.mime_type!==void 0&&typeof e.mime_type!="string"||e.sha256!==void 0&&typeof e.sha256!="string"||e.source!==void 0&&typeof e.source!="string"?r("file ref data does not match the AIS file-ref shape"):u(e)}function J(e){return!i(e)||e.method!=="GET"&&e.method!=="PUT"||typeof e.url!="string"||typeof e.expires_at!="string"||!Ye(e.headers)?r("presigned file URL data is invalid"):u(e)}function Xe(e){if(!i(e))return r("file upload session data is invalid");let t=H(e.file);if(!t.ok)return r(t.reason);let n=J(e.upload);return n.ok?u({file:t.value,upload:n.value}):r(n.reason)}function Je(e){if(!i(e))return r("file metadata data is invalid");let t=H(e.file);return t.ok?u({file:t.value}):r(t.reason)}function Ye(e){return i(e)?Object.values(e).every(t=>typeof t=="string"):!1}var S="/internal/files",io="/upload-session",so="/:fileId/complete",uo="/:fileId/access",ao="/:fileId/stat",co="/:fileId/content",po=()=>S,lo=()=>`${S}/upload-session`,fo=e=>`${S}/${encodeURIComponent(e)}/complete`,go=(e,t)=>`${S}/${encodeURIComponent(e)}/access?intent=${encodeURIComponent(t)}`,ie=e=>`?scope_kind=${encodeURIComponent(e.scopeKind)}&scope_id=${encodeURIComponent(e.scopeId)}`,Ro=(e,t)=>`${S}/${encodeURIComponent(e)}/stat${ie(t)}`,mo=(e,t)=>`${S}/${encodeURIComponent(e)}/content${ie(t)}`;function Io(e){if(!i(e))return r("internal file access data is invalid");if(e.intent==="runtime_read"||e.intent==="provider_multipart"){let t=H(e.file);if(!t.ok)return r(t.reason);let n=J(e.access);return n.ok?u({file:t.value,access:n.value,intent:e.intent}):r(n.reason)}return r("internal file access intent is invalid")}var xo="/:flowRunId/human-inputs",ho="/:flowRunId/human-inputs/:requestId",wo="/:flowRunId/human-inputs/:requestId/expire",To="/:flowRunId/human-inputs/:requestId/acknowledge",Qe=e=>`${g}/${encodeURIComponent(e)}/human-inputs`,se=(e,t)=>`${Qe(e)}/${encodeURIComponent(t)}`,So=(e,t)=>`${se(e,t)}/expire`,Po=(e,t)=>`${se(e,t)}/acknowledge`,ze="human_input_resolved";function Ao(e){return`${ze}_${e}`}function Co(e){return!i(e)||Object.keys(e).length!==4||!Object.hasOwn(e,"requestId")||!Object.hasOwn(e,"flowRunId")||!Object.hasOwn(e,"nodeId")||!Object.hasOwn(e,"status")||typeof e.requestId!="string"||e.requestId.length===0||typeof e.flowRunId!="string"||e.flowRunId.length===0||typeof e.nodeId!="string"||e.nodeId.length===0||e.status!=="submitted"&&e.status!=="expired"?r("Human Input resolved event shape is invalid"):u({requestId:e.requestId,flowRunId:e.flowRunId,nodeId:e.nodeId,status:e.status})}function m(e){return{ok:!1,reason:e}}function _(e,t){return i(e)?{ok:!0,value:e}:m(`${t} must be an object`)}function P(e,t){return typeof e!="string"||e.length===0?m(`${t} must be a non-empty string`):{ok:!0,value:e}}var Ze=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?(?:Z|[+-]\d{2}:\d{2})$/;function et(e,t){return typeof e!="string"||!Ze.test(e)||Number.isNaN(Date.parse(e))?m(`${t} must be an ISO-8601 timestamp`):{ok:!0,value:e}}function tt(e){let t=_(e,"renderedPrompt");if(!t.ok)return t;let n=P(t.value.title,"renderedPrompt.title");if(!n.ok)return n;let o={title:n.value};if(t.value.body!==void 0){if(typeof t.value.body!="string")return m("renderedPrompt.body must be a string");o.body=t.value.body}if(t.value.format!==void 0){if(t.value.format!=="plain"&&t.value.format!=="markdown")return m("renderedPrompt.format is invalid");o.format=t.value.format}return{ok:!0,value:o}}function nt(e){let t=_(e,"input");if(!t.ok)return t;let n=t.value.kind;if(n==="choice"){if(!Array.isArray(t.value.choices))return m("input.choices must be an array")}else if(n!=="text")if(n==="form"){if(!Array.isArray(t.value.fields))return m("input.fields must be an array")}else return m("input.kind is invalid");return{ok:!0,value:t.value}}function rt(e){if(e==null)return{ok:!0,value:void 0};let t=_(e,"partiallyRenderedDelivery");if(!t.ok)return t;let n=t.value.actions;if(n===void 0)return{ok:!0,value:{}};if(!Array.isArray(n))return m("partiallyRenderedDelivery.actions must be an array");let o=[];for(let s of n){let a=_(s,"delivery action");if(!a.ok)return a;let c=P(a.value.id,"delivery action id");if(!c.ok)return c;let d=ue(a.value.inputs,`delivery action '${c.value}' inputs`);if(!d.ok)return d;o.push({id:c.value,inputs:d.value})}return{ok:!0,value:{actions:o}}}function ue(e,t){let n=_(e,t);if(!n.ok)return n;let o={};for(let[s,a]of Object.entries(n.value)){let c=ae(a,`${t}.${s}`);if(!c.ok)return c;o[s]=c.value}return{ok:!0,value:o}}function ae(e,t){let n=_(e,t);if(!n.ok)return n;switch(n.value.kind){case"literal":return{ok:!0,value:{kind:"literal",value:n.value.value}};case"human_input_ref":{let s=P(n.value.path,`${t}.path`);return s.ok?{ok:!0,value:{kind:"human_input_ref",path:s.value}}:s}case"array":{if(!Array.isArray(n.value.items))return m(`${t}.items must be an array`);let s=[];for(let[a,c]of n.value.items.entries()){let d=ae(c,`${t}[${a}]`);if(!d.ok)return d;s.push(d.value)}return{ok:!0,value:{kind:"array",items:s}}}case"object":{let s=ue(n.value.entries,`${t}.entries`);return s.ok?{ok:!0,value:{kind:"object",entries:s.value}}:s}case"template":{if(!Array.isArray(n.value.parts))return m(`${t}.parts must be an array`);let s=[];for(let[a,c]of n.value.parts.entries()){let d=ot(c,`${t}.parts[${a}]`);if(!d.ok)return d;s.push(d.value)}return{ok:!0,value:{kind:"template",parts:s}}}default:return m(`${t}.kind is invalid`)}}function ot(e,t){let n=_(e,t);if(!n.ok)return n;let o=n.value.kind;if(o==="literal")return typeof n.value.value!="string"?m(`${t}.value must be a string`):{ok:!0,value:{kind:"literal",value:n.value.value}};if(o==="human_input_ref"){let s=P(n.value.path,`${t}.path`);return s.ok?{ok:!0,value:{kind:"human_input_ref",path:s.value}}:s}return m(`${t}.kind is invalid`)}function bo(e){let t=_(e,"request body");if(!t.ok)return r(t.reason);let n=Object.keys(t.value).find(ce=>!["executionScope","nodeId","renderedPrompt","input","partiallyRenderedDelivery","timeout","expiresAt"].includes(ce));if(n!==void 0)return r(`human input body does not accept the "${n}" field`);let o=k(t.value.executionScope);if(!o.ok)return r(o.reason);let s=P(t.value.nodeId,"nodeId");if(!s.ok)return r(s.reason);let a=tt(t.value.renderedPrompt);if(!a.ok)return r(a.reason);let c=nt(t.value.input);if(!c.ok)return r(c.reason);let d=P(t.value.timeout,"timeout");if(!d.ok)return r(d.reason);let f=et(t.value.expiresAt,"expiresAt");if(!f.ok)return r(f.reason);let l=rt(t.value.partiallyRenderedDelivery);return l.ok?u({executionScope:o.value,nodeId:s.value,renderedPrompt:a.value,input:c.value,timeout:d.value,expiresAt:f.value,...l.value!==void 0?{partiallyRenderedDelivery:l.value}:{}}):r(l.reason)}function it(e){return!i(e)||typeof e.id!="string"||e.id.length===0||typeof e.nodeId!="string"||typeof e.status!="string"||!(e.output===null||i(e.output))?r("human input request view must carry id, nodeId, status and output"):u(e)}function No(e){if(!i(e)||typeof e.created!="boolean")return r("human input create data must carry created:boolean");let t=it(e.request);return t.ok?u({created:e.created,request:t.value}):t}function vo(e){return!i(e)||e.acknowledged!==!0?r("human input acknowledge data must carry acknowledged:true"):u({acknowledged:!0})}var Do="ablehi-wfp-user-runtime-manifest/v1",Uo="unknown";function Fo(e){return e.endsWith(".js")?`${e.slice(0,-3)}.manifest.json`:`${e}.manifest.json`}var Ho="/internal/deployment-handshake",st=["start","terminate","send-event","start-webhook-watcher","run-polling-tick","invoke-tool","invoke-discovery","invoke-trigger-handler","invoke-webhook-protocol-adapter","deployment-handshake"],Lo=st,$o="HANDSHAKE_REQUEST_INVALID",Wo="HANDSHAKE_SECRET_UNCONFIGURED",Go="HANDSHAKE_SECRET_MISMATCH",Ko="HANDSHAKE_CONTRACT_VERSION_MISMATCH",qo="HANDSHAKE_DISPATCH_NAMESPACE_MISMATCH",Mo="HANDSHAKE_CAPABILITY_MISSING";function Vo(e){return[e.nonce,e.timestamp,e.contractVersion,e.dispatchNamespace].map(n=>`${n.length}:${n}`).join(".")}function jo(e){return["response",e.nonce,e.contractVersion,e.dispatchNamespace,...e.capabilities].map(n=>`${n.length}:${n}`).join(".")}export{Xt as COMPLETE_EVENT_WAIT_ROUTE_SUBPATH,dt as CONTEXT_STATE_CLEANUP_ROUTE_PATH,st as DEPLOYMENT_HANDSHAKE_DISPATCHER_CAPABILITIES,Lo as DEPLOYMENT_HANDSHAKE_REQUIRED_CAPABILITIES,Ho as DEPLOYMENT_HANDSHAKE_ROUTE,dr as DISCOVERY_INVOCATION_EGRESS_GRANT_ROUTE_SUBPATH,Lr as DISCOVERY_INVOCATION_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,gr as EGRESS_GRANT_AUDIT_ROUTE_SUBPATH,fr as EGRESS_GRANT_CONSUME_ROUTE_SUBPATH,Ke as EGRESS_GRANT_SCOPE_KINDS,Ft as EXECUTION_CONTEXT_ROUTE_SUBPATH,xt as EXECUTION_LEASE_INVALID,mt as EXECUTION_LEASE_ROUTE_SUBPATH,ht as EXECUTION_LEASE_SUPERSEDED,uo as FILE_ACCESS_ROUTE_SUBPATH,so as FILE_COMPLETE_ROUTE_SUBPATH,co as FILE_CONTENT_ROUTE_SUBPATH,ao as FILE_STAT_ROUTE_SUBPATH,io as FILE_UPLOAD_SESSION_ROUTE_SUBPATH,ar as FLOW_RUN_EGRESS_GRANT_ROUTE_SUBPATH,Vt as FLOW_RUN_EXECUTION_EVENTS_ROUTE_SUBPATH,xe as FLOW_RUN_EXECUTION_EVENT_TYPES,Mt as FLOW_RUN_RESULT_ROUTE_SUBPATH,Br as FLOW_RUN_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,fn as HANDLER_BUNDLES_ROUTE_SUBPATH,Mo as HANDSHAKE_CAPABILITY_MISSING,Ko as HANDSHAKE_CONTRACT_VERSION_MISMATCH,qo as HANDSHAKE_DISPATCH_NAMESPACE_MISMATCH,$o as HANDSHAKE_REQUEST_INVALID,Go as HANDSHAKE_SECRET_MISMATCH,Wo as HANDSHAKE_SECRET_UNCONFIGURED,xo as HUMAN_INPUTS_ROUTE_SUBPATH,To as HUMAN_INPUT_ACKNOWLEDGE_ROUTE_SUBPATH,Tt as HUMAN_INPUT_CANCELLED_BY_RESET,wo as HUMAN_INPUT_EXPIRE_ROUTE_SUBPATH,ho as HUMAN_INPUT_REQUEST_ROUTE_SUBPATH,ze as HUMAN_INPUT_RESOLVED_EVENT_PREFIX,X as INTERNAL_DISCOVERY_INVOCATIONS_ROUTE_PREFIX,re as INTERNAL_EGRESS_GRANTS_ROUTE_PREFIX,S as INTERNAL_FILES_ROUTE_PREFIX,g as INTERNAL_FLOW_RUNS_ROUTE_PREFIX,Se as INTERNAL_FLOW_VERSIONS_ROUTE_PREFIX,K as INTERNAL_INSTALLATIONS_ROUTE_PREFIX,N as INTERNAL_POLLING_TRIGGER_INSTANCES_ROUTE_PREFIX,j as INTERNAL_TOOL_INVOCATIONS_ROUTE_PREFIX,C as INTERNAL_WEBHOOK_TRIGGER_INSTANCES_ROUTE_PREFIX,Xn as POLLING_TRIGGER_CONTEXT_ROUTE_SUBPATH,pr as POLLING_TRIGGER_EGRESS_GRANT_ROUTE_SUBPATH,Jn as POLLING_TRIGGER_HANDLER_BUNDLES_ROUTE_SUBPATH,$r as POLLING_TRIGGER_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,Yn as POLLING_TRIGGER_TICK_EVENTS_ROUTE_SUBPATH,jt as REGISTER_EVENT_WAIT_ROUTE_SUBPATH,jr as RUNTIME_CREDENTIAL_SESSION_SCOPE_KINDS,_t as RUN_DISPATCH_UNAVAILABLE,de as SERVER_EXECUTION_CONTRACT_VERSION,qt as STEP_RESULT_ROUTE_SUBPATH,gn as TOOL_HANDLER_BUNDLES_ROUTE_SUBPATH,cr as TOOL_INVOCATION_EGRESS_GRANT_ROUTE_SUBPATH,Hr as TOOL_INVOCATION_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,wt as WAIT_EXECUTION_SUPERSEDED,Un as WEBHOOK_PROTOCOL_ADAPTER_BUNDLE_ROUTE_SUBPATH,Bn as WEBHOOK_PROTOCOL_ADAPTER_MODULE,Tn as WEBHOOK_TRIGGER_CONTEXT_ROUTE_SUBPATH,Pn as WEBHOOK_TRIGGER_DELIVERY_ROUTE_SUBPATH,lr as WEBHOOK_TRIGGER_EGRESS_GRANT_ROUTE_SUBPATH,An as WEBHOOK_TRIGGER_EVENTS_ROUTE_SUBPATH,Sn as WEBHOOK_TRIGGER_HANDLER_BUNDLES_ROUTE_SUBPATH,Cn as WEBHOOK_TRIGGER_REARM_ROUTE_SUBPATH,Wr as WEBHOOK_TRIGGER_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,Do as WFP_USER_RUNTIME_MANIFEST_FORMAT_VERSION,Uo as WFP_USER_RUNTIME_UNKNOWN_SOURCE_REVISION,kt as WORKFLOW_RESTART_INSTANCE_UNAVAILABLE,Et as WORKFLOW_RESTART_REJECTED,yt as WORKFLOW_RESTART_REQUEST_INVALID,It as WORKFLOW_RESTART_ROUTE,St as acquireExecutionLeasePath,Zt as completeEventWaitPath,Vo as deploymentHandshakeProbePayload,jo as deploymentHandshakeResponseProofPayload,Ir as discoveryInvocationEgressGrantPath,qr as discoveryInvocationRuntimeCredentialPath,_r as egressGrantAuditPath,Er as egressGrantConsumePath,Bt as executionContextPath,Rr as flowRunEgressGrantPath,Qt as flowRunExecutionEventsPath,Yt as flowRunResultPath,Gr as flowRunRuntimeCredentialPath,Hn as flowScriptProtocolAdapterModuleName,Rn as handlerBundlesPath,Po as humanInputAcknowledgePath,So as humanInputExpirePath,se as humanInputRequestPath,Ao as humanInputResolvedEventType,Qe as humanInputsPath,go as internalFileAccessPath,fo as internalFileCompletePath,mo as internalFileContentPath,Ro as internalFileStatPath,lo as internalFileUploadSessionPath,po as internalFilesPath,w as isValidRequestDigest,At as parseAcquireExecutionLeaseData,Pt as parseAcquireExecutionLeaseRequest,an as parseCompleteFlowRunWaitBody,dn as parseCompleteFlowRunWaitData,pt as parseContextStateCleanupRequestBody,lt as parseContextStateCleanupResponseData,x as parseContextStateScope,bo as parseCreateHumanInputBody,wr as parseDiscoveryGrantBody,Yr as parseDiscoveryRuntimeCredentialBody,Ar as parseEgressGrantAuditBody,Pr as parseEgressGrantConsumeBody,br as parseEgressGrantConsumeData,Cr as parseEgressGrantData,Q as parseExecutionAnchor,Ht as parseExecutionContextData,Re as parseExecutionLease,k as parseExecutionWriteScope,Je as parseFileMetadataData,H as parseFileRefData,$ as parseFileRuntimeLimits,Xe as parseFileUploadSessionData,xr as parseFlowActionGrantBody,Y as parseFlowExecutionScope,sn as parseFlowRunExecutionEventBody,on as parseFlowRunExecutionEventData,nn as parseFlowRunResultBody,rn as parseFlowRunResultData,Xr as parseFlowRuntimeCredentialBody,pn as parseFlowWaitResolvedEvent,Ae as parseHandlerBundle,In as parseHandlerBundlesData,vo as parseHumanInputAcknowledgeData,No as parseHumanInputCreateData,it as parseHumanInputRequestViewData,Co as parseHumanInputResolvedEvent,Io as parseInternalFileAccessData,tr as parsePollingPublishBody,Qr as parsePollingRuntimeCredentialBody,Ue as parsePollingTriggerContext,er as parsePollingTriggerDispatchData,Tr as parsePollingTriggerGrantBody,nr as parsePublishPollingTickEventsData,un as parseRegisterFlowRunWaitBody,cn as parseRegisterFlowRunWaitData,Zr as parseRuntimeCredentialSessionCredential,F as parseRuntimeNetwork,hr as parseSingleToolGrantBody,Jr as parseSingleToolRuntimeCredentialBody,en as parseStepRecordBody,tn as parseStepRecordData,yn as parseToolHandlerBundlesData,q as parseTriggerFileRuntimeDispatch,Wn as parseTriggerHandlerBundlesData,ve as parseWebhookDelivery,$n as parseWebhookDeliveryDispatchData,Gn as parseWebhookPublishEventsBody,Kn as parseWebhookRearmBody,zr as parseWebhookRuntimeCredentialBody,Sr as parseWebhookTriggerGrantBody,Ln as parseWebhookWatcherContext,Ct as parseWorkflowDispatchRestartRequest,bt as parseWorkflowDispatchRestartResponse,Qn as pollingTriggerContextPath,yr as pollingTriggerEgressGrantPath,zn as pollingTriggerHandlerBundlesPath,Mr as pollingTriggerRuntimeCredentialPath,Zn as pollingTriggerTickEventsPath,zt as registerEventWaitPath,Me as requestHasMultipartFileParts,Jt as stepResultPath,mn as toolHandlerBundlesPath,mr as toolInvocationEgressGrantPath,Kr as toolInvocationRuntimeCredentialPath,Fn as webhookProtocolAdapterBundlePath,bn as webhookTriggerContextPath,vn as webhookTriggerDeliveryPath,kr as webhookTriggerEgressGrantPath,On as webhookTriggerEventsPath,Nn as webhookTriggerHandlerBundlesPath,Dn as webhookTriggerRearmPath,Vr as webhookTriggerRuntimeCredentialPath,Fo as wfpUserRuntimeManifestPath};
|
|
1
|
+
var Ie="0.4.0";function u(e){return{ok:!0,value:e}}function r(e){return{ok:!1,reason:e}}function s(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var wt="/cleanup-state-scopes";function x(e){if(!s(e)||typeof e.kind!="string")return r("context state scope surface shape is invalid");switch(e.kind){case"webhook-trigger":return ye(e);case"polling-trigger":return Ee(e);case"flow-action":return ke(e);default:return r("context state scope kind is invalid")}}function Tt(e){if(!s(e))return r("cleanup request body must be a JSON object");let t=B(e,["scopes"]);if(t!==void 0)return r(`cleanup request does not accept the "${t}" field`);if(!Array.isArray(e.scopes))return r("cleanup request scopes must be an array");let n=[];for(let o of e.scopes){let i=x(o);if(!i.ok)return i;n.push(i.value)}return u({scopes:n})}function At(e){return!s(e)||typeof e.deleted!="number"||!Number.isSafeInteger(e.deleted)||e.deleted<0?r("cleanup response data surface shape is invalid"):u({deleted:e.deleted})}function ye(e){let t=B(e,["kind","workspaceId","triggerInstanceId"]);return t!==void 0?r(`webhook trigger scope does not accept "${t}"`):e.kind!=="webhook-trigger"||!_(e.workspaceId)||!_(e.triggerInstanceId)?r("webhook trigger state scope is invalid"):u({kind:"webhook-trigger",workspaceId:e.workspaceId,triggerInstanceId:e.triggerInstanceId})}function Ee(e){let t=B(e,["kind","workspaceId","pollingInstanceId"]);return t!==void 0?r(`polling trigger scope does not accept "${t}"`):e.kind!=="polling-trigger"||!_(e.workspaceId)||!_(e.pollingInstanceId)?r("polling trigger state scope is invalid"):u({kind:"polling-trigger",workspaceId:e.workspaceId,pollingInstanceId:e.pollingInstanceId})}function ke(e){let t=B(e,["kind","workspaceId","flowId","nodeId","connectionId"]);if(t!==void 0)return r(`flow action scope does not accept "${t}"`);let n=e.connectionId;return e.kind!=="flow-action"||!_(e.workspaceId)||!_(e.flowId)||!_(e.nodeId)||n!==null&&!_(n)?r("flow action state scope is invalid"):u({kind:"flow-action",workspaceId:e.workspaceId,flowId:e.flowId,nodeId:e.nodeId,connectionId:n})}function _(e){return typeof e=="string"&&e.length>0}function B(e,t){return Object.keys(e).find(n=>!t.includes(n))}import{parseFlowDefinition as Se}from"@ablehi/flow-contract";var Ot="/:flowRunId/execution-leases",Ct="/restart",Dt="WORKFLOW_RESTART_REQUEST_INVALID",vt="WORKFLOW_RESTART_INSTANCE_UNAVAILABLE",Ut="WORKFLOW_RESTART_REJECTED",Bt="RUN_DISPATCH_UNAVAILABLE",Ft="EXECUTION_LEASE_INVALID",Ht="EXECUTION_LEASE_SUPERSEDED",Lt="WAIT_EXECUTION_SUPERSEDED",Mt="HUMAN_INPUT_CANCELLED_BY_RESET";function $t(e){return`${g}/${encodeURIComponent(e)}/execution-leases`}var _e=/^generation:[A-Za-z0-9][A-Za-z0-9._:-]{0,239}$/;function Q(e){return!s(e)||!E(e,e.kind==="standalone"?["kind"]:["kind","productRunId"])?r("execution scope shape is invalid"):e.kind==="standalone"?u({kind:"standalone"}):e.kind==="automation_app"&&y(e.productRunId)?u({kind:"automation_app",productRunId:e.productRunId}):r("execution scope discriminator is invalid")}function Z(e){return s(e)?e.kind==="terminal"&&E(e,["kind"])?u({kind:"terminal"}):e.kind==="node"&&E(e,["kind","nodeId"])&&y(e.nodeId)?u({kind:"node",nodeId:e.nodeId}):r("execution anchor shape is invalid"):r("execution anchor must be an object")}function xe(e){if(!s(e)||!E(e,["productRunId","flowRunId","generationId","generationNumber","anchor","leaseId"])||!y(e.productRunId)||!y(e.flowRunId)||!y(e.generationId)||!he(e.generationNumber)||!y(e.leaseId))return r("execution lease shape is invalid");let t=Z(e.anchor);return t.ok?u({productRunId:e.productRunId,flowRunId:e.flowRunId,generationId:e.generationId,generationNumber:e.generationNumber,anchor:t.value,leaseId:e.leaseId}):r(t.reason)}function k(e){if(!s(e))return r("execution write scope must be an object");if(e.kind==="standalone"&&E(e,["kind"]))return u({kind:"standalone"});if(e.kind==="automation_app"&&E(e,["kind","lease"])){let t=xe(e.lease);return t.ok?u({kind:"automation_app",lease:t.value}):r(t.reason)}return r("execution write scope shape is invalid")}function Wt(e){if(!s(e)||!E(e,["anchor"]))return r("lease request shape is invalid");let t=Z(e.anchor);return t.ok?u({anchor:t.value}):r(t.reason)}function Gt(e){if(!s(e)||!E(e,["executionScope"]))return r("lease response shape is invalid");let t=k(e.executionScope);return t.ok?u({executionScope:t.value}):r(t.reason)}function Kt(e){return!s(e)||!E(e,["instanceId","flowRunId","commandId","generationId","from"])||!y(e.instanceId)||!y(e.flowRunId)||!y(e.commandId)||!y(e.generationId)||!s(e.from)||!E(e.from,["name","count","type"])||typeof e.from.name!="string"||!_e.test(e.from.name)||e.from.name==="generation:terminal"||e.from.count!==1||e.from.type!=="do"?r("restart request shape is invalid"):u(e)}function qt(e){return!s(e)||!E(e,["ok","data"])||e.ok!==!0||!s(e.data)||!E(e.data,["accepted","instanceId","commandId","generationId"])||e.data.accepted!==!0||!y(e.data.instanceId)||!y(e.data.commandId)||!y(e.data.generationId)?r("restart response shape is invalid"):u(e)}function E(e,t){let n=Object.keys(e).sort(),o=[...t].sort();return n.length===o.length&&n.every((i,a)=>i===o[a])}function y(e){return typeof e=="string"&&e.length>0}function he(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0}var g="/internal/flow-runs",zt="/:flowRunId/execution-context";function Qt(e){return`${g}/${encodeURIComponent(e)}/execution-context`}function W(e){return!s(e)||!$(e.fileMaxBytes)||!$(e.fileReadMaxBytes)||!$(e.inlineMultipartBytesMax)?r("file runtime limits must carry three positive integer bounds"):u({fileMaxBytes:e.fileMaxBytes,fileReadMaxBytes:e.fileReadMaxBytes,inlineMultipartBytesMax:e.inlineMultipartBytesMax})}function Zt(e){if(!s(e))return r("execution context must be a JSON object");let t=ee(e,["flowRunId","workspaceId","input","executionScope","compiled","executionBindings","fileRuntime"]);if(t!==void 0)return r(`execution context does not accept the "${t}" field`);let n=e.compiled;if(typeof e.flowRunId!="string"||typeof e.workspaceId!="string"||!s(e.input)||!s(n)||ee(n,["irSchemaVersion","interpreterContractVersion","ir","compiledArtifactId"])!==void 0||typeof n.irSchemaVersion!="string"||typeof n.interpreterContractVersion!="string"||typeof n.compiledArtifactId!="string"||!Te(e.executionBindings))return r("execution context surface shape is invalid");let o=Se(n.ir);if(!o.ok)return r(o.reason);let i=Q(e.executionScope);if(!i.ok)return r(i.reason);let a=we(e.fileRuntime);return a.ok?u({...e,compiled:{...n,ir:o.value},executionScope:i.value,fileRuntime:a.value}):r(a.reason)}function we(e){if(e===null)return u(null);if(!s(e))return r("fileRuntime must be null or an object");let t=W(e.limits);return t.ok?u({limits:t.value}):r(t.reason)}function Te(e){return Array.isArray(e)?e.every(t=>{if(!s(t))return!1;let n=t.connection,o=x(t.stateScope);return typeof t.nodeId=="string"&&typeof t.toolRef=="string"&&s(t.toolDescriptor)&&s(t.integrationDescriptor)&&s(n)&&typeof n.installationId=="string"&&typeof n.connectionRef=="string"&&typeof n.connectionId=="string"&&typeof n.authProfileRef=="string"&&typeof n.authType=="string"&&o.ok}):!1}function $(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0}function ee(e,t){return Object.keys(e).find(n=>!t.includes(n))}import{parseAblehiErrorDigest as G}from"@ablehi/error-contract";var sn="/:flowRunId/steps/:nodeId/result",un="/:flowRunId/result",an="/:flowRunId/execution-events",cn="/:flowRunId/waits/:nodeId/register",dn="/:flowRunId/waits/:nodeId/complete";function pn(e,t){return`${g}/${encodeURIComponent(e)}/steps/${encodeURIComponent(t)}/result`}function ln(e){return`${g}/${encodeURIComponent(e)}/result`}function fn(e){return`${g}/${encodeURIComponent(e)}/execution-events`}function gn(e,t){return`${g}/${encodeURIComponent(e)}/waits/${encodeURIComponent(t)}/register`}function mn(e,t){return`${g}/${encodeURIComponent(e)}/waits/${encodeURIComponent(t)}/complete`}function Rn(e){if(!s(e))return{ok:!1,kind:"validation",reason:"step record body must be a JSON object"};let t=R(e,["executionScope","attempt","result","durationMs"]);if(t!==void 0)return{ok:!1,kind:"validation",reason:`step record does not accept the "${t}" field`};let n=k(e.executionScope);if(!n.ok)return{ok:!1,kind:"validation",reason:n.reason};let o=e.attempt;if(typeof o!="number"||!Number.isInteger(o)||o<=0)return{ok:!1,kind:"validation",reason:"attempt must be a positive integer"};let i=Ae(e.result);if(!i.ok)return i;let a={executionScope:n.value,attempt:o,result:i.value};if(e.durationMs!==void 0){let c=e.durationMs;if(typeof c!="number"||!Number.isFinite(c)||c<0)return{ok:!1,kind:"validation",reason:"durationMs must be a non-negative number"};a.durationMs=c}return{ok:!0,value:a}}function Ae(e){if(!s(e))return{ok:!1,kind:"step_result_invalid",reason:"result must be a JSON object"};let t=e.status;if(t==="succeeded"){let n=R(e,["status","output"]);return n!==void 0?{ok:!1,kind:"validation",reason:`step record result does not accept the "${n}" field`}:"output"in e?{ok:!0,value:{status:"succeeded",output:e.output}}:{ok:!1,kind:"step_result_invalid",reason:"a succeeded result must carry output"}}if(t==="failed"){let n=R(e,["status","error"]);if(n!==void 0)return{ok:!1,kind:"validation",reason:`step record result does not accept the "${n}" field`};let o=G(e.error);return o.ok?{ok:!0,value:{status:"failed",error:o.value}}:{ok:!1,kind:"step_result_invalid",reason:`a failed result must carry an AblehiErrorDigest: ${o.reason}`}}if(t==="skipped"){let n=R(e,["status","reason"]);return n!==void 0?{ok:!1,kind:"validation",reason:`step record result does not accept the "${n}" field`}:e.reason!=="run_if_false"?{ok:!1,kind:"step_result_invalid",reason:'a skipped result reason must be "run_if_false"'}:{ok:!0,value:{status:"skipped",reason:"run_if_false"}}}if(t==="timed_out"){let n=R(e,["status","error"]);if(n!==void 0)return{ok:!1,kind:"validation",reason:`step record result does not accept the "${n}" field`};let o=G(e.error);return o.ok?{ok:!0,value:{status:"timed_out",error:o.value}}:{ok:!1,kind:"step_result_invalid",reason:`a timed_out result must carry an AblehiErrorDigest: ${o.reason}`}}return{ok:!1,kind:"step_result_invalid",reason:'result status must be "succeeded", "failed", "skipped", or "timed_out"'}}function In(e){return!s(e)||typeof e.flowRunId!="string"||typeof e.nodeId!="string"||!Pe(e.recorded)?r("step record data surface shape is invalid"):u({flowRunId:e.flowRunId,nodeId:e.nodeId,recorded:e.recorded})}function Pe(e){return e==="succeeded"||e==="failed"||e==="skipped"||e==="timed_out"}function yn(e){if(!s(e))return r("result body must be a JSON object");let t=R(e,["executionScope","status","output","error"]);if(t!==void 0)return r(`result does not accept the "${t}" field`);let n=k(e.executionScope);if(!n.ok)return r(n.reason);let o=e.status;if(o!=="succeeded"&&o!=="failed")return r('result status must be "succeeded" or "failed"');let i={executionScope:n.value,status:o};if(e.output!==void 0){if(o!=="succeeded")return r("output is only allowed on a succeeded result");i.output=e.output}if(e.error!==void 0){if(o!=="failed")return r("error is only allowed on a failed result");let a=G(e.error);if(!a.ok)return r(`result error must be an AblehiErrorDigest: ${a.reason}`);i.error=a.value}return o==="failed"&&i.error===void 0?r("a failed result must carry an AblehiErrorDigest"):u(i)}function En(e){return s(e)?u(e):r("flow run result data must be a JSON object")}var be=["flow_run_started","step_started","step_retry_scheduled","wait_registered","wait_event_received","wait_event_timed_out","human_input_created","human_input_submitted","human_input_expired","flow_run_succeeded","flow_run_failed","flow_run_interrupted","flow_run_cancelled"];function kn(e){if(!s(e))return r("execution event data must be a JSON object");let t=R(e,["flowRunId","eventId","accepted"]);return t!==void 0?r(`execution event data does not accept the "${t}" field`):typeof e.flowRunId!="string"||e.flowRunId.length===0?r("flowRunId must be a non-empty string"):typeof e.eventId!="string"||e.eventId.length===0?r("eventId must be a non-empty string"):e.accepted!==!0?r("accepted must be true"):u({flowRunId:e.flowRunId,eventId:e.eventId,accepted:!0})}function _n(e){if(!s(e))return r("execution event body must be a JSON object");let t=R(e,["executionScope","eventId","eventType","nodeId","stepRunId","attempt","durationMs","occurredAt","errorId","payloadRef","inputFact"]);if(t!==void 0)return r(`execution event does not accept the "${t}" field`);let n=k(e.executionScope);if(!n.ok)return r(n.reason);let o=e.eventId;if(typeof o!="string"||o.length===0)return r("eventId must be a non-empty string");let i=e.eventType;if(!Ne(i))return r("eventType is not a known flow execution event type");let a=e.occurredAt;if(typeof a!="string"||a.length===0)return r("occurredAt must be a non-empty string");let c={executionScope:n.value,eventId:o,eventType:i,occurredAt:a};for(let d of["nodeId","stepRunId","errorId","payloadRef"]){let l=e[d];if(l!==void 0){if(typeof l!="string"||l.length===0)return r(`${d} must be a non-empty string`);c[d]=l}}for(let d of["attempt","durationMs"]){let l=e[d];if(l!==void 0){if(typeof l!="number"||!Number.isFinite(l)||!Number.isInteger(l)||l<0)return r(`${d} must be a non-negative integer`);c[d]=l}}if(e.inputFact!==void 0){if(i!=="step_started")return r("inputFact is only allowed on step_started events");if(c.attempt===void 0)return r("inputFact requires attempt");let d=Oe(e.inputFact);if(!d.ok)return d;c.inputFact=d.value}return u(c)}function Ne(e){return typeof e=="string"&&be.includes(e)}function Oe(e){if(!s(e))return r("inputFact must be a JSON object");let t=R(e,["digestAlgorithm","digest","domain"]);if(t!==void 0)return r(`inputFact does not accept the "${t}" field`);if(e.digestAlgorithm!=="sha256")return r('inputFact.digestAlgorithm must be "sha256"');let n=e.digest;if(typeof n!="string"||!/^[0-9a-f]{64}$/.test(n))return r("inputFact.digest must be a sha256 hex string");let o=e.domain;if(!s(o))return r("inputFact.domain must be a JSON object");let i=R(o,["irSchemaVersion","interpreterContractVersion","compiledArtifactId","nodeId","algorithmVersion"]);return i!==void 0?r(`inputFact.domain does not accept the "${i}" field`):typeof o.irSchemaVersion!="string"||o.irSchemaVersion.length===0||typeof o.interpreterContractVersion!="string"||o.interpreterContractVersion.length===0||typeof o.compiledArtifactId!="string"||o.compiledArtifactId.length===0||typeof o.nodeId!="string"||o.nodeId.length===0?r("inputFact.domain string fields must be non-empty strings"):o.algorithmVersion!=="flow_input_digest.v1"?r('inputFact.domain.algorithmVersion must be "flow_input_digest.v1"'):u({digestAlgorithm:"sha256",digest:n,domain:{irSchemaVersion:o.irSchemaVersion,interpreterContractVersion:o.interpreterContractVersion,compiledArtifactId:o.compiledArtifactId,nodeId:o.nodeId,algorithmVersion:"flow_input_digest.v1"}})}var Ce=/^[A-Za-z0-9_-]{1,100}$/;function xn(e){if(!s(e))return r("register body must be a JSON object");let t=R(e,["executionScope","eventType","correlationKey"]);if(t!==void 0)return r(`register wait does not accept the "${t}" field`);let n=k(e.executionScope);if(!n.ok)return r(n.reason);let o=te(e.eventType);if(!o.ok)return r(o.reason);let i=e.correlationKey;return typeof i!="string"||i.length===0?r("correlationKey must be a non-empty string"):u({executionScope:n.value,eventType:o.value,correlationKey:i})}function hn(e){if(!s(e))return r("complete body must be a JSON object");let t=R(e,["executionScope","waitExecutionId","outcome","eventId"]);if(t!==void 0)return r(`complete wait does not accept the "${t}" field`);let n=k(e.executionScope);if(!n.ok)return r(n.reason);let o=e.waitExecutionId;if(typeof o!="string"||o.length===0)return r("waitExecutionId must be a non-empty string");let i=e.outcome;if(i!=="received"&&i!=="timed_out")return r('outcome must be "received" or "timed_out"');let a={executionScope:n.value,waitExecutionId:o,outcome:i};if(e.eventId!==void 0){if(typeof e.eventId!="string"||e.eventId.length===0)return r("eventId must be a non-empty string");a.eventId=e.eventId}return u(a)}function Sn(e){if(!s(e)||R(e,["waitExecutionId","workflowEventType"])!==void 0||typeof e.waitExecutionId!="string"||e.waitExecutionId.length===0)return r("register wait data surface shape is invalid");let t=te(e.workflowEventType);return t.ok?u({waitExecutionId:e.waitExecutionId,workflowEventType:t.value}):r(t.reason)}function wn(e){return!s(e)||R(e,["completed"])!==void 0||e.completed!==!0?r("complete wait data surface shape is invalid"):u({completed:!0})}function Tn(e){return!s(e)||R(e,["waitExecutionId","eventId","payload"])!==void 0||typeof e.waitExecutionId!="string"||e.waitExecutionId.length===0||typeof e.eventId!="string"||e.eventId.length===0||!Object.hasOwn(e,"payload")?r("Wait resolved event surface shape is invalid"):u({waitExecutionId:e.waitExecutionId,eventId:e.eventId,payload:e.payload})}function te(e){return typeof e!="string"||e.length===0?r("eventType must be a non-empty string"):Ce.test(e)?u(e):r("eventType must match ^[A-Za-z0-9_-]{1,100}$")}function R(e,t){return Object.keys(e).find(n=>!t.includes(n))}var De="/internal/flow-versions",Pn="/:flowVersionId/handler-bundles",q="/internal/installations",bn="/:installationId/handler-bundles";function Nn(e,t){return`${De}/${encodeURIComponent(e)}/handler-bundles?compiledArtifactId=${encodeURIComponent(t)}`}function On(e){return`${q}/${encodeURIComponent(e.installationId)}/handler-bundles?workspaceId=${encodeURIComponent(e.workspaceId)}&artifactDigest=${encodeURIComponent(e.artifactDigest)}`}var ve=new Set(["managed_only","managed_plus_unmanaged_sdk"]);function F(e){if(!S(e))return K("runtimeNetwork must be a JSON object");let t=e.networkModel;return typeof t!="string"||!ve.has(t)?K("runtimeNetwork.networkModel is unknown"):!ne(e.apiHosts)||!ne(e.authHosts)||typeof e.httpsOnly!="boolean"?K("runtimeNetwork host/https fields are invalid"):{ok:!0,value:{networkModel:t,apiHosts:e.apiHosts,authHosts:e.authHosts,httpsOnly:e.httpsOnly}}}function Cn(e){if(!S(e)||typeof e.flowVersionId!="string"||typeof e.compiledArtifactId!="string"||!Array.isArray(e.bundles))return b("handler bundles data surface shape is invalid");let t=re(e.bundles);return t.ok?{ok:!0,value:{flowVersionId:e.flowVersionId,compiledArtifactId:e.compiledArtifactId,bundles:t.value}}:t}function Dn(e){if(!S(e)||typeof e.installationId!="string"||typeof e.artifactDigest!="string"||!Array.isArray(e.bundles))return b("tool handler bundles data surface shape is invalid");let t=re(e.bundles);return t.ok?{ok:!0,value:{installationId:e.installationId,artifactDigest:e.artifactDigest,bundles:t.value}}:t}function re(e){let t=[];for(let n of e){let o=Ue(n);if(!o.ok)return o;t.push(o.value)}return{ok:!0,value:t}}function Ue(e){if(!S(e)||typeof e.toolRef!="string"||e.kind!=="handler"&&e.kind!=="request")return b("handler bundle entry shape is invalid");if(e.kind==="request"){if(e.module!==void 0)return b("a request bundle must not carry a module");let o=F(e.runtimeNetwork);return o.ok?{ok:!0,value:{toolRef:e.toolRef,kind:"request",runtimeNetwork:o.value}}:o}let t=e.module;if(!S(t)||typeof t.entry!="string"||t.entry.length===0||!Be(t.files))return b("a handler bundle must carry a { entry, files } module");let n=F(e.runtimeNetwork);return n.ok?{ok:!0,value:{toolRef:e.toolRef,kind:"handler",module:{entry:t.entry,files:t.files},runtimeNetwork:n.value}}:n}function b(e){return{ok:!1,kind:"shape",reason:e}}function K(e){return{ok:!1,kind:"runtime_network",reason:e}}function S(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ne(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function Be(e){return S(e)&&Object.values(e).every(t=>typeof t=="string")}var N="/internal/webhook-trigger-instances",Mn="/:triggerInstanceId/context",$n="/:triggerInstanceId/handler-bundles",Wn="/:triggerInstanceId/deliveries/:deliveryId",Gn="/:triggerInstanceId/events",Kn="/:triggerInstanceId/rearm",O=e=>`${N}/${encodeURIComponent(e)}`;function qn(e,t){return`${O(e)}/context?artifactDigest=${encodeURIComponent(t)}`}function Vn(e,t){return`${O(e)}/handler-bundles?artifactDigest=${encodeURIComponent(t)}`}function jn(e,t){return`${O(e)}/deliveries/${encodeURIComponent(t)}`}function Xn(e){return`${O(e)}/events`}function Jn(e){return`${O(e)}/rearm`}var Yn="/:installationId/webhook-protocol-adapter-bundle";function zn(e){return`${q}/${encodeURIComponent(e.installationId)}/webhook-protocol-adapter-bundle?workspaceId=${encodeURIComponent(e.workspaceId)}&artifactDigest=${encodeURIComponent(e.artifactDigest)}`}var Qn="modules/webhook/protocol-adapter.js";function Zn(e){return`modules/webhook/protocol-adapter-${e}.js`}function er(e){let t=s(e)?x(e.stateScope):r("webhook watcher context state scope is invalid");return!s(e)||typeof e.artifactDigest!="string"||typeof e.triggerRef!="string"||typeof e.triggerName!="string"||typeof e.integrationRef!="string"||!s(e.inputs)||e.connection!==null&&!Fe(e.connection)||!He(e.runtime)||!t.ok||t.value.kind!=="webhook-trigger"?r("webhook watcher context surface shape is invalid"):u(e)}function Fe(e){return s(e)&&typeof e.connectionId=="string"&&typeof e.connectionRef=="string"&&typeof e.integrationRef=="string"&&typeof e.authProfileRef=="string"&&typeof e.authType=="string"}function He(e){if(!s(e)||e.type!=="webhook"||typeof e.trigger_ref!="string")return!1;let t=e.webhook;return s(t)&&typeof t.event_handler_module=="string"&&typeof t.enable_handler_module=="string"&&typeof t.disable_handler_module=="string"}function Le(e){if(!s(e)||typeof e.deliveryId!="string"||typeof e.receivedAt!="string"||!s(e.request))return r("webhook delivery surface shape is invalid");let t=e.request;return t.method!=="POST"||!s(t.headers)||typeof t.rawBody!="string"?r("webhook delivery request shape is invalid"):u(e)}function V(e){if(!s(e)||typeof e.token!="string"||typeof e.expiresAt!="string")return r("trigger file runtime dispatch shape is invalid");let t=W(e.limits);return t.ok?u({token:e.token,expiresAt:e.expiresAt,limits:t.value}):r(t.reason)}function tr(e){if(!s(e))return r("webhook delivery dispatch data is invalid");let t=Le(e.delivery);if(!t.ok)return r(t.reason);let n=e.fileRuntime;if(n===null)return u({delivery:t.value,fileRuntime:null});let o=V(n);return o.ok?u({delivery:t.value,fileRuntime:o.value}):r(o.reason)}function nr(e){if(!s(e)||typeof e.triggerRef!="string"||typeof e.artifactDigest!="string"||!Array.isArray(e.modules)||!e.modules.every(Me))return{ok:!1,kind:"shape",reason:"trigger handler bundles data surface shape is invalid"};let t=F(e.runtimeNetwork);return t.ok?{ok:!0,value:{triggerRef:e.triggerRef,artifactDigest:e.artifactDigest,modules:e.modules,runtimeNetwork:t.value}}:t}function Me(e){return s(e)&&typeof e.specifier=="string"&&e.specifier.length>0&&typeof e.source=="string"}function rr(e){if(!s(e))return r("publish events body must be a JSON object");let t=j(e,["deliveryId","events"]);if(t!==void 0)return r(`publish events does not accept the "${t}" field`);let n=e.deliveryId;if(typeof n!="string"||n.length===0)return r("deliveryId must be a non-empty string");let o=e.events;if(!Array.isArray(o))return r("events must be an array");let i=[];for(let a of o){let c=$e(a);if(!c.ok)return c;i.push(c.value)}return u({deliveryId:n,events:i})}function $e(e){if(!s(e))return r("each event must be a JSON object");let t=j(e,["eventId","occurredAt","dedupeKey","payload"]);if(t!==void 0)return r(`event does not accept the "${t}" field`);let n=e.eventId;if(typeof n!="string"||n.length===0)return r("eventId must be a non-empty string");let o=e.occurredAt;if(typeof o!="string"||o.length===0)return r("occurredAt must be a non-empty string");if(!s(e.payload))return r("event payload must be a JSON object");let i={eventId:n,occurredAt:o,payload:e.payload};if(e.dedupeKey!==void 0){if(typeof e.dedupeKey!="string"||e.dedupeKey.length===0)return r("dedupeKey must be a non-empty string");i.dedupeKey=e.dedupeKey}return u(i)}function or(e){if(!s(e))return r("rearm body must be a JSON object");let t=j(e,["expectedWatcherInstanceId"]);if(t!==void 0)return r(`rearm does not accept the "${t}" field`);let n=e.expectedWatcherInstanceId;return typeof n!="string"||n.length===0?r("expectedWatcherInstanceId must be a non-empty string"):u({expectedWatcherInstanceId:n})}function j(e,t){return Object.keys(e).find(n=>!t.includes(n))}var C="/internal/polling-trigger-instances",cr="/:pollingInstanceId/context",dr="/:pollingInstanceId/handler-bundles",pr="/:pollingInstanceId/ticks/:tickId/events",X=e=>`${C}/${encodeURIComponent(e)}`;function lr(e,t,n){return`${X(e)}/context?artifactDigest=${encodeURIComponent(t)}&tickId=${encodeURIComponent(n)}`}function fr(e,t){return`${X(e)}/handler-bundles?artifactDigest=${encodeURIComponent(t)}`}function gr(e,t){return`${X(e)}/ticks/${encodeURIComponent(t)}/events`}function We(e){let t=s(e)?x(e.stateScope):r("polling trigger context state scope is invalid");return!s(e)||typeof e.artifactDigest!="string"||typeof e.triggerRef!="string"||typeof e.triggerName!="string"||typeof e.integrationRef!="string"||!s(e.inputs)||e.connection!==null&&!Ge(e.connection)||!Ke(e.runtime)||!t.ok||t.value.kind!=="polling-trigger"||!Ve(e.tick)||!je(e.limits)?r("polling trigger context surface shape is invalid"):u(e)}function mr(e){if(!s(e))return r("polling trigger dispatch data is invalid");let t=We(e.context);if(!t.ok)return r(t.reason);let n=e.fileRuntime;if(n===null)return u({context:t.value,fileRuntime:null});let o=V(n);return o.ok?u({context:t.value,fileRuntime:o.value}):r(o.reason)}function Ge(e){return s(e)&&typeof e.connectionId=="string"&&typeof e.connectionRef=="string"&&typeof e.integrationRef=="string"&&typeof e.authProfileRef=="string"&&typeof e.authType=="string"}function Ke(e){if(!s(e)||e.type!=="polling"||typeof e.trigger_id!="string"||typeof e.trigger_ref!="string"||!qe(e.file_outputs))return!1;let t=e.polling;if(!s(t)||typeof t.run_handler_module!="string")return!1;let n=t.schedule;if(!s(n)||n.type!=="interval"||typeof n.every_seconds!="number")return!1;let o=t.dedup;return s(o)&&(o.strategy==="cursor"||o.strategy==="hash"||o.strategy==="id_field")}function qe(e){return e===void 0?!0:Array.isArray(e)&&e.length>0&&e.every(t=>s(t)&&typeof t.field=="string"&&t.field.length>0)}function Ve(e){return s(e)&&typeof e.tickId=="string"&&typeof e.scheduledAt=="string"&&typeof e.attempt=="number"}function je(e){return s(e)&&typeof e.maxEventsPerTick=="number"}function Rr(e){if(!s(e))return r("publish body must be a JSON object");let t=oe(e,["events","nextCursor"]);if(t!==void 0)return r(`publish does not accept the "${t}" field`);let n=e.events;if(!Array.isArray(n))return r("events must be an array");let o=[];for(let a of n){let c=Xe(a);if(!c.ok)return c;o.push(c.value)}let i={events:o};if("nextCursor"in e){let a=e.nextCursor;if(a!==null&&typeof a!="string")return r("nextCursor must be a string, null, or omitted");i.nextCursor=a}return u(i)}function Xe(e){if(!s(e))return r("each event must be a JSON object");let t=oe(e,["eventId","occurredAt","dedupeKey","payload"]);if(t!==void 0)return r(`event does not accept the "${t}" field`);if(typeof e.eventId!="string"||e.eventId.length===0)return r("event eventId must be a non-empty string");if(!s(e.payload))return r("event payload must be a JSON object");let n={eventId:e.eventId,payload:e.payload};if(e.occurredAt!==void 0){if(typeof e.occurredAt!="string"||e.occurredAt.length===0)return r("event occurredAt must be a non-empty string");n.occurredAt=e.occurredAt}if(e.dedupeKey!==void 0){if(typeof e.dedupeKey!="string"||e.dedupeKey.length===0)return r("event dedupeKey must be a non-empty string");n.dedupeKey=e.dedupeKey}return u(n)}function Ir(e){return!s(e)||typeof e.tickId!="string"||typeof e.cursorUpdated!="boolean"||!Array.isArray(e.results)||!e.results.every(Je)?r("publish polling tick events data surface shape is invalid"):u(e)}function Je(e){return s(e)&&typeof e.eventId=="string"&&typeof e.dedupeKey=="string"&&typeof e.duplicate=="boolean"&&(e.flowRunId===null||typeof e.flowRunId=="string")}function oe(e,t){return Object.keys(e).find(n=>!t.includes(n))}var ie="/internal/egress-grants",J="/internal/tool-invocations",Y="/internal/discovery-invocations",hr="/:flowRunId/egress-grant",Sr="/:invocationId/egress-grant",wr="/:discoveryInvocationId/egress-grant",Tr="/:pollingInstanceId/egress-grant",Ar="/:triggerInstanceId/egress-grant",Pr="/:grantId/consume",br="/:grantId/audit",Nr=e=>`${g}/${encodeURIComponent(e)}/egress-grant`,Or=e=>`${J}/${encodeURIComponent(e)}/egress-grant`,Cr=e=>`${Y}/${encodeURIComponent(e)}/egress-grant`,Dr=e=>`${C}/${encodeURIComponent(e)}/egress-grant`,vr=e=>`${N}/${encodeURIComponent(e)}/egress-grant`,Ur=e=>`${ie}/${encodeURIComponent(e)}/consume`,Br=e=>`${ie}/${encodeURIComponent(e)}/audit`,Ye=["flow_action","single_tool","discovery","polling_trigger","webhook_trigger"],ze=/^[A-Za-z0-9][A-Za-z0-9:_+/=.-]{15,1023}$/;function w(e){return typeof e=="string"&&ze.test(e)}function Qe(e){if(!s(e)||e.body_type!=="multipart")return!1;let t=e.body;if(!s(t))return!1;let n=t.parts;return Array.isArray(n)?n.some(o=>s(o)?o.kind==="file"&&typeof o.file_id=="string"&&o.file_id.length>0:!1):!1}function p(e){return{ok:!1,kind:"shape",reason:e}}function T(){return{ok:!1,kind:"request_digest",reason:"request digest is missing or malformed"}}function D(e,t){if(!s(e))return{ok:!1,reason:"grant request body must be a JSON object"};for(let n of Object.keys(e))if(!t.includes(n))return{ok:!1,reason:`grant request does not accept the "${n}" field`};return{ok:!0,record:e}}function v(e){if(!s(e))return"request must be a JSON object"}function Fr(e){let t=D(e,["nodeId","request","requestDigest"]);if(!t.ok)return p(t.reason);let n=t.record.nodeId;if(typeof n!="string"||n.length===0)return p("nodeId is required");let o=v(t.record.request);if(o!==void 0)return p(o);let i=t.record.requestDigest;return w(i)?{ok:!0,value:{nodeId:n,requestDigest:i,requestHasMultipartFiles:Qe(t.record.request)}}:T()}function Hr(e){let t=D(e,["request","requestDigest"]);if(!t.ok)return p(t.reason);let n=v(t.record.request);if(n!==void 0)return p(n);let o=t.record.requestDigest;return w(o)?{ok:!0,value:{requestDigest:o}}:T()}function Lr(e){let t=D(e,["request","requestDigest"]);if(!t.ok)return p(t.reason);let n=v(t.record.request);if(n!==void 0)return p(n);let o=t.record.requestDigest;return w(o)?{ok:!0,value:{requestDigest:o}}:T()}function Mr(e){let t=D(e,["tickId","request","requestDigest"]);if(!t.ok)return p(t.reason);let n=t.record.tickId;if(typeof n!="string"||n.length===0)return p("tickId is required");let o=v(t.record.request);if(o!==void 0)return p(o);let i=t.record.requestDigest;return w(i)?{ok:!0,value:{tickId:n,requestDigest:i}}:T()}function $r(e){let t=D(e,["phase","lifecycle","deliveryId","request","requestDigest"]);if(!t.ok)return p(t.reason);let n=t.record.phase;if(n!=="lifecycle"&&n!=="handler")return p('phase must be "lifecycle" or "handler"');let o=t.record.lifecycle,i;if(o!==void 0){if(o!=="enable"&&o!=="disable"&&o!=="renew")return p('lifecycle must be "enable", "disable", or "renew"');i=o}if(n==="lifecycle"&&i===void 0)return p("lifecycle is required for the lifecycle phase");let a=t.record.deliveryId,c;if(a!==void 0){if(typeof a!="string"||a.length===0)return p("deliveryId must be a non-empty string");c=a}if(n==="handler"&&c===void 0)return p("deliveryId is required for the handler phase");let d=v(t.record.request);if(d!==void 0)return p(d);let l=t.record.requestDigest;return w(l)?{ok:!0,value:{phase:n,...i!==void 0?{lifecycle:i}:{},...c!==void 0?{deliveryId:c}:{},requestDigest:l}}:T()}function se(e){return Ye.includes(e)?e:void 0}var Ze=["scopeKind","scopeId","requestDigest"];function Wr(e){if(!s(e))return p("consume body must be a JSON object");for(let i of Object.keys(e))if(!Ze.includes(i))return p(`consume does not accept the "${i}" field`);let t=se(e.scopeKind);if(t===void 0)return p("scopeKind is invalid");let n=e.scopeId;if(typeof n!="string"||n.length===0)return p("scopeId is required");let o=e.requestDigest;return w(o)?{ok:!0,value:{scopeKind:t,scopeId:n,requestDigest:o}}:T()}var et=["scopeKind","scopeId","providerHost","status","durationMs","requestBytes","responseBytes","errorCode"];function H(e,t){return typeof e!="number"||!Number.isInteger(e)||e<0?{ok:!1,reason:`${t} must be a non-negative integer`}:{ok:!0,value:e}}function Gr(e){if(!s(e))return p("audit body must be a JSON object");for(let f of Object.keys(e))if(!et.includes(f))return p(`audit does not accept the "${f}" field`);let t=se(e.scopeKind);if(t===void 0)return p("scopeKind is invalid");let n=e.scopeId;if(typeof n!="string"||n.length===0)return p("scopeId is required");let o=e.providerHost;if(typeof o!="string"||o.length===0)return p("providerHost is required");let i=H(e.durationMs,"durationMs");if(!i.ok)return p(i.reason);let a;if(e.status!==void 0){let f=H(e.status,"status");if(!f.ok)return p(f.reason);a=f.value}let c;if(e.requestBytes!==void 0){let f=H(e.requestBytes,"requestBytes");if(!f.ok)return p(f.reason);c=f.value}let d;if(e.responseBytes!==void 0){let f=H(e.responseBytes,"responseBytes");if(!f.ok)return p(f.reason);d=f.value}let l;if(e.errorCode!==void 0){let f=e.errorCode;if(typeof f!="string"||f.length===0)return p("errorCode must be a non-empty string");l=f}return{ok:!0,value:{scopeKind:t,scopeId:n,providerHost:o,...a!==void 0?{status:a}:{},durationMs:i.value,...c!==void 0?{requestBytes:c}:{},...d!==void 0?{responseBytes:d}:{},...l!==void 0?{errorCode:l}:{}}}}function Kr(e){return!s(e)||!s(e.grant)?r("egress grant envelope must carry a grant object"):u(e.grant)}function qr(e){return!s(e)||e.consumed!==!0?r("egress grant consume data must carry consumed:true"):u({consumed:!0})}var Qr="/:flowRunId/runtime-credential",Zr="/:invocationId/runtime-credential",eo="/:discoveryInvocationId/runtime-credential",to="/:pollingInstanceId/runtime-credential",no="/:triggerInstanceId/runtime-credential",ro=e=>`${g}/${encodeURIComponent(e)}/runtime-credential`,oo=e=>`${J}/${encodeURIComponent(e)}/runtime-credential`,io=e=>`${Y}/${encodeURIComponent(e)}/runtime-credential`,so=e=>`${C}/${encodeURIComponent(e)}/runtime-credential`,uo=e=>`${N}/${encodeURIComponent(e)}/runtime-credential`,ao=["flow_action","tool_invoke","discovery","polling_trigger","webhook_trigger"];function U(e,t){if(!s(e))return{ok:!1,reason:"runtime credential request body must be a JSON object"};for(let n of Object.keys(e))if(!t.includes(n))return{ok:!1,reason:`runtime credential request does not accept the "${n}" field`};return{ok:!0,record:e}}function co(e){let t=U(e,["nodeId"]);if(!t.ok)return r(t.reason);let n=t.record.nodeId;return typeof n!="string"||n.length===0?r("nodeId is required"):u({nodeId:n})}function po(e){let t=U(e??{},[]);return t.ok?u(null):r(t.reason)}function lo(e){let t=U(e??{},[]);return t.ok?u(null):r(t.reason)}function fo(e){let t=U(e,["tickId"]);if(!t.ok)return r(t.reason);let n=t.record.tickId;return typeof n!="string"||n.length===0?r("tickId is required"):u({tickId:n})}function go(e){let t=U(e,["executionKind","deliveryId","lifecycleOperation"]);if(!t.ok)return r(t.reason);let n=t.record.executionKind;if(n!=="event_handler"&&n!=="lifecycle")return r('executionKind must be "event_handler" or "lifecycle"');let o,i=t.record.deliveryId;if(i!==void 0){if(typeof i!="string"||i.length===0)return r("deliveryId must be a non-empty string");o=i}let a,c=t.record.lifecycleOperation;if(c!==void 0){if(c!=="enable"&&c!=="disable"&&c!=="renew")return r('lifecycleOperation must be "enable", "disable", or "renew"');a=c}return n==="lifecycle"&&a===void 0?r("lifecycleOperation is required for the lifecycle execution kind"):u({executionKind:n,...o!==void 0?{deliveryId:o}:{},...a!==void 0?{lifecycleOperation:a}:{}})}function mo(e){return!s(e)||typeof e.sessionId!="string"||typeof e.connectionId!="string"||typeof e.authProfileRef!="string"||typeof e.authType!="string"||!s(e.credential)?r("runtime credential session must carry sessionId, connectionId, auth profile facts and a credential object"):u(e.credential)}function L(e){return!s(e)||typeof e.file_id!="string"||typeof e.name!="string"||typeof e.size_bytes!="number"||typeof e.created_at!="string"||typeof e.expires_at!="string"||e.mime_type!==void 0&&typeof e.mime_type!="string"||e.sha256!==void 0&&typeof e.sha256!="string"||e.source!==void 0&&typeof e.source!="string"?r("file ref data does not match the AIS file-ref shape"):u(e)}function z(e){return!s(e)||e.method!=="GET"&&e.method!=="PUT"||typeof e.url!="string"||typeof e.expires_at!="string"||!rt(e.headers)?r("presigned file URL data is invalid"):u(e)}function tt(e){if(!s(e))return r("file upload session data is invalid");let t=L(e.file);if(!t.ok)return r(t.reason);let n=z(e.upload);return n.ok?u({file:t.value,upload:n.value}):r(n.reason)}function nt(e){if(!s(e))return r("file metadata data is invalid");let t=L(e.file);return t.ok?u({file:t.value}):r(t.reason)}function rt(e){return s(e)?Object.values(e).every(t=>typeof t=="string"):!1}var A="/internal/files",_o="/upload-session",xo="/:fileId/complete",ho="/:fileId/access",So="/:fileId/stat",wo="/:fileId/content",To=()=>A,Ao=()=>`${A}/upload-session`,Po=e=>`${A}/${encodeURIComponent(e)}/complete`,bo=(e,t)=>`${A}/${encodeURIComponent(e)}/access?intent=${encodeURIComponent(t)}`,ue=e=>`?scope_kind=${encodeURIComponent(e.scopeKind)}&scope_id=${encodeURIComponent(e.scopeId)}`,No=(e,t)=>`${A}/${encodeURIComponent(e)}/stat${ue(t)}`,Oo=(e,t)=>`${A}/${encodeURIComponent(e)}/content${ue(t)}`;function Co(e){if(!s(e))return r("internal file access data is invalid");if(e.intent==="runtime_read"||e.intent==="provider_multipart"){let t=L(e.file);if(!t.ok)return r(t.reason);let n=z(e.access);return n.ok?u({file:t.value,access:n.value,intent:e.intent}):r(n.reason)}return r("internal file access intent is invalid")}import{isHumanInputSpec as ot}from"@ablehi/flow-contract";var Ho="/:flowRunId/human-inputs",Lo="/:flowRunId/human-inputs/:requestId",Mo="/:flowRunId/human-inputs/:requestId/expire",$o="/:flowRunId/human-inputs/:requestId/acknowledge",it=e=>`${g}/${encodeURIComponent(e)}/human-inputs`,pe=(e,t)=>`${it(e)}/${encodeURIComponent(t)}`,Wo=(e,t)=>`${pe(e,t)}/expire`,Go=(e,t)=>`${pe(e,t)}/acknowledge`,st="human_input_resolved";function Ko(e){return`${st}_${e}`}function qo(e){return!s(e)||Object.keys(e).length!==4||!Object.hasOwn(e,"requestId")||!Object.hasOwn(e,"flowRunId")||!Object.hasOwn(e,"nodeId")||!Object.hasOwn(e,"status")||typeof e.requestId!="string"||e.requestId.length===0||typeof e.flowRunId!="string"||e.flowRunId.length===0||typeof e.nodeId!="string"||e.nodeId.length===0||e.status!=="submitted"&&e.status!=="expired"?r("Human Input resolved event shape is invalid"):u({requestId:e.requestId,flowRunId:e.flowRunId,nodeId:e.nodeId,status:e.status})}var ae=160,ce=500;function ut(e){return s(e)?e.kind==="choice"?!M(e,["kind","choiceId","comment"])||typeof e.choiceId!="string"||e.choiceId.length===0||e.comment!==void 0&&typeof e.comment!="string"?r("Human Input choice response is invalid"):u({kind:"choice",choiceId:e.choiceId,...e.comment!==void 0?{comment:e.comment}:{}}):e.kind==="text"&&M(e,["kind","text"])&&typeof e.text=="string"?u({kind:"text",text:e.text}):e.kind==="form"&&M(e,["kind","values"])&&s(e.values)?u({kind:"form",values:e.values}):r("Human Input response is invalid"):r("Human Input response must be an object")}function Vo(e,t){let n=ut(e);if(!n.ok||n.value.kind!==t.kind)return r("Human Input response does not match its input spec");switch(t.kind){case"choice":{let o=n.value;return o.kind!=="choice"?r("Human Input choice response does not match its spec"):!t.choices.some(i=>i.id===o.choiceId)||o.comment!==void 0&&t.allowComment!==!0?r("Human Input choice response does not match its spec"):n}case"text":return n.value.kind!=="text"||t.required===!0&&n.value.text.trim().length===0?r("Human Input text response does not match its spec"):n;case"form":{if(n.value.kind!=="form")return r("Human Input form response does not match its spec");let o=new Map(t.fields.map(i=>[i.id,i]));if(Object.keys(n.value.values).some(i=>!o.has(i)))return r("Human Input form response contains an unknown field");for(let i of t.fields){let a=n.value.values[i.id];if(!Object.hasOwn(n.value.values,i.id)){if(i.required===!0)return r(`Human Input form response is missing required field '${i.id}'`);continue}if(a==null||!at(i,a))return r(`Human Input form response field '${i.id}' does not match its spec`)}return n}}}function at(e,t){switch(e.type){case"text":case"textarea":return typeof t=="string";case"number":return typeof t=="number"&&Number.isFinite(t);case"boolean":return typeof t=="boolean";case"select":return typeof t=="string"&&(e.options??[]).some(n=>n.id===t)}}function m(e){return{ok:!1,reason:e}}function h(e,t){return s(e)?{ok:!0,value:e}:m(`${t} must be an object`)}function M(e,t){return Object.keys(e).every(n=>t.includes(n))}function P(e,t){return typeof e!="string"||e.length===0?m(`${t} must be a non-empty string`):{ok:!0,value:e}}var ct=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?(?:Z|[+-]\d{2}:\d{2})$/;function dt(e,t){return typeof e!="string"||!ct.test(e)||Number.isNaN(Date.parse(e))?m(`${t} must be an ISO-8601 timestamp`):{ok:!0,value:e}}function le(e){let t=h(e,"renderedPrompt");if(!t.ok)return t;if(!M(t.value,["title","body","format"]))return m("renderedPrompt contains an unknown field");let n=P(t.value.title,"renderedPrompt.title");if(!n.ok)return n;if(!/[^\p{White_Space}]/u.test(n.value))return m("renderedPrompt.title must contain non-whitespace text");if(!de(n.value,ae))return m(`renderedPrompt.title must contain at most ${ae} code points`);let o={title:n.value};if(t.value.body!==void 0){if(typeof t.value.body!="string")return m("renderedPrompt.body must be a string");if(!de(t.value.body,ce))return m(`renderedPrompt.body must contain at most ${ce} code points`);o.body=t.value.body}if(t.value.format!==void 0){if(t.value.format!=="plain"&&t.value.format!=="markdown")return m("renderedPrompt.format is invalid");o.format=t.value.format}return{ok:!0,value:o}}function de(e,t){let n=0,o=e[Symbol.iterator]();for(;!o.next().done;)if(n+=1,n>t)return!1;return!0}function jo(e){let t=le(e);return t.ok?u(t.value):r(t.reason)}function pt(e){try{return ot(e)?u(e):r("Human Input spec shape is invalid")}catch{return r("Human Input spec shape is invalid")}}function lt(e){let t=pt(e);return t.ok?t:m(t.reason)}function ft(e){if(e==null)return{ok:!0,value:void 0};let t=h(e,"partiallyRenderedDelivery");if(!t.ok)return t;let n=t.value.actions;if(n===void 0)return{ok:!0,value:{}};if(!Array.isArray(n))return m("partiallyRenderedDelivery.actions must be an array");let o=[];for(let i of n){let a=h(i,"delivery action");if(!a.ok)return a;let c=P(a.value.id,"delivery action id");if(!c.ok)return c;let d=fe(a.value.inputs,`delivery action '${c.value}' inputs`);if(!d.ok)return d;o.push({id:c.value,inputs:d.value})}return{ok:!0,value:{actions:o}}}function fe(e,t){let n=h(e,t);if(!n.ok)return n;let o={};for(let[i,a]of Object.entries(n.value)){let c=ge(a,`${t}.${i}`);if(!c.ok)return c;o[i]=c.value}return{ok:!0,value:o}}function ge(e,t){let n=h(e,t);if(!n.ok)return n;switch(n.value.kind){case"literal":return{ok:!0,value:{kind:"literal",value:n.value.value}};case"human_input_ref":{let i=P(n.value.path,`${t}.path`);return i.ok?{ok:!0,value:{kind:"human_input_ref",path:i.value}}:i}case"array":{if(!Array.isArray(n.value.items))return m(`${t}.items must be an array`);let i=[];for(let[a,c]of n.value.items.entries()){let d=ge(c,`${t}[${a}]`);if(!d.ok)return d;i.push(d.value)}return{ok:!0,value:{kind:"array",items:i}}}case"object":{let i=fe(n.value.entries,`${t}.entries`);return i.ok?{ok:!0,value:{kind:"object",entries:i.value}}:i}case"template":{if(!Array.isArray(n.value.parts))return m(`${t}.parts must be an array`);let i=[];for(let[a,c]of n.value.parts.entries()){let d=gt(c,`${t}.parts[${a}]`);if(!d.ok)return d;i.push(d.value)}return{ok:!0,value:{kind:"template",parts:i}}}default:return m(`${t}.kind is invalid`)}}function gt(e,t){let n=h(e,t);if(!n.ok)return n;let o=n.value.kind;if(o==="literal")return typeof n.value.value!="string"?m(`${t}.value must be a string`):{ok:!0,value:{kind:"literal",value:n.value.value}};if(o==="human_input_ref"){let i=P(n.value.path,`${t}.path`);return i.ok?{ok:!0,value:{kind:"human_input_ref",path:i.value}}:i}return m(`${t}.kind is invalid`)}function Xo(e){let t=h(e,"request body");if(!t.ok)return r(t.reason);let n=Object.keys(t.value).find(Re=>!["executionScope","nodeId","renderedPrompt","input","partiallyRenderedDelivery","timeout","expiresAt"].includes(Re));if(n!==void 0)return r(`human input body does not accept the "${n}" field`);let o=k(t.value.executionScope);if(!o.ok)return r(o.reason);let i=P(t.value.nodeId,"nodeId");if(!i.ok)return r(i.reason);let a=le(t.value.renderedPrompt);if(!a.ok)return r(a.reason);let c=lt(t.value.input);if(!c.ok)return r(c.reason);let d=P(t.value.timeout,"timeout");if(!d.ok)return r(d.reason);let l=dt(t.value.expiresAt,"expiresAt");if(!l.ok)return r(l.reason);let f=ft(t.value.partiallyRenderedDelivery);return f.ok?u({executionScope:o.value,nodeId:i.value,renderedPrompt:a.value,input:c.value,timeout:d.value,expiresAt:l.value,...f.value!==void 0?{partiallyRenderedDelivery:f.value}:{}}):r(f.reason)}function mt(e){return!s(e)||typeof e.id!="string"||e.id.length===0||typeof e.nodeId!="string"||typeof e.status!="string"||!(e.output===null||s(e.output))?r("human input request view must carry id, nodeId, status and output"):u(e)}function Jo(e){if(!s(e)||typeof e.created!="boolean")return r("human input create data must carry created:boolean");let t=mt(e.request);return t.ok?u({created:e.created,request:t.value}):t}function Yo(e){return!s(e)||e.acknowledged!==!0?r("human input acknowledge data must carry acknowledged:true"):u({acknowledged:!0})}var Qo="ablehi-wfp-user-runtime-manifest/v1",Zo="unknown";function ei(e){return e.endsWith(".js")?`${e.slice(0,-3)}.manifest.json`:`${e}.manifest.json`}var ni="/internal/deployment-handshake",Rt=["start","terminate","send-event","start-webhook-watcher","run-polling-tick","invoke-tool","invoke-discovery","invoke-trigger-handler","invoke-webhook-protocol-adapter","deployment-handshake"],ri=Rt,oi="HANDSHAKE_REQUEST_INVALID",ii="HANDSHAKE_SECRET_UNCONFIGURED",si="HANDSHAKE_SECRET_MISMATCH",ui="HANDSHAKE_CONTRACT_VERSION_MISMATCH",ai="HANDSHAKE_DISPATCH_NAMESPACE_MISMATCH",ci="HANDSHAKE_CAPABILITY_MISSING";function di(e){return[e.nonce,e.timestamp,e.contractVersion,e.dispatchNamespace].map(n=>`${n.length}:${n}`).join(".")}function pi(e){return["response",e.nonce,e.contractVersion,e.dispatchNamespace,...e.capabilities].map(n=>`${n.length}:${n}`).join(".")}function gi(e){if(!s(e)||e.ok!==!1||!s(e.error))return r("Server execution error envelope is invalid");let t=Object.keys(e).find(i=>i!=="ok"&&i!=="error"&&i!=="guidance"),n=e.error,o=Object.keys(n).find(i=>i!=="code"&&i!=="message"&&i!=="retryable"&&i!=="issues"&&i!=="details");return t!==void 0||o!==void 0||typeof n.code!="string"||n.code.length===0||typeof n.message!="string"||typeof n.retryable!="boolean"||n.issues!==void 0&&!Array.isArray(n.issues)||n.details!==void 0&&!s(n.details)?r("Server execution error must carry code, message, and boolean retryable"):u(e)}import{lookupErrorRegistryEntry as It}from"@ablehi/error-contract";var ki="/:flowRunId/inbox-message-emissions/:nodeId";function _i(e,t){return`${g}/${encodeURIComponent(e)}/inbox-message-emissions/${encodeURIComponent(t)}`}function I(e){let t=It(e);if(t.code!==e)throw new Error(`Inbox message execution error code is not registered: ${e}`);return t.retryable}var xi=_t({INBOX_MESSAGE_IDEMPOTENCY_KEY_INVALID:{httpStatus:422,retryable:I("INBOX_MESSAGE_IDEMPOTENCY_KEY_INVALID")},INBOX_MESSAGE_PAYLOAD_INVALID:{httpStatus:422,retryable:I("INBOX_MESSAGE_PAYLOAD_INVALID")},INBOX_MESSAGE_PAYLOAD_TOO_LARGE:{httpStatus:413,retryable:I("INBOX_MESSAGE_PAYLOAD_TOO_LARGE")},INBOX_MESSAGE_RENDER_INVALID:{httpStatus:422,retryable:I("INBOX_MESSAGE_RENDER_INVALID")},INBOX_MESSAGE_CONTENT_TOO_LARGE:{httpStatus:413,retryable:I("INBOX_MESSAGE_CONTENT_TOO_LARGE")},INBOX_MESSAGE_ATTACHMENT_INVALID:{httpStatus:422,retryable:I("INBOX_MESSAGE_ATTACHMENT_INVALID")},INBOX_MESSAGE_ATTACHMENT_UNAVAILABLE:{httpStatus:409,retryable:I("INBOX_MESSAGE_ATTACHMENT_UNAVAILABLE")},FLOW_INBOX_MESSAGE_INVALID:{httpStatus:422,retryable:I("FLOW_INBOX_MESSAGE_INVALID")},EXECUTION_LEASE_INVALID:{httpStatus:409,retryable:I("EXECUTION_LEASE_INVALID")},EXECUTION_LEASE_SUPERSEDED:{httpStatus:409,retryable:I("EXECUTION_LEASE_SUPERSEDED")},AUTOMATION_APP_INSTALLATION_DISABLED:{httpStatus:409,retryable:I("AUTOMATION_APP_INSTALLATION_DISABLED")},INBOX_MESSAGE_EMISSION_WINDOW_CLOSED:{httpStatus:409,retryable:I("INBOX_MESSAGE_EMISSION_WINDOW_CLOSED")},INBOX_MESSAGE_EMISSION_CONFLICT:{httpStatus:409,retryable:I("INBOX_MESSAGE_EMISSION_CONFLICT")},INBOX_MESSAGE_EMISSION_UNAVAILABLE:{httpStatus:503,retryable:I("INBOX_MESSAGE_EMISSION_UNAVAILABLE")}});function hi(e){if(!s(e)||!me(e,["executionScope","idempotencyKey","payload"])||typeof e.idempotencyKey!="string"||!yt(e.payload))return r("Inbox message Emission request shape is invalid");let t=k(e.executionScope);return t.ok?u({executionScope:t.value,idempotencyKey:e.idempotencyKey,payload:e.payload}):r(t.reason)}function Si(e){return!s(e)||!me(e,["emissionId","outcome","occurredAt"])||typeof e.emissionId!="string"||e.emissionId.length===0||e.outcome!=="created"&&e.outcome!=="replayed"||typeof e.occurredAt!="string"||e.occurredAt.length===0?r("Inbox message Emission response shape is invalid"):u(e)}function me(e,t){let n=Object.keys(e).sort(),o=[...t].sort();return n.length===o.length&&n.every((i,a)=>i===o[a])}function yt(e){return s(e)&&Et(e)}function Et(e){let n=new WeakSet,o=[{value:e}],i=0;for(;o.length>0;){let a=o.pop();if(a.exiting){n.delete(a.value);continue}let c=a.value;if(c===null||typeof c=="string"||typeof c=="boolean"||typeof c=="number"&&Number.isFinite(c))continue;if(typeof c!="object"||n.has(c)||(i+=1,i>1e5))return!1;let d=Array.isArray(c)?c:s(c)&&kt(c)?Object.values(c):void 0;if(d===void 0)return!1;n.add(c),o.push({value:c,exiting:!0});for(let l=d.length-1;l>=0;l-=1)o.push({value:d[l]})}return!0}function kt(e){let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function _t(e){for(let t of Object.values(e))Object.freeze(t);return Object.freeze(e)}export{dn as COMPLETE_EVENT_WAIT_ROUTE_SUBPATH,wt as CONTEXT_STATE_CLEANUP_ROUTE_PATH,Rt as DEPLOYMENT_HANDSHAKE_DISPATCHER_CAPABILITIES,ri as DEPLOYMENT_HANDSHAKE_REQUIRED_CAPABILITIES,ni as DEPLOYMENT_HANDSHAKE_ROUTE,wr as DISCOVERY_INVOCATION_EGRESS_GRANT_ROUTE_SUBPATH,eo as DISCOVERY_INVOCATION_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,br as EGRESS_GRANT_AUDIT_ROUTE_SUBPATH,Pr as EGRESS_GRANT_CONSUME_ROUTE_SUBPATH,Ye as EGRESS_GRANT_SCOPE_KINDS,zt as EXECUTION_CONTEXT_ROUTE_SUBPATH,Ft as EXECUTION_LEASE_INVALID,Ot as EXECUTION_LEASE_ROUTE_SUBPATH,Ht as EXECUTION_LEASE_SUPERSEDED,ho as FILE_ACCESS_ROUTE_SUBPATH,xo as FILE_COMPLETE_ROUTE_SUBPATH,wo as FILE_CONTENT_ROUTE_SUBPATH,So as FILE_STAT_ROUTE_SUBPATH,_o as FILE_UPLOAD_SESSION_ROUTE_SUBPATH,hr as FLOW_RUN_EGRESS_GRANT_ROUTE_SUBPATH,an as FLOW_RUN_EXECUTION_EVENTS_ROUTE_SUBPATH,be as FLOW_RUN_EXECUTION_EVENT_TYPES,un as FLOW_RUN_RESULT_ROUTE_SUBPATH,Qr as FLOW_RUN_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,Pn as HANDLER_BUNDLES_ROUTE_SUBPATH,ci as HANDSHAKE_CAPABILITY_MISSING,ui as HANDSHAKE_CONTRACT_VERSION_MISMATCH,ai as HANDSHAKE_DISPATCH_NAMESPACE_MISMATCH,oi as HANDSHAKE_REQUEST_INVALID,si as HANDSHAKE_SECRET_MISMATCH,ii as HANDSHAKE_SECRET_UNCONFIGURED,Ho as HUMAN_INPUTS_ROUTE_SUBPATH,$o as HUMAN_INPUT_ACKNOWLEDGE_ROUTE_SUBPATH,Mt as HUMAN_INPUT_CANCELLED_BY_RESET,Mo as HUMAN_INPUT_EXPIRE_ROUTE_SUBPATH,ce as HUMAN_INPUT_PROMPT_BODY_MAX_CODE_POINTS,ae as HUMAN_INPUT_PROMPT_TITLE_MAX_CODE_POINTS,Lo as HUMAN_INPUT_REQUEST_ROUTE_SUBPATH,st as HUMAN_INPUT_RESOLVED_EVENT_PREFIX,ki as INBOX_MESSAGE_EMISSION_ROUTE_SUBPATH,xi as INBOX_MESSAGE_EXECUTION_ERROR_REGISTRY,Y as INTERNAL_DISCOVERY_INVOCATIONS_ROUTE_PREFIX,ie as INTERNAL_EGRESS_GRANTS_ROUTE_PREFIX,A as INTERNAL_FILES_ROUTE_PREFIX,g as INTERNAL_FLOW_RUNS_ROUTE_PREFIX,De as INTERNAL_FLOW_VERSIONS_ROUTE_PREFIX,q as INTERNAL_INSTALLATIONS_ROUTE_PREFIX,C as INTERNAL_POLLING_TRIGGER_INSTANCES_ROUTE_PREFIX,J as INTERNAL_TOOL_INVOCATIONS_ROUTE_PREFIX,N as INTERNAL_WEBHOOK_TRIGGER_INSTANCES_ROUTE_PREFIX,cr as POLLING_TRIGGER_CONTEXT_ROUTE_SUBPATH,Tr as POLLING_TRIGGER_EGRESS_GRANT_ROUTE_SUBPATH,dr as POLLING_TRIGGER_HANDLER_BUNDLES_ROUTE_SUBPATH,to as POLLING_TRIGGER_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,pr as POLLING_TRIGGER_TICK_EVENTS_ROUTE_SUBPATH,cn as REGISTER_EVENT_WAIT_ROUTE_SUBPATH,ao as RUNTIME_CREDENTIAL_SESSION_SCOPE_KINDS,Bt as RUN_DISPATCH_UNAVAILABLE,Ie as SERVER_EXECUTION_CONTRACT_VERSION,sn as STEP_RESULT_ROUTE_SUBPATH,bn as TOOL_HANDLER_BUNDLES_ROUTE_SUBPATH,Sr as TOOL_INVOCATION_EGRESS_GRANT_ROUTE_SUBPATH,Zr as TOOL_INVOCATION_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,Lt as WAIT_EXECUTION_SUPERSEDED,Yn as WEBHOOK_PROTOCOL_ADAPTER_BUNDLE_ROUTE_SUBPATH,Qn as WEBHOOK_PROTOCOL_ADAPTER_MODULE,Mn as WEBHOOK_TRIGGER_CONTEXT_ROUTE_SUBPATH,Wn as WEBHOOK_TRIGGER_DELIVERY_ROUTE_SUBPATH,Ar as WEBHOOK_TRIGGER_EGRESS_GRANT_ROUTE_SUBPATH,Gn as WEBHOOK_TRIGGER_EVENTS_ROUTE_SUBPATH,$n as WEBHOOK_TRIGGER_HANDLER_BUNDLES_ROUTE_SUBPATH,Kn as WEBHOOK_TRIGGER_REARM_ROUTE_SUBPATH,no as WEBHOOK_TRIGGER_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,Qo as WFP_USER_RUNTIME_MANIFEST_FORMAT_VERSION,Zo as WFP_USER_RUNTIME_UNKNOWN_SOURCE_REVISION,vt as WORKFLOW_RESTART_INSTANCE_UNAVAILABLE,Ut as WORKFLOW_RESTART_REJECTED,Dt as WORKFLOW_RESTART_REQUEST_INVALID,Ct as WORKFLOW_RESTART_ROUTE,$t as acquireExecutionLeasePath,mn as completeEventWaitPath,di as deploymentHandshakeProbePayload,pi as deploymentHandshakeResponseProofPayload,Cr as discoveryInvocationEgressGrantPath,io as discoveryInvocationRuntimeCredentialPath,Br as egressGrantAuditPath,Ur as egressGrantConsumePath,Qt as executionContextPath,Nr as flowRunEgressGrantPath,fn as flowRunExecutionEventsPath,ln as flowRunResultPath,ro as flowRunRuntimeCredentialPath,Zn as flowScriptProtocolAdapterModuleName,Nn as handlerBundlesPath,Go as humanInputAcknowledgePath,Wo as humanInputExpirePath,pe as humanInputRequestPath,Ko as humanInputResolvedEventType,it as humanInputsPath,_i as inboxMessageEmissionPath,bo as internalFileAccessPath,Po as internalFileCompletePath,Oo as internalFileContentPath,No as internalFileStatPath,Ao as internalFileUploadSessionPath,To as internalFilesPath,w as isValidRequestDigest,Gt as parseAcquireExecutionLeaseData,Wt as parseAcquireExecutionLeaseRequest,hn as parseCompleteFlowRunWaitBody,wn as parseCompleteFlowRunWaitData,Tt as parseContextStateCleanupRequestBody,At as parseContextStateCleanupResponseData,x as parseContextStateScope,Xo as parseCreateHumanInputBody,Lr as parseDiscoveryGrantBody,lo as parseDiscoveryRuntimeCredentialBody,Gr as parseEgressGrantAuditBody,Wr as parseEgressGrantConsumeBody,qr as parseEgressGrantConsumeData,Kr as parseEgressGrantData,Si as parseEmitInboxMessageData,hi as parseEmitInboxMessageRequest,Z as parseExecutionAnchor,Zt as parseExecutionContextData,xe as parseExecutionLease,k as parseExecutionWriteScope,nt as parseFileMetadataData,L as parseFileRefData,W as parseFileRuntimeLimits,tt as parseFileUploadSessionData,Fr as parseFlowActionGrantBody,Q as parseFlowExecutionScope,_n as parseFlowRunExecutionEventBody,kn as parseFlowRunExecutionEventData,yn as parseFlowRunResultBody,En as parseFlowRunResultData,co as parseFlowRuntimeCredentialBody,Tn as parseFlowWaitResolvedEvent,Ue as parseHandlerBundle,Cn as parseHandlerBundlesData,Yo as parseHumanInputAcknowledgeData,Jo as parseHumanInputCreateData,mt as parseHumanInputRequestViewData,qo as parseHumanInputResolvedEvent,ut as parseHumanInputResponse,Vo as parseHumanInputResponseForSpec,pt as parseHumanInputSpec,Co as parseInternalFileAccessData,Rr as parsePollingPublishBody,fo as parsePollingRuntimeCredentialBody,We as parsePollingTriggerContext,mr as parsePollingTriggerDispatchData,Mr as parsePollingTriggerGrantBody,Ir as parsePublishPollingTickEventsData,xn as parseRegisterFlowRunWaitBody,Sn as parseRegisterFlowRunWaitData,jo as parseRenderedHumanInputPrompt,mo as parseRuntimeCredentialSessionCredential,F as parseRuntimeNetwork,gi as parseServerExecutionErrorEnvelope,Hr as parseSingleToolGrantBody,po as parseSingleToolRuntimeCredentialBody,Rn as parseStepRecordBody,In as parseStepRecordData,Dn as parseToolHandlerBundlesData,V as parseTriggerFileRuntimeDispatch,nr as parseTriggerHandlerBundlesData,Le as parseWebhookDelivery,tr as parseWebhookDeliveryDispatchData,rr as parseWebhookPublishEventsBody,or as parseWebhookRearmBody,go as parseWebhookRuntimeCredentialBody,$r as parseWebhookTriggerGrantBody,er as parseWebhookWatcherContext,Kt as parseWorkflowDispatchRestartRequest,qt as parseWorkflowDispatchRestartResponse,lr as pollingTriggerContextPath,Dr as pollingTriggerEgressGrantPath,fr as pollingTriggerHandlerBundlesPath,so as pollingTriggerRuntimeCredentialPath,gr as pollingTriggerTickEventsPath,gn as registerEventWaitPath,Qe as requestHasMultipartFileParts,pn as stepResultPath,On as toolHandlerBundlesPath,Or as toolInvocationEgressGrantPath,oo as toolInvocationRuntimeCredentialPath,zn as webhookProtocolAdapterBundlePath,qn as webhookTriggerContextPath,jn as webhookTriggerDeliveryPath,vr as webhookTriggerEgressGrantPath,Xn as webhookTriggerEventsPath,Vn as webhookTriggerHandlerBundlesPath,Jn as webhookTriggerRearmPath,uo as webhookTriggerRuntimeCredentialPath,ei as wfpUserRuntimeManifestPath};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ablehi/server-execution-contract",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Ablehi server to Cloudflare execution contract.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"publishConfig": {
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"dist"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@ablehi/error-contract": "0.0.
|
|
28
|
-
"@ablehi/flow-contract": "0.
|
|
27
|
+
"@ablehi/error-contract": "0.0.2",
|
|
28
|
+
"@ablehi/flow-contract": "0.3.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@typescript-eslint/eslint-plugin": "^8.62.0",
|