@vertesia/workflow 0.52.0 → 0.55.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/lib/cjs/activities/createDocumentFromOther.js +1 -1
- package/lib/cjs/activities/executeInteraction.js +29 -15
- package/lib/cjs/activities/executeInteraction.js.map +1 -1
- package/lib/cjs/activities/extractDocumentText.js +33 -30
- package/lib/cjs/activities/extractDocumentText.js.map +1 -1
- package/lib/cjs/activities/generateEmbeddings.js +1 -1
- package/lib/cjs/activities/generateEmbeddings.js.map +1 -1
- package/lib/cjs/activities/generateImageRendition.js +31 -11
- package/lib/cjs/activities/generateImageRendition.js.map +1 -1
- package/lib/cjs/activities/generateOrAssignContentType.js +25 -12
- package/lib/cjs/activities/generateOrAssignContentType.js.map +1 -1
- package/lib/cjs/activities/getObjectFromStore.js +1 -1
- package/lib/cjs/activities/handleError.js +22 -0
- package/lib/cjs/activities/handleError.js.map +1 -0
- package/lib/cjs/activities/index-dsl.js +3 -1
- package/lib/cjs/activities/index-dsl.js.map +1 -1
- package/lib/cjs/activities/index.js +0 -1
- package/lib/cjs/activities/index.js.map +1 -1
- package/lib/cjs/activities/media/processPdfWithTextract.js +4 -4
- package/lib/cjs/activities/media/transcribeMediaWithGladia.js +1 -1
- package/lib/cjs/activities/media/transcribeMediaWithGladia.js.map +1 -1
- package/lib/cjs/activities/setDocumentStatus.js +1 -1
- package/lib/cjs/conversion/TextractProcessor.js +9 -9
- package/lib/cjs/conversion/image.js +6 -2
- package/lib/cjs/conversion/image.js.map +1 -1
- package/lib/cjs/conversion/markitdown.js +42 -0
- package/lib/cjs/conversion/markitdown.js.map +1 -0
- package/lib/cjs/conversion/mutool.js +1 -1
- package/lib/cjs/conversion/pandoc.js +9 -9
- package/lib/cjs/conversion/pandoc.js.map +1 -1
- package/lib/cjs/dsl/dsl-workflow.js +59 -11
- package/lib/cjs/dsl/dsl-workflow.js.map +1 -1
- package/lib/cjs/dsl/vars.js +6 -6
- package/lib/cjs/dsl/vars.js.map +1 -1
- package/lib/cjs/index.js +1 -1
- package/lib/cjs/iterative-generation/activities/extractToc.js +1 -1
- package/lib/cjs/iterative-generation/activities/extractToc.js.map +1 -1
- package/lib/cjs/iterative-generation/activities/generatePart.js +2 -2
- package/lib/cjs/iterative-generation/activities/generatePart.js.map +1 -1
- package/lib/cjs/iterative-generation/activities/generateToc.js +1 -1
- package/lib/cjs/iterative-generation/activities/generateToc.js.map +1 -1
- package/lib/cjs/iterative-generation/iterativeGenerationWorkflow.js +1 -1
- package/lib/cjs/iterative-generation/iterativeGenerationWorkflow.js.map +1 -1
- package/lib/cjs/iterative-generation/utils.js +4 -4
- package/lib/cjs/iterative-generation/utils.js.map +1 -1
- package/lib/esm/activities/createDocumentFromOther.js +1 -1
- package/lib/esm/activities/executeInteraction.js +31 -17
- package/lib/esm/activities/executeInteraction.js.map +1 -1
- package/lib/esm/activities/extractDocumentText.js +39 -36
- package/lib/esm/activities/extractDocumentText.js.map +1 -1
- package/lib/esm/activities/generateEmbeddings.js +1 -1
- package/lib/esm/activities/generateEmbeddings.js.map +1 -1
- package/lib/esm/activities/generateImageRendition.js +31 -11
- package/lib/esm/activities/generateImageRendition.js.map +1 -1
- package/lib/esm/activities/generateOrAssignContentType.js +25 -12
- package/lib/esm/activities/generateOrAssignContentType.js.map +1 -1
- package/lib/esm/activities/getObjectFromStore.js +1 -1
- package/lib/esm/activities/handleError.js +19 -0
- package/lib/esm/activities/handleError.js.map +1 -0
- package/lib/esm/activities/index-dsl.js +1 -0
- package/lib/esm/activities/index-dsl.js.map +1 -1
- package/lib/esm/activities/index.js +0 -1
- package/lib/esm/activities/index.js.map +1 -1
- package/lib/esm/activities/media/processPdfWithTextract.js +4 -4
- package/lib/esm/activities/media/transcribeMediaWithGladia.js +1 -1
- package/lib/esm/activities/media/transcribeMediaWithGladia.js.map +1 -1
- package/lib/esm/activities/setDocumentStatus.js +1 -1
- package/lib/esm/conversion/TextractProcessor.js +9 -9
- package/lib/esm/conversion/image.js +6 -2
- package/lib/esm/conversion/image.js.map +1 -1
- package/lib/esm/conversion/markitdown.js +36 -0
- package/lib/esm/conversion/markitdown.js.map +1 -0
- package/lib/esm/conversion/mutool.js +1 -1
- package/lib/esm/conversion/pandoc.js +11 -11
- package/lib/esm/conversion/pandoc.js.map +1 -1
- package/lib/esm/dsl/dsl-workflow.js +60 -12
- package/lib/esm/dsl/dsl-workflow.js.map +1 -1
- package/lib/esm/dsl/vars.js +6 -6
- package/lib/esm/dsl/vars.js.map +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/esm/iterative-generation/activities/extractToc.js +1 -1
- package/lib/esm/iterative-generation/activities/extractToc.js.map +1 -1
- package/lib/esm/iterative-generation/activities/generatePart.js +2 -2
- package/lib/esm/iterative-generation/activities/generatePart.js.map +1 -1
- package/lib/esm/iterative-generation/activities/generateToc.js +1 -1
- package/lib/esm/iterative-generation/activities/generateToc.js.map +1 -1
- package/lib/esm/iterative-generation/iterativeGenerationWorkflow.js +1 -1
- package/lib/esm/iterative-generation/iterativeGenerationWorkflow.js.map +1 -1
- package/lib/esm/iterative-generation/utils.js +4 -4
- package/lib/esm/iterative-generation/utils.js.map +1 -1
- package/lib/types/activities/createDocumentFromOther.d.ts +1 -1
- package/lib/types/activities/executeInteraction.d.ts +4 -4
- package/lib/types/activities/executeInteraction.d.ts.map +1 -1
- package/lib/types/activities/extractDocumentText.d.ts +3 -3
- package/lib/types/activities/extractDocumentText.d.ts.map +1 -1
- package/lib/types/activities/generateImageRendition.d.ts +1 -1
- package/lib/types/activities/generateImageRendition.d.ts.map +1 -1
- package/lib/types/activities/generateOrAssignContentType.d.ts +1 -1
- package/lib/types/activities/generateOrAssignContentType.d.ts.map +1 -1
- package/lib/types/activities/getObjectFromStore.d.ts +1 -1
- package/lib/types/activities/handleError.d.ts +6 -0
- package/lib/types/activities/handleError.d.ts.map +1 -0
- package/lib/types/activities/index-dsl.d.ts +1 -0
- package/lib/types/activities/index-dsl.d.ts.map +1 -1
- package/lib/types/activities/index.d.ts +0 -1
- package/lib/types/activities/index.d.ts.map +1 -1
- package/lib/types/activities/setDocumentStatus.d.ts +1 -1
- package/lib/types/conversion/image.d.ts.map +1 -1
- package/lib/types/conversion/markitdown.d.ts +2 -0
- package/lib/types/conversion/markitdown.d.ts.map +1 -0
- package/lib/types/conversion/mutool.d.ts +1 -1
- package/lib/types/conversion/pandoc.d.ts +1 -1
- package/lib/types/conversion/pandoc.d.ts.map +1 -1
- package/lib/types/dsl/dsl-workflow.d.ts +1 -1
- package/lib/types/dsl/dsl-workflow.d.ts.map +1 -1
- package/lib/types/dsl/vars.d.ts +2 -2
- package/lib/types/index.d.ts +1 -1
- package/lib/types/iterative-generation/types.d.ts +3 -3
- package/lib/types/iterative-generation/types.d.ts.map +1 -1
- package/lib/workflows-bundle.js +396 -94
- package/package.json +5 -4
- package/src/activities/createDocumentFromOther.ts +1 -1
- package/src/activities/executeInteraction.ts +66 -39
- package/src/activities/extractDocumentText.ts +67 -51
- package/src/activities/generateEmbeddings.ts +1 -1
- package/src/activities/generateImageRendition.ts +35 -14
- package/src/activities/generateOrAssignContentType.ts +52 -26
- package/src/activities/getObjectFromStore.ts +1 -1
- package/src/activities/handleError.ts +25 -0
- package/src/activities/index-dsl.ts +1 -0
- package/src/activities/index.ts +0 -1
- package/src/activities/media/processPdfWithTextract.ts +4 -4
- package/src/activities/media/transcribeMediaWithGladia.ts +1 -1
- package/src/activities/setDocumentStatus.ts +1 -1
- package/src/conversion/TextractProcessor.ts +9 -9
- package/src/conversion/image.ts +8 -2
- package/src/conversion/markitdown.ts +41 -0
- package/src/conversion/mutool.ts +1 -1
- package/src/conversion/pandoc.test.ts +2 -2
- package/src/conversion/pandoc.ts +38 -42
- package/src/dsl/dsl-workflow.ts +80 -12
- package/src/dsl/validation.test.ts +2 -2
- package/src/dsl/vars.test.ts +1 -1
- package/src/dsl/vars.ts +6 -6
- package/src/dsl/workflow-exec-child.test.ts +14 -4
- package/src/dsl/workflow-fetch.test.ts +1 -1
- package/src/dsl/workflow-import.test.ts +1 -1
- package/src/dsl/workflow.test.ts +12 -2
- package/src/index.ts +1 -1
- package/src/iterative-generation/activities/extractToc.ts +1 -1
- package/src/iterative-generation/activities/generatePart.ts +2 -2
- package/src/iterative-generation/activities/generateToc.ts +1 -1
- package/src/iterative-generation/iterativeGenerationWorkflow.ts +1 -1
- package/src/iterative-generation/types.ts +4 -4
- package/src/iterative-generation/utils.ts +4 -4
@@ -18,7 +18,7 @@ describe('workflow validation', () => {
|
|
18
18
|
expect(errors.length).toBe(1);
|
19
19
|
})
|
20
20
|
|
21
|
-
test('activities
|
21
|
+
test('activities should be an array', () => {
|
22
22
|
const workflow: any = {
|
23
23
|
name: "test",
|
24
24
|
activities: {}
|
@@ -81,7 +81,7 @@ describe('workflow validation', () => {
|
|
81
81
|
expect(errors.length).toBe(0);
|
82
82
|
})
|
83
83
|
|
84
|
-
test('import unknown
|
84
|
+
test('import unknown imported var through expressions', () => {
|
85
85
|
const workflow: any = {
|
86
86
|
name: "test",
|
87
87
|
vars: { "foo": true },
|
package/src/dsl/vars.test.ts
CHANGED
@@ -125,7 +125,7 @@ describe('Workflow vars', () => {
|
|
125
125
|
expect(resolved.prompt_data.message).toBe("hello");
|
126
126
|
expect(resolved.data2).toBeTypeOf("object");
|
127
127
|
expect(resolved.data2.message).toBe("hello");
|
128
|
-
expect(resolved.
|
128
|
+
expect(resolved.unknown).toBeUndefined();
|
129
129
|
});
|
130
130
|
|
131
131
|
|
package/src/dsl/vars.ts
CHANGED
@@ -20,9 +20,9 @@ export function splitPath(path: string) {
|
|
20
20
|
|
21
21
|
/**
|
22
22
|
* Get the property named by "name" of the given object
|
23
|
-
* If an array is
|
23
|
+
* If an array is indexed using a string key then a map is done and an array with the content of the properties with that name are returned
|
24
24
|
* Ex: docs.text => will return an array of text properties of the docs array
|
25
|
-
* @param object the
|
25
|
+
* @param object the object
|
26
26
|
* @param name the name of the property.
|
27
27
|
* @returns the property value
|
28
28
|
*/
|
@@ -128,7 +128,7 @@ export class Vars {
|
|
128
128
|
map: Record<string, any>;
|
129
129
|
/**
|
130
130
|
* This property is used when resolving params. It contains the list of references that should not be resolved to their value
|
131
|
-
* but instead they need to return the string representation of the expression to
|
131
|
+
* but instead they need to return the string representation of the expression to be able to regenerate another Vars instance with the same expression
|
132
132
|
*/
|
133
133
|
//TODO this feature is no more used - it was replaced by importVars so we can now delete `preserveRefs`
|
134
134
|
preserveRefs: Set<string> | undefined;
|
@@ -154,7 +154,7 @@ export class Vars {
|
|
154
154
|
}
|
155
155
|
|
156
156
|
/**
|
157
|
-
* Set a literal value (
|
157
|
+
* Set a literal value (cannot set a ref)
|
158
158
|
* To add refs use `append()`
|
159
159
|
* @param name
|
160
160
|
* @param value
|
@@ -291,7 +291,7 @@ export class Vars {
|
|
291
291
|
}
|
292
292
|
|
293
293
|
getUnknownReferences(obj: any) {
|
294
|
-
const visitor = new
|
294
|
+
const visitor = new UnknownReferencesVisitor(this);
|
295
295
|
new ObjectWalker().walk(obj, visitor);
|
296
296
|
return visitor.result;
|
297
297
|
}
|
@@ -311,7 +311,7 @@ function addImportVar(varPath: string, asName: string | undefined, vars: Vars, r
|
|
311
311
|
}
|
312
312
|
|
313
313
|
|
314
|
-
class
|
314
|
+
class UnknownReferencesVisitor implements ObjectVisitor {
|
315
315
|
|
316
316
|
result: { name: string, expression: string }[] = [];
|
317
317
|
|
@@ -1,6 +1,7 @@
|
|
1
|
-
import
|
1
|
+
import * as protos from '@temporalio/proto';
|
2
2
|
import { TestWorkflowEnvironment } from '@temporalio/testing';
|
3
3
|
import { Worker } from '@temporalio/worker';
|
4
|
+
import { ContentEventName, DSLActivityExecutionPayload, DSLWorkflowExecutionPayload, DSLWorkflowStep } from '@vertesia/common';
|
4
5
|
import { afterAll, beforeAll, describe, expect, test } from 'vitest';
|
5
6
|
import { dslWorkflow } from './dsl-workflow.js';
|
6
7
|
import { setupActivity } from './setup/ActivityContext.js';
|
@@ -86,12 +87,21 @@ const steps2: DSLWorkflowStep[] = [
|
|
86
87
|
// ========== test env setup ==========
|
87
88
|
|
88
89
|
|
89
|
-
describe('DSL Workflow with
|
90
|
+
describe('DSL Workflow with child workflows', () => {
|
90
91
|
|
91
92
|
let testEnv: TestWorkflowEnvironment;
|
92
93
|
|
93
94
|
beforeAll(async () => {
|
94
95
|
testEnv = await TestWorkflowEnvironment.createLocal();
|
96
|
+
const { connection } = testEnv;
|
97
|
+
await connection.operatorService.addSearchAttributes({
|
98
|
+
namespace: 'default',
|
99
|
+
searchAttributes: {
|
100
|
+
AccountId: protos.temporal.api.enums.v1.IndexedValueType.INDEXED_VALUE_TYPE_KEYWORD,
|
101
|
+
DocumentId: protos.temporal.api.enums.v1.IndexedValueType.INDEXED_VALUE_TYPE_KEYWORD,
|
102
|
+
ProjectId: protos.temporal.api.enums.v1.IndexedValueType.INDEXED_VALUE_TYPE_KEYWORD,
|
103
|
+
},
|
104
|
+
});
|
95
105
|
});
|
96
106
|
|
97
107
|
afterAll(async () => {
|
@@ -122,7 +132,7 @@ describe('DSL Workflow with chld workflows', () => {
|
|
122
132
|
auth_token: 'test',
|
123
133
|
config: {
|
124
134
|
studio_url: process.env.CP_STUDIO_URL || "http://localhost:8081",
|
125
|
-
store_url: process.env.
|
135
|
+
store_url: process.env.CP_STORE_URL || "http://localhost:8082",
|
126
136
|
},
|
127
137
|
workflow: {
|
128
138
|
steps: steps1,
|
@@ -167,7 +177,7 @@ describe('DSL Workflow with chld workflows', () => {
|
|
167
177
|
auth_token: 'test',
|
168
178
|
config: {
|
169
179
|
studio_url: process.env.CP_STUDIO_URL || "http://localhost:8081",
|
170
|
-
store_url: process.env.
|
180
|
+
store_url: process.env.CP_STORE_URL || "http://localhost:8082",
|
171
181
|
},
|
172
182
|
workflow: {
|
173
183
|
steps: steps2,
|
@@ -110,7 +110,7 @@ describe('DSL Workflow', () => {
|
|
110
110
|
auth_token: 'test',
|
111
111
|
config: {
|
112
112
|
studio_url: process.env.CP_STUDIO_URL || "http://localhost:8081",
|
113
|
-
store_url: process.env.
|
113
|
+
store_url: process.env.CP_STORE_URL || "http://localhost:8082",
|
114
114
|
},
|
115
115
|
workflow: {
|
116
116
|
activities,
|
@@ -64,7 +64,7 @@ describe('DSL Workflow import vars', () => {
|
|
64
64
|
auth_token: 'test',
|
65
65
|
config: {
|
66
66
|
studio_url: process.env.CP_STUDIO_URL || "http://localhost:8081",
|
67
|
-
store_url: process.env.
|
67
|
+
store_url: process.env.CP_STORE_URL || "http://localhost:8082",
|
68
68
|
},
|
69
69
|
workflow: {
|
70
70
|
activities,
|
package/src/dsl/workflow.test.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
import
|
1
|
+
import * as protos from '@temporalio/proto';
|
2
2
|
import { TestWorkflowEnvironment } from '@temporalio/testing';
|
3
3
|
import { Worker } from '@temporalio/worker';
|
4
|
+
import { ContentEventName, DSLActivityExecutionPayload, DSLActivitySpec, DSLWorkflowExecutionPayload } from '@vertesia/common';
|
4
5
|
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
|
5
6
|
import { dslWorkflow } from './dsl-workflow.js';
|
6
7
|
import { setupActivity } from "./setup/ActivityContext.js";
|
@@ -52,6 +53,15 @@ describe('DSL Workflow', () => {
|
|
52
53
|
|
53
54
|
beforeAll(async () => {
|
54
55
|
testEnv = await TestWorkflowEnvironment.createLocal();
|
56
|
+
const { connection } = testEnv;
|
57
|
+
await connection.operatorService.addSearchAttributes({
|
58
|
+
namespace: 'default',
|
59
|
+
searchAttributes: {
|
60
|
+
AccountId: protos.temporal.api.enums.v1.IndexedValueType.INDEXED_VALUE_TYPE_KEYWORD,
|
61
|
+
DocumentId: protos.temporal.api.enums.v1.IndexedValueType.INDEXED_VALUE_TYPE_KEYWORD,
|
62
|
+
ProjectId: protos.temporal.api.enums.v1.IndexedValueType.INDEXED_VALUE_TYPE_KEYWORD,
|
63
|
+
},
|
64
|
+
});
|
55
65
|
});
|
56
66
|
|
57
67
|
afterAll(async () => {
|
@@ -82,7 +92,7 @@ describe('DSL Workflow', () => {
|
|
82
92
|
auth_token: 'test',
|
83
93
|
config: {
|
84
94
|
studio_url: process.env.CP_STUDIO_URL || "http://localhost:8081",
|
85
|
-
store_url: process.env.
|
95
|
+
store_url: process.env.CP_STORE_URL || "http://localhost:8082",
|
86
96
|
},
|
87
97
|
workflow: {
|
88
98
|
activities,
|
package/src/index.ts
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
* Modify the `./activities/index.ts` if you want to modify activity exports
|
4
4
|
* 2. Workflows are exported through the '/workflows' named export in package.json.
|
5
5
|
* Modify the `./workflows.ts` file if you want to modify workflow exports
|
6
|
-
* 3. Here we export the API to be used to validate workflows and the types
|
6
|
+
* 3. Here we export the API to be used to validate workflows and the types required to create workflow TS definitions.
|
7
7
|
*/
|
8
8
|
|
9
9
|
//TODO remove this - it is only for backward compat - iot is used from old workflows
|
@@ -40,7 +40,7 @@ export async function it_gen_extractToc(payload: WorkflowExecutionPayload): Prom
|
|
40
40
|
await buildAndPublishMemoryPack(client, `${vars.memory}/output`, async () => {
|
41
41
|
return {
|
42
42
|
toc,
|
43
|
-
|
43
|
+
lastProcessedPart: undefined, // the part index (a number array)
|
44
44
|
previouslyGenerated: ""
|
45
45
|
} as OutputMemoryMeta
|
46
46
|
});
|
@@ -32,7 +32,7 @@ export async function it_gen_generatePart(payload: WorkflowExecutionPayload, pat
|
|
32
32
|
|
33
33
|
const content = await loadGeneratedContent(outMemory);
|
34
34
|
|
35
|
-
let previously_generated = getPreviouslyGeneratedContent(content, !part, vars.
|
35
|
+
let previously_generated = getPreviouslyGeneratedContent(content, !part, vars.remembrance_strategy);
|
36
36
|
|
37
37
|
if (!part) { // a new section
|
38
38
|
content.push({
|
@@ -58,7 +58,7 @@ export async function it_gen_generatePart(payload: WorkflowExecutionPayload, pat
|
|
58
58
|
|
59
59
|
const result = r.result as string;
|
60
60
|
content[content.length - 1].content += result;
|
61
|
-
meta.
|
61
|
+
meta.lastProcessedPart = path;
|
62
62
|
await buildAndPublishMemoryPack(client, `${memory}/output`, async ({ copyText }) => {
|
63
63
|
copyText(JSON.stringify(content, null, 2), "content.json");
|
64
64
|
return meta;
|
@@ -89,7 +89,7 @@ export async function it_gen_generateToc(payload: WorkflowExecutionPayload): Pro
|
|
89
89
|
await buildAndPublishMemoryPack(client, `${vars.memory}/output`, async () => {
|
90
90
|
return {
|
91
91
|
toc,
|
92
|
-
|
92
|
+
lastProcessedPart: undefined, // the part index (a number array)
|
93
93
|
previouslyGenerated: ""
|
94
94
|
} as OutputMemoryMeta
|
95
95
|
});
|
@@ -30,7 +30,7 @@ export async function iterativeGenerationWorkflow(payload: WorkflowExecutionPayl
|
|
30
30
|
}
|
31
31
|
|
32
32
|
// extractToc tries to extract the toc from the input memory pack (toc.json or toc.yaml)
|
33
|
-
// the generateToc activity is
|
33
|
+
// the generateToc activity is returning the toc hierarchy.
|
34
34
|
// It doesn't include extra TOC details like description etc.
|
35
35
|
// To minimize the payload size only the hierarchy and the section/part names are returned
|
36
36
|
let toc = await it_gen_extractToc(payload);
|
@@ -13,7 +13,7 @@ export interface IterativeGenerationPayload {
|
|
13
13
|
// the main interaction will only be used to prepare the iteration (to generate the TOC)
|
14
14
|
// otherwise it will be used for the iterative generation too.
|
15
15
|
interaction: string;
|
16
|
-
// if defined this will be used for the iterative interaction which will
|
16
|
+
// if defined this will be used for the iterative interaction which will generate parts.
|
17
17
|
// otherwise the main interaction will be used for iterative generation.
|
18
18
|
iterative_interaction?: string;
|
19
19
|
// the environment to use
|
@@ -34,10 +34,10 @@ export interface IterativeGenerationPayload {
|
|
34
34
|
* If not set to "none" the previously generated content will be passed to the iteration.
|
35
35
|
* If not set at all defaults to "section".
|
36
36
|
* If "section" is used only the section content previously generated will be passed to the next iteration.
|
37
|
-
* If "document" is used the whole
|
37
|
+
* If "document" is used the whole previously generated document content will be passed to the next iteration.
|
38
38
|
* Defaults to section.
|
39
39
|
*/
|
40
|
-
|
40
|
+
remembrance_strategy?: "document" | "section" | "none";
|
41
41
|
/**
|
42
42
|
* If present will save sections in files using the pattern
|
43
43
|
* The pattern must include a placeholder for the section id: %id.
|
@@ -88,7 +88,7 @@ export interface TocIndex {
|
|
88
88
|
export interface OutputMemoryMeta {
|
89
89
|
toc: Toc;
|
90
90
|
previouslyGenerated: string;
|
91
|
-
|
91
|
+
lastProcessedPart?: number[] | undefined;
|
92
92
|
}
|
93
93
|
|
94
94
|
export interface Section {
|
@@ -79,19 +79,19 @@ export function getPreviousPathIndex(toc: Toc, pathIndex: number[]): number[] |
|
|
79
79
|
|
80
80
|
|
81
81
|
export function expectMemoryIsConsistent(meta: OutputMemoryMeta, pathIndex: number[]) {
|
82
|
-
const metaLastProcessedPart = meta.
|
82
|
+
const metaLastProcessedPart = meta.lastProcessedPart;
|
83
83
|
if (!metaLastProcessedPart) {
|
84
84
|
if (pathIndex.length > 1 && pathIndex[0] !== 0) {
|
85
|
-
throw ApplicationFailure.nonRetryable('Memory last processed part is not
|
85
|
+
throw ApplicationFailure.nonRetryable('Memory last processed part is not consistent with the workflow.', 'MemoryPackNotConsistent', { currentIndex: pathIndex, expectedPreviousIndex: [pathIndex[0], pathIndex[1] - 1], previousIndex: metaLastProcessedPart });
|
86
86
|
} else {
|
87
87
|
return;
|
88
88
|
}
|
89
89
|
}
|
90
90
|
const prevPathIndex = getPreviousPathIndex(meta.toc, pathIndex);
|
91
91
|
if (!prevPathIndex) {
|
92
|
-
throw ApplicationFailure.nonRetryable('Memory last processed part is not
|
92
|
+
throw ApplicationFailure.nonRetryable('Memory last processed part is not consistent with the workflow', 'MemoryPackNotConsistent', { currentIndex: pathIndex, expectedPreviousIndex: prevPathIndex, previousIndex: metaLastProcessedPart });
|
93
93
|
} else if (!isSamePartIndex(prevPathIndex, metaLastProcessedPart)) {
|
94
|
-
throw ApplicationFailure.nonRetryable('Memory last processed part is not
|
94
|
+
throw ApplicationFailure.nonRetryable('Memory last processed part is not consistent with the workflow', 'MemoryPackNotConsistent', { currentIndex: pathIndex, expectedPreviousIndex: prevPathIndex, previousIndex: meta.lastProcessedPart });
|
95
95
|
}
|
96
96
|
}
|
97
97
|
|