@vm0/cli 9.252.1 → 9.253.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{agent-6DLY56R2.js → agent-X6O3YR4M.js} +7 -7
- package/{banking-22B7QVCY.js → banking-NGZXYSVB.js} +5 -5
- package/{chat-2QVQ3MLT.js → chat-CRY62LOA.js} +6 -6
- package/{chunk-OAESJHRL.js → chunk-2E37DQSD.js} +2 -2
- package/{chunk-FBISVSTZ.js → chunk-2YJV4T5H.js} +175 -8
- package/{chunk-FBISVSTZ.js.map → chunk-2YJV4T5H.js.map} +1 -1
- package/{chunk-7DGYI4QB.js → chunk-7JNLGFRW.js} +3 -3
- package/chunk-7JNLGFRW.js.map +1 -0
- package/{chunk-7NPYHUEQ.js → chunk-7YTIE7KU.js} +3 -3
- package/{chunk-CUAL7MH6.js → chunk-FJFJLQQW.js} +2 -2
- package/{chunk-DK3C2ME6.js → chunk-KMRZUQHC.js} +8 -1
- package/chunk-KMRZUQHC.js.map +1 -0
- package/{chunk-Z6BXUYYX.js → chunk-LIT3JQQR.js} +2 -2
- package/{chunk-MFNEXCZL.js → chunk-LO2JYFNP.js} +2 -2
- package/{chunk-7QTOTACG.js → chunk-RANJI5FZ.js} +2 -2
- package/{chunk-CPJVE3HV.js → chunk-RMLNBK2X.js} +2 -2
- package/{chunk-KBUXPDDX.js → chunk-XM3WOXFE.js} +4 -4
- package/{computer-use-TWN6NBIN.js → computer-use-C3HZXTKZ.js} +5 -5
- package/{connector-DEKQFV2G.js → connector-DPZKQG4U.js} +8 -8
- package/{credit-SGN2CQ4F.js → credit-WY6P3D6B.js} +7 -7
- package/{developer-support-7DKJHHFR.js → developer-support-RYY76Y65.js} +5 -5
- package/{doctor-PINI2CXE.js → doctor-XZH52P7J.js} +7 -7
- package/{feishu-RVNSCNUY.js → feishu-HLSIBEHH.js} +5 -5
- package/{finance-IL3LEHYM.js → finance-IWVIYPXL.js} +5 -5
- package/{generate-DVB7CDWO.js → generate-IAA656VE.js} +7 -7
- package/{github-HECK3WC6.js → github-MJZJ2VLC.js} +5 -5
- package/{goal-RJ4KHBJZ.js → goal-7OCVIFTQ.js} +5 -5
- package/{host-UAVQ4BZY.js → host-KX7NPRZM.js} +5 -5
- package/{logs-PFZVJGHK.js → logs-AHOU7TJL.js} +6 -6
- package/{mail-SJOUFJDK.js → mail-D3YBSKA6.js} +7 -7
- package/{maps-JCB6I264.js → maps-AT7I4KK6.js} +5 -5
- package/{model-GI5HI3B5.js → model-7AEJV5QI.js} +6 -6
- package/{model-provider-YVF7DWLL.js → model-provider-CNTRAXGR.js} +6 -6
- package/{org-SPWQ25RJ.js → org-4EOIMAMU.js} +5 -5
- package/package.json +1 -1
- package/{people-search-24TMMWRS.js → people-search-YIPV2HRX.js} +5 -5
- package/{phone-3XXRREOH.js → phone-RGFGHH4G.js} +5 -5
- package/{preference-SSKGMIHI.js → preference-UIFDOWCE.js} +5 -5
- package/{resource-HJBJYOZW.js → resource-UCO5W2EM.js} +5 -5
- package/{scrape-LCD2CT5P.js → scrape-V6KXL77N.js} +5 -5
- package/{search-IU6AXAPL.js → search-FKCTV4PA.js} +6 -6
- package/{secret-4GZ5YF55.js → secret-ZOUQEPTX.js} +5 -5
- package/{slack-TLBZUY27.js → slack-4WKWNC54.js} +5 -5
- package/{teams-ZKQMACHI.js → teams-MRN5OZEA.js} +5 -5
- package/{telegram-J4ZWDUEB.js → telegram-DJ6DOWYM.js} +5 -5
- package/{upgrade-UBEBOHV6.js → upgrade-2VYHUARI.js} +4 -4
- package/{variable-4K5GUB4B.js → variable-6SNXAUY7.js} +5 -5
- package/{video-5LENA5YA.js → video-DF4MZ6J2.js} +4 -4
- package/{weather-UL4D4T3L.js → weather-PATAREUP.js} +5 -5
- package/{web-6452PFF7.js → web-GMBMMBHY.js} +5 -5
- package/{web-search-D5HGEWU5.js → web-search-SYJ7DI6M.js} +5 -5
- package/{whoami-HYDZ6YSH.js → whoami-KD3QSC6J.js} +7 -7
- package/{workflow-W2HNGAVJ.js → workflow-DATIF2MF.js} +577 -41
- package/workflow-DATIF2MF.js.map +1 -0
- package/zero.js +42 -42
- package/chunk-7DGYI4QB.js.map +0 -1
- package/chunk-DK3C2ME6.js.map +0 -1
- package/workflow-W2HNGAVJ.js.map +0 -1
- /package/{agent-6DLY56R2.js.map → agent-X6O3YR4M.js.map} +0 -0
- /package/{banking-22B7QVCY.js.map → banking-NGZXYSVB.js.map} +0 -0
- /package/{chat-2QVQ3MLT.js.map → chat-CRY62LOA.js.map} +0 -0
- /package/{chunk-OAESJHRL.js.map → chunk-2E37DQSD.js.map} +0 -0
- /package/{chunk-7NPYHUEQ.js.map → chunk-7YTIE7KU.js.map} +0 -0
- /package/{chunk-CUAL7MH6.js.map → chunk-FJFJLQQW.js.map} +0 -0
- /package/{chunk-Z6BXUYYX.js.map → chunk-LIT3JQQR.js.map} +0 -0
- /package/{chunk-MFNEXCZL.js.map → chunk-LO2JYFNP.js.map} +0 -0
- /package/{chunk-7QTOTACG.js.map → chunk-RANJI5FZ.js.map} +0 -0
- /package/{chunk-CPJVE3HV.js.map → chunk-RMLNBK2X.js.map} +0 -0
- /package/{chunk-KBUXPDDX.js.map → chunk-XM3WOXFE.js.map} +0 -0
- /package/{computer-use-TWN6NBIN.js.map → computer-use-C3HZXTKZ.js.map} +0 -0
- /package/{connector-DEKQFV2G.js.map → connector-DPZKQG4U.js.map} +0 -0
- /package/{credit-SGN2CQ4F.js.map → credit-WY6P3D6B.js.map} +0 -0
- /package/{developer-support-7DKJHHFR.js.map → developer-support-RYY76Y65.js.map} +0 -0
- /package/{doctor-PINI2CXE.js.map → doctor-XZH52P7J.js.map} +0 -0
- /package/{feishu-RVNSCNUY.js.map → feishu-HLSIBEHH.js.map} +0 -0
- /package/{finance-IL3LEHYM.js.map → finance-IWVIYPXL.js.map} +0 -0
- /package/{generate-DVB7CDWO.js.map → generate-IAA656VE.js.map} +0 -0
- /package/{github-HECK3WC6.js.map → github-MJZJ2VLC.js.map} +0 -0
- /package/{goal-RJ4KHBJZ.js.map → goal-7OCVIFTQ.js.map} +0 -0
- /package/{host-UAVQ4BZY.js.map → host-KX7NPRZM.js.map} +0 -0
- /package/{logs-PFZVJGHK.js.map → logs-AHOU7TJL.js.map} +0 -0
- /package/{mail-SJOUFJDK.js.map → mail-D3YBSKA6.js.map} +0 -0
- /package/{maps-JCB6I264.js.map → maps-AT7I4KK6.js.map} +0 -0
- /package/{model-GI5HI3B5.js.map → model-7AEJV5QI.js.map} +0 -0
- /package/{model-provider-YVF7DWLL.js.map → model-provider-CNTRAXGR.js.map} +0 -0
- /package/{org-SPWQ25RJ.js.map → org-4EOIMAMU.js.map} +0 -0
- /package/{people-search-24TMMWRS.js.map → people-search-YIPV2HRX.js.map} +0 -0
- /package/{phone-3XXRREOH.js.map → phone-RGFGHH4G.js.map} +0 -0
- /package/{preference-SSKGMIHI.js.map → preference-UIFDOWCE.js.map} +0 -0
- /package/{resource-HJBJYOZW.js.map → resource-UCO5W2EM.js.map} +0 -0
- /package/{scrape-LCD2CT5P.js.map → scrape-V6KXL77N.js.map} +0 -0
- /package/{search-IU6AXAPL.js.map → search-FKCTV4PA.js.map} +0 -0
- /package/{secret-4GZ5YF55.js.map → secret-ZOUQEPTX.js.map} +0 -0
- /package/{slack-TLBZUY27.js.map → slack-4WKWNC54.js.map} +0 -0
- /package/{teams-ZKQMACHI.js.map → teams-MRN5OZEA.js.map} +0 -0
- /package/{telegram-J4ZWDUEB.js.map → telegram-DJ6DOWYM.js.map} +0 -0
- /package/{upgrade-UBEBOHV6.js.map → upgrade-2VYHUARI.js.map} +0 -0
- /package/{variable-4K5GUB4B.js.map → variable-6SNXAUY7.js.map} +0 -0
- /package/{video-5LENA5YA.js.map → video-DF4MZ6J2.js.map} +0 -0
- /package/{weather-UL4D4T3L.js.map → weather-PATAREUP.js.map} +0 -0
- /package/{web-6452PFF7.js.map → web-GMBMMBHY.js.map} +0 -0
- /package/{web-search-D5HGEWU5.js.map → web-search-SYJ7DI6M.js.map} +0 -0
- /package/{whoami-HYDZ6YSH.js.map → whoami-KD3QSC6J.js.map} +0 -0
package/chunk-DK3C2ME6.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../packages/connectors/src/feature-switch-key.ts","../../../packages/core/src/feature-switch.ts","../../../packages/core/src/feature-switch-key.ts","../../../packages/core/src/identity-hash.ts","../src/lib/api/zero-token.ts"],"sourcesContent":["/**\n * Feature switch keys\n *\n * Defines all available feature switch identifiers.\n */\nexport enum FeatureSwitchKey {\n Dummy = \"dummy\",\n ExternalConnectorCatalog = \"externalConnectorCatalog\",\n AhrefsConnector = \"ahrefsConnector\",\n BillConnector = \"billConnector\",\n BentomlConnector = \"bentomlConnector\",\n BoxConnector = \"boxConnector\",\n CanvaConnector = \"canvaConnector\",\n CalComConnector = \"calComConnector\",\n CopperConnector = \"copperConnector\",\n DatadogConnector = \"datadogConnector\",\n DeelConnector = \"deelConnector\",\n DocuSignConnector = \"docusignConnector\",\n DropboxConnector = \"dropboxConnector\",\n FigmaConnector = \"figmaConnector\",\n ExpensifyConnector = \"expensifyConnector\",\n GoogleContactsConnector = \"googleContactsConnector\",\n GoogleFormsConnector = \"googleFormsConnector\",\n MercuryConnector = \"mercuryConnector\",\n NeonConnector = \"neonConnector\",\n NetSuiteConnector = \"netSuiteConnector\",\n GarminConnectConnector = \"garminConnectConnector\",\n QuickBooksConnector = \"quickbooksConnector\",\n RedditConnector = \"redditConnector\",\n SupabaseConnector = \"supabaseConnector\",\n WebflowConnector = \"webflowConnector\",\n CloseConnector = \"closeConnector\",\n MetaAdsConnector = \"metaAdsConnector\",\n TikTokAdsConnector = \"tiktokAdsConnector\",\n AwsConnector = \"awsConnector\",\n PosthogConnector = \"posthogConnector\",\n PayPalConnector = \"payPalConnector\",\n RampConnector = \"rampConnector\",\n MailchimpConnector = \"mailchimpConnector\",\n ResendConnector = \"resendConnector\",\n PexelsConnector = \"pexelsConnector\",\n SpotifyConnector = \"spotifyConnector\",\n ZeroDebug = \"zeroDebug\",\n CanonicalSlackIngress = \"canonicalSlackIngress\",\n CanonicalSlackWebVisibility = \"canonicalSlackWebVisibility\",\n CanonicalSlackAssets = \"canonicalSlackAssets\",\n ZeroWeather = \"zeroWeather\",\n ZeroFinance = \"zeroFinance\",\n ZeroPeopleSearch = \"zeroPeopleSearch\",\n Banking = \"banking\",\n Lab = \"lab\",\n NotionWorkflowAutomations = \"notionWorkflowAutomations\",\n GithubWorkflowRunAutomations = \"githubWorkflowRunAutomations\",\n MorningBrief = \"morningBrief\",\n ManualMorningBrief = \"manualMorningBrief\",\n TestOauthConnector = \"testOauthConnector\",\n FreshdeskConnector = \"freshdeskConnector\",\n StabilityAiConnector = \"stabilityAiConnector\",\n ZoomConnector = \"zoomConnector\",\n WorkdayConnector = \"workdayConnector\",\n CodexFastMode = \"codexFastMode\",\n RealAgentInPreview = \"realAgentInPreview\",\n ComposerUploadPopover = \"composerUploadPopover\",\n StructuredPrompt = \"structuredPrompt\",\n\n ZapierConnector = \"zapierConnector\",\n HtmlArtifactCommentEditing = \"htmlArtifactCommentEditing\",\n ComputerUseDesktopPlugins = \"computerUseDesktopPlugins\",\n AgentUnreadIndicators = \"agentUnreadIndicators\",\n ChatThreadUnifiedSearch = \"chatThreadUnifiedSearch\",\n ComposerChatThreadSuggestions = \"composerChatThreadSuggestions\",\n SidebarSubscriptionUsage = \"sidebarSubscriptionUsage\",\n TeamsIntegration = \"teamsIntegration\",\n FeishuIntegration = \"feishuIntegration\",\n PresentationExport = \"presentationExport\",\n Artifacts = \"artifacts\",\n HostedArtifactVersions = \"hostedArtifactVersions\",\n VideoArtifactPosters = \"videoArtifactPosters\",\n WebsiteTemplateV2 = \"websiteTemplateV2\",\n PlanUpgradeGuidance = \"planUpgradeGuidance\",\n OrgPlanEntitlementReads = \"orgPlanEntitlementReads\",\n WorkflowConnectorReadiness = \"workflowConnectorReadiness\",\n ZeroMail = \"zeroMail\",\n ComposerConnectorPermissions = \"composerConnectorPermissions\",\n ThreeColumnNav = \"threeColumnNav\",\n ChatHistoryBackfillProgress = \"chatHistoryBackfillProgress\",\n}\n","/**\n * Feature switch system\n *\n * Provides centralized feature flag management with user-identity based overrides.\n * User IDs are stored as FNV-1a hashes to avoid exposing plain-text identifiers in source code.\n *\n * NOT AN AUTHORIZATION BOUNDARY. User-overridable switches can be self-enabled\n * through `POST /api/zero/feature-switches`, and `userOverridable: false` only\n * excludes a switch from that API. For money-granting, credential, or\n * privilege-escalation endpoints, gate with a hard identity check (e.g.\n * `isStaffOrg()` from `./staff-org`) instead of this system.\n */\n\nimport { FeatureSwitchKey } from \"./feature-switch-key\";\nimport { STAFF_ORG_ID_HASHES, fnv1a } from \"./identity-hash\";\n\nexport interface FeatureSwitch {\n readonly maintainer: string;\n readonly description?: string;\n readonly enabled: boolean;\n readonly enabledUserHashes?: readonly string[];\n readonly enabledEmailHashes?: readonly string[];\n readonly enabledOrgIdHashes?: readonly string[];\n readonly userOverridable?: boolean;\n}\n\nexport interface FeatureSwitchMetadata {\n readonly maintainer: string;\n readonly description?: string;\n readonly userOverridable: boolean;\n}\n\nexport interface FeatureSwitchContext {\n readonly userId?: string;\n readonly email?: string;\n readonly orgId?: string;\n readonly overrides?: Partial<Record<FeatureSwitchKey, boolean>>;\n}\n\n/**\n * Registry of all feature switches\n */\nconst FEATURE_SWITCHES: Record<FeatureSwitchKey, FeatureSwitch> = {\n [FeatureSwitchKey.Dummy]: {\n maintainer: \"ethan@vm0.ai\",\n description: \"Test-only feature switch for flag system validation\",\n enabled: true,\n },\n [FeatureSwitchKey.ExternalConnectorCatalog]: {\n maintainer: \"liangyou@vm0.ai\",\n description:\n \"Use the accepted external catalog as the global source for official connectors\",\n enabled: false,\n userOverridable: false,\n },\n [FeatureSwitchKey.AhrefsConnector]: {\n maintainer: \"yuma@vm0.ai\",\n description: \"Enable the Ahrefs SEO connector\",\n enabled: false,\n },\n [FeatureSwitchKey.BillConnector]: {\n maintainer: \"yuma@vm0.ai\",\n description: \"Enable the BILL Spend & Expense connector\",\n enabled: false,\n },\n [FeatureSwitchKey.BentomlConnector]: {\n maintainer: \"yuma@vm0.ai\",\n description: \"Enable the BentoML model serving connector\",\n enabled: false,\n },\n [FeatureSwitchKey.BoxConnector]: {\n maintainer: \"yuma@vm0.ai\",\n description: \"Enable the Box file storage connector\",\n enabled: false,\n },\n [FeatureSwitchKey.CanvaConnector]: {\n maintainer: \"yuma@vm0.ai\",\n description: \"Enable the Canva design connector\",\n enabled: false,\n },\n [FeatureSwitchKey.CalComConnector]: {\n maintainer: \"yuma@vm0.ai\",\n description: \"Enable the Cal.com scheduling connector\",\n enabled: false,\n },\n [FeatureSwitchKey.CopperConnector]: {\n maintainer: \"yuma@vm0.ai\",\n description: \"Enable the Copper CRM connector\",\n enabled: false,\n },\n [FeatureSwitchKey.DatadogConnector]: {\n maintainer: \"yuma@vm0.ai\",\n description: \"Enable the Datadog observability connector\",\n enabled: false,\n },\n [FeatureSwitchKey.DeelConnector]: {\n maintainer: \"yuma@vm0.ai\",\n description: \"Enable the Deel HR connector\",\n enabled: false,\n },\n [FeatureSwitchKey.DocuSignConnector]: {\n maintainer: \"yuma@vm0.ai\",\n description: \"Enable the DocuSign e-signature connector\",\n enabled: false,\n },\n [FeatureSwitchKey.DropboxConnector]: {\n maintainer: \"yuma@vm0.ai\",\n description: \"Enable the Dropbox file storage connector\",\n enabled: false,\n },\n [FeatureSwitchKey.FigmaConnector]: {\n maintainer: \"yuma@vm0.ai\",\n description: \"Enable the Figma design connector\",\n enabled: false,\n },\n [FeatureSwitchKey.ExpensifyConnector]: {\n maintainer: \"yuma@vm0.ai\",\n description: \"Enable the Expensify accounting connector\",\n enabled: false,\n },\n [FeatureSwitchKey.GoogleContactsConnector]: {\n maintainer: \"yuma@vm0.ai\",\n description: \"Enable the Google Contacts connector\",\n enabled: false,\n },\n [FeatureSwitchKey.GoogleFormsConnector]: {\n maintainer: \"yuma@vm0.ai\",\n description: \"Enable the Google Forms connector\",\n enabled: false,\n },\n [FeatureSwitchKey.MercuryConnector]: {\n maintainer: \"yuma@vm0.ai\",\n description: \"Enable the Mercury banking connector\",\n enabled: false,\n },\n [FeatureSwitchKey.NeonConnector]: {\n maintainer: \"yuma@vm0.ai\",\n description: \"Enable the Neon serverless Postgres connector\",\n enabled: false,\n },\n [FeatureSwitchKey.NetSuiteConnector]: {\n maintainer: \"yuma@vm0.ai\",\n description: \"Enable the Oracle NetSuite ERP connector\",\n enabled: false,\n },\n [FeatureSwitchKey.GarminConnectConnector]: {\n maintainer: \"yuma@vm0.ai\",\n description: \"Enable the Garmin Connect wellness connector\",\n enabled: false,\n },\n [FeatureSwitchKey.QuickBooksConnector]: {\n maintainer: \"yuma@vm0.ai\",\n description: \"Enable the QuickBooks accounting connector\",\n enabled: false,\n },\n [FeatureSwitchKey.RedditConnector]: {\n maintainer: \"yuma@vm0.ai\",\n description: \"Enable the Reddit connector integration\",\n enabled: false,\n },\n [FeatureSwitchKey.SupabaseConnector]: {\n maintainer: \"yuma@vm0.ai\",\n description: \"Enable the Supabase database connector integration\",\n enabled: false,\n },\n [FeatureSwitchKey.CloseConnector]: {\n maintainer: \"yuma@vm0.ai\",\n description: \"Enable the Close CRM connector\",\n enabled: false,\n },\n [FeatureSwitchKey.WebflowConnector]: {\n maintainer: \"yuma@vm0.ai\",\n description: \"Enable the Webflow site management connector\",\n enabled: false,\n },\n [FeatureSwitchKey.MetaAdsConnector]: {\n maintainer: \"ethan@vm0.ai\",\n description: \"Enable the Meta Ads Manager connector\",\n enabled: false,\n },\n [FeatureSwitchKey.TikTokAdsConnector]: {\n maintainer: \"yuma@vm0.ai\",\n description: \"Enable the TikTok Ads Manager connector\",\n enabled: false,\n },\n [FeatureSwitchKey.AwsConnector]: {\n maintainer: \"liangyou@vm0.ai\",\n description: \"Enable the temporary AWS remote login connector\",\n enabled: false,\n enabledOrgIdHashes: STAFF_ORG_ID_HASHES,\n },\n [FeatureSwitchKey.PosthogConnector]: {\n maintainer: \"yuma@vm0.ai\",\n description: \"Enable the PostHog analytics connector\",\n enabled: false,\n },\n [FeatureSwitchKey.PayPalConnector]: {\n maintainer: \"yuma@vm0.ai\",\n description: \"Enable the PayPal payments connector\",\n enabled: false,\n },\n [FeatureSwitchKey.RampConnector]: {\n maintainer: \"yuma@vm0.ai\",\n description: \"Enable the Ramp spend management connector\",\n enabled: false,\n },\n [FeatureSwitchKey.MailchimpConnector]: {\n maintainer: \"yuma@vm0.ai\",\n description: \"Enable the Mailchimp email marketing connector\",\n enabled: false,\n },\n [FeatureSwitchKey.ResendConnector]: {\n maintainer: \"yuma@vm0.ai\",\n description: \"Enable the Resend email service connector\",\n enabled: false,\n },\n [FeatureSwitchKey.PexelsConnector]: {\n maintainer: \"bingjie@vm0.ai\",\n description: \"Enable the Pexels stock photo and video connector\",\n enabled: false,\n },\n [FeatureSwitchKey.SpotifyConnector]: {\n maintainer: \"yuma@vm0.ai\",\n description: \"Enable the Spotify connector integration\",\n enabled: false,\n },\n [FeatureSwitchKey.ZeroDebug]: {\n maintainer: \"ethan@vm0.ai\",\n description:\n \"Reveal activity debug surfaces, activity log navigation, appended system prompts, and Debug preferences\",\n enabled: false,\n },\n [FeatureSwitchKey.CanonicalSlackIngress]: {\n maintainer: \"lancy@vm0.ai\",\n description:\n \"Route newly admitted per-user Slack threads through canonical chat ingress.\",\n enabled: false,\n enabledOrgIdHashes: STAFF_ORG_ID_HASHES,\n },\n [FeatureSwitchKey.CanonicalSlackWebVisibility]: {\n maintainer: \"lancy@vm0.ai\",\n description:\n \"Show canonical Slack chat threads in Web chat surfaces for enrolled users.\",\n enabled: false,\n enabledOrgIdHashes: STAFF_ORG_ID_HASHES,\n },\n [FeatureSwitchKey.CanonicalSlackAssets]: {\n maintainer: \"lancy@vm0.ai\",\n description:\n \"Canonicalize direct Slack inputs and run-scoped Slack file publications.\",\n enabled: false,\n enabledOrgIdHashes: STAFF_ORG_ID_HASHES,\n },\n [FeatureSwitchKey.ZeroWeather]: {\n maintainer: \"ethan@vm0.ai\",\n description:\n \"Enable the managed Google-backed Zero Weather and Air Quality APIs and weather:read ZERO_TOKEN capability.\",\n enabled: true,\n },\n [FeatureSwitchKey.ZeroFinance]: {\n maintainer: \"ethan@vm0.ai\",\n description:\n \"Enable the managed APIDojo-backed Zero Finance API and finance:read ZERO_TOKEN capability.\",\n enabled: false,\n enabledOrgIdHashes: STAFF_ORG_ID_HASHES,\n },\n [FeatureSwitchKey.ZeroPeopleSearch]: {\n maintainer: \"liangyou@vm0.ai\",\n description:\n \"Enable managed Perplexity People Search and the people-search:read ZERO_TOKEN capability.\",\n enabled: false,\n enabledOrgIdHashes: STAFF_ORG_ID_HASHES,\n },\n [FeatureSwitchKey.Banking]: {\n maintainer: \"linghan@vm0.ai\",\n description:\n \"Enable the managed Zero Banking gateway and banking:read ZERO_TOKEN capability for Finicity-backed accounts, balances, and transactions.\",\n enabled: false,\n enabledOrgIdHashes: STAFF_ORG_ID_HASHES,\n },\n [FeatureSwitchKey.Lab]: {\n maintainer: \"ethan@vm0.ai\",\n description: \"Show the Lab page for toggling experimental features\",\n enabled: false,\n enabledOrgIdHashes: STAFF_ORG_ID_HASHES,\n },\n [FeatureSwitchKey.MorningBrief]: {\n maintainer: \"ethan@vm0.ai\",\n description:\n \"Enable the daily 7:00 local-time Morning Brief email built from GitHub, Gmail, and Google Calendar.\",\n enabled: false,\n enabledOrgIdHashes: STAFF_ORG_ID_HASHES,\n userOverridable: true,\n },\n [FeatureSwitchKey.ManualMorningBrief]: {\n maintainer: \"ethan@vm0.ai\",\n description:\n \"Show a Send now button in Settings that triggers a Morning Brief immediately for testing.\",\n enabled: false,\n enabledOrgIdHashes: STAFF_ORG_ID_HASHES,\n userOverridable: true,\n },\n [FeatureSwitchKey.NotionWorkflowAutomations]: {\n maintainer: \"lancy@vm0.ai\",\n description:\n \"Enable Notion event workflow automations, starting with child pages created under a configured parent page.\",\n enabled: false,\n enabledOrgIdHashes: STAFF_ORG_ID_HASHES,\n },\n [FeatureSwitchKey.GithubWorkflowRunAutomations]: {\n maintainer: \"ethan@vm0.ai\",\n description:\n \"Enable GitHub Actions workflow run completed event automations.\",\n enabled: true,\n },\n [FeatureSwitchKey.TestOauthConnector]: {\n maintainer: \"liangyou@vm0.ai\",\n description:\n \"Enable the test-oauth connector, a synthetic OAuth 2.0 provider used only for automated tests. Off in prod.\",\n enabled: false,\n },\n [FeatureSwitchKey.FreshdeskConnector]: {\n maintainer: \"yuma@vm0.ai\",\n description: \"Enable the Freshdesk helpdesk connector\",\n enabled: false,\n },\n [FeatureSwitchKey.StabilityAiConnector]: {\n maintainer: \"yuma@vm0.ai\",\n description: \"Enable the Stability AI image generation connector\",\n enabled: false,\n },\n [FeatureSwitchKey.ZoomConnector]: {\n maintainer: \"yuma@vm0.ai\",\n description:\n \"Enable the Zoom connector (OAuth 2.0) for meetings, past participants, and cloud recordings access\",\n enabled: false,\n },\n [FeatureSwitchKey.WorkdayConnector]: {\n maintainer: \"yuma@vm0.ai\",\n description: \"Enable the Workday HCM and finance connector\",\n enabled: false,\n },\n\n [FeatureSwitchKey.CodexFastMode]: {\n maintainer: \"lancy@vm0.ai\",\n description:\n \"Enable Codex fast mode for ChatGPT subscription GPT 5.5 and GPT 5.6 web chat runs.\",\n enabled: false,\n enabledOrgIdHashes: STAFF_ORG_ID_HASHES,\n },\n [FeatureSwitchKey.RealAgentInPreview]: {\n maintainer: \"ethan@vm0.ai\",\n description:\n \"Send preview chat runs through real agent CLIs instead of preview mock runners.\",\n enabled: false,\n },\n [FeatureSwitchKey.ComposerUploadPopover]: {\n maintainer: \"bingjie@vm0.ai\",\n description:\n \"Use the Upload popover in the chat composer instead of the legacy paperclip attachment button.\",\n enabled: false,\n userOverridable: false,\n },\n [FeatureSwitchKey.StructuredPrompt]: {\n maintainer: \"bingjie@vm0.ai\",\n description:\n \"Enable structured user prompt rendering, sends, and drafts while preserving the legacy content fallback.\",\n enabled: false,\n enabledOrgIdHashes: STAFF_ORG_ID_HASHES,\n },\n [FeatureSwitchKey.ZapierConnector]: {\n maintainer: \"yuma@vm0.ai\",\n description:\n \"Enable the Zapier connector. When disabled, Zapier is hidden from the connectors list and cannot be connected.\",\n enabled: false,\n },\n [FeatureSwitchKey.HtmlArtifactCommentEditing]: {\n maintainer: \"bingjie@vm0.ai\",\n description:\n \"Enable the HTML artifact comment-editing workflow for collecting DOM comments and preparing instrumented working-copy edits.\",\n enabled: false,\n enabledOrgIdHashes: STAFF_ORG_ID_HASHES,\n },\n [FeatureSwitchKey.ComputerUseDesktopPlugins]: {\n maintainer: \"lancy@vm0.ai\",\n description:\n \"Enable Zero Desktop Computer Use plugins for local resources, starting with the bundled filesystem plugin gateway.\",\n enabled: false,\n enabledOrgIdHashes: STAFF_ORG_ID_HASHES,\n },\n [FeatureSwitchKey.AgentUnreadIndicators]: {\n maintainer: \"ethan@vm0.ai\",\n description:\n \"Show chat unread indicators in sidebar pinned agent lists and the conversation picker.\",\n enabled: false,\n enabledOrgIdHashes: STAFF_ORG_ID_HASHES,\n },\n [FeatureSwitchKey.ChatThreadUnifiedSearch]: {\n maintainer: \"ethan@vm0.ai\",\n description:\n \"Show chat thread title results from the local event-driven thread cache in the command-shift-a conversation picker.\",\n enabled: false,\n enabledOrgIdHashes: STAFF_ORG_ID_HASHES,\n },\n [FeatureSwitchKey.ComposerChatThreadSuggestions]: {\n maintainer: \"ethan@vm0.ai\",\n description:\n \"Suggest titled chat threads from the current agent when typing @ in the chat composer.\",\n enabled: false,\n enabledOrgIdHashes: STAFF_ORG_ID_HASHES,\n },\n [FeatureSwitchKey.ChatHistoryBackfillProgress]: {\n maintainer: \"ethan@vm0.ai\",\n description:\n \"Progress bar under the chat thread header showing history backfill progress while older messages load.\",\n // Not rolled out to anyone yet; enable per-user via the Lab page.\n enabled: false,\n },\n [FeatureSwitchKey.ThreeColumnNav]: {\n maintainer: \"ming@vm0.ai\",\n description:\n \"Slack-style three-column navigation: a labeled icon rail, a pinned-agents and chat-threads list column, and the conversation pane.\",\n enabled: false,\n // Ming only for the first pass; widen to staff once it settles.\n enabledEmailHashes: [\"54757055\"], // fnv1a(\"ming@vm0.ai\")\n },\n [FeatureSwitchKey.SidebarSubscriptionUsage]: {\n maintainer: \"ethan@vm0.ai\",\n description:\n \"Show Codex and Claude Code personal subscription usage in the Zero sidebar footer.\",\n enabled: false,\n enabledOrgIdHashes: STAFF_ORG_ID_HASHES,\n },\n [FeatureSwitchKey.TeamsIntegration]: {\n maintainer: \"linghan@vm0.ai\",\n description:\n \"Show standalone Microsoft Teams integration settings, connect flows, and Works page entry points.\",\n enabled: false,\n enabledOrgIdHashes: STAFF_ORG_ID_HASHES,\n },\n [FeatureSwitchKey.FeishuIntegration]: {\n maintainer: \"linghan@vm0.ai\",\n description:\n \"Show the Feishu direct-message integration and Works page entry point.\",\n enabled: false,\n enabledOrgIdHashes: STAFF_ORG_ID_HASHES,\n },\n [FeatureSwitchKey.PresentationExport]: {\n maintainer: \"bingjie@vm0.ai\",\n description:\n \"Enable downloading presentation artifacts as PPTX files and uploading them as native, editable Google Slides decks.\",\n enabled: false,\n enabledOrgIdHashes: STAFF_ORG_ID_HASHES,\n },\n [FeatureSwitchKey.Artifacts]: {\n maintainer: \"bingjie@vm0.ai\",\n description:\n \"Show the Artifacts manage page for generated artifacts in the current organization.\",\n enabled: false,\n enabledOrgIdHashes: STAFF_ORG_ID_HASHES,\n },\n [FeatureSwitchKey.HostedArtifactVersions]: {\n maintainer: \"yuma@vm0.ai\",\n description:\n \"Create immutable hosted artifact versions behind stable site aliases.\",\n enabled: false,\n },\n [FeatureSwitchKey.VideoArtifactPosters]: {\n maintainer: \"bingjie@vm0.ai\",\n description:\n \"Generate poster images asynchronously when video artifacts are recorded.\",\n enabled: false,\n enabledUserHashes: [\"032a75d8\"],\n },\n [FeatureSwitchKey.WebsiteTemplateV2]: {\n maintainer: \"bingjie@vm0.ai\",\n description:\n \"Generate websites from refreshed self-contained template packages. When off, website generation uses the existing package versions.\",\n enabled: false,\n enabledOrgIdHashes: STAFF_ORG_ID_HASHES,\n },\n [FeatureSwitchKey.PlanUpgradeGuidance]: {\n maintainer: \"ethan@vm0.ai\",\n description:\n \"Show plan-upgrade guidance in Zero CLI help and render billing plan links as rich chat cards.\",\n enabled: false,\n enabledOrgIdHashes: STAFF_ORG_ID_HASHES,\n userOverridable: false,\n },\n [FeatureSwitchKey.OrgPlanEntitlementReads]: {\n maintainer: \"yuma@vm0.ai\",\n description:\n \"Read runtime plan capability limits from org_plan_entitlements instead of deriving them from org_metadata.tier.\",\n enabled: true,\n userOverridable: false,\n },\n [FeatureSwitchKey.WorkflowConnectorReadiness]: {\n maintainer: \"lancy@vm0.ai\",\n description:\n \"Show the manual connector readiness check on workflow settings pages.\",\n enabled: false,\n enabledOrgIdHashes: STAFF_ORG_ID_HASHES,\n userOverridable: false,\n },\n [FeatureSwitchKey.ZeroMail]: {\n maintainer: \"ethan@vm0.ai\",\n description:\n \"Enable persistent Gmail and Outlook draft cards created through the Zero Mail CLI.\",\n enabled: false,\n enabledOrgIdHashes: STAFF_ORG_ID_HASHES,\n },\n [FeatureSwitchKey.ComposerConnectorPermissions]: {\n maintainer: \"ming@vm0.ai\",\n description:\n \"Show the configure-permissions entry in the chat composer connector popover, opening the agent×connector firewall dialog inline.\",\n enabled: false,\n userOverridable: true,\n },\n};\n\ninterface ResolvedHashes {\n readonly userHash?: string;\n readonly emailHash?: string;\n readonly orgIdHash?: string;\n}\n\nfunction evaluateSwitch(fs: FeatureSwitch, hashes: ResolvedHashes): boolean {\n if (fs.enabled) return true;\n if (hashes.userHash && fs.enabledUserHashes?.includes(hashes.userHash))\n return true;\n if (hashes.emailHash && fs.enabledEmailHashes?.includes(hashes.emailHash))\n return true;\n if (hashes.orgIdHash && fs.enabledOrgIdHashes?.includes(hashes.orgIdHash))\n return true;\n return false;\n}\n\n/**\n * Evaluate all feature switches at once for the given context.\n *\n * Computes identity hashes once and checks all switches synchronously.\n */\nexport function getAllFeatureStates(\n ctx?: FeatureSwitchContext,\n): Record<FeatureSwitchKey, boolean> {\n const switches = Object.values(FEATURE_SWITCHES);\n const hashes: ResolvedHashes = {\n userHash:\n ctx?.userId &&\n switches.some((s) => {\n return s.enabledUserHashes?.length;\n })\n ? fnv1a(ctx.userId)\n : undefined,\n emailHash:\n ctx?.email &&\n switches.some((s) => {\n return s.enabledEmailHashes?.length;\n })\n ? fnv1a(ctx.email.toLowerCase())\n : undefined,\n orgIdHash:\n ctx?.orgId &&\n switches.some((s) => {\n return s.enabledOrgIdHashes?.length;\n })\n ? fnv1a(ctx.orgId)\n : undefined,\n };\n\n const result = {} as Record<FeatureSwitchKey, boolean>;\n for (const key of Object.values(FeatureSwitchKey)) {\n result[key] = evaluateSwitch(FEATURE_SWITCHES[key], hashes);\n }\n\n if (ctx?.overrides) {\n for (const [key, value] of Object.entries(ctx.overrides)) {\n if (key in FEATURE_SWITCHES && value !== undefined) {\n result[key as FeatureSwitchKey] = value;\n }\n }\n }\n\n return result;\n}\n\n/**\n * Return the description for every feature switch.\n */\nexport function getFeatureSwitchDescriptions(): Record<\n FeatureSwitchKey,\n string | undefined\n> {\n const result = {} as Record<FeatureSwitchKey, string | undefined>;\n for (const key of Object.values(FeatureSwitchKey)) {\n result[key] = FEATURE_SWITCHES[key].description;\n }\n return result;\n}\n\n/**\n * Return display metadata for every feature switch.\n */\nexport function getFeatureSwitchMetadata(): Record<\n FeatureSwitchKey,\n FeatureSwitchMetadata\n> {\n const result = {} as Record<FeatureSwitchKey, FeatureSwitchMetadata>;\n for (const key of Object.values(FeatureSwitchKey)) {\n const featureSwitch = FEATURE_SWITCHES[key];\n result[key] = {\n maintainer: featureSwitch.maintainer,\n description: featureSwitch.description,\n userOverridable: featureSwitch.userOverridable !== false,\n };\n }\n return result;\n}\n\nexport function isUserOverridableFeatureSwitch(\n key: string,\n): key is FeatureSwitchKey {\n if (!(key in FEATURE_SWITCHES)) {\n return false;\n }\n return FEATURE_SWITCHES[key as FeatureSwitchKey].userOverridable !== false;\n}\n\nexport function getUserOverridableFeatureSwitchKeys(): readonly FeatureSwitchKey[] {\n return Object.values(FeatureSwitchKey).filter(isUserOverridableFeatureSwitch);\n}\n\nexport function filterUserOverridableFeatureSwitchOverrides(\n switches: Record<string, boolean>,\n): Record<string, boolean> {\n const filtered: Record<string, boolean> = {};\n for (const [key, value] of Object.entries(switches)) {\n if (isUserOverridableFeatureSwitch(key)) {\n filtered[key] = value;\n }\n }\n return filtered;\n}\n\n/**\n * Check if a feature is enabled for the given context.\n *\n * `ctx` is required so callers must pass identity (userId/orgId/email) or an\n * explicit `{}`. A switch gated by `enabledUserHashes` / `enabledOrgIdHashes`\n * silently returns `false` when ctx omits identity, which has caused bugs.\n * Client-side callers should usually read the platform `featureSwitch$` signal\n * instead — it also merges DB overrides on top of identity context.\n */\nexport function isFeatureEnabled(\n key: FeatureSwitchKey,\n ctx: FeatureSwitchContext,\n): boolean {\n const override = ctx.overrides?.[key];\n if (override !== undefined) {\n return override;\n }\n\n const featureSwitch = FEATURE_SWITCHES[key];\n if (featureSwitch.enabled) {\n return true;\n }\n if (ctx.userId && featureSwitch.enabledUserHashes?.length) {\n if (featureSwitch.enabledUserHashes.includes(fnv1a(ctx.userId)))\n return true;\n }\n if (ctx.email && featureSwitch.enabledEmailHashes?.length) {\n if (\n featureSwitch.enabledEmailHashes.includes(fnv1a(ctx.email.toLowerCase()))\n )\n return true;\n }\n if (ctx.orgId && featureSwitch.enabledOrgIdHashes?.length) {\n if (featureSwitch.enabledOrgIdHashes.includes(fnv1a(ctx.orgId)))\n return true;\n }\n return false;\n}\n","export { FeatureSwitchKey } from \"@vm0/connectors/feature-switch-key\";\n","/**\n * Identity hashing — FNV-1a 32-bit hash used to reference users / orgs / emails\n * without embedding plain-text identifiers in source code.\n *\n * Shared between the feature-switch registry (UI rollout targeting) and\n * `staff-org.ts` (authorization primitive). The hash is deterministic and\n * synchronous; no crypto API needed.\n */\n\nexport function fnv1a(input: string): string {\n let h = 2166136261 >>> 0;\n for (let i = 0; i < input.length; i++) {\n h ^= input.charCodeAt(i);\n h = Math.imul(h, 16777619) >>> 0;\n }\n return h.toString(16).padStart(8, \"0\");\n}\n\n/**\n * Hashes of internal staff org IDs.\n *\n * This list is the source of truth for `isStaffOrg()` — adding an entry here\n * grants that org access to every endpoint that uses `isStaffOrg` as an\n * authorization check. Treat changes with the same care as role grants.\n */\nexport const STAFF_ORG_ID_HASHES: readonly string[] = [\n \"afce210e\", // org_3ANttyrbWYJk6JKRSTRLEsbsDLe\n];\n","export interface ZeroTokenPayload {\n userId: string;\n runId: string;\n orgId: string;\n scope: string;\n capabilities: string[];\n iat: number;\n exp: number;\n}\n\n/**\n * Decode a ZERO_TOKEN JWT payload.\n * Only decodes — does NOT verify signature (server does that).\n * If no token is provided, reads from process.env.ZERO_TOKEN.\n * Returns undefined if token is missing, malformed, or not a zero-scoped token.\n */\nexport function decodeZeroTokenPayload(\n token?: string,\n): ZeroTokenPayload | undefined {\n const raw = token ?? process.env.ZERO_TOKEN;\n if (!raw) return undefined;\n\n const prefix = \"vm0_sandbox_\";\n if (!raw.startsWith(prefix)) return undefined;\n const jwt = raw.slice(prefix.length);\n\n const parts = jwt.split(\".\");\n if (parts.length !== 3) return undefined;\n\n try {\n const payload = JSON.parse(\n Buffer.from(parts[1]!, \"base64url\").toString(),\n ) as ZeroTokenPayload;\n if (payload.scope === \"zero\" && Array.isArray(payload.capabilities)) {\n return payload;\n }\n } catch {\n // Malformed token — fall through\n }\n return undefined;\n}\n"],"mappings":";;;;;;;;AAAA;;;ACAA;;;ACAA;;;ACAA;AASO,SAAS,MAAM,OAAuB;AAC3C,MAAI,IAAI,eAAe;AACvB,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACrC,SAAK,MAAM,WAAW,CAAC;AACvB,QAAI,KAAK,KAAK,GAAG,QAAQ,MAAM;AAAA,EACjC;AACA,SAAO,EAAE,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG;AACvC;AASO,IAAM,sBAAyC;AAAA,EACpD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pC,QAAM,MAAM,IAAI,MAAM,OAAO,MAAM;AAEnC,QAAM,QAAQ,IAAI,MAAM,GAAG;AAC3B,MAAI,MAAM,WAAW,EAAG,QAAO;AAE/B,MAAI;AACF,UAAM,UAAU,KAAK;AAAA,MACnB,OAAO,KAAK,MAAM,CAAC,GAAI,WAAW,EAAE,SAAS;AAAA,IAC/C;AACA,QAAI,QAAQ,UAAU,UAAU,MAAM,QAAQ,QAAQ,YAAY,GAAG;AACnE,aAAO;AAAA,IACT;AAAA,EACF,QAAQ;AAAA,EAER;AACA,SAAO;AACT;","names":[]}
|
package/workflow-W2HNGAVJ.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/zero/workflow/index.ts","../src/commands/zero/workflow/create.ts","../src/lib/skill-directory.ts","../src/commands/zero/workflow/format.ts","../src/commands/zero/workflow/edit.ts","../src/commands/zero/workflow/resolve-workflow-ref.ts","../src/commands/zero/workflow/view.ts","../src/commands/zero/workflow/list.ts","../src/commands/zero/workflow/delete.ts","../src/commands/zero/workflow/copy.ts","../src/commands/zero/workflow/automation/display.ts","../src/lib/domain/relative-time.ts","../src/commands/zero/shared/duration.ts","../src/commands/zero/workflow/automation/index.ts","../src/commands/zero/workflow/automation/gmail-config.ts"],"sourcesContent":["import { Command } from \"commander\";\nimport { createCommand } from \"./create\";\nimport { editCommand } from \"./edit\";\nimport { viewCommand } from \"./view\";\nimport { listCommand } from \"./list\";\nimport { deleteCommand } from \"./delete\";\nimport { copyCommand } from \"./copy\";\nimport { automationCommand } from \"./automation\";\n\nexport const zeroWorkflowCommand = new Command(\"workflow\")\n .description(\"Manage workflows\")\n .addCommand(createCommand)\n .addCommand(editCommand)\n .addCommand(viewCommand)\n .addCommand(listCommand)\n .addCommand(deleteCommand)\n .addCommand(copyCommand)\n .addCommand(automationCommand)\n .addHelpText(\n \"after\",\n `\nExamples:\n Create under an agent: zero workflow create my-workflow --agent <agent-id> --instruction \"Do things\"\n List workflows: zero workflow list\n View workflow content: zero workflow view <workflow> --agent <agent-id>\n Update workflow content: zero workflow edit <workflow> --agent <agent-id> --instruction \"New steps\"\n Copy onto another agent: zero workflow copy <workflow> --agent <source-agent-id> --to-agent <target-agent-id>\n Manage automations: zero workflow automation --help\n Delete a workflow: zero workflow delete <workflow> --agent <agent-id> -y`,\n );\n","import { Command } from \"commander\";\nimport chalk from \"chalk\";\nimport { readFileSync } from \"node:fs\";\nimport { createWorkflow } from \"../../../lib/api\";\nimport { withErrorHandler } from \"../../../lib/command\";\nimport { readSupplementaryFiles } from \"../../../lib/skill-directory\";\nimport { formatWorkflowAgentName } from \"./format\";\n\nexport const createCommand = new Command()\n .name(\"create\")\n .description(\"Create a workflow under an agent\")\n .argument(\"<name>\", \"Workflow name (lowercase alphanumeric with hyphens)\")\n .option(\n \"--agent <id>\",\n \"Agent ID to host the workflow (defaults to ZERO_AGENT_ID)\",\n )\n .option(\"--instruction <text>\", \"Workflow instruction text\")\n .option(\n \"--instruction-file <path>\",\n \"Path to a file containing the instruction\",\n )\n .option(\n \"--dir <path>\",\n \"Path to a directory of supplementary files (SKILL.md is not allowed)\",\n )\n .option(\"--display-name <name>\", \"Workflow display name\")\n .option(\"--description <text>\", \"Workflow description\")\n .option(\"--public\", \"Create as an org-public workflow\")\n .addHelpText(\n \"after\",\n `\nExamples:\n zero workflow create my-workflow --agent <agent-id> --instruction \"Summarize the inbox\"\n zero workflow create my-workflow --instruction-file ./instruction.md\n zero workflow create my-workflow --instruction \"Do things\" --dir ./workflows/my-workflow/files/\n zero workflow create shared-workflow --instruction \"Shared logic\" --public\n\nNotes:\n - A workflow belongs to exactly one agent; provide --agent or set ZERO_AGENT_ID\n - SKILL.md is synthesized from (name, description, instruction); do not include it\n - --dir uploads supplementary files only; any SKILL.md is rejected\n - New workflows are private by default\n - Copy a workflow onto another agent: zero workflow copy <workflow-id> --to-agent <agent-id>`,\n )\n .action(\n withErrorHandler(\n async (\n name: string,\n options: {\n agent?: string;\n instruction?: string;\n instructionFile?: string;\n dir?: string;\n displayName?: string;\n description?: string;\n public?: boolean;\n },\n ) => {\n const agentId = options.agent ?? process.env.ZERO_AGENT_ID;\n if (!agentId) {\n console.error(chalk.red(\"✗ --agent is required\"));\n console.error(\n chalk.dim(\n \" Provide --agent <agent-id> or run inside an agent sandbox (ZERO_AGENT_ID)\",\n ),\n );\n process.exit(1);\n }\n\n if (options.instruction && options.instructionFile) {\n console.error(\n chalk.red(\"✗ Use either --instruction or --instruction-file\"),\n );\n console.error(chalk.dim(\" Provide only one instruction source\"));\n process.exit(1);\n }\n\n const instruction = options.instructionFile\n ? readFileSync(options.instructionFile, \"utf-8\")\n : options.instruction;\n\n const files = options.dir\n ? readSupplementaryFiles(options.dir)\n : undefined;\n\n const workflow = await createWorkflow({\n agentId,\n chatThreadId: process.env.ZERO_CHAT_THREAD_ID || undefined,\n name,\n instruction,\n files,\n displayName: options.displayName,\n description: options.description,\n visibility: options.public ? \"public\" : undefined,\n });\n\n console.log(chalk.green(`✓ Workflow \"${workflow.name}\" created`));\n console.log(` ID: ${workflow.id}`);\n console.log(` Name: ${workflow.name}`);\n console.log(` Agent Name: ${formatWorkflowAgentName(workflow)}`);\n console.log(` Agent ID: ${workflow.agentId}`);\n console.log(` Visibility: ${workflow.visibility}`);\n if (files) {\n console.log(` Files: ${files.length} file(s)`);\n }\n if (workflow.displayName) {\n console.log(` Display Name: ${workflow.displayName}`);\n }\n if (workflow.description) {\n console.log(` Description: ${workflow.description}`);\n }\n console.log();\n console.log(\n `Copy onto another agent: zero workflow copy ${workflow.id} --to-agent <agent-id>`,\n );\n },\n ),\n );\n","import { readFileSync, readdirSync } from \"node:fs\";\nimport { join } from \"node:path\";\n\nconst IGNORED_NAMES = new Set([\"node_modules\", \".git\", \".DS_Store\"]);\n\n/**\n * Recursively read all supplementary files from a directory.\n *\n * Skips hidden files (starting with .), node_modules, and .git.\n * Rejects SKILL.md: it is synthesized server-side from the workflow's\n * (name, description, instruction) and must not be uploaded.\n */\nexport function readSupplementaryFiles(\n dirPath: string,\n): Array<{ path: string; content: string }> {\n const files: Array<{ path: string; content: string }> = [];\n\n function walk(dir: string, prefix: string) {\n const entries = readdirSync(dir, { withFileTypes: true });\n for (const entry of entries) {\n if (entry.name.startsWith(\".\") || IGNORED_NAMES.has(entry.name)) continue;\n\n const relPath = prefix ? `${prefix}/${entry.name}` : entry.name;\n if (entry.isDirectory()) {\n walk(join(dir, entry.name), relPath);\n } else {\n if (relPath === \"SKILL.md\") {\n throw new Error(\n \"SKILL.md is reserved and generated automatically; remove it from the directory\",\n );\n }\n files.push({\n path: relPath,\n content: readFileSync(join(dir, entry.name), \"utf-8\"),\n });\n }\n }\n }\n\n walk(dirPath, \"\");\n\n return files;\n}\n","import type { ZeroWorkflowSummary } from \"@vm0/api-contracts/contracts/zero-workflows\";\n\ntype WorkflowAgentFields = Pick<\n ZeroWorkflowSummary,\n \"agentDisplayName\" | \"agentName\" | \"agentId\"\n>;\n\nexport function formatWorkflowAgentName(workflow: WorkflowAgentFields): string {\n return workflow.agentDisplayName ?? workflow.agentName ?? \"-\";\n}\n","import { Command } from \"commander\";\nimport chalk from \"chalk\";\nimport { readFileSync } from \"node:fs\";\nimport { updateWorkflow } from \"../../../lib/api\";\nimport { withErrorHandler } from \"../../../lib/command\";\nimport { readSupplementaryFiles } from \"../../../lib/skill-directory\";\nimport {\n resolveWorkflowRef,\n type WorkflowRefOptions,\n} from \"./resolve-workflow-ref\";\n\nexport const editCommand = new Command()\n .name(\"edit\")\n .description(\"Update a workflow's instruction, files, or metadata\")\n .argument(\"<workflow>\", \"Workflow ID or name\")\n .option(\"--agent <id>\", \"Agent ID for resolving workflow names\")\n .option(\"--instruction <text>\", \"New instruction text\")\n .option(\n \"--instruction-file <path>\",\n \"Path to a file containing the instruction\",\n )\n .option(\n \"--dir <path>\",\n \"Path to a directory of supplementary files (SKILL.md is not allowed)\",\n )\n .option(\"--display-name <name>\", \"New display name\")\n .option(\"--description <text>\", \"New description\")\n .addHelpText(\n \"after\",\n `\nExamples:\n zero workflow edit tell-a-joke --agent <agent-id> --instruction \"New steps\"\n zero workflow edit <workflow-id> --instruction \"New steps\"\n zero workflow edit <workflow-id> --instruction-file ./instruction.md\n zero workflow edit <workflow-id> --dir ./workflows/my-workflow/files/\n zero workflow edit <workflow-id> --display-name \"My Workflow\" --description \"Does things\"\n\nNotes:\n - SKILL.md is synthesized automatically; --dir uploads supplementary files only\n - At least one of --instruction, --instruction-file, --dir, --display-name, or --description is required`,\n )\n .action(\n withErrorHandler(\n async (\n workflowRef: string,\n options: {\n instruction?: string;\n instructionFile?: string;\n dir?: string;\n displayName?: string;\n description?: string;\n } & WorkflowRefOptions,\n ) => {\n if (options.instruction && options.instructionFile) {\n console.error(\n chalk.red(\"✗ Use either --instruction or --instruction-file\"),\n );\n console.error(chalk.dim(\" Provide only one instruction source\"));\n process.exit(1);\n }\n\n const instruction = options.instructionFile\n ? readFileSync(options.instructionFile, \"utf-8\")\n : options.instruction;\n\n const files = options.dir\n ? readSupplementaryFiles(options.dir)\n : undefined;\n\n if (\n instruction === undefined &&\n files === undefined &&\n options.displayName === undefined &&\n options.description === undefined\n ) {\n console.error(chalk.red(\"✗ Nothing to update\"));\n console.error(\n chalk.dim(\n \" Provide --instruction, --instruction-file, --dir, --display-name, or --description\",\n ),\n );\n process.exit(1);\n }\n\n const workflowId = await resolveWorkflowRef(workflowRef, options);\n const workflow = await updateWorkflow(workflowId, {\n instruction,\n files,\n displayName: options.displayName,\n description: options.description,\n });\n\n console.log(chalk.green(`✓ Workflow \"${workflow.name}\" updated`));\n if (instruction !== undefined) {\n console.log(` Instruction: updated`);\n }\n if (files) {\n console.log(` Files: ${files.length} file(s)`);\n }\n if (options.displayName !== undefined) {\n console.log(` Display Name: ${workflow.displayName ?? \"-\"}`);\n }\n if (options.description !== undefined) {\n console.log(` Description: ${workflow.description ?? \"-\"}`);\n }\n },\n ),\n );\n","import { listWorkflows } from \"../../../lib/api\";\n\nconst UUID_RE =\n /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\nconst WORKFLOW_NAME_RE = /^[a-z0-9][a-z0-9-]*[a-z0-9]$/;\n\nexport interface WorkflowRefOptions {\n readonly agent?: string;\n}\n\nfunction isWorkflowName(ref: string): boolean {\n return ref.length >= 2 && ref.length <= 64 && WORKFLOW_NAME_RE.test(ref);\n}\n\nexport async function resolveWorkflowRef(\n ref: string,\n options: WorkflowRefOptions,\n): Promise<string> {\n if (UUID_RE.test(ref)) {\n return ref;\n }\n\n if (!isWorkflowName(ref)) {\n throw new Error(\n `Invalid workflow ref: \"${ref}\". Use a workflow ID or a slug name like \"tell-a-joke\"`,\n );\n }\n\n const agentId = options.agent ?? process.env.ZERO_AGENT_ID;\n if (!agentId) {\n throw new Error(\n \"Workflow name refs require an agent scope. Pass --agent <agent-id>, set ZERO_AGENT_ID, or use a workflow ID\",\n );\n }\n if (!UUID_RE.test(agentId)) {\n throw new Error(\n `Invalid agent ID: \"${agentId}\". Pass an agent UUID for --agent or use a workflow ID`,\n );\n }\n\n const workflows = await listWorkflows({ agentId });\n const matches = workflows.filter((workflow) => {\n return workflow.name === ref;\n });\n if (matches.length === 0) {\n throw new Error(\n `Workflow not found: \"${ref}\" under agent \"${agentId}\". Check the name and agent, or use the workflow ID`,\n );\n }\n\n const winners = matches.filter((workflow) => {\n return workflow.shadowedBy == null;\n });\n if (winners.length !== 1) {\n throw new Error(\n `Workflow name \"${ref}\" did not resolve to exactly one runtime winner under agent \"${agentId}\". Use the workflow ID`,\n );\n }\n return winners[0]!.id;\n}\n","import { Command } from \"commander\";\nimport chalk from \"chalk\";\nimport { getWorkflow } from \"../../../lib/api\";\nimport { withErrorHandler } from \"../../../lib/command\";\nimport { formatWorkflowAgentName } from \"./format\";\nimport {\n resolveWorkflowRef,\n type WorkflowRefOptions,\n} from \"./resolve-workflow-ref\";\n\nexport const viewCommand = new Command()\n .name(\"view\")\n .description(\"View a workflow\")\n .argument(\"<workflow>\", \"Workflow ID or name\")\n .option(\"--agent <id>\", \"Agent ID for resolving workflow names\")\n .addHelpText(\n \"after\",\n `\nExamples:\n zero workflow view tell-a-joke --agent <agent-id>\n zero workflow view <workflow-id>`,\n )\n .action(\n withErrorHandler(\n async (workflowRef: string, options: WorkflowRefOptions) => {\n const workflowId = await resolveWorkflowRef(workflowRef, options);\n const workflow = await getWorkflow(workflowId);\n\n console.log(chalk.bold(workflow.name));\n if (workflow.displayName) console.log(chalk.dim(workflow.displayName));\n console.log();\n console.log(`ID: ${workflow.id}`);\n console.log(`Name: ${workflow.name}`);\n console.log(`Visibility: ${workflow.visibility}`);\n console.log(`Agent Name: ${formatWorkflowAgentName(workflow)}`);\n console.log(`Agent ID: ${workflow.agentId}`);\n if (workflow.displayName)\n console.log(`Display Name: ${workflow.displayName}`);\n if (workflow.description)\n console.log(`Description: ${workflow.description}`);\n\n if (workflow.files && workflow.files.length > 0) {\n console.log();\n console.log(chalk.dim(\"── Files ──\"));\n for (const f of workflow.files) {\n console.log(` ${f.path} (${f.size} bytes)`);\n }\n }\n\n console.log();\n if (workflow.instruction) {\n console.log(chalk.dim(\"── Instruction ──\"));\n console.log(workflow.instruction);\n } else {\n console.log(chalk.dim(\"No instruction\"));\n }\n },\n ),\n );\n","import { Command } from \"commander\";\nimport chalk from \"chalk\";\nimport { listWorkflows } from \"../../../lib/api\";\nimport { withErrorHandler } from \"../../../lib/command\";\nimport { formatWorkflowAgentName } from \"./format\";\n\nexport const listCommand = new Command()\n .name(\"list\")\n .alias(\"ls\")\n .description(\"List visible workflows, optionally scoped to one agent\")\n .option(\"--agent <id>\", \"Only list workflows hosted by this agent\")\n .addHelpText(\n \"after\",\n `\nExamples:\n zero workflow list\n zero workflow list --agent <agent-id>`,\n )\n .action(\n withErrorHandler(async (options: { agent?: string }) => {\n const workflows = await listWorkflows({ agentId: options.agent });\n\n if (workflows.length === 0) {\n console.log(chalk.dim(\"No workflows found\"));\n console.log(\n chalk.dim(\n \" Create one with: zero workflow create <name> --agent <agent-id> --instruction <text>\",\n ),\n );\n return;\n }\n\n const idWidth = Math.max(\n 2,\n ...workflows.map((s) => {\n return s.id.length;\n }),\n );\n const nameWidth = Math.max(\n 4,\n ...workflows.map((s) => {\n return s.name.length;\n }),\n );\n const agentWidth = Math.max(\n 10,\n ...workflows.map((s) => {\n return formatWorkflowAgentName(s).length;\n }),\n );\n const agentIdWidth = Math.max(\n 8,\n ...workflows.map((s) => {\n return s.agentId.length;\n }),\n );\n\n const header = [\n \"ID\".padEnd(idWidth),\n \"NAME\".padEnd(nameWidth),\n \"VISIBILITY\".padEnd(10),\n \"AGENT NAME\".padEnd(agentWidth),\n \"AGENT ID\".padEnd(agentIdWidth),\n \"DESCRIPTION\",\n ].join(\" \");\n console.log(chalk.dim(header));\n\n for (const workflow of workflows) {\n const row = [\n workflow.id.padEnd(idWidth),\n workflow.name.padEnd(nameWidth),\n workflow.visibility.padEnd(10),\n formatWorkflowAgentName(workflow).padEnd(agentWidth),\n workflow.agentId.padEnd(agentIdWidth),\n workflow.description ?? \"-\",\n ].join(\" \");\n console.log(row);\n }\n }),\n );\n","import { Command } from \"commander\";\nimport chalk from \"chalk\";\nimport { deleteWorkflow, getWorkflow } from \"../../../lib/api\";\nimport { isInteractive, promptConfirm } from \"../../../lib/utils/prompt-utils\";\nimport { withErrorHandler } from \"../../../lib/command\";\nimport {\n resolveWorkflowRef,\n type WorkflowRefOptions,\n} from \"./resolve-workflow-ref\";\n\nexport const deleteCommand = new Command()\n .name(\"delete\")\n .alias(\"rm\")\n .description(\"Delete a workflow\")\n .argument(\"<workflow>\", \"Workflow ID or name\")\n .option(\"--agent <id>\", \"Agent ID for resolving workflow names\")\n .option(\"-y, --yes\", \"Skip confirmation prompt\")\n .addHelpText(\n \"after\",\n `\nExamples:\n zero workflow delete tell-a-joke --agent <agent-id> -y\n zero workflow delete <workflow-id>\n zero workflow delete <workflow-id> -y\n\nNotes:\n - Use -y to skip confirmation in non-interactive mode`,\n )\n .action(\n withErrorHandler(\n async (\n workflowRef: string,\n options: { yes?: boolean } & WorkflowRefOptions,\n ) => {\n const workflowId = await resolveWorkflowRef(workflowRef, options);\n const workflow = await getWorkflow(workflowId);\n\n if (!options.yes) {\n if (!isInteractive()) {\n throw new Error(\"--yes flag is required in non-interactive mode\");\n }\n const confirmed = await promptConfirm(\n `Delete workflow '${workflow.name}'?`,\n false,\n );\n if (!confirmed) {\n console.log(chalk.dim(\"Cancelled\"));\n return;\n }\n }\n\n await deleteWorkflow(workflowId);\n console.log(chalk.green(`✓ Workflow \"${workflow.name}\" deleted`));\n },\n ),\n );\n","import { Command } from \"commander\";\nimport chalk from \"chalk\";\nimport { copyWorkflow, listWorkflowAutomations } from \"../../../lib/api\";\nimport { withErrorHandler } from \"../../../lib/command\";\nimport { printWorkflowAutomationsTable } from \"./automation/display\";\nimport { formatWorkflowAgentName } from \"./format\";\nimport {\n resolveWorkflowRef,\n type WorkflowRefOptions,\n} from \"./resolve-workflow-ref\";\n\nexport const copyCommand = new Command()\n .name(\"copy\")\n .description(\"Copy (fork) a workflow onto another agent\")\n .argument(\"<workflow>\", \"Workflow ID or name to copy\")\n .option(\"--agent <id>\", \"Agent ID for resolving workflow names\")\n .requiredOption(\"--to-agent <agent-id>\", \"Target agent ID\")\n .addHelpText(\n \"after\",\n `\nExamples:\n zero workflow copy tell-a-joke --agent <source-agent-id> --to-agent <target-agent-id>\n zero workflow copy <workflow-id> --to-agent <target-agent-id>`,\n )\n .action(\n withErrorHandler(\n async (\n workflowRef: string,\n options: { toAgent: string } & WorkflowRefOptions,\n ) => {\n const workflowId = await resolveWorkflowRef(workflowRef, options);\n const workflow = await copyWorkflow(workflowId, options.toAgent);\n\n console.log(chalk.green(`✓ Workflow \"${workflow.name}\" copied`));\n console.log();\n console.log(` ID: ${workflow.id}`);\n console.log(` Name: ${workflow.name}`);\n console.log(` Visibility: ${workflow.visibility}`);\n console.log(` Agent Name: ${formatWorkflowAgentName(workflow)}`);\n console.log(` Agent ID: ${workflow.agentId}`);\n if (workflow.displayName)\n console.log(` Display Name: ${workflow.displayName}`);\n if (workflow.description)\n console.log(` Description: ${workflow.description}`);\n\n const automations = await listWorkflowAutomations(workflow.id);\n\n console.log();\n console.log(\n chalk.dim(`── Copied automations (${automations.length}) ──`),\n );\n if (automations.length === 0) {\n console.log(chalk.dim(\"No automations copied\"));\n } else {\n printWorkflowAutomationsTable(automations);\n }\n console.log();\n console.log(`View it: zero workflow view ${workflow.id}`);\n },\n ),\n );\n","import chalk from \"chalk\";\nimport type { GmailNewMessageEventConfig } from \"@vm0/api-contracts/contracts/zero-workflows\";\nimport type { ZeroWorkflowAutomationSummary } from \"../../../../lib/api\";\nimport { formatRelativeTime } from \"../../../../lib/domain/relative-time\";\nimport { formatDurationSeconds } from \"../../shared/duration\";\n\ntype GmailMatchRules = NonNullable<GmailNewMessageEventConfig[\"match\"]>;\ntype GmailTextMatcher = NonNullable<GmailMatchRules[\"from\"]>;\ntype GmailTextField = \"from\" | \"subject\" | \"body\" | \"to\" | \"cc\";\n\nconst GMAIL_TEXT_FIELDS: readonly GmailTextField[] = [\n \"from\",\n \"subject\",\n \"body\",\n \"to\",\n \"cc\",\n];\n\ntype WorkflowWebhookAutomationSummary = Extract<\n ZeroWorkflowAutomationSummary,\n { readonly kind: \"event\"; readonly eventType: \"webhook-received\" }\n>;\ntype WorkflowNotionChildPageAutomationSummary = Extract<\n ZeroWorkflowAutomationSummary,\n { readonly kind: \"event\"; readonly eventType: \"notion-child-page-created\" }\n>;\ntype WorkflowNotionDatabaseItemAutomationSummary = Extract<\n ZeroWorkflowAutomationSummary,\n {\n readonly kind: \"event\";\n readonly eventType: \"notion-database-item-created\";\n }\n>;\ntype WorkflowNotionPageContentUpdatedAutomationSummary = Extract<\n ZeroWorkflowAutomationSummary,\n {\n readonly kind: \"event\";\n readonly eventType: \"notion-page-content-updated\";\n }\n>;\n\nfunction isWebhookAutomation(\n automation: ZeroWorkflowAutomationSummary,\n): automation is WorkflowWebhookAutomationSummary {\n return (\n automation.kind === \"event\" && automation.eventType === \"webhook-received\"\n );\n}\n\nfunction isNotionChildPageAutomation(\n automation: ZeroWorkflowAutomationSummary,\n): automation is WorkflowNotionChildPageAutomationSummary {\n return (\n automation.kind === \"event\" &&\n automation.eventType === \"notion-child-page-created\"\n );\n}\n\nfunction isNotionDatabaseItemAutomation(\n automation: ZeroWorkflowAutomationSummary,\n): automation is WorkflowNotionDatabaseItemAutomationSummary {\n return (\n automation.kind === \"event\" &&\n automation.eventType === \"notion-database-item-created\"\n );\n}\n\nfunction isNotionPageContentUpdatedAutomation(\n automation: ZeroWorkflowAutomationSummary,\n): automation is WorkflowNotionPageContentUpdatedAutomationSummary {\n return (\n automation.kind === \"event\" &&\n automation.eventType === \"notion-page-content-updated\"\n );\n}\n\nfunction isGoogleCalendarAutomation(\n automation: ZeroWorkflowAutomationSummary,\n): automation is Extract<\n ZeroWorkflowAutomationSummary,\n {\n readonly kind: \"event\";\n readonly eventType:\n | \"google-calendar-event-created\"\n | \"google-calendar-event-updated\"\n | \"google-calendar-event-cancelled\";\n }\n> {\n return (\n automation.kind === \"event\" &&\n (automation.eventType === \"google-calendar-event-created\" ||\n automation.eventType === \"google-calendar-event-updated\" ||\n automation.eventType === \"google-calendar-event-cancelled\")\n );\n}\n\nfunction quote(value: string): string {\n return `\"${value}\"`;\n}\n\nfunction quoteList(values: readonly string[]): string {\n return values.map(quote).join(\", \");\n}\n\nfunction textMatcherParts(\n field: GmailTextField,\n matcher: GmailTextMatcher,\n): string[] {\n const parts: string[] = [];\n if (matcher.contains) {\n parts.push(`${field} contains ${quote(matcher.contains)}`);\n }\n if (matcher.containsAny) {\n parts.push(`${field} contains any of ${quoteList(matcher.containsAny)}`);\n }\n if (matcher.doesNotContain) {\n parts.push(`${field} does not contain ${quote(matcher.doesNotContain)}`);\n }\n if (matcher.doesNotContainAny) {\n parts.push(\n `${field} does not contain any of ${quoteList(matcher.doesNotContainAny)}`,\n );\n }\n return parts;\n}\n\nfunction formatGmailMatchSummary(config: GmailNewMessageEventConfig): string {\n const match = config.match;\n if (!match) {\n return \"all inbound messages\";\n }\n\n const parts: string[] = [];\n for (const field of GMAIL_TEXT_FIELDS) {\n const matcher = match[field];\n if (matcher) {\n parts.push(...textMatcherParts(field, matcher));\n }\n }\n return parts.length > 0 ? parts.join(\"; \") : \"all inbound messages\";\n}\n\nfunction formatGithubSubject(subject: string): string {\n if (subject === \"pull_requests\") {\n return \"pull requests\";\n }\n return subject;\n}\n\nfunction formatWebhookAutomationEntry(\n automation: WorkflowWebhookAutomationSummary,\n): string {\n return `Webhook: ${automation.webhookUrl ?? \"hidden\"}`;\n}\n\nfunction formatNotionParentPage(\n automation: WorkflowNotionChildPageAutomationSummary,\n): string {\n return (\n automation.eventConfig.parentPage.title ??\n automation.eventConfig.parentPage.url\n );\n}\n\nfunction formatNotionDatabase(\n automation: WorkflowNotionDatabaseItemAutomationSummary,\n): string {\n return (\n automation.eventConfig.dataSource.title ??\n automation.eventConfig.dataSource.url\n );\n}\n\nfunction formatNotionContentUpdatedScope(\n automation: WorkflowNotionPageContentUpdatedAutomationSummary,\n): string {\n return automation.eventConfig.scope.type === \"page\"\n ? (automation.eventConfig.scope.page.title ??\n automation.eventConfig.scope.page.url)\n : (automation.eventConfig.scope.dataSource.title ??\n automation.eventConfig.scope.dataSource.url);\n}\n\nfunction formatNotionContentUpdatedScopeUrl(\n automation: WorkflowNotionPageContentUpdatedAutomationSummary,\n): string {\n return automation.eventConfig.scope.type === \"page\"\n ? automation.eventConfig.scope.page.url\n : automation.eventConfig.scope.dataSource.url;\n}\n\nfunction formatWorkflowAutomationEntry(\n automation: ZeroWorkflowAutomationSummary,\n): string {\n if (\n automation.kind === \"event\" &&\n automation.eventType === \"gmail-new-message\"\n ) {\n return `Gmail new message: ${formatGmailMatchSummary(automation.eventConfig)}`;\n }\n if (\n automation.kind === \"event\" &&\n automation.eventType === \"gmail-label-applied\"\n ) {\n return `Gmail label applied: ${quote(automation.eventConfig.labelName)}`;\n }\n if (\n automation.kind === \"event\" &&\n automation.eventType === \"github-label-applied\"\n ) {\n return `GitHub label applied: ${quote(automation.eventConfig.labelName)} (${formatGithubSubject(\n automation.eventConfig.filters.subject,\n )}, actor ${automation.eventConfig.filters.actor.type})`;\n }\n if (\n automation.kind === \"event\" &&\n automation.eventType === \"google-calendar-event-created\"\n ) {\n return `Google Calendar event created: ${automation.eventConfig.calendarId}`;\n }\n if (\n automation.kind === \"event\" &&\n automation.eventType === \"google-calendar-event-updated\"\n ) {\n return `Google Calendar event updated: ${automation.eventConfig.calendarId}`;\n }\n if (\n automation.kind === \"event\" &&\n automation.eventType === \"google-calendar-event-cancelled\"\n ) {\n return `Google Calendar event cancelled: ${automation.eventConfig.calendarId}`;\n }\n if (\n automation.kind === \"event\" &&\n automation.eventType === \"google-meet-transcript-generated\"\n ) {\n return \"Google Meet transcript ready: meetings you organize\";\n }\n if (isWebhookAutomation(automation)) {\n return formatWebhookAutomationEntry(automation);\n }\n\n if (automation.kind !== \"schedule\") {\n return workflowAutomationKindLabel(automation);\n }\n\n const { schedule } = automation;\n switch (schedule.type) {\n case \"cron\":\n return `${schedule.cronExpression} (${schedule.timezone})`;\n case \"once\":\n return `at ${schedule.atTime} (${schedule.timezone})`;\n case \"loop\":\n return `every ${formatDurationSeconds(schedule.intervalSeconds)}`;\n }\n}\n\nfunction formatRunTime(value: string | null): string {\n return value ? formatRelativeTime(value) : chalk.dim(\"-\");\n}\n\nfunction workflowAutomationKindLabel(\n automation: ZeroWorkflowAutomationSummary,\n): string {\n if (automation.kind !== \"event\") {\n return formatWorkflowAutomationEntry(automation);\n }\n switch (automation.eventType) {\n case \"gmail-new-message\":\n return \"Gmail new message\";\n case \"gmail-label-applied\":\n return \"Gmail label applied\";\n case \"github-label-applied\":\n return \"GitHub label applied\";\n case \"github-workflow-run-completed\":\n return \"GitHub workflow completed\";\n case \"google-calendar-event-created\":\n return \"Google Calendar event created\";\n case \"google-calendar-event-updated\":\n return \"Google Calendar event updated\";\n case \"google-calendar-event-cancelled\":\n return \"Google Calendar event cancelled\";\n case \"google-meet-transcript-generated\":\n return \"Google Meet transcript ready\";\n case \"notion-child-page-created\":\n return `New Notion child page: ${formatNotionParentPage(automation)}`;\n case \"notion-database-item-created\":\n return `New Notion database item: ${formatNotionDatabase(automation)}`;\n case \"notion-page-content-updated\":\n return `Notion page content updated: ${formatNotionContentUpdatedScope(automation)}`;\n case \"webhook-received\":\n return \"Webhook\";\n }\n}\n\nfunction signedCurlExample(\n automation: WorkflowWebhookAutomationSummary,\n): string {\n const secret = automation.webhookSecret ?? \"<signing-secret>\";\n const webhookUrl = automation.webhookUrl ?? \"<webhook-url>\";\n return [\n `BODY='{\"hello\":\"world\"}'`,\n \"TIMESTAMP=$(date +%s)\",\n `SIGNATURE=$(printf \"%s.%s\" \"$TIMESTAMP\" \"$BODY\" | openssl dgst -sha256 -hmac \"${secret}\" -hex | awk '{print $2}')`,\n `curl -X POST \"${webhookUrl}\" \\\\`,\n ' -H \"Content-Type: application/json\" \\\\',\n ' -H \"X-VM0-Timestamp: $TIMESTAMP\" \\\\',\n ' -H \"X-VM0-Signature: $SIGNATURE\" \\\\',\n ' --data \"$BODY\"',\n ].join(\"\\n\");\n}\n\nexport function printWorkflowAutomationsTable(\n automations: readonly ZeroWorkflowAutomationSummary[],\n): void {\n const idWidth = Math.max(\n 2,\n ...automations.map((automation) => {\n return automation.id.length;\n }),\n );\n const scheduleWidth = Math.max(\n 7,\n ...automations.map((automation) => {\n return formatWorkflowAutomationEntry(automation).length;\n }),\n );\n\n console.log(\n chalk.dim(\n [\n \"ID\".padEnd(idWidth),\n \"STATUS\".padEnd(8),\n \"AUTOMATION\".padEnd(scheduleWidth),\n \"NEXT RUN\",\n ].join(\" \"),\n ),\n );\n\n for (const automation of automations) {\n const status = automation.enabled\n ? chalk.green(\"enabled\")\n : chalk.yellow(\"disabled\");\n console.log(\n [\n automation.id.padEnd(idWidth),\n status.padEnd(8 + (automation.enabled ? 0 : 2)),\n formatWorkflowAutomationEntry(automation).padEnd(scheduleWidth),\n formatRunTime(automation.nextRunAt),\n ].join(\" \"),\n );\n }\n}\n\nfunction printGithubWorkflowRunFilters(\n automation: ZeroWorkflowAutomationSummary,\n): void {\n if (\n automation.kind !== \"event\" ||\n automation.eventType !== \"github-workflow-run-completed\"\n ) {\n return;\n }\n const printFilter = (\n label: string,\n values: readonly string[] | undefined,\n ) => {\n console.log(`${`${label}:`.padEnd(14)}${values?.join(\", \") ?? \"any\"}`);\n };\n const { filters } = automation.eventConfig;\n printFilter(\"Repositories\", filters.repositories);\n printFilter(\"Workflows\", filters.workflows);\n printFilter(\"Conclusions\", filters.conclusions);\n printFilter(\"Branches\", filters.branches);\n printFilter(\"Events\", filters.events);\n printFilter(\"Actors\", filters.actors);\n}\n\nexport function printWorkflowAutomationDetails(\n automation: ZeroWorkflowAutomationSummary,\n options?: { readonly workflowRef?: string },\n): void {\n const status = automation.enabled\n ? chalk.green(\"enabled\")\n : chalk.yellow(\"disabled\");\n\n console.log(`${\"Kind:\".padEnd(14)}${automation.kind}`);\n console.log(`${\"ID:\".padEnd(14)}${automation.id}`);\n if (options?.workflowRef) {\n console.log(`${\"Workflow:\".padEnd(14)}${options.workflowRef}`);\n }\n console.log(`${\"Status:\".padEnd(14)}${status}`);\n console.log(\n `${\"Automation:\".padEnd(14)}${workflowAutomationKindLabel(automation)}`,\n );\n if (\n automation.kind === \"event\" &&\n automation.eventType === \"gmail-new-message\"\n ) {\n console.log(\n `${\"Match:\".padEnd(14)}${formatGmailMatchSummary(automation.eventConfig)}`,\n );\n }\n if (\n automation.kind === \"event\" &&\n automation.eventType === \"gmail-label-applied\"\n ) {\n console.log(`${\"Label:\".padEnd(14)}${automation.eventConfig.labelName}`);\n }\n if (\n automation.kind === \"event\" &&\n automation.eventType === \"github-label-applied\"\n ) {\n console.log(`${\"Label:\".padEnd(14)}${automation.eventConfig.labelName}`);\n console.log(\n `${\"Subject:\".padEnd(14)}${formatGithubSubject(\n automation.eventConfig.filters.subject,\n )}`,\n );\n console.log(\n `${\"Actor:\".padEnd(14)}${automation.eventConfig.filters.actor.type}`,\n );\n }\n printGithubWorkflowRunFilters(automation);\n if (isGoogleCalendarAutomation(automation)) {\n console.log(\n `${\"Calendar:\".padEnd(14)}${automation.eventConfig.calendarId}`,\n );\n }\n if (isNotionChildPageAutomation(automation)) {\n console.log(\n `${\"Parent page:\".padEnd(14)}${formatNotionParentPage(automation)}`,\n );\n console.log(\n `${\"Parent URL:\".padEnd(14)}${automation.eventConfig.parentPage.url}`,\n );\n }\n if (isNotionDatabaseItemAutomation(automation)) {\n console.log(`${\"Database:\".padEnd(14)}${formatNotionDatabase(automation)}`);\n console.log(\n `${\"Database URL:\".padEnd(14)}${automation.eventConfig.dataSource.url}`,\n );\n }\n if (isNotionPageContentUpdatedAutomation(automation)) {\n const scopeLabel =\n automation.eventConfig.scope.type === \"page\" ? \"Page\" : \"Database\";\n console.log(`${\"Scope:\".padEnd(14)}${scopeLabel}`);\n console.log(\n `${`${scopeLabel}:`.padEnd(14)}${formatNotionContentUpdatedScope(automation)}`,\n );\n console.log(\n `${`${scopeLabel} URL:`.padEnd(14)}${formatNotionContentUpdatedScopeUrl(automation)}`,\n );\n }\n if (isWebhookAutomation(automation)) {\n console.log(\n `${\"Webhook URL:\".padEnd(14)}${automation.webhookUrl ?? \"hidden\"}`,\n );\n console.log(\n `${\"Secret:\".padEnd(14)}${chalk.dim(`ends with ${automation.secretLastFour}`)}`,\n );\n console.log(\n `${\"Last received:\".padEnd(14)}${formatRunTime(automation.lastReceivedAt)}`,\n );\n if (automation.webhookSecret) {\n console.log(\n `${\"Signing key:\".padEnd(14)}${automation.webhookSecret} ${chalk.dim(\n \"(shown only once)\",\n )}`,\n );\n console.log(\"\");\n console.log(chalk.bold(\"Signed curl example:\"));\n console.log(signedCurlExample(automation));\n }\n }\n console.log(`${\"Owner:\".padEnd(14)}${automation.ownerUserId}`);\n console.log(\n `${\"Chat thread:\".padEnd(14)}${automation.chatThreadId ?? chalk.dim(\"-\")}`,\n );\n console.log(\n `${\"Next run:\".padEnd(14)}${formatRunTime(automation.nextRunAt)}`,\n );\n console.log(\n `${\"Last run:\".padEnd(14)}${formatRunTime(automation.lastRunAt)}`,\n );\n}\n","/**\n * Format a date string as relative time (e.g., \"in 2h\", \"3d ago\")\n */\nexport function formatRelativeTime(dateStr: string | null): string {\n if (!dateStr) return \"-\";\n\n const date = new Date(dateStr);\n const now = new Date();\n const diffMs = date.getTime() - now.getTime();\n const diffAbs = Math.abs(diffMs);\n\n const minutes = Math.floor(diffAbs / (1000 * 60));\n const hours = Math.floor(diffAbs / (1000 * 60 * 60));\n const days = Math.floor(diffAbs / (1000 * 60 * 60 * 24));\n\n const isPast = diffMs < 0;\n\n if (days > 0) {\n return isPast ? `${days}d ago` : `in ${days}d`;\n } else if (hours > 0) {\n return isPast ? `${hours}h ago` : `in ${hours}h`;\n } else if (minutes > 0) {\n return isPast ? `${minutes}m ago` : `in ${minutes}m`;\n } else {\n return isPast ? \"just now\" : \"soon\";\n }\n}\n","/**\n * Human-friendly duration handling for loop automations (`--every` / `--loop`).\n */\n\nconst DURATION_PATTERN = /^(\\d+)([smhd])$/;\n\nconst UNIT_SECONDS: Record<string, number> = {\n s: 1,\n m: 60,\n h: 60 * 60,\n d: 24 * 60 * 60,\n};\n\n/**\n * Parse a human duration like \"90s\", \"15m\", \"1h\", \"2d\" into seconds.\n * @throws Error when the input is not a positive integer + unit\n */\nexport function parseDurationSeconds(input: string): number {\n const match = input.match(DURATION_PATTERN);\n if (!match) {\n throw new Error(\n `Invalid duration: \"${input}\". Use <number><unit> with unit s, m, h, or d (e.g. 90s, 15m, 1h)`,\n );\n }\n\n const value = parseInt(match[1]!, 10);\n if (value <= 0) {\n throw new Error(`Invalid duration: \"${input}\". Must be greater than zero`);\n }\n\n return value * UNIT_SECONDS[match[2]!]!;\n}\n\n/**\n * Format seconds back into the largest exact unit (900 → \"15m\", 90 → \"90s\")\n */\nexport function formatDurationSeconds(seconds: number): string {\n for (const [unit, size] of [\n [\"d\", UNIT_SECONDS.d!],\n [\"h\", UNIT_SECONDS.h!],\n [\"m\", UNIT_SECONDS.m!],\n ] as const) {\n if (seconds % size === 0 && seconds >= size) {\n return `${seconds / size}${unit}`;\n }\n }\n return `${seconds}s`;\n}\n","import { Command } from \"commander\";\nimport chalk from \"chalk\";\nimport type {\n GithubLabelAppliedSubjectFilter,\n GithubWorkflowRunConclusion,\n ZeroWorkflowSchedule,\n} from \"@vm0/api-contracts/contracts/zero-workflows\";\nimport {\n type ZeroWorkflowAutomationCreateRequest,\n type ZeroWorkflowAutomationSummary,\n type ZeroWorkflowAutomationUpdateRequest,\n createWorkflowAutomation,\n deleteWorkflowAutomation,\n disableWorkflowAutomation,\n enableWorkflowAutomation,\n getWorkflowAutomation,\n listWorkflowAutomations,\n updateWorkflowAutomation,\n} from \"../../../../lib/api\";\nimport { withErrorHandler } from \"../../../../lib/command\";\nimport { parseDurationSeconds } from \"../../shared/duration\";\nimport {\n resolveWorkflowRef,\n type WorkflowRefOptions,\n} from \"../resolve-workflow-ref\";\nimport {\n printWorkflowAutomationDetails,\n printWorkflowAutomationsTable,\n} from \"./display\";\nimport {\n buildGmailLabelAppliedEventConfig,\n buildGmailNewMessageEventConfig,\n hasGmailLabelOption,\n hasGmailAutomationOptions,\n type GmailAutomationOptions,\n} from \"./gmail-config\";\n\ninterface AddOptions extends GmailAutomationOptions {\n readonly expr?: string;\n readonly at?: string;\n readonly every?: string;\n readonly timezone?: string;\n readonly agent?: string;\n readonly subject?: string;\n readonly actor?: string;\n readonly repository?: string;\n readonly workflow?: string;\n readonly conclusion?: string;\n readonly branch?: string;\n readonly triggeringEvent?: string;\n readonly calendarId?: string;\n readonly pageUrl?: string;\n readonly parentPageUrl?: string;\n readonly databaseUrl?: string;\n}\n\ninterface UpdateOptions extends GmailAutomationOptions {\n readonly expr?: string;\n readonly at?: string;\n readonly every?: string;\n readonly timezone?: string;\n readonly subject?: string;\n readonly actor?: string;\n readonly repository?: string;\n readonly workflow?: string;\n readonly conclusion?: string;\n readonly branch?: string;\n readonly triggeringEvent?: string;\n}\n\nconst SCHEDULE_KINDS = [\"cron\", \"once\", \"loop\"] as const;\nconst EVENT_KINDS = [\n \"gmail-new-message\",\n \"gmail-label-applied\",\n \"github-label-applied\",\n \"github-workflow-run-completed\",\n \"google-calendar-event-created\",\n \"google-calendar-event-updated\",\n \"google-calendar-event-cancelled\",\n \"notion-child-page-created\",\n \"notion-database-item-created\",\n \"notion-page-content-updated\",\n \"webhook\",\n] as const;\nconst AUTOMATION_KINDS = [...SCHEDULE_KINDS, ...EVENT_KINDS] as const;\nconst EXACTLY_ONE_FLAG_MESSAGE =\n \"Provide exactly one of --expr (cron), --at (once), --every (loop), Gmail match options, --label, --subject, --actor, --calendar-id, --page-url, --parent-page-url, or --database-url\";\n\nfunction addGmailAutomationOptions(command: Command): Command {\n return command\n .option(\n \"--config <path>\",\n \"Path to a Gmail new message automation config JSON\",\n )\n .option(\"--label <name>\", \"Label name for label-applied automations\")\n .option(\"--from-contains <text>\", \"Require the From header to contain text\")\n .option(\n \"--from-not-contains <text>\",\n \"Require the From header not to contain text\",\n )\n .option(\n \"--subject-contains <text>\",\n \"Require the Subject header to contain text\",\n )\n .option(\n \"--subject-not-contains <text>\",\n \"Require the Subject header not to contain text\",\n )\n .option(\n \"--body-contains <text>\",\n \"Require the message body to contain text\",\n )\n .option(\n \"--body-not-contains <text>\",\n \"Require the message body not to contain text\",\n )\n .option(\"--to-contains <text>\", \"Require the To header to contain text\")\n .option(\n \"--to-not-contains <text>\",\n \"Require the To header not to contain text\",\n )\n .option(\"--cc-contains <text>\", \"Require the Cc header to contain text\")\n .option(\n \"--cc-not-contains <text>\",\n \"Require the Cc header not to contain text\",\n );\n}\n\nfunction addGithubAutomationOptions(command: Command): Command {\n return command\n .option(\n \"--subject <subject>\",\n \"GitHub subject filter for github-label-applied: both | issues | pull-requests\",\n )\n .option(\n \"--actor <actor>\",\n \"GitHub actor filter: me | anyone for labels, or comma-separated logins for workflow runs\",\n )\n .option(\n \"--repository <repositories>\",\n \"GitHub workflow run repositories, comma-separated owner/name values\",\n )\n .option(\n \"--workflow <workflows>\",\n \"GitHub workflows, comma-separated IDs, names, or paths\",\n )\n .option(\n \"--conclusion <conclusions>\",\n \"Workflow run conclusions, comma-separated values\",\n )\n .option(\"--branch <branches>\", \"Workflow run branches, comma-separated\")\n .option(\n \"--triggering-event <events>\",\n \"Workflow run triggering events, comma-separated\",\n );\n}\n\nfunction timezoneOrUtc(timezone: string | undefined): string {\n return timezone ?? \"UTC\";\n}\n\nfunction assertValidTimezone(timezone: string): void {\n new Intl.DateTimeFormat(\"en-US\", { timeZone: timezone });\n}\n\nfunction hasExplicitOffset(value: string): boolean {\n return /(?:Z|[+-]\\d{2}:?\\d{2})$/i.test(value);\n}\n\nfunction parseLocalDateTime(value: string): {\n readonly year: number;\n readonly month: number;\n readonly day: number;\n readonly hour: number;\n readonly minute: number;\n readonly second: number;\n readonly millisecond: number;\n} {\n const match = value.match(\n /^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2})(?::(\\d{2})(?:\\.(\\d{1,3}))?)?$/,\n );\n if (!match) {\n throw new Error(\n `Invalid at time: \"${value}\". Use ISO datetime, e.g. 2026-06-10T09:00 or 2026-06-10T09:00:00Z`,\n );\n }\n return {\n year: Number(match[1]),\n month: Number(match[2]),\n day: Number(match[3]),\n hour: Number(match[4]),\n minute: Number(match[5]),\n second: match[6] ? Number(match[6]) : 0,\n millisecond: match[7] ? Number(match[7].padEnd(3, \"0\")) : 0,\n };\n}\n\nfunction zonedParts(instant: Date, timezone: string) {\n const parts = new Intl.DateTimeFormat(\"en-US\", {\n timeZone: timezone,\n year: \"numeric\",\n month: \"2-digit\",\n day: \"2-digit\",\n hour: \"2-digit\",\n minute: \"2-digit\",\n second: \"2-digit\",\n hourCycle: \"h23\",\n }).formatToParts(instant);\n const values = new Map<string, string>();\n for (const part of parts) {\n if (part.type !== \"literal\") {\n values.set(part.type, part.value);\n }\n }\n return {\n year: Number(values.get(\"year\")),\n month: Number(values.get(\"month\")),\n day: Number(values.get(\"day\")),\n hour: Number(values.get(\"hour\")),\n minute: Number(values.get(\"minute\")),\n second: Number(values.get(\"second\")),\n };\n}\n\nfunction wallTimeToUtcIso(value: string, timezone: string): string {\n assertValidTimezone(timezone);\n if (hasExplicitOffset(value)) {\n const instant = new Date(value);\n if (Number.isNaN(instant.getTime())) {\n throw new Error(`Invalid at time: \"${value}\"`);\n }\n return instant.toISOString();\n }\n\n const target = parseLocalDateTime(value);\n const targetUtc = Date.UTC(\n target.year,\n target.month - 1,\n target.day,\n target.hour,\n target.minute,\n target.second,\n target.millisecond,\n );\n let guess = targetUtc;\n for (let i = 0; i < 3; i++) {\n const parts = zonedParts(new Date(guess), timezone);\n const renderedUtc = Date.UTC(\n parts.year,\n parts.month - 1,\n parts.day,\n parts.hour,\n parts.minute,\n parts.second,\n target.millisecond,\n );\n guess += targetUtc - renderedUtc;\n }\n\n const result = new Date(guess);\n const rendered = zonedParts(result, timezone);\n if (\n rendered.year !== target.year ||\n rendered.month !== target.month ||\n rendered.day !== target.day ||\n rendered.hour !== target.hour ||\n rendered.minute !== target.minute ||\n rendered.second !== target.second\n ) {\n throw new Error(\n `Invalid at time for ${timezone}: \"${value}\". The local time does not exist`,\n );\n }\n return result.toISOString();\n}\n\nfunction buildSchedule(\n kind: string,\n options: UpdateOptions,\n): ZeroWorkflowSchedule {\n switch (kind) {\n case \"cron\":\n if (!options.expr) {\n throw new Error(\n 'cron automations require --expr (e.g. --expr \"0 9 * * *\")',\n );\n }\n return {\n type: \"cron\",\n cronExpression: options.expr,\n timezone: timezoneOrUtc(options.timezone),\n };\n case \"once\": {\n if (!options.at) {\n throw new Error(\n 'once automations require --at (e.g. --at \"2026-06-10T09:00\")',\n );\n }\n const timezone = timezoneOrUtc(options.timezone);\n return {\n type: \"once\",\n atTime: wallTimeToUtcIso(options.at, timezone),\n timezone,\n };\n }\n case \"loop\":\n if (!options.every) {\n throw new Error(\"loop automations require --every (e.g. --every 15m)\");\n }\n return {\n type: \"loop\",\n intervalSeconds: parseDurationSeconds(options.every),\n };\n default:\n throw new Error(\n `Unknown automation kind: \"${kind}\". Use one of: ${AUTOMATION_KINDS.join(\", \")}`,\n );\n }\n}\n\nfunction hasScheduleAddOptions(options: AddOptions): boolean {\n return (\n options.expr !== undefined ||\n options.at !== undefined ||\n options.every !== undefined ||\n options.timezone !== undefined\n );\n}\n\nfunction hasGithubLabelAutomationOptions(\n options: AddOptions | UpdateOptions,\n): boolean {\n return options.subject !== undefined || options.actor !== undefined;\n}\n\nfunction hasGithubWorkflowRunSpecificOptions(\n options: AddOptions | UpdateOptions,\n): boolean {\n return (\n options.repository !== undefined ||\n options.workflow !== undefined ||\n options.conclusion !== undefined ||\n options.branch !== undefined ||\n options.triggeringEvent !== undefined\n );\n}\n\nfunction hasGithubAutomationOptions(\n options: AddOptions | UpdateOptions,\n): boolean {\n return (\n hasGithubLabelAutomationOptions(options) ||\n hasGithubWorkflowRunSpecificOptions(options)\n );\n}\n\nfunction hasCalendarAutomationOptions(options: AddOptions): boolean {\n return options.calendarId !== undefined;\n}\n\nfunction hasNotionAutomationOptions(options: AddOptions): boolean {\n return (\n options.pageUrl !== undefined ||\n options.parentPageUrl !== undefined ||\n options.databaseUrl !== undefined\n );\n}\n\nfunction hasEventAddOptions(options: AddOptions): boolean {\n return (\n hasGmailAutomationOptions(options) ||\n hasGmailLabelOption(options) ||\n hasGithubAutomationOptions(options) ||\n hasCalendarAutomationOptions(options) ||\n hasNotionAutomationOptions(options)\n );\n}\n\nfunction assertNoScheduleAddOptions(options: AddOptions): void {\n if (hasScheduleAddOptions(options)) {\n throw new Error(\n \"--expr, --at, --every, and --timezone only apply to schedule automations\",\n );\n }\n}\n\nfunction assertNoGithubAutomationOptions(\n options: AddOptions,\n message = \"GitHub automation flags only apply to GitHub event automations\",\n): void {\n if (hasGithubAutomationOptions(options)) {\n throw new Error(message);\n }\n}\n\nfunction assertNoCalendarAutomationOptions(options: AddOptions): void {\n if (hasCalendarAutomationOptions(options)) {\n throw new Error(\n \"Google Calendar automation flags only apply to Google Calendar event automations\",\n );\n }\n}\n\nfunction assertNoNotionAutomationOptions(options: AddOptions): void {\n if (hasNotionAutomationOptions(options)) {\n throw new Error(\n \"Notion automation flags only apply to Notion event automations\",\n );\n }\n}\n\nfunction scheduleUpdateFlagCount(options: UpdateOptions): number {\n return [options.expr, options.at, options.every].filter((value) => {\n return value !== undefined;\n }).length;\n}\n\nfunction hasScheduleUpdateOptions(options: UpdateOptions): boolean {\n return scheduleUpdateFlagCount(options) > 0 || options.timezone !== undefined;\n}\n\nfunction parseGithubSubject(\n value: string | undefined,\n fallback: GithubLabelAppliedSubjectFilter = \"both\",\n): GithubLabelAppliedSubjectFilter {\n if (value === undefined) {\n return fallback;\n }\n switch (value) {\n case \"both\":\n case \"issues\":\n return value;\n case \"pull-requests\":\n return \"pull_requests\";\n default:\n throw new Error(\n `Invalid --subject \"${value}\". Use one of: both, issues, pull-requests`,\n );\n }\n}\n\nfunction parseGithubActor(\n value: string | undefined,\n fallback: \"me\" | \"anyone\" = \"me\",\n): \"me\" | \"anyone\" {\n if (value === undefined) {\n return fallback;\n }\n if (value === \"me\" || value === \"anyone\") {\n return value;\n }\n throw new Error(`Invalid --actor \"${value}\". Use one of: me, anyone`);\n}\n\nfunction buildGithubLabelAppliedEventConfig(\n options: AddOptions | UpdateOptions,\n existing?: Extract<\n ZeroWorkflowAutomationSummary,\n { readonly kind: \"event\"; readonly eventType: \"github-label-applied\" }\n >,\n) {\n const labelName = options.label?.trim() ?? existing?.eventConfig.labelName;\n if (!labelName) {\n throw new Error(\n 'github-label-applied automations require --label \"Label name\"',\n );\n }\n\n return {\n provider: \"github\" as const,\n event: \"label_applied\" as const,\n labelName,\n filters: {\n subject: parseGithubSubject(\n options.subject,\n existing?.eventConfig.filters.subject ?? \"both\",\n ),\n actor: {\n type: parseGithubActor(\n options.actor,\n existing?.eventConfig.filters.actor.type ?? \"me\",\n ),\n },\n },\n };\n}\n\nconst GITHUB_WORKFLOW_RUN_CONCLUSIONS: readonly GithubWorkflowRunConclusion[] =\n [\n \"action_required\",\n \"cancelled\",\n \"failure\",\n \"neutral\",\n \"skipped\",\n \"stale\",\n \"startup_failure\",\n \"success\",\n \"timed_out\",\n ];\n\nfunction parseGithubWorkflowRunFilter(\n value: string | undefined,\n fallback: readonly string[] | undefined,\n): string[] | undefined {\n if (value === undefined) {\n return fallback ? [...fallback] : undefined;\n }\n if (value.trim().toLowerCase() === \"any\") {\n return undefined;\n }\n const values = Array.from(\n new Set(\n value\n .split(\",\")\n .map((part) => {\n return part.trim();\n })\n .filter(Boolean),\n ),\n );\n if (values.length === 0) {\n throw new Error(\"GitHub workflow run filters cannot be empty; use any\");\n }\n return values;\n}\n\nfunction parseGithubWorkflowRunConclusions(\n value: string | undefined,\n fallback: readonly GithubWorkflowRunConclusion[] | undefined,\n): GithubWorkflowRunConclusion[] | undefined {\n const values = parseGithubWorkflowRunFilter(value, fallback);\n if (!values) {\n return undefined;\n }\n return values.map((conclusion) => {\n if (\n GITHUB_WORKFLOW_RUN_CONCLUSIONS.includes(\n conclusion as GithubWorkflowRunConclusion,\n )\n ) {\n return conclusion as GithubWorkflowRunConclusion;\n }\n throw new Error(\n `Invalid --conclusion \"${conclusion}\". Use one of: ${GITHUB_WORKFLOW_RUN_CONCLUSIONS.join(\", \")}, any`,\n );\n });\n}\n\nfunction buildGithubWorkflowRunCompletedEventConfig(\n options: AddOptions | UpdateOptions,\n existing?: Extract<\n ZeroWorkflowAutomationSummary,\n {\n readonly kind: \"event\";\n readonly eventType: \"github-workflow-run-completed\";\n }\n >,\n) {\n const filters = existing?.eventConfig.filters;\n return {\n provider: \"github\" as const,\n event: \"workflow_run_completed\" as const,\n filters: {\n repositories: parseGithubWorkflowRunFilter(\n options.repository,\n filters?.repositories,\n ),\n workflows: parseGithubWorkflowRunFilter(\n options.workflow,\n filters?.workflows,\n ),\n conclusions: parseGithubWorkflowRunConclusions(\n options.conclusion,\n filters?.conclusions,\n ),\n branches: parseGithubWorkflowRunFilter(options.branch, filters?.branches),\n events: parseGithubWorkflowRunFilter(\n options.triggeringEvent,\n filters?.events,\n ),\n actors: parseGithubWorkflowRunFilter(options.actor, filters?.actors),\n },\n };\n}\n\nfunction buildGmailNewMessageCreateRequest(\n options: AddOptions,\n): ZeroWorkflowAutomationCreateRequest {\n assertNoScheduleAddOptions(options);\n if (hasGmailLabelOption(options)) {\n throw new Error(\"--label only applies to label-applied event automations\");\n }\n assertNoGithubAutomationOptions(options);\n assertNoCalendarAutomationOptions(options);\n assertNoNotionAutomationOptions(options);\n return {\n kind: \"event\",\n eventType: \"gmail-new-message\",\n eventConfig: buildGmailNewMessageEventConfig(options),\n };\n}\n\nfunction buildGmailLabelAppliedCreateRequest(\n options: AddOptions,\n): ZeroWorkflowAutomationCreateRequest {\n assertNoScheduleAddOptions(options);\n if (hasGmailAutomationOptions(options)) {\n throw new Error(\n \"Gmail match flags and --config only apply to gmail-new-message automations\",\n );\n }\n assertNoGithubAutomationOptions(options);\n assertNoCalendarAutomationOptions(options);\n assertNoNotionAutomationOptions(options);\n return {\n kind: \"event\",\n eventType: \"gmail-label-applied\",\n eventConfig: buildGmailLabelAppliedEventConfig(options),\n };\n}\n\nfunction buildGithubLabelAppliedCreateRequest(\n options: AddOptions,\n): ZeroWorkflowAutomationCreateRequest {\n assertNoScheduleAddOptions(options);\n if (hasGmailAutomationOptions(options)) {\n throw new Error(\n \"Gmail match flags and --config only apply to Gmail event automations\",\n );\n }\n assertNoCalendarAutomationOptions(options);\n assertNoNotionAutomationOptions(options);\n if (hasGithubWorkflowRunSpecificOptions(options)) {\n throw new Error(\n \"Workflow run filter flags only apply to github-workflow-run-completed automations\",\n );\n }\n return {\n kind: \"event\",\n eventType: \"github-label-applied\",\n eventConfig: buildGithubLabelAppliedEventConfig(options),\n };\n}\n\nfunction buildGithubWorkflowRunCompletedCreateRequest(\n options: AddOptions,\n): ZeroWorkflowAutomationCreateRequest {\n assertNoScheduleAddOptions(options);\n if (hasGmailAutomationOptions(options) || hasGmailLabelOption(options)) {\n throw new Error(\n \"Gmail automation flags only apply to Gmail event automations\",\n );\n }\n if (options.subject !== undefined) {\n throw new Error(\n \"--subject only applies to github-label-applied automations\",\n );\n }\n assertNoCalendarAutomationOptions(options);\n assertNoNotionAutomationOptions(options);\n return {\n kind: \"event\",\n eventType: \"github-workflow-run-completed\",\n eventConfig: buildGithubWorkflowRunCompletedEventConfig(options),\n };\n}\n\nfunction buildGoogleCalendarEventCreateRequest(\n eventType:\n | \"google-calendar-event-created\"\n | \"google-calendar-event-updated\"\n | \"google-calendar-event-cancelled\",\n options: AddOptions,\n): ZeroWorkflowAutomationCreateRequest {\n assertNoScheduleAddOptions(options);\n if (\n hasGmailAutomationOptions(options) ||\n hasGmailLabelOption(options) ||\n hasGithubAutomationOptions(options) ||\n hasNotionAutomationOptions(options)\n ) {\n throw new Error(\n \"Gmail, GitHub, and Notion automation flags only apply to their event automations\",\n );\n }\n const calendarId = options.calendarId?.trim() || \"primary\";\n if (eventType === \"google-calendar-event-created\") {\n return {\n kind: \"event\",\n eventType: \"google-calendar-event-created\",\n eventConfig: {\n provider: \"google-calendar\",\n event: \"event_created\",\n calendarId,\n },\n };\n }\n if (eventType === \"google-calendar-event-updated\") {\n return {\n kind: \"event\",\n eventType: \"google-calendar-event-updated\",\n eventConfig: {\n provider: \"google-calendar\",\n event: \"event_updated\",\n calendarId,\n },\n };\n }\n return {\n kind: \"event\",\n eventType: \"google-calendar-event-cancelled\",\n eventConfig: {\n provider: \"google-calendar\",\n event: \"event_cancelled\",\n calendarId,\n },\n };\n}\n\nfunction buildNotionChildPageCreatedCreateRequest(\n options: AddOptions,\n): ZeroWorkflowAutomationCreateRequest {\n assertNoScheduleAddOptions(options);\n if (\n hasGmailAutomationOptions(options) ||\n hasGmailLabelOption(options) ||\n hasGithubAutomationOptions(options) ||\n hasCalendarAutomationOptions(options)\n ) {\n throw new Error(\n \"Gmail, GitHub, and Google Calendar automation flags only apply to their event automations\",\n );\n }\n\n const parentPageUrl = options.parentPageUrl?.trim();\n if (options.pageUrl !== undefined || options.databaseUrl !== undefined) {\n throw new Error(\n \"--page-url and --database-url do not apply to notion-child-page-created automations\",\n );\n }\n if (!parentPageUrl) {\n throw new Error(\n 'notion-child-page-created automations require --parent-page-url \"https://www.notion.so/...\"',\n );\n }\n\n return {\n kind: \"event\",\n eventType: \"notion-child-page-created\",\n eventConfig: {\n provider: \"notion\",\n event: \"child_page_created\",\n parentPageUrl,\n },\n };\n}\n\nfunction buildNotionDatabaseItemCreatedCreateRequest(\n options: AddOptions,\n): ZeroWorkflowAutomationCreateRequest {\n assertNoScheduleAddOptions(options);\n if (\n hasGmailAutomationOptions(options) ||\n hasGmailLabelOption(options) ||\n hasGithubAutomationOptions(options) ||\n hasCalendarAutomationOptions(options)\n ) {\n throw new Error(\n \"Gmail, GitHub, and Google Calendar automation flags only apply to their event automations\",\n );\n }\n\n if (options.pageUrl !== undefined || options.parentPageUrl !== undefined) {\n throw new Error(\n \"--page-url and --parent-page-url do not apply to notion-database-item-created automations\",\n );\n }\n const databaseUrl = options.databaseUrl?.trim();\n if (!databaseUrl) {\n throw new Error(\n 'notion-database-item-created automations require --database-url \"https://www.notion.so/...\"',\n );\n }\n\n return {\n kind: \"event\",\n eventType: \"notion-database-item-created\",\n eventConfig: {\n provider: \"notion\",\n event: \"database_item_created\",\n databaseUrl,\n },\n };\n}\n\nfunction buildNotionPageContentUpdatedCreateRequest(\n options: AddOptions,\n): ZeroWorkflowAutomationCreateRequest {\n assertNoScheduleAddOptions(options);\n if (\n hasGmailAutomationOptions(options) ||\n hasGmailLabelOption(options) ||\n hasGithubAutomationOptions(options) ||\n hasCalendarAutomationOptions(options)\n ) {\n throw new Error(\n \"Gmail, GitHub, and Google Calendar automation flags only apply to their event automations\",\n );\n }\n\n if (options.parentPageUrl !== undefined) {\n throw new Error(\n \"--parent-page-url only applies to notion-child-page-created automations\",\n );\n }\n const pageUrl = options.pageUrl?.trim();\n const databaseUrl = options.databaseUrl?.trim();\n if (\n (pageUrl !== undefined && pageUrl.length > 0) ===\n (databaseUrl !== undefined && databaseUrl.length > 0)\n ) {\n throw new Error(\n 'notion-page-content-updated automations require exactly one of --page-url \"https://www.notion.so/...\" or --database-url \"https://www.notion.so/...\"',\n );\n }\n\n return {\n kind: \"event\",\n eventType: \"notion-page-content-updated\",\n eventConfig:\n pageUrl !== undefined && pageUrl.length > 0\n ? {\n provider: \"notion\",\n event: \"page_content_updated\",\n pageUrl,\n }\n : {\n provider: \"notion\",\n event: \"page_content_updated\",\n databaseUrl: databaseUrl ?? \"\",\n },\n };\n}\n\nfunction buildWebhookCreateRequest(\n options: AddOptions,\n): ZeroWorkflowAutomationCreateRequest {\n assertNoScheduleAddOptions(options);\n if (hasEventAddOptions(options)) {\n throw new Error(\"Event automation flags only apply to event automations\");\n }\n return {\n kind: \"event\",\n eventType: \"webhook-received\",\n eventConfig: {\n provider: \"webhook\",\n event: \"received\",\n auth: { mode: \"hmac-sha256\" },\n },\n };\n}\n\nfunction buildScheduleCreateRequest(\n kind: string,\n options: AddOptions,\n): ZeroWorkflowAutomationCreateRequest {\n if (hasEventAddOptions(options)) {\n throw new Error(\"Event automation flags only apply to event automations\");\n }\n return { schedule: buildSchedule(kind, options) };\n}\n\nfunction buildCreateRequest(\n kind: string,\n options: AddOptions,\n): ZeroWorkflowAutomationCreateRequest {\n switch (kind) {\n case \"gmail-new-message\":\n return buildGmailNewMessageCreateRequest(options);\n case \"gmail-label-applied\":\n return buildGmailLabelAppliedCreateRequest(options);\n case \"github-label-applied\":\n return buildGithubLabelAppliedCreateRequest(options);\n case \"github-workflow-run-completed\":\n return buildGithubWorkflowRunCompletedCreateRequest(options);\n case \"google-calendar-event-created\":\n return buildGoogleCalendarEventCreateRequest(kind, options);\n case \"google-calendar-event-updated\":\n return buildGoogleCalendarEventCreateRequest(kind, options);\n case \"google-calendar-event-cancelled\":\n return buildGoogleCalendarEventCreateRequest(kind, options);\n case \"notion-child-page-created\":\n return buildNotionChildPageCreatedCreateRequest(options);\n case \"notion-database-item-created\":\n return buildNotionDatabaseItemCreatedCreateRequest(options);\n case \"notion-page-content-updated\":\n return buildNotionPageContentUpdatedCreateRequest(options);\n case \"webhook\":\n return buildWebhookCreateRequest(options);\n default:\n return buildScheduleCreateRequest(kind, options);\n }\n}\n\nfunction buildEventUpdate(\n options: UpdateOptions,\n existing: Extract<ZeroWorkflowAutomationSummary, { readonly kind: \"event\" }>,\n): ZeroWorkflowAutomationUpdateRequest {\n const hasGmailOptions = hasGmailAutomationOptions(options);\n const hasLabelOption = hasGmailLabelOption(options);\n const hasGithubOptions = hasGithubAutomationOptions(options);\n\n if (\n existing.eventType === \"google-calendar-event-created\" ||\n existing.eventType === \"google-calendar-event-updated\" ||\n existing.eventType === \"google-calendar-event-cancelled\"\n ) {\n throw new Error(\"Google Calendar event automations cannot be updated\");\n }\n\n if (existing.eventType === \"github-label-applied\") {\n if (hasGmailOptions) {\n throw new Error(\n \"Gmail match flags only apply to Gmail event automations\",\n );\n }\n if (hasGithubWorkflowRunSpecificOptions(options)) {\n throw new Error(\n \"Workflow run filter flags only apply to github-workflow-run-completed automations\",\n );\n }\n if (!hasLabelOption && !hasGithubOptions) {\n throw new Error(\n \"Provide --label, --subject, or --actor for github-label-applied automations\",\n );\n }\n return {\n eventConfig: buildGithubLabelAppliedEventConfig(options, existing),\n };\n }\n\n if (existing.eventType === \"github-workflow-run-completed\") {\n if (hasGmailOptions || hasLabelOption || options.subject !== undefined) {\n throw new Error(\n \"Gmail, label, and subject flags do not apply to GitHub workflow run automations\",\n );\n }\n if (!hasGithubAutomationOptions(options)) {\n throw new Error(\n \"Provide a GitHub workflow run filter flag; use any to clear a filter\",\n );\n }\n return {\n eventConfig: buildGithubWorkflowRunCompletedEventConfig(\n options,\n existing,\n ),\n };\n }\n\n if (hasGithubOptions) {\n throw new Error(\n \"GitHub automation flags only apply to GitHub event automations\",\n );\n }\n\n if (existing.eventType === \"gmail-label-applied\") {\n if (!hasLabelOption || hasGmailOptions) {\n throw new Error(\"Use --label for gmail-label-applied automations\");\n }\n return { eventConfig: buildGmailLabelAppliedEventConfig(options) };\n }\n\n if (!hasGmailOptions || hasLabelOption) {\n throw new Error(\n \"Use Gmail match options for gmail-new-message automations\",\n );\n }\n return { eventConfig: buildGmailNewMessageEventConfig(options) };\n}\n\nfunction buildScheduleUpdate(\n options: UpdateOptions,\n): ZeroWorkflowAutomationUpdateRequest {\n const hasGmailOptions = hasGmailAutomationOptions(options);\n const hasLabelOption = hasGmailLabelOption(options);\n if (hasGmailOptions || hasLabelOption) {\n throw new Error(\n \"Gmail automation flags only apply to Gmail event automations\",\n );\n }\n const flagCount = scheduleUpdateFlagCount(options);\n if (flagCount !== 1) {\n throw new Error(EXACTLY_ONE_FLAG_MESSAGE);\n }\n if (options.timezone && !options.expr && !options.at) {\n throw new Error(\"--timezone only applies to --expr and --at\");\n }\n if (options.expr) {\n return { schedule: buildSchedule(\"cron\", options) };\n }\n if (options.at) {\n return { schedule: buildSchedule(\"once\", options) };\n }\n return { schedule: buildSchedule(\"loop\", options) };\n}\n\nfunction buildUpdate(\n options: UpdateOptions,\n existing: ZeroWorkflowAutomationSummary,\n): ZeroWorkflowAutomationUpdateRequest {\n const hasEventOptions =\n hasGmailAutomationOptions(options) ||\n hasGmailLabelOption(options) ||\n hasGithubAutomationOptions(options);\n if (hasScheduleUpdateOptions(options) && hasEventOptions) {\n throw new Error(\"Use either schedule flags or event automation options\");\n }\n if (hasGmailAutomationOptions(options) && hasGmailLabelOption(options)) {\n throw new Error(\"Use either Gmail match options or --label\");\n }\n\n if (existing.kind === \"event\") {\n if (hasScheduleUpdateOptions(options)) {\n throw new Error(\"Schedule flags only apply to schedule automations\");\n }\n return buildEventUpdate(options, existing);\n }\n\n if (hasGithubAutomationOptions(options)) {\n throw new Error(\n \"GitHub automation flags only apply to GitHub event automations\",\n );\n }\n return buildScheduleUpdate(options);\n}\n\nconst addCommand = addGithubAutomationOptions(\n addGmailAutomationOptions(\n new Command()\n .name(\"add\")\n .description(\"Add an automation to a workflow\")\n .argument(\"<workflow>\", \"Workflow ID or name\")\n .argument(\"<kind>\", `Automation type: ${AUTOMATION_KINDS.join(\" | \")}`)\n .option(\"--expr <expression>\", 'Cron expression for kind \"cron\"')\n .option(\"--at <iso-time>\", 'Fire time for kind \"once\"')\n .option(\n \"--every <duration>\",\n 'Interval for kind \"loop\" (e.g. 15m, 1h, 90s)',\n )\n .option(\n \"-z, --timezone <tz>\",\n \"IANA timezone for cron/once (default: UTC)\",\n ),\n ),\n)\n .option(\n \"--calendar-id <id>\",\n \"Google Calendar ID for Google Calendar event automations (default: primary)\",\n )\n .option(\n \"--page-url <url>\",\n \"Notion page URL for notion-page-content-updated automations\",\n )\n .option(\n \"--parent-page-url <url>\",\n \"Parent Notion page URL for notion-child-page-created automations\",\n )\n .option(\n \"--database-url <url>\",\n \"Notion database URL for notion-database-item-created or notion-page-content-updated automations\",\n )\n .option(\"--agent <id>\", \"Agent ID for resolving a workflow name\")\n .addHelpText(\n \"after\",\n `\nExamples:\n zero workflow automation add tell-a-joke --agent <agent-id> cron --expr \"0 9 * * *\" -z Asia/Shanghai\n zero workflow automation add tell-a-joke --agent <agent-id> once --at \"2026-06-10T09:00\" -z Asia/Shanghai\n zero workflow automation add tell-a-joke --agent <agent-id> loop --every 15m\n zero workflow automation add triage --agent <agent-id> gmail-new-message --from-contains \"@example.com\"\n zero workflow automation add triage --agent <agent-id> gmail-new-message --config ./gmail-automation.json\n zero workflow automation add triage --agent <agent-id> gmail-label-applied --label \"Support\"\n zero workflow automation add triage --agent <agent-id> github-label-applied --label \"triage\" --subject both --actor me\n zero workflow automation add ci-triage --agent <agent-id> github-workflow-run-completed --repository vm0-ai/vm0 --workflow Turbo --conclusion failure,timed_out --branch main --triggering-event push --actor dependabot[bot]\n zero workflow automation add triage --agent <agent-id> google-calendar-event-created\n zero workflow automation add triage --agent <agent-id> google-calendar-event-updated\n zero workflow automation add triage --agent <agent-id> google-calendar-event-cancelled\n zero workflow automation add research-notes --agent <agent-id> notion-child-page-created --parent-page-url \"https://www.notion.so/workspace/Page-title-1234567890abcdef1234567890abcdef\"\n zero workflow automation add research-notes --agent <agent-id> notion-database-item-created --database-url \"https://www.notion.so/1234567890abcdef1234567890abcdef?v=abcdef1234567890abcdef1234567890\"\n zero workflow automation add research-notes --agent <agent-id> notion-page-content-updated --page-url \"https://www.notion.so/workspace/Page-title-1234567890abcdef1234567890abcdef\"\n zero workflow automation add research-notes --agent <agent-id> notion-page-content-updated --database-url \"https://www.notion.so/1234567890abcdef1234567890abcdef?v=abcdef1234567890abcdef1234567890\"\n zero workflow automation add triage --agent <agent-id> webhook\n\nNotes:\n - Workflow names resolve under --agent, then ZERO_AGENT_ID\n - Gmail automations match all inbound messages when no text match rules are provided\n - GitHub automations require the GitHub App installation in the workspace\n - GitHub workflow run filters accept comma-separated values; omit a filter to match any value\n - Webhook automations print the signing secret only once after creation\n - Use the workflow ID when a name is ambiguous`,\n )\n .action(\n withErrorHandler(\n async (workflowRef: string, kind: string, options: AddOptions) => {\n if (\n options.timezone &&\n kind !== \"cron\" &&\n kind !== \"once\" &&\n kind !== \"gmail-new-message\"\n ) {\n throw new Error(\n \"--timezone only applies to cron and once automations\",\n );\n }\n const workflowId = await resolveWorkflowRef(workflowRef, options);\n const body = buildCreateRequest(kind, options);\n const automation = await createWorkflowAutomation(workflowId, body);\n\n console.log(\n chalk.green(`✓ Automation added to workflow \"${workflowRef}\"`),\n );\n printWorkflowAutomationDetails(automation, { workflowRef });\n },\n ),\n );\n\nconst updateCommand = addGithubAutomationOptions(\n addGmailAutomationOptions(\n new Command()\n .name(\"update\")\n .description(\n \"Replace a workflow automation's schedule or event filter config\",\n )\n .argument(\"<automation>\", \"Workflow automation ID\")\n .option(\"--expr <expression>\", 'New cron schedule (e.g. \"0 9 * * *\")')\n .option(\"--at <iso-time>\", 'New one-time fire (e.g. \"2026-06-10T09:00\")')\n .option(\"--every <duration>\", \"New loop interval (e.g. 15m, 1h, 90s)\")\n .option(\"-z, --timezone <tz>\", \"IANA timezone for --expr / --at\"),\n ),\n)\n .addHelpText(\n \"after\",\n `\nExamples:\n zero workflow automation update 22222222-2222-4222-8222-222222222222 --expr \"0 9 * * *\" -z Asia/Shanghai\n zero workflow automation update 22222222-2222-4222-8222-222222222222 --at \"2026-06-10T09:00\" -z UTC\n zero workflow automation update 22222222-2222-4222-8222-222222222222 --every 10m\n zero workflow automation update 22222222-2222-4222-8222-222222222222 --from-contains \"@example.com\"\n zero workflow automation update 22222222-2222-4222-8222-222222222222 --config ./gmail-automation.json\n zero workflow automation update 22222222-2222-4222-8222-222222222222 --label \"Support\"\n zero workflow automation update 22222222-2222-4222-8222-222222222222 --actor anyone\n zero workflow automation update 22222222-2222-4222-8222-222222222222 --conclusion failure,timed_out --branch main\n zero workflow automation update 22222222-2222-4222-8222-222222222222 --actor any`,\n )\n .action(\n withErrorHandler(async (id: string, options: UpdateOptions) => {\n const existing = await getWorkflowAutomation(id);\n const automation = await updateWorkflowAutomation(\n id,\n buildUpdate(options, existing),\n );\n\n console.log(chalk.green(`✓ Automation ${automation.id} updated`));\n printWorkflowAutomationDetails(automation);\n }),\n );\n\nconst listCommand = new Command()\n .name(\"list\")\n .alias(\"ls\")\n .description(\"List a workflow's automations\")\n .argument(\"<workflow>\", \"Workflow ID or name\")\n .option(\"--agent <id>\", \"Agent ID for resolving a workflow name\")\n .addHelpText(\n \"after\",\n `\nExamples:\n zero workflow automation list tell-a-joke --agent <agent-id>\n zero workflow automation list <workflow-id>`,\n )\n .action(\n withErrorHandler(\n async (workflowRef: string, options: WorkflowRefOptions) => {\n const workflowId = await resolveWorkflowRef(workflowRef, options);\n const automations = await listWorkflowAutomations(workflowId);\n\n if (automations.length === 0) {\n console.log(chalk.dim(\"No automations\"));\n console.log(\n chalk.dim(\n ` Add one with: zero workflow automation add ${workflowRef} cron --expr \"0 9 * * *\"`,\n ),\n );\n return;\n }\n\n printWorkflowAutomationsTable(automations);\n },\n ),\n );\n\nconst showCommand = new Command()\n .name(\"show\")\n .description(\"Show a workflow automation\")\n .argument(\"<automation>\", \"Workflow automation ID\")\n .action(\n withErrorHandler(async (id: string) => {\n const automation = await getWorkflowAutomation(id);\n printWorkflowAutomationDetails(automation);\n }),\n );\n\nconst rmCommand = new Command()\n .name(\"rm\")\n .alias(\"remove\")\n .description(\"Remove a workflow automation\")\n .argument(\"<automation>\", \"Workflow automation ID\")\n .action(\n withErrorHandler(async (id: string) => {\n await deleteWorkflowAutomation(id);\n console.log(chalk.green(`✓ Automation ${id} removed`));\n }),\n );\n\nconst enableCommand = new Command()\n .name(\"enable\")\n .description(\"Enable a workflow automation\")\n .argument(\"<automation>\", \"Workflow automation ID\")\n .action(\n withErrorHandler(async (id: string) => {\n const automation = await enableWorkflowAutomation(id);\n console.log(chalk.green(`✓ Automation ${automation.id} enabled`));\n }),\n );\n\nconst disableCommand = new Command()\n .name(\"disable\")\n .description(\"Disable a workflow automation\")\n .argument(\"<automation>\", \"Workflow automation ID\")\n .action(\n withErrorHandler(async (id: string) => {\n const automation = await disableWorkflowAutomation(id);\n console.log(chalk.green(`✓ Automation ${automation.id} disabled`));\n }),\n );\n\nexport const automationCommand = new Command()\n .name(\"automation\")\n .description(\"Manage a workflow's automations\")\n .addCommand(addCommand)\n .addCommand(updateCommand)\n .addCommand(listCommand)\n .addCommand(showCommand)\n .addCommand(rmCommand)\n .addCommand(enableCommand)\n .addCommand(disableCommand)\n .addHelpText(\n \"after\",\n `\nExamples:\n Add an automation: zero workflow automation add <workflow-id> cron --expr \"0 9 * * *\"\n Add a Notion page: zero workflow automation add <workflow-id> notion-child-page-created --parent-page-url \"https://www.notion.so/...\"\n Add a webhook: zero workflow automation add <workflow-id> webhook\n Update a schedule: zero workflow automation update <automation-id> --every 10m\n List automations: zero workflow automation list <workflow-id>\n Inspect an automation: zero workflow automation show <automation-id>\n Pause one automation: zero workflow automation disable <automation-id>`,\n );\n","import { readFileSync } from \"node:fs\";\nimport type {\n GmailLabelAppliedEventConfig,\n GmailNewMessageEventConfig,\n} from \"@vm0/api-contracts/contracts/zero-workflows\";\n\ntype GmailMatchRules = NonNullable<GmailNewMessageEventConfig[\"match\"]>;\ntype GmailTextMatcher = NonNullable<GmailMatchRules[\"from\"]>;\ntype GmailTextField = \"from\" | \"subject\" | \"body\" | \"to\" | \"cc\";\n\nexport interface GmailAutomationOptions {\n readonly config?: string;\n readonly label?: string;\n readonly fromContains?: string;\n readonly fromNotContains?: string;\n readonly subjectContains?: string;\n readonly subjectNotContains?: string;\n readonly bodyContains?: string;\n readonly bodyNotContains?: string;\n readonly toContains?: string;\n readonly toNotContains?: string;\n readonly ccContains?: string;\n readonly ccNotContains?: string;\n}\n\ninterface TextFlagSpec {\n readonly field: GmailTextField;\n readonly contains?: string;\n readonly doesNotContain?: string;\n}\n\nconst TEXT_FIELD_LABELS: Record<GmailTextField, string> = {\n from: \"from\",\n subject: \"subject\",\n body: \"body\",\n to: \"to\",\n cc: \"cc\",\n};\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction textFieldFromKey(key: string): GmailTextField | null {\n switch (key) {\n case \"from\":\n case \"subject\":\n case \"body\":\n case \"to\":\n case \"cc\":\n return key;\n default:\n return null;\n }\n}\n\nfunction formatFieldName(field: GmailTextField): string {\n return TEXT_FIELD_LABELS[field];\n}\n\nfunction parseNonEmptyString(value: unknown, path: string): string {\n if (typeof value !== \"string\" || value.length === 0) {\n throw new Error(`${path} must be a non-empty string`);\n }\n return value;\n}\n\nfunction parseNonEmptyStringArray(value: unknown, path: string): string[] {\n if (!Array.isArray(value) || value.length === 0) {\n throw new Error(`${path} must be a non-empty string array`);\n }\n return value.map((item, index) => {\n return parseNonEmptyString(item, `${path}[${index}]`);\n });\n}\n\nfunction parseTextMatcher(\n field: GmailTextField,\n value: unknown,\n): GmailTextMatcher {\n if (!isRecord(value)) {\n throw new Error(`${formatFieldName(field)} must be an object`);\n }\n\n const matcher: {\n contains?: string;\n containsAny?: string[];\n doesNotContain?: string;\n doesNotContainAny?: string[];\n } = {};\n\n for (const key of Object.keys(value)) {\n switch (key) {\n case \"contains\":\n matcher.contains = parseNonEmptyString(\n value[key],\n `${formatFieldName(field)}.contains`,\n );\n break;\n case \"containsAny\":\n matcher.containsAny = parseNonEmptyStringArray(\n value[key],\n `${formatFieldName(field)}.containsAny`,\n );\n break;\n case \"doesNotContain\":\n matcher.doesNotContain = parseNonEmptyString(\n value[key],\n `${formatFieldName(field)}.doesNotContain`,\n );\n break;\n case \"doesNotContainAny\":\n matcher.doesNotContainAny = parseNonEmptyStringArray(\n value[key],\n `${formatFieldName(field)}.doesNotContainAny`,\n );\n break;\n default:\n throw new Error(\n `Unsupported Gmail automation text matcher \"${key}\" for ${formatFieldName(field)}`,\n );\n }\n }\n\n if (\n matcher.contains === undefined &&\n matcher.containsAny === undefined &&\n matcher.doesNotContain === undefined &&\n matcher.doesNotContainAny === undefined\n ) {\n throw new Error(\n `${formatFieldName(field)} must include at least one text matcher`,\n );\n }\n\n return matcher;\n}\n\nfunction parseMatch(value: unknown): GmailMatchRules | undefined {\n if (value === undefined) {\n return undefined;\n }\n if (!isRecord(value)) {\n throw new Error(\"match must be an object\");\n }\n\n const match: GmailMatchRules = {};\n for (const key of Object.keys(value)) {\n const field = textFieldFromKey(key);\n if (field === null) {\n throw new Error(\n `Unsupported Gmail automation match field \"${key}\". Supported fields: from, subject, body, to, cc`,\n );\n }\n match[field] = parseTextMatcher(field, value[key]);\n }\n\n return Object.keys(match).length > 0 ? match : undefined;\n}\n\nfunction readConfigMatch(path: string): GmailMatchRules | undefined {\n let parsed: unknown;\n try {\n parsed = JSON.parse(readFileSync(path, \"utf-8\"));\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n throw new Error(\n `Failed to read Gmail automation config \"${path}\": ${message}`,\n );\n }\n\n if (!isRecord(parsed)) {\n throw new Error(\"Gmail automation config must be a JSON object\");\n }\n\n for (const key of Object.keys(parsed)) {\n if (key !== \"match\") {\n throw new Error(\n `Unsupported Gmail automation config field \"${key}\". Use a top-level match object`,\n );\n }\n }\n\n return parseMatch(parsed.match);\n}\n\nfunction textFlagSpecs(\n options: GmailAutomationOptions,\n): readonly TextFlagSpec[] {\n return [\n {\n field: \"from\",\n contains: options.fromContains,\n doesNotContain: options.fromNotContains,\n },\n {\n field: \"subject\",\n contains: options.subjectContains,\n doesNotContain: options.subjectNotContains,\n },\n {\n field: \"body\",\n contains: options.bodyContains,\n doesNotContain: options.bodyNotContains,\n },\n {\n field: \"to\",\n contains: options.toContains,\n doesNotContain: options.toNotContains,\n },\n {\n field: \"cc\",\n contains: options.ccContains,\n doesNotContain: options.ccNotContains,\n },\n ];\n}\n\nexport function hasGmailAutomationOptions(\n options: GmailAutomationOptions,\n): boolean {\n return (\n options.config !== undefined ||\n textFlagSpecs(options).some((spec) => {\n return spec.contains !== undefined || spec.doesNotContain !== undefined;\n })\n );\n}\n\nexport function hasGmailLabelOption(options: GmailAutomationOptions): boolean {\n return options.label !== undefined;\n}\n\nfunction buildMatchFromFlags(\n options: GmailAutomationOptions,\n): GmailMatchRules | undefined {\n const match: GmailMatchRules = {};\n for (const spec of textFlagSpecs(options)) {\n const matcher: { contains?: string; doesNotContain?: string } = {};\n if (spec.contains !== undefined) {\n if (spec.contains.length === 0) {\n throw new Error(\n `${formatFieldName(spec.field)} contains must be non-empty`,\n );\n }\n matcher.contains = spec.contains;\n }\n if (spec.doesNotContain !== undefined) {\n if (spec.doesNotContain.length === 0) {\n throw new Error(\n `${formatFieldName(spec.field)} doesNotContain must be non-empty`,\n );\n }\n matcher.doesNotContain = spec.doesNotContain;\n }\n if (\n matcher.contains !== undefined ||\n matcher.doesNotContain !== undefined\n ) {\n match[spec.field] = matcher;\n }\n }\n return Object.keys(match).length > 0 ? match : undefined;\n}\n\nexport function buildGmailNewMessageEventConfig(\n options: GmailAutomationOptions,\n): GmailNewMessageEventConfig {\n if (\n options.config !== undefined &&\n textFlagSpecs(options).some((spec) => {\n return spec.contains !== undefined || spec.doesNotContain !== undefined;\n })\n ) {\n throw new Error(\"Use either --config or Gmail text match flags, not both\");\n }\n\n const match =\n options.config !== undefined\n ? readConfigMatch(options.config)\n : buildMatchFromFlags(options);\n\n return match\n ? { provider: \"gmail\", event: \"new_message\", match }\n : { provider: \"gmail\", event: \"new_message\" };\n}\n\nexport function buildGmailLabelAppliedEventConfig(\n options: GmailAutomationOptions,\n): GmailLabelAppliedEventConfig {\n const labelName = options.label?.trim();\n if (!labelName) {\n throw new Error(\n 'gmail-label-applied automations require --label \"Label name\"',\n );\n }\n return { provider: \"gmail\", event: \"label_applied\", labelName };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;ACAA;AAEA,SAAS,gBAAAA,qBAAoB;;;ACF7B;AAAA,SAAS,cAAc,mBAAmB;AAC1C,SAAS,YAAY;AAErB,IAAM,gBAAgB,oBAAI,IAAI,CAAC,gBAAgB,QAAQ,WAAW,CAAC;AAS5D,SAAS,uBACd,SAC0C;AAC1C,QAAM,QAAkD,CAAC;AAEzD,WAAS,KAAK,KAAa,QAAgB;AACzC,UAAM,UAAU,YAAY,KAAK,EAAE,eAAe,KAAK,CAAC;AACxD,eAAW,SAAS,SAAS;AAC3B,UAAI,MAAM,KAAK,WAAW,GAAG,KAAK,cAAc,IAAI,MAAM,IAAI,EAAG;AAEjE,YAAM,UAAU,SAAS,GAAG,MAAM,IAAI,MAAM,IAAI,KAAK,MAAM;AAC3D,UAAI,MAAM,YAAY,GAAG;AACvB,aAAK,KAAK,KAAK,MAAM,IAAI,GAAG,OAAO;AAAA,MACrC,OAAO;AACL,YAAI,YAAY,YAAY;AAC1B,gBAAM,IAAI;AAAA,YACR;AAAA,UACF;AAAA,QACF;AACA,c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ACd,YAAY,+BAA+B,EAC3C,SAAS,gBAAgB,wBAAwB,EACjD;AAAA,EACC,iBAAiB,OAAO,OAAe;AACrC,UAAM,aAAa,MAAM,0BAA0B,EAAE;AACrD,YAAQ,IAAI,eAAM,MAAM,qBAAgB,WAAW,EAAE,WAAW,CAAC;AAAA,EACnE,CAAC;AACH;AAEK,IAAM,oBAAoB,IAAI,QAAQ,EAC1C,KAAK,YAAY,EACjB,YAAY,iCAAiC,EAC7C,WAAW,UAAU,EACrB,WAAW,aAAa,EACxB,WAAWA,YAAW,EACtB,WAAW,WAAW,EACtB,WAAW,SAAS,EACpB,WAAW,aAAa,EACxB,WAAW,cAAc,EACzB;AAAA,EACC;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASF;;;Ab3uCK,IAAM,sBAAsB,IAAI,QAAQ,UAAU,EACtD,YAAY,kBAAkB,EAC9B,WAAW,aAAa,EACxB,WAAW,WAAW,EACtB,WAAW,WAAW,EACtB,WAAW,WAAW,EACtB,WAAW,aAAa,EACxB,WAAW,WAAW,EACtB,WAAW,iBAAiB,EAC5B;AAAA,EACC;AAAA,EACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASF;","names":["readFileSync","readFileSync","readFileSync","readFileSync","readFileSync","listCommand"]}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|