@contractspec/integration.workflow-devkit 0.1.1 → 0.1.3

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 CHANGED
@@ -19,6 +19,17 @@ Workflow DevKit compiler and runtime bridges for ContractSpec `WorkflowSpec`.
19
19
  - `@contractspec/integration.workflow-devkit/agent-adapter`
20
20
  - `@contractspec/integration.workflow-devkit/next`
21
21
 
22
+ ## Workflow vs step boundary
23
+
24
+ Workflow DevKit code runs across two different execution contexts:
25
+
26
+ - Workflow functions (`"use workflow"`) orchestrate control flow and must stay deterministic.
27
+ - Step functions (`"use step"`) perform the actual Node.js work.
28
+
29
+ This matches the Workflow docs: workflow functions do not have full Node.js access, while step functions do. Keep Node.js core modules, SDK clients, database access, and other side effects inside `use step` helpers. The workflow function itself should only compose Workflow primitives and call step helpers.
30
+
31
+ For `WorkflowSpec` authoring in Workflow-hosted apps, import the safe authoring API from `@contractspec/lib.contracts-spec/workflow/spec`, not the broad `@contractspec/lib.contracts-spec/workflow` barrel.
32
+
22
33
  ## Next.js example
23
34
 
24
35
  ```ts
@@ -52,6 +63,8 @@ import { onboardingWorkflow } from "./onboarding.workflow";
52
63
  export async function runOnboarding(input: Record<string, unknown>, bridge: WorkflowDevkitRuntimeBridge) {
53
64
  "use workflow";
54
65
 
66
+ // Keep this function deterministic. Node.js work belongs in `use step`
67
+ // helpers that your bridge dispatches to.
55
68
  return runWorkflowSpecWithWorkflowDevkit({
56
69
  spec: onboardingWorkflow,
57
70
  initialData: input,
@@ -1,5 +1,5 @@
1
1
  // src/helpers.ts
2
- import { evaluateExpression } from "@contractspec/lib.contracts-spec/workflow";
2
+ import { evaluateExpression } from "@contractspec/lib.contracts-spec/workflow/expression";
3
3
  function inferWorkflowDevkitBehavior(step) {
4
4
  return step.runtime?.workflowDevkit?.behavior ?? step.type;
5
5
  }
@@ -158,6 +158,9 @@ import { ${exportName} } from "${specImportPath}";
158
158
  export async function ${workflowFunctionName}(input = {}, bridge = {}) {
159
159
  "use workflow";
160
160
 
161
+ // Keep the workflow function deterministic.
162
+ // Any Node.js or side-effectful logic should live in "use step" helpers that
163
+ // your bridge calls, not in this orchestrator itself.
161
164
  return runWorkflowSpecWithWorkflowDevkit({
162
165
  spec: ${exportName},
163
166
  initialData: input,
@@ -1,5 +1,5 @@
1
1
  // src/helpers.ts
2
- import { evaluateExpression } from "@contractspec/lib.contracts-spec/workflow";
2
+ import { evaluateExpression } from "@contractspec/lib.contracts-spec/workflow/expression";
3
3
  function inferWorkflowDevkitBehavior(step) {
4
4
  return step.runtime?.workflowDevkit?.behavior ?? step.type;
5
5
  }
@@ -167,7 +167,7 @@ function readStartIndex(url) {
167
167
  }
168
168
 
169
169
  // src/helpers.ts
170
- import { evaluateExpression } from "@contractspec/lib.contracts-spec/workflow";
170
+ import { evaluateExpression } from "@contractspec/lib.contracts-spec/workflow/expression";
171
171
  function inferWorkflowDevkitBehavior(step) {
172
172
  return step.runtime?.workflowDevkit?.behavior ?? step.type;
173
173
  }
@@ -326,6 +326,9 @@ import { ${exportName} } from "${specImportPath}";
326
326
  export async function ${workflowFunctionName}(input = {}, bridge = {}) {
327
327
  "use workflow";
328
328
 
329
+ // Keep the workflow function deterministic.
330
+ // Any Node.js or side-effectful logic should live in "use step" helpers that
331
+ // your bridge calls, not in this orchestrator itself.
329
332
  return runWorkflowSpecWithWorkflowDevkit({
330
333
  spec: ${exportName},
331
334
  initialData: input,
@@ -1,5 +1,5 @@
1
1
  // src/helpers.ts
2
- import { evaluateExpression } from "@contractspec/lib.contracts-spec/workflow";
2
+ import { evaluateExpression } from "@contractspec/lib.contracts-spec/workflow/expression";
3
3
  function inferWorkflowDevkitBehavior(step) {
4
4
  return step.runtime?.workflowDevkit?.behavior ?? step.type;
5
5
  }
@@ -1,4 +1,4 @@
1
- import type { WorkflowSpec } from '@contractspec/lib.contracts-spec/workflow';
1
+ import type { WorkflowSpec } from '@contractspec/lib.contracts-spec/workflow/spec';
2
2
  import type { WorkflowDevkitCompilation, WorkflowDevkitGeneratedArtifacts } from './types';
3
3
  export interface CompileWorkflowSpecToWorkflowDevkitOptions {
4
4
  exportName: string;
package/dist/compiler.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // @bun
2
2
  // src/helpers.ts
3
- import { evaluateExpression } from "@contractspec/lib.contracts-spec/workflow";
3
+ import { evaluateExpression } from "@contractspec/lib.contracts-spec/workflow/expression";
4
4
  function inferWorkflowDevkitBehavior(step) {
5
5
  return step.runtime?.workflowDevkit?.behavior ?? step.type;
6
6
  }
@@ -159,6 +159,9 @@ import { ${exportName} } from "${specImportPath}";
159
159
  export async function ${workflowFunctionName}(input = {}, bridge = {}) {
160
160
  "use workflow";
161
161
 
162
+ // Keep the workflow function deterministic.
163
+ // Any Node.js or side-effectful logic should live in "use step" helpers that
164
+ // your bridge calls, not in this orchestrator itself.
162
165
  return runWorkflowSpecWithWorkflowDevkit({
163
166
  spec: ${exportName},
164
167
  initialData: input,
package/dist/helpers.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { Step, WorkflowSpec } from '@contractspec/lib.contracts-spec/workflow';
2
- export declare function inferWorkflowDevkitBehavior(step: Step): import("@contractspec/lib.contracts-spec/workflow").StepType | import("@contractspec/lib.contracts-spec/workflow").WorkflowDevkitStepBehavior;
1
+ import type { Step, WorkflowSpec } from '@contractspec/lib.contracts-spec/workflow/spec';
2
+ export declare function inferWorkflowDevkitBehavior(step: Step): import("@contractspec/lib.contracts-spec/workflow/spec").StepType | import("@contractspec/lib.contracts-spec/workflow/workflow-devkit").WorkflowDevkitStepBehavior;
3
3
  export declare function resolveWorkflowDevkitEntryStepId(spec: WorkflowSpec): string;
4
4
  export declare function resolveWorkflowDevkitRunIdentity(spec: WorkflowSpec, runIdentity?: string): string;
5
5
  export declare function resolveWorkflowDevkitWaitToken(spec: WorkflowSpec, step: Step, runIdentity?: string): string | undefined;
package/dist/helpers.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // @bun
2
2
  // src/helpers.ts
3
- import { evaluateExpression } from "@contractspec/lib.contracts-spec/workflow";
3
+ import { evaluateExpression } from "@contractspec/lib.contracts-spec/workflow/expression";
4
4
  function inferWorkflowDevkitBehavior(step) {
5
5
  return step.runtime?.workflowDevkit?.behavior ?? step.type;
6
6
  }
package/dist/index.js CHANGED
@@ -168,7 +168,7 @@ function readStartIndex(url) {
168
168
  }
169
169
 
170
170
  // src/helpers.ts
171
- import { evaluateExpression } from "@contractspec/lib.contracts-spec/workflow";
171
+ import { evaluateExpression } from "@contractspec/lib.contracts-spec/workflow/expression";
172
172
  function inferWorkflowDevkitBehavior(step) {
173
173
  return step.runtime?.workflowDevkit?.behavior ?? step.type;
174
174
  }
@@ -327,6 +327,9 @@ import { ${exportName} } from "${specImportPath}";
327
327
  export async function ${workflowFunctionName}(input = {}, bridge = {}) {
328
328
  "use workflow";
329
329
 
330
+ // Keep the workflow function deterministic.
331
+ // Any Node.js or side-effectful logic should live in "use step" helpers that
332
+ // your bridge calls, not in this orchestrator itself.
330
333
  return runWorkflowSpecWithWorkflowDevkit({
331
334
  spec: ${exportName},
332
335
  initialData: input,
@@ -1,5 +1,5 @@
1
1
  // src/helpers.ts
2
- import { evaluateExpression } from "@contractspec/lib.contracts-spec/workflow";
2
+ import { evaluateExpression } from "@contractspec/lib.contracts-spec/workflow/expression";
3
3
  function inferWorkflowDevkitBehavior(step) {
4
4
  return step.runtime?.workflowDevkit?.behavior ?? step.type;
5
5
  }
@@ -158,6 +158,9 @@ import { ${exportName} } from "${specImportPath}";
158
158
  export async function ${workflowFunctionName}(input = {}, bridge = {}) {
159
159
  "use workflow";
160
160
 
161
+ // Keep the workflow function deterministic.
162
+ // Any Node.js or side-effectful logic should live in "use step" helpers that
163
+ // your bridge calls, not in this orchestrator itself.
161
164
  return runWorkflowSpecWithWorkflowDevkit({
162
165
  spec: ${exportName},
163
166
  initialData: input,
@@ -1,5 +1,5 @@
1
1
  // src/helpers.ts
2
- import { evaluateExpression } from "@contractspec/lib.contracts-spec/workflow";
2
+ import { evaluateExpression } from "@contractspec/lib.contracts-spec/workflow/expression";
3
3
  function inferWorkflowDevkitBehavior(step) {
4
4
  return step.runtime?.workflowDevkit?.behavior ?? step.type;
5
5
  }
@@ -167,7 +167,7 @@ function readStartIndex(url) {
167
167
  }
168
168
 
169
169
  // src/helpers.ts
170
- import { evaluateExpression } from "@contractspec/lib.contracts-spec/workflow";
170
+ import { evaluateExpression } from "@contractspec/lib.contracts-spec/workflow/expression";
171
171
  function inferWorkflowDevkitBehavior(step) {
172
172
  return step.runtime?.workflowDevkit?.behavior ?? step.type;
173
173
  }
@@ -326,6 +326,9 @@ import { ${exportName} } from "${specImportPath}";
326
326
  export async function ${workflowFunctionName}(input = {}, bridge = {}) {
327
327
  "use workflow";
328
328
 
329
+ // Keep the workflow function deterministic.
330
+ // Any Node.js or side-effectful logic should live in "use step" helpers that
331
+ // your bridge calls, not in this orchestrator itself.
329
332
  return runWorkflowSpecWithWorkflowDevkit({
330
333
  spec: ${exportName},
331
334
  initialData: input,
@@ -1,5 +1,5 @@
1
1
  // src/helpers.ts
2
- import { evaluateExpression } from "@contractspec/lib.contracts-spec/workflow";
2
+ import { evaluateExpression } from "@contractspec/lib.contracts-spec/workflow/expression";
3
3
  function inferWorkflowDevkitBehavior(step) {
4
4
  return step.runtime?.workflowDevkit?.behavior ?? step.type;
5
5
  }
package/dist/runtime.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { WorkflowSpec } from '@contractspec/lib.contracts-spec/workflow';
1
+ import type { WorkflowSpec } from '@contractspec/lib.contracts-spec/workflow/spec';
2
2
  import type { WorkflowDevkitPrimitives, WorkflowDevkitRunResult, WorkflowDevkitRuntimeBridge } from './types';
3
3
  export interface RunWorkflowSpecWithWorkflowDevkitOptions {
4
4
  bridge?: WorkflowDevkitRuntimeBridge;
package/dist/runtime.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // @bun
2
2
  // src/helpers.ts
3
- import { evaluateExpression } from "@contractspec/lib.contracts-spec/workflow";
3
+ import { evaluateExpression } from "@contractspec/lib.contracts-spec/workflow/expression";
4
4
  function inferWorkflowDevkitBehavior(step) {
5
5
  return step.runtime?.workflowDevkit?.behavior ?? step.type;
6
6
  }
package/dist/types.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import type { Step, WorkflowDevkitHostTarget, WorkflowDevkitIntegrationMode, WorkflowDevkitStepBehavior, WorkflowDevkitStepRuntimeConfig, WorkflowSpec } from '@contractspec/lib.contracts-spec/workflow';
1
+ import type { Step, WorkflowSpec } from '@contractspec/lib.contracts-spec/workflow/spec';
2
+ import type { WorkflowDevkitHostTarget, WorkflowDevkitIntegrationMode, WorkflowDevkitStepBehavior, WorkflowDevkitStepRuntimeConfig } from '@contractspec/lib.contracts-spec/workflow/workflow-devkit';
2
3
  import type { UIMessageChunk } from 'ai';
3
4
  export interface WorkflowDevkitCompiledTransition {
4
5
  condition?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contractspec/integration.workflow-devkit",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Workflow DevKit compiler and runtime bridges for ContractSpec workflows",
5
5
  "keywords": [
6
6
  "contractspec",
@@ -77,7 +77,7 @@
77
77
  "scripts": {
78
78
  "publish:pkg": "bun publish --tolerate-republish --ignore-scripts --verbose",
79
79
  "publish:pkg:canary": "bun publish:pkg --tag canary",
80
- "build": "bun run prebuild && bun run build:bundle && bun run build:types",
80
+ "build": "bun run build:bundle && bun run build:types",
81
81
  "build:bundle": "contractspec-bun-build transpile",
82
82
  "build:types": "contractspec-bun-build types",
83
83
  "dev": "contractspec-bun-build dev",
@@ -90,15 +90,15 @@
90
90
  "typecheck": "tsc --noEmit"
91
91
  },
92
92
  "dependencies": {
93
- "@contractspec/lib.ai-agent": "8.0.3",
94
- "@contractspec/lib.contracts-spec": "5.0.3",
93
+ "@contractspec/lib.ai-agent": "8.0.5",
94
+ "@contractspec/lib.contracts-spec": "5.1.0",
95
95
  "@workflow/ai": "^4.1.0-beta.58",
96
96
  "ai": "6.0.138",
97
97
  "workflow": "^4.2.0-beta.72"
98
98
  },
99
99
  "devDependencies": {
100
- "@contractspec/tool.bun": "3.7.11",
101
- "@contractspec/tool.typescript": "3.7.11",
100
+ "@contractspec/tool.bun": "3.7.13",
101
+ "@contractspec/tool.typescript": "3.7.13",
102
102
  "typescript": "^5.9.3"
103
103
  },
104
104
  "publishConfig": {