@ablehi/server-execution-contract 0.3.6 → 0.3.7
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/action-transform.js +1 -1
- package/dist/edge.d.ts +2 -2
- package/dist/edge.js +1 -1
- package/dist/index.d.ts +384 -8
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var Fe="0.5.0";function u(e){return{ok:!0,value:e}}function r(e){return{ok:!1,reason:e}}function s(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var sn="/cleanup-state-scopes";function b(e){if(!s(e)||typeof e.kind!="string")return r("context state scope surface shape is invalid");switch(e.kind){case"webhook-trigger":return He(e);case"polling-trigger":return Le(e);case"flow-action":return $e(e);default:return r("context state scope kind is invalid")}}function an(e){if(!s(e))return r("cleanup request body must be a JSON object");let t=V(e,["scopes"]);if(t!==void 0)return r(`cleanup request does not accept the "${t}" field`);if(!Array.isArray(e.scopes))return r("cleanup request scopes must be an array");let n=[];for(let o of e.scopes){let i=b(o);if(!i.ok)return i;n.push(i.value)}return u({scopes:n})}function un(e){return!s(e)||typeof e.deleted!="number"||!Number.isSafeInteger(e.deleted)||e.deleted<0?r("cleanup response data surface shape is invalid"):u({deleted:e.deleted})}function He(e){let t=V(e,["kind","workspaceId","triggerInstanceId"]);return t!==void 0?r(`webhook trigger scope does not accept "${t}"`):e.kind!=="webhook-trigger"||!w(e.workspaceId)||!w(e.triggerInstanceId)?r("webhook trigger state scope is invalid"):u({kind:"webhook-trigger",workspaceId:e.workspaceId,triggerInstanceId:e.triggerInstanceId})}function Le(e){let t=V(e,["kind","workspaceId","pollingInstanceId"]);return t!==void 0?r(`polling trigger scope does not accept "${t}"`):e.kind!=="polling-trigger"||!w(e.workspaceId)||!w(e.pollingInstanceId)?r("polling trigger state scope is invalid"):u({kind:"polling-trigger",workspaceId:e.workspaceId,pollingInstanceId:e.pollingInstanceId})}function $e(e){let t=V(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"||!w(e.workspaceId)||!w(e.flowId)||!w(e.nodeId)||n!==null&&!w(n)?r("flow action state scope is invalid"):u({kind:"flow-action",workspaceId:e.workspaceId,flowId:e.flowId,nodeId:e.nodeId,connectionId:n})}function w(e){return typeof e=="string"&&e.length>0}function V(e,t){return Object.keys(e).find(n=>!t.includes(n))}import{FLOW_INTERPRETER_CONTRACT_VERSION as Me,FLOW_IR_SCHEMA_VERSION as We,parseFlowDefinition as Ge}from"@ablehi/flow-contract";var R="/internal/flow-runs",fn="/:flowRunId/execution-context";function gn(e){return`${R}/${encodeURIComponent(e)}/execution-context`}function ne(e){return!s(e)||_(e,["fileMaxBytes","fileReadMaxBytes","inlineMultipartBytesMax"])!==void 0||!j(e.fileMaxBytes)||!j(e.fileReadMaxBytes)||!j(e.inlineMultipartBytesMax)?r("file runtime limits must carry three positive integer bounds"):u({fileMaxBytes:e.fileMaxBytes,fileReadMaxBytes:e.fileReadMaxBytes,inlineMultipartBytesMax:e.inlineMultipartBytesMax})}function mn(e){if(!s(e))return r("execution context must be a JSON object");let t=_(e,["flowRunId","workspaceId","input","executionGeneration","compiled","executionBindings","fileRuntime"]);if(t!==void 0)return r(`execution context does not accept the "${t}" field`);let n=e.compiled;if(typeof e.flowRunId!="string"||typeof e.workspaceId!="string"||!s(e.input)||!s(n)||_(n,["irSchemaVersion","interpreterContractVersion","ir","compiledArtifactId"])!==void 0||n.irSchemaVersion!==We||n.interpreterContractVersion!==Me||typeof n.compiledArtifactId!="string"||!Ve(e.executionBindings))return r("execution context surface shape is invalid");let o=Ge(n.ir);if(!o.ok)return r(o.reason);let i=Ke(e.executionGeneration,e.flowRunId);if(!i.ok)return r(i.reason);let c=qe(e.fileRuntime);return c.ok?u({...e,compiled:{...n,ir:o.value},executionGeneration:i.value,fileRuntime:c.value}):r(c.reason)}function Ke(e,t){return!s(e)||_(e,["id","flowRunId","number"])!==void 0||typeof e.id!="string"||e.id.length===0||typeof e.flowRunId!="string"||e.flowRunId!==t||!j(e.number)?r("executionGeneration surface shape is invalid"):u({id:e.id,flowRunId:e.flowRunId,number:e.number})}function qe(e){if(e===null)return u(null);if(!s(e))return r("fileRuntime must be null or an object");if(_(e,["limits"])!==void 0)return r("fileRuntime surface shape is invalid");let t=ne(e.limits);return t.ok?u({limits:t.value}):r(t.reason)}function Ve(e){return Array.isArray(e)?e.every(t=>{if(!s(t)||!b(t.stateScope).ok||!x(t.nodeId))return!1;if(t.executionKind==="direct")return _(t,["executionKind","nodeId","stateScope","toolRef","toolDescriptor","integrationDescriptor","connection"])===void 0&&x(t.toolRef)&&s(t.toolDescriptor)&&s(t.integrationDescriptor)&&Re(t.toolDescriptor,t.connection);if(t.executionKind!=="server_transformed")return!1;let o=t.realAction;return _(t,["executionKind","nodeId","stateScope","canonicalToolRef","serverTransformRef","serverTransformContractDigest","realAction"])===void 0&&x(t.canonicalToolRef)&&x(t.serverTransformRef)&&Je(t.serverTransformContractDigest)&&s(o)&&_(o,["toolRef","toolDescriptor","integrationDescriptor","connection"])===void 0&&x(o.toolRef)&&s(o.toolDescriptor)&&s(o.integrationDescriptor)&&Re(o.toolDescriptor,o.connection)}):!1}function Re(e,t){return e.auth_required===!1?t===null:e.auth_required===!0&&je(t)}function je(e){return s(e)&&_(e,["installationId","connectionRef","connectionId","authProfileRef","authType","connectionConfig"])===void 0&&x(e.installationId)&&x(e.connectionRef)&&x(e.connectionId)&&x(e.authProfileRef)&&x(e.authType)&&(e.connectionConfig===void 0||s(e.connectionConfig))}function Je(e){return typeof e=="string"&&/^[0-9a-f]{64}$/.test(e)}function x(e){return typeof e=="string"&&e.length>0}function j(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0}function _(e,t){return Object.keys(e).find(n=>!t.includes(n))}var kn="/:flowRunId/execution-leases",xn="/restart",En="WORKFLOW_RESTART_REQUEST_INVALID",_n="WORKFLOW_RESTART_INSTANCE_UNAVAILABLE",hn="WORKFLOW_RESTART_REJECTED",wn="RUN_DISPATCH_UNAVAILABLE",Tn="EXECUTION_LEASE_INVALID",bn="EXECUTION_LEASE_SUPERSEDED",Sn="WAIT_EXECUTION_SUPERSEDED",Pn="HUMAN_INPUT_CANCELLED_BY_RESET";function An(e){return`${R}/${encodeURIComponent(e)}/execution-leases`}var Xe=/^generation:[A-Za-z0-9][A-Za-z0-9._:-]{0,239}$/;function Ie(e){return s(e)?e.kind==="terminal"&&h(e,["kind"])?u({kind:"terminal"}):e.kind==="node"&&h(e,["kind","nodeId"])&&y(e.nodeId)?u({kind:"node",nodeId:e.nodeId}):r("execution anchor shape is invalid"):r("execution anchor must be an object")}function k(e){if(!s(e)||!h(e,["flowRunId","generationId","generationNumber","anchor","leaseId"])||!y(e.flowRunId)||!y(e.generationId)||!Ye(e.generationNumber)||!y(e.leaseId))return r("execution lease shape is invalid");let t=Ie(e.anchor);return t.ok?u({flowRunId:e.flowRunId,generationId:e.generationId,generationNumber:e.generationNumber,anchor:t.value,leaseId:e.leaseId}):r(t.reason)}function Cn(e){if(!s(e)||!h(e,["anchor"]))return r("lease request shape is invalid");let t=Ie(e.anchor);return t.ok?u({anchor:t.value}):r(t.reason)}function Nn(e){if(!s(e)||!h(e,["lease"]))return r("lease response shape is invalid");let t=k(e.lease);return t.ok?u({lease:t.value}):r(t.reason)}function On(e){return!s(e)||!h(e,["instanceId","flowRunId","commandId","generationId","from"])||!y(e.instanceId)||!y(e.flowRunId)||!y(e.commandId)||!y(e.generationId)||!s(e.from)||!h(e.from,["name","count","type"])||typeof e.from.name!="string"||!Xe.test(e.from.name)||e.from.name==="generation:terminal"||e.from.count!==1||e.from.type!=="do"?r("restart request shape is invalid"):u(e)}function Dn(e){return!s(e)||!h(e,["ok","data"])||e.ok!==!0||!s(e.data)||!h(e.data,["accepted","instanceId","commandId","generationId"])||e.data.accepted!==!0||!y(e.data.instanceId)||!y(e.data.commandId)||!y(e.data.generationId)?r("restart response shape is invalid"):u(e)}function h(e,t){let n=Object.keys(e).sort(),o=[...t].sort();return n.length===o.length&&n.every((i,c)=>i===o[c])}function y(e){return typeof e=="string"&&e.length>0}function Ye(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0}import{parseAblehiErrorDigest as re}from"@ablehi/error-contract";var Ln="/:flowRunId/steps/:nodeId/result",$n="/:flowRunId/result",Mn="/:flowRunId/execution-events",Wn="/:flowRunId/waits/:nodeId/register",Gn="/:flowRunId/waits/:nodeId/complete";function Kn(e,t){return`${R}/${encodeURIComponent(e)}/steps/${encodeURIComponent(t)}/result`}function qn(e){return`${R}/${encodeURIComponent(e)}/result`}function Vn(e){return`${R}/${encodeURIComponent(e)}/execution-events`}function jn(e,t){return`${R}/${encodeURIComponent(e)}/waits/${encodeURIComponent(t)}/register`}function Jn(e,t){return`${R}/${encodeURIComponent(e)}/waits/${encodeURIComponent(t)}/complete`}function Xn(e){if(!s(e))return{ok:!1,kind:"validation",reason:"step record body must be a JSON object"};let t=I(e,["executionLease","attempt","result","durationMs"]);if(t!==void 0)return{ok:!1,kind:"validation",reason:`step record does not accept the "${t}" field`};let n=k(e.executionLease);if(!n.ok)return{ok:!1,kind:"validation",reason:n.reason};let o=e.attempt;if(typeof o!="number"||!Number.isInteger(o)||o<=0)return{ok:!1,kind:"validation",reason:"attempt must be a positive integer"};let i=ze(e.result);if(!i.ok)return i;let c={executionLease:n.value,attempt:o,result:i.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"};c.durationMs=a}return{ok:!0,value:c}}function ze(e){if(!s(e))return{ok:!1,kind:"step_result_invalid",reason:"result must be a JSON object"};let t=e.status;if(t==="succeeded"){let n=I(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=I(e,["status","error"]);if(n!==void 0)return{ok:!1,kind:"validation",reason:`step record result does not accept the "${n}" field`};let o=re(e.error);return o.ok?{ok:!0,value:{status:"failed",error:o.value}}:{ok:!1,kind:"step_result_invalid",reason:`a failed result must carry an AblehiErrorDigest: ${o.reason}`}}if(t==="skipped"){let n=I(e,["status","reason"]);return n!==void 0?{ok:!1,kind:"validation",reason:`step record result does not accept the "${n}" field`}:e.reason!=="run_if_false"?{ok:!1,kind:"step_result_invalid",reason:'a skipped result reason must be "run_if_false"'}:{ok:!0,value:{status:"skipped",reason:"run_if_false"}}}if(t==="timed_out"){let n=I(e,["status","error"]);if(n!==void 0)return{ok:!1,kind:"validation",reason:`step record result does not accept the "${n}" field`};let o=re(e.error);return o.ok?{ok:!0,value:{status:"timed_out",error:o.value}}:{ok:!1,kind:"step_result_invalid",reason:`a timed_out result must carry an AblehiErrorDigest: ${o.reason}`}}return{ok:!1,kind:"step_result_invalid",reason:'result status must be "succeeded", "failed", "skipped", or "timed_out"'}}function Yn(e){return!s(e)||typeof e.flowRunId!="string"||typeof e.nodeId!="string"||!Qe(e.recorded)?r("step record data surface shape is invalid"):u({flowRunId:e.flowRunId,nodeId:e.nodeId,recorded:e.recorded})}function Qe(e){return e==="succeeded"||e==="failed"||e==="skipped"||e==="timed_out"}function zn(e){if(!s(e))return r("result body must be a JSON object");let t=I(e,["executionLease","status","output","error"]);if(t!==void 0)return r(`result does not accept the "${t}" field`);let n=k(e.executionLease);if(!n.ok)return r(n.reason);let o=e.status;if(o!=="succeeded"&&o!=="failed")return r('result status must be "succeeded" or "failed"');let i={executionLease:n.value,status:o};if(e.output!==void 0){if(o!=="succeeded")return r("output is only allowed on a succeeded result");i.output=e.output}if(e.error!==void 0){if(o!=="failed")return r("error is only allowed on a failed result");let c=re(e.error);if(!c.ok)return r(`result error must be an AblehiErrorDigest: ${c.reason}`);i.error=c.value}return o==="failed"&&i.error===void 0?r("a failed result must carry an AblehiErrorDigest"):u(i)}function Qn(e){return s(e)?u(e):r("flow run result data must be a JSON object")}var Ze=["step_started","step_retry_scheduled"];function Zn(e){if(!s(e))return r("execution event data must be a JSON object");let t=I(e,["flowRunId","eventId","accepted"]);return t!==void 0?r(`execution event data does not accept the "${t}" field`):typeof e.flowRunId!="string"||e.flowRunId.length===0?r("flowRunId must be a non-empty string"):typeof e.eventId!="string"||e.eventId.length===0?r("eventId must be a non-empty string"):e.accepted!==!0?r("accepted must be true"):u({flowRunId:e.flowRunId,eventId:e.eventId,accepted:!0})}function er(e){if(!s(e))return r("execution event body must be a JSON object");let t=I(e,["executionLease","eventId","eventType","nodeId","stepRunId","attempt","durationMs","occurredAt","errorId","payloadRef","inputFact"]);if(t!==void 0)return r(`execution event does not accept the "${t}" field`);let n=k(e.executionLease);if(!n.ok)return r(n.reason);let o=e.eventId;if(typeof o!="string"||o.length===0)return r("eventId must be a non-empty string");let i=e.eventType;if(!et(i))return r("eventType is not a known flow execution event type");let c=e.occurredAt;if(typeof c!="string"||c.length===0)return r("occurredAt must be a non-empty string");let a={executionLease:n.value,eventId:o,eventType:i,occurredAt:c};for(let d of["nodeId","stepRunId","errorId","payloadRef"]){let f=e[d];if(f!==void 0){if(typeof f!="string"||f.length===0)return r(`${d} must be a non-empty string`);a[d]=f}}for(let d of["attempt","durationMs"]){let f=e[d];if(f!==void 0){if(typeof f!="number"||!Number.isFinite(f)||!Number.isInteger(f)||f<0)return r(`${d} must be a non-negative integer`);a[d]=f}}if(e.inputFact!==void 0){if(i!=="step_started")return r("inputFact is only allowed on step_started events");if(a.attempt===void 0)return r("inputFact requires attempt");let d=tt(e.inputFact);if(!d.ok)return d;a.inputFact=d.value}return u(a)}function et(e){return typeof e=="string"&&Ze.includes(e)}function tt(e){if(!s(e))return r("inputFact must be a JSON object");let t=I(e,["digestAlgorithm","digest","domain"]);if(t!==void 0)return r(`inputFact does not accept the "${t}" field`);if(e.digestAlgorithm!=="sha256")return r('inputFact.digestAlgorithm must be "sha256"');let n=e.digest;if(typeof n!="string"||!/^[0-9a-f]{64}$/.test(n))return r("inputFact.digest must be a sha256 hex string");let o=e.domain;if(!s(o))return r("inputFact.domain must be a JSON object");let i=I(o,["irSchemaVersion","interpreterContractVersion","compiledArtifactId","nodeId","algorithmVersion"]);return i!==void 0?r(`inputFact.domain does not accept the "${i}" field`):typeof o.irSchemaVersion!="string"||o.irSchemaVersion.length===0||typeof o.interpreterContractVersion!="string"||o.interpreterContractVersion.length===0||typeof o.compiledArtifactId!="string"||o.compiledArtifactId.length===0||typeof o.nodeId!="string"||o.nodeId.length===0?r("inputFact.domain string fields must be non-empty strings"):o.algorithmVersion!=="flow_input_digest.v1"?r('inputFact.domain.algorithmVersion must be "flow_input_digest.v1"'):u({digestAlgorithm:"sha256",digest:n,domain:{irSchemaVersion:o.irSchemaVersion,interpreterContractVersion:o.interpreterContractVersion,compiledArtifactId:o.compiledArtifactId,nodeId:o.nodeId,algorithmVersion:"flow_input_digest.v1"}})}var nt=/^[A-Za-z0-9_-]{1,100}$/;function tr(e){if(!s(e))return r("register body must be a JSON object");let t=I(e,["executionLease","eventType","correlationKey"]);if(t!==void 0)return r(`register wait does not accept the "${t}" field`);let n=k(e.executionLease);if(!n.ok)return r(n.reason);let o=ye(e.eventType);if(!o.ok)return r(o.reason);let i=e.correlationKey;return typeof i!="string"||i.length===0?r("correlationKey must be a non-empty string"):u({executionLease:n.value,eventType:o.value,correlationKey:i})}function nr(e){if(!s(e))return r("complete body must be a JSON object");let t=I(e,["executionLease","waitExecutionId","outcome","eventId"]);if(t!==void 0)return r(`complete wait does not accept the "${t}" field`);let n=k(e.executionLease);if(!n.ok)return r(n.reason);let o=e.waitExecutionId;if(typeof o!="string"||o.length===0)return r("waitExecutionId must be a non-empty string");let i=e.outcome;if(i!=="received"&&i!=="timed_out")return r('outcome must be "received" or "timed_out"');let c={executionLease:n.value,waitExecutionId:o,outcome:i};if(e.eventId!==void 0){if(typeof e.eventId!="string"||e.eventId.length===0)return r("eventId must be a non-empty string");c.eventId=e.eventId}return u(c)}function rr(e){if(!s(e)||I(e,["waitExecutionId","workflowEventType"])!==void 0||typeof e.waitExecutionId!="string"||e.waitExecutionId.length===0)return r("register wait data surface shape is invalid");let t=ye(e.workflowEventType);return t.ok?u({waitExecutionId:e.waitExecutionId,workflowEventType:t.value}):r(t.reason)}function or(e){return!s(e)||I(e,["completed"])!==void 0||e.completed!==!0?r("complete wait data surface shape is invalid"):u({completed:!0})}function ir(e){return!s(e)||I(e,["waitExecutionId","eventId","payload"])!==void 0||typeof e.waitExecutionId!="string"||e.waitExecutionId.length===0||typeof e.eventId!="string"||e.eventId.length===0||!Object.hasOwn(e,"payload")?r("Wait resolved event surface shape is invalid"):u({waitExecutionId:e.waitExecutionId,eventId:e.eventId,payload:e.payload})}function ye(e){return typeof e!="string"||e.length===0?r("eventType must be a non-empty string"):nt.test(e)?u(e):r("eventType must match ^[A-Za-z0-9_-]{1,100}$")}function I(e,t){return Object.keys(e).find(n=>!t.includes(n))}var rt="/internal/flow-versions",ar="/:flowVersionId/handler-bundles",ie="/internal/installations",ur="/:installationId/handler-bundles";function cr(e,t){return`${rt}/${encodeURIComponent(e)}/handler-bundles?compiledArtifactId=${encodeURIComponent(t)}`}function dr(e){return`${ie}/${encodeURIComponent(e.installationId)}/handler-bundles?workspaceId=${encodeURIComponent(e.workspaceId)}&artifactDigest=${encodeURIComponent(e.artifactDigest)}`}var ot=new Set(["managed_only","managed_plus_unmanaged_sdk"]);function J(e){if(!A(e))return oe("runtimeNetwork must be a JSON object");let t=e.networkModel;return typeof t!="string"||!ot.has(t)?oe("runtimeNetwork.networkModel is unknown"):!ke(e.apiHosts)||!ke(e.authHosts)||typeof e.httpsOnly!="boolean"?oe("runtimeNetwork host/https fields are invalid"):{ok:!0,value:{networkModel:t,apiHosts:e.apiHosts,authHosts:e.authHosts,httpsOnly:e.httpsOnly}}}function pr(e){if(!A(e)||typeof e.flowVersionId!="string"||typeof e.compiledArtifactId!="string"||!Array.isArray(e.bundles))return B("handler bundles data surface shape is invalid");let t=xe(e.bundles);return t.ok?{ok:!0,value:{flowVersionId:e.flowVersionId,compiledArtifactId:e.compiledArtifactId,bundles:t.value}}:t}function lr(e){if(!A(e)||typeof e.installationId!="string"||typeof e.artifactDigest!="string"||!Array.isArray(e.bundles))return B("tool handler bundles data surface shape is invalid");let t=xe(e.bundles);return t.ok?{ok:!0,value:{installationId:e.installationId,artifactDigest:e.artifactDigest,bundles:t.value}}:t}function xe(e){let t=[];for(let n of e){let o=it(n);if(!o.ok)return o;t.push(o.value)}return{ok:!0,value:t}}function it(e){if(!A(e)||typeof e.toolRef!="string"||e.kind!=="handler"&&e.kind!=="request")return B("handler bundle entry shape is invalid");if(e.kind==="request"){if(e.module!==void 0)return B("a request bundle must not carry a module");let o=J(e.runtimeNetwork);return o.ok?{ok:!0,value:{toolRef:e.toolRef,kind:"request",runtimeNetwork:o.value}}:o}let t=e.module;if(!A(t)||typeof t.entry!="string"||t.entry.length===0||!st(t.files))return B("a handler bundle must carry a { entry, files } module");let n=J(e.runtimeNetwork);return n.ok?{ok:!0,value:{toolRef:e.toolRef,kind:"handler",module:{entry:t.entry,files:t.files},runtimeNetwork:n.value}}:n}function B(e){return{ok:!1,kind:"shape",reason:e}}function oe(e){return{ok:!1,kind:"runtime_network",reason:e}}function A(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ke(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function st(e){return A(e)&&Object.values(e).every(t=>typeof t=="string")}var F="/internal/webhook-trigger-instances",kr="/:triggerInstanceId/context",xr="/:triggerInstanceId/handler-bundles",Er="/:triggerInstanceId/deliveries/:deliveryId",_r="/:triggerInstanceId/events",hr="/:triggerInstanceId/rearm",H=e=>`${F}/${encodeURIComponent(e)}`;function wr(e,t){return`${H(e)}/context?artifactDigest=${encodeURIComponent(t)}`}function Tr(e,t){return`${H(e)}/handler-bundles?artifactDigest=${encodeURIComponent(t)}`}function br(e,t){return`${H(e)}/deliveries/${encodeURIComponent(t)}`}function Sr(e){return`${H(e)}/events`}function Pr(e){return`${H(e)}/rearm`}var Ar="/:installationId/webhook-protocol-adapter-bundle";function Cr(e){return`${ie}/${encodeURIComponent(e.installationId)}/webhook-protocol-adapter-bundle?workspaceId=${encodeURIComponent(e.workspaceId)}&artifactDigest=${encodeURIComponent(e.artifactDigest)}`}var Nr="modules/webhook/protocol-adapter.js";function Or(e){return`modules/webhook/protocol-adapter-${e}.js`}function Dr(e){let t=s(e)?b(e.stateScope):r("webhook watcher context state scope is invalid");return!s(e)||typeof e.artifactDigest!="string"||typeof e.triggerRef!="string"||typeof e.triggerName!="string"||typeof e.integrationRef!="string"||!s(e.inputs)||e.connection!==null&&!at(e.connection)||!ut(e.runtime)||!t.ok||t.value.kind!=="webhook-trigger"?r("webhook watcher context surface shape is invalid"):u(e)}function at(e){return s(e)&&typeof e.connectionId=="string"&&typeof e.connectionRef=="string"&&typeof e.integrationRef=="string"&&typeof e.authProfileRef=="string"&&typeof e.authType=="string"}function ut(e){if(!s(e)||e.type!=="webhook"||typeof e.trigger_ref!="string")return!1;let t=e.webhook;return s(t)&&typeof t.event_handler_module=="string"&&typeof t.enable_handler_module=="string"&&typeof t.disable_handler_module=="string"}function ct(e){if(!s(e)||typeof e.deliveryId!="string"||typeof e.receivedAt!="string"||!s(e.request))return r("webhook delivery surface shape is invalid");let t=e.request;return t.method!=="POST"||!s(t.headers)||typeof t.rawBody!="string"?r("webhook delivery request shape is invalid"):u(e)}function se(e){if(!s(e)||typeof e.token!="string"||typeof e.expiresAt!="string")return r("trigger file runtime dispatch shape is invalid");let t=ne(e.limits);return t.ok?u({token:e.token,expiresAt:e.expiresAt,limits:t.value}):r(t.reason)}function vr(e){if(!s(e))return r("webhook delivery dispatch data is invalid");let t=ct(e.delivery);if(!t.ok)return r(t.reason);let n=e.fileRuntime;if(n===null)return u({delivery:t.value,fileRuntime:null});let o=se(n);return o.ok?u({delivery:t.value,fileRuntime:o.value}):r(o.reason)}function Ur(e){if(!s(e)||typeof e.triggerRef!="string"||typeof e.artifactDigest!="string"||!Array.isArray(e.modules)||!e.modules.every(dt))return{ok:!1,kind:"shape",reason:"trigger handler bundles data surface shape is invalid"};let t=J(e.runtimeNetwork);return t.ok?{ok:!0,value:{triggerRef:e.triggerRef,artifactDigest:e.artifactDigest,modules:e.modules,runtimeNetwork:t.value}}:t}function dt(e){return s(e)&&typeof e.specifier=="string"&&e.specifier.length>0&&typeof e.source=="string"}function Br(e){if(!s(e))return r("publish events body must be a JSON object");let t=ae(e,["deliveryId","events"]);if(t!==void 0)return r(`publish events does not accept the "${t}" field`);let n=e.deliveryId;if(typeof n!="string"||n.length===0)return r("deliveryId must be a non-empty string");let o=e.events;if(!Array.isArray(o))return r("events must be an array");let i=[];for(let c of o){let a=pt(c);if(!a.ok)return a;i.push(a.value)}return u({deliveryId:n,events:i})}function pt(e){if(!s(e))return r("each event must be a JSON object");let t=ae(e,["eventId","occurredAt","dedupeKey","payload"]);if(t!==void 0)return r(`event does not accept the "${t}" field`);let n=e.eventId;if(typeof n!="string"||n.length===0)return r("eventId must be a non-empty string");let o=e.occurredAt;if(typeof o!="string"||o.length===0)return r("occurredAt must be a non-empty string");if(!s(e.payload))return r("event payload must be a JSON object");let i={eventId:n,occurredAt:o,payload:e.payload};if(e.dedupeKey!==void 0){if(typeof e.dedupeKey!="string"||e.dedupeKey.length===0)return r("dedupeKey must be a non-empty string");i.dedupeKey=e.dedupeKey}return u(i)}function Fr(e){if(!s(e))return r("rearm body must be a JSON object");let t=ae(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 ae(e,t){return Object.keys(e).find(n=>!t.includes(n))}var L="/internal/polling-trigger-instances",Wr="/:pollingInstanceId/context",Gr="/:pollingInstanceId/handler-bundles",Kr="/:pollingInstanceId/ticks/:tickId/events",ue=e=>`${L}/${encodeURIComponent(e)}`;function qr(e,t,n){return`${ue(e)}/context?artifactDigest=${encodeURIComponent(t)}&tickId=${encodeURIComponent(n)}`}function Vr(e,t){return`${ue(e)}/handler-bundles?artifactDigest=${encodeURIComponent(t)}`}function jr(e,t){return`${ue(e)}/ticks/${encodeURIComponent(t)}/events`}function lt(e){let t=s(e)?b(e.stateScope):r("polling trigger context state scope is invalid");return!s(e)||typeof e.artifactDigest!="string"||typeof e.triggerRef!="string"||typeof e.triggerName!="string"||typeof e.integrationRef!="string"||!s(e.inputs)||e.connection!==null&&!ft(e.connection)||!gt(e.runtime)||!t.ok||t.value.kind!=="polling-trigger"||!Rt(e.tick)||!It(e.limits)?r("polling trigger context surface shape is invalid"):u(e)}function Jr(e){if(!s(e))return r("polling trigger dispatch data is invalid");let t=lt(e.context);if(!t.ok)return r(t.reason);let n=e.fileRuntime;if(n===null)return u({context:t.value,fileRuntime:null});let o=se(n);return o.ok?u({context:t.value,fileRuntime:o.value}):r(o.reason)}function ft(e){return s(e)&&typeof e.connectionId=="string"&&typeof e.connectionRef=="string"&&typeof e.integrationRef=="string"&&typeof e.authProfileRef=="string"&&typeof e.authType=="string"}function gt(e){if(!s(e)||e.type!=="polling"||typeof e.trigger_id!="string"||typeof e.trigger_ref!="string"||!mt(e.file_outputs))return!1;let t=e.polling;if(!s(t)||typeof t.run_handler_module!="string")return!1;let n=t.schedule;if(!s(n)||n.type!=="interval"||typeof n.every_seconds!="number")return!1;let o=t.dedup;return s(o)&&(o.strategy==="cursor"||o.strategy==="hash"||o.strategy==="id_field")}function mt(e){return e===void 0?!0:Array.isArray(e)&&e.length>0&&e.every(t=>s(t)&&typeof t.field=="string"&&t.field.length>0)}function Rt(e){return s(e)&&typeof e.tickId=="string"&&typeof e.scheduledAt=="string"&&typeof e.attempt=="number"}function It(e){return s(e)&&typeof e.maxEventsPerTick=="number"}function Xr(e){if(!s(e))return r("publish body must be a JSON object");let t=Ee(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 c of n){let a=yt(c);if(!a.ok)return a;o.push(a.value)}let i={events:o};if("nextCursor"in e){let c=e.nextCursor;if(c!==null&&typeof c!="string")return r("nextCursor must be a string, null, or omitted");i.nextCursor=c}return u(i)}function yt(e){if(!s(e))return r("each event must be a JSON object");let t=Ee(e,["eventId","occurredAt","dedupeKey","payload"]);if(t!==void 0)return r(`event does not accept the "${t}" field`);if(typeof e.eventId!="string"||e.eventId.length===0)return r("event eventId must be a non-empty string");if(!s(e.payload))return r("event payload must be a JSON object");let n={eventId:e.eventId,payload:e.payload};if(e.occurredAt!==void 0){if(typeof e.occurredAt!="string"||e.occurredAt.length===0)return r("event occurredAt must be a non-empty string");n.occurredAt=e.occurredAt}if(e.dedupeKey!==void 0){if(typeof e.dedupeKey!="string"||e.dedupeKey.length===0)return r("event dedupeKey must be a non-empty string");n.dedupeKey=e.dedupeKey}return u(n)}function Yr(e){return!s(e)||typeof e.tickId!="string"||typeof e.cursorUpdated!="boolean"||!Array.isArray(e.results)||!e.results.every(kt)?r("publish polling tick events data surface shape is invalid"):u(e)}function kt(e){return s(e)&&typeof e.eventId=="string"&&typeof e.dedupeKey=="string"&&typeof e.duplicate=="boolean"&&(e.flowRunId===null||typeof e.flowRunId=="string")}function Ee(e,t){return Object.keys(e).find(n=>!t.includes(n))}var _e="/internal/egress-grants",ce="/internal/tool-invocations",de="/internal/discovery-invocations",no="/:flowRunId/egress-grant",ro="/:invocationId/egress-grant",oo="/:discoveryInvocationId/egress-grant",io="/:pollingInstanceId/egress-grant",so="/:triggerInstanceId/egress-grant",ao="/:grantId/consume",uo="/:grantId/audit",co=e=>`${R}/${encodeURIComponent(e)}/egress-grant`,po=e=>`${ce}/${encodeURIComponent(e)}/egress-grant`,lo=e=>`${de}/${encodeURIComponent(e)}/egress-grant`,fo=e=>`${L}/${encodeURIComponent(e)}/egress-grant`,go=e=>`${F}/${encodeURIComponent(e)}/egress-grant`,mo=e=>`${_e}/${encodeURIComponent(e)}/consume`,Ro=e=>`${_e}/${encodeURIComponent(e)}/audit`,xt=["flow_action","single_tool","discovery","polling_trigger","webhook_trigger"],Et=/^[A-Za-z0-9][A-Za-z0-9:_+/=.-]{15,1023}$/;function C(e){return typeof e=="string"&&Et.test(e)}function _t(e){if(!s(e)||e.body_type!=="multipart")return!1;let t=e.body;if(!s(t))return!1;let n=t.parts;return Array.isArray(n)?n.some(o=>s(o)?o.kind==="file"&&typeof o.file_id=="string"&&o.file_id.length>0:!1):!1}function p(e){return{ok:!1,kind:"shape",reason:e}}function N(){return{ok:!1,kind:"request_digest",reason:"request digest is missing or malformed"}}function $(e,t){if(!s(e))return{ok:!1,reason:"grant request body must be a JSON object"};for(let n of Object.keys(e))if(!t.includes(n))return{ok:!1,reason:`grant request does not accept the "${n}" field`};return{ok:!0,record:e}}function M(e){if(!s(e))return"request must be a JSON object"}function Io(e){let t=$(e,["nodeId","request","requestDigest"]);if(!t.ok)return p(t.reason);let n=t.record.nodeId;if(typeof n!="string"||n.length===0)return p("nodeId is required");let o=M(t.record.request);if(o!==void 0)return p(o);let i=t.record.requestDigest;return C(i)?{ok:!0,value:{nodeId:n,requestDigest:i,requestHasMultipartFiles:_t(t.record.request)}}:N()}function yo(e){let t=$(e,["request","requestDigest"]);if(!t.ok)return p(t.reason);let n=M(t.record.request);if(n!==void 0)return p(n);let o=t.record.requestDigest;return C(o)?{ok:!0,value:{requestDigest:o}}:N()}function ko(e){let t=$(e,["request","requestDigest"]);if(!t.ok)return p(t.reason);let n=M(t.record.request);if(n!==void 0)return p(n);let o=t.record.requestDigest;return C(o)?{ok:!0,value:{requestDigest:o}}:N()}function xo(e){let t=$(e,["tickId","request","requestDigest"]);if(!t.ok)return p(t.reason);let n=t.record.tickId;if(typeof n!="string"||n.length===0)return p("tickId is required");let o=M(t.record.request);if(o!==void 0)return p(o);let i=t.record.requestDigest;return C(i)?{ok:!0,value:{tickId:n,requestDigest:i}}:N()}function Eo(e){let t=$(e,["phase","lifecycle","deliveryId","request","requestDigest"]);if(!t.ok)return p(t.reason);let n=t.record.phase;if(n!=="lifecycle"&&n!=="handler")return p('phase must be "lifecycle" or "handler"');let o=t.record.lifecycle,i;if(o!==void 0){if(o!=="enable"&&o!=="disable"&&o!=="renew")return p('lifecycle must be "enable", "disable", or "renew"');i=o}if(n==="lifecycle"&&i===void 0)return p("lifecycle is required for the lifecycle phase");let c=t.record.deliveryId,a;if(c!==void 0){if(typeof c!="string"||c.length===0)return p("deliveryId must be a non-empty string");a=c}if(n==="handler"&&a===void 0)return p("deliveryId is required for the handler phase");let d=M(t.record.request);if(d!==void 0)return p(d);let f=t.record.requestDigest;return C(f)?{ok:!0,value:{phase:n,...i!==void 0?{lifecycle:i}:{},...a!==void 0?{deliveryId:a}:{},requestDigest:f}}:N()}function he(e){return xt.includes(e)?e:void 0}var ht=["scopeKind","scopeId","requestDigest"];function _o(e){if(!s(e))return p("consume body must be a JSON object");for(let i of Object.keys(e))if(!ht.includes(i))return p(`consume does not accept the "${i}" field`);let t=he(e.scopeKind);if(t===void 0)return p("scopeKind is invalid");let n=e.scopeId;if(typeof n!="string"||n.length===0)return p("scopeId is required");let o=e.requestDigest;return C(o)?{ok:!0,value:{scopeKind:t,scopeId:n,requestDigest:o}}:N()}var wt=["scopeKind","scopeId","providerHost","status","durationMs","requestBytes","responseBytes","errorCode"];function X(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 ho(e){if(!s(e))return p("audit body must be a JSON object");for(let l of Object.keys(e))if(!wt.includes(l))return p(`audit does not accept the "${l}" field`);let t=he(e.scopeKind);if(t===void 0)return p("scopeKind is invalid");let n=e.scopeId;if(typeof n!="string"||n.length===0)return p("scopeId is required");let o=e.providerHost;if(typeof o!="string"||o.length===0)return p("providerHost is required");let i=X(e.durationMs,"durationMs");if(!i.ok)return p(i.reason);let c;if(e.status!==void 0){let l=X(e.status,"status");if(!l.ok)return p(l.reason);c=l.value}let a;if(e.requestBytes!==void 0){let l=X(e.requestBytes,"requestBytes");if(!l.ok)return p(l.reason);a=l.value}let d;if(e.responseBytes!==void 0){let l=X(e.responseBytes,"responseBytes");if(!l.ok)return p(l.reason);d=l.value}let f;if(e.errorCode!==void 0){let l=e.errorCode;if(typeof l!="string"||l.length===0)return p("errorCode must be a non-empty string");f=l}return{ok:!0,value:{scopeKind:t,scopeId:n,providerHost:o,...c!==void 0?{status:c}:{},durationMs:i.value,...a!==void 0?{requestBytes:a}:{},...d!==void 0?{responseBytes:d}:{},...f!==void 0?{errorCode:f}:{}}}}function wo(e){return!s(e)||!s(e.grant)?r("egress grant envelope must carry a grant object"):u(e.grant)}function To(e){return!s(e)||e.consumed!==!0?r("egress grant consume data must carry consumed:true"):u({consumed:!0})}var Oo="/:flowRunId/runtime-credential",Do="/:invocationId/runtime-credential",vo="/:discoveryInvocationId/runtime-credential",Uo="/:pollingInstanceId/runtime-credential",Bo="/:triggerInstanceId/runtime-credential",Fo=e=>`${R}/${encodeURIComponent(e)}/runtime-credential`,Ho=e=>`${ce}/${encodeURIComponent(e)}/runtime-credential`,Lo=e=>`${de}/${encodeURIComponent(e)}/runtime-credential`,$o=e=>`${L}/${encodeURIComponent(e)}/runtime-credential`,Mo=e=>`${F}/${encodeURIComponent(e)}/runtime-credential`,Wo=["flow_action","tool_invoke","discovery","polling_trigger","webhook_trigger"];function W(e,t){if(!s(e))return{ok:!1,reason:"runtime credential request body must be a JSON object"};for(let n of Object.keys(e))if(!t.includes(n))return{ok:!1,reason:`runtime credential request does not accept the "${n}" field`};return{ok:!0,record:e}}function Go(e){let t=W(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 Ko(e){let t=W(e??{},[]);return t.ok?u(null):r(t.reason)}function qo(e){let t=W(e??{},[]);return t.ok?u(null):r(t.reason)}function Vo(e){let t=W(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 jo(e){let t=W(e,["executionKind","deliveryId","lifecycleOperation"]);if(!t.ok)return r(t.reason);let n=t.record.executionKind;if(n!=="event_handler"&&n!=="lifecycle")return r('executionKind must be "event_handler" or "lifecycle"');let o,i=t.record.deliveryId;if(i!==void 0){if(typeof i!="string"||i.length===0)return r("deliveryId must be a non-empty string");o=i}let c,a=t.record.lifecycleOperation;if(a!==void 0){if(a!=="enable"&&a!=="disable"&&a!=="renew")return r('lifecycleOperation must be "enable", "disable", or "renew"');c=a}return n==="lifecycle"&&c===void 0?r("lifecycleOperation is required for the lifecycle execution kind"):u({executionKind:n,...o!==void 0?{deliveryId:o}:{},...c!==void 0?{lifecycleOperation:c}:{}})}function Jo(e){return!s(e)||typeof e.sessionId!="string"||typeof e.connectionId!="string"||typeof e.authProfileRef!="string"||typeof e.authType!="string"||!s(e.credential)?r("runtime credential session must carry sessionId, connectionId, auth profile facts and a credential object"):u(e.credential)}function Y(e){return!s(e)||typeof e.file_id!="string"||typeof e.name!="string"||typeof e.size_bytes!="number"||typeof e.created_at!="string"||typeof e.expires_at!="string"||e.mime_type!==void 0&&typeof e.mime_type!="string"||e.sha256!==void 0&&typeof e.sha256!="string"||e.source!==void 0&&typeof e.source!="string"?r("file ref data does not match the AIS file-ref shape"):u(e)}function pe(e){return!s(e)||e.method!=="GET"&&e.method!=="PUT"||typeof e.url!="string"||typeof e.expires_at!="string"||!St(e.headers)?r("presigned file URL data is invalid"):u(e)}function Tt(e){if(!s(e))return r("file upload session data is invalid");let t=Y(e.file);if(!t.ok)return r(t.reason);let n=pe(e.upload);return n.ok?u({file:t.value,upload:n.value}):r(n.reason)}function bt(e){if(!s(e))return r("file metadata data is invalid");let t=Y(e.file);return t.ok?u({file:t.value}):r(t.reason)}function St(e){return s(e)?Object.values(e).every(t=>typeof t=="string"):!1}var O="/internal/files",ei="/upload-session",ti="/:fileId/complete",ni="/:fileId/access",ri="/:fileId/stat",oi="/:fileId/content",ii=()=>O,si=()=>`${O}/upload-session`,ai=e=>`${O}/${encodeURIComponent(e)}/complete`,ui=(e,t)=>`${O}/${encodeURIComponent(e)}/access?intent=${encodeURIComponent(t)}`,we=e=>`?scope_kind=${encodeURIComponent(e.scopeKind)}&scope_id=${encodeURIComponent(e.scopeId)}`,ci=(e,t)=>`${O}/${encodeURIComponent(e)}/stat${we(t)}`,di=(e,t)=>`${O}/${encodeURIComponent(e)}/content${we(t)}`;function pi(e){if(!s(e))return r("internal file access data is invalid");if(e.intent==="runtime_read"||e.intent==="provider_multipart"){let t=Y(e.file);if(!t.ok)return r(t.reason);let n=pe(e.access);return n.ok?u({file:t.value,access:n.value,intent:e.intent}):r(n.reason)}return r("internal file access intent is invalid")}import{isHumanInputSpec as Pt}from"@ablehi/flow-contract";var Ii="/:flowRunId/human-inputs",yi="/:flowRunId/human-inputs/:requestId",ki="/:flowRunId/human-inputs/:requestId/expire",xi="/:flowRunId/human-inputs/:requestId/acknowledge",At=e=>`${R}/${encodeURIComponent(e)}/human-inputs`,Pe=(e,t)=>`${At(e)}/${encodeURIComponent(t)}`,Ei=(e,t)=>`${Pe(e,t)}/expire`,_i=(e,t)=>`${Pe(e,t)}/acknowledge`,Ct="human_input_resolved";function hi(e){return`${Ct}_${e}`}function wi(e){return!s(e)||Object.keys(e).length!==4||!Object.hasOwn(e,"requestId")||!Object.hasOwn(e,"flowRunId")||!Object.hasOwn(e,"nodeId")||!Object.hasOwn(e,"status")||typeof e.requestId!="string"||e.requestId.length===0||typeof e.flowRunId!="string"||e.flowRunId.length===0||typeof e.nodeId!="string"||e.nodeId.length===0||e.status!=="submitted"&&e.status!=="expired"?r("Human Input resolved event shape is invalid"):u({requestId:e.requestId,flowRunId:e.flowRunId,nodeId:e.nodeId,status:e.status})}var Te=160,be=500;function Nt(e){return s(e)?e.kind==="choice"?!z(e,["kind","choiceId","comment"])||typeof e.choiceId!="string"||e.choiceId.length===0||e.comment!==void 0&&typeof e.comment!="string"?r("Human Input choice response is invalid"):u({kind:"choice",choiceId:e.choiceId,...e.comment!==void 0?{comment:e.comment}:{}}):e.kind==="text"&&z(e,["kind","text"])&&typeof e.text=="string"?u({kind:"text",text:e.text}):e.kind==="form"&&z(e,["kind","values"])&&s(e.values)?u({kind:"form",values:e.values}):r("Human Input response is invalid"):r("Human Input response must be an object")}function Ti(e,t){let n=Nt(e);if(!n.ok||n.value.kind!==t.kind)return r("Human Input response does not match its input spec");switch(t.kind){case"choice":{let o=n.value;return o.kind!=="choice"?r("Human Input choice response does not match its spec"):!t.choices.some(i=>i.id===o.choiceId)||o.comment!==void 0&&t.allowComment!==!0?r("Human Input choice response does not match its spec"):n}case"text":return n.value.kind!=="text"||t.required===!0&&n.value.text.trim().length===0?r("Human Input text response does not match its spec"):n;case"form":{if(n.value.kind!=="form")return r("Human Input form response does not match its spec");let o=new Map(t.fields.map(i=>[i.id,i]));if(Object.keys(n.value.values).some(i=>!o.has(i)))return r("Human Input form response contains an unknown field");for(let i of t.fields){let c=n.value.values[i.id];if(!Object.hasOwn(n.value.values,i.id)){if(i.required===!0)return r(`Human Input form response is missing required field '${i.id}'`);continue}if(c==null||!Ot(i,c))return r(`Human Input form response field '${i.id}' does not match its spec`)}return n}}}function Ot(e,t){switch(e.type){case"text":case"textarea":return typeof t=="string";case"number":return typeof t=="number"&&Number.isFinite(t);case"boolean":return typeof t=="boolean";case"select":return typeof t=="string"&&(e.options??[]).some(n=>n.id===t)}}function m(e){return{ok:!1,reason:e}}function S(e,t){return s(e)?{ok:!0,value:e}:m(`${t} must be an object`)}function z(e,t){return Object.keys(e).every(n=>t.includes(n))}function D(e,t){return typeof e!="string"||e.length===0?m(`${t} must be a non-empty string`):{ok:!0,value:e}}var Dt=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?(?:Z|[+-]\d{2}:\d{2})$/;function vt(e,t){return typeof e!="string"||!Dt.test(e)||Number.isNaN(Date.parse(e))?m(`${t} must be an ISO-8601 timestamp`):{ok:!0,value:e}}function Ae(e){let t=S(e,"renderedPrompt");if(!t.ok)return t;if(!z(t.value,["title","body","format"]))return m("renderedPrompt contains an unknown field");let n=D(t.value.title,"renderedPrompt.title");if(!n.ok)return n;if(!/[^\p{White_Space}]/u.test(n.value))return m("renderedPrompt.title must contain non-whitespace text");if(!Se(n.value,Te))return m(`renderedPrompt.title must contain at most ${Te} code points`);let o={title:n.value};if(t.value.body!==void 0){if(typeof t.value.body!="string")return m("renderedPrompt.body must be a string");if(!Se(t.value.body,be))return m(`renderedPrompt.body must contain at most ${be} code points`);o.body=t.value.body}if(t.value.format!==void 0){if(t.value.format!=="plain"&&t.value.format!=="markdown")return m("renderedPrompt.format is invalid");o.format=t.value.format}return{ok:!0,value:o}}function Se(e,t){let n=0,o=e[Symbol.iterator]();for(;!o.next().done;)if(n+=1,n>t)return!1;return!0}function bi(e){let t=Ae(e);return t.ok?u(t.value):r(t.reason)}function Ut(e){try{return Pt(e)?u(e):r("Human Input spec shape is invalid")}catch{return r("Human Input spec shape is invalid")}}function Bt(e){let t=Ut(e);return t.ok?t:m(t.reason)}function Ft(e){if(e==null)return{ok:!0,value:void 0};let t=S(e,"partiallyRenderedDelivery");if(!t.ok)return t;let n=t.value.actions;if(n===void 0)return{ok:!0,value:{}};if(!Array.isArray(n))return m("partiallyRenderedDelivery.actions must be an array");let o=[];for(let i of n){let c=S(i,"delivery action");if(!c.ok)return c;let a=D(c.value.id,"delivery action id");if(!a.ok)return a;let d=Ce(c.value.inputs,`delivery action '${a.value}' inputs`);if(!d.ok)return d;o.push({id:a.value,inputs:d.value})}return{ok:!0,value:{actions:o}}}function Ce(e,t){let n=S(e,t);if(!n.ok)return n;let o={};for(let[i,c]of Object.entries(n.value)){let a=Ne(c,`${t}.${i}`);if(!a.ok)return a;o[i]=a.value}return{ok:!0,value:o}}function Ne(e,t){let n=S(e,t);if(!n.ok)return n;switch(n.value.kind){case"literal":return{ok:!0,value:{kind:"literal",value:n.value.value}};case"human_input_ref":{let i=D(n.value.path,`${t}.path`);return i.ok?{ok:!0,value:{kind:"human_input_ref",path:i.value}}:i}case"array":{if(!Array.isArray(n.value.items))return m(`${t}.items must be an array`);let i=[];for(let[c,a]of n.value.items.entries()){let d=Ne(a,`${t}[${c}]`);if(!d.ok)return d;i.push(d.value)}return{ok:!0,value:{kind:"array",items:i}}}case"object":{let i=Ce(n.value.entries,`${t}.entries`);return i.ok?{ok:!0,value:{kind:"object",entries:i.value}}:i}case"template":{if(!Array.isArray(n.value.parts))return m(`${t}.parts must be an array`);let i=[];for(let[c,a]of n.value.parts.entries()){let d=Ht(a,`${t}.parts[${c}]`);if(!d.ok)return d;i.push(d.value)}return{ok:!0,value:{kind:"template",parts:i}}}default:return m(`${t}.kind is invalid`)}}function Ht(e,t){let n=S(e,t);if(!n.ok)return n;let o=n.value.kind;if(o==="literal")return typeof n.value.value!="string"?m(`${t}.value must be a string`):{ok:!0,value:{kind:"literal",value:n.value.value}};if(o==="human_input_ref"){let i=D(n.value.path,`${t}.path`);return i.ok?{ok:!0,value:{kind:"human_input_ref",path:i.value}}:i}return m(`${t}.kind is invalid`)}function Si(e){let t=S(e,"request body");if(!t.ok)return r(t.reason);let n=Object.keys(t.value).find(T=>!["executionLease","nodeId","renderedPrompt","input","partiallyRenderedDelivery","timeout","expiresAt"].includes(T));if(n!==void 0)return r(`human input body does not accept the "${n}" field`);let o=k(t.value.executionLease);if(!o.ok)return r(o.reason);let i=D(t.value.nodeId,"nodeId");if(!i.ok)return r(i.reason);let c=Ae(t.value.renderedPrompt);if(!c.ok)return r(c.reason);let a=Bt(t.value.input);if(!a.ok)return r(a.reason);let d=D(t.value.timeout,"timeout");if(!d.ok)return r(d.reason);let f=vt(t.value.expiresAt,"expiresAt");if(!f.ok)return r(f.reason);let l=Ft(t.value.partiallyRenderedDelivery);return l.ok?u({executionLease:o.value,nodeId:i.value,renderedPrompt:c.value,input:a.value,timeout:d.value,expiresAt:f.value,...l.value!==void 0?{partiallyRenderedDelivery:l.value}:{}}):r(l.reason)}function Lt(e){return!s(e)||typeof e.id!="string"||e.id.length===0||typeof e.nodeId!="string"||typeof e.status!="string"||!(e.output===null||s(e.output))?r("human input request view must carry id, nodeId, status and output"):u(e)}function Pi(e){if(!s(e)||typeof e.created!="boolean")return r("human input create data must carry created:boolean");let t=Lt(e.request);return t.ok?u({created:e.created,request:t.value}):t}function Ai(e){return!s(e)||e.acknowledged!==!0?r("human input acknowledge data must carry acknowledged:true"):u({acknowledged:!0})}var Ni="ablehi-wfp-user-runtime-manifest/v1",Oi="unknown";function Di(e){return e.endsWith(".js")?`${e.slice(0,-3)}.manifest.json`:`${e}.manifest.json`}var Ui="/internal/deployment-handshake",$t=["start","terminate","send-event","start-webhook-watcher","run-polling-tick","invoke-tool","invoke-discovery","invoke-trigger-handler","invoke-webhook-protocol-adapter","deployment-handshake"],Bi=$t,Fi="HANDSHAKE_REQUEST_INVALID",Hi="HANDSHAKE_SECRET_UNCONFIGURED",Li="HANDSHAKE_SECRET_MISMATCH",$i="HANDSHAKE_CONTRACT_VERSION_MISMATCH",Mi="HANDSHAKE_DISPATCH_NAMESPACE_MISMATCH",Wi="HANDSHAKE_CAPABILITY_MISSING";function Gi(e){return[e.nonce,e.timestamp,e.contractVersion,e.dispatchNamespace].map(n=>`${n.length}:${n}`).join(".")}function Ki(e){return["response",e.nonce,e.contractVersion,e.dispatchNamespace,...e.capabilities].map(n=>`${n.length}:${n}`).join(".")}function ji(e){if(!s(e)||e.ok!==!1||!s(e.error))return r("Server execution error envelope is invalid");let t=Object.keys(e).find(i=>i!=="ok"&&i!=="error"&&i!=="guidance"),n=e.error,o=Object.keys(n).find(i=>i!=="code"&&i!=="message"&&i!=="retryable"&&i!=="issues"&&i!=="details");return t!==void 0||o!==void 0||typeof n.code!="string"||n.code.length===0||typeof n.message!="string"||typeof n.retryable!="boolean"||n.issues!==void 0&&!Array.isArray(n.issues)||n.details!==void 0&&!s(n.details)?r("Server execution error must carry code, message, and boolean retryable"):u(e)}var Oe="workflow.action-transform.v1",zi="/:flowRunId/nodes/:nodeId/action-transform",Mt=1048576;function Qi(e,t){return`/internal/flow-runs/${encodeURIComponent(e)}/nodes/${encodeURIComponent(t)}/action-transform`}function ve(e){return le(e,new WeakSet)}function Zi(e){return ge(new TextEncoder().encode(ve(e)))}function Wt(e){return ge(new TextEncoder().encode([e.flowRunId,e.generationId,e.nodeId,e.operation,String(e.attempt),e.valueDigest].join("\0")))}function es(e){if(!s(e)||!Q(e,["schemaVersion","executionLease","serverTransformRef","operation","attempt","idempotencyIdentity","valueDigest","value"]))return r("action transform request shape is invalid");if(e.schemaVersion!==Oe)return r("action transform schemaVersion is unsupported");let t=k(e.executionLease);if(!t.ok)return r(t.reason);if(!v(e.serverTransformRef))return r("serverTransformRef must be a non-empty string");let n=e.operation;if(!Be(n))return r("action transform operation is invalid");let o=e.attempt;if(!en(n,o))return r(n==="input"?"input transform attempt must be 0":"output and error transform attempt must be a positive integer");if(!fe(e.valueDigest)||!fe(e.idempotencyIdentity))return r("action transform digests must be lowercase SHA-256 hex");let i=Ue(n,e.value);if(!i.ok)return i;if(i.digest!==e.valueDigest)return r("action transform valueDigest does not match value");let c=t.value.anchor.kind==="node"?t.value.anchor.nodeId:void 0;return c===void 0?r("action transform lease anchor must be a node"):Wt({flowRunId:t.value.flowRunId,generationId:t.value.generationId,nodeId:c,operation:n,attempt:o,valueDigest:i.digest})!==e.idempotencyIdentity?r("action transform idempotencyIdentity is invalid"):u({schemaVersion:Oe,executionLease:t.value,serverTransformRef:e.serverTransformRef,operation:n,attempt:o,idempotencyIdentity:e.idempotencyIdentity,valueDigest:i.digest,value:e.value})}function ts(e){if(!s(e)||!Q(e,["operation","valueDigest","value"]))return r("action transform data shape is invalid");let t=e.operation;if(!Be(t)||!fe(e.valueDigest))return r("action transform data operation or digest is invalid");let n=Ue(t,e.value);return n.ok?n.digest!==e.valueDigest?r("action transform response valueDigest does not match value"):u({operation:t,valueDigest:n.digest,value:e.value}):n}function Ue(e,t){let n;try{n=ve(t)}catch(o){return{ok:!1,reason:`action transform value must be JSON: ${o instanceof Error?o.message:String(o)}`}}return new TextEncoder().encode(n).byteLength>Mt?{ok:!1,reason:"action transform value exceeds 1048576 bytes"}:e==="error"&&!Gt(t)?{ok:!1,reason:"error transform value is invalid"}:{ok:!0,digest:ge(new TextEncoder().encode(n))}}function Gt(e){return!(!s(e)||!me(e,["code","error","data"])||!v(e.code)||e.error!==void 0&&(!Kt(e.error)||e.error.code!==e.code))}function le(e,t){if(e===null)return"null";if(typeof e=="boolean")return e?"true":"false";if(typeof e=="string"){De(e);let n=JSON.stringify(e);if(n===void 0)throw new TypeError("string is not JSON serializable");return n}if(typeof e=="number"){if(!Number.isFinite(e))throw new TypeError("numbers must be finite");let n=JSON.stringify(e);if(n===void 0)throw new TypeError("number is not JSON serializable");return n}if(typeof e!="object")throw new TypeError("value contains a non-JSON member");if(t.has(e))throw new TypeError("value contains a cycle");t.add(e);try{if(Array.isArray(e)){let c=[];for(let a=0;a<e.length;a+=1){if(!(a in e))throw new TypeError("value contains a sparse array");c.push(le(e[a],t))}return`[${c.join(",")}]`}let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)throw new TypeError("value contains a non-plain object");let o=e;return`{${Object.keys(o).sort().map(c=>(De(c),`${JSON.stringify(c)}:${le(o[c],t)}`)).join(",")}}`}finally{t.delete(e)}}function De(e){for(let t=0;t<e.length;t+=1){let n=e.charCodeAt(t);if(n>=55296&&n<=56319){let o=e.charCodeAt(t+1);if(!(o>=56320&&o<=57343))throw new TypeError("strings must not contain lone surrogate code points");t+=1;continue}if(n>=56320&&n<=57343)throw new TypeError("strings must not contain lone surrogate code points")}}function Kt(e){return!s(e)||!tn(e,["source","scope","subject","attempt","code","category","retryable","occurredAt","evidence"],["source","scope","subject","code","occurredAt"])||!qt(e.source)||e.scope!=="flow_step"&&e.scope!=="integration_invocation"||!jt(e.subject)||!v(e.code)||!v(e.occurredAt)||e.attempt!==void 0&&(!s(e.attempt)||!Q(e.attempt,["number"])||!Xt(e.attempt.number))||e.category!==void 0&&!Jt(e.category)||e.retryable!==void 0&&typeof e.retryable!="boolean"?!1:e.evidence===void 0||s(e.evidence)}function qt(e){return s(e)&&Q(e,["project","component"])&&(e.project==="ablehi-server"||e.project==="ablehi-cf-execution-runtime"||e.project==="agentIntegrations")&&v(e.component)}var Vt=["workspaceId","flowId","flowVersionId","flowRunId","stepId","nodeId","integrationId","actionId","toolRef","connectionId","requestId","traceRef"];function jt(e){return s(e)&&me(e,Vt)&&Object.values(e).every(v)}function Jt(e){return["validation","auth","permission","not_found","rate_limit","provider","network","runtime","internal","canceled"].includes(e)}function Xt(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0}function ge(e){let t=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),n=e.byteLength*8,o=Math.ceil((e.byteLength+9)/64)*64,i=new Uint8Array(o);i.set(e),i[e.byteLength]=128;let c=new DataView(i.buffer);c.setUint32(o-8,Math.floor(n/4294967296),!1),c.setUint32(o-4,n>>>0,!1);let a=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),d=new Uint32Array(64);for(let f=0;f<o;f+=64){for(let g=0;g<16;g+=1)d[g]=c.getUint32(f+g*4,!1);for(let g=16;g<64;g+=1){let q=d[g-15],te=d[g-2];d[g]=zt(te)+d[g-7]+Yt(q)+d[g-16]>>>0}let l=a[0],T=a[1],U=a[2],Z=a[3],P=a[4],G=a[5],K=a[6],ee=a[7];for(let g=0;g<64;g+=1){let q=ee+Zt(P)+(P&G^~P&K)+t[g]+d[g]>>>0,te=Qt(l)+(l&T^l&U^T&U)>>>0;ee=K,K=G,G=P,P=Z+q>>>0,Z=U,U=T,T=l,l=q+te>>>0}a[0]=a[0]+l>>>0,a[1]=a[1]+T>>>0,a[2]=a[2]+U>>>0,a[3]=a[3]+Z>>>0,a[4]=a[4]+P>>>0,a[5]=a[5]+G>>>0,a[6]=a[6]+K>>>0,a[7]=a[7]+ee>>>0}return[...a].map(f=>f.toString(16).padStart(8,"0")).join("")}function E(e,t){return e>>>t|e<<32-t}function Yt(e){return E(e,7)^E(e,18)^e>>>3}function zt(e){return E(e,17)^E(e,19)^e>>>10}function Qt(e){return E(e,2)^E(e,13)^E(e,22)}function Zt(e){return E(e,6)^E(e,11)^E(e,25)}function Be(e){return e==="input"||e==="output"||e==="error"}function en(e,t){return typeof t=="number"&&Number.isSafeInteger(t)&&(e==="input"?t===0:t>=1)}function fe(e){return typeof e=="string"&&/^[0-9a-f]{64}$/.test(e)}function v(e){return typeof e=="string"&&e.length>0}function Q(e,t){let n=Object.keys(e).sort(),o=[...t].sort();return n.length===o.length&&n.every((i,c)=>i===o[c])}function me(e,t){return Object.keys(e).every(n=>t.includes(n))}function tn(e,t,n){return me(e,t)&&n.every(o=>o in e)}export{zi as ACTION_TRANSFORM_ROUTE_SUBPATH,Oe as ACTION_TRANSFORM_SCHEMA_VERSION,Gn as COMPLETE_EVENT_WAIT_ROUTE_SUBPATH,sn as CONTEXT_STATE_CLEANUP_ROUTE_PATH,$t as DEPLOYMENT_HANDSHAKE_DISPATCHER_CAPABILITIES,Bi as DEPLOYMENT_HANDSHAKE_REQUIRED_CAPABILITIES,Ui as DEPLOYMENT_HANDSHAKE_ROUTE,oo as DISCOVERY_INVOCATION_EGRESS_GRANT_ROUTE_SUBPATH,vo as DISCOVERY_INVOCATION_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,uo as EGRESS_GRANT_AUDIT_ROUTE_SUBPATH,ao as EGRESS_GRANT_CONSUME_ROUTE_SUBPATH,xt as EGRESS_GRANT_SCOPE_KINDS,fn as EXECUTION_CONTEXT_ROUTE_SUBPATH,Tn as EXECUTION_LEASE_INVALID,kn as EXECUTION_LEASE_ROUTE_SUBPATH,bn as EXECUTION_LEASE_SUPERSEDED,ni as FILE_ACCESS_ROUTE_SUBPATH,ti as FILE_COMPLETE_ROUTE_SUBPATH,oi as FILE_CONTENT_ROUTE_SUBPATH,ri as FILE_STAT_ROUTE_SUBPATH,ei as FILE_UPLOAD_SESSION_ROUTE_SUBPATH,no as FLOW_RUN_EGRESS_GRANT_ROUTE_SUBPATH,Mn as FLOW_RUN_EXECUTION_EVENTS_ROUTE_SUBPATH,$n as FLOW_RUN_RESULT_ROUTE_SUBPATH,Oo as FLOW_RUN_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,ar as HANDLER_BUNDLES_ROUTE_SUBPATH,Wi as HANDSHAKE_CAPABILITY_MISSING,$i as HANDSHAKE_CONTRACT_VERSION_MISMATCH,Mi as HANDSHAKE_DISPATCH_NAMESPACE_MISMATCH,Fi as HANDSHAKE_REQUEST_INVALID,Li as HANDSHAKE_SECRET_MISMATCH,Hi as HANDSHAKE_SECRET_UNCONFIGURED,Ii as HUMAN_INPUTS_ROUTE_SUBPATH,xi as HUMAN_INPUT_ACKNOWLEDGE_ROUTE_SUBPATH,Pn as HUMAN_INPUT_CANCELLED_BY_RESET,ki as HUMAN_INPUT_EXPIRE_ROUTE_SUBPATH,be as HUMAN_INPUT_PROMPT_BODY_MAX_CODE_POINTS,Te as HUMAN_INPUT_PROMPT_TITLE_MAX_CODE_POINTS,yi as HUMAN_INPUT_REQUEST_ROUTE_SUBPATH,Ct as HUMAN_INPUT_RESOLVED_EVENT_PREFIX,de as INTERNAL_DISCOVERY_INVOCATIONS_ROUTE_PREFIX,_e as INTERNAL_EGRESS_GRANTS_ROUTE_PREFIX,O as INTERNAL_FILES_ROUTE_PREFIX,R as INTERNAL_FLOW_RUNS_ROUTE_PREFIX,rt as INTERNAL_FLOW_VERSIONS_ROUTE_PREFIX,ie as INTERNAL_INSTALLATIONS_ROUTE_PREFIX,L as INTERNAL_POLLING_TRIGGER_INSTANCES_ROUTE_PREFIX,ce as INTERNAL_TOOL_INVOCATIONS_ROUTE_PREFIX,F as INTERNAL_WEBHOOK_TRIGGER_INSTANCES_ROUTE_PREFIX,Wr as POLLING_TRIGGER_CONTEXT_ROUTE_SUBPATH,io as POLLING_TRIGGER_EGRESS_GRANT_ROUTE_SUBPATH,Gr as POLLING_TRIGGER_HANDLER_BUNDLES_ROUTE_SUBPATH,Uo as POLLING_TRIGGER_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,Kr as POLLING_TRIGGER_TICK_EVENTS_ROUTE_SUBPATH,Wn as REGISTER_EVENT_WAIT_ROUTE_SUBPATH,Wo as RUNTIME_CREDENTIAL_SESSION_SCOPE_KINDS,Ze as RUNTIME_REPORTED_EXECUTION_EVENT_TYPES,wn as RUN_DISPATCH_UNAVAILABLE,Fe as SERVER_EXECUTION_CONTRACT_VERSION,Ln as STEP_RESULT_ROUTE_SUBPATH,ur as TOOL_HANDLER_BUNDLES_ROUTE_SUBPATH,ro as TOOL_INVOCATION_EGRESS_GRANT_ROUTE_SUBPATH,Do as TOOL_INVOCATION_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,Sn as WAIT_EXECUTION_SUPERSEDED,Ar as WEBHOOK_PROTOCOL_ADAPTER_BUNDLE_ROUTE_SUBPATH,Nr as WEBHOOK_PROTOCOL_ADAPTER_MODULE,kr as WEBHOOK_TRIGGER_CONTEXT_ROUTE_SUBPATH,Er as WEBHOOK_TRIGGER_DELIVERY_ROUTE_SUBPATH,so as WEBHOOK_TRIGGER_EGRESS_GRANT_ROUTE_SUBPATH,_r as WEBHOOK_TRIGGER_EVENTS_ROUTE_SUBPATH,xr as WEBHOOK_TRIGGER_HANDLER_BUNDLES_ROUTE_SUBPATH,hr as WEBHOOK_TRIGGER_REARM_ROUTE_SUBPATH,Bo as WEBHOOK_TRIGGER_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,Ni as WFP_USER_RUNTIME_MANIFEST_FORMAT_VERSION,Oi as WFP_USER_RUNTIME_UNKNOWN_SOURCE_REVISION,_n as WORKFLOW_RESTART_INSTANCE_UNAVAILABLE,hn as WORKFLOW_RESTART_REJECTED,En as WORKFLOW_RESTART_REQUEST_INVALID,xn as WORKFLOW_RESTART_ROUTE,An as acquireExecutionLeasePath,Wt as actionTransformIdempotencyIdentity,Qi as actionTransformPath,Zi as actionTransformValueDigest,Jn as completeEventWaitPath,Gi as deploymentHandshakeProbePayload,Ki as deploymentHandshakeResponseProofPayload,lo as discoveryInvocationEgressGrantPath,Lo as discoveryInvocationRuntimeCredentialPath,Ro as egressGrantAuditPath,mo as egressGrantConsumePath,gn as executionContextPath,co as flowRunEgressGrantPath,Vn as flowRunExecutionEventsPath,qn as flowRunResultPath,Fo as flowRunRuntimeCredentialPath,Or as flowScriptProtocolAdapterModuleName,cr as handlerBundlesPath,_i as humanInputAcknowledgePath,Ei as humanInputExpirePath,Pe as humanInputRequestPath,hi as humanInputResolvedEventType,At as humanInputsPath,ui as internalFileAccessPath,ai as internalFileCompletePath,di as internalFileContentPath,ci as internalFileStatPath,si as internalFileUploadSessionPath,ii as internalFilesPath,C as isValidRequestDigest,Nn as parseAcquireExecutionLeaseData,Cn as parseAcquireExecutionLeaseRequest,ts as parseActionTransformData,es as parseActionTransformRequest,nr as parseCompleteFlowRunWaitBody,or as parseCompleteFlowRunWaitData,an as parseContextStateCleanupRequestBody,un as parseContextStateCleanupResponseData,b as parseContextStateScope,Si as parseCreateHumanInputBody,ko as parseDiscoveryGrantBody,qo as parseDiscoveryRuntimeCredentialBody,ho as parseEgressGrantAuditBody,_o as parseEgressGrantConsumeBody,To as parseEgressGrantConsumeData,wo as parseEgressGrantData,Ie as parseExecutionAnchor,mn as parseExecutionContextData,k as parseExecutionLease,bt as parseFileMetadataData,Y as parseFileRefData,ne as parseFileRuntimeLimits,Tt as parseFileUploadSessionData,Io as parseFlowActionGrantBody,er as parseFlowRunExecutionEventBody,Zn as parseFlowRunExecutionEventData,zn as parseFlowRunResultBody,Qn as parseFlowRunResultData,Go as parseFlowRuntimeCredentialBody,ir as parseFlowWaitResolvedEvent,it as parseHandlerBundle,pr as parseHandlerBundlesData,Ai as parseHumanInputAcknowledgeData,Pi as parseHumanInputCreateData,Lt as parseHumanInputRequestViewData,wi as parseHumanInputResolvedEvent,Nt as parseHumanInputResponse,Ti as parseHumanInputResponseForSpec,Ut as parseHumanInputSpec,pi as parseInternalFileAccessData,Xr as parsePollingPublishBody,Vo as parsePollingRuntimeCredentialBody,lt as parsePollingTriggerContext,Jr as parsePollingTriggerDispatchData,xo as parsePollingTriggerGrantBody,Yr as parsePublishPollingTickEventsData,tr as parseRegisterFlowRunWaitBody,rr as parseRegisterFlowRunWaitData,bi as parseRenderedHumanInputPrompt,Jo as parseRuntimeCredentialSessionCredential,J as parseRuntimeNetwork,ji as parseServerExecutionErrorEnvelope,yo as parseSingleToolGrantBody,Ko as parseSingleToolRuntimeCredentialBody,Xn as parseStepRecordBody,Yn as parseStepRecordData,lr as parseToolHandlerBundlesData,se as parseTriggerFileRuntimeDispatch,Ur as parseTriggerHandlerBundlesData,ct as parseWebhookDelivery,vr as parseWebhookDeliveryDispatchData,Br as parseWebhookPublishEventsBody,Fr as parseWebhookRearmBody,jo as parseWebhookRuntimeCredentialBody,Eo as parseWebhookTriggerGrantBody,Dr as parseWebhookWatcherContext,On as parseWorkflowDispatchRestartRequest,Dn as parseWorkflowDispatchRestartResponse,qr as pollingTriggerContextPath,fo as pollingTriggerEgressGrantPath,Vr as pollingTriggerHandlerBundlesPath,$o as pollingTriggerRuntimeCredentialPath,jr as pollingTriggerTickEventsPath,jn as registerEventWaitPath,_t as requestHasMultipartFileParts,Kn as stepResultPath,dr as toolHandlerBundlesPath,po as toolInvocationEgressGrantPath,Ho as toolInvocationRuntimeCredentialPath,Cr as webhookProtocolAdapterBundlePath,wr as webhookTriggerContextPath,br as webhookTriggerDeliveryPath,go as webhookTriggerEgressGrantPath,Sr as webhookTriggerEventsPath,Tr as webhookTriggerHandlerBundlesPath,Pr as webhookTriggerRearmPath,Mo as webhookTriggerRuntimeCredentialPath,Di as wfpUserRuntimeManifestPath};
|
|
1
|
+
var D="0.6.0";function s(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 ar="/cleanup-state-scopes";function U(e){if(!i(e)||typeof e.kind!="string")return r("context state scope surface shape is invalid");switch(e.kind){case"webhook-trigger":return pt(e);case"polling-trigger":return lt(e);case"flow-action":return ft(e);default:return r("context state scope kind is invalid")}}function ur(e){if(!i(e))return r("cleanup request body must be a JSON object");let t=re(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 a=U(o);if(!a.ok)return a;n.push(a.value)}return s({scopes:n})}function cr(e){return!i(e)||typeof e.deleted!="number"||!Number.isSafeInteger(e.deleted)||e.deleted<0?r("cleanup response data surface shape is invalid"):s({deleted:e.deleted})}function pt(e){let t=re(e,["kind","workspaceId","triggerInstanceId"]);return t!==void 0?r(`webhook trigger scope does not accept "${t}"`):e.kind!=="webhook-trigger"||!O(e.workspaceId)||!O(e.triggerInstanceId)?r("webhook trigger state scope is invalid"):s({kind:"webhook-trigger",workspaceId:e.workspaceId,triggerInstanceId:e.triggerInstanceId})}function lt(e){let t=re(e,["kind","workspaceId","pollingInstanceId"]);return t!==void 0?r(`polling trigger scope does not accept "${t}"`):e.kind!=="polling-trigger"||!O(e.workspaceId)||!O(e.pollingInstanceId)?r("polling trigger state scope is invalid"):s({kind:"polling-trigger",workspaceId:e.workspaceId,pollingInstanceId:e.pollingInstanceId})}function ft(e){let t=re(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"||!O(e.workspaceId)||!O(e.flowId)||!O(e.nodeId)||n!==null&&!O(n)?r("flow action state scope is invalid"):s({kind:"flow-action",workspaceId:e.workspaceId,flowId:e.flowId,nodeId:e.nodeId,connectionId:n})}function O(e){return typeof e=="string"&&e.length>0}function re(e,t){return Object.keys(e).find(n=>!t.includes(n))}import{FLOW_INTERPRETER_CONTRACT_VERSION as wt,FLOW_IR_SCHEMA_VERSION as Tt,parseFlowDefinition as bt}from"@ablehi/flow-contract";var fr="/:flowRunId/execution-leases",gr="/restart",mr="WORKFLOW_RESTART_REQUEST_INVALID",Rr="WORKFLOW_RESTART_INSTANCE_UNAVAILABLE",yr="WORKFLOW_RESTART_REJECTED",xr="RUN_DISPATCH_UNAVAILABLE",Ir="EXECUTION_LEASE_INVALID",kr="EXECUTION_LEASE_SUPERSEDED",Er="WAIT_EXECUTION_SUPERSEDED",hr="HUMAN_INPUT_CANCELLED_BY_RESET";function _r(e){return`${I}/${encodeURIComponent(e)}/execution-leases`}var gt=/^generation:[A-Za-z0-9][A-Za-z0-9._:-]{0,239}$/;function ve(e){return i(e)?e.kind==="terminal"&&S(e,["kind"])?s({kind:"terminal"}):e.kind==="node"&&S(e,["kind","nodeId"])&&w(e.nodeId)?s({kind:"node",nodeId:e.nodeId}):r("execution anchor shape is invalid"):r("execution anchor must be an object")}function y(e){if(!i(e)||!S(e,["flowRunId","generationId","generationNumber","anchor","leaseId"])||!w(e.flowRunId)||!w(e.generationId)||!mt(e.generationNumber)||!w(e.leaseId))return r("execution lease shape is invalid");let t=ve(e.anchor);return t.ok?s({flowRunId:e.flowRunId,generationId:e.generationId,generationNumber:e.generationNumber,anchor:t.value,leaseId:e.leaseId}):r(t.reason)}function wr(e){if(!i(e)||!S(e,["anchor"]))return r("lease request shape is invalid");let t=ve(e.anchor);return t.ok?s({anchor:t.value}):r(t.reason)}function Tr(e){if(!i(e)||!S(e,["lease"]))return r("lease response shape is invalid");let t=y(e.lease);return t.ok?s({lease:t.value}):r(t.reason)}function br(e){return!i(e)||!S(e,["instanceId","flowRunId","commandId","generationId","from"])||!w(e.instanceId)||!w(e.flowRunId)||!w(e.commandId)||!w(e.generationId)||!i(e.from)||!S(e.from,["name","count","type"])||typeof e.from.name!="string"||!gt.test(e.from.name)||e.from.name==="generation:terminal"||e.from.count!==1||e.from.type!=="do"?r("restart request shape is invalid"):s(e)}function Pr(e){return!i(e)||!S(e,["ok","data"])||e.ok!==!0||!i(e.data)||!S(e.data,["accepted","instanceId","commandId","generationId"])||e.data.accepted!==!0||!w(e.data.instanceId)||!w(e.data.commandId)||!w(e.data.generationId)?r("restart response shape is invalid"):s(e)}function S(e,t){let n=Object.keys(e).sort(),o=[...t].sort();return n.length===o.length&&n.every((a,u)=>a===o[u])}function w(e){return typeof e=="string"&&e.length>0}function mt(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0}var Le="execution.payload-ref.v1",Rt=4194304,Dr=716800,Or=786432,yt=8388608,Nr=262144,xt=4194304,Ur=8388608,vr=65536,Lr=900,Fr=600,Br=120,It="/internal/execution-payloads/reservations",Hr="/internal/execution-payloads/trigger-results/resolve",kt=["execution_context","trigger_context","trigger_delivery","run_input","step_input","node_output","transform_value","wait_event","human_input","trigger_events","step_output","flow_terminal_output"];function qr(e){return`${It}/${encodeURIComponent(e)}/commit`}function Mr(e){return`/internal/execution-payloads/${encodeURIComponent(e)}/access`}function Be(e){return e==="execution_context"||e==="trigger_context"?Rt:e==="run_input"?xt:yt}function ye(e){return me(e,new WeakSet)}function h(e){if(!i(e)||!g(e,["schemaVersion","payloadRef","kind","digest","byteSize","contentType"])||e.schemaVersion!==Le||!E(e.payloadRef)||!qe(e.kind)||!B(e.byteSize)||e.contentType!=="application/json")return r("execution payload ref shape is invalid");let t=xe(e.digest);return t.ok?e.byteSize>Be(e.kind)?r("execution payload ref exceeds its kind byte limit"):s({schemaVersion:Le,payloadRef:e.payloadRef,kind:e.kind,digest:t.value,byteSize:e.byteSize,contentType:"application/json"}):t}function Vr(e){if(!i(e)||!g(e,["authority","kind","digest","byteSize","contentType","owner"])||!qe(e.kind)||!B(e.byteSize)||e.byteSize>Be(e.kind)||e.contentType!=="application/json")return r("execution payload reservation request shape is invalid");let t=oe(e.authority);if(!t.ok)return t;let n=xe(e.digest);if(!n.ok)return n;let o=Et(e.owner);return o.ok?s({authority:t.value,kind:e.kind,digest:n.value,byteSize:e.byteSize,contentType:"application/json",owner:o.value}):o}function $r(e){if(!i(e)||!g(e,["authority","digest","byteSize"])||!B(e.byteSize))return r("execution payload commit request shape is invalid");let t=oe(e.authority);if(!t.ok)return t;let n=xe(e.digest);return n.ok?s({authority:t.value,digest:n.value,byteSize:e.byteSize}):n}function Wr(e){if(!i(e)||!g(e,["authority","intent"])||e.intent!=="runtime-read")return r("execution payload access request shape is invalid");let t=oe(e.authority);return t.ok?s({authority:t.value,intent:"runtime-read"}):t}function Kr(e){if(!i(e)||!g(e,["authority","owner"]))return r("trigger payload resolve request shape is invalid");let t=oe(e.authority);if(!t.ok||t.value.kind==="run")return r("trigger payload authority is invalid");let n=e.owner;return i(n)&&n.kind==="webhook"&&n.phase==="delivery_events"&&g(n,["kind","phase","deliveryId"])&&E(n.deliveryId)&&t.value.kind==="webhook_watcher"?s({authority:t.value,owner:{kind:"webhook",phase:"delivery_events",deliveryId:n.deliveryId}}):i(n)&&n.kind==="polling"&&n.phase==="tick_events"&&g(n,["kind","phase"])&&t.value.kind==="polling_tick"?s({authority:t.value,owner:{kind:"polling",phase:"tick_events"}}):r("trigger payload resolve owner is invalid")}function Gr(e){if(!i(e))return r("execution payload reservation data must be an object");if(e.disposition==="reuse"&&g(e,["disposition","payload"])){let t=h(e.payload);return t.ok?s({disposition:"reuse",payload:t.value}):t}if(e.disposition==="upload"&&g(e,["disposition","reservationId","upload"])&&E(e.reservationId)){let t=He(e.upload,"PUT");return t.ok?s({disposition:"upload",reservationId:e.reservationId,upload:t.value}):t}return r("execution payload reservation disposition is invalid")}function jr(e){if(!i(e)||!g(e,["payload","status"])||e.status!=="committed")return r("execution payload commit data shape is invalid");let t=h(e.payload);return t.ok?s({payload:t.value,status:"committed"}):t}function Xr(e){if(!i(e)||!g(e,["payload","access"]))return r("execution payload access data shape is invalid");let t=h(e.payload);if(!t.ok)return t;let n=He(e.access,"GET");return n.ok?s({payload:t.value,access:n.value}):n}function Jr(e){if(i(e)&&e.disposition==="missing"&&g(e,["disposition"]))return s({disposition:"missing"});if(i(e)&&e.disposition==="committed"&&g(e,["disposition","payload"])){let t=h(e.payload);return!t.ok||t.value.kind!=="trigger_events"?r("committed trigger payload is invalid"):s({disposition:"committed",payload:t.value})}return r("trigger payload resolve data shape is invalid")}function oe(e){if(!i(e))return r("execution payload authority must be an object");if(e.kind==="run"&&g(e,["kind","executionLease"])){let t=y(e.executionLease);return t.ok?s({kind:"run",executionLease:t.value}):t}return e.kind==="webhook_watcher"&&g(e,["kind","triggerInstanceId","watcherInstanceId","watcherGeneration","artifactDigest"])&&E(e.triggerInstanceId)&&E(e.watcherInstanceId)&&B(e.watcherGeneration)&&Re(e.artifactDigest)?s({kind:"webhook_watcher",triggerInstanceId:e.triggerInstanceId,watcherInstanceId:e.watcherInstanceId,watcherGeneration:e.watcherGeneration,artifactDigest:e.artifactDigest}):e.kind==="polling_tick"&&g(e,["kind","pollingInstanceId","tickId","artifactDigest"])&&E(e.pollingInstanceId)&&E(e.tickId)&&Re(e.artifactDigest)?s({kind:"polling_tick",pollingInstanceId:e.pollingInstanceId,tickId:e.tickId,artifactDigest:e.artifactDigest}):r("execution payload authority shape is invalid")}function Et(e){if(!i(e))return r("execution payload owner must be an object");if(e.kind==="run"&&g(e,["kind","phase"])&&(e.phase==="execution_context"||e.phase==="run_input"||e.phase==="terminal_output"))return s({kind:"run",phase:e.phase});if(e.kind==="node"&&g(e,["kind","nodeId","attempt","phase","invocationId","claimEpoch"])&&E(e.nodeId)&&B(e.attempt)){if(e.phase==="provider_output"&&E(e.invocationId)&&B(e.claimEpoch))return s({kind:"node",nodeId:e.nodeId,attempt:e.attempt,phase:"provider_output",invocationId:e.invocationId,claimEpoch:e.claimEpoch});if((e.phase==="mapped_input"||e.phase==="success_transform"||e.phase==="error_transform"||e.phase==="step_output")&&(e.invocationId===null||E(e.invocationId))&&e.claimEpoch===null)return s({kind:"node",nodeId:e.nodeId,attempt:e.attempt,phase:e.phase,invocationId:e.invocationId,claimEpoch:null})}return e.kind==="event"&&g(e,["kind","nodeId","eventId","eventType"])&&E(e.nodeId)&&E(e.eventId)&&(e.eventType==="wait_event"||e.eventType==="human_input")?s({kind:"event",nodeId:e.nodeId,eventId:e.eventId,eventType:e.eventType}):e.kind==="webhook"&&g(e,["kind","phase","deliveryId"])&&(e.phase==="watcher_context"||e.phase==="delivery_input"||e.phase==="delivery_events")&&(e.deliveryId===null||E(e.deliveryId))?s({kind:"webhook",phase:e.phase,deliveryId:e.deliveryId}):e.kind==="polling"&&g(e,["kind","phase"])&&(e.phase==="tick_context"||e.phase==="tick_events")?s({kind:"polling",phase:e.phase}):r("execution payload owner shape is invalid")}function xe(e){return i(e)&&g(e,["algorithm","value"])&&e.algorithm==="sha256"&&Re(e.value)?s({algorithm:"sha256",value:e.value}):r("execution payload digest is invalid")}function He(e,t){return!i(e)||!g(e,["method","url","headers","expiresAt"])||e.method!==t||!E(e.url)||!ht(e.headers)||!_t(e.expiresAt)?r(`execution payload ${t} access is invalid`):s({method:t,url:e.url,headers:{...e.headers},expiresAt:e.expiresAt})}function me(e,t){if(e===null)return"null";if(typeof e=="boolean")return e?"true":"false";if(typeof e=="string")return Fe(e),JSON.stringify(e);if(typeof e=="number"){if(!Number.isFinite(e))throw new TypeError("execution payload numbers must be finite");return JSON.stringify(e)}if(typeof e!="object")throw new TypeError("execution payload contains a non-JSON member");if(t.has(e))throw new TypeError("execution payload contains a cycle");t.add(e);try{if(Array.isArray(e)){let u=[];for(let c=0;c<e.length;c+=1){if(!(c in e))throw new TypeError("execution payload contains a sparse array");u.push(me(e[c],t))}return`[${u.join(",")}]`}let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)throw new TypeError("execution payload contains a non-plain object");let o=e;return`{${Object.keys(o).sort().map(u=>(Fe(u),`${JSON.stringify(u)}:${me(o[u],t)}`)).join(",")}}`}finally{t.delete(e)}}function Fe(e){for(let t=0;t<e.length;t+=1){let n=e.charCodeAt(t);if(n>=55296&&n<=56319){let o=e.charCodeAt(t+1);if(!Number.isInteger(o)||o<56320||o>57343)throw new TypeError("execution payload strings must not contain lone surrogates");t+=1}else if(n>=56320&&n<=57343)throw new TypeError("execution payload strings must not contain lone surrogates")}}function g(e,t){let n=Object.keys(e).sort(),o=[...t].sort();return n.length===o.length&&n.every((a,u)=>a===o[u])}function qe(e){return typeof e=="string"&&kt.includes(e)}function B(e){return Number.isSafeInteger(e)&&e>0}function E(e){return typeof e=="string"&&e.length>0}function Re(e){return typeof e=="string"&&/^[a-f0-9]{64}$/.test(e)}function ht(e){return i(e)&&Object.values(e).every(t=>typeof t=="string")}function _t(e){return typeof e=="string"&&Number.isFinite(Date.parse(e))&&new Date(e).toISOString()===e}var I="/internal/flow-runs",to="/:flowRunId/execution-context";function no(e){return`${I}/${encodeURIComponent(e)}/execution-context`}function Ie(e){return!i(e)||P(e,["fileMaxBytes","fileReadMaxBytes","inlineMultipartBytesMax"])!==void 0||!ie(e.fileMaxBytes)||!ie(e.fileReadMaxBytes)||!ie(e.inlineMultipartBytesMax)?r("file runtime limits must carry three positive integer bounds"):s({fileMaxBytes:e.fileMaxBytes,fileReadMaxBytes:e.fileReadMaxBytes,inlineMultipartBytesMax:e.inlineMultipartBytesMax})}function ro(e){if(!i(e))return r("execution context must be a JSON object");let t=P(e,["flowRunId","workspaceId","executionGeneration","compiled","context"]);if(t!==void 0)return r(`execution context does not accept the "${t}" field`);let n=e.compiled;if(typeof e.flowRunId!="string"||typeof e.workspaceId!="string"||!i(n)||P(n,["irSchemaVersion","interpreterContractVersion","ir","compiledArtifactId"])!==void 0||n.irSchemaVersion!==Tt||n.interpreterContractVersion!==wt||typeof n.compiledArtifactId!="string")return r("execution context surface shape is invalid");let o=bt(n.ir);if(!o.ok)return r(o.reason);let a=Pt(e.executionGeneration,e.flowRunId);if(!a.ok)return r(a.reason);let u=h(e.context);return!u.ok||u.value.kind!=="execution_context"?r("execution context payload ref is invalid"):s({flowRunId:e.flowRunId,workspaceId:e.workspaceId,compiled:{...n,ir:o.value},executionGeneration:a.value,context:u.value})}function oo(e){if(!i(e)||P(e,["input","executionBindings","fileRuntime"])!==void 0||!St(e.executionBindings))return r("execution context payload shape is invalid");let t=h(e.input);if(!t.ok||t.value.kind!=="run_input")return r("execution context run input ref is invalid");let n=Ct(e.fileRuntime);return n.ok?s({input:t.value,executionBindings:e.executionBindings,fileRuntime:n.value}):r(n.reason)}function Pt(e,t){return!i(e)||P(e,["id","flowRunId","number"])!==void 0||typeof e.id!="string"||e.id.length===0||typeof e.flowRunId!="string"||e.flowRunId!==t||!ie(e.number)?r("executionGeneration surface shape is invalid"):s({id:e.id,flowRunId:e.flowRunId,number:e.number})}function Ct(e){if(e===null)return s(null);if(!i(e))return r("fileRuntime must be null or an object");if(P(e,["limits"])!==void 0)return r("fileRuntime surface shape is invalid");let t=Ie(e.limits);return t.ok?s({limits:t.value}):r(t.reason)}function St(e){return Array.isArray(e)?e.every(t=>{if(!i(t)||!U(t.stateScope).ok||!b(t.nodeId))return!1;if(t.executionKind==="direct")return P(t,["executionKind","nodeId","stateScope","toolRef","toolDescriptor","integrationDescriptor","connection"])===void 0&&b(t.toolRef)&&i(t.toolDescriptor)&&i(t.integrationDescriptor)&&Me(t.toolDescriptor,t.connection);if(t.executionKind!=="server_transformed")return!1;let o=t.realAction;return P(t,["executionKind","nodeId","stateScope","canonicalToolRef","serverTransformRef","serverTransformContractDigest","realAction"])===void 0&&b(t.canonicalToolRef)&&b(t.serverTransformRef)&&Dt(t.serverTransformContractDigest)&&i(o)&&P(o,["toolRef","toolDescriptor","integrationDescriptor","connection"])===void 0&&b(o.toolRef)&&i(o.toolDescriptor)&&i(o.integrationDescriptor)&&Me(o.toolDescriptor,o.connection)}):!1}function Me(e,t){return e.auth_required===!1?t===null:e.auth_required===!0&&At(t)}function At(e){return i(e)&&P(e,["installationId","connectionRef","connectionId","authProfileRef","authType","connectionConfig"])===void 0&&b(e.installationId)&&b(e.connectionRef)&&b(e.connectionId)&&b(e.authProfileRef)&&b(e.authType)&&(e.connectionConfig===void 0||i(e.connectionConfig))}function Dt(e){return typeof e=="string"&&/^[0-9a-f]{64}$/.test(e)}function b(e){return typeof e=="string"&&e.length>0}function ie(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0}function P(e,t){return Object.keys(e).find(n=>!t.includes(n))}import{parseAblehiErrorDigest as ke}from"@ablehi/error-contract";var lo="/:flowRunId/steps/:nodeId/result",fo="/:flowRunId/result",go="/:flowRunId/execution-events",mo="/:flowRunId/waits/:nodeId/register",Ro="/:flowRunId/waits/:nodeId/complete";function yo(e,t){return`${I}/${encodeURIComponent(e)}/steps/${encodeURIComponent(t)}/result`}function xo(e){return`${I}/${encodeURIComponent(e)}/result`}function Io(e){return`${I}/${encodeURIComponent(e)}/execution-events`}function ko(e,t){return`${I}/${encodeURIComponent(e)}/waits/${encodeURIComponent(t)}/register`}function Eo(e,t){return`${I}/${encodeURIComponent(e)}/waits/${encodeURIComponent(t)}/complete`}function ho(e){if(!i(e))return{ok:!1,kind:"validation",reason:"step record body must be a JSON object"};let t=k(e,["executionLease","attempt","result","durationMs"]);if(t!==void 0)return{ok:!1,kind:"validation",reason:`step record does not accept the "${t}" field`};let n=y(e.executionLease);if(!n.ok)return{ok:!1,kind:"validation",reason:n.reason};let o=e.attempt;if(typeof o!="number"||!Number.isInteger(o)||o<=0)return{ok:!1,kind:"validation",reason:"attempt must be a positive integer"};let a=Ot(e.result);if(!a.ok)return a;let u={executionLease:n.value,attempt:o,result:a.value};if(e.durationMs!==void 0){let c=e.durationMs;if(typeof c!="number"||!Number.isFinite(c)||c<0)return{ok:!1,kind:"validation",reason:"durationMs must be a non-negative number"};u.durationMs=c}return{ok:!0,value:u}}function Ot(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"]);if(n!==void 0)return{ok:!1,kind:"validation",reason:`step record result does not accept the "${n}" field`};if(!("output"in e))return{ok:!1,kind:"step_result_invalid",reason:"a succeeded result must carry output"};let o=h(e.output);return!o.ok||o.value.kind!=="step_output"?{ok:!1,kind:"step_result_invalid",reason:"a succeeded result must carry a step_output payload ref"}:{ok:!0,value:{status:"succeeded",output:o.value}}}if(t==="failed"){let n=k(e,["status","error"]);if(n!==void 0)return{ok:!1,kind:"validation",reason:`step record result does not accept the "${n}" field`};let o=ke(e.error);return o.ok?{ok:!0,value:{status:"failed",error:o.value}}:{ok:!1,kind:"step_result_invalid",reason:`a failed result must carry an AblehiErrorDigest: ${o.reason}`}}if(t==="skipped"){let n=k(e,["status","reason"]);return n!==void 0?{ok:!1,kind:"validation",reason:`step record result does not accept the "${n}" field`}:e.reason!=="run_if_false"?{ok:!1,kind:"step_result_invalid",reason:'a skipped result reason must be "run_if_false"'}:{ok:!0,value:{status:"skipped",reason:"run_if_false"}}}if(t==="timed_out"){let n=k(e,["status","error"]);if(n!==void 0)return{ok:!1,kind:"validation",reason:`step record result does not accept the "${n}" field`};let o=ke(e.error);return o.ok?{ok:!0,value:{status:"timed_out",error:o.value}}:{ok:!1,kind:"step_result_invalid",reason:`a timed_out result must carry an AblehiErrorDigest: ${o.reason}`}}return{ok:!1,kind:"step_result_invalid",reason:'result status must be "succeeded", "failed", "skipped", or "timed_out"'}}function _o(e){return!i(e)||typeof e.flowRunId!="string"||typeof e.nodeId!="string"||!Nt(e.recorded)?r("step record data surface shape is invalid"):s({flowRunId:e.flowRunId,nodeId:e.nodeId,recorded:e.recorded})}function Nt(e){return e==="succeeded"||e==="failed"||e==="skipped"||e==="timed_out"}function wo(e){if(!i(e))return r("result body must be a JSON object");let t=k(e,["executionLease","status","output","error"]);if(t!==void 0)return r(`result does not accept the "${t}" field`);let n=y(e.executionLease);if(!n.ok)return r(n.reason);let o=e.status;if(o!=="succeeded"&&o!=="failed")return r('result status must be "succeeded" or "failed"');let a={executionLease:n.value,status:o};if(o==="succeeded"){let u=h(e.output);if(!u.ok||u.value.kind!=="flow_terminal_output")return r("a succeeded result must carry a flow_terminal_output payload ref");a.output=u.value}else if(e.output!==void 0)return r("output is only allowed on a succeeded result");if(e.error!==void 0){if(o!=="failed")return r("error is only allowed on a failed result");let u=ke(e.error);if(!u.ok)return r(`result error must be an AblehiErrorDigest: ${u.reason}`);a.error=u.value}return o==="failed"&&a.error===void 0?r("a failed result must carry an AblehiErrorDigest"):s(a)}function To(e){return i(e)?s(e):r("flow run result data must be a JSON object")}var Ut=["step_started","step_retry_scheduled"];function bo(e){if(!i(e))return r("execution event data must be a JSON object");let t=k(e,["flowRunId","eventId","accepted"]);return t!==void 0?r(`execution event data does not accept the "${t}" field`):typeof e.flowRunId!="string"||e.flowRunId.length===0?r("flowRunId must be a non-empty string"):typeof e.eventId!="string"||e.eventId.length===0?r("eventId must be a non-empty string"):e.accepted!==!0?r("accepted must be true"):s({flowRunId:e.flowRunId,eventId:e.eventId,accepted:!0})}function Po(e){if(!i(e))return r("execution event body must be a JSON object");let t=k(e,["executionLease","eventId","eventType","nodeId","stepRunId","attempt","durationMs","occurredAt","errorId","payloadRef","inputFact"]);if(t!==void 0)return r(`execution event does not accept the "${t}" field`);let n=y(e.executionLease);if(!n.ok)return r(n.reason);let o=e.eventId;if(typeof o!="string"||o.length===0)return r("eventId must be a non-empty string");let a=e.eventType;if(!vt(a))return r("eventType is not a known flow execution event type");let u=e.occurredAt;if(typeof u!="string"||u.length===0)return r("occurredAt must be a non-empty string");let c={executionLease:n.value,eventId:o,eventType:a,occurredAt:u};for(let d of["nodeId","stepRunId","errorId","payloadRef"]){let f=e[d];if(f!==void 0){if(typeof f!="string"||f.length===0)return r(`${d} must be a non-empty string`);c[d]=f}}for(let d of["attempt","durationMs"]){let f=e[d];if(f!==void 0){if(typeof f!="number"||!Number.isFinite(f)||!Number.isInteger(f)||f<0)return r(`${d} must be a non-negative integer`);c[d]=f}}if(e.inputFact!==void 0){if(a!=="step_started")return r("inputFact is only allowed on step_started events");if(c.attempt===void 0)return r("inputFact requires attempt");let d=Lt(e.inputFact);if(!d.ok)return d;c.inputFact=d.value}return s(c)}function vt(e){return typeof e=="string"&&Ut.includes(e)}function Lt(e){if(!i(e))return r("inputFact must be a JSON object");let t=k(e,["digestAlgorithm","digest","domain"]);if(t!==void 0)return r(`inputFact does not accept the "${t}" field`);if(e.digestAlgorithm!=="sha256")return r('inputFact.digestAlgorithm must be "sha256"');let n=e.digest;if(typeof n!="string"||!/^[0-9a-f]{64}$/.test(n))return r("inputFact.digest must be a sha256 hex string");let o=e.domain;if(!i(o))return r("inputFact.domain must be a JSON object");let a=k(o,["irSchemaVersion","interpreterContractVersion","compiledArtifactId","nodeId","algorithmVersion"]);return a!==void 0?r(`inputFact.domain does not accept the "${a}" field`):typeof o.irSchemaVersion!="string"||o.irSchemaVersion.length===0||typeof o.interpreterContractVersion!="string"||o.interpreterContractVersion.length===0||typeof o.compiledArtifactId!="string"||o.compiledArtifactId.length===0||typeof o.nodeId!="string"||o.nodeId.length===0?r("inputFact.domain string fields must be non-empty strings"):o.algorithmVersion!=="flow_input_digest.v1"?r('inputFact.domain.algorithmVersion must be "flow_input_digest.v1"'):s({digestAlgorithm:"sha256",digest:n,domain:{irSchemaVersion:o.irSchemaVersion,interpreterContractVersion:o.interpreterContractVersion,compiledArtifactId:o.compiledArtifactId,nodeId:o.nodeId,algorithmVersion:"flow_input_digest.v1"}})}var Ft=/^[A-Za-z0-9_-]{1,100}$/;function Co(e){if(!i(e))return r("register body must be a JSON object");let t=k(e,["executionLease","eventType","correlationKey"]);if(t!==void 0)return r(`register wait does not accept the "${t}" field`);let n=y(e.executionLease);if(!n.ok)return r(n.reason);let o=Ve(e.eventType);if(!o.ok)return r(o.reason);let a=e.correlationKey;return typeof a!="string"||a.length===0?r("correlationKey must be a non-empty string"):s({executionLease:n.value,eventType:o.value,correlationKey:a})}function So(e){if(!i(e))return r("complete body must be a JSON object");let t=k(e,["executionLease","waitExecutionId","outcome","eventId"]);if(t!==void 0)return r(`complete wait does not accept the "${t}" field`);let n=y(e.executionLease);if(!n.ok)return r(n.reason);let o=e.waitExecutionId;if(typeof o!="string"||o.length===0)return r("waitExecutionId must be a non-empty string");let a=e.outcome;if(a!=="received"&&a!=="timed_out")return r('outcome must be "received" or "timed_out"');let u={executionLease:n.value,waitExecutionId:o,outcome:a};if(e.eventId!==void 0){if(typeof e.eventId!="string"||e.eventId.length===0)return r("eventId must be a non-empty string");u.eventId=e.eventId}return s(u)}function Ao(e){if(!i(e)||k(e,["waitExecutionId","workflowEventType"])!==void 0||typeof e.waitExecutionId!="string"||e.waitExecutionId.length===0)return r("register wait data surface shape is invalid");let t=Ve(e.workflowEventType);return t.ok?s({waitExecutionId:e.waitExecutionId,workflowEventType:t.value}):r(t.reason)}function Do(e){return!i(e)||k(e,["completed"])!==void 0||e.completed!==!0?r("complete wait data surface shape is invalid"):s({completed:!0})}function Oo(e){return!i(e)||k(e,["waitExecutionId","eventId","payload"])!==void 0||typeof e.waitExecutionId!="string"||e.waitExecutionId.length===0||typeof e.eventId!="string"||e.eventId.length===0||!Object.hasOwn(e,"payload")?r("Wait resolved event surface shape is invalid"):s({waitExecutionId:e.waitExecutionId,eventId:e.eventId,payload:e.payload})}function Ve(e){return typeof e!="string"||e.length===0?r("eventType must be a non-empty string"):Ft.test(e)?s(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 Bt="/internal/flow-versions",Uo="/:flowVersionId/handler-bundles",he="/internal/installations",vo="/:installationId/handler-bundles";function Lo(e,t){return`${Bt}/${encodeURIComponent(e)}/handler-bundles?compiledArtifactId=${encodeURIComponent(t)}`}function Fo(e){return`${he}/${encodeURIComponent(e.installationId)}/handler-bundles?workspaceId=${encodeURIComponent(e.workspaceId)}&artifactDigest=${encodeURIComponent(e.artifactDigest)}`}var Ht=new Set(["managed_only","managed_plus_unmanaged_sdk"]);function se(e){if(!H(e))return Ee("runtimeNetwork must be a JSON object");let t=e.networkModel;return typeof t!="string"||!Ht.has(t)?Ee("runtimeNetwork.networkModel is unknown"):!$e(e.apiHosts)||!$e(e.authHosts)||typeof e.httpsOnly!="boolean"?Ee("runtimeNetwork host/https fields are invalid"):{ok:!0,value:{networkModel:t,apiHosts:e.apiHosts,authHosts:e.authHosts,httpsOnly:e.httpsOnly}}}function Bo(e){if(!H(e)||typeof e.flowVersionId!="string"||typeof e.compiledArtifactId!="string"||!Array.isArray(e.bundles))return j("handler bundles data surface shape is invalid");let t=We(e.bundles);return t.ok?{ok:!0,value:{flowVersionId:e.flowVersionId,compiledArtifactId:e.compiledArtifactId,bundles:t.value}}:t}function Ho(e){if(!H(e)||typeof e.installationId!="string"||typeof e.artifactDigest!="string"||!Array.isArray(e.bundles))return j("tool handler bundles data surface shape is invalid");let t=We(e.bundles);return t.ok?{ok:!0,value:{installationId:e.installationId,artifactDigest:e.artifactDigest,bundles:t.value}}:t}function We(e){let t=[];for(let n of e){let o=qt(n);if(!o.ok)return o;t.push(o.value)}return{ok:!0,value:t}}function qt(e){if(!H(e)||typeof e.toolRef!="string"||e.kind!=="handler"&&e.kind!=="request")return j("handler bundle entry shape is invalid");if(e.kind==="request"){if(e.module!==void 0)return j("a request bundle must not carry a module");let o=se(e.runtimeNetwork);return o.ok?{ok:!0,value:{toolRef:e.toolRef,kind:"request",runtimeNetwork:o.value}}:o}let t=e.module;if(!H(t)||typeof t.entry!="string"||t.entry.length===0||!Mt(t.files))return j("a handler bundle must carry a { entry, files } module");let n=se(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 j(e){return{ok:!1,kind:"shape",reason:e}}function Ee(e){return{ok:!1,kind:"runtime_network",reason:e}}function H(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function $e(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function Mt(e){return H(e)&&Object.values(e).every(t=>typeof t=="string")}var X="/internal/webhook-trigger-instances",Go="/:triggerInstanceId/context",jo="/:triggerInstanceId/handler-bundles",Xo="/:triggerInstanceId/deliveries/:deliveryId",Jo="/:triggerInstanceId/events",Yo="/:triggerInstanceId/rearm",J=e=>`${X}/${encodeURIComponent(e)}`;function zo(e,t){return`${J(e)}/context?artifactDigest=${encodeURIComponent(t)}`}function Qo(e,t){return`${J(e)}/handler-bundles?artifactDigest=${encodeURIComponent(t)}`}function Zo(e,t){return`${J(e)}/deliveries/${encodeURIComponent(t)}`}function ei(e){return`${J(e)}/events`}function ti(e){return`${J(e)}/rearm`}var ni="/:installationId/webhook-protocol-adapter-bundle";function ri(e){return`${he}/${encodeURIComponent(e.installationId)}/webhook-protocol-adapter-bundle?workspaceId=${encodeURIComponent(e.workspaceId)}&artifactDigest=${encodeURIComponent(e.artifactDigest)}`}var oi="modules/webhook/protocol-adapter.js";function ii(e){return`modules/webhook/protocol-adapter-${e}.js`}function si(e){let t=i(e)?U(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&&!Vt(e.connection)||!$t(e.runtime)||!t.ok||t.value.kind!=="webhook-trigger"?r("webhook watcher context surface shape is invalid"):s(e)}function Vt(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 $t(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 Wt(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"):s(e)}function _e(e){if(!i(e)||typeof e.token!="string"||typeof e.expiresAt!="string")return r("trigger file runtime dispatch shape is invalid");let t=Ie(e.limits);return t.ok?s({token:e.token,expiresAt:e.expiresAt,limits:t.value}):r(t.reason)}function ai(e){if(!i(e))return r("webhook delivery dispatch data is invalid");let t=Wt(e.delivery);if(!t.ok)return r(t.reason);let n=e.fileRuntime;if(n===null)return s({delivery:t.value,fileRuntime:null});let o=_e(n);return o.ok?s({delivery:t.value,fileRuntime:o.value}):r(o.reason)}function ui(e){if(!i(e)||typeof e.triggerRef!="string"||typeof e.artifactDigest!="string"||!Array.isArray(e.modules)||!e.modules.every(Kt))return{ok:!1,kind:"shape",reason:"trigger handler bundles data surface shape is invalid"};let t=se(e.runtimeNetwork);return t.ok?{ok:!0,value:{triggerRef:e.triggerRef,artifactDigest:e.artifactDigest,modules:e.modules,runtimeNetwork:t.value}}:t}function Kt(e){return i(e)&&typeof e.specifier=="string"&&e.specifier.length>0&&typeof e.source=="string"}function ci(e){if(!i(e))return r("publish events body must be a JSON object");let t=we(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 a=[];for(let u of o){let c=Gt(u);if(!c.ok)return c;a.push(c.value)}return s({deliveryId:n,events:a})}function Gt(e){if(!i(e))return r("each event must be a JSON object");let t=we(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 a={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");a.dedupeKey=e.dedupeKey}return s(a)}function di(e){if(!i(e))return r("rearm body must be a JSON object");let t=we(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"):s({expectedWatcherInstanceId:n})}function we(e,t){return Object.keys(e).find(n=>!t.includes(n))}var Y="/internal/polling-trigger-instances",mi="/:pollingInstanceId/context",Ri="/:pollingInstanceId/handler-bundles",yi="/:pollingInstanceId/ticks/:tickId/events",Te=e=>`${Y}/${encodeURIComponent(e)}`;function xi(e,t,n){return`${Te(e)}/context?artifactDigest=${encodeURIComponent(t)}&tickId=${encodeURIComponent(n)}`}function Ii(e,t){return`${Te(e)}/handler-bundles?artifactDigest=${encodeURIComponent(t)}`}function ki(e,t){return`${Te(e)}/ticks/${encodeURIComponent(t)}/events`}function jt(e){let t=i(e)?U(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&&!Xt(e.connection)||!Jt(e.runtime)||!t.ok||t.value.kind!=="polling-trigger"||!zt(e.tick)||!Qt(e.limits)?r("polling trigger context surface shape is invalid"):s(e)}function Ei(e){if(!i(e))return r("polling trigger dispatch data is invalid");let t=jt(e.context);if(!t.ok)return r(t.reason);let n=e.fileRuntime;if(n===null)return s({context:t.value,fileRuntime:null});let o=_e(n);return o.ok?s({context:t.value,fileRuntime:o.value}):r(o.reason)}function Xt(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 Jt(e){if(!i(e)||e.type!=="polling"||typeof e.trigger_id!="string"||typeof e.trigger_ref!="string"||!Yt(e.file_outputs))return!1;let t=e.polling;if(!i(t)||typeof t.run_handler_module!="string")return!1;let n=t.schedule;if(!i(n)||n.type!=="interval"||typeof n.every_seconds!="number")return!1;let o=t.dedup;return i(o)&&(o.strategy==="cursor"||o.strategy==="hash"||o.strategy==="id_field")}function Yt(e){return e===void 0?!0:Array.isArray(e)&&e.length>0&&e.every(t=>i(t)&&typeof t.field=="string"&&t.field.length>0)}function zt(e){return i(e)&&typeof e.tickId=="string"&&typeof e.scheduledAt=="string"&&typeof e.attempt=="number"}function Qt(e){return i(e)&&typeof e.maxEventsPerTick=="number"}function hi(e){if(!i(e))return r("publish body must be a JSON object");let t=Ke(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 u of n){let c=Zt(u);if(!c.ok)return c;o.push(c.value)}let a={events:o};if("nextCursor"in e){let u=e.nextCursor;if(u!==null&&typeof u!="string")return r("nextCursor must be a string, null, or omitted");a.nextCursor=u}return s(a)}function Zt(e){if(!i(e))return r("each event must be a JSON object");let t=Ke(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 s(n)}function _i(e){return!i(e)||typeof e.tickId!="string"||typeof e.cursorUpdated!="boolean"||!Array.isArray(e.results)||!e.results.every(en)?r("publish polling tick events data surface shape is invalid"):s(e)}function en(e){return i(e)&&typeof e.eventId=="string"&&typeof e.dedupeKey=="string"&&typeof e.duplicate=="boolean"&&(e.flowRunId===null||typeof e.flowRunId=="string")}function Ke(e,t){return Object.keys(e).find(n=>!t.includes(n))}var Ge="/internal/egress-grants",be="/internal/tool-invocations",Pe="/internal/discovery-invocations",Si="/:flowRunId/egress-grant",Ai="/:invocationId/egress-grant",Di="/:discoveryInvocationId/egress-grant",Oi="/:pollingInstanceId/egress-grant",Ni="/:triggerInstanceId/egress-grant",Ui="/:grantId/consume",vi="/:grantId/audit",Li=e=>`${I}/${encodeURIComponent(e)}/egress-grant`,Fi=e=>`${be}/${encodeURIComponent(e)}/egress-grant`,Bi=e=>`${Pe}/${encodeURIComponent(e)}/egress-grant`,Hi=e=>`${Y}/${encodeURIComponent(e)}/egress-grant`,qi=e=>`${X}/${encodeURIComponent(e)}/egress-grant`,Mi=e=>`${Ge}/${encodeURIComponent(e)}/consume`,Vi=e=>`${Ge}/${encodeURIComponent(e)}/audit`,tn=["flow_action","single_tool","discovery","polling_trigger","webhook_trigger"],nn=/^[A-Za-z0-9][A-Za-z0-9:_+/=.-]{15,1023}$/;function q(e){return typeof e=="string"&&nn.test(e)}function rn(e){if(!i(e)||e.body_type!=="multipart")return!1;let t=e.body;if(!i(t))return!1;let n=t.parts;return Array.isArray(n)?n.some(o=>i(o)?o.kind==="file"&&typeof o.file_id=="string"&&o.file_id.length>0:!1):!1}function p(e){return{ok:!1,kind:"shape",reason:e}}function M(){return{ok:!1,kind:"request_digest",reason:"request digest is missing or malformed"}}function z(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 Q(e){if(!i(e))return"request must be a JSON object"}function $i(e){let t=z(e,["nodeId","request","requestDigest"]);if(!t.ok)return p(t.reason);let n=t.record.nodeId;if(typeof n!="string"||n.length===0)return p("nodeId is required");let o=Q(t.record.request);if(o!==void 0)return p(o);let a=t.record.requestDigest;return q(a)?{ok:!0,value:{nodeId:n,requestDigest:a,requestHasMultipartFiles:rn(t.record.request)}}:M()}function Wi(e){let t=z(e,["request","requestDigest"]);if(!t.ok)return p(t.reason);let n=Q(t.record.request);if(n!==void 0)return p(n);let o=t.record.requestDigest;return q(o)?{ok:!0,value:{requestDigest:o}}:M()}function Ki(e){let t=z(e,["request","requestDigest"]);if(!t.ok)return p(t.reason);let n=Q(t.record.request);if(n!==void 0)return p(n);let o=t.record.requestDigest;return q(o)?{ok:!0,value:{requestDigest:o}}:M()}function Gi(e){let t=z(e,["tickId","request","requestDigest"]);if(!t.ok)return p(t.reason);let n=t.record.tickId;if(typeof n!="string"||n.length===0)return p("tickId is required");let o=Q(t.record.request);if(o!==void 0)return p(o);let a=t.record.requestDigest;return q(a)?{ok:!0,value:{tickId:n,requestDigest:a}}:M()}function ji(e){let t=z(e,["phase","lifecycle","deliveryId","request","requestDigest"]);if(!t.ok)return p(t.reason);let n=t.record.phase;if(n!=="lifecycle"&&n!=="handler")return p('phase must be "lifecycle" or "handler"');let o=t.record.lifecycle,a;if(o!==void 0){if(o!=="enable"&&o!=="disable"&&o!=="renew")return p('lifecycle must be "enable", "disable", or "renew"');a=o}if(n==="lifecycle"&&a===void 0)return p("lifecycle is required for the lifecycle phase");let u=t.record.deliveryId,c;if(u!==void 0){if(typeof u!="string"||u.length===0)return p("deliveryId must be a non-empty string");c=u}if(n==="handler"&&c===void 0)return p("deliveryId is required for the handler phase");let d=Q(t.record.request);if(d!==void 0)return p(d);let f=t.record.requestDigest;return q(f)?{ok:!0,value:{phase:n,...a!==void 0?{lifecycle:a}:{},...c!==void 0?{deliveryId:c}:{},requestDigest:f}}:M()}function je(e){return tn.includes(e)?e:void 0}var on=["scopeKind","scopeId","requestDigest"];function Xi(e){if(!i(e))return p("consume body must be a JSON object");for(let a of Object.keys(e))if(!on.includes(a))return p(`consume does not accept the "${a}" field`);let t=je(e.scopeKind);if(t===void 0)return p("scopeKind is invalid");let n=e.scopeId;if(typeof n!="string"||n.length===0)return p("scopeId is required");let o=e.requestDigest;return q(o)?{ok:!0,value:{scopeKind:t,scopeId:n,requestDigest:o}}:M()}var sn=["scopeKind","scopeId","providerHost","status","durationMs","requestBytes","responseBytes","errorCode"];function ae(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 Ji(e){if(!i(e))return p("audit body must be a JSON object");for(let l of Object.keys(e))if(!sn.includes(l))return p(`audit does not accept the "${l}" field`);let t=je(e.scopeKind);if(t===void 0)return p("scopeKind is invalid");let n=e.scopeId;if(typeof n!="string"||n.length===0)return p("scopeId is required");let o=e.providerHost;if(typeof o!="string"||o.length===0)return p("providerHost is required");let a=ae(e.durationMs,"durationMs");if(!a.ok)return p(a.reason);let u;if(e.status!==void 0){let l=ae(e.status,"status");if(!l.ok)return p(l.reason);u=l.value}let c;if(e.requestBytes!==void 0){let l=ae(e.requestBytes,"requestBytes");if(!l.ok)return p(l.reason);c=l.value}let d;if(e.responseBytes!==void 0){let l=ae(e.responseBytes,"responseBytes");if(!l.ok)return p(l.reason);d=l.value}let f;if(e.errorCode!==void 0){let l=e.errorCode;if(typeof l!="string"||l.length===0)return p("errorCode must be a non-empty string");f=l}return{ok:!0,value:{scopeKind:t,scopeId:n,providerHost:o,...u!==void 0?{status:u}:{},durationMs:a.value,...c!==void 0?{requestBytes:c}:{},...d!==void 0?{responseBytes:d}:{},...f!==void 0?{errorCode:f}:{}}}}function Yi(e){return!i(e)||!i(e.grant)?r("egress grant envelope must carry a grant object"):s(e.grant)}function zi(e){return!i(e)||e.consumed!==!0?r("egress grant consume data must carry consumed:true"):s({consumed:!0})}var os="/:flowRunId/runtime-credential",is="/:invocationId/runtime-credential",ss="/:discoveryInvocationId/runtime-credential",as="/:pollingInstanceId/runtime-credential",us="/:triggerInstanceId/runtime-credential",cs=e=>`${I}/${encodeURIComponent(e)}/runtime-credential`,ds=e=>`${be}/${encodeURIComponent(e)}/runtime-credential`,ps=e=>`${Pe}/${encodeURIComponent(e)}/runtime-credential`,ls=e=>`${Y}/${encodeURIComponent(e)}/runtime-credential`,fs=e=>`${X}/${encodeURIComponent(e)}/runtime-credential`,gs=["flow_action","tool_invoke","discovery","polling_trigger","webhook_trigger"];function Z(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 ms(e){let t=Z(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"):s({nodeId:n})}function Rs(e){let t=Z(e??{},[]);return t.ok?s(null):r(t.reason)}function ys(e){let t=Z(e??{},[]);return t.ok?s(null):r(t.reason)}function xs(e){let t=Z(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"):s({tickId:n})}function Is(e){let t=Z(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,a=t.record.deliveryId;if(a!==void 0){if(typeof a!="string"||a.length===0)return r("deliveryId must be a non-empty string");o=a}let u,c=t.record.lifecycleOperation;if(c!==void 0){if(c!=="enable"&&c!=="disable"&&c!=="renew")return r('lifecycleOperation must be "enable", "disable", or "renew"');u=c}return n==="lifecycle"&&u===void 0?r("lifecycleOperation is required for the lifecycle execution kind"):s({executionKind:n,...o!==void 0?{deliveryId:o}:{},...u!==void 0?{lifecycleOperation:u}:{}})}function ks(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"):s(e.credential)}function ue(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"):s(e)}function Ce(e){return!i(e)||e.method!=="GET"&&e.method!=="PUT"||typeof e.url!="string"||typeof e.expires_at!="string"||!cn(e.headers)?r("presigned file URL data is invalid"):s(e)}function an(e){if(!i(e))return r("file upload session data is invalid");let t=ue(e.file);if(!t.ok)return r(t.reason);let n=Ce(e.upload);return n.ok?s({file:t.value,upload:n.value}):r(n.reason)}function un(e){if(!i(e))return r("file metadata data is invalid");let t=ue(e.file);return t.ok?s({file:t.value}):r(t.reason)}function cn(e){return i(e)?Object.values(e).every(t=>typeof t=="string"):!1}var V="/internal/files",bs="/upload-session",Ps="/:fileId/complete",Cs="/:fileId/access",Ss="/:fileId/stat",As="/:fileId/content",Ds=()=>V,Os=()=>`${V}/upload-session`,Ns=e=>`${V}/${encodeURIComponent(e)}/complete`,Us=(e,t)=>`${V}/${encodeURIComponent(e)}/access?intent=${encodeURIComponent(t)}`,Xe=e=>`?scope_kind=${encodeURIComponent(e.scopeKind)}&scope_id=${encodeURIComponent(e.scopeId)}`,vs=(e,t)=>`${V}/${encodeURIComponent(e)}/stat${Xe(t)}`,Ls=(e,t)=>`${V}/${encodeURIComponent(e)}/content${Xe(t)}`;function Fs(e){if(!i(e))return r("internal file access data is invalid");if(e.intent==="runtime_read"||e.intent==="provider_multipart"){let t=ue(e.file);if(!t.ok)return r(t.reason);let n=Ce(e.access);return n.ok?s({file:t.value,access:n.value,intent:e.intent}):r(n.reason)}return r("internal file access intent is invalid")}import{isHumanInputSpec as dn}from"@ablehi/flow-contract";var $s="/:flowRunId/human-inputs",Ws="/:flowRunId/human-inputs/:requestId",Ks="/:flowRunId/human-inputs/:requestId/expire",Gs="/:flowRunId/human-inputs/:requestId/acknowledge",pn=e=>`${I}/${encodeURIComponent(e)}/human-inputs`,Qe=(e,t)=>`${pn(e)}/${encodeURIComponent(t)}`,js=(e,t)=>`${Qe(e,t)}/expire`,Xs=(e,t)=>`${Qe(e,t)}/acknowledge`,ln="human_input_resolved";function Js(e){return`${ln}_${e}`}function Ys(e){return!i(e)||Object.keys(e).length!==4||!Object.hasOwn(e,"requestId")||!Object.hasOwn(e,"flowRunId")||!Object.hasOwn(e,"nodeId")||!Object.hasOwn(e,"status")||typeof e.requestId!="string"||e.requestId.length===0||typeof e.flowRunId!="string"||e.flowRunId.length===0||typeof e.nodeId!="string"||e.nodeId.length===0||e.status!=="submitted"&&e.status!=="expired"?r("Human Input resolved event shape is invalid"):s({requestId:e.requestId,flowRunId:e.flowRunId,nodeId:e.nodeId,status:e.status})}var Je=160,Ye=500;function fn(e){return i(e)?e.kind==="choice"?!ce(e,["kind","choiceId","comment"])||typeof e.choiceId!="string"||e.choiceId.length===0||e.comment!==void 0&&typeof e.comment!="string"?r("Human Input choice response is invalid"):s({kind:"choice",choiceId:e.choiceId,...e.comment!==void 0?{comment:e.comment}:{}}):e.kind==="text"&&ce(e,["kind","text"])&&typeof e.text=="string"?s({kind:"text",text:e.text}):e.kind==="form"&&ce(e,["kind","values"])&&i(e.values)?s({kind:"form",values:e.values}):r("Human Input response is invalid"):r("Human Input response must be an object")}function zs(e,t){let n=fn(e);if(!n.ok||n.value.kind!==t.kind)return r("Human Input response does not match its input spec");switch(t.kind){case"choice":{let o=n.value;return o.kind!=="choice"?r("Human Input choice response does not match its spec"):!t.choices.some(a=>a.id===o.choiceId)||o.comment!==void 0&&t.allowComment!==!0?r("Human Input choice response does not match its spec"):n}case"text":return n.value.kind!=="text"||t.required===!0&&n.value.text.trim().length===0?r("Human Input text response does not match its spec"):n;case"form":{if(n.value.kind!=="form")return r("Human Input form response does not match its spec");let o=new Map(t.fields.map(a=>[a.id,a]));if(Object.keys(n.value.values).some(a=>!o.has(a)))return r("Human Input form response contains an unknown field");for(let a of t.fields){let u=n.value.values[a.id];if(!Object.hasOwn(n.value.values,a.id)){if(a.required===!0)return r(`Human Input form response is missing required field '${a.id}'`);continue}if(u==null||!gn(a,u))return r(`Human Input form response field '${a.id}' does not match its spec`)}return n}}}function gn(e,t){switch(e.type){case"text":case"textarea":return typeof t=="string";case"number":return typeof t=="number"&&Number.isFinite(t);case"boolean":return typeof t=="boolean";case"select":return typeof t=="string"&&(e.options??[]).some(n=>n.id===t)}}function x(e){return{ok:!1,reason:e}}function v(e,t){return i(e)?{ok:!0,value:e}:x(`${t} must be an object`)}function ce(e,t){return Object.keys(e).every(n=>t.includes(n))}function $(e,t){return typeof e!="string"||e.length===0?x(`${t} must be a non-empty string`):{ok:!0,value:e}}var mn=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?(?:Z|[+-]\d{2}:\d{2})$/;function Rn(e,t){return typeof e!="string"||!mn.test(e)||Number.isNaN(Date.parse(e))?x(`${t} must be an ISO-8601 timestamp`):{ok:!0,value:e}}function Ze(e){let t=v(e,"renderedPrompt");if(!t.ok)return t;if(!ce(t.value,["title","body","format"]))return x("renderedPrompt contains an unknown field");let n=$(t.value.title,"renderedPrompt.title");if(!n.ok)return n;if(!/[^\p{White_Space}]/u.test(n.value))return x("renderedPrompt.title must contain non-whitespace text");if(!ze(n.value,Je))return x(`renderedPrompt.title must contain at most ${Je} code points`);let o={title:n.value};if(t.value.body!==void 0){if(typeof t.value.body!="string")return x("renderedPrompt.body must be a string");if(!ze(t.value.body,Ye))return x(`renderedPrompt.body must contain at most ${Ye} code points`);o.body=t.value.body}if(t.value.format!==void 0){if(t.value.format!=="plain"&&t.value.format!=="markdown")return x("renderedPrompt.format is invalid");o.format=t.value.format}return{ok:!0,value:o}}function ze(e,t){let n=0,o=e[Symbol.iterator]();for(;!o.next().done;)if(n+=1,n>t)return!1;return!0}function Qs(e){let t=Ze(e);return t.ok?s(t.value):r(t.reason)}function yn(e){try{return dn(e)?s(e):r("Human Input spec shape is invalid")}catch{return r("Human Input spec shape is invalid")}}function xn(e){let t=yn(e);return t.ok?t:x(t.reason)}function In(e){if(e==null)return{ok:!0,value:void 0};let t=v(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 x("partiallyRenderedDelivery.actions must be an array");let o=[];for(let a of n){let u=v(a,"delivery action");if(!u.ok)return u;let c=$(u.value.id,"delivery action id");if(!c.ok)return c;let d=et(u.value.inputs,`delivery action '${c.value}' inputs`);if(!d.ok)return d;o.push({id:c.value,inputs:d.value})}return{ok:!0,value:{actions:o}}}function et(e,t){let n=v(e,t);if(!n.ok)return n;let o={};for(let[a,u]of Object.entries(n.value)){let c=tt(u,`${t}.${a}`);if(!c.ok)return c;o[a]=c.value}return{ok:!0,value:o}}function tt(e,t){let n=v(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 a=$(n.value.path,`${t}.path`);return a.ok?{ok:!0,value:{kind:"human_input_ref",path:a.value}}:a}case"array":{if(!Array.isArray(n.value.items))return x(`${t}.items must be an array`);let a=[];for(let[u,c]of n.value.items.entries()){let d=tt(c,`${t}[${u}]`);if(!d.ok)return d;a.push(d.value)}return{ok:!0,value:{kind:"array",items:a}}}case"object":{let a=et(n.value.entries,`${t}.entries`);return a.ok?{ok:!0,value:{kind:"object",entries:a.value}}:a}case"template":{if(!Array.isArray(n.value.parts))return x(`${t}.parts must be an array`);let a=[];for(let[u,c]of n.value.parts.entries()){let d=kn(c,`${t}.parts[${u}]`);if(!d.ok)return d;a.push(d.value)}return{ok:!0,value:{kind:"template",parts:a}}}default:return x(`${t}.kind is invalid`)}}function kn(e,t){let n=v(e,t);if(!n.ok)return n;let o=n.value.kind;if(o==="literal")return typeof n.value.value!="string"?x(`${t}.value must be a string`):{ok:!0,value:{kind:"literal",value:n.value.value}};if(o==="human_input_ref"){let a=$(n.value.path,`${t}.path`);return a.ok?{ok:!0,value:{kind:"human_input_ref",path:a.value}}:a}return x(`${t}.kind is invalid`)}function Zs(e){let t=v(e,"request body");if(!t.ok)return r(t.reason);let n=Object.keys(t.value).find(N=>!["executionLease","nodeId","renderedPrompt","input","partiallyRenderedDelivery","timeout","expiresAt"].includes(N));if(n!==void 0)return r(`human input body does not accept the "${n}" field`);let o=y(t.value.executionLease);if(!o.ok)return r(o.reason);let a=$(t.value.nodeId,"nodeId");if(!a.ok)return r(a.reason);let u=Ze(t.value.renderedPrompt);if(!u.ok)return r(u.reason);let c=xn(t.value.input);if(!c.ok)return r(c.reason);let d=$(t.value.timeout,"timeout");if(!d.ok)return r(d.reason);let f=Rn(t.value.expiresAt,"expiresAt");if(!f.ok)return r(f.reason);let l=In(t.value.partiallyRenderedDelivery);return l.ok?s({executionLease:o.value,nodeId:a.value,renderedPrompt:u.value,input:c.value,timeout:d.value,expiresAt:f.value,...l.value!==void 0?{partiallyRenderedDelivery:l.value}:{}}):r(l.reason)}function En(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"):s(e)}function ea(e){if(!i(e)||typeof e.created!="boolean")return r("human input create data must carry created:boolean");let t=En(e.request);return t.ok?s({created:e.created,request:t.value}):t}function ta(e){return!i(e)||e.acknowledged!==!0?r("human input acknowledge data must carry acknowledged:true"):s({acknowledged:!0})}var ra="ablehi-wfp-user-runtime-manifest/v1",oa="unknown";function ia(e){return e.endsWith(".js")?`${e.slice(0,-3)}.manifest.json`:`${e}.manifest.json`}var aa="/internal/deployment-handshake",hn=["start","terminate","send-event","start-webhook-watcher","run-polling-tick","invoke-tool","invoke-discovery","invoke-trigger-handler","invoke-webhook-protocol-adapter","deployment-handshake"],ua=hn,ca="HANDSHAKE_REQUEST_INVALID",da="HANDSHAKE_SECRET_UNCONFIGURED",pa="HANDSHAKE_SECRET_MISMATCH",la="HANDSHAKE_CONTRACT_VERSION_MISMATCH",fa="HANDSHAKE_DISPATCH_NAMESPACE_MISMATCH",ga="HANDSHAKE_CAPABILITY_MISSING";function ma(e){return[e.nonce,e.timestamp,e.contractVersion,e.dispatchNamespace].map(n=>`${n.length}:${n}`).join(".")}function Ra(e){return["response",e.nonce,e.contractVersion,e.dispatchNamespace,...e.capabilities].map(n=>`${n.length}:${n}`).join(".")}function Ia(e){if(!i(e)||e.ok!==!1||!i(e.error))return r("Server execution error envelope is invalid");let t=Object.keys(e).find(a=>a!=="ok"&&a!=="error"&&a!=="guidance"),n=e.error,o=Object.keys(n).find(a=>a!=="code"&&a!=="message"&&a!=="retryable"&&a!=="issues"&&a!=="details");return t!==void 0||o!==void 0||typeof n.code!="string"||n.code.length===0||typeof n.message!="string"||typeof n.retryable!="boolean"||n.issues!==void 0&&!Array.isArray(n.issues)||n.details!==void 0&&!i(n.details)?r("Server execution error must carry code, message, and boolean retryable"):s(e)}var nt="workflow.action-transform.v1",wa="/:flowRunId/nodes/:nodeId/action-transform",_n=1048576;function Ta(e,t){return`/internal/flow-runs/${encodeURIComponent(e)}/nodes/${encodeURIComponent(t)}/action-transform`}function ba(e){return Ae(new TextEncoder().encode(ye(e)))}function wn(e){return Ae(new TextEncoder().encode([e.flowRunId,e.generationId,e.nodeId,e.operation,String(e.attempt),e.valueDigest].join("\0")))}function Pa(e){if(!i(e)||!de(e,["schemaVersion","executionLease","serverTransformRef","operation","attempt","idempotencyIdentity","valueDigest","value"]))return r("action transform request shape is invalid");if(e.schemaVersion!==nt)return r("action transform schemaVersion is unsupported");let t=y(e.executionLease);if(!t.ok)return r(t.reason);if(!W(e.serverTransformRef))return r("serverTransformRef must be a non-empty string");let n=e.operation;if(!ot(n))return r("action transform operation is invalid");let o=e.attempt;if(!Ln(n,o))return r(n==="input"?"input transform attempt must be 0":"output and error transform attempt must be a positive integer");if(!Se(e.valueDigest)||!Se(e.idempotencyIdentity))return r("action transform digests must be lowercase SHA-256 hex");let a=rt(n,e.value);if(!a.ok)return a;if(a.digest!==e.valueDigest)return r("action transform valueDigest does not match value");let u=t.value.anchor.kind==="node"?t.value.anchor.nodeId:void 0;return u===void 0?r("action transform lease anchor must be a node"):wn({flowRunId:t.value.flowRunId,generationId:t.value.generationId,nodeId:u,operation:n,attempt:o,valueDigest:a.digest})!==e.idempotencyIdentity?r("action transform idempotencyIdentity is invalid"):s({schemaVersion:nt,executionLease:t.value,serverTransformRef:e.serverTransformRef,operation:n,attempt:o,idempotencyIdentity:e.idempotencyIdentity,valueDigest:a.digest,value:e.value})}function Ca(e){if(!i(e)||!de(e,["operation","valueDigest","value"]))return r("action transform data shape is invalid");let t=e.operation;if(!ot(t)||!Se(e.valueDigest))return r("action transform data operation or digest is invalid");let n=rt(t,e.value);return n.ok?n.digest!==e.valueDigest?r("action transform response valueDigest does not match value"):s({operation:t,valueDigest:n.digest,value:e.value}):n}function rt(e,t){let n;try{n=ye(t)}catch(o){return{ok:!1,reason:`action transform value must be JSON: ${o instanceof Error?o.message:String(o)}`}}return new TextEncoder().encode(n).byteLength>_n?{ok:!1,reason:"action transform value exceeds 1048576 bytes"}:e==="error"&&!Tn(t)?{ok:!1,reason:"error transform value is invalid"}:{ok:!0,digest:Ae(new TextEncoder().encode(n))}}function Tn(e){return!(!i(e)||!De(e,["code","error","data"])||!W(e.code)||e.error!==void 0&&(!bn(e.error)||e.error.code!==e.code))}function bn(e){return!i(e)||!Fn(e,["source","scope","subject","attempt","code","category","retryable","occurredAt","evidence"],["source","scope","subject","code","occurredAt"])||!Pn(e.source)||e.scope!=="flow_step"&&e.scope!=="integration_invocation"||!Sn(e.subject)||!W(e.code)||!W(e.occurredAt)||e.attempt!==void 0&&(!i(e.attempt)||!de(e.attempt,["number"])||!Dn(e.attempt.number))||e.category!==void 0&&!An(e.category)||e.retryable!==void 0&&typeof e.retryable!="boolean"?!1:e.evidence===void 0||i(e.evidence)}function Pn(e){return i(e)&&de(e,["project","component"])&&(e.project==="ablehi-server"||e.project==="ablehi-cf-execution-runtime"||e.project==="agentIntegrations")&&W(e.component)}var Cn=["workspaceId","flowId","flowVersionId","flowRunId","stepId","nodeId","integrationId","actionId","toolRef","connectionId","requestId","traceRef"];function Sn(e){return i(e)&&De(e,Cn)&&Object.values(e).every(W)}function An(e){return["validation","auth","permission","not_found","rate_limit","provider","network","runtime","internal","canceled"].includes(e)}function Dn(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0}function Ae(e){let t=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),n=e.byteLength*8,o=Math.ceil((e.byteLength+9)/64)*64,a=new Uint8Array(o);a.set(e),a[e.byteLength]=128;let u=new DataView(a.buffer);u.setUint32(o-8,Math.floor(n/4294967296),!1),u.setUint32(o-4,n>>>0,!1);let c=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),d=new Uint32Array(64);for(let f=0;f<o;f+=64){for(let R=0;R<16;R+=1)d[R]=u.getUint32(f+R*4,!1);for(let R=16;R<64;R+=1){let ne=d[R-15],ge=d[R-2];d[R]=Nn(ge)+d[R-7]+On(ne)+d[R-16]>>>0}let l=c[0],N=c[1],G=c[2],le=c[3],F=c[4],ee=c[5],te=c[6],fe=c[7];for(let R=0;R<64;R+=1){let ne=fe+vn(F)+(F&ee^~F&te)+t[R]+d[R]>>>0,ge=Un(l)+(l&N^l&G^N&G)>>>0;fe=te,te=ee,ee=F,F=le+ne>>>0,le=G,G=N,N=l,l=ne+ge>>>0}c[0]=c[0]+l>>>0,c[1]=c[1]+N>>>0,c[2]=c[2]+G>>>0,c[3]=c[3]+le>>>0,c[4]=c[4]+F>>>0,c[5]=c[5]+ee>>>0,c[6]=c[6]+te>>>0,c[7]=c[7]+fe>>>0}return[...c].map(f=>f.toString(16).padStart(8,"0")).join("")}function C(e,t){return e>>>t|e<<32-t}function On(e){return C(e,7)^C(e,18)^e>>>3}function Nn(e){return C(e,17)^C(e,19)^e>>>10}function Un(e){return C(e,2)^C(e,13)^C(e,22)}function vn(e){return C(e,6)^C(e,11)^C(e,25)}function ot(e){return e==="input"||e==="output"||e==="error"}function Ln(e,t){return typeof t=="number"&&Number.isSafeInteger(t)&&(e==="input"?t===0:t>=1)}function Se(e){return typeof e=="string"&&/^[0-9a-f]{64}$/.test(e)}function W(e){return typeof e=="string"&&e.length>0}function de(e,t){let n=Object.keys(e).sort(),o=[...t].sort();return n.length===o.length&&n.every((a,u)=>a===o[u])}function De(e,t){return Object.keys(e).every(n=>t.includes(n))}function Fn(e,t,n){return De(e,t)&&n.every(o=>o in e)}import{isKnownErrorCode as Bn}from"@ablehi/error-contract";function Hn(e,t){if(!i(e)||!st(e,["ok","data"])||e.ok!==!0)return r("execution success envelope shape is invalid");let n=t(e.data);return n.ok?s({ok:!0,data:n.value}):r(n.reason)}function qn(e){return!i(e)||!st(e,["ok","error"])||e.ok!==!1||!i(e.error)||!Mn(e.error,["code","requestId","details"])||!Vn(e.error,"code")||!Bn(e.error.code)||e.error.requestId!==void 0&&!$n(e.error.requestId)||e.error.details!==void 0&&!i(e.error.details)?r("execution error envelope shape is invalid"):s({ok:!1,error:{code:e.error.code,...e.error.requestId===void 0?{}:{requestId:e.error.requestId},...e.error.details===void 0?{}:{details:e.error.details}}})}function it(e,t){return i(e)&&e.ok===!0?Hn(e,t):qn(e)}function st(e,t){let n=Object.keys(e).sort(),o=[...t].sort();return n.length===o.length&&n.every((a,u)=>a===o[u])}function Mn(e,t){return Object.keys(e).every(n=>t.includes(n))}function Vn(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function $n(e){return typeof e=="string"&&e.length>0}import{isKnownErrorCode as Wn}from"@ablehi/error-contract";var Kn="/internal/execution-runtime/releases",La="x-ablehi-execution-release-token",Fa="/release-probe";function K(e){return`${Kn}/${encodeURIComponent(e)}`}function Ba(e){return`${K(e)}/quiesce`}function Ha(e){return`${K(e)}/drain`}function qa(e){return`${K(e)}/probe`}function Ma(e){return`${K(e)}/complete`}function Va(e){return`${K(e)}/rollback`}function $a(e){return`${K(e)}/resume`}function Wa(e){if(!i(e)||!m(e,["releaseId","environment","expectedContractVersion","previous"])||!T(e.releaseId)||!at(e.environment)||e.expectedContractVersion!==D)return r("execution runtime release create request is invalid");let t=L(e.previous);return t.ok?s({releaseId:e.releaseId,environment:e.environment,expectedContractVersion:D,previous:t.value}):t}function Ka(e){if(!i(e)||!m(e,["deployed"]))return r("execution runtime release complete request is invalid");let t=L(e.deployed);return t.ok?s({deployed:t.value}):t}function Ga(e){if(!i(e)||!m(e,["observed"]))return r("execution runtime release probe request is invalid");let t=L(e.observed);return t.ok?s({observed:t.value}):t}function ja(e){return!i(e)||!m(e,["releaseId","nonce","expectedContractVersion","probeScriptName","probeArtifactDigest"])||!T(e.releaseId)||!T(e.nonce)||e.expectedContractVersion!==D||!T(e.probeScriptName)||!pe(e.probeArtifactDigest)?r("execution runtime probe request is invalid"):s({releaseId:e.releaseId,nonce:e.nonce,expectedContractVersion:D,probeScriptName:e.probeScriptName,probeArtifactDigest:e.probeArtifactDigest})}function Xa(e){if(!i(e))return r("execution runtime release rollback request is invalid");if(e.phase==="begin"&&m(e,["phase","failure"])&&i(e.failure)&&m(e.failure,["code","at","detailDigest"])&&Wn(e.failure.code)&&Qn(e.failure.at)&&pe(e.failure.detailDigest))return s({phase:"begin",failure:{code:e.failure.code,at:e.failure.at,detailDigest:e.failure.detailDigest}});if(e.phase==="complete"&&m(e,["phase","rolledBack"])){let t=L(e.rolledBack);return t.ok?s({phase:"complete",rolledBack:t.value}):t}return r("execution runtime release rollback request is invalid")}function Ja(e){return i(e)&&m(e,[])?s({}):r("execution runtime release resume request is invalid")}function Ya(e){return i(e)&&m(e,["releaseId","mode","status"])&&T(e.releaseId)&&ut(e.mode)&&(e.status==="created"||e.status==="retrying")?s({releaseId:e.releaseId,mode:e.mode,status:e.status}):r("execution runtime release create data is invalid")}function za(e){return i(e)&&m(e,["status"])&&e.status==="quiescing"?s({status:"quiescing"}):r("execution runtime release quiesce data is invalid")}function Qa(e){let t=["queuedRunDispatches","queuedTriggerDeliveries","activeActionClaims","activeFlowInstances","activeWatcherInstances","activeWebhookInvocations","activePollingTicks"];return!i(e)||!m(e,["status",...t,"deadlineAt"])||e.status!=="draining"&&e.status!=="ready"||!t.every(n=>Xn(e[n]))||!jn(e.deadlineAt)?r("execution runtime drain data is invalid"):s({status:e.status,queuedRunDispatches:e.queuedRunDispatches,queuedTriggerDeliveries:e.queuedTriggerDeliveries,activeActionClaims:e.activeActionClaims,activeFlowInstances:e.activeFlowInstances,activeWatcherInstances:e.activeWatcherInstances,activeWebhookInvocations:e.activeWebhookInvocations,activePollingTicks:e.activePollingTicks,deadlineAt:e.deadlineAt})}function Za(e){if(!i(e)||!m(e,["status","deployed"])||e.status!=="succeeded")return r("execution runtime release complete data is invalid");let t=L(e.deployed);return t.ok?s({status:"succeeded",deployed:t.value}):t}function eu(e){if(!i(e)||!m(e,["releaseId","environment","mode","status","gateState","previous","recoveryDisposition"])||!T(e.releaseId)||!at(e.environment)||!ut(e.mode)||!Jn(e.status)||!Yn(e.gateState)||!zn(e.recoveryDisposition))return r("execution runtime release status data is invalid");let t=L(e.previous);return t.ok?s({releaseId:e.releaseId,environment:e.environment,mode:e.mode,status:e.status,gateState:e.gateState,previous:t.value,recoveryDisposition:e.recoveryDisposition}):t}function Gn(e){return!i(e)||!m(e,["contractVersion","mainVersionId","outboundVersionId","dispatchNamespace","probeArtifactDigest","capabilityEchoDigest"])||e.contractVersion!==D||!T(e.mainVersionId)||!T(e.outboundVersionId)||!T(e.dispatchNamespace)||!pe(e.probeArtifactDigest)||!pe(e.capabilityEchoDigest)?r("execution runtime probe data is invalid"):s({contractVersion:D,mainVersionId:e.mainVersionId,outboundVersionId:e.outboundVersionId,dispatchNamespace:e.dispatchNamespace,probeArtifactDigest:e.probeArtifactDigest,capabilityEchoDigest:e.capabilityEchoDigest})}function tu(e){if(!i(e)||!m(e,["target","probe"])||e.target!=="candidate"&&e.target!=="previous")return r("execution runtime release probe data is invalid");let t=Gn(e.probe);return t.ok?s({target:e.target,probe:t.value}):t}function nu(e){if(!i(e))return r("execution runtime release rollback data is invalid");if(e.disposition==="rollback"&&e.status==="rolling_back"&&m(e,["disposition","previous","status"])){let t=L(e.previous);return t.ok?s({disposition:"rollback",previous:t.value,status:"rolling_back"}):t}return e.disposition==="fix_forward"&&e.status==="failed"&&m(e,["disposition","status"])?s({disposition:"fix_forward",status:"failed"}):e.disposition==="rolled_back"&&e.status==="rolled_back"&&m(e,["disposition","status"])?s({disposition:"rolled_back",status:"rolled_back"}):r("execution runtime release rollback data is invalid")}function ru(e){return i(e)&&m(e,["status"])&&e.status==="open"?s({status:"open"}):r("execution runtime release resume data is invalid")}function L(e){return i(e)&&m(e,["mainVersionId","outboundVersionId"])&&T(e.mainVersionId)&&T(e.outboundVersionId)?s({mainVersionId:e.mainVersionId,outboundVersionId:e.outboundVersionId}):r("execution runtime version pair is invalid")}function m(e,t){let n=Object.keys(e).sort(),o=[...t].sort();return n.length===o.length&&n.every((a,u)=>a===o[u])}function T(e){return typeof e=="string"&&e.length>0}function pe(e){return typeof e=="string"&&/^[a-f0-9]{64}$/.test(e)}function jn(e){return typeof e=="string"&&Number.isFinite(Date.parse(e))&&new Date(e).toISOString()===e}function Xn(e){return Number.isSafeInteger(e)&&e>=0}function at(e){return e==="staging"||e==="production"}function ut(e){return e==="bootstrap_cutover"||e==="paired_release"}function Jn(e){return e==="created"||e==="quiescing"||e==="deploying"||e==="verifying"||e==="succeeded"||e==="rolling_back"||e==="rolled_back"||e==="failed"}function Yn(e){return e==="open"||e==="quiescing"||e==="closed"}function zn(e){return e==="rollback"||e==="fix_forward"||e==="resume"||e==="none"}function Qn(e){return e==="outbound_deploy"||e==="main_deploy"||e==="candidate_probe"}import{parseAblehiErrorDigest as Oe}from"@ablehi/error-contract";function cu(e,t){return`${ct(e,t)}/claim`}function du(e,t){return`${ct(e,t)}/finish`}function pu(e){return`${e.flowRunId}:${e.nodeId}:attempt:${e.attempt}`}function lu(e){if(!i(e)||!_(e,["executionLease","nodeId","attempt"])||!Zn(e.nodeId)||!Ne(e.attempt))return r("action invocation claim request shape is invalid");let t=y(e.executionLease);return t.ok?t.value.anchor.kind!=="node"||t.value.anchor.nodeId!==e.nodeId?r("action invocation claim lease anchor is invalid"):s({executionLease:t.value,nodeId:e.nodeId,attempt:e.attempt}):t}function fu(e){if(!i(e)||!Ne(e.claimEpoch))return r("action invocation finish request shape is invalid");let t=y(e.executionLease);if(!t.ok)return t;if(e.outcome==="succeeded"&&_(e,["executionLease","claimEpoch","outcome","output"])){let n=h(e.output);return!n.ok||n.value.kind!=="node_output"?r("action invocation output ref is invalid"):s({executionLease:t.value,claimEpoch:e.claimEpoch,outcome:"succeeded",output:n.value})}if(e.outcome==="failed"&&_(e,["executionLease","claimEpoch","outcome","error"])){let n=Oe(e.error);return n.ok?s({executionLease:t.value,claimEpoch:e.claimEpoch,outcome:"failed",error:n.value}):r(n.reason)}return r("action invocation finish outcome is invalid")}function gu(e){if(!i(e))return r("action invocation claim data must be an object");switch(e.disposition){case"execute":return _(e,["disposition","claimEpoch","claimExpiresAt"])&&Ne(e.claimEpoch)&&er(e.claimExpiresAt)?s({disposition:"execute",claimEpoch:e.claimEpoch,claimExpiresAt:e.claimExpiresAt}):r("action invocation execute data is invalid");case"reuse":{if(!_(e,["disposition","output"]))return r("action invocation reuse data is invalid");let t=h(e.output);return t.ok&&t.value.kind==="node_output"?s({disposition:"reuse",output:t.value}):r("action invocation reuse output is invalid")}case"retry_later":return _(e,["disposition","retryAfterMs"])&&dt(e.retryAfterMs)?s({disposition:"retry_later",retryAfterMs:e.retryAfterMs}):r("action invocation retry data is invalid");case"failed":{if(!_(e,["disposition","error"]))return r("action invocation failed data is invalid");let t=Oe(e.error);return t.ok?s({disposition:"failed",error:t.value}):r(t.reason)}case"outcome_unknown":return _(e,["disposition","errorCode"])&&e.errorCode==="ACTION_OUTCOME_UNKNOWN"?s({disposition:"outcome_unknown",errorCode:"ACTION_OUTCOME_UNKNOWN"}):r("action invocation unknown outcome data is invalid");default:return r("action invocation claim disposition is invalid")}}function mu(e){if(!i(e))return r("action invocation finish data must be an object");if(e.disposition==="succeeded"&&_(e,["disposition","output"])){let t=h(e.output);return t.ok&&t.value.kind==="node_output"?s({disposition:"succeeded",output:t.value}):r("action invocation succeeded output is invalid")}if(e.disposition==="in_progress"&&_(e,["disposition","retryAfterMs"])&&dt(e.retryAfterMs))return s({disposition:"in_progress",retryAfterMs:e.retryAfterMs});if(e.disposition==="outcome_unknown"&&_(e,["disposition","errorCode"])&&e.errorCode==="ACTION_OUTCOME_UNKNOWN")return s({disposition:"outcome_unknown",errorCode:"ACTION_OUTCOME_UNKNOWN"});if(e.disposition==="failed"&&_(e,["disposition","error"])){let t=Oe(e.error);return t.ok?s({disposition:"failed",error:t.value}):r(t.reason)}return r("action invocation finish disposition is invalid")}function ct(e,t){return`/internal/flow-runs/${encodeURIComponent(e)}/action-invocations/${encodeURIComponent(t)}`}function _(e,t){let n=Object.keys(e).sort(),o=[...t].sort();return n.length===o.length&&n.every((a,u)=>a===o[u])}function Ne(e){return Number.isSafeInteger(e)&&e>0}function dt(e){return Number.isSafeInteger(e)&&e>=0}function Zn(e){return typeof e=="string"&&e.length>0}function er(e){return typeof e=="string"&&Number.isFinite(Date.parse(e))&&new Date(e).toISOString()===e}var Iu="/start";function ku(e){if(!i(e)||!Ue(e,["flowRunId","instanceId","metadata","serverCallbackBaseUrl"])||!A(e.flowRunId)||!A(e.instanceId)||!rr(e.serverCallbackBaseUrl))return r("workflow dispatch start request is invalid");let t=nr(e.metadata);return t.ok?s({flowRunId:e.flowRunId,instanceId:e.instanceId,metadata:t.value,serverCallbackBaseUrl:e.serverCallbackBaseUrl}):t}function tr(e){return i(e)&&Ue(e,["instanceId"])&&A(e.instanceId)?s({instanceId:e.instanceId}):r("workflow dispatch start data is invalid")}function Eu(e){return it(e,tr)}function nr(e){return!i(e)||!Ue(e,["workspaceId","flowId","flowVersionId","compiledArtifactId","scriptName"])||!A(e.workspaceId)||!A(e.flowId)||!A(e.flowVersionId)||!A(e.compiledArtifactId)||!A(e.scriptName)?r("flow run dispatch metadata is invalid"):s({workspaceId:e.workspaceId,flowId:e.flowId,flowVersionId:e.flowVersionId,compiledArtifactId:e.compiledArtifactId,scriptName:e.scriptName})}function Ue(e,t){let n=Object.keys(e).sort(),o=[...t].sort();return n.length===o.length&&n.every((a,u)=>a===o[u])}function A(e){return typeof e=="string"&&e.length>0}function rr(e){if(!A(e))return!1;try{let t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}}export{Fr as ACTION_INVOCATION_CLAIM_TTL_SECONDS,wa as ACTION_TRANSFORM_ROUTE_SUBPATH,nt as ACTION_TRANSFORM_SCHEMA_VERSION,Ro as COMPLETE_EVENT_WAIT_ROUTE_SUBPATH,ar as CONTEXT_STATE_CLEANUP_ROUTE_PATH,hn as DEPLOYMENT_HANDSHAKE_DISPATCHER_CAPABILITIES,ua as DEPLOYMENT_HANDSHAKE_REQUIRED_CAPABILITIES,aa as DEPLOYMENT_HANDSHAKE_ROUTE,Di as DISCOVERY_INVOCATION_EGRESS_GRANT_ROUTE_SUBPATH,ss as DISCOVERY_INVOCATION_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,vi as EGRESS_GRANT_AUDIT_ROUTE_SUBPATH,Ui as EGRESS_GRANT_CONSUME_ROUTE_SUBPATH,tn as EGRESS_GRANT_SCOPE_KINDS,Or as EXECUTION_BOOTSTRAP_MAX_BYTES,Dr as EXECUTION_COMPILED_BOOTSTRAP_MAX_BYTES,Rt as EXECUTION_CONTEXT_MAX_BYTES,to as EXECUTION_CONTEXT_ROUTE_SUBPATH,Ir as EXECUTION_LEASE_INVALID,fr as EXECUTION_LEASE_ROUTE_SUBPATH,kr as EXECUTION_LEASE_SUPERSEDED,kt as EXECUTION_PAYLOAD_KINDS,Le as EXECUTION_PAYLOAD_REF_SCHEMA_VERSION,It as EXECUTION_PAYLOAD_RESERVATIONS_ROUTE,Lr as EXECUTION_PAYLOAD_RESERVATION_TTL_SECONDS,Hr as EXECUTION_PAYLOAD_TRIGGER_RESULTS_RESOLVE_ROUTE,Nr as EXECUTION_REF_CALLBACK_MAX_BYTES,Br as EXECUTION_RELEASE_DRAIN_SECONDS,Fa as EXECUTION_RUNTIME_PROBE_ROUTE,Kn as EXECUTION_RUNTIME_RELEASES_ROUTE,La as EXECUTION_RUNTIME_RELEASE_TOKEN_HEADER,yt as EXECUTION_VALUE_MAX_BYTES,Cs as FILE_ACCESS_ROUTE_SUBPATH,Ps as FILE_COMPLETE_ROUTE_SUBPATH,As as FILE_CONTENT_ROUTE_SUBPATH,Ss as FILE_STAT_ROUTE_SUBPATH,bs as FILE_UPLOAD_SESSION_ROUTE_SUBPATH,Si as FLOW_RUN_EGRESS_GRANT_ROUTE_SUBPATH,go as FLOW_RUN_EXECUTION_EVENTS_ROUTE_SUBPATH,fo as FLOW_RUN_RESULT_ROUTE_SUBPATH,os as FLOW_RUN_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,Uo as HANDLER_BUNDLES_ROUTE_SUBPATH,ga as HANDSHAKE_CAPABILITY_MISSING,la as HANDSHAKE_CONTRACT_VERSION_MISMATCH,fa as HANDSHAKE_DISPATCH_NAMESPACE_MISMATCH,ca as HANDSHAKE_REQUEST_INVALID,pa as HANDSHAKE_SECRET_MISMATCH,da as HANDSHAKE_SECRET_UNCONFIGURED,$s as HUMAN_INPUTS_ROUTE_SUBPATH,Gs as HUMAN_INPUT_ACKNOWLEDGE_ROUTE_SUBPATH,hr as HUMAN_INPUT_CANCELLED_BY_RESET,Ks as HUMAN_INPUT_EXPIRE_ROUTE_SUBPATH,Ye as HUMAN_INPUT_PROMPT_BODY_MAX_CODE_POINTS,Je as HUMAN_INPUT_PROMPT_TITLE_MAX_CODE_POINTS,Ws as HUMAN_INPUT_REQUEST_ROUTE_SUBPATH,ln as HUMAN_INPUT_RESOLVED_EVENT_PREFIX,Ur as HUMAN_WAIT_EVENT_INPUT_MAX_BYTES,Pe as INTERNAL_DISCOVERY_INVOCATIONS_ROUTE_PREFIX,Ge as INTERNAL_EGRESS_GRANTS_ROUTE_PREFIX,V as INTERNAL_FILES_ROUTE_PREFIX,I as INTERNAL_FLOW_RUNS_ROUTE_PREFIX,Bt as INTERNAL_FLOW_VERSIONS_ROUTE_PREFIX,he as INTERNAL_INSTALLATIONS_ROUTE_PREFIX,Y as INTERNAL_POLLING_TRIGGER_INSTANCES_ROUTE_PREFIX,be as INTERNAL_TOOL_INVOCATIONS_ROUTE_PREFIX,X as INTERNAL_WEBHOOK_TRIGGER_INSTANCES_ROUTE_PREFIX,mi as POLLING_TRIGGER_CONTEXT_ROUTE_SUBPATH,Oi as POLLING_TRIGGER_EGRESS_GRANT_ROUTE_SUBPATH,Ri as POLLING_TRIGGER_HANDLER_BUNDLES_ROUTE_SUBPATH,as as POLLING_TRIGGER_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,yi as POLLING_TRIGGER_TICK_EVENTS_ROUTE_SUBPATH,vr as PUBLIC_INGRESS_ENVELOPE_OVERHEAD_BYTES,mo as REGISTER_EVENT_WAIT_ROUTE_SUBPATH,gs as RUNTIME_CREDENTIAL_SESSION_SCOPE_KINDS,Ut as RUNTIME_REPORTED_EXECUTION_EVENT_TYPES,xr as RUN_DISPATCH_UNAVAILABLE,xt as RUN_INPUT_MAX_BYTES,D as SERVER_EXECUTION_CONTRACT_VERSION,lo as STEP_RESULT_ROUTE_SUBPATH,vo as TOOL_HANDLER_BUNDLES_ROUTE_SUBPATH,Ai as TOOL_INVOCATION_EGRESS_GRANT_ROUTE_SUBPATH,is as TOOL_INVOCATION_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,Er as WAIT_EXECUTION_SUPERSEDED,ni as WEBHOOK_PROTOCOL_ADAPTER_BUNDLE_ROUTE_SUBPATH,oi as WEBHOOK_PROTOCOL_ADAPTER_MODULE,Go as WEBHOOK_TRIGGER_CONTEXT_ROUTE_SUBPATH,Xo as WEBHOOK_TRIGGER_DELIVERY_ROUTE_SUBPATH,Ni as WEBHOOK_TRIGGER_EGRESS_GRANT_ROUTE_SUBPATH,Jo as WEBHOOK_TRIGGER_EVENTS_ROUTE_SUBPATH,jo as WEBHOOK_TRIGGER_HANDLER_BUNDLES_ROUTE_SUBPATH,Yo as WEBHOOK_TRIGGER_REARM_ROUTE_SUBPATH,us as WEBHOOK_TRIGGER_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,ra as WFP_USER_RUNTIME_MANIFEST_FORMAT_VERSION,oa as WFP_USER_RUNTIME_UNKNOWN_SOURCE_REVISION,Rr as WORKFLOW_RESTART_INSTANCE_UNAVAILABLE,yr as WORKFLOW_RESTART_REJECTED,mr as WORKFLOW_RESTART_REQUEST_INVALID,gr as WORKFLOW_RESTART_ROUTE,Iu as WORKFLOW_START_ROUTE,_r as acquireExecutionLeasePath,cu as actionInvocationClaimPath,du as actionInvocationFinishPath,pu as actionInvocationId,wn as actionTransformIdempotencyIdentity,Ta as actionTransformPath,ba as actionTransformValueDigest,ye as canonicalizeExecutionPayload,Eo as completeEventWaitPath,ma as deploymentHandshakeProbePayload,Ra as deploymentHandshakeResponseProofPayload,Bi as discoveryInvocationEgressGrantPath,ps as discoveryInvocationRuntimeCredentialPath,Vi as egressGrantAuditPath,Mi as egressGrantConsumePath,no as executionContextPath,Mr as executionPayloadAccessPath,qr as executionPayloadCommitPath,Be as executionPayloadMaxBytes,Ma as executionRuntimeReleaseCompletePath,Ha as executionRuntimeReleaseDrainPath,K as executionRuntimeReleasePath,qa as executionRuntimeReleaseProbePath,Ba as executionRuntimeReleaseQuiescePath,$a as executionRuntimeReleaseResumePath,Va as executionRuntimeReleaseRollbackPath,Li as flowRunEgressGrantPath,Io as flowRunExecutionEventsPath,xo as flowRunResultPath,cs as flowRunRuntimeCredentialPath,ii as flowScriptProtocolAdapterModuleName,Lo as handlerBundlesPath,Xs as humanInputAcknowledgePath,js as humanInputExpirePath,Qe as humanInputRequestPath,Js as humanInputResolvedEventType,pn as humanInputsPath,Us as internalFileAccessPath,Ns as internalFileCompletePath,Ls as internalFileContentPath,vs as internalFileStatPath,Os as internalFileUploadSessionPath,Ds as internalFilesPath,q as isValidRequestDigest,Tr as parseAcquireExecutionLeaseData,wr as parseAcquireExecutionLeaseRequest,Ca as parseActionTransformData,Pa as parseActionTransformRequest,gu as parseClaimActionInvocationData,lu as parseClaimActionInvocationRequest,jr as parseCommitExecutionPayloadData,$r as parseCommitExecutionPayloadRequest,Za as parseCompleteExecutionRuntimeReleaseData,Ka as parseCompleteExecutionRuntimeReleaseRequest,So as parseCompleteFlowRunWaitBody,Do as parseCompleteFlowRunWaitData,ur as parseContextStateCleanupRequestBody,cr as parseContextStateCleanupResponseData,U as parseContextStateScope,Xr as parseCreateExecutionPayloadAccessData,Wr as parseCreateExecutionPayloadAccessRequest,Gr as parseCreateExecutionPayloadReservationData,Vr as parseCreateExecutionPayloadReservationRequest,Ya as parseCreateExecutionRuntimeReleaseData,Wa as parseCreateExecutionRuntimeReleaseRequest,Zs as parseCreateHumanInputBody,Ki as parseDiscoveryGrantBody,ys as parseDiscoveryRuntimeCredentialBody,Ji as parseEgressGrantAuditBody,Xi as parseEgressGrantConsumeBody,zi as parseEgressGrantConsumeData,Yi as parseEgressGrantData,ve as parseExecutionAnchor,ro as parseExecutionContextData,oo as parseExecutionContextPayloadData,it as parseExecutionEnvelope,qn as parseExecutionErrorEnvelope,y as parseExecutionLease,h as parseExecutionPayloadRef,Qa as parseExecutionRuntimeDrainData,Gn as parseExecutionRuntimeProbeData,ja as parseExecutionRuntimeProbeRequest,eu as parseExecutionRuntimeReleaseStatusData,Hn as parseExecutionSuccessEnvelope,un as parseFileMetadataData,ue as parseFileRefData,Ie as parseFileRuntimeLimits,an as parseFileUploadSessionData,mu as parseFinishActionInvocationData,fu as parseFinishActionInvocationRequest,$i as parseFlowActionGrantBody,Po as parseFlowRunExecutionEventBody,bo as parseFlowRunExecutionEventData,wo as parseFlowRunResultBody,To as parseFlowRunResultData,ms as parseFlowRuntimeCredentialBody,Oo as parseFlowWaitResolvedEvent,qt as parseHandlerBundle,Bo as parseHandlerBundlesData,ta as parseHumanInputAcknowledgeData,ea as parseHumanInputCreateData,En as parseHumanInputRequestViewData,Ys as parseHumanInputResolvedEvent,fn as parseHumanInputResponse,zs as parseHumanInputResponseForSpec,yn as parseHumanInputSpec,Fs as parseInternalFileAccessData,hi as parsePollingPublishBody,xs as parsePollingRuntimeCredentialBody,jt as parsePollingTriggerContext,Ei as parsePollingTriggerDispatchData,Gi as parsePollingTriggerGrantBody,tu as parseProbeExecutionRuntimeReleaseData,Ga as parseProbeExecutionRuntimeReleaseRequest,_i as parsePublishPollingTickEventsData,za as parseQuiesceExecutionRuntimeReleaseData,Co as parseRegisterFlowRunWaitBody,Ao as parseRegisterFlowRunWaitData,Qs as parseRenderedHumanInputPrompt,Jr as parseResolveCommittedTriggerPayloadData,Kr as parseResolveCommittedTriggerPayloadRequest,ru as parseResumeExecutionRuntimeReleaseData,Ja as parseResumeExecutionRuntimeReleaseRequest,nu as parseRollbackExecutionRuntimeReleaseData,Xa as parseRollbackExecutionRuntimeReleaseRequest,ks as parseRuntimeCredentialSessionCredential,se as parseRuntimeNetwork,Ia as parseServerExecutionErrorEnvelope,Wi as parseSingleToolGrantBody,Rs as parseSingleToolRuntimeCredentialBody,ho as parseStepRecordBody,_o as parseStepRecordData,Ho as parseToolHandlerBundlesData,_e as parseTriggerFileRuntimeDispatch,ui as parseTriggerHandlerBundlesData,Wt as parseWebhookDelivery,ai as parseWebhookDeliveryDispatchData,ci as parseWebhookPublishEventsBody,di as parseWebhookRearmBody,Is as parseWebhookRuntimeCredentialBody,ji as parseWebhookTriggerGrantBody,si as parseWebhookWatcherContext,br as parseWorkflowDispatchRestartRequest,Pr as parseWorkflowDispatchRestartResponse,tr as parseWorkflowDispatchStartData,ku as parseWorkflowDispatchStartRequest,Eu as parseWorkflowDispatchStartResponse,xi as pollingTriggerContextPath,Hi as pollingTriggerEgressGrantPath,Ii as pollingTriggerHandlerBundlesPath,ls as pollingTriggerRuntimeCredentialPath,ki as pollingTriggerTickEventsPath,ko as registerEventWaitPath,rn as requestHasMultipartFileParts,yo as stepResultPath,Fo as toolHandlerBundlesPath,Fi as toolInvocationEgressGrantPath,ds as toolInvocationRuntimeCredentialPath,ri as webhookProtocolAdapterBundlePath,zo as webhookTriggerContextPath,Zo as webhookTriggerDeliveryPath,qi as webhookTriggerEgressGrantPath,ei as webhookTriggerEventsPath,Qo as webhookTriggerHandlerBundlesPath,ti as webhookTriggerRearmPath,fs as webhookTriggerRuntimeCredentialPath,ia as wfpUserRuntimeManifestPath};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ablehi/server-execution-contract",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.7",
|
|
4
4
|
"description": "Ablehi server to Cloudflare execution contract.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"publishConfig": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@ablehi/ais-package-contract": "0.0.8",
|
|
32
32
|
"@ablehi/flow-contract": "0.3.2",
|
|
33
|
-
"@ablehi/error-contract": "0.0.
|
|
33
|
+
"@ablehi/error-contract": "0.0.6"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@typescript-eslint/eslint-plugin": "^8.62.0",
|