@axiom-lattice/protocols 2.1.41 → 2.1.43

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.
@@ -39,8 +39,8 @@ export interface UIConfig {
39
39
  */
40
40
  export interface UIComponent<T = any> {
41
41
  render: (props?: any) => T;
42
- addEventListener: (event: string, handler: Function) => void;
43
- removeEventListener: (event: string, handler: Function) => void;
42
+ addEventListener: (event: string, handler: (...args: unknown[]) => void) => void;
43
+ removeEventListener: (event: string, handler: (...args: unknown[]) => void) => void;
44
44
  }
45
45
 
46
46
  /**
@@ -52,6 +52,6 @@ export interface UILatticeProtocol<T = any>
52
52
  render: (props?: any) => T;
53
53
 
54
54
  // 事件处理
55
- addEventListener: (event: string, handler: Function) => void;
56
- removeEventListener: (event: string, handler: Function) => void;
55
+ addEventListener: (event: string, handler: (...args: unknown[]) => void) => void;
56
+ removeEventListener: (event: string, handler: (...args: unknown[]) => void) => void;
57
57
  }
@@ -0,0 +1,72 @@
1
+ /**
2
+ * YAML Workflow DSL — linear model with parallel blocks
3
+ *
4
+ * Steps execute top-to-bottom. `parallel:` blocks declare concurrency.
5
+ * `if` on any step skips it. `map` iterates over arrays.
6
+ * No `needs` — execution order = reading order.
7
+ *
8
+ * Template syntax:
9
+ * {{input}} — initial user input
10
+ * {{label}} — output of step with given label
11
+ * {{label.field}} — nested field access on structured output
12
+ * {{item}} — current element in map iterations
13
+ */
14
+
15
+ // ─── Top-level ─────────────────────────────────────────────────────────────
16
+
17
+ export interface YamlWorkflow {
18
+ /** Optional workflow name — defaults to "workflow" if omitted. */
19
+ name?: string;
20
+ steps: YamlTopLevelStep[];
21
+ }
22
+
23
+ export type YamlTopLevelStep = YamlAgentStep | YamlParallelBlock | YamlMapStep;
24
+
25
+ // ─── Agent step ────────────────────────────────────────────────────────────
26
+
27
+ export interface YamlAgentStep {
28
+ /** Unique label serving as state key and template reference. */
29
+ label: string;
30
+ /** JS expression evaluated as boolean. Step skipped when falsy. */
31
+ if?: string;
32
+ /** Agent instruction with {{template}} references. */
33
+ prompt: string;
34
+ /** Shorthand output schema: { field: "string" | "number" | "boolean" } */
35
+ output?: Record<string, unknown>;
36
+ /** When true, inject ask_user_to_clarify middleware. */
37
+ ask?: boolean;
38
+ }
39
+
40
+ // ─── Parallel block ────────────────────────────────────────────────────────
41
+
42
+ export interface YamlParallelBlock {
43
+ parallel: YamlAgentStep[];
44
+ /** JS expression evaluated as boolean. Entire block skipped when falsy. */
45
+ if?: string;
46
+ /** Shorthand output schema for aggregated results. */
47
+ output?: Record<string, unknown>;
48
+ }
49
+
50
+ // ─── Map step ──────────────────────────────────────────────────────────────
51
+
52
+ export interface YamlMapStep {
53
+ map: {
54
+ /** Path to source array (e.g. "extract.items"). */
55
+ source: string;
56
+ /** Step label for referencing in templates (e.g. {{label}}). */
57
+ label: string;
58
+ /** JS expression evaluated as boolean. Entire map skipped when falsy. */
59
+ if?: string;
60
+ /** Agent applied to each element. Use {{item}} for current element. */
61
+ each: {
62
+ prompt: string;
63
+ output?: Record<string, unknown>;
64
+ };
65
+ /** Shorthand output schema for the aggregated results. */
66
+ output?: Record<string, unknown>;
67
+ /** Items per batch (default 50). */
68
+ batch?: number;
69
+ /** Max parallel items (default 5). */
70
+ concurrency?: number;
71
+ };
72
+ }
@@ -11,7 +11,7 @@ export interface TopologyEdge {
11
11
  purpose: string;
12
12
  }
13
13
 
14
- export type WorkflowRunStatus = 'running' | 'completed' | 'failed' | 'cancelled';
14
+ export type WorkflowRunStatus = 'running' | 'completed' | 'failed' | 'cancelled' | 'interrupted';
15
15
 
16
16
  export interface WorkflowRun {
17
17
  id: string;
@@ -25,13 +25,13 @@ export interface WorkflowRun {
25
25
  errorMessage?: string;
26
26
  metadata?: Record<string, any>;
27
27
  startedAt: Date;
28
- completedAt?: Date;
28
+ completedAt?: Date | null;
29
29
  createdAt: Date;
30
30
  updatedAt: Date;
31
31
  }
32
32
 
33
- export type StepType = 'task_delegation' | 'tool_call' | 'human_in_loop' | 'topology_transition';
34
- export type StepStatus = 'running' | 'completed' | 'failed' | 'interrupted';
33
+ export type StepType = 'task_delegation' | 'tool_call' | 'human_in_loop' | 'topology_transition' | 'agent' | 'human_feedback' | 'map' | 'input' | 'terminal';
34
+ export type StepStatus = 'running' | 'completed' | 'failed' | 'interrupted' | 'skipped';
35
35
 
36
36
  export interface RunStep {
37
37
  id: string;
@@ -39,6 +39,8 @@ export interface RunStep {
39
39
  tenantId: string;
40
40
  stepType: StepType;
41
41
  stepName: string;
42
+ /** Sub-agent thread_id for agent/map steps. null for input/terminal. */
43
+ threadId?: string | null;
42
44
  edgeFrom?: string;
43
45
  edgeTo?: string;
44
46
  edgePurpose?: string;
@@ -47,7 +49,7 @@ export interface RunStep {
47
49
  status: StepStatus;
48
50
  errorMessage?: string;
49
51
  startedAt: Date;
50
- completedAt?: Date;
52
+ completedAt?: Date | null;
51
53
  durationMs?: number;
52
54
  createdAt: Date;
53
55
  updatedAt: Date;
@@ -65,7 +67,7 @@ export interface UpdateWorkflowRunRequest {
65
67
  status?: WorkflowRunStatus;
66
68
  completedEdges?: number;
67
69
  errorMessage?: string;
68
- completedAt?: Date;
70
+ completedAt?: Date | null;
69
71
  metadata?: Record<string, any>;
70
72
  }
71
73
 
@@ -74,6 +76,7 @@ export interface CreateRunStepRequest {
74
76
  tenantId: string;
75
77
  stepType: StepType;
76
78
  stepName: string;
79
+ threadId?: string | null;
77
80
  edgeFrom?: string;
78
81
  edgeTo?: string;
79
82
  edgePurpose?: string;
@@ -84,7 +87,7 @@ export interface UpdateRunStepRequest {
84
87
  status?: StepStatus;
85
88
  output?: Record<string, any>;
86
89
  errorMessage?: string;
87
- completedAt?: Date;
90
+ completedAt?: Date | null;
88
91
  durationMs?: number;
89
92
  }
90
93
 
@@ -100,6 +103,8 @@ export interface WorkflowTrackingStore {
100
103
 
101
104
  // RunStep CRUD
102
105
  createRunStep(request: CreateRunStepRequest): Promise<RunStep>;
106
+ /** Idempotent create — uses (runId, stepType, stepName) as unique key. Returns existing step if one already exists. */
107
+ upsertRunStep(request: CreateRunStepRequest): Promise<RunStep>;
103
108
  updateRunStep(runId: string, stepId: string, updates: UpdateRunStepRequest): Promise<RunStep | null>;
104
109
  getRunSteps(runId: string): Promise<RunStep[]>;
105
110
  getRunStepsByType(runId: string, stepType: StepType): Promise<RunStep[]>;
package/src/index.ts CHANGED
@@ -31,11 +31,19 @@ export * from "./UserStoreProtocol";
31
31
  export * from "./UserTenantLinkProtocol";
32
32
  export * from "./WorkflowTrackingStoreProtocol";
33
33
  export * from "./BindingProtocol";
34
+ export * from "./MenuProtocol";
34
35
  export * from "./EvalStoreProtocol";
36
+ export * from "./TaskStoreProtocol";
35
37
 
36
38
  export * from "./ChannelAdapterProtocol";
37
39
  export * from "./A2AProtocol";
38
40
  export * from "./A2AApiKeyStoreProtocol";
39
41
 
42
+ // Workflow DSL (concise, public API)
43
+ export * from "./WorkflowDSL";
44
+
45
+ // Internal DSL (expanded IR, internal use)
46
+ export * from "./InternalDSL";
47
+
40
48
  // 导出通用类型
41
49
  export * from "./types";