@ablehi/server-contract 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/edge.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- declare const SERVER_CONTRACT_VERSION = "0.1.4";
1
+ declare const SERVER_CONTRACT_VERSION = "0.1.5";
2
2
  type ServerContractVersion = typeof SERVER_CONTRACT_VERSION;
3
3
 
4
4
  declare const FLOW_IR_SCHEMA_VERSION = "flow.ir.v1";
package/dist/edge.js CHANGED
@@ -1 +1 @@
1
- var J="0.1.4";var Ce="flow.ir.v1";var X="flow.interp.v2";function a(e){return{ok:!0,value:e}}function o(e){return{ok:!1,reason:e}}function i(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var f="/internal/flow-runs",Fe="/:flowRunId/execution-context";function Ge(e){return`${f}/${encodeURIComponent(e)}/execution-context`}function Y(e){return!i(e)||!C(e.fileMaxBytes)||!C(e.fileReadMaxBytes)||!C(e.inlineMultipartBytesMax)?o("file runtime limits must carry three positive integer bounds"):a({fileMaxBytes:e.fileMaxBytes,fileReadMaxBytes:e.fileReadMaxBytes,inlineMultipartBytesMax:e.inlineMultipartBytesMax})}function Le(e){if(!i(e))return o("execution context must be a JSON object");let t=e.compiled;if(typeof e.flowRunId!="string"||typeof e.workspaceId!="string"||!i(e.input)||!i(t)||typeof t.irSchemaVersion!="string"||typeof t.interpreterContractVersion!="string"||typeof t.compiledArtifactId!="string"||!i(t.ir)||!Array.isArray(t.ir.nodes)||!Q(e.executionBindings))return o("execution context surface shape is invalid");let n=z(e.fileRuntime);return n.ok?a({...e,fileRuntime:n.value}):o(n.reason)}function z(e){if(e===null)return a(null);if(!i(e))return o("fileRuntime must be null or an object");let t=Y(e.limits);return t.ok?a({limits:t.value}):o(t.reason)}function Q(e){return Array.isArray(e)?e.every(t=>{if(!i(t))return!1;let n=t.connection;return typeof t.nodeId=="string"&&typeof t.toolRef=="string"&&i(t.toolDescriptor)&&i(t.integrationDescriptor)&&i(n)&&typeof n.installationId=="string"&&typeof n.connectionRef=="string"&&typeof n.connectionId=="string"&&typeof n.authType=="string"}):!1}function C(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0}var We="/:flowRunId/steps/:nodeId/result",Ve="/:flowRunId/result",qe="/:flowRunId/event-waits/:nodeId";function je(e,t){return`${f}/${encodeURIComponent(e)}/steps/${encodeURIComponent(t)}/result`}function Je(e){return`${f}/${encodeURIComponent(e)}/result`}function Xe(e,t){return`${f}/${encodeURIComponent(e)}/event-waits/${encodeURIComponent(t)}`}function Ye(e){if(!i(e))return{ok:!1,kind:"validation",reason:"step record body must be a JSON object"};let t=R(e,["attempt","result","durationMs"]);if(t!==void 0)return{ok:!1,kind:"validation",reason:`step record does not accept the "${t}" field`};let n=e.attempt;if(typeof n!="number"||!Number.isInteger(n)||n<=0)return{ok:!1,kind:"validation",reason:"attempt must be a positive integer"};let r=Z(e.result);if(!r.ok)return r;let s={attempt:n,result:r.value};if(e.durationMs!==void 0){let u=e.durationMs;if(typeof u!="number"||!Number.isFinite(u)||u<0)return{ok:!1,kind:"validation",reason:"durationMs must be a non-negative number"};s.durationMs=u}return{ok:!0,value:s}}function Z(e){if(!i(e))return{ok:!1,kind:"step_result_invalid",reason:"result must be a JSON object"};let t=e.status;if(t==="succeeded"){let n=R(e,["status","output"]);return n!==void 0?{ok:!1,kind:"validation",reason:`step record result does not accept the "${n}" field`}:"output"in e?{ok:!0,value:{status:"succeeded",output:e.output}}:{ok:!1,kind:"step_result_invalid",reason:"a succeeded result must carry output"}}if(t==="failed"){let n=R(e,["status","errorCode","issues"]);if(n!==void 0)return{ok:!1,kind:"validation",reason:`step record result does not accept the "${n}" field`};let r=e.errorCode;if(typeof r!="string"||r.length===0)return{ok:!1,kind:"step_result_invalid",reason:"a failed result must carry a non-empty errorCode"};let s={status:"failed",errorCode:r};return e.issues!==void 0&&(s.issues=e.issues),{ok:!0,value:s}}return{ok:!1,kind:"step_result_invalid",reason:'result status must be "succeeded" or "failed"'}}function ze(e){return!i(e)||typeof e.flowRunId!="string"||typeof e.nodeId!="string"||e.recorded!=="succeeded"&&e.recorded!=="failed"?o("step record data surface shape is invalid"):a({flowRunId:e.flowRunId,nodeId:e.nodeId,recorded:e.recorded})}function Qe(e){if(!i(e))return o("result body must be a JSON object");let t=R(e,["status","output","error","composition"]);if(t!==void 0)return o(`result does not accept the "${t}" field`);let n=e.status;if(n!=="succeeded"&&n!=="failed")return o('result status must be "succeeded" or "failed"');let r={status:n};if(e.output!==void 0&&(r.output=e.output),e.error!==void 0){let s=e.error;if(!i(s))return o("result error must be a JSON object");let u=R(s,["code","message"]);if(u!==void 0)return o(`result error does not accept the "${u}" field`);if(typeof s.code!="string"||typeof s.message!="string")return o("result error must carry string code and message");r.error={code:s.code,message:s.message}}if(e.composition!==void 0){if(n!=="succeeded")return o("composition is only allowed on a succeeded result");r.composition=e.composition}return a(r)}function Ze(e){return i(e)?a(e):o("flow run result data must be a JSON object")}var ee=/^[A-Za-z0-9_-]{1,100}$/;function et(e){if(!i(e))return o("register body must be a JSON object");let t=R(e,["eventType","correlationKey"]);if(t!==void 0)return o(`register wait does not accept the "${t}" field`);let n=F(e.eventType);if(!n.ok)return o(n.reason);let r=e.correlationKey;return typeof r!="string"||r.length===0?o("correlationKey must be a non-empty string"):a({eventType:n.value,correlationKey:r})}function tt(e){if(!i(e))return o("complete body must be a JSON object");let t=R(e,["eventType","correlationKey","outcome","eventId"]);if(t!==void 0)return o(`complete wait does not accept the "${t}" field`);let n=e.outcome;if(n!=="received"&&n!=="timed_out")return o('outcome must be "received" or "timed_out"');let r=F(e.eventType);if(!r.ok)return o(r.reason);let s=e.correlationKey;if(typeof s!="string"||s.length===0)return o("correlationKey must be a non-empty string");let u={eventType:r.value,correlationKey:s,outcome:n};if(e.eventId!==void 0){if(typeof e.eventId!="string"||e.eventId.length===0)return o("eventId must be a non-empty string");u.eventId=e.eventId}return a(u)}function nt(e){return!i(e)||e.registered!==!0?o("register wait data surface shape is invalid"):a({registered:!0})}function F(e){return typeof e!="string"||e.length===0?o("eventType must be a non-empty string"):ee.test(e)?a(e):o("eventType must match ^[A-Za-z0-9_-]{1,100}$")}function R(e,t){return Object.keys(e).find(n=>!t.includes(n))}var te="/internal/flow-versions",ot="/:flowVersionId/handler-bundles",B="/internal/installations",it="/:installationId/handler-bundles";function st(e,t){return`${te}/${encodeURIComponent(e)}/handler-bundles?compiledArtifactId=${encodeURIComponent(t)}`}function ut(e){return`${B}/${encodeURIComponent(e.installationId)}/handler-bundles?workspaceId=${encodeURIComponent(e.workspaceId)}&artifactDigest=${encodeURIComponent(e.artifactDigest)}`}var ne=new Set(["managed_only","managed_plus_unmanaged_sdk"]);function w(e){if(!y(e))return D("runtimeNetwork must be a JSON object");let t=e.networkModel;return typeof t!="string"||!ne.has(t)?D("runtimeNetwork.networkModel is unknown"):!G(e.apiHosts)||!G(e.authHosts)||typeof e.httpsOnly!="boolean"?D("runtimeNetwork host/https fields are invalid"):{ok:!0,value:{networkModel:t,apiHosts:e.apiHosts,authHosts:e.authHosts,httpsOnly:e.httpsOnly}}}function at(e){if(!y(e)||typeof e.flowVersionId!="string"||typeof e.compiledArtifactId!="string"||!Array.isArray(e.bundles))return _("handler bundles data surface shape is invalid");let t=L(e.bundles);return t.ok?{ok:!0,value:{flowVersionId:e.flowVersionId,compiledArtifactId:e.compiledArtifactId,bundles:t.value}}:t}function dt(e){if(!y(e)||typeof e.installationId!="string"||typeof e.artifactDigest!="string"||!Array.isArray(e.bundles))return _("tool handler bundles data surface shape is invalid");let t=L(e.bundles);return t.ok?{ok:!0,value:{installationId:e.installationId,artifactDigest:e.artifactDigest,bundles:t.value}}:t}function L(e){let t=[];for(let n of e){let r=re(n);if(!r.ok)return r;t.push(r.value)}return{ok:!0,value:t}}function re(e){if(!y(e)||typeof e.toolRef!="string"||e.kind!=="handler"&&e.kind!=="request")return _("handler bundle entry shape is invalid");if(e.kind==="request"){if(e.module!==void 0)return _("a request bundle must not carry a module");let r=w(e.runtimeNetwork);return r.ok?{ok:!0,value:{toolRef:e.toolRef,kind:"request",runtimeNetwork:r.value}}:r}let t=e.module;if(!y(t)||typeof t.entry!="string"||t.entry.length===0||!oe(t.files))return _("a handler bundle must carry a { entry, files } module");let n=w(e.runtimeNetwork);return n.ok?{ok:!0,value:{toolRef:e.toolRef,kind:"handler",module:{entry:t.entry,files:t.files},runtimeNetwork:n.value}}:n}function _(e){return{ok:!1,kind:"shape",reason:e}}function D(e){return{ok:!1,kind:"runtime_network",reason:e}}function y(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function G(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function oe(e){return y(e)&&Object.values(e).every(t=>typeof t=="string")}var E="/internal/webhook-trigger-instances",ft="/:triggerInstanceId/context",mt="/:triggerInstanceId/handler-bundles",Rt="/:triggerInstanceId/deliveries/:deliveryId",yt="/:triggerInstanceId/events",It="/:triggerInstanceId/rearm",kt="/:triggerInstanceId/store/:namespace/:key",I=e=>`${E}/${encodeURIComponent(e)}`;function _t(e,t){return`${I(e)}/context?artifactDigest=${encodeURIComponent(t)}`}function Et(e,t){return`${I(e)}/handler-bundles?artifactDigest=${encodeURIComponent(t)}`}function Tt(e,t){return`${I(e)}/deliveries/${encodeURIComponent(t)}`}function xt(e){return`${I(e)}/events`}function ht(e){return`${I(e)}/rearm`}function wt(e,t,n){return`${I(e)}/store/${encodeURIComponent(t)}/${encodeURIComponent(n)}`}var Pt="/:installationId/webhook-protocol-adapter-bundle";function Nt(e){return`${B}/${encodeURIComponent(e.installationId)}/webhook-protocol-adapter-bundle?workspaceId=${encodeURIComponent(e.workspaceId)}&artifactDigest=${encodeURIComponent(e.artifactDigest)}`}var bt="modules/webhook/protocol-adapter.js";function At(e){return`modules/webhook/protocol-adapter-${e}.js`}function St(e){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&&!ie(e.connection)||!se(e.runtime)?o("webhook watcher context surface shape is invalid"):a(e)}function ie(e){return i(e)&&typeof e.connectionId=="string"&&typeof e.connectionRef=="string"&&typeof e.integrationRef=="string"&&typeof e.authType=="string"}function se(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 vt(e){if(!i(e)||typeof e.deliveryId!="string"||typeof e.receivedAt!="string"||!i(e.request))return o("webhook delivery surface shape is invalid");let t=e.request;return t.method!=="POST"||!i(t.headers)||typeof t.rawBody!="string"?o("webhook delivery request shape is invalid"):a(e)}function Ot(e){if(!i(e)||typeof e.triggerRef!="string"||typeof e.artifactDigest!="string"||!Array.isArray(e.modules)||!e.modules.every(ue))return{ok:!1,kind:"shape",reason:"trigger handler bundles data surface shape is invalid"};let t=w(e.runtimeNetwork);return t.ok?{ok:!0,value:{triggerRef:e.triggerRef,artifactDigest:e.artifactDigest,modules:e.modules,runtimeNetwork:t.value}}:t}function ue(e){return i(e)&&typeof e.specifier=="string"&&e.specifier.length>0&&typeof e.source=="string"}function ae(e){return!i(e)||!("value"in e)?o("webhook store get surface shape is invalid"):a(e.value)}function Ct(e){if(!i(e))return o("publish events body must be a JSON object");let t=P(e,["deliveryId","events"]);if(t!==void 0)return o(`publish events does not accept the "${t}" field`);let n=e.deliveryId;if(typeof n!="string"||n.length===0)return o("deliveryId must be a non-empty string");let r=e.events;if(!Array.isArray(r))return o("events must be an array");let s=[];for(let u of r){let d=de(u);if(!d.ok)return d;s.push(d.value)}return a({deliveryId:n,events:s})}function de(e){if(!i(e))return o("each event must be a JSON object");let t=P(e,["eventId","occurredAt","dedupeKey","payload"]);if(t!==void 0)return o(`event does not accept the "${t}" field`);let n=e.eventId;if(typeof n!="string"||n.length===0)return o("eventId must be a non-empty string");let r=e.occurredAt;if(typeof r!="string"||r.length===0)return o("occurredAt must be a non-empty string");if(!i(e.payload))return o("event payload must be a JSON object");let s={eventId:n,occurredAt:r,payload:e.payload};if(e.dedupeKey!==void 0){if(typeof e.dedupeKey!="string"||e.dedupeKey.length===0)return o("dedupeKey must be a non-empty string");s.dedupeKey=e.dedupeKey}return a(s)}function Dt(e){if(!i(e))return o("rearm body must be a JSON object");let t=P(e,["expectedWatcherInstanceId"]);if(t!==void 0)return o(`rearm does not accept the "${t}" field`);let n=e.expectedWatcherInstanceId;return typeof n!="string"||n.length===0?o("expectedWatcherInstanceId must be a non-empty string"):a({expectedWatcherInstanceId:n})}function le(e){if(!i(e))return o("store body must be a JSON object");let t=P(e,["value"]);return t!==void 0?o(`store put does not accept the "${t}" field`):"value"in e?a({value:e.value}):o("store put requires a value field")}function P(e,t){return Object.keys(e).find(n=>!t.includes(n))}var T="/internal/polling-trigger-instances",Ut="/:pollingInstanceId/context",Ft="/:pollingInstanceId/handler-bundles",Gt="/:pollingInstanceId/ticks/:tickId/events",Lt="/:pollingInstanceId/store/:namespace/:key",N=e=>`${T}/${encodeURIComponent(e)}`;function Mt(e,t,n){return`${N(e)}/context?artifactDigest=${encodeURIComponent(t)}&tickId=${encodeURIComponent(n)}`}function $t(e,t){return`${N(e)}/handler-bundles?artifactDigest=${encodeURIComponent(t)}`}function Kt(e,t){return`${N(e)}/ticks/${encodeURIComponent(t)}/events`}function Wt(e,t,n){return`${N(e)}/store/${encodeURIComponent(t)}/${encodeURIComponent(n)}`}function Vt(e){return!i(e)||typeof e.artifactDigest!="string"||typeof e.triggerRef!="string"||typeof e.triggerName!="string"||typeof e.integrationRef!="string"||!i(e.inputs)||e.connection!==null&&!pe(e.connection)||!ce(e.runtime)||!ge(e.tick)||!fe(e.limits)?o("polling trigger context surface shape is invalid"):a(e)}function pe(e){return i(e)&&typeof e.connectionId=="string"&&typeof e.connectionRef=="string"&&typeof e.integrationRef=="string"&&typeof e.authType=="string"}function ce(e){if(!i(e)||e.type!=="polling"||typeof e.trigger_id!="string"||typeof e.trigger_ref!="string")return!1;let t=e.polling;if(!i(t)||typeof t.run_handler_module!="string")return!1;let n=t.schedule;if(!i(n)||n.type!=="interval"||typeof n.every_seconds!="number")return!1;let r=t.dedup;return i(r)&&(r.strategy==="cursor"||r.strategy==="hash"||r.strategy==="id_field")}function ge(e){return i(e)&&typeof e.tickId=="string"&&typeof e.scheduledAt=="string"&&typeof e.attempt=="number"}function fe(e){return i(e)&&typeof e.maxEventsPerTick=="number"}function qt(e){if(!i(e))return o("publish body must be a JSON object");let t=M(e,["events","nextCursor"]);if(t!==void 0)return o(`publish does not accept the "${t}" field`);let n=e.events;if(!Array.isArray(n))return o("events must be an array");let r=[];for(let u of n){let d=me(u);if(!d.ok)return d;r.push(d.value)}let s={events:r};if("nextCursor"in e){let u=e.nextCursor;if(u!==null&&typeof u!="string")return o("nextCursor must be a string, null, or omitted");s.nextCursor=u}return a(s)}function me(e){if(!i(e))return o("each event must be a JSON object");let t=M(e,["eventId","occurredAt","dedupeKey","payload"]);if(t!==void 0)return o(`event does not accept the "${t}" field`);if(typeof e.eventId!="string"||e.eventId.length===0)return o("event eventId must be a non-empty string");if(!i(e.payload))return o("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 o("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 o("event dedupeKey must be a non-empty string");n.dedupeKey=e.dedupeKey}return a(n)}function jt(e){return!i(e)||typeof e.tickId!="string"||typeof e.cursorUpdated!="boolean"||!Array.isArray(e.results)||!e.results.every(Re)?o("publish polling tick events data surface shape is invalid"):a(e)}function Re(e){return i(e)&&typeof e.eventId=="string"&&typeof e.dedupeKey=="string"&&typeof e.duplicate=="boolean"&&(e.flowRunId===null||typeof e.flowRunId=="string")}function M(e,t){return Object.keys(e).find(n=>!t.includes(n))}var $="/internal/egress-grants",H="/internal/tool-invocations",en="/:flowRunId/egress-grant",tn="/:invocationId/egress-grant",nn="/:pollingInstanceId/egress-grant",rn="/:triggerInstanceId/egress-grant",on="/:grantId/consume",sn="/:grantId/audit",un=e=>`${f}/${encodeURIComponent(e)}/egress-grant`,an=e=>`${H}/${encodeURIComponent(e)}/egress-grant`,dn=e=>`${T}/${encodeURIComponent(e)}/egress-grant`,ln=e=>`${E}/${encodeURIComponent(e)}/egress-grant`,pn=e=>`${$}/${encodeURIComponent(e)}/consume`,cn=e=>`${$}/${encodeURIComponent(e)}/audit`,ye=["flow_action","single_tool","polling_trigger","webhook_trigger"],Ie=/^[A-Za-z0-9][A-Za-z0-9:_+/=.-]{15,1023}$/;function x(e){return typeof e=="string"&&Ie.test(e)}function ke(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(r=>i(r)?r.kind==="file"&&typeof r.file_id=="string"&&r.file_id.length>0:!1):!1}function l(e){return{ok:!1,kind:"shape",reason:e}}function h(){return{ok:!1,kind:"request_digest",reason:"request digest is missing or malformed"}}function A(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 S(e){if(!i(e))return"request must be a JSON object"}function gn(e){let t=A(e,["nodeId","request","requestDigest"]);if(!t.ok)return l(t.reason);let n=t.record.nodeId;if(typeof n!="string"||n.length===0)return l("nodeId is required");let r=S(t.record.request);if(r!==void 0)return l(r);let s=t.record.requestDigest;return x(s)?{ok:!0,value:{nodeId:n,requestDigest:s,requestHasMultipartFiles:ke(t.record.request)}}:h()}function fn(e){let t=A(e,["request","requestDigest"]);if(!t.ok)return l(t.reason);let n=S(t.record.request);if(n!==void 0)return l(n);let r=t.record.requestDigest;return x(r)?{ok:!0,value:{requestDigest:r}}:h()}function mn(e){let t=A(e,["tickId","request","requestDigest"]);if(!t.ok)return l(t.reason);let n=t.record.tickId;if(typeof n!="string"||n.length===0)return l("tickId is required");let r=S(t.record.request);if(r!==void 0)return l(r);let s=t.record.requestDigest;return x(s)?{ok:!0,value:{tickId:n,requestDigest:s}}:h()}function Rn(e){let t=A(e,["phase","lifecycle","request","requestDigest"]);if(!t.ok)return l(t.reason);let n=t.record.phase;if(n!=="lifecycle"&&n!=="handler")return l('phase must be "lifecycle" or "handler"');let r=t.record.lifecycle,s;if(r!==void 0){if(r!=="enable"&&r!=="disable"&&r!=="renew")return l('lifecycle must be "enable", "disable", or "renew"');s=r}if(n==="lifecycle"&&s===void 0)return l("lifecycle is required for the lifecycle phase");let u=S(t.record.request);if(u!==void 0)return l(u);let d=t.record.requestDigest;return x(d)?{ok:!0,value:{phase:n,...s!==void 0?{lifecycle:s}:{},requestDigest:d}}:h()}function K(e){return ye.includes(e)?e:void 0}var _e=["scopeKind","scopeId","requestDigest"];function yn(e){if(!i(e))return l("consume body must be a JSON object");for(let s of Object.keys(e))if(!_e.includes(s))return l(`consume does not accept the "${s}" field`);let t=K(e.scopeKind);if(t===void 0)return l("scopeKind is invalid");let n=e.scopeId;if(typeof n!="string"||n.length===0)return l("scopeId is required");let r=e.requestDigest;return x(r)?{ok:!0,value:{scopeKind:t,scopeId:n,requestDigest:r}}:h()}var Ee=["scopeKind","scopeId","providerHost","status","durationMs","requestBytes","responseBytes","errorCode"];function b(e,t){return typeof e!="number"||!Number.isInteger(e)||e<0?{ok:!1,reason:`${t} must be a non-negative integer`}:{ok:!0,value:e}}function In(e){if(!i(e))return l("audit body must be a JSON object");for(let c of Object.keys(e))if(!Ee.includes(c))return l(`audit does not accept the "${c}" field`);let t=K(e.scopeKind);if(t===void 0)return l("scopeKind is invalid");let n=e.scopeId;if(typeof n!="string"||n.length===0)return l("scopeId is required");let r=e.providerHost;if(typeof r!="string"||r.length===0)return l("providerHost is required");let s=b(e.durationMs,"durationMs");if(!s.ok)return l(s.reason);let u;if(e.status!==void 0){let c=b(e.status,"status");if(!c.ok)return l(c.reason);u=c.value}let d;if(e.requestBytes!==void 0){let c=b(e.requestBytes,"requestBytes");if(!c.ok)return l(c.reason);d=c.value}let p;if(e.responseBytes!==void 0){let c=b(e.responseBytes,"responseBytes");if(!c.ok)return l(c.reason);p=c.value}let O;if(e.errorCode!==void 0){let c=e.errorCode;if(typeof c!="string"||c.length===0)return l("errorCode must be a non-empty string");O=c}return{ok:!0,value:{scopeKind:t,scopeId:n,providerHost:r,...u!==void 0?{status:u}:{},durationMs:s.value,...d!==void 0?{requestBytes:d}:{},...p!==void 0?{responseBytes:p}:{},...O!==void 0?{errorCode:O}:{}}}}function kn(e){return!i(e)||!i(e.grant)?o("egress grant envelope must carry a grant object"):a(e.grant)}function _n(e){return!i(e)||e.consumed!==!0?o("egress grant consume data must carry consumed:true"):a({consumed:!0})}var Nn="/:flowRunId/runtime-credential",bn="/:invocationId/runtime-credential",An="/:pollingInstanceId/runtime-credential",Sn="/:triggerInstanceId/runtime-credential",vn=e=>`${f}/${encodeURIComponent(e)}/runtime-credential`,On=e=>`${H}/${encodeURIComponent(e)}/runtime-credential`,Cn=e=>`${T}/${encodeURIComponent(e)}/runtime-credential`,Dn=e=>`${E}/${encodeURIComponent(e)}/runtime-credential`,Bn=["flow_action","tool_invoke","polling_trigger","webhook_trigger"];function v(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 Hn(e){let t=v(e,["nodeId"]);if(!t.ok)return o(t.reason);let n=t.record.nodeId;return typeof n!="string"||n.length===0?o("nodeId is required"):a({nodeId:n})}function Un(e){let t=v(e??{},[]);return t.ok?a(null):o(t.reason)}function Fn(e){let t=v(e,["tickId"]);if(!t.ok)return o(t.reason);let n=t.record.tickId;return typeof n!="string"||n.length===0?o("tickId is required"):a({tickId:n})}function Gn(e){let t=v(e,["executionKind","deliveryId","lifecycleOperation"]);if(!t.ok)return o(t.reason);let n=t.record.executionKind;if(n!=="event_handler"&&n!=="lifecycle")return o('executionKind must be "event_handler" or "lifecycle"');let r,s=t.record.deliveryId;if(s!==void 0){if(typeof s!="string"||s.length===0)return o("deliveryId must be a non-empty string");r=s}let u,d=t.record.lifecycleOperation;if(d!==void 0){if(d!=="enable"&&d!=="disable"&&d!=="renew")return o('lifecycleOperation must be "enable", "disable", or "renew"');u=d}return n==="lifecycle"&&u===void 0?o("lifecycleOperation is required for the lifecycle execution kind"):a({executionKind:n,...r!==void 0?{deliveryId:r}:{},...u!==void 0?{lifecycleOperation:u}:{}})}function Ln(e){return!i(e)||typeof e.sessionId!="string"||typeof e.connectionId!="string"||!i(e.credential)?o("runtime credential session must carry sessionId, connectionId and a credential object"):a(e.credential)}var U="/internal/files",Kn="/:fileId/stat",Wn="/:fileId/content",Vn=()=>U,W=e=>`?scope_kind=${encodeURIComponent(e.scopeKind)}&scope_id=${encodeURIComponent(e.scopeId)}`,qn=(e,t)=>`${U}/${encodeURIComponent(e)}/stat${W(t)}`,jn=(e,t)=>`${U}/${encodeURIComponent(e)}/content${W(t)}`;function Jn(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"?o("file ref data does not match the AIS file-ref shape"):a(e)}var Qn="/:flowRunId/human-inputs",Zn="/:flowRunId/human-inputs/:requestId",er="/:flowRunId/human-inputs/:requestId/expire",tr="/:flowRunId/human-inputs/:requestId/acknowledge",Te=e=>`${f}/${encodeURIComponent(e)}/human-inputs`,V=(e,t)=>`${Te(e)}/${encodeURIComponent(t)}`,nr=(e,t)=>`${V(e,t)}/expire`,rr=(e,t)=>`${V(e,t)}/acknowledge`,xe="human_input_resolved";function or(e){return`${xe}_${e}`}function g(e){return{ok:!1,reason:e}}function m(e,t){return i(e)?{ok:!0,value:e}:g(`${t} must be an object`)}function k(e,t){return typeof e!="string"||e.length===0?g(`${t} must be a non-empty string`):{ok:!0,value:e}}var he=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?(?:Z|[+-]\d{2}:\d{2})$/;function we(e,t){return typeof e!="string"||!he.test(e)||Number.isNaN(Date.parse(e))?g(`${t} must be an ISO-8601 timestamp`):{ok:!0,value:e}}function Pe(e){let t=m(e,"renderedPrompt");if(!t.ok)return t;let n=k(t.value.title,"renderedPrompt.title");if(!n.ok)return n;let r={title:n.value};if(t.value.body!==void 0){if(typeof t.value.body!="string")return g("renderedPrompt.body must be a string");r.body=t.value.body}if(t.value.format!==void 0){if(t.value.format!=="plain"&&t.value.format!=="markdown")return g("renderedPrompt.format is invalid");r.format=t.value.format}return{ok:!0,value:r}}function Ne(e){let t=m(e,"input");if(!t.ok)return t;let n=t.value.kind;if(n==="choice"){if(!Array.isArray(t.value.choices))return g("input.choices must be an array")}else if(n!=="text")if(n==="form"){if(!Array.isArray(t.value.fields))return g("input.fields must be an array")}else return g("input.kind is invalid");return{ok:!0,value:t.value}}function be(e){if(e==null)return{ok:!0,value:void 0};let t=m(e,"partiallyRenderedDelivery");if(!t.ok)return t;let n=t.value.actions;if(n===void 0)return{ok:!0,value:{}};if(!Array.isArray(n))return g("partiallyRenderedDelivery.actions must be an array");let r=[];for(let s of n){let u=m(s,"delivery action");if(!u.ok)return u;let d=k(u.value.id,"delivery action id");if(!d.ok)return d;let p=q(u.value.inputs,`delivery action '${d.value}' inputs`);if(!p.ok)return p;r.push({id:d.value,inputs:p.value})}return{ok:!0,value:{actions:r}}}function q(e,t){let n=m(e,t);if(!n.ok)return n;let r={};for(let[s,u]of Object.entries(n.value)){let d=j(u,`${t}.${s}`);if(!d.ok)return d;r[s]=d.value}return{ok:!0,value:r}}function j(e,t){let n=m(e,t);if(!n.ok)return n;switch(n.value.kind){case"literal":return{ok:!0,value:{kind:"literal",value:n.value.value}};case"human_input_ref":{let s=k(n.value.path,`${t}.path`);return s.ok?{ok:!0,value:{kind:"human_input_ref",path:s.value}}:s}case"array":{if(!Array.isArray(n.value.items))return g(`${t}.items must be an array`);let s=[];for(let[u,d]of n.value.items.entries()){let p=j(d,`${t}[${u}]`);if(!p.ok)return p;s.push(p.value)}return{ok:!0,value:{kind:"array",items:s}}}case"object":{let s=q(n.value.entries,`${t}.entries`);return s.ok?{ok:!0,value:{kind:"object",entries:s.value}}:s}case"template":{if(!Array.isArray(n.value.parts))return g(`${t}.parts must be an array`);let s=[];for(let[u,d]of n.value.parts.entries()){let p=Ae(d,`${t}.parts[${u}]`);if(!p.ok)return p;s.push(p.value)}return{ok:!0,value:{kind:"template",parts:s}}}default:return g(`${t}.kind is invalid`)}}function Ae(e,t){let n=m(e,t);if(!n.ok)return n;let r=n.value.kind;if(r==="literal")return typeof n.value.value!="string"?g(`${t}.value must be a string`):{ok:!0,value:{kind:"literal",value:n.value.value}};if(r==="human_input_ref"){let s=k(n.value.path,`${t}.path`);return s.ok?{ok:!0,value:{kind:"human_input_ref",path:s.value}}:s}return g(`${t}.kind is invalid`)}function ir(e){let t=m(e,"request body");if(!t.ok)return o(t.reason);let n=k(t.value.nodeId,"nodeId");if(!n.ok)return o(n.reason);let r=Pe(t.value.renderedPrompt);if(!r.ok)return o(r.reason);let s=Ne(t.value.input);if(!s.ok)return o(s.reason);let u=k(t.value.timeout,"timeout");if(!u.ok)return o(u.reason);let d=we(t.value.expiresAt,"expiresAt");if(!d.ok)return o(d.reason);let p=be(t.value.partiallyRenderedDelivery);return p.ok?a({nodeId:n.value,renderedPrompt:r.value,input:s.value,timeout:u.value,expiresAt:d.value,...p.value!==void 0?{partiallyRenderedDelivery:p.value}:{}}):o(p.reason)}function Se(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))?o("human input request view must carry id, nodeId, status and output"):a(e)}function sr(e){if(!i(e)||typeof e.created!="boolean")return o("human input create data must carry created:boolean");let t=Se(e.request);return t.ok?a({created:e.created,request:t.value}):t}function ur(e){return!i(e)||e.acknowledged!==!0?o("human input acknowledge data must carry acknowledged:true"):a({acknowledged:!0})}var dr="ablehi-wfp-user-runtime-manifest/v1",lr="unknown";function pr(e){return e.endsWith(".js")?`${e.slice(0,-3)}.manifest.json`:`${e}.manifest.json`}var gr="/internal/deployment-handshake",ve=["start","terminate","send-event","start-webhook-watcher","run-polling-tick","invoke-tool","invoke-trigger-handler","invoke-webhook-protocol-adapter","deployment-handshake"],fr=ve,mr="HANDSHAKE_REQUEST_INVALID",Rr="HANDSHAKE_SECRET_UNCONFIGURED",yr="HANDSHAKE_SECRET_MISMATCH",Ir="HANDSHAKE_CONTRACT_VERSION_MISMATCH",kr="HANDSHAKE_DISPATCH_NAMESPACE_MISMATCH",_r="HANDSHAKE_CAPABILITY_MISSING";function Er(e){return[e.nonce,e.timestamp,e.contractVersion,e.dispatchNamespace].map(n=>`${n.length}:${n}`).join(".")}function Tr(e){return["response",e.nonce,e.contractVersion,e.dispatchNamespace,...e.capabilities].map(n=>`${n.length}:${n}`).join(".")}export{ve as DEPLOYMENT_HANDSHAKE_DISPATCHER_CAPABILITIES,fr as DEPLOYMENT_HANDSHAKE_REQUIRED_CAPABILITIES,gr as DEPLOYMENT_HANDSHAKE_ROUTE,sn as EGRESS_GRANT_AUDIT_ROUTE_SUBPATH,on as EGRESS_GRANT_CONSUME_ROUTE_SUBPATH,ye as EGRESS_GRANT_SCOPE_KINDS,qe as EVENT_WAIT_ROUTE_SUBPATH,Fe as EXECUTION_CONTEXT_ROUTE_SUBPATH,Wn as FILE_CONTENT_ROUTE_SUBPATH,Kn as FILE_STAT_ROUTE_SUBPATH,X as FLOW_INTERPRETER_CONTRACT_VERSION,Ce as FLOW_IR_SCHEMA_VERSION,en as FLOW_RUN_EGRESS_GRANT_ROUTE_SUBPATH,Ve as FLOW_RUN_RESULT_ROUTE_SUBPATH,Nn as FLOW_RUN_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,ot as HANDLER_BUNDLES_ROUTE_SUBPATH,_r as HANDSHAKE_CAPABILITY_MISSING,Ir as HANDSHAKE_CONTRACT_VERSION_MISMATCH,kr as HANDSHAKE_DISPATCH_NAMESPACE_MISMATCH,mr as HANDSHAKE_REQUEST_INVALID,yr as HANDSHAKE_SECRET_MISMATCH,Rr as HANDSHAKE_SECRET_UNCONFIGURED,Qn as HUMAN_INPUTS_ROUTE_SUBPATH,tr as HUMAN_INPUT_ACKNOWLEDGE_ROUTE_SUBPATH,er as HUMAN_INPUT_EXPIRE_ROUTE_SUBPATH,Zn as HUMAN_INPUT_REQUEST_ROUTE_SUBPATH,xe as HUMAN_INPUT_RESOLVED_EVENT_PREFIX,$ as INTERNAL_EGRESS_GRANTS_ROUTE_PREFIX,U as INTERNAL_FILES_ROUTE_PREFIX,f as INTERNAL_FLOW_RUNS_ROUTE_PREFIX,te as INTERNAL_FLOW_VERSIONS_ROUTE_PREFIX,B as INTERNAL_INSTALLATIONS_ROUTE_PREFIX,T as INTERNAL_POLLING_TRIGGER_INSTANCES_ROUTE_PREFIX,H as INTERNAL_TOOL_INVOCATIONS_ROUTE_PREFIX,E as INTERNAL_WEBHOOK_TRIGGER_INSTANCES_ROUTE_PREFIX,Ut as POLLING_TRIGGER_CONTEXT_ROUTE_SUBPATH,nn as POLLING_TRIGGER_EGRESS_GRANT_ROUTE_SUBPATH,Ft as POLLING_TRIGGER_HANDLER_BUNDLES_ROUTE_SUBPATH,An as POLLING_TRIGGER_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,Lt as POLLING_TRIGGER_STORE_ROUTE_SUBPATH,Gt as POLLING_TRIGGER_TICK_EVENTS_ROUTE_SUBPATH,Bn as RUNTIME_CREDENTIAL_SESSION_SCOPE_KINDS,J as SERVER_CONTRACT_VERSION,We as STEP_RESULT_ROUTE_SUBPATH,it as TOOL_HANDLER_BUNDLES_ROUTE_SUBPATH,tn as TOOL_INVOCATION_EGRESS_GRANT_ROUTE_SUBPATH,bn as TOOL_INVOCATION_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,Pt as WEBHOOK_PROTOCOL_ADAPTER_BUNDLE_ROUTE_SUBPATH,bt as WEBHOOK_PROTOCOL_ADAPTER_MODULE,ft as WEBHOOK_TRIGGER_CONTEXT_ROUTE_SUBPATH,Rt as WEBHOOK_TRIGGER_DELIVERY_ROUTE_SUBPATH,rn as WEBHOOK_TRIGGER_EGRESS_GRANT_ROUTE_SUBPATH,yt as WEBHOOK_TRIGGER_EVENTS_ROUTE_SUBPATH,mt as WEBHOOK_TRIGGER_HANDLER_BUNDLES_ROUTE_SUBPATH,It as WEBHOOK_TRIGGER_REARM_ROUTE_SUBPATH,Sn as WEBHOOK_TRIGGER_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,kt as WEBHOOK_TRIGGER_STORE_ROUTE_SUBPATH,dr as WFP_USER_RUNTIME_MANIFEST_FORMAT_VERSION,lr as WFP_USER_RUNTIME_UNKNOWN_SOURCE_REVISION,o as contractParseFail,a as contractParseOk,Er as deploymentHandshakeProbePayload,Tr as deploymentHandshakeResponseProofPayload,cn as egressGrantAuditPath,pn as egressGrantConsumePath,Xe as eventWaitPath,Ge as executionContextPath,un as flowRunEgressGrantPath,Je as flowRunResultPath,vn as flowRunRuntimeCredentialPath,At as flowScriptProtocolAdapterModuleName,st as handlerBundlesPath,rr as humanInputAcknowledgePath,nr as humanInputExpirePath,V as humanInputRequestPath,or as humanInputResolvedEventType,Te as humanInputsPath,jn as internalFileContentPath,qn as internalFileStatPath,Vn as internalFilesPath,i as isJsonRecord,x as isValidRequestDigest,tt as parseCompleteFlowRunWaitBody,ir as parseCreateHumanInputBody,In as parseEgressGrantAuditBody,yn as parseEgressGrantConsumeBody,_n as parseEgressGrantConsumeData,kn as parseEgressGrantData,Le as parseExecutionContextData,Jn as parseFileRefData,Y as parseFileRuntimeLimits,gn as parseFlowActionGrantBody,Qe as parseFlowRunResultBody,Ze as parseFlowRunResultData,Hn as parseFlowRuntimeCredentialBody,re as parseHandlerBundle,at as parseHandlerBundlesData,ur as parseHumanInputAcknowledgeData,sr as parseHumanInputCreateData,Se as parseHumanInputRequestViewData,qt as parsePollingPublishBody,Fn as parsePollingRuntimeCredentialBody,le as parsePollingStorePutBody,ae as parsePollingStoreValue,Vt as parsePollingTriggerContext,mn as parsePollingTriggerGrantBody,jt as parsePublishPollingTickEventsData,et as parseRegisterFlowRunWaitBody,nt as parseRegisterFlowRunWaitData,Ln as parseRuntimeCredentialSessionCredential,w as parseRuntimeNetwork,fn as parseSingleToolGrantBody,Un as parseSingleToolRuntimeCredentialBody,Ye as parseStepRecordBody,ze as parseStepRecordData,dt as parseToolHandlerBundlesData,Ot as parseTriggerHandlerBundlesData,vt as parseWebhookDelivery,Ct as parseWebhookPublishEventsBody,Dt as parseWebhookRearmBody,Gn as parseWebhookRuntimeCredentialBody,le as parseWebhookStorePutBody,ae as parseWebhookStoreValue,Rn as parseWebhookTriggerGrantBody,St as parseWebhookWatcherContext,Mt as pollingTriggerContextPath,dn as pollingTriggerEgressGrantPath,$t as pollingTriggerHandlerBundlesPath,Cn as pollingTriggerRuntimeCredentialPath,Wt as pollingTriggerStorePath,Kt as pollingTriggerTickEventsPath,ke as requestHasMultipartFileParts,je as stepResultPath,ut as toolHandlerBundlesPath,an as toolInvocationEgressGrantPath,On as toolInvocationRuntimeCredentialPath,Nt as webhookProtocolAdapterBundlePath,_t as webhookTriggerContextPath,Tt as webhookTriggerDeliveryPath,ln as webhookTriggerEgressGrantPath,xt as webhookTriggerEventsPath,Et as webhookTriggerHandlerBundlesPath,ht as webhookTriggerRearmPath,Dn as webhookTriggerRuntimeCredentialPath,wt as webhookTriggerStorePath,pr as wfpUserRuntimeManifestPath};
1
+ var J="0.1.5";var Ce="flow.ir.v1";var X="flow.interp.v2";function a(e){return{ok:!0,value:e}}function o(e){return{ok:!1,reason:e}}function i(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var f="/internal/flow-runs",Fe="/:flowRunId/execution-context";function Ge(e){return`${f}/${encodeURIComponent(e)}/execution-context`}function Y(e){return!i(e)||!C(e.fileMaxBytes)||!C(e.fileReadMaxBytes)||!C(e.inlineMultipartBytesMax)?o("file runtime limits must carry three positive integer bounds"):a({fileMaxBytes:e.fileMaxBytes,fileReadMaxBytes:e.fileReadMaxBytes,inlineMultipartBytesMax:e.inlineMultipartBytesMax})}function Le(e){if(!i(e))return o("execution context must be a JSON object");let t=e.compiled;if(typeof e.flowRunId!="string"||typeof e.workspaceId!="string"||!i(e.input)||!i(t)||typeof t.irSchemaVersion!="string"||typeof t.interpreterContractVersion!="string"||typeof t.compiledArtifactId!="string"||!i(t.ir)||!Array.isArray(t.ir.nodes)||!Q(e.executionBindings))return o("execution context surface shape is invalid");let n=z(e.fileRuntime);return n.ok?a({...e,fileRuntime:n.value}):o(n.reason)}function z(e){if(e===null)return a(null);if(!i(e))return o("fileRuntime must be null or an object");let t=Y(e.limits);return t.ok?a({limits:t.value}):o(t.reason)}function Q(e){return Array.isArray(e)?e.every(t=>{if(!i(t))return!1;let n=t.connection;return typeof t.nodeId=="string"&&typeof t.toolRef=="string"&&i(t.toolDescriptor)&&i(t.integrationDescriptor)&&i(n)&&typeof n.installationId=="string"&&typeof n.connectionRef=="string"&&typeof n.connectionId=="string"&&typeof n.authType=="string"}):!1}function C(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0}var We="/:flowRunId/steps/:nodeId/result",Ve="/:flowRunId/result",qe="/:flowRunId/event-waits/:nodeId";function je(e,t){return`${f}/${encodeURIComponent(e)}/steps/${encodeURIComponent(t)}/result`}function Je(e){return`${f}/${encodeURIComponent(e)}/result`}function Xe(e,t){return`${f}/${encodeURIComponent(e)}/event-waits/${encodeURIComponent(t)}`}function Ye(e){if(!i(e))return{ok:!1,kind:"validation",reason:"step record body must be a JSON object"};let t=R(e,["attempt","result","durationMs"]);if(t!==void 0)return{ok:!1,kind:"validation",reason:`step record does not accept the "${t}" field`};let n=e.attempt;if(typeof n!="number"||!Number.isInteger(n)||n<=0)return{ok:!1,kind:"validation",reason:"attempt must be a positive integer"};let r=Z(e.result);if(!r.ok)return r;let s={attempt:n,result:r.value};if(e.durationMs!==void 0){let u=e.durationMs;if(typeof u!="number"||!Number.isFinite(u)||u<0)return{ok:!1,kind:"validation",reason:"durationMs must be a non-negative number"};s.durationMs=u}return{ok:!0,value:s}}function Z(e){if(!i(e))return{ok:!1,kind:"step_result_invalid",reason:"result must be a JSON object"};let t=e.status;if(t==="succeeded"){let n=R(e,["status","output"]);return n!==void 0?{ok:!1,kind:"validation",reason:`step record result does not accept the "${n}" field`}:"output"in e?{ok:!0,value:{status:"succeeded",output:e.output}}:{ok:!1,kind:"step_result_invalid",reason:"a succeeded result must carry output"}}if(t==="failed"){let n=R(e,["status","errorCode","issues"]);if(n!==void 0)return{ok:!1,kind:"validation",reason:`step record result does not accept the "${n}" field`};let r=e.errorCode;if(typeof r!="string"||r.length===0)return{ok:!1,kind:"step_result_invalid",reason:"a failed result must carry a non-empty errorCode"};let s={status:"failed",errorCode:r};return e.issues!==void 0&&(s.issues=e.issues),{ok:!0,value:s}}return{ok:!1,kind:"step_result_invalid",reason:'result status must be "succeeded" or "failed"'}}function ze(e){return!i(e)||typeof e.flowRunId!="string"||typeof e.nodeId!="string"||e.recorded!=="succeeded"&&e.recorded!=="failed"?o("step record data surface shape is invalid"):a({flowRunId:e.flowRunId,nodeId:e.nodeId,recorded:e.recorded})}function Qe(e){if(!i(e))return o("result body must be a JSON object");let t=R(e,["status","output","error","composition"]);if(t!==void 0)return o(`result does not accept the "${t}" field`);let n=e.status;if(n!=="succeeded"&&n!=="failed")return o('result status must be "succeeded" or "failed"');let r={status:n};if(e.output!==void 0&&(r.output=e.output),e.error!==void 0){let s=e.error;if(!i(s))return o("result error must be a JSON object");let u=R(s,["code","message"]);if(u!==void 0)return o(`result error does not accept the "${u}" field`);if(typeof s.code!="string"||typeof s.message!="string")return o("result error must carry string code and message");r.error={code:s.code,message:s.message}}if(e.composition!==void 0){if(n!=="succeeded")return o("composition is only allowed on a succeeded result");r.composition=e.composition}return a(r)}function Ze(e){return i(e)?a(e):o("flow run result data must be a JSON object")}var ee=/^[A-Za-z0-9_-]{1,100}$/;function et(e){if(!i(e))return o("register body must be a JSON object");let t=R(e,["eventType","correlationKey"]);if(t!==void 0)return o(`register wait does not accept the "${t}" field`);let n=F(e.eventType);if(!n.ok)return o(n.reason);let r=e.correlationKey;return typeof r!="string"||r.length===0?o("correlationKey must be a non-empty string"):a({eventType:n.value,correlationKey:r})}function tt(e){if(!i(e))return o("complete body must be a JSON object");let t=R(e,["eventType","correlationKey","outcome","eventId"]);if(t!==void 0)return o(`complete wait does not accept the "${t}" field`);let n=e.outcome;if(n!=="received"&&n!=="timed_out")return o('outcome must be "received" or "timed_out"');let r=F(e.eventType);if(!r.ok)return o(r.reason);let s=e.correlationKey;if(typeof s!="string"||s.length===0)return o("correlationKey must be a non-empty string");let u={eventType:r.value,correlationKey:s,outcome:n};if(e.eventId!==void 0){if(typeof e.eventId!="string"||e.eventId.length===0)return o("eventId must be a non-empty string");u.eventId=e.eventId}return a(u)}function nt(e){return!i(e)||e.registered!==!0?o("register wait data surface shape is invalid"):a({registered:!0})}function F(e){return typeof e!="string"||e.length===0?o("eventType must be a non-empty string"):ee.test(e)?a(e):o("eventType must match ^[A-Za-z0-9_-]{1,100}$")}function R(e,t){return Object.keys(e).find(n=>!t.includes(n))}var te="/internal/flow-versions",ot="/:flowVersionId/handler-bundles",B="/internal/installations",it="/:installationId/handler-bundles";function st(e,t){return`${te}/${encodeURIComponent(e)}/handler-bundles?compiledArtifactId=${encodeURIComponent(t)}`}function ut(e){return`${B}/${encodeURIComponent(e.installationId)}/handler-bundles?workspaceId=${encodeURIComponent(e.workspaceId)}&artifactDigest=${encodeURIComponent(e.artifactDigest)}`}var ne=new Set(["managed_only","managed_plus_unmanaged_sdk"]);function w(e){if(!y(e))return D("runtimeNetwork must be a JSON object");let t=e.networkModel;return typeof t!="string"||!ne.has(t)?D("runtimeNetwork.networkModel is unknown"):!G(e.apiHosts)||!G(e.authHosts)||typeof e.httpsOnly!="boolean"?D("runtimeNetwork host/https fields are invalid"):{ok:!0,value:{networkModel:t,apiHosts:e.apiHosts,authHosts:e.authHosts,httpsOnly:e.httpsOnly}}}function at(e){if(!y(e)||typeof e.flowVersionId!="string"||typeof e.compiledArtifactId!="string"||!Array.isArray(e.bundles))return _("handler bundles data surface shape is invalid");let t=L(e.bundles);return t.ok?{ok:!0,value:{flowVersionId:e.flowVersionId,compiledArtifactId:e.compiledArtifactId,bundles:t.value}}:t}function dt(e){if(!y(e)||typeof e.installationId!="string"||typeof e.artifactDigest!="string"||!Array.isArray(e.bundles))return _("tool handler bundles data surface shape is invalid");let t=L(e.bundles);return t.ok?{ok:!0,value:{installationId:e.installationId,artifactDigest:e.artifactDigest,bundles:t.value}}:t}function L(e){let t=[];for(let n of e){let r=re(n);if(!r.ok)return r;t.push(r.value)}return{ok:!0,value:t}}function re(e){if(!y(e)||typeof e.toolRef!="string"||e.kind!=="handler"&&e.kind!=="request")return _("handler bundle entry shape is invalid");if(e.kind==="request"){if(e.module!==void 0)return _("a request bundle must not carry a module");let r=w(e.runtimeNetwork);return r.ok?{ok:!0,value:{toolRef:e.toolRef,kind:"request",runtimeNetwork:r.value}}:r}let t=e.module;if(!y(t)||typeof t.entry!="string"||t.entry.length===0||!oe(t.files))return _("a handler bundle must carry a { entry, files } module");let n=w(e.runtimeNetwork);return n.ok?{ok:!0,value:{toolRef:e.toolRef,kind:"handler",module:{entry:t.entry,files:t.files},runtimeNetwork:n.value}}:n}function _(e){return{ok:!1,kind:"shape",reason:e}}function D(e){return{ok:!1,kind:"runtime_network",reason:e}}function y(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function G(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function oe(e){return y(e)&&Object.values(e).every(t=>typeof t=="string")}var E="/internal/webhook-trigger-instances",ft="/:triggerInstanceId/context",mt="/:triggerInstanceId/handler-bundles",Rt="/:triggerInstanceId/deliveries/:deliveryId",yt="/:triggerInstanceId/events",It="/:triggerInstanceId/rearm",kt="/:triggerInstanceId/store/:namespace/:key",I=e=>`${E}/${encodeURIComponent(e)}`;function _t(e,t){return`${I(e)}/context?artifactDigest=${encodeURIComponent(t)}`}function Et(e,t){return`${I(e)}/handler-bundles?artifactDigest=${encodeURIComponent(t)}`}function Tt(e,t){return`${I(e)}/deliveries/${encodeURIComponent(t)}`}function xt(e){return`${I(e)}/events`}function ht(e){return`${I(e)}/rearm`}function wt(e,t,n){return`${I(e)}/store/${encodeURIComponent(t)}/${encodeURIComponent(n)}`}var Pt="/:installationId/webhook-protocol-adapter-bundle";function Nt(e){return`${B}/${encodeURIComponent(e.installationId)}/webhook-protocol-adapter-bundle?workspaceId=${encodeURIComponent(e.workspaceId)}&artifactDigest=${encodeURIComponent(e.artifactDigest)}`}var bt="modules/webhook/protocol-adapter.js";function At(e){return`modules/webhook/protocol-adapter-${e}.js`}function St(e){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&&!ie(e.connection)||!se(e.runtime)?o("webhook watcher context surface shape is invalid"):a(e)}function ie(e){return i(e)&&typeof e.connectionId=="string"&&typeof e.connectionRef=="string"&&typeof e.integrationRef=="string"&&typeof e.authType=="string"}function se(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 vt(e){if(!i(e)||typeof e.deliveryId!="string"||typeof e.receivedAt!="string"||!i(e.request))return o("webhook delivery surface shape is invalid");let t=e.request;return t.method!=="POST"||!i(t.headers)||typeof t.rawBody!="string"?o("webhook delivery request shape is invalid"):a(e)}function Ot(e){if(!i(e)||typeof e.triggerRef!="string"||typeof e.artifactDigest!="string"||!Array.isArray(e.modules)||!e.modules.every(ue))return{ok:!1,kind:"shape",reason:"trigger handler bundles data surface shape is invalid"};let t=w(e.runtimeNetwork);return t.ok?{ok:!0,value:{triggerRef:e.triggerRef,artifactDigest:e.artifactDigest,modules:e.modules,runtimeNetwork:t.value}}:t}function ue(e){return i(e)&&typeof e.specifier=="string"&&e.specifier.length>0&&typeof e.source=="string"}function ae(e){return!i(e)||!("value"in e)?o("webhook store get surface shape is invalid"):a(e.value)}function Ct(e){if(!i(e))return o("publish events body must be a JSON object");let t=P(e,["deliveryId","events"]);if(t!==void 0)return o(`publish events does not accept the "${t}" field`);let n=e.deliveryId;if(typeof n!="string"||n.length===0)return o("deliveryId must be a non-empty string");let r=e.events;if(!Array.isArray(r))return o("events must be an array");let s=[];for(let u of r){let d=de(u);if(!d.ok)return d;s.push(d.value)}return a({deliveryId:n,events:s})}function de(e){if(!i(e))return o("each event must be a JSON object");let t=P(e,["eventId","occurredAt","dedupeKey","payload"]);if(t!==void 0)return o(`event does not accept the "${t}" field`);let n=e.eventId;if(typeof n!="string"||n.length===0)return o("eventId must be a non-empty string");let r=e.occurredAt;if(typeof r!="string"||r.length===0)return o("occurredAt must be a non-empty string");if(!i(e.payload))return o("event payload must be a JSON object");let s={eventId:n,occurredAt:r,payload:e.payload};if(e.dedupeKey!==void 0){if(typeof e.dedupeKey!="string"||e.dedupeKey.length===0)return o("dedupeKey must be a non-empty string");s.dedupeKey=e.dedupeKey}return a(s)}function Dt(e){if(!i(e))return o("rearm body must be a JSON object");let t=P(e,["expectedWatcherInstanceId"]);if(t!==void 0)return o(`rearm does not accept the "${t}" field`);let n=e.expectedWatcherInstanceId;return typeof n!="string"||n.length===0?o("expectedWatcherInstanceId must be a non-empty string"):a({expectedWatcherInstanceId:n})}function le(e){if(!i(e))return o("store body must be a JSON object");let t=P(e,["value"]);return t!==void 0?o(`store put does not accept the "${t}" field`):"value"in e?a({value:e.value}):o("store put requires a value field")}function P(e,t){return Object.keys(e).find(n=>!t.includes(n))}var T="/internal/polling-trigger-instances",Ut="/:pollingInstanceId/context",Ft="/:pollingInstanceId/handler-bundles",Gt="/:pollingInstanceId/ticks/:tickId/events",Lt="/:pollingInstanceId/store/:namespace/:key",N=e=>`${T}/${encodeURIComponent(e)}`;function Mt(e,t,n){return`${N(e)}/context?artifactDigest=${encodeURIComponent(t)}&tickId=${encodeURIComponent(n)}`}function $t(e,t){return`${N(e)}/handler-bundles?artifactDigest=${encodeURIComponent(t)}`}function Kt(e,t){return`${N(e)}/ticks/${encodeURIComponent(t)}/events`}function Wt(e,t,n){return`${N(e)}/store/${encodeURIComponent(t)}/${encodeURIComponent(n)}`}function Vt(e){return!i(e)||typeof e.artifactDigest!="string"||typeof e.triggerRef!="string"||typeof e.triggerName!="string"||typeof e.integrationRef!="string"||!i(e.inputs)||e.connection!==null&&!pe(e.connection)||!ce(e.runtime)||!ge(e.tick)||!fe(e.limits)?o("polling trigger context surface shape is invalid"):a(e)}function pe(e){return i(e)&&typeof e.connectionId=="string"&&typeof e.connectionRef=="string"&&typeof e.integrationRef=="string"&&typeof e.authType=="string"}function ce(e){if(!i(e)||e.type!=="polling"||typeof e.trigger_id!="string"||typeof e.trigger_ref!="string")return!1;let t=e.polling;if(!i(t)||typeof t.run_handler_module!="string")return!1;let n=t.schedule;if(!i(n)||n.type!=="interval"||typeof n.every_seconds!="number")return!1;let r=t.dedup;return i(r)&&(r.strategy==="cursor"||r.strategy==="hash"||r.strategy==="id_field")}function ge(e){return i(e)&&typeof e.tickId=="string"&&typeof e.scheduledAt=="string"&&typeof e.attempt=="number"}function fe(e){return i(e)&&typeof e.maxEventsPerTick=="number"}function qt(e){if(!i(e))return o("publish body must be a JSON object");let t=M(e,["events","nextCursor"]);if(t!==void 0)return o(`publish does not accept the "${t}" field`);let n=e.events;if(!Array.isArray(n))return o("events must be an array");let r=[];for(let u of n){let d=me(u);if(!d.ok)return d;r.push(d.value)}let s={events:r};if("nextCursor"in e){let u=e.nextCursor;if(u!==null&&typeof u!="string")return o("nextCursor must be a string, null, or omitted");s.nextCursor=u}return a(s)}function me(e){if(!i(e))return o("each event must be a JSON object");let t=M(e,["eventId","occurredAt","dedupeKey","payload"]);if(t!==void 0)return o(`event does not accept the "${t}" field`);if(typeof e.eventId!="string"||e.eventId.length===0)return o("event eventId must be a non-empty string");if(!i(e.payload))return o("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 o("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 o("event dedupeKey must be a non-empty string");n.dedupeKey=e.dedupeKey}return a(n)}function jt(e){return!i(e)||typeof e.tickId!="string"||typeof e.cursorUpdated!="boolean"||!Array.isArray(e.results)||!e.results.every(Re)?o("publish polling tick events data surface shape is invalid"):a(e)}function Re(e){return i(e)&&typeof e.eventId=="string"&&typeof e.dedupeKey=="string"&&typeof e.duplicate=="boolean"&&(e.flowRunId===null||typeof e.flowRunId=="string")}function M(e,t){return Object.keys(e).find(n=>!t.includes(n))}var $="/internal/egress-grants",H="/internal/tool-invocations",en="/:flowRunId/egress-grant",tn="/:invocationId/egress-grant",nn="/:pollingInstanceId/egress-grant",rn="/:triggerInstanceId/egress-grant",on="/:grantId/consume",sn="/:grantId/audit",un=e=>`${f}/${encodeURIComponent(e)}/egress-grant`,an=e=>`${H}/${encodeURIComponent(e)}/egress-grant`,dn=e=>`${T}/${encodeURIComponent(e)}/egress-grant`,ln=e=>`${E}/${encodeURIComponent(e)}/egress-grant`,pn=e=>`${$}/${encodeURIComponent(e)}/consume`,cn=e=>`${$}/${encodeURIComponent(e)}/audit`,ye=["flow_action","single_tool","polling_trigger","webhook_trigger"],Ie=/^[A-Za-z0-9][A-Za-z0-9:_+/=.-]{15,1023}$/;function x(e){return typeof e=="string"&&Ie.test(e)}function ke(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(r=>i(r)?r.kind==="file"&&typeof r.file_id=="string"&&r.file_id.length>0:!1):!1}function l(e){return{ok:!1,kind:"shape",reason:e}}function h(){return{ok:!1,kind:"request_digest",reason:"request digest is missing or malformed"}}function A(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 S(e){if(!i(e))return"request must be a JSON object"}function gn(e){let t=A(e,["nodeId","request","requestDigest"]);if(!t.ok)return l(t.reason);let n=t.record.nodeId;if(typeof n!="string"||n.length===0)return l("nodeId is required");let r=S(t.record.request);if(r!==void 0)return l(r);let s=t.record.requestDigest;return x(s)?{ok:!0,value:{nodeId:n,requestDigest:s,requestHasMultipartFiles:ke(t.record.request)}}:h()}function fn(e){let t=A(e,["request","requestDigest"]);if(!t.ok)return l(t.reason);let n=S(t.record.request);if(n!==void 0)return l(n);let r=t.record.requestDigest;return x(r)?{ok:!0,value:{requestDigest:r}}:h()}function mn(e){let t=A(e,["tickId","request","requestDigest"]);if(!t.ok)return l(t.reason);let n=t.record.tickId;if(typeof n!="string"||n.length===0)return l("tickId is required");let r=S(t.record.request);if(r!==void 0)return l(r);let s=t.record.requestDigest;return x(s)?{ok:!0,value:{tickId:n,requestDigest:s}}:h()}function Rn(e){let t=A(e,["phase","lifecycle","request","requestDigest"]);if(!t.ok)return l(t.reason);let n=t.record.phase;if(n!=="lifecycle"&&n!=="handler")return l('phase must be "lifecycle" or "handler"');let r=t.record.lifecycle,s;if(r!==void 0){if(r!=="enable"&&r!=="disable"&&r!=="renew")return l('lifecycle must be "enable", "disable", or "renew"');s=r}if(n==="lifecycle"&&s===void 0)return l("lifecycle is required for the lifecycle phase");let u=S(t.record.request);if(u!==void 0)return l(u);let d=t.record.requestDigest;return x(d)?{ok:!0,value:{phase:n,...s!==void 0?{lifecycle:s}:{},requestDigest:d}}:h()}function K(e){return ye.includes(e)?e:void 0}var _e=["scopeKind","scopeId","requestDigest"];function yn(e){if(!i(e))return l("consume body must be a JSON object");for(let s of Object.keys(e))if(!_e.includes(s))return l(`consume does not accept the "${s}" field`);let t=K(e.scopeKind);if(t===void 0)return l("scopeKind is invalid");let n=e.scopeId;if(typeof n!="string"||n.length===0)return l("scopeId is required");let r=e.requestDigest;return x(r)?{ok:!0,value:{scopeKind:t,scopeId:n,requestDigest:r}}:h()}var Ee=["scopeKind","scopeId","providerHost","status","durationMs","requestBytes","responseBytes","errorCode"];function b(e,t){return typeof e!="number"||!Number.isInteger(e)||e<0?{ok:!1,reason:`${t} must be a non-negative integer`}:{ok:!0,value:e}}function In(e){if(!i(e))return l("audit body must be a JSON object");for(let c of Object.keys(e))if(!Ee.includes(c))return l(`audit does not accept the "${c}" field`);let t=K(e.scopeKind);if(t===void 0)return l("scopeKind is invalid");let n=e.scopeId;if(typeof n!="string"||n.length===0)return l("scopeId is required");let r=e.providerHost;if(typeof r!="string"||r.length===0)return l("providerHost is required");let s=b(e.durationMs,"durationMs");if(!s.ok)return l(s.reason);let u;if(e.status!==void 0){let c=b(e.status,"status");if(!c.ok)return l(c.reason);u=c.value}let d;if(e.requestBytes!==void 0){let c=b(e.requestBytes,"requestBytes");if(!c.ok)return l(c.reason);d=c.value}let p;if(e.responseBytes!==void 0){let c=b(e.responseBytes,"responseBytes");if(!c.ok)return l(c.reason);p=c.value}let O;if(e.errorCode!==void 0){let c=e.errorCode;if(typeof c!="string"||c.length===0)return l("errorCode must be a non-empty string");O=c}return{ok:!0,value:{scopeKind:t,scopeId:n,providerHost:r,...u!==void 0?{status:u}:{},durationMs:s.value,...d!==void 0?{requestBytes:d}:{},...p!==void 0?{responseBytes:p}:{},...O!==void 0?{errorCode:O}:{}}}}function kn(e){return!i(e)||!i(e.grant)?o("egress grant envelope must carry a grant object"):a(e.grant)}function _n(e){return!i(e)||e.consumed!==!0?o("egress grant consume data must carry consumed:true"):a({consumed:!0})}var Nn="/:flowRunId/runtime-credential",bn="/:invocationId/runtime-credential",An="/:pollingInstanceId/runtime-credential",Sn="/:triggerInstanceId/runtime-credential",vn=e=>`${f}/${encodeURIComponent(e)}/runtime-credential`,On=e=>`${H}/${encodeURIComponent(e)}/runtime-credential`,Cn=e=>`${T}/${encodeURIComponent(e)}/runtime-credential`,Dn=e=>`${E}/${encodeURIComponent(e)}/runtime-credential`,Bn=["flow_action","tool_invoke","polling_trigger","webhook_trigger"];function v(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 Hn(e){let t=v(e,["nodeId"]);if(!t.ok)return o(t.reason);let n=t.record.nodeId;return typeof n!="string"||n.length===0?o("nodeId is required"):a({nodeId:n})}function Un(e){let t=v(e??{},[]);return t.ok?a(null):o(t.reason)}function Fn(e){let t=v(e,["tickId"]);if(!t.ok)return o(t.reason);let n=t.record.tickId;return typeof n!="string"||n.length===0?o("tickId is required"):a({tickId:n})}function Gn(e){let t=v(e,["executionKind","deliveryId","lifecycleOperation"]);if(!t.ok)return o(t.reason);let n=t.record.executionKind;if(n!=="event_handler"&&n!=="lifecycle")return o('executionKind must be "event_handler" or "lifecycle"');let r,s=t.record.deliveryId;if(s!==void 0){if(typeof s!="string"||s.length===0)return o("deliveryId must be a non-empty string");r=s}let u,d=t.record.lifecycleOperation;if(d!==void 0){if(d!=="enable"&&d!=="disable"&&d!=="renew")return o('lifecycleOperation must be "enable", "disable", or "renew"');u=d}return n==="lifecycle"&&u===void 0?o("lifecycleOperation is required for the lifecycle execution kind"):a({executionKind:n,...r!==void 0?{deliveryId:r}:{},...u!==void 0?{lifecycleOperation:u}:{}})}function Ln(e){return!i(e)||typeof e.sessionId!="string"||typeof e.connectionId!="string"||!i(e.credential)?o("runtime credential session must carry sessionId, connectionId and a credential object"):a(e.credential)}var U="/internal/files",Kn="/:fileId/stat",Wn="/:fileId/content",Vn=()=>U,W=e=>`?scope_kind=${encodeURIComponent(e.scopeKind)}&scope_id=${encodeURIComponent(e.scopeId)}`,qn=(e,t)=>`${U}/${encodeURIComponent(e)}/stat${W(t)}`,jn=(e,t)=>`${U}/${encodeURIComponent(e)}/content${W(t)}`;function Jn(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"?o("file ref data does not match the AIS file-ref shape"):a(e)}var Qn="/:flowRunId/human-inputs",Zn="/:flowRunId/human-inputs/:requestId",er="/:flowRunId/human-inputs/:requestId/expire",tr="/:flowRunId/human-inputs/:requestId/acknowledge",Te=e=>`${f}/${encodeURIComponent(e)}/human-inputs`,V=(e,t)=>`${Te(e)}/${encodeURIComponent(t)}`,nr=(e,t)=>`${V(e,t)}/expire`,rr=(e,t)=>`${V(e,t)}/acknowledge`,xe="human_input_resolved";function or(e){return`${xe}_${e}`}function g(e){return{ok:!1,reason:e}}function m(e,t){return i(e)?{ok:!0,value:e}:g(`${t} must be an object`)}function k(e,t){return typeof e!="string"||e.length===0?g(`${t} must be a non-empty string`):{ok:!0,value:e}}var he=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?(?:Z|[+-]\d{2}:\d{2})$/;function we(e,t){return typeof e!="string"||!he.test(e)||Number.isNaN(Date.parse(e))?g(`${t} must be an ISO-8601 timestamp`):{ok:!0,value:e}}function Pe(e){let t=m(e,"renderedPrompt");if(!t.ok)return t;let n=k(t.value.title,"renderedPrompt.title");if(!n.ok)return n;let r={title:n.value};if(t.value.body!==void 0){if(typeof t.value.body!="string")return g("renderedPrompt.body must be a string");r.body=t.value.body}if(t.value.format!==void 0){if(t.value.format!=="plain"&&t.value.format!=="markdown")return g("renderedPrompt.format is invalid");r.format=t.value.format}return{ok:!0,value:r}}function Ne(e){let t=m(e,"input");if(!t.ok)return t;let n=t.value.kind;if(n==="choice"){if(!Array.isArray(t.value.choices))return g("input.choices must be an array")}else if(n!=="text")if(n==="form"){if(!Array.isArray(t.value.fields))return g("input.fields must be an array")}else return g("input.kind is invalid");return{ok:!0,value:t.value}}function be(e){if(e==null)return{ok:!0,value:void 0};let t=m(e,"partiallyRenderedDelivery");if(!t.ok)return t;let n=t.value.actions;if(n===void 0)return{ok:!0,value:{}};if(!Array.isArray(n))return g("partiallyRenderedDelivery.actions must be an array");let r=[];for(let s of n){let u=m(s,"delivery action");if(!u.ok)return u;let d=k(u.value.id,"delivery action id");if(!d.ok)return d;let p=q(u.value.inputs,`delivery action '${d.value}' inputs`);if(!p.ok)return p;r.push({id:d.value,inputs:p.value})}return{ok:!0,value:{actions:r}}}function q(e,t){let n=m(e,t);if(!n.ok)return n;let r={};for(let[s,u]of Object.entries(n.value)){let d=j(u,`${t}.${s}`);if(!d.ok)return d;r[s]=d.value}return{ok:!0,value:r}}function j(e,t){let n=m(e,t);if(!n.ok)return n;switch(n.value.kind){case"literal":return{ok:!0,value:{kind:"literal",value:n.value.value}};case"human_input_ref":{let s=k(n.value.path,`${t}.path`);return s.ok?{ok:!0,value:{kind:"human_input_ref",path:s.value}}:s}case"array":{if(!Array.isArray(n.value.items))return g(`${t}.items must be an array`);let s=[];for(let[u,d]of n.value.items.entries()){let p=j(d,`${t}[${u}]`);if(!p.ok)return p;s.push(p.value)}return{ok:!0,value:{kind:"array",items:s}}}case"object":{let s=q(n.value.entries,`${t}.entries`);return s.ok?{ok:!0,value:{kind:"object",entries:s.value}}:s}case"template":{if(!Array.isArray(n.value.parts))return g(`${t}.parts must be an array`);let s=[];for(let[u,d]of n.value.parts.entries()){let p=Ae(d,`${t}.parts[${u}]`);if(!p.ok)return p;s.push(p.value)}return{ok:!0,value:{kind:"template",parts:s}}}default:return g(`${t}.kind is invalid`)}}function Ae(e,t){let n=m(e,t);if(!n.ok)return n;let r=n.value.kind;if(r==="literal")return typeof n.value.value!="string"?g(`${t}.value must be a string`):{ok:!0,value:{kind:"literal",value:n.value.value}};if(r==="human_input_ref"){let s=k(n.value.path,`${t}.path`);return s.ok?{ok:!0,value:{kind:"human_input_ref",path:s.value}}:s}return g(`${t}.kind is invalid`)}function ir(e){let t=m(e,"request body");if(!t.ok)return o(t.reason);let n=k(t.value.nodeId,"nodeId");if(!n.ok)return o(n.reason);let r=Pe(t.value.renderedPrompt);if(!r.ok)return o(r.reason);let s=Ne(t.value.input);if(!s.ok)return o(s.reason);let u=k(t.value.timeout,"timeout");if(!u.ok)return o(u.reason);let d=we(t.value.expiresAt,"expiresAt");if(!d.ok)return o(d.reason);let p=be(t.value.partiallyRenderedDelivery);return p.ok?a({nodeId:n.value,renderedPrompt:r.value,input:s.value,timeout:u.value,expiresAt:d.value,...p.value!==void 0?{partiallyRenderedDelivery:p.value}:{}}):o(p.reason)}function Se(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))?o("human input request view must carry id, nodeId, status and output"):a(e)}function sr(e){if(!i(e)||typeof e.created!="boolean")return o("human input create data must carry created:boolean");let t=Se(e.request);return t.ok?a({created:e.created,request:t.value}):t}function ur(e){return!i(e)||e.acknowledged!==!0?o("human input acknowledge data must carry acknowledged:true"):a({acknowledged:!0})}var dr="ablehi-wfp-user-runtime-manifest/v1",lr="unknown";function pr(e){return e.endsWith(".js")?`${e.slice(0,-3)}.manifest.json`:`${e}.manifest.json`}var gr="/internal/deployment-handshake",ve=["start","terminate","send-event","start-webhook-watcher","run-polling-tick","invoke-tool","invoke-trigger-handler","invoke-webhook-protocol-adapter","deployment-handshake"],fr=ve,mr="HANDSHAKE_REQUEST_INVALID",Rr="HANDSHAKE_SECRET_UNCONFIGURED",yr="HANDSHAKE_SECRET_MISMATCH",Ir="HANDSHAKE_CONTRACT_VERSION_MISMATCH",kr="HANDSHAKE_DISPATCH_NAMESPACE_MISMATCH",_r="HANDSHAKE_CAPABILITY_MISSING";function Er(e){return[e.nonce,e.timestamp,e.contractVersion,e.dispatchNamespace].map(n=>`${n.length}:${n}`).join(".")}function Tr(e){return["response",e.nonce,e.contractVersion,e.dispatchNamespace,...e.capabilities].map(n=>`${n.length}:${n}`).join(".")}export{ve as DEPLOYMENT_HANDSHAKE_DISPATCHER_CAPABILITIES,fr as DEPLOYMENT_HANDSHAKE_REQUIRED_CAPABILITIES,gr as DEPLOYMENT_HANDSHAKE_ROUTE,sn as EGRESS_GRANT_AUDIT_ROUTE_SUBPATH,on as EGRESS_GRANT_CONSUME_ROUTE_SUBPATH,ye as EGRESS_GRANT_SCOPE_KINDS,qe as EVENT_WAIT_ROUTE_SUBPATH,Fe as EXECUTION_CONTEXT_ROUTE_SUBPATH,Wn as FILE_CONTENT_ROUTE_SUBPATH,Kn as FILE_STAT_ROUTE_SUBPATH,X as FLOW_INTERPRETER_CONTRACT_VERSION,Ce as FLOW_IR_SCHEMA_VERSION,en as FLOW_RUN_EGRESS_GRANT_ROUTE_SUBPATH,Ve as FLOW_RUN_RESULT_ROUTE_SUBPATH,Nn as FLOW_RUN_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,ot as HANDLER_BUNDLES_ROUTE_SUBPATH,_r as HANDSHAKE_CAPABILITY_MISSING,Ir as HANDSHAKE_CONTRACT_VERSION_MISMATCH,kr as HANDSHAKE_DISPATCH_NAMESPACE_MISMATCH,mr as HANDSHAKE_REQUEST_INVALID,yr as HANDSHAKE_SECRET_MISMATCH,Rr as HANDSHAKE_SECRET_UNCONFIGURED,Qn as HUMAN_INPUTS_ROUTE_SUBPATH,tr as HUMAN_INPUT_ACKNOWLEDGE_ROUTE_SUBPATH,er as HUMAN_INPUT_EXPIRE_ROUTE_SUBPATH,Zn as HUMAN_INPUT_REQUEST_ROUTE_SUBPATH,xe as HUMAN_INPUT_RESOLVED_EVENT_PREFIX,$ as INTERNAL_EGRESS_GRANTS_ROUTE_PREFIX,U as INTERNAL_FILES_ROUTE_PREFIX,f as INTERNAL_FLOW_RUNS_ROUTE_PREFIX,te as INTERNAL_FLOW_VERSIONS_ROUTE_PREFIX,B as INTERNAL_INSTALLATIONS_ROUTE_PREFIX,T as INTERNAL_POLLING_TRIGGER_INSTANCES_ROUTE_PREFIX,H as INTERNAL_TOOL_INVOCATIONS_ROUTE_PREFIX,E as INTERNAL_WEBHOOK_TRIGGER_INSTANCES_ROUTE_PREFIX,Ut as POLLING_TRIGGER_CONTEXT_ROUTE_SUBPATH,nn as POLLING_TRIGGER_EGRESS_GRANT_ROUTE_SUBPATH,Ft as POLLING_TRIGGER_HANDLER_BUNDLES_ROUTE_SUBPATH,An as POLLING_TRIGGER_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,Lt as POLLING_TRIGGER_STORE_ROUTE_SUBPATH,Gt as POLLING_TRIGGER_TICK_EVENTS_ROUTE_SUBPATH,Bn as RUNTIME_CREDENTIAL_SESSION_SCOPE_KINDS,J as SERVER_CONTRACT_VERSION,We as STEP_RESULT_ROUTE_SUBPATH,it as TOOL_HANDLER_BUNDLES_ROUTE_SUBPATH,tn as TOOL_INVOCATION_EGRESS_GRANT_ROUTE_SUBPATH,bn as TOOL_INVOCATION_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,Pt as WEBHOOK_PROTOCOL_ADAPTER_BUNDLE_ROUTE_SUBPATH,bt as WEBHOOK_PROTOCOL_ADAPTER_MODULE,ft as WEBHOOK_TRIGGER_CONTEXT_ROUTE_SUBPATH,Rt as WEBHOOK_TRIGGER_DELIVERY_ROUTE_SUBPATH,rn as WEBHOOK_TRIGGER_EGRESS_GRANT_ROUTE_SUBPATH,yt as WEBHOOK_TRIGGER_EVENTS_ROUTE_SUBPATH,mt as WEBHOOK_TRIGGER_HANDLER_BUNDLES_ROUTE_SUBPATH,It as WEBHOOK_TRIGGER_REARM_ROUTE_SUBPATH,Sn as WEBHOOK_TRIGGER_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,kt as WEBHOOK_TRIGGER_STORE_ROUTE_SUBPATH,dr as WFP_USER_RUNTIME_MANIFEST_FORMAT_VERSION,lr as WFP_USER_RUNTIME_UNKNOWN_SOURCE_REVISION,o as contractParseFail,a as contractParseOk,Er as deploymentHandshakeProbePayload,Tr as deploymentHandshakeResponseProofPayload,cn as egressGrantAuditPath,pn as egressGrantConsumePath,Xe as eventWaitPath,Ge as executionContextPath,un as flowRunEgressGrantPath,Je as flowRunResultPath,vn as flowRunRuntimeCredentialPath,At as flowScriptProtocolAdapterModuleName,st as handlerBundlesPath,rr as humanInputAcknowledgePath,nr as humanInputExpirePath,V as humanInputRequestPath,or as humanInputResolvedEventType,Te as humanInputsPath,jn as internalFileContentPath,qn as internalFileStatPath,Vn as internalFilesPath,i as isJsonRecord,x as isValidRequestDigest,tt as parseCompleteFlowRunWaitBody,ir as parseCreateHumanInputBody,In as parseEgressGrantAuditBody,yn as parseEgressGrantConsumeBody,_n as parseEgressGrantConsumeData,kn as parseEgressGrantData,Le as parseExecutionContextData,Jn as parseFileRefData,Y as parseFileRuntimeLimits,gn as parseFlowActionGrantBody,Qe as parseFlowRunResultBody,Ze as parseFlowRunResultData,Hn as parseFlowRuntimeCredentialBody,re as parseHandlerBundle,at as parseHandlerBundlesData,ur as parseHumanInputAcknowledgeData,sr as parseHumanInputCreateData,Se as parseHumanInputRequestViewData,qt as parsePollingPublishBody,Fn as parsePollingRuntimeCredentialBody,le as parsePollingStorePutBody,ae as parsePollingStoreValue,Vt as parsePollingTriggerContext,mn as parsePollingTriggerGrantBody,jt as parsePublishPollingTickEventsData,et as parseRegisterFlowRunWaitBody,nt as parseRegisterFlowRunWaitData,Ln as parseRuntimeCredentialSessionCredential,w as parseRuntimeNetwork,fn as parseSingleToolGrantBody,Un as parseSingleToolRuntimeCredentialBody,Ye as parseStepRecordBody,ze as parseStepRecordData,dt as parseToolHandlerBundlesData,Ot as parseTriggerHandlerBundlesData,vt as parseWebhookDelivery,Ct as parseWebhookPublishEventsBody,Dt as parseWebhookRearmBody,Gn as parseWebhookRuntimeCredentialBody,le as parseWebhookStorePutBody,ae as parseWebhookStoreValue,Rn as parseWebhookTriggerGrantBody,St as parseWebhookWatcherContext,Mt as pollingTriggerContextPath,dn as pollingTriggerEgressGrantPath,$t as pollingTriggerHandlerBundlesPath,Cn as pollingTriggerRuntimeCredentialPath,Wt as pollingTriggerStorePath,Kt as pollingTriggerTickEventsPath,ke as requestHasMultipartFileParts,je as stepResultPath,ut as toolHandlerBundlesPath,an as toolInvocationEgressGrantPath,On as toolInvocationRuntimeCredentialPath,Nt as webhookProtocolAdapterBundlePath,_t as webhookTriggerContextPath,Tt as webhookTriggerDeliveryPath,ln as webhookTriggerEgressGrantPath,xt as webhookTriggerEventsPath,Et as webhookTriggerHandlerBundlesPath,ht as webhookTriggerRearmPath,Dn as webhookTriggerRuntimeCredentialPath,wt as webhookTriggerStorePath,pr as wfpUserRuntimeManifestPath};
package/dist/index.d.ts CHANGED
@@ -543,9 +543,29 @@ type FlowVersionGetData<TIr = unknown> = {
543
543
  declare const AGENT_ROUTE_PREFIX = "/workspaces/:workspaceId/agent";
544
544
  declare const AGENT_CHAT_ROUTE_SUBPATH = "/chat";
545
545
  declare const AGENT_FLOW_CONTEXT_ROUTE_SUBPATH = "/flow-context";
546
+ declare const AGENT_SESSIONS_ROUTE_SUBPATH = "/sessions";
547
+ declare const AGENT_SESSION_ITEM_ROUTE_SUBPATH = "/sessions/:sessionId";
546
548
  declare const agentChatPath: (workspaceId: string) => string;
549
+ declare const agentSessionsPath: (workspaceId: string) => string;
550
+ declare const agentSessionPath: (workspaceId: string, sessionId: string) => string;
551
+ declare const AGENT_SESSION_LIST_DEFAULT_LIMIT = 20;
552
+ declare const AGENT_SESSION_LIST_MAX_LIMIT = 50;
553
+ declare const AGENT_SESSION_DETAIL_MESSAGE_LIMIT = 100;
547
554
  type AgentCapabilityKind = "flow_authoring";
548
555
  declare const AGENT_CAPABILITY_FLOW_AUTHORING: AgentCapabilityKind;
556
+ type AgentPageResourceType = "flow" | "flow_run" | "inbox_entry" | "integration";
557
+ declare const AGENT_PAGE_RESOURCE_TYPES: readonly AgentPageResourceType[];
558
+ type AgentPageResourceRef = {
559
+ type: AgentPageResourceType;
560
+ id: string;
561
+ };
562
+ type AgentPageContext = {
563
+ routeId: string;
564
+ resources?: AgentPageResourceRef[];
565
+ };
566
+ declare const AGENT_PAGE_CONTEXT_ROUTE_ID_MAX_LENGTH = 256;
567
+ declare const AGENT_PAGE_CONTEXT_MAX_RESOURCES = 10;
568
+ declare const AGENT_PAGE_CONTEXT_RESOURCE_ID_MAX_LENGTH = 256;
549
569
  type FlowAuthoringWorkingDraftCandidate = {
550
570
  flowId?: string | null;
551
571
  ir: unknown;
@@ -555,8 +575,30 @@ type AgentTaskSurface = {
555
575
  workingDraft: FlowAuthoringWorkingDraftCandidate;
556
576
  };
557
577
  type AgentChatRequestBody = {
578
+ sessionId: string;
558
579
  messages: unknown[];
559
- surface: AgentTaskSurface;
580
+ pageContext: AgentPageContext;
581
+ surface?: AgentTaskSurface;
582
+ };
583
+ type AgentSessionSummary = {
584
+ id: string;
585
+ title: string | null;
586
+ createdAt: string;
587
+ updatedAt: string;
588
+ };
589
+ type AgentSessionListData = {
590
+ sessions: AgentSessionSummary[];
591
+ };
592
+ type AgentUiMessageRole = "user" | "assistant" | "system";
593
+ type AgentUiMessageProjection = {
594
+ id: string;
595
+ role: AgentUiMessageRole;
596
+ parts: unknown[];
597
+ metadata?: Record<string, unknown>;
598
+ };
599
+ type AgentSessionDetailData = {
600
+ session: AgentSessionSummary;
601
+ messages: AgentUiMessageProjection[];
560
602
  };
561
603
  declare const FLOW_AUTHORING_TOOL_NAMES: readonly ["getFlowContext", "getWorkingFlowIr", "setFlowMeta", "addNode", "updateNode", "removeNode", "setTrigger", "removeTrigger", "setOutputs", "setComposition", "validateFlow", "saveFlowDraft", "requestConnect"];
562
604
  type FlowAuthoringToolName = (typeof FLOW_AUTHORING_TOOL_NAMES)[number];
@@ -660,6 +702,10 @@ declare const AGENT_RUNTIME_UNCONFIGURED_ERROR_CODE = "AGENT_RUNTIME_UNCONFIGURE
660
702
  declare const AGENT_RUNTIME_FAILED_ERROR_CODE = "AGENT_RUNTIME_FAILED";
661
703
  declare const AGENT_APPROVAL_NOT_FOUND_ERROR_CODE = "AGENT_APPROVAL_NOT_FOUND";
662
704
  declare const AGENT_APPROVAL_EXPIRED_ERROR_CODE = "AGENT_APPROVAL_EXPIRED";
705
+ declare const AGENT_SESSION_NOT_FOUND_ERROR_CODE = "AGENT_SESSION_NOT_FOUND";
706
+ declare const AGENT_MESSAGE_DELTA_INVALID_ERROR_CODE = "AGENT_MESSAGE_DELTA_INVALID";
707
+ declare const AGENT_PAGE_CONTEXT_INVALID_ERROR_CODE = "AGENT_PAGE_CONTEXT_INVALID";
708
+ declare const AGENT_CANDIDATE_INVALID_ERROR_CODE = "AGENT_CANDIDATE_INVALID";
663
709
 
664
710
  declare const WORKSPACE_RUNS_ROUTE_PREFIX = "/workspaces/:workspaceId/runs";
665
711
  declare const WORKSPACE_FLOW_RUNS_ROUTE_PREFIX = "/workspaces/:workspaceId/flows/:flowId/runs";
@@ -905,4 +951,4 @@ type SimulateTriggerData = {
905
951
  duplicate: boolean;
906
952
  };
907
953
 
908
- export { AGENT_APPROVAL_EXPIRED_ERROR_CODE, AGENT_APPROVAL_NOT_FOUND_ERROR_CODE, AGENT_CAPABILITY_FLOW_AUTHORING, AGENT_CHAT_ROUTE_SUBPATH, AGENT_FLOW_CONTEXT_ROUTE_SUBPATH, AGENT_ROUTE_PREFIX, AGENT_RUNTIME_FAILED_ERROR_CODE, AGENT_RUNTIME_UNCONFIGURED_ERROR_CODE, type AddNodeInput, type AgentCapabilityKind, type AgentChatRequestBody, type AgentTaskSurface, type Bounded, CATALOG_DEFAULT_PROVIDER_APP_CONFIG_ROUTE_SUBPATH, CATALOG_INTEGRATIONS_ROUTE_SUBPATH, CATALOG_INTEGRATION_DETAIL_ROUTE_SUBPATH, CATALOG_ROUTE_PREFIX, CATALOG_VERSIONS_ROUTE_SUBPATH, CONNECTIONS_ROUTE_SUBPATH, CONNECTION_DISCONNECT_ROUTE_SUBPATH, CONNECT_COMPLETE_ROUTE_SUBPATH, CONNECT_OPTIONS_ROUTE_SUBPATH, CONNECT_START_ROUTE_SUBPATH, CONNECT_SUBMIT_ROUTE_SUBPATH, CURRENT_USER_ROUTE_PATH, type CatalogDetailData, type CatalogDetailLatestData, type CatalogIntegrationSummaryData, type CatalogListData, type CatalogPublishData, type CatalogToolFunctionData, type CatalogTriggerFunctionData, type CatalogVersionSummaryData, type CompiledFlowVersionSummaryData, type ConnectCompleteResultData, type ConnectCompletedResultData, type ConnectDefaultUnavailableReason, type ConnectFieldDefData, type ConnectInputNextActionData, type ConnectInputTarget, type ConnectOptionsData, type ConnectRedirectNextActionData, type ConnectStartBody, type ConnectStartResultData, type ConnectSubmitBody, type ConnectSubmitResultData, type ConnectionAuthType, type ConnectionListData, type ConnectionSummaryData, type ControlPlaneToolData, type ControlPlaneToolDeliveryData, type ControlPlaneTriggerData, type CurrentUserData, type DefaultProviderAppConfigAdminData, type DefaultProviderAppConfigDisableData, type DefaultProviderAppConfigUpsertBody, type DefaultProviderAppConfigWriteData, type DeletedFlowSummaryData, type DeliverFlowRunEventData, type DisconnectResultData, FLOW_AUTHORING_EDIT_TOOL_NAMES, FLOW_AUTHORING_TOOL_DESCRIPTORS, FLOW_AUTHORING_TOOL_NAMES, FLOW_DISABLE_ROUTE_SUBPATH, FLOW_DRAFT_APPROVAL_DATA_PART_TYPE, FLOW_DRAFT_APPROVAL_KIND, FLOW_DRAFT_ROUTE_SUBPATH, FLOW_ENABLE_ROUTE_SUBPATH, FLOW_ITEM_ROUTE_SUBPATH, FLOW_RUN_STATUSES, FLOW_VALIDATE_ROUTE_SUBPATH, FLOW_VERSIONS_ROUTE_SUBPATH, FLOW_VERSION_ITEM_ROUTE_SUBPATH, type FlowAuthoringEditToolName, type FlowAuthoringToolDescriptor, type FlowAuthoringToolExecution, type FlowAuthoringToolInputSchema, type FlowAuthoringToolName, type FlowAuthoringWorkingDraftCandidate, type FlowBadgeData, FlowCompositionSpec, type FlowDeleteData, type FlowDraftApprovalProjection, type FlowDraftRecordData, type FlowDraftSaveSummary, type FlowListData, type FlowListItemData, type FlowMetaUpdate, FlowNode, type FlowPublishData, type FlowRecordData, type FlowRunCancelData, type FlowRunDetailData, type FlowRunListData, type FlowRunStatus, type FlowRunSummaryData, type FlowRunTerminalErrorData, type FlowRunTriggerData, type FlowStatus, type FlowToolError, type FlowValidateData, type FlowValidationIssueData, type FlowVersionGetData, type FlowVersionListData, type FlowWithDraftData, type GetFlowContextInput, type GetWorkingFlowIrInput, type GetWorkingFlowIrOutput, HUMAN_INPUT_TOKENS_ROUTE_PREFIX, HUMAN_INPUT_TOKEN_ROUTE_SUBPATH, HUMAN_INPUT_TOKEN_SUBMIT_ROUTE_SUBPATH, type HumanInputPublicOutputData, type HumanInputRequestViewData, type HumanInputSubmitPayload, type HumanInputTokenSubmitData, type HumanInputTokenViewData, INBOX_ENTRY_HUMAN_INPUT_SUBMIT_ROUTE_SUBPATH, INBOX_ENTRY_ROUTE_SUBPATH, INBOX_ITEM_ROUTE_SUBPATH, INTEGRATION_ITEM_ROUTE_SUBPATH, INTEGRATION_TOOLS_ROUTE_SUBPATH, type InboxEntryDetailData, type InboxEntryListData, type InboxEntryListEntryData, type InboxEntryStatus, type InboxEntryType, type InboxHumanInputEntryData, type InboxItemDetailData, type InboxItemDetailEntryData, type InboxItemListData, type InboxItemListEntryData, type InboxLinksData, type InboxReportData, type InstallationCatalogInfoData, type InstallationData, type InstallationSource, type InstallationToolsData, type IntegrationGetData, type IntegrationInstallBody, type IntegrationInstallData, type IntegrationListData, type IntegrationUninstallData, JsonObject, Mapping, PROVIDER_CALLBACK_REDIRECT_ROUTE_PATH, type ProviderAppConfigSource, type ProviderSetupData, type PublicCompiledFlowVersionData, type PublicResolvedBindingData, type PublicResolvedToolBindingData, type PublicResolvedTriggerBindingData, RUN_CANCEL_ROUTE_SUBPATH, RUN_EVENTS_ROUTE_SUBPATH, RUN_ITEM_ROUTE_SUBPATH, type RegistrationSummaryData, type RemoveNodeInput, type RemoveTriggerInput, type RequestConnectInput, type RequestConnectOutput, STEP_RUN_STATUSES, type SaveFlowDraftInput, type SaveToolOutput, type SetCompositionInput, type SetFlowMetaInput, type SetOutputsInput, type SetTriggerInput, type SimulateTriggerBody, type SimulateTriggerData, type SimulateTriggerEventBody, type StepRunStatus, type StepRunSummaryData, TRIGGER_INSTANCES_ROUTE_SUBPATH, TRIGGER_SIMULATE_ROUTE_SUBPATH, TriggerBinding, type TriggerInstanceDiagnosticData, type TriggerInstanceLastErrorData, type TriggerInstanceStatus, type TriggerInstancesData, type TruncatedPlaceholder, type UpdateNodeInput, type ValidateFlowToolInput, type ValidateToolOutput, WORKSPACES_ROUTE_PREFIX, WORKSPACE_ACCESS_ROUTE_SUBPATH, WORKSPACE_API_KEYS_ROUTE_SUBPATH, WORKSPACE_API_KEY_CANONICAL_SCOPES, WORKSPACE_API_KEY_FULL_ACCESS_SCOPE, WORKSPACE_API_KEY_ITEM_ROUTE_SUBPATH, WORKSPACE_CONNECTION_MOUNT_PREFIX, WORKSPACE_FLOWS_ROUTE_PREFIX, WORKSPACE_FLOW_RUNS_ROUTE_PREFIX, WORKSPACE_INBOX_ENTRIES_ROUTE_PREFIX, WORKSPACE_INBOX_ITEMS_ROUTE_PREFIX, WORKSPACE_INTEGRATIONS_ROUTE_PREFIX, WORKSPACE_RUNS_ROUTE_PREFIX, type WorkingIrSummary, type WorkspaceAccessData, type WorkspaceApiKeyCreateBody, type WorkspaceApiKeyCreateData, type WorkspaceApiKeyData, type WorkspaceApiKeyListData, type WorkspaceApiKeyRevokeData, type WorkspaceApiKeyScope, type WorkspaceApiKeyStatus, type WorkspaceData, type WorkspaceMembershipData, type WorkspaceMembershipRole, agentChatPath, catalogDefaultProviderAppConfigPath, catalogIntegrationPath, catalogIntegrationsPath, catalogVersionsPath, connectCompletePath, connectOptionsPath, connectStartPath, connectSubmitPath, connectionDisconnectPath, currentUserPath, findFlowAuthoringToolDescriptor, flowDisablePath, flowDraftPath, flowEnablePath, flowPath, flowRunsPath, flowValidatePath, flowVersionPath, flowVersionsPath, formatFlowToolError, humanInputTokenPath, humanInputTokenSubmitPath, inboxEntryHumanInputSubmitPath, inboxEntryPath, inboxItemPath, installationToolsPath, runCancelPath, runEventsPath, runPath, triggerInstancesPath, triggerSimulatePath, workspaceApiKeyPath, workspaceApiKeysPath, workspaceConnectionsPath, workspaceFlowsPath, workspaceInboxEntriesPath, workspaceInboxItemsPath, workspaceIntegrationPath, workspaceIntegrationsPath, workspacePath, workspaceRunsPath };
954
+ export { AGENT_APPROVAL_EXPIRED_ERROR_CODE, AGENT_APPROVAL_NOT_FOUND_ERROR_CODE, AGENT_CANDIDATE_INVALID_ERROR_CODE, AGENT_CAPABILITY_FLOW_AUTHORING, AGENT_CHAT_ROUTE_SUBPATH, AGENT_FLOW_CONTEXT_ROUTE_SUBPATH, AGENT_MESSAGE_DELTA_INVALID_ERROR_CODE, AGENT_PAGE_CONTEXT_INVALID_ERROR_CODE, AGENT_PAGE_CONTEXT_MAX_RESOURCES, AGENT_PAGE_CONTEXT_RESOURCE_ID_MAX_LENGTH, AGENT_PAGE_CONTEXT_ROUTE_ID_MAX_LENGTH, AGENT_PAGE_RESOURCE_TYPES, AGENT_ROUTE_PREFIX, AGENT_RUNTIME_FAILED_ERROR_CODE, AGENT_RUNTIME_UNCONFIGURED_ERROR_CODE, AGENT_SESSIONS_ROUTE_SUBPATH, AGENT_SESSION_DETAIL_MESSAGE_LIMIT, AGENT_SESSION_ITEM_ROUTE_SUBPATH, AGENT_SESSION_LIST_DEFAULT_LIMIT, AGENT_SESSION_LIST_MAX_LIMIT, AGENT_SESSION_NOT_FOUND_ERROR_CODE, type AddNodeInput, type AgentCapabilityKind, type AgentChatRequestBody, type AgentPageContext, type AgentPageResourceRef, type AgentPageResourceType, type AgentSessionDetailData, type AgentSessionListData, type AgentSessionSummary, type AgentTaskSurface, type AgentUiMessageProjection, type AgentUiMessageRole, type Bounded, CATALOG_DEFAULT_PROVIDER_APP_CONFIG_ROUTE_SUBPATH, CATALOG_INTEGRATIONS_ROUTE_SUBPATH, CATALOG_INTEGRATION_DETAIL_ROUTE_SUBPATH, CATALOG_ROUTE_PREFIX, CATALOG_VERSIONS_ROUTE_SUBPATH, CONNECTIONS_ROUTE_SUBPATH, CONNECTION_DISCONNECT_ROUTE_SUBPATH, CONNECT_COMPLETE_ROUTE_SUBPATH, CONNECT_OPTIONS_ROUTE_SUBPATH, CONNECT_START_ROUTE_SUBPATH, CONNECT_SUBMIT_ROUTE_SUBPATH, CURRENT_USER_ROUTE_PATH, type CatalogDetailData, type CatalogDetailLatestData, type CatalogIntegrationSummaryData, type CatalogListData, type CatalogPublishData, type CatalogToolFunctionData, type CatalogTriggerFunctionData, type CatalogVersionSummaryData, type CompiledFlowVersionSummaryData, type ConnectCompleteResultData, type ConnectCompletedResultData, type ConnectDefaultUnavailableReason, type ConnectFieldDefData, type ConnectInputNextActionData, type ConnectInputTarget, type ConnectOptionsData, type ConnectRedirectNextActionData, type ConnectStartBody, type ConnectStartResultData, type ConnectSubmitBody, type ConnectSubmitResultData, type ConnectionAuthType, type ConnectionListData, type ConnectionSummaryData, type ControlPlaneToolData, type ControlPlaneToolDeliveryData, type ControlPlaneTriggerData, type CurrentUserData, type DefaultProviderAppConfigAdminData, type DefaultProviderAppConfigDisableData, type DefaultProviderAppConfigUpsertBody, type DefaultProviderAppConfigWriteData, type DeletedFlowSummaryData, type DeliverFlowRunEventData, type DisconnectResultData, FLOW_AUTHORING_EDIT_TOOL_NAMES, FLOW_AUTHORING_TOOL_DESCRIPTORS, FLOW_AUTHORING_TOOL_NAMES, FLOW_DISABLE_ROUTE_SUBPATH, FLOW_DRAFT_APPROVAL_DATA_PART_TYPE, FLOW_DRAFT_APPROVAL_KIND, FLOW_DRAFT_ROUTE_SUBPATH, FLOW_ENABLE_ROUTE_SUBPATH, FLOW_ITEM_ROUTE_SUBPATH, FLOW_RUN_STATUSES, FLOW_VALIDATE_ROUTE_SUBPATH, FLOW_VERSIONS_ROUTE_SUBPATH, FLOW_VERSION_ITEM_ROUTE_SUBPATH, type FlowAuthoringEditToolName, type FlowAuthoringToolDescriptor, type FlowAuthoringToolExecution, type FlowAuthoringToolInputSchema, type FlowAuthoringToolName, type FlowAuthoringWorkingDraftCandidate, type FlowBadgeData, FlowCompositionSpec, type FlowDeleteData, type FlowDraftApprovalProjection, type FlowDraftRecordData, type FlowDraftSaveSummary, type FlowListData, type FlowListItemData, type FlowMetaUpdate, FlowNode, type FlowPublishData, type FlowRecordData, type FlowRunCancelData, type FlowRunDetailData, type FlowRunListData, type FlowRunStatus, type FlowRunSummaryData, type FlowRunTerminalErrorData, type FlowRunTriggerData, type FlowStatus, type FlowToolError, type FlowValidateData, type FlowValidationIssueData, type FlowVersionGetData, type FlowVersionListData, type FlowWithDraftData, type GetFlowContextInput, type GetWorkingFlowIrInput, type GetWorkingFlowIrOutput, HUMAN_INPUT_TOKENS_ROUTE_PREFIX, HUMAN_INPUT_TOKEN_ROUTE_SUBPATH, HUMAN_INPUT_TOKEN_SUBMIT_ROUTE_SUBPATH, type HumanInputPublicOutputData, type HumanInputRequestViewData, type HumanInputSubmitPayload, type HumanInputTokenSubmitData, type HumanInputTokenViewData, INBOX_ENTRY_HUMAN_INPUT_SUBMIT_ROUTE_SUBPATH, INBOX_ENTRY_ROUTE_SUBPATH, INBOX_ITEM_ROUTE_SUBPATH, INTEGRATION_ITEM_ROUTE_SUBPATH, INTEGRATION_TOOLS_ROUTE_SUBPATH, type InboxEntryDetailData, type InboxEntryListData, type InboxEntryListEntryData, type InboxEntryStatus, type InboxEntryType, type InboxHumanInputEntryData, type InboxItemDetailData, type InboxItemDetailEntryData, type InboxItemListData, type InboxItemListEntryData, type InboxLinksData, type InboxReportData, type InstallationCatalogInfoData, type InstallationData, type InstallationSource, type InstallationToolsData, type IntegrationGetData, type IntegrationInstallBody, type IntegrationInstallData, type IntegrationListData, type IntegrationUninstallData, JsonObject, Mapping, PROVIDER_CALLBACK_REDIRECT_ROUTE_PATH, type ProviderAppConfigSource, type ProviderSetupData, type PublicCompiledFlowVersionData, type PublicResolvedBindingData, type PublicResolvedToolBindingData, type PublicResolvedTriggerBindingData, RUN_CANCEL_ROUTE_SUBPATH, RUN_EVENTS_ROUTE_SUBPATH, RUN_ITEM_ROUTE_SUBPATH, type RegistrationSummaryData, type RemoveNodeInput, type RemoveTriggerInput, type RequestConnectInput, type RequestConnectOutput, STEP_RUN_STATUSES, type SaveFlowDraftInput, type SaveToolOutput, type SetCompositionInput, type SetFlowMetaInput, type SetOutputsInput, type SetTriggerInput, type SimulateTriggerBody, type SimulateTriggerData, type SimulateTriggerEventBody, type StepRunStatus, type StepRunSummaryData, TRIGGER_INSTANCES_ROUTE_SUBPATH, TRIGGER_SIMULATE_ROUTE_SUBPATH, TriggerBinding, type TriggerInstanceDiagnosticData, type TriggerInstanceLastErrorData, type TriggerInstanceStatus, type TriggerInstancesData, type TruncatedPlaceholder, type UpdateNodeInput, type ValidateFlowToolInput, type ValidateToolOutput, WORKSPACES_ROUTE_PREFIX, WORKSPACE_ACCESS_ROUTE_SUBPATH, WORKSPACE_API_KEYS_ROUTE_SUBPATH, WORKSPACE_API_KEY_CANONICAL_SCOPES, WORKSPACE_API_KEY_FULL_ACCESS_SCOPE, WORKSPACE_API_KEY_ITEM_ROUTE_SUBPATH, WORKSPACE_CONNECTION_MOUNT_PREFIX, WORKSPACE_FLOWS_ROUTE_PREFIX, WORKSPACE_FLOW_RUNS_ROUTE_PREFIX, WORKSPACE_INBOX_ENTRIES_ROUTE_PREFIX, WORKSPACE_INBOX_ITEMS_ROUTE_PREFIX, WORKSPACE_INTEGRATIONS_ROUTE_PREFIX, WORKSPACE_RUNS_ROUTE_PREFIX, type WorkingIrSummary, type WorkspaceAccessData, type WorkspaceApiKeyCreateBody, type WorkspaceApiKeyCreateData, type WorkspaceApiKeyData, type WorkspaceApiKeyListData, type WorkspaceApiKeyRevokeData, type WorkspaceApiKeyScope, type WorkspaceApiKeyStatus, type WorkspaceData, type WorkspaceMembershipData, type WorkspaceMembershipRole, agentChatPath, agentSessionPath, agentSessionsPath, catalogDefaultProviderAppConfigPath, catalogIntegrationPath, catalogIntegrationsPath, catalogVersionsPath, connectCompletePath, connectOptionsPath, connectStartPath, connectSubmitPath, connectionDisconnectPath, currentUserPath, findFlowAuthoringToolDescriptor, flowDisablePath, flowDraftPath, flowEnablePath, flowPath, flowRunsPath, flowValidatePath, flowVersionPath, flowVersionsPath, formatFlowToolError, humanInputTokenPath, humanInputTokenSubmitPath, inboxEntryHumanInputSubmitPath, inboxEntryPath, inboxItemPath, installationToolsPath, runCancelPath, runEventsPath, runPath, triggerInstancesPath, triggerSimulatePath, workspaceApiKeyPath, workspaceApiKeysPath, workspaceConnectionsPath, workspaceFlowsPath, workspaceInboxEntriesPath, workspaceInboxItemsPath, workspaceIntegrationPath, workspaceIntegrationsPath, workspacePath, workspaceRunsPath };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- var ne="0.1.4";var Ze="flow.ir.v1";var re="flow.interp.v2";function u(e){return{ok:!0,value:e}}function o(e){return{ok:!1,reason:e}}function i(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var f="/internal/flow-runs",ot="/:flowRunId/execution-context";function it(e){return`${f}/${encodeURIComponent(e)}/execution-context`}function oe(e){return!i(e)||!F(e.fileMaxBytes)||!F(e.fileReadMaxBytes)||!F(e.inlineMultipartBytesMax)?o("file runtime limits must carry three positive integer bounds"):u({fileMaxBytes:e.fileMaxBytes,fileReadMaxBytes:e.fileReadMaxBytes,inlineMultipartBytesMax:e.inlineMultipartBytesMax})}function st(e){if(!i(e))return o("execution context must be a JSON object");let t=e.compiled;if(typeof e.flowRunId!="string"||typeof e.workspaceId!="string"||!i(e.input)||!i(t)||typeof t.irSchemaVersion!="string"||typeof t.interpreterContractVersion!="string"||typeof t.compiledArtifactId!="string"||!i(t.ir)||!Array.isArray(t.ir.nodes)||!se(e.executionBindings))return o("execution context surface shape is invalid");let n=ie(e.fileRuntime);return n.ok?u({...e,fileRuntime:n.value}):o(n.reason)}function ie(e){if(e===null)return u(null);if(!i(e))return o("fileRuntime must be null or an object");let t=oe(e.limits);return t.ok?u({limits:t.value}):o(t.reason)}function se(e){return Array.isArray(e)?e.every(t=>{if(!i(t))return!1;let n=t.connection;return typeof t.nodeId=="string"&&typeof t.toolRef=="string"&&i(t.toolDescriptor)&&i(t.integrationDescriptor)&&i(n)&&typeof n.installationId=="string"&&typeof n.connectionRef=="string"&&typeof n.connectionId=="string"&&typeof n.authType=="string"}):!1}function F(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0}var lt="/:flowRunId/steps/:nodeId/result",dt="/:flowRunId/result",ct="/:flowRunId/event-waits/:nodeId";function gt(e,t){return`${f}/${encodeURIComponent(e)}/steps/${encodeURIComponent(t)}/result`}function ft(e){return`${f}/${encodeURIComponent(e)}/result`}function mt(e,t){return`${f}/${encodeURIComponent(e)}/event-waits/${encodeURIComponent(t)}`}function yt(e){if(!i(e))return{ok:!1,kind:"validation",reason:"step record body must be a JSON object"};let t=y(e,["attempt","result","durationMs"]);if(t!==void 0)return{ok:!1,kind:"validation",reason:`step record does not accept the "${t}" field`};let n=e.attempt;if(typeof n!="number"||!Number.isInteger(n)||n<=0)return{ok:!1,kind:"validation",reason:"attempt must be a positive integer"};let r=ae(e.result);if(!r.ok)return r;let s={attempt:n,result:r.value};if(e.durationMs!==void 0){let a=e.durationMs;if(typeof a!="number"||!Number.isFinite(a)||a<0)return{ok:!1,kind:"validation",reason:"durationMs must be a non-negative number"};s.durationMs=a}return{ok:!0,value:s}}function ae(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=y(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=y(e,["status","errorCode","issues"]);if(n!==void 0)return{ok:!1,kind:"validation",reason:`step record result does not accept the "${n}" field`};let r=e.errorCode;if(typeof r!="string"||r.length===0)return{ok:!1,kind:"step_result_invalid",reason:"a failed result must carry a non-empty errorCode"};let s={status:"failed",errorCode:r};return e.issues!==void 0&&(s.issues=e.issues),{ok:!0,value:s}}return{ok:!1,kind:"step_result_invalid",reason:'result status must be "succeeded" or "failed"'}}function Rt(e){return!i(e)||typeof e.flowRunId!="string"||typeof e.nodeId!="string"||e.recorded!=="succeeded"&&e.recorded!=="failed"?o("step record data surface shape is invalid"):u({flowRunId:e.flowRunId,nodeId:e.nodeId,recorded:e.recorded})}function It(e){if(!i(e))return o("result body must be a JSON object");let t=y(e,["status","output","error","composition"]);if(t!==void 0)return o(`result does not accept the "${t}" field`);let n=e.status;if(n!=="succeeded"&&n!=="failed")return o('result status must be "succeeded" or "failed"');let r={status:n};if(e.output!==void 0&&(r.output=e.output),e.error!==void 0){let s=e.error;if(!i(s))return o("result error must be a JSON object");let a=y(s,["code","message"]);if(a!==void 0)return o(`result error does not accept the "${a}" field`);if(typeof s.code!="string"||typeof s.message!="string")return o("result error must carry string code and message");r.error={code:s.code,message:s.message}}if(e.composition!==void 0){if(n!=="succeeded")return o("composition is only allowed on a succeeded result");r.composition=e.composition}return u(r)}function _t(e){return i(e)?u(e):o("flow run result data must be a JSON object")}var ue=/^[A-Za-z0-9_-]{1,100}$/;function xt(e){if(!i(e))return o("register body must be a JSON object");let t=y(e,["eventType","correlationKey"]);if(t!==void 0)return o(`register wait does not accept the "${t}" field`);let n=K(e.eventType);if(!n.ok)return o(n.reason);let r=e.correlationKey;return typeof r!="string"||r.length===0?o("correlationKey must be a non-empty string"):u({eventType:n.value,correlationKey:r})}function kt(e){if(!i(e))return o("complete body must be a JSON object");let t=y(e,["eventType","correlationKey","outcome","eventId"]);if(t!==void 0)return o(`complete wait does not accept the "${t}" field`);let n=e.outcome;if(n!=="received"&&n!=="timed_out")return o('outcome must be "received" or "timed_out"');let r=K(e.eventType);if(!r.ok)return o(r.reason);let s=e.correlationKey;if(typeof s!="string"||s.length===0)return o("correlationKey must be a non-empty string");let a={eventType:r.value,correlationKey:s,outcome:n};if(e.eventId!==void 0){if(typeof e.eventId!="string"||e.eventId.length===0)return o("eventId must be a non-empty string");a.eventId=e.eventId}return u(a)}function Tt(e){return!i(e)||e.registered!==!0?o("register wait data surface shape is invalid"):u({registered:!0})}function K(e){return typeof e!="string"||e.length===0?o("eventType must be a non-empty string"):ue.test(e)?u(e):o("eventType must match ^[A-Za-z0-9_-]{1,100}$")}function y(e,t){return Object.keys(e).find(n=>!t.includes(n))}var pe="/internal/flow-versions",Et="/:flowVersionId/handler-bundles",H="/internal/installations",ht="/:installationId/handler-bundles";function At(e,t){return`${pe}/${encodeURIComponent(e)}/handler-bundles?compiledArtifactId=${encodeURIComponent(t)}`}function Pt(e){return`${H}/${encodeURIComponent(e.installationId)}/handler-bundles?workspaceId=${encodeURIComponent(e.workspaceId)}&artifactDigest=${encodeURIComponent(e.artifactDigest)}`}var le=new Set(["managed_only","managed_plus_unmanaged_sdk"]);function P(e){if(!R(e))return B("runtimeNetwork must be a JSON object");let t=e.networkModel;return typeof t!="string"||!le.has(t)?B("runtimeNetwork.networkModel is unknown"):!V(e.apiHosts)||!V(e.authHosts)||typeof e.httpsOnly!="boolean"?B("runtimeNetwork host/https fields are invalid"):{ok:!0,value:{networkModel:t,apiHosts:e.apiHosts,authHosts:e.authHosts,httpsOnly:e.httpsOnly}}}function St(e){if(!R(e)||typeof e.flowVersionId!="string"||typeof e.compiledArtifactId!="string"||!Array.isArray(e.bundles))return T("handler bundles data surface shape is invalid");let t=q(e.bundles);return t.ok?{ok:!0,value:{flowVersionId:e.flowVersionId,compiledArtifactId:e.compiledArtifactId,bundles:t.value}}:t}function bt(e){if(!R(e)||typeof e.installationId!="string"||typeof e.artifactDigest!="string"||!Array.isArray(e.bundles))return T("tool handler bundles data surface shape is invalid");let t=q(e.bundles);return t.ok?{ok:!0,value:{installationId:e.installationId,artifactDigest:e.artifactDigest,bundles:t.value}}:t}function q(e){let t=[];for(let n of e){let r=de(n);if(!r.ok)return r;t.push(r.value)}return{ok:!0,value:t}}function de(e){if(!R(e)||typeof e.toolRef!="string"||e.kind!=="handler"&&e.kind!=="request")return T("handler bundle entry shape is invalid");if(e.kind==="request"){if(e.module!==void 0)return T("a request bundle must not carry a module");let r=P(e.runtimeNetwork);return r.ok?{ok:!0,value:{toolRef:e.toolRef,kind:"request",runtimeNetwork:r.value}}:r}let t=e.module;if(!R(t)||typeof t.entry!="string"||t.entry.length===0||!ce(t.files))return T("a handler bundle must carry a { entry, files } module");let n=P(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 T(e){return{ok:!1,kind:"shape",reason:e}}function B(e){return{ok:!1,kind:"runtime_network",reason:e}}function R(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function V(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function ce(e){return R(e)&&Object.values(e).every(t=>typeof t=="string")}var w="/internal/webhook-trigger-instances",Dt="/:triggerInstanceId/context",Ut="/:triggerInstanceId/handler-bundles",Ft="/:triggerInstanceId/deliveries/:deliveryId",Bt="/:triggerInstanceId/events",Ht="/:triggerInstanceId/rearm",$t="/:triggerInstanceId/store/:namespace/:key",I=e=>`${w}/${encodeURIComponent(e)}`;function Lt(e,t){return`${I(e)}/context?artifactDigest=${encodeURIComponent(t)}`}function Mt(e,t){return`${I(e)}/handler-bundles?artifactDigest=${encodeURIComponent(t)}`}function Gt(e,t){return`${I(e)}/deliveries/${encodeURIComponent(t)}`}function Wt(e){return`${I(e)}/events`}function Kt(e){return`${I(e)}/rearm`}function Vt(e,t,n){return`${I(e)}/store/${encodeURIComponent(t)}/${encodeURIComponent(n)}`}var qt="/:installationId/webhook-protocol-adapter-bundle";function jt(e){return`${H}/${encodeURIComponent(e.installationId)}/webhook-protocol-adapter-bundle?workspaceId=${encodeURIComponent(e.workspaceId)}&artifactDigest=${encodeURIComponent(e.artifactDigest)}`}var Jt="modules/webhook/protocol-adapter.js";function Xt(e){return`modules/webhook/protocol-adapter-${e}.js`}function Yt(e){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&&!ge(e.connection)||!fe(e.runtime)?o("webhook watcher context surface shape is invalid"):u(e)}function ge(e){return i(e)&&typeof e.connectionId=="string"&&typeof e.connectionRef=="string"&&typeof e.integrationRef=="string"&&typeof e.authType=="string"}function fe(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 zt(e){if(!i(e)||typeof e.deliveryId!="string"||typeof e.receivedAt!="string"||!i(e.request))return o("webhook delivery surface shape is invalid");let t=e.request;return t.method!=="POST"||!i(t.headers)||typeof t.rawBody!="string"?o("webhook delivery request shape is invalid"):u(e)}function Qt(e){if(!i(e)||typeof e.triggerRef!="string"||typeof e.artifactDigest!="string"||!Array.isArray(e.modules)||!e.modules.every(me))return{ok:!1,kind:"shape",reason:"trigger handler bundles data surface shape is invalid"};let t=P(e.runtimeNetwork);return t.ok?{ok:!0,value:{triggerRef:e.triggerRef,artifactDigest:e.artifactDigest,modules:e.modules,runtimeNetwork:t.value}}:t}function me(e){return i(e)&&typeof e.specifier=="string"&&e.specifier.length>0&&typeof e.source=="string"}function ye(e){return!i(e)||!("value"in e)?o("webhook store get surface shape is invalid"):u(e.value)}function Zt(e){if(!i(e))return o("publish events body must be a JSON object");let t=S(e,["deliveryId","events"]);if(t!==void 0)return o(`publish events does not accept the "${t}" field`);let n=e.deliveryId;if(typeof n!="string"||n.length===0)return o("deliveryId must be a non-empty string");let r=e.events;if(!Array.isArray(r))return o("events must be an array");let s=[];for(let a of r){let p=Re(a);if(!p.ok)return p;s.push(p.value)}return u({deliveryId:n,events:s})}function Re(e){if(!i(e))return o("each event must be a JSON object");let t=S(e,["eventId","occurredAt","dedupeKey","payload"]);if(t!==void 0)return o(`event does not accept the "${t}" field`);let n=e.eventId;if(typeof n!="string"||n.length===0)return o("eventId must be a non-empty string");let r=e.occurredAt;if(typeof r!="string"||r.length===0)return o("occurredAt must be a non-empty string");if(!i(e.payload))return o("event payload must be a JSON object");let s={eventId:n,occurredAt:r,payload:e.payload};if(e.dedupeKey!==void 0){if(typeof e.dedupeKey!="string"||e.dedupeKey.length===0)return o("dedupeKey must be a non-empty string");s.dedupeKey=e.dedupeKey}return u(s)}function en(e){if(!i(e))return o("rearm body must be a JSON object");let t=S(e,["expectedWatcherInstanceId"]);if(t!==void 0)return o(`rearm does not accept the "${t}" field`);let n=e.expectedWatcherInstanceId;return typeof n!="string"||n.length===0?o("expectedWatcherInstanceId must be a non-empty string"):u({expectedWatcherInstanceId:n})}function Ie(e){if(!i(e))return o("store body must be a JSON object");let t=S(e,["value"]);return t!==void 0?o(`store put does not accept the "${t}" field`):"value"in e?u({value:e.value}):o("store put requires a value field")}function S(e,t){return Object.keys(e).find(n=>!t.includes(n))}var E="/internal/polling-trigger-instances",rn="/:pollingInstanceId/context",on="/:pollingInstanceId/handler-bundles",sn="/:pollingInstanceId/ticks/:tickId/events",an="/:pollingInstanceId/store/:namespace/:key",b=e=>`${E}/${encodeURIComponent(e)}`;function un(e,t,n){return`${b(e)}/context?artifactDigest=${encodeURIComponent(t)}&tickId=${encodeURIComponent(n)}`}function pn(e,t){return`${b(e)}/handler-bundles?artifactDigest=${encodeURIComponent(t)}`}function ln(e,t){return`${b(e)}/ticks/${encodeURIComponent(t)}/events`}function dn(e,t,n){return`${b(e)}/store/${encodeURIComponent(t)}/${encodeURIComponent(n)}`}function cn(e){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&&!_e(e.connection)||!xe(e.runtime)||!ke(e.tick)||!Te(e.limits)?o("polling trigger context surface shape is invalid"):u(e)}function _e(e){return i(e)&&typeof e.connectionId=="string"&&typeof e.connectionRef=="string"&&typeof e.integrationRef=="string"&&typeof e.authType=="string"}function xe(e){if(!i(e)||e.type!=="polling"||typeof e.trigger_id!="string"||typeof e.trigger_ref!="string")return!1;let t=e.polling;if(!i(t)||typeof t.run_handler_module!="string")return!1;let n=t.schedule;if(!i(n)||n.type!=="interval"||typeof n.every_seconds!="number")return!1;let r=t.dedup;return i(r)&&(r.strategy==="cursor"||r.strategy==="hash"||r.strategy==="id_field")}function ke(e){return i(e)&&typeof e.tickId=="string"&&typeof e.scheduledAt=="string"&&typeof e.attempt=="number"}function Te(e){return i(e)&&typeof e.maxEventsPerTick=="number"}function gn(e){if(!i(e))return o("publish body must be a JSON object");let t=j(e,["events","nextCursor"]);if(t!==void 0)return o(`publish does not accept the "${t}" field`);let n=e.events;if(!Array.isArray(n))return o("events must be an array");let r=[];for(let a of n){let p=we(a);if(!p.ok)return p;r.push(p.value)}let s={events:r};if("nextCursor"in e){let a=e.nextCursor;if(a!==null&&typeof a!="string")return o("nextCursor must be a string, null, or omitted");s.nextCursor=a}return u(s)}function we(e){if(!i(e))return o("each event must be a JSON object");let t=j(e,["eventId","occurredAt","dedupeKey","payload"]);if(t!==void 0)return o(`event does not accept the "${t}" field`);if(typeof e.eventId!="string"||e.eventId.length===0)return o("event eventId must be a non-empty string");if(!i(e.payload))return o("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 o("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 o("event dedupeKey must be a non-empty string");n.dedupeKey=e.dedupeKey}return u(n)}function fn(e){return!i(e)||typeof e.tickId!="string"||typeof e.cursorUpdated!="boolean"||!Array.isArray(e.results)||!e.results.every(Ee)?o("publish polling tick events data surface shape is invalid"):u(e)}function Ee(e){return i(e)&&typeof e.eventId=="string"&&typeof e.dedupeKey=="string"&&typeof e.duplicate=="boolean"&&(e.flowRunId===null||typeof e.flowRunId=="string")}function j(e,t){return Object.keys(e).find(n=>!t.includes(n))}var J="/internal/egress-grants",$="/internal/tool-invocations",kn="/:flowRunId/egress-grant",Tn="/:invocationId/egress-grant",wn="/:pollingInstanceId/egress-grant",En="/:triggerInstanceId/egress-grant",hn="/:grantId/consume",An="/:grantId/audit",Pn=e=>`${f}/${encodeURIComponent(e)}/egress-grant`,Sn=e=>`${$}/${encodeURIComponent(e)}/egress-grant`,bn=e=>`${E}/${encodeURIComponent(e)}/egress-grant`,Nn=e=>`${w}/${encodeURIComponent(e)}/egress-grant`,Cn=e=>`${J}/${encodeURIComponent(e)}/consume`,On=e=>`${J}/${encodeURIComponent(e)}/audit`,he=["flow_action","single_tool","polling_trigger","webhook_trigger"],Ae=/^[A-Za-z0-9][A-Za-z0-9:_+/=.-]{15,1023}$/;function h(e){return typeof e=="string"&&Ae.test(e)}function Pe(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(r=>i(r)?r.kind==="file"&&typeof r.file_id=="string"&&r.file_id.length>0:!1):!1}function l(e){return{ok:!1,kind:"shape",reason:e}}function A(){return{ok:!1,kind:"request_digest",reason:"request digest is missing or malformed"}}function C(e,t){if(!i(e))return{ok:!1,reason:"grant request body must be a JSON object"};for(let n of Object.keys(e))if(!t.includes(n))return{ok:!1,reason:`grant request does not accept the "${n}" field`};return{ok:!0,record:e}}function O(e){if(!i(e))return"request must be a JSON object"}function vn(e){let t=C(e,["nodeId","request","requestDigest"]);if(!t.ok)return l(t.reason);let n=t.record.nodeId;if(typeof n!="string"||n.length===0)return l("nodeId is required");let r=O(t.record.request);if(r!==void 0)return l(r);let s=t.record.requestDigest;return h(s)?{ok:!0,value:{nodeId:n,requestDigest:s,requestHasMultipartFiles:Pe(t.record.request)}}:A()}function Dn(e){let t=C(e,["request","requestDigest"]);if(!t.ok)return l(t.reason);let n=O(t.record.request);if(n!==void 0)return l(n);let r=t.record.requestDigest;return h(r)?{ok:!0,value:{requestDigest:r}}:A()}function Un(e){let t=C(e,["tickId","request","requestDigest"]);if(!t.ok)return l(t.reason);let n=t.record.tickId;if(typeof n!="string"||n.length===0)return l("tickId is required");let r=O(t.record.request);if(r!==void 0)return l(r);let s=t.record.requestDigest;return h(s)?{ok:!0,value:{tickId:n,requestDigest:s}}:A()}function Fn(e){let t=C(e,["phase","lifecycle","request","requestDigest"]);if(!t.ok)return l(t.reason);let n=t.record.phase;if(n!=="lifecycle"&&n!=="handler")return l('phase must be "lifecycle" or "handler"');let r=t.record.lifecycle,s;if(r!==void 0){if(r!=="enable"&&r!=="disable"&&r!=="renew")return l('lifecycle must be "enable", "disable", or "renew"');s=r}if(n==="lifecycle"&&s===void 0)return l("lifecycle is required for the lifecycle phase");let a=O(t.record.request);if(a!==void 0)return l(a);let p=t.record.requestDigest;return h(p)?{ok:!0,value:{phase:n,...s!==void 0?{lifecycle:s}:{},requestDigest:p}}:A()}function X(e){return he.includes(e)?e:void 0}var Se=["scopeKind","scopeId","requestDigest"];function Bn(e){if(!i(e))return l("consume body must be a JSON object");for(let s of Object.keys(e))if(!Se.includes(s))return l(`consume does not accept the "${s}" field`);let t=X(e.scopeKind);if(t===void 0)return l("scopeKind is invalid");let n=e.scopeId;if(typeof n!="string"||n.length===0)return l("scopeId is required");let r=e.requestDigest;return h(r)?{ok:!0,value:{scopeKind:t,scopeId:n,requestDigest:r}}:A()}var be=["scopeKind","scopeId","providerHost","status","durationMs","requestBytes","responseBytes","errorCode"];function N(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 Hn(e){if(!i(e))return l("audit body must be a JSON object");for(let c of Object.keys(e))if(!be.includes(c))return l(`audit does not accept the "${c}" field`);let t=X(e.scopeKind);if(t===void 0)return l("scopeKind is invalid");let n=e.scopeId;if(typeof n!="string"||n.length===0)return l("scopeId is required");let r=e.providerHost;if(typeof r!="string"||r.length===0)return l("providerHost is required");let s=N(e.durationMs,"durationMs");if(!s.ok)return l(s.reason);let a;if(e.status!==void 0){let c=N(e.status,"status");if(!c.ok)return l(c.reason);a=c.value}let p;if(e.requestBytes!==void 0){let c=N(e.requestBytes,"requestBytes");if(!c.ok)return l(c.reason);p=c.value}let d;if(e.responseBytes!==void 0){let c=N(e.responseBytes,"responseBytes");if(!c.ok)return l(c.reason);d=c.value}let U;if(e.errorCode!==void 0){let c=e.errorCode;if(typeof c!="string"||c.length===0)return l("errorCode must be a non-empty string");U=c}return{ok:!0,value:{scopeKind:t,scopeId:n,providerHost:r,...a!==void 0?{status:a}:{},durationMs:s.value,...p!==void 0?{requestBytes:p}:{},...d!==void 0?{responseBytes:d}:{},...U!==void 0?{errorCode:U}:{}}}}function $n(e){return!i(e)||!i(e.grant)?o("egress grant envelope must carry a grant object"):u(e.grant)}function Ln(e){return!i(e)||e.consumed!==!0?o("egress grant consume data must carry consumed:true"):u({consumed:!0})}var jn="/:flowRunId/runtime-credential",Jn="/:invocationId/runtime-credential",Xn="/:pollingInstanceId/runtime-credential",Yn="/:triggerInstanceId/runtime-credential",zn=e=>`${f}/${encodeURIComponent(e)}/runtime-credential`,Qn=e=>`${$}/${encodeURIComponent(e)}/runtime-credential`,Zn=e=>`${E}/${encodeURIComponent(e)}/runtime-credential`,er=e=>`${w}/${encodeURIComponent(e)}/runtime-credential`,tr=["flow_action","tool_invoke","polling_trigger","webhook_trigger"];function v(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 nr(e){let t=v(e,["nodeId"]);if(!t.ok)return o(t.reason);let n=t.record.nodeId;return typeof n!="string"||n.length===0?o("nodeId is required"):u({nodeId:n})}function rr(e){let t=v(e??{},[]);return t.ok?u(null):o(t.reason)}function or(e){let t=v(e,["tickId"]);if(!t.ok)return o(t.reason);let n=t.record.tickId;return typeof n!="string"||n.length===0?o("tickId is required"):u({tickId:n})}function ir(e){let t=v(e,["executionKind","deliveryId","lifecycleOperation"]);if(!t.ok)return o(t.reason);let n=t.record.executionKind;if(n!=="event_handler"&&n!=="lifecycle")return o('executionKind must be "event_handler" or "lifecycle"');let r,s=t.record.deliveryId;if(s!==void 0){if(typeof s!="string"||s.length===0)return o("deliveryId must be a non-empty string");r=s}let a,p=t.record.lifecycleOperation;if(p!==void 0){if(p!=="enable"&&p!=="disable"&&p!=="renew")return o('lifecycleOperation must be "enable", "disable", or "renew"');a=p}return n==="lifecycle"&&a===void 0?o("lifecycleOperation is required for the lifecycle execution kind"):u({executionKind:n,...r!==void 0?{deliveryId:r}:{},...a!==void 0?{lifecycleOperation:a}:{}})}function sr(e){return!i(e)||typeof e.sessionId!="string"||typeof e.connectionId!="string"||!i(e.credential)?o("runtime credential session must carry sessionId, connectionId and a credential object"):u(e.credential)}var L="/internal/files",pr="/:fileId/stat",lr="/:fileId/content",dr=()=>L,Y=e=>`?scope_kind=${encodeURIComponent(e.scopeKind)}&scope_id=${encodeURIComponent(e.scopeId)}`,cr=(e,t)=>`${L}/${encodeURIComponent(e)}/stat${Y(t)}`,gr=(e,t)=>`${L}/${encodeURIComponent(e)}/content${Y(t)}`;function fr(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"?o("file ref data does not match the AIS file-ref shape"):u(e)}var Ir="/:flowRunId/human-inputs",_r="/:flowRunId/human-inputs/:requestId",xr="/:flowRunId/human-inputs/:requestId/expire",kr="/:flowRunId/human-inputs/:requestId/acknowledge",Ne=e=>`${f}/${encodeURIComponent(e)}/human-inputs`,z=(e,t)=>`${Ne(e)}/${encodeURIComponent(t)}`,Tr=(e,t)=>`${z(e,t)}/expire`,wr=(e,t)=>`${z(e,t)}/acknowledge`,Ce="human_input_resolved";function Er(e){return`${Ce}_${e}`}function g(e){return{ok:!1,reason:e}}function m(e,t){return i(e)?{ok:!0,value:e}:g(`${t} must be an object`)}function _(e,t){return typeof e!="string"||e.length===0?g(`${t} must be a non-empty string`):{ok:!0,value:e}}var Oe=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?(?:Z|[+-]\d{2}:\d{2})$/;function ve(e,t){return typeof e!="string"||!Oe.test(e)||Number.isNaN(Date.parse(e))?g(`${t} must be an ISO-8601 timestamp`):{ok:!0,value:e}}function De(e){let t=m(e,"renderedPrompt");if(!t.ok)return t;let n=_(t.value.title,"renderedPrompt.title");if(!n.ok)return n;let r={title:n.value};if(t.value.body!==void 0){if(typeof t.value.body!="string")return g("renderedPrompt.body must be a string");r.body=t.value.body}if(t.value.format!==void 0){if(t.value.format!=="plain"&&t.value.format!=="markdown")return g("renderedPrompt.format is invalid");r.format=t.value.format}return{ok:!0,value:r}}function Ue(e){let t=m(e,"input");if(!t.ok)return t;let n=t.value.kind;if(n==="choice"){if(!Array.isArray(t.value.choices))return g("input.choices must be an array")}else if(n!=="text")if(n==="form"){if(!Array.isArray(t.value.fields))return g("input.fields must be an array")}else return g("input.kind is invalid");return{ok:!0,value:t.value}}function Fe(e){if(e==null)return{ok:!0,value:void 0};let t=m(e,"partiallyRenderedDelivery");if(!t.ok)return t;let n=t.value.actions;if(n===void 0)return{ok:!0,value:{}};if(!Array.isArray(n))return g("partiallyRenderedDelivery.actions must be an array");let r=[];for(let s of n){let a=m(s,"delivery action");if(!a.ok)return a;let p=_(a.value.id,"delivery action id");if(!p.ok)return p;let d=Q(a.value.inputs,`delivery action '${p.value}' inputs`);if(!d.ok)return d;r.push({id:p.value,inputs:d.value})}return{ok:!0,value:{actions:r}}}function Q(e,t){let n=m(e,t);if(!n.ok)return n;let r={};for(let[s,a]of Object.entries(n.value)){let p=Z(a,`${t}.${s}`);if(!p.ok)return p;r[s]=p.value}return{ok:!0,value:r}}function Z(e,t){let n=m(e,t);if(!n.ok)return n;switch(n.value.kind){case"literal":return{ok:!0,value:{kind:"literal",value:n.value.value}};case"human_input_ref":{let s=_(n.value.path,`${t}.path`);return s.ok?{ok:!0,value:{kind:"human_input_ref",path:s.value}}:s}case"array":{if(!Array.isArray(n.value.items))return g(`${t}.items must be an array`);let s=[];for(let[a,p]of n.value.items.entries()){let d=Z(p,`${t}[${a}]`);if(!d.ok)return d;s.push(d.value)}return{ok:!0,value:{kind:"array",items:s}}}case"object":{let s=Q(n.value.entries,`${t}.entries`);return s.ok?{ok:!0,value:{kind:"object",entries:s.value}}:s}case"template":{if(!Array.isArray(n.value.parts))return g(`${t}.parts must be an array`);let s=[];for(let[a,p]of n.value.parts.entries()){let d=Be(p,`${t}.parts[${a}]`);if(!d.ok)return d;s.push(d.value)}return{ok:!0,value:{kind:"template",parts:s}}}default:return g(`${t}.kind is invalid`)}}function Be(e,t){let n=m(e,t);if(!n.ok)return n;let r=n.value.kind;if(r==="literal")return typeof n.value.value!="string"?g(`${t}.value must be a string`):{ok:!0,value:{kind:"literal",value:n.value.value}};if(r==="human_input_ref"){let s=_(n.value.path,`${t}.path`);return s.ok?{ok:!0,value:{kind:"human_input_ref",path:s.value}}:s}return g(`${t}.kind is invalid`)}function hr(e){let t=m(e,"request body");if(!t.ok)return o(t.reason);let n=_(t.value.nodeId,"nodeId");if(!n.ok)return o(n.reason);let r=De(t.value.renderedPrompt);if(!r.ok)return o(r.reason);let s=Ue(t.value.input);if(!s.ok)return o(s.reason);let a=_(t.value.timeout,"timeout");if(!a.ok)return o(a.reason);let p=ve(t.value.expiresAt,"expiresAt");if(!p.ok)return o(p.reason);let d=Fe(t.value.partiallyRenderedDelivery);return d.ok?u({nodeId:n.value,renderedPrompt:r.value,input:s.value,timeout:a.value,expiresAt:p.value,...d.value!==void 0?{partiallyRenderedDelivery:d.value}:{}}):o(d.reason)}function He(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))?o("human input request view must carry id, nodeId, status and output"):u(e)}function Ar(e){if(!i(e)||typeof e.created!="boolean")return o("human input create data must carry created:boolean");let t=He(e.request);return t.ok?u({created:e.created,request:t.value}):t}function Pr(e){return!i(e)||e.acknowledged!==!0?o("human input acknowledge data must carry acknowledged:true"):u({acknowledged:!0})}var br="ablehi-wfp-user-runtime-manifest/v1",Nr="unknown";function Cr(e){return e.endsWith(".js")?`${e.slice(0,-3)}.manifest.json`:`${e}.manifest.json`}var vr="/internal/deployment-handshake",$e=["start","terminate","send-event","start-webhook-watcher","run-polling-tick","invoke-tool","invoke-trigger-handler","invoke-webhook-protocol-adapter","deployment-handshake"],Dr=$e,Ur="HANDSHAKE_REQUEST_INVALID",Fr="HANDSHAKE_SECRET_UNCONFIGURED",Br="HANDSHAKE_SECRET_MISMATCH",Hr="HANDSHAKE_CONTRACT_VERSION_MISMATCH",$r="HANDSHAKE_DISPATCH_NAMESPACE_MISMATCH",Lr="HANDSHAKE_CAPABILITY_MISSING";function Mr(e){return[e.nonce,e.timestamp,e.contractVersion,e.dispatchNamespace].map(n=>`${n.length}:${n}`).join(".")}function Gr(e){return["response",e.nonce,e.contractVersion,e.dispatchNamespace,...e.capabilities].map(n=>`${n.length}:${n}`).join(".")}var Kr="/me",Vr=()=>"/me";var M="/workspaces",jr="/:workspaceId",Jr=e=>`${M}/${encodeURIComponent(e)}`;var zr="/:workspaceId/api-keys",Qr="/:workspaceId/api-keys/:apiKeyId",Le=e=>`${M}/${encodeURIComponent(e)}/api-keys`,Zr=(e,t)=>`${Le(e)}/${encodeURIComponent(t)}`,Me="workspace.full_access",eo=[Me];var G="/catalog",no="/integrations",ro="/integrations/:slug",oo="/versions",io="/integrations/:slug/default-provider-app-config",so=e=>{let t=`${G}/integrations`;return e?.category!==void 0&&e.category!==""?`${t}?category=${encodeURIComponent(e.category)}`:t},Ge=e=>`${G}/integrations/${encodeURIComponent(e)}`,ao=()=>`${G}/versions`,uo=e=>`${Ge(e)}/default-provider-app-config`;var lo="/workspaces/:workspaceId/integrations",co="/:installationId",go="/:installationId/tools",We=e=>`/workspaces/${encodeURIComponent(e)}/integrations`,Ke=(e,t)=>`${We(e)}/${encodeURIComponent(t)}`,fo=(e,t)=>`${Ke(e,t)}/tools`;var yo="/workspaces/:workspaceId",Ro="/connections",Io="/integrations/:installationId/connect/start",_o="/integrations/:installationId/connect/options",xo="/connect-sessions/:sessionId/submit",ko="/connect-sessions/:sessionId/complete",To="/integrations/:installationId/connections/:connectionRef",wo="/callbacks/redirect",x=e=>`/workspaces/${encodeURIComponent(e)}`,Eo=e=>`${x(e)}/connections`,ho=(e,t)=>`${x(e)}/integrations/${encodeURIComponent(t)}/connect/start`,Ao=(e,t)=>`${x(e)}/integrations/${encodeURIComponent(t)}/connect/options`,Po=(e,t)=>`${x(e)}/connect-sessions/${encodeURIComponent(t)}/submit`,So=(e,t)=>`${x(e)}/connect-sessions/${encodeURIComponent(t)}/complete`,bo=(e,t,n)=>`${x(e)}/integrations/${encodeURIComponent(t)}/connections/${encodeURIComponent(n)}`;var Co="/workspaces/:workspaceId/flows",Oo="/validate",vo="/:flowId",Do="/:flowId/enable",Uo="/:flowId/disable",Fo="/:flowId/draft",Bo="/:flowId/versions",Ho="/:flowId/versions/:version",ee=e=>`/workspaces/${encodeURIComponent(e)}/flows`,$o=e=>`${ee(e)}/validate`,D=(e,t)=>`${ee(e)}/${encodeURIComponent(t)}`,Lo=(e,t)=>`${D(e,t)}/enable`,Mo=(e,t)=>`${D(e,t)}/disable`,Go=(e,t)=>`${D(e,t)}/draft`,Ve=(e,t)=>`${D(e,t)}/versions`,Wo=(e,t,n)=>`${Ve(e,t)}/${n}`;var Vo="/workspaces/:workspaceId/agent",qo="/chat",jo="/flow-context",Jo=e=>`/workspaces/${encodeURIComponent(e)}/agent/chat`,Xo="flow_authoring",Yo=["getFlowContext","getWorkingFlowIr","setFlowMeta","addNode","updateNode","removeNode","setTrigger","removeTrigger","setOutputs","setComposition","validateFlow","saveFlowDraft","requestConnect"],zo=["setFlowMeta","addNode","updateNode","removeNode","setTrigger","removeTrigger","setOutputs","setComposition"];function Qo(e){return JSON.stringify(e)}var W={type:"object",properties:{},additionalProperties:!1},k={type:"object",additionalProperties:!0},qe=[{name:"getFlowContext",execution:"server",description:"Read the current workspace environment snapshot (installed integrations, their control-plane tools and triggers with stable refs, and active connections). Call this first to learn which toolRef / triggerRef / connectionRef values are available before editing the flow.",inputSchema:W},{name:"getWorkingFlowIr",execution:"client",description:"Read the current browser working flow IR (flow.ir.v1), including existing triggers, nodes, outputs, and composition. Call this before editing an existing or non-empty flow, or whenever you need to inspect the current flow state.",inputSchema:W},{name:"setFlowMeta",execution:"client",description:"Set the working flow metadata: the flow logical name and/or its inputSchema (the $input contract).",inputSchema:{type:"object",properties:{flow:{type:"string",description:"Flow logical name."},inputSchema:{...k,description:"JSON object describing $input."}},additionalProperties:!1}},{name:"addNode",execution:"client",description:"Add one node to the working flow IR. node.kind is action | wait_event | sleep | human_input. action needs { id, kind:'action', toolRef, connectionRef, inputs }. wait_event needs { id, kind:'wait_event', eventType, correlation, timeout, onTimeout }. sleep needs { id, kind:'sleep', duration }. human_input needs { id, kind:'human_input', prompt:{ title, body?, format?:'plain'|'markdown' }, input, timeout, delivery? } \u2014 use it whenever the flow must WAIT for a person to review/approve/choose/answer before continuing; never use a normal action node or a provider approval tool as the wait point. human_input.input is { kind:'choice', choices:[{ id, label, style? }], allowComment? } | { kind:'text', multiline?, placeholder?, required? } | { kind:'form', fields:[{ id, label, type:'text'|'textarea'|'number'|'boolean'|'select', required?, options? }] }. Approve/reject is input.kind:'choice' with choices approve and reject (reject is just a choice with NO automatic side effect; wire any reject behavior yourself). Three or more options is the same choice kind with more choices. Free text is input.kind:'text'; structured answers are input.kind:'form'. Downstream nodes read $nodes.<human_input_id>.output, whose runtime shape is { status:'submitted', response, actor, submissionSource, submittedAt } | { status:'expired', actor, expiredAt } \u2014 the submitted value is nested under output.response ({ kind:'choice', choiceId, comment? } | { kind:'text', text } | { kind:'form', values }), NEVER directly on output. Examples: choice branch runIf { eq:[ $nodes.review.output.response.choiceId, 'approve' ] }; text value ${$nodes.ask.output.response.text}; form field ${$nodes.details.output.response.values.priority}; timeout branch runIf { eq:[ $nodes.review.output.status, 'expired' ] } (an expired human_input is a normal output, not a failure). Optional external notifications go under delivery.actions[] as { id, toolRef, connectionRef, inputs } using the SAME action triad as an action node (concrete string toolRef + concrete user-chosen string connectionRef + inputs); Inbox is always the default surface and is never itself a delivery action; you may add zero or more delivery actions. Only delivery.actions[].inputs may reference $humanInput, and the standard payload field uses the whole-object single reference form $humanInput.actions.<deliveryActionId>.payload (never string-interpolated). Do not invent provider shorthand fields; use the action's own input names. If a native feedback action declares fixed choice ids, the human_input.input.choices[].id MUST match those ids exactly (labels may differ, e.g. Yes/No) \u2014 never auto-map yes/no to approve/reject. Use dependsOn and $nodes.<id>.output.* references to wire data between nodes. node inputs MUST NOT reference $trigger (trigger output is bound only in the trigger's inputMapping / dedupeKey); read trigger-derived values via $input.* instead. In text templates reference fields with ${$input.*} / ${$nodes.*}; mixed text MUST NOT contain a bare reference (write 'Issue: ${$input.title}', never 'Issue: $input.title'), and a literal dollar sign is written as $$ (e.g. 'Pay $$5'). duration / timeout strings MUST be '<positive integer> <unit>' where unit is second|minute|hour|day (plural allowed), e.g. '1 hour', '10 minutes', '5 days' \u2014 compact forms like '1h' / '10m' are rejected by the server.",inputSchema:{type:"object",properties:{node:{...k,description:"A FlowNode object."}},required:["node"],additionalProperties:!1}},{name:"updateNode",execution:"client",description:"Patch an existing node by id. patch is a partial node object whose fields are shallow-merged into the node.",inputSchema:{type:"object",properties:{id:{type:"string",description:"Target node id."},patch:{...k,description:"Partial node fields to merge."}},required:["id","patch"],additionalProperties:!1}},{name:"removeNode",execution:"client",description:"Remove a node from the working flow IR by id.",inputSchema:{type:"object",properties:{id:{type:"string",description:"Node id to remove."}},required:["id"],additionalProperties:!1}},{name:"setTrigger",execution:"client",description:"Upsert a trigger by id (replaces a trigger with the same id). trigger.kind is schedule | integration | manual. schedule needs { id, kind:'schedule', cron, timezone }. integration needs { id, kind:'integration', triggerRef, connectionRef, config, inputMapping?, dedupeKey? }. manual needs { id, kind:'manual' }. For an integration trigger, fill config from the trigger inputSchema in getFlowContext and NEVER omit a requiredInputs field (e.g. linear/new_issue requires config.team_id). $trigger.output.* may ONLY be referenced inside the trigger's own inputMapping / dedupeKey; node inputs MUST NOT reference $trigger. In any text template, reference fields with ${$input.*} / ${$nodes.*}; mixed text MUST NOT contain a bare reference (write 'Issue: ${$input.title}', never 'Issue: $input.title'), and a literal dollar sign is written as $$ (e.g. 'Pay $$5'). Always run validateFlow (Server /flows/validate) before saveFlowDraft.",inputSchema:{type:"object",properties:{trigger:{...k,description:"A TriggerBinding object."}},required:["trigger"],additionalProperties:!1}},{name:"removeTrigger",execution:"client",description:"Remove a trigger from the working flow IR by id.",inputSchema:{type:"object",properties:{id:{type:"string",description:"Trigger id to remove."}},required:["id"],additionalProperties:!1}},{name:"setOutputs",execution:"client",description:"Set the working flow outputs mapping: the MACHINE response / API response of the flow (structured data for programs and webhooks), NOT the user-facing result. The user-readable Inbox result is composition (use setComposition for that); never describe outputs to the user as their result, and never derive composition from outputs. Only reference fields that exist in a tool or trigger output schema. Use $nodes.<id>.output.<arrayField>.length to project an array count. In text templates reference fields with ${$input.*} / ${$nodes.*}; mixed text MUST NOT contain a bare reference (write 'Total: ${$nodes.sum.output.value}', never 'Total: $nodes.sum.output.value'), and a literal dollar sign is written as $$ (e.g. 'Pay $$5'). Do not invent output fields from node inputs; for example, if a search tool output only declares results, use a literal or $input value for the original query instead of $nodes.<id>.output.query.",inputSchema:{type:"object",properties:{outputs:{...k,description:"Outputs mapping object."}},required:["outputs"],additionalProperties:!1}},{name:"setComposition",execution:"client",description:"Set the flow composition: the USER-READABLE result work that a successful run saves as one Inbox result for a person to read (NOT the machine response \u2014 that is outputs). composition.title is a short headline. composition.detail.format MUST be 'markdown' and composition.detail.body is the markdown a human reads. Optionally composition.detail.data is a structured mapping kept for reference (never shown by default). Add composition.report ONLY when the flow already has a node that produces a human report (e.g. an AI analysis/report node): set its report.format='markdown' and report.body from that node output; never invent a report when no report-producing node exists. Reference run data with ${$input.*} / ${$nodes.*} only (composition MUST NOT reference $trigger or $outputs); mixed text MUST NOT contain a bare reference (write 'Result: ${$nodes.sum.output.value}', never 'Result: $nodes.sum.output.value'), and a literal dollar sign is written as $$ (e.g. 'Pay $$5'). Creating a flow MUST create a composition; editing nodes or input semantics MUST keep composition consistent. The whole composition object replaces the previous one.",inputSchema:{type:"object",properties:{composition:{...k,description:"A FlowCompositionSpec: { title, detail:{ format:'markdown', body, data? }, report?:{ title?, format:'markdown', body, data? } }."}},required:["composition"],additionalProperties:!1}},{name:"validateFlow",execution:"client",description:"Validate the current working flow IR against the Ablehi Server (authoritative). Returns { valid, issues }. The server is the only source of flow validity.",inputSchema:W},{name:"saveFlowDraft",execution:"server",needsApproval:!0,description:"Persist the current working flow IR as a draft on the Ablehi Server (the persistence truth). Requires user approval before running. Optionally pass a flow name.",inputSchema:{type:"object",properties:{flow:{type:"string",description:"Optional flow name."}},additionalProperties:!1}},{name:"requestConnect",execution:"client",description:"Ask the user to connect an integration so a connectionRef becomes available. Opens the connection UI. The user supplies any credential directly to the Ablehi Server; you only receive { status, connectionRef? } and never the secret.",inputSchema:{type:"object",properties:{installationId:{type:"string",description:"Installation to connect."},connectionName:{type:"string",description:"Optional connection display name."}},required:["installationId"],additionalProperties:!1}}];function Zo(e){return qe.find(t=>t.name===e)}var ei="data-flowDraftApproval",ti="save_flow_draft",ni="AGENT_RUNTIME_UNCONFIGURED",ri="AGENT_RUNTIME_FAILED",oi="AGENT_APPROVAL_NOT_FOUND",ii="AGENT_APPROVAL_EXPIRED";var ai="/workspaces/:workspaceId/runs",ui="/workspaces/:workspaceId/flows/:flowId/runs",pi="/:runId",li="/:runId/cancel",di="/:runId/events",je=e=>`/workspaces/${encodeURIComponent(e)}/runs`,te=(e,t)=>`${je(e)}/${encodeURIComponent(t)}`,ci=(e,t)=>`${te(e,t)}/cancel`,gi=(e,t)=>`${te(e,t)}/events`,fi=(e,t)=>`/workspaces/${encodeURIComponent(e)}/flows/${encodeURIComponent(t)}/runs`,mi=["queued","running","succeeded","failed","interrupted","cancelled"],yi=["succeeded","skipped","timed_out","failed"];var Ii="/workspaces/:workspaceId/inbox/items",_i="/workspaces/:workspaceId/inbox/entries",xi="/:itemId",ki="/:entryId",Ti="/:entryId/human-input/submit",Je=e=>`/workspaces/${encodeURIComponent(e)}/inbox/items`,wi=(e,t)=>`${Je(e)}/${encodeURIComponent(t)}`,Xe=e=>`/workspaces/${encodeURIComponent(e)}/inbox/entries`,Ye=(e,t)=>`${Xe(e)}/${encodeURIComponent(t)}`,Ei=(e,t)=>`${Ye(e,t)}/human-input/submit`;var Ai="/human-input/tokens",Pi="/:token",Si="/:token/submit",ze=e=>`/human-input/tokens/${encodeURIComponent(e)}`,bi=e=>`${ze(e)}/submit`;var Ci="/:flowId/trigger-instances",Oi="/:flowId/triggers/:triggerBindingId/simulate",vi=(e,t)=>`/workspaces/${encodeURIComponent(e)}/flows/${encodeURIComponent(t)}/trigger-instances`,Di=(e,t,n)=>`/workspaces/${encodeURIComponent(e)}/flows/${encodeURIComponent(t)}/triggers/${encodeURIComponent(n)}/simulate`;export{ii as AGENT_APPROVAL_EXPIRED_ERROR_CODE,oi as AGENT_APPROVAL_NOT_FOUND_ERROR_CODE,Xo as AGENT_CAPABILITY_FLOW_AUTHORING,qo as AGENT_CHAT_ROUTE_SUBPATH,jo as AGENT_FLOW_CONTEXT_ROUTE_SUBPATH,Vo as AGENT_ROUTE_PREFIX,ri as AGENT_RUNTIME_FAILED_ERROR_CODE,ni as AGENT_RUNTIME_UNCONFIGURED_ERROR_CODE,io as CATALOG_DEFAULT_PROVIDER_APP_CONFIG_ROUTE_SUBPATH,no as CATALOG_INTEGRATIONS_ROUTE_SUBPATH,ro as CATALOG_INTEGRATION_DETAIL_ROUTE_SUBPATH,G as CATALOG_ROUTE_PREFIX,oo as CATALOG_VERSIONS_ROUTE_SUBPATH,Ro as CONNECTIONS_ROUTE_SUBPATH,To as CONNECTION_DISCONNECT_ROUTE_SUBPATH,ko as CONNECT_COMPLETE_ROUTE_SUBPATH,_o as CONNECT_OPTIONS_ROUTE_SUBPATH,Io as CONNECT_START_ROUTE_SUBPATH,xo as CONNECT_SUBMIT_ROUTE_SUBPATH,Kr as CURRENT_USER_ROUTE_PATH,$e as DEPLOYMENT_HANDSHAKE_DISPATCHER_CAPABILITIES,Dr as DEPLOYMENT_HANDSHAKE_REQUIRED_CAPABILITIES,vr as DEPLOYMENT_HANDSHAKE_ROUTE,An as EGRESS_GRANT_AUDIT_ROUTE_SUBPATH,hn as EGRESS_GRANT_CONSUME_ROUTE_SUBPATH,he as EGRESS_GRANT_SCOPE_KINDS,ct as EVENT_WAIT_ROUTE_SUBPATH,ot as EXECUTION_CONTEXT_ROUTE_SUBPATH,lr as FILE_CONTENT_ROUTE_SUBPATH,pr as FILE_STAT_ROUTE_SUBPATH,zo as FLOW_AUTHORING_EDIT_TOOL_NAMES,qe as FLOW_AUTHORING_TOOL_DESCRIPTORS,Yo as FLOW_AUTHORING_TOOL_NAMES,Uo as FLOW_DISABLE_ROUTE_SUBPATH,ei as FLOW_DRAFT_APPROVAL_DATA_PART_TYPE,ti as FLOW_DRAFT_APPROVAL_KIND,Fo as FLOW_DRAFT_ROUTE_SUBPATH,Do as FLOW_ENABLE_ROUTE_SUBPATH,re as FLOW_INTERPRETER_CONTRACT_VERSION,Ze as FLOW_IR_SCHEMA_VERSION,vo as FLOW_ITEM_ROUTE_SUBPATH,kn as FLOW_RUN_EGRESS_GRANT_ROUTE_SUBPATH,dt as FLOW_RUN_RESULT_ROUTE_SUBPATH,jn as FLOW_RUN_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,mi as FLOW_RUN_STATUSES,Oo as FLOW_VALIDATE_ROUTE_SUBPATH,Bo as FLOW_VERSIONS_ROUTE_SUBPATH,Ho as FLOW_VERSION_ITEM_ROUTE_SUBPATH,Et as HANDLER_BUNDLES_ROUTE_SUBPATH,Lr as HANDSHAKE_CAPABILITY_MISSING,Hr as HANDSHAKE_CONTRACT_VERSION_MISMATCH,$r as HANDSHAKE_DISPATCH_NAMESPACE_MISMATCH,Ur as HANDSHAKE_REQUEST_INVALID,Br as HANDSHAKE_SECRET_MISMATCH,Fr as HANDSHAKE_SECRET_UNCONFIGURED,Ir as HUMAN_INPUTS_ROUTE_SUBPATH,kr as HUMAN_INPUT_ACKNOWLEDGE_ROUTE_SUBPATH,xr as HUMAN_INPUT_EXPIRE_ROUTE_SUBPATH,_r as HUMAN_INPUT_REQUEST_ROUTE_SUBPATH,Ce as HUMAN_INPUT_RESOLVED_EVENT_PREFIX,Ai as HUMAN_INPUT_TOKENS_ROUTE_PREFIX,Pi as HUMAN_INPUT_TOKEN_ROUTE_SUBPATH,Si as HUMAN_INPUT_TOKEN_SUBMIT_ROUTE_SUBPATH,Ti as INBOX_ENTRY_HUMAN_INPUT_SUBMIT_ROUTE_SUBPATH,ki as INBOX_ENTRY_ROUTE_SUBPATH,xi as INBOX_ITEM_ROUTE_SUBPATH,co as INTEGRATION_ITEM_ROUTE_SUBPATH,go as INTEGRATION_TOOLS_ROUTE_SUBPATH,J as INTERNAL_EGRESS_GRANTS_ROUTE_PREFIX,L as INTERNAL_FILES_ROUTE_PREFIX,f as INTERNAL_FLOW_RUNS_ROUTE_PREFIX,pe as INTERNAL_FLOW_VERSIONS_ROUTE_PREFIX,H as INTERNAL_INSTALLATIONS_ROUTE_PREFIX,E as INTERNAL_POLLING_TRIGGER_INSTANCES_ROUTE_PREFIX,$ as INTERNAL_TOOL_INVOCATIONS_ROUTE_PREFIX,w as INTERNAL_WEBHOOK_TRIGGER_INSTANCES_ROUTE_PREFIX,rn as POLLING_TRIGGER_CONTEXT_ROUTE_SUBPATH,wn as POLLING_TRIGGER_EGRESS_GRANT_ROUTE_SUBPATH,on as POLLING_TRIGGER_HANDLER_BUNDLES_ROUTE_SUBPATH,Xn as POLLING_TRIGGER_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,an as POLLING_TRIGGER_STORE_ROUTE_SUBPATH,sn as POLLING_TRIGGER_TICK_EVENTS_ROUTE_SUBPATH,wo as PROVIDER_CALLBACK_REDIRECT_ROUTE_PATH,tr as RUNTIME_CREDENTIAL_SESSION_SCOPE_KINDS,li as RUN_CANCEL_ROUTE_SUBPATH,di as RUN_EVENTS_ROUTE_SUBPATH,pi as RUN_ITEM_ROUTE_SUBPATH,ne as SERVER_CONTRACT_VERSION,lt as STEP_RESULT_ROUTE_SUBPATH,yi as STEP_RUN_STATUSES,ht as TOOL_HANDLER_BUNDLES_ROUTE_SUBPATH,Tn as TOOL_INVOCATION_EGRESS_GRANT_ROUTE_SUBPATH,Jn as TOOL_INVOCATION_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,Ci as TRIGGER_INSTANCES_ROUTE_SUBPATH,Oi as TRIGGER_SIMULATE_ROUTE_SUBPATH,qt as WEBHOOK_PROTOCOL_ADAPTER_BUNDLE_ROUTE_SUBPATH,Jt as WEBHOOK_PROTOCOL_ADAPTER_MODULE,Dt as WEBHOOK_TRIGGER_CONTEXT_ROUTE_SUBPATH,Ft as WEBHOOK_TRIGGER_DELIVERY_ROUTE_SUBPATH,En as WEBHOOK_TRIGGER_EGRESS_GRANT_ROUTE_SUBPATH,Bt as WEBHOOK_TRIGGER_EVENTS_ROUTE_SUBPATH,Ut as WEBHOOK_TRIGGER_HANDLER_BUNDLES_ROUTE_SUBPATH,Ht as WEBHOOK_TRIGGER_REARM_ROUTE_SUBPATH,Yn as WEBHOOK_TRIGGER_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,$t as WEBHOOK_TRIGGER_STORE_ROUTE_SUBPATH,br as WFP_USER_RUNTIME_MANIFEST_FORMAT_VERSION,Nr as WFP_USER_RUNTIME_UNKNOWN_SOURCE_REVISION,M as WORKSPACES_ROUTE_PREFIX,jr as WORKSPACE_ACCESS_ROUTE_SUBPATH,zr as WORKSPACE_API_KEYS_ROUTE_SUBPATH,eo as WORKSPACE_API_KEY_CANONICAL_SCOPES,Me as WORKSPACE_API_KEY_FULL_ACCESS_SCOPE,Qr as WORKSPACE_API_KEY_ITEM_ROUTE_SUBPATH,yo as WORKSPACE_CONNECTION_MOUNT_PREFIX,Co as WORKSPACE_FLOWS_ROUTE_PREFIX,ui as WORKSPACE_FLOW_RUNS_ROUTE_PREFIX,_i as WORKSPACE_INBOX_ENTRIES_ROUTE_PREFIX,Ii as WORKSPACE_INBOX_ITEMS_ROUTE_PREFIX,lo as WORKSPACE_INTEGRATIONS_ROUTE_PREFIX,ai as WORKSPACE_RUNS_ROUTE_PREFIX,Jo as agentChatPath,uo as catalogDefaultProviderAppConfigPath,Ge as catalogIntegrationPath,so as catalogIntegrationsPath,ao as catalogVersionsPath,So as connectCompletePath,Ao as connectOptionsPath,ho as connectStartPath,Po as connectSubmitPath,bo as connectionDisconnectPath,o as contractParseFail,u as contractParseOk,Vr as currentUserPath,Mr as deploymentHandshakeProbePayload,Gr as deploymentHandshakeResponseProofPayload,On as egressGrantAuditPath,Cn as egressGrantConsumePath,mt as eventWaitPath,it as executionContextPath,Zo as findFlowAuthoringToolDescriptor,Mo as flowDisablePath,Go as flowDraftPath,Lo as flowEnablePath,D as flowPath,Pn as flowRunEgressGrantPath,ft as flowRunResultPath,zn as flowRunRuntimeCredentialPath,fi as flowRunsPath,Xt as flowScriptProtocolAdapterModuleName,$o as flowValidatePath,Wo as flowVersionPath,Ve as flowVersionsPath,Qo as formatFlowToolError,At as handlerBundlesPath,wr as humanInputAcknowledgePath,Tr as humanInputExpirePath,z as humanInputRequestPath,Er as humanInputResolvedEventType,ze as humanInputTokenPath,bi as humanInputTokenSubmitPath,Ne as humanInputsPath,Ei as inboxEntryHumanInputSubmitPath,Ye as inboxEntryPath,wi as inboxItemPath,fo as installationToolsPath,gr as internalFileContentPath,cr as internalFileStatPath,dr as internalFilesPath,i as isJsonRecord,h as isValidRequestDigest,kt as parseCompleteFlowRunWaitBody,hr as parseCreateHumanInputBody,Hn as parseEgressGrantAuditBody,Bn as parseEgressGrantConsumeBody,Ln as parseEgressGrantConsumeData,$n as parseEgressGrantData,st as parseExecutionContextData,fr as parseFileRefData,oe as parseFileRuntimeLimits,vn as parseFlowActionGrantBody,It as parseFlowRunResultBody,_t as parseFlowRunResultData,nr as parseFlowRuntimeCredentialBody,de as parseHandlerBundle,St as parseHandlerBundlesData,Pr as parseHumanInputAcknowledgeData,Ar as parseHumanInputCreateData,He as parseHumanInputRequestViewData,gn as parsePollingPublishBody,or as parsePollingRuntimeCredentialBody,Ie as parsePollingStorePutBody,ye as parsePollingStoreValue,cn as parsePollingTriggerContext,Un as parsePollingTriggerGrantBody,fn as parsePublishPollingTickEventsData,xt as parseRegisterFlowRunWaitBody,Tt as parseRegisterFlowRunWaitData,sr as parseRuntimeCredentialSessionCredential,P as parseRuntimeNetwork,Dn as parseSingleToolGrantBody,rr as parseSingleToolRuntimeCredentialBody,yt as parseStepRecordBody,Rt as parseStepRecordData,bt as parseToolHandlerBundlesData,Qt as parseTriggerHandlerBundlesData,zt as parseWebhookDelivery,Zt as parseWebhookPublishEventsBody,en as parseWebhookRearmBody,ir as parseWebhookRuntimeCredentialBody,Ie as parseWebhookStorePutBody,ye as parseWebhookStoreValue,Fn as parseWebhookTriggerGrantBody,Yt as parseWebhookWatcherContext,un as pollingTriggerContextPath,bn as pollingTriggerEgressGrantPath,pn as pollingTriggerHandlerBundlesPath,Zn as pollingTriggerRuntimeCredentialPath,dn as pollingTriggerStorePath,ln as pollingTriggerTickEventsPath,Pe as requestHasMultipartFileParts,ci as runCancelPath,gi as runEventsPath,te as runPath,gt as stepResultPath,Pt as toolHandlerBundlesPath,Sn as toolInvocationEgressGrantPath,Qn as toolInvocationRuntimeCredentialPath,vi as triggerInstancesPath,Di as triggerSimulatePath,jt as webhookProtocolAdapterBundlePath,Lt as webhookTriggerContextPath,Gt as webhookTriggerDeliveryPath,Nn as webhookTriggerEgressGrantPath,Wt as webhookTriggerEventsPath,Mt as webhookTriggerHandlerBundlesPath,Kt as webhookTriggerRearmPath,er as webhookTriggerRuntimeCredentialPath,Vt as webhookTriggerStorePath,Cr as wfpUserRuntimeManifestPath,Zr as workspaceApiKeyPath,Le as workspaceApiKeysPath,Eo as workspaceConnectionsPath,ee as workspaceFlowsPath,Xe as workspaceInboxEntriesPath,Je as workspaceInboxItemsPath,Ke as workspaceIntegrationPath,We as workspaceIntegrationsPath,Jr as workspacePath,je as workspaceRunsPath};
1
+ var ne="0.1.5";var Ze="flow.ir.v1";var re="flow.interp.v2";function u(e){return{ok:!0,value:e}}function o(e){return{ok:!1,reason:e}}function i(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var f="/internal/flow-runs",ot="/:flowRunId/execution-context";function it(e){return`${f}/${encodeURIComponent(e)}/execution-context`}function oe(e){return!i(e)||!F(e.fileMaxBytes)||!F(e.fileReadMaxBytes)||!F(e.inlineMultipartBytesMax)?o("file runtime limits must carry three positive integer bounds"):u({fileMaxBytes:e.fileMaxBytes,fileReadMaxBytes:e.fileReadMaxBytes,inlineMultipartBytesMax:e.inlineMultipartBytesMax})}function st(e){if(!i(e))return o("execution context must be a JSON object");let t=e.compiled;if(typeof e.flowRunId!="string"||typeof e.workspaceId!="string"||!i(e.input)||!i(t)||typeof t.irSchemaVersion!="string"||typeof t.interpreterContractVersion!="string"||typeof t.compiledArtifactId!="string"||!i(t.ir)||!Array.isArray(t.ir.nodes)||!se(e.executionBindings))return o("execution context surface shape is invalid");let n=ie(e.fileRuntime);return n.ok?u({...e,fileRuntime:n.value}):o(n.reason)}function ie(e){if(e===null)return u(null);if(!i(e))return o("fileRuntime must be null or an object");let t=oe(e.limits);return t.ok?u({limits:t.value}):o(t.reason)}function se(e){return Array.isArray(e)?e.every(t=>{if(!i(t))return!1;let n=t.connection;return typeof t.nodeId=="string"&&typeof t.toolRef=="string"&&i(t.toolDescriptor)&&i(t.integrationDescriptor)&&i(n)&&typeof n.installationId=="string"&&typeof n.connectionRef=="string"&&typeof n.connectionId=="string"&&typeof n.authType=="string"}):!1}function F(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0}var lt="/:flowRunId/steps/:nodeId/result",dt="/:flowRunId/result",ct="/:flowRunId/event-waits/:nodeId";function gt(e,t){return`${f}/${encodeURIComponent(e)}/steps/${encodeURIComponent(t)}/result`}function ft(e){return`${f}/${encodeURIComponent(e)}/result`}function mt(e,t){return`${f}/${encodeURIComponent(e)}/event-waits/${encodeURIComponent(t)}`}function Rt(e){if(!i(e))return{ok:!1,kind:"validation",reason:"step record body must be a JSON object"};let t=R(e,["attempt","result","durationMs"]);if(t!==void 0)return{ok:!1,kind:"validation",reason:`step record does not accept the "${t}" field`};let n=e.attempt;if(typeof n!="number"||!Number.isInteger(n)||n<=0)return{ok:!1,kind:"validation",reason:"attempt must be a positive integer"};let r=ae(e.result);if(!r.ok)return r;let s={attempt:n,result:r.value};if(e.durationMs!==void 0){let a=e.durationMs;if(typeof a!="number"||!Number.isFinite(a)||a<0)return{ok:!1,kind:"validation",reason:"durationMs must be a non-negative number"};s.durationMs=a}return{ok:!0,value:s}}function ae(e){if(!i(e))return{ok:!1,kind:"step_result_invalid",reason:"result must be a JSON object"};let t=e.status;if(t==="succeeded"){let n=R(e,["status","output"]);return n!==void 0?{ok:!1,kind:"validation",reason:`step record result does not accept the "${n}" field`}:"output"in e?{ok:!0,value:{status:"succeeded",output:e.output}}:{ok:!1,kind:"step_result_invalid",reason:"a succeeded result must carry output"}}if(t==="failed"){let n=R(e,["status","errorCode","issues"]);if(n!==void 0)return{ok:!1,kind:"validation",reason:`step record result does not accept the "${n}" field`};let r=e.errorCode;if(typeof r!="string"||r.length===0)return{ok:!1,kind:"step_result_invalid",reason:"a failed result must carry a non-empty errorCode"};let s={status:"failed",errorCode:r};return e.issues!==void 0&&(s.issues=e.issues),{ok:!0,value:s}}return{ok:!1,kind:"step_result_invalid",reason:'result status must be "succeeded" or "failed"'}}function yt(e){return!i(e)||typeof e.flowRunId!="string"||typeof e.nodeId!="string"||e.recorded!=="succeeded"&&e.recorded!=="failed"?o("step record data surface shape is invalid"):u({flowRunId:e.flowRunId,nodeId:e.nodeId,recorded:e.recorded})}function It(e){if(!i(e))return o("result body must be a JSON object");let t=R(e,["status","output","error","composition"]);if(t!==void 0)return o(`result does not accept the "${t}" field`);let n=e.status;if(n!=="succeeded"&&n!=="failed")return o('result status must be "succeeded" or "failed"');let r={status:n};if(e.output!==void 0&&(r.output=e.output),e.error!==void 0){let s=e.error;if(!i(s))return o("result error must be a JSON object");let a=R(s,["code","message"]);if(a!==void 0)return o(`result error does not accept the "${a}" field`);if(typeof s.code!="string"||typeof s.message!="string")return o("result error must carry string code and message");r.error={code:s.code,message:s.message}}if(e.composition!==void 0){if(n!=="succeeded")return o("composition is only allowed on a succeeded result");r.composition=e.composition}return u(r)}function _t(e){return i(e)?u(e):o("flow run result data must be a JSON object")}var ue=/^[A-Za-z0-9_-]{1,100}$/;function Tt(e){if(!i(e))return o("register body must be a JSON object");let t=R(e,["eventType","correlationKey"]);if(t!==void 0)return o(`register wait does not accept the "${t}" field`);let n=K(e.eventType);if(!n.ok)return o(n.reason);let r=e.correlationKey;return typeof r!="string"||r.length===0?o("correlationKey must be a non-empty string"):u({eventType:n.value,correlationKey:r})}function xt(e){if(!i(e))return o("complete body must be a JSON object");let t=R(e,["eventType","correlationKey","outcome","eventId"]);if(t!==void 0)return o(`complete wait does not accept the "${t}" field`);let n=e.outcome;if(n!=="received"&&n!=="timed_out")return o('outcome must be "received" or "timed_out"');let r=K(e.eventType);if(!r.ok)return o(r.reason);let s=e.correlationKey;if(typeof s!="string"||s.length===0)return o("correlationKey must be a non-empty string");let a={eventType:r.value,correlationKey:s,outcome:n};if(e.eventId!==void 0){if(typeof e.eventId!="string"||e.eventId.length===0)return o("eventId must be a non-empty string");a.eventId=e.eventId}return u(a)}function kt(e){return!i(e)||e.registered!==!0?o("register wait data surface shape is invalid"):u({registered:!0})}function K(e){return typeof e!="string"||e.length===0?o("eventType must be a non-empty string"):ue.test(e)?u(e):o("eventType must match ^[A-Za-z0-9_-]{1,100}$")}function R(e,t){return Object.keys(e).find(n=>!t.includes(n))}var pe="/internal/flow-versions",wt="/:flowVersionId/handler-bundles",H="/internal/installations",ht="/:installationId/handler-bundles";function At(e,t){return`${pe}/${encodeURIComponent(e)}/handler-bundles?compiledArtifactId=${encodeURIComponent(t)}`}function St(e){return`${H}/${encodeURIComponent(e.installationId)}/handler-bundles?workspaceId=${encodeURIComponent(e.workspaceId)}&artifactDigest=${encodeURIComponent(e.artifactDigest)}`}var le=new Set(["managed_only","managed_plus_unmanaged_sdk"]);function S(e){if(!y(e))return B("runtimeNetwork must be a JSON object");let t=e.networkModel;return typeof t!="string"||!le.has(t)?B("runtimeNetwork.networkModel is unknown"):!V(e.apiHosts)||!V(e.authHosts)||typeof e.httpsOnly!="boolean"?B("runtimeNetwork host/https fields are invalid"):{ok:!0,value:{networkModel:t,apiHosts:e.apiHosts,authHosts:e.authHosts,httpsOnly:e.httpsOnly}}}function Pt(e){if(!y(e)||typeof e.flowVersionId!="string"||typeof e.compiledArtifactId!="string"||!Array.isArray(e.bundles))return k("handler bundles data surface shape is invalid");let t=q(e.bundles);return t.ok?{ok:!0,value:{flowVersionId:e.flowVersionId,compiledArtifactId:e.compiledArtifactId,bundles:t.value}}:t}function bt(e){if(!y(e)||typeof e.installationId!="string"||typeof e.artifactDigest!="string"||!Array.isArray(e.bundles))return k("tool handler bundles data surface shape is invalid");let t=q(e.bundles);return t.ok?{ok:!0,value:{installationId:e.installationId,artifactDigest:e.artifactDigest,bundles:t.value}}:t}function q(e){let t=[];for(let n of e){let r=de(n);if(!r.ok)return r;t.push(r.value)}return{ok:!0,value:t}}function de(e){if(!y(e)||typeof e.toolRef!="string"||e.kind!=="handler"&&e.kind!=="request")return k("handler bundle entry shape is invalid");if(e.kind==="request"){if(e.module!==void 0)return k("a request bundle must not carry a module");let r=S(e.runtimeNetwork);return r.ok?{ok:!0,value:{toolRef:e.toolRef,kind:"request",runtimeNetwork:r.value}}:r}let t=e.module;if(!y(t)||typeof t.entry!="string"||t.entry.length===0||!ce(t.files))return k("a handler bundle must carry a { entry, files } module");let n=S(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 k(e){return{ok:!1,kind:"shape",reason:e}}function B(e){return{ok:!1,kind:"runtime_network",reason:e}}function y(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function V(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function ce(e){return y(e)&&Object.values(e).every(t=>typeof t=="string")}var E="/internal/webhook-trigger-instances",vt="/:triggerInstanceId/context",Ut="/:triggerInstanceId/handler-bundles",Ft="/:triggerInstanceId/deliveries/:deliveryId",Bt="/:triggerInstanceId/events",Ht="/:triggerInstanceId/rearm",$t="/:triggerInstanceId/store/:namespace/:key",I=e=>`${E}/${encodeURIComponent(e)}`;function Lt(e,t){return`${I(e)}/context?artifactDigest=${encodeURIComponent(t)}`}function Gt(e,t){return`${I(e)}/handler-bundles?artifactDigest=${encodeURIComponent(t)}`}function Mt(e,t){return`${I(e)}/deliveries/${encodeURIComponent(t)}`}function Wt(e){return`${I(e)}/events`}function Kt(e){return`${I(e)}/rearm`}function Vt(e,t,n){return`${I(e)}/store/${encodeURIComponent(t)}/${encodeURIComponent(n)}`}var qt="/:installationId/webhook-protocol-adapter-bundle";function jt(e){return`${H}/${encodeURIComponent(e.installationId)}/webhook-protocol-adapter-bundle?workspaceId=${encodeURIComponent(e.workspaceId)}&artifactDigest=${encodeURIComponent(e.artifactDigest)}`}var Xt="modules/webhook/protocol-adapter.js";function Jt(e){return`modules/webhook/protocol-adapter-${e}.js`}function Yt(e){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&&!ge(e.connection)||!fe(e.runtime)?o("webhook watcher context surface shape is invalid"):u(e)}function ge(e){return i(e)&&typeof e.connectionId=="string"&&typeof e.connectionRef=="string"&&typeof e.integrationRef=="string"&&typeof e.authType=="string"}function fe(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 zt(e){if(!i(e)||typeof e.deliveryId!="string"||typeof e.receivedAt!="string"||!i(e.request))return o("webhook delivery surface shape is invalid");let t=e.request;return t.method!=="POST"||!i(t.headers)||typeof t.rawBody!="string"?o("webhook delivery request shape is invalid"):u(e)}function Qt(e){if(!i(e)||typeof e.triggerRef!="string"||typeof e.artifactDigest!="string"||!Array.isArray(e.modules)||!e.modules.every(me))return{ok:!1,kind:"shape",reason:"trigger handler bundles data surface shape is invalid"};let t=S(e.runtimeNetwork);return t.ok?{ok:!0,value:{triggerRef:e.triggerRef,artifactDigest:e.artifactDigest,modules:e.modules,runtimeNetwork:t.value}}:t}function me(e){return i(e)&&typeof e.specifier=="string"&&e.specifier.length>0&&typeof e.source=="string"}function Re(e){return!i(e)||!("value"in e)?o("webhook store get surface shape is invalid"):u(e.value)}function Zt(e){if(!i(e))return o("publish events body must be a JSON object");let t=P(e,["deliveryId","events"]);if(t!==void 0)return o(`publish events does not accept the "${t}" field`);let n=e.deliveryId;if(typeof n!="string"||n.length===0)return o("deliveryId must be a non-empty string");let r=e.events;if(!Array.isArray(r))return o("events must be an array");let s=[];for(let a of r){let p=ye(a);if(!p.ok)return p;s.push(p.value)}return u({deliveryId:n,events:s})}function ye(e){if(!i(e))return o("each event must be a JSON object");let t=P(e,["eventId","occurredAt","dedupeKey","payload"]);if(t!==void 0)return o(`event does not accept the "${t}" field`);let n=e.eventId;if(typeof n!="string"||n.length===0)return o("eventId must be a non-empty string");let r=e.occurredAt;if(typeof r!="string"||r.length===0)return o("occurredAt must be a non-empty string");if(!i(e.payload))return o("event payload must be a JSON object");let s={eventId:n,occurredAt:r,payload:e.payload};if(e.dedupeKey!==void 0){if(typeof e.dedupeKey!="string"||e.dedupeKey.length===0)return o("dedupeKey must be a non-empty string");s.dedupeKey=e.dedupeKey}return u(s)}function en(e){if(!i(e))return o("rearm body must be a JSON object");let t=P(e,["expectedWatcherInstanceId"]);if(t!==void 0)return o(`rearm does not accept the "${t}" field`);let n=e.expectedWatcherInstanceId;return typeof n!="string"||n.length===0?o("expectedWatcherInstanceId must be a non-empty string"):u({expectedWatcherInstanceId:n})}function Ie(e){if(!i(e))return o("store body must be a JSON object");let t=P(e,["value"]);return t!==void 0?o(`store put does not accept the "${t}" field`):"value"in e?u({value:e.value}):o("store put requires a value field")}function P(e,t){return Object.keys(e).find(n=>!t.includes(n))}var w="/internal/polling-trigger-instances",rn="/:pollingInstanceId/context",on="/:pollingInstanceId/handler-bundles",sn="/:pollingInstanceId/ticks/:tickId/events",an="/:pollingInstanceId/store/:namespace/:key",b=e=>`${w}/${encodeURIComponent(e)}`;function un(e,t,n){return`${b(e)}/context?artifactDigest=${encodeURIComponent(t)}&tickId=${encodeURIComponent(n)}`}function pn(e,t){return`${b(e)}/handler-bundles?artifactDigest=${encodeURIComponent(t)}`}function ln(e,t){return`${b(e)}/ticks/${encodeURIComponent(t)}/events`}function dn(e,t,n){return`${b(e)}/store/${encodeURIComponent(t)}/${encodeURIComponent(n)}`}function cn(e){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&&!_e(e.connection)||!Te(e.runtime)||!xe(e.tick)||!ke(e.limits)?o("polling trigger context surface shape is invalid"):u(e)}function _e(e){return i(e)&&typeof e.connectionId=="string"&&typeof e.connectionRef=="string"&&typeof e.integrationRef=="string"&&typeof e.authType=="string"}function Te(e){if(!i(e)||e.type!=="polling"||typeof e.trigger_id!="string"||typeof e.trigger_ref!="string")return!1;let t=e.polling;if(!i(t)||typeof t.run_handler_module!="string")return!1;let n=t.schedule;if(!i(n)||n.type!=="interval"||typeof n.every_seconds!="number")return!1;let r=t.dedup;return i(r)&&(r.strategy==="cursor"||r.strategy==="hash"||r.strategy==="id_field")}function xe(e){return i(e)&&typeof e.tickId=="string"&&typeof e.scheduledAt=="string"&&typeof e.attempt=="number"}function ke(e){return i(e)&&typeof e.maxEventsPerTick=="number"}function gn(e){if(!i(e))return o("publish body must be a JSON object");let t=j(e,["events","nextCursor"]);if(t!==void 0)return o(`publish does not accept the "${t}" field`);let n=e.events;if(!Array.isArray(n))return o("events must be an array");let r=[];for(let a of n){let p=Ee(a);if(!p.ok)return p;r.push(p.value)}let s={events:r};if("nextCursor"in e){let a=e.nextCursor;if(a!==null&&typeof a!="string")return o("nextCursor must be a string, null, or omitted");s.nextCursor=a}return u(s)}function Ee(e){if(!i(e))return o("each event must be a JSON object");let t=j(e,["eventId","occurredAt","dedupeKey","payload"]);if(t!==void 0)return o(`event does not accept the "${t}" field`);if(typeof e.eventId!="string"||e.eventId.length===0)return o("event eventId must be a non-empty string");if(!i(e.payload))return o("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 o("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 o("event dedupeKey must be a non-empty string");n.dedupeKey=e.dedupeKey}return u(n)}function fn(e){return!i(e)||typeof e.tickId!="string"||typeof e.cursorUpdated!="boolean"||!Array.isArray(e.results)||!e.results.every(we)?o("publish polling tick events data surface shape is invalid"):u(e)}function we(e){return i(e)&&typeof e.eventId=="string"&&typeof e.dedupeKey=="string"&&typeof e.duplicate=="boolean"&&(e.flowRunId===null||typeof e.flowRunId=="string")}function j(e,t){return Object.keys(e).find(n=>!t.includes(n))}var X="/internal/egress-grants",$="/internal/tool-invocations",xn="/:flowRunId/egress-grant",kn="/:invocationId/egress-grant",En="/:pollingInstanceId/egress-grant",wn="/:triggerInstanceId/egress-grant",hn="/:grantId/consume",An="/:grantId/audit",Sn=e=>`${f}/${encodeURIComponent(e)}/egress-grant`,Pn=e=>`${$}/${encodeURIComponent(e)}/egress-grant`,bn=e=>`${w}/${encodeURIComponent(e)}/egress-grant`,Nn=e=>`${E}/${encodeURIComponent(e)}/egress-grant`,On=e=>`${X}/${encodeURIComponent(e)}/consume`,Cn=e=>`${X}/${encodeURIComponent(e)}/audit`,he=["flow_action","single_tool","polling_trigger","webhook_trigger"],Ae=/^[A-Za-z0-9][A-Za-z0-9:_+/=.-]{15,1023}$/;function h(e){return typeof e=="string"&&Ae.test(e)}function Se(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(r=>i(r)?r.kind==="file"&&typeof r.file_id=="string"&&r.file_id.length>0:!1):!1}function l(e){return{ok:!1,kind:"shape",reason:e}}function A(){return{ok:!1,kind:"request_digest",reason:"request digest is missing or malformed"}}function O(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 C(e){if(!i(e))return"request must be a JSON object"}function Dn(e){let t=O(e,["nodeId","request","requestDigest"]);if(!t.ok)return l(t.reason);let n=t.record.nodeId;if(typeof n!="string"||n.length===0)return l("nodeId is required");let r=C(t.record.request);if(r!==void 0)return l(r);let s=t.record.requestDigest;return h(s)?{ok:!0,value:{nodeId:n,requestDigest:s,requestHasMultipartFiles:Se(t.record.request)}}:A()}function vn(e){let t=O(e,["request","requestDigest"]);if(!t.ok)return l(t.reason);let n=C(t.record.request);if(n!==void 0)return l(n);let r=t.record.requestDigest;return h(r)?{ok:!0,value:{requestDigest:r}}:A()}function Un(e){let t=O(e,["tickId","request","requestDigest"]);if(!t.ok)return l(t.reason);let n=t.record.tickId;if(typeof n!="string"||n.length===0)return l("tickId is required");let r=C(t.record.request);if(r!==void 0)return l(r);let s=t.record.requestDigest;return h(s)?{ok:!0,value:{tickId:n,requestDigest:s}}:A()}function Fn(e){let t=O(e,["phase","lifecycle","request","requestDigest"]);if(!t.ok)return l(t.reason);let n=t.record.phase;if(n!=="lifecycle"&&n!=="handler")return l('phase must be "lifecycle" or "handler"');let r=t.record.lifecycle,s;if(r!==void 0){if(r!=="enable"&&r!=="disable"&&r!=="renew")return l('lifecycle must be "enable", "disable", or "renew"');s=r}if(n==="lifecycle"&&s===void 0)return l("lifecycle is required for the lifecycle phase");let a=C(t.record.request);if(a!==void 0)return l(a);let p=t.record.requestDigest;return h(p)?{ok:!0,value:{phase:n,...s!==void 0?{lifecycle:s}:{},requestDigest:p}}:A()}function J(e){return he.includes(e)?e:void 0}var Pe=["scopeKind","scopeId","requestDigest"];function Bn(e){if(!i(e))return l("consume body must be a JSON object");for(let s of Object.keys(e))if(!Pe.includes(s))return l(`consume does not accept the "${s}" field`);let t=J(e.scopeKind);if(t===void 0)return l("scopeKind is invalid");let n=e.scopeId;if(typeof n!="string"||n.length===0)return l("scopeId is required");let r=e.requestDigest;return h(r)?{ok:!0,value:{scopeKind:t,scopeId:n,requestDigest:r}}:A()}var be=["scopeKind","scopeId","providerHost","status","durationMs","requestBytes","responseBytes","errorCode"];function N(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 Hn(e){if(!i(e))return l("audit body must be a JSON object");for(let c of Object.keys(e))if(!be.includes(c))return l(`audit does not accept the "${c}" field`);let t=J(e.scopeKind);if(t===void 0)return l("scopeKind is invalid");let n=e.scopeId;if(typeof n!="string"||n.length===0)return l("scopeId is required");let r=e.providerHost;if(typeof r!="string"||r.length===0)return l("providerHost is required");let s=N(e.durationMs,"durationMs");if(!s.ok)return l(s.reason);let a;if(e.status!==void 0){let c=N(e.status,"status");if(!c.ok)return l(c.reason);a=c.value}let p;if(e.requestBytes!==void 0){let c=N(e.requestBytes,"requestBytes");if(!c.ok)return l(c.reason);p=c.value}let d;if(e.responseBytes!==void 0){let c=N(e.responseBytes,"responseBytes");if(!c.ok)return l(c.reason);d=c.value}let U;if(e.errorCode!==void 0){let c=e.errorCode;if(typeof c!="string"||c.length===0)return l("errorCode must be a non-empty string");U=c}return{ok:!0,value:{scopeKind:t,scopeId:n,providerHost:r,...a!==void 0?{status:a}:{},durationMs:s.value,...p!==void 0?{requestBytes:p}:{},...d!==void 0?{responseBytes:d}:{},...U!==void 0?{errorCode:U}:{}}}}function $n(e){return!i(e)||!i(e.grant)?o("egress grant envelope must carry a grant object"):u(e.grant)}function Ln(e){return!i(e)||e.consumed!==!0?o("egress grant consume data must carry consumed:true"):u({consumed:!0})}var jn="/:flowRunId/runtime-credential",Xn="/:invocationId/runtime-credential",Jn="/:pollingInstanceId/runtime-credential",Yn="/:triggerInstanceId/runtime-credential",zn=e=>`${f}/${encodeURIComponent(e)}/runtime-credential`,Qn=e=>`${$}/${encodeURIComponent(e)}/runtime-credential`,Zn=e=>`${w}/${encodeURIComponent(e)}/runtime-credential`,er=e=>`${E}/${encodeURIComponent(e)}/runtime-credential`,tr=["flow_action","tool_invoke","polling_trigger","webhook_trigger"];function D(e,t){if(!i(e))return{ok:!1,reason:"runtime credential request body must be a JSON object"};for(let n of Object.keys(e))if(!t.includes(n))return{ok:!1,reason:`runtime credential request does not accept the "${n}" field`};return{ok:!0,record:e}}function nr(e){let t=D(e,["nodeId"]);if(!t.ok)return o(t.reason);let n=t.record.nodeId;return typeof n!="string"||n.length===0?o("nodeId is required"):u({nodeId:n})}function rr(e){let t=D(e??{},[]);return t.ok?u(null):o(t.reason)}function or(e){let t=D(e,["tickId"]);if(!t.ok)return o(t.reason);let n=t.record.tickId;return typeof n!="string"||n.length===0?o("tickId is required"):u({tickId:n})}function ir(e){let t=D(e,["executionKind","deliveryId","lifecycleOperation"]);if(!t.ok)return o(t.reason);let n=t.record.executionKind;if(n!=="event_handler"&&n!=="lifecycle")return o('executionKind must be "event_handler" or "lifecycle"');let r,s=t.record.deliveryId;if(s!==void 0){if(typeof s!="string"||s.length===0)return o("deliveryId must be a non-empty string");r=s}let a,p=t.record.lifecycleOperation;if(p!==void 0){if(p!=="enable"&&p!=="disable"&&p!=="renew")return o('lifecycleOperation must be "enable", "disable", or "renew"');a=p}return n==="lifecycle"&&a===void 0?o("lifecycleOperation is required for the lifecycle execution kind"):u({executionKind:n,...r!==void 0?{deliveryId:r}:{},...a!==void 0?{lifecycleOperation:a}:{}})}function sr(e){return!i(e)||typeof e.sessionId!="string"||typeof e.connectionId!="string"||!i(e.credential)?o("runtime credential session must carry sessionId, connectionId and a credential object"):u(e.credential)}var L="/internal/files",pr="/:fileId/stat",lr="/:fileId/content",dr=()=>L,Y=e=>`?scope_kind=${encodeURIComponent(e.scopeKind)}&scope_id=${encodeURIComponent(e.scopeId)}`,cr=(e,t)=>`${L}/${encodeURIComponent(e)}/stat${Y(t)}`,gr=(e,t)=>`${L}/${encodeURIComponent(e)}/content${Y(t)}`;function fr(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"?o("file ref data does not match the AIS file-ref shape"):u(e)}var Ir="/:flowRunId/human-inputs",_r="/:flowRunId/human-inputs/:requestId",Tr="/:flowRunId/human-inputs/:requestId/expire",xr="/:flowRunId/human-inputs/:requestId/acknowledge",Ne=e=>`${f}/${encodeURIComponent(e)}/human-inputs`,z=(e,t)=>`${Ne(e)}/${encodeURIComponent(t)}`,kr=(e,t)=>`${z(e,t)}/expire`,Er=(e,t)=>`${z(e,t)}/acknowledge`,Oe="human_input_resolved";function wr(e){return`${Oe}_${e}`}function g(e){return{ok:!1,reason:e}}function m(e,t){return i(e)?{ok:!0,value:e}:g(`${t} must be an object`)}function _(e,t){return typeof e!="string"||e.length===0?g(`${t} must be a non-empty string`):{ok:!0,value:e}}var Ce=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?(?:Z|[+-]\d{2}:\d{2})$/;function De(e,t){return typeof e!="string"||!Ce.test(e)||Number.isNaN(Date.parse(e))?g(`${t} must be an ISO-8601 timestamp`):{ok:!0,value:e}}function ve(e){let t=m(e,"renderedPrompt");if(!t.ok)return t;let n=_(t.value.title,"renderedPrompt.title");if(!n.ok)return n;let r={title:n.value};if(t.value.body!==void 0){if(typeof t.value.body!="string")return g("renderedPrompt.body must be a string");r.body=t.value.body}if(t.value.format!==void 0){if(t.value.format!=="plain"&&t.value.format!=="markdown")return g("renderedPrompt.format is invalid");r.format=t.value.format}return{ok:!0,value:r}}function Ue(e){let t=m(e,"input");if(!t.ok)return t;let n=t.value.kind;if(n==="choice"){if(!Array.isArray(t.value.choices))return g("input.choices must be an array")}else if(n!=="text")if(n==="form"){if(!Array.isArray(t.value.fields))return g("input.fields must be an array")}else return g("input.kind is invalid");return{ok:!0,value:t.value}}function Fe(e){if(e==null)return{ok:!0,value:void 0};let t=m(e,"partiallyRenderedDelivery");if(!t.ok)return t;let n=t.value.actions;if(n===void 0)return{ok:!0,value:{}};if(!Array.isArray(n))return g("partiallyRenderedDelivery.actions must be an array");let r=[];for(let s of n){let a=m(s,"delivery action");if(!a.ok)return a;let p=_(a.value.id,"delivery action id");if(!p.ok)return p;let d=Q(a.value.inputs,`delivery action '${p.value}' inputs`);if(!d.ok)return d;r.push({id:p.value,inputs:d.value})}return{ok:!0,value:{actions:r}}}function Q(e,t){let n=m(e,t);if(!n.ok)return n;let r={};for(let[s,a]of Object.entries(n.value)){let p=Z(a,`${t}.${s}`);if(!p.ok)return p;r[s]=p.value}return{ok:!0,value:r}}function Z(e,t){let n=m(e,t);if(!n.ok)return n;switch(n.value.kind){case"literal":return{ok:!0,value:{kind:"literal",value:n.value.value}};case"human_input_ref":{let s=_(n.value.path,`${t}.path`);return s.ok?{ok:!0,value:{kind:"human_input_ref",path:s.value}}:s}case"array":{if(!Array.isArray(n.value.items))return g(`${t}.items must be an array`);let s=[];for(let[a,p]of n.value.items.entries()){let d=Z(p,`${t}[${a}]`);if(!d.ok)return d;s.push(d.value)}return{ok:!0,value:{kind:"array",items:s}}}case"object":{let s=Q(n.value.entries,`${t}.entries`);return s.ok?{ok:!0,value:{kind:"object",entries:s.value}}:s}case"template":{if(!Array.isArray(n.value.parts))return g(`${t}.parts must be an array`);let s=[];for(let[a,p]of n.value.parts.entries()){let d=Be(p,`${t}.parts[${a}]`);if(!d.ok)return d;s.push(d.value)}return{ok:!0,value:{kind:"template",parts:s}}}default:return g(`${t}.kind is invalid`)}}function Be(e,t){let n=m(e,t);if(!n.ok)return n;let r=n.value.kind;if(r==="literal")return typeof n.value.value!="string"?g(`${t}.value must be a string`):{ok:!0,value:{kind:"literal",value:n.value.value}};if(r==="human_input_ref"){let s=_(n.value.path,`${t}.path`);return s.ok?{ok:!0,value:{kind:"human_input_ref",path:s.value}}:s}return g(`${t}.kind is invalid`)}function hr(e){let t=m(e,"request body");if(!t.ok)return o(t.reason);let n=_(t.value.nodeId,"nodeId");if(!n.ok)return o(n.reason);let r=ve(t.value.renderedPrompt);if(!r.ok)return o(r.reason);let s=Ue(t.value.input);if(!s.ok)return o(s.reason);let a=_(t.value.timeout,"timeout");if(!a.ok)return o(a.reason);let p=De(t.value.expiresAt,"expiresAt");if(!p.ok)return o(p.reason);let d=Fe(t.value.partiallyRenderedDelivery);return d.ok?u({nodeId:n.value,renderedPrompt:r.value,input:s.value,timeout:a.value,expiresAt:p.value,...d.value!==void 0?{partiallyRenderedDelivery:d.value}:{}}):o(d.reason)}function He(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))?o("human input request view must carry id, nodeId, status and output"):u(e)}function Ar(e){if(!i(e)||typeof e.created!="boolean")return o("human input create data must carry created:boolean");let t=He(e.request);return t.ok?u({created:e.created,request:t.value}):t}function Sr(e){return!i(e)||e.acknowledged!==!0?o("human input acknowledge data must carry acknowledged:true"):u({acknowledged:!0})}var br="ablehi-wfp-user-runtime-manifest/v1",Nr="unknown";function Or(e){return e.endsWith(".js")?`${e.slice(0,-3)}.manifest.json`:`${e}.manifest.json`}var Dr="/internal/deployment-handshake",$e=["start","terminate","send-event","start-webhook-watcher","run-polling-tick","invoke-tool","invoke-trigger-handler","invoke-webhook-protocol-adapter","deployment-handshake"],vr=$e,Ur="HANDSHAKE_REQUEST_INVALID",Fr="HANDSHAKE_SECRET_UNCONFIGURED",Br="HANDSHAKE_SECRET_MISMATCH",Hr="HANDSHAKE_CONTRACT_VERSION_MISMATCH",$r="HANDSHAKE_DISPATCH_NAMESPACE_MISMATCH",Lr="HANDSHAKE_CAPABILITY_MISSING";function Gr(e){return[e.nonce,e.timestamp,e.contractVersion,e.dispatchNamespace].map(n=>`${n.length}:${n}`).join(".")}function Mr(e){return["response",e.nonce,e.contractVersion,e.dispatchNamespace,...e.capabilities].map(n=>`${n.length}:${n}`).join(".")}var Kr="/me",Vr=()=>"/me";var G="/workspaces",jr="/:workspaceId",Xr=e=>`${G}/${encodeURIComponent(e)}`;var zr="/:workspaceId/api-keys",Qr="/:workspaceId/api-keys/:apiKeyId",Le=e=>`${G}/${encodeURIComponent(e)}/api-keys`,Zr=(e,t)=>`${Le(e)}/${encodeURIComponent(t)}`,Ge="workspace.full_access",eo=[Ge];var M="/catalog",no="/integrations",ro="/integrations/:slug",oo="/versions",io="/integrations/:slug/default-provider-app-config",so=e=>{let t=`${M}/integrations`;return e?.category!==void 0&&e.category!==""?`${t}?category=${encodeURIComponent(e.category)}`:t},Me=e=>`${M}/integrations/${encodeURIComponent(e)}`,ao=()=>`${M}/versions`,uo=e=>`${Me(e)}/default-provider-app-config`;var lo="/workspaces/:workspaceId/integrations",co="/:installationId",go="/:installationId/tools",We=e=>`/workspaces/${encodeURIComponent(e)}/integrations`,Ke=(e,t)=>`${We(e)}/${encodeURIComponent(t)}`,fo=(e,t)=>`${Ke(e,t)}/tools`;var Ro="/workspaces/:workspaceId",yo="/connections",Io="/integrations/:installationId/connect/start",_o="/integrations/:installationId/connect/options",To="/connect-sessions/:sessionId/submit",xo="/connect-sessions/:sessionId/complete",ko="/integrations/:installationId/connections/:connectionRef",Eo="/callbacks/redirect",T=e=>`/workspaces/${encodeURIComponent(e)}`,wo=e=>`${T(e)}/connections`,ho=(e,t)=>`${T(e)}/integrations/${encodeURIComponent(t)}/connect/start`,Ao=(e,t)=>`${T(e)}/integrations/${encodeURIComponent(t)}/connect/options`,So=(e,t)=>`${T(e)}/connect-sessions/${encodeURIComponent(t)}/submit`,Po=(e,t)=>`${T(e)}/connect-sessions/${encodeURIComponent(t)}/complete`,bo=(e,t,n)=>`${T(e)}/integrations/${encodeURIComponent(t)}/connections/${encodeURIComponent(n)}`;var Oo="/workspaces/:workspaceId/flows",Co="/validate",Do="/:flowId",vo="/:flowId/enable",Uo="/:flowId/disable",Fo="/:flowId/draft",Bo="/:flowId/versions",Ho="/:flowId/versions/:version",ee=e=>`/workspaces/${encodeURIComponent(e)}/flows`,$o=e=>`${ee(e)}/validate`,v=(e,t)=>`${ee(e)}/${encodeURIComponent(t)}`,Lo=(e,t)=>`${v(e,t)}/enable`,Go=(e,t)=>`${v(e,t)}/disable`,Mo=(e,t)=>`${v(e,t)}/draft`,Ve=(e,t)=>`${v(e,t)}/versions`,Wo=(e,t,n)=>`${Ve(e,t)}/${n}`;var Vo="/workspaces/:workspaceId/agent",qo="/chat",jo="/flow-context",Xo="/sessions",Jo="/sessions/:sessionId",Yo=e=>`/workspaces/${encodeURIComponent(e)}/agent/chat`,zo=e=>`/workspaces/${encodeURIComponent(e)}/agent/sessions`,Qo=(e,t)=>`/workspaces/${encodeURIComponent(e)}/agent/sessions/${encodeURIComponent(t)}`,Zo=20,ei=50,ti=100,ni="flow_authoring",ri=["flow","flow_run","inbox_entry","integration"],oi=256,ii=10,si=256,ai=["getFlowContext","getWorkingFlowIr","setFlowMeta","addNode","updateNode","removeNode","setTrigger","removeTrigger","setOutputs","setComposition","validateFlow","saveFlowDraft","requestConnect"],ui=["setFlowMeta","addNode","updateNode","removeNode","setTrigger","removeTrigger","setOutputs","setComposition"];function pi(e){return JSON.stringify(e)}var W={type:"object",properties:{},additionalProperties:!1},x={type:"object",additionalProperties:!0},qe=[{name:"getFlowContext",execution:"server",description:"Read the current workspace environment snapshot (installed integrations, their control-plane tools and triggers with stable refs, and active connections). Call this first to learn which toolRef / triggerRef / connectionRef values are available before editing the flow.",inputSchema:W},{name:"getWorkingFlowIr",execution:"client",description:"Read the current browser working flow IR (flow.ir.v1), including existing triggers, nodes, outputs, and composition. Call this before editing an existing or non-empty flow, or whenever you need to inspect the current flow state.",inputSchema:W},{name:"setFlowMeta",execution:"client",description:"Set the working flow metadata: the flow logical name and/or its inputSchema (the $input contract).",inputSchema:{type:"object",properties:{flow:{type:"string",description:"Flow logical name."},inputSchema:{...x,description:"JSON object describing $input."}},additionalProperties:!1}},{name:"addNode",execution:"client",description:"Add one node to the working flow IR. node.kind is action | wait_event | sleep | human_input. action needs { id, kind:'action', toolRef, connectionRef, inputs }. wait_event needs { id, kind:'wait_event', eventType, correlation, timeout, onTimeout }. sleep needs { id, kind:'sleep', duration }. human_input needs { id, kind:'human_input', prompt:{ title, body?, format?:'plain'|'markdown' }, input, timeout, delivery? } \u2014 use it whenever the flow must WAIT for a person to review/approve/choose/answer before continuing; never use a normal action node or a provider approval tool as the wait point. human_input.input is { kind:'choice', choices:[{ id, label, style? }], allowComment? } | { kind:'text', multiline?, placeholder?, required? } | { kind:'form', fields:[{ id, label, type:'text'|'textarea'|'number'|'boolean'|'select', required?, options? }] }. Approve/reject is input.kind:'choice' with choices approve and reject (reject is just a choice with NO automatic side effect; wire any reject behavior yourself). Three or more options is the same choice kind with more choices. Free text is input.kind:'text'; structured answers are input.kind:'form'. Downstream nodes read $nodes.<human_input_id>.output, whose runtime shape is { status:'submitted', response, actor, submissionSource, submittedAt } | { status:'expired', actor, expiredAt } \u2014 the submitted value is nested under output.response ({ kind:'choice', choiceId, comment? } | { kind:'text', text } | { kind:'form', values }), NEVER directly on output. Examples: choice branch runIf { eq:[ $nodes.review.output.response.choiceId, 'approve' ] }; text value ${$nodes.ask.output.response.text}; form field ${$nodes.details.output.response.values.priority}; timeout branch runIf { eq:[ $nodes.review.output.status, 'expired' ] } (an expired human_input is a normal output, not a failure). Optional external notifications go under delivery.actions[] as { id, toolRef, connectionRef, inputs } using the SAME action triad as an action node (concrete string toolRef + concrete user-chosen string connectionRef + inputs); Inbox is always the default surface and is never itself a delivery action; you may add zero or more delivery actions. Only delivery.actions[].inputs may reference $humanInput, and the standard payload field uses the whole-object single reference form $humanInput.actions.<deliveryActionId>.payload (never string-interpolated). Do not invent provider shorthand fields; use the action's own input names. If a native feedback action declares fixed choice ids, the human_input.input.choices[].id MUST match those ids exactly (labels may differ, e.g. Yes/No) \u2014 never auto-map yes/no to approve/reject. Use dependsOn and $nodes.<id>.output.* references to wire data between nodes. node inputs MUST NOT reference $trigger (trigger output is bound only in the trigger's inputMapping / dedupeKey); read trigger-derived values via $input.* instead. In text templates reference fields with ${$input.*} / ${$nodes.*}; mixed text MUST NOT contain a bare reference (write 'Issue: ${$input.title}', never 'Issue: $input.title'), and a literal dollar sign is written as $$ (e.g. 'Pay $$5'). duration / timeout strings MUST be '<positive integer> <unit>' where unit is second|minute|hour|day (plural allowed), e.g. '1 hour', '10 minutes', '5 days' \u2014 compact forms like '1h' / '10m' are rejected by the server.",inputSchema:{type:"object",properties:{node:{...x,description:"A FlowNode object."}},required:["node"],additionalProperties:!1}},{name:"updateNode",execution:"client",description:"Patch an existing node by id. patch is a partial node object whose fields are shallow-merged into the node.",inputSchema:{type:"object",properties:{id:{type:"string",description:"Target node id."},patch:{...x,description:"Partial node fields to merge."}},required:["id","patch"],additionalProperties:!1}},{name:"removeNode",execution:"client",description:"Remove a node from the working flow IR by id.",inputSchema:{type:"object",properties:{id:{type:"string",description:"Node id to remove."}},required:["id"],additionalProperties:!1}},{name:"setTrigger",execution:"client",description:"Upsert a trigger by id (replaces a trigger with the same id). trigger.kind is schedule | integration | manual. schedule needs { id, kind:'schedule', cron, timezone }. integration needs { id, kind:'integration', triggerRef, connectionRef, config, inputMapping?, dedupeKey? }. manual needs { id, kind:'manual' }. For an integration trigger, fill config from the trigger inputSchema in getFlowContext and NEVER omit a requiredInputs field (e.g. linear/new_issue requires config.team_id). $trigger.output.* may ONLY be referenced inside the trigger's own inputMapping / dedupeKey; node inputs MUST NOT reference $trigger. In any text template, reference fields with ${$input.*} / ${$nodes.*}; mixed text MUST NOT contain a bare reference (write 'Issue: ${$input.title}', never 'Issue: $input.title'), and a literal dollar sign is written as $$ (e.g. 'Pay $$5'). Always run validateFlow (Server /flows/validate) before saveFlowDraft.",inputSchema:{type:"object",properties:{trigger:{...x,description:"A TriggerBinding object."}},required:["trigger"],additionalProperties:!1}},{name:"removeTrigger",execution:"client",description:"Remove a trigger from the working flow IR by id.",inputSchema:{type:"object",properties:{id:{type:"string",description:"Trigger id to remove."}},required:["id"],additionalProperties:!1}},{name:"setOutputs",execution:"client",description:"Set the working flow outputs mapping: the MACHINE response / API response of the flow (structured data for programs and webhooks), NOT the user-facing result. The user-readable Inbox result is composition (use setComposition for that); never describe outputs to the user as their result, and never derive composition from outputs. Only reference fields that exist in a tool or trigger output schema. Use $nodes.<id>.output.<arrayField>.length to project an array count. In text templates reference fields with ${$input.*} / ${$nodes.*}; mixed text MUST NOT contain a bare reference (write 'Total: ${$nodes.sum.output.value}', never 'Total: $nodes.sum.output.value'), and a literal dollar sign is written as $$ (e.g. 'Pay $$5'). Do not invent output fields from node inputs; for example, if a search tool output only declares results, use a literal or $input value for the original query instead of $nodes.<id>.output.query.",inputSchema:{type:"object",properties:{outputs:{...x,description:"Outputs mapping object."}},required:["outputs"],additionalProperties:!1}},{name:"setComposition",execution:"client",description:"Set the flow composition: the USER-READABLE result work that a successful run saves as one Inbox result for a person to read (NOT the machine response \u2014 that is outputs). composition.title is a short headline. composition.detail.format MUST be 'markdown' and composition.detail.body is the markdown a human reads. Optionally composition.detail.data is a structured mapping kept for reference (never shown by default). Add composition.report ONLY when the flow already has a node that produces a human report (e.g. an AI analysis/report node): set its report.format='markdown' and report.body from that node output; never invent a report when no report-producing node exists. Reference run data with ${$input.*} / ${$nodes.*} only (composition MUST NOT reference $trigger or $outputs); mixed text MUST NOT contain a bare reference (write 'Result: ${$nodes.sum.output.value}', never 'Result: $nodes.sum.output.value'), and a literal dollar sign is written as $$ (e.g. 'Pay $$5'). Creating a flow MUST create a composition; editing nodes or input semantics MUST keep composition consistent. The whole composition object replaces the previous one.",inputSchema:{type:"object",properties:{composition:{...x,description:"A FlowCompositionSpec: { title, detail:{ format:'markdown', body, data? }, report?:{ title?, format:'markdown', body, data? } }."}},required:["composition"],additionalProperties:!1}},{name:"validateFlow",execution:"client",description:"Validate the current working flow IR against the Ablehi Server (authoritative). Returns { valid, issues }. The server is the only source of flow validity.",inputSchema:W},{name:"saveFlowDraft",execution:"server",needsApproval:!0,description:"Persist the current working flow IR as a draft on the Ablehi Server (the persistence truth). Requires user approval before running. Optionally pass a flow name.",inputSchema:{type:"object",properties:{flow:{type:"string",description:"Optional flow name."}},additionalProperties:!1}},{name:"requestConnect",execution:"client",description:"Ask the user to connect an integration so a connectionRef becomes available. Opens the connection UI. The user supplies any credential directly to the Ablehi Server; you only receive { status, connectionRef? } and never the secret.",inputSchema:{type:"object",properties:{installationId:{type:"string",description:"Installation to connect."},connectionName:{type:"string",description:"Optional connection display name."}},required:["installationId"],additionalProperties:!1}}];function li(e){return qe.find(t=>t.name===e)}var di="data-flowDraftApproval",ci="save_flow_draft",gi="AGENT_RUNTIME_UNCONFIGURED",fi="AGENT_RUNTIME_FAILED",mi="AGENT_APPROVAL_NOT_FOUND",Ri="AGENT_APPROVAL_EXPIRED",yi="AGENT_SESSION_NOT_FOUND",Ii="AGENT_MESSAGE_DELTA_INVALID",_i="AGENT_PAGE_CONTEXT_INVALID",Ti="AGENT_CANDIDATE_INVALID";var ki="/workspaces/:workspaceId/runs",Ei="/workspaces/:workspaceId/flows/:flowId/runs",wi="/:runId",hi="/:runId/cancel",Ai="/:runId/events",je=e=>`/workspaces/${encodeURIComponent(e)}/runs`,te=(e,t)=>`${je(e)}/${encodeURIComponent(t)}`,Si=(e,t)=>`${te(e,t)}/cancel`,Pi=(e,t)=>`${te(e,t)}/events`,bi=(e,t)=>`/workspaces/${encodeURIComponent(e)}/flows/${encodeURIComponent(t)}/runs`,Ni=["queued","running","succeeded","failed","interrupted","cancelled"],Oi=["succeeded","skipped","timed_out","failed"];var Di="/workspaces/:workspaceId/inbox/items",vi="/workspaces/:workspaceId/inbox/entries",Ui="/:itemId",Fi="/:entryId",Bi="/:entryId/human-input/submit",Xe=e=>`/workspaces/${encodeURIComponent(e)}/inbox/items`,Hi=(e,t)=>`${Xe(e)}/${encodeURIComponent(t)}`,Je=e=>`/workspaces/${encodeURIComponent(e)}/inbox/entries`,Ye=(e,t)=>`${Je(e)}/${encodeURIComponent(t)}`,$i=(e,t)=>`${Ye(e,t)}/human-input/submit`;var Gi="/human-input/tokens",Mi="/:token",Wi="/:token/submit",ze=e=>`/human-input/tokens/${encodeURIComponent(e)}`,Ki=e=>`${ze(e)}/submit`;var qi="/:flowId/trigger-instances",ji="/:flowId/triggers/:triggerBindingId/simulate",Xi=(e,t)=>`/workspaces/${encodeURIComponent(e)}/flows/${encodeURIComponent(t)}/trigger-instances`,Ji=(e,t,n)=>`/workspaces/${encodeURIComponent(e)}/flows/${encodeURIComponent(t)}/triggers/${encodeURIComponent(n)}/simulate`;export{Ri as AGENT_APPROVAL_EXPIRED_ERROR_CODE,mi as AGENT_APPROVAL_NOT_FOUND_ERROR_CODE,Ti as AGENT_CANDIDATE_INVALID_ERROR_CODE,ni as AGENT_CAPABILITY_FLOW_AUTHORING,qo as AGENT_CHAT_ROUTE_SUBPATH,jo as AGENT_FLOW_CONTEXT_ROUTE_SUBPATH,Ii as AGENT_MESSAGE_DELTA_INVALID_ERROR_CODE,_i as AGENT_PAGE_CONTEXT_INVALID_ERROR_CODE,ii as AGENT_PAGE_CONTEXT_MAX_RESOURCES,si as AGENT_PAGE_CONTEXT_RESOURCE_ID_MAX_LENGTH,oi as AGENT_PAGE_CONTEXT_ROUTE_ID_MAX_LENGTH,ri as AGENT_PAGE_RESOURCE_TYPES,Vo as AGENT_ROUTE_PREFIX,fi as AGENT_RUNTIME_FAILED_ERROR_CODE,gi as AGENT_RUNTIME_UNCONFIGURED_ERROR_CODE,Xo as AGENT_SESSIONS_ROUTE_SUBPATH,ti as AGENT_SESSION_DETAIL_MESSAGE_LIMIT,Jo as AGENT_SESSION_ITEM_ROUTE_SUBPATH,Zo as AGENT_SESSION_LIST_DEFAULT_LIMIT,ei as AGENT_SESSION_LIST_MAX_LIMIT,yi as AGENT_SESSION_NOT_FOUND_ERROR_CODE,io as CATALOG_DEFAULT_PROVIDER_APP_CONFIG_ROUTE_SUBPATH,no as CATALOG_INTEGRATIONS_ROUTE_SUBPATH,ro as CATALOG_INTEGRATION_DETAIL_ROUTE_SUBPATH,M as CATALOG_ROUTE_PREFIX,oo as CATALOG_VERSIONS_ROUTE_SUBPATH,yo as CONNECTIONS_ROUTE_SUBPATH,ko as CONNECTION_DISCONNECT_ROUTE_SUBPATH,xo as CONNECT_COMPLETE_ROUTE_SUBPATH,_o as CONNECT_OPTIONS_ROUTE_SUBPATH,Io as CONNECT_START_ROUTE_SUBPATH,To as CONNECT_SUBMIT_ROUTE_SUBPATH,Kr as CURRENT_USER_ROUTE_PATH,$e as DEPLOYMENT_HANDSHAKE_DISPATCHER_CAPABILITIES,vr as DEPLOYMENT_HANDSHAKE_REQUIRED_CAPABILITIES,Dr as DEPLOYMENT_HANDSHAKE_ROUTE,An as EGRESS_GRANT_AUDIT_ROUTE_SUBPATH,hn as EGRESS_GRANT_CONSUME_ROUTE_SUBPATH,he as EGRESS_GRANT_SCOPE_KINDS,ct as EVENT_WAIT_ROUTE_SUBPATH,ot as EXECUTION_CONTEXT_ROUTE_SUBPATH,lr as FILE_CONTENT_ROUTE_SUBPATH,pr as FILE_STAT_ROUTE_SUBPATH,ui as FLOW_AUTHORING_EDIT_TOOL_NAMES,qe as FLOW_AUTHORING_TOOL_DESCRIPTORS,ai as FLOW_AUTHORING_TOOL_NAMES,Uo as FLOW_DISABLE_ROUTE_SUBPATH,di as FLOW_DRAFT_APPROVAL_DATA_PART_TYPE,ci as FLOW_DRAFT_APPROVAL_KIND,Fo as FLOW_DRAFT_ROUTE_SUBPATH,vo as FLOW_ENABLE_ROUTE_SUBPATH,re as FLOW_INTERPRETER_CONTRACT_VERSION,Ze as FLOW_IR_SCHEMA_VERSION,Do as FLOW_ITEM_ROUTE_SUBPATH,xn as FLOW_RUN_EGRESS_GRANT_ROUTE_SUBPATH,dt as FLOW_RUN_RESULT_ROUTE_SUBPATH,jn as FLOW_RUN_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,Ni as FLOW_RUN_STATUSES,Co as FLOW_VALIDATE_ROUTE_SUBPATH,Bo as FLOW_VERSIONS_ROUTE_SUBPATH,Ho as FLOW_VERSION_ITEM_ROUTE_SUBPATH,wt as HANDLER_BUNDLES_ROUTE_SUBPATH,Lr as HANDSHAKE_CAPABILITY_MISSING,Hr as HANDSHAKE_CONTRACT_VERSION_MISMATCH,$r as HANDSHAKE_DISPATCH_NAMESPACE_MISMATCH,Ur as HANDSHAKE_REQUEST_INVALID,Br as HANDSHAKE_SECRET_MISMATCH,Fr as HANDSHAKE_SECRET_UNCONFIGURED,Ir as HUMAN_INPUTS_ROUTE_SUBPATH,xr as HUMAN_INPUT_ACKNOWLEDGE_ROUTE_SUBPATH,Tr as HUMAN_INPUT_EXPIRE_ROUTE_SUBPATH,_r as HUMAN_INPUT_REQUEST_ROUTE_SUBPATH,Oe as HUMAN_INPUT_RESOLVED_EVENT_PREFIX,Gi as HUMAN_INPUT_TOKENS_ROUTE_PREFIX,Mi as HUMAN_INPUT_TOKEN_ROUTE_SUBPATH,Wi as HUMAN_INPUT_TOKEN_SUBMIT_ROUTE_SUBPATH,Bi as INBOX_ENTRY_HUMAN_INPUT_SUBMIT_ROUTE_SUBPATH,Fi as INBOX_ENTRY_ROUTE_SUBPATH,Ui as INBOX_ITEM_ROUTE_SUBPATH,co as INTEGRATION_ITEM_ROUTE_SUBPATH,go as INTEGRATION_TOOLS_ROUTE_SUBPATH,X as INTERNAL_EGRESS_GRANTS_ROUTE_PREFIX,L as INTERNAL_FILES_ROUTE_PREFIX,f as INTERNAL_FLOW_RUNS_ROUTE_PREFIX,pe as INTERNAL_FLOW_VERSIONS_ROUTE_PREFIX,H as INTERNAL_INSTALLATIONS_ROUTE_PREFIX,w as INTERNAL_POLLING_TRIGGER_INSTANCES_ROUTE_PREFIX,$ as INTERNAL_TOOL_INVOCATIONS_ROUTE_PREFIX,E as INTERNAL_WEBHOOK_TRIGGER_INSTANCES_ROUTE_PREFIX,rn as POLLING_TRIGGER_CONTEXT_ROUTE_SUBPATH,En as POLLING_TRIGGER_EGRESS_GRANT_ROUTE_SUBPATH,on as POLLING_TRIGGER_HANDLER_BUNDLES_ROUTE_SUBPATH,Jn as POLLING_TRIGGER_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,an as POLLING_TRIGGER_STORE_ROUTE_SUBPATH,sn as POLLING_TRIGGER_TICK_EVENTS_ROUTE_SUBPATH,Eo as PROVIDER_CALLBACK_REDIRECT_ROUTE_PATH,tr as RUNTIME_CREDENTIAL_SESSION_SCOPE_KINDS,hi as RUN_CANCEL_ROUTE_SUBPATH,Ai as RUN_EVENTS_ROUTE_SUBPATH,wi as RUN_ITEM_ROUTE_SUBPATH,ne as SERVER_CONTRACT_VERSION,lt as STEP_RESULT_ROUTE_SUBPATH,Oi as STEP_RUN_STATUSES,ht as TOOL_HANDLER_BUNDLES_ROUTE_SUBPATH,kn as TOOL_INVOCATION_EGRESS_GRANT_ROUTE_SUBPATH,Xn as TOOL_INVOCATION_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,qi as TRIGGER_INSTANCES_ROUTE_SUBPATH,ji as TRIGGER_SIMULATE_ROUTE_SUBPATH,qt as WEBHOOK_PROTOCOL_ADAPTER_BUNDLE_ROUTE_SUBPATH,Xt as WEBHOOK_PROTOCOL_ADAPTER_MODULE,vt as WEBHOOK_TRIGGER_CONTEXT_ROUTE_SUBPATH,Ft as WEBHOOK_TRIGGER_DELIVERY_ROUTE_SUBPATH,wn as WEBHOOK_TRIGGER_EGRESS_GRANT_ROUTE_SUBPATH,Bt as WEBHOOK_TRIGGER_EVENTS_ROUTE_SUBPATH,Ut as WEBHOOK_TRIGGER_HANDLER_BUNDLES_ROUTE_SUBPATH,Ht as WEBHOOK_TRIGGER_REARM_ROUTE_SUBPATH,Yn as WEBHOOK_TRIGGER_RUNTIME_CREDENTIAL_ROUTE_SUBPATH,$t as WEBHOOK_TRIGGER_STORE_ROUTE_SUBPATH,br as WFP_USER_RUNTIME_MANIFEST_FORMAT_VERSION,Nr as WFP_USER_RUNTIME_UNKNOWN_SOURCE_REVISION,G as WORKSPACES_ROUTE_PREFIX,jr as WORKSPACE_ACCESS_ROUTE_SUBPATH,zr as WORKSPACE_API_KEYS_ROUTE_SUBPATH,eo as WORKSPACE_API_KEY_CANONICAL_SCOPES,Ge as WORKSPACE_API_KEY_FULL_ACCESS_SCOPE,Qr as WORKSPACE_API_KEY_ITEM_ROUTE_SUBPATH,Ro as WORKSPACE_CONNECTION_MOUNT_PREFIX,Oo as WORKSPACE_FLOWS_ROUTE_PREFIX,Ei as WORKSPACE_FLOW_RUNS_ROUTE_PREFIX,vi as WORKSPACE_INBOX_ENTRIES_ROUTE_PREFIX,Di as WORKSPACE_INBOX_ITEMS_ROUTE_PREFIX,lo as WORKSPACE_INTEGRATIONS_ROUTE_PREFIX,ki as WORKSPACE_RUNS_ROUTE_PREFIX,Yo as agentChatPath,Qo as agentSessionPath,zo as agentSessionsPath,uo as catalogDefaultProviderAppConfigPath,Me as catalogIntegrationPath,so as catalogIntegrationsPath,ao as catalogVersionsPath,Po as connectCompletePath,Ao as connectOptionsPath,ho as connectStartPath,So as connectSubmitPath,bo as connectionDisconnectPath,o as contractParseFail,u as contractParseOk,Vr as currentUserPath,Gr as deploymentHandshakeProbePayload,Mr as deploymentHandshakeResponseProofPayload,Cn as egressGrantAuditPath,On as egressGrantConsumePath,mt as eventWaitPath,it as executionContextPath,li as findFlowAuthoringToolDescriptor,Go as flowDisablePath,Mo as flowDraftPath,Lo as flowEnablePath,v as flowPath,Sn as flowRunEgressGrantPath,ft as flowRunResultPath,zn as flowRunRuntimeCredentialPath,bi as flowRunsPath,Jt as flowScriptProtocolAdapterModuleName,$o as flowValidatePath,Wo as flowVersionPath,Ve as flowVersionsPath,pi as formatFlowToolError,At as handlerBundlesPath,Er as humanInputAcknowledgePath,kr as humanInputExpirePath,z as humanInputRequestPath,wr as humanInputResolvedEventType,ze as humanInputTokenPath,Ki as humanInputTokenSubmitPath,Ne as humanInputsPath,$i as inboxEntryHumanInputSubmitPath,Ye as inboxEntryPath,Hi as inboxItemPath,fo as installationToolsPath,gr as internalFileContentPath,cr as internalFileStatPath,dr as internalFilesPath,i as isJsonRecord,h as isValidRequestDigest,xt as parseCompleteFlowRunWaitBody,hr as parseCreateHumanInputBody,Hn as parseEgressGrantAuditBody,Bn as parseEgressGrantConsumeBody,Ln as parseEgressGrantConsumeData,$n as parseEgressGrantData,st as parseExecutionContextData,fr as parseFileRefData,oe as parseFileRuntimeLimits,Dn as parseFlowActionGrantBody,It as parseFlowRunResultBody,_t as parseFlowRunResultData,nr as parseFlowRuntimeCredentialBody,de as parseHandlerBundle,Pt as parseHandlerBundlesData,Sr as parseHumanInputAcknowledgeData,Ar as parseHumanInputCreateData,He as parseHumanInputRequestViewData,gn as parsePollingPublishBody,or as parsePollingRuntimeCredentialBody,Ie as parsePollingStorePutBody,Re as parsePollingStoreValue,cn as parsePollingTriggerContext,Un as parsePollingTriggerGrantBody,fn as parsePublishPollingTickEventsData,Tt as parseRegisterFlowRunWaitBody,kt as parseRegisterFlowRunWaitData,sr as parseRuntimeCredentialSessionCredential,S as parseRuntimeNetwork,vn as parseSingleToolGrantBody,rr as parseSingleToolRuntimeCredentialBody,Rt as parseStepRecordBody,yt as parseStepRecordData,bt as parseToolHandlerBundlesData,Qt as parseTriggerHandlerBundlesData,zt as parseWebhookDelivery,Zt as parseWebhookPublishEventsBody,en as parseWebhookRearmBody,ir as parseWebhookRuntimeCredentialBody,Ie as parseWebhookStorePutBody,Re as parseWebhookStoreValue,Fn as parseWebhookTriggerGrantBody,Yt as parseWebhookWatcherContext,un as pollingTriggerContextPath,bn as pollingTriggerEgressGrantPath,pn as pollingTriggerHandlerBundlesPath,Zn as pollingTriggerRuntimeCredentialPath,dn as pollingTriggerStorePath,ln as pollingTriggerTickEventsPath,Se as requestHasMultipartFileParts,Si as runCancelPath,Pi as runEventsPath,te as runPath,gt as stepResultPath,St as toolHandlerBundlesPath,Pn as toolInvocationEgressGrantPath,Qn as toolInvocationRuntimeCredentialPath,Xi as triggerInstancesPath,Ji as triggerSimulatePath,jt as webhookProtocolAdapterBundlePath,Lt as webhookTriggerContextPath,Mt as webhookTriggerDeliveryPath,Nn as webhookTriggerEgressGrantPath,Wt as webhookTriggerEventsPath,Gt as webhookTriggerHandlerBundlesPath,Kt as webhookTriggerRearmPath,er as webhookTriggerRuntimeCredentialPath,Vt as webhookTriggerStorePath,Or as wfpUserRuntimeManifestPath,Zr as workspaceApiKeyPath,Le as workspaceApiKeysPath,wo as workspaceConnectionsPath,ee as workspaceFlowsPath,Je as workspaceInboxEntriesPath,Xe as workspaceInboxItemsPath,Ke as workspaceIntegrationPath,We as workspaceIntegrationsPath,Xr as workspacePath,je as workspaceRunsPath};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ablehi/server-contract",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Ablehi server wire contract: routes, wire DTOs, Flow IR and interpreter version.",
5
5
  "license": "Apache-2.0",
6
6
  "publishConfig": {