@vertesia/workflow 0.24.0-dev.202601221707
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 +13 -0
- package/README.md +65 -0
- package/bin/bundle-workflows.mjs +39 -0
- package/lib/cjs/activities/advanced/createDocumentTypeFromInteractionRun.js +33 -0
- package/lib/cjs/activities/advanced/createDocumentTypeFromInteractionRun.js.map +1 -0
- package/lib/cjs/activities/advanced/createOrUpdateDocumentFromInteractionRun.js +73 -0
- package/lib/cjs/activities/advanced/createOrUpdateDocumentFromInteractionRun.js.map +1 -0
- package/lib/cjs/activities/advanced/updateDocumentFromInteractionRun.js +19 -0
- package/lib/cjs/activities/advanced/updateDocumentFromInteractionRun.js.map +1 -0
- package/lib/cjs/activities/chunkDocument.js +85 -0
- package/lib/cjs/activities/chunkDocument.js.map +1 -0
- package/lib/cjs/activities/copyParentArtifacts.js +127 -0
- package/lib/cjs/activities/copyParentArtifacts.js.map +1 -0
- package/lib/cjs/activities/createDocumentFromOther.js +64 -0
- package/lib/cjs/activities/createDocumentFromOther.js.map +1 -0
- package/lib/cjs/activities/executeInteraction.js +194 -0
- package/lib/cjs/activities/executeInteraction.js.map +1 -0
- package/lib/cjs/activities/extractDocumentText.js +156 -0
- package/lib/cjs/activities/extractDocumentText.js.map +1 -0
- package/lib/cjs/activities/generateDocumentProperties.js +83 -0
- package/lib/cjs/activities/generateDocumentProperties.js.map +1 -0
- package/lib/cjs/activities/generateEmbeddings.js +257 -0
- package/lib/cjs/activities/generateEmbeddings.js.map +1 -0
- package/lib/cjs/activities/generateOrAssignContentType.js +125 -0
- package/lib/cjs/activities/generateOrAssignContentType.js.map +1 -0
- package/lib/cjs/activities/getObjectFromStore.js +20 -0
- package/lib/cjs/activities/getObjectFromStore.js.map +1 -0
- package/lib/cjs/activities/handleError.js +22 -0
- package/lib/cjs/activities/handleError.js.map +1 -0
- package/lib/cjs/activities/index-dsl.js +51 -0
- package/lib/cjs/activities/index-dsl.js.map +1 -0
- package/lib/cjs/activities/index.js +21 -0
- package/lib/cjs/activities/index.js.map +1 -0
- package/lib/cjs/activities/media/prepareAudio.js +239 -0
- package/lib/cjs/activities/media/prepareAudio.js.map +1 -0
- package/lib/cjs/activities/media/prepareVideo.js +429 -0
- package/lib/cjs/activities/media/prepareVideo.js.map +1 -0
- package/lib/cjs/activities/media/processPdfWithTextract.js +103 -0
- package/lib/cjs/activities/media/processPdfWithTextract.js.map +1 -0
- package/lib/cjs/activities/media/saveGladiaTranscription.js +81 -0
- package/lib/cjs/activities/media/saveGladiaTranscription.js.map +1 -0
- package/lib/cjs/activities/media/transcribeMediaWithGladia.js +82 -0
- package/lib/cjs/activities/media/transcribeMediaWithGladia.js.map +1 -0
- package/lib/cjs/activities/notifyWebhook.js +158 -0
- package/lib/cjs/activities/notifyWebhook.js.map +1 -0
- package/lib/cjs/activities/rateLimiter.js +30 -0
- package/lib/cjs/activities/rateLimiter.js.map +1 -0
- package/lib/cjs/activities/renditions/generateImageRendition.js +66 -0
- package/lib/cjs/activities/renditions/generateImageRendition.js.map +1 -0
- package/lib/cjs/activities/renditions/generateVideoRendition.js +200 -0
- package/lib/cjs/activities/renditions/generateVideoRendition.js.map +1 -0
- package/lib/cjs/activities/setDocumentStatus.js +15 -0
- package/lib/cjs/activities/setDocumentStatus.js.map +1 -0
- package/lib/cjs/conversion/TextractProcessor.js +417 -0
- package/lib/cjs/conversion/TextractProcessor.js.map +1 -0
- package/lib/cjs/conversion/image.js +149 -0
- package/lib/cjs/conversion/image.js.map +1 -0
- package/lib/cjs/conversion/markitdown.js +42 -0
- package/lib/cjs/conversion/markitdown.js.map +1 -0
- package/lib/cjs/conversion/mutool.js +147 -0
- package/lib/cjs/conversion/mutool.js.map +1 -0
- package/lib/cjs/conversion/pandoc.js +39 -0
- package/lib/cjs/conversion/pandoc.js.map +1 -0
- package/lib/cjs/dsl/conditions.js +81 -0
- package/lib/cjs/dsl/conditions.js.map +1 -0
- package/lib/cjs/dsl/dsl-workflow.js +343 -0
- package/lib/cjs/dsl/dsl-workflow.js.map +1 -0
- package/lib/cjs/dsl/dslProxyActivities.js +23 -0
- package/lib/cjs/dsl/dslProxyActivities.js.map +1 -0
- package/lib/cjs/dsl/projections.js +59 -0
- package/lib/cjs/dsl/projections.js.map +1 -0
- package/lib/cjs/dsl/setup/ActivityContext.js +122 -0
- package/lib/cjs/dsl/setup/ActivityContext.js.map +1 -0
- package/lib/cjs/dsl/setup/fetch/DataProvider.js +51 -0
- package/lib/cjs/dsl/setup/fetch/DataProvider.js.map +1 -0
- package/lib/cjs/dsl/setup/fetch/index.js +16 -0
- package/lib/cjs/dsl/setup/fetch/index.js.map +1 -0
- package/lib/cjs/dsl/setup/fetch/providers.js +67 -0
- package/lib/cjs/dsl/setup/fetch/providers.js.map +1 -0
- package/lib/cjs/dsl/test/test-child-workflow.js +10 -0
- package/lib/cjs/dsl/test/test-child-workflow.js.map +1 -0
- package/lib/cjs/dsl/validation.js +122 -0
- package/lib/cjs/dsl/validation.js.map +1 -0
- package/lib/cjs/dsl/vars.js +341 -0
- package/lib/cjs/dsl/vars.js.map +1 -0
- package/lib/cjs/dsl/walk.js +100 -0
- package/lib/cjs/dsl/walk.js.map +1 -0
- package/lib/cjs/dsl.js +20 -0
- package/lib/cjs/dsl.js.map +1 -0
- package/lib/cjs/errors.js +79 -0
- package/lib/cjs/errors.js.map +1 -0
- package/lib/cjs/index.js +56 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/iterative-generation/activities/extractToc.js +47 -0
- package/lib/cjs/iterative-generation/activities/extractToc.js.map +1 -0
- package/lib/cjs/iterative-generation/activities/finalizeOutput.js +72 -0
- package/lib/cjs/iterative-generation/activities/finalizeOutput.js.map +1 -0
- package/lib/cjs/iterative-generation/activities/generatePart.js +78 -0
- package/lib/cjs/iterative-generation/activities/generatePart.js.map +1 -0
- package/lib/cjs/iterative-generation/activities/generateToc.js +86 -0
- package/lib/cjs/iterative-generation/activities/generateToc.js.map +1 -0
- package/lib/cjs/iterative-generation/activities/index.js +12 -0
- package/lib/cjs/iterative-generation/activities/index.js.map +1 -0
- package/lib/cjs/iterative-generation/iterativeGenerationWorkflow.js +56 -0
- package/lib/cjs/iterative-generation/iterativeGenerationWorkflow.js.map +1 -0
- package/lib/cjs/iterative-generation/types.js +5 -0
- package/lib/cjs/iterative-generation/types.js.map +1 -0
- package/lib/cjs/iterative-generation/utils.js +121 -0
- package/lib/cjs/iterative-generation/utils.js.map +1 -0
- package/lib/cjs/package.json +3 -0
- package/lib/cjs/result-types.js +10 -0
- package/lib/cjs/result-types.js.map +1 -0
- package/lib/cjs/system/notifyWebhookWorkflow.js +53 -0
- package/lib/cjs/system/notifyWebhookWorkflow.js.map +1 -0
- package/lib/cjs/system/recalculateEmbeddingsWorkflow.js +33 -0
- package/lib/cjs/system/recalculateEmbeddingsWorkflow.js.map +1 -0
- package/lib/cjs/utils/auth.js +15 -0
- package/lib/cjs/utils/auth.js.map +1 -0
- package/lib/cjs/utils/blobs.js +64 -0
- package/lib/cjs/utils/blobs.js.map +1 -0
- package/lib/cjs/utils/chunks.js +14 -0
- package/lib/cjs/utils/chunks.js.map +1 -0
- package/lib/cjs/utils/client.js +31 -0
- package/lib/cjs/utils/client.js.map +1 -0
- package/lib/cjs/utils/expand-vars.js +33 -0
- package/lib/cjs/utils/expand-vars.js.map +1 -0
- package/lib/cjs/utils/memory.js +65 -0
- package/lib/cjs/utils/memory.js.map +1 -0
- package/lib/cjs/utils/renditions.js +88 -0
- package/lib/cjs/utils/renditions.js.map +1 -0
- package/lib/cjs/utils/storage.js +54 -0
- package/lib/cjs/utils/storage.js.map +1 -0
- package/lib/cjs/utils/tokens.js +38 -0
- package/lib/cjs/utils/tokens.js.map +1 -0
- package/lib/cjs/vars.js +20 -0
- package/lib/cjs/vars.js.map +1 -0
- package/lib/cjs/workflows.js +15 -0
- package/lib/cjs/workflows.js.map +1 -0
- package/lib/esm/activities/advanced/createDocumentTypeFromInteractionRun.js +30 -0
- package/lib/esm/activities/advanced/createDocumentTypeFromInteractionRun.js.map +1 -0
- package/lib/esm/activities/advanced/createOrUpdateDocumentFromInteractionRun.js +70 -0
- package/lib/esm/activities/advanced/createOrUpdateDocumentFromInteractionRun.js.map +1 -0
- package/lib/esm/activities/advanced/updateDocumentFromInteractionRun.js +16 -0
- package/lib/esm/activities/advanced/updateDocumentFromInteractionRun.js.map +1 -0
- package/lib/esm/activities/chunkDocument.js +82 -0
- package/lib/esm/activities/chunkDocument.js.map +1 -0
- package/lib/esm/activities/copyParentArtifacts.js +124 -0
- package/lib/esm/activities/copyParentArtifacts.js.map +1 -0
- package/lib/esm/activities/createDocumentFromOther.js +58 -0
- package/lib/esm/activities/createDocumentFromOther.js.map +1 -0
- package/lib/esm/activities/executeInteraction.js +190 -0
- package/lib/esm/activities/executeInteraction.js.map +1 -0
- package/lib/esm/activities/extractDocumentText.js +153 -0
- package/lib/esm/activities/extractDocumentText.js.map +1 -0
- package/lib/esm/activities/generateDocumentProperties.js +80 -0
- package/lib/esm/activities/generateDocumentProperties.js.map +1 -0
- package/lib/esm/activities/generateEmbeddings.js +254 -0
- package/lib/esm/activities/generateEmbeddings.js.map +1 -0
- package/lib/esm/activities/generateOrAssignContentType.js +122 -0
- package/lib/esm/activities/generateOrAssignContentType.js.map +1 -0
- package/lib/esm/activities/getObjectFromStore.js +17 -0
- package/lib/esm/activities/getObjectFromStore.js.map +1 -0
- package/lib/esm/activities/handleError.js +19 -0
- package/lib/esm/activities/handleError.js.map +1 -0
- package/lib/esm/activities/index-dsl.js +25 -0
- package/lib/esm/activities/index-dsl.js.map +1 -0
- package/lib/esm/activities/index.js +5 -0
- package/lib/esm/activities/index.js.map +1 -0
- package/lib/esm/activities/media/prepareAudio.js +200 -0
- package/lib/esm/activities/media/prepareAudio.js.map +1 -0
- package/lib/esm/activities/media/prepareVideo.js +390 -0
- package/lib/esm/activities/media/prepareVideo.js.map +1 -0
- package/lib/esm/activities/media/processPdfWithTextract.js +99 -0
- package/lib/esm/activities/media/processPdfWithTextract.js.map +1 -0
- package/lib/esm/activities/media/saveGladiaTranscription.js +78 -0
- package/lib/esm/activities/media/saveGladiaTranscription.js.map +1 -0
- package/lib/esm/activities/media/transcribeMediaWithGladia.js +79 -0
- package/lib/esm/activities/media/transcribeMediaWithGladia.js.map +1 -0
- package/lib/esm/activities/notifyWebhook.js +155 -0
- package/lib/esm/activities/notifyWebhook.js.map +1 -0
- package/lib/esm/activities/rateLimiter.js +27 -0
- package/lib/esm/activities/rateLimiter.js.map +1 -0
- package/lib/esm/activities/renditions/generateImageRendition.js +63 -0
- package/lib/esm/activities/renditions/generateImageRendition.js.map +1 -0
- package/lib/esm/activities/renditions/generateVideoRendition.js +194 -0
- package/lib/esm/activities/renditions/generateVideoRendition.js.map +1 -0
- package/lib/esm/activities/setDocumentStatus.js +12 -0
- package/lib/esm/activities/setDocumentStatus.js.map +1 -0
- package/lib/esm/conversion/TextractProcessor.js +410 -0
- package/lib/esm/conversion/TextractProcessor.js.map +1 -0
- package/lib/esm/conversion/image.js +143 -0
- package/lib/esm/conversion/image.js.map +1 -0
- package/lib/esm/conversion/markitdown.js +36 -0
- package/lib/esm/conversion/markitdown.js.map +1 -0
- package/lib/esm/conversion/mutool.js +139 -0
- package/lib/esm/conversion/mutool.js.map +1 -0
- package/lib/esm/conversion/pandoc.js +36 -0
- package/lib/esm/conversion/pandoc.js.map +1 -0
- package/lib/esm/dsl/conditions.js +75 -0
- package/lib/esm/dsl/conditions.js.map +1 -0
- package/lib/esm/dsl/dsl-workflow.js +336 -0
- package/lib/esm/dsl/dsl-workflow.js.map +1 -0
- package/lib/esm/dsl/dslProxyActivities.js +20 -0
- package/lib/esm/dsl/dslProxyActivities.js.map +1 -0
- package/lib/esm/dsl/projections.js +55 -0
- package/lib/esm/dsl/projections.js.map +1 -0
- package/lib/esm/dsl/setup/ActivityContext.js +117 -0
- package/lib/esm/dsl/setup/ActivityContext.js.map +1 -0
- package/lib/esm/dsl/setup/fetch/DataProvider.js +47 -0
- package/lib/esm/dsl/setup/fetch/DataProvider.js.map +1 -0
- package/lib/esm/dsl/setup/fetch/index.js +12 -0
- package/lib/esm/dsl/setup/fetch/index.js.map +1 -0
- package/lib/esm/dsl/setup/fetch/providers.js +61 -0
- package/lib/esm/dsl/setup/fetch/providers.js.map +1 -0
- package/lib/esm/dsl/test/test-child-workflow.js +5 -0
- package/lib/esm/dsl/test/test-child-workflow.js.map +1 -0
- package/lib/esm/dsl/validation.js +118 -0
- package/lib/esm/dsl/validation.js.map +1 -0
- package/lib/esm/dsl/vars.js +335 -0
- package/lib/esm/dsl/vars.js.map +1 -0
- package/lib/esm/dsl/walk.js +96 -0
- package/lib/esm/dsl/walk.js.map +1 -0
- package/lib/esm/dsl.js +4 -0
- package/lib/esm/dsl.js.map +1 -0
- package/lib/esm/errors.js +69 -0
- package/lib/esm/errors.js.map +1 -0
- package/lib/esm/index.js +38 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/iterative-generation/activities/extractToc.js +44 -0
- package/lib/esm/iterative-generation/activities/extractToc.js.map +1 -0
- package/lib/esm/iterative-generation/activities/finalizeOutput.js +69 -0
- package/lib/esm/iterative-generation/activities/finalizeOutput.js.map +1 -0
- package/lib/esm/iterative-generation/activities/generatePart.js +75 -0
- package/lib/esm/iterative-generation/activities/generatePart.js.map +1 -0
- package/lib/esm/iterative-generation/activities/generateToc.js +83 -0
- package/lib/esm/iterative-generation/activities/generateToc.js.map +1 -0
- package/lib/esm/iterative-generation/activities/index.js +5 -0
- package/lib/esm/iterative-generation/activities/index.js.map +1 -0
- package/lib/esm/iterative-generation/iterativeGenerationWorkflow.js +53 -0
- package/lib/esm/iterative-generation/iterativeGenerationWorkflow.js.map +1 -0
- package/lib/esm/iterative-generation/types.js +2 -0
- package/lib/esm/iterative-generation/types.js.map +1 -0
- package/lib/esm/iterative-generation/utils.js +112 -0
- package/lib/esm/iterative-generation/utils.js.map +1 -0
- package/lib/esm/result-types.js +7 -0
- package/lib/esm/result-types.js.map +1 -0
- package/lib/esm/system/notifyWebhookWorkflow.js +50 -0
- package/lib/esm/system/notifyWebhookWorkflow.js.map +1 -0
- package/lib/esm/system/recalculateEmbeddingsWorkflow.js +30 -0
- package/lib/esm/system/recalculateEmbeddingsWorkflow.js.map +1 -0
- package/lib/esm/utils/auth.js +8 -0
- package/lib/esm/utils/auth.js.map +1 -0
- package/lib/esm/utils/blobs.js +54 -0
- package/lib/esm/utils/blobs.js.map +1 -0
- package/lib/esm/utils/chunks.js +9 -0
- package/lib/esm/utils/chunks.js.map +1 -0
- package/lib/esm/utils/client.js +27 -0
- package/lib/esm/utils/client.js.map +1 -0
- package/lib/esm/utils/expand-vars.js +30 -0
- package/lib/esm/utils/expand-vars.js.map +1 -0
- package/lib/esm/utils/memory.js +55 -0
- package/lib/esm/utils/memory.js.map +1 -0
- package/lib/esm/utils/renditions.js +80 -0
- package/lib/esm/utils/renditions.js.map +1 -0
- package/lib/esm/utils/storage.js +45 -0
- package/lib/esm/utils/storage.js.map +1 -0
- package/lib/esm/utils/tokens.js +34 -0
- package/lib/esm/utils/tokens.js.map +1 -0
- package/lib/esm/vars.js +4 -0
- package/lib/esm/vars.js.map +1 -0
- package/lib/esm/workflows.js +8 -0
- package/lib/esm/workflows.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/types/activities/advanced/createDocumentTypeFromInteractionRun.d.ts +17 -0
- package/lib/types/activities/advanced/createDocumentTypeFromInteractionRun.d.ts.map +1 -0
- package/lib/types/activities/advanced/createOrUpdateDocumentFromInteractionRun.d.ts +39 -0
- package/lib/types/activities/advanced/createOrUpdateDocumentFromInteractionRun.d.ts.map +1 -0
- package/lib/types/activities/advanced/updateDocumentFromInteractionRun.d.ts +19 -0
- package/lib/types/activities/advanced/updateDocumentFromInteractionRun.d.ts.map +1 -0
- package/lib/types/activities/chunkDocument.d.ts +33 -0
- package/lib/types/activities/chunkDocument.d.ts.map +1 -0
- package/lib/types/activities/copyParentArtifacts.d.ts +19 -0
- package/lib/types/activities/copyParentArtifacts.d.ts.map +1 -0
- package/lib/types/activities/createDocumentFromOther.d.ts +21 -0
- package/lib/types/activities/createDocumentFromOther.d.ts.map +1 -0
- package/lib/types/activities/executeInteraction.d.ts +61 -0
- package/lib/types/activities/executeInteraction.d.ts.map +1 -0
- package/lib/types/activities/extractDocumentText.d.ts +10 -0
- package/lib/types/activities/extractDocumentText.d.ts.map +1 -0
- package/lib/types/activities/generateDocumentProperties.d.ts +32 -0
- package/lib/types/activities/generateDocumentProperties.d.ts.map +1 -0
- package/lib/types/activities/generateEmbeddings.d.ts +53 -0
- package/lib/types/activities/generateEmbeddings.d.ts.map +1 -0
- package/lib/types/activities/generateOrAssignContentType.d.ts +44 -0
- package/lib/types/activities/generateOrAssignContentType.d.ts.map +1 -0
- package/lib/types/activities/getObjectFromStore.d.ts +14 -0
- package/lib/types/activities/getObjectFromStore.d.ts.map +1 -0
- 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 +25 -0
- package/lib/types/activities/index-dsl.d.ts.map +1 -0
- package/lib/types/activities/index.d.ts +5 -0
- package/lib/types/activities/index.d.ts.map +1 -0
- package/lib/types/activities/media/prepareAudio.d.ts +25 -0
- package/lib/types/activities/media/prepareAudio.d.ts.map +1 -0
- package/lib/types/activities/media/prepareVideo.d.ts +30 -0
- package/lib/types/activities/media/prepareVideo.d.ts.map +1 -0
- package/lib/types/activities/media/processPdfWithTextract.d.ts +26 -0
- package/lib/types/activities/media/processPdfWithTextract.d.ts.map +1 -0
- package/lib/types/activities/media/saveGladiaTranscription.d.ts +14 -0
- package/lib/types/activities/media/saveGladiaTranscription.d.ts.map +1 -0
- package/lib/types/activities/media/transcribeMediaWithGladia.d.ts +19 -0
- package/lib/types/activities/media/transcribeMediaWithGladia.d.ts.map +1 -0
- package/lib/types/activities/notifyWebhook.d.ts +27 -0
- package/lib/types/activities/notifyWebhook.d.ts.map +1 -0
- package/lib/types/activities/rateLimiter.d.ts +11 -0
- package/lib/types/activities/rateLimiter.d.ts.map +1 -0
- package/lib/types/activities/renditions/generateImageRendition.d.ts +14 -0
- package/lib/types/activities/renditions/generateImageRendition.d.ts.map +1 -0
- package/lib/types/activities/renditions/generateVideoRendition.d.ts +15 -0
- package/lib/types/activities/renditions/generateVideoRendition.d.ts.map +1 -0
- package/lib/types/activities/setDocumentStatus.d.ts +15 -0
- package/lib/types/activities/setDocumentStatus.d.ts.map +1 -0
- package/lib/types/conversion/TextractProcessor.d.ts +45 -0
- package/lib/types/conversion/TextractProcessor.d.ts.map +1 -0
- package/lib/types/conversion/image.d.ts +13 -0
- package/lib/types/conversion/image.d.ts.map +1 -0
- 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 +19 -0
- package/lib/types/conversion/mutool.d.ts.map +1 -0
- package/lib/types/conversion/pandoc.d.ts +2 -0
- package/lib/types/conversion/pandoc.d.ts.map +1 -0
- package/lib/types/dsl/conditions.d.ts +2 -0
- package/lib/types/dsl/conditions.d.ts.map +1 -0
- package/lib/types/dsl/dsl-workflow.d.ts +5 -0
- package/lib/types/dsl/dsl-workflow.d.ts.map +1 -0
- package/lib/types/dsl/dslProxyActivities.d.ts +10 -0
- package/lib/types/dsl/dslProxyActivities.d.ts.map +1 -0
- package/lib/types/dsl/projections.d.ts +4 -0
- package/lib/types/dsl/projections.d.ts.map +1 -0
- package/lib/types/dsl/setup/ActivityContext.d.ts +17 -0
- package/lib/types/dsl/setup/ActivityContext.d.ts.map +1 -0
- package/lib/types/dsl/setup/fetch/DataProvider.d.ts +9 -0
- package/lib/types/dsl/setup/fetch/DataProvider.d.ts.map +1 -0
- package/lib/types/dsl/setup/fetch/index.d.ts +6 -0
- package/lib/types/dsl/setup/fetch/index.d.ts.map +1 -0
- package/lib/types/dsl/setup/fetch/providers.d.ts +25 -0
- package/lib/types/dsl/setup/fetch/providers.d.ts.map +1 -0
- package/lib/types/dsl/test/test-child-workflow.d.ts +4 -0
- package/lib/types/dsl/test/test-child-workflow.d.ts.map +1 -0
- package/lib/types/dsl/validation.d.ts +4 -0
- package/lib/types/dsl/validation.d.ts.map +1 -0
- package/lib/types/dsl/vars.d.ts +48 -0
- package/lib/types/dsl/vars.d.ts.map +1 -0
- package/lib/types/dsl/walk.d.ts +18 -0
- package/lib/types/dsl/walk.d.ts.map +1 -0
- package/lib/types/dsl.d.ts +4 -0
- package/lib/types/dsl.d.ts.map +1 -0
- package/lib/types/errors.d.ts +37 -0
- package/lib/types/errors.d.ts.map +1 -0
- package/lib/types/index.d.ts +37 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/iterative-generation/activities/extractToc.d.ts +10 -0
- package/lib/types/iterative-generation/activities/extractToc.d.ts.map +1 -0
- package/lib/types/iterative-generation/activities/finalizeOutput.d.ts +3 -0
- package/lib/types/iterative-generation/activities/finalizeOutput.d.ts.map +1 -0
- package/lib/types/iterative-generation/activities/generatePart.d.ts +3 -0
- package/lib/types/iterative-generation/activities/generatePart.d.ts.map +1 -0
- package/lib/types/iterative-generation/activities/generateToc.d.ts +4 -0
- package/lib/types/iterative-generation/activities/generateToc.d.ts.map +1 -0
- package/lib/types/iterative-generation/activities/index.d.ts +5 -0
- package/lib/types/iterative-generation/activities/index.d.ts.map +1 -0
- package/lib/types/iterative-generation/iterativeGenerationWorkflow.d.ts +3 -0
- package/lib/types/iterative-generation/iterativeGenerationWorkflow.d.ts.map +1 -0
- package/lib/types/iterative-generation/types.d.ts +79 -0
- package/lib/types/iterative-generation/types.d.ts.map +1 -0
- package/lib/types/iterative-generation/utils.d.ts +26 -0
- package/lib/types/iterative-generation/utils.d.ts.map +1 -0
- package/lib/types/result-types.d.ts +22 -0
- package/lib/types/result-types.d.ts.map +1 -0
- package/lib/types/system/notifyWebhookWorkflow.d.ts +8 -0
- package/lib/types/system/notifyWebhookWorkflow.d.ts.map +1 -0
- package/lib/types/system/recalculateEmbeddingsWorkflow.d.ts +25 -0
- package/lib/types/system/recalculateEmbeddingsWorkflow.d.ts.map +1 -0
- package/lib/types/utils/auth.d.ts +4 -0
- package/lib/types/utils/auth.d.ts.map +1 -0
- package/lib/types/utils/blobs.d.ts +7 -0
- package/lib/types/utils/blobs.d.ts.map +1 -0
- package/lib/types/utils/chunks.d.ts +9 -0
- package/lib/types/utils/chunks.d.ts.map +1 -0
- package/lib/types/utils/client.d.ts +8 -0
- package/lib/types/utils/client.d.ts.map +1 -0
- package/lib/types/utils/expand-vars.d.ts +8 -0
- package/lib/types/utils/expand-vars.d.ts.map +1 -0
- package/lib/types/utils/memory.d.ts +8 -0
- package/lib/types/utils/memory.d.ts.map +1 -0
- package/lib/types/utils/renditions.d.ts +23 -0
- package/lib/types/utils/renditions.d.ts.map +1 -0
- package/lib/types/utils/storage.d.ts +16 -0
- package/lib/types/utils/storage.d.ts.map +1 -0
- package/lib/types/utils/tokens.d.ts +11 -0
- package/lib/types/utils/tokens.d.ts.map +1 -0
- package/lib/types/vars.d.ts +3 -0
- package/lib/types/vars.d.ts.map +1 -0
- package/lib/types/workflows.d.ts +8 -0
- package/lib/types/workflows.d.ts.map +1 -0
- package/lib/workflows-bundle.js +17213 -0
- package/package.json +146 -0
- package/src/activities/advanced/createDocumentTypeFromInteractionRun.ts +55 -0
- package/src/activities/advanced/createOrUpdateDocumentFromInteractionRun.ts +119 -0
- package/src/activities/advanced/updateDocumentFromInteractionRun.ts +35 -0
- package/src/activities/chunkDocument.ts +146 -0
- package/src/activities/copyParentArtifacts.ts +162 -0
- package/src/activities/createDocumentFromOther.ts +92 -0
- package/src/activities/executeInteraction.ts +300 -0
- package/src/activities/extractDocumentText.ts +205 -0
- package/src/activities/generateDocumentProperties.ts +120 -0
- package/src/activities/generateEmbeddings.ts +387 -0
- package/src/activities/generateOrAssignContentType.ts +218 -0
- package/src/activities/getObjectFromStore.ts +31 -0
- package/src/activities/handleError.ts +25 -0
- package/src/activities/index-dsl.ts +25 -0
- package/src/activities/index.ts +4 -0
- package/src/activities/media/prepareAudio.ts +334 -0
- package/src/activities/media/prepareVideo.ts +622 -0
- package/src/activities/media/processPdfWithTextract.ts +141 -0
- package/src/activities/media/saveGladiaTranscription.ts +128 -0
- package/src/activities/media/transcribeMediaWithGladia.ts +117 -0
- package/src/activities/notifyWebhook.test.ts +134 -0
- package/src/activities/notifyWebhook.ts +199 -0
- package/src/activities/rateLimiter.ts +41 -0
- package/src/activities/renditions/generateImageRendition.ts +111 -0
- package/src/activities/renditions/generateVideoRendition.ts +293 -0
- package/src/activities/setDocumentStatus.ts +25 -0
- package/src/conversion/TextractProcessor.ts +506 -0
- package/src/conversion/image.test.ts +118 -0
- package/src/conversion/image.ts +168 -0
- package/src/conversion/markitdown.ts +41 -0
- package/src/conversion/mutool.test.ts +74 -0
- package/src/conversion/mutool.ts +180 -0
- package/src/conversion/pandoc.test.ts +24 -0
- package/src/conversion/pandoc.ts +40 -0
- package/src/dsl/conditions.ts +76 -0
- package/src/dsl/dsl-workflow.test.ts +58 -0
- package/src/dsl/dsl-workflow.ts +397 -0
- package/src/dsl/dslProxyActivities.ts +38 -0
- package/src/dsl/ms.d.ts +11 -0
- package/src/dsl/projections.test.ts +159 -0
- package/src/dsl/projections.ts +72 -0
- package/src/dsl/setup/ActivityContext.ts +178 -0
- package/src/dsl/setup/fetch/DataProvider.ts +45 -0
- package/src/dsl/setup/fetch/index.ts +19 -0
- package/src/dsl/setup/fetch/providers.ts +67 -0
- package/src/dsl/test/test-child-workflow.ts +6 -0
- package/src/dsl/validation.test.ts +257 -0
- package/src/dsl/validation.ts +125 -0
- package/src/dsl/vars.test.ts +245 -0
- package/src/dsl/vars.ts +340 -0
- package/src/dsl/walk.test.ts +81 -0
- package/src/dsl/walk.ts +103 -0
- package/src/dsl/workflow-exec-child.test.ts +273 -0
- package/src/dsl/workflow-fetch.test.ts +138 -0
- package/src/dsl/workflow-import.test.ts +89 -0
- package/src/dsl/workflow.test.ts +122 -0
- package/src/dsl.ts +3 -0
- package/src/errors.ts +101 -0
- package/src/index.ts +41 -0
- package/src/iterative-generation/activities/extractToc.ts +63 -0
- package/src/iterative-generation/activities/finalizeOutput.ts +100 -0
- package/src/iterative-generation/activities/generatePart.ts +123 -0
- package/src/iterative-generation/activities/generateToc.ts +116 -0
- package/src/iterative-generation/activities/index.ts +4 -0
- package/src/iterative-generation/iterativeGenerationWorkflow.ts +68 -0
- package/src/iterative-generation/types.ts +99 -0
- package/src/iterative-generation/utils.ts +126 -0
- package/src/result-types.ts +25 -0
- package/src/system/notifyWebhookWorkflow.ts +70 -0
- package/src/system/recalculateEmbeddingsWorkflow.ts +41 -0
- package/src/utils/auth.ts +10 -0
- package/src/utils/blobs.ts +59 -0
- package/src/utils/chunks.ts +17 -0
- package/src/utils/client.ts +46 -0
- package/src/utils/expand-vars.ts +31 -0
- package/src/utils/memory.ts +61 -0
- package/src/utils/renditions.ts +127 -0
- package/src/utils/storage.ts +60 -0
- package/src/utils/tokens.ts +44 -0
- package/src/vars.ts +3 -0
- package/src/workflows.ts +7 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import * as protos from '@temporalio/proto';
|
|
2
|
+
import { TestWorkflowEnvironment } from '@temporalio/testing';
|
|
3
|
+
import { Worker } from '@temporalio/worker';
|
|
4
|
+
import { ContentEventName, DSLActivityExecutionPayload, DSLActivitySpec, DSLWorkflowExecutionPayload } from '@vertesia/common';
|
|
5
|
+
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
|
|
6
|
+
import { dslWorkflow } from './dsl-workflow.js';
|
|
7
|
+
import { setupActivity } from "./setup/ActivityContext.js";
|
|
8
|
+
|
|
9
|
+
async function sayHello(payload: DSLActivityExecutionPayload): Promise<string> {
|
|
10
|
+
const { params } = await setupActivity(payload);
|
|
11
|
+
return params.lang === 'fr' ? "Bonjour" : "Hello";
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async function sayName(payload: DSLActivityExecutionPayload): Promise<string> {
|
|
15
|
+
const { params } = await setupActivity(payload);
|
|
16
|
+
return params.lang === 'fr' ? "Monde" : "World";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async function sayGreeting(payload: DSLActivityExecutionPayload): Promise<string> {
|
|
20
|
+
const { params } = await setupActivity(payload);
|
|
21
|
+
return `${params.hello}, ${params.name}!`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
const activities: DSLActivitySpec[] = [
|
|
26
|
+
{
|
|
27
|
+
name: 'sayHello',
|
|
28
|
+
output: 'hello',
|
|
29
|
+
import: ["lang"],
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: 'sayName',
|
|
33
|
+
output: 'name',
|
|
34
|
+
import: ["lang"],
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: 'sayGreeting',
|
|
38
|
+
import: ["hello", "name"],
|
|
39
|
+
condition: {
|
|
40
|
+
hello: { $null: false },
|
|
41
|
+
name: { $null: false }
|
|
42
|
+
},
|
|
43
|
+
output: 'result',
|
|
44
|
+
},
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
// ========== test env setup ==========
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
describe('DSL Workflow', () => {
|
|
51
|
+
|
|
52
|
+
let testEnv: TestWorkflowEnvironment;
|
|
53
|
+
|
|
54
|
+
beforeAll(async () => {
|
|
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
|
+
TenantId: protos.temporal.api.enums.v1.IndexedValueType.INDEXED_VALUE_TYPE_KEYWORD,
|
|
64
|
+
InitiatedBy: protos.temporal.api.enums.v1.IndexedValueType.INDEXED_VALUE_TYPE_KEYWORD,
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
afterAll(async () => {
|
|
70
|
+
await testEnv?.teardown();
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('successfully completes a mock workflow', async () => {
|
|
74
|
+
const { client, nativeConnection } = testEnv;
|
|
75
|
+
const taskQueue = 'test';
|
|
76
|
+
|
|
77
|
+
const lang = 'fr';
|
|
78
|
+
|
|
79
|
+
const worker = await Worker.create({
|
|
80
|
+
connection: nativeConnection,
|
|
81
|
+
taskQueue,
|
|
82
|
+
workflowsPath: new URL("./dsl-workflow.ts", import.meta.url).pathname,
|
|
83
|
+
activities: { sayHello, sayName, sayGreeting },
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const payload: DSLWorkflowExecutionPayload = {
|
|
87
|
+
event: ContentEventName.create,
|
|
88
|
+
objectIds: ['123'],
|
|
89
|
+
vars: {},
|
|
90
|
+
account_id: '123',
|
|
91
|
+
project_id: '123',
|
|
92
|
+
timestamp: Date.now(),
|
|
93
|
+
wf_rule_name: 'test',
|
|
94
|
+
auth_token: process.env.VERTESIA_KEY || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwOi8vbW9jay10b2tlbi1zZXJ2ZXIiLCJzdWIiOiJ0ZXN0In0.signature',
|
|
95
|
+
config: {
|
|
96
|
+
studio_url: process.env.CP_STUDIO_URL || "http://localhost:8081",
|
|
97
|
+
store_url: process.env.CP_STORE_URL || "http://localhost:8082",
|
|
98
|
+
},
|
|
99
|
+
workflow: {
|
|
100
|
+
activities,
|
|
101
|
+
vars: {
|
|
102
|
+
lang,
|
|
103
|
+
},
|
|
104
|
+
name: 'test',
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
let result = await worker.runUntil(client.workflow.execute(dslWorkflow, {
|
|
109
|
+
args: [payload],
|
|
110
|
+
workflowId: 'test',
|
|
111
|
+
taskQueue,
|
|
112
|
+
}));
|
|
113
|
+
|
|
114
|
+
expect(result).toBe('Bonjour, Monde!');
|
|
115
|
+
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
});
|
package/src/dsl.ts
ADDED
package/src/errors.ts
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { ApplicationFailure } from "@temporalio/workflow";
|
|
2
|
+
import { DSLActivitySpec, DSLWorkflowSpec } from "@vertesia/common";
|
|
3
|
+
|
|
4
|
+
export class DocumentNotFoundError extends ApplicationFailure {
|
|
5
|
+
constructor(message: string, public ids?: string[]) {
|
|
6
|
+
super(
|
|
7
|
+
message,
|
|
8
|
+
"DocumentNotFoundError",
|
|
9
|
+
true, // non-retryable
|
|
10
|
+
)
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export class ActivityParamNotFoundError extends ApplicationFailure {
|
|
15
|
+
constructor(
|
|
16
|
+
public paramName: string,
|
|
17
|
+
public activity: DSLActivitySpec,
|
|
18
|
+
) {
|
|
19
|
+
super(
|
|
20
|
+
`Required parameter ${paramName} not found in activity ${activity.name}`,
|
|
21
|
+
"ActivityParamNotFoundError",
|
|
22
|
+
true, // non-retryable
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export class ActivityParamInvalidError extends ApplicationFailure {
|
|
28
|
+
constructor(
|
|
29
|
+
public paramName: string,
|
|
30
|
+
public activity: DSLActivitySpec,
|
|
31
|
+
reason?: string,
|
|
32
|
+
) {
|
|
33
|
+
super(
|
|
34
|
+
`${paramName} in activity ${activity.name} is invalid${reason ? ` ${reason}` : ""}`,
|
|
35
|
+
"ActivityParamInvalidError",
|
|
36
|
+
true, // non-retryable
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export class WorkflowParamNotFoundError extends ApplicationFailure {
|
|
42
|
+
constructor(
|
|
43
|
+
public paramName: string,
|
|
44
|
+
public workflow?: DSLWorkflowSpec,
|
|
45
|
+
) {
|
|
46
|
+
super(
|
|
47
|
+
`Required parameter ${paramName} not found in workflow ${workflow?.name}`,
|
|
48
|
+
"WorkflowParamNotFoundError",
|
|
49
|
+
true, // non-retryable
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export class ResourceExhaustedError extends ApplicationFailure {
|
|
55
|
+
constructor(
|
|
56
|
+
public statusCode: number = 429,
|
|
57
|
+
message?: string,
|
|
58
|
+
) {
|
|
59
|
+
super(
|
|
60
|
+
message || "Resource exhausted - rate limit exceeded",
|
|
61
|
+
"ResourceExhaustedError",
|
|
62
|
+
true, // non-retryable
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export class InvalidContentTypeError extends ApplicationFailure {
|
|
68
|
+
constructor(
|
|
69
|
+
public objectId: string,
|
|
70
|
+
public expectedType: string,
|
|
71
|
+
public actualType: string,
|
|
72
|
+
) {
|
|
73
|
+
super(
|
|
74
|
+
`Document ${objectId} has invalid content type. Expected ${expectedType}, got ${actualType}`,
|
|
75
|
+
"InvalidContentTypeError",
|
|
76
|
+
true, // non-retryable
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export class TokenExpiredError extends ApplicationFailure {
|
|
82
|
+
constructor(
|
|
83
|
+
public statusCode: number,
|
|
84
|
+
message?: string,
|
|
85
|
+
) {
|
|
86
|
+
super(
|
|
87
|
+
message || "Token expired: Authentication required",
|
|
88
|
+
"TokenExpiredError",
|
|
89
|
+
true, // non-retryable
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export const WF_NON_RETRYABLE_ERRORS = [
|
|
95
|
+
"DocumentNotFoundError",
|
|
96
|
+
"ActivityParamInvalidError",
|
|
97
|
+
"ActivityParamNotFoundError",
|
|
98
|
+
"WorkflowParamNotFoundError",
|
|
99
|
+
"InvalidContentTypeError",
|
|
100
|
+
"TokenExpiredError",
|
|
101
|
+
];
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 1. Activities are exported through the '/activities' named export in package.json.
|
|
3
|
+
* Modify the `./activities/index.ts` if you want to modify activity exports
|
|
4
|
+
* 2. Workflows are exported through the '/workflows' named export in package.json.
|
|
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 required to create workflow TS definitions.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
//TODO remove this - it is only for backward compat - iot is used from old workflows
|
|
10
|
+
export { dslWorkflow } from "./dsl/dsl-workflow.js";
|
|
11
|
+
export * from "./iterative-generation/iterativeGenerationWorkflow.js";
|
|
12
|
+
|
|
13
|
+
export * from "./activities/advanced/createDocumentTypeFromInteractionRun.js";
|
|
14
|
+
export * from "./activities/advanced/createOrUpdateDocumentFromInteractionRun.js";
|
|
15
|
+
export * from "./activities/advanced/updateDocumentFromInteractionRun.js";
|
|
16
|
+
export * from "./activities/chunkDocument.js";
|
|
17
|
+
export * from "./activities/executeInteraction.js";
|
|
18
|
+
export * from "./activities/extractDocumentText.js";
|
|
19
|
+
export * from "./activities/generateDocumentProperties.js";
|
|
20
|
+
export * from "./activities/generateEmbeddings.js";
|
|
21
|
+
export * from "./activities/renditions/generateImageRendition.js";
|
|
22
|
+
export * from "./activities/renditions/generateVideoRendition.js";
|
|
23
|
+
export * from "./activities/generateOrAssignContentType.js";
|
|
24
|
+
export * from "./activities/notifyWebhook.js";
|
|
25
|
+
export * from "./activities/rateLimiter.js";
|
|
26
|
+
export * from "./activities/setDocumentStatus.js";
|
|
27
|
+
export * from "./iterative-generation/activities/index.js";
|
|
28
|
+
export * from "./activities/media/prepareVideo.js";
|
|
29
|
+
export * from "./activities/media/prepareAudio.js";
|
|
30
|
+
|
|
31
|
+
export * from "./dsl/setup/ActivityContext.js";
|
|
32
|
+
export * from "./errors.js";
|
|
33
|
+
export * from "./result-types.js";
|
|
34
|
+
export * from "./utils/blobs.js";
|
|
35
|
+
export * from "./utils/client.js";
|
|
36
|
+
export * from "./utils/memory.js";
|
|
37
|
+
export * from "./utils/tokens.js";
|
|
38
|
+
export * from "./utils/renditions.js";
|
|
39
|
+
export * from "./utils/storage.js";
|
|
40
|
+
|
|
41
|
+
export * from "./conversion/image.js";
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { log } from "@temporalio/activity";
|
|
2
|
+
import { WorkflowExecutionPayload } from "@vertesia/common";
|
|
3
|
+
import { parse as parseYaml } from "yaml";
|
|
4
|
+
import { getVertesiaClient } from "../../utils/client.js";
|
|
5
|
+
import {
|
|
6
|
+
buildAndPublishMemoryPack,
|
|
7
|
+
loadMemoryPack,
|
|
8
|
+
} from "../../utils/memory.js";
|
|
9
|
+
import {
|
|
10
|
+
IterativeGenerationPayload,
|
|
11
|
+
OutputMemoryMeta,
|
|
12
|
+
Toc,
|
|
13
|
+
TocIndex,
|
|
14
|
+
} from "../types.js";
|
|
15
|
+
import { tocIndex } from "../utils.js";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* This activity is called if the toc was provided in the payload. Otherwise
|
|
19
|
+
* the generateToc is called.
|
|
20
|
+
*
|
|
21
|
+
* @param payload
|
|
22
|
+
*/
|
|
23
|
+
export async function it_gen_extractToc(
|
|
24
|
+
payload: WorkflowExecutionPayload,
|
|
25
|
+
): Promise<TocIndex | null> {
|
|
26
|
+
const vars = payload.vars as IterativeGenerationPayload;
|
|
27
|
+
const memory = vars.memory;
|
|
28
|
+
const client = await getVertesiaClient(payload);
|
|
29
|
+
|
|
30
|
+
const inMemory = await loadMemoryPack(client, `${memory}/input`);
|
|
31
|
+
let tocJson: string | null = null;
|
|
32
|
+
let tocYaml: string | null = null;
|
|
33
|
+
let toc: any;
|
|
34
|
+
tocJson = await inMemory.getEntryText("toc.json");
|
|
35
|
+
if (!tocJson) {
|
|
36
|
+
tocYaml = await inMemory.getEntryText("toc.yaml");
|
|
37
|
+
if (tocYaml) {
|
|
38
|
+
toc = parseYaml(tocYaml) as Toc;
|
|
39
|
+
}
|
|
40
|
+
} else {
|
|
41
|
+
toc = JSON.parse(tocJson) as Toc;
|
|
42
|
+
}
|
|
43
|
+
if (!toc) {
|
|
44
|
+
log.info(`Nothing to extract: no TOC found in the input memory pack.`);
|
|
45
|
+
return null; // no toc found
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
log.info(`Found a TOC in the input memory pack`);
|
|
49
|
+
|
|
50
|
+
await buildAndPublishMemoryPack(
|
|
51
|
+
client,
|
|
52
|
+
`${vars.memory}/output`,
|
|
53
|
+
async () => {
|
|
54
|
+
return {
|
|
55
|
+
toc,
|
|
56
|
+
lastProcessedPart: undefined, // the part index (a number array)
|
|
57
|
+
previouslyGenerated: "",
|
|
58
|
+
} as OutputMemoryMeta;
|
|
59
|
+
},
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
return tocIndex(toc);
|
|
63
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { log } from "@temporalio/activity";
|
|
2
|
+
import { WorkflowExecutionPayload } from "@vertesia/common";
|
|
3
|
+
import { getVertesiaClient } from "../../utils/client.js";
|
|
4
|
+
import { expandVars } from "../../utils/expand-vars.js";
|
|
5
|
+
import {
|
|
6
|
+
buildAndPublishMemoryPack,
|
|
7
|
+
loadMemoryPack,
|
|
8
|
+
} from "../../utils/memory.js";
|
|
9
|
+
import {
|
|
10
|
+
IterativeGenerationPayload,
|
|
11
|
+
Section,
|
|
12
|
+
SECTION_ID_PLACEHOLDER,
|
|
13
|
+
TocSection,
|
|
14
|
+
} from "../types.js";
|
|
15
|
+
|
|
16
|
+
export async function it_gen_finalizeOutput(
|
|
17
|
+
payload: WorkflowExecutionPayload,
|
|
18
|
+
): Promise<string> {
|
|
19
|
+
const vars = payload.vars as IterativeGenerationPayload;
|
|
20
|
+
|
|
21
|
+
const memory = vars.memory;
|
|
22
|
+
const client = await getVertesiaClient(payload);
|
|
23
|
+
const inMemory = await loadMemoryPack(client, `${memory}/input`);
|
|
24
|
+
const outMemory = await loadMemoryPack(client, `${memory}/output`);
|
|
25
|
+
|
|
26
|
+
const content = await outMemory.getEntryText("content.json");
|
|
27
|
+
if (!content) {
|
|
28
|
+
log.info(`Nothing to do. No content.json file found`);
|
|
29
|
+
return "No content.json file found";
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
log.info(`Creating the final output memory pack.`);
|
|
33
|
+
|
|
34
|
+
const inMeta = await inMemory.getMetadata();
|
|
35
|
+
let tocName = "toc.json";
|
|
36
|
+
let toc = await inMemory.getEntryText(tocName);
|
|
37
|
+
if (!toc) {
|
|
38
|
+
tocName = "toc.yaml";
|
|
39
|
+
toc = await inMemory.getEntryText(tocName);
|
|
40
|
+
}
|
|
41
|
+
if (!toc) {
|
|
42
|
+
const outMeta = await outMemory.getMetadata();
|
|
43
|
+
tocName = "toc.json";
|
|
44
|
+
toc = JSON.stringify(outMeta.toc);
|
|
45
|
+
}
|
|
46
|
+
const sections = JSON.parse(content) as Section[];
|
|
47
|
+
|
|
48
|
+
await buildAndPublishMemoryPack(
|
|
49
|
+
client,
|
|
50
|
+
`${memory}/output`,
|
|
51
|
+
async ({ copyText }) => {
|
|
52
|
+
// copy the input toc file if any
|
|
53
|
+
if (toc) {
|
|
54
|
+
copyText(toc, tocName);
|
|
55
|
+
}
|
|
56
|
+
// copy the raw JSON content
|
|
57
|
+
copyText(content, "content.json");
|
|
58
|
+
if (vars.section_file_pattern) {
|
|
59
|
+
log.info(
|
|
60
|
+
`Saving sections to files using pattern: ${vars.section_file_pattern}`,
|
|
61
|
+
);
|
|
62
|
+
// save sections to files
|
|
63
|
+
for (const section of sections) {
|
|
64
|
+
let content = section.content;
|
|
65
|
+
if (vars.section_file_header) {
|
|
66
|
+
content =
|
|
67
|
+
getSectionFileHeader(
|
|
68
|
+
section,
|
|
69
|
+
vars.section_file_header,
|
|
70
|
+
) +
|
|
71
|
+
"\n\n" +
|
|
72
|
+
content;
|
|
73
|
+
}
|
|
74
|
+
copyText(
|
|
75
|
+
content,
|
|
76
|
+
getSectionFileName(section, vars.section_file_pattern),
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
...inMeta,
|
|
82
|
+
vars,
|
|
83
|
+
};
|
|
84
|
+
},
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
return `Processing done. Extracted files to: ${vars.section_file_pattern}`;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function getSectionFileHeader(section: TocSection, header: string): string {
|
|
91
|
+
const date = new Date().toISOString();
|
|
92
|
+
return expandVars(header, {
|
|
93
|
+
section,
|
|
94
|
+
date,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function getSectionFileName(section: TocSection, pattern: string): string {
|
|
99
|
+
return pattern.replace(SECTION_ID_PLACEHOLDER, section.id);
|
|
100
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { ApplicationFailure } from "@temporalio/workflow";
|
|
2
|
+
import { WorkflowExecutionPayload } from "@vertesia/common";
|
|
3
|
+
import { MemoryPack } from "@vertesia/memory";
|
|
4
|
+
import { getVertesiaClient } from "../../utils/client.js";
|
|
5
|
+
import {
|
|
6
|
+
buildAndPublishMemoryPack,
|
|
7
|
+
loadMemoryPack,
|
|
8
|
+
} from "../../utils/memory.js";
|
|
9
|
+
import {
|
|
10
|
+
IterativeGenerationPayload,
|
|
11
|
+
OutputMemoryMeta,
|
|
12
|
+
Section,
|
|
13
|
+
TocPart,
|
|
14
|
+
TocSection,
|
|
15
|
+
} from "../types.js";
|
|
16
|
+
import { executeWithVars, expectMemoryIsConsistent } from "../utils.js";
|
|
17
|
+
|
|
18
|
+
export async function it_gen_generatePart(
|
|
19
|
+
payload: WorkflowExecutionPayload,
|
|
20
|
+
path: number[],
|
|
21
|
+
) {
|
|
22
|
+
const vars = payload.vars as IterativeGenerationPayload;
|
|
23
|
+
const client = await getVertesiaClient(payload);
|
|
24
|
+
const memory = vars.memory;
|
|
25
|
+
|
|
26
|
+
const [sectionIndex, partIndex] = path;
|
|
27
|
+
const outMemory = await loadMemoryPack(client, `${memory}/output`);
|
|
28
|
+
const meta = (await outMemory.getMetadata()) as OutputMemoryMeta;
|
|
29
|
+
|
|
30
|
+
// the section we build is the section at the given index
|
|
31
|
+
const section: TocSection = meta.toc.sections[sectionIndex];
|
|
32
|
+
if (!section) {
|
|
33
|
+
throw ApplicationFailure.nonRetryable(
|
|
34
|
+
"Section not found in the TOC",
|
|
35
|
+
"SectionNotFound",
|
|
36
|
+
{ memory, path },
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
let part: TocPart | undefined;
|
|
40
|
+
if (partIndex !== undefined) {
|
|
41
|
+
part = section.parts?.[partIndex];
|
|
42
|
+
if (!part) {
|
|
43
|
+
throw ApplicationFailure.nonRetryable(
|
|
44
|
+
"Part not found in the TOC section",
|
|
45
|
+
"PartNotFound",
|
|
46
|
+
{ memory, path },
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
expectMemoryIsConsistent(meta, path);
|
|
52
|
+
|
|
53
|
+
const content = await loadGeneratedContent(outMemory);
|
|
54
|
+
|
|
55
|
+
let previously_generated = getPreviouslyGeneratedContent(
|
|
56
|
+
content,
|
|
57
|
+
!part,
|
|
58
|
+
vars.remembrance_strategy,
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
if (!part) {
|
|
62
|
+
// a new section
|
|
63
|
+
content.push({
|
|
64
|
+
id: section.id,
|
|
65
|
+
name: section.name,
|
|
66
|
+
description: section.description,
|
|
67
|
+
content: "",
|
|
68
|
+
});
|
|
69
|
+
} else if (!content.length) {
|
|
70
|
+
throw ApplicationFailure.nonRetryable(
|
|
71
|
+
"content.json is empty while generating a part",
|
|
72
|
+
"InvalidIterationState",
|
|
73
|
+
{ memory, path },
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const interaction = vars.iterative_interaction || vars.interaction;
|
|
78
|
+
const r = await executeWithVars(client, interaction, vars, {
|
|
79
|
+
iteration: {
|
|
80
|
+
toc: meta.toc,
|
|
81
|
+
previously_generated,
|
|
82
|
+
section: section.name,
|
|
83
|
+
part: part?.name,
|
|
84
|
+
path: path,
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
const result = r.result.text();
|
|
89
|
+
content[content.length - 1].content += result;
|
|
90
|
+
meta.lastProcessedPart = path;
|
|
91
|
+
await buildAndPublishMemoryPack(
|
|
92
|
+
client,
|
|
93
|
+
`${memory}/output`,
|
|
94
|
+
async ({ copyText }) => {
|
|
95
|
+
copyText(JSON.stringify(content, null, 2), "content.json");
|
|
96
|
+
return meta;
|
|
97
|
+
},
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
async function loadGeneratedContent(memory: MemoryPack): Promise<Section[]> {
|
|
102
|
+
const content = await memory.getEntryText("content.json");
|
|
103
|
+
return content ? JSON.parse(content) : [];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function getPreviouslyGeneratedContent(
|
|
107
|
+
sections: Section[],
|
|
108
|
+
isNewSection: boolean,
|
|
109
|
+
strategy?: "document" | "section" | "none",
|
|
110
|
+
): string {
|
|
111
|
+
switch (strategy) {
|
|
112
|
+
case "document":
|
|
113
|
+
return sections
|
|
114
|
+
.map((section: Section) => section.content || "")
|
|
115
|
+
.join("\n\n");
|
|
116
|
+
case "none":
|
|
117
|
+
return "";
|
|
118
|
+
default:
|
|
119
|
+
return isNewSection
|
|
120
|
+
? ""
|
|
121
|
+
: sections[sections.length - 1]?.content || "";
|
|
122
|
+
}
|
|
123
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { WorkflowExecutionPayload } from "@vertesia/common";
|
|
2
|
+
import { getVertesiaClient } from "../../utils/client.js";
|
|
3
|
+
import { buildAndPublishMemoryPack } from "../../utils/memory.js";
|
|
4
|
+
import {
|
|
5
|
+
IterativeGenerationPayload,
|
|
6
|
+
OutputMemoryMeta,
|
|
7
|
+
Toc,
|
|
8
|
+
TocIndex,
|
|
9
|
+
} from "../types.js";
|
|
10
|
+
import { executeWithVars, tocIndex } from "../utils.js";
|
|
11
|
+
|
|
12
|
+
const defaultTocSchema = {
|
|
13
|
+
type: "object",
|
|
14
|
+
properties: {
|
|
15
|
+
sections: {
|
|
16
|
+
type: "array",
|
|
17
|
+
items: {
|
|
18
|
+
type: "object",
|
|
19
|
+
properties: {
|
|
20
|
+
id: {
|
|
21
|
+
type: "string",
|
|
22
|
+
description:
|
|
23
|
+
"the id of the section, can be a filename if working on a file, a slug if working on a document or path, or a unique identifier if working on a model.",
|
|
24
|
+
},
|
|
25
|
+
operation: {
|
|
26
|
+
type: "string",
|
|
27
|
+
enum: ["create", "update", "delete"],
|
|
28
|
+
description:
|
|
29
|
+
"The operation to perform on the section, create, update or delete. If update, you will be requested later to provide the list of change operation to perform.",
|
|
30
|
+
},
|
|
31
|
+
name: {
|
|
32
|
+
type: "string",
|
|
33
|
+
description:
|
|
34
|
+
"The name or title of the section, should be the path in the OpenAPI spec, of the title of the section/part.",
|
|
35
|
+
},
|
|
36
|
+
description: {
|
|
37
|
+
type: "string",
|
|
38
|
+
},
|
|
39
|
+
instructions: {
|
|
40
|
+
type: "string",
|
|
41
|
+
},
|
|
42
|
+
parts: {
|
|
43
|
+
type: "array",
|
|
44
|
+
description:
|
|
45
|
+
"when the section is too large, you can split it into parts, each part should have a title and description. Use it to split the section into subsection. When doing an API documentation, you can do one part for each path. When generating code, you can do one part for each method. When generating an OpenAPI spec, you can do one part for each operation.",
|
|
46
|
+
items: {
|
|
47
|
+
type: "object",
|
|
48
|
+
properties: {
|
|
49
|
+
id: {
|
|
50
|
+
type: "string",
|
|
51
|
+
description:
|
|
52
|
+
"the id of the part, can be a filename if working on a file, a slug if working on a document or path, or a unique identifier if working on a model.",
|
|
53
|
+
},
|
|
54
|
+
name: {
|
|
55
|
+
type: "string",
|
|
56
|
+
description:
|
|
57
|
+
"The name or title of the part, should be the path in the OpenAPI spec, of the title of the section/part.",
|
|
58
|
+
},
|
|
59
|
+
/*
|
|
60
|
+
"description": {
|
|
61
|
+
"type": "string"
|
|
62
|
+
},
|
|
63
|
+
*/
|
|
64
|
+
instructions: {
|
|
65
|
+
type: "string",
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
required: ["id", "name"],
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
required: ["id", "name", "operation"],
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
required: ["sections"],
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export async function it_gen_generateToc(
|
|
80
|
+
payload: WorkflowExecutionPayload,
|
|
81
|
+
): Promise<TocIndex> {
|
|
82
|
+
const vars = payload.vars as IterativeGenerationPayload;
|
|
83
|
+
|
|
84
|
+
const schema = vars.toc_schema || defaultTocSchema;
|
|
85
|
+
|
|
86
|
+
const client = await getVertesiaClient(payload);
|
|
87
|
+
|
|
88
|
+
const run = await executeWithVars(
|
|
89
|
+
client,
|
|
90
|
+
vars.interaction,
|
|
91
|
+
vars,
|
|
92
|
+
undefined,
|
|
93
|
+
schema,
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
//Parse the CompletionResult[] to get a Toc object
|
|
97
|
+
const jsonResults = run.result.object();
|
|
98
|
+
|
|
99
|
+
const toc: Toc = {
|
|
100
|
+
sections: jsonResults.sections
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
await buildAndPublishMemoryPack(
|
|
104
|
+
client,
|
|
105
|
+
`${vars.memory}/output`,
|
|
106
|
+
async () => {
|
|
107
|
+
return {
|
|
108
|
+
toc,
|
|
109
|
+
lastProcessedPart: undefined, // the part index (a number array)
|
|
110
|
+
previouslyGenerated: "",
|
|
111
|
+
} satisfies OutputMemoryMeta;
|
|
112
|
+
},
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
return tocIndex(toc);
|
|
116
|
+
}
|