@oxygen-agent/cli 1.1014.1895 → 1.1014.1997
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/README.md +1 -1
- package/dist/auto-update.d.ts +1 -1
- package/dist/auto-update.js +3 -3
- package/dist/cli-install.d.ts +65 -0
- package/dist/cli-install.js +165 -0
- package/dist/commands/billing.js +1 -1
- package/dist/commands/managed-inboxes.js +6 -2
- package/dist/commands/sequences.js +1 -1
- package/dist/commands/subscriptions.js +7 -5
- package/dist/update.d.ts +4 -57
- package/dist/update.js +17 -163
- package/node_modules/@oxygen/shared/dist/billing.d.ts +5 -1
- package/node_modules/@oxygen/shared/dist/billing.js +5 -1
- package/node_modules/@oxygen/shared/dist/capability-discovery-skill-audiences.generated.d.ts +30 -0
- package/node_modules/@oxygen/shared/dist/capability-discovery-skill-audiences.generated.js +33 -0
- package/node_modules/@oxygen/shared/dist/capability-discovery-skills.d.ts +39 -0
- package/node_modules/@oxygen/shared/dist/capability-discovery-skills.js +86 -0
- package/node_modules/@oxygen/shared/dist/capability-discovery-types.d.ts +93 -0
- package/node_modules/@oxygen/shared/dist/capability-discovery-types.js +1 -0
- package/node_modules/@oxygen/shared/dist/capability-discovery.d.ts +12 -270
- package/node_modules/@oxygen/shared/dist/capability-discovery.js +123 -3712
- package/node_modules/@oxygen/shared/dist/capability-intents/agency-directory.rules.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/agency-directory.rules.js +5 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/agents.d.ts +10 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/agents.js +53 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/agents.rules.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/agents.rules.js +25 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/billing-and-budgets.d.ts +31 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/billing-and-budgets.js +70 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/billing-and-budgets.rules.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/billing-and-budgets.rules.js +85 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/collaboration.d.ts +9 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/collaboration.js +54 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/collaboration.rules.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/collaboration.rules.js +28 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/connected-integrations.rules.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/connected-integrations.rules.js +23 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/connected-linkedin.d.ts +43 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/connected-linkedin.js +90 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/connected-linkedin.rules.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/connected-linkedin.rules.js +58 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/connected-whatsapp.rules.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/connected-whatsapp.rules.js +14 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/geo.rules.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/geo.rules.js +9 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/index.generated.d.ts +365 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/index.generated.js +90 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/knowledge-graph.d.ts +20 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/knowledge-graph.js +37 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/knowledge-graph.rules.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/knowledge-graph.rules.js +43 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/linkedin-public-research.d.ts +4 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/linkedin-public-research.js +26 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/linkedin-public-research.rules.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/linkedin-public-research.rules.js +42 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/messages.d.ts +6 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/messages.js +16 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/messages.rules.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/messages.rules.js +68 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/normalize.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/normalize.js +4 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/platform-operations.d.ts +6 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/platform-operations.js +23 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/platform-operations.rules.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/platform-operations.rules.js +25 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/posts.d.ts +1 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/posts.js +12 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/posts.rules.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/posts.rules.js +20 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/publishing.d.ts +86 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/publishing.js +135 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/publishing.rules.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/publishing.rules.js +89 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/read-inspection.d.ts +7 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/read-inspection.js +85 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/read-inspection.rules.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/read-inspection.rules.js +28 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/recipes.d.ts +7 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/recipes.js +73 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/recipes.rules.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/recipes.rules.js +36 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/records.d.ts +86 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/records.js +240 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/records.rules.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/records.rules.js +71 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/sending-infrastructure.d.ts +27 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/sending-infrastructure.js +67 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/sending-infrastructure.rules.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/sending-infrastructure.rules.js +115 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/sequences.d.ts +71 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/sequences.js +150 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/sequences.rules.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/sequences.rules.js +149 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/signals.d.ts +42 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/signals.js +42 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/signals.rules.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/signals.rules.js +47 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/sourcing-and-provider-tools.d.ts +60 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/sourcing-and-provider-tools.js +94 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/sourcing-and-provider-tools.rules.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/sourcing-and-provider-tools.rules.js +94 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/tables.d.ts +196 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/tables.js +394 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/tables.rules.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/tables.rules.js +384 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/tags.rules.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/tags.rules.js +5 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/visual-rendering.rules.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/visual-rendering.rules.js +8 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/workflows.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/workflows.js +20 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/workflows.rules.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/workflows.rules.js +90 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/workspace-access.d.ts +59 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/workspace-access.js +121 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/workspace-access.rules.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-intents/workspace-access.rules.js +58 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/ads.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/ads.js +17 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/agency-directory.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/agency-directory.js +17 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/agents.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/agents.js +17 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/billing-and-budgets.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/billing-and-budgets.js +17 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/collaboration.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/collaboration.js +39 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/connected-integrations.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/connected-integrations.js +17 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/connected-linkedin.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/connected-linkedin.js +17 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/connected-whatsapp.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/connected-whatsapp.js +17 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/dashboards.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/dashboards.js +28 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/discovery-and-skills.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/discovery-and-skills.js +22 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/geo.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/geo.js +13 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/index.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/index.js +64 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/knowledge-graph.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/knowledge-graph.js +17 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/linkedin-public-research.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/linkedin-public-research.js +18 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/messages.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/messages.js +21 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/observability.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/observability.js +17 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/onboarding-and-copilot.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/onboarding-and-copilot.js +23 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/platform-operations.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/platform-operations.js +17 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/posts.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/posts.js +17 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/publishing.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/publishing.js +20 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/recipes.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/recipes.js +17 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/records.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/records.js +20 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/sending-infrastructure.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/sending-infrastructure.js +42 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/sequences.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/sequences.js +32 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/signals.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/signals.js +17 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/sourcing-and-provider-tools.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/sourcing-and-provider-tools.js +21 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/support-and-feedback.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/support-and-feedback.js +17 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/tables.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/tables.js +34 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/tags.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/tags.js +17 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/visual-rendering.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/visual-rendering.js +17 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/workflows.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/workflows.js +17 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/workspace-access.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-routes/workspace-access.js +26 -0
- package/node_modules/@oxygen/shared/dist/contracts/connectors.js +2 -0
- package/node_modules/@oxygen/shared/dist/contracts/customer-operations.d.ts +1 -1
- package/node_modules/@oxygen/shared/dist/contracts/operations/agent-sessions.d.ts +1 -0
- package/node_modules/@oxygen/shared/dist/contracts/operations/agent-sessions.js +1 -0
- package/node_modules/@oxygen/shared/dist/contracts/operations/browser.d.ts +1 -0
- package/node_modules/@oxygen/shared/dist/contracts/operations/browser.js +1 -0
- package/node_modules/@oxygen/shared/dist/contracts/operations/clay-migration.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/contracts/operations/clay-migration.js +2 -0
- package/node_modules/@oxygen/shared/dist/contracts/operations/connectors.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/contracts/operations/connectors.js +2 -0
- package/node_modules/@oxygen/shared/dist/contracts/operations/geo.d.ts +1 -0
- package/node_modules/@oxygen/shared/dist/contracts/operations/geo.js +1 -0
- package/node_modules/@oxygen/shared/dist/contracts/operations/guided-activation.d.ts +1 -0
- package/node_modules/@oxygen/shared/dist/contracts/operations/guided-activation.js +1 -0
- package/node_modules/@oxygen/shared/dist/contracts/operations/index.generated.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/contracts/operations/index.generated.js +26 -0
- package/node_modules/@oxygen/shared/dist/contracts/operations/reply-oxygent.d.ts +1 -0
- package/node_modules/@oxygen/shared/dist/contracts/operations/reply-oxygent.js +1 -0
- package/node_modules/@oxygen/shared/dist/contracts/operations/sender-limits.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/contracts/operations/sender-limits.js +2 -0
- package/node_modules/@oxygen/shared/dist/contracts/operations/table-feed-update.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/contracts/operations/table-feed-update.js +2 -0
- package/node_modules/@oxygen/shared/dist/contracts/operations/teammates.d.ts +1 -0
- package/node_modules/@oxygen/shared/dist/contracts/operations/teammates.js +1 -0
- package/node_modules/@oxygen/shared/dist/contracts/operations/workspace-pages.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/contracts/operations/workspace-pages.js +2 -0
- package/node_modules/@oxygen/shared/dist/contracts/operations/workspace-skills.d.ts +1 -0
- package/node_modules/@oxygen/shared/dist/contracts/operations/workspace-skills.js +1 -0
- package/node_modules/@oxygen/shared/dist/contracts/operations.d.ts +6 -0
- package/node_modules/@oxygen/shared/dist/contracts/operations.js +7 -15
- package/node_modules/@oxygen/shared/dist/contracts/sender-limits.js +1 -0
- package/node_modules/@oxygen/shared/dist/diagnostic-storage-lock.js +33 -22
- package/node_modules/@oxygen/shared/dist/diagnostics.js +11 -8
- package/node_modules/@oxygen/shared/dist/first-month-offer-window.d.ts +3 -0
- package/node_modules/@oxygen/shared/dist/first-month-offer.d.ts +15 -7
- package/node_modules/@oxygen/shared/dist/first-month-offer.js +23 -9
- package/node_modules/@oxygen/shared/dist/guided-activation.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/listed-website-platforms.d.ts +1 -1
- package/node_modules/@oxygen/shared/dist/listed-website-platforms.js +23 -1
- package/node_modules/@oxygen/shared/dist/onboarding-leads.d.ts +67 -0
- package/node_modules/@oxygen/shared/dist/onboarding-leads.js +78 -0
- package/node_modules/@oxygen/shared/dist/otlp-log-sink.js +20 -0
- package/node_modules/@oxygen/shared/dist/plan-capabilities.js +1 -1
- package/node_modules/@oxygen/shared/dist/plan-limits.d.ts +2 -2
- package/node_modules/@oxygen/shared/dist/plan-limits.js +6 -7
- package/node_modules/@oxygen/shared/dist/sending-domain-faults.d.ts +1 -1
- package/node_modules/@oxygen/shared/dist/sending-domain-faults.js +1 -1
- package/node_modules/@oxygen/shared/dist/tenant-migration-names.d.ts +5 -0
- package/node_modules/@oxygen/shared/dist/tenant-migration-names.js +8 -0
- package/node_modules/@oxygen/shared/dist/version.generated.d.ts +1 -1
- package/node_modules/@oxygen/shared/dist/version.generated.js +1 -1
- package/node_modules/@oxygen/workflows/dist/graph/lint.d.ts +1 -1
- package/node_modules/@oxygen/workflows/dist/graph/lint.js +4 -3
- package/node_modules/@oxygen/workflows/dist/index.d.ts +2 -59
- package/node_modules/@oxygen/workflows/dist/index.js +4 -904
- package/node_modules/@oxygen/workflows/dist/manifest-validation.d.ts +75 -0
- package/node_modules/@oxygen/workflows/dist/manifest-validation.js +903 -0
- package/package.json +1 -1
|
@@ -0,0 +1,903 @@
|
|
|
1
|
+
export const WORKFLOW_MANIFEST_VERSION = 1;
|
|
2
|
+
export const DURABLE_RECIPE_COMPILER_VERSION = "oxygen-recipes-v2";
|
|
3
|
+
export const MAX_RECIPE_BUNDLE_BYTES = 2_000_000;
|
|
4
|
+
// Compatibility and determinism lint only. The Vercel sandbox process,
|
|
5
|
+
// denied network policy, and runtime global guards are the security boundary.
|
|
6
|
+
const UNSAFE_RECIPE_BUNDLE_PATTERNS = [
|
|
7
|
+
{ token: "globalThis", pattern: /\bglobalThis\b/ }, // skipcq: SCT-A000
|
|
8
|
+
{ token: "global", pattern: /\bglobal\b/ },
|
|
9
|
+
{ token: "process", pattern: /\bprocess\b/ },
|
|
10
|
+
{ token: "fetch", pattern: /\bfetch\b/ },
|
|
11
|
+
{ token: "XMLHttpRequest", pattern: /\bXMLHttpRequest\b/ }, // skipcq: SCT-A000
|
|
12
|
+
{ token: "WebSocket", pattern: /\bWebSocket\b/ },
|
|
13
|
+
{ token: "EventSource", pattern: /\bEventSource\b/ }, // skipcq: SCT-A000
|
|
14
|
+
// Block CommonJS require(...) but allow a `.require` method access (the
|
|
15
|
+
// ctx.approvals.require() durable-approval API). A real global require is a
|
|
16
|
+
// bare identifier; any X.require on a dangerous global (globalThis/process/…)
|
|
17
|
+
// is already caught by that global's own rule above.
|
|
18
|
+
{ token: "require", pattern: /(?<!\.)\brequire\b/ },
|
|
19
|
+
{ token: "dynamic import", pattern: /\bimport(?:\s|\/\*[\s\S]*?\*\/)*\(/ }, // skipcq: SCT-A000
|
|
20
|
+
{ token: "node module import", pattern: /\b(?:node:)?(?:fs|child_process|net|tls|http|https|dns|dgram|worker_threads)\b/ }, // skipcq: SCT-A000
|
|
21
|
+
{ token: "eval", pattern: /\beval\b/ },
|
|
22
|
+
{ token: "Function", pattern: /\bFunction\b/ },
|
|
23
|
+
{ token: "constructor", pattern: /\bconstructor\b/ },
|
|
24
|
+
{ token: "Date.now", pattern: /\bDate\s*\.\s*now\b/ },
|
|
25
|
+
{ token: "new Date", pattern: /\bnew\s+Date\b/ },
|
|
26
|
+
{ token: "Math.random", pattern: /\bMath\s*\.\s*random\b/ },
|
|
27
|
+
{ token: "crypto.randomUUID", pattern: /\bcrypto\s*\.\s*randomUUID\b/ },
|
|
28
|
+
{ token: "setTimeout", pattern: /\bsetTimeout\b/ },
|
|
29
|
+
{ token: "setInterval", pattern: /\bsetInterval\b/ }, // skipcq: SCT-A000
|
|
30
|
+
];
|
|
31
|
+
// Code v1 has no ctx.now()/ctx.uuid() capability and runs as a pure transform,
|
|
32
|
+
// so its determinism/capability denylist is intentionally stricter than the
|
|
33
|
+
// durable-recipe compatibility scan above. Keep this separate: old immutable
|
|
34
|
+
// recipe revisions must not acquire new lint failures merely because Code v1 is
|
|
35
|
+
// introduced.
|
|
36
|
+
const UNSAFE_WORKFLOW_CODE_SOURCE_PATTERNS = [
|
|
37
|
+
...UNSAFE_RECIPE_BUNDLE_PATTERNS,
|
|
38
|
+
{ token: "Date", pattern: /\bDate\b/ },
|
|
39
|
+
{ token: "WebAssembly", pattern: /\bWebAssembly\b/ },
|
|
40
|
+
{ token: "setImmediate", pattern: /\bsetImmediate\b/ },
|
|
41
|
+
{ token: "queueMicrotask", pattern: /\bqueueMicrotask\b/ },
|
|
42
|
+
];
|
|
43
|
+
/** A valid workflow / recipe / trigger status. Optional everywhere it appears. */
|
|
44
|
+
export function isValidWorkflowStatus(value) {
|
|
45
|
+
return value === "active" || value === "disabled";
|
|
46
|
+
}
|
|
47
|
+
// Shared positive-finite validator for the optional per-run / per-step
|
|
48
|
+
// max_credits caps (Gap 2). `undefined` is valid (no cap); anything else must be
|
|
49
|
+
// a positive finite number, or lint rejects the manifest.
|
|
50
|
+
// Exported for ./graph/lint.ts so the v2 graph linter enforces the same rule as
|
|
51
|
+
// v1 rather than a second copy of it. Not part of the product surface.
|
|
52
|
+
export function validateOptionalMaxCredits(value, path, add) {
|
|
53
|
+
if (value === undefined)
|
|
54
|
+
return;
|
|
55
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
|
|
56
|
+
add(path, "invalid_max_credits", "max_credits must be a positive number.");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
export function lintRecipeManifest(// skipcq: JS-R1005
|
|
60
|
+
value, options = {}) {
|
|
61
|
+
const issues = [];
|
|
62
|
+
const add = (path, code, message) => issues.push({ path, code, message });
|
|
63
|
+
if (!isRecord(value)) {
|
|
64
|
+
add("$", "invalid_manifest", "Recipe manifest must be an object.");
|
|
65
|
+
return { ok: false, issues };
|
|
66
|
+
}
|
|
67
|
+
if (value.manifest_version !== WORKFLOW_MANIFEST_VERSION) {
|
|
68
|
+
add("$.manifest_version", "invalid_manifest_version", "Recipe manifest version must be 1.");
|
|
69
|
+
}
|
|
70
|
+
if (value.compiler_version !== DURABLE_RECIPE_COMPILER_VERSION) {
|
|
71
|
+
add("$.compiler_version", "invalid_compiler_version", `Recipe manifest compiler_version must be '${DURABLE_RECIPE_COMPILER_VERSION}'.`);
|
|
72
|
+
}
|
|
73
|
+
const workflow = value.workflow;
|
|
74
|
+
if (!isRecord(workflow)) {
|
|
75
|
+
add("$.workflow", "missing_workflow", "Recipe metadata is required.");
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
if (!isNonEmptyString(workflow.id))
|
|
79
|
+
add("$.workflow.id", "invalid_workflow_id", "Recipe id is required.");
|
|
80
|
+
if (!isNonEmptyString(workflow.name))
|
|
81
|
+
add("$.workflow.name", "invalid_workflow_name", "Recipe name is required.");
|
|
82
|
+
if (workflow.status !== undefined && !isValidWorkflowStatus(workflow.status)) {
|
|
83
|
+
add("$.workflow.status", "invalid_workflow_status", "Recipe status must be active or disabled.");
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (value.trigger !== undefined)
|
|
87
|
+
validateTrigger(value.trigger, "$.trigger", add);
|
|
88
|
+
if (value.configuration_schema !== undefined && !isRecord(value.configuration_schema)) {
|
|
89
|
+
add("$.configuration_schema", "invalid_configuration_schema", "Recipe configuration_schema must be a JSON Schema object.");
|
|
90
|
+
}
|
|
91
|
+
if (value.configuration !== undefined && !isRecord(value.configuration)) {
|
|
92
|
+
add("$.configuration", "invalid_configuration", "Recipe configuration must be an object.");
|
|
93
|
+
}
|
|
94
|
+
else if (isRecord(value.configuration_schema)) {
|
|
95
|
+
for (const issue of validateJsonSchemaValue(isRecord(value.configuration) ? value.configuration : {}, value.configuration_schema, "$.configuration")) {
|
|
96
|
+
add(issue.path, issue.code, issue.message);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (!isNonEmptyString(value.bundle)) {
|
|
100
|
+
add("$.bundle", "missing_bundle", "Recipe bundle is required.");
|
|
101
|
+
}
|
|
102
|
+
else if (Buffer.byteLength(value.bundle, "utf8") > MAX_RECIPE_BUNDLE_BYTES) {
|
|
103
|
+
add("$.bundle", "bundle_too_large", "Recipe bundle exceeds the maximum allowed size.");
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
validateRecipeBundleSafety(value.bundle, "$.bundle", add);
|
|
107
|
+
}
|
|
108
|
+
if (value.bundle_format !== "esm") {
|
|
109
|
+
add("$.bundle_format", "invalid_bundle_format", "Recipe bundle_format must be 'esm'.");
|
|
110
|
+
}
|
|
111
|
+
validateOptionalMaxCredits(value.max_credits, "$.max_credits", add);
|
|
112
|
+
if (value.runtime !== "durable") {
|
|
113
|
+
add("$.runtime", "invalid_recipe_runtime", "Durable recipe manifests must set runtime to durable.");
|
|
114
|
+
}
|
|
115
|
+
if (Array.isArray(value.tools_used)) {
|
|
116
|
+
value.tools_used.forEach((toolId, index) => {
|
|
117
|
+
if (typeof toolId !== "string" || !toolId.trim()) {
|
|
118
|
+
add(`$.tools_used.${index}`, "invalid_tool_id", "Recipe tools_used entries must be non-empty strings.");
|
|
119
|
+
}
|
|
120
|
+
else if (isWorkflowToolRejected(toolId)) {
|
|
121
|
+
add(`$.tools_used.${index}`, "unsupported_workflow_tool", `Tool '${toolId}' is not allowed in durable recipes.`);
|
|
122
|
+
}
|
|
123
|
+
else if (options.isToolAllowed && !options.isToolAllowed(toolId)) {
|
|
124
|
+
add(`$.tools_used.${index}`, "tool_not_allowed", `Tool '${toolId}' is not available for durable recipes.`);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
else if (value.tools_used !== undefined) {
|
|
129
|
+
add("$.tools_used", "invalid_tools_used", "Recipe tools_used must be an array of tool ids.");
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
add("$.tools_used", "missing_recipe_tools", "Durable recipe manifests must declare tools_used (use [] for pure recipes).");
|
|
133
|
+
}
|
|
134
|
+
const declaredTools = Array.isArray(value.tools_used)
|
|
135
|
+
? new Set(value.tools_used.filter((toolId) => typeof toolId === "string" && toolId.trim().length > 0))
|
|
136
|
+
: new Set();
|
|
137
|
+
if (value.visual_plan !== undefined) {
|
|
138
|
+
validateRecipeVisualPlan(value.visual_plan, "$.visual_plan", declaredTools, add);
|
|
139
|
+
}
|
|
140
|
+
if (!isNonEmptyString(value.source_hash)) {
|
|
141
|
+
add("$.source_hash", "missing_source_hash", "Recipe manifest source_hash is required.");
|
|
142
|
+
}
|
|
143
|
+
return { ok: issues.length === 0, issues };
|
|
144
|
+
}
|
|
145
|
+
function validateRecipeVisualPlan(value, path, declaredTools, add) {
|
|
146
|
+
if (!isRecord(value)) {
|
|
147
|
+
add(path, "invalid_visual_plan", "Recipe visual_plan must be an object.");
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
if (value.version !== 1) {
|
|
151
|
+
add(`${path}.version`, "invalid_visual_plan_version", "Recipe visual_plan version must be 1.");
|
|
152
|
+
}
|
|
153
|
+
if (!Array.isArray(value.steps)) {
|
|
154
|
+
add(`${path}.steps`, "invalid_visual_plan_steps", "Recipe visual_plan steps must be an array.");
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
if (value.steps.length === 0) {
|
|
158
|
+
add(`${path}.steps`, "missing_visual_plan_steps", "Recipe visual_plan must declare at least one step.");
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const idToIndex = new Map();
|
|
162
|
+
value.steps.forEach((step, index) => {
|
|
163
|
+
if (isRecord(step) && isNonEmptyString(step.id) && !idToIndex.has(step.id)) {
|
|
164
|
+
idToIndex.set(step.id, index);
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
const ids = new Set();
|
|
168
|
+
value.steps.forEach((step, index) => {
|
|
169
|
+
const stepPath = `${path}.steps.${index}`;
|
|
170
|
+
if (!isRecord(step)) {
|
|
171
|
+
add(stepPath, "invalid_visual_plan_step", "Recipe visual_plan step must be an object.");
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
if (!isNonEmptyString(step.id)) {
|
|
175
|
+
add(`${stepPath}.id`, "invalid_visual_plan_step_id", "Recipe visual_plan step id is required.");
|
|
176
|
+
}
|
|
177
|
+
else if (ids.has(step.id)) {
|
|
178
|
+
add(`${stepPath}.id`, "duplicate_visual_plan_step_id", `Recipe visual_plan step id '${step.id}' is duplicated.`);
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
ids.add(step.id);
|
|
182
|
+
}
|
|
183
|
+
if (!isNonEmptyString(step.label)) {
|
|
184
|
+
add(`${stepPath}.label`, "invalid_visual_plan_step_label", "Recipe visual_plan step label is required.");
|
|
185
|
+
}
|
|
186
|
+
if (step.description !== undefined && typeof step.description !== "string") {
|
|
187
|
+
add(`${stepPath}.description`, "invalid_visual_plan_description", "Recipe visual_plan description must be a string.");
|
|
188
|
+
}
|
|
189
|
+
if (step.checkpoint_id !== undefined && !isNonEmptyString(step.checkpoint_id)) {
|
|
190
|
+
add(`${stepPath}.checkpoint_id`, "invalid_visual_plan_checkpoint", "Recipe visual_plan checkpoint_id must be a non-empty string.");
|
|
191
|
+
}
|
|
192
|
+
if (step.kind === "tool") {
|
|
193
|
+
if (!isNonEmptyString(step.tool)) {
|
|
194
|
+
add(`${stepPath}.tool`, "missing_visual_plan_tool", "Recipe visual_plan tool step requires a tool id.");
|
|
195
|
+
}
|
|
196
|
+
else if (!declaredTools.has(step.tool)) {
|
|
197
|
+
add(`${stepPath}.tool`, "visual_plan_tool_not_declared", `Recipe visual_plan tool '${step.tool}' must be present in tools_used.`);
|
|
198
|
+
}
|
|
199
|
+
if (step.effect !== undefined
|
|
200
|
+
&& step.effect !== "none"
|
|
201
|
+
&& step.effect !== "external_read"
|
|
202
|
+
&& step.effect !== "external_write") {
|
|
203
|
+
add(`${stepPath}.effect`, "invalid_visual_plan_effect", "Recipe visual_plan tool effect is invalid.");
|
|
204
|
+
}
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
if (step.kind === "step")
|
|
208
|
+
return;
|
|
209
|
+
if (step.kind === "branch") {
|
|
210
|
+
if (step.condition_label !== undefined && typeof step.condition_label !== "string") {
|
|
211
|
+
add(`${stepPath}.condition_label`, "invalid_visual_plan_condition", "Recipe visual_plan condition_label must be a string.");
|
|
212
|
+
}
|
|
213
|
+
validateBranchTarget(step.then_id, `${stepPath}.then_id`, "then_id", index, idToIndex, add);
|
|
214
|
+
if (step.else_id !== undefined) {
|
|
215
|
+
validateBranchTarget(step.else_id, `${stepPath}.else_id`, "else_id", index, idToIndex, add);
|
|
216
|
+
}
|
|
217
|
+
if (step.join_id !== undefined) {
|
|
218
|
+
validateBranchTarget(step.join_id, `${stepPath}.join_id`, "join_id", index, idToIndex, add);
|
|
219
|
+
}
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
add(`${stepPath}.kind`, "invalid_visual_plan_step_kind", "Recipe visual_plan step kind must be tool, step, or branch.");
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
export function validateJsonSchemaValue(value, schema, path = "$", maxIssues = Number.POSITIVE_INFINITY, maxVisits = Number.POSITIVE_INFINITY) {
|
|
226
|
+
if (!schema || typeof schema !== "object" || Array.isArray(schema))
|
|
227
|
+
return [];
|
|
228
|
+
const issues = [];
|
|
229
|
+
const budget = {
|
|
230
|
+
visits: 0,
|
|
231
|
+
maximum: Math.max(1, Math.floor(maxVisits)),
|
|
232
|
+
exhausted: false,
|
|
233
|
+
};
|
|
234
|
+
validateJsonSchemaValueInto(value, schema, path, issues, Math.max(1, Math.floor(maxIssues)), budget);
|
|
235
|
+
if (budget.exhausted) {
|
|
236
|
+
return [{
|
|
237
|
+
path,
|
|
238
|
+
code: "schema_validation_too_complex",
|
|
239
|
+
message: `${path} exceeded the JSON Schema validation work limit.`,
|
|
240
|
+
}];
|
|
241
|
+
}
|
|
242
|
+
return issues;
|
|
243
|
+
}
|
|
244
|
+
function consumeJsonSchemaValidationBudget(budget, amount = 1) {
|
|
245
|
+
if (budget.exhausted)
|
|
246
|
+
return false;
|
|
247
|
+
budget.visits += amount;
|
|
248
|
+
if (budget.visits <= budget.maximum)
|
|
249
|
+
return true;
|
|
250
|
+
budget.exhausted = true;
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
/** Comment/string-aware author feedback for the stricter oxygen-js-v1 runtime. */
|
|
254
|
+
export function lintWorkflowCodeSourceSafety(source, path = "$.source") {
|
|
255
|
+
const issues = [];
|
|
256
|
+
if (!source.trim()) {
|
|
257
|
+
issues.push({ path, code: "empty_function_source", message: "Typed code source cannot be empty." });
|
|
258
|
+
return issues;
|
|
259
|
+
}
|
|
260
|
+
const scan = stripCommentsAndStrings(source);
|
|
261
|
+
if (scan.ambiguousSlash) {
|
|
262
|
+
return [{ path, code: "unsafe_code_source", message: "Typed code source has an ambiguous slash after a brace. Parenthesize the expression or separate statements with a semicolon." }];
|
|
263
|
+
}
|
|
264
|
+
const scannable = scan.source;
|
|
265
|
+
for (const entry of UNSAFE_WORKFLOW_CODE_SOURCE_PATTERNS) {
|
|
266
|
+
if (!entry.pattern.test(scannable))
|
|
267
|
+
continue;
|
|
268
|
+
issues.push({
|
|
269
|
+
path,
|
|
270
|
+
code: "unsafe_code_source",
|
|
271
|
+
message: `Typed code source cannot reference '${entry.token}'. Bind deterministic JSON inputs and use explicit Tool nodes for capabilities.`,
|
|
272
|
+
});
|
|
273
|
+
break;
|
|
274
|
+
}
|
|
275
|
+
return issues;
|
|
276
|
+
}
|
|
277
|
+
function validateJsonSchemaValueInto(// skipcq: JS-R1005
|
|
278
|
+
value, schema, path, issues, maxIssues, budget) {
|
|
279
|
+
if (issues.length >= maxIssues || budget.exhausted)
|
|
280
|
+
return;
|
|
281
|
+
if (!consumeJsonSchemaValidationBudget(budget))
|
|
282
|
+
return;
|
|
283
|
+
const startCount = issues.length;
|
|
284
|
+
if (schema.const !== undefined && !jsonEqual(value, schema.const, budget)) {
|
|
285
|
+
addJsonSchemaValidationIssue(issues, maxIssues, {
|
|
286
|
+
path,
|
|
287
|
+
code: "schema_const_mismatch",
|
|
288
|
+
message: `${path} must equal the schema const value.`,
|
|
289
|
+
});
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
if (Array.isArray(schema.enum)
|
|
293
|
+
&& schema.enum.length > 0
|
|
294
|
+
&& !schema.enum.some((entry) => budget.exhausted || jsonEqual(value, entry, budget))) {
|
|
295
|
+
addJsonSchemaValidationIssue(issues, maxIssues, {
|
|
296
|
+
path,
|
|
297
|
+
code: "schema_enum_mismatch",
|
|
298
|
+
message: `${path} must be one of the allowed values.`,
|
|
299
|
+
});
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
if (Array.isArray(schema.anyOf) && schema.anyOf.length > 0) {
|
|
303
|
+
const matched = schema.anyOf.some((candidate) => {
|
|
304
|
+
if (budget.exhausted)
|
|
305
|
+
return true;
|
|
306
|
+
const candidateIssues = [];
|
|
307
|
+
validateJsonSchemaValueInto(value, candidate, path, candidateIssues, 1, budget);
|
|
308
|
+
return candidateIssues.length === 0;
|
|
309
|
+
});
|
|
310
|
+
if (!matched) {
|
|
311
|
+
addJsonSchemaValidationIssue(issues, maxIssues, {
|
|
312
|
+
path,
|
|
313
|
+
code: "schema_any_of_mismatch",
|
|
314
|
+
message: `${path} must match at least one allowed schema.`,
|
|
315
|
+
});
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
// A matching anyOf does not erase sibling constraints. JSON Schema applies
|
|
319
|
+
// them together; returning here silently skipped object/array rules.
|
|
320
|
+
}
|
|
321
|
+
const expectedTypes = normalizeSchemaTypes(schema);
|
|
322
|
+
if (expectedTypes.length > 0 && !expectedTypes.some((type) => matchesJsonSchemaType(value, type))) {
|
|
323
|
+
addJsonSchemaValidationIssue(issues, maxIssues, {
|
|
324
|
+
path,
|
|
325
|
+
code: "schema_type_mismatch",
|
|
326
|
+
message: `${path} must be ${formatSchemaTypes(expectedTypes)}.`,
|
|
327
|
+
});
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
const shouldValidateObject = expectedTypes.includes("object")
|
|
331
|
+
|| Boolean(schema.properties)
|
|
332
|
+
|| Array.isArray(schema.required)
|
|
333
|
+
|| schema.additionalProperties !== undefined;
|
|
334
|
+
if (shouldValidateObject && isRecord(value)) {
|
|
335
|
+
const properties = schema.properties ?? {};
|
|
336
|
+
for (const requiredKey of schema.required ?? []) {
|
|
337
|
+
if (issues.length >= maxIssues || budget.exhausted)
|
|
338
|
+
break;
|
|
339
|
+
if (!consumeJsonSchemaValidationBudget(budget))
|
|
340
|
+
break;
|
|
341
|
+
if (!Object.hasOwn(value, requiredKey) || value[requiredKey] === undefined) {
|
|
342
|
+
addJsonSchemaValidationIssue(issues, maxIssues, {
|
|
343
|
+
path: `${path}.${requiredKey}`,
|
|
344
|
+
code: "schema_required",
|
|
345
|
+
message: `${path}.${requiredKey} is required.`,
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
// Object enumeration is real host work. Charge every key before iterating so
|
|
350
|
+
// a large output tested against many `anyOf` object candidates cannot rescan
|
|
351
|
+
// the same object hundreds of times outside the sandbox timeout.
|
|
352
|
+
const valueKeys = Object.keys(value);
|
|
353
|
+
if (!consumeJsonSchemaValidationBudget(budget, valueKeys.length))
|
|
354
|
+
return;
|
|
355
|
+
for (const key of valueKeys) {
|
|
356
|
+
if (issues.length >= maxIssues || budget.exhausted)
|
|
357
|
+
break;
|
|
358
|
+
const propertyValue = value[key];
|
|
359
|
+
const propertySchema = Object.hasOwn(properties, key) ? properties[key] : undefined;
|
|
360
|
+
if (isRecord(propertySchema)) {
|
|
361
|
+
validateJsonSchemaValueInto(propertyValue, propertySchema, `${path}.${key}`, issues, maxIssues, budget);
|
|
362
|
+
}
|
|
363
|
+
else if (schema.additionalProperties === false) {
|
|
364
|
+
addJsonSchemaValidationIssue(issues, maxIssues, {
|
|
365
|
+
path: `${path}.${key}`,
|
|
366
|
+
code: "schema_additional_property",
|
|
367
|
+
message: `${path}.${key} is not allowed.`,
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
else if (isRecord(schema.additionalProperties)) {
|
|
371
|
+
validateJsonSchemaValueInto(propertyValue, schema.additionalProperties, `${path}.${key}`, issues, maxIssues, budget);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
const shouldValidateArray = expectedTypes.includes("array") || Boolean(schema.items);
|
|
376
|
+
if (shouldValidateArray && Array.isArray(value) && schema.items) {
|
|
377
|
+
for (let index = 0; index < value.length && issues.length < maxIssues && !budget.exhausted; index += 1) {
|
|
378
|
+
validateJsonSchemaValueInto(value[index], schema.items, `${path}.${index}`, issues, maxIssues, budget);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
if (issues.length > startCount)
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
function addJsonSchemaValidationIssue(issues, maxIssues, issue) {
|
|
385
|
+
if (issues.length < maxIssues)
|
|
386
|
+
issues.push(issue);
|
|
387
|
+
}
|
|
388
|
+
function normalizeSchemaTypes(schema) {
|
|
389
|
+
if (Array.isArray(schema.type))
|
|
390
|
+
return schema.type.filter((entry) => typeof entry === "string");
|
|
391
|
+
if (typeof schema.type === "string")
|
|
392
|
+
return [schema.type];
|
|
393
|
+
if (schema.properties || schema.required || schema.additionalProperties !== undefined)
|
|
394
|
+
return ["object"];
|
|
395
|
+
if (schema.items)
|
|
396
|
+
return ["array"];
|
|
397
|
+
return [];
|
|
398
|
+
}
|
|
399
|
+
function matchesJsonSchemaType(value, type) {
|
|
400
|
+
switch (type) {
|
|
401
|
+
case "array":
|
|
402
|
+
return Array.isArray(value);
|
|
403
|
+
case "boolean":
|
|
404
|
+
return typeof value === "boolean";
|
|
405
|
+
case "integer":
|
|
406
|
+
return typeof value === "number" && Number.isInteger(value);
|
|
407
|
+
case "null":
|
|
408
|
+
return value === null;
|
|
409
|
+
case "number":
|
|
410
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
411
|
+
case "object":
|
|
412
|
+
return isRecord(value);
|
|
413
|
+
case "string":
|
|
414
|
+
return typeof value === "string";
|
|
415
|
+
default:
|
|
416
|
+
return true;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
function formatSchemaTypes(types) {
|
|
420
|
+
if (types.length === 1)
|
|
421
|
+
return `a ${types[0]}`;
|
|
422
|
+
return types.map((type) => type === "null" ? "null" : `a ${type}`).join(" or ");
|
|
423
|
+
}
|
|
424
|
+
function jsonEqual(left, right, budget) {
|
|
425
|
+
return jsonEqualInto(left, right, new WeakMap(), budget);
|
|
426
|
+
}
|
|
427
|
+
function jsonEqualInto(left, right, seen, budget) {
|
|
428
|
+
if (!consumeJsonSchemaValidationBudget(budget))
|
|
429
|
+
return false;
|
|
430
|
+
if (left === right)
|
|
431
|
+
return true;
|
|
432
|
+
if (left === null || right === null || typeof left !== typeof right)
|
|
433
|
+
return false;
|
|
434
|
+
if (typeof left !== "object" || typeof right !== "object")
|
|
435
|
+
return false;
|
|
436
|
+
const leftArray = Array.isArray(left);
|
|
437
|
+
if (leftArray !== Array.isArray(right))
|
|
438
|
+
return false;
|
|
439
|
+
const compared = seen.get(left);
|
|
440
|
+
if (compared?.has(right))
|
|
441
|
+
return true;
|
|
442
|
+
if (compared)
|
|
443
|
+
compared.add(right);
|
|
444
|
+
else
|
|
445
|
+
seen.set(left, new WeakSet([right]));
|
|
446
|
+
if (leftArray) {
|
|
447
|
+
const rightArray = right;
|
|
448
|
+
return left.length === rightArray.length
|
|
449
|
+
&& left.every((entry, index) => !budget.exhausted && jsonEqualInto(entry, rightArray[index], seen, budget));
|
|
450
|
+
}
|
|
451
|
+
const leftRecord = left;
|
|
452
|
+
const rightRecord = right;
|
|
453
|
+
const leftKeys = Object.keys(leftRecord);
|
|
454
|
+
const rightKeys = Object.keys(rightRecord);
|
|
455
|
+
if (!consumeJsonSchemaValidationBudget(budget, leftKeys.length + rightKeys.length))
|
|
456
|
+
return false;
|
|
457
|
+
return leftKeys.length === rightKeys.length
|
|
458
|
+
&& leftKeys.every((key) => Object.hasOwn(rightRecord, key)
|
|
459
|
+
&& !budget.exhausted
|
|
460
|
+
&& jsonEqualInto(leftRecord[key], rightRecord[key], seen, budget));
|
|
461
|
+
}
|
|
462
|
+
// Optional idempotency_key_path (webhook + event triggers): when present it must
|
|
463
|
+
// be a non-empty string. `label` distinguishes the trigger type in the message.
|
|
464
|
+
function validateOptionalIdempotencyKeyPath(value, path, label, add) {
|
|
465
|
+
if (value !== undefined && value !== null && !isNonEmptyString(value)) {
|
|
466
|
+
add(`${path}.idempotency_key_path`, "invalid_idempotency_key_path", `${label} idempotency path is invalid.`);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
// Exported for ./graph/lint.ts — see validateOptionalMaxCredits above.
|
|
470
|
+
export function validateTrigger(// skipcq: JS-R1005
|
|
471
|
+
value, path, add) {
|
|
472
|
+
if (!isRecord(value)) {
|
|
473
|
+
add(path, "invalid_trigger", "Workflow trigger must be an object.");
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
476
|
+
if (value.status !== undefined && !isValidWorkflowStatus(value.status)) {
|
|
477
|
+
add(`${path}.status`, "invalid_trigger_status", "Trigger status must be active or disabled.");
|
|
478
|
+
}
|
|
479
|
+
if (value.type === "api")
|
|
480
|
+
return;
|
|
481
|
+
if (value.type === "webhook") {
|
|
482
|
+
if (!isNonEmptyString(value.trigger_id)) {
|
|
483
|
+
add(`${path}.trigger_id`, "invalid_trigger_id", "Webhook trigger_id is required.");
|
|
484
|
+
}
|
|
485
|
+
validateOptionalIdempotencyKeyPath(value.idempotency_key_path, path, "Webhook", add);
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
if (value.type === "cron") {
|
|
489
|
+
if (!isNonEmptyString(value.cron)) {
|
|
490
|
+
add(`${path}.cron`, "invalid_cron", "Cron trigger cron expression is required.");
|
|
491
|
+
}
|
|
492
|
+
else {
|
|
493
|
+
try {
|
|
494
|
+
parseCronSchedule(value.cron);
|
|
495
|
+
}
|
|
496
|
+
catch (error) {
|
|
497
|
+
add(`${path}.cron`, "invalid_cron", error instanceof Error ? error.message : "Cron expression is invalid.");
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
// Validate the timezone here so an unknown zone fails lint with a typed
|
|
501
|
+
// issue, rather than passing lint and blowing up at apply time (the
|
|
502
|
+
// scheduler's Intl.DateTimeFormat throws on an unknown zone). null/empty
|
|
503
|
+
// are allowed — the scheduler falls back to UTC.
|
|
504
|
+
const { timezone } = value;
|
|
505
|
+
if (timezone !== undefined && timezone !== null) {
|
|
506
|
+
if (typeof timezone !== "string") {
|
|
507
|
+
add(`${path}.timezone`, "invalid_timezone", "Cron trigger timezone must be a string IANA timezone.");
|
|
508
|
+
}
|
|
509
|
+
else if (timezone.trim() && !isValidTimeZone(timezone.trim())) {
|
|
510
|
+
add(`${path}.timezone`, "invalid_timezone", `Unknown timezone '${timezone}'. Use an IANA timezone such as 'America/New_York' or 'UTC'.`);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
return;
|
|
514
|
+
}
|
|
515
|
+
if (value.type === "event") {
|
|
516
|
+
if (!isNonEmptyString(value.source)) {
|
|
517
|
+
add(`${path}.source`, "invalid_event_source", "Event trigger source is required.");
|
|
518
|
+
}
|
|
519
|
+
if (!isNonEmptyString(value.event)) {
|
|
520
|
+
add(`${path}.event`, "invalid_event_type", "Event trigger event is required.");
|
|
521
|
+
}
|
|
522
|
+
validateOptionalIdempotencyKeyPath(value.idempotency_key_path, path, "Event", add);
|
|
523
|
+
if (value.filters !== undefined)
|
|
524
|
+
validateEventFilters(value.filters, `${path}.filters`, add);
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
add(`${path}.type`, "invalid_trigger_type", "Trigger type must be api, webhook, cron, or event.");
|
|
528
|
+
}
|
|
529
|
+
function validateEventFilters(value, path, add) {
|
|
530
|
+
if (!Array.isArray(value)) {
|
|
531
|
+
add(path, "invalid_event_filters", "Event trigger filters must be an array.");
|
|
532
|
+
return;
|
|
533
|
+
}
|
|
534
|
+
value.forEach((filter, index) => {
|
|
535
|
+
const filterPath = `${path}.${index}`;
|
|
536
|
+
if (!isRecord(filter)) {
|
|
537
|
+
add(filterPath, "invalid_event_filter", "Event trigger filter must be an object.");
|
|
538
|
+
return;
|
|
539
|
+
}
|
|
540
|
+
if (!isNonEmptyString(filter.path)) {
|
|
541
|
+
add(`${filterPath}.path`, "invalid_event_filter_path", "Event filter path is required.");
|
|
542
|
+
}
|
|
543
|
+
if (filter.op !== "eq"
|
|
544
|
+
&& filter.op !== "neq"
|
|
545
|
+
&& filter.op !== "exists"
|
|
546
|
+
&& filter.op !== "not_exists") {
|
|
547
|
+
add(`${filterPath}.op`, "invalid_event_filter_op", "Event filter op is invalid.");
|
|
548
|
+
}
|
|
549
|
+
if ((filter.op === "eq" || filter.op === "neq") && !Object.hasOwn(filter, "value")) {
|
|
550
|
+
add(`${filterPath}.value`, "missing_event_filter_value", "Event eq/neq filters require a value.");
|
|
551
|
+
}
|
|
552
|
+
});
|
|
553
|
+
}
|
|
554
|
+
export function validateBranchTarget(target, path, fieldLabel, branchIndex, idToIndex, add) {
|
|
555
|
+
if (typeof target !== "string" || target.trim().length === 0) {
|
|
556
|
+
add(path, `missing_branch_${fieldLabel}`, `Branch step ${fieldLabel} is required.`);
|
|
557
|
+
return;
|
|
558
|
+
}
|
|
559
|
+
const targetIndex = idToIndex.get(target);
|
|
560
|
+
if (targetIndex === undefined) {
|
|
561
|
+
add(path, "invalid_branch_target", `Branch ${fieldLabel} references unknown step id '${target}'.`);
|
|
562
|
+
return;
|
|
563
|
+
}
|
|
564
|
+
if (targetIndex <= branchIndex) {
|
|
565
|
+
add(path, "branch_back_jump", `Branch ${fieldLabel} must reference a step that comes after the branch in declared order.`);
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
// Exported for ./graph/lint.ts — see validateOptionalMaxCredits above. v2 `code`
|
|
569
|
+
// nodes are the v2 spelling of a v1 transform step and must clear the identical
|
|
570
|
+
// purity scan; the graph linter re-labels the issues it raises as
|
|
571
|
+
// `unsafe_code_source`.
|
|
572
|
+
export function validatePureFunctionSource(source, path, add) {
|
|
573
|
+
if (!source.trim()) {
|
|
574
|
+
add(path, "empty_function_source", "Workflow function source cannot be empty.");
|
|
575
|
+
return;
|
|
576
|
+
}
|
|
577
|
+
const forbidden = [
|
|
578
|
+
"import",
|
|
579
|
+
"require",
|
|
580
|
+
"process",
|
|
581
|
+
"global",
|
|
582
|
+
"globalThis",
|
|
583
|
+
"fetch",
|
|
584
|
+
"XMLHttpRequest",
|
|
585
|
+
"Function",
|
|
586
|
+
"eval",
|
|
587
|
+
"constructor",
|
|
588
|
+
"setTimeout",
|
|
589
|
+
"setInterval",
|
|
590
|
+
];
|
|
591
|
+
for (const token of forbidden) {
|
|
592
|
+
const pattern = new RegExp(`\\b${escapeRegExp(token)}\\b`);
|
|
593
|
+
if (pattern.test(source)) {
|
|
594
|
+
add(path, "impure_workflow_function", `Workflow function source cannot reference '${token}'.`);
|
|
595
|
+
return;
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
// Blank out comment bodies and string/template-literal *text* so the unsafe-token
|
|
600
|
+
// scan matches only real code identifiers — not a bundle comment ("closed-loop
|
|
601
|
+
// eval") or a string ("retrieval"), which the raw \b-boundary scan flagged as
|
|
602
|
+
// false positives. A real eval(...) or new Function(...) — including inside a
|
|
603
|
+
// `${ ... }` template interpolation, which stays code — is still caught.
|
|
604
|
+
// @oxygen/workflows ships no AST parser, so this is a small hand-rolled lexer;
|
|
605
|
+
// the vm sandbox + runtime global guards remain the actual security boundary.
|
|
606
|
+
function stripCommentsAndStrings(source) {
|
|
607
|
+
const out = [];
|
|
608
|
+
const stack = [{ mode: "code", braces: 0 }];
|
|
609
|
+
const expressionKeywords = new Set(["return", "throw", "case", "delete", "void", "typeof", "yield", "await", "in", "instanceof", "else", "do"]);
|
|
610
|
+
const controlKeywords = new Set(["if", "while", "for", "with", "switch", "catch"]);
|
|
611
|
+
const statementBlockKeywords = new Set(["else", "do", "try", "finally", "catch"]);
|
|
612
|
+
const braceKinds = [];
|
|
613
|
+
const controlParens = [];
|
|
614
|
+
let regexAllowed = true;
|
|
615
|
+
let ambiguousAfterBrace = false;
|
|
616
|
+
let previousToken = "";
|
|
617
|
+
let previousWordEnd = 0;
|
|
618
|
+
let i = 0;
|
|
619
|
+
const n = source.length;
|
|
620
|
+
while (i < n) {
|
|
621
|
+
const top = stack[stack.length - 1];
|
|
622
|
+
const ch = source[i];
|
|
623
|
+
const next = i + 1 < n ? source[i + 1] : "";
|
|
624
|
+
if (top.mode === "template") {
|
|
625
|
+
if (ch === "\\") {
|
|
626
|
+
i += 2;
|
|
627
|
+
continue;
|
|
628
|
+
}
|
|
629
|
+
if (ch === "`") {
|
|
630
|
+
stack.pop();
|
|
631
|
+
regexAllowed = false;
|
|
632
|
+
previousToken = "literal";
|
|
633
|
+
i += 1;
|
|
634
|
+
continue;
|
|
635
|
+
}
|
|
636
|
+
if (ch === "$" && next === "{") {
|
|
637
|
+
stack.push({ mode: "code", braces: 0 });
|
|
638
|
+
regexAllowed = true;
|
|
639
|
+
previousToken = "";
|
|
640
|
+
out.push(" ");
|
|
641
|
+
i += 2;
|
|
642
|
+
continue;
|
|
643
|
+
}
|
|
644
|
+
i += 1; // drop template text
|
|
645
|
+
continue;
|
|
646
|
+
}
|
|
647
|
+
if (ch === "/" && next === "/") {
|
|
648
|
+
i += 2;
|
|
649
|
+
while (i < n && source[i] !== "\n")
|
|
650
|
+
i += 1;
|
|
651
|
+
continue;
|
|
652
|
+
}
|
|
653
|
+
if (ch === "/" && next === "*") {
|
|
654
|
+
i += 2;
|
|
655
|
+
while (i < n && !(source[i] === "*" && source[i + 1] === "/"))
|
|
656
|
+
i += 1;
|
|
657
|
+
i = Math.min(i + 2, n);
|
|
658
|
+
continue;
|
|
659
|
+
}
|
|
660
|
+
if (ch === "/" && ambiguousAfterBrace)
|
|
661
|
+
return { source: out.join(""), ambiguousSlash: true };
|
|
662
|
+
if (!/\s/.test(ch))
|
|
663
|
+
ambiguousAfterBrace = false;
|
|
664
|
+
// Regex quotes must not make the string scanner swallow executable code.
|
|
665
|
+
if (ch === "/" && regexAllowed) {
|
|
666
|
+
let end = i + 1;
|
|
667
|
+
let characterClass = false;
|
|
668
|
+
while (end < n && source[end] !== "\n" && source[end] !== "\r") {
|
|
669
|
+
const current = source[end];
|
|
670
|
+
if (current === "\\") {
|
|
671
|
+
end += 2;
|
|
672
|
+
continue;
|
|
673
|
+
}
|
|
674
|
+
if (current === "[")
|
|
675
|
+
characterClass = true;
|
|
676
|
+
else if (current === "]")
|
|
677
|
+
characterClass = false;
|
|
678
|
+
else if (current === "/" && !characterClass)
|
|
679
|
+
break;
|
|
680
|
+
end += 1;
|
|
681
|
+
}
|
|
682
|
+
if (end < n && source[end] === "/") {
|
|
683
|
+
end += 1;
|
|
684
|
+
while (end < n && /[a-z]/i.test(source[end]))
|
|
685
|
+
end += 1;
|
|
686
|
+
out.push('""');
|
|
687
|
+
i = end;
|
|
688
|
+
regexAllowed = false;
|
|
689
|
+
previousToken = "literal";
|
|
690
|
+
continue;
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
if (ch === '"' || ch === "'") {
|
|
694
|
+
const quote = ch;
|
|
695
|
+
i += 1;
|
|
696
|
+
while (i < n && source[i] !== quote)
|
|
697
|
+
i += source[i] === "\\" ? 2 : 1;
|
|
698
|
+
i += 1;
|
|
699
|
+
out.push('""');
|
|
700
|
+
regexAllowed = false;
|
|
701
|
+
previousToken = "literal";
|
|
702
|
+
continue;
|
|
703
|
+
}
|
|
704
|
+
if (ch === "`") {
|
|
705
|
+
stack.push({ mode: "template" });
|
|
706
|
+
i += 1;
|
|
707
|
+
continue;
|
|
708
|
+
}
|
|
709
|
+
if (/[a-z_$]/i.test(ch)) {
|
|
710
|
+
const start = i;
|
|
711
|
+
while (i < n && /[\w$]/.test(source[i]))
|
|
712
|
+
i += 1;
|
|
713
|
+
const word = source.slice(start, i);
|
|
714
|
+
out.push(word);
|
|
715
|
+
previousToken = previousToken === "." ? "identifier" : word;
|
|
716
|
+
previousWordEnd = i;
|
|
717
|
+
regexAllowed = expressionKeywords.has(previousToken);
|
|
718
|
+
continue;
|
|
719
|
+
}
|
|
720
|
+
if (ch === "}" && top.braces === 0 && stack.length > 1) {
|
|
721
|
+
stack.pop();
|
|
722
|
+
out.push(" ");
|
|
723
|
+
i += 1;
|
|
724
|
+
continue;
|
|
725
|
+
}
|
|
726
|
+
if (ch === "=" && next === ">") {
|
|
727
|
+
out.push("=>");
|
|
728
|
+
previousToken = "=>";
|
|
729
|
+
regexAllowed = true;
|
|
730
|
+
i += 2;
|
|
731
|
+
continue;
|
|
732
|
+
}
|
|
733
|
+
if (ch === "{") {
|
|
734
|
+
const enclosing = braceKinds[braceKinds.length - 1];
|
|
735
|
+
let kind = "unknown";
|
|
736
|
+
if ((previousToken === ")" && regexAllowed) || statementBlockKeywords.has(previousToken)
|
|
737
|
+
|| previousToken === ";" || (previousToken === "{" && (enclosing === "statement" || enclosing === "function")))
|
|
738
|
+
kind = "statement";
|
|
739
|
+
else if (previousToken === "=>")
|
|
740
|
+
kind = "function";
|
|
741
|
+
else if (["=", "(", "[", ","].includes(previousToken) || (previousToken === ":" && enclosing === "object")
|
|
742
|
+
|| (previousToken === "return" && !/[\r\n]/.test(source.slice(previousWordEnd, i))))
|
|
743
|
+
kind = "object";
|
|
744
|
+
braceKinds.push(kind);
|
|
745
|
+
}
|
|
746
|
+
if (ch === "(")
|
|
747
|
+
controlParens.push(controlKeywords.has(previousToken));
|
|
748
|
+
if (ch === ")")
|
|
749
|
+
regexAllowed = controlParens.pop() ?? false;
|
|
750
|
+
else if (ch === "}") {
|
|
751
|
+
const kind = braceKinds.pop();
|
|
752
|
+
regexAllowed = kind === "statement";
|
|
753
|
+
// Other brace forms need a parser to distinguish declarations from expressions.
|
|
754
|
+
ambiguousAfterBrace = kind === "unknown";
|
|
755
|
+
}
|
|
756
|
+
else if (!/\s/.test(ch)) {
|
|
757
|
+
if (!((ch === "+" || ch === "-") && (next === ch || previousToken === ch))) {
|
|
758
|
+
regexAllowed = /[([{,:;=!?&|+*%^~<>\/-]/.test(ch);
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
if (!/\s/.test(ch))
|
|
762
|
+
previousToken = ch;
|
|
763
|
+
if (ch === "{")
|
|
764
|
+
top.braces += 1;
|
|
765
|
+
else if (ch === "}")
|
|
766
|
+
top.braces = Math.max(0, top.braces - 1);
|
|
767
|
+
out.push(ch);
|
|
768
|
+
i += 1;
|
|
769
|
+
}
|
|
770
|
+
return { source: out.join(""), ambiguousSlash: false };
|
|
771
|
+
}
|
|
772
|
+
export function validateRecipeBundleSafety(source, path, add) {
|
|
773
|
+
if (!source.trim()) {
|
|
774
|
+
add(path, "empty_recipe_bundle", "Recipe bundle cannot be empty.");
|
|
775
|
+
return;
|
|
776
|
+
}
|
|
777
|
+
// Scan only real code: comments and string literals are blanked first so a
|
|
778
|
+
// token that merely appears in prose or data (e.g. "eval" in a comment) does
|
|
779
|
+
// not trip the lint, while genuine calls survive.
|
|
780
|
+
const scan = stripCommentsAndStrings(source);
|
|
781
|
+
if (scan.ambiguousSlash) {
|
|
782
|
+
add(path, "unsafe_recipe_bundle", "Durable recipe bundle has an ambiguous slash after a brace. Parenthesize the expression or separate statements with a semicolon.");
|
|
783
|
+
return;
|
|
784
|
+
}
|
|
785
|
+
const scannable = scan.source;
|
|
786
|
+
for (const entry of UNSAFE_RECIPE_BUNDLE_PATTERNS) {
|
|
787
|
+
if (entry.pattern.test(scannable)) {
|
|
788
|
+
add(path, "unsafe_recipe_bundle", `Durable recipe bundle cannot reference '${entry.token}'. Use ctx.tools.run(), ctx.step(), ctx.now(), or ctx.uuid() instead.`);
|
|
789
|
+
return;
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
// Exported for ./graph/lint.ts — see validateOptionalMaxCredits above. One deny
|
|
794
|
+
// list, enforced identically for v1 tool steps and v2 tool nodes.
|
|
795
|
+
export function isWorkflowToolRejected(toolId) {
|
|
796
|
+
return toolId === "run_javascript" || toolId === "custom_http";
|
|
797
|
+
}
|
|
798
|
+
const CRON_FIELD_LIMITS = [
|
|
799
|
+
{ name: "minute", min: 0, max: 59 },
|
|
800
|
+
{ name: "hour", min: 0, max: 23 },
|
|
801
|
+
{ name: "day-of-month", min: 1, max: 31 },
|
|
802
|
+
{ name: "month", min: 1, max: 12 },
|
|
803
|
+
{ name: "day-of-week", min: 0, max: 7 },
|
|
804
|
+
];
|
|
805
|
+
export function parseCronSchedule(value) {
|
|
806
|
+
const parts = value.trim().split(/\s+/);
|
|
807
|
+
if (parts.length !== 5) {
|
|
808
|
+
throw new Error("Cron expression must have five space-separated parts.");
|
|
809
|
+
}
|
|
810
|
+
const [minute, hour, dayOfMonth, month, dayOfWeek] = parts;
|
|
811
|
+
if (!minute || !hour || !dayOfMonth || !month || !dayOfWeek) {
|
|
812
|
+
throw new Error("Cron expression must have five space-separated parts.");
|
|
813
|
+
}
|
|
814
|
+
const minutes = parseCronField(minute, CRON_FIELD_LIMITS[0]);
|
|
815
|
+
const hours = parseCronField(hour, CRON_FIELD_LIMITS[1]);
|
|
816
|
+
const daysOfMonth = parseCronField(dayOfMonth, CRON_FIELD_LIMITS[2]);
|
|
817
|
+
const months = parseCronField(month, CRON_FIELD_LIMITS[3]);
|
|
818
|
+
const daysOfWeek = normalizeDaysOfWeek(parseCronField(dayOfWeek, CRON_FIELD_LIMITS[4]));
|
|
819
|
+
return {
|
|
820
|
+
minutes,
|
|
821
|
+
hours,
|
|
822
|
+
daysOfMonth,
|
|
823
|
+
months,
|
|
824
|
+
daysOfWeek,
|
|
825
|
+
dayOfMonthRestricted: dayOfMonth !== "*",
|
|
826
|
+
dayOfWeekRestricted: dayOfWeek !== "*",
|
|
827
|
+
};
|
|
828
|
+
}
|
|
829
|
+
function parseCronField(expression, limits) {
|
|
830
|
+
const values = new Set();
|
|
831
|
+
for (const rawToken of expression.split(",")) {
|
|
832
|
+
const token = rawToken.trim();
|
|
833
|
+
if (!token)
|
|
834
|
+
throw new Error(`Cron ${limits.name} field contains an empty item.`);
|
|
835
|
+
const parts = token.split("/");
|
|
836
|
+
const rangePart = parts[0];
|
|
837
|
+
const stepPart = parts[1];
|
|
838
|
+
if (!rangePart || parts.length > 2) {
|
|
839
|
+
throw new Error(`Cron ${limits.name} field is invalid.`);
|
|
840
|
+
}
|
|
841
|
+
const step = stepPart === undefined ? 1 : Number(stepPart);
|
|
842
|
+
if (!Number.isInteger(step) || step < 1) {
|
|
843
|
+
throw new Error(`Cron ${limits.name} step must be a positive integer.`);
|
|
844
|
+
}
|
|
845
|
+
const [start, end] = parseCronRange(rangePart, limits);
|
|
846
|
+
for (let current = start; current <= end; current += step) {
|
|
847
|
+
values.add(current);
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
if (values.size === 0)
|
|
851
|
+
throw new Error(`Cron ${limits.name} field is empty.`);
|
|
852
|
+
return values;
|
|
853
|
+
}
|
|
854
|
+
function parseCronRange(value, limits) {
|
|
855
|
+
if (value === "*")
|
|
856
|
+
return [limits.min, limits.max];
|
|
857
|
+
const parts = value.split("-");
|
|
858
|
+
const startRaw = parts[0];
|
|
859
|
+
const endRaw = parts[1];
|
|
860
|
+
if (!startRaw || parts.length > 2) {
|
|
861
|
+
throw new Error(`Cron ${limits.name} range is invalid.`);
|
|
862
|
+
}
|
|
863
|
+
const start = Number(startRaw);
|
|
864
|
+
const end = endRaw === undefined ? start : Number(endRaw);
|
|
865
|
+
if (!Number.isInteger(start) || !Number.isInteger(end)) {
|
|
866
|
+
throw new Error(`Cron ${limits.name} values must be integers.`);
|
|
867
|
+
}
|
|
868
|
+
if (start < limits.min || end > limits.max || start > end) {
|
|
869
|
+
throw new Error(`Cron ${limits.name} values must be between ${limits.min} and ${limits.max}.`);
|
|
870
|
+
}
|
|
871
|
+
return [start, end];
|
|
872
|
+
}
|
|
873
|
+
function normalizeDaysOfWeek(values) {
|
|
874
|
+
const normalized = new Set();
|
|
875
|
+
for (const value of values) {
|
|
876
|
+
normalized.add(value === 7 ? 0 : value);
|
|
877
|
+
}
|
|
878
|
+
return normalized;
|
|
879
|
+
}
|
|
880
|
+
function isValidTimeZone(timezone) {
|
|
881
|
+
try {
|
|
882
|
+
// Throws RangeError for an unknown IANA zone; same mechanism the scheduler
|
|
883
|
+
// uses, so lint accepts exactly the zones the runtime can resolve.
|
|
884
|
+
new Intl.DateTimeFormat("en-US", { timeZone: timezone }).format(0);
|
|
885
|
+
return true;
|
|
886
|
+
}
|
|
887
|
+
catch {
|
|
888
|
+
return false;
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
export function isRecord(value) {
|
|
892
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
893
|
+
}
|
|
894
|
+
export function isNonEmptyString(value) {
|
|
895
|
+
return typeof value === "string" && value.trim().length > 0;
|
|
896
|
+
}
|
|
897
|
+
// The canonical list of internal workflow tool ids lives in @oxygen/tools
|
|
898
|
+
// (OXYGEN_INTERNAL_WORKFLOW_TOOL_IDS). Both the worker's runtime registry and the
|
|
899
|
+
// web's lint allowlist derive from it, so re-declaring it here would recreate
|
|
900
|
+
// exactly the drift that broke crm-sync.
|
|
901
|
+
function escapeRegExp(value) {
|
|
902
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
903
|
+
}
|