@obora/runtime 0.1.0
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 -0
- package/README.md +183 -0
- package/dist/_legacy/actor/base/BaseActor.d.ts +87 -0
- package/dist/_legacy/actor/pool/ActorPool.d.ts +194 -0
- package/dist/_legacy/actor/pool/NoOpMessageBus.d.ts +16 -0
- package/dist/_legacy/actor/pool/PoolManager.d.ts +76 -0
- package/dist/_legacy/actor/pool/index.d.ts +3 -0
- package/dist/_legacy/actor/runtime/ActorRunner.d.ts +54 -0
- package/dist/_legacy/actor/runtime/ActorRuntime.d.ts +161 -0
- package/dist/_legacy/actor/runtime/DefaultActorFactory.d.ts +44 -0
- package/dist/_legacy/actor/runtime/types.d.ts +41 -0
- package/dist/_legacy/actor/runtime/utils/delay.d.ts +7 -0
- package/dist/_legacy/actor/supervision/Supervisor.d.ts +102 -0
- package/dist/_legacy/actor/supervision/SupervisorTree.d.ts +54 -0
- package/dist/_legacy/actor/supervision/types.d.ts +130 -0
- package/dist/_legacy/actor/types/action.d.ts +65 -0
- package/dist/_legacy/actor/types/actor.d.ts +251 -0
- package/dist/_legacy/actor/types/blackboard.d.ts +46 -0
- package/dist/_legacy/actor/types/crypto.d.ts +6 -0
- package/dist/_legacy/actor/types/message.d.ts +209 -0
- package/dist/_legacy/actor/types/metrics.d.ts +43 -0
- package/dist/_legacy/actor/types/observation.d.ts +45 -0
- package/dist/_legacy/actor/types/result.d.ts +110 -0
- package/dist/_legacy/agents/roles/analyst-agent.d.ts +18 -0
- package/dist/_legacy/agents/roles/base-agent.d.ts +320 -0
- package/dist/_legacy/agents/roles/director-agent.d.ts +26 -0
- package/dist/_legacy/agents/roles/executor-agent.d.ts +26 -0
- package/dist/_legacy/agents/roles/factory.d.ts +30 -0
- package/dist/_legacy/agents/roles/index.d.ts +6 -0
- package/dist/_legacy/agents/roles/verifier-agent.d.ts +18 -0
- package/dist/_legacy/blackboard/core/accessors/decisions-accessor.d.ts +190 -0
- package/dist/_legacy/blackboard/core/accessors/index.d.ts +7 -0
- package/dist/_legacy/blackboard/core/accessors/knowledge-accessor.d.ts +154 -0
- package/dist/_legacy/blackboard/core/accessors/state-accessor.d.ts +173 -0
- package/dist/_legacy/blackboard/core/blackboard-events.d.ts +105 -0
- package/dist/_legacy/blackboard/core/blackboard.d.ts +286 -0
- package/dist/_legacy/blackboard/core/id-generator.d.ts +53 -0
- package/dist/_legacy/blackboard/core/immutable.d.ts +45 -0
- package/dist/_legacy/blackboard/core/index.d.ts +13 -0
- package/dist/_legacy/blackboard/core/path-utils.d.ts +75 -0
- package/dist/_legacy/blackboard/core/tkg.d.ts +50 -0
- package/dist/_legacy/blackboard/core/versioning.d.ts +80 -0
- package/dist/_legacy/blackboard/domains/agenda/AgendaStore.d.ts +34 -0
- package/dist/_legacy/blackboard/domains/agenda/events.d.ts +12 -0
- package/dist/_legacy/blackboard/domains/agenda/index.d.ts +6 -0
- package/dist/_legacy/blackboard/domains/agenda/types.d.ts +26 -0
- package/dist/_legacy/blackboard/domains/consensus/ConsensusRuleEngine.d.ts +10 -0
- package/dist/_legacy/blackboard/domains/consensus/index.d.ts +4 -0
- package/dist/_legacy/blackboard/domains/consensus/types.d.ts +27 -0
- package/dist/_legacy/blackboard/domains/tkg/InMemoryTKG.d.ts +38 -0
- package/dist/_legacy/blackboard/domains/tkg/JsonFileReflectorStateStore.d.ts +9 -0
- package/dist/_legacy/blackboard/domains/tkg/ObserverReflector.d.ts +114 -0
- package/dist/_legacy/blackboard/domains/tkg/index.d.ts +4 -0
- package/dist/_legacy/blackboard/domains/voting/VotingSessionStore.d.ts +14 -0
- package/dist/_legacy/blackboard/domains/voting/index.d.ts +3 -0
- package/dist/_legacy/blackboard/domains/voting/types.d.ts +32 -0
- package/dist/_legacy/blackboard/events/event-bus.d.ts +254 -0
- package/dist/_legacy/blackboard/events/event-factory.d.ts +80 -0
- package/dist/_legacy/blackboard/events/index.d.ts +17 -0
- package/dist/_legacy/blackboard/events/types.d.ts +554 -0
- package/dist/_legacy/blackboard/snapshot/compression.d.ts +170 -0
- package/dist/_legacy/blackboard/snapshot/id-utils.d.ts +20 -0
- package/dist/_legacy/blackboard/snapshot/index.d.ts +21 -0
- package/dist/_legacy/blackboard/snapshot/serializer.d.ts +123 -0
- package/dist/_legacy/blackboard/snapshot/snapshot-comparer.d.ts +102 -0
- package/dist/_legacy/blackboard/snapshot/snapshot-creator.d.ts +49 -0
- package/dist/_legacy/blackboard/snapshot/snapshot-manager.d.ts +253 -0
- package/dist/_legacy/blackboard/snapshot/snapshot-restorer.d.ts +54 -0
- package/dist/_legacy/blackboard/snapshot/snapshot-serializer.d.ts +45 -0
- package/dist/_legacy/blackboard/snapshot/snapshot-validator.d.ts +55 -0
- package/dist/_legacy/blackboard/snapshot/type-guards.d.ts +12 -0
- package/dist/_legacy/blackboard/snapshot/types.d.ts +151 -0
- package/dist/_legacy/blackboard/snapshot/utils.d.ts +20 -0
- package/dist/_legacy/blackboard/types/agent.d.ts +89 -0
- package/dist/_legacy/blackboard/types/base.d.ts +213 -0
- package/dist/_legacy/blackboard/types/blackboard.d.ts +217 -0
- package/dist/_legacy/blackboard/types/decision.d.ts +260 -0
- package/dist/_legacy/blackboard/types/index.d.ts +12 -0
- package/dist/_legacy/blackboard/types/knowledge.d.ts +224 -0
- package/dist/_legacy/blackboard/types/message.d.ts +162 -0
- package/dist/_legacy/blackboard/types/task.d.ts +154 -0
- package/dist/_legacy/blackboard/types/tkg.d.ts +189 -0
- package/dist/_legacy/blackboard/workflow/meeting-state-machine/MeetingStateMachine.d.ts +22 -0
- package/dist/_legacy/blackboard/workflow/meeting-state-machine/types.d.ts +30 -0
- package/dist/_legacy/cli-runtime/runtime/agent-registry.d.ts +33 -0
- package/dist/_legacy/cli-runtime/runtime/blackboard.d.ts +41 -0
- package/dist/_legacy/cli-runtime/runtime/context-builder.d.ts +88 -0
- package/dist/_legacy/cli-runtime/runtime/retry-policy.d.ts +8 -0
- package/dist/_legacy/cli-runtime/runtime/step-executor.d.ts +33 -0
- package/dist/_legacy/cli-runtime/runtime/types.d.ts +12 -0
- package/dist/_legacy/cli-runtime/runtime/utils.d.ts +2 -0
- package/dist/_legacy/database/src/duckdb-client.d.ts +178 -0
- package/dist/_legacy/workflow/errors/diagnosis.d.ts +32 -0
- package/dist/_legacy/workflow/errors/index.d.ts +52 -0
- package/dist/_legacy/workflow/graph/index.d.ts +57 -0
- package/dist/_legacy/workflow/index.d.ts +9 -0
- package/dist/_legacy/workflow/parser/workflow-parser.d.ts +13 -0
- package/dist/_legacy/workflow/resolver/dependency-resolver.d.ts +83 -0
- package/dist/_legacy/workflow/types/workflow.d.ts +173 -0
- package/dist/_legacy/workflow/utils.d.ts +2 -0
- package/dist/_legacy/workflow/validator/workflow-validator.d.ts +71 -0
- package/dist/artifacts/index.d.ts +2 -0
- package/dist/artifacts/local-file-artifact-store.d.ts +22 -0
- package/dist/artifacts/types.d.ts +19 -0
- package/dist/audit/AuditReplay.d.ts +4 -0
- package/dist/audit/AuditStore.d.ts +13 -0
- package/dist/audit/AuditTrail.d.ts +28 -0
- package/dist/audit/DefaultAuditRecorder.d.ts +10 -0
- package/dist/audit/EventBusAdapter.d.ts +12 -0
- package/dist/audit/InMemoryAuditStore.d.ts +9 -0
- package/dist/audit/ReExecutionDiffReport.d.ts +24 -0
- package/dist/audit/ReExecutionPlanner.d.ts +30 -0
- package/dist/audit/ReExecutionRuntime.d.ts +35 -0
- package/dist/audit/database-api.d.ts +32 -0
- package/dist/audit/database-index.d.ts +5 -0
- package/dist/audit/event-bus.d.ts +1 -0
- package/dist/audit/event-factory.d.ts +1 -0
- package/dist/audit/index.d.ts +12 -0
- package/dist/audit/testing.d.ts +15 -0
- package/dist/audit/tkg/InMemoryTKG.d.ts +1 -0
- package/dist/audit/tkg/JsonFileReflectorStateStore.d.ts +1 -0
- package/dist/audit/tkg/ObserverReflector.d.ts +1 -0
- package/dist/audit/tkg/index.d.ts +1 -0
- package/dist/audit/types.d.ts +23 -0
- package/dist/blackboard/core/accessors/decisions-accessor.d.ts +190 -0
- package/dist/blackboard/core/accessors/index.d.ts +7 -0
- package/dist/blackboard/core/accessors/knowledge-accessor.d.ts +154 -0
- package/dist/blackboard/core/accessors/state-accessor.d.ts +173 -0
- package/dist/blackboard/core/blackboard-events.d.ts +105 -0
- package/dist/blackboard/core/blackboard.d.ts +286 -0
- package/dist/blackboard/core/id-generator.d.ts +53 -0
- package/dist/blackboard/core/immutable.d.ts +45 -0
- package/dist/blackboard/core/index.d.ts +13 -0
- package/dist/blackboard/core/path-utils.d.ts +75 -0
- package/dist/blackboard/core/tkg.d.ts +50 -0
- package/dist/blackboard/core/versioning.d.ts +80 -0
- package/dist/blackboard/events/event-bus.d.ts +254 -0
- package/dist/blackboard/events/event-factory.d.ts +80 -0
- package/dist/blackboard/events/index.d.ts +17 -0
- package/dist/blackboard/events/types.d.ts +554 -0
- package/dist/blackboard/index.d.ts +20 -0
- package/dist/blackboard/observer-reflector.d.ts +114 -0
- package/dist/blackboard/snapshot/compression.d.ts +170 -0
- package/dist/blackboard/snapshot/id-utils.d.ts +20 -0
- package/dist/blackboard/snapshot/index.d.ts +21 -0
- package/dist/blackboard/snapshot/serializer.d.ts +123 -0
- package/dist/blackboard/snapshot/snapshot-comparer.d.ts +102 -0
- package/dist/blackboard/snapshot/snapshot-creator.d.ts +49 -0
- package/dist/blackboard/snapshot/snapshot-manager.d.ts +253 -0
- package/dist/blackboard/snapshot/snapshot-restorer.d.ts +54 -0
- package/dist/blackboard/snapshot/snapshot-serializer.d.ts +45 -0
- package/dist/blackboard/snapshot/snapshot-validator.d.ts +55 -0
- package/dist/blackboard/snapshot/type-guards.d.ts +12 -0
- package/dist/blackboard/snapshot/types.d.ts +151 -0
- package/dist/blackboard/snapshot/utils.d.ts +20 -0
- package/dist/blackboard/types/agent.d.ts +89 -0
- package/dist/blackboard/types/base.d.ts +213 -0
- package/dist/blackboard/types/blackboard.d.ts +217 -0
- package/dist/blackboard/types/decision.d.ts +260 -0
- package/dist/blackboard/types/index.d.ts +12 -0
- package/dist/blackboard/types/knowledge.d.ts +224 -0
- package/dist/blackboard/types/message.d.ts +162 -0
- package/dist/blackboard/types/task.d.ts +154 -0
- package/dist/blackboard/types/tkg.d.ts +189 -0
- package/dist/cell/ActorPool.d.ts +1 -0
- package/dist/cell/AgentFactory.d.ts +1 -0
- package/dist/cell/AgentRegistry.d.ts +1 -0
- package/dist/cell/BaseActor.d.ts +1 -0
- package/dist/cell/CellContext.d.ts +39 -0
- package/dist/cell/CellManager.d.ts +80 -0
- package/dist/cell/ExecutionCell.d.ts +44 -0
- package/dist/cell/PoolManager.d.ts +1 -0
- package/dist/cell/actor-types/action.d.ts +65 -0
- package/dist/cell/actor-types/actor.d.ts +251 -0
- package/dist/cell/actor-types/blackboard.d.ts +46 -0
- package/dist/cell/actor-types/crypto.d.ts +6 -0
- package/dist/cell/actor-types/index.d.ts +12 -0
- package/dist/cell/actor-types/message.d.ts +209 -0
- package/dist/cell/actor-types/metrics.d.ts +43 -0
- package/dist/cell/actor-types/observation.d.ts +45 -0
- package/dist/cell/actor-types/result.d.ts +110 -0
- package/dist/cell/agents/AnalystCellAgent.d.ts +2 -0
- package/dist/cell/agents/BaseRuntimeAgent.d.ts +2 -0
- package/dist/cell/agents/DirectorCellAgent.d.ts +2 -0
- package/dist/cell/agents/ExecutorCellAgent.d.ts +2 -0
- package/dist/cell/agents/VerifierCellAgent.d.ts +2 -0
- package/dist/cell/agents/index.d.ts +5 -0
- package/dist/cell/index.d.ts +9 -0
- package/dist/cell/internal/ActorRunnerAdapter.d.ts +2 -0
- package/dist/cell/internal/CellActorFactory.d.ts +2 -0
- package/dist/cell/internal/NoOpRuntimeBus.d.ts +2 -0
- package/dist/cell/internal/delay.d.ts +1 -0
- package/dist/cell/pool-index.d.ts +1 -0
- package/dist/cell/types.d.ts +47 -0
- package/dist/checkpoint/CheckpointFactoryRegistry.d.ts +16 -0
- package/dist/checkpoint/CheckpointManager.d.ts +41 -0
- package/dist/checkpoint/index.d.ts +5 -0
- package/dist/checkpoint/policy-hash.d.ts +11 -0
- package/dist/consensus/ConsensusGate.d.ts +83 -0
- package/dist/consensus/ConsensusRuleEngine.d.ts +1 -0
- package/dist/consensus/agenda/AgendaStore.d.ts +1 -0
- package/dist/consensus/agenda/events.d.ts +1 -0
- package/dist/consensus/agenda/index.d.ts +1 -0
- package/dist/consensus/agenda/types.d.ts +1 -0
- package/dist/consensus/index.d.ts +2 -0
- package/dist/consensus/types.d.ts +1 -0
- package/dist/consensus/voting/VotingSessionStore.d.ts +1 -0
- package/dist/consensus/voting/index.d.ts +1 -0
- package/dist/consensus/voting/types.d.ts +1 -0
- package/dist/errors/OboraErrorCode.d.ts +28 -0
- package/dist/errors/index.d.ts +1 -0
- package/dist/gates/GateAssignment.d.ts +28 -0
- package/dist/gates/MultiStageApproval.d.ts +74 -0
- package/dist/gates/SLAManager.d.ts +21 -0
- package/dist/gates/index.d.ts +4 -0
- package/dist/gates/types.d.ts +19 -0
- package/dist/index.cjs +26588 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.js +26330 -0
- package/dist/index.js.map +1 -0
- package/dist/judgment/JudgmentEngine.d.ts +24 -0
- package/dist/judgment/JudgmentNormalizer.d.ts +37 -0
- package/dist/judgment/JudgmentPolicy.d.ts +74 -0
- package/dist/judgment/JudgmentReporter.d.ts +70 -0
- package/dist/judgment/OperationalLogger.d.ts +68 -0
- package/dist/judgment/index.d.ts +6 -0
- package/dist/judgment/types.d.ts +42 -0
- package/dist/orchestrator/ExecutionContextBuilder.d.ts +1 -0
- package/dist/orchestrator/RuntimeOrchestrator.d.ts +94 -0
- package/dist/orchestrator/StepScheduler.d.ts +2 -0
- package/dist/orchestrator/index.d.ts +4 -0
- package/dist/orchestrator/types.d.ts +80 -0
- package/dist/orchestrator/utils.d.ts +1 -0
- package/dist/patterns/CustomPatternAPI.d.ts +10 -0
- package/dist/patterns/PatternRegistry.d.ts +19 -0
- package/dist/patterns/builtin/BrainstormPattern.d.ts +13 -0
- package/dist/patterns/builtin/CompositePattern.d.ts +11 -0
- package/dist/patterns/builtin/ConsensusPattern.d.ts +17 -0
- package/dist/patterns/builtin/DiscussionPattern.d.ts +13 -0
- package/dist/patterns/builtin/FanOutFanInPattern.d.ts +21 -0
- package/dist/patterns/builtin/PeerReviewPattern.d.ts +40 -0
- package/dist/patterns/builtin/PipelinePattern.d.ts +6 -0
- package/dist/patterns/builtin/RedBluePattern.d.ts +13 -0
- package/dist/patterns/builtin/SupervisorPattern.d.ts +13 -0
- package/dist/patterns/builtin/discussion/MeetingStateMachine.d.ts +1 -0
- package/dist/patterns/builtin/discussion/index.d.ts +2 -0
- package/dist/patterns/builtin/discussion/types.d.ts +1 -0
- package/dist/patterns/examples/OxfordDebatePattern.d.ts +11 -0
- package/dist/patterns/examples/index.d.ts +1 -0
- package/dist/patterns/index.d.ts +14 -0
- package/dist/patterns/resolveCustomPattern.d.ts +22 -0
- package/dist/patterns/types.d.ts +252 -0
- package/dist/plugins/PluginLoader.d.ts +16 -0
- package/dist/plugins/PluginRegistry.d.ts +15 -0
- package/dist/plugins/builtins.d.ts +137 -0
- package/dist/plugins/index.d.ts +5 -0
- package/dist/plugins/types.d.ts +52 -0
- package/dist/plugins/validator.d.ts +3 -0
- package/dist/policy/DefaultPolicyEngine.d.ts +43 -0
- package/dist/policy/DynamicPolicyContext.d.ts +21 -0
- package/dist/policy/DynamicQuotaEvaluator.d.ts +9 -0
- package/dist/policy/DynamicToolPolicy.d.ts +10 -0
- package/dist/policy/PolicyEngine.d.ts +14 -0
- package/dist/policy/PolicyLoader.d.ts +3 -0
- package/dist/policy/expressions/ExpressionEvaluator.d.ts +37 -0
- package/dist/policy/expressions/ExpressionParser.d.ts +35 -0
- package/dist/policy/expressions/constants.d.ts +5 -0
- package/dist/policy/expressions/index.d.ts +2 -0
- package/dist/policy/index.d.ts +9 -0
- package/dist/policy/rules/GateRule.d.ts +7 -0
- package/dist/policy/rules/ResourceRule.d.ts +7 -0
- package/dist/policy/rules/SandboxRule.d.ts +7 -0
- package/dist/policy/rules/ToolRule.d.ts +23 -0
- package/dist/policy/rules/index.d.ts +4 -0
- package/dist/policy/types.d.ts +156 -0
- package/dist/recovery/RecoveryEngine.d.ts +11 -0
- package/dist/recovery/RetryStrategy.d.ts +2 -0
- package/dist/recovery/SupervisionTree.d.ts +1 -0
- package/dist/recovery/index.d.ts +4 -0
- package/dist/recovery/types.d.ts +103 -0
- package/dist/state/RuntimeBlackboardCompat.d.ts +1 -0
- package/dist/state/StateBinder.d.ts +40 -0
- package/dist/state/StateManager.d.ts +1 -0
- package/dist/state/accessors/decisions-accessor.d.ts +1 -0
- package/dist/state/accessors/index.d.ts +1 -0
- package/dist/state/accessors/knowledge-accessor.d.ts +1 -0
- package/dist/state/accessors/state-accessor.d.ts +1 -0
- package/dist/state/blackboard-events.d.ts +1 -0
- package/dist/state/core-index.d.ts +1 -0
- package/dist/state/id-generator.d.ts +1 -0
- package/dist/state/immutable.d.ts +1 -0
- package/dist/state/index.d.ts +6 -0
- package/dist/state/path-utils.d.ts +1 -0
- package/dist/state/snapshot/compression.d.ts +1 -0
- package/dist/state/snapshot/id-utils.d.ts +1 -0
- package/dist/state/snapshot/index.d.ts +1 -0
- package/dist/state/snapshot/serializer.d.ts +1 -0
- package/dist/state/snapshot/snapshot-comparer.d.ts +1 -0
- package/dist/state/snapshot/snapshot-creator.d.ts +1 -0
- package/dist/state/snapshot/snapshot-manager.d.ts +1 -0
- package/dist/state/snapshot/snapshot-restorer.d.ts +1 -0
- package/dist/state/snapshot/snapshot-serializer.d.ts +1 -0
- package/dist/state/snapshot/snapshot-validator.d.ts +1 -0
- package/dist/state/snapshot/type-guards.d.ts +1 -0
- package/dist/state/snapshot/types.d.ts +1 -0
- package/dist/state/snapshot/utils.d.ts +1 -0
- package/dist/state/tkg.d.ts +1 -0
- package/dist/state/types/agent.d.ts +1 -0
- package/dist/state/types/base.d.ts +1 -0
- package/dist/state/types/blackboard.d.ts +1 -0
- package/dist/state/types/decision.d.ts +1 -0
- package/dist/state/types/index.d.ts +1 -0
- package/dist/state/types/knowledge.d.ts +1 -0
- package/dist/state/types/message.d.ts +1 -0
- package/dist/state/types/task.d.ts +1 -0
- package/dist/state/types/tkg.d.ts +1 -0
- package/dist/state/versioning.d.ts +1 -0
- package/dist/storage/index.d.ts +3 -0
- package/dist/storage/inmemory-adapter.d.ts +27 -0
- package/dist/storage/sqlite-adapter.d.ts +43 -0
- package/dist/storage/types.d.ts +129 -0
- package/package.json +76 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ContextBuilder — assembles AgentContext with a shared Blackboard
|
|
3
|
+
* for workflow execution.
|
|
4
|
+
*
|
|
5
|
+
* Responsibilities:
|
|
6
|
+
* - Create one Blackboard per workflow run (single session scope)
|
|
7
|
+
* - Build AgentContext for each step with board, task, history
|
|
8
|
+
* - Record step results/errors on the board for inter-step state sharing
|
|
9
|
+
* - Maintain single-writer: only this module writes step results to board
|
|
10
|
+
*
|
|
11
|
+
* @module @obora/cli/runtime/context-builder
|
|
12
|
+
*/
|
|
13
|
+
import type { ChatMessage } from "@obora/adapters";
|
|
14
|
+
import type { AgentContext } from "../../agents/roles/index.js";
|
|
15
|
+
import { Blackboard } from "./blackboard.js";
|
|
16
|
+
import type { Step, Workflow } from "../../../_legacy/workflow/index.js";
|
|
17
|
+
import type { StepResult } from "./step-executor.js";
|
|
18
|
+
import type { StepErrorMetadata } from "./types.js";
|
|
19
|
+
/** Metadata stored in blackboard state.context.workflow for replay/trace */
|
|
20
|
+
export interface WorkflowMeta {
|
|
21
|
+
workflowName: string;
|
|
22
|
+
workflowVersion: string;
|
|
23
|
+
featureName: string;
|
|
24
|
+
startedAt: string;
|
|
25
|
+
sessionId: string;
|
|
26
|
+
}
|
|
27
|
+
/** Result record stored on blackboard for each step */
|
|
28
|
+
export interface StepResultRecord {
|
|
29
|
+
success: boolean;
|
|
30
|
+
output: string | null;
|
|
31
|
+
error: string | null;
|
|
32
|
+
errorMeta?: StepErrorMetadata | null;
|
|
33
|
+
diagnosisCode: string | null;
|
|
34
|
+
completedAt: string | null;
|
|
35
|
+
failedAt: string | null;
|
|
36
|
+
}
|
|
37
|
+
/** Returns an ISO-8601 timestamp string. Injectable for deterministic tests. */
|
|
38
|
+
export type Clock = () => string;
|
|
39
|
+
/** Override the clock used by record* functions. Pass `null` to reset. */
|
|
40
|
+
export declare function setClock(clock: Clock | null): void;
|
|
41
|
+
/**
|
|
42
|
+
* Create a Blackboard instance scoped to a single workflow run.
|
|
43
|
+
*
|
|
44
|
+
* Initialises `state.context.workflow` with replay-friendly metadata and
|
|
45
|
+
* `state.steps` as an empty container for per-step results.
|
|
46
|
+
*/
|
|
47
|
+
export declare function createWorkflowBlackboard(sessionId: string, workflow: Workflow, featureName: string): Blackboard;
|
|
48
|
+
/**
|
|
49
|
+
* Build an AgentContext for a single step execution.
|
|
50
|
+
*
|
|
51
|
+
* @param sessionId - Workflow run session ID
|
|
52
|
+
* @param board - Shared Blackboard instance (workflow-scoped)
|
|
53
|
+
* @param step - Current workflow step
|
|
54
|
+
* @param history - Accumulated LLM chat history from prior steps
|
|
55
|
+
*/
|
|
56
|
+
export declare function buildAgentContext(sessionId: string, board: Blackboard | AgentContext["board"], step: Step, history?: ChatMessage[]): AgentContext;
|
|
57
|
+
/**
|
|
58
|
+
* Record a successful step result on the blackboard.
|
|
59
|
+
* Path: `state.context.steps.<stepName>`
|
|
60
|
+
*/
|
|
61
|
+
export declare function recordStepResult(board: Blackboard | AgentContext["board"], stepName: string, result: StepResult): void;
|
|
62
|
+
/**
|
|
63
|
+
* Record a failed step result on the blackboard.
|
|
64
|
+
* Path: `state.context.steps.<stepName>`
|
|
65
|
+
*/
|
|
66
|
+
export declare function recordStepError(board: Blackboard | AgentContext["board"], stepName: string, result: StepResult): void;
|
|
67
|
+
/**
|
|
68
|
+
* Read a previous step's result from the blackboard.
|
|
69
|
+
* Returns null if the step has not been recorded yet.
|
|
70
|
+
*
|
|
71
|
+
* Uses a single `board.read({ strict: false })` call for atomicity
|
|
72
|
+
* and efficiency (one traversal instead of exists + read).
|
|
73
|
+
*/
|
|
74
|
+
export declare function readStepResult(board: Blackboard | AgentContext["board"], stepName: string): StepResultRecord | null;
|
|
75
|
+
/**
|
|
76
|
+
* Maximum number of chat messages retained in the rolling history window.
|
|
77
|
+
* Prevents unbounded memory growth in long workflows while keeping enough
|
|
78
|
+
* context for downstream steps.
|
|
79
|
+
*/
|
|
80
|
+
export declare const MAX_HISTORY_LENGTH = 200;
|
|
81
|
+
/**
|
|
82
|
+
* Append a message to the chat history, trimming the oldest entries when
|
|
83
|
+
* the history exceeds `MAX_HISTORY_LENGTH`.
|
|
84
|
+
*
|
|
85
|
+
* **Note:** Mutates the input array in-place for performance. Callers
|
|
86
|
+
* sharing the array reference should be aware of this contract.
|
|
87
|
+
*/
|
|
88
|
+
export declare function appendHistory(history: ChatMessage[], message: ChatMessage): void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface RetryPolicy {
|
|
2
|
+
baseDelayMs: number;
|
|
3
|
+
maxDelayMs: number;
|
|
4
|
+
backoffMultiplier?: number;
|
|
5
|
+
jitterRatio?: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function calculateDelay(attempt: number, policy: RetryPolicy): number;
|
|
8
|
+
export declare function waitWithAbort(ms: number, signal?: AbortSignal): Promise<void>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StepExecutor — bridges workflow Step to BaseAgent.execute()
|
|
3
|
+
*/
|
|
4
|
+
import type { Step } from "../../../_legacy/workflow/index.js";
|
|
5
|
+
import { type AgentConfig } from "@obora/adapters";
|
|
6
|
+
import { type ErrorCode } from "../../../_legacy/workflow/index.js";
|
|
7
|
+
import type { BaseAgent, Task, AgentContext } from "../../agents/roles/index.js";
|
|
8
|
+
import type { StepErrorMetadata } from "./types.js";
|
|
9
|
+
export interface StepResult {
|
|
10
|
+
success: boolean;
|
|
11
|
+
output?: string;
|
|
12
|
+
error?: string;
|
|
13
|
+
diagnosisCode?: ErrorCode;
|
|
14
|
+
errorMeta?: StepErrorMetadata;
|
|
15
|
+
}
|
|
16
|
+
export interface AgentResolver {
|
|
17
|
+
resolve(agentName: string): BaseAgent | Promise<BaseAgent>;
|
|
18
|
+
resolve(query: {
|
|
19
|
+
agent?: string;
|
|
20
|
+
type?: string;
|
|
21
|
+
config?: AgentConfig;
|
|
22
|
+
}): BaseAgent | Promise<BaseAgent>;
|
|
23
|
+
}
|
|
24
|
+
export { parseDuration } from "./utils.js";
|
|
25
|
+
export declare function stepToTask(step: Step): Task;
|
|
26
|
+
export interface ExecuteStepOptions {
|
|
27
|
+
timeoutMs?: number;
|
|
28
|
+
signal?: AbortSignal;
|
|
29
|
+
retryAttempts?: number;
|
|
30
|
+
resolvedAgentConfig?: AgentConfig;
|
|
31
|
+
onEvent?: (event: unknown) => void;
|
|
32
|
+
}
|
|
33
|
+
export declare function executeStep(step: Step, resolver: AgentResolver, context: AgentContext, options?: ExecuteStepOptions): Promise<StepResult>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ErrorCode } from "../../../_legacy/workflow/index.js";
|
|
2
|
+
export type UserFacingErrorCode = "E4001" | "E4002" | "E4003" | "E4005" | "E4006" | "E4007" | "E4010" | "E4012" | "E4013" | "E4014";
|
|
3
|
+
export type InternalDiagCode = "E4011";
|
|
4
|
+
export interface StepErrorMetadata {
|
|
5
|
+
code: UserFacingErrorCode;
|
|
6
|
+
message: string;
|
|
7
|
+
provider?: string;
|
|
8
|
+
statusCode?: number;
|
|
9
|
+
attempts?: number;
|
|
10
|
+
lastError?: ErrorCode;
|
|
11
|
+
failedAt?: string;
|
|
12
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DuckDB client for data persistence
|
|
3
|
+
* @module @obora/database/duckdb-client
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Project record
|
|
7
|
+
*/
|
|
8
|
+
export interface Project {
|
|
9
|
+
id?: number;
|
|
10
|
+
name: string;
|
|
11
|
+
path: string;
|
|
12
|
+
created_at?: string;
|
|
13
|
+
updated_at?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Workflow run record
|
|
17
|
+
*/
|
|
18
|
+
export interface WorkflowRun {
|
|
19
|
+
id?: number;
|
|
20
|
+
project_id: number;
|
|
21
|
+
feature: string;
|
|
22
|
+
workflow: string;
|
|
23
|
+
mode: "auto" | "supervised" | "gated";
|
|
24
|
+
status: "pending" | "running" | "paused" | "completed" | "failed" | "cancelled";
|
|
25
|
+
current_step?: string;
|
|
26
|
+
started_at?: string;
|
|
27
|
+
completed_at?: string;
|
|
28
|
+
error_message?: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Step execution record
|
|
32
|
+
*/
|
|
33
|
+
export interface StepExecution {
|
|
34
|
+
id?: number;
|
|
35
|
+
run_id: number;
|
|
36
|
+
step_name: string;
|
|
37
|
+
step_index: number;
|
|
38
|
+
agent: string;
|
|
39
|
+
status: "pending" | "running" | "completed" | "failed" | "skipped";
|
|
40
|
+
retry_count?: number;
|
|
41
|
+
started_at?: string;
|
|
42
|
+
completed_at?: string;
|
|
43
|
+
error_message?: string;
|
|
44
|
+
output_path?: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Metric record
|
|
48
|
+
*/
|
|
49
|
+
export interface Metric {
|
|
50
|
+
id?: number;
|
|
51
|
+
run_id: number;
|
|
52
|
+
step_id?: number;
|
|
53
|
+
metric_name: string;
|
|
54
|
+
metric_value: number;
|
|
55
|
+
recorded_at?: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Database client wrapper
|
|
59
|
+
*/
|
|
60
|
+
export declare class OboraDatabase {
|
|
61
|
+
private db;
|
|
62
|
+
private connection;
|
|
63
|
+
private dbPath;
|
|
64
|
+
private initialized;
|
|
65
|
+
constructor(dbPath?: string);
|
|
66
|
+
/**
|
|
67
|
+
* Initialize database schema
|
|
68
|
+
*/
|
|
69
|
+
initialize(): Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* Execute a SQL query without returning results
|
|
72
|
+
*/
|
|
73
|
+
run(sql: string, params?: any[]): Promise<void>;
|
|
74
|
+
/**
|
|
75
|
+
* Execute a SQL query and return all rows
|
|
76
|
+
*/
|
|
77
|
+
query(sql: string, params?: any[]): Promise<any[]>;
|
|
78
|
+
/**
|
|
79
|
+
* Execute a SQL query and return first row
|
|
80
|
+
*/
|
|
81
|
+
queryOne(sql: string, params?: any[]): Promise<any | null>;
|
|
82
|
+
/**
|
|
83
|
+
* Close database connection
|
|
84
|
+
*/
|
|
85
|
+
close(): void;
|
|
86
|
+
/**
|
|
87
|
+
* Get database path
|
|
88
|
+
*/
|
|
89
|
+
getPath(): string;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Insert a new project
|
|
93
|
+
*/
|
|
94
|
+
export declare function insertProject(db: OboraDatabase, project: Omit<Project, "id" | "created_at" | "updated_at">): Promise<number>;
|
|
95
|
+
/**
|
|
96
|
+
* Get a project by ID
|
|
97
|
+
*/
|
|
98
|
+
export declare function getProject(db: OboraDatabase, id: number): Promise<Project | null>;
|
|
99
|
+
/**
|
|
100
|
+
* Get a project by path
|
|
101
|
+
*/
|
|
102
|
+
export declare function getProjectByPath(db: OboraDatabase, projectPath: string): Promise<Project | null>;
|
|
103
|
+
/**
|
|
104
|
+
* List all projects
|
|
105
|
+
*/
|
|
106
|
+
export declare function listProjects(db: OboraDatabase): Promise<Project[]>;
|
|
107
|
+
/**
|
|
108
|
+
* Update a project
|
|
109
|
+
*/
|
|
110
|
+
export declare function updateProject(db: OboraDatabase, id: number, updates: Partial<Project>): Promise<void>;
|
|
111
|
+
/**
|
|
112
|
+
* Delete a project
|
|
113
|
+
*/
|
|
114
|
+
export declare function deleteProject(db: OboraDatabase, id: number): Promise<void>;
|
|
115
|
+
/**
|
|
116
|
+
* Insert a new workflow run
|
|
117
|
+
*/
|
|
118
|
+
export declare function insertWorkflowRun(db: OboraDatabase, run: Omit<WorkflowRun, "id" | "started_at">): Promise<number>;
|
|
119
|
+
/**
|
|
120
|
+
* Get a workflow run by ID
|
|
121
|
+
*/
|
|
122
|
+
export declare function getWorkflowRun(db: OboraDatabase, id: number): Promise<WorkflowRun | null>;
|
|
123
|
+
/**
|
|
124
|
+
* List workflow runs for a project
|
|
125
|
+
*/
|
|
126
|
+
export declare function listWorkflowRuns(db: OboraDatabase, projectId: number): Promise<WorkflowRun[]>;
|
|
127
|
+
/**
|
|
128
|
+
* Update workflow run status
|
|
129
|
+
*/
|
|
130
|
+
export declare function updateWorkflowRunStatus(db: OboraDatabase, id: number, status: WorkflowRun["status"], currentStep?: string, errorMessage?: string): Promise<void>;
|
|
131
|
+
/**
|
|
132
|
+
* Delete a workflow run
|
|
133
|
+
*/
|
|
134
|
+
export declare function deleteWorkflowRun(db: OboraDatabase, id: number): Promise<void>;
|
|
135
|
+
/**
|
|
136
|
+
* Insert a new step execution
|
|
137
|
+
*/
|
|
138
|
+
export declare function insertStepExecution(db: OboraDatabase, step: Omit<StepExecution, "id" | "started_at">): Promise<number>;
|
|
139
|
+
/**
|
|
140
|
+
* Get a step execution by ID
|
|
141
|
+
*/
|
|
142
|
+
export declare function getStepExecution(db: OboraDatabase, id: number): Promise<StepExecution | null>;
|
|
143
|
+
/**
|
|
144
|
+
* List step executions for a run
|
|
145
|
+
*/
|
|
146
|
+
export declare function listStepExecutions(db: OboraDatabase, runId: number): Promise<StepExecution[]>;
|
|
147
|
+
/**
|
|
148
|
+
* Update step execution status
|
|
149
|
+
*/
|
|
150
|
+
export declare function updateStepExecutionStatus(db: OboraDatabase, id: number, status: StepExecution["status"], output?: string, errorMessage?: string): Promise<void>;
|
|
151
|
+
/**
|
|
152
|
+
* Increment retry count for a step
|
|
153
|
+
*/
|
|
154
|
+
export declare function incrementStepRetry(db: OboraDatabase, id: number): Promise<void>;
|
|
155
|
+
/**
|
|
156
|
+
* Delete step executions for a run
|
|
157
|
+
*/
|
|
158
|
+
export declare function deleteStepExecutions(db: OboraDatabase, runId: number): Promise<void>;
|
|
159
|
+
/**
|
|
160
|
+
* Insert a new metric
|
|
161
|
+
*/
|
|
162
|
+
export declare function insertMetric(db: OboraDatabase, metric: Omit<Metric, "id" | "recorded_at">): Promise<number>;
|
|
163
|
+
/**
|
|
164
|
+
* Get metrics for a run
|
|
165
|
+
*/
|
|
166
|
+
export declare function getMetricsForRun(db: OboraDatabase, runId: number): Promise<Metric[]>;
|
|
167
|
+
/**
|
|
168
|
+
* Get metrics for a specific step
|
|
169
|
+
*/
|
|
170
|
+
export declare function getMetricsForStep(db: OboraDatabase, stepId: number): Promise<Metric[]>;
|
|
171
|
+
/**
|
|
172
|
+
* Aggregate metric value for a run
|
|
173
|
+
*/
|
|
174
|
+
export declare function aggregateMetric(db: OboraDatabase, runId: number, metricName: string, aggregate?: "SUM" | "AVG" | "MIN" | "MAX" | "COUNT"): Promise<number | null>;
|
|
175
|
+
/**
|
|
176
|
+
* Delete metrics for a run
|
|
177
|
+
*/
|
|
178
|
+
export declare function deleteMetrics(db: OboraDatabase, runId: number): Promise<void>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Actionable diagnosis templates for high-frequency errors
|
|
3
|
+
* Each template follows: Hypothesis → Evidence → Command → Rollback
|
|
4
|
+
* @module @obora/core/errors/diagnosis
|
|
5
|
+
*/
|
|
6
|
+
export interface DiagnosisTemplate {
|
|
7
|
+
/** Error code */
|
|
8
|
+
code: string;
|
|
9
|
+
/** One-line summary */
|
|
10
|
+
title: string;
|
|
11
|
+
/** Probable cause hypothesis */
|
|
12
|
+
hypothesis: string;
|
|
13
|
+
/** How to confirm the hypothesis */
|
|
14
|
+
evidence: string;
|
|
15
|
+
/** Command(s) to fix */
|
|
16
|
+
commands: string[];
|
|
17
|
+
/** How to undo if the fix makes things worse */
|
|
18
|
+
rollback: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Get diagnosis template for a given error code.
|
|
22
|
+
* Returns undefined if no template exists.
|
|
23
|
+
*/
|
|
24
|
+
export declare function getDiagnosis(code: string): DiagnosisTemplate | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Format a diagnosis template as a human-readable CLI string.
|
|
27
|
+
*/
|
|
28
|
+
export declare function formatDiagnosis(diag: DiagnosisTemplate): string;
|
|
29
|
+
/**
|
|
30
|
+
* Get all registered diagnosis templates.
|
|
31
|
+
*/
|
|
32
|
+
export declare function getAllDiagnoses(): DiagnosisTemplate[];
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error codes and classes for obora-kit
|
|
3
|
+
* @module @obora/core/errors
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Error codes mapping
|
|
7
|
+
* Reference: docs/spec/10-error-codes.md
|
|
8
|
+
*/
|
|
9
|
+
export declare const ErrorCodes: {
|
|
10
|
+
readonly E1001: "Unknown error";
|
|
11
|
+
readonly E1002: "Configuration not found";
|
|
12
|
+
readonly E1003: "Permission denied";
|
|
13
|
+
readonly E2001: "Invalid YAML syntax";
|
|
14
|
+
readonly E2002: "Missing required field";
|
|
15
|
+
readonly E2003: "Invalid field type";
|
|
16
|
+
readonly E2004: "Unknown field";
|
|
17
|
+
readonly E2005: "Invalid duration format";
|
|
18
|
+
readonly E2006: "Duplicate step name";
|
|
19
|
+
readonly E3001: "Circular dependency detected";
|
|
20
|
+
readonly E3002: "Missing dependency";
|
|
21
|
+
readonly E3003: "Self dependency";
|
|
22
|
+
readonly E3004: "Unresolved input file";
|
|
23
|
+
readonly E4001: "Step execution failed";
|
|
24
|
+
readonly E4002: "Timeout exceeded";
|
|
25
|
+
readonly E4003: "Agent not found";
|
|
26
|
+
readonly E4004: "Lock acquisition failed";
|
|
27
|
+
readonly E4005: "Step failed after retries exhausted";
|
|
28
|
+
readonly E4006: "Spec validation failed";
|
|
29
|
+
readonly E4007: "Context assembly failed";
|
|
30
|
+
readonly E6003: "OpenClaw connection failed";
|
|
31
|
+
};
|
|
32
|
+
export type ErrorCode = keyof typeof ErrorCodes;
|
|
33
|
+
/**
|
|
34
|
+
* Base error class for obora-kit
|
|
35
|
+
*/
|
|
36
|
+
export declare class OboraError extends Error {
|
|
37
|
+
readonly code: ErrorCode;
|
|
38
|
+
readonly details?: Record<string, unknown>;
|
|
39
|
+
constructor(code: ErrorCode, message?: string, details?: Record<string, unknown>);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* YAML parsing error
|
|
43
|
+
*/
|
|
44
|
+
export declare class ParseError extends OboraError {
|
|
45
|
+
constructor(code: ErrorCode, message?: string, details?: Record<string, unknown>);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Dependency resolution error
|
|
49
|
+
*/
|
|
50
|
+
export declare class DependencyError extends OboraError {
|
|
51
|
+
constructor(code: ErrorCode, message?: string, details?: Record<string, unknown>);
|
|
52
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Graph utilities for dependency resolution
|
|
3
|
+
* @module @obora/core/graph
|
|
4
|
+
*/
|
|
5
|
+
import type { Step } from "../types/workflow.js";
|
|
6
|
+
/**
|
|
7
|
+
* Graph representation using adjacency list
|
|
8
|
+
*/
|
|
9
|
+
export interface Graph {
|
|
10
|
+
/** Set of all node names */
|
|
11
|
+
nodes: Set<string>;
|
|
12
|
+
/** Edge map: node -> set of dependent nodes (forward direction) */
|
|
13
|
+
edges: Map<string, Set<string>>;
|
|
14
|
+
/** Reverse edge map: node -> set of nodes this node depends on */
|
|
15
|
+
reverseEdges: Map<string, Set<string>>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Result of cycle detection
|
|
19
|
+
*/
|
|
20
|
+
export interface CycleResult {
|
|
21
|
+
/** Whether a cycle exists */
|
|
22
|
+
hasCycle: boolean;
|
|
23
|
+
/** The path that forms the cycle (if any) */
|
|
24
|
+
cyclePath?: string[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Result of topological sort
|
|
28
|
+
*/
|
|
29
|
+
export interface TopologicalResult {
|
|
30
|
+
/** Whether sort was successful (no cycles) */
|
|
31
|
+
success: boolean;
|
|
32
|
+
/** Sorted node names in execution order */
|
|
33
|
+
order: string[];
|
|
34
|
+
/** Cycle path if cycle detected */
|
|
35
|
+
cyclePath?: string[];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Build a graph from steps
|
|
39
|
+
*/
|
|
40
|
+
export declare function buildGraph(steps: Step[]): Graph;
|
|
41
|
+
/**
|
|
42
|
+
* Detect cycles using DFS
|
|
43
|
+
*/
|
|
44
|
+
export declare function detectCycles(graph: Graph): CycleResult;
|
|
45
|
+
/**
|
|
46
|
+
* Topological sort using Kahn's Algorithm
|
|
47
|
+
*/
|
|
48
|
+
export declare function topologicalSort(graph: Graph): TopologicalResult;
|
|
49
|
+
/**
|
|
50
|
+
* Compute execution levels for each node
|
|
51
|
+
* Level 0 = no dependencies, Level N = depends on nodes up to level N-1
|
|
52
|
+
*/
|
|
53
|
+
export declare function computeLevels(graph: Graph): Map<string, number>;
|
|
54
|
+
/**
|
|
55
|
+
* Group nodes by execution level
|
|
56
|
+
*/
|
|
57
|
+
export declare function groupByLevel(steps: Step[]): Map<number, Step[]>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "./utils.js";
|
|
2
|
+
export * from "./types/workflow.js";
|
|
3
|
+
export * from "./errors/index.js";
|
|
4
|
+
export * from "./errors/diagnosis.js";
|
|
5
|
+
export * from "./parser/workflow-parser.js";
|
|
6
|
+
export * from "./graph/index.js";
|
|
7
|
+
export * from "./validator/workflow-validator.js";
|
|
8
|
+
export { ValidationErrorCode } from "./validator/workflow-validator.js";
|
|
9
|
+
export * from "./resolver/dependency-resolver.js";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workflow YAML parser
|
|
3
|
+
* @module @obora/core/parser/workflow-parser
|
|
4
|
+
*/
|
|
5
|
+
import type { DependencyMap, ParserOptions, Workflow } from "../types/workflow.js";
|
|
6
|
+
/**
|
|
7
|
+
* Parse workflow YAML string into typed Workflow object
|
|
8
|
+
*/
|
|
9
|
+
export declare function parseWorkflow(yamlContent: string, options?: ParserOptions): Workflow;
|
|
10
|
+
/**
|
|
11
|
+
* Resolve dependencies including implicit ones from inputs/outputs
|
|
12
|
+
*/
|
|
13
|
+
export declare function resolveDependencies(workflow: Workflow): DependencyMap;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dependency resolver using Kahn's Algorithm
|
|
3
|
+
* @module @obora/core/resolver/dependency-resolver
|
|
4
|
+
*/
|
|
5
|
+
import { type CycleResult } from "../graph/index.js";
|
|
6
|
+
import type { Step, Workflow } from "../types/workflow.js";
|
|
7
|
+
/**
|
|
8
|
+
* Step group at a specific execution level
|
|
9
|
+
*/
|
|
10
|
+
export interface StepGroup {
|
|
11
|
+
/** Execution level (0 = no dependencies, 1+ = depends on earlier levels) */
|
|
12
|
+
level: number;
|
|
13
|
+
/** Steps that can be executed in parallel at this level */
|
|
14
|
+
steps: Step[];
|
|
15
|
+
/** Whether steps in this group can be executed in parallel */
|
|
16
|
+
parallelizable: boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Execution plan for a workflow
|
|
20
|
+
*/
|
|
21
|
+
export interface ExecutionPlan {
|
|
22
|
+
/** Whether the plan is valid (no cycles) */
|
|
23
|
+
isValid: boolean;
|
|
24
|
+
/** Execution order of step names */
|
|
25
|
+
executionOrder: string[];
|
|
26
|
+
/** Cyclic dependency path (if any) */
|
|
27
|
+
cyclicPath?: string[];
|
|
28
|
+
/** Steps grouped by execution level */
|
|
29
|
+
stepGroups: StepGroup[];
|
|
30
|
+
/** Conditional back-edges (source -> target) */
|
|
31
|
+
backEdges: Array<{
|
|
32
|
+
source: string;
|
|
33
|
+
target: string;
|
|
34
|
+
}>;
|
|
35
|
+
/** Non-fatal planning warnings */
|
|
36
|
+
warnings: string[];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Dependency graph representation
|
|
40
|
+
*/
|
|
41
|
+
export interface DependencyGraph {
|
|
42
|
+
/** Map of step name to Step object */
|
|
43
|
+
nodes: Map<string, Step>;
|
|
44
|
+
/** Map of step name to list of dependency step names */
|
|
45
|
+
edges: Map<string, string[]>;
|
|
46
|
+
/** Conditional back-edges (source -> target) */
|
|
47
|
+
backEdges: Map<string, string>;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Build dependency graph from steps
|
|
51
|
+
*/
|
|
52
|
+
export declare function buildDependencyGraph(steps: Step[]): DependencyGraph;
|
|
53
|
+
/**
|
|
54
|
+
* Resolve execution order using topological sort (Kahn's Algorithm)
|
|
55
|
+
*/
|
|
56
|
+
export declare function resolveTopologicalOrder(steps: Step[]): string[] | null;
|
|
57
|
+
/**
|
|
58
|
+
* Check for cycles using DFS
|
|
59
|
+
*/
|
|
60
|
+
export declare function detectCyclesDFS(steps: Step[]): CycleResult;
|
|
61
|
+
/**
|
|
62
|
+
* Calculate execution levels using BFS
|
|
63
|
+
*/
|
|
64
|
+
export declare function calculateExecutionLevels(steps: Step[]): Map<string, number>;
|
|
65
|
+
/**
|
|
66
|
+
* Group steps by execution level
|
|
67
|
+
*/
|
|
68
|
+
export declare function groupStepsByLevel(steps: Step[]): StepGroup[];
|
|
69
|
+
/**
|
|
70
|
+
* Generate full execution plan
|
|
71
|
+
*/
|
|
72
|
+
export declare function generateExecutionPlan(workflow: Workflow): ExecutionPlan;
|
|
73
|
+
/**
|
|
74
|
+
* Get next executable steps from current execution state
|
|
75
|
+
*/
|
|
76
|
+
export declare function getNextSteps(workflow: Workflow, completedSteps: Set<string>): Step[];
|
|
77
|
+
/**
|
|
78
|
+
* Validate execution order
|
|
79
|
+
*/
|
|
80
|
+
export declare function validateExecutionOrder(workflow: Workflow, order: string[]): {
|
|
81
|
+
valid: boolean;
|
|
82
|
+
errors: string[];
|
|
83
|
+
};
|