@almadar/agent 1.6.4 → 2.0.1
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/LICENSE +21 -72
- package/README.md +25 -0
- package/dist/agent/event-budget.d.ts +28 -0
- package/dist/agent/experimental/hitl-v2.d.ts +161 -0
- package/dist/agent/experimental/hitl-workflow-integration.d.ts +182 -0
- package/dist/agent/index.d.ts +14 -13
- package/dist/agent/index.js.map +1 -1
- package/dist/agent/interrupt-config.d.ts +51 -0
- package/dist/agent/session-manager.d.ts +204 -0
- package/dist/agent/skill-agent.d.ts +182 -0
- package/dist/agent/workflow-middleware.d.ts +63 -0
- package/dist/agent/workflow-tool-wrapper.d.ts +87 -0
- package/dist/{api-types-CXrq-fts.d.ts → api-types.d.ts} +85 -51
- package/dist/context/compaction.d.ts +191 -0
- package/dist/context-compaction.d.ts +55 -0
- package/dist/evals/online-sampling.d.ts +114 -0
- package/dist/evals/utils/compact-orbital.d.ts +100 -0
- package/dist/event-transformer/event-transformer.d.ts +120 -0
- package/dist/event-transformer/index.d.ts +4 -122
- package/dist/events.d.ts +85 -0
- package/dist/index.d.ts +58 -1678
- package/dist/index.js +39 -0
- package/dist/index.js.map +1 -1
- package/dist/memory/MemoryManager.d.ts +243 -0
- package/dist/memory/PreferenceLearner.d.ts +59 -0
- package/dist/memory/agentic-search.d.ts +116 -0
- package/dist/memory/index.d.ts +14 -0
- package/dist/memory/memory-orbital.d.ts +66 -0
- package/dist/memory/types.d.ts +143 -0
- package/dist/metrics.d.ts +77 -0
- package/dist/multi-user.d.ts +155 -0
- package/dist/observability/index.d.ts +14 -0
- package/dist/observability/langsmith-integration.d.ts +203 -0
- package/dist/observability.d.ts +196 -0
- package/dist/orbitals/archive/sanitize.d.ts +24 -0
- package/dist/orbitals/batch/batch-generator.d.ts +41 -0
- package/dist/orbitals/batch/concurrency.d.ts +54 -0
- package/dist/orbitals/batch/index.d.ts +14 -0
- package/dist/orbitals/batch/prompt-assembler.d.ts +92 -0
- package/dist/orbitals/batch/types.d.ts +103 -0
- package/dist/orbitals/cache/index.d.ts +11 -0
- package/dist/orbitals/cache/orbital-fingerprint.d.ts +37 -0
- package/dist/orbitals/cache/prompt-assembler.d.ts +65 -0
- package/dist/orbitals/cache/structural-templates.d.ts +33 -0
- package/dist/orbitals/combiner/index.d.ts +102 -0
- package/dist/orbitals/domain-language/index.d.ts +9 -0
- package/dist/orbitals/domain-language/prompts/index.d.ts +11 -0
- package/dist/orbitals/domain-language/prompts/odl-examples.d.ts +8 -0
- package/dist/orbitals/domain-language/prompts/odl-patterns.d.ts +8 -0
- package/dist/orbitals/domain-language/prompts/odl-syntax.d.ts +8 -0
- package/dist/orbitals/domain-language/prompts/odl-to-schema.d.ts +8 -0
- package/dist/orbitals/generation/index.d.ts +10 -0
- package/dist/orbitals/generation/orbital-generator.d.ts +120 -0
- package/dist/orbitals/shared/constants.d.ts +65 -0
- package/dist/orbitals/shared/index.d.ts +11 -0
- package/dist/orbitals/shared/types.d.ts +187 -0
- package/dist/orbitals/shared/utils.d.ts +97 -0
- package/dist/orchestration/complexity-classifier.d.ts +38 -0
- package/dist/orchestration/fixing-orchestrator.d.ts +53 -0
- package/dist/orchestration/index.d.ts +31 -0
- package/dist/orchestration/provider-router.d.ts +45 -0
- package/dist/{firestore-checkpointer-CkNKXoun.d.ts → persistence/firestore-checkpointer.d.ts} +13 -58
- package/dist/persistence/firestore-session-store.d.ts +75 -0
- package/dist/persistence/firestore-store.d.ts +86 -0
- package/dist/persistence/index.d.ts +7 -198
- package/dist/persistence/memory-backend.d.ts +33 -0
- package/dist/persistence/types.d.ts +40 -0
- package/dist/security/audit-log.d.ts +44 -0
- package/dist/state-sync.d.ts +171 -0
- package/dist/subagents.d.ts +38 -0
- package/dist/tools/combine-schemas.d.ts +154 -0
- package/dist/tools/composition.d.ts +119 -0
- package/dist/{orbital-subagent-BdFuf77p.d.ts → tools/domain-orbital.d.ts} +22 -461
- package/dist/tools/execute.d.ts +38 -0
- package/dist/tools/finish-task.d.ts +56 -0
- package/dist/tools/generate-schema.d.ts +53 -0
- package/dist/tools/github.d.ts +297 -0
- package/dist/tools/index.d.ts +1318 -8
- package/dist/tools/orbital-batch-subagent.d.ts +85 -0
- package/dist/tools/orbital-subagent.d.ts +454 -0
- package/dist/tools/orchestrated-fixing.d.ts +74 -0
- package/dist/tools/orchestrated-generation.d.ts +75 -0
- package/dist/tools/sandbox-executor.d.ts +31 -0
- package/dist/tools/schema-chunking.d.ts +117 -0
- package/dist/tools/trait-subagent.d.ts +179 -0
- package/dist/tools/validate-schema.d.ts +17 -0
- package/dist/types.d.ts +14 -17
- package/dist/utils/safety/capability-token.d.ts +50 -0
- package/dist/utils/safety/circuit-breaker.d.ts +71 -0
- package/dist/utils/safety/index.d.ts +19 -0
- package/dist/utils/safety/rate-limiter.d.ts +39 -0
- package/dist/utils/safety/threshold-auth.d.ts +70 -0
- package/dist/workspace/git-client.d.ts +51 -0
- package/dist/workspace/index.d.ts +29 -346
- package/dist/workspace/index.js +39 -0
- package/dist/workspace/index.js.map +1 -1
- package/dist/workspace/memory-files.d.ts +31 -0
- package/dist/workspace/sink-manager.d.ts +26 -0
- package/dist/workspace/sinks/firestore-sink.d.ts +41 -0
- package/dist/workspace/sinks/git-sink.d.ts +47 -0
- package/dist/workspace/sinks/index.d.ts +9 -0
- package/dist/workspace/templates.d.ts +32 -0
- package/dist/workspace/types.d.ts +86 -0
- package/dist/workspace/workspace-manager.d.ts +57 -0
- package/package.json +12 -10
- package/dist/index-DW3F-Ihx.d.ts +0 -2501
- package/dist/index-DZn69no8.d.ts +0 -1014
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* State Synchronization Support - GAP-010
|
|
3
|
+
*
|
|
4
|
+
* Provides agent-side support for real-time state synchronization.
|
|
5
|
+
* The actual transport (WebSocket/SSE) is handled by @almadar/server.
|
|
6
|
+
*
|
|
7
|
+
* This module provides:
|
|
8
|
+
* - State change notifications
|
|
9
|
+
* - Conflict resolution utilities
|
|
10
|
+
* - State serialization for sync
|
|
11
|
+
* - Event emitters for server integration
|
|
12
|
+
*
|
|
13
|
+
* @packageDocumentation
|
|
14
|
+
*/
|
|
15
|
+
import { EventEmitter } from 'events';
|
|
16
|
+
import type { Checkpoint } from '@langchain/langgraph-checkpoint';
|
|
17
|
+
/**
|
|
18
|
+
* State change event types
|
|
19
|
+
*/
|
|
20
|
+
export type StateChangeType = 'checkpoint_created' | 'checkpoint_updated' | 'session_started' | 'session_ended' | 'tool_executed' | 'memory_updated' | 'interrupt_triggered' | 'interrupt_resolved';
|
|
21
|
+
/**
|
|
22
|
+
* State change event
|
|
23
|
+
*/
|
|
24
|
+
export interface StateChangeEvent {
|
|
25
|
+
/** Change type */
|
|
26
|
+
type: StateChangeType;
|
|
27
|
+
/** Thread/session ID */
|
|
28
|
+
threadId: string;
|
|
29
|
+
/** User ID */
|
|
30
|
+
userId?: string;
|
|
31
|
+
/** Timestamp */
|
|
32
|
+
timestamp: number;
|
|
33
|
+
/** Change payload */
|
|
34
|
+
payload: Record<string, unknown>;
|
|
35
|
+
/** Version vector for conflict resolution */
|
|
36
|
+
version: VersionVector;
|
|
37
|
+
/** Source client ID */
|
|
38
|
+
sourceClientId?: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Version vector for conflict resolution
|
|
42
|
+
*/
|
|
43
|
+
export interface VersionVector {
|
|
44
|
+
/** Logical timestamp */
|
|
45
|
+
timestamp: number;
|
|
46
|
+
/** Sequence number */
|
|
47
|
+
sequence: number;
|
|
48
|
+
/** Node/client ID */
|
|
49
|
+
nodeId: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Sync state snapshot
|
|
53
|
+
*/
|
|
54
|
+
export interface StateSyncSnapshot {
|
|
55
|
+
/** Thread ID */
|
|
56
|
+
threadId: string;
|
|
57
|
+
/** Current checkpoint */
|
|
58
|
+
checkpoint?: Checkpoint;
|
|
59
|
+
/** Session metadata */
|
|
60
|
+
sessionMetadata?: Record<string, unknown>;
|
|
61
|
+
/** Memory state */
|
|
62
|
+
memoryState?: Record<string, unknown>;
|
|
63
|
+
/** Version vector */
|
|
64
|
+
version: VersionVector;
|
|
65
|
+
/** Last updated */
|
|
66
|
+
lastUpdated: number;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Conflict resolution result
|
|
70
|
+
*/
|
|
71
|
+
export interface ConflictResolution {
|
|
72
|
+
/** Whether conflict was resolved */
|
|
73
|
+
resolved: boolean;
|
|
74
|
+
/** Winning state if resolved */
|
|
75
|
+
winningState?: StateSyncSnapshot;
|
|
76
|
+
/** Conflicting changes if not resolved */
|
|
77
|
+
conflicts?: Array<{
|
|
78
|
+
clientA: StateChangeEvent;
|
|
79
|
+
clientB: StateChangeEvent;
|
|
80
|
+
}>;
|
|
81
|
+
/** Resolution strategy used */
|
|
82
|
+
strategy: 'last_write_wins' | 'merge' | 'manual';
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Sync configuration
|
|
86
|
+
*/
|
|
87
|
+
export interface StateSyncConfig {
|
|
88
|
+
/** Enable sync */
|
|
89
|
+
enabled: boolean;
|
|
90
|
+
/** Conflict resolution strategy */
|
|
91
|
+
conflictStrategy: 'last_write_wins' | 'merge' | 'manual';
|
|
92
|
+
/** Throttle interval (ms) */
|
|
93
|
+
throttleInterval: number;
|
|
94
|
+
/** Max retry attempts */
|
|
95
|
+
maxRetries: number;
|
|
96
|
+
/** Client ID */
|
|
97
|
+
clientId: string;
|
|
98
|
+
}
|
|
99
|
+
export declare class StateSyncManager extends EventEmitter {
|
|
100
|
+
private config;
|
|
101
|
+
private sequenceNumber;
|
|
102
|
+
private pendingChanges;
|
|
103
|
+
private throttleTimer;
|
|
104
|
+
constructor(config?: Partial<StateSyncConfig>);
|
|
105
|
+
/**
|
|
106
|
+
* Notify that state has changed (called by agent internals)
|
|
107
|
+
*/
|
|
108
|
+
notifyStateChange(type: StateChangeType, threadId: string, payload: Record<string, unknown>, userId?: string): void;
|
|
109
|
+
/**
|
|
110
|
+
* Receive state change from server (called by server transport)
|
|
111
|
+
*/
|
|
112
|
+
receiveRemoteChange(event: StateChangeEvent): void;
|
|
113
|
+
/**
|
|
114
|
+
* Create sync snapshot for current state
|
|
115
|
+
*/
|
|
116
|
+
createSnapshot(threadId: string, state: {
|
|
117
|
+
checkpoint?: Checkpoint;
|
|
118
|
+
sessionMetadata?: Record<string, unknown>;
|
|
119
|
+
memoryState?: Record<string, unknown>;
|
|
120
|
+
}): StateSyncSnapshot;
|
|
121
|
+
/**
|
|
122
|
+
* Compare two version vectors
|
|
123
|
+
* Returns: -1 if a < b, 0 if concurrent/equal, 1 if a > b
|
|
124
|
+
*/
|
|
125
|
+
compareVersions(a: VersionVector, b: VersionVector): number;
|
|
126
|
+
/**
|
|
127
|
+
* Check if there are pending changes to sync
|
|
128
|
+
*/
|
|
129
|
+
hasPendingChanges(): boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Get and clear pending changes
|
|
132
|
+
*/
|
|
133
|
+
flushPendingChanges(): StateChangeEvent[];
|
|
134
|
+
/**
|
|
135
|
+
* Get sync configuration
|
|
136
|
+
*/
|
|
137
|
+
getConfig(): StateSyncConfig;
|
|
138
|
+
/**
|
|
139
|
+
* Update sync configuration
|
|
140
|
+
*/
|
|
141
|
+
updateConfig(config: Partial<StateSyncConfig>): void;
|
|
142
|
+
/**
|
|
143
|
+
* Dispose resources
|
|
144
|
+
*/
|
|
145
|
+
dispose(): void;
|
|
146
|
+
private generateClientId;
|
|
147
|
+
private createVersionVector;
|
|
148
|
+
private scheduleSync;
|
|
149
|
+
private findConflicts;
|
|
150
|
+
private resolveConflicts;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Get or create global state sync manager
|
|
154
|
+
*/
|
|
155
|
+
export declare function getStateSyncManager(config?: Partial<StateSyncConfig>): StateSyncManager;
|
|
156
|
+
/**
|
|
157
|
+
* Reset global state sync manager
|
|
158
|
+
*/
|
|
159
|
+
export declare function resetStateSyncManager(): void;
|
|
160
|
+
/**
|
|
161
|
+
* Create a synchronized wrapper for session operations
|
|
162
|
+
*/
|
|
163
|
+
export declare function withSync<T extends (...args: unknown[]) => unknown>(fn: T, syncManager: StateSyncManager, options: {
|
|
164
|
+
threadId: string;
|
|
165
|
+
type: StateChangeType;
|
|
166
|
+
getPayload: (...args: unknown[]) => Record<string, unknown>;
|
|
167
|
+
}): T;
|
|
168
|
+
/**
|
|
169
|
+
* Debounce sync notifications
|
|
170
|
+
*/
|
|
171
|
+
export declare function debounceSync(syncManager: StateSyncManager, delay?: number): (type: StateChangeType, threadId: string, payload: Record<string, unknown>) => void;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* KFlow DeepAgent Subagents
|
|
3
|
+
*
|
|
4
|
+
* Specialized subagents for complex schema generation tasks.
|
|
5
|
+
* These are spawned via the `task()` built-in tool.
|
|
6
|
+
*
|
|
7
|
+
* Uses @almadar/skills for schema reference documentation.
|
|
8
|
+
*
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
11
|
+
import type { SubAgent } from './types.js';
|
|
12
|
+
/**
|
|
13
|
+
* Create the Schema Generator Subagent configuration.
|
|
14
|
+
*
|
|
15
|
+
* Focused agent for generating KFlow schemas from requirements.
|
|
16
|
+
* Writes schema to file and verifies it exists.
|
|
17
|
+
*/
|
|
18
|
+
export declare function createSchemaGeneratorSubagent(): SubAgent;
|
|
19
|
+
/**
|
|
20
|
+
* Create the Error Fixer Subagent configuration.
|
|
21
|
+
*
|
|
22
|
+
* Focused agent for fixing validation and compilation errors.
|
|
23
|
+
*/
|
|
24
|
+
export declare function createErrorFixerSubagent(): SubAgent;
|
|
25
|
+
/**
|
|
26
|
+
* Create the Test Analyzer Subagent configuration.
|
|
27
|
+
*
|
|
28
|
+
* Focused agent for analyzing test failures and suggesting fixes.
|
|
29
|
+
*/
|
|
30
|
+
export declare function createTestAnalyzerSubagent(): SubAgent;
|
|
31
|
+
/**
|
|
32
|
+
* Create all subagent configurations.
|
|
33
|
+
*/
|
|
34
|
+
export declare function createSubagents(): SubAgent[];
|
|
35
|
+
/**
|
|
36
|
+
* Create subagent configs as a record for easy lookup.
|
|
37
|
+
*/
|
|
38
|
+
export declare function createSubagentConfigs(): Record<string, SubAgent>;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Construct Combined Schema Tool
|
|
3
|
+
*
|
|
4
|
+
* Deterministically combines generated orbitals into a single OrbitalSchema
|
|
5
|
+
* without LLM involvement.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
/**
|
|
11
|
+
* Create the construct_combined_schema tool.
|
|
12
|
+
*/
|
|
13
|
+
export declare function createCombineSchemasTool(workDir?: string): import("@langchain/core/tools").DynamicStructuredTool<z.ZodObject<{
|
|
14
|
+
orbitals: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
15
|
+
name: z.ZodString;
|
|
16
|
+
description: z.ZodOptional<z.ZodString>;
|
|
17
|
+
entity: z.ZodObject<{
|
|
18
|
+
name: z.ZodString;
|
|
19
|
+
collection: z.ZodOptional<z.ZodString>;
|
|
20
|
+
fields: z.ZodArray<z.ZodAny, "many">;
|
|
21
|
+
timestamps: z.ZodOptional<z.ZodBoolean>;
|
|
22
|
+
}, "strip", z.ZodTypeAny, {
|
|
23
|
+
name: string;
|
|
24
|
+
fields: any[];
|
|
25
|
+
collection?: string | undefined;
|
|
26
|
+
timestamps?: boolean | undefined;
|
|
27
|
+
}, {
|
|
28
|
+
name: string;
|
|
29
|
+
fields: any[];
|
|
30
|
+
collection?: string | undefined;
|
|
31
|
+
timestamps?: boolean | undefined;
|
|
32
|
+
}>;
|
|
33
|
+
traits: z.ZodArray<z.ZodAny, "many">;
|
|
34
|
+
pages: z.ZodArray<z.ZodAny, "many">;
|
|
35
|
+
emits: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
36
|
+
listens: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
|
|
37
|
+
}, "strip", z.ZodTypeAny, {
|
|
38
|
+
pages: any[];
|
|
39
|
+
traits: any[];
|
|
40
|
+
name: string;
|
|
41
|
+
entity: {
|
|
42
|
+
name: string;
|
|
43
|
+
fields: any[];
|
|
44
|
+
collection?: string | undefined;
|
|
45
|
+
timestamps?: boolean | undefined;
|
|
46
|
+
};
|
|
47
|
+
description?: string | undefined;
|
|
48
|
+
emits?: string[] | undefined;
|
|
49
|
+
listens?: any[] | undefined;
|
|
50
|
+
}, {
|
|
51
|
+
pages: any[];
|
|
52
|
+
traits: any[];
|
|
53
|
+
name: string;
|
|
54
|
+
entity: {
|
|
55
|
+
name: string;
|
|
56
|
+
fields: any[];
|
|
57
|
+
collection?: string | undefined;
|
|
58
|
+
timestamps?: boolean | undefined;
|
|
59
|
+
};
|
|
60
|
+
description?: string | undefined;
|
|
61
|
+
emits?: string[] | undefined;
|
|
62
|
+
listens?: any[] | undefined;
|
|
63
|
+
}>, "many">>;
|
|
64
|
+
name: z.ZodOptional<z.ZodString>;
|
|
65
|
+
description: z.ZodOptional<z.ZodString>;
|
|
66
|
+
version: z.ZodOptional<z.ZodString>;
|
|
67
|
+
theme: z.ZodOptional<z.ZodString>;
|
|
68
|
+
defaultRoute: z.ZodOptional<z.ZodString>;
|
|
69
|
+
validate: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
70
|
+
}, "strip", z.ZodTypeAny, {
|
|
71
|
+
validate: boolean;
|
|
72
|
+
version?: string | undefined;
|
|
73
|
+
name?: string | undefined;
|
|
74
|
+
description?: string | undefined;
|
|
75
|
+
theme?: string | undefined;
|
|
76
|
+
orbitals?: {
|
|
77
|
+
pages: any[];
|
|
78
|
+
traits: any[];
|
|
79
|
+
name: string;
|
|
80
|
+
entity: {
|
|
81
|
+
name: string;
|
|
82
|
+
fields: any[];
|
|
83
|
+
collection?: string | undefined;
|
|
84
|
+
timestamps?: boolean | undefined;
|
|
85
|
+
};
|
|
86
|
+
description?: string | undefined;
|
|
87
|
+
emits?: string[] | undefined;
|
|
88
|
+
listens?: any[] | undefined;
|
|
89
|
+
}[] | undefined;
|
|
90
|
+
defaultRoute?: string | undefined;
|
|
91
|
+
}, {
|
|
92
|
+
version?: string | undefined;
|
|
93
|
+
name?: string | undefined;
|
|
94
|
+
description?: string | undefined;
|
|
95
|
+
validate?: boolean | undefined;
|
|
96
|
+
theme?: string | undefined;
|
|
97
|
+
orbitals?: {
|
|
98
|
+
pages: any[];
|
|
99
|
+
traits: any[];
|
|
100
|
+
name: string;
|
|
101
|
+
entity: {
|
|
102
|
+
name: string;
|
|
103
|
+
fields: any[];
|
|
104
|
+
collection?: string | undefined;
|
|
105
|
+
timestamps?: boolean | undefined;
|
|
106
|
+
};
|
|
107
|
+
description?: string | undefined;
|
|
108
|
+
emits?: string[] | undefined;
|
|
109
|
+
listens?: any[] | undefined;
|
|
110
|
+
}[] | undefined;
|
|
111
|
+
defaultRoute?: string | undefined;
|
|
112
|
+
}>, {
|
|
113
|
+
validate: boolean;
|
|
114
|
+
version?: string | undefined;
|
|
115
|
+
name?: string | undefined;
|
|
116
|
+
description?: string | undefined;
|
|
117
|
+
theme?: string | undefined;
|
|
118
|
+
orbitals?: {
|
|
119
|
+
pages: any[];
|
|
120
|
+
traits: any[];
|
|
121
|
+
name: string;
|
|
122
|
+
entity: {
|
|
123
|
+
name: string;
|
|
124
|
+
fields: any[];
|
|
125
|
+
collection?: string | undefined;
|
|
126
|
+
timestamps?: boolean | undefined;
|
|
127
|
+
};
|
|
128
|
+
description?: string | undefined;
|
|
129
|
+
emits?: string[] | undefined;
|
|
130
|
+
listens?: any[] | undefined;
|
|
131
|
+
}[] | undefined;
|
|
132
|
+
defaultRoute?: string | undefined;
|
|
133
|
+
}, {
|
|
134
|
+
version?: string | undefined;
|
|
135
|
+
name?: string | undefined;
|
|
136
|
+
description?: string | undefined;
|
|
137
|
+
validate?: boolean | undefined;
|
|
138
|
+
theme?: string | undefined;
|
|
139
|
+
orbitals?: {
|
|
140
|
+
pages: any[];
|
|
141
|
+
traits: any[];
|
|
142
|
+
name: string;
|
|
143
|
+
entity: {
|
|
144
|
+
name: string;
|
|
145
|
+
fields: any[];
|
|
146
|
+
collection?: string | undefined;
|
|
147
|
+
timestamps?: boolean | undefined;
|
|
148
|
+
};
|
|
149
|
+
description?: string | undefined;
|
|
150
|
+
emits?: string[] | undefined;
|
|
151
|
+
listens?: any[] | undefined;
|
|
152
|
+
}[] | undefined;
|
|
153
|
+
defaultRoute?: string | undefined;
|
|
154
|
+
}, string, "construct_combined_schema">;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Composition & Chaining - Phase 3.3
|
|
3
|
+
*
|
|
4
|
+
* Composable tool workflows with parallel execution, error handling,
|
|
5
|
+
* and conditional branching.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
export type ToolStepStatus = 'pending' | 'running' | 'success' | 'error' | 'skipped';
|
|
10
|
+
export interface ToolStep {
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
tool: string;
|
|
14
|
+
input: Record<string, unknown> | ((context: WorkflowContext) => Record<string, unknown>);
|
|
15
|
+
condition?: (context: WorkflowContext) => boolean;
|
|
16
|
+
dependsOn?: string[];
|
|
17
|
+
status: ToolStepStatus;
|
|
18
|
+
output?: unknown;
|
|
19
|
+
error?: string;
|
|
20
|
+
startTime?: number;
|
|
21
|
+
endTime?: number;
|
|
22
|
+
}
|
|
23
|
+
export interface WorkflowContext {
|
|
24
|
+
workflowId: string;
|
|
25
|
+
inputs: Record<string, unknown>;
|
|
26
|
+
outputs: Record<string, unknown>;
|
|
27
|
+
stepResults: Map<string, {
|
|
28
|
+
success: boolean;
|
|
29
|
+
output?: unknown;
|
|
30
|
+
error?: string;
|
|
31
|
+
}>;
|
|
32
|
+
metadata: {
|
|
33
|
+
startTime: number;
|
|
34
|
+
stepsCompleted: number;
|
|
35
|
+
stepsFailed: number;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export interface WorkflowDefinition {
|
|
39
|
+
name: string;
|
|
40
|
+
description: string;
|
|
41
|
+
inputs: Record<string, {
|
|
42
|
+
type: string;
|
|
43
|
+
required: boolean;
|
|
44
|
+
default?: unknown;
|
|
45
|
+
}>;
|
|
46
|
+
steps: ToolStep[];
|
|
47
|
+
onError?: 'stop' | 'continue' | 'retry';
|
|
48
|
+
maxRetries?: number;
|
|
49
|
+
}
|
|
50
|
+
export interface WorkflowExecutionResult {
|
|
51
|
+
success: boolean;
|
|
52
|
+
workflowId: string;
|
|
53
|
+
context: WorkflowContext;
|
|
54
|
+
steps: ToolStep[];
|
|
55
|
+
durationMs: number;
|
|
56
|
+
error?: string;
|
|
57
|
+
}
|
|
58
|
+
export interface ParallelExecutionResult {
|
|
59
|
+
stepId: string;
|
|
60
|
+
success: boolean;
|
|
61
|
+
output?: unknown;
|
|
62
|
+
error?: string;
|
|
63
|
+
durationMs: number;
|
|
64
|
+
}
|
|
65
|
+
export interface ToolExecutor {
|
|
66
|
+
execute(tool: string, input: Record<string, unknown>): Promise<unknown>;
|
|
67
|
+
}
|
|
68
|
+
export declare class WorkflowEngine {
|
|
69
|
+
private executor;
|
|
70
|
+
private workflows;
|
|
71
|
+
constructor(executor: ToolExecutor);
|
|
72
|
+
/**
|
|
73
|
+
* Register a workflow definition
|
|
74
|
+
*/
|
|
75
|
+
registerWorkflow(definition: WorkflowDefinition): void;
|
|
76
|
+
/**
|
|
77
|
+
* Execute a workflow by name
|
|
78
|
+
*/
|
|
79
|
+
executeWorkflow(workflowName: string, inputs: Record<string, unknown>): Promise<WorkflowExecutionResult>;
|
|
80
|
+
/**
|
|
81
|
+
* Execute a workflow definition directly
|
|
82
|
+
*/
|
|
83
|
+
runWorkflow(definition: WorkflowDefinition, inputs: Record<string, unknown>): Promise<WorkflowExecutionResult>;
|
|
84
|
+
/**
|
|
85
|
+
* Execute independent steps in parallel
|
|
86
|
+
*/
|
|
87
|
+
executeParallel(steps: Array<{
|
|
88
|
+
id: string;
|
|
89
|
+
tool: string;
|
|
90
|
+
input: Record<string, unknown>;
|
|
91
|
+
}>, context: WorkflowContext): Promise<ParallelExecutionResult[]>;
|
|
92
|
+
/**
|
|
93
|
+
* Create a workflow builder for fluent API
|
|
94
|
+
*/
|
|
95
|
+
createWorkflow(name: string, description: string): WorkflowBuilder;
|
|
96
|
+
private executeStep;
|
|
97
|
+
private resolveDependencies;
|
|
98
|
+
}
|
|
99
|
+
export declare class WorkflowBuilder {
|
|
100
|
+
private engine;
|
|
101
|
+
private definition;
|
|
102
|
+
constructor(engine: WorkflowEngine, name: string, description: string);
|
|
103
|
+
input(name: string, type: string, required?: boolean, defaultValue?: unknown): this;
|
|
104
|
+
step(id: string, tool: string, input: Record<string, unknown> | ((context: WorkflowContext) => Record<string, unknown>), options?: {
|
|
105
|
+
dependsOn?: string[];
|
|
106
|
+
condition?: (context: WorkflowContext) => boolean;
|
|
107
|
+
}): this;
|
|
108
|
+
parallel(steps: Array<{
|
|
109
|
+
id: string;
|
|
110
|
+
tool: string;
|
|
111
|
+
input: Record<string, unknown>;
|
|
112
|
+
}>): this;
|
|
113
|
+
onError(policy: 'stop' | 'continue' | 'retry'): this;
|
|
114
|
+
retry(maxRetries: number): this;
|
|
115
|
+
build(): WorkflowDefinition;
|
|
116
|
+
execute(inputs: Record<string, unknown>): Promise<WorkflowExecutionResult>;
|
|
117
|
+
}
|
|
118
|
+
export declare function createSchemaGenerationWorkflow(engine: WorkflowEngine): WorkflowDefinition;
|
|
119
|
+
export declare function createWorkflowEngine(executor: ToolExecutor): WorkflowEngine;
|