@oxygen-agent/cli 1.1014.1997 → 1.1014.2040
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/command-families/tables/options.d.ts +1 -0
- package/dist/command-families/tables/register-automation.js +3 -1
- package/dist/commands/observability.js +4 -4
- package/dist/commands/table-runs.js +10 -0
- package/dist/commands/tags.js +2 -2
- package/dist/commands/workflows.js +31 -10
- package/dist/http-client.d.ts +1 -1
- package/dist/http-client.js +1 -1
- package/node_modules/@oxygen/formula/dist/cross-row-function.d.ts +13 -0
- package/node_modules/@oxygen/formula/dist/cross-row-function.js +1 -0
- package/node_modules/@oxygen/formula/dist/{refactor-internals → cross-row-functions}/novelty-score.d.ts +2 -0
- package/node_modules/@oxygen/formula/dist/{refactor-internals → cross-row-functions}/novelty-score.js +1 -0
- package/node_modules/@oxygen/formula/dist/cross-row-functions.generated.d.ts +3 -0
- package/node_modules/@oxygen/formula/dist/cross-row-functions.generated.js +3 -0
- package/node_modules/@oxygen/formula/dist/evaluate.d.ts +12 -1
- package/node_modules/@oxygen/formula/dist/evaluate.js +28 -3
- package/node_modules/@oxygen/recipe-sdk/dist/index.d.ts +2 -0
- package/node_modules/@oxygen/shared/dist/capability-discovery.js +1 -1
- package/node_modules/@oxygen/shared/dist/cell-format.js +2 -2
- package/node_modules/@oxygen/shared/dist/collab.d.ts +1 -1
- package/node_modules/@oxygen/shared/dist/contracts/geo.js +1 -1
- package/node_modules/@oxygen/shared/dist/dnc-identities.js +1 -1
- package/node_modules/@oxygen/shared/dist/error-redaction.d.ts +1 -1
- package/node_modules/@oxygen/shared/dist/error-redaction.js +2 -2
- package/node_modules/@oxygen/shared/dist/esp-contract.d.ts +133 -0
- package/node_modules/@oxygen/shared/dist/esp-contract.js +121 -0
- package/node_modules/@oxygen/shared/dist/{geo.js → geo/geo.js} +2 -2
- package/node_modules/@oxygen/shared/dist/index.d.ts +6 -5
- package/node_modules/@oxygen/shared/dist/index.js +7 -5
- package/node_modules/@oxygen/shared/dist/knowledge-bootstrap.js +1 -1
- package/node_modules/@oxygen/shared/dist/linkedin-connection-identity.js +1 -1
- package/node_modules/@oxygen/shared/dist/{sending-domain-rollout.js → mailboxes/sending-domain-rollout.js} +1 -1
- package/node_modules/@oxygen/shared/dist/mcp-event-contract.js +1 -1
- package/node_modules/@oxygen/shared/dist/{social-post-metrics-core.d.ts → posts/metrics-core.d.ts} +1 -1
- package/node_modules/@oxygen/shared/dist/{social-post-metrics-linkedin.d.ts → posts/metrics-linkedin.d.ts} +1 -1
- package/node_modules/@oxygen/shared/dist/{social-post-metrics-linkedin.js → posts/metrics-linkedin.js} +2 -2
- package/node_modules/@oxygen/shared/dist/{social-post-metrics-series.d.ts → posts/metrics-series.d.ts} +1 -1
- package/node_modules/@oxygen/shared/dist/{social-post-metrics-series.js → posts/metrics-series.js} +1 -1
- package/node_modules/@oxygen/shared/dist/{social-post-metrics-x.d.ts → posts/metrics-x.d.ts} +1 -1
- package/node_modules/@oxygen/shared/dist/{social-post-metrics-x.js → posts/metrics-x.js} +2 -2
- package/node_modules/@oxygen/shared/dist/{social-post-metrics.d.ts → posts/metrics.d.ts} +3 -3
- package/node_modules/@oxygen/shared/dist/{social-post-metrics.js → posts/metrics.js} +3 -3
- package/node_modules/@oxygen/shared/dist/recipient-provider.d.ts +2 -10
- package/node_modules/@oxygen/shared/dist/recipient-provider.js +1 -9
- package/node_modules/@oxygen/shared/dist/sequence-internals/esp-policy.d.ts +2 -118
- package/node_modules/@oxygen/shared/dist/sequence-internals/esp-policy.js +2 -107
- package/node_modules/@oxygen/shared/dist/sequences.d.ts +0 -1
- package/node_modules/@oxygen/shared/dist/sequences.js +0 -2
- package/node_modules/@oxygen/shared/dist/{native-chat-discovery.d.ts → support/native-chat-discovery.d.ts} +1 -1
- package/node_modules/@oxygen/shared/dist/{native-chat-discovery.js → support/native-chat-discovery.js} +1 -1
- package/node_modules/@oxygen/shared/dist/suppression-entries.js +1 -1
- package/node_modules/@oxygen/shared/dist/table-field-types.d.ts +1 -1
- package/node_modules/@oxygen/shared/dist/table-field-types.js +2 -2
- package/node_modules/@oxygen/shared/dist/{column-output-fields.js → tables/column-output-fields.js} +4 -4
- package/node_modules/@oxygen/shared/dist/{tags.d.ts → tags/tags.d.ts} +1 -1
- package/node_modules/@oxygen/shared/dist/{tags.js → tags/tags.js} +1 -1
- package/node_modules/@oxygen/shared/dist/ugc-amplification-identity.js +1 -1
- 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/shared/dist/workspace-placement-bulk.d.ts +6 -0
- package/node_modules/@oxygen/shared/dist/workspace-placement-bulk.js +9 -2
- package/node_modules/@oxygen/shared/dist/workspace-placement-schedule.d.ts +44 -0
- package/node_modules/@oxygen/shared/dist/workspace-placement-schedule.js +90 -0
- package/node_modules/@oxygen/shared/dist/workspace-placement-view.d.ts +24 -0
- package/node_modules/@oxygen/shared/dist/workspace-placement-view.js +5 -4
- package/node_modules/@oxygen/shared/dist/workspace-placement.d.ts +4 -0
- package/node_modules/@oxygen/shared/dist/workspace-placement.js +7 -1
- package/node_modules/@oxygen/shared/package.json +0 -25
- package/node_modules/@oxygen/workflows/dist/cron.d.ts +42 -0
- package/node_modules/@oxygen/workflows/dist/cron.js +271 -0
- package/node_modules/@oxygen/workflows/dist/event-dispatch.d.ts +2 -1
- package/node_modules/@oxygen/workflows/dist/graph/condition.d.ts +3 -0
- package/node_modules/@oxygen/workflows/dist/graph/condition.js +19 -0
- package/node_modules/@oxygen/workflows/dist/graph/expression.d.ts +1 -2
- package/node_modules/@oxygen/workflows/dist/graph/expression.js +2 -19
- package/node_modules/@oxygen/workflows/dist/graph/types.d.ts +4 -3
- package/node_modules/@oxygen/workflows/dist/index.d.ts +8 -985
- package/node_modules/@oxygen/workflows/dist/index.js +8 -1221
- package/node_modules/@oxygen/workflows/dist/manifest-builders.d.ts +73 -0
- package/node_modules/@oxygen/workflows/dist/manifest-builders.js +102 -0
- package/node_modules/@oxygen/workflows/dist/manifest-guards.d.ts +16 -0
- package/node_modules/@oxygen/workflows/dist/manifest-guards.js +34 -0
- package/node_modules/@oxygen/workflows/dist/manifest-hash.d.ts +47 -0
- package/node_modules/@oxygen/workflows/dist/manifest-hash.js +102 -0
- package/node_modules/@oxygen/workflows/dist/manifest-lint.d.ts +17 -0
- package/node_modules/@oxygen/workflows/dist/manifest-lint.js +474 -0
- package/node_modules/@oxygen/workflows/dist/manifest-types.d.ts +256 -0
- package/node_modules/@oxygen/workflows/dist/manifest-types.js +9 -0
- package/node_modules/@oxygen/workflows/dist/pure-function.d.ts +17 -0
- package/node_modules/@oxygen/workflows/dist/pure-function.js +130 -0
- package/node_modules/@oxygen/workflows/dist/refactor-internals/condition-comparison.d.ts +1 -17
- package/node_modules/@oxygen/workflows/dist/refactor-internals/condition-comparison.js +1 -93
- package/node_modules/@oxygen/workflows/dist/refactor-internals/condition-pattern.d.ts +16 -0
- package/node_modules/@oxygen/workflows/dist/refactor-internals/condition-pattern.js +92 -0
- package/node_modules/@oxygen/workflows/dist/workflow-schemas.d.ts +545 -0
- package/node_modules/@oxygen/workflows/dist/workflow-schemas.js +135 -0
- package/node_modules/@oxygen/workflows/package.json +4 -0
- package/package.json +1 -1
- /package/node_modules/@oxygen/shared/dist/{geo.d.ts → geo/geo.d.ts} +0 -0
- /package/node_modules/@oxygen/shared/dist/{sending-domain-rollout.d.ts → mailboxes/sending-domain-rollout.d.ts} +0 -0
- /package/node_modules/@oxygen/shared/dist/{attempt-provenance.d.ts → observability/attempt-provenance.d.ts} +0 -0
- /package/node_modules/@oxygen/shared/dist/{attempt-provenance.js → observability/attempt-provenance.js} +0 -0
- /package/node_modules/@oxygen/shared/dist/{linkedin-mentions.d.ts → posts/linkedin-mentions.d.ts} +0 -0
- /package/node_modules/@oxygen/shared/dist/{linkedin-mentions.js → posts/linkedin-mentions.js} +0 -0
- /package/node_modules/@oxygen/shared/dist/{linkedin-post-keywords.d.ts → posts/linkedin-post-keywords.d.ts} +0 -0
- /package/node_modules/@oxygen/shared/dist/{linkedin-post-keywords.js → posts/linkedin-post-keywords.js} +0 -0
- /package/node_modules/@oxygen/shared/dist/{linkedin-post-url.d.ts → posts/linkedin-post-url.d.ts} +0 -0
- /package/node_modules/@oxygen/shared/dist/{linkedin-post-url.js → posts/linkedin-post-url.js} +0 -0
- /package/node_modules/@oxygen/shared/dist/{social-post-metrics-core.js → posts/metrics-core.js} +0 -0
- /package/node_modules/@oxygen/shared/dist/{native-chat.d.ts → support/native-chat.d.ts} +0 -0
- /package/node_modules/@oxygen/shared/dist/{native-chat.js → support/native-chat.js} +0 -0
- /package/node_modules/@oxygen/shared/dist/{plain-support-events.d.ts → support/plain-support-events.d.ts} +0 -0
- /package/node_modules/@oxygen/shared/dist/{plain-support-events.js → support/plain-support-events.js} +0 -0
- /package/node_modules/@oxygen/shared/dist/{column-output-fields.d.ts → tables/column-output-fields.d.ts} +0 -0
- /package/node_modules/@oxygen/shared/dist/{linkedin-url.d.ts → tables/linkedin-url.d.ts} +0 -0
- /package/node_modules/@oxygen/shared/dist/{linkedin-url.js → tables/linkedin-url.js} +0 -0
- /package/node_modules/@oxygen/shared/dist/{select-options.d.ts → tables/select-options.d.ts} +0 -0
- /package/node_modules/@oxygen/shared/dist/{select-options.js → tables/select-options.js} +0 -0
|
@@ -0,0 +1,474 @@
|
|
|
1
|
+
import { isNonEmptyString, isRecord, isValidWorkflowStatus, isWorkflowToolRejected, lintRecipeManifest, validateBranchTarget, validateOptionalMaxCredits, validatePureFunctionSource, validateRecipeBundleSafety, validateTrigger, WORKFLOW_MANIFEST_VERSION } from "./manifest-validation.js";
|
|
2
|
+
import { BLUEPRINT_COMPILER_VERSION, BLUEPRINT_VERSION, WORKFLOW_COMPILER_VERSION } from "./manifest-types.js";
|
|
3
|
+
import { hashWorkflowSource, workflowJsonReplacer } from "./manifest-hash.js";
|
|
4
|
+
import { isWorkflowGraphManifest } from "./graph/types.js";
|
|
5
|
+
import { lintWorkflowGraphManifest } from "./graph/lint.js";
|
|
6
|
+
/**
|
|
7
|
+
* v1 manifest and blueprint linting, assertion and compilation. Graph manifests lint through `graph/lint.ts`.
|
|
8
|
+
*/
|
|
9
|
+
// Step ids that must not be used: they collide with JavaScript object internals
|
|
10
|
+
// when the runtime assembles ctx.steps, so their outputs would be silently lost.
|
|
11
|
+
const RESERVED_STEP_IDS = new Set(["__proto__", "constructor", "prototype"]);
|
|
12
|
+
export function compileWorkflowDefinition(// skipcq: JS-R1005 -- compiler validates workflow metadata, trigger, steps, branch targets, and defaults together.
|
|
13
|
+
definition, options = {}) {
|
|
14
|
+
const sourceHash = options.sourceHash
|
|
15
|
+
?? hashWorkflowSource(options.source ?? JSON.stringify(definition, workflowJsonReplacer));
|
|
16
|
+
const manifest = {
|
|
17
|
+
manifest_version: WORKFLOW_MANIFEST_VERSION,
|
|
18
|
+
workflow: {
|
|
19
|
+
id: definition.id,
|
|
20
|
+
name: definition.name,
|
|
21
|
+
...(definition.status ? { status: definition.status } : {}),
|
|
22
|
+
},
|
|
23
|
+
...(definition.specification ? { specification: definition.specification } : {}),
|
|
24
|
+
...(definition.trigger ? { trigger: definition.trigger } : {}),
|
|
25
|
+
...(definition.inputSchema ? { input_schema: definition.inputSchema } : {}),
|
|
26
|
+
...(definition.maxCredits != null ? { max_credits: definition.maxCredits } : {}),
|
|
27
|
+
steps: definition.steps.map((step) => {
|
|
28
|
+
if (step.kind === "transform") {
|
|
29
|
+
return {
|
|
30
|
+
kind: "transform",
|
|
31
|
+
id: step.id,
|
|
32
|
+
...(step.description ? { description: step.description } : {}),
|
|
33
|
+
run_source: serializeWorkflowFunction(step.run, `steps.${step.id}.run`),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
if (step.kind === "branch") {
|
|
37
|
+
return {
|
|
38
|
+
kind: "branch",
|
|
39
|
+
id: step.id,
|
|
40
|
+
...(step.description ? { description: step.description } : {}),
|
|
41
|
+
condition_source: serializeWorkflowFunction(step.condition, `steps.${step.id}.condition`),
|
|
42
|
+
then_id: step.then,
|
|
43
|
+
...(step.else !== undefined ? { else_id: step.else } : {}),
|
|
44
|
+
...(step.join !== undefined ? { join_id: step.join } : {}),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
kind: "tool",
|
|
49
|
+
id: step.id,
|
|
50
|
+
...(step.description ? { description: step.description } : {}),
|
|
51
|
+
tool: step.tool,
|
|
52
|
+
effect: step.effect ?? "external_read",
|
|
53
|
+
...(step.mode ? { mode: step.mode } : {}),
|
|
54
|
+
...(step.connectionId !== undefined ? { connection_id: step.connectionId } : {}),
|
|
55
|
+
...(step.maxCredits != null ? { max_credits: step.maxCredits } : {}),
|
|
56
|
+
payload_source: serializeWorkflowFunction(step.payload, `steps.${step.id}.payload`),
|
|
57
|
+
};
|
|
58
|
+
}),
|
|
59
|
+
source_hash: sourceHash,
|
|
60
|
+
compiler_version: WORKFLOW_COMPILER_VERSION,
|
|
61
|
+
created_at: (options.createdAt ?? new Date()).toISOString(),
|
|
62
|
+
};
|
|
63
|
+
assertWorkflowManifest(manifest);
|
|
64
|
+
return manifest;
|
|
65
|
+
}
|
|
66
|
+
export function lintWorkflowManifest(// skipcq: JS-R1005
|
|
67
|
+
value, options = {}) {
|
|
68
|
+
if (isWorkflowGraphManifest(value)) {
|
|
69
|
+
return lintWorkflowGraphManifest(value, options);
|
|
70
|
+
}
|
|
71
|
+
if (isRecord(value)
|
|
72
|
+
&& typeof value.compiler_version === "string"
|
|
73
|
+
&& value.compiler_version.startsWith("oxygen-recipes-")) {
|
|
74
|
+
return lintRecipeManifest(value, options);
|
|
75
|
+
}
|
|
76
|
+
const issues = [];
|
|
77
|
+
const add = (path, code, message) => issues.push({ path, code, message });
|
|
78
|
+
if (!isRecord(value)) {
|
|
79
|
+
add("$", "invalid_manifest", "Workflow manifest must be an object.");
|
|
80
|
+
return { ok: false, issues };
|
|
81
|
+
}
|
|
82
|
+
if (value.manifest_version !== WORKFLOW_MANIFEST_VERSION) {
|
|
83
|
+
add("$.manifest_version", "invalid_manifest_version", "Workflow manifest version must be 1.");
|
|
84
|
+
}
|
|
85
|
+
const workflow = value.workflow;
|
|
86
|
+
if (!isRecord(workflow)) {
|
|
87
|
+
add("$.workflow", "missing_workflow", "Workflow metadata is required.");
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
if (!isNonEmptyString(workflow.id))
|
|
91
|
+
add("$.workflow.id", "invalid_workflow_id", "Workflow id is required.");
|
|
92
|
+
if (!isNonEmptyString(workflow.name))
|
|
93
|
+
add("$.workflow.name", "invalid_workflow_name", "Workflow name is required.");
|
|
94
|
+
if (workflow.status !== undefined && !isValidWorkflowStatus(workflow.status)) {
|
|
95
|
+
add("$.workflow.status", "invalid_workflow_status", "Workflow status must be active or disabled.");
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (value.trigger !== undefined)
|
|
99
|
+
validateTrigger(value.trigger, "$.trigger", add);
|
|
100
|
+
validateOptionalMaxCredits(value.max_credits, "$.max_credits", add);
|
|
101
|
+
if (!Array.isArray(value.steps) || value.steps.length === 0) {
|
|
102
|
+
add("$.steps", "missing_steps", "At least one workflow step is required.");
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
// Pre-pass: collect id → declared-index so branch targets can be
|
|
106
|
+
// validated for existence + forward-only direction in the main pass.
|
|
107
|
+
const idToIndex = new Map();
|
|
108
|
+
value.steps.forEach((step, index) => {
|
|
109
|
+
if (isRecord(step) && isNonEmptyString(step.id)) {
|
|
110
|
+
if (!idToIndex.has(step.id))
|
|
111
|
+
idToIndex.set(step.id, index);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
const ids = new Set();
|
|
115
|
+
value.steps.forEach((step, index) => {
|
|
116
|
+
const path = `$.steps.${index}`;
|
|
117
|
+
if (!isRecord(step)) {
|
|
118
|
+
add(path, "invalid_step", "Workflow step must be an object.");
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
if (!isNonEmptyString(step.id)) {
|
|
122
|
+
add(`${path}.id`, "invalid_step_id", "Step id is required.");
|
|
123
|
+
}
|
|
124
|
+
else if (RESERVED_STEP_IDS.has(step.id)) {
|
|
125
|
+
// Step ids become keys on the ctx.steps object the runtime assembles.
|
|
126
|
+
// "__proto__" / "constructor" / "prototype" collide with JavaScript
|
|
127
|
+
// object internals: assigning ctx.steps["__proto__"] = output hits the
|
|
128
|
+
// prototype setter, so the output is silently dropped from step outputs
|
|
129
|
+
// and unreadable downstream while the run still reports success. Reject
|
|
130
|
+
// at authoring time instead of letting that data loss happen at runtime.
|
|
131
|
+
add(`${path}.id`, "reserved_step_id", `Step id '${step.id}' is reserved (it collides with a JavaScript object key and would be dropped from step outputs). Choose another id.`);
|
|
132
|
+
}
|
|
133
|
+
else if (ids.has(step.id)) {
|
|
134
|
+
add(`${path}.id`, "duplicate_step_id", `Step id '${step.id}' is duplicated.`);
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
ids.add(step.id);
|
|
138
|
+
}
|
|
139
|
+
if (step.kind === "transform") {
|
|
140
|
+
if (!isNonEmptyString(step.run_source)) {
|
|
141
|
+
add(`${path}.run_source`, "missing_step_code", "Transform step run_source is required.");
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
validatePureFunctionSource(step.run_source, `${path}.run_source`, add);
|
|
145
|
+
}
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
if (step.kind === "tool") {
|
|
149
|
+
if (!isNonEmptyString(step.tool)) {
|
|
150
|
+
add(`${path}.tool`, "missing_tool", "Tool step tool id is required.");
|
|
151
|
+
}
|
|
152
|
+
else if (isWorkflowToolRejected(step.tool)) {
|
|
153
|
+
add(`${path}.tool`, "unsupported_workflow_tool", `Tool '${step.tool}' is not allowed in workflow automations.`);
|
|
154
|
+
}
|
|
155
|
+
else if (options.isToolAllowed && !options.isToolAllowed(step.tool)) {
|
|
156
|
+
add(`${path}.tool`, "tool_not_allowed", `Tool '${step.tool}' is not available for workflow automations.`);
|
|
157
|
+
}
|
|
158
|
+
if (!isNonEmptyString(step.payload_source)) {
|
|
159
|
+
add(`${path}.payload_source`, "missing_step_code", "Tool step payload_source is required.");
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
validatePureFunctionSource(step.payload_source, `${path}.payload_source`, add);
|
|
163
|
+
}
|
|
164
|
+
if (step.effect !== "none"
|
|
165
|
+
&& step.effect !== "external_read"
|
|
166
|
+
&& step.effect !== "external_write") {
|
|
167
|
+
add(`${path}.effect`, "invalid_step_effect", "Step effect is invalid.");
|
|
168
|
+
}
|
|
169
|
+
else if (isNonEmptyString(step.tool)) {
|
|
170
|
+
// No resolver: skip the canonical cross-check rather than refuse.
|
|
171
|
+
//
|
|
172
|
+
// This function is reached by compileWorkflowDefinition, which the CLI
|
|
173
|
+
// calls locally — and the CLI deliberately cannot classify effects,
|
|
174
|
+
// because that is exactly the dependency removed from this package.
|
|
175
|
+
// Refusing here would make `oxygen workflows` unable to compile any
|
|
176
|
+
// manifest containing a tool step.
|
|
177
|
+
//
|
|
178
|
+
// Skipping is safe because this check is a CONVENIENCE, not the gate:
|
|
179
|
+
// apply and the worker runtime both resolve the effect canonically and
|
|
180
|
+
// both REFUSE what they cannot classify. The divergence v1.513.2 fixed
|
|
181
|
+
// was lint disagreeing with apply, and that is addressed by the server
|
|
182
|
+
// lint path always injecting resolveWorkflowToolEffect (see
|
|
183
|
+
// apps/web/src/lib/workflows.ts lintHostedWorkflowManifest) — not by a
|
|
184
|
+
// default inside this package.
|
|
185
|
+
const resolveEffect = options.resolveToolEffect;
|
|
186
|
+
if (resolveEffect) {
|
|
187
|
+
const canonicalEffect = resolveEffect(step.tool);
|
|
188
|
+
if (canonicalEffect !== null && step.effect !== canonicalEffect) {
|
|
189
|
+
add(`${path}.effect`, "tool_effect_mismatch", `Tool '${step.tool}' has canonical effect '${canonicalEffect}', not '${String(step.effect)}'. Set step.effect to '${canonicalEffect}'.`);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
if (step.mode !== undefined
|
|
194
|
+
&& step.mode !== "dry_run"
|
|
195
|
+
&& step.mode !== "live"
|
|
196
|
+
&& step.mode !== "smoke_test") {
|
|
197
|
+
add(`${path}.mode`, "invalid_step_mode", "Step mode is invalid.");
|
|
198
|
+
}
|
|
199
|
+
if (step.connection_id !== undefined && !isNonEmptyString(step.connection_id)) {
|
|
200
|
+
add(`${path}.connection_id`, "invalid_connection_id", "Tool step connection_id must be a non-empty string.");
|
|
201
|
+
}
|
|
202
|
+
validateOptionalMaxCredits(step.max_credits, `${path}.max_credits`, add);
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
if (step.kind === "branch") {
|
|
206
|
+
if (!isNonEmptyString(step.condition_source)) {
|
|
207
|
+
add(`${path}.condition_source`, "missing_step_code", "Branch step condition_source is required.");
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
validatePureFunctionSource(step.condition_source, `${path}.condition_source`, add);
|
|
211
|
+
}
|
|
212
|
+
validateBranchTarget(step.then_id, `${path}.then_id`, "then_id", index, idToIndex, add);
|
|
213
|
+
if (step.else_id !== undefined) {
|
|
214
|
+
validateBranchTarget(step.else_id, `${path}.else_id`, "else_id", index, idToIndex, add);
|
|
215
|
+
}
|
|
216
|
+
if (step.join_id !== undefined) {
|
|
217
|
+
validateBranchTarget(step.join_id, `${path}.join_id`, "join_id", index, idToIndex, add);
|
|
218
|
+
}
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
add(`${path}.kind`, "invalid_step_kind", "Step kind must be transform, tool, or branch.");
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
if (!isNonEmptyString(value.source_hash)) {
|
|
225
|
+
add("$.source_hash", "missing_source_hash", "Manifest source_hash is required.");
|
|
226
|
+
}
|
|
227
|
+
if (!isNonEmptyString(value.compiler_version)) {
|
|
228
|
+
add("$.compiler_version", "missing_compiler_version", "Manifest compiler_version is required.");
|
|
229
|
+
}
|
|
230
|
+
return { ok: issues.length === 0, issues };
|
|
231
|
+
}
|
|
232
|
+
export function assertRecipeManifest(value, options = {}) {
|
|
233
|
+
const result = lintRecipeManifest(value, options);
|
|
234
|
+
if (result.ok)
|
|
235
|
+
return;
|
|
236
|
+
const first = result.issues[0];
|
|
237
|
+
throw new Error(first ? `${first.code}: ${first.message}` : "Invalid recipe manifest.");
|
|
238
|
+
}
|
|
239
|
+
export function assertWorkflowManifest(value, options = {}) {
|
|
240
|
+
const result = lintWorkflowManifest(value, options);
|
|
241
|
+
if (result.ok)
|
|
242
|
+
return;
|
|
243
|
+
const first = result.issues[0];
|
|
244
|
+
throw new Error(first ? `${first.code}: ${first.message}` : "Invalid workflow manifest.");
|
|
245
|
+
}
|
|
246
|
+
const BLUEPRINT_REF_PATTERN = /^[a-z][a-z0-9_-]{0,79}$/;
|
|
247
|
+
const BLUEPRINT_PROMPT_SLUG_PATTERN = /^[a-z][a-z0-9_-]{0,119}$/;
|
|
248
|
+
export function lintBlueprint(// skipcq: JS-R1005
|
|
249
|
+
value, options = {}) {
|
|
250
|
+
const issues = [];
|
|
251
|
+
const add = (path, code, message) => issues.push({ path, code, message });
|
|
252
|
+
if (!isRecord(value)) {
|
|
253
|
+
add("$", "invalid_blueprint", "Blueprint must be an object.");
|
|
254
|
+
return { ok: false, issues };
|
|
255
|
+
}
|
|
256
|
+
if (value.blueprint_version !== BLUEPRINT_VERSION) {
|
|
257
|
+
add("$.blueprint_version", "invalid_blueprint_version", "Blueprint version must be 1.");
|
|
258
|
+
}
|
|
259
|
+
if (value.compiler_version !== BLUEPRINT_COMPILER_VERSION) {
|
|
260
|
+
add("$.compiler_version", "invalid_compiler_version", `Blueprint compiler_version must be '${BLUEPRINT_COMPILER_VERSION}'.`);
|
|
261
|
+
}
|
|
262
|
+
if (!isNonEmptyString(value.id))
|
|
263
|
+
add("$.id", "invalid_blueprint_id", "Blueprint id is required.");
|
|
264
|
+
if (!isNonEmptyString(value.name))
|
|
265
|
+
add("$.name", "invalid_blueprint_name", "Blueprint name is required.");
|
|
266
|
+
if (typeof value.summary !== "string")
|
|
267
|
+
add("$.summary", "invalid_summary", "Blueprint summary must be a string.");
|
|
268
|
+
if (!Array.isArray(value.tags)) {
|
|
269
|
+
add("$.tags", "invalid_tags", "Blueprint tags must be an array of strings.");
|
|
270
|
+
}
|
|
271
|
+
if (!isNonEmptyString(value.exported_at)) {
|
|
272
|
+
add("$.exported_at", "invalid_exported_at", "Blueprint exported_at must be an ISO timestamp.");
|
|
273
|
+
}
|
|
274
|
+
if (!isNonEmptyString(value.source_hash)) {
|
|
275
|
+
add("$.source_hash", "missing_source_hash", "Blueprint source_hash is required.");
|
|
276
|
+
}
|
|
277
|
+
const tableRefs = new Set();
|
|
278
|
+
if (!Array.isArray(value.tables)) {
|
|
279
|
+
add("$.tables", "invalid_tables", "Blueprint tables must be an array.");
|
|
280
|
+
}
|
|
281
|
+
else {
|
|
282
|
+
value.tables.forEach((table, index) => {
|
|
283
|
+
const path = `$.tables.${index}`;
|
|
284
|
+
if (!isRecord(table)) {
|
|
285
|
+
add(path, "invalid_table", "Blueprint table must be an object.");
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
if (!isNonEmptyString(table.ref) || !BLUEPRINT_REF_PATTERN.test(table.ref)) {
|
|
289
|
+
add(`${path}.ref`, "invalid_table_ref", "Blueprint table ref must be lowercase kebab/snake_case (a-z0-9_-).");
|
|
290
|
+
}
|
|
291
|
+
else {
|
|
292
|
+
if (tableRefs.has(table.ref)) {
|
|
293
|
+
add(`${path}.ref`, "duplicate_table_ref", `Blueprint table ref '${table.ref}' is duplicated.`);
|
|
294
|
+
}
|
|
295
|
+
tableRefs.add(table.ref);
|
|
296
|
+
}
|
|
297
|
+
if (!isNonEmptyString(table.name))
|
|
298
|
+
add(`${path}.name`, "invalid_table_name", "Blueprint table name is required.");
|
|
299
|
+
if (!Array.isArray(table.columns) || table.columns.length === 0) {
|
|
300
|
+
add(`${path}.columns`, "invalid_table_columns", "Blueprint table must declare at least one column.");
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
table.columns.forEach((column, columnIndex) => {
|
|
304
|
+
const columnPath = `${path}.columns.${columnIndex}`;
|
|
305
|
+
if (!isRecord(column)) {
|
|
306
|
+
add(columnPath, "invalid_column", "Blueprint column must be an object.");
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
if (!isNonEmptyString(column.label)) {
|
|
310
|
+
add(`${columnPath}.label`, "invalid_column_label", "Blueprint column label is required.");
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
if (value.column_grafts !== undefined) {
|
|
317
|
+
if (!Array.isArray(value.column_grafts)) {
|
|
318
|
+
add("$.column_grafts", "invalid_column_grafts", "Blueprint column_grafts must be an array.");
|
|
319
|
+
}
|
|
320
|
+
else {
|
|
321
|
+
value.column_grafts.forEach((graft, index) => {
|
|
322
|
+
const path = `$.column_grafts.${index}`;
|
|
323
|
+
if (!isRecord(graft)) {
|
|
324
|
+
add(path, "invalid_column_graft", "Column graft must be an object.");
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
if (!isNonEmptyString(graft.table_ref) || !tableRefs.has(graft.table_ref)) {
|
|
328
|
+
add(`${path}.table_ref`, "invalid_graft_ref", "Column graft table_ref must match a declared blueprint table ref.");
|
|
329
|
+
}
|
|
330
|
+
if (!isRecord(graft.column) || !isNonEmptyString(graft.column.label)) {
|
|
331
|
+
add(`${path}.column`, "invalid_graft_column", "Column graft column must be an object with a label.");
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
const promptSlugs = new Set();
|
|
337
|
+
if (!Array.isArray(value.prompt_templates)) {
|
|
338
|
+
add("$.prompt_templates", "invalid_prompt_templates", "Blueprint prompt_templates must be an array.");
|
|
339
|
+
}
|
|
340
|
+
else {
|
|
341
|
+
value.prompt_templates.forEach((prompt, index) => {
|
|
342
|
+
const path = `$.prompt_templates.${index}`;
|
|
343
|
+
if (!isRecord(prompt)) {
|
|
344
|
+
add(path, "invalid_prompt", "Blueprint prompt must be an object.");
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
if (!isNonEmptyString(prompt.slug) || !BLUEPRINT_PROMPT_SLUG_PATTERN.test(prompt.slug)) {
|
|
348
|
+
add(`${path}.slug`, "invalid_prompt_slug", "Prompt slug must be lowercase kebab/snake_case (a-z0-9_-).");
|
|
349
|
+
}
|
|
350
|
+
else {
|
|
351
|
+
if (promptSlugs.has(prompt.slug)) {
|
|
352
|
+
add(`${path}.slug`, "duplicate_prompt_slug", `Prompt slug '${prompt.slug}' is duplicated.`);
|
|
353
|
+
}
|
|
354
|
+
promptSlugs.add(prompt.slug);
|
|
355
|
+
}
|
|
356
|
+
if (!isNonEmptyString(prompt.name))
|
|
357
|
+
add(`${path}.name`, "invalid_prompt_name", "Prompt name is required.");
|
|
358
|
+
if (!isNonEmptyString(prompt.body))
|
|
359
|
+
add(`${path}.body`, "invalid_prompt_body", "Prompt body is required.");
|
|
360
|
+
if (prompt.kind !== "ai_column_system" && prompt.kind !== "scoring_rubric" && prompt.kind !== "other") {
|
|
361
|
+
add(`${path}.kind`, "invalid_prompt_kind", "Prompt kind must be ai_column_system, scoring_rubric, or other.");
|
|
362
|
+
}
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
if (!Array.isArray(value.workflows)) {
|
|
366
|
+
add("$.workflows", "invalid_workflows", "Blueprint workflows must be an array.");
|
|
367
|
+
}
|
|
368
|
+
else if (value.workflows.length === 0) {
|
|
369
|
+
add("$.workflows", "missing_workflows", "Blueprint must include at least one workflow.");
|
|
370
|
+
}
|
|
371
|
+
else {
|
|
372
|
+
value.workflows.forEach((entry, index) => {
|
|
373
|
+
const path = `$.workflows.${index}`;
|
|
374
|
+
if (!isRecord(entry)) {
|
|
375
|
+
add(path, "invalid_workflow_entry", "Workflow entry must be an object.");
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
const manifest = entry.manifest;
|
|
379
|
+
const manifestResult = lintWorkflowManifest(manifest, options);
|
|
380
|
+
if (!manifestResult.ok) {
|
|
381
|
+
manifestResult.issues.forEach((issue) => {
|
|
382
|
+
add(`${path}.manifest${issue.path.replace(/^\$/, "")}`, issue.code, issue.message);
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
if (entry.table_refs !== undefined && !isRecord(entry.table_refs)) {
|
|
386
|
+
add(`${path}.table_refs`, "invalid_workflow_table_refs", "Workflow table_refs must be an object map.");
|
|
387
|
+
}
|
|
388
|
+
else if (isRecord(entry.table_refs)) {
|
|
389
|
+
for (const refName of Object.keys(entry.table_refs)) {
|
|
390
|
+
if (!tableRefs.has(refName)) {
|
|
391
|
+
add(`${path}.table_refs.${refName}`, "unknown_workflow_table_ref", `Workflow references table ref '${refName}' which is not declared on this blueprint.`);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
if (entry.prompt_template_slugs !== undefined) {
|
|
396
|
+
if (!Array.isArray(entry.prompt_template_slugs)) {
|
|
397
|
+
add(`${path}.prompt_template_slugs`, "invalid_prompt_slug_list", "Workflow prompt_template_slugs must be an array of strings.");
|
|
398
|
+
}
|
|
399
|
+
else {
|
|
400
|
+
entry.prompt_template_slugs.forEach((slug, slugIndex) => {
|
|
401
|
+
if (!isNonEmptyString(slug)) {
|
|
402
|
+
add(`${path}.prompt_template_slugs.${slugIndex}`, "invalid_prompt_slug", "Workflow prompt slug references must be non-empty strings.");
|
|
403
|
+
}
|
|
404
|
+
else if (!promptSlugs.has(slug)) {
|
|
405
|
+
add(`${path}.prompt_template_slugs.${slugIndex}`, "unknown_prompt_slug", `Workflow references prompt slug '${slug}' which is not declared on this blueprint.`);
|
|
406
|
+
}
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
const requires = value.requires;
|
|
413
|
+
if (!isRecord(requires)) {
|
|
414
|
+
add("$.requires", "invalid_requires", "Blueprint requires must be an object.");
|
|
415
|
+
}
|
|
416
|
+
else {
|
|
417
|
+
if (requires.integrations !== undefined) {
|
|
418
|
+
if (!Array.isArray(requires.integrations)) {
|
|
419
|
+
add("$.requires.integrations", "invalid_requires_integrations", "Blueprint requires.integrations must be an array.");
|
|
420
|
+
}
|
|
421
|
+
else {
|
|
422
|
+
requires.integrations.forEach((entry, index) => {
|
|
423
|
+
const path = `$.requires.integrations.${index}`;
|
|
424
|
+
if (!isRecord(entry)) {
|
|
425
|
+
add(path, "invalid_integration", "Integration requirement must be an object.");
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
if (!isNonEmptyString(entry.kind)) {
|
|
429
|
+
add(`${path}.kind`, "invalid_integration_kind", "Integration requirement kind is required (e.g. 'instantly', 'apollo').");
|
|
430
|
+
}
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
if (requires.context_keys !== undefined && !Array.isArray(requires.context_keys)) {
|
|
435
|
+
add("$.requires.context_keys", "invalid_context_keys", "Blueprint requires.context_keys must be an array of strings.");
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
return { ok: issues.length === 0, issues };
|
|
439
|
+
}
|
|
440
|
+
export function assertBlueprint(value, options = {}) {
|
|
441
|
+
const result = lintBlueprint(value, options);
|
|
442
|
+
if (result.ok)
|
|
443
|
+
return;
|
|
444
|
+
const first = result.issues[0];
|
|
445
|
+
throw new Error(first ? `${first.code}: ${first.message}` : "Invalid blueprint.");
|
|
446
|
+
}
|
|
447
|
+
export function assertRecipeBundleSafe(bundle) {
|
|
448
|
+
const issues = lintRecipeBundleSafety(bundle, "$.bundle");
|
|
449
|
+
const first = issues[0];
|
|
450
|
+
if (first)
|
|
451
|
+
throw new Error(`${first.code}: ${first.message}`);
|
|
452
|
+
}
|
|
453
|
+
export function lintRecipeBundleSafety(bundle, path = "$.bundle") {
|
|
454
|
+
const issues = [];
|
|
455
|
+
validateRecipeBundleSafety(bundle, path, (issuePath, code, message) => {
|
|
456
|
+
issues.push({ path: issuePath, code, message });
|
|
457
|
+
});
|
|
458
|
+
return issues;
|
|
459
|
+
}
|
|
460
|
+
function serializeWorkflowFunction(fn, path) {
|
|
461
|
+
if (typeof fn !== "function") {
|
|
462
|
+
throw new Error(`${path} must be a function.`);
|
|
463
|
+
}
|
|
464
|
+
const source = Function.prototype.toString.call(fn);
|
|
465
|
+
const issues = [];
|
|
466
|
+
validatePureFunctionSource(source, path, (issuePath, code, message) => {
|
|
467
|
+
issues.push({ path: issuePath, code, message });
|
|
468
|
+
});
|
|
469
|
+
if (issues.length > 0) {
|
|
470
|
+
const first = issues[0];
|
|
471
|
+
throw new Error(first ? `${first.code}: ${first.message}` : `${path} is invalid.`);
|
|
472
|
+
}
|
|
473
|
+
return source;
|
|
474
|
+
}
|