@oxygen-agent/cli 1.1014.1874 → 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 -258
- package/node_modules/@oxygen/shared/dist/capability-discovery.js +123 -3700
- 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/log.d.ts +4 -0
- package/node_modules/@oxygen/shared/dist/log.js +4 -0
- 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/onboarding-research.d.ts +19 -0
- package/node_modules/@oxygen/shared/dist/onboarding-research.js +33 -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
|
@@ -2,6 +2,7 @@ import { createHash } from "node:crypto";
|
|
|
2
2
|
import * as vm from "node:vm"; // skipcq: JS-C1003
|
|
3
3
|
import { isWorkflowGraphManifest, WORKFLOW_CODE_V1_DEFAULT_OUTPUT_BYTES, WORKFLOW_CODE_V1_DEFAULT_TIMEOUT_MS, WORKFLOW_CODE_V1_MAX_OUTPUT_BYTES, WORKFLOW_CODE_V1_MIN_OUTPUT_BYTES, WORKFLOW_CODE_V1_MIN_TIMEOUT_MS, } from "./graph/types.js";
|
|
4
4
|
import { lintWorkflowGraphManifest } from "./graph/lint.js";
|
|
5
|
+
import { DURABLE_RECIPE_COMPILER_VERSION, isNonEmptyString, isRecord, isValidWorkflowStatus, isWorkflowToolRejected, lintRecipeManifest, parseCronSchedule, validateBranchTarget, validateOptionalMaxCredits, validatePureFunctionSource, validateRecipeBundleSafety, validateTrigger, WORKFLOW_MANIFEST_VERSION, } from "./manifest-validation.js";
|
|
5
6
|
export * from "./usage-estimate.js";
|
|
6
7
|
// Pure event-dispatch semantics, shared by the apps/web and apps/worker event
|
|
7
8
|
// dispatchers so the filter gate, idempotency rule, and delivery verdict cannot
|
|
@@ -9,66 +10,22 @@ export * from "./usage-estimate.js";
|
|
|
9
10
|
export * from "./event-dispatch.js";
|
|
10
11
|
// oxygen-workflows-v2. The graph barrel is browser-safe on its own (importable as
|
|
11
12
|
// "@oxygen/workflows/graph"); the linter is not — it reuses the v1 pure-function
|
|
12
|
-
// scanner
|
|
13
|
+
// scanner — so it is re-exported here, from the node entry point only.
|
|
13
14
|
export * from "./graph/index.js";
|
|
14
15
|
export * from "./graph/lint.js";
|
|
15
16
|
export * from "./portable.js";
|
|
16
17
|
export { RECIPE_TIMESTAMP_MILLIS_SOURCE } from "./recipe-timestamp.js";
|
|
17
18
|
export * from "./refactor-internals/execution-policy.js";
|
|
18
|
-
|
|
19
|
+
// The v1 manifest validators the v2 graph linter reuses; see manifest-validation.ts.
|
|
20
|
+
export { DURABLE_RECIPE_COMPILER_VERSION, isWorkflowToolRejected, lintRecipeManifest, lintWorkflowCodeSourceSafety, MAX_RECIPE_BUNDLE_BYTES, validateJsonSchemaValue, validateOptionalMaxCredits, validatePureFunctionSource, validateTrigger, WORKFLOW_MANIFEST_VERSION, } from "./manifest-validation.js";
|
|
19
21
|
export const WORKFLOW_COMPILER_VERSION = "oxygen-workflows-v1";
|
|
20
|
-
export const DURABLE_RECIPE_COMPILER_VERSION = "oxygen-recipes-v2";
|
|
21
22
|
export const BLUEPRINT_VERSION = 1;
|
|
22
23
|
export const BLUEPRINT_COMPILER_VERSION = "oxygen-blueprints-v1";
|
|
23
|
-
export const MAX_RECIPE_BUNDLE_BYTES = 2_000_000;
|
|
24
24
|
export const MAX_BLUEPRINT_BYTES = 4_000_000;
|
|
25
25
|
export const DEFAULT_WORKFLOW_CRON_TIMEZONE = "UTC";
|
|
26
26
|
// Step ids that must not be used: they collide with JavaScript object internals
|
|
27
27
|
// when the runtime assembles ctx.steps, so their outputs would be silently lost.
|
|
28
28
|
const RESERVED_STEP_IDS = new Set(["__proto__", "constructor", "prototype"]);
|
|
29
|
-
// Compatibility and determinism lint only. The Vercel sandbox process,
|
|
30
|
-
// denied network policy, and runtime global guards are the security boundary.
|
|
31
|
-
const UNSAFE_RECIPE_BUNDLE_PATTERNS = [
|
|
32
|
-
{ token: "globalThis", pattern: /\bglobalThis\b/ }, // skipcq: SCT-A000
|
|
33
|
-
{ token: "global", pattern: /\bglobal\b/ },
|
|
34
|
-
{ token: "process", pattern: /\bprocess\b/ },
|
|
35
|
-
{ token: "fetch", pattern: /\bfetch\b/ },
|
|
36
|
-
{ token: "XMLHttpRequest", pattern: /\bXMLHttpRequest\b/ }, // skipcq: SCT-A000
|
|
37
|
-
{ token: "WebSocket", pattern: /\bWebSocket\b/ },
|
|
38
|
-
{ token: "EventSource", pattern: /\bEventSource\b/ }, // skipcq: SCT-A000
|
|
39
|
-
// Block CommonJS require(...) but allow a `.require` method access (the
|
|
40
|
-
// ctx.approvals.require() durable-approval API). A real global require is a
|
|
41
|
-
// bare identifier; any X.require on a dangerous global (globalThis/process/…)
|
|
42
|
-
// is already caught by that global's own rule above.
|
|
43
|
-
{ token: "require", pattern: /(?<!\.)\brequire\b/ },
|
|
44
|
-
{ token: "dynamic import", pattern: /\bimport(?:\s|\/\*[\s\S]*?\*\/)*\(/ }, // skipcq: SCT-A000
|
|
45
|
-
{ token: "node module import", pattern: /\b(?:node:)?(?:fs|child_process|net|tls|http|https|dns|dgram|worker_threads)\b/ }, // skipcq: SCT-A000
|
|
46
|
-
{ token: "eval", pattern: /\beval\b/ },
|
|
47
|
-
{ token: "Function", pattern: /\bFunction\b/ },
|
|
48
|
-
{ token: "constructor", pattern: /\bconstructor\b/ },
|
|
49
|
-
{ token: "Date.now", pattern: /\bDate\s*\.\s*now\b/ },
|
|
50
|
-
{ token: "new Date", pattern: /\bnew\s+Date\b/ },
|
|
51
|
-
{ token: "Math.random", pattern: /\bMath\s*\.\s*random\b/ },
|
|
52
|
-
{ token: "crypto.randomUUID", pattern: /\bcrypto\s*\.\s*randomUUID\b/ },
|
|
53
|
-
{ token: "setTimeout", pattern: /\bsetTimeout\b/ },
|
|
54
|
-
{ token: "setInterval", pattern: /\bsetInterval\b/ }, // skipcq: SCT-A000
|
|
55
|
-
];
|
|
56
|
-
// Code v1 has no ctx.now()/ctx.uuid() capability and runs as a pure transform,
|
|
57
|
-
// so its determinism/capability denylist is intentionally stricter than the
|
|
58
|
-
// durable-recipe compatibility scan above. Keep this separate: old immutable
|
|
59
|
-
// recipe revisions must not acquire new lint failures merely because Code v1 is
|
|
60
|
-
// introduced.
|
|
61
|
-
const UNSAFE_WORKFLOW_CODE_SOURCE_PATTERNS = [
|
|
62
|
-
...UNSAFE_RECIPE_BUNDLE_PATTERNS,
|
|
63
|
-
{ token: "Date", pattern: /\bDate\b/ },
|
|
64
|
-
{ token: "WebAssembly", pattern: /\bWebAssembly\b/ },
|
|
65
|
-
{ token: "setImmediate", pattern: /\bsetImmediate\b/ },
|
|
66
|
-
{ token: "queueMicrotask", pattern: /\bqueueMicrotask\b/ },
|
|
67
|
-
];
|
|
68
|
-
/** A valid workflow / recipe / trigger status. Optional everywhere it appears. */
|
|
69
|
-
function isValidWorkflowStatus(value) {
|
|
70
|
-
return value === "active" || value === "disabled";
|
|
71
|
-
}
|
|
72
29
|
export function defineWorkflow(input) {
|
|
73
30
|
return {
|
|
74
31
|
__oxygen_workflow_definition: true,
|
|
@@ -480,18 +437,6 @@ export function hashRecipeSource(input) {
|
|
|
480
437
|
configuration: input.configuration ?? null,
|
|
481
438
|
}, workflowJsonReplacer));
|
|
482
439
|
}
|
|
483
|
-
// Shared positive-finite validator for the optional per-run / per-step
|
|
484
|
-
// max_credits caps (Gap 2). `undefined` is valid (no cap); anything else must be
|
|
485
|
-
// a positive finite number, or lint rejects the manifest.
|
|
486
|
-
// Exported for ./graph/lint.ts so the v2 graph linter enforces the same rule as
|
|
487
|
-
// v1 rather than a second copy of it. Not part of the product surface.
|
|
488
|
-
export function validateOptionalMaxCredits(value, path, add) {
|
|
489
|
-
if (value === undefined)
|
|
490
|
-
return;
|
|
491
|
-
if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
|
|
492
|
-
add(path, "invalid_max_credits", "max_credits must be a positive number.");
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
440
|
export function lintWorkflowManifest(// skipcq: JS-R1005
|
|
496
441
|
value, options = {}) {
|
|
497
442
|
if (isWorkflowGraphManifest(value)) {
|
|
@@ -658,172 +603,6 @@ value, options = {}) {
|
|
|
658
603
|
}
|
|
659
604
|
return { ok: issues.length === 0, issues };
|
|
660
605
|
}
|
|
661
|
-
export function lintRecipeManifest(// skipcq: JS-R1005
|
|
662
|
-
value, options = {}) {
|
|
663
|
-
const issues = [];
|
|
664
|
-
const add = (path, code, message) => issues.push({ path, code, message });
|
|
665
|
-
if (!isRecord(value)) {
|
|
666
|
-
add("$", "invalid_manifest", "Recipe manifest must be an object.");
|
|
667
|
-
return { ok: false, issues };
|
|
668
|
-
}
|
|
669
|
-
if (value.manifest_version !== WORKFLOW_MANIFEST_VERSION) {
|
|
670
|
-
add("$.manifest_version", "invalid_manifest_version", "Recipe manifest version must be 1.");
|
|
671
|
-
}
|
|
672
|
-
if (value.compiler_version !== DURABLE_RECIPE_COMPILER_VERSION) {
|
|
673
|
-
add("$.compiler_version", "invalid_compiler_version", `Recipe manifest compiler_version must be '${DURABLE_RECIPE_COMPILER_VERSION}'.`);
|
|
674
|
-
}
|
|
675
|
-
const workflow = value.workflow;
|
|
676
|
-
if (!isRecord(workflow)) {
|
|
677
|
-
add("$.workflow", "missing_workflow", "Recipe metadata is required.");
|
|
678
|
-
}
|
|
679
|
-
else {
|
|
680
|
-
if (!isNonEmptyString(workflow.id))
|
|
681
|
-
add("$.workflow.id", "invalid_workflow_id", "Recipe id is required.");
|
|
682
|
-
if (!isNonEmptyString(workflow.name))
|
|
683
|
-
add("$.workflow.name", "invalid_workflow_name", "Recipe name is required.");
|
|
684
|
-
if (workflow.status !== undefined && !isValidWorkflowStatus(workflow.status)) {
|
|
685
|
-
add("$.workflow.status", "invalid_workflow_status", "Recipe status must be active or disabled.");
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
if (value.trigger !== undefined)
|
|
689
|
-
validateTrigger(value.trigger, "$.trigger", add);
|
|
690
|
-
if (value.configuration_schema !== undefined && !isRecord(value.configuration_schema)) {
|
|
691
|
-
add("$.configuration_schema", "invalid_configuration_schema", "Recipe configuration_schema must be a JSON Schema object.");
|
|
692
|
-
}
|
|
693
|
-
if (value.configuration !== undefined && !isRecord(value.configuration)) {
|
|
694
|
-
add("$.configuration", "invalid_configuration", "Recipe configuration must be an object.");
|
|
695
|
-
}
|
|
696
|
-
else if (isRecord(value.configuration_schema)) {
|
|
697
|
-
for (const issue of validateJsonSchemaValue(isRecord(value.configuration) ? value.configuration : {}, value.configuration_schema, "$.configuration")) {
|
|
698
|
-
add(issue.path, issue.code, issue.message);
|
|
699
|
-
}
|
|
700
|
-
}
|
|
701
|
-
if (!isNonEmptyString(value.bundle)) {
|
|
702
|
-
add("$.bundle", "missing_bundle", "Recipe bundle is required.");
|
|
703
|
-
}
|
|
704
|
-
else if (Buffer.byteLength(value.bundle, "utf8") > MAX_RECIPE_BUNDLE_BYTES) {
|
|
705
|
-
add("$.bundle", "bundle_too_large", "Recipe bundle exceeds the maximum allowed size.");
|
|
706
|
-
}
|
|
707
|
-
else {
|
|
708
|
-
validateRecipeBundleSafety(value.bundle, "$.bundle", add);
|
|
709
|
-
}
|
|
710
|
-
if (value.bundle_format !== "esm") {
|
|
711
|
-
add("$.bundle_format", "invalid_bundle_format", "Recipe bundle_format must be 'esm'.");
|
|
712
|
-
}
|
|
713
|
-
validateOptionalMaxCredits(value.max_credits, "$.max_credits", add);
|
|
714
|
-
if (value.runtime !== "durable") {
|
|
715
|
-
add("$.runtime", "invalid_recipe_runtime", "Durable recipe manifests must set runtime to durable.");
|
|
716
|
-
}
|
|
717
|
-
if (Array.isArray(value.tools_used)) {
|
|
718
|
-
value.tools_used.forEach((toolId, index) => {
|
|
719
|
-
if (typeof toolId !== "string" || !toolId.trim()) {
|
|
720
|
-
add(`$.tools_used.${index}`, "invalid_tool_id", "Recipe tools_used entries must be non-empty strings.");
|
|
721
|
-
}
|
|
722
|
-
else if (isWorkflowToolRejected(toolId)) {
|
|
723
|
-
add(`$.tools_used.${index}`, "unsupported_workflow_tool", `Tool '${toolId}' is not allowed in durable recipes.`);
|
|
724
|
-
}
|
|
725
|
-
else if (options.isToolAllowed && !options.isToolAllowed(toolId)) {
|
|
726
|
-
add(`$.tools_used.${index}`, "tool_not_allowed", `Tool '${toolId}' is not available for durable recipes.`);
|
|
727
|
-
}
|
|
728
|
-
});
|
|
729
|
-
}
|
|
730
|
-
else if (value.tools_used !== undefined) {
|
|
731
|
-
add("$.tools_used", "invalid_tools_used", "Recipe tools_used must be an array of tool ids.");
|
|
732
|
-
}
|
|
733
|
-
else {
|
|
734
|
-
add("$.tools_used", "missing_recipe_tools", "Durable recipe manifests must declare tools_used (use [] for pure recipes).");
|
|
735
|
-
}
|
|
736
|
-
const declaredTools = Array.isArray(value.tools_used)
|
|
737
|
-
? new Set(value.tools_used.filter((toolId) => typeof toolId === "string" && toolId.trim().length > 0))
|
|
738
|
-
: new Set();
|
|
739
|
-
if (value.visual_plan !== undefined) {
|
|
740
|
-
validateRecipeVisualPlan(value.visual_plan, "$.visual_plan", declaredTools, add);
|
|
741
|
-
}
|
|
742
|
-
if (!isNonEmptyString(value.source_hash)) {
|
|
743
|
-
add("$.source_hash", "missing_source_hash", "Recipe manifest source_hash is required.");
|
|
744
|
-
}
|
|
745
|
-
return { ok: issues.length === 0, issues };
|
|
746
|
-
}
|
|
747
|
-
function validateRecipeVisualPlan(value, path, declaredTools, add) {
|
|
748
|
-
if (!isRecord(value)) {
|
|
749
|
-
add(path, "invalid_visual_plan", "Recipe visual_plan must be an object.");
|
|
750
|
-
return;
|
|
751
|
-
}
|
|
752
|
-
if (value.version !== 1) {
|
|
753
|
-
add(`${path}.version`, "invalid_visual_plan_version", "Recipe visual_plan version must be 1.");
|
|
754
|
-
}
|
|
755
|
-
if (!Array.isArray(value.steps)) {
|
|
756
|
-
add(`${path}.steps`, "invalid_visual_plan_steps", "Recipe visual_plan steps must be an array.");
|
|
757
|
-
return;
|
|
758
|
-
}
|
|
759
|
-
if (value.steps.length === 0) {
|
|
760
|
-
add(`${path}.steps`, "missing_visual_plan_steps", "Recipe visual_plan must declare at least one step.");
|
|
761
|
-
return;
|
|
762
|
-
}
|
|
763
|
-
const idToIndex = new Map();
|
|
764
|
-
value.steps.forEach((step, index) => {
|
|
765
|
-
if (isRecord(step) && isNonEmptyString(step.id) && !idToIndex.has(step.id)) {
|
|
766
|
-
idToIndex.set(step.id, index);
|
|
767
|
-
}
|
|
768
|
-
});
|
|
769
|
-
const ids = new Set();
|
|
770
|
-
value.steps.forEach((step, index) => {
|
|
771
|
-
const stepPath = `${path}.steps.${index}`;
|
|
772
|
-
if (!isRecord(step)) {
|
|
773
|
-
add(stepPath, "invalid_visual_plan_step", "Recipe visual_plan step must be an object.");
|
|
774
|
-
return;
|
|
775
|
-
}
|
|
776
|
-
if (!isNonEmptyString(step.id)) {
|
|
777
|
-
add(`${stepPath}.id`, "invalid_visual_plan_step_id", "Recipe visual_plan step id is required.");
|
|
778
|
-
}
|
|
779
|
-
else if (ids.has(step.id)) {
|
|
780
|
-
add(`${stepPath}.id`, "duplicate_visual_plan_step_id", `Recipe visual_plan step id '${step.id}' is duplicated.`);
|
|
781
|
-
}
|
|
782
|
-
else {
|
|
783
|
-
ids.add(step.id);
|
|
784
|
-
}
|
|
785
|
-
if (!isNonEmptyString(step.label)) {
|
|
786
|
-
add(`${stepPath}.label`, "invalid_visual_plan_step_label", "Recipe visual_plan step label is required.");
|
|
787
|
-
}
|
|
788
|
-
if (step.description !== undefined && typeof step.description !== "string") {
|
|
789
|
-
add(`${stepPath}.description`, "invalid_visual_plan_description", "Recipe visual_plan description must be a string.");
|
|
790
|
-
}
|
|
791
|
-
if (step.checkpoint_id !== undefined && !isNonEmptyString(step.checkpoint_id)) {
|
|
792
|
-
add(`${stepPath}.checkpoint_id`, "invalid_visual_plan_checkpoint", "Recipe visual_plan checkpoint_id must be a non-empty string.");
|
|
793
|
-
}
|
|
794
|
-
if (step.kind === "tool") {
|
|
795
|
-
if (!isNonEmptyString(step.tool)) {
|
|
796
|
-
add(`${stepPath}.tool`, "missing_visual_plan_tool", "Recipe visual_plan tool step requires a tool id.");
|
|
797
|
-
}
|
|
798
|
-
else if (!declaredTools.has(step.tool)) {
|
|
799
|
-
add(`${stepPath}.tool`, "visual_plan_tool_not_declared", `Recipe visual_plan tool '${step.tool}' must be present in tools_used.`);
|
|
800
|
-
}
|
|
801
|
-
if (step.effect !== undefined
|
|
802
|
-
&& step.effect !== "none"
|
|
803
|
-
&& step.effect !== "external_read"
|
|
804
|
-
&& step.effect !== "external_write") {
|
|
805
|
-
add(`${stepPath}.effect`, "invalid_visual_plan_effect", "Recipe visual_plan tool effect is invalid.");
|
|
806
|
-
}
|
|
807
|
-
return;
|
|
808
|
-
}
|
|
809
|
-
if (step.kind === "step")
|
|
810
|
-
return;
|
|
811
|
-
if (step.kind === "branch") {
|
|
812
|
-
if (step.condition_label !== undefined && typeof step.condition_label !== "string") {
|
|
813
|
-
add(`${stepPath}.condition_label`, "invalid_visual_plan_condition", "Recipe visual_plan condition_label must be a string.");
|
|
814
|
-
}
|
|
815
|
-
validateBranchTarget(step.then_id, `${stepPath}.then_id`, "then_id", index, idToIndex, add);
|
|
816
|
-
if (step.else_id !== undefined) {
|
|
817
|
-
validateBranchTarget(step.else_id, `${stepPath}.else_id`, "else_id", index, idToIndex, add);
|
|
818
|
-
}
|
|
819
|
-
if (step.join_id !== undefined) {
|
|
820
|
-
validateBranchTarget(step.join_id, `${stepPath}.join_id`, "join_id", index, idToIndex, add);
|
|
821
|
-
}
|
|
822
|
-
return;
|
|
823
|
-
}
|
|
824
|
-
add(`${stepPath}.kind`, "invalid_visual_plan_step_kind", "Recipe visual_plan step kind must be tool, step, or branch.");
|
|
825
|
-
});
|
|
826
|
-
}
|
|
827
606
|
export function assertRecipeManifest(value, options = {}) {
|
|
828
607
|
const result = lintRecipeManifest(value, options);
|
|
829
608
|
if (result.ok)
|
|
@@ -1066,34 +845,6 @@ export function buildBlueprint(input) {
|
|
|
1066
845
|
?? hashWorkflowSource(JSON.stringify(draft, workflowJsonReplacer));
|
|
1067
846
|
return { ...draft, source_hash: sourceHash };
|
|
1068
847
|
}
|
|
1069
|
-
export function validateJsonSchemaValue(value, schema, path = "$", maxIssues = Number.POSITIVE_INFINITY, maxVisits = Number.POSITIVE_INFINITY) {
|
|
1070
|
-
if (!schema || typeof schema !== "object" || Array.isArray(schema))
|
|
1071
|
-
return [];
|
|
1072
|
-
const issues = [];
|
|
1073
|
-
const budget = {
|
|
1074
|
-
visits: 0,
|
|
1075
|
-
maximum: Math.max(1, Math.floor(maxVisits)),
|
|
1076
|
-
exhausted: false,
|
|
1077
|
-
};
|
|
1078
|
-
validateJsonSchemaValueInto(value, schema, path, issues, Math.max(1, Math.floor(maxIssues)), budget);
|
|
1079
|
-
if (budget.exhausted) {
|
|
1080
|
-
return [{
|
|
1081
|
-
path,
|
|
1082
|
-
code: "schema_validation_too_complex",
|
|
1083
|
-
message: `${path} exceeded the JSON Schema validation work limit.`,
|
|
1084
|
-
}];
|
|
1085
|
-
}
|
|
1086
|
-
return issues;
|
|
1087
|
-
}
|
|
1088
|
-
function consumeJsonSchemaValidationBudget(budget, amount = 1) {
|
|
1089
|
-
if (budget.exhausted)
|
|
1090
|
-
return false;
|
|
1091
|
-
budget.visits += amount;
|
|
1092
|
-
if (budget.visits <= budget.maximum)
|
|
1093
|
-
return true;
|
|
1094
|
-
budget.exhausted = true;
|
|
1095
|
-
return false;
|
|
1096
|
-
}
|
|
1097
848
|
export function assertRecipeBundleSafe(bundle) {
|
|
1098
849
|
const issues = lintRecipeBundleSafety(bundle, "$.bundle");
|
|
1099
850
|
const first = issues[0];
|
|
@@ -1107,30 +858,6 @@ export function lintRecipeBundleSafety(bundle, path = "$.bundle") {
|
|
|
1107
858
|
});
|
|
1108
859
|
return issues;
|
|
1109
860
|
}
|
|
1110
|
-
/** Comment/string-aware author feedback for the stricter oxygen-js-v1 runtime. */
|
|
1111
|
-
export function lintWorkflowCodeSourceSafety(source, path = "$.source") {
|
|
1112
|
-
const issues = [];
|
|
1113
|
-
if (!source.trim()) {
|
|
1114
|
-
issues.push({ path, code: "empty_function_source", message: "Typed code source cannot be empty." });
|
|
1115
|
-
return issues;
|
|
1116
|
-
}
|
|
1117
|
-
const scan = stripCommentsAndStrings(source);
|
|
1118
|
-
if (scan.ambiguousSlash) {
|
|
1119
|
-
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." }];
|
|
1120
|
-
}
|
|
1121
|
-
const scannable = scan.source;
|
|
1122
|
-
for (const entry of UNSAFE_WORKFLOW_CODE_SOURCE_PATTERNS) {
|
|
1123
|
-
if (!entry.pattern.test(scannable))
|
|
1124
|
-
continue;
|
|
1125
|
-
issues.push({
|
|
1126
|
-
path,
|
|
1127
|
-
code: "unsafe_code_source",
|
|
1128
|
-
message: `Typed code source cannot reference '${entry.token}'. Bind deterministic JSON inputs and use explicit Tool nodes for capabilities.`,
|
|
1129
|
-
});
|
|
1130
|
-
break;
|
|
1131
|
-
}
|
|
1132
|
-
return issues;
|
|
1133
|
-
}
|
|
1134
861
|
/**
|
|
1135
862
|
* The ceiling of the legacy synchronous `node:vm` path below. It stays at 10 s
|
|
1136
863
|
* (and its callers pass 1 s) when the typed Code node rose to 30 s (repricing
|
|
@@ -1352,283 +1079,6 @@ export function getWorkflowSchema(subject = "apply") {
|
|
|
1352
1079
|
return { schemas };
|
|
1353
1080
|
return schemas[subject];
|
|
1354
1081
|
}
|
|
1355
|
-
function validateJsonSchemaValueInto(// skipcq: JS-R1005
|
|
1356
|
-
value, schema, path, issues, maxIssues, budget) {
|
|
1357
|
-
if (issues.length >= maxIssues || budget.exhausted)
|
|
1358
|
-
return;
|
|
1359
|
-
if (!consumeJsonSchemaValidationBudget(budget))
|
|
1360
|
-
return;
|
|
1361
|
-
const startCount = issues.length;
|
|
1362
|
-
if (schema.const !== undefined && !jsonEqual(value, schema.const, budget)) {
|
|
1363
|
-
addJsonSchemaValidationIssue(issues, maxIssues, {
|
|
1364
|
-
path,
|
|
1365
|
-
code: "schema_const_mismatch",
|
|
1366
|
-
message: `${path} must equal the schema const value.`,
|
|
1367
|
-
});
|
|
1368
|
-
return;
|
|
1369
|
-
}
|
|
1370
|
-
if (Array.isArray(schema.enum)
|
|
1371
|
-
&& schema.enum.length > 0
|
|
1372
|
-
&& !schema.enum.some((entry) => budget.exhausted || jsonEqual(value, entry, budget))) {
|
|
1373
|
-
addJsonSchemaValidationIssue(issues, maxIssues, {
|
|
1374
|
-
path,
|
|
1375
|
-
code: "schema_enum_mismatch",
|
|
1376
|
-
message: `${path} must be one of the allowed values.`,
|
|
1377
|
-
});
|
|
1378
|
-
return;
|
|
1379
|
-
}
|
|
1380
|
-
if (Array.isArray(schema.anyOf) && schema.anyOf.length > 0) {
|
|
1381
|
-
const matched = schema.anyOf.some((candidate) => {
|
|
1382
|
-
if (budget.exhausted)
|
|
1383
|
-
return true;
|
|
1384
|
-
const candidateIssues = [];
|
|
1385
|
-
validateJsonSchemaValueInto(value, candidate, path, candidateIssues, 1, budget);
|
|
1386
|
-
return candidateIssues.length === 0;
|
|
1387
|
-
});
|
|
1388
|
-
if (!matched) {
|
|
1389
|
-
addJsonSchemaValidationIssue(issues, maxIssues, {
|
|
1390
|
-
path,
|
|
1391
|
-
code: "schema_any_of_mismatch",
|
|
1392
|
-
message: `${path} must match at least one allowed schema.`,
|
|
1393
|
-
});
|
|
1394
|
-
return;
|
|
1395
|
-
}
|
|
1396
|
-
// A matching anyOf does not erase sibling constraints. JSON Schema applies
|
|
1397
|
-
// them together; returning here silently skipped object/array rules.
|
|
1398
|
-
}
|
|
1399
|
-
const expectedTypes = normalizeSchemaTypes(schema);
|
|
1400
|
-
if (expectedTypes.length > 0 && !expectedTypes.some((type) => matchesJsonSchemaType(value, type))) {
|
|
1401
|
-
addJsonSchemaValidationIssue(issues, maxIssues, {
|
|
1402
|
-
path,
|
|
1403
|
-
code: "schema_type_mismatch",
|
|
1404
|
-
message: `${path} must be ${formatSchemaTypes(expectedTypes)}.`,
|
|
1405
|
-
});
|
|
1406
|
-
return;
|
|
1407
|
-
}
|
|
1408
|
-
const shouldValidateObject = expectedTypes.includes("object")
|
|
1409
|
-
|| Boolean(schema.properties)
|
|
1410
|
-
|| Array.isArray(schema.required)
|
|
1411
|
-
|| schema.additionalProperties !== undefined;
|
|
1412
|
-
if (shouldValidateObject && isRecord(value)) {
|
|
1413
|
-
const properties = schema.properties ?? {};
|
|
1414
|
-
for (const requiredKey of schema.required ?? []) {
|
|
1415
|
-
if (issues.length >= maxIssues || budget.exhausted)
|
|
1416
|
-
break;
|
|
1417
|
-
if (!consumeJsonSchemaValidationBudget(budget))
|
|
1418
|
-
break;
|
|
1419
|
-
if (!Object.hasOwn(value, requiredKey) || value[requiredKey] === undefined) {
|
|
1420
|
-
addJsonSchemaValidationIssue(issues, maxIssues, {
|
|
1421
|
-
path: `${path}.${requiredKey}`,
|
|
1422
|
-
code: "schema_required",
|
|
1423
|
-
message: `${path}.${requiredKey} is required.`,
|
|
1424
|
-
});
|
|
1425
|
-
}
|
|
1426
|
-
}
|
|
1427
|
-
// Object enumeration is real host work. Charge every key before iterating so
|
|
1428
|
-
// a large output tested against many `anyOf` object candidates cannot rescan
|
|
1429
|
-
// the same object hundreds of times outside the sandbox timeout.
|
|
1430
|
-
const valueKeys = Object.keys(value);
|
|
1431
|
-
if (!consumeJsonSchemaValidationBudget(budget, valueKeys.length))
|
|
1432
|
-
return;
|
|
1433
|
-
for (const key of valueKeys) {
|
|
1434
|
-
if (issues.length >= maxIssues || budget.exhausted)
|
|
1435
|
-
break;
|
|
1436
|
-
const propertyValue = value[key];
|
|
1437
|
-
const propertySchema = Object.hasOwn(properties, key) ? properties[key] : undefined;
|
|
1438
|
-
if (isRecord(propertySchema)) {
|
|
1439
|
-
validateJsonSchemaValueInto(propertyValue, propertySchema, `${path}.${key}`, issues, maxIssues, budget);
|
|
1440
|
-
}
|
|
1441
|
-
else if (schema.additionalProperties === false) {
|
|
1442
|
-
addJsonSchemaValidationIssue(issues, maxIssues, {
|
|
1443
|
-
path: `${path}.${key}`,
|
|
1444
|
-
code: "schema_additional_property",
|
|
1445
|
-
message: `${path}.${key} is not allowed.`,
|
|
1446
|
-
});
|
|
1447
|
-
}
|
|
1448
|
-
else if (isRecord(schema.additionalProperties)) {
|
|
1449
|
-
validateJsonSchemaValueInto(propertyValue, schema.additionalProperties, `${path}.${key}`, issues, maxIssues, budget);
|
|
1450
|
-
}
|
|
1451
|
-
}
|
|
1452
|
-
}
|
|
1453
|
-
const shouldValidateArray = expectedTypes.includes("array") || Boolean(schema.items);
|
|
1454
|
-
if (shouldValidateArray && Array.isArray(value) && schema.items) {
|
|
1455
|
-
for (let index = 0; index < value.length && issues.length < maxIssues && !budget.exhausted; index += 1) {
|
|
1456
|
-
validateJsonSchemaValueInto(value[index], schema.items, `${path}.${index}`, issues, maxIssues, budget);
|
|
1457
|
-
}
|
|
1458
|
-
}
|
|
1459
|
-
if (issues.length > startCount)
|
|
1460
|
-
return;
|
|
1461
|
-
}
|
|
1462
|
-
function addJsonSchemaValidationIssue(issues, maxIssues, issue) {
|
|
1463
|
-
if (issues.length < maxIssues)
|
|
1464
|
-
issues.push(issue);
|
|
1465
|
-
}
|
|
1466
|
-
function normalizeSchemaTypes(schema) {
|
|
1467
|
-
if (Array.isArray(schema.type))
|
|
1468
|
-
return schema.type.filter((entry) => typeof entry === "string");
|
|
1469
|
-
if (typeof schema.type === "string")
|
|
1470
|
-
return [schema.type];
|
|
1471
|
-
if (schema.properties || schema.required || schema.additionalProperties !== undefined)
|
|
1472
|
-
return ["object"];
|
|
1473
|
-
if (schema.items)
|
|
1474
|
-
return ["array"];
|
|
1475
|
-
return [];
|
|
1476
|
-
}
|
|
1477
|
-
function matchesJsonSchemaType(value, type) {
|
|
1478
|
-
switch (type) {
|
|
1479
|
-
case "array":
|
|
1480
|
-
return Array.isArray(value);
|
|
1481
|
-
case "boolean":
|
|
1482
|
-
return typeof value === "boolean";
|
|
1483
|
-
case "integer":
|
|
1484
|
-
return typeof value === "number" && Number.isInteger(value);
|
|
1485
|
-
case "null":
|
|
1486
|
-
return value === null;
|
|
1487
|
-
case "number":
|
|
1488
|
-
return typeof value === "number" && Number.isFinite(value);
|
|
1489
|
-
case "object":
|
|
1490
|
-
return isRecord(value);
|
|
1491
|
-
case "string":
|
|
1492
|
-
return typeof value === "string";
|
|
1493
|
-
default:
|
|
1494
|
-
return true;
|
|
1495
|
-
}
|
|
1496
|
-
}
|
|
1497
|
-
function formatSchemaTypes(types) {
|
|
1498
|
-
if (types.length === 1)
|
|
1499
|
-
return `a ${types[0]}`;
|
|
1500
|
-
return types.map((type) => type === "null" ? "null" : `a ${type}`).join(" or ");
|
|
1501
|
-
}
|
|
1502
|
-
function jsonEqual(left, right, budget) {
|
|
1503
|
-
return jsonEqualInto(left, right, new WeakMap(), budget);
|
|
1504
|
-
}
|
|
1505
|
-
function jsonEqualInto(left, right, seen, budget) {
|
|
1506
|
-
if (!consumeJsonSchemaValidationBudget(budget))
|
|
1507
|
-
return false;
|
|
1508
|
-
if (left === right)
|
|
1509
|
-
return true;
|
|
1510
|
-
if (left === null || right === null || typeof left !== typeof right)
|
|
1511
|
-
return false;
|
|
1512
|
-
if (typeof left !== "object" || typeof right !== "object")
|
|
1513
|
-
return false;
|
|
1514
|
-
const leftArray = Array.isArray(left);
|
|
1515
|
-
if (leftArray !== Array.isArray(right))
|
|
1516
|
-
return false;
|
|
1517
|
-
const compared = seen.get(left);
|
|
1518
|
-
if (compared?.has(right))
|
|
1519
|
-
return true;
|
|
1520
|
-
if (compared)
|
|
1521
|
-
compared.add(right);
|
|
1522
|
-
else
|
|
1523
|
-
seen.set(left, new WeakSet([right]));
|
|
1524
|
-
if (leftArray) {
|
|
1525
|
-
const rightArray = right;
|
|
1526
|
-
return left.length === rightArray.length
|
|
1527
|
-
&& left.every((entry, index) => !budget.exhausted && jsonEqualInto(entry, rightArray[index], seen, budget));
|
|
1528
|
-
}
|
|
1529
|
-
const leftRecord = left;
|
|
1530
|
-
const rightRecord = right;
|
|
1531
|
-
const leftKeys = Object.keys(leftRecord);
|
|
1532
|
-
const rightKeys = Object.keys(rightRecord);
|
|
1533
|
-
if (!consumeJsonSchemaValidationBudget(budget, leftKeys.length + rightKeys.length))
|
|
1534
|
-
return false;
|
|
1535
|
-
return leftKeys.length === rightKeys.length
|
|
1536
|
-
&& leftKeys.every((key) => Object.hasOwn(rightRecord, key)
|
|
1537
|
-
&& !budget.exhausted
|
|
1538
|
-
&& jsonEqualInto(leftRecord[key], rightRecord[key], seen, budget));
|
|
1539
|
-
}
|
|
1540
|
-
// Optional idempotency_key_path (webhook + event triggers): when present it must
|
|
1541
|
-
// be a non-empty string. `label` distinguishes the trigger type in the message.
|
|
1542
|
-
function validateOptionalIdempotencyKeyPath(value, path, label, add) {
|
|
1543
|
-
if (value !== undefined && value !== null && !isNonEmptyString(value)) {
|
|
1544
|
-
add(`${path}.idempotency_key_path`, "invalid_idempotency_key_path", `${label} idempotency path is invalid.`);
|
|
1545
|
-
}
|
|
1546
|
-
}
|
|
1547
|
-
// Exported for ./graph/lint.ts — see validateOptionalMaxCredits above.
|
|
1548
|
-
export function validateTrigger(// skipcq: JS-R1005
|
|
1549
|
-
value, path, add) {
|
|
1550
|
-
if (!isRecord(value)) {
|
|
1551
|
-
add(path, "invalid_trigger", "Workflow trigger must be an object.");
|
|
1552
|
-
return;
|
|
1553
|
-
}
|
|
1554
|
-
if (value.status !== undefined && !isValidWorkflowStatus(value.status)) {
|
|
1555
|
-
add(`${path}.status`, "invalid_trigger_status", "Trigger status must be active or disabled.");
|
|
1556
|
-
}
|
|
1557
|
-
if (value.type === "api")
|
|
1558
|
-
return;
|
|
1559
|
-
if (value.type === "webhook") {
|
|
1560
|
-
if (!isNonEmptyString(value.trigger_id)) {
|
|
1561
|
-
add(`${path}.trigger_id`, "invalid_trigger_id", "Webhook trigger_id is required.");
|
|
1562
|
-
}
|
|
1563
|
-
validateOptionalIdempotencyKeyPath(value.idempotency_key_path, path, "Webhook", add);
|
|
1564
|
-
return;
|
|
1565
|
-
}
|
|
1566
|
-
if (value.type === "cron") {
|
|
1567
|
-
if (!isNonEmptyString(value.cron)) {
|
|
1568
|
-
add(`${path}.cron`, "invalid_cron", "Cron trigger cron expression is required.");
|
|
1569
|
-
}
|
|
1570
|
-
else {
|
|
1571
|
-
try {
|
|
1572
|
-
parseCronSchedule(value.cron);
|
|
1573
|
-
}
|
|
1574
|
-
catch (error) {
|
|
1575
|
-
add(`${path}.cron`, "invalid_cron", error instanceof Error ? error.message : "Cron expression is invalid.");
|
|
1576
|
-
}
|
|
1577
|
-
}
|
|
1578
|
-
// Validate the timezone here so an unknown zone fails lint with a typed
|
|
1579
|
-
// issue, rather than passing lint and blowing up at apply time (the
|
|
1580
|
-
// scheduler's Intl.DateTimeFormat throws on an unknown zone). null/empty
|
|
1581
|
-
// are allowed — the scheduler falls back to UTC.
|
|
1582
|
-
const { timezone } = value;
|
|
1583
|
-
if (timezone !== undefined && timezone !== null) {
|
|
1584
|
-
if (typeof timezone !== "string") {
|
|
1585
|
-
add(`${path}.timezone`, "invalid_timezone", "Cron trigger timezone must be a string IANA timezone.");
|
|
1586
|
-
}
|
|
1587
|
-
else if (timezone.trim() && !isValidTimeZone(timezone.trim())) {
|
|
1588
|
-
add(`${path}.timezone`, "invalid_timezone", `Unknown timezone '${timezone}'. Use an IANA timezone such as 'America/New_York' or 'UTC'.`);
|
|
1589
|
-
}
|
|
1590
|
-
}
|
|
1591
|
-
return;
|
|
1592
|
-
}
|
|
1593
|
-
if (value.type === "event") {
|
|
1594
|
-
if (!isNonEmptyString(value.source)) {
|
|
1595
|
-
add(`${path}.source`, "invalid_event_source", "Event trigger source is required.");
|
|
1596
|
-
}
|
|
1597
|
-
if (!isNonEmptyString(value.event)) {
|
|
1598
|
-
add(`${path}.event`, "invalid_event_type", "Event trigger event is required.");
|
|
1599
|
-
}
|
|
1600
|
-
validateOptionalIdempotencyKeyPath(value.idempotency_key_path, path, "Event", add);
|
|
1601
|
-
if (value.filters !== undefined)
|
|
1602
|
-
validateEventFilters(value.filters, `${path}.filters`, add);
|
|
1603
|
-
return;
|
|
1604
|
-
}
|
|
1605
|
-
add(`${path}.type`, "invalid_trigger_type", "Trigger type must be api, webhook, cron, or event.");
|
|
1606
|
-
}
|
|
1607
|
-
function validateEventFilters(value, path, add) {
|
|
1608
|
-
if (!Array.isArray(value)) {
|
|
1609
|
-
add(path, "invalid_event_filters", "Event trigger filters must be an array.");
|
|
1610
|
-
return;
|
|
1611
|
-
}
|
|
1612
|
-
value.forEach((filter, index) => {
|
|
1613
|
-
const filterPath = `${path}.${index}`;
|
|
1614
|
-
if (!isRecord(filter)) {
|
|
1615
|
-
add(filterPath, "invalid_event_filter", "Event trigger filter must be an object.");
|
|
1616
|
-
return;
|
|
1617
|
-
}
|
|
1618
|
-
if (!isNonEmptyString(filter.path)) {
|
|
1619
|
-
add(`${filterPath}.path`, "invalid_event_filter_path", "Event filter path is required.");
|
|
1620
|
-
}
|
|
1621
|
-
if (filter.op !== "eq"
|
|
1622
|
-
&& filter.op !== "neq"
|
|
1623
|
-
&& filter.op !== "exists"
|
|
1624
|
-
&& filter.op !== "not_exists") {
|
|
1625
|
-
add(`${filterPath}.op`, "invalid_event_filter_op", "Event filter op is invalid.");
|
|
1626
|
-
}
|
|
1627
|
-
if ((filter.op === "eq" || filter.op === "neq") && !Object.hasOwn(filter, "value")) {
|
|
1628
|
-
add(`${filterPath}.value`, "missing_event_filter_value", "Event eq/neq filters require a value.");
|
|
1629
|
-
}
|
|
1630
|
-
});
|
|
1631
|
-
}
|
|
1632
1082
|
function serializeWorkflowFunction(fn, path) {
|
|
1633
1083
|
if (typeof fn !== "function") {
|
|
1634
1084
|
throw new Error(`${path} must be a function.`);
|
|
@@ -1644,333 +1094,7 @@ function serializeWorkflowFunction(fn, path) {
|
|
|
1644
1094
|
}
|
|
1645
1095
|
return source;
|
|
1646
1096
|
}
|
|
1647
|
-
function validateBranchTarget(target, path, fieldLabel, branchIndex, idToIndex, add) {
|
|
1648
|
-
if (typeof target !== "string" || target.trim().length === 0) {
|
|
1649
|
-
add(path, `missing_branch_${fieldLabel}`, `Branch step ${fieldLabel} is required.`);
|
|
1650
|
-
return;
|
|
1651
|
-
}
|
|
1652
|
-
const targetIndex = idToIndex.get(target);
|
|
1653
|
-
if (targetIndex === undefined) {
|
|
1654
|
-
add(path, "invalid_branch_target", `Branch ${fieldLabel} references unknown step id '${target}'.`);
|
|
1655
|
-
return;
|
|
1656
|
-
}
|
|
1657
|
-
if (targetIndex <= branchIndex) {
|
|
1658
|
-
add(path, "branch_back_jump", `Branch ${fieldLabel} must reference a step that comes after the branch in declared order.`);
|
|
1659
|
-
}
|
|
1660
|
-
}
|
|
1661
|
-
// Exported for ./graph/lint.ts — see validateOptionalMaxCredits above. v2 `code`
|
|
1662
|
-
// nodes are the v2 spelling of a v1 transform step and must clear the identical
|
|
1663
|
-
// purity scan; the graph linter re-labels the issues it raises as
|
|
1664
|
-
// `unsafe_code_source`.
|
|
1665
|
-
export function validatePureFunctionSource(source, path, add) {
|
|
1666
|
-
if (!source.trim()) {
|
|
1667
|
-
add(path, "empty_function_source", "Workflow function source cannot be empty.");
|
|
1668
|
-
return;
|
|
1669
|
-
}
|
|
1670
|
-
const forbidden = [
|
|
1671
|
-
"import",
|
|
1672
|
-
"require",
|
|
1673
|
-
"process",
|
|
1674
|
-
"global",
|
|
1675
|
-
"globalThis",
|
|
1676
|
-
"fetch",
|
|
1677
|
-
"XMLHttpRequest",
|
|
1678
|
-
"Function",
|
|
1679
|
-
"eval",
|
|
1680
|
-
"constructor",
|
|
1681
|
-
"setTimeout",
|
|
1682
|
-
"setInterval",
|
|
1683
|
-
];
|
|
1684
|
-
for (const token of forbidden) {
|
|
1685
|
-
const pattern = new RegExp(`\\b${escapeRegExp(token)}\\b`);
|
|
1686
|
-
if (pattern.test(source)) {
|
|
1687
|
-
add(path, "impure_workflow_function", `Workflow function source cannot reference '${token}'.`);
|
|
1688
|
-
return;
|
|
1689
|
-
}
|
|
1690
|
-
}
|
|
1691
|
-
}
|
|
1692
|
-
// Blank out comment bodies and string/template-literal *text* so the unsafe-token
|
|
1693
|
-
// scan matches only real code identifiers — not a bundle comment ("closed-loop
|
|
1694
|
-
// eval") or a string ("retrieval"), which the raw \b-boundary scan flagged as
|
|
1695
|
-
// false positives. A real eval(...) or new Function(...) — including inside a
|
|
1696
|
-
// `${ ... }` template interpolation, which stays code — is still caught.
|
|
1697
|
-
// @oxygen/workflows ships no AST parser, so this is a small hand-rolled lexer;
|
|
1698
|
-
// the vm sandbox + runtime global guards remain the actual security boundary.
|
|
1699
|
-
function stripCommentsAndStrings(source) {
|
|
1700
|
-
const out = [];
|
|
1701
|
-
const stack = [{ mode: "code", braces: 0 }];
|
|
1702
|
-
const expressionKeywords = new Set(["return", "throw", "case", "delete", "void", "typeof", "yield", "await", "in", "instanceof", "else", "do"]);
|
|
1703
|
-
const controlKeywords = new Set(["if", "while", "for", "with", "switch", "catch"]);
|
|
1704
|
-
const statementBlockKeywords = new Set(["else", "do", "try", "finally", "catch"]);
|
|
1705
|
-
const braceKinds = [];
|
|
1706
|
-
const controlParens = [];
|
|
1707
|
-
let regexAllowed = true;
|
|
1708
|
-
let ambiguousAfterBrace = false;
|
|
1709
|
-
let previousToken = "";
|
|
1710
|
-
let previousWordEnd = 0;
|
|
1711
|
-
let i = 0;
|
|
1712
|
-
const n = source.length;
|
|
1713
|
-
while (i < n) {
|
|
1714
|
-
const top = stack[stack.length - 1];
|
|
1715
|
-
const ch = source[i];
|
|
1716
|
-
const next = i + 1 < n ? source[i + 1] : "";
|
|
1717
|
-
if (top.mode === "template") {
|
|
1718
|
-
if (ch === "\\") {
|
|
1719
|
-
i += 2;
|
|
1720
|
-
continue;
|
|
1721
|
-
}
|
|
1722
|
-
if (ch === "`") {
|
|
1723
|
-
stack.pop();
|
|
1724
|
-
regexAllowed = false;
|
|
1725
|
-
previousToken = "literal";
|
|
1726
|
-
i += 1;
|
|
1727
|
-
continue;
|
|
1728
|
-
}
|
|
1729
|
-
if (ch === "$" && next === "{") {
|
|
1730
|
-
stack.push({ mode: "code", braces: 0 });
|
|
1731
|
-
regexAllowed = true;
|
|
1732
|
-
previousToken = "";
|
|
1733
|
-
out.push(" ");
|
|
1734
|
-
i += 2;
|
|
1735
|
-
continue;
|
|
1736
|
-
}
|
|
1737
|
-
i += 1; // drop template text
|
|
1738
|
-
continue;
|
|
1739
|
-
}
|
|
1740
|
-
if (ch === "/" && next === "/") {
|
|
1741
|
-
i += 2;
|
|
1742
|
-
while (i < n && source[i] !== "\n")
|
|
1743
|
-
i += 1;
|
|
1744
|
-
continue;
|
|
1745
|
-
}
|
|
1746
|
-
if (ch === "/" && next === "*") {
|
|
1747
|
-
i += 2;
|
|
1748
|
-
while (i < n && !(source[i] === "*" && source[i + 1] === "/"))
|
|
1749
|
-
i += 1;
|
|
1750
|
-
i = Math.min(i + 2, n);
|
|
1751
|
-
continue;
|
|
1752
|
-
}
|
|
1753
|
-
if (ch === "/" && ambiguousAfterBrace)
|
|
1754
|
-
return { source: out.join(""), ambiguousSlash: true };
|
|
1755
|
-
if (!/\s/.test(ch))
|
|
1756
|
-
ambiguousAfterBrace = false;
|
|
1757
|
-
// Regex quotes must not make the string scanner swallow executable code.
|
|
1758
|
-
if (ch === "/" && regexAllowed) {
|
|
1759
|
-
let end = i + 1;
|
|
1760
|
-
let characterClass = false;
|
|
1761
|
-
while (end < n && source[end] !== "\n" && source[end] !== "\r") {
|
|
1762
|
-
const current = source[end];
|
|
1763
|
-
if (current === "\\") {
|
|
1764
|
-
end += 2;
|
|
1765
|
-
continue;
|
|
1766
|
-
}
|
|
1767
|
-
if (current === "[")
|
|
1768
|
-
characterClass = true;
|
|
1769
|
-
else if (current === "]")
|
|
1770
|
-
characterClass = false;
|
|
1771
|
-
else if (current === "/" && !characterClass)
|
|
1772
|
-
break;
|
|
1773
|
-
end += 1;
|
|
1774
|
-
}
|
|
1775
|
-
if (end < n && source[end] === "/") {
|
|
1776
|
-
end += 1;
|
|
1777
|
-
while (end < n && /[a-z]/i.test(source[end]))
|
|
1778
|
-
end += 1;
|
|
1779
|
-
out.push('""');
|
|
1780
|
-
i = end;
|
|
1781
|
-
regexAllowed = false;
|
|
1782
|
-
previousToken = "literal";
|
|
1783
|
-
continue;
|
|
1784
|
-
}
|
|
1785
|
-
}
|
|
1786
|
-
if (ch === '"' || ch === "'") {
|
|
1787
|
-
const quote = ch;
|
|
1788
|
-
i += 1;
|
|
1789
|
-
while (i < n && source[i] !== quote)
|
|
1790
|
-
i += source[i] === "\\" ? 2 : 1;
|
|
1791
|
-
i += 1;
|
|
1792
|
-
out.push('""');
|
|
1793
|
-
regexAllowed = false;
|
|
1794
|
-
previousToken = "literal";
|
|
1795
|
-
continue;
|
|
1796
|
-
}
|
|
1797
|
-
if (ch === "`") {
|
|
1798
|
-
stack.push({ mode: "template" });
|
|
1799
|
-
i += 1;
|
|
1800
|
-
continue;
|
|
1801
|
-
}
|
|
1802
|
-
if (/[a-z_$]/i.test(ch)) {
|
|
1803
|
-
const start = i;
|
|
1804
|
-
while (i < n && /[\w$]/.test(source[i]))
|
|
1805
|
-
i += 1;
|
|
1806
|
-
const word = source.slice(start, i);
|
|
1807
|
-
out.push(word);
|
|
1808
|
-
previousToken = previousToken === "." ? "identifier" : word;
|
|
1809
|
-
previousWordEnd = i;
|
|
1810
|
-
regexAllowed = expressionKeywords.has(previousToken);
|
|
1811
|
-
continue;
|
|
1812
|
-
}
|
|
1813
|
-
if (ch === "}" && top.braces === 0 && stack.length > 1) {
|
|
1814
|
-
stack.pop();
|
|
1815
|
-
out.push(" ");
|
|
1816
|
-
i += 1;
|
|
1817
|
-
continue;
|
|
1818
|
-
}
|
|
1819
|
-
if (ch === "=" && next === ">") {
|
|
1820
|
-
out.push("=>");
|
|
1821
|
-
previousToken = "=>";
|
|
1822
|
-
regexAllowed = true;
|
|
1823
|
-
i += 2;
|
|
1824
|
-
continue;
|
|
1825
|
-
}
|
|
1826
|
-
if (ch === "{") {
|
|
1827
|
-
const enclosing = braceKinds[braceKinds.length - 1];
|
|
1828
|
-
let kind = "unknown";
|
|
1829
|
-
if ((previousToken === ")" && regexAllowed) || statementBlockKeywords.has(previousToken)
|
|
1830
|
-
|| previousToken === ";" || (previousToken === "{" && (enclosing === "statement" || enclosing === "function")))
|
|
1831
|
-
kind = "statement";
|
|
1832
|
-
else if (previousToken === "=>")
|
|
1833
|
-
kind = "function";
|
|
1834
|
-
else if (["=", "(", "[", ","].includes(previousToken) || (previousToken === ":" && enclosing === "object")
|
|
1835
|
-
|| (previousToken === "return" && !/[\r\n]/.test(source.slice(previousWordEnd, i))))
|
|
1836
|
-
kind = "object";
|
|
1837
|
-
braceKinds.push(kind);
|
|
1838
|
-
}
|
|
1839
|
-
if (ch === "(")
|
|
1840
|
-
controlParens.push(controlKeywords.has(previousToken));
|
|
1841
|
-
if (ch === ")")
|
|
1842
|
-
regexAllowed = controlParens.pop() ?? false;
|
|
1843
|
-
else if (ch === "}") {
|
|
1844
|
-
const kind = braceKinds.pop();
|
|
1845
|
-
regexAllowed = kind === "statement";
|
|
1846
|
-
// Other brace forms need a parser to distinguish declarations from expressions.
|
|
1847
|
-
ambiguousAfterBrace = kind === "unknown";
|
|
1848
|
-
}
|
|
1849
|
-
else if (!/\s/.test(ch)) {
|
|
1850
|
-
if (!((ch === "+" || ch === "-") && (next === ch || previousToken === ch))) {
|
|
1851
|
-
regexAllowed = /[([{,:;=!?&|+*%^~<>\/-]/.test(ch);
|
|
1852
|
-
}
|
|
1853
|
-
}
|
|
1854
|
-
if (!/\s/.test(ch))
|
|
1855
|
-
previousToken = ch;
|
|
1856
|
-
if (ch === "{")
|
|
1857
|
-
top.braces += 1;
|
|
1858
|
-
else if (ch === "}")
|
|
1859
|
-
top.braces = Math.max(0, top.braces - 1);
|
|
1860
|
-
out.push(ch);
|
|
1861
|
-
i += 1;
|
|
1862
|
-
}
|
|
1863
|
-
return { source: out.join(""), ambiguousSlash: false };
|
|
1864
|
-
}
|
|
1865
|
-
function validateRecipeBundleSafety(source, path, add) {
|
|
1866
|
-
if (!source.trim()) {
|
|
1867
|
-
add(path, "empty_recipe_bundle", "Recipe bundle cannot be empty.");
|
|
1868
|
-
return;
|
|
1869
|
-
}
|
|
1870
|
-
// Scan only real code: comments and string literals are blanked first so a
|
|
1871
|
-
// token that merely appears in prose or data (e.g. "eval" in a comment) does
|
|
1872
|
-
// not trip the lint, while genuine calls survive.
|
|
1873
|
-
const scan = stripCommentsAndStrings(source);
|
|
1874
|
-
if (scan.ambiguousSlash) {
|
|
1875
|
-
add(path, "unsafe_recipe_bundle", "Durable recipe bundle has an ambiguous slash after a brace. Parenthesize the expression or separate statements with a semicolon.");
|
|
1876
|
-
return;
|
|
1877
|
-
}
|
|
1878
|
-
const scannable = scan.source;
|
|
1879
|
-
for (const entry of UNSAFE_RECIPE_BUNDLE_PATTERNS) {
|
|
1880
|
-
if (entry.pattern.test(scannable)) {
|
|
1881
|
-
add(path, "unsafe_recipe_bundle", `Durable recipe bundle cannot reference '${entry.token}'. Use ctx.tools.run(), ctx.step(), ctx.now(), or ctx.uuid() instead.`);
|
|
1882
|
-
return;
|
|
1883
|
-
}
|
|
1884
|
-
}
|
|
1885
|
-
}
|
|
1886
|
-
// Exported for ./graph/lint.ts — see validateOptionalMaxCredits above. One deny
|
|
1887
|
-
// list, enforced identically for v1 tool steps and v2 tool nodes.
|
|
1888
|
-
export function isWorkflowToolRejected(toolId) {
|
|
1889
|
-
return toolId === "run_javascript" || toolId === "custom_http";
|
|
1890
|
-
}
|
|
1891
|
-
const CRON_FIELD_LIMITS = [
|
|
1892
|
-
{ name: "minute", min: 0, max: 59 },
|
|
1893
|
-
{ name: "hour", min: 0, max: 23 },
|
|
1894
|
-
{ name: "day-of-month", min: 1, max: 31 },
|
|
1895
|
-
{ name: "month", min: 1, max: 12 },
|
|
1896
|
-
{ name: "day-of-week", min: 0, max: 7 },
|
|
1897
|
-
];
|
|
1898
1097
|
const zonedFormatters = new Map();
|
|
1899
|
-
function parseCronSchedule(value) {
|
|
1900
|
-
const parts = value.trim().split(/\s+/);
|
|
1901
|
-
if (parts.length !== 5) {
|
|
1902
|
-
throw new Error("Cron expression must have five space-separated parts.");
|
|
1903
|
-
}
|
|
1904
|
-
const [minute, hour, dayOfMonth, month, dayOfWeek] = parts;
|
|
1905
|
-
if (!minute || !hour || !dayOfMonth || !month || !dayOfWeek) {
|
|
1906
|
-
throw new Error("Cron expression must have five space-separated parts.");
|
|
1907
|
-
}
|
|
1908
|
-
const minutes = parseCronField(minute, CRON_FIELD_LIMITS[0]);
|
|
1909
|
-
const hours = parseCronField(hour, CRON_FIELD_LIMITS[1]);
|
|
1910
|
-
const daysOfMonth = parseCronField(dayOfMonth, CRON_FIELD_LIMITS[2]);
|
|
1911
|
-
const months = parseCronField(month, CRON_FIELD_LIMITS[3]);
|
|
1912
|
-
const daysOfWeek = normalizeDaysOfWeek(parseCronField(dayOfWeek, CRON_FIELD_LIMITS[4]));
|
|
1913
|
-
return {
|
|
1914
|
-
minutes,
|
|
1915
|
-
hours,
|
|
1916
|
-
daysOfMonth,
|
|
1917
|
-
months,
|
|
1918
|
-
daysOfWeek,
|
|
1919
|
-
dayOfMonthRestricted: dayOfMonth !== "*",
|
|
1920
|
-
dayOfWeekRestricted: dayOfWeek !== "*",
|
|
1921
|
-
};
|
|
1922
|
-
}
|
|
1923
|
-
function parseCronField(expression, limits) {
|
|
1924
|
-
const values = new Set();
|
|
1925
|
-
for (const rawToken of expression.split(",")) {
|
|
1926
|
-
const token = rawToken.trim();
|
|
1927
|
-
if (!token)
|
|
1928
|
-
throw new Error(`Cron ${limits.name} field contains an empty item.`);
|
|
1929
|
-
const parts = token.split("/");
|
|
1930
|
-
const rangePart = parts[0];
|
|
1931
|
-
const stepPart = parts[1];
|
|
1932
|
-
if (!rangePart || parts.length > 2) {
|
|
1933
|
-
throw new Error(`Cron ${limits.name} field is invalid.`);
|
|
1934
|
-
}
|
|
1935
|
-
const step = stepPart === undefined ? 1 : Number(stepPart);
|
|
1936
|
-
if (!Number.isInteger(step) || step < 1) {
|
|
1937
|
-
throw new Error(`Cron ${limits.name} step must be a positive integer.`);
|
|
1938
|
-
}
|
|
1939
|
-
const [start, end] = parseCronRange(rangePart, limits);
|
|
1940
|
-
for (let current = start; current <= end; current += step) {
|
|
1941
|
-
values.add(current);
|
|
1942
|
-
}
|
|
1943
|
-
}
|
|
1944
|
-
if (values.size === 0)
|
|
1945
|
-
throw new Error(`Cron ${limits.name} field is empty.`);
|
|
1946
|
-
return values;
|
|
1947
|
-
}
|
|
1948
|
-
function parseCronRange(value, limits) {
|
|
1949
|
-
if (value === "*")
|
|
1950
|
-
return [limits.min, limits.max];
|
|
1951
|
-
const parts = value.split("-");
|
|
1952
|
-
const startRaw = parts[0];
|
|
1953
|
-
const endRaw = parts[1];
|
|
1954
|
-
if (!startRaw || parts.length > 2) {
|
|
1955
|
-
throw new Error(`Cron ${limits.name} range is invalid.`);
|
|
1956
|
-
}
|
|
1957
|
-
const start = Number(startRaw);
|
|
1958
|
-
const end = endRaw === undefined ? start : Number(endRaw);
|
|
1959
|
-
if (!Number.isInteger(start) || !Number.isInteger(end)) {
|
|
1960
|
-
throw new Error(`Cron ${limits.name} values must be integers.`);
|
|
1961
|
-
}
|
|
1962
|
-
if (start < limits.min || end > limits.max || start > end) {
|
|
1963
|
-
throw new Error(`Cron ${limits.name} values must be between ${limits.min} and ${limits.max}.`);
|
|
1964
|
-
}
|
|
1965
|
-
return [start, end];
|
|
1966
|
-
}
|
|
1967
|
-
function normalizeDaysOfWeek(values) {
|
|
1968
|
-
const normalized = new Set();
|
|
1969
|
-
for (const value of values) {
|
|
1970
|
-
normalized.add(value === 7 ? 0 : value);
|
|
1971
|
-
}
|
|
1972
|
-
return normalized;
|
|
1973
|
-
}
|
|
1974
1098
|
// Date-only match (month + day-of-month/day-of-week), excluding hour/minute.
|
|
1975
1099
|
// Lets nextCronRunAfter skip whole non-matching days in one jump.
|
|
1976
1100
|
function matchesCronDate(schedule, parts) {
|
|
@@ -2013,17 +1137,6 @@ function zonedDateParts(date, timezone) {
|
|
|
2013
1137
|
dayOfWeek: weekdayToNumber(parts.get("weekday") ?? ""),
|
|
2014
1138
|
};
|
|
2015
1139
|
}
|
|
2016
|
-
function isValidTimeZone(timezone) {
|
|
2017
|
-
try {
|
|
2018
|
-
// Throws RangeError for an unknown IANA zone; same mechanism the scheduler
|
|
2019
|
-
// uses, so lint accepts exactly the zones the runtime can resolve.
|
|
2020
|
-
new Intl.DateTimeFormat("en-US", { timeZone: timezone }).format(0);
|
|
2021
|
-
return true;
|
|
2022
|
-
}
|
|
2023
|
-
catch {
|
|
2024
|
-
return false;
|
|
2025
|
-
}
|
|
2026
|
-
}
|
|
2027
1140
|
function getZonedFormatter(timezone) {
|
|
2028
1141
|
const cached = zonedFormatters.get(timezone);
|
|
2029
1142
|
if (cached)
|
|
@@ -2121,16 +1234,3 @@ async function withTimeout(promise, timeoutMs) {
|
|
|
2121
1234
|
clearTimeout(timer);
|
|
2122
1235
|
}
|
|
2123
1236
|
}
|
|
2124
|
-
function isRecord(value) {
|
|
2125
|
-
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
2126
|
-
}
|
|
2127
|
-
function isNonEmptyString(value) {
|
|
2128
|
-
return typeof value === "string" && value.trim().length > 0;
|
|
2129
|
-
}
|
|
2130
|
-
// The canonical list of internal workflow tool ids lives in @oxygen/tools
|
|
2131
|
-
// (OXYGEN_INTERNAL_WORKFLOW_TOOL_IDS). Both the worker's runtime registry and the
|
|
2132
|
-
// web's lint allowlist derive from it, so re-declaring it here would recreate
|
|
2133
|
-
// exactly the drift that broke crm-sync.
|
|
2134
|
-
function escapeRegExp(value) {
|
|
2135
|
-
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2136
|
-
}
|