@cynodia/axiom-agent-api 0.13.1-alpha.1 → 0.14.0-alpha.2
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/dist/api.d.ts +8 -0
- package/dist/api.js +10 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/workflow.d.ts +65 -0
- package/dist/workflow.js +74 -0
- package/package.json +2 -2
package/dist/api.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type { ChangeSet } from './changes.js';
|
|
|
5
5
|
import type { MigrationImpact, SchemaInspection } from './migration.js';
|
|
6
6
|
import type { DistributedSemanticsInspection } from './distributed.js';
|
|
7
7
|
import type { LiveQueryAnalysis } from './live-query.js';
|
|
8
|
+
import type { WorkflowAnalysis } from './workflow.js';
|
|
8
9
|
/**
|
|
9
10
|
* The machine-facing interface to an application. Agents query semantics and apply
|
|
10
11
|
* structural transformations; they never edit generated code.
|
|
@@ -51,5 +52,12 @@ export declare class AgentAPI extends PresentationQueries {
|
|
|
51
52
|
* `AxiomServer.inspectLiveQueries()`.
|
|
52
53
|
*/
|
|
53
54
|
analyzeLiveQuery(queryId: string): LiveQueryAnalysis;
|
|
55
|
+
/**
|
|
56
|
+
* The durable-workflow semantics of one `WorkflowDef` (spec14 §138, §139): its inputs,
|
|
57
|
+
* step shape and edges, action / event dependencies, reachable terminal outcomes,
|
|
58
|
+
* acyclicity, and the kinds of `waitingReason` an instance can produce. Static over the
|
|
59
|
+
* graph; live runtime state is `AxiomServer.getWorkflow(instanceId)`.
|
|
60
|
+
*/
|
|
61
|
+
analyzeWorkflow(workflowId: string): WorkflowAnalysis;
|
|
54
62
|
}
|
|
55
63
|
//# sourceMappingURL=api.d.ts.map
|
package/dist/api.js
CHANGED
|
@@ -4,6 +4,7 @@ import { Transaction } from './transaction.js';
|
|
|
4
4
|
import { inspectSchema, migrationImpact } from './migration.js';
|
|
5
5
|
import { inspectDistributedSemantics } from './distributed.js';
|
|
6
6
|
import { analyzeLiveQuery } from './live-query.js';
|
|
7
|
+
import { analyzeWorkflow } from './workflow.js';
|
|
7
8
|
/**
|
|
8
9
|
* The machine-facing interface to an application. Agents query semantics and apply
|
|
9
10
|
* structural transformations; they never edit generated code.
|
|
@@ -72,4 +73,13 @@ export class AgentAPI extends PresentationQueries {
|
|
|
72
73
|
analyzeLiveQuery(queryId) {
|
|
73
74
|
return analyzeLiveQuery(this.graph, queryId);
|
|
74
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* The durable-workflow semantics of one `WorkflowDef` (spec14 §138, §139): its inputs,
|
|
78
|
+
* step shape and edges, action / event dependencies, reachable terminal outcomes,
|
|
79
|
+
* acyclicity, and the kinds of `waitingReason` an instance can produce. Static over the
|
|
80
|
+
* graph; live runtime state is `AxiomServer.getWorkflow(instanceId)`.
|
|
81
|
+
*/
|
|
82
|
+
analyzeWorkflow(workflowId) {
|
|
83
|
+
return analyzeWorkflow(this.graph, workflowId);
|
|
84
|
+
}
|
|
75
85
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export * from './queries.js';
|
|
|
3
3
|
export * from './migration.js';
|
|
4
4
|
export * from './distributed.js';
|
|
5
5
|
export * from './live-query.js';
|
|
6
|
+
export * from './workflow.js';
|
|
6
7
|
export * from './presentation-queries.js';
|
|
7
8
|
export * from './transaction.js';
|
|
8
9
|
export * from './api.js';
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@ export * from './queries.js';
|
|
|
3
3
|
export * from './migration.js';
|
|
4
4
|
export * from './distributed.js';
|
|
5
5
|
export * from './live-query.js';
|
|
6
|
+
export * from './workflow.js';
|
|
6
7
|
export * from './presentation-queries.js';
|
|
7
8
|
export * from './transaction.js';
|
|
8
9
|
export * from './api.js';
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { type ApplicationGraph, type WorkflowStepType } from '@cynodia/axiom-core';
|
|
2
|
+
/**
|
|
3
|
+
* Static, graph-derivable workflow analysis (spec14 §138, §139). The AgentAPI works over an
|
|
4
|
+
* `ApplicationGraph`, not a running authority, so it answers the *semantic* questions — the
|
|
5
|
+
* inputs, the shape, the dependencies, the terminal outcomes, why an instance could wait —
|
|
6
|
+
* not the live runtime state (that is `AxiomServer.getWorkflow(instanceId)`).
|
|
7
|
+
*
|
|
8
|
+
* Nothing here executes a workflow. A `WorkflowDef` is graph meaning; the runtime owns
|
|
9
|
+
* scheduling, persistence, retries and fencing.
|
|
10
|
+
*/
|
|
11
|
+
export interface WorkflowStepAnalysis {
|
|
12
|
+
id: string;
|
|
13
|
+
type: WorkflowStepType;
|
|
14
|
+
/** Every step id this step can hand control to. */
|
|
15
|
+
successors: string[];
|
|
16
|
+
/** `action` steps: the ActionDef id and whether a retry policy is declared. */
|
|
17
|
+
action?: {
|
|
18
|
+
actionId: string;
|
|
19
|
+
retry: boolean;
|
|
20
|
+
onError: string | null;
|
|
21
|
+
};
|
|
22
|
+
/** `wait-event` steps: the EventDef id, whether it has a timeout / timeout edge. */
|
|
23
|
+
event?: {
|
|
24
|
+
eventId: string;
|
|
25
|
+
hasWhere: boolean;
|
|
26
|
+
timeout: boolean;
|
|
27
|
+
onTimeout: string | null;
|
|
28
|
+
binds: string[];
|
|
29
|
+
};
|
|
30
|
+
/** `timer` steps: `after` seconds or `at` (an expression). */
|
|
31
|
+
timer?: {
|
|
32
|
+
afterSeconds: number | null;
|
|
33
|
+
at: boolean;
|
|
34
|
+
};
|
|
35
|
+
terminal?: 'completed' | 'failed';
|
|
36
|
+
}
|
|
37
|
+
export interface WorkflowAnalysis {
|
|
38
|
+
workflowId: string;
|
|
39
|
+
inputs: Array<{
|
|
40
|
+
id: string;
|
|
41
|
+
required: boolean;
|
|
42
|
+
}>;
|
|
43
|
+
bindings: Array<{
|
|
44
|
+
id: string;
|
|
45
|
+
producedBy: string;
|
|
46
|
+
}>;
|
|
47
|
+
entry: string;
|
|
48
|
+
steps: WorkflowStepAnalysis[];
|
|
49
|
+
/** Distinct `ActionDef` ids the workflow invokes. */
|
|
50
|
+
actionDependencies: string[];
|
|
51
|
+
/** Distinct `EventDef` ids the workflow waits on. */
|
|
52
|
+
eventDependencies: string[];
|
|
53
|
+
/** The reachable terminal steps, by kind. */
|
|
54
|
+
terminalOutcomes: {
|
|
55
|
+
completed: string[];
|
|
56
|
+
failed: string[];
|
|
57
|
+
};
|
|
58
|
+
acyclic: boolean;
|
|
59
|
+
/** Every distinct kind of `waitingReason` this workflow can produce (spec14 §141). */
|
|
60
|
+
possibleWaitReasons: Array<'event' | 'timer' | 'retry' | 'ownership'>;
|
|
61
|
+
/** The authorization context: workflow ActionDef steps run under the workflow's bound principal (spec14 §23). */
|
|
62
|
+
authorizationContext: 'workflow-bound-principal';
|
|
63
|
+
}
|
|
64
|
+
export declare function analyzeWorkflow(graph: ApplicationGraph, workflowId: string): WorkflowAnalysis;
|
|
65
|
+
//# sourceMappingURL=workflow.d.ts.map
|
package/dist/workflow.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { workflowActionIds, workflowEventIds, workflowHasCycle, workflowReachableSteps, workflowStepSuccessors, } from '@cynodia/axiom-core';
|
|
2
|
+
export function analyzeWorkflow(graph, workflowId) {
|
|
3
|
+
const workflow = graph
|
|
4
|
+
.getNodesByKind('workflow')
|
|
5
|
+
.find((node) => String(node.id) === String(workflowId));
|
|
6
|
+
if (!workflow) {
|
|
7
|
+
throw new Error(`analyzeWorkflow: no workflow node "${workflowId}"`);
|
|
8
|
+
}
|
|
9
|
+
const reachable = workflowReachableSteps(workflow);
|
|
10
|
+
const steps = workflow.steps
|
|
11
|
+
.filter((step) => reachable.has(String(step.id)))
|
|
12
|
+
.map((step) => describeStep(step));
|
|
13
|
+
const completed = steps.filter((s) => s.type === 'complete').map((s) => s.id);
|
|
14
|
+
const failed = steps.filter((s) => s.type === 'fail').map((s) => s.id);
|
|
15
|
+
const waitReasons = new Set(['ownership']);
|
|
16
|
+
for (const step of workflow.steps) {
|
|
17
|
+
if (!reachable.has(String(step.id)))
|
|
18
|
+
continue;
|
|
19
|
+
if (step.type === 'wait-event')
|
|
20
|
+
waitReasons.add('event');
|
|
21
|
+
if (step.type === 'timer')
|
|
22
|
+
waitReasons.add('timer');
|
|
23
|
+
if (step.type === 'action' && step.retry)
|
|
24
|
+
waitReasons.add('retry');
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
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) })),
|
|
30
|
+
entry: String(workflow.entry),
|
|
31
|
+
steps,
|
|
32
|
+
actionDependencies: [...new Set(workflowActionIds(workflow).map(String))].sort(),
|
|
33
|
+
eventDependencies: [...new Set(workflowEventIds(workflow).map(String))].sort(),
|
|
34
|
+
terminalOutcomes: { completed: completed.sort(), failed: failed.sort() },
|
|
35
|
+
acyclic: !workflowHasCycle(workflow),
|
|
36
|
+
possibleWaitReasons: [...waitReasons].sort(),
|
|
37
|
+
authorizationContext: 'workflow-bound-principal',
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function describeStep(step) {
|
|
41
|
+
const base = {
|
|
42
|
+
id: String(step.id),
|
|
43
|
+
type: step.type,
|
|
44
|
+
successors: workflowStepSuccessors(step).map(String),
|
|
45
|
+
};
|
|
46
|
+
switch (step.type) {
|
|
47
|
+
case 'action':
|
|
48
|
+
base.action = {
|
|
49
|
+
actionId: String(step.action),
|
|
50
|
+
retry: Boolean(step.retry),
|
|
51
|
+
onError: step.onError ? String(step.onError) : null,
|
|
52
|
+
};
|
|
53
|
+
break;
|
|
54
|
+
case 'wait-event':
|
|
55
|
+
base.event = {
|
|
56
|
+
eventId: String(step.event),
|
|
57
|
+
hasWhere: Boolean(step.where),
|
|
58
|
+
timeout: Boolean(step.timeout),
|
|
59
|
+
onTimeout: step.onTimeout ? String(step.onTimeout) : null,
|
|
60
|
+
binds: Object.keys(step.bind ?? {}).sort(),
|
|
61
|
+
};
|
|
62
|
+
break;
|
|
63
|
+
case 'timer':
|
|
64
|
+
base.timer = { afterSeconds: step.after ? step.after.seconds : null, at: Boolean(step.at) };
|
|
65
|
+
break;
|
|
66
|
+
case 'complete':
|
|
67
|
+
base.terminal = 'completed';
|
|
68
|
+
break;
|
|
69
|
+
case 'fail':
|
|
70
|
+
base.terminal = 'failed';
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
return base;
|
|
74
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cynodia/axiom-agent-api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0-alpha.2",
|
|
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.
|
|
34
|
+
"@cynodia/axiom-core": "0.14.0-alpha.2"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
37
|
"build": "tsc -b tsconfig.json tsconfig.test.json",
|