@ablehi/server-execution-contract 0.1.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 +2 -0
- package/dist/edge.js +1 -0
- package/dist/index.d.ts +802 -0
- package/dist/index.js +1 -0
- package/package.json +44 -0
package/dist/edge.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { CONTEXT_STATE_CLEANUP_ROUTE_PATH, CompleteFlowRunWaitBody, CompleteFlowRunWaitData, ContextStateCleanupRequestBody, ContextStateCleanupResponseData, ContextStateScope, CreateHumanInputRequestBody, DEPLOYMENT_HANDSHAKE_DISPATCHER_CAPABILITIES, DEPLOYMENT_HANDSHAKE_REQUIRED_CAPABILITIES, DEPLOYMENT_HANDSHAKE_ROUTE, DeploymentHandshakeData, DeploymentHandshakeRequestBody, DeploymentHandshakeResponse, EGRESS_GRANT_AUDIT_ROUTE_SUBPATH, EGRESS_GRANT_CONSUME_ROUTE_SUBPATH, EGRESS_GRANT_SCOPE_KINDS, EVENT_WAIT_ROUTE_SUBPATH, EXECUTION_CONTEXT_ROUTE_SUBPATH, EgressGrant, EgressGrantAuditBody, EgressGrantBodyParseResult, EgressGrantConsumeBody, EgressGrantCredentialMaterial, EgressGrantFileRuntime, EgressGrantScopeKind, ExecutionBinding, ExecutionBindingConnection, ExecutionContextCompiled, ExecutionContextData, 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_RESULT_ROUTE_SUBPATH, FLOW_RUN_RUNTIME_CREDENTIAL_ROUTE_SUBPATH, FileMetadataData, FileRefData, FileRuntimeLimits, FileRuntimeScope, FileRuntimeScopeKind, FileUploadSessionData, FlowActionGrantBody, FlowExecutionContextFileRuntime, FlowRunResultData, FlowRunResultRequestBody, FlowRuntimeCredentialBody, 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_EXPIRE_ROUTE_SUBPATH, HUMAN_INPUT_REQUEST_ROUTE_SUBPATH, HUMAN_INPUT_RESOLVED_EVENT_PREFIX, HandlerBundle, HandlerBundleModule, HandlerBundlesData, HandlerBundlesParseResult, HumanInputActor, HumanInputOutput, HumanInputRequestView, HumanInputResolvedEvent, HumanInputResponse, 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, 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, PackagePollingTriggerRuntimeDescriptor, PackageWebhookTriggerRuntimeDescriptor, ParsedFlowRunResultBody, PartiallyRenderedHumanInputDelivery, PartiallyRenderedMapping, PartiallyRenderedTemplatePart, PartiallyRenderedValue, PollingPublishBody, PollingPublishEvent, PollingRuntimeCredentialBody, PollingTriggerContext, PollingTriggerGrantBody, PresignedFileUrlData, PublishPollingTickEventResult, PublishPollingTickEventsData, RUNTIME_CREDENTIAL_SESSION_SCOPE_KINDS, RegisterFlowRunWaitBody, RegisterFlowRunWaitData, RenderedFlowComposition, 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, TriggerHandlerBundlesData, TriggerHandlerModule, 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, WebhookDelivery, WebhookProtocolAdapterBundleData, WebhookProtocolAdapterModule, WebhookPublishEvent, WebhookPublishEventsBody, WebhookPublishEventsData, WebhookRearmBody, WebhookRearmData, WebhookRuntimeCredentialBody, WebhookTriggerGrantBody, WebhookTriggerVerificationMethod, WebhookWatcherContext, WfpUserRuntimeManifest, deploymentHandshakeProbePayload, deploymentHandshakeResponseProofPayload, egressGrantAuditPath, egressGrantConsumePath, eventWaitPath, executionContextPath, flowRunEgressGrantPath, flowRunResultPath, flowRunRuntimeCredentialPath, flowScriptProtocolAdapterModuleName, handlerBundlesPath, humanInputAcknowledgePath, humanInputExpirePath, humanInputRequestPath, humanInputResolvedEventType, humanInputsPath, internalFileAccessPath, internalFileCompletePath, internalFileContentPath, internalFileStatPath, internalFileUploadSessionPath, internalFilesPath, isValidRequestDigest, parseCompleteFlowRunWaitBody, parseContextStateCleanupRequestBody, parseContextStateCleanupResponseData, parseContextStateScope, parseCreateHumanInputBody, parseEgressGrantAuditBody, parseEgressGrantConsumeBody, parseEgressGrantConsumeData, parseEgressGrantData, parseExecutionContextData, parseFileMetadataData, parseFileRefData, parseFileRuntimeLimits, parseFileUploadSessionData, parseFlowActionGrantBody, parseFlowRunResultBody, parseFlowRunResultData, parseFlowRuntimeCredentialBody, parseHandlerBundle, parseHandlerBundlesData, parseHumanInputAcknowledgeData, parseHumanInputCreateData, parseHumanInputRequestViewData, parseInternalFileAccessData, parsePollingPublishBody, parsePollingRuntimeCredentialBody, parsePollingTriggerContext, parsePollingTriggerGrantBody, parsePublishPollingTickEventsData, parseRegisterFlowRunWaitBody, parseRegisterFlowRunWaitData, parseRuntimeCredentialSessionCredential, parseRuntimeNetwork, parseSingleToolGrantBody, parseSingleToolRuntimeCredentialBody, parseStepRecordBody, parseStepRecordData, parseToolHandlerBundlesData, parseTriggerHandlerBundlesData, parseWebhookDelivery, parseWebhookPublishEventsBody, parseWebhookRearmBody, parseWebhookRuntimeCredentialBody, parseWebhookTriggerGrantBody, parseWebhookWatcherContext, pollingTriggerContextPath, pollingTriggerEgressGrantPath, pollingTriggerHandlerBundlesPath, pollingTriggerRuntimeCredentialPath, pollingTriggerTickEventsPath, requestHasMultipartFileParts, stepResultPath, toolHandlerBundlesPath, toolInvocationEgressGrantPath, toolInvocationRuntimeCredentialPath, webhookProtocolAdapterBundlePath, webhookTriggerContextPath, webhookTriggerDeliveryPath, webhookTriggerEgressGrantPath, webhookTriggerEventsPath, webhookTriggerHandlerBundlesPath, webhookTriggerRearmPath, webhookTriggerRuntimeCredentialPath, wfpUserRuntimeManifestPath } from './index.js';
|
|
2
|
+
import '@ablehi/flow-contract';
|
package/dist/edge.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var Z="0.2.8";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 Le="/cleanup-state-scopes";function y(e){if(!i(e)||typeof e.kind!="string")return r("context state scope surface shape is invalid");switch(e.kind){case"webhook-trigger":return ee(e);case"polling-trigger":return te(e);case"flow-action":return ne(e);default:return r("context state scope kind is invalid")}}function qe(e){if(!i(e))return r("cleanup request body must be a JSON object");let t=C(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=y(o);if(!s.ok)return s;n.push(s.value)}return u({scopes:n})}function We(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 ee(e){let t=C(e,["kind","workspaceId","triggerInstanceId"]);return t!==void 0?r(`webhook trigger scope does not accept "${t}"`):e.kind!=="webhook-trigger"||!R(e.workspaceId)||!R(e.triggerInstanceId)?r("webhook trigger state scope is invalid"):u({kind:"webhook-trigger",workspaceId:e.workspaceId,triggerInstanceId:e.triggerInstanceId})}function te(e){let t=C(e,["kind","workspaceId","pollingInstanceId"]);return t!==void 0?r(`polling trigger scope does not accept "${t}"`):e.kind!=="polling-trigger"||!R(e.workspaceId)||!R(e.pollingInstanceId)?r("polling trigger state scope is invalid"):u({kind:"polling-trigger",workspaceId:e.workspaceId,pollingInstanceId:e.pollingInstanceId})}function ne(e){let t=C(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"||!R(e.workspaceId)||!R(e.flowId)||!R(e.nodeId)||n!==null&&!R(n)?r("flow action state scope is invalid"):u({kind:"flow-action",workspaceId:e.workspaceId,flowId:e.flowId,nodeId:e.nodeId,connectionId:n})}function R(e){return typeof e=="string"&&e.length>0}function C(e,t){return Object.keys(e).find(n=>!t.includes(n))}var f="/internal/flow-runs",Xe="/:flowRunId/execution-context";function Ye(e){return`${f}/${encodeURIComponent(e)}/execution-context`}function re(e){return!i(e)||!B(e.fileMaxBytes)||!B(e.fileReadMaxBytes)||!B(e.inlineMultipartBytesMax)?r("file runtime limits must carry three positive integer bounds"):u({fileMaxBytes:e.fileMaxBytes,fileReadMaxBytes:e.fileReadMaxBytes,inlineMultipartBytesMax:e.inlineMultipartBytesMax})}function ze(e){if(!i(e))return r("execution context must be a JSON object");let t=e.compiled;if(typeof e.flowRunId!="string"||typeof e.workspaceId!="string"||!i(e.input)||!i(t)||typeof t.irSchemaVersion!="string"||typeof t.interpreterContractVersion!="string"||typeof t.compiledArtifactId!="string"||!i(t.ir)||!Array.isArray(t.ir.nodes)||!ie(e.executionBindings))return r("execution context surface shape is invalid");let n=oe(e.fileRuntime);return n.ok?u({...e,fileRuntime:n.value}):r(n.reason)}function oe(e){if(e===null)return u(null);if(!i(e))return r("fileRuntime must be null or an object");let t=re(e.limits);return t.ok?u({limits:t.value}):r(t.reason)}function ie(e){return Array.isArray(e)?e.every(t=>{if(!i(t))return!1;let n=t.connection,o=y(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 B(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0}var tt="/:flowRunId/steps/:nodeId/result",nt="/:flowRunId/result",rt="/:flowRunId/event-waits/:nodeId";function ot(e,t){return`${f}/${encodeURIComponent(e)}/steps/${encodeURIComponent(t)}/result`}function it(e){return`${f}/${encodeURIComponent(e)}/result`}function st(e,t){return`${f}/${encodeURIComponent(e)}/event-waits/${encodeURIComponent(t)}`}function ut(e){if(!i(e))return{ok:!1,kind:"validation",reason:"step record body must be a JSON object"};let t=k(e,["attempt","result","durationMs"]);if(t!==void 0)return{ok:!1,kind:"validation",reason:`step record does not accept the "${t}" field`};let n=e.attempt;if(typeof n!="number"||!Number.isInteger(n)||n<=0)return{ok:!1,kind:"validation",reason:"attempt must be a positive integer"};let o=se(e.result);if(!o.ok)return o;let s={attempt:n,result:o.value};if(e.durationMs!==void 0){let a=e.durationMs;if(typeof a!="number"||!Number.isFinite(a)||a<0)return{ok:!1,kind:"validation",reason:"durationMs must be a non-negative number"};s.durationMs=a}return{ok:!0,value:s}}function se(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=k(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=k(e,["status","errorCode","issues"]);if(n!==void 0)return{ok:!1,kind:"validation",reason:`step record result does not accept the "${n}" field`};let o=e.errorCode;if(typeof o!="string"||o.length===0)return{ok:!1,kind:"step_result_invalid",reason:"a failed result must carry a non-empty errorCode"};let s={status:"failed",errorCode:o};return e.issues!==void 0&&(s.issues=e.issues),{ok:!0,value:s}}return{ok:!1,kind:"step_result_invalid",reason:'result status must be "succeeded" or "failed"'}}function at(e){return!i(e)||typeof e.flowRunId!="string"||typeof e.nodeId!="string"||e.recorded!=="succeeded"&&e.recorded!=="failed"?r("step record data surface shape is invalid"):u({flowRunId:e.flowRunId,nodeId:e.nodeId,recorded:e.recorded})}function ct(e){if(!i(e))return r("result body must be a JSON object");let t=k(e,["status","output","error","composition"]);if(t!==void 0)return r(`result does not accept the "${t}" field`);let n=e.status;if(n!=="succeeded"&&n!=="failed")return r('result status must be "succeeded" or "failed"');let o={status:n};if(e.output!==void 0&&(o.output=e.output),e.error!==void 0){let s=e.error;if(!i(s))return r("result error must be a JSON object");let a=k(s,["code","message"]);if(a!==void 0)return r(`result error does not accept the "${a}" field`);if(typeof s.code!="string"||typeof s.message!="string")return r("result error must carry string code and message");o.error={code:s.code,message:s.message}}if(e.composition!==void 0){if(n!=="succeeded")return r("composition is only allowed on a succeeded result");o.composition=e.composition}return u(o)}function dt(e){return i(e)?u(e):r("flow run result data must be a JSON object")}var ue=/^[A-Za-z0-9_-]{1,100}$/;function lt(e){if(!i(e))return r("register body must be a JSON object");let t=k(e,["eventType","correlationKey"]);if(t!==void 0)return r(`register wait does not accept the "${t}" field`);let n=L(e.eventType);if(!n.ok)return r(n.reason);let o=e.correlationKey;return typeof o!="string"||o.length===0?r("correlationKey must be a non-empty string"):u({eventType:n.value,correlationKey:o})}function pt(e){if(!i(e))return r("complete body must be a JSON object");let t=k(e,["eventType","correlationKey","outcome","eventId"]);if(t!==void 0)return r(`complete wait does not accept the "${t}" field`);let n=e.outcome;if(n!=="received"&&n!=="timed_out")return r('outcome must be "received" or "timed_out"');let o=L(e.eventType);if(!o.ok)return r(o.reason);let s=e.correlationKey;if(typeof s!="string"||s.length===0)return r("correlationKey must be a non-empty string");let a={eventType:o.value,correlationKey:s,outcome:n};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 gt(e){return!i(e)||e.registered!==!0?r("register wait data surface shape is invalid"):u({registered:!0})}function L(e){return typeof e!="string"||e.length===0?r("eventType must be a non-empty string"):ue.test(e)?u(e):r("eventType must match ^[A-Za-z0-9_-]{1,100}$")}function k(e,t){return Object.keys(e).find(n=>!t.includes(n))}var ae="/internal/flow-versions",Rt="/:flowVersionId/handler-bundles",F="/internal/installations",mt="/:installationId/handler-bundles";function yt(e,t){return`${ae}/${encodeURIComponent(e)}/handler-bundles?compiledArtifactId=${encodeURIComponent(t)}`}function kt(e){return`${F}/${encodeURIComponent(e.installationId)}/handler-bundles?workspaceId=${encodeURIComponent(e.workspaceId)}&artifactDigest=${encodeURIComponent(e.artifactDigest)}`}var ce=new Set(["managed_only","managed_plus_unmanaged_sdk"]);function b(e){if(!I(e))return H("runtimeNetwork must be a JSON object");let t=e.networkModel;return typeof t!="string"||!ce.has(t)?H("runtimeNetwork.networkModel is unknown"):!q(e.apiHosts)||!q(e.authHosts)||typeof e.httpsOnly!="boolean"?H("runtimeNetwork host/https fields are invalid"):{ok:!0,value:{networkModel:t,apiHosts:e.apiHosts,authHosts:e.authHosts,httpsOnly:e.httpsOnly}}}function It(e){if(!I(e)||typeof e.flowVersionId!="string"||typeof e.compiledArtifactId!="string"||!Array.isArray(e.bundles))return E("handler bundles data surface shape is invalid");let t=W(e.bundles);return t.ok?{ok:!0,value:{flowVersionId:e.flowVersionId,compiledArtifactId:e.compiledArtifactId,bundles:t.value}}:t}function _t(e){if(!I(e)||typeof e.installationId!="string"||typeof e.artifactDigest!="string"||!Array.isArray(e.bundles))return E("tool handler bundles data surface shape is invalid");let t=W(e.bundles);return t.ok?{ok:!0,value:{installationId:e.installationId,artifactDigest:e.artifactDigest,bundles:t.value}}:t}function W(e){let t=[];for(let n of e){let o=de(n);if(!o.ok)return o;t.push(o.value)}return{ok:!0,value:t}}function de(e){if(!I(e)||typeof e.toolRef!="string"||e.kind!=="handler"&&e.kind!=="request")return E("handler bundle entry shape is invalid");if(e.kind==="request"){if(e.module!==void 0)return E("a request bundle must not carry a module");let o=b(e.runtimeNetwork);return o.ok?{ok:!0,value:{toolRef:e.toolRef,kind:"request",runtimeNetwork:o.value}}:o}let t=e.module;if(!I(t)||typeof t.entry!="string"||t.entry.length===0||!le(t.files))return E("a handler bundle must carry a { entry, files } module");let n=b(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 E(e){return{ok:!1,kind:"shape",reason:e}}function H(e){return{ok:!1,kind:"runtime_network",reason:e}}function I(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function q(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function le(e){return I(e)&&Object.values(e).every(t=>typeof t=="string")}var x="/internal/webhook-trigger-instances",Pt="/:triggerInstanceId/context",St="/:triggerInstanceId/handler-bundles",Ct="/:triggerInstanceId/deliveries/:deliveryId",bt="/:triggerInstanceId/events",At="/:triggerInstanceId/rearm",w=e=>`${x}/${encodeURIComponent(e)}`;function vt(e,t){return`${w(e)}/context?artifactDigest=${encodeURIComponent(t)}`}function Nt(e,t){return`${w(e)}/handler-bundles?artifactDigest=${encodeURIComponent(t)}`}function Ot(e,t){return`${w(e)}/deliveries/${encodeURIComponent(t)}`}function Dt(e){return`${w(e)}/events`}function Ut(e){return`${w(e)}/rearm`}var Bt="/:installationId/webhook-protocol-adapter-bundle";function Ht(e){return`${F}/${encodeURIComponent(e.installationId)}/webhook-protocol-adapter-bundle?workspaceId=${encodeURIComponent(e.workspaceId)}&artifactDigest=${encodeURIComponent(e.artifactDigest)}`}var Ft="modules/webhook/protocol-adapter.js";function $t(e){return`modules/webhook/protocol-adapter-${e}.js`}function Gt(e){let t=i(e)?y(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&&!pe(e.connection)||!ge(e.runtime)||!t.ok||t.value.kind!=="webhook-trigger"?r("webhook watcher context surface shape is invalid"):u(e)}function pe(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 ge(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 Mt(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 Kt(e){if(!i(e)||typeof e.triggerRef!="string"||typeof e.artifactDigest!="string"||!Array.isArray(e.modules)||!e.modules.every(fe))return{ok:!1,kind:"shape",reason:"trigger handler bundles data surface shape is invalid"};let t=b(e.runtimeNetwork);return t.ok?{ok:!0,value:{triggerRef:e.triggerRef,artifactDigest:e.artifactDigest,modules:e.modules,runtimeNetwork:t.value}}:t}function fe(e){return i(e)&&typeof e.specifier=="string"&&e.specifier.length>0&&typeof e.source=="string"}function Lt(e){if(!i(e))return r("publish events body must be a JSON object");let t=$(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=Re(a);if(!c.ok)return c;s.push(c.value)}return u({deliveryId:n,events:s})}function Re(e){if(!i(e))return r("each event must be a JSON object");let t=$(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 qt(e){if(!i(e))return r("rearm body must be a JSON object");let t=$(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 $(e,t){return Object.keys(e).find(n=>!t.includes(n))}var T="/internal/polling-trigger-instances",Jt="/:pollingInstanceId/context",Xt="/:pollingInstanceId/handler-bundles",Yt="/:pollingInstanceId/ticks/:tickId/events",G=e=>`${T}/${encodeURIComponent(e)}`;function zt(e,t,n){return`${G(e)}/context?artifactDigest=${encodeURIComponent(t)}&tickId=${encodeURIComponent(n)}`}function Qt(e,t){return`${G(e)}/handler-bundles?artifactDigest=${encodeURIComponent(t)}`}function Zt(e,t){return`${G(e)}/ticks/${encodeURIComponent(t)}/events`}function en(e){let t=i(e)?y(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&&!me(e.connection)||!ye(e.runtime)||!t.ok||t.value.kind!=="polling-trigger"||!ke(e.tick)||!Ie(e.limits)?r("polling trigger context surface shape is invalid"):u(e)}function me(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 ye(e){if(!i(e)||e.type!=="polling"||typeof e.trigger_id!="string"||typeof e.trigger_ref!="string")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 ke(e){return i(e)&&typeof e.tickId=="string"&&typeof e.scheduledAt=="string"&&typeof e.attempt=="number"}function Ie(e){return i(e)&&typeof e.maxEventsPerTick=="number"}function tn(e){if(!i(e))return r("publish body must be a JSON object");let t=j(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=_e(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 _e(e){if(!i(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`);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 nn(e){return!i(e)||typeof e.tickId!="string"||typeof e.cursorUpdated!="boolean"||!Array.isArray(e.results)||!e.results.every(he)?r("publish polling tick events data surface shape is invalid"):u(e)}function he(e){return i(e)&&typeof e.eventId=="string"&&typeof e.dedupeKey=="string"&&typeof e.duplicate=="boolean"&&(e.flowRunId===null||typeof e.flowRunId=="string")}function j(e,t){return Object.keys(e).find(n=>!t.includes(n))}var V="/internal/egress-grants",M="/internal/tool-invocations",cn="/:flowRunId/egress-grant",dn="/:invocationId/egress-grant",ln="/:pollingInstanceId/egress-grant",pn="/:triggerInstanceId/egress-grant",gn="/:grantId/consume",fn="/:grantId/audit",Rn=e=>`${f}/${encodeURIComponent(e)}/egress-grant`,mn=e=>`${M}/${encodeURIComponent(e)}/egress-grant`,yn=e=>`${T}/${encodeURIComponent(e)}/egress-grant`,kn=e=>`${x}/${encodeURIComponent(e)}/egress-grant`,In=e=>`${V}/${encodeURIComponent(e)}/consume`,_n=e=>`${V}/${encodeURIComponent(e)}/audit`,Ee=["flow_action","single_tool","polling_trigger","webhook_trigger"],xe=/^[A-Za-z0-9][A-Za-z0-9:_+/=.-]{15,1023}$/;function P(e){return typeof e=="string"&&xe.test(e)}function we(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 d(e){return{ok:!1,kind:"shape",reason:e}}function S(){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 N(e){if(!i(e))return"request must be a JSON object"}function hn(e){let t=v(e,["nodeId","request","requestDigest"]);if(!t.ok)return d(t.reason);let n=t.record.nodeId;if(typeof n!="string"||n.length===0)return d("nodeId is required");let o=N(t.record.request);if(o!==void 0)return d(o);let s=t.record.requestDigest;return P(s)?{ok:!0,value:{nodeId:n,requestDigest:s,requestHasMultipartFiles:we(t.record.request)}}:S()}function En(e){let t=v(e,["request","requestDigest"]);if(!t.ok)return d(t.reason);let n=N(t.record.request);if(n!==void 0)return d(n);let o=t.record.requestDigest;return P(o)?{ok:!0,value:{requestDigest:o}}:S()}function xn(e){let t=v(e,["tickId","request","requestDigest"]);if(!t.ok)return d(t.reason);let n=t.record.tickId;if(typeof n!="string"||n.length===0)return d("tickId is required");let o=N(t.record.request);if(o!==void 0)return d(o);let s=t.record.requestDigest;return P(s)?{ok:!0,value:{tickId:n,requestDigest:s}}:S()}function wn(e){let t=v(e,["phase","lifecycle","request","requestDigest"]);if(!t.ok)return d(t.reason);let n=t.record.phase;if(n!=="lifecycle"&&n!=="handler")return d('phase must be "lifecycle" or "handler"');let o=t.record.lifecycle,s;if(o!==void 0){if(o!=="enable"&&o!=="disable"&&o!=="renew")return d('lifecycle must be "enable", "disable", or "renew"');s=o}if(n==="lifecycle"&&s===void 0)return d("lifecycle is required for the lifecycle phase");let a=N(t.record.request);if(a!==void 0)return d(a);let c=t.record.requestDigest;return P(c)?{ok:!0,value:{phase:n,...s!==void 0?{lifecycle:s}:{},requestDigest:c}}:S()}function J(e){return Ee.includes(e)?e:void 0}var Te=["scopeKind","scopeId","requestDigest"];function Tn(e){if(!i(e))return d("consume body must be a JSON object");for(let s of Object.keys(e))if(!Te.includes(s))return d(`consume does not accept the "${s}" field`);let t=J(e.scopeKind);if(t===void 0)return d("scopeKind is invalid");let n=e.scopeId;if(typeof n!="string"||n.length===0)return d("scopeId is required");let o=e.requestDigest;return P(o)?{ok:!0,value:{scopeKind:t,scopeId:n,requestDigest:o}}:S()}var Pe=["scopeKind","scopeId","providerHost","status","durationMs","requestBytes","responseBytes","errorCode"];function A(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 Pn(e){if(!i(e))return d("audit body must be a JSON object");for(let p of Object.keys(e))if(!Pe.includes(p))return d(`audit does not accept the "${p}" field`);let t=J(e.scopeKind);if(t===void 0)return d("scopeKind is invalid");let n=e.scopeId;if(typeof n!="string"||n.length===0)return d("scopeId is required");let o=e.providerHost;if(typeof o!="string"||o.length===0)return d("providerHost is required");let s=A(e.durationMs,"durationMs");if(!s.ok)return d(s.reason);let a;if(e.status!==void 0){let p=A(e.status,"status");if(!p.ok)return d(p.reason);a=p.value}let c;if(e.requestBytes!==void 0){let p=A(e.requestBytes,"requestBytes");if(!p.ok)return d(p.reason);c=p.value}let l;if(e.responseBytes!==void 0){let p=A(e.responseBytes,"responseBytes");if(!p.ok)return d(p.reason);l=p.value}let U;if(e.errorCode!==void 0){let p=e.errorCode;if(typeof p!="string"||p.length===0)return d("errorCode must be a non-empty string");U=p}return{ok:!0,value:{scopeKind:t,scopeId:n,providerHost:o,...a!==void 0?{status:a}:{},durationMs:s.value,...c!==void 0?{requestBytes:c}:{},...l!==void 0?{responseBytes:l}:{},...U!==void 0?{errorCode:U}:{}}}}function Sn(e){return!i(e)||!i(e.grant)?r("egress grant envelope must carry a grant object"):u(e.grant)}function Cn(e){return!i(e)||e.consumed!==!0?r("egress grant consume data must carry consumed:true"):u({consumed:!0})}var Un="/:flowRunId/runtime-credential",Bn="/:invocationId/runtime-credential",Hn="/:pollingInstanceId/runtime-credential",Fn="/:triggerInstanceId/runtime-credential",$n=e=>`${f}/${encodeURIComponent(e)}/runtime-credential`,Gn=e=>`${M}/${encodeURIComponent(e)}/runtime-credential`,Mn=e=>`${T}/${encodeURIComponent(e)}/runtime-credential`,Kn=e=>`${x}/${encodeURIComponent(e)}/runtime-credential`,Ln=["flow_action","tool_invoke","polling_trigger","webhook_trigger"];function O(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 qn(e){let t=O(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 Wn(e){let t=O(e??{},[]);return t.ok?u(null):r(t.reason)}function jn(e){let t=O(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 Vn(e){let t=O(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 Jn(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 D(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 K(e){return!i(e)||e.method!=="GET"&&e.method!=="PUT"||typeof e.url!="string"||typeof e.expires_at!="string"||!be(e.headers)?r("presigned file URL data is invalid"):u(e)}function Se(e){if(!i(e))return r("file upload session data is invalid");let t=D(e.file);if(!t.ok)return r(t.reason);let n=K(e.upload);return n.ok?u({file:t.value,upload:n.value}):r(n.reason)}function Ce(e){if(!i(e))return r("file metadata data is invalid");let t=D(e.file);return t.ok?u({file:t.value}):r(t.reason)}function be(e){return i(e)?Object.values(e).every(t=>typeof t=="string"):!1}var _="/internal/files",er="/upload-session",tr="/:fileId/complete",nr="/:fileId/access",rr="/:fileId/stat",or="/:fileId/content",ir=()=>_,sr=()=>`${_}/upload-session`,ur=e=>`${_}/${encodeURIComponent(e)}/complete`,ar=(e,t)=>`${_}/${encodeURIComponent(e)}/access?intent=${encodeURIComponent(t)}`,X=e=>`?scope_kind=${encodeURIComponent(e.scopeKind)}&scope_id=${encodeURIComponent(e.scopeId)}`,cr=(e,t)=>`${_}/${encodeURIComponent(e)}/stat${X(t)}`,dr=(e,t)=>`${_}/${encodeURIComponent(e)}/content${X(t)}`;function lr(e){if(!i(e))return r("internal file access data is invalid");if(e.intent==="runtime_read"||e.intent==="provider_multipart"){let t=D(e.file);if(!t.ok)return r(t.reason);let n=K(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 Rr="/:flowRunId/human-inputs",mr="/:flowRunId/human-inputs/:requestId",yr="/:flowRunId/human-inputs/:requestId/expire",kr="/:flowRunId/human-inputs/:requestId/acknowledge",Ae=e=>`${f}/${encodeURIComponent(e)}/human-inputs`,Y=(e,t)=>`${Ae(e)}/${encodeURIComponent(t)}`,Ir=(e,t)=>`${Y(e,t)}/expire`,_r=(e,t)=>`${Y(e,t)}/acknowledge`,ve="human_input_resolved";function hr(e){return`${ve}_${e}`}function g(e){return{ok:!1,reason:e}}function m(e,t){return i(e)?{ok:!0,value:e}:g(`${t} must be an object`)}function h(e,t){return typeof e!="string"||e.length===0?g(`${t} must be a non-empty string`):{ok:!0,value:e}}var Ne=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?(?:Z|[+-]\d{2}:\d{2})$/;function Oe(e,t){return typeof e!="string"||!Ne.test(e)||Number.isNaN(Date.parse(e))?g(`${t} must be an ISO-8601 timestamp`):{ok:!0,value:e}}function De(e){let t=m(e,"renderedPrompt");if(!t.ok)return t;let n=h(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 g("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 g("renderedPrompt.format is invalid");o.format=t.value.format}return{ok:!0,value:o}}function Ue(e){let t=m(e,"input");if(!t.ok)return t;let n=t.value.kind;if(n==="choice"){if(!Array.isArray(t.value.choices))return g("input.choices must be an array")}else if(n!=="text")if(n==="form"){if(!Array.isArray(t.value.fields))return g("input.fields must be an array")}else return g("input.kind is invalid");return{ok:!0,value:t.value}}function Be(e){if(e==null)return{ok:!0,value:void 0};let t=m(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 g("partiallyRenderedDelivery.actions must be an array");let o=[];for(let s of n){let a=m(s,"delivery action");if(!a.ok)return a;let c=h(a.value.id,"delivery action id");if(!c.ok)return c;let l=z(a.value.inputs,`delivery action '${c.value}' inputs`);if(!l.ok)return l;o.push({id:c.value,inputs:l.value})}return{ok:!0,value:{actions:o}}}function z(e,t){let n=m(e,t);if(!n.ok)return n;let o={};for(let[s,a]of Object.entries(n.value)){let c=Q(a,`${t}.${s}`);if(!c.ok)return c;o[s]=c.value}return{ok:!0,value:o}}function Q(e,t){let n=m(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=h(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 g(`${t}.items must be an array`);let s=[];for(let[a,c]of n.value.items.entries()){let l=Q(c,`${t}[${a}]`);if(!l.ok)return l;s.push(l.value)}return{ok:!0,value:{kind:"array",items:s}}}case"object":{let s=z(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 g(`${t}.parts must be an array`);let s=[];for(let[a,c]of n.value.parts.entries()){let l=He(c,`${t}.parts[${a}]`);if(!l.ok)return l;s.push(l.value)}return{ok:!0,value:{kind:"template",parts:s}}}default:return g(`${t}.kind is invalid`)}}function He(e,t){let n=m(e,t);if(!n.ok)return n;let o=n.value.kind;if(o==="literal")return typeof n.value.value!="string"?g(`${t}.value must be a string`):{ok:!0,value:{kind:"literal",value:n.value.value}};if(o==="human_input_ref"){let s=h(n.value.path,`${t}.path`);return s.ok?{ok:!0,value:{kind:"human_input_ref",path:s.value}}:s}return g(`${t}.kind is invalid`)}function Er(e){let t=m(e,"request body");if(!t.ok)return r(t.reason);let n=h(t.value.nodeId,"nodeId");if(!n.ok)return r(n.reason);let o=De(t.value.renderedPrompt);if(!o.ok)return r(o.reason);let s=Ue(t.value.input);if(!s.ok)return r(s.reason);let a=h(t.value.timeout,"timeout");if(!a.ok)return r(a.reason);let c=Oe(t.value.expiresAt,"expiresAt");if(!c.ok)return r(c.reason);let l=Be(t.value.partiallyRenderedDelivery);return l.ok?u({nodeId:n.value,renderedPrompt:o.value,input:s.value,timeout:a.value,expiresAt:c.value,...l.value!==void 0?{partiallyRenderedDelivery:l.value}:{}}):r(l.reason)}function Fe(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 xr(e){if(!i(e)||typeof e.created!="boolean")return r("human input create data must carry created:boolean");let t=Fe(e.request);return t.ok?u({created:e.created,request:t.value}):t}function wr(e){return!i(e)||e.acknowledged!==!0?r("human input acknowledge data must carry acknowledged:true"):u({acknowledged:!0})}var Pr="ablehi-wfp-user-runtime-manifest/v1",Sr="unknown";function Cr(e){return e.endsWith(".js")?`${e.slice(0,-3)}.manifest.json`:`${e}.manifest.json`}var Ar="/internal/deployment-handshake",$e=["start","terminate","send-event","start-webhook-watcher","run-polling-tick","invoke-tool","invoke-trigger-handler","invoke-webhook-protocol-adapter","deployment-handshake"],vr=$e,Nr="HANDSHAKE_REQUEST_INVALID",Or="HANDSHAKE_SECRET_UNCONFIGURED",Dr="HANDSHAKE_SECRET_MISMATCH",Ur="HANDSHAKE_CONTRACT_VERSION_MISMATCH",Br="HANDSHAKE_DISPATCH_NAMESPACE_MISMATCH",Hr="HANDSHAKE_CAPABILITY_MISSING";function Fr(e){return[e.nonce,e.timestamp,e.contractVersion,e.dispatchNamespace].map(n=>`${n.length}:${n}`).join(".")}function $r(e){return["response",e.nonce,e.contractVersion,e.dispatchNamespace,...e.capabilities].map(n=>`${n.length}:${n}`).join(".")}export{Le as CONTEXT_STATE_CLEANUP_ROUTE_PATH,$e as DEPLOYMENT_HANDSHAKE_DISPATCHER_CAPABILITIES,vr as DEPLOYMENT_HANDSHAKE_REQUIRED_CAPABILITIES,Ar as DEPLOYMENT_HANDSHAKE_ROUTE,fn as EGRESS_GRANT_AUDIT_ROUTE_SUBPATH,gn as EGRESS_GRANT_CONSUME_ROUTE_SUBPATH,Ee as EGRESS_GRANT_SCOPE_KINDS,rt as EVENT_WAIT_ROUTE_SUBPATH,Xe as EXECUTION_CONTEXT_ROUTE_SUBPATH,nr as FILE_ACCESS_ROUTE_SUBPATH,tr as FILE_COMPLETE_ROUTE_SUBPATH,or as FILE_CONTENT_ROUTE_SUBPATH,rr as FILE_STAT_ROUTE_SUBPATH,er as FILE_UPLOAD_SESSION_ROUTE_SUBPATH,cn as FLOW_RUN_EGRESS_GRANT_ROUTE_SUBPATH,nt as FLOW_RUN_RESULT_ROUTE_SUBPATH,Un as FLOW_RUN_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,Rt as HANDLER_BUNDLES_ROUTE_SUBPATH,Hr as HANDSHAKE_CAPABILITY_MISSING,Ur as HANDSHAKE_CONTRACT_VERSION_MISMATCH,Br as HANDSHAKE_DISPATCH_NAMESPACE_MISMATCH,Nr as HANDSHAKE_REQUEST_INVALID,Dr as HANDSHAKE_SECRET_MISMATCH,Or as HANDSHAKE_SECRET_UNCONFIGURED,Rr as HUMAN_INPUTS_ROUTE_SUBPATH,kr as HUMAN_INPUT_ACKNOWLEDGE_ROUTE_SUBPATH,yr as HUMAN_INPUT_EXPIRE_ROUTE_SUBPATH,mr as HUMAN_INPUT_REQUEST_ROUTE_SUBPATH,ve as HUMAN_INPUT_RESOLVED_EVENT_PREFIX,V as INTERNAL_EGRESS_GRANTS_ROUTE_PREFIX,_ as INTERNAL_FILES_ROUTE_PREFIX,f as INTERNAL_FLOW_RUNS_ROUTE_PREFIX,ae as INTERNAL_FLOW_VERSIONS_ROUTE_PREFIX,F as INTERNAL_INSTALLATIONS_ROUTE_PREFIX,T as INTERNAL_POLLING_TRIGGER_INSTANCES_ROUTE_PREFIX,M as INTERNAL_TOOL_INVOCATIONS_ROUTE_PREFIX,x as INTERNAL_WEBHOOK_TRIGGER_INSTANCES_ROUTE_PREFIX,Jt as POLLING_TRIGGER_CONTEXT_ROUTE_SUBPATH,ln as POLLING_TRIGGER_EGRESS_GRANT_ROUTE_SUBPATH,Xt as POLLING_TRIGGER_HANDLER_BUNDLES_ROUTE_SUBPATH,Hn as POLLING_TRIGGER_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,Yt as POLLING_TRIGGER_TICK_EVENTS_ROUTE_SUBPATH,Ln as RUNTIME_CREDENTIAL_SESSION_SCOPE_KINDS,Z as SERVER_EXECUTION_CONTRACT_VERSION,tt as STEP_RESULT_ROUTE_SUBPATH,mt as TOOL_HANDLER_BUNDLES_ROUTE_SUBPATH,dn as TOOL_INVOCATION_EGRESS_GRANT_ROUTE_SUBPATH,Bn as TOOL_INVOCATION_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,Bt as WEBHOOK_PROTOCOL_ADAPTER_BUNDLE_ROUTE_SUBPATH,Ft as WEBHOOK_PROTOCOL_ADAPTER_MODULE,Pt as WEBHOOK_TRIGGER_CONTEXT_ROUTE_SUBPATH,Ct as WEBHOOK_TRIGGER_DELIVERY_ROUTE_SUBPATH,pn as WEBHOOK_TRIGGER_EGRESS_GRANT_ROUTE_SUBPATH,bt as WEBHOOK_TRIGGER_EVENTS_ROUTE_SUBPATH,St as WEBHOOK_TRIGGER_HANDLER_BUNDLES_ROUTE_SUBPATH,At as WEBHOOK_TRIGGER_REARM_ROUTE_SUBPATH,Fn as WEBHOOK_TRIGGER_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,Pr as WFP_USER_RUNTIME_MANIFEST_FORMAT_VERSION,Sr as WFP_USER_RUNTIME_UNKNOWN_SOURCE_REVISION,Fr as deploymentHandshakeProbePayload,$r as deploymentHandshakeResponseProofPayload,_n as egressGrantAuditPath,In as egressGrantConsumePath,st as eventWaitPath,Ye as executionContextPath,Rn as flowRunEgressGrantPath,it as flowRunResultPath,$n as flowRunRuntimeCredentialPath,$t as flowScriptProtocolAdapterModuleName,yt as handlerBundlesPath,_r as humanInputAcknowledgePath,Ir as humanInputExpirePath,Y as humanInputRequestPath,hr as humanInputResolvedEventType,Ae as humanInputsPath,ar as internalFileAccessPath,ur as internalFileCompletePath,dr as internalFileContentPath,cr as internalFileStatPath,sr as internalFileUploadSessionPath,ir as internalFilesPath,P as isValidRequestDigest,pt as parseCompleteFlowRunWaitBody,qe as parseContextStateCleanupRequestBody,We as parseContextStateCleanupResponseData,y as parseContextStateScope,Er as parseCreateHumanInputBody,Pn as parseEgressGrantAuditBody,Tn as parseEgressGrantConsumeBody,Cn as parseEgressGrantConsumeData,Sn as parseEgressGrantData,ze as parseExecutionContextData,Ce as parseFileMetadataData,D as parseFileRefData,re as parseFileRuntimeLimits,Se as parseFileUploadSessionData,hn as parseFlowActionGrantBody,ct as parseFlowRunResultBody,dt as parseFlowRunResultData,qn as parseFlowRuntimeCredentialBody,de as parseHandlerBundle,It as parseHandlerBundlesData,wr as parseHumanInputAcknowledgeData,xr as parseHumanInputCreateData,Fe as parseHumanInputRequestViewData,lr as parseInternalFileAccessData,tn as parsePollingPublishBody,jn as parsePollingRuntimeCredentialBody,en as parsePollingTriggerContext,xn as parsePollingTriggerGrantBody,nn as parsePublishPollingTickEventsData,lt as parseRegisterFlowRunWaitBody,gt as parseRegisterFlowRunWaitData,Jn as parseRuntimeCredentialSessionCredential,b as parseRuntimeNetwork,En as parseSingleToolGrantBody,Wn as parseSingleToolRuntimeCredentialBody,ut as parseStepRecordBody,at as parseStepRecordData,_t as parseToolHandlerBundlesData,Kt as parseTriggerHandlerBundlesData,Mt as parseWebhookDelivery,Lt as parseWebhookPublishEventsBody,qt as parseWebhookRearmBody,Vn as parseWebhookRuntimeCredentialBody,wn as parseWebhookTriggerGrantBody,Gt as parseWebhookWatcherContext,zt as pollingTriggerContextPath,yn as pollingTriggerEgressGrantPath,Qt as pollingTriggerHandlerBundlesPath,Mn as pollingTriggerRuntimeCredentialPath,Zt as pollingTriggerTickEventsPath,we as requestHasMultipartFileParts,ot as stepResultPath,kt as toolHandlerBundlesPath,mn as toolInvocationEgressGrantPath,Gn as toolInvocationRuntimeCredentialPath,Ht as webhookProtocolAdapterBundlePath,vt as webhookTriggerContextPath,Ot as webhookTriggerDeliveryPath,kn as webhookTriggerEgressGrantPath,Dt as webhookTriggerEventsPath,Nt as webhookTriggerHandlerBundlesPath,Ut as webhookTriggerRearmPath,Kn as webhookTriggerRuntimeCredentialPath,Cr as wfpUserRuntimeManifestPath};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,802 @@
|
|
|
1
|
+
import { PublishedFlowDefinition, RuntimeHumanInputSpec } from '@ablehi/flow-contract';
|
|
2
|
+
|
|
3
|
+
declare const SERVER_EXECUTION_CONTRACT_VERSION = "0.2.8";
|
|
4
|
+
type ServerExecutionContractVersion = typeof SERVER_EXECUTION_CONTRACT_VERSION;
|
|
5
|
+
|
|
6
|
+
type ContractParseResult<T> = {
|
|
7
|
+
ok: true;
|
|
8
|
+
value: T;
|
|
9
|
+
} | {
|
|
10
|
+
ok: false;
|
|
11
|
+
reason: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
declare const CONTEXT_STATE_CLEANUP_ROUTE_PATH = "/cleanup-state-scopes";
|
|
15
|
+
type ContextStateScope = {
|
|
16
|
+
kind: "webhook-trigger";
|
|
17
|
+
workspaceId: string;
|
|
18
|
+
triggerInstanceId: string;
|
|
19
|
+
} | {
|
|
20
|
+
kind: "polling-trigger";
|
|
21
|
+
workspaceId: string;
|
|
22
|
+
pollingInstanceId: string;
|
|
23
|
+
} | {
|
|
24
|
+
kind: "flow-action";
|
|
25
|
+
workspaceId: string;
|
|
26
|
+
flowId: string;
|
|
27
|
+
nodeId: string;
|
|
28
|
+
connectionId: string | null;
|
|
29
|
+
};
|
|
30
|
+
type ContextStateCleanupRequestBody = {
|
|
31
|
+
scopes: ContextStateScope[];
|
|
32
|
+
};
|
|
33
|
+
type ContextStateCleanupResponseData = {
|
|
34
|
+
deleted: number;
|
|
35
|
+
};
|
|
36
|
+
declare function parseContextStateScope(value: unknown): ContractParseResult<ContextStateScope>;
|
|
37
|
+
declare function parseContextStateCleanupRequestBody(body: unknown): ContractParseResult<ContextStateCleanupRequestBody>;
|
|
38
|
+
declare function parseContextStateCleanupResponseData(data: unknown): ContractParseResult<ContextStateCleanupResponseData>;
|
|
39
|
+
|
|
40
|
+
declare const INTERNAL_FLOW_RUNS_ROUTE_PREFIX = "/internal/flow-runs";
|
|
41
|
+
declare const EXECUTION_CONTEXT_ROUTE_SUBPATH = "/:flowRunId/execution-context";
|
|
42
|
+
declare function executionContextPath(flowRunId: string): string;
|
|
43
|
+
type ExecutionBindingConnection = {
|
|
44
|
+
installationId: string;
|
|
45
|
+
connectionRef: string;
|
|
46
|
+
connectionId: string;
|
|
47
|
+
authProfileRef: string;
|
|
48
|
+
authType: string;
|
|
49
|
+
connectionConfig?: Record<string, unknown>;
|
|
50
|
+
};
|
|
51
|
+
type ExecutionBinding<TToolDescriptor = Record<string, unknown>, TIntegrationDescriptor = Record<string, unknown>> = {
|
|
52
|
+
nodeId: string;
|
|
53
|
+
toolRef: string;
|
|
54
|
+
toolDescriptor: TToolDescriptor;
|
|
55
|
+
integrationDescriptor: TIntegrationDescriptor;
|
|
56
|
+
connection: ExecutionBindingConnection;
|
|
57
|
+
stateScope: ContextStateScope;
|
|
58
|
+
};
|
|
59
|
+
type FileRuntimeLimits = {
|
|
60
|
+
fileMaxBytes: number;
|
|
61
|
+
fileReadMaxBytes: number;
|
|
62
|
+
inlineMultipartBytesMax: number;
|
|
63
|
+
};
|
|
64
|
+
type FlowExecutionContextFileRuntime = {
|
|
65
|
+
limits: FileRuntimeLimits;
|
|
66
|
+
} | null;
|
|
67
|
+
type ExecutionContextCompiled = {
|
|
68
|
+
irSchemaVersion: string;
|
|
69
|
+
interpreterContractVersion: string;
|
|
70
|
+
ir: PublishedFlowDefinition;
|
|
71
|
+
compiledArtifactId: string;
|
|
72
|
+
};
|
|
73
|
+
type ExecutionContextData<TToolDescriptor = Record<string, unknown>, TIntegrationDescriptor = Record<string, unknown>> = {
|
|
74
|
+
flowRunId: string;
|
|
75
|
+
workspaceId: string;
|
|
76
|
+
input: Record<string, unknown>;
|
|
77
|
+
compiled: ExecutionContextCompiled;
|
|
78
|
+
executionBindings: Array<ExecutionBinding<TToolDescriptor, TIntegrationDescriptor>>;
|
|
79
|
+
fileRuntime: FlowExecutionContextFileRuntime;
|
|
80
|
+
};
|
|
81
|
+
declare function parseFileRuntimeLimits(value: unknown): ContractParseResult<FileRuntimeLimits>;
|
|
82
|
+
declare function parseExecutionContextData(data: unknown): ContractParseResult<ExecutionContextData>;
|
|
83
|
+
|
|
84
|
+
declare const STEP_RESULT_ROUTE_SUBPATH = "/:flowRunId/steps/:nodeId/result";
|
|
85
|
+
declare const FLOW_RUN_RESULT_ROUTE_SUBPATH = "/:flowRunId/result";
|
|
86
|
+
declare const EVENT_WAIT_ROUTE_SUBPATH = "/:flowRunId/event-waits/:nodeId";
|
|
87
|
+
declare function stepResultPath(flowRunId: string, nodeId: string): string;
|
|
88
|
+
declare function flowRunResultPath(flowRunId: string): string;
|
|
89
|
+
declare function eventWaitPath(flowRunId: string, nodeId: string): string;
|
|
90
|
+
type StepRecordResult = {
|
|
91
|
+
status: "succeeded";
|
|
92
|
+
output: unknown;
|
|
93
|
+
} | {
|
|
94
|
+
status: "failed";
|
|
95
|
+
errorCode: string;
|
|
96
|
+
issues?: unknown;
|
|
97
|
+
};
|
|
98
|
+
type StepRecordBody = {
|
|
99
|
+
attempt: number;
|
|
100
|
+
result: StepRecordResult;
|
|
101
|
+
durationMs?: number;
|
|
102
|
+
};
|
|
103
|
+
type StepRecordData = {
|
|
104
|
+
flowRunId: string;
|
|
105
|
+
nodeId: string;
|
|
106
|
+
recorded: "succeeded" | "failed";
|
|
107
|
+
};
|
|
108
|
+
type StepRecordBodyParseResult = {
|
|
109
|
+
ok: true;
|
|
110
|
+
value: StepRecordBody;
|
|
111
|
+
} | {
|
|
112
|
+
ok: false;
|
|
113
|
+
kind: "validation" | "step_result_invalid";
|
|
114
|
+
reason: string;
|
|
115
|
+
};
|
|
116
|
+
declare function parseStepRecordBody(body: unknown): StepRecordBodyParseResult;
|
|
117
|
+
declare function parseStepRecordData(data: unknown): ContractParseResult<StepRecordData>;
|
|
118
|
+
type RenderedFlowComposition = {
|
|
119
|
+
title: string;
|
|
120
|
+
detail: {
|
|
121
|
+
format: "markdown";
|
|
122
|
+
body: string;
|
|
123
|
+
data?: unknown;
|
|
124
|
+
};
|
|
125
|
+
report?: {
|
|
126
|
+
origin: "flow_node";
|
|
127
|
+
title?: string;
|
|
128
|
+
format: "markdown";
|
|
129
|
+
body: string;
|
|
130
|
+
data?: unknown;
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
type FlowRunResultRequestBody = {
|
|
134
|
+
status: "succeeded";
|
|
135
|
+
output?: unknown;
|
|
136
|
+
composition?: RenderedFlowComposition;
|
|
137
|
+
} | {
|
|
138
|
+
status: "failed";
|
|
139
|
+
error: {
|
|
140
|
+
code: string;
|
|
141
|
+
message: string;
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
type ParsedFlowRunResultBody = {
|
|
145
|
+
status: "succeeded" | "failed";
|
|
146
|
+
output?: unknown;
|
|
147
|
+
error?: {
|
|
148
|
+
code: string;
|
|
149
|
+
message: string;
|
|
150
|
+
};
|
|
151
|
+
composition?: unknown;
|
|
152
|
+
};
|
|
153
|
+
declare function parseFlowRunResultBody(body: unknown): ContractParseResult<ParsedFlowRunResultBody>;
|
|
154
|
+
type FlowRunResultData = {
|
|
155
|
+
run: unknown;
|
|
156
|
+
};
|
|
157
|
+
declare function parseFlowRunResultData(data: unknown): ContractParseResult<FlowRunResultData>;
|
|
158
|
+
type RegisterFlowRunWaitBody = {
|
|
159
|
+
eventType: string;
|
|
160
|
+
correlationKey: string;
|
|
161
|
+
};
|
|
162
|
+
type CompleteFlowRunWaitBody = {
|
|
163
|
+
eventType: string;
|
|
164
|
+
correlationKey: string;
|
|
165
|
+
outcome: "received" | "timed_out";
|
|
166
|
+
eventId?: string;
|
|
167
|
+
};
|
|
168
|
+
type RegisterFlowRunWaitData = {
|
|
169
|
+
registered: true;
|
|
170
|
+
};
|
|
171
|
+
type CompleteFlowRunWaitData = {
|
|
172
|
+
completed: true;
|
|
173
|
+
};
|
|
174
|
+
declare function parseRegisterFlowRunWaitBody(body: unknown): ContractParseResult<RegisterFlowRunWaitBody>;
|
|
175
|
+
declare function parseCompleteFlowRunWaitBody(body: unknown): ContractParseResult<CompleteFlowRunWaitBody>;
|
|
176
|
+
declare function parseRegisterFlowRunWaitData(data: unknown): ContractParseResult<RegisterFlowRunWaitData>;
|
|
177
|
+
|
|
178
|
+
declare const INTERNAL_FLOW_VERSIONS_ROUTE_PREFIX = "/internal/flow-versions";
|
|
179
|
+
declare const HANDLER_BUNDLES_ROUTE_SUBPATH = "/:flowVersionId/handler-bundles";
|
|
180
|
+
declare const INTERNAL_INSTALLATIONS_ROUTE_PREFIX = "/internal/installations";
|
|
181
|
+
declare const TOOL_HANDLER_BUNDLES_ROUTE_SUBPATH = "/:installationId/handler-bundles";
|
|
182
|
+
declare function handlerBundlesPath(flowVersionId: string, compiledArtifactId: string): string;
|
|
183
|
+
declare function toolHandlerBundlesPath(args: {
|
|
184
|
+
installationId: string;
|
|
185
|
+
workspaceId: string;
|
|
186
|
+
artifactDigest: string;
|
|
187
|
+
}): string;
|
|
188
|
+
type RuntimeNetworkModel = "managed_only" | "managed_plus_unmanaged_sdk";
|
|
189
|
+
type RuntimeNetwork = {
|
|
190
|
+
networkModel: RuntimeNetworkModel;
|
|
191
|
+
apiHosts: string[];
|
|
192
|
+
authHosts: string[];
|
|
193
|
+
httpsOnly: boolean;
|
|
194
|
+
};
|
|
195
|
+
type HandlerBundleModule = {
|
|
196
|
+
entry: string;
|
|
197
|
+
files: Record<string, string>;
|
|
198
|
+
};
|
|
199
|
+
type HandlerBundle = {
|
|
200
|
+
toolRef: string;
|
|
201
|
+
kind: "request";
|
|
202
|
+
runtimeNetwork: RuntimeNetwork;
|
|
203
|
+
} | {
|
|
204
|
+
toolRef: string;
|
|
205
|
+
kind: "handler";
|
|
206
|
+
module: HandlerBundleModule;
|
|
207
|
+
runtimeNetwork: RuntimeNetwork;
|
|
208
|
+
};
|
|
209
|
+
type HandlerBundlesData = {
|
|
210
|
+
flowVersionId: string;
|
|
211
|
+
compiledArtifactId: string;
|
|
212
|
+
bundles: HandlerBundle[];
|
|
213
|
+
};
|
|
214
|
+
type ToolHandlerBundlesData = {
|
|
215
|
+
installationId: string;
|
|
216
|
+
artifactDigest: string;
|
|
217
|
+
bundles: HandlerBundle[];
|
|
218
|
+
};
|
|
219
|
+
type HandlerBundlesParseResult<T> = {
|
|
220
|
+
ok: true;
|
|
221
|
+
value: T;
|
|
222
|
+
} | {
|
|
223
|
+
ok: false;
|
|
224
|
+
kind: "shape" | "runtime_network";
|
|
225
|
+
reason: string;
|
|
226
|
+
};
|
|
227
|
+
declare function parseRuntimeNetwork(value: unknown): HandlerBundlesParseResult<RuntimeNetwork>;
|
|
228
|
+
declare function parseHandlerBundlesData(data: unknown): HandlerBundlesParseResult<HandlerBundlesData>;
|
|
229
|
+
declare function parseToolHandlerBundlesData(data: unknown): HandlerBundlesParseResult<ToolHandlerBundlesData>;
|
|
230
|
+
declare function parseHandlerBundle(value: unknown): HandlerBundlesParseResult<HandlerBundle>;
|
|
231
|
+
|
|
232
|
+
declare const INTERNAL_WEBHOOK_TRIGGER_INSTANCES_ROUTE_PREFIX = "/internal/webhook-trigger-instances";
|
|
233
|
+
declare const WEBHOOK_TRIGGER_CONTEXT_ROUTE_SUBPATH = "/:triggerInstanceId/context";
|
|
234
|
+
declare const WEBHOOK_TRIGGER_HANDLER_BUNDLES_ROUTE_SUBPATH = "/:triggerInstanceId/handler-bundles";
|
|
235
|
+
declare const WEBHOOK_TRIGGER_DELIVERY_ROUTE_SUBPATH = "/:triggerInstanceId/deliveries/:deliveryId";
|
|
236
|
+
declare const WEBHOOK_TRIGGER_EVENTS_ROUTE_SUBPATH = "/:triggerInstanceId/events";
|
|
237
|
+
declare const WEBHOOK_TRIGGER_REARM_ROUTE_SUBPATH = "/:triggerInstanceId/rearm";
|
|
238
|
+
declare function webhookTriggerContextPath(triggerInstanceId: string, artifactDigest: string): string;
|
|
239
|
+
declare function webhookTriggerHandlerBundlesPath(triggerInstanceId: string, artifactDigest: string): string;
|
|
240
|
+
declare function webhookTriggerDeliveryPath(triggerInstanceId: string, deliveryId: string): string;
|
|
241
|
+
declare function webhookTriggerEventsPath(triggerInstanceId: string): string;
|
|
242
|
+
declare function webhookTriggerRearmPath(triggerInstanceId: string): string;
|
|
243
|
+
declare const WEBHOOK_PROTOCOL_ADAPTER_BUNDLE_ROUTE_SUBPATH = "/:installationId/webhook-protocol-adapter-bundle";
|
|
244
|
+
declare function webhookProtocolAdapterBundlePath(args: {
|
|
245
|
+
installationId: string;
|
|
246
|
+
workspaceId: string;
|
|
247
|
+
artifactDigest: string;
|
|
248
|
+
}): string;
|
|
249
|
+
type WebhookTriggerVerificationMethod = "header_exact_match" | "hmac_sha256" | "hmac_sha1";
|
|
250
|
+
type PackageWebhookTriggerRuntimeDescriptor = {
|
|
251
|
+
trigger_id: string;
|
|
252
|
+
trigger_ref: string;
|
|
253
|
+
type: "webhook";
|
|
254
|
+
webhook: {
|
|
255
|
+
verification_method: WebhookTriggerVerificationMethod;
|
|
256
|
+
signature_header: string;
|
|
257
|
+
timestamp_header?: string;
|
|
258
|
+
tolerance_seconds?: number;
|
|
259
|
+
binding_policy: "per_instance";
|
|
260
|
+
endpoint_mode: "instance";
|
|
261
|
+
ack_mode: "platform_managed";
|
|
262
|
+
event_handler_module: string;
|
|
263
|
+
enable_handler_module: string;
|
|
264
|
+
disable_handler_module: string;
|
|
265
|
+
renew_handler_module?: string;
|
|
266
|
+
};
|
|
267
|
+
};
|
|
268
|
+
type TriggerConnectionInfo = {
|
|
269
|
+
connectionId: string;
|
|
270
|
+
connectionRef: string;
|
|
271
|
+
integrationRef: string;
|
|
272
|
+
authProfileRef: string;
|
|
273
|
+
authType: "oauth2" | "oauth1" | "api_key" | "basic_auth" | "bearer" | "jwt" | "custom" | "two_step";
|
|
274
|
+
connectionConfig?: Record<string, unknown>;
|
|
275
|
+
};
|
|
276
|
+
type WebhookWatcherContext = {
|
|
277
|
+
artifactDigest: string;
|
|
278
|
+
triggerRef: string;
|
|
279
|
+
triggerName: string;
|
|
280
|
+
integrationRef: string;
|
|
281
|
+
inputs: Record<string, unknown>;
|
|
282
|
+
connection: TriggerConnectionInfo | null;
|
|
283
|
+
runtime: PackageWebhookTriggerRuntimeDescriptor;
|
|
284
|
+
stateScope: ContextStateScope;
|
|
285
|
+
watcher?: {
|
|
286
|
+
instanceId: string;
|
|
287
|
+
generation: number;
|
|
288
|
+
};
|
|
289
|
+
};
|
|
290
|
+
type WebhookDelivery = {
|
|
291
|
+
deliveryId: string;
|
|
292
|
+
receivedAt: string;
|
|
293
|
+
request: {
|
|
294
|
+
method: "POST";
|
|
295
|
+
headers: Record<string, string>;
|
|
296
|
+
rawBody: string;
|
|
297
|
+
};
|
|
298
|
+
};
|
|
299
|
+
type TriggerHandlerModule = {
|
|
300
|
+
specifier: string;
|
|
301
|
+
source: string;
|
|
302
|
+
};
|
|
303
|
+
type TriggerHandlerBundlesData = {
|
|
304
|
+
triggerRef: string;
|
|
305
|
+
artifactDigest: string;
|
|
306
|
+
modules: TriggerHandlerModule[];
|
|
307
|
+
runtimeNetwork: RuntimeNetwork;
|
|
308
|
+
};
|
|
309
|
+
type WebhookPublishEvent = {
|
|
310
|
+
eventId: string;
|
|
311
|
+
occurredAt: string;
|
|
312
|
+
dedupeKey?: string;
|
|
313
|
+
payload: Record<string, unknown>;
|
|
314
|
+
};
|
|
315
|
+
type WebhookPublishEventsBody = {
|
|
316
|
+
deliveryId: string;
|
|
317
|
+
events: WebhookPublishEvent[];
|
|
318
|
+
};
|
|
319
|
+
type WebhookPublishEventsData = {
|
|
320
|
+
deliveryId: string;
|
|
321
|
+
results: {
|
|
322
|
+
eventId: string;
|
|
323
|
+
flowRunId: string;
|
|
324
|
+
status: "dispatched" | "duplicate";
|
|
325
|
+
}[];
|
|
326
|
+
};
|
|
327
|
+
type WebhookRearmBody = {
|
|
328
|
+
expectedWatcherInstanceId: string;
|
|
329
|
+
};
|
|
330
|
+
type WebhookRearmData = {
|
|
331
|
+
rearmed: boolean;
|
|
332
|
+
};
|
|
333
|
+
type WebhookProtocolAdapterModule = {
|
|
334
|
+
specifier: string;
|
|
335
|
+
source: string;
|
|
336
|
+
};
|
|
337
|
+
declare const WEBHOOK_PROTOCOL_ADAPTER_MODULE = "modules/webhook/protocol-adapter.js";
|
|
338
|
+
type WebhookProtocolAdapterBundleData = {
|
|
339
|
+
protocolId: string;
|
|
340
|
+
artifactDigest: string;
|
|
341
|
+
module: typeof WEBHOOK_PROTOCOL_ADAPTER_MODULE;
|
|
342
|
+
modules: WebhookProtocolAdapterModule[];
|
|
343
|
+
};
|
|
344
|
+
declare function flowScriptProtocolAdapterModuleName(artifactDigest: string): string;
|
|
345
|
+
declare function parseWebhookWatcherContext(data: unknown): ContractParseResult<WebhookWatcherContext>;
|
|
346
|
+
declare function parseWebhookDelivery(data: unknown): ContractParseResult<WebhookDelivery>;
|
|
347
|
+
declare function parseTriggerHandlerBundlesData(data: unknown): HandlerBundlesParseResult<TriggerHandlerBundlesData>;
|
|
348
|
+
declare function parseWebhookPublishEventsBody(body: unknown): ContractParseResult<WebhookPublishEventsBody>;
|
|
349
|
+
declare function parseWebhookRearmBody(body: unknown): ContractParseResult<WebhookRearmBody>;
|
|
350
|
+
|
|
351
|
+
declare const INTERNAL_POLLING_TRIGGER_INSTANCES_ROUTE_PREFIX = "/internal/polling-trigger-instances";
|
|
352
|
+
declare const POLLING_TRIGGER_CONTEXT_ROUTE_SUBPATH = "/:pollingInstanceId/context";
|
|
353
|
+
declare const POLLING_TRIGGER_HANDLER_BUNDLES_ROUTE_SUBPATH = "/:pollingInstanceId/handler-bundles";
|
|
354
|
+
declare const POLLING_TRIGGER_TICK_EVENTS_ROUTE_SUBPATH = "/:pollingInstanceId/ticks/:tickId/events";
|
|
355
|
+
declare function pollingTriggerContextPath(pollingInstanceId: string, artifactDigest: string, tickId: string): string;
|
|
356
|
+
declare function pollingTriggerHandlerBundlesPath(pollingInstanceId: string, artifactDigest: string): string;
|
|
357
|
+
declare function pollingTriggerTickEventsPath(pollingInstanceId: string, tickId: string): string;
|
|
358
|
+
type PackagePollingTriggerRuntimeDescriptor = {
|
|
359
|
+
trigger_id: string;
|
|
360
|
+
trigger_ref: string;
|
|
361
|
+
type: "polling";
|
|
362
|
+
polling: {
|
|
363
|
+
schedule: {
|
|
364
|
+
type: "interval";
|
|
365
|
+
every_seconds: number;
|
|
366
|
+
};
|
|
367
|
+
dedup: {
|
|
368
|
+
strategy: "cursor" | "hash" | "id_field";
|
|
369
|
+
cursor_field?: string;
|
|
370
|
+
id_field?: string;
|
|
371
|
+
};
|
|
372
|
+
run_handler_module: string;
|
|
373
|
+
};
|
|
374
|
+
};
|
|
375
|
+
type PollingTriggerContext = {
|
|
376
|
+
artifactDigest: string;
|
|
377
|
+
triggerRef: string;
|
|
378
|
+
triggerName: string;
|
|
379
|
+
integrationRef: string;
|
|
380
|
+
inputs: Record<string, unknown>;
|
|
381
|
+
connection: TriggerConnectionInfo | null;
|
|
382
|
+
runtime: PackagePollingTriggerRuntimeDescriptor;
|
|
383
|
+
stateScope: ContextStateScope;
|
|
384
|
+
tick: {
|
|
385
|
+
tickId: string;
|
|
386
|
+
scheduledAt: string;
|
|
387
|
+
attempt: number;
|
|
388
|
+
};
|
|
389
|
+
limits: {
|
|
390
|
+
maxEventsPerTick: number;
|
|
391
|
+
};
|
|
392
|
+
};
|
|
393
|
+
type PollingPublishEvent = {
|
|
394
|
+
eventId: string;
|
|
395
|
+
occurredAt?: string;
|
|
396
|
+
dedupeKey?: string;
|
|
397
|
+
payload: Record<string, unknown>;
|
|
398
|
+
};
|
|
399
|
+
type PollingPublishBody = {
|
|
400
|
+
events: PollingPublishEvent[];
|
|
401
|
+
nextCursor?: string | null;
|
|
402
|
+
};
|
|
403
|
+
type PublishPollingTickEventResult = {
|
|
404
|
+
eventId: string;
|
|
405
|
+
dedupeKey: string;
|
|
406
|
+
duplicate: boolean;
|
|
407
|
+
flowRunId: string | null;
|
|
408
|
+
};
|
|
409
|
+
type PublishPollingTickEventsData = {
|
|
410
|
+
tickId: string;
|
|
411
|
+
cursorUpdated: boolean;
|
|
412
|
+
results: PublishPollingTickEventResult[];
|
|
413
|
+
};
|
|
414
|
+
declare function parsePollingTriggerContext(data: unknown): ContractParseResult<PollingTriggerContext>;
|
|
415
|
+
declare function parsePollingPublishBody(body: unknown): ContractParseResult<PollingPublishBody>;
|
|
416
|
+
declare function parsePublishPollingTickEventsData(data: unknown): ContractParseResult<PublishPollingTickEventsData>;
|
|
417
|
+
|
|
418
|
+
declare const INTERNAL_EGRESS_GRANTS_ROUTE_PREFIX = "/internal/egress-grants";
|
|
419
|
+
declare const INTERNAL_TOOL_INVOCATIONS_ROUTE_PREFIX = "/internal/tool-invocations";
|
|
420
|
+
declare const FLOW_RUN_EGRESS_GRANT_ROUTE_SUBPATH = "/:flowRunId/egress-grant";
|
|
421
|
+
declare const TOOL_INVOCATION_EGRESS_GRANT_ROUTE_SUBPATH = "/:invocationId/egress-grant";
|
|
422
|
+
declare const POLLING_TRIGGER_EGRESS_GRANT_ROUTE_SUBPATH = "/:pollingInstanceId/egress-grant";
|
|
423
|
+
declare const WEBHOOK_TRIGGER_EGRESS_GRANT_ROUTE_SUBPATH = "/:triggerInstanceId/egress-grant";
|
|
424
|
+
declare const EGRESS_GRANT_CONSUME_ROUTE_SUBPATH = "/:grantId/consume";
|
|
425
|
+
declare const EGRESS_GRANT_AUDIT_ROUTE_SUBPATH = "/:grantId/audit";
|
|
426
|
+
declare const flowRunEgressGrantPath: (flowRunId: string) => string;
|
|
427
|
+
declare const toolInvocationEgressGrantPath: (invocationId: string) => string;
|
|
428
|
+
declare const pollingTriggerEgressGrantPath: (pollingInstanceId: string) => string;
|
|
429
|
+
declare const webhookTriggerEgressGrantPath: (triggerInstanceId: string) => string;
|
|
430
|
+
declare const egressGrantConsumePath: (grantId: string) => string;
|
|
431
|
+
declare const egressGrantAuditPath: (grantId: string) => string;
|
|
432
|
+
declare const EGRESS_GRANT_SCOPE_KINDS: readonly ["flow_action", "single_tool", "polling_trigger", "webhook_trigger"];
|
|
433
|
+
type EgressGrantScopeKind = (typeof EGRESS_GRANT_SCOPE_KINDS)[number];
|
|
434
|
+
type EgressGrantFileRuntime = {
|
|
435
|
+
baseUrl: string;
|
|
436
|
+
token: string;
|
|
437
|
+
expiresAt: string;
|
|
438
|
+
limits: {
|
|
439
|
+
fileReadMaxBytes: number;
|
|
440
|
+
inlineMultipartBytesMax: number;
|
|
441
|
+
};
|
|
442
|
+
};
|
|
443
|
+
type EgressGrantCredentialMaterial<TCredential = unknown> = {
|
|
444
|
+
connectionId: string;
|
|
445
|
+
authProfileRef: string;
|
|
446
|
+
authType: string;
|
|
447
|
+
credential: TCredential;
|
|
448
|
+
};
|
|
449
|
+
type EgressGrant<TDescriptor = unknown, TCredential = unknown> = {
|
|
450
|
+
grantId: string;
|
|
451
|
+
scopeKind: EgressGrantScopeKind;
|
|
452
|
+
scopeId: string;
|
|
453
|
+
workspaceId: string;
|
|
454
|
+
installationId: string;
|
|
455
|
+
connectionId: string | null;
|
|
456
|
+
artifactDigest: string;
|
|
457
|
+
descriptorHash: string;
|
|
458
|
+
requestDigest: string;
|
|
459
|
+
issuedAt: string;
|
|
460
|
+
expiresAt: string;
|
|
461
|
+
networkPolicy: unknown;
|
|
462
|
+
descriptor: TDescriptor;
|
|
463
|
+
connection: unknown | null;
|
|
464
|
+
credential: EgressGrantCredentialMaterial<TCredential> | null;
|
|
465
|
+
fileRuntime?: EgressGrantFileRuntime;
|
|
466
|
+
signature: string;
|
|
467
|
+
};
|
|
468
|
+
type EgressGrantConsumeBody = {
|
|
469
|
+
scopeKind: EgressGrantScopeKind;
|
|
470
|
+
scopeId: string;
|
|
471
|
+
requestDigest: string;
|
|
472
|
+
};
|
|
473
|
+
type EgressGrantAuditBody = {
|
|
474
|
+
scopeKind: EgressGrantScopeKind;
|
|
475
|
+
scopeId: string;
|
|
476
|
+
providerHost: string;
|
|
477
|
+
status?: number;
|
|
478
|
+
durationMs: number;
|
|
479
|
+
requestBytes?: number;
|
|
480
|
+
responseBytes?: number;
|
|
481
|
+
errorCode?: string;
|
|
482
|
+
};
|
|
483
|
+
type FlowActionGrantBody = {
|
|
484
|
+
nodeId: string;
|
|
485
|
+
requestDigest: string;
|
|
486
|
+
requestHasMultipartFiles: boolean;
|
|
487
|
+
};
|
|
488
|
+
type SingleToolGrantBody = {
|
|
489
|
+
requestDigest: string;
|
|
490
|
+
};
|
|
491
|
+
type PollingTriggerGrantBody = {
|
|
492
|
+
tickId: string;
|
|
493
|
+
requestDigest: string;
|
|
494
|
+
};
|
|
495
|
+
type WebhookTriggerGrantBody = {
|
|
496
|
+
phase: "lifecycle" | "handler";
|
|
497
|
+
lifecycle?: "enable" | "disable" | "renew";
|
|
498
|
+
requestDigest: string;
|
|
499
|
+
};
|
|
500
|
+
declare function isValidRequestDigest(value: unknown): value is string;
|
|
501
|
+
declare function requestHasMultipartFileParts(request: unknown): boolean;
|
|
502
|
+
type EgressGrantBodyParseResult<T> = {
|
|
503
|
+
ok: true;
|
|
504
|
+
value: T;
|
|
505
|
+
} | {
|
|
506
|
+
ok: false;
|
|
507
|
+
kind: "shape" | "request_digest";
|
|
508
|
+
reason: string;
|
|
509
|
+
};
|
|
510
|
+
declare function parseFlowActionGrantBody(body: unknown): EgressGrantBodyParseResult<FlowActionGrantBody>;
|
|
511
|
+
declare function parseSingleToolGrantBody(body: unknown): EgressGrantBodyParseResult<SingleToolGrantBody>;
|
|
512
|
+
declare function parsePollingTriggerGrantBody(body: unknown): EgressGrantBodyParseResult<PollingTriggerGrantBody>;
|
|
513
|
+
declare function parseWebhookTriggerGrantBody(body: unknown): EgressGrantBodyParseResult<WebhookTriggerGrantBody>;
|
|
514
|
+
declare function parseEgressGrantConsumeBody(body: unknown): EgressGrantBodyParseResult<EgressGrantConsumeBody>;
|
|
515
|
+
declare function parseEgressGrantAuditBody(body: unknown): EgressGrantBodyParseResult<EgressGrantAuditBody>;
|
|
516
|
+
declare function parseEgressGrantData(data: unknown): ContractParseResult<EgressGrant<unknown>>;
|
|
517
|
+
declare function parseEgressGrantConsumeData(data: unknown): ContractParseResult<{
|
|
518
|
+
consumed: true;
|
|
519
|
+
}>;
|
|
520
|
+
|
|
521
|
+
declare const FLOW_RUN_RUNTIME_CREDENTIAL_ROUTE_SUBPATH = "/:flowRunId/runtime-credential";
|
|
522
|
+
declare const TOOL_INVOCATION_RUNTIME_CREDENTIAL_ROUTE_SUBPATH = "/:invocationId/runtime-credential";
|
|
523
|
+
declare const POLLING_TRIGGER_RUNTIME_CREDENTIAL_ROUTE_SUBPATH = "/:pollingInstanceId/runtime-credential";
|
|
524
|
+
declare const WEBHOOK_TRIGGER_RUNTIME_CREDENTIAL_ROUTE_SUBPATH = "/:triggerInstanceId/runtime-credential";
|
|
525
|
+
declare const flowRunRuntimeCredentialPath: (flowRunId: string) => string;
|
|
526
|
+
declare const toolInvocationRuntimeCredentialPath: (invocationId: string) => string;
|
|
527
|
+
declare const pollingTriggerRuntimeCredentialPath: (pollingInstanceId: string) => string;
|
|
528
|
+
declare const webhookTriggerRuntimeCredentialPath: (triggerInstanceId: string) => string;
|
|
529
|
+
declare const RUNTIME_CREDENTIAL_SESSION_SCOPE_KINDS: readonly ["flow_action", "tool_invoke", "polling_trigger", "webhook_trigger"];
|
|
530
|
+
type RuntimeCredentialSessionScopeKind = (typeof RUNTIME_CREDENTIAL_SESSION_SCOPE_KINDS)[number];
|
|
531
|
+
type RuntimeCredentialSessionNetwork = {
|
|
532
|
+
networkModel: "managed_plus_unmanaged_sdk";
|
|
533
|
+
apiHosts: string[];
|
|
534
|
+
authHosts: string[];
|
|
535
|
+
httpsOnly: true;
|
|
536
|
+
};
|
|
537
|
+
type RuntimeCredentialSession<TCredential = unknown> = {
|
|
538
|
+
sessionId: string;
|
|
539
|
+
scopeKind: RuntimeCredentialSessionScopeKind;
|
|
540
|
+
scopeId: string;
|
|
541
|
+
workspaceId: string;
|
|
542
|
+
installationId: string;
|
|
543
|
+
artifactDigest: string;
|
|
544
|
+
descriptorHash: string;
|
|
545
|
+
connectionId: string;
|
|
546
|
+
connectionRef: string;
|
|
547
|
+
authProfileRef: string;
|
|
548
|
+
authType: string;
|
|
549
|
+
credential: TCredential;
|
|
550
|
+
network: RuntimeCredentialSessionNetwork;
|
|
551
|
+
expiresAt: string;
|
|
552
|
+
};
|
|
553
|
+
type FlowRuntimeCredentialBody = {
|
|
554
|
+
nodeId: string;
|
|
555
|
+
};
|
|
556
|
+
type PollingRuntimeCredentialBody = {
|
|
557
|
+
tickId: string;
|
|
558
|
+
};
|
|
559
|
+
type WebhookRuntimeCredentialBody = {
|
|
560
|
+
executionKind: "event_handler" | "lifecycle";
|
|
561
|
+
deliveryId?: string;
|
|
562
|
+
lifecycleOperation?: "enable" | "disable" | "renew";
|
|
563
|
+
};
|
|
564
|
+
declare function parseFlowRuntimeCredentialBody(body: unknown): ContractParseResult<FlowRuntimeCredentialBody>;
|
|
565
|
+
declare function parseSingleToolRuntimeCredentialBody(body: unknown): ContractParseResult<null>;
|
|
566
|
+
declare function parsePollingRuntimeCredentialBody(body: unknown): ContractParseResult<PollingRuntimeCredentialBody>;
|
|
567
|
+
declare function parseWebhookRuntimeCredentialBody(body: unknown): ContractParseResult<WebhookRuntimeCredentialBody>;
|
|
568
|
+
declare function parseRuntimeCredentialSessionCredential(data: unknown): ContractParseResult<Record<string, unknown>>;
|
|
569
|
+
|
|
570
|
+
type FileRefData = {
|
|
571
|
+
file_id: string;
|
|
572
|
+
name: string;
|
|
573
|
+
mime_type?: string;
|
|
574
|
+
size_bytes: number;
|
|
575
|
+
created_at: string;
|
|
576
|
+
expires_at: string;
|
|
577
|
+
sha256?: string;
|
|
578
|
+
source?: string;
|
|
579
|
+
};
|
|
580
|
+
type PresignedFileUrlData = {
|
|
581
|
+
method: "GET" | "PUT";
|
|
582
|
+
url: string;
|
|
583
|
+
headers: Record<string, string>;
|
|
584
|
+
expires_at: string;
|
|
585
|
+
};
|
|
586
|
+
type FileUploadSessionData = {
|
|
587
|
+
file: FileRefData;
|
|
588
|
+
upload: PresignedFileUrlData;
|
|
589
|
+
};
|
|
590
|
+
type FileMetadataData = {
|
|
591
|
+
file: FileRefData;
|
|
592
|
+
};
|
|
593
|
+
declare function parseFileRefData(data: unknown): ContractParseResult<FileRefData>;
|
|
594
|
+
declare function parseFileUploadSessionData(data: unknown): ContractParseResult<FileUploadSessionData>;
|
|
595
|
+
declare function parseFileMetadataData(data: unknown): ContractParseResult<FileMetadataData>;
|
|
596
|
+
|
|
597
|
+
declare const INTERNAL_FILES_ROUTE_PREFIX = "/internal/files";
|
|
598
|
+
declare const FILE_UPLOAD_SESSION_ROUTE_SUBPATH = "/upload-session";
|
|
599
|
+
declare const FILE_COMPLETE_ROUTE_SUBPATH = "/:fileId/complete";
|
|
600
|
+
declare const FILE_ACCESS_ROUTE_SUBPATH = "/:fileId/access";
|
|
601
|
+
declare const FILE_STAT_ROUTE_SUBPATH = "/:fileId/stat";
|
|
602
|
+
declare const FILE_CONTENT_ROUTE_SUBPATH = "/:fileId/content";
|
|
603
|
+
type FileRuntimeScopeKind = "flow_run" | "tool_invocation";
|
|
604
|
+
type FileRuntimeScope = {
|
|
605
|
+
scopeKind: FileRuntimeScopeKind;
|
|
606
|
+
scopeId: string;
|
|
607
|
+
};
|
|
608
|
+
type InternalFileAccessIntent = "runtime_read" | "provider_multipart";
|
|
609
|
+
type InternalFileAccessData = {
|
|
610
|
+
file: FileRefData;
|
|
611
|
+
access: PresignedFileUrlData;
|
|
612
|
+
intent: InternalFileAccessIntent;
|
|
613
|
+
};
|
|
614
|
+
declare const internalFilesPath: () => string;
|
|
615
|
+
declare const internalFileUploadSessionPath: () => string;
|
|
616
|
+
declare const internalFileCompletePath: (fileId: string) => string;
|
|
617
|
+
declare const internalFileAccessPath: (fileId: string, intent: InternalFileAccessIntent) => string;
|
|
618
|
+
declare const internalFileStatPath: (fileId: string, scope: FileRuntimeScope) => string;
|
|
619
|
+
declare const internalFileContentPath: (fileId: string, scope: FileRuntimeScope) => string;
|
|
620
|
+
|
|
621
|
+
declare function parseInternalFileAccessData(data: unknown): ContractParseResult<InternalFileAccessData>;
|
|
622
|
+
|
|
623
|
+
declare const HUMAN_INPUTS_ROUTE_SUBPATH = "/:flowRunId/human-inputs";
|
|
624
|
+
declare const HUMAN_INPUT_REQUEST_ROUTE_SUBPATH = "/:flowRunId/human-inputs/:requestId";
|
|
625
|
+
declare const HUMAN_INPUT_EXPIRE_ROUTE_SUBPATH = "/:flowRunId/human-inputs/:requestId/expire";
|
|
626
|
+
declare const HUMAN_INPUT_ACKNOWLEDGE_ROUTE_SUBPATH = "/:flowRunId/human-inputs/:requestId/acknowledge";
|
|
627
|
+
declare const humanInputsPath: (flowRunId: string) => string;
|
|
628
|
+
declare const humanInputRequestPath: (flowRunId: string, requestId: string) => string;
|
|
629
|
+
declare const humanInputExpirePath: (flowRunId: string, requestId: string) => string;
|
|
630
|
+
declare const humanInputAcknowledgePath: (flowRunId: string, requestId: string) => string;
|
|
631
|
+
declare const HUMAN_INPUT_RESOLVED_EVENT_PREFIX = "human_input_resolved";
|
|
632
|
+
declare function humanInputResolvedEventType(requestId: string): string;
|
|
633
|
+
type HumanInputResolvedEvent = {
|
|
634
|
+
requestId: string;
|
|
635
|
+
flowRunId: string;
|
|
636
|
+
nodeId: string;
|
|
637
|
+
status: "submitted" | "expired";
|
|
638
|
+
};
|
|
639
|
+
type RenderedHumanInputPrompt = {
|
|
640
|
+
title: string;
|
|
641
|
+
body?: string;
|
|
642
|
+
format?: "plain" | "markdown";
|
|
643
|
+
};
|
|
644
|
+
type PartiallyRenderedValue = {
|
|
645
|
+
kind: "literal";
|
|
646
|
+
value: unknown;
|
|
647
|
+
} | {
|
|
648
|
+
kind: "array";
|
|
649
|
+
items: PartiallyRenderedValue[];
|
|
650
|
+
} | {
|
|
651
|
+
kind: "object";
|
|
652
|
+
entries: Record<string, PartiallyRenderedValue>;
|
|
653
|
+
} | {
|
|
654
|
+
kind: "human_input_ref";
|
|
655
|
+
path: string;
|
|
656
|
+
} | {
|
|
657
|
+
kind: "template";
|
|
658
|
+
parts: PartiallyRenderedTemplatePart[];
|
|
659
|
+
};
|
|
660
|
+
type PartiallyRenderedTemplatePart = {
|
|
661
|
+
kind: "literal";
|
|
662
|
+
value: string;
|
|
663
|
+
} | {
|
|
664
|
+
kind: "human_input_ref";
|
|
665
|
+
path: string;
|
|
666
|
+
};
|
|
667
|
+
type PartiallyRenderedMapping = Record<string, PartiallyRenderedValue>;
|
|
668
|
+
type PartiallyRenderedHumanInputDelivery = {
|
|
669
|
+
actions?: Array<{
|
|
670
|
+
id: string;
|
|
671
|
+
inputs: PartiallyRenderedMapping;
|
|
672
|
+
}>;
|
|
673
|
+
};
|
|
674
|
+
type CreateHumanInputRequestBody = {
|
|
675
|
+
nodeId: string;
|
|
676
|
+
renderedPrompt: RenderedHumanInputPrompt;
|
|
677
|
+
input: RuntimeHumanInputSpec;
|
|
678
|
+
partiallyRenderedDelivery?: PartiallyRenderedHumanInputDelivery;
|
|
679
|
+
timeout: string;
|
|
680
|
+
expiresAt: string;
|
|
681
|
+
};
|
|
682
|
+
type HumanInputResponse = {
|
|
683
|
+
kind: "choice";
|
|
684
|
+
choiceId: string;
|
|
685
|
+
comment?: string;
|
|
686
|
+
} | {
|
|
687
|
+
kind: "text";
|
|
688
|
+
text: string;
|
|
689
|
+
} | {
|
|
690
|
+
kind: "form";
|
|
691
|
+
values: Record<string, unknown>;
|
|
692
|
+
};
|
|
693
|
+
type HumanInputActor = {
|
|
694
|
+
type: "user";
|
|
695
|
+
userId: string;
|
|
696
|
+
} | {
|
|
697
|
+
type: "api_key";
|
|
698
|
+
apiKeyId: string;
|
|
699
|
+
} | {
|
|
700
|
+
type: "anonymous";
|
|
701
|
+
} | {
|
|
702
|
+
type: "provider";
|
|
703
|
+
provider: string;
|
|
704
|
+
providerActorId?: string;
|
|
705
|
+
} | {
|
|
706
|
+
type: "system";
|
|
707
|
+
};
|
|
708
|
+
type HumanInputOutput = {
|
|
709
|
+
status: "submitted";
|
|
710
|
+
response: HumanInputResponse;
|
|
711
|
+
actor: Exclude<HumanInputActor, {
|
|
712
|
+
type: "system";
|
|
713
|
+
}>;
|
|
714
|
+
submissionSource: string;
|
|
715
|
+
submittedAt: string;
|
|
716
|
+
} | {
|
|
717
|
+
status: "expired";
|
|
718
|
+
actor: {
|
|
719
|
+
type: "system";
|
|
720
|
+
};
|
|
721
|
+
expiredAt: string;
|
|
722
|
+
};
|
|
723
|
+
type HumanInputRequestView = {
|
|
724
|
+
id: string;
|
|
725
|
+
workspaceId: string;
|
|
726
|
+
flowRunId: string;
|
|
727
|
+
nodeId: string;
|
|
728
|
+
status: "pending" | "submitted" | "expired" | "cancelled";
|
|
729
|
+
inputKind: string;
|
|
730
|
+
timeout: string;
|
|
731
|
+
expiresAt: string;
|
|
732
|
+
createdAt: string;
|
|
733
|
+
updatedAt: string;
|
|
734
|
+
output: HumanInputOutput | null;
|
|
735
|
+
};
|
|
736
|
+
declare function parseCreateHumanInputBody(body: unknown): ContractParseResult<CreateHumanInputRequestBody>;
|
|
737
|
+
declare function parseHumanInputRequestViewData(data: unknown): ContractParseResult<HumanInputRequestView>;
|
|
738
|
+
declare function parseHumanInputCreateData(data: unknown): ContractParseResult<{
|
|
739
|
+
created: boolean;
|
|
740
|
+
request: HumanInputRequestView;
|
|
741
|
+
}>;
|
|
742
|
+
declare function parseHumanInputAcknowledgeData(data: unknown): ContractParseResult<{
|
|
743
|
+
acknowledged: true;
|
|
744
|
+
}>;
|
|
745
|
+
|
|
746
|
+
declare const WFP_USER_RUNTIME_MANIFEST_FORMAT_VERSION = "ablehi-wfp-user-runtime-manifest/v1";
|
|
747
|
+
type WfpUserRuntimeManifest = {
|
|
748
|
+
formatVersion: typeof WFP_USER_RUNTIME_MANIFEST_FORMAT_VERSION;
|
|
749
|
+
runtimeContractVersion: string;
|
|
750
|
+
sha256: string;
|
|
751
|
+
sourceRevision: string;
|
|
752
|
+
};
|
|
753
|
+
declare const WFP_USER_RUNTIME_UNKNOWN_SOURCE_REVISION = "unknown";
|
|
754
|
+
declare function wfpUserRuntimeManifestPath(bundlePath: string): string;
|
|
755
|
+
|
|
756
|
+
declare const DEPLOYMENT_HANDSHAKE_ROUTE = "/internal/deployment-handshake";
|
|
757
|
+
type DeploymentHandshakeRequestBody = {
|
|
758
|
+
nonce: string;
|
|
759
|
+
timestamp: string;
|
|
760
|
+
contractVersion: string;
|
|
761
|
+
dispatchNamespace: string;
|
|
762
|
+
probe: string;
|
|
763
|
+
};
|
|
764
|
+
type DeploymentHandshakeData = {
|
|
765
|
+
nonce: string;
|
|
766
|
+
contractVersion: string;
|
|
767
|
+
dispatchNamespace: string;
|
|
768
|
+
capabilities: string[];
|
|
769
|
+
proof: string;
|
|
770
|
+
};
|
|
771
|
+
type DeploymentHandshakeResponse = {
|
|
772
|
+
ok: true;
|
|
773
|
+
data: DeploymentHandshakeData;
|
|
774
|
+
} | {
|
|
775
|
+
ok: false;
|
|
776
|
+
error: {
|
|
777
|
+
code: string;
|
|
778
|
+
message: string;
|
|
779
|
+
};
|
|
780
|
+
};
|
|
781
|
+
declare const DEPLOYMENT_HANDSHAKE_DISPATCHER_CAPABILITIES: readonly ["start", "terminate", "send-event", "start-webhook-watcher", "run-polling-tick", "invoke-tool", "invoke-trigger-handler", "invoke-webhook-protocol-adapter", "deployment-handshake"];
|
|
782
|
+
declare const DEPLOYMENT_HANDSHAKE_REQUIRED_CAPABILITIES: readonly ["start", "terminate", "send-event", "start-webhook-watcher", "run-polling-tick", "invoke-tool", "invoke-trigger-handler", "invoke-webhook-protocol-adapter", "deployment-handshake"];
|
|
783
|
+
declare const HANDSHAKE_REQUEST_INVALID = "HANDSHAKE_REQUEST_INVALID";
|
|
784
|
+
declare const HANDSHAKE_SECRET_UNCONFIGURED = "HANDSHAKE_SECRET_UNCONFIGURED";
|
|
785
|
+
declare const HANDSHAKE_SECRET_MISMATCH = "HANDSHAKE_SECRET_MISMATCH";
|
|
786
|
+
declare const HANDSHAKE_CONTRACT_VERSION_MISMATCH = "HANDSHAKE_CONTRACT_VERSION_MISMATCH";
|
|
787
|
+
declare const HANDSHAKE_DISPATCH_NAMESPACE_MISMATCH = "HANDSHAKE_DISPATCH_NAMESPACE_MISMATCH";
|
|
788
|
+
declare const HANDSHAKE_CAPABILITY_MISSING = "HANDSHAKE_CAPABILITY_MISSING";
|
|
789
|
+
declare function deploymentHandshakeProbePayload(input: {
|
|
790
|
+
nonce: string;
|
|
791
|
+
timestamp: string;
|
|
792
|
+
contractVersion: string;
|
|
793
|
+
dispatchNamespace: string;
|
|
794
|
+
}): string;
|
|
795
|
+
declare function deploymentHandshakeResponseProofPayload(input: {
|
|
796
|
+
nonce: string;
|
|
797
|
+
contractVersion: string;
|
|
798
|
+
dispatchNamespace: string;
|
|
799
|
+
capabilities: string[];
|
|
800
|
+
}): string;
|
|
801
|
+
|
|
802
|
+
export { 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, type DeploymentHandshakeData, type DeploymentHandshakeRequestBody, type DeploymentHandshakeResponse, EGRESS_GRANT_AUDIT_ROUTE_SUBPATH, EGRESS_GRANT_CONSUME_ROUTE_SUBPATH, EGRESS_GRANT_SCOPE_KINDS, EVENT_WAIT_ROUTE_SUBPATH, EXECUTION_CONTEXT_ROUTE_SUBPATH, type EgressGrant, type EgressGrantAuditBody, type EgressGrantBodyParseResult, type EgressGrantConsumeBody, type EgressGrantCredentialMaterial, type EgressGrantFileRuntime, type EgressGrantScopeKind, type ExecutionBinding, type ExecutionBindingConnection, type ExecutionContextCompiled, type ExecutionContextData, 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_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 FlowRunResultData, type FlowRunResultRequestBody, type FlowRuntimeCredentialBody, 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_EXPIRE_ROUTE_SUBPATH, 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, 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 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 PackagePollingTriggerRuntimeDescriptor, type PackageWebhookTriggerRuntimeDescriptor, type ParsedFlowRunResultBody, type PartiallyRenderedHumanInputDelivery, type PartiallyRenderedMapping, type PartiallyRenderedTemplatePart, type PartiallyRenderedValue, type PollingPublishBody, type PollingPublishEvent, type PollingRuntimeCredentialBody, type PollingTriggerContext, type PollingTriggerGrantBody, type PresignedFileUrlData, type PublishPollingTickEventResult, type PublishPollingTickEventsData, RUNTIME_CREDENTIAL_SESSION_SCOPE_KINDS, type RegisterFlowRunWaitBody, type RegisterFlowRunWaitData, type RenderedFlowComposition, type RenderedHumanInputPrompt, type RuntimeCredentialSession, type RuntimeCredentialSessionNetwork, type RuntimeCredentialSessionScopeKind, type RuntimeNetwork, type RuntimeNetworkModel, SERVER_EXECUTION_CONTRACT_VERSION, STEP_RESULT_ROUTE_SUBPATH, type ServerExecutionContractVersion, 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 TriggerHandlerBundlesData, type TriggerHandlerModule, 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, type WebhookDelivery, type WebhookProtocolAdapterBundleData, type WebhookProtocolAdapterModule, type WebhookPublishEvent, type WebhookPublishEventsBody, type WebhookPublishEventsData, type WebhookRearmBody, type WebhookRearmData, type WebhookRuntimeCredentialBody, type WebhookTriggerGrantBody, type WebhookTriggerVerificationMethod, type WebhookWatcherContext, type WfpUserRuntimeManifest, deploymentHandshakeProbePayload, deploymentHandshakeResponseProofPayload, egressGrantAuditPath, egressGrantConsumePath, eventWaitPath, executionContextPath, flowRunEgressGrantPath, flowRunResultPath, flowRunRuntimeCredentialPath, flowScriptProtocolAdapterModuleName, handlerBundlesPath, humanInputAcknowledgePath, humanInputExpirePath, humanInputRequestPath, humanInputResolvedEventType, humanInputsPath, internalFileAccessPath, internalFileCompletePath, internalFileContentPath, internalFileStatPath, internalFileUploadSessionPath, internalFilesPath, isValidRequestDigest, parseCompleteFlowRunWaitBody, parseContextStateCleanupRequestBody, parseContextStateCleanupResponseData, parseContextStateScope, parseCreateHumanInputBody, parseEgressGrantAuditBody, parseEgressGrantConsumeBody, parseEgressGrantConsumeData, parseEgressGrantData, parseExecutionContextData, parseFileMetadataData, parseFileRefData, parseFileRuntimeLimits, parseFileUploadSessionData, parseFlowActionGrantBody, parseFlowRunResultBody, parseFlowRunResultData, parseFlowRuntimeCredentialBody, parseHandlerBundle, parseHandlerBundlesData, parseHumanInputAcknowledgeData, parseHumanInputCreateData, parseHumanInputRequestViewData, parseInternalFileAccessData, parsePollingPublishBody, parsePollingRuntimeCredentialBody, parsePollingTriggerContext, parsePollingTriggerGrantBody, parsePublishPollingTickEventsData, parseRegisterFlowRunWaitBody, parseRegisterFlowRunWaitData, parseRuntimeCredentialSessionCredential, parseRuntimeNetwork, parseSingleToolGrantBody, parseSingleToolRuntimeCredentialBody, parseStepRecordBody, parseStepRecordData, parseToolHandlerBundlesData, parseTriggerHandlerBundlesData, parseWebhookDelivery, parseWebhookPublishEventsBody, parseWebhookRearmBody, parseWebhookRuntimeCredentialBody, parseWebhookTriggerGrantBody, parseWebhookWatcherContext, pollingTriggerContextPath, pollingTriggerEgressGrantPath, pollingTriggerHandlerBundlesPath, pollingTriggerRuntimeCredentialPath, pollingTriggerTickEventsPath, requestHasMultipartFileParts, stepResultPath, toolHandlerBundlesPath, toolInvocationEgressGrantPath, toolInvocationRuntimeCredentialPath, webhookProtocolAdapterBundlePath, webhookTriggerContextPath, webhookTriggerDeliveryPath, webhookTriggerEgressGrantPath, webhookTriggerEventsPath, webhookTriggerHandlerBundlesPath, webhookTriggerRearmPath, webhookTriggerRuntimeCredentialPath, wfpUserRuntimeManifestPath };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var Z="0.2.8";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 Le="/cleanup-state-scopes";function y(e){if(!i(e)||typeof e.kind!="string")return r("context state scope surface shape is invalid");switch(e.kind){case"webhook-trigger":return ee(e);case"polling-trigger":return te(e);case"flow-action":return ne(e);default:return r("context state scope kind is invalid")}}function qe(e){if(!i(e))return r("cleanup request body must be a JSON object");let t=C(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=y(o);if(!s.ok)return s;n.push(s.value)}return u({scopes:n})}function We(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 ee(e){let t=C(e,["kind","workspaceId","triggerInstanceId"]);return t!==void 0?r(`webhook trigger scope does not accept "${t}"`):e.kind!=="webhook-trigger"||!R(e.workspaceId)||!R(e.triggerInstanceId)?r("webhook trigger state scope is invalid"):u({kind:"webhook-trigger",workspaceId:e.workspaceId,triggerInstanceId:e.triggerInstanceId})}function te(e){let t=C(e,["kind","workspaceId","pollingInstanceId"]);return t!==void 0?r(`polling trigger scope does not accept "${t}"`):e.kind!=="polling-trigger"||!R(e.workspaceId)||!R(e.pollingInstanceId)?r("polling trigger state scope is invalid"):u({kind:"polling-trigger",workspaceId:e.workspaceId,pollingInstanceId:e.pollingInstanceId})}function ne(e){let t=C(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"||!R(e.workspaceId)||!R(e.flowId)||!R(e.nodeId)||n!==null&&!R(n)?r("flow action state scope is invalid"):u({kind:"flow-action",workspaceId:e.workspaceId,flowId:e.flowId,nodeId:e.nodeId,connectionId:n})}function R(e){return typeof e=="string"&&e.length>0}function C(e,t){return Object.keys(e).find(n=>!t.includes(n))}var f="/internal/flow-runs",Xe="/:flowRunId/execution-context";function Ye(e){return`${f}/${encodeURIComponent(e)}/execution-context`}function re(e){return!i(e)||!B(e.fileMaxBytes)||!B(e.fileReadMaxBytes)||!B(e.inlineMultipartBytesMax)?r("file runtime limits must carry three positive integer bounds"):u({fileMaxBytes:e.fileMaxBytes,fileReadMaxBytes:e.fileReadMaxBytes,inlineMultipartBytesMax:e.inlineMultipartBytesMax})}function ze(e){if(!i(e))return r("execution context must be a JSON object");let t=e.compiled;if(typeof e.flowRunId!="string"||typeof e.workspaceId!="string"||!i(e.input)||!i(t)||typeof t.irSchemaVersion!="string"||typeof t.interpreterContractVersion!="string"||typeof t.compiledArtifactId!="string"||!i(t.ir)||!Array.isArray(t.ir.nodes)||!ie(e.executionBindings))return r("execution context surface shape is invalid");let n=oe(e.fileRuntime);return n.ok?u({...e,fileRuntime:n.value}):r(n.reason)}function oe(e){if(e===null)return u(null);if(!i(e))return r("fileRuntime must be null or an object");let t=re(e.limits);return t.ok?u({limits:t.value}):r(t.reason)}function ie(e){return Array.isArray(e)?e.every(t=>{if(!i(t))return!1;let n=t.connection,o=y(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 B(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0}var tt="/:flowRunId/steps/:nodeId/result",nt="/:flowRunId/result",rt="/:flowRunId/event-waits/:nodeId";function ot(e,t){return`${f}/${encodeURIComponent(e)}/steps/${encodeURIComponent(t)}/result`}function it(e){return`${f}/${encodeURIComponent(e)}/result`}function st(e,t){return`${f}/${encodeURIComponent(e)}/event-waits/${encodeURIComponent(t)}`}function ut(e){if(!i(e))return{ok:!1,kind:"validation",reason:"step record body must be a JSON object"};let t=k(e,["attempt","result","durationMs"]);if(t!==void 0)return{ok:!1,kind:"validation",reason:`step record does not accept the "${t}" field`};let n=e.attempt;if(typeof n!="number"||!Number.isInteger(n)||n<=0)return{ok:!1,kind:"validation",reason:"attempt must be a positive integer"};let o=se(e.result);if(!o.ok)return o;let s={attempt:n,result:o.value};if(e.durationMs!==void 0){let a=e.durationMs;if(typeof a!="number"||!Number.isFinite(a)||a<0)return{ok:!1,kind:"validation",reason:"durationMs must be a non-negative number"};s.durationMs=a}return{ok:!0,value:s}}function se(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=k(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=k(e,["status","errorCode","issues"]);if(n!==void 0)return{ok:!1,kind:"validation",reason:`step record result does not accept the "${n}" field`};let o=e.errorCode;if(typeof o!="string"||o.length===0)return{ok:!1,kind:"step_result_invalid",reason:"a failed result must carry a non-empty errorCode"};let s={status:"failed",errorCode:o};return e.issues!==void 0&&(s.issues=e.issues),{ok:!0,value:s}}return{ok:!1,kind:"step_result_invalid",reason:'result status must be "succeeded" or "failed"'}}function at(e){return!i(e)||typeof e.flowRunId!="string"||typeof e.nodeId!="string"||e.recorded!=="succeeded"&&e.recorded!=="failed"?r("step record data surface shape is invalid"):u({flowRunId:e.flowRunId,nodeId:e.nodeId,recorded:e.recorded})}function ct(e){if(!i(e))return r("result body must be a JSON object");let t=k(e,["status","output","error","composition"]);if(t!==void 0)return r(`result does not accept the "${t}" field`);let n=e.status;if(n!=="succeeded"&&n!=="failed")return r('result status must be "succeeded" or "failed"');let o={status:n};if(e.output!==void 0&&(o.output=e.output),e.error!==void 0){let s=e.error;if(!i(s))return r("result error must be a JSON object");let a=k(s,["code","message"]);if(a!==void 0)return r(`result error does not accept the "${a}" field`);if(typeof s.code!="string"||typeof s.message!="string")return r("result error must carry string code and message");o.error={code:s.code,message:s.message}}if(e.composition!==void 0){if(n!=="succeeded")return r("composition is only allowed on a succeeded result");o.composition=e.composition}return u(o)}function dt(e){return i(e)?u(e):r("flow run result data must be a JSON object")}var ue=/^[A-Za-z0-9_-]{1,100}$/;function lt(e){if(!i(e))return r("register body must be a JSON object");let t=k(e,["eventType","correlationKey"]);if(t!==void 0)return r(`register wait does not accept the "${t}" field`);let n=L(e.eventType);if(!n.ok)return r(n.reason);let o=e.correlationKey;return typeof o!="string"||o.length===0?r("correlationKey must be a non-empty string"):u({eventType:n.value,correlationKey:o})}function pt(e){if(!i(e))return r("complete body must be a JSON object");let t=k(e,["eventType","correlationKey","outcome","eventId"]);if(t!==void 0)return r(`complete wait does not accept the "${t}" field`);let n=e.outcome;if(n!=="received"&&n!=="timed_out")return r('outcome must be "received" or "timed_out"');let o=L(e.eventType);if(!o.ok)return r(o.reason);let s=e.correlationKey;if(typeof s!="string"||s.length===0)return r("correlationKey must be a non-empty string");let a={eventType:o.value,correlationKey:s,outcome:n};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 gt(e){return!i(e)||e.registered!==!0?r("register wait data surface shape is invalid"):u({registered:!0})}function L(e){return typeof e!="string"||e.length===0?r("eventType must be a non-empty string"):ue.test(e)?u(e):r("eventType must match ^[A-Za-z0-9_-]{1,100}$")}function k(e,t){return Object.keys(e).find(n=>!t.includes(n))}var ae="/internal/flow-versions",Rt="/:flowVersionId/handler-bundles",F="/internal/installations",mt="/:installationId/handler-bundles";function yt(e,t){return`${ae}/${encodeURIComponent(e)}/handler-bundles?compiledArtifactId=${encodeURIComponent(t)}`}function kt(e){return`${F}/${encodeURIComponent(e.installationId)}/handler-bundles?workspaceId=${encodeURIComponent(e.workspaceId)}&artifactDigest=${encodeURIComponent(e.artifactDigest)}`}var ce=new Set(["managed_only","managed_plus_unmanaged_sdk"]);function b(e){if(!I(e))return H("runtimeNetwork must be a JSON object");let t=e.networkModel;return typeof t!="string"||!ce.has(t)?H("runtimeNetwork.networkModel is unknown"):!q(e.apiHosts)||!q(e.authHosts)||typeof e.httpsOnly!="boolean"?H("runtimeNetwork host/https fields are invalid"):{ok:!0,value:{networkModel:t,apiHosts:e.apiHosts,authHosts:e.authHosts,httpsOnly:e.httpsOnly}}}function It(e){if(!I(e)||typeof e.flowVersionId!="string"||typeof e.compiledArtifactId!="string"||!Array.isArray(e.bundles))return E("handler bundles data surface shape is invalid");let t=W(e.bundles);return t.ok?{ok:!0,value:{flowVersionId:e.flowVersionId,compiledArtifactId:e.compiledArtifactId,bundles:t.value}}:t}function _t(e){if(!I(e)||typeof e.installationId!="string"||typeof e.artifactDigest!="string"||!Array.isArray(e.bundles))return E("tool handler bundles data surface shape is invalid");let t=W(e.bundles);return t.ok?{ok:!0,value:{installationId:e.installationId,artifactDigest:e.artifactDigest,bundles:t.value}}:t}function W(e){let t=[];for(let n of e){let o=de(n);if(!o.ok)return o;t.push(o.value)}return{ok:!0,value:t}}function de(e){if(!I(e)||typeof e.toolRef!="string"||e.kind!=="handler"&&e.kind!=="request")return E("handler bundle entry shape is invalid");if(e.kind==="request"){if(e.module!==void 0)return E("a request bundle must not carry a module");let o=b(e.runtimeNetwork);return o.ok?{ok:!0,value:{toolRef:e.toolRef,kind:"request",runtimeNetwork:o.value}}:o}let t=e.module;if(!I(t)||typeof t.entry!="string"||t.entry.length===0||!le(t.files))return E("a handler bundle must carry a { entry, files } module");let n=b(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 E(e){return{ok:!1,kind:"shape",reason:e}}function H(e){return{ok:!1,kind:"runtime_network",reason:e}}function I(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function q(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function le(e){return I(e)&&Object.values(e).every(t=>typeof t=="string")}var x="/internal/webhook-trigger-instances",Pt="/:triggerInstanceId/context",St="/:triggerInstanceId/handler-bundles",Ct="/:triggerInstanceId/deliveries/:deliveryId",bt="/:triggerInstanceId/events",At="/:triggerInstanceId/rearm",w=e=>`${x}/${encodeURIComponent(e)}`;function vt(e,t){return`${w(e)}/context?artifactDigest=${encodeURIComponent(t)}`}function Nt(e,t){return`${w(e)}/handler-bundles?artifactDigest=${encodeURIComponent(t)}`}function Ot(e,t){return`${w(e)}/deliveries/${encodeURIComponent(t)}`}function Dt(e){return`${w(e)}/events`}function Ut(e){return`${w(e)}/rearm`}var Bt="/:installationId/webhook-protocol-adapter-bundle";function Ht(e){return`${F}/${encodeURIComponent(e.installationId)}/webhook-protocol-adapter-bundle?workspaceId=${encodeURIComponent(e.workspaceId)}&artifactDigest=${encodeURIComponent(e.artifactDigest)}`}var Ft="modules/webhook/protocol-adapter.js";function $t(e){return`modules/webhook/protocol-adapter-${e}.js`}function Gt(e){let t=i(e)?y(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&&!pe(e.connection)||!ge(e.runtime)||!t.ok||t.value.kind!=="webhook-trigger"?r("webhook watcher context surface shape is invalid"):u(e)}function pe(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 ge(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 Mt(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 Kt(e){if(!i(e)||typeof e.triggerRef!="string"||typeof e.artifactDigest!="string"||!Array.isArray(e.modules)||!e.modules.every(fe))return{ok:!1,kind:"shape",reason:"trigger handler bundles data surface shape is invalid"};let t=b(e.runtimeNetwork);return t.ok?{ok:!0,value:{triggerRef:e.triggerRef,artifactDigest:e.artifactDigest,modules:e.modules,runtimeNetwork:t.value}}:t}function fe(e){return i(e)&&typeof e.specifier=="string"&&e.specifier.length>0&&typeof e.source=="string"}function Lt(e){if(!i(e))return r("publish events body must be a JSON object");let t=$(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=Re(a);if(!c.ok)return c;s.push(c.value)}return u({deliveryId:n,events:s})}function Re(e){if(!i(e))return r("each event must be a JSON object");let t=$(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 qt(e){if(!i(e))return r("rearm body must be a JSON object");let t=$(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 $(e,t){return Object.keys(e).find(n=>!t.includes(n))}var T="/internal/polling-trigger-instances",Jt="/:pollingInstanceId/context",Xt="/:pollingInstanceId/handler-bundles",Yt="/:pollingInstanceId/ticks/:tickId/events",G=e=>`${T}/${encodeURIComponent(e)}`;function zt(e,t,n){return`${G(e)}/context?artifactDigest=${encodeURIComponent(t)}&tickId=${encodeURIComponent(n)}`}function Qt(e,t){return`${G(e)}/handler-bundles?artifactDigest=${encodeURIComponent(t)}`}function Zt(e,t){return`${G(e)}/ticks/${encodeURIComponent(t)}/events`}function en(e){let t=i(e)?y(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&&!me(e.connection)||!ye(e.runtime)||!t.ok||t.value.kind!=="polling-trigger"||!ke(e.tick)||!Ie(e.limits)?r("polling trigger context surface shape is invalid"):u(e)}function me(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 ye(e){if(!i(e)||e.type!=="polling"||typeof e.trigger_id!="string"||typeof e.trigger_ref!="string")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 ke(e){return i(e)&&typeof e.tickId=="string"&&typeof e.scheduledAt=="string"&&typeof e.attempt=="number"}function Ie(e){return i(e)&&typeof e.maxEventsPerTick=="number"}function tn(e){if(!i(e))return r("publish body must be a JSON object");let t=j(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=_e(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 _e(e){if(!i(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`);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 nn(e){return!i(e)||typeof e.tickId!="string"||typeof e.cursorUpdated!="boolean"||!Array.isArray(e.results)||!e.results.every(he)?r("publish polling tick events data surface shape is invalid"):u(e)}function he(e){return i(e)&&typeof e.eventId=="string"&&typeof e.dedupeKey=="string"&&typeof e.duplicate=="boolean"&&(e.flowRunId===null||typeof e.flowRunId=="string")}function j(e,t){return Object.keys(e).find(n=>!t.includes(n))}var V="/internal/egress-grants",M="/internal/tool-invocations",cn="/:flowRunId/egress-grant",dn="/:invocationId/egress-grant",ln="/:pollingInstanceId/egress-grant",pn="/:triggerInstanceId/egress-grant",gn="/:grantId/consume",fn="/:grantId/audit",Rn=e=>`${f}/${encodeURIComponent(e)}/egress-grant`,mn=e=>`${M}/${encodeURIComponent(e)}/egress-grant`,yn=e=>`${T}/${encodeURIComponent(e)}/egress-grant`,kn=e=>`${x}/${encodeURIComponent(e)}/egress-grant`,In=e=>`${V}/${encodeURIComponent(e)}/consume`,_n=e=>`${V}/${encodeURIComponent(e)}/audit`,Ee=["flow_action","single_tool","polling_trigger","webhook_trigger"],xe=/^[A-Za-z0-9][A-Za-z0-9:_+/=.-]{15,1023}$/;function P(e){return typeof e=="string"&&xe.test(e)}function we(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 d(e){return{ok:!1,kind:"shape",reason:e}}function S(){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 N(e){if(!i(e))return"request must be a JSON object"}function hn(e){let t=v(e,["nodeId","request","requestDigest"]);if(!t.ok)return d(t.reason);let n=t.record.nodeId;if(typeof n!="string"||n.length===0)return d("nodeId is required");let o=N(t.record.request);if(o!==void 0)return d(o);let s=t.record.requestDigest;return P(s)?{ok:!0,value:{nodeId:n,requestDigest:s,requestHasMultipartFiles:we(t.record.request)}}:S()}function En(e){let t=v(e,["request","requestDigest"]);if(!t.ok)return d(t.reason);let n=N(t.record.request);if(n!==void 0)return d(n);let o=t.record.requestDigest;return P(o)?{ok:!0,value:{requestDigest:o}}:S()}function xn(e){let t=v(e,["tickId","request","requestDigest"]);if(!t.ok)return d(t.reason);let n=t.record.tickId;if(typeof n!="string"||n.length===0)return d("tickId is required");let o=N(t.record.request);if(o!==void 0)return d(o);let s=t.record.requestDigest;return P(s)?{ok:!0,value:{tickId:n,requestDigest:s}}:S()}function wn(e){let t=v(e,["phase","lifecycle","request","requestDigest"]);if(!t.ok)return d(t.reason);let n=t.record.phase;if(n!=="lifecycle"&&n!=="handler")return d('phase must be "lifecycle" or "handler"');let o=t.record.lifecycle,s;if(o!==void 0){if(o!=="enable"&&o!=="disable"&&o!=="renew")return d('lifecycle must be "enable", "disable", or "renew"');s=o}if(n==="lifecycle"&&s===void 0)return d("lifecycle is required for the lifecycle phase");let a=N(t.record.request);if(a!==void 0)return d(a);let c=t.record.requestDigest;return P(c)?{ok:!0,value:{phase:n,...s!==void 0?{lifecycle:s}:{},requestDigest:c}}:S()}function J(e){return Ee.includes(e)?e:void 0}var Te=["scopeKind","scopeId","requestDigest"];function Tn(e){if(!i(e))return d("consume body must be a JSON object");for(let s of Object.keys(e))if(!Te.includes(s))return d(`consume does not accept the "${s}" field`);let t=J(e.scopeKind);if(t===void 0)return d("scopeKind is invalid");let n=e.scopeId;if(typeof n!="string"||n.length===0)return d("scopeId is required");let o=e.requestDigest;return P(o)?{ok:!0,value:{scopeKind:t,scopeId:n,requestDigest:o}}:S()}var Pe=["scopeKind","scopeId","providerHost","status","durationMs","requestBytes","responseBytes","errorCode"];function A(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 Pn(e){if(!i(e))return d("audit body must be a JSON object");for(let p of Object.keys(e))if(!Pe.includes(p))return d(`audit does not accept the "${p}" field`);let t=J(e.scopeKind);if(t===void 0)return d("scopeKind is invalid");let n=e.scopeId;if(typeof n!="string"||n.length===0)return d("scopeId is required");let o=e.providerHost;if(typeof o!="string"||o.length===0)return d("providerHost is required");let s=A(e.durationMs,"durationMs");if(!s.ok)return d(s.reason);let a;if(e.status!==void 0){let p=A(e.status,"status");if(!p.ok)return d(p.reason);a=p.value}let c;if(e.requestBytes!==void 0){let p=A(e.requestBytes,"requestBytes");if(!p.ok)return d(p.reason);c=p.value}let l;if(e.responseBytes!==void 0){let p=A(e.responseBytes,"responseBytes");if(!p.ok)return d(p.reason);l=p.value}let U;if(e.errorCode!==void 0){let p=e.errorCode;if(typeof p!="string"||p.length===0)return d("errorCode must be a non-empty string");U=p}return{ok:!0,value:{scopeKind:t,scopeId:n,providerHost:o,...a!==void 0?{status:a}:{},durationMs:s.value,...c!==void 0?{requestBytes:c}:{},...l!==void 0?{responseBytes:l}:{},...U!==void 0?{errorCode:U}:{}}}}function Sn(e){return!i(e)||!i(e.grant)?r("egress grant envelope must carry a grant object"):u(e.grant)}function Cn(e){return!i(e)||e.consumed!==!0?r("egress grant consume data must carry consumed:true"):u({consumed:!0})}var Un="/:flowRunId/runtime-credential",Bn="/:invocationId/runtime-credential",Hn="/:pollingInstanceId/runtime-credential",Fn="/:triggerInstanceId/runtime-credential",$n=e=>`${f}/${encodeURIComponent(e)}/runtime-credential`,Gn=e=>`${M}/${encodeURIComponent(e)}/runtime-credential`,Mn=e=>`${T}/${encodeURIComponent(e)}/runtime-credential`,Kn=e=>`${x}/${encodeURIComponent(e)}/runtime-credential`,Ln=["flow_action","tool_invoke","polling_trigger","webhook_trigger"];function O(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 qn(e){let t=O(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 Wn(e){let t=O(e??{},[]);return t.ok?u(null):r(t.reason)}function jn(e){let t=O(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 Vn(e){let t=O(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 Jn(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 D(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 K(e){return!i(e)||e.method!=="GET"&&e.method!=="PUT"||typeof e.url!="string"||typeof e.expires_at!="string"||!be(e.headers)?r("presigned file URL data is invalid"):u(e)}function Se(e){if(!i(e))return r("file upload session data is invalid");let t=D(e.file);if(!t.ok)return r(t.reason);let n=K(e.upload);return n.ok?u({file:t.value,upload:n.value}):r(n.reason)}function Ce(e){if(!i(e))return r("file metadata data is invalid");let t=D(e.file);return t.ok?u({file:t.value}):r(t.reason)}function be(e){return i(e)?Object.values(e).every(t=>typeof t=="string"):!1}var _="/internal/files",er="/upload-session",tr="/:fileId/complete",nr="/:fileId/access",rr="/:fileId/stat",or="/:fileId/content",ir=()=>_,sr=()=>`${_}/upload-session`,ur=e=>`${_}/${encodeURIComponent(e)}/complete`,ar=(e,t)=>`${_}/${encodeURIComponent(e)}/access?intent=${encodeURIComponent(t)}`,X=e=>`?scope_kind=${encodeURIComponent(e.scopeKind)}&scope_id=${encodeURIComponent(e.scopeId)}`,cr=(e,t)=>`${_}/${encodeURIComponent(e)}/stat${X(t)}`,dr=(e,t)=>`${_}/${encodeURIComponent(e)}/content${X(t)}`;function lr(e){if(!i(e))return r("internal file access data is invalid");if(e.intent==="runtime_read"||e.intent==="provider_multipart"){let t=D(e.file);if(!t.ok)return r(t.reason);let n=K(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 Rr="/:flowRunId/human-inputs",mr="/:flowRunId/human-inputs/:requestId",yr="/:flowRunId/human-inputs/:requestId/expire",kr="/:flowRunId/human-inputs/:requestId/acknowledge",Ae=e=>`${f}/${encodeURIComponent(e)}/human-inputs`,Y=(e,t)=>`${Ae(e)}/${encodeURIComponent(t)}`,Ir=(e,t)=>`${Y(e,t)}/expire`,_r=(e,t)=>`${Y(e,t)}/acknowledge`,ve="human_input_resolved";function hr(e){return`${ve}_${e}`}function g(e){return{ok:!1,reason:e}}function m(e,t){return i(e)?{ok:!0,value:e}:g(`${t} must be an object`)}function h(e,t){return typeof e!="string"||e.length===0?g(`${t} must be a non-empty string`):{ok:!0,value:e}}var Ne=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?(?:Z|[+-]\d{2}:\d{2})$/;function Oe(e,t){return typeof e!="string"||!Ne.test(e)||Number.isNaN(Date.parse(e))?g(`${t} must be an ISO-8601 timestamp`):{ok:!0,value:e}}function De(e){let t=m(e,"renderedPrompt");if(!t.ok)return t;let n=h(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 g("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 g("renderedPrompt.format is invalid");o.format=t.value.format}return{ok:!0,value:o}}function Ue(e){let t=m(e,"input");if(!t.ok)return t;let n=t.value.kind;if(n==="choice"){if(!Array.isArray(t.value.choices))return g("input.choices must be an array")}else if(n!=="text")if(n==="form"){if(!Array.isArray(t.value.fields))return g("input.fields must be an array")}else return g("input.kind is invalid");return{ok:!0,value:t.value}}function Be(e){if(e==null)return{ok:!0,value:void 0};let t=m(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 g("partiallyRenderedDelivery.actions must be an array");let o=[];for(let s of n){let a=m(s,"delivery action");if(!a.ok)return a;let c=h(a.value.id,"delivery action id");if(!c.ok)return c;let l=z(a.value.inputs,`delivery action '${c.value}' inputs`);if(!l.ok)return l;o.push({id:c.value,inputs:l.value})}return{ok:!0,value:{actions:o}}}function z(e,t){let n=m(e,t);if(!n.ok)return n;let o={};for(let[s,a]of Object.entries(n.value)){let c=Q(a,`${t}.${s}`);if(!c.ok)return c;o[s]=c.value}return{ok:!0,value:o}}function Q(e,t){let n=m(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=h(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 g(`${t}.items must be an array`);let s=[];for(let[a,c]of n.value.items.entries()){let l=Q(c,`${t}[${a}]`);if(!l.ok)return l;s.push(l.value)}return{ok:!0,value:{kind:"array",items:s}}}case"object":{let s=z(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 g(`${t}.parts must be an array`);let s=[];for(let[a,c]of n.value.parts.entries()){let l=He(c,`${t}.parts[${a}]`);if(!l.ok)return l;s.push(l.value)}return{ok:!0,value:{kind:"template",parts:s}}}default:return g(`${t}.kind is invalid`)}}function He(e,t){let n=m(e,t);if(!n.ok)return n;let o=n.value.kind;if(o==="literal")return typeof n.value.value!="string"?g(`${t}.value must be a string`):{ok:!0,value:{kind:"literal",value:n.value.value}};if(o==="human_input_ref"){let s=h(n.value.path,`${t}.path`);return s.ok?{ok:!0,value:{kind:"human_input_ref",path:s.value}}:s}return g(`${t}.kind is invalid`)}function Er(e){let t=m(e,"request body");if(!t.ok)return r(t.reason);let n=h(t.value.nodeId,"nodeId");if(!n.ok)return r(n.reason);let o=De(t.value.renderedPrompt);if(!o.ok)return r(o.reason);let s=Ue(t.value.input);if(!s.ok)return r(s.reason);let a=h(t.value.timeout,"timeout");if(!a.ok)return r(a.reason);let c=Oe(t.value.expiresAt,"expiresAt");if(!c.ok)return r(c.reason);let l=Be(t.value.partiallyRenderedDelivery);return l.ok?u({nodeId:n.value,renderedPrompt:o.value,input:s.value,timeout:a.value,expiresAt:c.value,...l.value!==void 0?{partiallyRenderedDelivery:l.value}:{}}):r(l.reason)}function Fe(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 xr(e){if(!i(e)||typeof e.created!="boolean")return r("human input create data must carry created:boolean");let t=Fe(e.request);return t.ok?u({created:e.created,request:t.value}):t}function wr(e){return!i(e)||e.acknowledged!==!0?r("human input acknowledge data must carry acknowledged:true"):u({acknowledged:!0})}var Pr="ablehi-wfp-user-runtime-manifest/v1",Sr="unknown";function Cr(e){return e.endsWith(".js")?`${e.slice(0,-3)}.manifest.json`:`${e}.manifest.json`}var Ar="/internal/deployment-handshake",$e=["start","terminate","send-event","start-webhook-watcher","run-polling-tick","invoke-tool","invoke-trigger-handler","invoke-webhook-protocol-adapter","deployment-handshake"],vr=$e,Nr="HANDSHAKE_REQUEST_INVALID",Or="HANDSHAKE_SECRET_UNCONFIGURED",Dr="HANDSHAKE_SECRET_MISMATCH",Ur="HANDSHAKE_CONTRACT_VERSION_MISMATCH",Br="HANDSHAKE_DISPATCH_NAMESPACE_MISMATCH",Hr="HANDSHAKE_CAPABILITY_MISSING";function Fr(e){return[e.nonce,e.timestamp,e.contractVersion,e.dispatchNamespace].map(n=>`${n.length}:${n}`).join(".")}function $r(e){return["response",e.nonce,e.contractVersion,e.dispatchNamespace,...e.capabilities].map(n=>`${n.length}:${n}`).join(".")}export{Le as CONTEXT_STATE_CLEANUP_ROUTE_PATH,$e as DEPLOYMENT_HANDSHAKE_DISPATCHER_CAPABILITIES,vr as DEPLOYMENT_HANDSHAKE_REQUIRED_CAPABILITIES,Ar as DEPLOYMENT_HANDSHAKE_ROUTE,fn as EGRESS_GRANT_AUDIT_ROUTE_SUBPATH,gn as EGRESS_GRANT_CONSUME_ROUTE_SUBPATH,Ee as EGRESS_GRANT_SCOPE_KINDS,rt as EVENT_WAIT_ROUTE_SUBPATH,Xe as EXECUTION_CONTEXT_ROUTE_SUBPATH,nr as FILE_ACCESS_ROUTE_SUBPATH,tr as FILE_COMPLETE_ROUTE_SUBPATH,or as FILE_CONTENT_ROUTE_SUBPATH,rr as FILE_STAT_ROUTE_SUBPATH,er as FILE_UPLOAD_SESSION_ROUTE_SUBPATH,cn as FLOW_RUN_EGRESS_GRANT_ROUTE_SUBPATH,nt as FLOW_RUN_RESULT_ROUTE_SUBPATH,Un as FLOW_RUN_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,Rt as HANDLER_BUNDLES_ROUTE_SUBPATH,Hr as HANDSHAKE_CAPABILITY_MISSING,Ur as HANDSHAKE_CONTRACT_VERSION_MISMATCH,Br as HANDSHAKE_DISPATCH_NAMESPACE_MISMATCH,Nr as HANDSHAKE_REQUEST_INVALID,Dr as HANDSHAKE_SECRET_MISMATCH,Or as HANDSHAKE_SECRET_UNCONFIGURED,Rr as HUMAN_INPUTS_ROUTE_SUBPATH,kr as HUMAN_INPUT_ACKNOWLEDGE_ROUTE_SUBPATH,yr as HUMAN_INPUT_EXPIRE_ROUTE_SUBPATH,mr as HUMAN_INPUT_REQUEST_ROUTE_SUBPATH,ve as HUMAN_INPUT_RESOLVED_EVENT_PREFIX,V as INTERNAL_EGRESS_GRANTS_ROUTE_PREFIX,_ as INTERNAL_FILES_ROUTE_PREFIX,f as INTERNAL_FLOW_RUNS_ROUTE_PREFIX,ae as INTERNAL_FLOW_VERSIONS_ROUTE_PREFIX,F as INTERNAL_INSTALLATIONS_ROUTE_PREFIX,T as INTERNAL_POLLING_TRIGGER_INSTANCES_ROUTE_PREFIX,M as INTERNAL_TOOL_INVOCATIONS_ROUTE_PREFIX,x as INTERNAL_WEBHOOK_TRIGGER_INSTANCES_ROUTE_PREFIX,Jt as POLLING_TRIGGER_CONTEXT_ROUTE_SUBPATH,ln as POLLING_TRIGGER_EGRESS_GRANT_ROUTE_SUBPATH,Xt as POLLING_TRIGGER_HANDLER_BUNDLES_ROUTE_SUBPATH,Hn as POLLING_TRIGGER_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,Yt as POLLING_TRIGGER_TICK_EVENTS_ROUTE_SUBPATH,Ln as RUNTIME_CREDENTIAL_SESSION_SCOPE_KINDS,Z as SERVER_EXECUTION_CONTRACT_VERSION,tt as STEP_RESULT_ROUTE_SUBPATH,mt as TOOL_HANDLER_BUNDLES_ROUTE_SUBPATH,dn as TOOL_INVOCATION_EGRESS_GRANT_ROUTE_SUBPATH,Bn as TOOL_INVOCATION_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,Bt as WEBHOOK_PROTOCOL_ADAPTER_BUNDLE_ROUTE_SUBPATH,Ft as WEBHOOK_PROTOCOL_ADAPTER_MODULE,Pt as WEBHOOK_TRIGGER_CONTEXT_ROUTE_SUBPATH,Ct as WEBHOOK_TRIGGER_DELIVERY_ROUTE_SUBPATH,pn as WEBHOOK_TRIGGER_EGRESS_GRANT_ROUTE_SUBPATH,bt as WEBHOOK_TRIGGER_EVENTS_ROUTE_SUBPATH,St as WEBHOOK_TRIGGER_HANDLER_BUNDLES_ROUTE_SUBPATH,At as WEBHOOK_TRIGGER_REARM_ROUTE_SUBPATH,Fn as WEBHOOK_TRIGGER_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,Pr as WFP_USER_RUNTIME_MANIFEST_FORMAT_VERSION,Sr as WFP_USER_RUNTIME_UNKNOWN_SOURCE_REVISION,Fr as deploymentHandshakeProbePayload,$r as deploymentHandshakeResponseProofPayload,_n as egressGrantAuditPath,In as egressGrantConsumePath,st as eventWaitPath,Ye as executionContextPath,Rn as flowRunEgressGrantPath,it as flowRunResultPath,$n as flowRunRuntimeCredentialPath,$t as flowScriptProtocolAdapterModuleName,yt as handlerBundlesPath,_r as humanInputAcknowledgePath,Ir as humanInputExpirePath,Y as humanInputRequestPath,hr as humanInputResolvedEventType,Ae as humanInputsPath,ar as internalFileAccessPath,ur as internalFileCompletePath,dr as internalFileContentPath,cr as internalFileStatPath,sr as internalFileUploadSessionPath,ir as internalFilesPath,P as isValidRequestDigest,pt as parseCompleteFlowRunWaitBody,qe as parseContextStateCleanupRequestBody,We as parseContextStateCleanupResponseData,y as parseContextStateScope,Er as parseCreateHumanInputBody,Pn as parseEgressGrantAuditBody,Tn as parseEgressGrantConsumeBody,Cn as parseEgressGrantConsumeData,Sn as parseEgressGrantData,ze as parseExecutionContextData,Ce as parseFileMetadataData,D as parseFileRefData,re as parseFileRuntimeLimits,Se as parseFileUploadSessionData,hn as parseFlowActionGrantBody,ct as parseFlowRunResultBody,dt as parseFlowRunResultData,qn as parseFlowRuntimeCredentialBody,de as parseHandlerBundle,It as parseHandlerBundlesData,wr as parseHumanInputAcknowledgeData,xr as parseHumanInputCreateData,Fe as parseHumanInputRequestViewData,lr as parseInternalFileAccessData,tn as parsePollingPublishBody,jn as parsePollingRuntimeCredentialBody,en as parsePollingTriggerContext,xn as parsePollingTriggerGrantBody,nn as parsePublishPollingTickEventsData,lt as parseRegisterFlowRunWaitBody,gt as parseRegisterFlowRunWaitData,Jn as parseRuntimeCredentialSessionCredential,b as parseRuntimeNetwork,En as parseSingleToolGrantBody,Wn as parseSingleToolRuntimeCredentialBody,ut as parseStepRecordBody,at as parseStepRecordData,_t as parseToolHandlerBundlesData,Kt as parseTriggerHandlerBundlesData,Mt as parseWebhookDelivery,Lt as parseWebhookPublishEventsBody,qt as parseWebhookRearmBody,Vn as parseWebhookRuntimeCredentialBody,wn as parseWebhookTriggerGrantBody,Gt as parseWebhookWatcherContext,zt as pollingTriggerContextPath,yn as pollingTriggerEgressGrantPath,Qt as pollingTriggerHandlerBundlesPath,Mn as pollingTriggerRuntimeCredentialPath,Zt as pollingTriggerTickEventsPath,we as requestHasMultipartFileParts,ot as stepResultPath,kt as toolHandlerBundlesPath,mn as toolInvocationEgressGrantPath,Gn as toolInvocationRuntimeCredentialPath,Ht as webhookProtocolAdapterBundlePath,vt as webhookTriggerContextPath,Ot as webhookTriggerDeliveryPath,kn as webhookTriggerEgressGrantPath,Dt as webhookTriggerEventsPath,Nt as webhookTriggerHandlerBundlesPath,Ut as webhookTriggerRearmPath,Kn as webhookTriggerRuntimeCredentialPath,Cr as wfpUserRuntimeManifestPath};
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ablehi/server-execution-contract",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Ablehi server to Cloudflare execution contract.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"main": "dist/index.js",
|
|
11
|
+
"types": "dist/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"import": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./edge": {
|
|
18
|
+
"types": "./dist/edge.d.ts",
|
|
19
|
+
"import": "./dist/edge.js"
|
|
20
|
+
},
|
|
21
|
+
"./package.json": "./package.json"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist"
|
|
25
|
+
],
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@ablehi/flow-contract": "0.1.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@typescript-eslint/eslint-plugin": "^8.62.0",
|
|
31
|
+
"@typescript-eslint/parser": "^8.62.0",
|
|
32
|
+
"eslint": "^10.5.0",
|
|
33
|
+
"tsup": "^8.5.1",
|
|
34
|
+
"typescript": "^6.0.3",
|
|
35
|
+
"vitest": "^4.1.9"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "tsup",
|
|
39
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
40
|
+
"test": "vitest run --passWithNoTests",
|
|
41
|
+
"lint": "eslint src --ext .ts",
|
|
42
|
+
"check": "pnpm build && pnpm typecheck && pnpm lint && pnpm test"
|
|
43
|
+
}
|
|
44
|
+
}
|