@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
package/package.json
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vertesia/workflow",
|
|
3
|
+
"version": "0.24.0-dev.202601221707",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Vertesia workflow DSL",
|
|
6
|
+
"main": "./lib/esm/index.js",
|
|
7
|
+
"files": [
|
|
8
|
+
"lib",
|
|
9
|
+
"src"
|
|
10
|
+
],
|
|
11
|
+
"bin": {
|
|
12
|
+
"bundle-workflows": "./bin/bundle-workflows.mjs"
|
|
13
|
+
},
|
|
14
|
+
"license": "Apache-2.0",
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@smithy/types": "^3.7.2",
|
|
17
|
+
"@temporalio/proto": "^1.11.5",
|
|
18
|
+
"@temporalio/testing": "^1.11.5",
|
|
19
|
+
"@temporalio/worker": "^1.11.5",
|
|
20
|
+
"@types/jsonwebtoken": "^9.0.10",
|
|
21
|
+
"@types/node": "^22.13.5",
|
|
22
|
+
"@types/papaparse": "^5.5.1",
|
|
23
|
+
"@types/tmp": "^0.2.6",
|
|
24
|
+
"ts-dual-module": "^0.6.3",
|
|
25
|
+
"vitest": "^4.0.16"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@aws-sdk/client-s3": "^3.948.0",
|
|
29
|
+
"@aws-sdk/client-textract": "^3.948.0",
|
|
30
|
+
"@aws-sdk/credential-providers": "^3.948.0",
|
|
31
|
+
"@temporalio/activity": "^1.11.5",
|
|
32
|
+
"@temporalio/workflow": "^1.11.5",
|
|
33
|
+
"@types/json-schema": "^7.0.15",
|
|
34
|
+
"fast-deep-equal": "^3.1.3",
|
|
35
|
+
"jsonwebtoken": "^9.0.3",
|
|
36
|
+
"mime": "^4.0.0",
|
|
37
|
+
"ms": "3.0.0-canary.1",
|
|
38
|
+
"node-web-stream-adapters": "^0.2.1",
|
|
39
|
+
"p-limit": "^6.2.0",
|
|
40
|
+
"papaparse": "^5.5.3",
|
|
41
|
+
"seedrandom": "^3.0.5",
|
|
42
|
+
"sharp": "^0.33.4",
|
|
43
|
+
"tiktoken": "^1.0.22",
|
|
44
|
+
"tmp": "^0.2.4",
|
|
45
|
+
"tmp-promise": "^3.0.3",
|
|
46
|
+
"yaml": "^2.6.0",
|
|
47
|
+
"@llumiverse/common": "0.24.0-dev.202601221707",
|
|
48
|
+
"@vertesia/client": "0.24.0-dev.202601221707",
|
|
49
|
+
"@vertesia/common": "0.24.0-dev.202601221707",
|
|
50
|
+
"@vertesia/api-fetch-client": "0.24.0-dev.202601221707",
|
|
51
|
+
"@vertesia/memory": "0.24.0-dev.202601221707"
|
|
52
|
+
},
|
|
53
|
+
"ts_dual_module": {
|
|
54
|
+
"outDir": "lib",
|
|
55
|
+
"exports": {
|
|
56
|
+
"activities": "./activities/index.js",
|
|
57
|
+
"dsl-activities": "./activities/index-dsl.js",
|
|
58
|
+
"workflows": "./workflows",
|
|
59
|
+
"workflows-bundle": "./workflows-bundle.js",
|
|
60
|
+
"vars": "./vars"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"exports": {
|
|
64
|
+
".": {
|
|
65
|
+
"types": "./lib/types/index.d.ts",
|
|
66
|
+
"import": "./lib/esm/index.js",
|
|
67
|
+
"require": "./lib/cjs/index.js"
|
|
68
|
+
},
|
|
69
|
+
"./vars": {
|
|
70
|
+
"types": "./lib/types/vars.d.ts",
|
|
71
|
+
"import": "./lib/esm/vars.js",
|
|
72
|
+
"require": "./lib/cjs/vars.js"
|
|
73
|
+
},
|
|
74
|
+
"./activities": {
|
|
75
|
+
"types": "./lib/types/activities/index.d.ts",
|
|
76
|
+
"import": "./lib/esm/activities/index.js",
|
|
77
|
+
"require": "./lib/cjs/activities/index.js"
|
|
78
|
+
},
|
|
79
|
+
"./dsl-activities": {
|
|
80
|
+
"types": "./lib/types/activities/index-dsl.d.ts",
|
|
81
|
+
"import": "./lib/esm/activities/index-dsl.js",
|
|
82
|
+
"require": "./lib/cjs/activities/index-dsl.js"
|
|
83
|
+
},
|
|
84
|
+
"./workflows": {
|
|
85
|
+
"types": "./lib/types/workflows.d.ts",
|
|
86
|
+
"import": "./lib/esm/workflows.js",
|
|
87
|
+
"require": "./lib/cjs/workflows.js"
|
|
88
|
+
},
|
|
89
|
+
"./dsl": {
|
|
90
|
+
"types": "./lib/types/dsl.d.ts",
|
|
91
|
+
"import": "./lib/esm/dsl.js",
|
|
92
|
+
"require": "./lib/cjs/dsl.js"
|
|
93
|
+
},
|
|
94
|
+
"./workflows-bundle": {
|
|
95
|
+
"import": "./lib/workflows-bundle.js"
|
|
96
|
+
},
|
|
97
|
+
"./errors": {
|
|
98
|
+
"types": "./lib/types/errors.d.ts",
|
|
99
|
+
"import": "./lib/esm/errors.js",
|
|
100
|
+
"require": "./lib/cjs/errors.js"
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
"repository": {
|
|
104
|
+
"type": "git",
|
|
105
|
+
"url": "https://github.com/vertesia/composableai.git",
|
|
106
|
+
"directory": "packages/workflow"
|
|
107
|
+
},
|
|
108
|
+
"keywords": [
|
|
109
|
+
"vertesia",
|
|
110
|
+
"workflow",
|
|
111
|
+
"dsl",
|
|
112
|
+
"temporalio",
|
|
113
|
+
"llm",
|
|
114
|
+
"ai",
|
|
115
|
+
"agents",
|
|
116
|
+
"typescript"
|
|
117
|
+
],
|
|
118
|
+
"types": "./lib/types/index.d.ts",
|
|
119
|
+
"typesVersions": {
|
|
120
|
+
"*": {
|
|
121
|
+
"activities": [
|
|
122
|
+
"./lib/types/activities/index.d.ts"
|
|
123
|
+
],
|
|
124
|
+
"dsl-activities": [
|
|
125
|
+
"./lib/types/activities/index-dsl.d.ts"
|
|
126
|
+
],
|
|
127
|
+
"workflows": [
|
|
128
|
+
"./lib/types/workflows.d.ts"
|
|
129
|
+
],
|
|
130
|
+
"dsl": [
|
|
131
|
+
"./lib/types/dsl.d.ts"
|
|
132
|
+
],
|
|
133
|
+
"vars": [
|
|
134
|
+
"./lib/types/dsl/vars.d.ts"
|
|
135
|
+
],
|
|
136
|
+
"errors": [
|
|
137
|
+
"./lib/types/errors.d.ts"
|
|
138
|
+
]
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
"scripts": {
|
|
142
|
+
"test": "vitest run",
|
|
143
|
+
"build": "pnpm exec tsmod build && node ./bin/bundle-workflows.mjs lib/esm/workflows.js lib/workflows-bundle.js",
|
|
144
|
+
"clean": "rm -rf ./lib tsconfig.tsbuildinfo"
|
|
145
|
+
}
|
|
146
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { log } from "@temporalio/activity";
|
|
2
|
+
import { InteractionOutput } from "@vertesia/client";
|
|
3
|
+
import { CreateContentObjectTypePayload, DSLActivityExecutionPayload, DSLActivitySpec, ExecutionRun } from "@vertesia/common";
|
|
4
|
+
import { projectResult } from "../../dsl/projections.js";
|
|
5
|
+
import { setupActivity } from "../../dsl/setup/ActivityContext.js";
|
|
6
|
+
import { ActivityParamNotFoundError } from "../../errors.js";
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export interface CreateDocumentTypeFromInteractionRunParams {
|
|
10
|
+
/**
|
|
11
|
+
* The execution run object to use. Required.
|
|
12
|
+
* Not required in params since it is usually fetched
|
|
13
|
+
*/
|
|
14
|
+
run: ExecutionRun,
|
|
15
|
+
/**
|
|
16
|
+
* If defined then update the object type with the created type
|
|
17
|
+
*/
|
|
18
|
+
updateObjectId?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface CreateDocumentTypeFromInteractionRun extends DSLActivitySpec<CreateDocumentTypeFromInteractionRunParams> {
|
|
22
|
+
name: 'createDocumentTypeFromInteractionRun';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export async function createDocumentTypeFromInteractionRun(payload: DSLActivityExecutionPayload<CreateDocumentTypeFromInteractionRunParams>) {
|
|
26
|
+
const { params, client } = await setupActivity<CreateDocumentTypeFromInteractionRunParams>(payload);
|
|
27
|
+
|
|
28
|
+
if (!params.run) {
|
|
29
|
+
throw new ActivityParamNotFoundError("run", payload.activity);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const jsonResult = InteractionOutput.from(params.run.result).object();
|
|
33
|
+
|
|
34
|
+
if (!jsonResult.document_type) {
|
|
35
|
+
log.error("No name generated for type: " + JSON.stringify(jsonResult), jsonResult);
|
|
36
|
+
throw new Error("No name generated for type");
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
log.info("Generated schema for type", jsonResult.metadata_schema);
|
|
40
|
+
const typeData: CreateContentObjectTypePayload = {
|
|
41
|
+
name: jsonResult.document_type,
|
|
42
|
+
object_schema: jsonResult.metadata_schema,
|
|
43
|
+
is_chunkable: !!jsonResult.is_chunkable,
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const type = await client.types.create(typeData);
|
|
47
|
+
|
|
48
|
+
if (params.updateObjectId) {
|
|
49
|
+
await client.objects.update(params.updateObjectId, {
|
|
50
|
+
type: type.id,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return projectResult(payload, params, type, { id: type.id, name: type.name });
|
|
55
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { log } from "@temporalio/activity";
|
|
2
|
+
import { ContentObjectStatus, DSLActivityExecutionPayload, DSLActivitySpec } from "@vertesia/common";
|
|
3
|
+
import { setupActivity } from "../../dsl/setup/ActivityContext.js";
|
|
4
|
+
import { ActivityParamNotFoundError, DocumentNotFoundError } from "../../errors.js";
|
|
5
|
+
|
|
6
|
+
interface CreateOrUpdateObjectFromInteractionRunParams {
|
|
7
|
+
/**
|
|
8
|
+
* The execution run object to use. Required.
|
|
9
|
+
* Not required in params since it is usually fetched
|
|
10
|
+
*/
|
|
11
|
+
run_id?: string,
|
|
12
|
+
/**
|
|
13
|
+
* The document type to use. Required if update_existing_id is false.
|
|
14
|
+
* Not required in params since it is usually fetched
|
|
15
|
+
*/
|
|
16
|
+
object_type?: string,
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The id of the document to update. If not provided, a new document will be created
|
|
20
|
+
*/
|
|
21
|
+
update_existing_id?: string,
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The name of the object to use. If not provided, the name will be generated from the interaction result
|
|
25
|
+
*/
|
|
26
|
+
fallback_name?: string, // a name to use if no one was generated by the interaction
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The name of the parent object to use. If not provided, the document will be created at the root level
|
|
30
|
+
*/
|
|
31
|
+
parent?: string, // the parent object id
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The name of the property to use for the text. If not provided, the text will be set to the result of the interaction
|
|
35
|
+
*/
|
|
36
|
+
update_text_from_property?: string,
|
|
37
|
+
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface CreateOrUpdateObjectFromInteractionRun extends DSLActivitySpec<CreateOrUpdateObjectFromInteractionRunParams> {
|
|
41
|
+
name: 'createOrUpdateDocumentFromInteractionRun';
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export async function createOrUpdateDocumentFromInteractionRun(payload: DSLActivityExecutionPayload<CreateOrUpdateObjectFromInteractionRunParams>) {
|
|
45
|
+
const { params, client } = await setupActivity<CreateOrUpdateObjectFromInteractionRunParams>(payload);
|
|
46
|
+
|
|
47
|
+
const runId = params.run_id;
|
|
48
|
+
const objectTypeName = params.object_type;
|
|
49
|
+
|
|
50
|
+
if (!runId) {
|
|
51
|
+
throw new ActivityParamNotFoundError("run_id", payload.activity);
|
|
52
|
+
}
|
|
53
|
+
if (!objectTypeName && !params.update_existing_id) {
|
|
54
|
+
throw new ActivityParamNotFoundError("object_type", payload.activity);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
log.info("Creating document from interaction result", { runId, objectTypeName });
|
|
58
|
+
|
|
59
|
+
const run = await client.runs.retrieve(runId).catch((e) => {
|
|
60
|
+
throw new DocumentNotFoundError(`Error fetching run ${runId}: ${e.message}`);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const type = objectTypeName ?
|
|
64
|
+
await client.types.getTypeByName(objectTypeName).catch((e) => {
|
|
65
|
+
throw new DocumentNotFoundError(`Error fetching type ${objectTypeName}: ${e.message}`);
|
|
66
|
+
})
|
|
67
|
+
: undefined;
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
const result = run.result;
|
|
71
|
+
const inputData = run.parameters;
|
|
72
|
+
|
|
73
|
+
// Try to parse result as JSON, fallback to text if not valid JSON
|
|
74
|
+
let jsonResult: any = null;
|
|
75
|
+
try {
|
|
76
|
+
jsonResult = result.object();
|
|
77
|
+
} catch (e) {
|
|
78
|
+
log.info("Result is not valid JSON, will use text content instead", { error: e instanceof Error ? e.message : String(e) });
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const name = jsonResult?.['name'] || jsonResult?.["title"] || inputData['name'] || params.fallback_name || undefined;
|
|
82
|
+
|
|
83
|
+
const docPayload = {
|
|
84
|
+
name,
|
|
85
|
+
parent: params.parent ?? undefined,
|
|
86
|
+
properties: jsonResult ? jsonResult : {},
|
|
87
|
+
text: !jsonResult ? result.text() : undefined,
|
|
88
|
+
type: type?.id,
|
|
89
|
+
status: ContentObjectStatus.completed,
|
|
90
|
+
generation_run_info: {
|
|
91
|
+
id: run.id,
|
|
92
|
+
date: new Date().toISOString(),
|
|
93
|
+
model: run.modelId,
|
|
94
|
+
target: jsonResult ? 'properties' : 'text'
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
if (params.update_text_from_property) {
|
|
99
|
+
const text = docPayload.properties[params.update_text_from_property];
|
|
100
|
+
if (text) {
|
|
101
|
+
docPayload.text = text;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
//create or update the document
|
|
106
|
+
let newDoc: boolean = false;
|
|
107
|
+
let doc = undefined;
|
|
108
|
+
if (params.update_existing_id) {
|
|
109
|
+
log.info(`Updating existing document ${params.update_existing_id}`);
|
|
110
|
+
doc = await client.objects.update(params.update_existing_id, docPayload, { suppressWorkflows: true });
|
|
111
|
+
} else {
|
|
112
|
+
log.info(`Creating new document of type ${objectTypeName}`);
|
|
113
|
+
doc = await client.objects.create(docPayload);
|
|
114
|
+
newDoc = true;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
log.info(`Document ${objectTypeName + ' '}${doc.id}(${doc.name}) ${newDoc ? 'created' : 'updated'}`);
|
|
118
|
+
return { id: doc.id, isNew: newDoc, type: name }
|
|
119
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { InteractionOutput } from "@vertesia/client";
|
|
2
|
+
import { DSLActivityExecutionPayload, DSLActivitySpec, ExecutionRun } from "@vertesia/common";
|
|
3
|
+
import { setupActivity } from "../../dsl/setup/ActivityContext.js";
|
|
4
|
+
import { ActivityParamNotFoundError } from "../../errors.js";
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export interface UpdateDocumentFromInteractionRunParams {
|
|
8
|
+
/**
|
|
9
|
+
* The execution run object to use. Required.
|
|
10
|
+
* Not required in params since it is usually fetched
|
|
11
|
+
*/
|
|
12
|
+
run?: ExecutionRun,
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface UpdateDocumentFromInteractionRun extends DSLActivitySpec<UpdateDocumentFromInteractionRunParams> {
|
|
16
|
+
name: 'updateDocumentFromInteractionRun';
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export async function updateDocumentFromInteractionRun(payload: DSLActivityExecutionPayload<UpdateDocumentFromInteractionRunParams>) {
|
|
20
|
+
const { params, client, objectId } = await setupActivity<UpdateDocumentFromInteractionRunParams>(payload);
|
|
21
|
+
|
|
22
|
+
if (!params.run) {
|
|
23
|
+
throw new ActivityParamNotFoundError("run", payload.activity);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const docProps = InteractionOutput.from(params.run.result).object();
|
|
27
|
+
|
|
28
|
+
if (!docProps) {
|
|
29
|
+
return { status: "failed", error: "no-props" };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
await client.objects.update(objectId, docProps, { suppressWorkflows: true });
|
|
33
|
+
|
|
34
|
+
return { status: "success" };
|
|
35
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { log } from "@temporalio/activity";
|
|
2
|
+
import { DSLActivityExecutionPayload, DSLActivitySpec } from "@vertesia/common";
|
|
3
|
+
import { setupActivity } from "../dsl/setup/ActivityContext.js";
|
|
4
|
+
import { DocPart } from "../utils/chunks.js";
|
|
5
|
+
import { InteractionExecutionParams, executeInteractionFromActivity } from "./executeInteraction.js";
|
|
6
|
+
|
|
7
|
+
const INT_CHUNK_DOCUMENT = "sys:ChunkDocument"
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
export interface ChunkDocumentResult {
|
|
12
|
+
id: string
|
|
13
|
+
status: "completed" | "failed" | "skipped"
|
|
14
|
+
parts?: string[]
|
|
15
|
+
message?: string
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface ChunkDocumentParams extends InteractionExecutionParams {
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* If true, force chunking even if the document is already chunked
|
|
22
|
+
*/
|
|
23
|
+
force?: boolean;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The interaction name to use for chunking
|
|
27
|
+
* If not set, the default interaction will be used
|
|
28
|
+
*/
|
|
29
|
+
interactionName?: string;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The object type to use for the document parts
|
|
33
|
+
* If not set, the type of the document will be used
|
|
34
|
+
*/
|
|
35
|
+
docPartType?: string;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* If true, create parts as document objects
|
|
39
|
+
*/
|
|
40
|
+
createParts?: boolean;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface ChunkDocument extends DSLActivitySpec<ChunkDocumentParams> {
|
|
44
|
+
name: 'chunkDocument';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
export async function chunkDocument(payload: DSLActivityExecutionPayload<ChunkDocumentParams>): Promise<ChunkDocumentResult> {
|
|
49
|
+
const { params, client, objectId } = await setupActivity<ChunkDocumentParams>(payload);
|
|
50
|
+
|
|
51
|
+
const { force } = params;
|
|
52
|
+
const interactionName = params.interactionName ?? INT_CHUNK_DOCUMENT;
|
|
53
|
+
|
|
54
|
+
log.info(`Object ${objectId} chunking started`);
|
|
55
|
+
|
|
56
|
+
const document = await client.objects.retrieve(objectId, "+text");
|
|
57
|
+
|
|
58
|
+
const type = document.type ? await client.types.retrieve(document.type.id) : undefined;
|
|
59
|
+
|
|
60
|
+
if (!type?.is_chunkable) {
|
|
61
|
+
log.warn('Type is not chunkable for object ID: ' + objectId);
|
|
62
|
+
return { id: objectId, status: "skipped", message: "type not chunkable" }
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
//check if text is present
|
|
66
|
+
if (!document.text) {
|
|
67
|
+
log.warn('No text found for object ID: ' + objectId);
|
|
68
|
+
return { id: objectId, status: "failed", message: "no text found" }
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (!force && document.parts && document.parts.length > 0 && document.parts_etag === document.text_etag) {
|
|
72
|
+
log.info('Document already chunked for object ID: ' + objectId);
|
|
73
|
+
return { id: objectId, status: "skipped", message: "document already chunked with correct etag" }
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
//instrument the text with line numbers
|
|
77
|
+
const lines = document.text.split('\n')
|
|
78
|
+
const instrumented = lines.map((l, i) => `{%${i}%}${l}`).join('\n')
|
|
79
|
+
|
|
80
|
+
const res = await executeInteractionFromActivity(client, interactionName, params, {
|
|
81
|
+
objectId: objectId,
|
|
82
|
+
content: instrumented
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const jsonResult = res.result.object();
|
|
86
|
+
|
|
87
|
+
const parts = jsonResult.parts as DocPart[];
|
|
88
|
+
if (!parts || parts.length === 0) {
|
|
89
|
+
log.warn('No parts found for object ID: ' + objectId, res);
|
|
90
|
+
return { id: objectId, status: "failed", parts: [], message: "no parts found" }
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Only create parts as document if the flag is set
|
|
96
|
+
*/
|
|
97
|
+
if (params.createParts) {
|
|
98
|
+
|
|
99
|
+
const partDocs = await Promise.all(parts.map(async (part, i) => {
|
|
100
|
+
|
|
101
|
+
const text = lines.filter((_l, i) => i >= part.line_number_start && i <= part.line_number_end).join('\n');
|
|
102
|
+
|
|
103
|
+
const location = () => {
|
|
104
|
+
let location = document.location;
|
|
105
|
+
if (location.endsWith('/')) {
|
|
106
|
+
location += document.name + "/" + part.type
|
|
107
|
+
}
|
|
108
|
+
location += '/' + document.name + "/" + part.type;
|
|
109
|
+
return location;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const docPart = await client.objects.create({
|
|
113
|
+
name: part.name,
|
|
114
|
+
parent: objectId,
|
|
115
|
+
text: text,
|
|
116
|
+
location: location(),
|
|
117
|
+
properties: {
|
|
118
|
+
part_number: i + 1,
|
|
119
|
+
etag: document.text_etag,
|
|
120
|
+
source_line_start: part.line_number_start,
|
|
121
|
+
source_line_end: part.line_number_end,
|
|
122
|
+
title: part.name
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
return docPart;
|
|
126
|
+
}));
|
|
127
|
+
|
|
128
|
+
//delete previous parts
|
|
129
|
+
if (document.parts && document.parts.length > 0) {
|
|
130
|
+
log.info('Deleting previous parts for object ID: ' + objectId, { parts: document.parts });
|
|
131
|
+
await Promise.all(document.parts.map(async (partId) => {
|
|
132
|
+
await client.objects.delete(partId);
|
|
133
|
+
}));
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
await client.objects.update(objectId, {
|
|
137
|
+
parts: partDocs.map(p => p.id),
|
|
138
|
+
parts_etag: document.text_etag
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
log.info(`Object ${objectId} chunking completed`, { parts: document.parts });
|
|
143
|
+
|
|
144
|
+
return { id: objectId, status: "completed", parts: document.parts }
|
|
145
|
+
|
|
146
|
+
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { log, activityInfo } from "@temporalio/activity";
|
|
2
|
+
import { NodeStreamSource } from "@vertesia/client/node";
|
|
3
|
+
import { DSLActivityExecutionPayload, DSLActivitySpec } from "@vertesia/common";
|
|
4
|
+
import { Readable } from "stream";
|
|
5
|
+
import { setupActivity } from "../dsl/setup/ActivityContext.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Directories in the agent workspace to copy from parent to child.
|
|
9
|
+
*/
|
|
10
|
+
const WORKSPACE_DIRECTORIES = ['scripts', 'files', 'skills', 'docs', 'out'];
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Files that should never be copied (child has its own).
|
|
14
|
+
*/
|
|
15
|
+
const EXCLUDED_FILES = ['conversation.json', 'tools.json'];
|
|
16
|
+
|
|
17
|
+
export interface CopyParentArtifactsParams {
|
|
18
|
+
parent_run_id: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface CopyParentArtifacts extends DSLActivitySpec<CopyParentArtifactsParams> {
|
|
22
|
+
name: 'copyParentArtifacts';
|
|
23
|
+
projection?: never;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Copy workspace artifacts from parent workflow's agent space to current workflow's agent space.
|
|
28
|
+
*
|
|
29
|
+
* Copies: scripts/, files/, skills/, docs/, out/
|
|
30
|
+
* Excludes: conversation.json, tools.json
|
|
31
|
+
*/
|
|
32
|
+
export async function copyParentArtifacts(
|
|
33
|
+
payload: DSLActivityExecutionPayload<CopyParentArtifactsParams>
|
|
34
|
+
): Promise<{ copied: number; files: string[] }> {
|
|
35
|
+
const { client, params } = await setupActivity<CopyParentArtifactsParams>(payload);
|
|
36
|
+
const childRunId = activityInfo().workflowExecution.runId;
|
|
37
|
+
const parentRunId = params.parent_run_id;
|
|
38
|
+
|
|
39
|
+
log.info(`Copying artifacts from parent ${parentRunId} to child ${childRunId}`);
|
|
40
|
+
|
|
41
|
+
// List all files in parent's agent space
|
|
42
|
+
const parentFiles = await client.files.listArtifacts(parentRunId);
|
|
43
|
+
|
|
44
|
+
if (parentFiles.length === 0) {
|
|
45
|
+
log.info("No artifacts in parent agent space");
|
|
46
|
+
return { copied: 0, files: [] };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const copiedFiles: string[] = [];
|
|
50
|
+
|
|
51
|
+
for (const fullPath of parentFiles) {
|
|
52
|
+
const relativePath = extractRelativePath(fullPath, parentRunId);
|
|
53
|
+
if (!relativePath) continue;
|
|
54
|
+
|
|
55
|
+
// Only copy workspace directories
|
|
56
|
+
const dir = relativePath.split('/')[0];
|
|
57
|
+
if (!WORKSPACE_DIRECTORIES.includes(dir)) continue;
|
|
58
|
+
|
|
59
|
+
// Skip excluded files
|
|
60
|
+
const fileName = relativePath.split('/').pop() || '';
|
|
61
|
+
if (EXCLUDED_FILES.includes(fileName)) continue;
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
await copyArtifact(client, parentRunId, childRunId, relativePath);
|
|
65
|
+
copiedFiles.push(relativePath);
|
|
66
|
+
} catch (err: any) {
|
|
67
|
+
log.warn(`Failed to copy ${relativePath}: ${err.message}`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
log.info(`Copied ${copiedFiles.length} artifacts from parent`);
|
|
72
|
+
return { copied: copiedFiles.length, files: copiedFiles };
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Extract relative path from full artifact storage path.
|
|
77
|
+
* Storage paths can be: "store_xxx/agents/{runId}/..." or "agents/{runId}/..."
|
|
78
|
+
*/
|
|
79
|
+
function extractRelativePath(fullPath: string, runId: string): string | null {
|
|
80
|
+
// Look for the pattern: agents/{runId}/
|
|
81
|
+
const marker = `/agents/${runId}/`;
|
|
82
|
+
const idx = fullPath.lastIndexOf(marker);
|
|
83
|
+
if (idx >= 0) {
|
|
84
|
+
return fullPath.slice(idx + marker.length);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Also try without leading slash
|
|
88
|
+
const legacyPrefix = `agents/${runId}/`;
|
|
89
|
+
if (fullPath.startsWith(legacyPrefix)) {
|
|
90
|
+
return fullPath.slice(legacyPrefix.length);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// If path contains the runId, try to extract after it
|
|
94
|
+
const runIdIdx = fullPath.indexOf(runId);
|
|
95
|
+
if (runIdIdx >= 0) {
|
|
96
|
+
const afterRunId = fullPath.slice(runIdIdx + runId.length);
|
|
97
|
+
if (afterRunId.startsWith('/')) {
|
|
98
|
+
return afterRunId.slice(1);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Copy a single artifact from parent to child agent space
|
|
107
|
+
*/
|
|
108
|
+
async function copyArtifact(
|
|
109
|
+
client: any,
|
|
110
|
+
parentRunId: string,
|
|
111
|
+
childRunId: string,
|
|
112
|
+
relativePath: string
|
|
113
|
+
): Promise<void> {
|
|
114
|
+
// Download from parent's agent space
|
|
115
|
+
const stream = await client.files.downloadArtifact(parentRunId, relativePath);
|
|
116
|
+
|
|
117
|
+
// Convert web stream to node stream for upload
|
|
118
|
+
const nodeStream = Readable.fromWeb(stream as any);
|
|
119
|
+
|
|
120
|
+
// Determine mime type from extension
|
|
121
|
+
const mimeType = getMimeType(relativePath);
|
|
122
|
+
const fileName = relativePath.split('/').pop() || relativePath;
|
|
123
|
+
|
|
124
|
+
// Upload to child's agent space at the same relative path
|
|
125
|
+
const source = new NodeStreamSource(
|
|
126
|
+
nodeStream,
|
|
127
|
+
fileName,
|
|
128
|
+
mimeType
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
await client.files.uploadArtifact(childRunId, relativePath, source);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Get mime type from file extension
|
|
136
|
+
*/
|
|
137
|
+
function getMimeType(filePath: string): string {
|
|
138
|
+
const ext = filePath.split('.').pop()?.toLowerCase();
|
|
139
|
+
const mimeTypes: Record<string, string> = {
|
|
140
|
+
'json': 'application/json',
|
|
141
|
+
'txt': 'text/plain',
|
|
142
|
+
'md': 'text/markdown',
|
|
143
|
+
'html': 'text/html',
|
|
144
|
+
'csv': 'text/csv',
|
|
145
|
+
'png': 'image/png',
|
|
146
|
+
'jpg': 'image/jpeg',
|
|
147
|
+
'jpeg': 'image/jpeg',
|
|
148
|
+
'gif': 'image/gif',
|
|
149
|
+
'svg': 'image/svg+xml',
|
|
150
|
+
'pdf': 'application/pdf',
|
|
151
|
+
'xml': 'application/xml',
|
|
152
|
+
'zip': 'application/zip',
|
|
153
|
+
'js': 'application/javascript',
|
|
154
|
+
'ts': 'application/typescript',
|
|
155
|
+
'py': 'text/x-python',
|
|
156
|
+
'sh': 'text/x-shellscript',
|
|
157
|
+
'bash': 'text/x-shellscript',
|
|
158
|
+
'yaml': 'text/yaml',
|
|
159
|
+
'yml': 'text/yaml',
|
|
160
|
+
};
|
|
161
|
+
return mimeTypes[ext || ''] || 'application/octet-stream';
|
|
162
|
+
}
|