work-ctrl-flow-logic 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -4
- package/src/instance.ts +20 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "work-ctrl-flow-logic",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "WorkCtrlFlow 引擎:可中断可恢复的动态工作流(快照重放 + WaitHandle/ResumeSignal)",
|
|
6
6
|
"type": "module",
|
|
@@ -12,9 +12,10 @@
|
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"depa-behavior-tree": "0.1.0",
|
|
15
|
-
"
|
|
16
|
-
"instant-ctrl-flow-
|
|
17
|
-
"
|
|
15
|
+
"flow-step-space-logic": "0.1.0",
|
|
16
|
+
"instant-ctrl-flow-contract": "0.1.1",
|
|
17
|
+
"instant-ctrl-flow-logic": "0.1.3",
|
|
18
|
+
"work-ctrl-flow-contract": "0.1.2"
|
|
18
19
|
},
|
|
19
20
|
"files": [
|
|
20
21
|
"src"
|
package/src/instance.ts
CHANGED
|
@@ -8,6 +8,7 @@ import fs from 'node:fs';
|
|
|
8
8
|
import path from 'node:path';
|
|
9
9
|
import { createHash, randomUUID } from 'node:crypto';
|
|
10
10
|
import { loadFlowBundle } from 'instant-ctrl-flow-logic/filesystem';
|
|
11
|
+
import { assembleDefinitionStepProfileDirectory } from 'flow-step-space-logic/filesystem';
|
|
11
12
|
import {
|
|
12
13
|
FLOW_INSTANCE_SCHEMA_VERSION,
|
|
13
14
|
type FlowDefinitionProvenance,
|
|
@@ -686,6 +687,25 @@ export function annotateFlowFile(instanceDir: string, view: TreeViewAnnotation):
|
|
|
686
687
|
const tmp = file + '.tmp';
|
|
687
688
|
fs.writeFileSync(tmp, text);
|
|
688
689
|
fs.renameSync(tmp, file);
|
|
690
|
+
|
|
691
|
+
const assembled = assembleDefinitionStepProfileDirectory(instanceDir, 'WorkCtrlFlow');
|
|
692
|
+
if (!assembled.forest || assembled.diagnostics.length > 0) return;
|
|
693
|
+
for (const stepId of assembled.forest.stepOrder) {
|
|
694
|
+
const stepFile = path.join(instanceDir, ...assembled.forest.steps[stepId].sourceRef.split('/'));
|
|
695
|
+
let stepText = stripViewAttrs(fs.readFileSync(stepFile, 'utf8'));
|
|
696
|
+
const coreOffset = stepText.indexOf('<Core');
|
|
697
|
+
const prefix = coreOffset >= 0 ? stepText.slice(0, coreOffset) : '';
|
|
698
|
+
let coreText = coreOffset >= 0 ? stepText.slice(coreOffset) : stepText;
|
|
699
|
+
for (const [id, annotation] of Object.entries(view.nodes)) {
|
|
700
|
+
const entries: Record<string, string | number> = { status: annotation.status };
|
|
701
|
+
if (annotation.iterations !== undefined) entries.iterations = annotation.iterations;
|
|
702
|
+
coreText = injectAttrs(coreText, id, entries);
|
|
703
|
+
}
|
|
704
|
+
stepText = `${prefix}${coreText}`;
|
|
705
|
+
const stepTmp = `${stepFile}.tmp`;
|
|
706
|
+
fs.writeFileSync(stepTmp, stepText);
|
|
707
|
+
fs.renameSync(stepTmp, stepFile);
|
|
708
|
+
}
|
|
689
709
|
}
|
|
690
710
|
|
|
691
711
|
/** BPCtrlFlow:把任务状态机现值同步进实例 task.space.xnl(替换既有 status 值;真源在 TaskSpaceStore) */
|