@cynodia/axiom-agent-api 0.14.0-alpha.1 → 0.14.0-alpha.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.
Files changed (2) hide show
  1. package/dist/workflow.js +23 -6
  2. package/package.json +2 -2
package/dist/workflow.js CHANGED
@@ -1,19 +1,30 @@
1
- import { workflowActionIds, workflowEventIds, workflowHasCycle, workflowReachableSteps, workflowStepSuccessors, } from '@cynodia/axiom-core';
1
+ import { isWorkflowStep, workflowActionIds, workflowEventIds, workflowHasCycle, workflowReachableSteps, workflowStepSuccessors, workflowStructuralProblems, } from '@cynodia/axiom-core';
2
2
  export function analyzeWorkflow(graph, workflowId) {
3
3
  const workflow = graph
4
4
  .getNodesByKind('workflow')
5
- .find((node) => String(node.id) === String(workflowId));
5
+ .find((node) => String(node?.id) === String(workflowId));
6
6
  if (!workflow) {
7
7
  throw new Error(`analyzeWorkflow: no workflow node "${workflowId}"`);
8
8
  }
9
+ // spec14pt4 F1 — `analyzeWorkflow` is static analysis and must be **total** over a
10
+ // malformed `WorkflowDef` (a `null` step, `steps` that is not an array, an unknown step
11
+ // kind). Prove structural validity through the shared total validator *before* any
12
+ // traversal reads `step.id` / `step.type`; a structured `Error` (AgentAPI's existing
13
+ // convention, mirroring the "no workflow node" throw above) — never a native `TypeError`.
14
+ const structuralProblems = workflowStructuralProblems(workflow);
15
+ if (structuralProblems.length > 0) {
16
+ throw new Error(`analyzeWorkflow: workflow "${String(workflow.id ?? workflowId)}" is not structurally valid: ` +
17
+ structuralProblems.map((p) => `[${p.code}] ${p.message}`).join('; '));
18
+ }
19
+ const stepList = (Array.isArray(workflow.steps) ? workflow.steps : []).filter(isWorkflowStep);
9
20
  const reachable = workflowReachableSteps(workflow);
10
- const steps = workflow.steps
21
+ const steps = stepList
11
22
  .filter((step) => reachable.has(String(step.id)))
12
23
  .map((step) => describeStep(step));
13
24
  const completed = steps.filter((s) => s.type === 'complete').map((s) => s.id);
14
25
  const failed = steps.filter((s) => s.type === 'fail').map((s) => s.id);
15
26
  const waitReasons = new Set(['ownership']);
16
- for (const step of workflow.steps) {
27
+ for (const step of stepList) {
17
28
  if (!reachable.has(String(step.id)))
18
29
  continue;
19
30
  if (step.type === 'wait-event')
@@ -25,8 +36,14 @@ export function analyzeWorkflow(graph, workflowId) {
25
36
  }
26
37
  return {
27
38
  workflowId: String(workflow.id),
28
- inputs: (workflow.inputs ?? []).map((input) => ({ id: String(input.id), required: input.required !== false })),
29
- bindings: (workflow.bindings ?? []).map((b) => ({ id: String(b.id), producedBy: String(b.producedBy) })),
39
+ inputs: (Array.isArray(workflow.inputs) ? workflow.inputs : []).map((input) => ({
40
+ id: String(input.id),
41
+ required: input.required !== false,
42
+ })),
43
+ bindings: (Array.isArray(workflow.bindings) ? workflow.bindings : []).map((b) => ({
44
+ id: String(b.id),
45
+ producedBy: String(b.producedBy),
46
+ })),
30
47
  entry: String(workflow.entry),
31
48
  steps,
32
49
  actionDependencies: [...new Set(workflowActionIds(workflow).map(String))].sort(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cynodia/axiom-agent-api",
3
- "version": "0.14.0-alpha.1",
3
+ "version": "0.14.0-alpha.3",
4
4
  "description": "Semantic queries and transactional graph transformations for AI agents.",
5
5
  "license": "MIT",
6
6
  "author": "AskTech AS",
@@ -31,7 +31,7 @@
31
31
  }
32
32
  },
33
33
  "dependencies": {
34
- "@cynodia/axiom-core": "0.14.0-alpha.1"
34
+ "@cynodia/axiom-core": "0.14.0-alpha.3"
35
35
  },
36
36
  "scripts": {
37
37
  "build": "tsc -b tsconfig.json tsconfig.test.json",