@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.
Files changed (119) hide show
  1. package/README.md +1 -1
  2. package/dist/command-families/tables/options.d.ts +1 -0
  3. package/dist/command-families/tables/register-automation.js +3 -1
  4. package/dist/commands/observability.js +4 -4
  5. package/dist/commands/table-runs.js +10 -0
  6. package/dist/commands/tags.js +2 -2
  7. package/dist/commands/workflows.js +31 -10
  8. package/dist/http-client.d.ts +1 -1
  9. package/dist/http-client.js +1 -1
  10. package/node_modules/@oxygen/formula/dist/cross-row-function.d.ts +13 -0
  11. package/node_modules/@oxygen/formula/dist/cross-row-function.js +1 -0
  12. package/node_modules/@oxygen/formula/dist/{refactor-internals → cross-row-functions}/novelty-score.d.ts +2 -0
  13. package/node_modules/@oxygen/formula/dist/{refactor-internals → cross-row-functions}/novelty-score.js +1 -0
  14. package/node_modules/@oxygen/formula/dist/cross-row-functions.generated.d.ts +3 -0
  15. package/node_modules/@oxygen/formula/dist/cross-row-functions.generated.js +3 -0
  16. package/node_modules/@oxygen/formula/dist/evaluate.d.ts +12 -1
  17. package/node_modules/@oxygen/formula/dist/evaluate.js +28 -3
  18. package/node_modules/@oxygen/recipe-sdk/dist/index.d.ts +2 -0
  19. package/node_modules/@oxygen/shared/dist/capability-discovery.js +1 -1
  20. package/node_modules/@oxygen/shared/dist/cell-format.js +2 -2
  21. package/node_modules/@oxygen/shared/dist/collab.d.ts +1 -1
  22. package/node_modules/@oxygen/shared/dist/contracts/geo.js +1 -1
  23. package/node_modules/@oxygen/shared/dist/dnc-identities.js +1 -1
  24. package/node_modules/@oxygen/shared/dist/error-redaction.d.ts +1 -1
  25. package/node_modules/@oxygen/shared/dist/error-redaction.js +2 -2
  26. package/node_modules/@oxygen/shared/dist/esp-contract.d.ts +133 -0
  27. package/node_modules/@oxygen/shared/dist/esp-contract.js +121 -0
  28. package/node_modules/@oxygen/shared/dist/{geo.js → geo/geo.js} +2 -2
  29. package/node_modules/@oxygen/shared/dist/index.d.ts +6 -5
  30. package/node_modules/@oxygen/shared/dist/index.js +7 -5
  31. package/node_modules/@oxygen/shared/dist/knowledge-bootstrap.js +1 -1
  32. package/node_modules/@oxygen/shared/dist/linkedin-connection-identity.js +1 -1
  33. package/node_modules/@oxygen/shared/dist/{sending-domain-rollout.js → mailboxes/sending-domain-rollout.js} +1 -1
  34. package/node_modules/@oxygen/shared/dist/mcp-event-contract.js +1 -1
  35. package/node_modules/@oxygen/shared/dist/{social-post-metrics-core.d.ts → posts/metrics-core.d.ts} +1 -1
  36. package/node_modules/@oxygen/shared/dist/{social-post-metrics-linkedin.d.ts → posts/metrics-linkedin.d.ts} +1 -1
  37. package/node_modules/@oxygen/shared/dist/{social-post-metrics-linkedin.js → posts/metrics-linkedin.js} +2 -2
  38. package/node_modules/@oxygen/shared/dist/{social-post-metrics-series.d.ts → posts/metrics-series.d.ts} +1 -1
  39. package/node_modules/@oxygen/shared/dist/{social-post-metrics-series.js → posts/metrics-series.js} +1 -1
  40. package/node_modules/@oxygen/shared/dist/{social-post-metrics-x.d.ts → posts/metrics-x.d.ts} +1 -1
  41. package/node_modules/@oxygen/shared/dist/{social-post-metrics-x.js → posts/metrics-x.js} +2 -2
  42. package/node_modules/@oxygen/shared/dist/{social-post-metrics.d.ts → posts/metrics.d.ts} +3 -3
  43. package/node_modules/@oxygen/shared/dist/{social-post-metrics.js → posts/metrics.js} +3 -3
  44. package/node_modules/@oxygen/shared/dist/recipient-provider.d.ts +2 -10
  45. package/node_modules/@oxygen/shared/dist/recipient-provider.js +1 -9
  46. package/node_modules/@oxygen/shared/dist/sequence-internals/esp-policy.d.ts +2 -118
  47. package/node_modules/@oxygen/shared/dist/sequence-internals/esp-policy.js +2 -107
  48. package/node_modules/@oxygen/shared/dist/sequences.d.ts +0 -1
  49. package/node_modules/@oxygen/shared/dist/sequences.js +0 -2
  50. package/node_modules/@oxygen/shared/dist/{native-chat-discovery.d.ts → support/native-chat-discovery.d.ts} +1 -1
  51. package/node_modules/@oxygen/shared/dist/{native-chat-discovery.js → support/native-chat-discovery.js} +1 -1
  52. package/node_modules/@oxygen/shared/dist/suppression-entries.js +1 -1
  53. package/node_modules/@oxygen/shared/dist/table-field-types.d.ts +1 -1
  54. package/node_modules/@oxygen/shared/dist/table-field-types.js +2 -2
  55. package/node_modules/@oxygen/shared/dist/{column-output-fields.js → tables/column-output-fields.js} +4 -4
  56. package/node_modules/@oxygen/shared/dist/{tags.d.ts → tags/tags.d.ts} +1 -1
  57. package/node_modules/@oxygen/shared/dist/{tags.js → tags/tags.js} +1 -1
  58. package/node_modules/@oxygen/shared/dist/ugc-amplification-identity.js +1 -1
  59. package/node_modules/@oxygen/shared/dist/version.generated.d.ts +1 -1
  60. package/node_modules/@oxygen/shared/dist/version.generated.js +1 -1
  61. package/node_modules/@oxygen/shared/dist/workspace-placement-bulk.d.ts +6 -0
  62. package/node_modules/@oxygen/shared/dist/workspace-placement-bulk.js +9 -2
  63. package/node_modules/@oxygen/shared/dist/workspace-placement-schedule.d.ts +44 -0
  64. package/node_modules/@oxygen/shared/dist/workspace-placement-schedule.js +90 -0
  65. package/node_modules/@oxygen/shared/dist/workspace-placement-view.d.ts +24 -0
  66. package/node_modules/@oxygen/shared/dist/workspace-placement-view.js +5 -4
  67. package/node_modules/@oxygen/shared/dist/workspace-placement.d.ts +4 -0
  68. package/node_modules/@oxygen/shared/dist/workspace-placement.js +7 -1
  69. package/node_modules/@oxygen/shared/package.json +0 -25
  70. package/node_modules/@oxygen/workflows/dist/cron.d.ts +42 -0
  71. package/node_modules/@oxygen/workflows/dist/cron.js +271 -0
  72. package/node_modules/@oxygen/workflows/dist/event-dispatch.d.ts +2 -1
  73. package/node_modules/@oxygen/workflows/dist/graph/condition.d.ts +3 -0
  74. package/node_modules/@oxygen/workflows/dist/graph/condition.js +19 -0
  75. package/node_modules/@oxygen/workflows/dist/graph/expression.d.ts +1 -2
  76. package/node_modules/@oxygen/workflows/dist/graph/expression.js +2 -19
  77. package/node_modules/@oxygen/workflows/dist/graph/types.d.ts +4 -3
  78. package/node_modules/@oxygen/workflows/dist/index.d.ts +8 -985
  79. package/node_modules/@oxygen/workflows/dist/index.js +8 -1221
  80. package/node_modules/@oxygen/workflows/dist/manifest-builders.d.ts +73 -0
  81. package/node_modules/@oxygen/workflows/dist/manifest-builders.js +102 -0
  82. package/node_modules/@oxygen/workflows/dist/manifest-guards.d.ts +16 -0
  83. package/node_modules/@oxygen/workflows/dist/manifest-guards.js +34 -0
  84. package/node_modules/@oxygen/workflows/dist/manifest-hash.d.ts +47 -0
  85. package/node_modules/@oxygen/workflows/dist/manifest-hash.js +102 -0
  86. package/node_modules/@oxygen/workflows/dist/manifest-lint.d.ts +17 -0
  87. package/node_modules/@oxygen/workflows/dist/manifest-lint.js +474 -0
  88. package/node_modules/@oxygen/workflows/dist/manifest-types.d.ts +256 -0
  89. package/node_modules/@oxygen/workflows/dist/manifest-types.js +9 -0
  90. package/node_modules/@oxygen/workflows/dist/pure-function.d.ts +17 -0
  91. package/node_modules/@oxygen/workflows/dist/pure-function.js +130 -0
  92. package/node_modules/@oxygen/workflows/dist/refactor-internals/condition-comparison.d.ts +1 -17
  93. package/node_modules/@oxygen/workflows/dist/refactor-internals/condition-comparison.js +1 -93
  94. package/node_modules/@oxygen/workflows/dist/refactor-internals/condition-pattern.d.ts +16 -0
  95. package/node_modules/@oxygen/workflows/dist/refactor-internals/condition-pattern.js +92 -0
  96. package/node_modules/@oxygen/workflows/dist/workflow-schemas.d.ts +545 -0
  97. package/node_modules/@oxygen/workflows/dist/workflow-schemas.js +135 -0
  98. package/node_modules/@oxygen/workflows/package.json +4 -0
  99. package/package.json +1 -1
  100. /package/node_modules/@oxygen/shared/dist/{geo.d.ts → geo/geo.d.ts} +0 -0
  101. /package/node_modules/@oxygen/shared/dist/{sending-domain-rollout.d.ts → mailboxes/sending-domain-rollout.d.ts} +0 -0
  102. /package/node_modules/@oxygen/shared/dist/{attempt-provenance.d.ts → observability/attempt-provenance.d.ts} +0 -0
  103. /package/node_modules/@oxygen/shared/dist/{attempt-provenance.js → observability/attempt-provenance.js} +0 -0
  104. /package/node_modules/@oxygen/shared/dist/{linkedin-mentions.d.ts → posts/linkedin-mentions.d.ts} +0 -0
  105. /package/node_modules/@oxygen/shared/dist/{linkedin-mentions.js → posts/linkedin-mentions.js} +0 -0
  106. /package/node_modules/@oxygen/shared/dist/{linkedin-post-keywords.d.ts → posts/linkedin-post-keywords.d.ts} +0 -0
  107. /package/node_modules/@oxygen/shared/dist/{linkedin-post-keywords.js → posts/linkedin-post-keywords.js} +0 -0
  108. /package/node_modules/@oxygen/shared/dist/{linkedin-post-url.d.ts → posts/linkedin-post-url.d.ts} +0 -0
  109. /package/node_modules/@oxygen/shared/dist/{linkedin-post-url.js → posts/linkedin-post-url.js} +0 -0
  110. /package/node_modules/@oxygen/shared/dist/{social-post-metrics-core.js → posts/metrics-core.js} +0 -0
  111. /package/node_modules/@oxygen/shared/dist/{native-chat.d.ts → support/native-chat.d.ts} +0 -0
  112. /package/node_modules/@oxygen/shared/dist/{native-chat.js → support/native-chat.js} +0 -0
  113. /package/node_modules/@oxygen/shared/dist/{plain-support-events.d.ts → support/plain-support-events.d.ts} +0 -0
  114. /package/node_modules/@oxygen/shared/dist/{plain-support-events.js → support/plain-support-events.js} +0 -0
  115. /package/node_modules/@oxygen/shared/dist/{column-output-fields.d.ts → tables/column-output-fields.d.ts} +0 -0
  116. /package/node_modules/@oxygen/shared/dist/{linkedin-url.d.ts → tables/linkedin-url.d.ts} +0 -0
  117. /package/node_modules/@oxygen/shared/dist/{linkedin-url.js → tables/linkedin-url.js} +0 -0
  118. /package/node_modules/@oxygen/shared/dist/{select-options.d.ts → tables/select-options.d.ts} +0 -0
  119. /package/node_modules/@oxygen/shared/dist/{select-options.js → tables/select-options.js} +0 -0
