@keystrokehq/keystroke 0.0.87 → 0.0.89
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/action.cjs +1 -1
- package/dist/action.d.cts +2 -2
- package/dist/action.d.mts +2 -2
- package/dist/action.mjs +1 -1
- package/dist/agent.cjs +3 -3
- package/dist/agent.d.cts +3 -3
- package/dist/agent.d.mts +3 -3
- package/dist/agent.mjs +3 -3
- package/dist/config.d.cts +1 -1
- package/dist/config.d.cts.map +1 -1
- package/dist/config.d.mts +1 -1
- package/dist/config.d.mts.map +1 -1
- package/dist/credentials.cjs +1 -1
- package/dist/credentials.d.cts +1 -1
- package/dist/credentials.d.mts +1 -1
- package/dist/credentials.mjs +1 -1
- package/dist/{dist-DgIJtGrg.mjs → dist-BFyot0Xl.mjs} +27 -41
- package/dist/{dist-DgIJtGrg.mjs.map → dist-BFyot0Xl.mjs.map} +1 -1
- package/dist/{dist-B1Dy8DVb.cjs → dist-CIwENY01.cjs} +27 -41
- package/dist/{dist-B1Dy8DVb.cjs.map → dist-CIwENY01.cjs.map} +1 -1
- package/dist/{dist-DYbhRy-F.mjs → dist-CnS5tygi.mjs} +13 -1
- package/dist/dist-CnS5tygi.mjs.map +1 -0
- package/dist/{dist-BdtvGgfO.mjs → dist-DL6FMwfb.mjs} +200 -122
- package/dist/dist-DL6FMwfb.mjs.map +1 -0
- package/dist/{dist-BM_f7hFN.cjs → dist-DLFFj5pe.cjs} +13 -1
- package/dist/dist-DLFFj5pe.cjs.map +1 -0
- package/dist/{dist-CZZMGcuu.cjs → dist-iCJ9uxzf.cjs} +211 -127
- package/dist/dist-iCJ9uxzf.cjs.map +1 -0
- package/dist/{index-Bv6uZ8Xd.d.mts → index-C6_DVB_V.d.cts} +14 -17
- package/dist/index-C6_DVB_V.d.cts.map +1 -0
- package/dist/{index-avLUReqf.d.cts → index-CfK7yBQI.d.cts} +2 -2
- package/dist/{index-CvXJv3hY.d.mts.map → index-CfK7yBQI.d.cts.map} +1 -1
- package/dist/{index-BeEymXir.d.cts → index-CiuCYKLw.d.cts} +22 -2
- package/dist/index-CiuCYKLw.d.cts.map +1 -0
- package/dist/{index-BeEymXir.d.mts → index-CiuCYKLw.d.mts} +22 -2
- package/dist/index-CiuCYKLw.d.mts.map +1 -0
- package/dist/{index-CpJJgeJ2.d.cts → index-DwZkaYLS.d.mts} +14 -17
- package/dist/index-DwZkaYLS.d.mts.map +1 -0
- package/dist/{index-BwRlj7pv.d.cts → index-MfPRY7cK.d.cts} +2 -2
- package/dist/{index-BspW44XX.d.mts.map → index-MfPRY7cK.d.cts.map} +1 -1
- package/dist/{index-CvXJv3hY.d.mts → index-by6PXA-8.d.mts} +2 -2
- package/dist/{index-avLUReqf.d.cts.map → index-by6PXA-8.d.mts.map} +1 -1
- package/dist/{index-BspW44XX.d.mts → index-ptRM3z9H.d.mts} +2 -2
- package/dist/{index-BwRlj7pv.d.cts.map → index-ptRM3z9H.d.mts.map} +1 -1
- package/dist/{mistral-Deqt4GvJ.cjs → mistral-BPMTd7Oz.cjs} +2 -2
- package/dist/{mistral-Deqt4GvJ.cjs.map → mistral-BPMTd7Oz.cjs.map} +1 -1
- package/dist/{mistral-wT_K1dZn.mjs → mistral-DoHWkziU.mjs} +2 -2
- package/dist/{mistral-wT_K1dZn.mjs.map → mistral-DoHWkziU.mjs.map} +1 -1
- package/dist/{sse-D12n5Ckf.mjs → sse-CWAja0ZC.mjs} +2 -2
- package/dist/{sse-D12n5Ckf.mjs.map → sse-CWAja0ZC.mjs.map} +1 -1
- package/dist/{sse-DvOq9Ntd.cjs → sse-D-SrPUr3.cjs} +2 -2
- package/dist/{sse-DvOq9Ntd.cjs.map → sse-D-SrPUr3.cjs.map} +1 -1
- package/dist/trigger.cjs +1 -1
- package/dist/trigger.d.cts +2 -2
- package/dist/trigger.d.mts +2 -2
- package/dist/trigger.mjs +1 -1
- package/dist/workflow.cjs +3 -2
- package/dist/workflow.d.cts +2 -2
- package/dist/workflow.d.mts +2 -2
- package/dist/workflow.mjs +2 -2
- package/package.json +1 -1
- package/dist/dist-BM_f7hFN.cjs.map +0 -1
- package/dist/dist-BdtvGgfO.mjs.map +0 -1
- package/dist/dist-CZZMGcuu.cjs.map +0 -1
- package/dist/dist-DYbhRy-F.mjs.map +0 -1
- package/dist/index-BeEymXir.d.cts.map +0 -1
- package/dist/index-BeEymXir.d.mts.map +0 -1
- package/dist/index-Bv6uZ8Xd.d.mts.map +0 -1
- package/dist/index-CpJJgeJ2.d.cts.map +0 -1
|
@@ -920,6 +920,18 @@ const WorkflowRunTriggerSchema = z.enum([
|
|
|
920
920
|
"poll",
|
|
921
921
|
"retry"
|
|
922
922
|
]);
|
|
923
|
+
z.enum([
|
|
924
|
+
"run_started",
|
|
925
|
+
"step_completed",
|
|
926
|
+
"step_failed",
|
|
927
|
+
"step_retrying",
|
|
928
|
+
"sleep_scheduled",
|
|
929
|
+
"sleep_completed",
|
|
930
|
+
"hook_created",
|
|
931
|
+
"hook_resumed",
|
|
932
|
+
"run_completed",
|
|
933
|
+
"run_failed"
|
|
934
|
+
]);
|
|
923
935
|
const WorkflowRunSummarySchema = z.object({
|
|
924
936
|
id: z.string(),
|
|
925
937
|
status: WorkflowRunStatusSchema,
|
|
@@ -1483,4 +1495,4 @@ function resolveActionTool(action, options) {
|
|
|
1483
1495
|
//#endregion
|
|
1484
1496
|
export { credentialInputSchema as _, getActionCredentialRequirements as a, normalizeCredentialList as b, isStepInvocation as c, runOutsideActionExecution as d, runWithinActionExecution as f, credential as g, DEFAULT_CREDENTIAL_RESOLUTION_CHAIN as h, executeAction as i, registerWorkflowRunGetter as l, CREDENTIAL_SCOPE_LEVEL_TO_SCOPE_TYPE as m, createStepInvocation as n, getWorkflowRunHandle as o, CREDENTIAL_SCOPE_LEVELS as p, defineAction as r, isAction as s, actionCoreSchema as t, resolveActionTool as u, defineCredential as v, toCredentialRequirement as x, isCredentialInput as y };
|
|
1485
1497
|
|
|
1486
|
-
//# sourceMappingURL=dist-
|
|
1498
|
+
//# sourceMappingURL=dist-CnS5tygi.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dist-CnS5tygi.mjs","names":[],"sources":["../../shared/dist/index.mjs","../../action/dist/index.mjs"],"sourcesContent":["import { z } from \"zod\";\n//#region src/constants/conventions.ts\n/** File-layout rules shared by agents, workflows, triggers, and OpenAPI `x-keystroke`. */\nconst DISCOVERY_CONVENTIONS = {\n\tagents: {\n\t\tflat: \"{name}.ts → POST /agents/{name}\",\n\t\tnested: \"{path}/agent.ts or {path}/index.ts → POST /agents/{path}\",\n\t\thelpers: \"Other .ts files under nested folders are not mounted.\"\n\t},\n\tworkflows: {\n\t\tflat: \"{name}.ts → POST /workflows/{name}\",\n\t\tnested: \"{path}/workflow.ts or {path}/index.ts → POST /workflows/{path}\",\n\t\thelpers: \"Other .ts files under nested folders are not mounted.\"\n\t},\n\ttriggers: {\n\t\tflat: \"{name}.ts → trigger key {name}, attachment id {triggerKey}:{workflowKey}\",\n\t\tnested: \"{path}/trigger.ts or {path}/index.ts → trigger key {path}\",\n\t\thelpers: \"Reusable sources live under triggers/sources/ and are not discovered.\"\n\t},\n\topenapi: \"GET /openapi.json is built from the same discovery + mount loop as the live server.\"\n};\n//#endregion\n//#region src/constants/http.ts\nconst ACTIVE_ORG_COOKIE = \"keystroke-active-org-id\";\nconst ACTIVE_ORG_HEADER = \"x-keystroke-org-id\";\n//#endregion\n//#region src/organization-slug.ts\n/** Auth, session, and account-entry URL segments. */\nconst AUTH_ACCOUNT_SLUGS = [\n\t\"2fa\",\n\t\"accept-invite\",\n\t\"auth\",\n\t\"authorize\",\n\t\"callback\",\n\t\"callbacks\",\n\t\"confirm-email\",\n\t\"confirmation\",\n\t\"connect\",\n\t\"device\",\n\t\"email-verification\",\n\t\"forgot-password\",\n\t\"invite\",\n\t\"invites\",\n\t\"login\",\n\t\"logout\",\n\t\"magic-link\",\n\t\"mfa\",\n\t\"oauth\",\n\t\"onboarding\",\n\t\"password\",\n\t\"recovery\",\n\t\"register\",\n\t\"reset-password\",\n\t\"saml\",\n\t\"session\",\n\t\"sessions\",\n\t\"sign-in\",\n\t\"sign-up\",\n\t\"signin\",\n\t\"signout\",\n\t\"signup\",\n\t\"sso\",\n\t\"token\",\n\t\"tokens\",\n\t\"unlink\",\n\t\"verify\",\n\t\"verify-email\"\n];\n/** Org, workspace, billing, and account-management URL segments. */\nconst ORG_ACCOUNT_SLUGS = [\n\t\"account\",\n\t\"accounts\",\n\t\"billing\",\n\t\"console\",\n\t\"invoice\",\n\t\"invoices\",\n\t\"member\",\n\t\"members\",\n\t\"me\",\n\t\"org\",\n\t\"organization\",\n\t\"organizations\",\n\t\"orgs\",\n\t\"payment\",\n\t\"payments\",\n\t\"plan\",\n\t\"plans\",\n\t\"portal\",\n\t\"preferences\",\n\t\"profile\",\n\t\"settings\",\n\t\"subscription\",\n\t\"subscriptions\",\n\t\"team\",\n\t\"teams\",\n\t\"upgrade\",\n\t\"usage\",\n\t\"user\",\n\t\"users\",\n\t\"workspace\",\n\t\"workspaces\"\n];\n/** Product surfaces, resource types, and in-app navigation segments. */\nconst PRODUCT_SLUGS = [\n\t\"action\",\n\t\"actions\",\n\t\"activity\",\n\t\"agent\",\n\t\"agents\",\n\t\"analytics\",\n\t\"app\",\n\t\"apps\",\n\t\"artifact\",\n\t\"artifacts\",\n\t\"assistant\",\n\t\"assistants\",\n\t\"audit\",\n\t\"audit-log\",\n\t\"automation\",\n\t\"automations\",\n\t\"branch\",\n\t\"branches\",\n\t\"canvas\",\n\t\"chat\",\n\t\"chats\",\n\t\"connection\",\n\t\"connections\",\n\t\"create\",\n\t\"credential\",\n\t\"credentials\",\n\t\"dashboard\",\n\t\"deployment\",\n\t\"deployments\",\n\t\"examples\",\n\t\"execute\",\n\t\"execution\",\n\t\"executions\",\n\t\"explore\",\n\t\"get-started\",\n\t\"history\",\n\t\"inbox\",\n\t\"inspector\",\n\t\"integration\",\n\t\"integrations\",\n\t\"library\",\n\t\"logs\",\n\t\"marketplace\",\n\t\"mcp\",\n\t\"mcps\",\n\t\"new\",\n\t\"notifications\",\n\t\"observe\",\n\t\"plugin\",\n\t\"plugins\",\n\t\"primitive\",\n\t\"primitives\",\n\t\"project\",\n\t\"projects\",\n\t\"recents\",\n\t\"registry\",\n\t\"reports\",\n\t\"run\",\n\t\"runs\",\n\t\"runtime\",\n\t\"runtimes\",\n\t\"sandbox\",\n\t\"sandboxes\",\n\t\"search\",\n\t\"skill\",\n\t\"skills\",\n\t\"templates\",\n\t\"thread\",\n\t\"threads\",\n\t\"trigger\",\n\t\"triggers\",\n\t\"version\",\n\t\"versions\",\n\t\"workflow\",\n\t\"workflows\"\n];\n/** Marketing, docs, company, and go-to-market URL segments. */\nconst MARKETING_SITE_SLUGS = [\n\t\"about\",\n\t\"affiliates\",\n\t\"ai\",\n\t\"announcements\",\n\t\"anthropic\",\n\t\"blog\",\n\t\"book-demo\",\n\t\"brand\",\n\t\"campaigns\",\n\t\"career\",\n\t\"careers\",\n\t\"case-studies\",\n\t\"casestudies\",\n\t\"changelog\",\n\t\"chatgpt\",\n\t\"chrome-extension\",\n\t\"claude\",\n\t\"codex\",\n\t\"community\",\n\t\"company\",\n\t\"compare\",\n\t\"contact\",\n\t\"contribute\",\n\t\"creators\",\n\t\"customers\",\n\t\"demo\",\n\t\"demos\",\n\t\"discord\",\n\t\"docs\",\n\t\"documentation\",\n\t\"download\",\n\t\"downloads\",\n\t\"dust\",\n\t\"emerging-talent\",\n\t\"engineering-blog\",\n\t\"enterprise\",\n\t\"events\",\n\t\"experts\",\n\t\"extension\",\n\t\"faq\",\n\t\"faqs\",\n\t\"features\",\n\t\"forum\",\n\t\"glean\",\n\t\"grok\",\n\t\"guide\",\n\t\"guides\",\n\t\"gumloop\",\n\t\"handbook\",\n\t\"help\",\n\t\"help-center\",\n\t\"home\",\n\t\"how-it-works\",\n\t\"howitworks\",\n\t\"inspo\",\n\t\"intern\",\n\t\"investors\",\n\t\"jobs\",\n\t\"legal\",\n\t\"lindy\",\n\t\"llm\",\n\t\"llms\",\n\t\"love\",\n\t\"make\",\n\t\"manifesto\",\n\t\"media\",\n\t\"merch\",\n\t\"mission\",\n\t\"mobile\",\n\t\"models\",\n\t\"n8n\",\n\t\"news\",\n\t\"newsroom\",\n\t\"open\",\n\t\"open-claw\",\n\t\"open-source\",\n\t\"openai\",\n\t\"our-story\",\n\t\"overview\",\n\t\"partners\",\n\t\"pi\",\n\t\"pipedream\",\n\t\"platform\",\n\t\"press\",\n\t\"press-kit\",\n\t\"pricing\",\n\t\"privacy\",\n\t\"product\",\n\t\"products\",\n\t\"provider\",\n\t\"providers\",\n\t\"quick-start\",\n\t\"quickstart\",\n\t\"refer\",\n\t\"relay\",\n\t\"relay-app\",\n\t\"reporting\",\n\t\"request-demo\",\n\t\"resources\",\n\t\"roadmap\",\n\t\"schedule-demo\",\n\t\"security\",\n\t\"solutions\",\n\t\"stack-ai\",\n\t\"stackai\",\n\t\"startup\",\n\t\"startups\",\n\t\"status\",\n\t\"stories\",\n\t\"story\",\n\t\"students\",\n\t\"support\",\n\t\"swag\",\n\t\"switch\",\n\t\"talent\",\n\t\"terms\",\n\t\"testimonials\",\n\t\"thesis\",\n\t\"tines\",\n\t\"trust\",\n\t\"tutorials\",\n\t\"university\",\n\t\"use-case\",\n\t\"use-cases\",\n\t\"usecases\",\n\t\"versus\",\n\t\"vellum\",\n\t\"vs\",\n\t\"webinars\",\n\t\"workato\",\n\t\"xai\",\n\t\"yc\",\n\t\"zapier\"\n];\n/** Integrations, competitors, and partner brand slugs (marketing / integration pages). */\nconst INTEGRATION_BRAND_SLUGS = [\n\t\"airtable\",\n\t\"asana\",\n\t\"aws\",\n\t\"azure\",\n\t\"bun\",\n\t\"confluence\",\n\t\"copilot\",\n\t\"cursor\",\n\t\"databricks\",\n\t\"figma\",\n\t\"firebase\",\n\t\"fly\",\n\t\"gcp\",\n\t\"gemini\",\n\t\"github\",\n\t\"gitlab\",\n\t\"gmail\",\n\t\"heroku\",\n\t\"hubspot\",\n\t\"huggingface\",\n\t\"jira\",\n\t\"linear\",\n\t\"mailchimp\",\n\t\"meta\",\n\t\"mistral\",\n\t\"mixmax\",\n\t\"monday\",\n\t\"netlify\",\n\t\"neon\",\n\t\"notion\",\n\t\"npm\",\n\t\"outlook\",\n\t\"outreach\",\n\t\"perplexity\",\n\t\"planetscale\",\n\t\"pnpm\",\n\t\"postmark\",\n\t\"ramp\",\n\t\"railway\",\n\t\"render\",\n\t\"resend\",\n\t\"salesforce\",\n\t\"segment\",\n\t\"sendgrid\",\n\t\"shopify\",\n\t\"slack\",\n\t\"snowflake\",\n\t\"stripe\",\n\t\"supabase\",\n\t\"terraform\",\n\t\"trello\",\n\t\"turso\",\n\t\"twilio\",\n\t\"typeform\",\n\t\"vercel\",\n\t\"vscode\",\n\t\"windsurf\",\n\t\"yarn\"\n];\n/** Company, team, and department landing-page segments. */\nconst COMPANY_TEAM_SLUGS = [\n\t\"engineers\",\n\t\"engineering\",\n\t\"executives\",\n\t\"hc\",\n\t\"intern\",\n\t\"it\",\n\t\"leadership\",\n\t\"marketing\",\n\t\"ops\",\n\t\"revops\",\n\t\"sales\",\n\t\"services\",\n\t\"tech\"\n];\n/** Legal, trust, compliance, and policy URL segments. */\nconst LEGAL_TRUST_SLUGS = [\n\t\"accessibility\",\n\t\"agreement\",\n\t\"a11y\",\n\t\"bug-bounty\",\n\t\"compliance\",\n\t\"cookie-policy\",\n\t\"cookies\",\n\t\"disclose\",\n\t\"dpa\",\n\t\"eula\",\n\t\"gdpr\",\n\t\"hipaa\",\n\t\"iso\",\n\t\"msa\",\n\t\"pci\",\n\t\"responsible-disclosure\",\n\t\"sla\",\n\t\"soc2\",\n\t\"tos\",\n\t\"trust-center\",\n\t\"trustcenter\",\n\t\"vulnerability\"\n];\n/** Developer, API, CLI, and technical URL segments. */\nconst DEVELOPER_TECH_SLUGS = [\n\t\"api\",\n\t\"api-docs\",\n\t\"cli\",\n\t\"code\",\n\t\"config\",\n\t\"developer\",\n\t\"developer-tools\",\n\t\"developers\",\n\t\"dev-tools\",\n\t\"devtools\",\n\t\"dev\",\n\t\"dev-states\",\n\t\"graphql\",\n\t\"graphql-playground\",\n\t\"mcp-server\",\n\t\"mcp-servers\",\n\t\"openapi\",\n\t\"sdk\",\n\t\"swagger\"\n];\n/** Infra, ops, static assets, and system URL segments. */\nconst INFRA_SYSTEM_SLUGS = [\n\t\"acme-challenge\",\n\t\"admin\",\n\t\"apple-app-site-association\",\n\t\"assets\",\n\t\"batch\",\n\t\"cache\",\n\t\"cdn\",\n\t\"cron\",\n\t\"debug\",\n\t\"error\",\n\t\"errors\",\n\t\"favicon\",\n\t\"feed\",\n\t\"files\",\n\t\"health\",\n\t\"healthcheck\",\n\t\"healthz\",\n\t\"hooks\",\n\t\"internal\",\n\t\"item\",\n\t\"manifest\",\n\t\"metrics\",\n\t\"null\",\n\t\"ping\",\n\t\"prod\",\n\t\"public\",\n\t\"redirect\",\n\t\"robots\",\n\t\"rpc\",\n\t\"rss\",\n\t\"sharer\",\n\t\"sitemap\",\n\t\"staging\",\n\t\"static\",\n\t\"storage\",\n\t\"test\",\n\t\"undefined\",\n\t\"universal\",\n\t\"webhooks\",\n\t\"well-known\",\n\t\"www\"\n];\n/** Reserved slugs that are valid org names in theory but blocked for routing safety. */\nconst ROUTING_SAFETY_SLUGS = [\n\t\"alpha\",\n\t\"anonymous\",\n\t\"archive\",\n\t\"archived\",\n\t\"beta\",\n\t\"clone\",\n\t\"copy\",\n\t\"default\",\n\t\"deleted\",\n\t\"demo-org\",\n\t\"draft\",\n\t\"drafts\",\n\t\"duplicate\",\n\t\"early-access\",\n\t\"embed\",\n\t\"embedded\",\n\t\"export\",\n\t\"fork\",\n\t\"free\",\n\t\"guest\",\n\t\"import\",\n\t\"index\",\n\t\"list\",\n\t\"manage\",\n\t\"moderator\",\n\t\"newsletter\",\n\t\"owner\",\n\t\"preview\",\n\t\"previews\",\n\t\"private\",\n\t\"pro\",\n\t\"public-api\",\n\t\"publish\",\n\t\"published\",\n\t\"queue\",\n\t\"remove\",\n\t\"root\",\n\t\"sample\",\n\t\"samples\",\n\t\"selection\",\n\t\"share\",\n\t\"shared\",\n\t\"sponsor\",\n\t\"sponsors\",\n\t\"sponsorship\",\n\t\"subscribe\",\n\t\"super\",\n\t\"superuser\",\n\t\"system\",\n\t\"sys\",\n\t\"test-org\",\n\t\"trash\",\n\t\"unpublish\",\n\t\"unsubscribe\",\n\t\"upload\",\n\t\"uploads\",\n\t\"waitlist\",\n\t\"widget\",\n\t\"widgets\",\n\t\"worker\",\n\t\"workers\"\n];\n/**\n* URL segments reserved for global (non-org) routes — cannot be used as an org slug.\n* Prefer adding new entries to the category arrays above; the Set is the enforcement surface.\n*/\nconst RESERVED_ORGANIZATION_SLUGS = new Set([\n\t...AUTH_ACCOUNT_SLUGS,\n\t...ORG_ACCOUNT_SLUGS,\n\t...PRODUCT_SLUGS,\n\t...MARKETING_SITE_SLUGS,\n\t...INTEGRATION_BRAND_SLUGS,\n\t...COMPANY_TEAM_SLUGS,\n\t...LEGAL_TRUST_SLUGS,\n\t...DEVELOPER_TECH_SLUGS,\n\t...INFRA_SYSTEM_SLUGS,\n\t...ROUTING_SAFETY_SLUGS\n]);\n/**\n* Base slug format: lowercase, 2-64 chars, alphanumeric + dashes.\n*\n* IMPORTANT: this is the schema for *reading* slugs (persisted rows, API\n* responses). It intentionally does NOT enforce the reserved-name list — an org\n* created before a name became reserved must still parse on read. Use\n* `ClaimableOrganizationSlugSchema` to validate slugs a user is trying to claim.\n*/\nconst OrganizationSlugSchema = z.string().trim().toLowerCase().min(2, \"Slug must be at least 2 characters\").max(64, \"Slug must be at most 64 characters\").regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, \"Use lowercase letters, numbers, and dashes only\");\n/**\n* Slug validation for *claiming* a slug (organization create/rename). Adds the\n* reserved-name check on top of the base format. Never use this to parse\n* existing org data, or pre-existing orgs whose slug later became reserved would\n* fail to load.\n*/\nconst ClaimableOrganizationSlugSchema = OrganizationSlugSchema.refine((slug) => !RESERVED_ORGANIZATION_SLUGS.has(slug), \"This slug is reserved\");\n/** Normalize a display name into slug-shaped text (may be empty or too short to claim). */\nfunction normalizeOrganizationNameToSlugBase(name) {\n\treturn name.trim().toLowerCase().replace(/[^a-z0-9]+/g, \"-\").replace(/-+/g, \"-\").replace(/^-|-$/g, \"\");\n}\n/**\n* Live slug preview while typing an org name. Returns normalized text only —\n* no server-side `\"org\"` fallback when the preview is empty or under min length.\n*/\nfunction previewOrganizationSlugFromName(name) {\n\treturn normalizeOrganizationNameToSlugBase(name);\n}\n/** Derive a URL slug from a display name (not guaranteed unique). */\nfunction slugifyOrganizationName(name) {\n\tconst base = normalizeOrganizationNameToSlugBase(name);\n\tif (!base) return \"org\";\n\tconst parsed = OrganizationSlugSchema.safeParse(base);\n\treturn parsed.success ? parsed.data : \"org\";\n}\nfunction parseOrganizationSlug(input) {\n\treturn OrganizationSlugSchema.parse(input);\n}\n//#endregion\n//#region src/constants/projects.ts\n/** Platform wait for project /health before declaring unreachable. */\nconst PROJECT_PING_TIMEOUT_MS = 15e3;\n/** Browser→platform request budget (ping + small platform overhead). */\nconst PROJECT_REACHABILITY_REQUEST_TIMEOUT_MS = 17e3;\n/** Pause between reachability checks after the previous check finishes. */\nconst PROJECT_REACHABILITY_RETRY_MS = 5e3;\n//#endregion\n//#region src/public-url.ts\n/** Normalize a public origin URL (no trailing slash). */\nfunction originFromPublicUrl(value, fallback) {\n\tconst trimmed = value?.trim();\n\tif (!trimmed) return fallback.replace(/\\/+$/, \"\");\n\treturn trimmed.replace(/\\/+$/, \"\");\n}\n/** TCP port to bind for a local server, derived from a public URL. */\nfunction listenPortFromUrl(url, fallback) {\n\tconst parsed = new URL(url);\n\tif (parsed.port) {\n\t\tconst port = Number(parsed.port);\n\t\tif (Number.isFinite(port) && port > 0) return port;\n\t}\n\tif (parsed.protocol === \"https:\") return 443;\n\tif (parsed.protocol === \"http:\") return 80;\n\treturn fallback;\n}\n/** Shorthand: listen port from `PUBLIC_*_URL` or fallback. */\nfunction listenPortFromPublicUrl(value, fallback) {\n\tconst trimmed = value?.trim();\n\tif (!trimmed) return fallback;\n\ttry {\n\t\treturn listenPortFromUrl(trimmed, fallback);\n\t} catch {\n\t\treturn fallback;\n\t}\n}\n//#endregion\n//#region src/constants/route-manifest.ts\n/** On-disk path under the project root (packed in deploy artifacts when present). */\nconst ROUTE_MANIFEST_REL_PATH = \"dist/.keystroke/route-manifest.json\";\n/** HTTP route served by the project server after bootstrap. */\nconst ROUTE_MANIFEST_HTTP_PATH = \"/.keystroke/route-manifest\";\n//#endregion\n//#region src/schemas/route-manifest.ts\nconst serializedRouteManifestEntrySchema = z.discriminatedUnion(\"kind\", [\n\tz.object({\n\t\tkind: z.literal(\"health\"),\n\t\tmethod: z.literal(\"GET\"),\n\t\tpath: z.literal(\"/health\")\n\t}),\n\tz.object({\n\t\tkind: z.literal(\"agent\"),\n\t\tmethod: z.literal(\"POST\"),\n\t\tpath: z.string(),\n\t\tmoduleFile: z.string(),\n\t\trequestSchema: z.record(z.string(), z.unknown()),\n\t\tresponseSchema: z.record(z.string(), z.unknown())\n\t}),\n\tz.object({\n\t\tkind: z.literal(\"agent-sessions-list\"),\n\t\tmethod: z.literal(\"GET\"),\n\t\tpath: z.string(),\n\t\tagentId: z.string(),\n\t\tmoduleFile: z.string()\n\t}),\n\tz.object({\n\t\tkind: z.literal(\"agent-session-detail\"),\n\t\tmethod: z.literal(\"GET\"),\n\t\tpath: z.string(),\n\t\tagentId: z.string(),\n\t\tmoduleFile: z.string()\n\t}),\n\tz.object({\n\t\tkind: z.literal(\"workflow\"),\n\t\tmethod: z.literal(\"POST\"),\n\t\tpath: z.string(),\n\t\tworkflowId: z.string(),\n\t\tworkflowName: z.string().optional(),\n\t\tmoduleFile: z.string(),\n\t\trequestSchema: z.record(z.string(), z.unknown()),\n\t\tresponseSchema: z.record(z.string(), z.unknown())\n\t}),\n\tz.object({\n\t\tkind: z.literal(\"workflow-runs-list\"),\n\t\tmethod: z.literal(\"GET\"),\n\t\tpath: z.string(),\n\t\tworkflowId: z.string(),\n\t\tworkflowName: z.string().optional(),\n\t\tmoduleFile: z.string()\n\t}),\n\tz.object({\n\t\tkind: z.literal(\"workflow-run-detail\"),\n\t\tmethod: z.literal(\"GET\"),\n\t\tpath: z.string(),\n\t\tworkflowId: z.string(),\n\t\tworkflowName: z.string().optional(),\n\t\tmoduleFile: z.string()\n\t}),\n\tz.object({\n\t\tkind: z.literal(\"trigger-webhook\"),\n\t\tmethod: z.literal(\"POST\"),\n\t\tpath: z.string(),\n\t\tattachmentIds: z.array(z.string()),\n\t\tmoduleFile: z.string(),\n\t\trequestSchema: z.record(z.string(), z.unknown()),\n\t\tresponseSchema: z.record(z.string(), z.unknown())\n\t}),\n\tz.object({\n\t\tkind: z.literal(\"trigger-poll\"),\n\t\tmethod: z.literal(\"POST\"),\n\t\tpath: z.string(),\n\t\tattachmentId: z.string(),\n\t\tmoduleFile: z.string(),\n\t\tschedule: z.string(),\n\t\tresponseSchema: z.record(z.string(), z.unknown())\n\t}),\n\tz.object({\n\t\tkind: z.literal(\"trigger-poll-group\"),\n\t\tmethod: z.literal(\"POST\"),\n\t\tpath: z.string(),\n\t\tpollId: z.string(),\n\t\tattachmentIds: z.array(z.string()),\n\t\tmoduleFile: z.string(),\n\t\tschedule: z.string(),\n\t\tresponseSchema: z.record(z.string(), z.unknown())\n\t}),\n\tz.object({\n\t\tkind: z.literal(\"trigger-runs-list\"),\n\t\tmethod: z.literal(\"GET\"),\n\t\tpath: z.string(),\n\t\tattachmentId: z.string(),\n\t\tmoduleFile: z.string()\n\t}),\n\tz.object({\n\t\tkind: z.literal(\"trigger-run-detail\"),\n\t\tmethod: z.literal(\"GET\"),\n\t\tpath: z.string(),\n\t\tattachmentId: z.string(),\n\t\tmoduleFile: z.string()\n\t}),\n\tz.object({\n\t\tkind: z.literal(\"cron-schedule\"),\n\t\tattachmentId: z.string(),\n\t\tmoduleFile: z.string(),\n\t\tschedule: z.string()\n\t}),\n\tz.object({\n\t\tkind: z.literal(\"plugin\"),\n\t\tmethod: z.enum([\n\t\t\t\"GET\",\n\t\t\t\"POST\",\n\t\t\t\"PUT\",\n\t\t\t\"PATCH\",\n\t\t\t\"DELETE\"\n\t\t]),\n\t\tpath: z.string(),\n\t\tplugin: z.string()\n\t})\n]);\nconst StoredRouteManifestSchema = z.object({\n\tversion: z.literal(1),\n\tentries: z.array(serializedRouteManifestEntrySchema),\n\tintegrations: z.array(z.string()).optional()\n});\nfunction parseStoredRouteManifest(value) {\n\treturn StoredRouteManifestSchema.parse(value);\n}\n//#endregion\n//#region src/schemas/credentials.ts\n/** How a credential instance is stored (`credential_instances.auth_kind`). */\nconst CredentialAuthKindSchema = z.enum([\"api_key\", \"oauth_managed\"]);\n/** Where a credential instance is stored (`credential_instances.scope_type`). */\nconst CredentialScopeTypeSchema = z.enum([\n\t\"global\",\n\t\"organization\",\n\t\"project\",\n\t\"user\"\n]);\n/**\n* Resolution chain step when an action/tool looks up credentials.\n* `selection` uses explicit instance ids; other levels map to {@link CredentialScopeType}.\n*/\nconst CredentialScopeLevelSchema = z.enum([\n\t\"selection\",\n\t\"organization\",\n\t\"project\",\n\t\"user\"\n]);\nconst CREDENTIAL_AUTH_KINDS = CredentialAuthKindSchema.options;\nconst CREDENTIAL_SCOPE_TYPES = CredentialScopeTypeSchema.options;\nconst CREDENTIAL_SCOPE_LEVELS = CredentialScopeLevelSchema.options;\n/** Default chain when `credential.static(...).scope()` is called with no args. */\nconst DEFAULT_CREDENTIAL_RESOLUTION_CHAIN = [\"organization\", \"project\"];\nconst CREDENTIAL_SCOPE_LEVEL_TO_SCOPE_TYPE = {\n\torganization: \"organization\",\n\tproject: \"project\",\n\tuser: \"user\"\n};\n//#endregion\n//#region src/schemas/credential-spec.ts\nfunction isCredentialInput(value) {\n\tif (typeof value !== \"object\" || value === null) return false;\n\tconst candidate = value;\n\treturn typeof candidate.key === \"string\" && CredentialAuthKindSchema.safeParse(candidate.kind).success && candidate.schema instanceof z.ZodType;\n}\nconst credentialInputSchema = z.custom((value) => isCredentialInput(value), \"must be a credential requirement\");\nfunction createRef(kind, key, schema, options) {\n\tconst tokenField = options?.tokenField;\n\treturn {\n\t\tkind,\n\t\tkey,\n\t\tschema,\n\t\t...tokenField !== void 0 ? { tokenField } : {},\n\t\tscope(...chain) {\n\t\t\treturn {\n\t\t\t\tkey,\n\t\t\t\tkind,\n\t\t\t\tschema,\n\t\t\t\tchain: chain.length > 0 ? chain : DEFAULT_CREDENTIAL_RESOLUTION_CHAIN,\n\t\t\t\t...tokenField !== void 0 ? { tokenField } : {}\n\t\t\t};\n\t\t}\n\t};\n}\nfunction staticCredential(key, schema) {\n\treturn createRef(\"api_key\", key, schema instanceof z.ZodType ? schema : z.object(schema));\n}\nfunction oauthCredential(key, options) {\n\tconst tokenField = options?.tokenField ?? \"accessToken\";\n\treturn createRef(\"oauth_managed\", key, tokenField === \"accessToken\" ? z.object({ accessToken: z.string() }) : z.object({ [tokenField]: z.string() }), { tokenField });\n}\nconst credential = {\n\tstatic: staticCredential,\n\toauth: oauthCredential\n};\nfunction defineCredential(input) {\n\tif (input.kind === \"oauth\") return input.tokenField !== void 0 ? credential.oauth(input.key, { tokenField: input.tokenField }) : credential.oauth(input.key);\n\tif (\"schema\" in input) return credential.static(input.key, input.schema);\n\treturn credential.static(input.key, input.fields);\n}\nfunction normalizeCredentialList(list) {\n\treturn list.map((item) => toCredentialRequirement(item));\n}\nfunction isCredentialRequirement(item) {\n\treturn \"chain\" in item;\n}\nfunction toCredentialRequirement(item) {\n\tif (isCredentialRequirement(item)) return item;\n\treturn {\n\t\tkey: item.key,\n\t\tkind: item.kind,\n\t\tschema: item.schema,\n\t\tchain: DEFAULT_CREDENTIAL_RESOLUTION_CHAIN,\n\t\t...item.tokenField !== void 0 ? { tokenField: item.tokenField } : {}\n\t};\n}\n//#endregion\n//#region src/schemas/organizations.ts\n/** Canonical copy for slug collision errors (API + UI). */\nconst ORGANIZATION_SLUG_TAKEN_MESSAGE = \"That slug is already taken.\";\nconst OrganizationSlugErrorCodeSchema = z.enum([\n\t\"slug_taken\",\n\t\"slug_reserved\",\n\t\"slug_invalid\"\n]);\nconst SlugAvailabilityReasonSchema = z.enum([\n\t\"taken\",\n\t\"reserved\",\n\t\"invalid\"\n]);\nconst SlugAvailabilityResponseSchema = z.object({\n\tslug: z.string(),\n\tavailable: z.boolean(),\n\treason: SlugAvailabilityReasonSchema.optional(),\n\tsuggestion: OrganizationSlugSchema.optional()\n});\nconst SlugAvailabilityQuerySchema = z.object({\n\tslug: z.string().trim().min(1),\n\texcludeOrganizationId: z.string().min(1).optional()\n});\n/** Client-side instant validation before hitting the availability endpoint. */\nfunction validateClaimableOrganizationSlug(slug) {\n\tconst normalized = slug.trim().toLowerCase();\n\tif (!normalized) return {\n\t\tvalid: false,\n\t\treason: \"invalid\",\n\t\tmessage: \"Slug is required\"\n\t};\n\tconst format = OrganizationSlugSchema.safeParse(normalized);\n\tif (!format.success) return {\n\t\tvalid: false,\n\t\treason: \"invalid\",\n\t\tmessage: format.error.issues[0]?.message ?? \"Invalid slug\"\n\t};\n\tif (RESERVED_ORGANIZATION_SLUGS.has(format.data)) return {\n\t\tvalid: false,\n\t\treason: \"reserved\",\n\t\tmessage: \"This slug is reserved\"\n\t};\n\treturn { valid: true };\n}\nfunction organizationSlugErrorCodeFromMessage(message) {\n\tif (message === \"That slug is already taken.\" || /already taken/i.test(message)) return \"slug_taken\";\n\tif (/reserved/i.test(message)) return \"slug_reserved\";\n\treturn \"slug_invalid\";\n}\nconst ProjectStatusSchema = z.enum([\n\t\"inactive\",\n\t\"starting\",\n\t\"active\",\n\t\"failed\"\n]);\nconst OrganizationUserRoleSchema = z.enum([\n\t\"owner\",\n\t\"admin\",\n\t\"builder\"\n]);\nconst isoDateTime$2 = z.string().datetime();\nconst OrganizationSchema = z.object({\n\tid: z.string(),\n\tname: z.string(),\n\tslug: OrganizationSlugSchema,\n\tcreatedAt: isoDateTime$2,\n\tupdatedAt: isoDateTime$2\n});\nconst ProjectSchema = z.object({\n\tid: z.string(),\n\torganizationId: z.string(),\n\tname: z.string(),\n\tdescription: z.string().nullable(),\n\tstatus: ProjectStatusSchema,\n\tbaseUrl: z.string().nullable(),\n\truntimeId: z.string().nullable(),\n\tlastError: z.string().nullable(),\n\tcreatedAt: isoDateTime$2,\n\tupdatedAt: isoDateTime$2\n});\nconst UserOrganizationSchema = z.object({\n\torganization: OrganizationSchema,\n\trole: OrganizationUserRoleSchema\n});\nconst CurrentOrganizationResponseSchema = z.object({ organization: UserOrganizationSchema.nullable() });\nconst ActiveOrganizationResponseSchema = CurrentOrganizationResponseSchema;\nconst ListOrganizationsResponseSchema = z.object({ organizations: z.array(UserOrganizationSchema) });\nconst SetActiveOrganizationRequestSchema = z.object({ organizationId: z.string().min(1) });\nconst CreateOrganizationRequestSchema = z.object({\n\tname: z.string().trim().min(1),\n\t/** Format-only at the wire boundary; reserved-name checks run in platform-database. */\n\tslug: OrganizationSlugSchema.optional()\n});\nconst UpdateOrganizationRequestSchema = z.object({ slug: ClaimableOrganizationSlugSchema });\nconst CreateOrganizationResponseSchema = z.object({ organization: UserOrganizationSchema });\nconst ListProjectsResponseSchema = z.object({ projects: z.array(ProjectSchema) });\nconst CreateProjectRequestSchema = z.object({\n\tname: z.string().trim().min(1),\n\tdescription: z.string().trim().min(1).optional()\n});\nconst CreateProjectResponseSchema = z.object({ project: ProjectSchema });\nconst ProjectResponseSchema = z.object({ project: ProjectSchema });\nconst ProjectReachabilityResponseSchema = z.object({ reachable: z.boolean() });\nfunction parseCreateOrganizationRequest(input) {\n\treturn CreateOrganizationRequestSchema.parse(input);\n}\n//#endregion\n//#region src/schemas/errors/schema.ts\nconst ValidationErrorDetailSchema = z.object({\n\tpath: z.string(),\n\tmessage: z.string()\n});\n/** Machine-readable codes returned in standard API error bodies. */\nconst ErrorResponseCodeSchema = OrganizationSlugErrorCodeSchema.or(z.enum([\"needs_org_selection\"]));\n/** Standard JSON error body returned by the HTTP API. */\nconst ErrorResponseSchema = z.object({\n\terror: z.string(),\n\tcode: ErrorResponseCodeSchema.optional(),\n\tmessage: z.string().optional(),\n\tdetails: z.array(ValidationErrorDetailSchema).optional()\n});\n//#endregion\n//#region src/schemas/errors/from-zod.ts\n/** Build the JSON body for HTTP 400 validation failures. */\nfunction validationErrorResponse(error, summary) {\n\treturn {\n\t\terror: summary,\n\t\tdetails: error.issues.map((issue) => ({\n\t\t\tpath: issue.path.join(\".\"),\n\t\t\tmessage: issue.message\n\t\t}))\n\t};\n}\n//#endregion\n//#region src/schemas/errors/parse.ts\nconst MessageOnlyErrorBodySchema = z.object({ message: z.string() });\n/** Parse a JSON error body from the API. */\nfunction parseErrorResponse(body) {\n\tconst parsed = ErrorResponseSchema.safeParse(body);\n\tif (parsed.success) return parsed.data;\n\tconst messageOnly = MessageOnlyErrorBodySchema.safeParse(body);\n\tif (messageOnly.success) return {\n\t\terror: messageOnly.data.message,\n\t\tmessage: messageOnly.data.message\n\t};\n}\n//#endregion\n//#region src/schemas/http.ts\nconst CredentialRunContextSchema = z.object({\n\torgId: z.string().min(1).optional(),\n\tprojectId: z.string().min(1).optional(),\n\tuserId: z.string().min(1).optional(),\n\tuserIds: z.record(z.string(), z.string()).optional(),\n\tselection: z.record(z.string(), z.string()).optional()\n});\nconst ThinkingLevelSchema = z.enum([\n\t\"off\",\n\t\"minimal\",\n\t\"low\",\n\t\"medium\",\n\t\"high\",\n\t\"xhigh\"\n]);\nconst PromptInputSchema = z.object({\n\tmessage: z.string().min(1),\n\tsessionId: z.string().min(1).optional(),\n\tsubscriptionId: z.string().min(1).optional(),\n\tcontext: CredentialRunContextSchema.optional(),\n\tthinkingLevel: ThinkingLevelSchema.optional()\n});\nconst PromptResponseSchema = z.object({\n\tsessionId: z.string(),\n\tmessages: z.array(z.record(z.string(), z.unknown())),\n\terror: z.string().nullable()\n});\nconst SkipResponseSchema = z.object({\n\tok: z.literal(true),\n\tskipped: z.literal(true)\n});\nconst HealthResponseSchema = z.object({ ok: z.literal(true) });\nconst PlatformInfoResponseSchema = z.object({ service: z.string() });\nconst ConnectProviderSchema = z.object({\n\tkey: z.string(),\n\tmode: z.enum([\"authorize-url\", \"browser-redirect\"]),\n\tpath: z.string(),\n\trequiresAuth: z.boolean()\n});\nconst ConnectProvidersResponseSchema = z.object({ providers: z.array(ConnectProviderSchema) });\nconst ConnectAuthorizeUrlResponseSchema = z.object({ url: z.string() });\nconst QueuedRunResponseSchema = z.object({ runId: z.string() });\nconst QueuedAgentPromptResponseSchema = z.object({ sessionId: z.string() });\nfunction parsePromptInput(input) {\n\treturn PromptInputSchema.parse(input);\n}\nconst PollRunRequestSchema = z.object({\n\tworkflows: z.array(z.string().min(1)).optional(),\n\tattachments: z.array(z.string().min(1)).optional()\n});\nconst PollAttachmentResultSchema = z.object({\n\tattachmentKey: z.string(),\n\tworkflowKey: z.string(),\n\trunId: z.string().optional(),\n\tbody: z.unknown().optional(),\n\tqueued: z.boolean(),\n\tskipped: z.boolean().optional()\n});\nconst PollRunMultiResponseSchema = z.object({ results: z.array(PollAttachmentResultSchema) });\nconst PollRunResponseSchema = z.union([\n\tz.record(z.string(), z.unknown()),\n\tPollRunMultiResponseSchema,\n\tSkipResponseSchema,\n\tz.object({ runId: z.string() })\n]);\nfunction parsePollRunRequest(body) {\n\tif (body === void 0 || body === null) return {};\n\treturn PollRunRequestSchema.parse(body);\n}\n//#endregion\n//#region src/schemas/workflow-runs.ts\nconst WorkflowRunStatusSchema = z.enum([\n\t\"pending\",\n\t\"running\",\n\t\"completed\",\n\t\"failed\"\n]);\nconst WorkflowRunTriggerSchema = z.enum([\n\t\"api\",\n\t\"cron\",\n\t\"webhook\",\n\t\"poll\",\n\t\"retry\"\n]);\n/**\n* Durable workflow event-log entry types. Shared so the persistence layer\n* (`@keystrokehq/database` schema) and the runtime-agnostic replay engine\n* (`@keystrokehq/workflow`) reference one definition instead of duplicating it.\n*/\nconst WorkflowEventTypeSchema = z.enum([\n\t\"run_started\",\n\t\"step_completed\",\n\t\"step_failed\",\n\t\"step_retrying\",\n\t\"sleep_scheduled\",\n\t\"sleep_completed\",\n\t\"hook_created\",\n\t\"hook_resumed\",\n\t\"run_completed\",\n\t\"run_failed\"\n]);\nconst WorkflowRunSummarySchema = z.object({\n\tid: z.string(),\n\tstatus: WorkflowRunStatusSchema,\n\ttrigger: WorkflowRunTriggerSchema,\n\ttriggeredAt: z.string(),\n\tstartedAt: z.string().nullable(),\n\tfinishedAt: z.string().nullable(),\n\ttriggerRunId: z.string().nullable(),\n\tattachmentId: z.string().nullable()\n});\nconst WorkflowRunRecordSchema = z.object({\n\tid: z.string(),\n\tworkflowKey: z.string(),\n\tstatus: WorkflowRunStatusSchema,\n\ttrigger: WorkflowRunTriggerSchema,\n\ttriggeredAt: z.string(),\n\tstartedAt: z.string().nullable(),\n\tfinishedAt: z.string().nullable(),\n\ttriggerRunId: z.string().nullable(),\n\tattachmentId: z.string().nullable(),\n\tparentWorkflowRunId: z.string().nullable(),\n\tparentSpanId: z.string().nullable(),\n\tinput: z.unknown().nullable(),\n\toutput: z.unknown().nullable(),\n\terror: z.unknown().nullable()\n});\nconst WorkflowRunListQuerySchema = z.object({\n\tlimit: z.coerce.number().int().min(1).max(100).optional().default(20),\n\tcursor: z.string().min(1).optional(),\n\tstatus: WorkflowRunStatusSchema.optional(),\n\ttrigger: WorkflowRunTriggerSchema.optional()\n});\nconst WorkflowRunListResponseSchema = z.object({\n\titems: z.array(WorkflowRunSummarySchema),\n\tnextCursor: z.string().nullable()\n});\nconst WorkflowRunDetailIncludeSchema = z.enum([\n\t\"trigger\",\n\t\"steps\",\n\t\"trace\"\n]);\nconst WorkflowRunDetailQuerySchema = z.object({ include: z.string().optional() });\nconst DEFAULT_DETAIL_INCLUDE$2 = [\n\t\"trigger\",\n\t\"steps\",\n\t\"trace\"\n];\nfunction parseWorkflowRunDetailInclude(include) {\n\tif (!include?.trim()) return [...DEFAULT_DETAIL_INCLUDE$2];\n\tconst parsed = include.split(\",\").map((part) => part.trim()).filter((part) => WorkflowRunDetailIncludeSchema.options.includes(part));\n\treturn parsed.length > 0 ? parsed : [...DEFAULT_DETAIL_INCLUDE$2];\n}\nconst TriggerRunDetailSchema = z.object({\n\tid: z.string(),\n\tattachmentId: z.string(),\n\tattachmentKey: z.string().nullable(),\n\ttriggerType: z.enum([\n\t\t\"cron\",\n\t\t\"webhook\",\n\t\t\"poll\"\n\t]),\n\tsourcePath: z.string().nullable(),\n\tpayload: z.unknown().nullable(),\n\ttriggeredAt: z.string()\n});\nconst WorkflowStepRunSchema = z.object({\n\tid: z.string(),\n\tactionKey: z.string(),\n\toutput: z.unknown(),\n\tcompletedAt: z.string()\n});\nconst TraceTriggerSummarySchema = z.object({\n\ttriggerType: z.string(),\n\ttriggerRunId: z.string(),\n\tworkflowKey: z.string().optional(),\n\tagentKey: z.string().optional(),\n\tattachmentId: z.string().nullable().optional(),\n\tattachmentKey: z.string().nullable().optional(),\n\troute: z.string().optional(),\n\tsourcePath: z.string().nullable().optional()\n}).nullable();\nconst TraceGatewaySummarySchema = z.object({\n\tgatewayAttachmentId: z.string(),\n\tgatewayAttachmentKey: z.string(),\n\tthreadId: z.string().optional(),\n\tchannelId: z.string().optional(),\n\tmode: z.string().optional()\n}).nullable();\nconst TraceSpanSchema = z.object({\n\tid: z.string(),\n\ttraceId: z.string(),\n\tparentSpanId: z.string().nullable(),\n\tkind: z.string(),\n\trefId: z.string(),\n\tname: z.string(),\n\tstatus: z.string(),\n\tstartedAt: z.string(),\n\tfinishedAt: z.string().nullable(),\n\tmetadata: z.unknown().nullable(),\n\terror: z.unknown().nullable()\n});\nconst TraceLogSchema = z.object({\n\tid: z.string(),\n\ttraceId: z.string(),\n\tspanId: z.string(),\n\tseq: z.number(),\n\tlevel: z.string(),\n\tmessage: z.string(),\n\tdata: z.unknown().nullable(),\n\tsource: z.string(),\n\tcreatedAt: z.string()\n});\nconst TraceResponseSchema = z.object({\n\ttraceId: z.string(),\n\ttrigger: TraceTriggerSummarySchema,\n\tgateway: TraceGatewaySummarySchema,\n\tspans: z.array(TraceSpanSchema),\n\tlogs: z.array(TraceLogSchema)\n});\nconst WorkflowRunDetailResponseSchema = z.object({\n\trun: WorkflowRunRecordSchema,\n\ttrigger: TriggerRunDetailSchema.nullable(),\n\tsteps: z.array(WorkflowStepRunSchema),\n\ttrace: TraceResponseSchema.nullable()\n});\n//#endregion\n//#region src/schemas/agent-sessions.ts\nconst AgentSessionStatusSchema = z.enum([\n\t\"running\",\n\t\"completed\",\n\t\"failed\"\n]);\nconst AgentSessionSourceSchema = z.enum([\"api\", \"gateway\"]);\nconst AgentSessionSummarySchema = z.object({\n\tid: z.string(),\n\tstatus: AgentSessionStatusSchema,\n\tsource: AgentSessionSourceSchema,\n\tcreatedAt: z.string(),\n\tupdatedAt: z.string(),\n\tmessageCount: z.number()\n});\nconst AgentSessionRecordSchema = z.object({\n\tid: z.string(),\n\tagentKey: z.string(),\n\tstatus: AgentSessionStatusSchema,\n\tsource: AgentSessionSourceSchema,\n\tcreatedAt: z.string(),\n\tupdatedAt: z.string(),\n\tparentSpanId: z.string().nullable(),\n\tmessageCount: z.number(),\n\terror: z.unknown().nullable()\n});\nconst AgentSessionListQuerySchema = z.object({\n\tlimit: z.coerce.number().int().min(1).max(100).optional().default(20),\n\tcursor: z.string().min(1).optional(),\n\tstatus: AgentSessionStatusSchema.optional(),\n\tsource: AgentSessionSourceSchema.optional()\n});\nconst AgentSessionListResponseSchema = z.object({\n\titems: z.array(AgentSessionSummarySchema),\n\tnextCursor: z.string().nullable()\n});\nconst AgentSessionDetailIncludeSchema = z.enum([\n\t\"gateway\",\n\t\"messages\",\n\t\"events\",\n\t\"trace\"\n]);\nconst AgentSessionDetailQuerySchema = z.object({ include: z.string().optional() });\nconst DEFAULT_DETAIL_INCLUDE$1 = [\n\t\"gateway\",\n\t\"messages\",\n\t\"trace\"\n];\nfunction parseAgentSessionDetailInclude(include) {\n\tif (!include?.trim()) return [...DEFAULT_DETAIL_INCLUDE$1];\n\tconst parsed = include.split(\",\").map((part) => part.trim()).filter((part) => AgentSessionDetailIncludeSchema.options.includes(part));\n\treturn parsed.length > 0 ? parsed : [...DEFAULT_DETAIL_INCLUDE$1];\n}\nconst GatewaySessionDetailSchema = z.object({\n\tthreadId: z.string(),\n\tattachmentId: z.string(),\n\tattachmentKey: z.string().nullable()\n});\nconst AgentEventSchema = z.object({\n\tid: z.string(),\n\tsessionId: z.string(),\n\tseq: z.number(),\n\teventType: z.string(),\n\tpayload: z.unknown(),\n\tcreatedAt: z.string()\n});\nconst AgentSessionDetailResponseSchema = z.object({\n\tsession: AgentSessionRecordSchema,\n\tgateway: GatewaySessionDetailSchema.nullable(),\n\tmessages: z.array(z.record(z.string(), z.unknown())),\n\tevents: z.array(AgentEventSchema),\n\ttrace: TraceResponseSchema.nullable()\n});\n//#endregion\n//#region src/schemas/gateway-attachments.ts\nconst SlackGatewayModeSchema = z.enum([\n\t\"mention\",\n\t\"channel\",\n\t\"dm\"\n]);\nconst GatewayAttachmentSourceSchema = z.object({\n\tkind: z.literal(\"slack\"),\n\tmode: SlackGatewayModeSchema,\n\tcredentialKey: z.string(),\n\tchannelIds: z.array(z.string()).optional(),\n\tsubscribeOnMention: z.boolean()\n});\nconst GatewayAttachmentRecordSchema = z.object({\n\tid: z.string(),\n\tkey: z.string(),\n\tagentKey: z.string(),\n\tchannelId: z.string(),\n\tplatform: z.string(),\n\tsource: GatewayAttachmentSourceSchema,\n\tregisteredAt: z.string(),\n\tupdatedAt: z.string()\n});\nconst GatewayAttachmentListResponseSchema = z.object({ attachments: z.array(GatewayAttachmentRecordSchema) });\nconst UpsertGatewayAttachmentBodySchema = z.object({\n\tagentKey: z.string().min(1),\n\tmode: SlackGatewayModeSchema.optional(),\n\tsubscribeOnMention: z.boolean().optional()\n});\nconst AgentListItemSchema = z.object({\n\tkey: z.string(),\n\tname: z.string().optional(),\n\troute: z.string()\n});\nconst AgentListResponseSchema = z.object({ agents: z.array(AgentListItemSchema) });\n//#endregion\n//#region src/schemas/workflow-deployments.ts\nconst WorkflowSubscriptionRecordSchema = z.object({\n\tid: z.string(),\n\tworkflowKey: z.string(),\n\tuserId: z.string(),\n\tenabled: z.boolean(),\n\tcreatedAt: z.string(),\n\tupdatedAt: z.string()\n});\nconst WorkflowSubscriptionListResponseSchema = z.object({ subscriptions: z.array(WorkflowSubscriptionRecordSchema) });\nconst UpsertWorkflowSubscriptionBodySchema = z.object({\n\tuserId: z.string().min(1).optional(),\n\tenabled: z.boolean().optional()\n});\nconst CredentialInstanceRecordSchema = z.object({\n\tid: z.string(),\n\tkey: z.string(),\n\tscopeType: CredentialScopeTypeSchema,\n\tscopeId: z.string().nullable(),\n\tlabel: z.string().nullable(),\n\tisDefault: z.boolean(),\n\tauthKind: CredentialAuthKindSchema\n});\nconst CredentialInstanceListResponseSchema = z.object({ instances: z.array(CredentialInstanceRecordSchema) });\nconst CreateCredentialInstanceBodySchema = z.object({\n\tkey: z.string().min(1),\n\tscopeType: CredentialScopeTypeSchema,\n\tscopeId: z.string().nullable().optional(),\n\tlabel: z.string().nullable().optional(),\n\tisDefault: z.boolean().optional(),\n\tvalue: z.record(z.string(), z.unknown()).refine((value) => Object.keys(value).length > 0, { message: \"value must be a non-empty object\" })\n});\nconst UpdateCredentialInstanceBodySchema = z.object({\n\tlabel: z.string().nullable().optional(),\n\tisDefault: z.boolean().optional(),\n\tvalue: z.record(z.string(), z.unknown()).refine((value) => Object.keys(value).length > 0, { message: \"value must be a non-empty object\" }).optional()\n});\n//#endregion\n//#region src/schemas/trigger-runs.ts\nconst TriggerRunTypeSchema = z.enum([\n\t\"cron\",\n\t\"webhook\",\n\t\"poll\"\n]);\nconst TriggerRunWorkflowSummarySchema = z.object({\n\tid: z.string(),\n\tstatus: WorkflowRunStatusSchema,\n\tworkflowKey: z.string()\n});\nconst TriggerRunSummarySchema = z.object({\n\tid: z.string(),\n\ttriggerType: TriggerRunTypeSchema,\n\ttriggeredAt: z.string(),\n\tsourcePath: z.string().nullable(),\n\tworkflowRun: TriggerRunWorkflowSummarySchema.nullable()\n});\nconst TriggerRunRecordSchema = z.object({\n\tid: z.string(),\n\tattachmentId: z.string(),\n\tattachmentKey: z.string(),\n\ttriggerType: TriggerRunTypeSchema,\n\tsourcePath: z.string().nullable(),\n\tpayload: z.unknown().nullable(),\n\ttriggeredAt: z.string()\n});\nconst TriggerRunListQuerySchema = z.object({\n\tlimit: z.coerce.number().int().min(1).max(100).optional().default(20),\n\tcursor: z.string().min(1).optional(),\n\ttriggerType: TriggerRunTypeSchema.optional()\n});\nconst TriggerRunListResponseSchema = z.object({\n\titems: z.array(TriggerRunSummarySchema),\n\tnextCursor: z.string().nullable()\n});\nconst TriggerRunDetailIncludeSchema = z.enum([\"workflows\", \"trace\"]);\nconst TriggerRunDetailQuerySchema = z.object({ include: z.string().optional() });\nconst DEFAULT_DETAIL_INCLUDE = [\"workflows\", \"trace\"];\nfunction parseTriggerRunDetailInclude(include) {\n\tif (!include?.trim()) return [...DEFAULT_DETAIL_INCLUDE];\n\tconst parsed = include.split(\",\").map((part) => part.trim()).filter((part) => TriggerRunDetailIncludeSchema.options.includes(part));\n\treturn parsed.length > 0 ? parsed : [...DEFAULT_DETAIL_INCLUDE];\n}\nconst TriggerRunDetailResponseSchema = z.object({\n\trun: TriggerRunRecordSchema,\n\tworkflowRuns: z.array(WorkflowRunSummarySchema),\n\ttrace: TraceResponseSchema.nullable()\n});\n//#endregion\n//#region src/schemas/triggers.ts\nconst TriggerTypeSchema = z.enum([\n\t\"webhook\",\n\t\"poll\",\n\t\"cron\"\n]);\nconst TriggerListItemSchema = z.object({\n\tkey: z.string(),\n\ttype: TriggerTypeSchema,\n\troute: z.string().optional(),\n\twebhookUrl: z.string().url().optional(),\n\tworkflowKey: z.string()\n});\nconst TriggerListResponseSchema = z.object({ triggers: z.array(TriggerListItemSchema) });\nconst TriggerListQuerySchema = z.object({ endpoint: z.string().min(1).optional() });\nconst TriggerDetailResponseSchema = TriggerListItemSchema;\n//#endregion\n//#region src/schemas/members.ts\nconst OrganizationMemberRoleSchema = z.enum([\n\t\"owner\",\n\t\"admin\",\n\t\"builder\"\n]);\nconst OrganizationMemberStatusSchema = z.enum([\n\t\"invited\",\n\t\"active\",\n\t\"rejected\",\n\t\"suspended\"\n]);\nconst InvitableOrganizationMemberRoleSchema = z.enum([\"admin\", \"builder\"]);\nconst isoDateTime$1 = z.string().datetime();\nconst OrganizationMemberSchema = z.object({\n\tid: z.string(),\n\tname: z.string(),\n\temail: z.string().email(),\n\trole: OrganizationMemberRoleSchema,\n\tstatus: OrganizationMemberStatusSchema,\n\tavatarUrl: z.string().optional(),\n\tjoinedAt: isoDateTime$1.optional(),\n\tlastActiveAt: isoDateTime$1.nullable().optional()\n});\nconst ListOrganizationMembersResponseSchema = z.object({ members: z.array(OrganizationMemberSchema) });\nconst InviteOrganizationMembersRequestSchema = z.object({\n\temails: z.array(z.string().trim().email()).min(1),\n\trole: InvitableOrganizationMemberRoleSchema\n});\nconst InviteOrganizationMemberResultStatusSchema = z.enum([\n\t\"sent\",\n\t\"already_member\",\n\t\"pending\",\n\t\"invalid\"\n]);\nconst InviteOrganizationMemberResultSchema = z.object({\n\temail: z.string(),\n\tstatus: InviteOrganizationMemberResultStatusSchema,\n\tinvitationId: z.string().optional()\n});\nconst InviteOrganizationMembersResponseSchema = z.object({ results: z.array(InviteOrganizationMemberResultSchema) });\nconst UpdateOrganizationMemberRequestSchema = z.object({ role: InvitableOrganizationMemberRoleSchema });\nconst UpdateOrganizationMemberResponseSchema = z.object({ member: OrganizationMemberSchema });\nconst OrganizationInvitationSchema = z.object({\n\tid: z.string(),\n\torganizationName: z.string(),\n\torganizationSlug: OrganizationSlugSchema,\n\tinvitedByName: z.string().optional(),\n\tinvitedByEmail: z.string().email().optional(),\n\trole: OrganizationMemberRoleSchema\n});\nconst ListOrganizationInvitationsResponseSchema = z.object({ invitations: z.array(OrganizationInvitationSchema) });\nconst AcceptOrganizationInvitationResponseSchema = z.object({ organization: UserOrganizationSchema });\nconst DeclineOrganizationInvitationResponseSchema = z.object({ success: z.literal(true) });\n/** Web path to auto-accept an invitation after sign-in (used in invite emails). */\nfunction organizationInvitationAcceptPath(invitationId) {\n\treturn `/organization/invitations?${new URLSearchParams({ accept: invitationId }).toString()}`;\n}\n//#endregion\n//#region src/schemas/project-artifacts.ts\nconst ProjectArtifactStatusSchema = z.enum([\"pending\", \"ready\"]);\nconst isoDateTime = z.string().datetime();\nconst ProjectArtifactSchema = z.object({\n\tid: z.string(),\n\tprojectId: z.string(),\n\tstorageKey: z.string(),\n\tstatus: ProjectArtifactStatusSchema,\n\tcreatedAt: isoDateTime,\n\tupdatedAt: isoDateTime\n});\nconst CreateProjectArtifactResponseSchema = z.object({\n\tartifact: ProjectArtifactSchema,\n\tuploadUrl: z.string().url(),\n\texpiresInSeconds: z.number().int().positive()\n});\nconst CompleteProjectArtifactResponseSchema = z.object({\n\tartifact: ProjectArtifactSchema,\n\tproject: ProjectSchema\n});\n//#endregion\n//#region src/mappers/organizations.ts\nfunction mapOrganization(row) {\n\treturn OrganizationSchema.parse({\n\t\tid: row.id,\n\t\tname: row.name,\n\t\tslug: row.slug,\n\t\tcreatedAt: row.createdAt.toISOString(),\n\t\tupdatedAt: row.updatedAt.toISOString()\n\t});\n}\nfunction mapProject(row) {\n\treturn ProjectSchema.parse({\n\t\tid: row.id,\n\t\torganizationId: row.organizationId,\n\t\tname: row.name,\n\t\tdescription: row.description,\n\t\tstatus: row.status,\n\t\tbaseUrl: row.baseUrl,\n\t\truntimeId: row.runtimeId,\n\t\tlastError: row.lastError,\n\t\tcreatedAt: row.createdAt.toISOString(),\n\t\tupdatedAt: row.updatedAt.toISOString()\n\t});\n}\nfunction mapUserOrganization(row) {\n\treturn UserOrganizationSchema.parse({\n\t\torganization: mapOrganization(row.organization),\n\t\trole: row.role\n\t});\n}\n//#endregion\n//#region src/mappers/members.ts\nfunction mapOrganizationMember(row) {\n\treturn OrganizationMemberSchema.parse({\n\t\tid: row.id,\n\t\tname: row.name,\n\t\temail: row.email,\n\t\trole: row.role,\n\t\tstatus: row.status,\n\t\t...row.image ? { avatarUrl: row.image } : {},\n\t\tjoinedAt: row.createdAt.toISOString(),\n\t\tlastActiveAt: null\n\t});\n}\nfunction mapOrganizationInvitation(row) {\n\treturn OrganizationInvitationSchema.parse({\n\t\tid: row.id,\n\t\torganizationName: row.organizationName,\n\t\torganizationSlug: row.organizationSlug,\n\t\trole: row.role,\n\t\t...row.invitedByName ? { invitedByName: row.invitedByName } : {},\n\t\t...row.invitedByEmail ? { invitedByEmail: row.invitedByEmail } : {}\n\t});\n}\n//#endregion\n//#region src/mappers/project-artifacts.ts\nfunction mapProjectArtifact(row) {\n\treturn ProjectArtifactSchema.parse({\n\t\tid: row.id,\n\t\tprojectId: row.projectId,\n\t\tstorageKey: row.storageKey,\n\t\tstatus: row.status,\n\t\tcreatedAt: row.createdAt.toISOString(),\n\t\tupdatedAt: row.updatedAt.toISOString()\n\t});\n}\n//#endregion\nexport { ACTIVE_ORG_COOKIE, ACTIVE_ORG_HEADER, AcceptOrganizationInvitationResponseSchema, ActiveOrganizationResponseSchema, AgentListResponseSchema, AgentSessionDetailQuerySchema, AgentSessionDetailResponseSchema, AgentSessionListQuerySchema, AgentSessionListResponseSchema, CREDENTIAL_AUTH_KINDS, CREDENTIAL_SCOPE_LEVELS, CREDENTIAL_SCOPE_LEVEL_TO_SCOPE_TYPE, CREDENTIAL_SCOPE_TYPES, ClaimableOrganizationSlugSchema, CompleteProjectArtifactResponseSchema, ConnectAuthorizeUrlResponseSchema, ConnectProvidersResponseSchema, CreateCredentialInstanceBodySchema, CreateOrganizationRequestSchema, CreateOrganizationResponseSchema, CreateProjectArtifactResponseSchema, CreateProjectRequestSchema, CreateProjectResponseSchema, CredentialAuthKindSchema, CredentialInstanceListResponseSchema, CredentialInstanceRecordSchema, CredentialScopeLevelSchema, CredentialScopeTypeSchema, CurrentOrganizationResponseSchema, DEFAULT_CREDENTIAL_RESOLUTION_CHAIN, DISCOVERY_CONVENTIONS, DeclineOrganizationInvitationResponseSchema, ErrorResponseCodeSchema, ErrorResponseSchema, GatewayAttachmentListResponseSchema, GatewayAttachmentRecordSchema, HealthResponseSchema, InvitableOrganizationMemberRoleSchema, InviteOrganizationMembersRequestSchema, InviteOrganizationMembersResponseSchema, ListOrganizationInvitationsResponseSchema, ListOrganizationMembersResponseSchema, ListOrganizationsResponseSchema, ListProjectsResponseSchema, ORGANIZATION_SLUG_TAKEN_MESSAGE, OrganizationInvitationSchema, OrganizationMemberRoleSchema, OrganizationMemberSchema, OrganizationMemberStatusSchema, OrganizationSchema, OrganizationSlugErrorCodeSchema, OrganizationSlugSchema, OrganizationUserRoleSchema, PROJECT_PING_TIMEOUT_MS, PROJECT_REACHABILITY_REQUEST_TIMEOUT_MS, PROJECT_REACHABILITY_RETRY_MS, PlatformInfoResponseSchema, PollRunRequestSchema, PollRunResponseSchema, ProjectArtifactSchema, ProjectArtifactStatusSchema, ProjectReachabilityResponseSchema, ProjectResponseSchema, ProjectSchema, ProjectStatusSchema, PromptInputSchema, PromptResponseSchema, QueuedAgentPromptResponseSchema, QueuedRunResponseSchema, RESERVED_ORGANIZATION_SLUGS, ROUTE_MANIFEST_HTTP_PATH, ROUTE_MANIFEST_REL_PATH, SetActiveOrganizationRequestSchema, SkipResponseSchema, SlugAvailabilityQuerySchema, SlugAvailabilityReasonSchema, SlugAvailabilityResponseSchema, StoredRouteManifestSchema, TriggerDetailResponseSchema, TriggerListItemSchema, TriggerListQuerySchema, TriggerListResponseSchema, TriggerRunDetailQuerySchema, TriggerRunDetailResponseSchema, TriggerRunListQuerySchema, TriggerRunListResponseSchema, TriggerTypeSchema, UpdateCredentialInstanceBodySchema, UpdateOrganizationMemberRequestSchema, UpdateOrganizationMemberResponseSchema, UpdateOrganizationRequestSchema, UpsertGatewayAttachmentBodySchema, UpsertWorkflowSubscriptionBodySchema, UserOrganizationSchema, ValidationErrorDetailSchema, WorkflowEventTypeSchema, WorkflowRunDetailQuerySchema, WorkflowRunDetailResponseSchema, WorkflowRunListQuerySchema, WorkflowRunListResponseSchema, WorkflowSubscriptionListResponseSchema, WorkflowSubscriptionRecordSchema, credential, credentialInputSchema, defineCredential, isCredentialInput, listenPortFromPublicUrl, listenPortFromUrl, mapOrganization, mapOrganizationInvitation, mapOrganizationMember, mapProject, mapProjectArtifact, mapUserOrganization, normalizeCredentialList, organizationInvitationAcceptPath, organizationSlugErrorCodeFromMessage, originFromPublicUrl, parseAgentSessionDetailInclude, parseCreateOrganizationRequest, parseErrorResponse, parseOrganizationSlug, parsePollRunRequest, parsePromptInput, parseStoredRouteManifest, parseTriggerRunDetailInclude, parseWorkflowRunDetailInclude, previewOrganizationSlugFromName, slugifyOrganizationName, toCredentialRequirement, validateClaimableOrganizationSlug, validationErrorResponse };\n\n//# sourceMappingURL=index.mjs.map","import { z } from \"zod\";\nimport { CREDENTIAL_SCOPE_LEVELS, DEFAULT_CREDENTIAL_RESOLUTION_CHAIN, credential, credentialInputSchema, defineCredential, isCredentialInput, normalizeCredentialList, toCredentialRequirement } from \"@keystrokehq/shared\";\nimport { AsyncLocalStorage } from \"node:async_hooks\";\n//#region src/action-definition.ts\nconst zodSchema = z.custom((v) => v instanceof z.ZodType, \"must be a Zod schema\");\n/** Runtime validation for an unbranded action definition. */\nconst actionCoreSchema = z.object({\n\tkey: z.string().trim().min(1),\n\tname: z.string().trim().min(1),\n\tdescription: z.string().optional(),\n\tinput: zodSchema,\n\toutput: zodSchema,\n\tcredentials: z.array(credentialInputSchema).optional(),\n\trun: z.function()\n});\nconst ACTION = Symbol.for(\"keystroke.action\");\n/**\n* Validates brand + shape via `actionCoreSchema` so discovery and guards reject\n* malformed definitions.\n*/\nfunction isAction(value) {\n\tif (typeof value !== \"object\" || value === null) return false;\n\tif (!(ACTION in value) || value[ACTION] !== true) return false;\n\treturn actionCoreSchema.safeParse(value).success;\n}\nfunction getActionCredentialRequirements(action) {\n\treturn action.credentials;\n}\n//#endregion\n//#region src/action-execution-context.ts\n/**\n* Tracks the action whose `run` is currently executing. Actions are leaf units:\n* orchestration belongs in workflows, not inside another action. We use this to\n* reject an action that tries to invoke another action's `run` (directly or as a\n* step) while one is already on the stack.\n*/\nconst executingAction = new AsyncLocalStorage();\n/**\n* Runs an action's `run` body. Throws if another action is already executing in\n* the current async context — that means an action called another action.\n*/\nfunction runWithinActionExecution(actionKey, run) {\n\tconst parentKey = executingAction.getStore();\n\tif (parentKey !== void 0) throw new Error(`Action \"${actionKey}\" was invoked from inside action \"${parentKey}\". Actions are leaf units — an action must not call another action. Orchestrate actions in a workflow (src/workflows/), or attach the action directly as an agent tool (src/agents/).`);\n\treturn executingAction.run(actionKey, run);\n}\n/**\n* Resets the action-execution context for the duration of `fn`. Agent tool calls\n* are fresh top-level executions even when the agent was prompted from inside an\n* action, so calling actions as agent tools must not trip the guard.\n*/\nfunction runOutsideActionExecution(fn) {\n\treturn executingAction.exit(fn);\n}\n//#endregion\n//#region src/workflow-run-registry.ts\nconst REGISTRY_KEY = Symbol.for(\"keystroke.workflowRunGetter\");\nfunction registry() {\n\tconst globalScope = globalThis;\n\tif (!globalScope[REGISTRY_KEY]) globalScope[REGISTRY_KEY] = {};\n\treturn globalScope[REGISTRY_KEY];\n}\nfunction registerWorkflowRunGetter(fn) {\n\tregistry().getter = fn;\n}\nfunction getWorkflowRunHandle() {\n\treturn registry().getter?.();\n}\n//#endregion\n//#region src/step-invocation.ts\nfunction buildSelectionForAction(action, instanceId) {\n\tif (!action.credentials?.length) return {};\n\tconst requirements = normalizeCredentialList(action.credentials);\n\treturn Object.fromEntries(requirements.map((requirement) => [requirement.key, instanceId]));\n}\nfunction executeStep(state) {\n\tif (state.input === void 0) throw new Error(`Step \"${state.action.key}\" has no input. Call .run(input) before awaiting or chaining .scope().`);\n\tconst handle = getWorkflowRunHandle();\n\tif (!handle) throw new Error(`Step \"${state.action.key}\" must run inside a workflow or be called as .run(input, credentials) in tests.`);\n\treturn handle.actionRunner(state.action, state.input, {\n\t\tid: state.id,\n\t\tcredentialChain: state.chain,\n\t\tcredentialSelection: state.selection\n\t});\n}\nfunction isStepInvocation(value) {\n\treturn typeof value === \"object\" && value !== null && \"then\" in value && typeof value.then === \"function\" && \"scope\" in value && typeof value.scope === \"function\";\n}\nfunction createStepInvocation(state) {\n\treturn {\n\t\tscope(...chain) {\n\t\t\treturn createStepInvocation({\n\t\t\t\t...state,\n\t\t\t\tchain: chain.length > 0 ? chain : state.chain\n\t\t\t});\n\t\t},\n\t\tselect(instanceIdOrMap) {\n\t\t\tconst nextSelection = typeof instanceIdOrMap === \"string\" ? buildSelectionForAction(state.action, instanceIdOrMap) : instanceIdOrMap;\n\t\t\treturn createStepInvocation({\n\t\t\t\t...state,\n\t\t\t\tselection: {\n\t\t\t\t\t...state.selection,\n\t\t\t\t\t...nextSelection\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t\trun(input) {\n\t\t\treturn createStepInvocation({\n\t\t\t\t...state,\n\t\t\t\tinput\n\t\t\t});\n\t\t},\n\t\tstepId(id) {\n\t\t\treturn createStepInvocation({\n\t\t\t\t...state,\n\t\t\t\tid\n\t\t\t});\n\t\t},\n\t\tthen(onfulfilled, onrejected) {\n\t\t\treturn executeStep(state).then(onfulfilled, onrejected);\n\t\t}\n\t};\n}\n//#endregion\n//#region src/define-action.ts\nfunction attachStepApi(action) {\n\tconst execute = action.run.bind(action);\n\tconst stepAction = action;\n\treturn {\n\t\t...action,\n\t\trun(input, credentials) {\n\t\t\tif (credentials !== void 0) return execute(input, credentials);\n\t\t\treturn createStepInvocation({\n\t\t\t\taction: stepAction,\n\t\t\t\tinput\n\t\t\t});\n\t\t},\n\t\tscope(...chain) {\n\t\t\treturn createStepInvocation({\n\t\t\t\taction: stepAction,\n\t\t\t\tinput: void 0,\n\t\t\t\tchain\n\t\t\t});\n\t\t}\n\t};\n}\nfunction defineAction(def) {\n\tconst result = actionCoreSchema.safeParse(def);\n\tif (!result.success) throw new Error(`Invalid action definition: ${formatIssues(result.error.issues)}`);\n\tconst guardedRun = (input, credentials) => runWithinActionExecution(result.data.key, () => def.run(input, credentials));\n\treturn attachStepApi({\n\t\t...result.data,\n\t\trun: guardedRun,\n\t\tcredentials: def.credentials,\n\t\t[ACTION]: true\n\t});\n}\nfunction formatIssues(issues) {\n\treturn issues.map((issue) => {\n\t\treturn `${issue.path.length > 0 ? `${issue.path.join(\".\")}: ` : \"\"}${issue.message}`;\n\t}).join(\"; \");\n}\n//#endregion\n//#region src/execute-action.ts\nasync function executeAction(action, input, credentials = {}) {\n\tconst validatedInput = action.input.parse(input);\n\tconst result = await action.run(validatedInput, credentials);\n\treturn action.output.parse(result);\n}\n//#endregion\n//#region src/resolve-action-tool.ts\nfunction resolveActionTool(action, options) {\n\tconst consumer = options?.consumer ?? {\n\t\tkind: \"tool\",\n\t\tname: action.key\n\t};\n\treturn {\n\t\tname: action.key,\n\t\tlabel: action.name,\n\t\tdescription: action.description ?? action.name,\n\t\tparameters: z.toJSONSchema(action.input, { target: \"openapi-3.0\" }),\n\t\tasync execute(_toolCallId, params, _signal) {\n\t\t\tconst requirements = getActionCredentialRequirements(action);\n\t\t\tlet credentials = {};\n\t\t\tif (requirements?.length) {\n\t\t\t\tif (!options?.resolveCredentials) throw new Error(`Missing credential resolver for action \"${action.key}\"`);\n\t\t\t\tcredentials = await options.resolveCredentials(requirements, consumer, options.contextOverride);\n\t\t\t}\n\t\t\tconst output = await runOutsideActionExecution(() => executeAction(action, params, credentials));\n\t\t\treturn {\n\t\t\t\tcontent: [{\n\t\t\t\t\ttype: \"text\",\n\t\t\t\t\ttext: JSON.stringify(output)\n\t\t\t\t}],\n\t\t\t\tdetails: output\n\t\t\t};\n\t\t}\n\t};\n}\n//#endregion\nexport { CREDENTIAL_SCOPE_LEVELS, DEFAULT_CREDENTIAL_RESOLUTION_CHAIN, actionCoreSchema, createStepInvocation, credential, credentialInputSchema, defineAction, defineCredential, executeAction, getActionCredentialRequirements, getWorkflowRunHandle, isAction, isCredentialInput, isStepInvocation, normalizeCredentialList, registerWorkflowRunGetter, resolveActionTool, runOutsideActionExecution, runWithinActionExecution, toCredentialRequirement };\n\n//# sourceMappingURL=index.mjs.map"],"mappings":";;;;AA4BA,MAAM,qBAAqB;CAC1B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD;;AAEA,MAAM,oBAAoB;CACzB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD;;AAEA,MAAM,gBAAgB;CACrB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD;;AAEA,MAAM,uBAAuB;CAC5B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD;;AAEA,MAAM,0BAA0B;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD;;AAEA,MAAM,qBAAqB;CAC1B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD;;AAEA,MAAM,oBAAoB;CACzB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD;;AAEA,MAAM,uBAAuB;CAC5B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD;;AAEA,MAAM,qBAAqB;CAC1B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;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EACD;CACD;AACD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { U as SandboxDefinitionSchema } from "./dist-f_JGyGWx.mjs";
|
|
2
|
-
import { a as getActionCredentialRequirements, b as normalizeCredentialList, i as executeAction, l as registerWorkflowRunGetter } from "./dist-
|
|
3
|
-
import { i as withSpan, l as resolveActionCredentials, r as logSystem, t as captureConsole } from "./dist-
|
|
2
|
+
import { a as getActionCredentialRequirements, b as normalizeCredentialList, i as executeAction, l as registerWorkflowRunGetter } from "./dist-CnS5tygi.mjs";
|
|
3
|
+
import { i as withSpan, l as resolveActionCredentials, r as logSystem, t as captureConsole } from "./dist-BFyot0Xl.mjs";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
6
6
|
//#region ../workflow/dist/index.mjs
|
|
@@ -39,81 +39,39 @@ function formatIssues(issues) {
|
|
|
39
39
|
return `${issue.path.length > 0 ? `${issue.path.join(".")}: ` : ""}${issue.message}`;
|
|
40
40
|
}).join("; ");
|
|
41
41
|
}
|
|
42
|
-
function
|
|
43
|
-
if (
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
chain
|
|
47
|
-
}));
|
|
48
|
-
}
|
|
49
|
-
function createActionRunner(store, runId, options = {}) {
|
|
50
|
-
return async (action, input, runOptions) => {
|
|
51
|
-
const actionKey = runOptions?.id ?? action.key;
|
|
52
|
-
const cached = await store.get(runId, actionKey);
|
|
53
|
-
if (cached !== void 0) {
|
|
54
|
-
await withSpan({
|
|
55
|
-
kind: "action",
|
|
56
|
-
name: actionKey,
|
|
57
|
-
refId: `${runId}:${actionKey}`,
|
|
58
|
-
metadata: {
|
|
59
|
-
runId,
|
|
60
|
-
actionKey,
|
|
61
|
-
replayed: true
|
|
62
|
-
}
|
|
63
|
-
}, async () => {
|
|
64
|
-
await logSystem("info", "action replayed from checkpoint", {
|
|
65
|
-
runId,
|
|
66
|
-
actionKey
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
return action.output.parse(cached);
|
|
70
|
-
}
|
|
71
|
-
return withSpan({
|
|
72
|
-
kind: "action",
|
|
73
|
-
name: actionKey,
|
|
74
|
-
refId: `${runId}:${actionKey}`,
|
|
75
|
-
metadata: {
|
|
76
|
-
runId,
|
|
77
|
-
actionKey
|
|
78
|
-
}
|
|
79
|
-
}, async () => captureConsole(async () => {
|
|
80
|
-
const requirements = withCredentialChainOverride(getActionCredentialRequirements(action), runOptions?.credentialChain);
|
|
81
|
-
const contextOverride = runOptions?.credentialSelection ? { selection: runOptions.credentialSelection } : void 0;
|
|
82
|
-
const validatedOutput = await executeAction(action, input, requirements?.length ? await resolveActionCredentials(requirements, {
|
|
83
|
-
resolveCredentials: options.resolveCredentials,
|
|
84
|
-
context: options.credentialContext,
|
|
85
|
-
oauthAdapter: options.oauthAdapter,
|
|
86
|
-
consumer: {
|
|
87
|
-
kind: "action",
|
|
88
|
-
name: action.key
|
|
89
|
-
},
|
|
90
|
-
contextOverride
|
|
91
|
-
}) : {});
|
|
92
|
-
await store.set(runId, actionKey, validatedOutput);
|
|
93
|
-
return validatedOutput;
|
|
94
|
-
}));
|
|
42
|
+
function serializeWorkflowError(error) {
|
|
43
|
+
if (error instanceof Error) return {
|
|
44
|
+
name: error.name,
|
|
45
|
+
message: error.message
|
|
95
46
|
};
|
|
47
|
+
return { message: String(error) };
|
|
96
48
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
49
|
+
/** Rebuild an Error from a recorded error so replay re-raises the same failure. */
|
|
50
|
+
function deserializeWorkflowError(data) {
|
|
51
|
+
const serialized = data;
|
|
52
|
+
const error = new Error(serialized?.message ?? "Workflow step failed");
|
|
53
|
+
if (serialized?.name) error.name = serialized.name;
|
|
54
|
+
return error;
|
|
55
|
+
}
|
|
56
|
+
const UNIT_MS = {
|
|
57
|
+
ms: 1,
|
|
58
|
+
s: 1e3,
|
|
59
|
+
m: 6e4,
|
|
60
|
+
h: 36e5,
|
|
61
|
+
d: 864e5
|
|
108
62
|
};
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
if (
|
|
113
|
-
return
|
|
114
|
-
}
|
|
115
|
-
function
|
|
116
|
-
|
|
63
|
+
/** Resolve a sleep duration to an absolute resume time. */
|
|
64
|
+
function resolveResumeAt(duration, now = /* @__PURE__ */ new Date()) {
|
|
65
|
+
if (duration instanceof Date) return duration;
|
|
66
|
+
if (typeof duration === "number") return new Date(now.getTime() + Math.max(0, duration));
|
|
67
|
+
return new Date(now.getTime() + parseDurationToMs(duration));
|
|
68
|
+
}
|
|
69
|
+
function parseDurationToMs(value) {
|
|
70
|
+
const match = /^(\d+(?:\.\d+)?)\s*(ms|s|m|h|d)$/.exec(value.trim());
|
|
71
|
+
if (!match) throw new Error(`Invalid sleep duration "${value}". Use a number of ms, a Date, or a string like "5s", "10m", "1h".`);
|
|
72
|
+
const amount = Number(match[1]);
|
|
73
|
+
const unit = match[2];
|
|
74
|
+
return Math.round(amount * UNIT_MS[unit]);
|
|
117
75
|
}
|
|
118
76
|
/** Indexes replay events by correlationId for O(1) cache-hit checks during replay. */
|
|
119
77
|
var EventsConsumer = class {
|
|
@@ -132,6 +90,27 @@ var EventsConsumer = class {
|
|
|
132
90
|
hasEventType(correlationId, type) {
|
|
133
91
|
return this.events(correlationId).some((event) => event.type === type);
|
|
134
92
|
}
|
|
93
|
+
/**
|
|
94
|
+
* Cache lookup for a step. Returns the recorded output on a `step_completed`,
|
|
95
|
+
* re-raises the recorded error on a terminal `step_failed` (so a permanently
|
|
96
|
+
* failed step is not re-executed), and otherwise reports a miss — including
|
|
97
|
+
* when only `step_retrying` events exist (the step re-runs on the next pass).
|
|
98
|
+
*/
|
|
99
|
+
getStepResult(correlationId) {
|
|
100
|
+
const events = this.events(correlationId);
|
|
101
|
+
const failed = events.find((event) => event.type === "step_failed");
|
|
102
|
+
if (failed) throw deserializeWorkflowError(failed.data);
|
|
103
|
+
const completed = events.find((event) => event.type === "step_completed");
|
|
104
|
+
if (completed) return {
|
|
105
|
+
completed: true,
|
|
106
|
+
result: completed.data
|
|
107
|
+
};
|
|
108
|
+
return { completed: false };
|
|
109
|
+
}
|
|
110
|
+
/** Number of prior `step_retrying` events recorded for a step (= failed attempts so far). */
|
|
111
|
+
countRetrying(correlationId) {
|
|
112
|
+
return this.events(correlationId).filter((event) => event.type === "step_retrying").length;
|
|
113
|
+
}
|
|
135
114
|
isSleepCompleted(correlationId) {
|
|
136
115
|
return this.hasEventType(correlationId, "sleep_completed");
|
|
137
116
|
}
|
|
@@ -154,48 +133,6 @@ var EventsConsumer = class {
|
|
|
154
133
|
};
|
|
155
134
|
}
|
|
156
135
|
};
|
|
157
|
-
/** In-memory durable log for inline execution and tests. */
|
|
158
|
-
var MemoryEventLog = class {
|
|
159
|
-
events = [];
|
|
160
|
-
ids = /* @__PURE__ */ new Set();
|
|
161
|
-
async append(event) {
|
|
162
|
-
const id = event.id ?? crypto.randomUUID();
|
|
163
|
-
if (this.ids.has(id)) return false;
|
|
164
|
-
this.ids.add(id);
|
|
165
|
-
this.events.push({
|
|
166
|
-
id,
|
|
167
|
-
runId: event.runId,
|
|
168
|
-
seq: this.events.length,
|
|
169
|
-
type: event.type,
|
|
170
|
-
correlationId: event.correlationId ?? null,
|
|
171
|
-
data: event.data ?? null
|
|
172
|
-
});
|
|
173
|
-
return true;
|
|
174
|
-
}
|
|
175
|
-
async listReplay(runId) {
|
|
176
|
-
return this.events.filter((event) => event.runId === runId).map((event) => ({ ...event }));
|
|
177
|
-
}
|
|
178
|
-
};
|
|
179
|
-
const UNIT_MS = {
|
|
180
|
-
ms: 1,
|
|
181
|
-
s: 1e3,
|
|
182
|
-
m: 6e4,
|
|
183
|
-
h: 36e5,
|
|
184
|
-
d: 864e5
|
|
185
|
-
};
|
|
186
|
-
/** Resolve a sleep duration to an absolute resume time. */
|
|
187
|
-
function resolveResumeAt(duration, now = /* @__PURE__ */ new Date()) {
|
|
188
|
-
if (duration instanceof Date) return duration;
|
|
189
|
-
if (typeof duration === "number") return new Date(now.getTime() + Math.max(0, duration));
|
|
190
|
-
return new Date(now.getTime() + parseDurationToMs(duration));
|
|
191
|
-
}
|
|
192
|
-
function parseDurationToMs(value) {
|
|
193
|
-
const match = /^(\d+(?:\.\d+)?)\s*(ms|s|m|h|d)$/.exec(value.trim());
|
|
194
|
-
if (!match) throw new Error(`Invalid sleep duration "${value}". Use a number of ms, a Date, or a string like "5s", "10m", "1h".`);
|
|
195
|
-
const amount = Number(match[1]);
|
|
196
|
-
const unit = match[2];
|
|
197
|
-
return Math.round(amount * UNIT_MS[unit]);
|
|
198
|
-
}
|
|
199
136
|
/** A promise that never settles — returned by a suspending primitive so the body parks. */
|
|
200
137
|
function createPendingPromise() {
|
|
201
138
|
return new Promise(() => {});
|
|
@@ -232,13 +169,36 @@ function createReplayState(params) {
|
|
|
232
169
|
runId: params.runId,
|
|
233
170
|
consumer: params.consumer,
|
|
234
171
|
coordinator: params.coordinator,
|
|
172
|
+
eventLog: params.eventLog,
|
|
235
173
|
newEvents: [],
|
|
236
174
|
now: params.now ?? /* @__PURE__ */ new Date(),
|
|
237
175
|
hookBaseUrl: params.hookBaseUrl,
|
|
238
176
|
sleepCounter: 0,
|
|
239
|
-
hookCounter: 0
|
|
177
|
+
hookCounter: 0,
|
|
178
|
+
stepOccurrences: /* @__PURE__ */ new Map(),
|
|
179
|
+
stepCorrelationIds: /* @__PURE__ */ new Set()
|
|
240
180
|
};
|
|
241
181
|
}
|
|
182
|
+
/**
|
|
183
|
+
* Allocate the correlation id for a step. An explicit `.stepId(x)` maps to
|
|
184
|
+
* `step:x` (and must be unique within a run); otherwise the key is
|
|
185
|
+
* `step:<actionKey>#<occurrence>` so that two calls to the same action get
|
|
186
|
+
* distinct, replay-stable ids and inserting an unrelated call never shifts the
|
|
187
|
+
* ids of later calls (unlike a single global ordinal).
|
|
188
|
+
*/
|
|
189
|
+
function nextStepCorrelationId(state, actionKey, explicitId) {
|
|
190
|
+
if (explicitId !== void 0) {
|
|
191
|
+
const correlationId = `step:${explicitId}`;
|
|
192
|
+
if (state.stepCorrelationIds.has(correlationId)) throw new Error(`Duplicate step id "${explicitId}" in workflow run ${state.runId}`);
|
|
193
|
+
state.stepCorrelationIds.add(correlationId);
|
|
194
|
+
return correlationId;
|
|
195
|
+
}
|
|
196
|
+
const occurrence = state.stepOccurrences.get(actionKey) ?? 0;
|
|
197
|
+
state.stepOccurrences.set(actionKey, occurrence + 1);
|
|
198
|
+
const correlationId = `step:${actionKey}#${occurrence}`;
|
|
199
|
+
state.stepCorrelationIds.add(correlationId);
|
|
200
|
+
return correlationId;
|
|
201
|
+
}
|
|
242
202
|
function createSleep(state) {
|
|
243
203
|
return function sleep(duration) {
|
|
244
204
|
const correlationId = `sleep#${state.sleepCounter++}`;
|
|
@@ -299,6 +259,123 @@ function createHook(state) {
|
|
|
299
259
|
};
|
|
300
260
|
};
|
|
301
261
|
}
|
|
262
|
+
function withCredentialChainOverride(requirements, chain) {
|
|
263
|
+
if (!requirements || !chain) return requirements;
|
|
264
|
+
return normalizeCredentialList(requirements).map((requirement) => ({
|
|
265
|
+
...requirement,
|
|
266
|
+
chain
|
|
267
|
+
}));
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Builds the per-run action runner. Each action call resolves a stable
|
|
271
|
+
* `correlation_id`, short-circuits from the durable event log on a cache hit,
|
|
272
|
+
* and otherwise executes and appends `step_completed` immediately (preserving
|
|
273
|
+
* per-step crash durability). A thrown step appends `step_retrying` (non-fatal,
|
|
274
|
+
* re-run on the next attempt) and rethrows; the terminal `step_failed` is
|
|
275
|
+
* written by the job handler once the queue exhausts retries.
|
|
276
|
+
*/
|
|
277
|
+
function createActionRunner(state, options = {}) {
|
|
278
|
+
const { runId, consumer, eventLog } = state;
|
|
279
|
+
return async (action, input, runOptions) => {
|
|
280
|
+
const correlationId = nextStepCorrelationId(state, action.key, runOptions?.id);
|
|
281
|
+
const cached = consumer.getStepResult(correlationId);
|
|
282
|
+
if (cached.completed) {
|
|
283
|
+
await withSpan({
|
|
284
|
+
kind: "action",
|
|
285
|
+
name: action.key,
|
|
286
|
+
refId: `${runId}:${correlationId}`,
|
|
287
|
+
metadata: {
|
|
288
|
+
runId,
|
|
289
|
+
actionKey: action.key,
|
|
290
|
+
correlationId,
|
|
291
|
+
replayed: true
|
|
292
|
+
}
|
|
293
|
+
}, async () => {
|
|
294
|
+
await logSystem("info", "action replayed from checkpoint", {
|
|
295
|
+
runId,
|
|
296
|
+
actionKey: action.key,
|
|
297
|
+
correlationId
|
|
298
|
+
});
|
|
299
|
+
});
|
|
300
|
+
return action.output.parse(cached.result);
|
|
301
|
+
}
|
|
302
|
+
return withSpan({
|
|
303
|
+
kind: "action",
|
|
304
|
+
name: action.key,
|
|
305
|
+
refId: `${runId}:${correlationId}`,
|
|
306
|
+
metadata: {
|
|
307
|
+
runId,
|
|
308
|
+
actionKey: action.key,
|
|
309
|
+
correlationId
|
|
310
|
+
}
|
|
311
|
+
}, async () => captureConsole(async () => {
|
|
312
|
+
try {
|
|
313
|
+
const requirements = withCredentialChainOverride(getActionCredentialRequirements(action), runOptions?.credentialChain);
|
|
314
|
+
const contextOverride = runOptions?.credentialSelection ? { selection: runOptions.credentialSelection } : void 0;
|
|
315
|
+
const validatedOutput = await executeAction(action, input, requirements?.length ? await resolveActionCredentials(requirements, {
|
|
316
|
+
resolveCredentials: options.resolveCredentials,
|
|
317
|
+
context: options.credentialContext,
|
|
318
|
+
oauthAdapter: options.oauthAdapter,
|
|
319
|
+
consumer: {
|
|
320
|
+
kind: "action",
|
|
321
|
+
name: action.key
|
|
322
|
+
},
|
|
323
|
+
contextOverride
|
|
324
|
+
}) : {});
|
|
325
|
+
await eventLog.append({
|
|
326
|
+
id: `step_completed:${runId}:${correlationId}`,
|
|
327
|
+
runId,
|
|
328
|
+
type: "step_completed",
|
|
329
|
+
correlationId,
|
|
330
|
+
data: validatedOutput
|
|
331
|
+
});
|
|
332
|
+
return validatedOutput;
|
|
333
|
+
} catch (error) {
|
|
334
|
+
const attempt = consumer.countRetrying(correlationId);
|
|
335
|
+
await eventLog.append({
|
|
336
|
+
id: `step_retrying:${runId}:${correlationId}:${attempt}`,
|
|
337
|
+
runId,
|
|
338
|
+
type: "step_retrying",
|
|
339
|
+
correlationId,
|
|
340
|
+
data: serializeWorkflowError(error)
|
|
341
|
+
});
|
|
342
|
+
state.failedCorrelationId = correlationId;
|
|
343
|
+
throw error;
|
|
344
|
+
}
|
|
345
|
+
}));
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
const storage = new AsyncLocalStorage();
|
|
349
|
+
registerWorkflowRunGetter(() => {
|
|
350
|
+
const store = storage.getStore();
|
|
351
|
+
if (!store) return;
|
|
352
|
+
return { actionRunner: store.actionRunner };
|
|
353
|
+
});
|
|
354
|
+
function runWithWorkflowContext(store, fn) {
|
|
355
|
+
return storage.run(store, fn);
|
|
356
|
+
}
|
|
357
|
+
/** In-memory durable log for inline execution and tests. */
|
|
358
|
+
var MemoryEventLog = class {
|
|
359
|
+
events = [];
|
|
360
|
+
ids = /* @__PURE__ */ new Set();
|
|
361
|
+
async append(event) {
|
|
362
|
+
const id = event.id ?? crypto.randomUUID();
|
|
363
|
+
if (this.ids.has(id)) return false;
|
|
364
|
+
this.ids.add(id);
|
|
365
|
+
this.events.push({
|
|
366
|
+
id,
|
|
367
|
+
runId: event.runId,
|
|
368
|
+
seq: this.events.length,
|
|
369
|
+
type: event.type,
|
|
370
|
+
correlationId: event.correlationId ?? null,
|
|
371
|
+
data: event.data ?? null
|
|
372
|
+
});
|
|
373
|
+
return true;
|
|
374
|
+
}
|
|
375
|
+
async listReplay(runId) {
|
|
376
|
+
return this.events.filter((event) => event.runId === runId).map((event) => ({ ...event }));
|
|
377
|
+
}
|
|
378
|
+
};
|
|
302
379
|
/**
|
|
303
380
|
* The single way to run a workflow: replay its event log from the top, execute
|
|
304
381
|
* un-cached primitives, and either complete/fail or suspend at the first
|
|
@@ -312,17 +389,17 @@ function createHook(state) {
|
|
|
312
389
|
async function executeWorkflow(workflow, input, options = {}) {
|
|
313
390
|
const runId = options.runId ?? crypto.randomUUID();
|
|
314
391
|
const eventLog = options.eventLog ?? new MemoryEventLog();
|
|
315
|
-
const actionStore = options.actionStore ?? new MemoryActionStore();
|
|
316
392
|
const consumer = new EventsConsumer(await eventLog.listReplay(runId));
|
|
317
393
|
const coordinator = new SuspensionCoordinator();
|
|
318
394
|
const state = createReplayState({
|
|
319
395
|
runId,
|
|
320
396
|
consumer,
|
|
321
397
|
coordinator,
|
|
398
|
+
eventLog,
|
|
322
399
|
hookBaseUrl: options.hookBaseUrl,
|
|
323
400
|
now: options.now
|
|
324
401
|
});
|
|
325
|
-
const actionRunner = createActionRunner(
|
|
402
|
+
const actionRunner = createActionRunner(state, {
|
|
326
403
|
resolveCredentials: options.resolveCredentials,
|
|
327
404
|
credentialContext: options.credentialContext,
|
|
328
405
|
oauthAdapter: options.oauthAdapter
|
|
@@ -369,12 +446,13 @@ async function executeWorkflow(workflow, input, options = {}) {
|
|
|
369
446
|
};
|
|
370
447
|
} else result = {
|
|
371
448
|
status: "failed",
|
|
372
|
-
error: outcome.error
|
|
449
|
+
error: outcome.error,
|
|
450
|
+
failedCorrelationId: state.failedCorrelationId
|
|
373
451
|
};
|
|
374
452
|
for (const event of state.newEvents) await eventLog.append(event);
|
|
375
453
|
return result;
|
|
376
454
|
}
|
|
377
455
|
//#endregion
|
|
378
|
-
export { isWorkflow as a, executeWorkflow as i,
|
|
456
|
+
export { isWorkflow as a, executeWorkflow as i, defineWorkflow as n, serializeWorkflowError as o, deserializeWorkflowError as r, MemoryEventLog as t };
|
|
379
457
|
|
|
380
|
-
//# sourceMappingURL=dist-
|
|
458
|
+
//# sourceMappingURL=dist-DL6FMwfb.mjs.map
|