@telora/factory 0.4.5
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/audit.d.ts +69 -0
- package/dist/audit.d.ts.map +1 -0
- package/dist/audit.js +376 -0
- package/dist/audit.js.map +1 -0
- package/dist/builder-completion.d.ts +35 -0
- package/dist/builder-completion.d.ts.map +1 -0
- package/dist/builder-completion.js +375 -0
- package/dist/builder-completion.js.map +1 -0
- package/dist/builder-spawner.d.ts +40 -0
- package/dist/builder-spawner.d.ts.map +1 -0
- package/dist/builder-spawner.js +493 -0
- package/dist/builder-spawner.js.map +1 -0
- package/dist/completion-gate.d.ts +52 -0
- package/dist/completion-gate.d.ts.map +1 -0
- package/dist/completion-gate.js +336 -0
- package/dist/completion-gate.js.map +1 -0
- package/dist/completion-report.d.ts +36 -0
- package/dist/completion-report.d.ts.map +1 -0
- package/dist/completion-report.js +348 -0
- package/dist/completion-report.js.map +1 -0
- package/dist/completion.d.ts +58 -0
- package/dist/completion.d.ts.map +1 -0
- package/dist/completion.js +287 -0
- package/dist/completion.js.map +1 -0
- package/dist/config.d.ts +16 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +57 -0
- package/dist/config.js.map +1 -0
- package/dist/context-manager.d.ts +152 -0
- package/dist/context-manager.d.ts.map +1 -0
- package/dist/context-manager.js +421 -0
- package/dist/context-manager.js.map +1 -0
- package/dist/crash-detection.d.ts +70 -0
- package/dist/crash-detection.d.ts.map +1 -0
- package/dist/crash-detection.js +123 -0
- package/dist/crash-detection.js.map +1 -0
- package/dist/crash-recovery.d.ts +83 -0
- package/dist/crash-recovery.d.ts.map +1 -0
- package/dist/crash-recovery.js +522 -0
- package/dist/crash-recovery.js.map +1 -0
- package/dist/crash-resolution.d.ts +34 -0
- package/dist/crash-resolution.d.ts.map +1 -0
- package/dist/crash-resolution.js +382 -0
- package/dist/crash-resolution.js.map +1 -0
- package/dist/escalation.d.ts +150 -0
- package/dist/escalation.d.ts.map +1 -0
- package/dist/escalation.js +352 -0
- package/dist/escalation.js.map +1 -0
- package/dist/execution-target.d.ts +31 -0
- package/dist/execution-target.d.ts.map +1 -0
- package/dist/execution-target.js +71 -0
- package/dist/execution-target.js.map +1 -0
- package/dist/execution-unit-init.d.ts +28 -0
- package/dist/execution-unit-init.d.ts.map +1 -0
- package/dist/execution-unit-init.js +115 -0
- package/dist/execution-unit-init.js.map +1 -0
- package/dist/execution.d.ts +17 -0
- package/dist/execution.d.ts.map +1 -0
- package/dist/execution.js +20 -0
- package/dist/execution.js.map +1 -0
- package/dist/factory-engine.d.ts +100 -0
- package/dist/factory-engine.d.ts.map +1 -0
- package/dist/factory-engine.js +243 -0
- package/dist/factory-engine.js.map +1 -0
- package/dist/gap-detection.d.ts +43 -0
- package/dist/gap-detection.d.ts.map +1 -0
- package/dist/gap-detection.js +149 -0
- package/dist/gap-detection.js.map +1 -0
- package/dist/gate-context.d.ts +23 -0
- package/dist/gate-context.d.ts.map +1 -0
- package/dist/gate-context.js +63 -0
- package/dist/gate-context.js.map +1 -0
- package/dist/gate-engine.d.ts +55 -0
- package/dist/gate-engine.d.ts.map +1 -0
- package/dist/gate-engine.js +191 -0
- package/dist/gate-engine.js.map +1 -0
- package/dist/gates/adversarial.d.ts +59 -0
- package/dist/gates/adversarial.d.ts.map +1 -0
- package/dist/gates/adversarial.js +426 -0
- package/dist/gates/adversarial.js.map +1 -0
- package/dist/gates/adversary-spawner.d.ts +35 -0
- package/dist/gates/adversary-spawner.d.ts.map +1 -0
- package/dist/gates/adversary-spawner.js +286 -0
- package/dist/gates/adversary-spawner.js.map +1 -0
- package/dist/gates/adversary-test-dir.d.ts +41 -0
- package/dist/gates/adversary-test-dir.d.ts.map +1 -0
- package/dist/gates/adversary-test-dir.js +150 -0
- package/dist/gates/adversary-test-dir.js.map +1 -0
- package/dist/gates/behavioral-parser.d.ts +32 -0
- package/dist/gates/behavioral-parser.d.ts.map +1 -0
- package/dist/gates/behavioral-parser.js +190 -0
- package/dist/gates/behavioral-parser.js.map +1 -0
- package/dist/gates/behavioral-runner.d.ts +36 -0
- package/dist/gates/behavioral-runner.d.ts.map +1 -0
- package/dist/gates/behavioral-runner.js +306 -0
- package/dist/gates/behavioral-runner.js.map +1 -0
- package/dist/gates/behavioral.d.ts +37 -0
- package/dist/gates/behavioral.d.ts.map +1 -0
- package/dist/gates/behavioral.js +485 -0
- package/dist/gates/behavioral.js.map +1 -0
- package/dist/gates/deterministic.d.ts +24 -0
- package/dist/gates/deterministic.d.ts.map +1 -0
- package/dist/gates/deterministic.js +186 -0
- package/dist/gates/deterministic.js.map +1 -0
- package/dist/git-factory.d.ts +59 -0
- package/dist/git-factory.d.ts.map +1 -0
- package/dist/git-factory.js +102 -0
- package/dist/git-factory.js.map +1 -0
- package/dist/guard-evaluation.d.ts +48 -0
- package/dist/guard-evaluation.d.ts.map +1 -0
- package/dist/guard-evaluation.js +416 -0
- package/dist/guard-evaluation.js.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +39 -0
- package/dist/index.js.map +1 -0
- package/dist/instance-completion.d.ts +34 -0
- package/dist/instance-completion.d.ts.map +1 -0
- package/dist/instance-completion.js +366 -0
- package/dist/instance-completion.js.map +1 -0
- package/dist/instance-lifecycle.d.ts +15 -0
- package/dist/instance-lifecycle.d.ts.map +1 -0
- package/dist/instance-lifecycle.js +18 -0
- package/dist/instance-lifecycle.js.map +1 -0
- package/dist/instance-phase-dispatch.d.ts +75 -0
- package/dist/instance-phase-dispatch.d.ts.map +1 -0
- package/dist/instance-phase-dispatch.js +674 -0
- package/dist/instance-phase-dispatch.js.map +1 -0
- package/dist/instance-poll-loop.d.ts +43 -0
- package/dist/instance-poll-loop.d.ts.map +1 -0
- package/dist/instance-poll-loop.js +360 -0
- package/dist/instance-poll-loop.js.map +1 -0
- package/dist/instance-state-machine.d.ts +52 -0
- package/dist/instance-state-machine.d.ts.map +1 -0
- package/dist/instance-state-machine.js +235 -0
- package/dist/instance-state-machine.js.map +1 -0
- package/dist/log-manager.d.ts +28 -0
- package/dist/log-manager.d.ts.map +1 -0
- package/dist/log-manager.js +71 -0
- package/dist/log-manager.js.map +1 -0
- package/dist/pipeline-evaluator.d.ts +61 -0
- package/dist/pipeline-evaluator.d.ts.map +1 -0
- package/dist/pipeline-evaluator.js +107 -0
- package/dist/pipeline-evaluator.js.map +1 -0
- package/dist/pipeline-metrics.d.ts +52 -0
- package/dist/pipeline-metrics.d.ts.map +1 -0
- package/dist/pipeline-metrics.js +40 -0
- package/dist/pipeline-metrics.js.map +1 -0
- package/dist/pipeline-traversal.d.ts +43 -0
- package/dist/pipeline-traversal.d.ts.map +1 -0
- package/dist/pipeline-traversal.js +68 -0
- package/dist/pipeline-traversal.js.map +1 -0
- package/dist/plan-parser.d.ts +76 -0
- package/dist/plan-parser.d.ts.map +1 -0
- package/dist/plan-parser.js +223 -0
- package/dist/plan-parser.js.map +1 -0
- package/dist/planning-phase.d.ts +52 -0
- package/dist/planning-phase.d.ts.map +1 -0
- package/dist/planning-phase.js +444 -0
- package/dist/planning-phase.js.map +1 -0
- package/dist/planning-prompt.d.ts +64 -0
- package/dist/planning-prompt.d.ts.map +1 -0
- package/dist/planning-prompt.js +251 -0
- package/dist/planning-prompt.js.map +1 -0
- package/dist/planning.d.ts +16 -0
- package/dist/planning.d.ts.map +1 -0
- package/dist/planning.js +17 -0
- package/dist/planning.js.map +1 -0
- package/dist/process-runner.d.ts +41 -0
- package/dist/process-runner.d.ts.map +1 -0
- package/dist/process-runner.js +81 -0
- package/dist/process-runner.js.map +1 -0
- package/dist/product-config.d.ts +34 -0
- package/dist/product-config.d.ts.map +1 -0
- package/dist/product-config.js +43 -0
- package/dist/product-config.js.map +1 -0
- package/dist/queries/cycle-evaluations.d.ts +23 -0
- package/dist/queries/cycle-evaluations.d.ts.map +1 -0
- package/dist/queries/cycle-evaluations.js +37 -0
- package/dist/queries/cycle-evaluations.js.map +1 -0
- package/dist/queries/escalations.d.ts +30 -0
- package/dist/queries/escalations.d.ts.map +1 -0
- package/dist/queries/escalations.js +42 -0
- package/dist/queries/escalations.js.map +1 -0
- package/dist/queries/execution-units.d.ts +76 -0
- package/dist/queries/execution-units.d.ts.map +1 -0
- package/dist/queries/execution-units.js +109 -0
- package/dist/queries/execution-units.js.map +1 -0
- package/dist/queries/gate-results.d.ts +32 -0
- package/dist/queries/gate-results.d.ts.map +1 -0
- package/dist/queries/gate-results.js +44 -0
- package/dist/queries/gate-results.js.map +1 -0
- package/dist/queries/instances.d.ts +51 -0
- package/dist/queries/instances.d.ts.map +1 -0
- package/dist/queries/instances.js +77 -0
- package/dist/queries/instances.js.map +1 -0
- package/dist/queries/sessions.d.ts +50 -0
- package/dist/queries/sessions.d.ts.map +1 -0
- package/dist/queries/sessions.js +81 -0
- package/dist/queries/sessions.js.map +1 -0
- package/dist/queries/shared.d.ts +38 -0
- package/dist/queries/shared.d.ts.map +1 -0
- package/dist/queries/shared.js +119 -0
- package/dist/queries/shared.js.map +1 -0
- package/dist/queries/specs.d.ts +12 -0
- package/dist/queries/specs.d.ts.map +1 -0
- package/dist/queries/specs.js +21 -0
- package/dist/queries/specs.js.map +1 -0
- package/dist/queries/strategies.d.ts +14 -0
- package/dist/queries/strategies.d.ts.map +1 -0
- package/dist/queries/strategies.js +18 -0
- package/dist/queries/strategies.js.map +1 -0
- package/dist/queries/work-units.d.ts +42 -0
- package/dist/queries/work-units.d.ts.map +1 -0
- package/dist/queries/work-units.js +57 -0
- package/dist/queries/work-units.js.map +1 -0
- package/dist/queries/workflows.d.ts +29 -0
- package/dist/queries/workflows.d.ts.map +1 -0
- package/dist/queries/workflows.js +103 -0
- package/dist/queries/workflows.js.map +1 -0
- package/dist/remediation-units.d.ts +40 -0
- package/dist/remediation-units.d.ts.map +1 -0
- package/dist/remediation-units.js +263 -0
- package/dist/remediation-units.js.map +1 -0
- package/dist/replanning.d.ts +72 -0
- package/dist/replanning.d.ts.map +1 -0
- package/dist/replanning.js +403 -0
- package/dist/replanning.js.map +1 -0
- package/dist/resource-limits.d.ts +62 -0
- package/dist/resource-limits.d.ts.map +1 -0
- package/dist/resource-limits.js +322 -0
- package/dist/resource-limits.js.map +1 -0
- package/dist/scheduler.d.ts +98 -0
- package/dist/scheduler.d.ts.map +1 -0
- package/dist/scheduler.js +203 -0
- package/dist/scheduler.js.map +1 -0
- package/dist/session-adapter.d.ts +89 -0
- package/dist/session-adapter.d.ts.map +1 -0
- package/dist/session-adapter.js +108 -0
- package/dist/session-adapter.js.map +1 -0
- package/dist/sop-generator.d.ts +29 -0
- package/dist/sop-generator.d.ts.map +1 -0
- package/dist/sop-generator.js +235 -0
- package/dist/sop-generator.js.map +1 -0
- package/dist/spec-profiles.d.ts +41 -0
- package/dist/spec-profiles.d.ts.map +1 -0
- package/dist/spec-profiles.js +131 -0
- package/dist/spec-profiles.js.map +1 -0
- package/dist/strategy-design-graph.d.ts +23 -0
- package/dist/strategy-design-graph.d.ts.map +1 -0
- package/dist/strategy-design-graph.js +205 -0
- package/dist/strategy-design-graph.js.map +1 -0
- package/dist/strategy-design-prompt.d.ts +28 -0
- package/dist/strategy-design-prompt.d.ts.map +1 -0
- package/dist/strategy-design-prompt.js +108 -0
- package/dist/strategy-design-prompt.js.map +1 -0
- package/dist/strategy-design-schema.d.ts +767 -0
- package/dist/strategy-design-schema.d.ts.map +1 -0
- package/dist/strategy-design-schema.js +126 -0
- package/dist/strategy-design-schema.js.map +1 -0
- package/dist/strategy-design.d.ts +69 -0
- package/dist/strategy-design.d.ts.map +1 -0
- package/dist/strategy-design.js +411 -0
- package/dist/strategy-design.js.map +1 -0
- package/dist/strategy-gating.d.ts +31 -0
- package/dist/strategy-gating.d.ts.map +1 -0
- package/dist/strategy-gating.js +276 -0
- package/dist/strategy-gating.js.map +1 -0
- package/dist/team-prompt-builder.d.ts +47 -0
- package/dist/team-prompt-builder.d.ts.map +1 -0
- package/dist/team-prompt-builder.js +362 -0
- package/dist/team-prompt-builder.js.map +1 -0
- package/dist/trace-engine.d.ts +40 -0
- package/dist/trace-engine.d.ts.map +1 -0
- package/dist/trace-engine.js +344 -0
- package/dist/trace-engine.js.map +1 -0
- package/dist/types.d.ts +612 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +9 -0
- package/dist/types.js.map +1 -0
- package/dist/unit-session-lifecycle.d.ts +78 -0
- package/dist/unit-session-lifecycle.d.ts.map +1 -0
- package/dist/unit-session-lifecycle.js +141 -0
- package/dist/unit-session-lifecycle.js.map +1 -0
- package/dist/unit-session.d.ts +30 -0
- package/dist/unit-session.d.ts.map +1 -0
- package/dist/unit-session.js +370 -0
- package/dist/unit-session.js.map +1 -0
- package/dist/watchdogs.d.ts +33 -0
- package/dist/watchdogs.d.ts.map +1 -0
- package/dist/watchdogs.js +170 -0
- package/dist/watchdogs.js.map +1 -0
- package/dist/work-unit-scheduler.d.ts +34 -0
- package/dist/work-unit-scheduler.d.ts.map +1 -0
- package/dist/work-unit-scheduler.js +91 -0
- package/dist/work-unit-scheduler.js.map +1 -0
- package/dist/workflow-transition.d.ts +90 -0
- package/dist/workflow-transition.d.ts.map +1 -0
- package/dist/workflow-transition.js +340 -0
- package/dist/workflow-transition.js.map +1 -0
- package/package.json +65 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pipeline Traversal
|
|
3
|
+
*
|
|
4
|
+
* Manages advancing through pipeline nodes when the current node
|
|
5
|
+
* completes execution. Evaluates outgoing edge conditions to
|
|
6
|
+
* determine the next node.
|
|
7
|
+
*/
|
|
8
|
+
import type { FactoryInstanceState, PipelineGraph } from './types.js';
|
|
9
|
+
import type { PipelineExecutionMetrics } from './pipeline-metrics.js';
|
|
10
|
+
/** Result of a pipeline advance attempt. */
|
|
11
|
+
export interface PipelineAdvanceResult {
|
|
12
|
+
/** What happened during the advance. */
|
|
13
|
+
outcome: 'advanced' | 'completed' | 'no_match' | 'no_pipeline';
|
|
14
|
+
/** The next node ID (if advanced). */
|
|
15
|
+
nextNodeId?: string;
|
|
16
|
+
/** The completed node ID. */
|
|
17
|
+
completedNodeId?: string;
|
|
18
|
+
/** Human-readable message. */
|
|
19
|
+
message: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Attempt to advance the pipeline to the next node.
|
|
23
|
+
*
|
|
24
|
+
* Called when the current pipeline node's execution completes.
|
|
25
|
+
* Evaluates outgoing edge conditions and determines the next step.
|
|
26
|
+
*
|
|
27
|
+
* Does NOT mutate state - returns the result for the caller to apply.
|
|
28
|
+
*
|
|
29
|
+
* @param state - Current factory instance state
|
|
30
|
+
* @param metrics - Current execution metrics for condition evaluation
|
|
31
|
+
* @returns The advance result
|
|
32
|
+
*/
|
|
33
|
+
export declare function advancePipeline(state: FactoryInstanceState, metrics: PipelineExecutionMetrics): PipelineAdvanceResult;
|
|
34
|
+
/**
|
|
35
|
+
* Get the label of a pipeline node by ID.
|
|
36
|
+
* Returns the ID itself if the node is not found.
|
|
37
|
+
*/
|
|
38
|
+
export declare function getNodeLabel(graph: PipelineGraph, nodeId: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* Check if an instance uses pipeline traversal (has a pipeline graph).
|
|
41
|
+
*/
|
|
42
|
+
export declare function usesPipeline(state: FactoryInstanceState): boolean;
|
|
43
|
+
//# sourceMappingURL=pipeline-traversal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline-traversal.d.ts","sourceRoot":"","sources":["../src/pipeline-traversal.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEtE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAEtE,4CAA4C;AAC5C,MAAM,WAAW,qBAAqB;IACpC,wCAAwC;IACxC,OAAO,EAAE,UAAU,GAAG,WAAW,GAAG,UAAU,GAAG,aAAa,CAAC;IAC/D,sCAAsC;IACtC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,6BAA6B;IAC7B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,8BAA8B;IAC9B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,oBAAoB,EAC3B,OAAO,EAAE,wBAAwB,GAChC,qBAAqB,CAyCvB;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,aAAa,EACpB,MAAM,EAAE,MAAM,GACb,MAAM,CAGR;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAEjE"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pipeline Traversal
|
|
3
|
+
*
|
|
4
|
+
* Manages advancing through pipeline nodes when the current node
|
|
5
|
+
* completes execution. Evaluates outgoing edge conditions to
|
|
6
|
+
* determine the next node.
|
|
7
|
+
*/
|
|
8
|
+
import { findNextNode, isTerminalNode } from './pipeline-evaluator.js';
|
|
9
|
+
/**
|
|
10
|
+
* Attempt to advance the pipeline to the next node.
|
|
11
|
+
*
|
|
12
|
+
* Called when the current pipeline node's execution completes.
|
|
13
|
+
* Evaluates outgoing edge conditions and determines the next step.
|
|
14
|
+
*
|
|
15
|
+
* Does NOT mutate state - returns the result for the caller to apply.
|
|
16
|
+
*
|
|
17
|
+
* @param state - Current factory instance state
|
|
18
|
+
* @param metrics - Current execution metrics for condition evaluation
|
|
19
|
+
* @returns The advance result
|
|
20
|
+
*/
|
|
21
|
+
export function advancePipeline(state, metrics) {
|
|
22
|
+
const { pipelineGraph, currentPipelineNodeId } = state;
|
|
23
|
+
// No pipeline graph = legacy mode, nothing to do
|
|
24
|
+
if (!pipelineGraph || !currentPipelineNodeId) {
|
|
25
|
+
return {
|
|
26
|
+
outcome: 'no_pipeline',
|
|
27
|
+
message: 'No pipeline graph configured (legacy mode).',
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
// Check if current node is terminal (no outgoing edges)
|
|
31
|
+
if (isTerminalNode(currentPipelineNodeId, pipelineGraph.edges)) {
|
|
32
|
+
return {
|
|
33
|
+
outcome: 'completed',
|
|
34
|
+
completedNodeId: currentPipelineNodeId,
|
|
35
|
+
message: `Pipeline completed at terminal node "${currentPipelineNodeId}".`,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
// Find the next node by evaluating outgoing edge conditions
|
|
39
|
+
const nextNodeId = findNextNode(currentPipelineNodeId, pipelineGraph.edges, metrics);
|
|
40
|
+
if (!nextNodeId) {
|
|
41
|
+
return {
|
|
42
|
+
outcome: 'no_match',
|
|
43
|
+
completedNodeId: currentPipelineNodeId,
|
|
44
|
+
message: `No outgoing edge condition matched for node "${currentPipelineNodeId}". Escalation needed.`,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
outcome: 'advanced',
|
|
49
|
+
nextNodeId,
|
|
50
|
+
completedNodeId: currentPipelineNodeId,
|
|
51
|
+
message: `Pipeline advanced from "${currentPipelineNodeId}" to "${nextNodeId}".`,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Get the label of a pipeline node by ID.
|
|
56
|
+
* Returns the ID itself if the node is not found.
|
|
57
|
+
*/
|
|
58
|
+
export function getNodeLabel(graph, nodeId) {
|
|
59
|
+
const node = graph.nodes.find((n) => n.id === nodeId);
|
|
60
|
+
return node?.label ?? nodeId;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Check if an instance uses pipeline traversal (has a pipeline graph).
|
|
64
|
+
*/
|
|
65
|
+
export function usesPipeline(state) {
|
|
66
|
+
return state.pipelineGraph !== null && state.currentPipelineNodeId !== null;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=pipeline-traversal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline-traversal.js","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E,KAAK,MAAM,CAAC,CAAC;IACtD,OAAO,IAAI,EAAE,KAAK,IAAI,MAAM,CAAC;AAC/B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,KAA2B;IACtD,OAAO,KAAK,CAAC,aAAa,KAAK,IAAI,IAAI,KAAK,CAAC,qBAAqB,KAAK,IAAI,CAAC;AAC9E,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Work plan parsing, validation, and tempId-to-UUID mapping.
|
|
3
|
+
*
|
|
4
|
+
* Contains the Zod schemas for AI-generated work plans, JSON extraction
|
|
5
|
+
* from Claude Code output, dependency validation, and tempId mapping.
|
|
6
|
+
* Split from planning.ts for maintainability.
|
|
7
|
+
*/
|
|
8
|
+
import { z } from 'zod';
|
|
9
|
+
import type { WorkPlanUnit } from './types.js';
|
|
10
|
+
export declare const WorkPlanSchema: z.ZodObject<{
|
|
11
|
+
workUnits: z.ZodArray<z.ZodObject<{
|
|
12
|
+
tempId: z.ZodString;
|
|
13
|
+
title: z.ZodString;
|
|
14
|
+
description: z.ZodString;
|
|
15
|
+
sortOrder: z.ZodNumber;
|
|
16
|
+
blockedBy: z.ZodArray<z.ZodString, "many">;
|
|
17
|
+
}, "strip", z.ZodTypeAny, {
|
|
18
|
+
description: string;
|
|
19
|
+
tempId: string;
|
|
20
|
+
title: string;
|
|
21
|
+
sortOrder: number;
|
|
22
|
+
blockedBy: string[];
|
|
23
|
+
}, {
|
|
24
|
+
description: string;
|
|
25
|
+
tempId: string;
|
|
26
|
+
title: string;
|
|
27
|
+
sortOrder: number;
|
|
28
|
+
blockedBy: string[];
|
|
29
|
+
}>, "many">;
|
|
30
|
+
}, "strip", z.ZodTypeAny, {
|
|
31
|
+
workUnits: {
|
|
32
|
+
description: string;
|
|
33
|
+
tempId: string;
|
|
34
|
+
title: string;
|
|
35
|
+
sortOrder: number;
|
|
36
|
+
blockedBy: string[];
|
|
37
|
+
}[];
|
|
38
|
+
}, {
|
|
39
|
+
workUnits: {
|
|
40
|
+
description: string;
|
|
41
|
+
tempId: string;
|
|
42
|
+
title: string;
|
|
43
|
+
sortOrder: number;
|
|
44
|
+
blockedBy: string[];
|
|
45
|
+
}[];
|
|
46
|
+
}>;
|
|
47
|
+
/**
|
|
48
|
+
* Claude Code --print --output-format json returns a JSON array of content blocks.
|
|
49
|
+
* Each block has { type, text } for text content. We need to extract the work plan
|
|
50
|
+
* JSON from the text content.
|
|
51
|
+
*
|
|
52
|
+
* The response format is:
|
|
53
|
+
* [{ "type": "text", "text": "..." }, ...]
|
|
54
|
+
*
|
|
55
|
+
* We concatenate all text blocks and extract the JSON work plan.
|
|
56
|
+
*/
|
|
57
|
+
export declare function extractWorkPlanJson(rawOutput: string): string;
|
|
58
|
+
/**
|
|
59
|
+
* Validate that all blockedBy references point to valid tempIds within the plan.
|
|
60
|
+
* Returns an error message if validation fails, null if valid.
|
|
61
|
+
*/
|
|
62
|
+
export declare function validateDependencies(units: WorkPlanUnit[]): string | null;
|
|
63
|
+
/**
|
|
64
|
+
* Map tempId references to real UUIDs.
|
|
65
|
+
*
|
|
66
|
+
* Generates a UUID for each work unit, then replaces tempId references
|
|
67
|
+
* in blockedBy arrays with the corresponding real UUIDs.
|
|
68
|
+
*/
|
|
69
|
+
export declare function mapTempIdsToUuids(units: WorkPlanUnit[]): Array<{
|
|
70
|
+
id: string;
|
|
71
|
+
title: string;
|
|
72
|
+
description: string;
|
|
73
|
+
sortOrder: number;
|
|
74
|
+
blockedBy: string[];
|
|
75
|
+
}>;
|
|
76
|
+
//# sourceMappingURL=plan-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan-parser.d.ts","sourceRoot":"","sources":["../src/plan-parser.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAc/C,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAEzB,CAAC;AAMH;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAsI7D;AAMD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,YAAY,EAAE,GAAG,MAAM,GAAG,IAAI,CAgBzE;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,YAAY,EAAE,GACpB,KAAK,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAyBnG"}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Work plan parsing, validation, and tempId-to-UUID mapping.
|
|
3
|
+
*
|
|
4
|
+
* Contains the Zod schemas for AI-generated work plans, JSON extraction
|
|
5
|
+
* from Claude Code output, dependency validation, and tempId mapping.
|
|
6
|
+
* Split from planning.ts for maintainability.
|
|
7
|
+
*/
|
|
8
|
+
import { randomUUID } from 'node:crypto';
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
// ============================================================================
|
|
11
|
+
// Zod schema for AI-generated work plan
|
|
12
|
+
// ============================================================================
|
|
13
|
+
const WorkPlanUnitSchema = z.object({
|
|
14
|
+
tempId: z.string().min(1),
|
|
15
|
+
title: z.string().min(1),
|
|
16
|
+
description: z.string().min(1),
|
|
17
|
+
sortOrder: z.number().int().min(0),
|
|
18
|
+
blockedBy: z.array(z.string()),
|
|
19
|
+
});
|
|
20
|
+
export const WorkPlanSchema = z.object({
|
|
21
|
+
workUnits: z.array(WorkPlanUnitSchema).min(1),
|
|
22
|
+
});
|
|
23
|
+
// ============================================================================
|
|
24
|
+
// JSON extraction from Claude Code output
|
|
25
|
+
// ============================================================================
|
|
26
|
+
/**
|
|
27
|
+
* Claude Code --print --output-format json returns a JSON array of content blocks.
|
|
28
|
+
* Each block has { type, text } for text content. We need to extract the work plan
|
|
29
|
+
* JSON from the text content.
|
|
30
|
+
*
|
|
31
|
+
* The response format is:
|
|
32
|
+
* [{ "type": "text", "text": "..." }, ...]
|
|
33
|
+
*
|
|
34
|
+
* We concatenate all text blocks and extract the JSON work plan.
|
|
35
|
+
*/
|
|
36
|
+
export function extractWorkPlanJson(rawOutput) {
|
|
37
|
+
// Extract AI text content from Claude Code --print --output-format json output.
|
|
38
|
+
//
|
|
39
|
+
// The output is a single JSON line: {"type":"result","result":"<text>","usage":{...}}
|
|
40
|
+
// But stdout may also contain non-JSON lines (git output, tool output leaking to stdout).
|
|
41
|
+
// Strategy: find the result JSON line, extract the result string, then parse the AI's text.
|
|
42
|
+
let textContent = null;
|
|
43
|
+
// Scan each line for the Claude Code result envelope
|
|
44
|
+
for (const line of rawOutput.split('\n')) {
|
|
45
|
+
const trimmedLine = line.trim();
|
|
46
|
+
if (!trimmedLine || !trimmedLine.startsWith('{'))
|
|
47
|
+
continue;
|
|
48
|
+
try {
|
|
49
|
+
const parsed = JSON.parse(trimmedLine);
|
|
50
|
+
if (parsed.type === 'result' && typeof parsed.result === 'string') {
|
|
51
|
+
textContent = parsed.result;
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
// Also handle array-of-content-blocks format (older Claude Code versions)
|
|
55
|
+
if (parsed.type === 'result' && Array.isArray(parsed.result)) {
|
|
56
|
+
const texts = [];
|
|
57
|
+
for (const block of parsed.result) {
|
|
58
|
+
if (typeof block === 'object' && block !== null && block.type === 'text') {
|
|
59
|
+
const text = block.text;
|
|
60
|
+
if (typeof text === 'string')
|
|
61
|
+
texts.push(text);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (texts.length > 0) {
|
|
65
|
+
textContent = texts.join('');
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
// Not valid JSON -- skip this line
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
// Fallback: try parsing the whole output as a single JSON value.
|
|
75
|
+
// --output-format json --verbose returns a JSON array of streaming events,
|
|
76
|
+
// not NDJSON lines. Find the {type: "result"} event within the array.
|
|
77
|
+
if (textContent === null) {
|
|
78
|
+
try {
|
|
79
|
+
const parsed = JSON.parse(rawOutput);
|
|
80
|
+
if (Array.isArray(parsed)) {
|
|
81
|
+
// Look for {type: "result"} event first (verbose JSON array format)
|
|
82
|
+
for (const event of parsed) {
|
|
83
|
+
if (typeof event !== 'object' || event === null)
|
|
84
|
+
continue;
|
|
85
|
+
const ev = event;
|
|
86
|
+
if (ev.type === 'result' && typeof ev.result === 'string') {
|
|
87
|
+
textContent = ev.result;
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
if (ev.type === 'result' && Array.isArray(ev.result)) {
|
|
91
|
+
const texts = [];
|
|
92
|
+
for (const block of ev.result) {
|
|
93
|
+
if (typeof block === 'object' && block !== null && block.type === 'text') {
|
|
94
|
+
const text = block.text;
|
|
95
|
+
if (typeof text === 'string')
|
|
96
|
+
texts.push(text);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (texts.length > 0) {
|
|
100
|
+
textContent = texts.join('');
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
// Fallback: look for {type: "text"} content blocks (older format)
|
|
106
|
+
if (textContent === null) {
|
|
107
|
+
const textBlocks = parsed.filter((block) => typeof block === 'object' &&
|
|
108
|
+
block !== null &&
|
|
109
|
+
'type' in block &&
|
|
110
|
+
'text' in block &&
|
|
111
|
+
block.type === 'text' &&
|
|
112
|
+
typeof block.text === 'string');
|
|
113
|
+
if (textBlocks.length > 0) {
|
|
114
|
+
textContent = textBlocks.map((b) => b.text).join('');
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
// Not a single JSON value either
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
// Last resort: use raw output as-is
|
|
124
|
+
if (textContent === null) {
|
|
125
|
+
textContent = rawOutput;
|
|
126
|
+
}
|
|
127
|
+
// Extract the JSON object from the text content.
|
|
128
|
+
// The AI might wrap it in markdown code fences or include preamble text.
|
|
129
|
+
const trimmed = textContent.trim();
|
|
130
|
+
// Try direct parse first (ideal case: pure JSON)
|
|
131
|
+
try {
|
|
132
|
+
JSON.parse(trimmed);
|
|
133
|
+
return trimmed;
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
// Not clean JSON -- extract below
|
|
137
|
+
}
|
|
138
|
+
// Look for a JSON object within markdown code fences
|
|
139
|
+
const fencedMatch = trimmed.match(/```(?:json)?\s*\n?([\s\S]*?)\n?```/);
|
|
140
|
+
if (fencedMatch?.[1]) {
|
|
141
|
+
const fenced = fencedMatch[1].trim();
|
|
142
|
+
try {
|
|
143
|
+
JSON.parse(fenced);
|
|
144
|
+
return fenced;
|
|
145
|
+
}
|
|
146
|
+
catch {
|
|
147
|
+
// Fenced content isn't valid JSON either -- fall through
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
// Find the first valid JSON object by scanning for } from the end.
|
|
151
|
+
// More robust than manual brace counting -- lets JSON.parse validate.
|
|
152
|
+
const braceStart = trimmed.indexOf('{');
|
|
153
|
+
if (braceStart !== -1) {
|
|
154
|
+
let pos = trimmed.length;
|
|
155
|
+
while (pos > braceStart) {
|
|
156
|
+
pos = trimmed.lastIndexOf('}', pos - 1);
|
|
157
|
+
if (pos === -1)
|
|
158
|
+
break;
|
|
159
|
+
try {
|
|
160
|
+
JSON.parse(trimmed.slice(braceStart, pos + 1));
|
|
161
|
+
return trimmed.slice(braceStart, pos + 1);
|
|
162
|
+
}
|
|
163
|
+
catch {
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
throw new Error('Could not extract JSON work plan from Claude Code output');
|
|
169
|
+
}
|
|
170
|
+
// ============================================================================
|
|
171
|
+
// Dependency mapping: tempId -> real UUID
|
|
172
|
+
// ============================================================================
|
|
173
|
+
/**
|
|
174
|
+
* Validate that all blockedBy references point to valid tempIds within the plan.
|
|
175
|
+
* Returns an error message if validation fails, null if valid.
|
|
176
|
+
*/
|
|
177
|
+
export function validateDependencies(units) {
|
|
178
|
+
const validTempIds = new Set(units.map((u) => u.tempId));
|
|
179
|
+
for (const unit of units) {
|
|
180
|
+
for (const dep of unit.blockedBy) {
|
|
181
|
+
if (!validTempIds.has(dep)) {
|
|
182
|
+
return `Work unit "${unit.tempId}" references unknown dependency "${dep}"`;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
// A unit cannot depend on itself
|
|
186
|
+
if (unit.blockedBy.includes(unit.tempId)) {
|
|
187
|
+
return `Work unit "${unit.tempId}" has a self-dependency`;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Map tempId references to real UUIDs.
|
|
194
|
+
*
|
|
195
|
+
* Generates a UUID for each work unit, then replaces tempId references
|
|
196
|
+
* in blockedBy arrays with the corresponding real UUIDs.
|
|
197
|
+
*/
|
|
198
|
+
export function mapTempIdsToUuids(units) {
|
|
199
|
+
// Build tempId -> UUID mapping
|
|
200
|
+
const idMap = new Map();
|
|
201
|
+
for (const unit of units) {
|
|
202
|
+
idMap.set(unit.tempId, randomUUID());
|
|
203
|
+
}
|
|
204
|
+
// Map units with real UUIDs as id and in blockedBy.
|
|
205
|
+
// The id field MUST be sent to the server so that blockedBy references
|
|
206
|
+
// resolve to actual work unit row IDs. Without this, the DB generates
|
|
207
|
+
// its own IDs and blockedBy points to phantom UUIDs.
|
|
208
|
+
return units.map((unit) => ({
|
|
209
|
+
id: idMap.get(unit.tempId),
|
|
210
|
+
title: unit.title,
|
|
211
|
+
description: unit.description,
|
|
212
|
+
sortOrder: unit.sortOrder,
|
|
213
|
+
blockedBy: unit.blockedBy.map((tempId) => {
|
|
214
|
+
const realId = idMap.get(tempId);
|
|
215
|
+
if (!realId) {
|
|
216
|
+
// This should not happen if validateDependencies passed
|
|
217
|
+
throw new Error(`BUG: tempId "${tempId}" not found in idMap`);
|
|
218
|
+
}
|
|
219
|
+
return realId;
|
|
220
|
+
}),
|
|
221
|
+
}));
|
|
222
|
+
}
|
|
223
|
+
//# sourceMappingURL=plan-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan-parser.js","sourceRoot":"","sources":["../src/plan-parser.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,+EAA+E;AAC/E,wCAAwC;AACxC,+EAA+E;AAE/E,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IAClC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACzB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACxB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9B,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAClC,SAAS,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;CAC/B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IACrC,SAAS,EAAE,CAAC,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;CAC9C,CAAC,CAAC;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;gBACxD,MAAM,IAAI,KAAK,CAAC,gBAAgB,MAAM,sBAAsB,CAAC,CAAC;YAChE,CAAC;YACD,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC;KACH,CAAC,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Planning phase orchestration and retry logic.
|
|
3
|
+
*
|
|
4
|
+
* Contains the main planning entry points that coordinate the planning flow:
|
|
5
|
+
* spawning Claude Code, validating results, retrying on failure, and
|
|
6
|
+
* managing flat vs per-strategy planning flows.
|
|
7
|
+
* Split from planning.ts for maintainability.
|
|
8
|
+
*/
|
|
9
|
+
import type { ResourceGovernor } from '@telora/daemon-core';
|
|
10
|
+
import type { FactoryBlueprint, FactoryConfig, FactoryInstanceState, WorkPlan } from './types.js';
|
|
11
|
+
import { type ParsedTokenUsage } from './queries/shared.js';
|
|
12
|
+
/** Result of a single plan generation attempt. */
|
|
13
|
+
export type PlanGenerationResult = {
|
|
14
|
+
success: true;
|
|
15
|
+
workPlan: WorkPlan;
|
|
16
|
+
tokenUsage: ParsedTokenUsage | null;
|
|
17
|
+
} | {
|
|
18
|
+
success: false;
|
|
19
|
+
error: string;
|
|
20
|
+
tokenUsage: ParsedTokenUsage | null;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Spawn Claude Code and validate the resulting work plan.
|
|
24
|
+
*
|
|
25
|
+
* This function encapsulates steps 2-4 of the planning phase:
|
|
26
|
+
* - Spawns Claude Code in --print mode with the given prompt
|
|
27
|
+
* - Extracts and parses the JSON work plan from the output
|
|
28
|
+
* - Validates schema, dependencies, and resource limits
|
|
29
|
+
*
|
|
30
|
+
* Extracted as a standalone function so it can be called in a retry loop
|
|
31
|
+
* when the AI produces an invalid plan.
|
|
32
|
+
*/
|
|
33
|
+
export declare function generateAndValidateWorkPlan(prompt: string, config: FactoryConfig, worktreePath: string, blueprint: FactoryBlueprint): Promise<PlanGenerationResult>;
|
|
34
|
+
/**
|
|
35
|
+
* Run the planning phase for a factory instance.
|
|
36
|
+
*
|
|
37
|
+
* This function is called by the instance lifecycle manager when an instance
|
|
38
|
+
* transitions to 'planning'. It:
|
|
39
|
+
* 1. Creates a git worktree and branch
|
|
40
|
+
* 2. Checks if the instance has generated strategies (from designing phase)
|
|
41
|
+
* 3a. If strategies exist: runs per-strategy scoped planning in dependency order
|
|
42
|
+
* 3b. If no strategies: runs flat planning (legacy behavior)
|
|
43
|
+
* 4. Transitions the instance to 'building'
|
|
44
|
+
*
|
|
45
|
+
* @returns An object indicating success or failure with an optional error message.
|
|
46
|
+
*/
|
|
47
|
+
export declare function runPlanningPhase(state: FactoryInstanceState, config: FactoryConfig, governor?: ResourceGovernor | null): Promise<{
|
|
48
|
+
success: boolean;
|
|
49
|
+
error?: string;
|
|
50
|
+
tokenUsage?: ParsedTokenUsage | null;
|
|
51
|
+
}>;
|
|
52
|
+
//# sourceMappingURL=planning-phase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"planning-phase.d.ts","sourceRoot":"","sources":["../src/planning-phase.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGlG,OAAO,EAA4C,KAAK,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AA0BtG,kDAAkD;AAClD,MAAM,MAAM,oBAAoB,GAC5B;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,QAAQ,CAAC;IAAC,UAAU,EAAE,gBAAgB,GAAG,IAAI,CAAA;CAAE,GAC1E;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,gBAAgB,GAAG,IAAI,CAAA;CAAE,CAAC;AAE3E;;;;;;;;;;GAUG;AACH,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,aAAa,EACrB,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,gBAAgB,GAC1B,OAAO,CAAC,oBAAoB,CAAC,CA4G/B;AAMD;;;;;;;;;;;;GAYG;AACH,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,oBAAoB,EAC3B,MAAM,EAAE,aAAa,EACrB,QAAQ,CAAC,EAAE,gBAAgB,GAAG,IAAI,GACjC,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAA;CAAE,CAAC,CA+FrF"}
|