@@ -0,0 +1,73 @@
1
+ import type { JsonSchema, WorkflowStatus, WorkflowStepEffect } from "./manifest-validation.js";
2
+ import type { WorkflowBranchStepDefinition, WorkflowDefinition, WorkflowEventFilter, WorkflowFunction, WorkflowMode, WorkflowStepDefinition, WorkflowToolStepDefinition, WorkflowTransformStepDefinition, WorkflowTriggerDefinition } from "./manifest-types.js";
3
+ /**
4
+ * Authoring helpers for v1 workflow definitions: the definition, trigger and step constructors.
5
+ */
6
+ export declare function defineWorkflow(input: {
7
+ id: string;
8
+ name: string;
9
+ status?: WorkflowStatus;
10
+ specification?: string;
11
+ trigger?: WorkflowTriggerDefinition;
12
+ inputSchema?: JsonSchema;
13
+ maxCredits?: number;
14
+ steps: WorkflowStepDefinition[];
15
+ }): WorkflowDefinition;
16
+ export declare function apiTrigger(input?: {
17
+ status?: WorkflowStatus;
18
+ }): WorkflowTriggerDefinition;
19
+ export declare function webhookTrigger(input: {
20
+ id: string;
21
+ name?: string | null;
22
+ secret?: boolean;
23
+ idempotencyKeyPath?: string | null;
24
+ status?: WorkflowStatus;
25
+ }): WorkflowTriggerDefinition;
26
+ export declare function cronTrigger(input: {
27
+ cron: string;
28
+ timezone?: string | null;
29
+ status?: WorkflowStatus;
30
+ }): WorkflowTriggerDefinition;
31
+ export declare function eventTrigger(input: {
32
+ source: string;
33
+ event: string;
34
+ filters?: WorkflowEventFilter[];
35
+ idempotencyKeyPath?: string | null;
36
+ status?: WorkflowStatus;
37
+ }): WorkflowTriggerDefinition;
38
+ export declare function transformStep(input: {
39
+ id: string;
40
+ description?: string;
41
+ run: WorkflowFunction;
42
+ }): WorkflowTransformStepDefinition;
43
+ export declare function toolStep(input: {
44
+ id: string;
45
+ description?: string;
46
+ tool: string;
47
+ effect?: WorkflowStepEffect;
48
+ mode?: WorkflowMode;
49
+ connectionId?: string;
50
+ maxCredits?: number;
51
+ payload: WorkflowFunction;
52
+ }): WorkflowToolStepDefinition;
53
+ /**
54
+ * Conditional step. `condition` is evaluated; control then flows by mode:
55
+ *
56
+ * - then only (no `else`, no `join`) — GUARD: truthy continues to `then` (steps
57
+ * between the branch and `then` are skipped); falsy skips straight to the end
58
+ * of the workflow (no step after the branch runs) and the run completes.
59
+ * - then + else (no `join`) — skip-until-target jump to `then`/`else`; from the
60
+ * chosen target, the remaining steps run sequentially through the end.
61
+ * - then + else + join — real if/else: the non-chosen arm is skipped and `join`
62
+ * is the convergence point where shared downstream work resumes.
63
+ *
64
+ * All targets must be ids of later steps (branches are forward-only).
65
+ */
66
+ export declare function branchStep(input: {
67
+ id: string;
68
+ description?: string;
69
+ condition: WorkflowFunction;
70
+ then: string;
71
+ else?: string;
72
+ join?: string;
73
+ }): WorkflowBranchStepDefinition;
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Authoring helpers for v1 workflow definitions: the definition, trigger and step constructors.
3
+ */
4
+ export function defineWorkflow(input) {
5
+ return {
6
+ __oxygen_workflow_definition: true,
7
+ id: input.id,
8
+ name: input.name,
9
+ ...(input.status ? { status: input.status } : {}),
10
+ ...(input.specification ? { specification: input.specification } : {}),
11
+ ...(input.trigger ? { trigger: input.trigger } : {}),
12
+ ...(input.inputSchema ? { inputSchema: input.inputSchema } : {}),
13
+ ...(input.maxCredits != null ? { maxCredits: input.maxCredits } : {}),
14
+ steps: input.steps,
15
+ };
16
+ }
17
+ export function apiTrigger(input = {}) {
18
+ return {
19
+ type: "api",
20
+ ...(input.status ? { status: input.status } : {}),
21
+ };
22
+ }
23
+ export function webhookTrigger(input) {
24
+ return {
25
+ type: "webhook",
26
+ trigger_id: input.id,
27
+ ...(input.name !== undefined ? { trigger_name: input.name } : {}),
28
+ secret_required: input.secret ?? true,
29
+ ...(input.idempotencyKeyPath !== undefined
30
+ ? { idempotency_key_path: input.idempotencyKeyPath }
31
+ : {}),
32
+ ...(input.status ? { status: input.status } : {}),
33
+ };
34
+ }
35
+ export function cronTrigger(input) {
36
+ return {
37
+ type: "cron",
38
+ cron: input.cron,
39
+ ...(input.timezone !== undefined ? { timezone: input.timezone } : {}),
40
+ ...(input.status ? { status: input.status } : {}),
41
+ };
42
+ }
43
+ export function eventTrigger(input) {
44
+ return {
45
+ type: "event",
46
+ source: input.source,
47
+ event: input.event,
48
+ ...(input.filters ? { filters: input.filters } : {}),
49
+ ...(input.idempotencyKeyPath !== undefined
50
+ ? { idempotency_key_path: input.idempotencyKeyPath }
51
+ : {}),
52
+ ...(input.status ? { status: input.status } : {}),
53
+ };
54
+ }
55
+ export function transformStep(input) {
56
+ return {
57
+ __oxygen_workflow_step: true,
58
+ kind: "transform",
59
+ id: input.id,
60
+ ...(input.description ? { description: input.description } : {}),
61
+ run: input.run,
62
+ };
63
+ }
64
+ export function toolStep(input) {
65
+ return {
66
+ __oxygen_workflow_step: true,
67
+ kind: "tool",
68
+ id: input.id,
69
+ ...(input.description ? { description: input.description } : {}),
70
+ tool: input.tool,
71
+ ...(input.effect ? { effect: input.effect } : {}),
72
+ ...(input.mode ? { mode: input.mode } : {}),
73
+ ...(input.connectionId !== undefined ? { connectionId: input.connectionId } : {}),
74
+ ...(input.maxCredits != null ? { maxCredits: input.maxCredits } : {}),
75
+ payload: input.payload,
76
+ };
77
+ }
78
+ /**
79
+ * Conditional step. `condition` is evaluated; control then flows by mode:
80
+ *
81
+ * - then only (no `else`, no `join`) — GUARD: truthy continues to `then` (steps
82
+ * between the branch and `then` are skipped); falsy skips straight to the end
83
+ * of the workflow (no step after the branch runs) and the run completes.
84
+ * - then + else (no `join`) — skip-until-target jump to `then`/`else`; from the
85
+ * chosen target, the remaining steps run sequentially through the end.
86
+ * - then + else + join — real if/else: the non-chosen arm is skipped and `join`
87
+ * is the convergence point where shared downstream work resumes.
88
+ *
89
+ * All targets must be ids of later steps (branches are forward-only).
90
+ */
91
+ export function branchStep(input) {
92
+ return {
93
+ __oxygen_workflow_step: true,
94
+ kind: "branch",
95
+ id: input.id,
96
+ ...(input.description ? { description: input.description } : {}),
97
+ condition: input.condition,
98
+ then: input.then,
99
+ ...(input.else !== undefined ? { else: input.else } : {}),
100
+ ...(input.join !== undefined ? { join: input.join } : {}),
101
+ };
102
+ }
@@ -0,0 +1,16 @@
1
+ import { type AnyWorkflowManifest, type Blueprint, type RecipeManifest, type WorkflowDefinition, type WorkflowManifest } from "./manifest-types.js";
2
+ /**
3
+ * Shape guards for v1 workflow, recipe and blueprint manifests.
4
+ */
5
+ export declare function isWorkflowDefinition(value: unknown): value is WorkflowDefinition;
6
+ export declare function isWorkflowManifest(value: unknown): value is WorkflowManifest;
7
+ export declare function isRecipeManifest(value: unknown): value is RecipeManifest;
8
+ /**
9
+ * Every manifest shape the platform can store and run: v1 hosted steps, durable
10
+ * recipes, and oxygen-workflows-v2 graphs. This is the gate `workflows apply`
11
+ * and the CLI loader route through, so a shape listed here must already have a
12
+ * linter and a worker execution path — accepting a manifest we cannot run would
13
+ * cut a revision that fails at run time instead of at authoring time.
14
+ */
15
+ export declare function isAnyWorkflowManifest(value: unknown): value is AnyWorkflowManifest;
16
+ export declare function isBlueprint(value: unknown): value is Blueprint;
@@ -0,0 +1,34 @@
1
+ import { DURABLE_RECIPE_COMPILER_VERSION, isRecord, WORKFLOW_MANIFEST_VERSION } from "./manifest-validation.js";
2
+ import { BLUEPRINT_COMPILER_VERSION, BLUEPRINT_VERSION } from "./manifest-types.js";
3
+ import { isWorkflowGraphManifest } from "./graph/types.js";
4
+ /**
5
+ * Shape guards for v1 workflow, recipe and blueprint manifests.
6
+ */
7
+ export function isWorkflowDefinition(value) {
8
+ return isRecord(value) && value.__oxygen_workflow_definition === true;
9
+ }
10
+ export function isWorkflowManifest(value) {
11
+ return isRecord(value)
12
+ && value.manifest_version === WORKFLOW_MANIFEST_VERSION
13
+ && Array.isArray(value.steps);
14
+ }
15
+ export function isRecipeManifest(value) {
16
+ return isRecord(value)
17
+ && value.manifest_version === WORKFLOW_MANIFEST_VERSION
18
+ && value.compiler_version === DURABLE_RECIPE_COMPILER_VERSION;
19
+ }
20
+ /**
21
+ * Every manifest shape the platform can store and run: v1 hosted steps, durable
22
+ * recipes, and oxygen-workflows-v2 graphs. This is the gate `workflows apply`
23
+ * and the CLI loader route through, so a shape listed here must already have a
24
+ * linter and a worker execution path — accepting a manifest we cannot run would
25
+ * cut a revision that fails at run time instead of at authoring time.
26
+ */
27
+ export function isAnyWorkflowManifest(value) {
28
+ return isWorkflowManifest(value) || isRecipeManifest(value) || isWorkflowGraphManifest(value);
29
+ }
30
+ export function isBlueprint(value) {
31
+ return isRecord(value)
32
+ && value.blueprint_version === BLUEPRINT_VERSION
33
+ && value.compiler_version === BLUEPRINT_COMPILER_VERSION;
34
+ }
@@ -0,0 +1,47 @@
1
+ import { type JsonSchema, type WorkflowStatus } from "./manifest-validation.js";
2
+ import { type Blueprint, type BlueprintColumnGraft, type BlueprintPromptTemplate, type BlueprintRequires, type BlueprintTable, type BlueprintWorkflow, type RecipeManifest, type RecipeVisualPlanManifest, type WorkflowTriggerManifest } from "./manifest-types.js";
3
+ /**
4
+ * Source hashing and canonical serialization for workflow plans, recipes and blueprints.
5
+ */
6
+ export declare function buildRecipeManifest(input: {
7
+ workflowId: string;
8
+ workflowName: string;
9
+ status?: WorkflowStatus;
10
+ trigger?: WorkflowTriggerManifest;
11
+ inputSchema?: JsonSchema;
12
+ configurationSchema?: JsonSchema;
13
+ configuration?: Record<string, unknown>;
14
+ bundle: string;
15
+ toolsUsed: string[];
16
+ visualPlan?: RecipeVisualPlanManifest;
17
+ maxCredits?: number;
18
+ sourceHash?: string;
19
+ createdAt?: Date;
20
+ }): RecipeManifest;
21
+ /** Canonical executable identity shared by recipe compilers and repair paths. */
22
+ export declare function hashRecipeSource(input: {
23
+ bundle: string;
24
+ configurationSchema?: JsonSchema;
25
+ configuration?: Record<string, unknown>;
26
+ }): string;
27
+ export declare function buildBlueprint(input: {
28
+ id: string;
29
+ name: string;
30
+ summary?: string;
31
+ tags?: string[];
32
+ audience?: string[];
33
+ requires?: BlueprintRequires;
34
+ inputSchema?: JsonSchema;
35
+ tables: BlueprintTable[];
36
+ columnGrafts?: BlueprintColumnGraft[];
37
+ promptTemplates?: BlueprintPromptTemplate[];
38
+ workflows: BlueprintWorkflow[];
39
+ exportedFrom?: {
40
+ oxygen_version?: string;
41
+ };
42
+ exportedAt?: Date;
43
+ sourceHash?: string;
44
+ }): Blueprint;
45
+ export declare function hashWorkflowSource(source: string): string;
46
+ export declare function computeWorkflowPlanHash(input: Record<string, unknown>): string;
47
+ export declare function workflowJsonReplacer(_key: string, value: unknown): unknown;
@@ -0,0 +1,102 @@
1
+ import { DURABLE_RECIPE_COMPILER_VERSION, WORKFLOW_MANIFEST_VERSION } from "./manifest-validation.js";
2
+ import { BLUEPRINT_COMPILER_VERSION, BLUEPRINT_VERSION } from "./manifest-types.js";
3
+ import { createHash } from "node:crypto";
4
+ /**
5
+ * Source hashing and canonical serialization for workflow plans, recipes and blueprints.
6
+ */
7
+ export function buildRecipeManifest(input) {
8
+ const bundle = input.bundle;
9
+ if (typeof bundle !== "string" || bundle.length === 0) {
10
+ throw new Error("Recipe bundle source is required.");
11
+ }
12
+ const sourceHash = input.sourceHash ?? hashRecipeSource({
13
+ bundle,
14
+ ...(input.configurationSchema !== undefined
15
+ ? { configurationSchema: input.configurationSchema }
16
+ : {}),
17
+ ...(input.configuration !== undefined ? { configuration: input.configuration } : {}),
18
+ });
19
+ const manifest = {
20
+ manifest_version: WORKFLOW_MANIFEST_VERSION,
21
+ workflow: {
22
+ id: input.workflowId,
23
+ name: input.workflowName,
24
+ ...(input.status ? { status: input.status } : {}),
25
+ },
26
+ ...(input.trigger ? { trigger: input.trigger } : {}),
27
+ ...(input.inputSchema ? { input_schema: input.inputSchema } : {}),
28
+ ...(input.configurationSchema ? { configuration_schema: input.configurationSchema } : {}),
29
+ ...(input.configuration ? { configuration: input.configuration } : {}),
30
+ runtime: "durable",
31
+ bundle,
32
+ bundle_format: "esm",
33
+ tools_used: Array.from(new Set((input.toolsUsed ?? []).filter(Boolean))).sort(),
34
+ ...(input.visualPlan ? { visual_plan: input.visualPlan } : {}),
35
+ ...(input.maxCredits != null ? { max_credits: input.maxCredits } : {}),
36
+ source_hash: sourceHash,
37
+ compiler_version: DURABLE_RECIPE_COMPILER_VERSION,
38
+ created_at: (input.createdAt ?? new Date()).toISOString(),
39
+ };
40
+ return manifest;
41
+ }
42
+ /** Canonical executable identity shared by recipe compilers and repair paths. */
43
+ export function hashRecipeSource(input) {
44
+ // Preserve the historical bundle-only identity for recipes that have no
45
+ // editable configuration. Configuration-bearing revisions include schema +
46
+ // values because either can change the behavior of the same bundle source.
47
+ if (input.configurationSchema === undefined && input.configuration === undefined) {
48
+ return hashWorkflowSource(input.bundle);
49
+ }
50
+ return hashWorkflowSource(JSON.stringify({
51
+ bundle: input.bundle,
52
+ configuration_schema: input.configurationSchema ?? null,
53
+ configuration: input.configuration ?? null,
54
+ }, workflowJsonReplacer));
55
+ }
56
+ export function buildBlueprint(input) {
57
+ const draft = {
58
+ blueprint_version: BLUEPRINT_VERSION,
59
+ id: input.id,
60
+ name: input.name,
61
+ summary: input.summary ?? "",
62
+ tags: Array.isArray(input.tags) ? Array.from(new Set(input.tags.filter(Boolean))) : [],
63
+ ...(input.audience ? { audience: input.audience } : {}),
64
+ requires: input.requires ?? {},
65
+ ...(input.inputSchema ? { input_schema: input.inputSchema } : {}),
66
+ tables: input.tables,
67
+ ...(input.columnGrafts && input.columnGrafts.length > 0 ? { column_grafts: input.columnGrafts } : {}),
68
+ prompt_templates: input.promptTemplates ?? [],
69
+ workflows: input.workflows,
70
+ exported_at: (input.exportedAt ?? new Date()).toISOString(),
71
+ ...(input.exportedFrom ? { exported_from: input.exportedFrom } : {}),
72
+ compiler_version: BLUEPRINT_COMPILER_VERSION,
73
+ };
74
+ const sourceHash = input.sourceHash
75
+ ?? hashWorkflowSource(JSON.stringify(draft, workflowJsonReplacer));
76
+ return { ...draft, source_hash: sourceHash };
77
+ }
78
+ export function hashWorkflowSource(source) {
79
+ return createHash("sha256").update(source).digest("hex");
80
+ }
81
+ // Deterministic plan hash (Gap 4): binds an approval decision to the exact
82
+ // reviewed plan + cost so it cannot be replayed against a changed plan. The
83
+ // durable mid-run approval gate (recipe-context) hashes its relevant fields
84
+ // through this; binding the imperative `workflows call` admission path the same
85
+ // way is a flagged follow-up. Canonical (sorted-key) JSON keeps the hash stable
86
+ // regardless of key order or undefined fields.
87
+ export function computeWorkflowPlanHash(input) {
88
+ return hashWorkflowSource(canonicalJsonStringify(input));
89
+ }
90
+ function canonicalJsonStringify(value) {
91
+ if (value === null || typeof value !== "object")
92
+ return JSON.stringify(value) ?? "null";
93
+ if (Array.isArray(value))
94
+ return `[${value.map(canonicalJsonStringify).join(",")}]`;
95
+ const entries = Object.entries(value)
96
+ .filter(([, entryValue]) => entryValue !== undefined)
97
+ .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));
98
+ return `{${entries.map(([key, entryValue]) => `${JSON.stringify(key)}:${canonicalJsonStringify(entryValue)}`).join(",")}}`;
99
+ }
100
+ export function workflowJsonReplacer(_key, value) {
101
+ return typeof value === "function" ? Function.prototype.toString.call(value) : value;
102
+ }
@@ -0,0 +1,17 @@
1
+ import { type WorkflowLintIssue, type WorkflowLintResult, type WorkflowManifestValidationOptions } from "./manifest-validation.js";
2
+ import { type Blueprint, type RecipeManifest, type WorkflowDefinition, type WorkflowManifest } from "./manifest-types.js";
3
+ export declare function compileWorkflowDefinition(// skipcq: JS-R1005 -- compiler validates workflow metadata, trigger, steps, branch targets, and defaults together.
4
+ definition: WorkflowDefinition, options?: {
5
+ source?: string;
6
+ sourceHash?: string;
7
+ createdAt?: Date;
8
+ }): WorkflowManifest;
9
+ export declare function lintWorkflowManifest(// skipcq: JS-R1005
10
+ value: unknown, options?: WorkflowManifestValidationOptions): WorkflowLintResult;
11
+ export declare function assertRecipeManifest(value: unknown, options?: WorkflowManifestValidationOptions): asserts value is RecipeManifest;
12
+ export declare function assertWorkflowManifest(value: unknown, options?: WorkflowManifestValidationOptions): asserts value is WorkflowManifest;
13
+ export declare function lintBlueprint(// skipcq: JS-R1005
14
+ value: unknown, options?: WorkflowManifestValidationOptions): WorkflowLintResult;
15
+ export declare function assertBlueprint(value: unknown, options?: WorkflowManifestValidationOptions): asserts value is Blueprint;
16
+ export declare function assertRecipeBundleSafe(bundle: string): void;
17
+ export declare function lintRecipeBundleSafety(bundle: string, path?: string): WorkflowLintIssue[];