UNPKG

eve

Version:

Filesystem-first framework for durable backend AI agents that run anywhere.

1 lines 906 B
import{z}from"#compiled/zod/index.js";import{EVE_ACTIVITY_ROUTE_PATTERN}from"#protocol/routes.js";import{normalizePublicEveRoutePath}from"#shared/eve-route-path.js";import{isReservedIpAddress}from"#shared/network-address.js";const schema=z.object({url:z.string().min(1),version:z.literal(1)}).strict();function parseActivitySink(e){if(e===void 0)return;let t=schema.safeParse(e);if(!t.success)throw Error(`Expected activitySink version 1.`);let n;try{n=new URL(t.data.url)}catch{throw Error(`Activity sink url must be absolute.`)}let r=EVE_ACTIVITY_ROUTE_PATTERN.slice(0,-6),i=normalizePublicEveRoutePath(n.pathname),a=i.lastIndexOf(r),o=i.slice(a+r.length);if(a<0||o.length<32)throw Error(`Activity sink url must contain an opaque activity token.`);if(isReservedIpAddress(n.hostname))throw Error(`Activity sink url host must not be a private or reserved address.`);return t.data}export{parseActivitySink};