helixlife-expert-cli 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +159 -0
- package/cli/bin/helixlife-expert.js +3 -0
- package/cli/dist/core/api/client.d.ts +31 -0
- package/cli/dist/core/api/client.d.ts.map +1 -0
- package/cli/dist/core/api/client.js +183 -0
- package/cli/dist/core/api/client.js.map +1 -0
- package/cli/dist/core/api/http.d.ts +3 -0
- package/cli/dist/core/api/http.d.ts.map +1 -0
- package/cli/dist/core/api/http.js +22 -0
- package/cli/dist/core/api/http.js.map +1 -0
- package/cli/dist/core/api/response.d.ts +48 -0
- package/cli/dist/core/api/response.d.ts.map +1 -0
- package/cli/dist/core/api/response.js +84 -0
- package/cli/dist/core/api/response.js.map +1 -0
- package/cli/dist/core/api/sse.d.ts +6 -0
- package/cli/dist/core/api/sse.d.ts.map +1 -0
- package/cli/dist/core/api/sse.js +60 -0
- package/cli/dist/core/api/sse.js.map +1 -0
- package/cli/dist/core/auth/index.d.ts +35 -0
- package/cli/dist/core/auth/index.d.ts.map +1 -0
- package/cli/dist/core/auth/index.js +150 -0
- package/cli/dist/core/auth/index.js.map +1 -0
- package/cli/dist/core/env-config.d.ts +16 -0
- package/cli/dist/core/env-config.d.ts.map +1 -0
- package/cli/dist/core/env-config.js +80 -0
- package/cli/dist/core/env-config.js.map +1 -0
- package/cli/dist/core/errors.d.ts +20 -0
- package/cli/dist/core/errors.d.ts.map +1 -0
- package/cli/dist/core/errors.js +28 -0
- package/cli/dist/core/errors.js.map +1 -0
- package/cli/dist/core/index.d.ts +16 -0
- package/cli/dist/core/index.d.ts.map +1 -0
- package/cli/dist/core/index.js +16 -0
- package/cli/dist/core/index.js.map +1 -0
- package/cli/dist/core/interactive.d.ts +18 -0
- package/cli/dist/core/interactive.d.ts.map +1 -0
- package/cli/dist/core/interactive.js +74 -0
- package/cli/dist/core/interactive.js.map +1 -0
- package/cli/dist/core/output/index.d.ts +29 -0
- package/cli/dist/core/output/index.d.ts.map +1 -0
- package/cli/dist/core/output/index.js +153 -0
- package/cli/dist/core/output/index.js.map +1 -0
- package/cli/dist/core/parse.d.ts +9 -0
- package/cli/dist/core/parse.d.ts.map +1 -0
- package/cli/dist/core/parse.js +31 -0
- package/cli/dist/core/parse.js.map +1 -0
- package/cli/dist/core/paths.d.ts +21 -0
- package/cli/dist/core/paths.d.ts.map +1 -0
- package/cli/dist/core/paths.js +65 -0
- package/cli/dist/core/paths.js.map +1 -0
- package/cli/dist/core/sse-utils.d.ts +49 -0
- package/cli/dist/core/sse-utils.d.ts.map +1 -0
- package/cli/dist/core/sse-utils.js +181 -0
- package/cli/dist/core/sse-utils.js.map +1 -0
- package/cli/dist/core/terminal.d.ts +2 -0
- package/cli/dist/core/terminal.d.ts.map +1 -0
- package/cli/dist/core/terminal.js +6 -0
- package/cli/dist/core/terminal.js.map +1 -0
- package/cli/dist/core/token/index.d.ts +5 -0
- package/cli/dist/core/token/index.d.ts.map +1 -0
- package/cli/dist/core/token/index.js +26 -0
- package/cli/dist/core/token/index.js.map +1 -0
- package/cli/dist/core/types/config.d.ts +8 -0
- package/cli/dist/core/types/config.d.ts.map +1 -0
- package/cli/dist/core/types/config.js +30 -0
- package/cli/dist/core/types/config.js.map +1 -0
- package/cli/dist/core/version.d.ts +2 -0
- package/cli/dist/core/version.d.ts.map +1 -0
- package/cli/dist/core/version.js +10 -0
- package/cli/dist/core/version.js.map +1 -0
- package/cli/dist/index.d.ts +2 -0
- package/cli/dist/index.d.ts.map +1 -0
- package/cli/dist/index.js +23 -0
- package/cli/dist/index.js.map +1 -0
- package/cli/dist/modules/analysis/constants.d.ts +3 -0
- package/cli/dist/modules/analysis/constants.d.ts.map +1 -0
- package/cli/dist/modules/analysis/constants.js +3 -0
- package/cli/dist/modules/analysis/constants.js.map +1 -0
- package/cli/dist/modules/analysis/index.d.ts +3 -0
- package/cli/dist/modules/analysis/index.d.ts.map +1 -0
- package/cli/dist/modules/analysis/index.js +23 -0
- package/cli/dist/modules/analysis/index.js.map +1 -0
- package/cli/dist/modules/auth/index.d.ts +3 -0
- package/cli/dist/modules/auth/index.d.ts.map +1 -0
- package/cli/dist/modules/auth/index.js +76 -0
- package/cli/dist/modules/auth/index.js.map +1 -0
- package/cli/dist/modules/expert-scaffold.d.ts +27 -0
- package/cli/dist/modules/expert-scaffold.d.ts.map +1 -0
- package/cli/dist/modules/expert-scaffold.js +25 -0
- package/cli/dist/modules/expert-scaffold.js.map +1 -0
- package/cli/dist/modules/fund/clinical/apps.d.ts +19 -0
- package/cli/dist/modules/fund/clinical/apps.d.ts.map +1 -0
- package/cli/dist/modules/fund/clinical/apps.js +14 -0
- package/cli/dist/modules/fund/clinical/apps.js.map +1 -0
- package/cli/dist/modules/fund/clinical/command-utils.d.ts +4 -0
- package/cli/dist/modules/fund/clinical/command-utils.d.ts.map +1 -0
- package/cli/dist/modules/fund/clinical/command-utils.js +40 -0
- package/cli/dist/modules/fund/clinical/command-utils.js.map +1 -0
- package/cli/dist/modules/fund/clinical/commands/article-create.d.ts +9 -0
- package/cli/dist/modules/fund/clinical/commands/article-create.d.ts.map +1 -0
- package/cli/dist/modules/fund/clinical/commands/article-create.js +99 -0
- package/cli/dist/modules/fund/clinical/commands/article-create.js.map +1 -0
- package/cli/dist/modules/fund/clinical/commands/article-download.d.ts +30 -0
- package/cli/dist/modules/fund/clinical/commands/article-download.d.ts.map +1 -0
- package/cli/dist/modules/fund/clinical/commands/article-download.js +153 -0
- package/cli/dist/modules/fund/clinical/commands/article-download.js.map +1 -0
- package/cli/dist/modules/fund/clinical/commands/four-elements-create.d.ts +7 -0
- package/cli/dist/modules/fund/clinical/commands/four-elements-create.d.ts.map +1 -0
- package/cli/dist/modules/fund/clinical/commands/four-elements-create.js +81 -0
- package/cli/dist/modules/fund/clinical/commands/four-elements-create.js.map +1 -0
- package/cli/dist/modules/fund/clinical/commands/four-elements-precheck.d.ts +7 -0
- package/cli/dist/modules/fund/clinical/commands/four-elements-precheck.d.ts.map +1 -0
- package/cli/dist/modules/fund/clinical/commands/four-elements-precheck.js +76 -0
- package/cli/dist/modules/fund/clinical/commands/four-elements-precheck.js.map +1 -0
- package/cli/dist/modules/fund/clinical/commands/four-elements-update.d.ts +16 -0
- package/cli/dist/modules/fund/clinical/commands/four-elements-update.d.ts.map +1 -0
- package/cli/dist/modules/fund/clinical/commands/four-elements-update.js +108 -0
- package/cli/dist/modules/fund/clinical/commands/four-elements-update.js.map +1 -0
- package/cli/dist/modules/fund/clinical/commands/sample-size.d.ts +14 -0
- package/cli/dist/modules/fund/clinical/commands/sample-size.d.ts.map +1 -0
- package/cli/dist/modules/fund/clinical/commands/sample-size.js +164 -0
- package/cli/dist/modules/fund/clinical/commands/sample-size.js.map +1 -0
- package/cli/dist/modules/fund/clinical/commands/topic-evaluation-create.d.ts +25 -0
- package/cli/dist/modules/fund/clinical/commands/topic-evaluation-create.d.ts.map +1 -0
- package/cli/dist/modules/fund/clinical/commands/topic-evaluation-create.js +228 -0
- package/cli/dist/modules/fund/clinical/commands/topic-evaluation-create.js.map +1 -0
- package/cli/dist/modules/fund/clinical/commands/topic-evaluation-parameters.d.ts +45 -0
- package/cli/dist/modules/fund/clinical/commands/topic-evaluation-parameters.d.ts.map +1 -0
- package/cli/dist/modules/fund/clinical/commands/topic-evaluation-parameters.js +211 -0
- package/cli/dist/modules/fund/clinical/commands/topic-evaluation-parameters.js.map +1 -0
- package/cli/dist/modules/fund/clinical/constants.d.ts +85 -0
- package/cli/dist/modules/fund/clinical/constants.d.ts.map +1 -0
- package/cli/dist/modules/fund/clinical/constants.js +161 -0
- package/cli/dist/modules/fund/clinical/constants.js.map +1 -0
- package/cli/dist/modules/fund/clinical/form-rules.d.ts +56 -0
- package/cli/dist/modules/fund/clinical/form-rules.d.ts.map +1 -0
- package/cli/dist/modules/fund/clinical/form-rules.js +542 -0
- package/cli/dist/modules/fund/clinical/form-rules.js.map +1 -0
- package/cli/dist/modules/fund/clinical/four-elements.d.ts +46 -0
- package/cli/dist/modules/fund/clinical/four-elements.d.ts.map +1 -0
- package/cli/dist/modules/fund/clinical/four-elements.js +190 -0
- package/cli/dist/modules/fund/clinical/four-elements.js.map +1 -0
- package/cli/dist/modules/fund/clinical/index.d.ts +3 -0
- package/cli/dist/modules/fund/clinical/index.d.ts.map +1 -0
- package/cli/dist/modules/fund/clinical/index.js +176 -0
- package/cli/dist/modules/fund/clinical/index.js.map +1 -0
- package/cli/dist/modules/fund/clinical/parameters.d.ts +51 -0
- package/cli/dist/modules/fund/clinical/parameters.d.ts.map +1 -0
- package/cli/dist/modules/fund/clinical/parameters.js +145 -0
- package/cli/dist/modules/fund/clinical/parameters.js.map +1 -0
- package/cli/dist/modules/fund/clinical/sample-size.d.ts +130 -0
- package/cli/dist/modules/fund/clinical/sample-size.d.ts.map +1 -0
- package/cli/dist/modules/fund/clinical/sample-size.js +356 -0
- package/cli/dist/modules/fund/clinical/sample-size.js.map +1 -0
- package/cli/dist/modules/fund/clinical/session-cache.d.ts +25 -0
- package/cli/dist/modules/fund/clinical/session-cache.d.ts.map +1 -0
- package/cli/dist/modules/fund/clinical/session-cache.js +100 -0
- package/cli/dist/modules/fund/clinical/session-cache.js.map +1 -0
- package/cli/dist/modules/fund/clinical/sse-utils.d.ts +22 -0
- package/cli/dist/modules/fund/clinical/sse-utils.d.ts.map +1 -0
- package/cli/dist/modules/fund/clinical/sse-utils.js +80 -0
- package/cli/dist/modules/fund/clinical/sse-utils.js.map +1 -0
- package/cli/dist/modules/fund/constants.d.ts +3 -0
- package/cli/dist/modules/fund/constants.d.ts.map +1 -0
- package/cli/dist/modules/fund/constants.js +3 -0
- package/cli/dist/modules/fund/constants.js.map +1 -0
- package/cli/dist/modules/fund/index.d.ts +3 -0
- package/cli/dist/modules/fund/index.d.ts.map +1 -0
- package/cli/dist/modules/fund/index.js +28 -0
- package/cli/dist/modules/fund/index.js.map +1 -0
- package/cli/dist/modules/fund/nsfc/apps.d.ts +54 -0
- package/cli/dist/modules/fund/nsfc/apps.d.ts.map +1 -0
- package/cli/dist/modules/fund/nsfc/apps.js +76 -0
- package/cli/dist/modules/fund/nsfc/apps.js.map +1 -0
- package/cli/dist/modules/fund/nsfc/article-cache.d.ts +14 -0
- package/cli/dist/modules/fund/nsfc/article-cache.d.ts.map +1 -0
- package/cli/dist/modules/fund/nsfc/article-cache.js +79 -0
- package/cli/dist/modules/fund/nsfc/article-cache.js.map +1 -0
- package/cli/dist/modules/fund/nsfc/commands/article-create.d.ts +8 -0
- package/cli/dist/modules/fund/nsfc/commands/article-create.d.ts.map +1 -0
- package/cli/dist/modules/fund/nsfc/commands/article-create.js +108 -0
- package/cli/dist/modules/fund/nsfc/commands/article-create.js.map +1 -0
- package/cli/dist/modules/fund/nsfc/commands/article-download.d.ts +42 -0
- package/cli/dist/modules/fund/nsfc/commands/article-download.d.ts.map +1 -0
- package/cli/dist/modules/fund/nsfc/commands/article-download.js +189 -0
- package/cli/dist/modules/fund/nsfc/commands/article-download.js.map +1 -0
- package/cli/dist/modules/fund/nsfc/commands/format-convert.d.ts +9 -0
- package/cli/dist/modules/fund/nsfc/commands/format-convert.d.ts.map +1 -0
- package/cli/dist/modules/fund/nsfc/commands/format-convert.js +98 -0
- package/cli/dist/modules/fund/nsfc/commands/format-convert.js.map +1 -0
- package/cli/dist/modules/fund/nsfc/commands/hypothesis-analyze.d.ts +12 -0
- package/cli/dist/modules/fund/nsfc/commands/hypothesis-analyze.d.ts.map +1 -0
- package/cli/dist/modules/fund/nsfc/commands/hypothesis-analyze.js +351 -0
- package/cli/dist/modules/fund/nsfc/commands/hypothesis-analyze.js.map +1 -0
- package/cli/dist/modules/fund/nsfc/commands/hypothesis-create.d.ts +21 -0
- package/cli/dist/modules/fund/nsfc/commands/hypothesis-create.d.ts.map +1 -0
- package/cli/dist/modules/fund/nsfc/commands/hypothesis-create.js +197 -0
- package/cli/dist/modules/fund/nsfc/commands/hypothesis-create.js.map +1 -0
- package/cli/dist/modules/fund/nsfc/commands/hypothesis-figure.d.ts +9 -0
- package/cli/dist/modules/fund/nsfc/commands/hypothesis-figure.d.ts.map +1 -0
- package/cli/dist/modules/fund/nsfc/commands/hypothesis-figure.js +120 -0
- package/cli/dist/modules/fund/nsfc/commands/hypothesis-figure.js.map +1 -0
- package/cli/dist/modules/fund/nsfc/commands/hypothesis-genes-select.d.ts +11 -0
- package/cli/dist/modules/fund/nsfc/commands/hypothesis-genes-select.d.ts.map +1 -0
- package/cli/dist/modules/fund/nsfc/commands/hypothesis-genes-select.js +125 -0
- package/cli/dist/modules/fund/nsfc/commands/hypothesis-genes-select.js.map +1 -0
- package/cli/dist/modules/fund/nsfc/commands/hypothesis-pick.d.ts +11 -0
- package/cli/dist/modules/fund/nsfc/commands/hypothesis-pick.d.ts.map +1 -0
- package/cli/dist/modules/fund/nsfc/commands/hypothesis-pick.js +109 -0
- package/cli/dist/modules/fund/nsfc/commands/hypothesis-pick.js.map +1 -0
- package/cli/dist/modules/fund/nsfc/commands/outline-confirm.d.ts +9 -0
- package/cli/dist/modules/fund/nsfc/commands/outline-confirm.d.ts.map +1 -0
- package/cli/dist/modules/fund/nsfc/commands/outline-confirm.js +64 -0
- package/cli/dist/modules/fund/nsfc/commands/outline-confirm.js.map +1 -0
- package/cli/dist/modules/fund/nsfc/commands/outline-create.d.ts +8 -0
- package/cli/dist/modules/fund/nsfc/commands/outline-create.d.ts.map +1 -0
- package/cli/dist/modules/fund/nsfc/commands/outline-create.js +103 -0
- package/cli/dist/modules/fund/nsfc/commands/outline-create.js.map +1 -0
- package/cli/dist/modules/fund/nsfc/commands/research-path-confirm.d.ts +9 -0
- package/cli/dist/modules/fund/nsfc/commands/research-path-confirm.d.ts.map +1 -0
- package/cli/dist/modules/fund/nsfc/commands/research-path-confirm.js +176 -0
- package/cli/dist/modules/fund/nsfc/commands/research-path-confirm.js.map +1 -0
- package/cli/dist/modules/fund/nsfc/commands/tech-roadmap.d.ts +9 -0
- package/cli/dist/modules/fund/nsfc/commands/tech-roadmap.d.ts.map +1 -0
- package/cli/dist/modules/fund/nsfc/commands/tech-roadmap.js +190 -0
- package/cli/dist/modules/fund/nsfc/commands/tech-roadmap.js.map +1 -0
- package/cli/dist/modules/fund/nsfc/constants.d.ts +96 -0
- package/cli/dist/modules/fund/nsfc/constants.d.ts.map +1 -0
- package/cli/dist/modules/fund/nsfc/constants.js +156 -0
- package/cli/dist/modules/fund/nsfc/constants.js.map +1 -0
- package/cli/dist/modules/fund/nsfc/graph-render.d.ts +25 -0
- package/cli/dist/modules/fund/nsfc/graph-render.d.ts.map +1 -0
- package/cli/dist/modules/fund/nsfc/graph-render.js +212 -0
- package/cli/dist/modules/fund/nsfc/graph-render.js.map +1 -0
- package/cli/dist/modules/fund/nsfc/index.d.ts +4 -0
- package/cli/dist/modules/fund/nsfc/index.d.ts.map +1 -0
- package/cli/dist/modules/fund/nsfc/index.js +238 -0
- package/cli/dist/modules/fund/nsfc/index.js.map +1 -0
- package/cli/dist/modules/fund/nsfc/mermaid-render.d.ts +18 -0
- package/cli/dist/modules/fund/nsfc/mermaid-render.d.ts.map +1 -0
- package/cli/dist/modules/fund/nsfc/mermaid-render.js +47 -0
- package/cli/dist/modules/fund/nsfc/mermaid-render.js.map +1 -0
- package/cli/dist/modules/fund/nsfc/parse-hypothesis.d.ts +76 -0
- package/cli/dist/modules/fund/nsfc/parse-hypothesis.d.ts.map +1 -0
- package/cli/dist/modules/fund/nsfc/parse-hypothesis.js +278 -0
- package/cli/dist/modules/fund/nsfc/parse-hypothesis.js.map +1 -0
- package/cli/dist/modules/fund/nsfc/parse-outline.d.ts +23 -0
- package/cli/dist/modules/fund/nsfc/parse-outline.d.ts.map +1 -0
- package/cli/dist/modules/fund/nsfc/parse-outline.js +91 -0
- package/cli/dist/modules/fund/nsfc/parse-outline.js.map +1 -0
- package/cli/dist/modules/fund/nsfc/png-watermark.d.ts +24 -0
- package/cli/dist/modules/fund/nsfc/png-watermark.d.ts.map +1 -0
- package/cli/dist/modules/fund/nsfc/png-watermark.js +78 -0
- package/cli/dist/modules/fund/nsfc/png-watermark.js.map +1 -0
- package/cli/dist/modules/fund/nsfc/prompt-hypothesis.d.ts +20 -0
- package/cli/dist/modules/fund/nsfc/prompt-hypothesis.d.ts.map +1 -0
- package/cli/dist/modules/fund/nsfc/prompt-hypothesis.js +107 -0
- package/cli/dist/modules/fund/nsfc/prompt-hypothesis.js.map +1 -0
- package/cli/dist/modules/fund/nsfc/prompt-step2.d.ts +18 -0
- package/cli/dist/modules/fund/nsfc/prompt-step2.d.ts.map +1 -0
- package/cli/dist/modules/fund/nsfc/prompt-step2.js +107 -0
- package/cli/dist/modules/fund/nsfc/prompt-step2.js.map +1 -0
- package/cli/dist/modules/fund/nsfc/request-body.d.ts +47 -0
- package/cli/dist/modules/fund/nsfc/request-body.d.ts.map +1 -0
- package/cli/dist/modules/fund/nsfc/request-body.js +38 -0
- package/cli/dist/modules/fund/nsfc/request-body.js.map +1 -0
- package/cli/dist/modules/fund/nsfc/session-cache.d.ts +48 -0
- package/cli/dist/modules/fund/nsfc/session-cache.d.ts.map +1 -0
- package/cli/dist/modules/fund/nsfc/session-cache.js +90 -0
- package/cli/dist/modules/fund/nsfc/session-cache.js.map +1 -0
- package/cli/dist/modules/fund/nsfc/sse-utils.d.ts +22 -0
- package/cli/dist/modules/fund/nsfc/sse-utils.d.ts.map +1 -0
- package/cli/dist/modules/fund/nsfc/sse-utils.js +81 -0
- package/cli/dist/modules/fund/nsfc/sse-utils.js.map +1 -0
- package/cli/dist/modules/fund/nsfc/upload.d.ts +3 -0
- package/cli/dist/modules/fund/nsfc/upload.d.ts.map +1 -0
- package/cli/dist/modules/fund/nsfc/upload.js +59 -0
- package/cli/dist/modules/fund/nsfc/upload.js.map +1 -0
- package/cli/dist/modules/fund/nsfc/validate.d.ts +30 -0
- package/cli/dist/modules/fund/nsfc/validate.d.ts.map +1 -0
- package/cli/dist/modules/fund/nsfc/validate.js +91 -0
- package/cli/dist/modules/fund/nsfc/validate.js.map +1 -0
- package/cli/dist/modules/literature/commands/workflow-list.d.ts +5 -0
- package/cli/dist/modules/literature/commands/workflow-list.d.ts.map +1 -0
- package/cli/dist/modules/literature/commands/workflow-list.js +9 -0
- package/cli/dist/modules/literature/commands/workflow-list.js.map +1 -0
- package/cli/dist/modules/literature/commands/workflow-params.d.ts +6 -0
- package/cli/dist/modules/literature/commands/workflow-params.d.ts.map +1 -0
- package/cli/dist/modules/literature/commands/workflow-params.js +9 -0
- package/cli/dist/modules/literature/commands/workflow-params.js.map +1 -0
- package/cli/dist/modules/literature/commands/workflow-run.d.ts +7 -0
- package/cli/dist/modules/literature/commands/workflow-run.d.ts.map +1 -0
- package/cli/dist/modules/literature/commands/workflow-run.js +10 -0
- package/cli/dist/modules/literature/commands/workflow-run.js.map +1 -0
- package/cli/dist/modules/literature/constants.d.ts +20 -0
- package/cli/dist/modules/literature/constants.d.ts.map +1 -0
- package/cli/dist/modules/literature/constants.js +56 -0
- package/cli/dist/modules/literature/constants.js.map +1 -0
- package/cli/dist/modules/literature/index.d.ts +3 -0
- package/cli/dist/modules/literature/index.d.ts.map +1 -0
- package/cli/dist/modules/literature/index.js +63 -0
- package/cli/dist/modules/literature/index.js.map +1 -0
- package/cli/dist/modules/meta/analysis.d.ts +127 -0
- package/cli/dist/modules/meta/analysis.d.ts.map +1 -0
- package/cli/dist/modules/meta/analysis.js +1165 -0
- package/cli/dist/modules/meta/analysis.js.map +1 -0
- package/cli/dist/modules/meta/api.d.ts +11 -0
- package/cli/dist/modules/meta/api.d.ts.map +1 -0
- package/cli/dist/modules/meta/api.js +40 -0
- package/cli/dist/modules/meta/api.js.map +1 -0
- package/cli/dist/modules/meta/commands.d.ts +3 -0
- package/cli/dist/modules/meta/commands.d.ts.map +1 -0
- package/cli/dist/modules/meta/commands.js +1185 -0
- package/cli/dist/modules/meta/commands.js.map +1 -0
- package/cli/dist/modules/meta/constants.d.ts +8 -0
- package/cli/dist/modules/meta/constants.d.ts.map +1 -0
- package/cli/dist/modules/meta/constants.js +9 -0
- package/cli/dist/modules/meta/constants.js.map +1 -0
- package/cli/dist/modules/meta/extraction.d.ts +206 -0
- package/cli/dist/modules/meta/extraction.d.ts.map +1 -0
- package/cli/dist/modules/meta/extraction.js +1248 -0
- package/cli/dist/modules/meta/extraction.js.map +1 -0
- package/cli/dist/modules/meta/index.d.ts +3 -0
- package/cli/dist/modules/meta/index.d.ts.map +1 -0
- package/cli/dist/modules/meta/index.js +19 -0
- package/cli/dist/modules/meta/index.js.map +1 -0
- package/cli/dist/modules/meta/node.d.ts +70 -0
- package/cli/dist/modules/meta/node.d.ts.map +1 -0
- package/cli/dist/modules/meta/node.js +167 -0
- package/cli/dist/modules/meta/node.js.map +1 -0
- package/cli/dist/modules/meta/plot-params.d.ts +82 -0
- package/cli/dist/modules/meta/plot-params.d.ts.map +1 -0
- package/cli/dist/modules/meta/plot-params.js +1179 -0
- package/cli/dist/modules/meta/plot-params.js.map +1 -0
- package/cli/dist/modules/meta/prisma-flow-docx.d.ts +23 -0
- package/cli/dist/modules/meta/prisma-flow-docx.d.ts.map +1 -0
- package/cli/dist/modules/meta/prisma-flow-docx.js +302 -0
- package/cli/dist/modules/meta/prisma-flow-docx.js.map +1 -0
- package/cli/dist/modules/meta/retrieve.d.ts +113 -0
- package/cli/dist/modules/meta/retrieve.d.ts.map +1 -0
- package/cli/dist/modules/meta/retrieve.js +913 -0
- package/cli/dist/modules/meta/retrieve.js.map +1 -0
- package/cli/dist/modules/meta/screening.d.ts +179 -0
- package/cli/dist/modules/meta/screening.d.ts.map +1 -0
- package/cli/dist/modules/meta/screening.js +1255 -0
- package/cli/dist/modules/meta/screening.js.map +1 -0
- package/cli/dist/modules/meta/topic.d.ts +110 -0
- package/cli/dist/modules/meta/topic.d.ts.map +1 -0
- package/cli/dist/modules/meta/topic.js +865 -0
- package/cli/dist/modules/meta/topic.js.map +1 -0
- package/cli/dist/modules/meta/types.d.ts +49 -0
- package/cli/dist/modules/meta/types.d.ts.map +1 -0
- package/cli/dist/modules/meta/types.js +2 -0
- package/cli/dist/modules/meta/types.js.map +1 -0
- package/cli/dist/modules/meta/workflow.d.ts +154 -0
- package/cli/dist/modules/meta/workflow.d.ts.map +1 -0
- package/cli/dist/modules/meta/workflow.js +956 -0
- package/cli/dist/modules/meta/workflow.js.map +1 -0
- package/cli/dist/modules/meta/writing.d.ts +83 -0
- package/cli/dist/modules/meta/writing.d.ts.map +1 -0
- package/cli/dist/modules/meta/writing.js +1077 -0
- package/cli/dist/modules/meta/writing.js.map +1 -0
- package/cli/dist/modules/proposal/artifacts.d.ts +18 -0
- package/cli/dist/modules/proposal/artifacts.d.ts.map +1 -0
- package/cli/dist/modules/proposal/artifacts.js +43 -0
- package/cli/dist/modules/proposal/artifacts.js.map +1 -0
- package/cli/dist/modules/proposal/commands/basic-create.d.ts +22 -0
- package/cli/dist/modules/proposal/commands/basic-create.d.ts.map +1 -0
- package/cli/dist/modules/proposal/commands/basic-create.js +81 -0
- package/cli/dist/modules/proposal/commands/basic-create.js.map +1 -0
- package/cli/dist/modules/proposal/commands/basic-result.d.ts +24 -0
- package/cli/dist/modules/proposal/commands/basic-result.d.ts.map +1 -0
- package/cli/dist/modules/proposal/commands/basic-result.js +96 -0
- package/cli/dist/modules/proposal/commands/basic-result.js.map +1 -0
- package/cli/dist/modules/proposal/commands/bioinfo-params.d.ts +5 -0
- package/cli/dist/modules/proposal/commands/bioinfo-params.d.ts.map +1 -0
- package/cli/dist/modules/proposal/commands/bioinfo-params.js +9 -0
- package/cli/dist/modules/proposal/commands/bioinfo-params.js.map +1 -0
- package/cli/dist/modules/proposal/commands/bioinfo-run.d.ts +6 -0
- package/cli/dist/modules/proposal/commands/bioinfo-run.d.ts.map +1 -0
- package/cli/dist/modules/proposal/commands/bioinfo-run.js +10 -0
- package/cli/dist/modules/proposal/commands/bioinfo-run.js.map +1 -0
- package/cli/dist/modules/proposal/commands/clinical-list.d.ts +5 -0
- package/cli/dist/modules/proposal/commands/clinical-list.d.ts.map +1 -0
- package/cli/dist/modules/proposal/commands/clinical-list.js +9 -0
- package/cli/dist/modules/proposal/commands/clinical-list.js.map +1 -0
- package/cli/dist/modules/proposal/commands/clinical-params.d.ts +6 -0
- package/cli/dist/modules/proposal/commands/clinical-params.d.ts.map +1 -0
- package/cli/dist/modules/proposal/commands/clinical-params.js +9 -0
- package/cli/dist/modules/proposal/commands/clinical-params.js.map +1 -0
- package/cli/dist/modules/proposal/commands/clinical-run.d.ts +7 -0
- package/cli/dist/modules/proposal/commands/clinical-run.d.ts.map +1 -0
- package/cli/dist/modules/proposal/commands/clinical-run.js +10 -0
- package/cli/dist/modules/proposal/commands/clinical-run.js.map +1 -0
- package/cli/dist/modules/proposal/constants.d.ts +34 -0
- package/cli/dist/modules/proposal/constants.d.ts.map +1 -0
- package/cli/dist/modules/proposal/constants.js +75 -0
- package/cli/dist/modules/proposal/constants.js.map +1 -0
- package/cli/dist/modules/proposal/index.d.ts +3 -0
- package/cli/dist/modules/proposal/index.d.ts.map +1 -0
- package/cli/dist/modules/proposal/index.js +95 -0
- package/cli/dist/modules/proposal/index.js.map +1 -0
- package/cli/dist/modules/proposal/newidea-env.d.ts +28 -0
- package/cli/dist/modules/proposal/newidea-env.d.ts.map +1 -0
- package/cli/dist/modules/proposal/newidea-env.js +69 -0
- package/cli/dist/modules/proposal/newidea-env.js.map +1 -0
- package/cli/dist/modules/proposal/newidea-runner.d.ts +25 -0
- package/cli/dist/modules/proposal/newidea-runner.d.ts.map +1 -0
- package/cli/dist/modules/proposal/newidea-runner.js +158 -0
- package/cli/dist/modules/proposal/newidea-runner.js.map +1 -0
- package/cli/dist/modules/proposal/parse.d.ts +25 -0
- package/cli/dist/modules/proposal/parse.d.ts.map +1 -0
- package/cli/dist/modules/proposal/parse.js +173 -0
- package/cli/dist/modules/proposal/parse.js.map +1 -0
- package/cli/dist/modules/sci/apps.d.ts +48 -0
- package/cli/dist/modules/sci/apps.d.ts.map +1 -0
- package/cli/dist/modules/sci/apps.js +43 -0
- package/cli/dist/modules/sci/apps.js.map +1 -0
- package/cli/dist/modules/sci/article-cache.d.ts +32 -0
- package/cli/dist/modules/sci/article-cache.d.ts.map +1 -0
- package/cli/dist/modules/sci/article-cache.js +163 -0
- package/cli/dist/modules/sci/article-cache.js.map +1 -0
- package/cli/dist/modules/sci/article-validate.d.ts +11 -0
- package/cli/dist/modules/sci/article-validate.d.ts.map +1 -0
- package/cli/dist/modules/sci/article-validate.js +43 -0
- package/cli/dist/modules/sci/article-validate.js.map +1 -0
- package/cli/dist/modules/sci/commands/article-create.d.ts +46 -0
- package/cli/dist/modules/sci/commands/article-create.d.ts.map +1 -0
- package/cli/dist/modules/sci/commands/article-create.js +315 -0
- package/cli/dist/modules/sci/commands/article-create.js.map +1 -0
- package/cli/dist/modules/sci/commands/article-download.d.ts +50 -0
- package/cli/dist/modules/sci/commands/article-download.d.ts.map +1 -0
- package/cli/dist/modules/sci/commands/article-download.js +281 -0
- package/cli/dist/modules/sci/commands/article-download.js.map +1 -0
- package/cli/dist/modules/sci/commands/outline.d.ts +36 -0
- package/cli/dist/modules/sci/commands/outline.d.ts.map +1 -0
- package/cli/dist/modules/sci/commands/outline.js +491 -0
- package/cli/dist/modules/sci/commands/outline.js.map +1 -0
- package/cli/dist/modules/sci/commands/template.d.ts +9 -0
- package/cli/dist/modules/sci/commands/template.d.ts.map +1 -0
- package/cli/dist/modules/sci/commands/template.js +12 -0
- package/cli/dist/modules/sci/commands/template.js.map +1 -0
- package/cli/dist/modules/sci/commands.d.ts +3 -0
- package/cli/dist/modules/sci/commands.d.ts.map +1 -0
- package/cli/dist/modules/sci/commands.js +108 -0
- package/cli/dist/modules/sci/commands.js.map +1 -0
- package/cli/dist/modules/sci/constants.d.ts +117 -0
- package/cli/dist/modules/sci/constants.d.ts.map +1 -0
- package/cli/dist/modules/sci/constants.js +152 -0
- package/cli/dist/modules/sci/constants.js.map +1 -0
- package/cli/dist/modules/sci/content-source.d.ts +18 -0
- package/cli/dist/modules/sci/content-source.d.ts.map +1 -0
- package/cli/dist/modules/sci/content-source.js +54 -0
- package/cli/dist/modules/sci/content-source.js.map +1 -0
- package/cli/dist/modules/sci/index.d.ts +3 -0
- package/cli/dist/modules/sci/index.d.ts.map +1 -0
- package/cli/dist/modules/sci/index.js +19 -0
- package/cli/dist/modules/sci/index.js.map +1 -0
- package/cli/dist/modules/sci/outline-transform.d.ts +16 -0
- package/cli/dist/modules/sci/outline-transform.d.ts.map +1 -0
- package/cli/dist/modules/sci/outline-transform.js +67 -0
- package/cli/dist/modules/sci/outline-transform.js.map +1 -0
- package/cli/dist/modules/sci/precheck-cache.d.ts +23 -0
- package/cli/dist/modules/sci/precheck-cache.d.ts.map +1 -0
- package/cli/dist/modules/sci/precheck-cache.js +141 -0
- package/cli/dist/modules/sci/precheck-cache.js.map +1 -0
- package/cli/dist/modules/sci/prompt-article.d.ts +12 -0
- package/cli/dist/modules/sci/prompt-article.d.ts.map +1 -0
- package/cli/dist/modules/sci/prompt-article.js +37 -0
- package/cli/dist/modules/sci/prompt-article.js.map +1 -0
- package/cli/dist/modules/sci/prompt-precheck.d.ts +16 -0
- package/cli/dist/modules/sci/prompt-precheck.d.ts.map +1 -0
- package/cli/dist/modules/sci/prompt-precheck.js +61 -0
- package/cli/dist/modules/sci/prompt-precheck.js.map +1 -0
- package/cli/dist/modules/sci/sse-utils.d.ts +50 -0
- package/cli/dist/modules/sci/sse-utils.d.ts.map +1 -0
- package/cli/dist/modules/sci/sse-utils.js +207 -0
- package/cli/dist/modules/sci/sse-utils.js.map +1 -0
- package/cli/dist/modules/shared/result-wrapper.d.ts +71 -0
- package/cli/dist/modules/shared/result-wrapper.d.ts.map +1 -0
- package/cli/dist/modules/shared/result-wrapper.js +95 -0
- package/cli/dist/modules/shared/result-wrapper.js.map +1 -0
- package/cli/dist/modules/shared/workflow-app/api.d.ts +6 -0
- package/cli/dist/modules/shared/workflow-app/api.d.ts.map +1 -0
- package/cli/dist/modules/shared/workflow-app/api.js +31 -0
- package/cli/dist/modules/shared/workflow-app/api.js.map +1 -0
- package/cli/dist/modules/shared/workflow-app/command.d.ts +30 -0
- package/cli/dist/modules/shared/workflow-app/command.d.ts.map +1 -0
- package/cli/dist/modules/shared/workflow-app/command.js +183 -0
- package/cli/dist/modules/shared/workflow-app/command.js.map +1 -0
- package/cli/dist/modules/shared/workflow-app/constants.d.ts +12 -0
- package/cli/dist/modules/shared/workflow-app/constants.d.ts.map +1 -0
- package/cli/dist/modules/shared/workflow-app/constants.js +21 -0
- package/cli/dist/modules/shared/workflow-app/constants.js.map +1 -0
- package/cli/dist/modules/shared/workflow-app/form.d.ts +21 -0
- package/cli/dist/modules/shared/workflow-app/form.d.ts.map +1 -0
- package/cli/dist/modules/shared/workflow-app/form.js +123 -0
- package/cli/dist/modules/shared/workflow-app/form.js.map +1 -0
- package/cli/dist/modules/shared/workflow-app/index.d.ts +8 -0
- package/cli/dist/modules/shared/workflow-app/index.d.ts.map +1 -0
- package/cli/dist/modules/shared/workflow-app/index.js +7 -0
- package/cli/dist/modules/shared/workflow-app/index.js.map +1 -0
- package/cli/dist/modules/shared/workflow-app/run.d.ts +15 -0
- package/cli/dist/modules/shared/workflow-app/run.d.ts.map +1 -0
- package/cli/dist/modules/shared/workflow-app/run.js +71 -0
- package/cli/dist/modules/shared/workflow-app/run.js.map +1 -0
- package/cli/dist/modules/shared/workflow-app/types.d.ts +74 -0
- package/cli/dist/modules/shared/workflow-app/types.d.ts.map +1 -0
- package/cli/dist/modules/shared/workflow-app/types.js +3 -0
- package/cli/dist/modules/shared/workflow-app/types.js.map +1 -0
- package/cli/dist/modules/site-configs.d.ts +4 -0
- package/cli/dist/modules/site-configs.d.ts.map +1 -0
- package/cli/dist/modules/site-configs.js +21 -0
- package/cli/dist/modules/site-configs.js.map +1 -0
- package/cli/dist/modules/upgrade/index.d.ts +6 -0
- package/cli/dist/modules/upgrade/index.d.ts.map +1 -0
- package/cli/dist/modules/upgrade/index.js +105 -0
- package/cli/dist/modules/upgrade/index.js.map +1 -0
- package/cli/dist/program.d.ts +3 -0
- package/cli/dist/program.d.ts.map +1 -0
- package/cli/dist/program.js +69 -0
- package/cli/dist/program.js.map +1 -0
- package/package.json +37 -0
|
@@ -0,0 +1,1077 @@
|
|
|
1
|
+
import { mkdir, readFile, stat, writeFile } from "node:fs/promises";
|
|
2
|
+
import { basename, dirname, extname, join, resolve } from "node:path";
|
|
3
|
+
import { ApiClient, createStderrProgress, helixlifeError, helixlifeErrorCode, printOutput, renderListAsMarkdown } from "../../core/index.js";
|
|
4
|
+
import { requestMeta } from "./api.js";
|
|
5
|
+
import { META_API_PREFIX, META_FULLTEXT_WAIT_HINT } from "./constants.js";
|
|
6
|
+
import { createMetaNode, getMetaNodeOutput, pollMetaNodeStatus } from "./node.js";
|
|
7
|
+
import { exportFinalPrismaWordArtifact, exportPrismaFlow } from "./analysis.js";
|
|
8
|
+
import { exportFinalExtractionMarkdownArtifacts } from "./extraction.js";
|
|
9
|
+
import { exportFinalScreeningMarkdownArtifacts } from "./screening.js";
|
|
10
|
+
const META_WRITING_NODE_TYPES = {
|
|
11
|
+
PICOS: "generate_picos",
|
|
12
|
+
CRITERIA: "generate_sorting_criteria",
|
|
13
|
+
BASELINE: "baseline_information",
|
|
14
|
+
EFFECT: "effect_quantity",
|
|
15
|
+
BIAS: "publication_bias",
|
|
16
|
+
ASSESSMENT: "quality_assessment_plot",
|
|
17
|
+
METHOD: "generate_method",
|
|
18
|
+
RESULT: "generate_outcome",
|
|
19
|
+
FULLTEXT: "generate_fulltext",
|
|
20
|
+
};
|
|
21
|
+
/** 方法 get 后必须原文完整展示正文与产物,禁止摘要代替。 */
|
|
22
|
+
const WRITING_METHOD_DISPLAY_INSTRUCTION = "必须将响应 text 原文逐字完整输出到对话,并交付 artifact(方法.md);" +
|
|
23
|
+
"禁止摘要、截断、润色;禁止用「方法已生成」「方法正文已完整展示」「含 N 个章节」或章节名清单代替正文;" +
|
|
24
|
+
"未在回复中贴出方法正文原文即视为交付失败;展示后按操作选项以 Markdown 无序列表列出后停顿,禁止弹选择器,禁止用 / 同行拼接。";
|
|
25
|
+
/** 结果:交付产物,且回复文本中也要展示部分正文预览。 */
|
|
26
|
+
const WRITING_RESULT_DISPLAY_INSTRUCTION = "交付并展示 artifact(结果.md);获取结果后回复文本中也要展示开头若干段原文,随后输出 ...,并提示「详细内容可查看文档产物」;" +
|
|
27
|
+
"禁止只用「结果已生成」而无预览;禁止只列操作选项却不展示产物;展示后按操作选项以 Markdown 无序列表列出后停顿,禁止弹选择器,禁止用 / 同行拼接。";
|
|
28
|
+
/** 生成初稿:交付整包最终产物,且回复文本中也要展示部分正文预览。 */
|
|
29
|
+
const WRITING_FULLTEXT_DISPLAY_INSTRUCTION = "必须交付并展示全部 artifact:初筛结果.xlsx、复筛结果.xlsx、质量评估.xlsx、结局指标.xlsx、PRISMA流程图.docx、PRISMA流程图.pdf、生成初稿.docx;" +
|
|
30
|
+
"若响应含 text,回复文本中也要展示开头若干段原文后接 ...,并提示「详细内容可查看文档产物」;" +
|
|
31
|
+
"禁止只交付生成初稿.docx 而省略其余产物;结束后不弹选择器。";
|
|
32
|
+
/**
|
|
33
|
+
* 下载生成初稿同次交付的配套产物(筛选/抽提 xlsx + PRISMA docx/pdf)。
|
|
34
|
+
*/
|
|
35
|
+
async function exportFullTextCompanionArtifacts(options) {
|
|
36
|
+
const [screeningArtifacts, extractionArtifacts, prismaDocx, prismaPdf] = await Promise.all([
|
|
37
|
+
exportFinalScreeningMarkdownArtifacts({
|
|
38
|
+
workflowId: options.workflowId,
|
|
39
|
+
configPath: options.configPath,
|
|
40
|
+
output: options.outputDirectory,
|
|
41
|
+
}),
|
|
42
|
+
exportFinalExtractionMarkdownArtifacts({
|
|
43
|
+
workflowId: options.workflowId,
|
|
44
|
+
configPath: options.configPath,
|
|
45
|
+
output: options.outputDirectory,
|
|
46
|
+
}),
|
|
47
|
+
exportFinalPrismaWordArtifact({
|
|
48
|
+
workflowId: options.workflowId,
|
|
49
|
+
configPath: options.configPath,
|
|
50
|
+
output: options.outputDirectory,
|
|
51
|
+
}),
|
|
52
|
+
exportPrismaFlow({
|
|
53
|
+
workflowId: options.workflowId,
|
|
54
|
+
configPath: options.configPath,
|
|
55
|
+
output: options.outputDirectory,
|
|
56
|
+
exportFormat: "pdf",
|
|
57
|
+
}),
|
|
58
|
+
]);
|
|
59
|
+
return [
|
|
60
|
+
...screeningArtifacts,
|
|
61
|
+
...extractionArtifacts,
|
|
62
|
+
prismaDocx,
|
|
63
|
+
prismaPdf,
|
|
64
|
+
];
|
|
65
|
+
}
|
|
66
|
+
function parseJsonObject(raw, optionName) {
|
|
67
|
+
const jsonText = raw?.replace(/^\uFEFF/, "").trim();
|
|
68
|
+
if (!jsonText) {
|
|
69
|
+
return {};
|
|
70
|
+
}
|
|
71
|
+
try {
|
|
72
|
+
const parsed = JSON.parse(jsonText);
|
|
73
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
74
|
+
throw new Error("not an object");
|
|
75
|
+
}
|
|
76
|
+
return parsed;
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
throw new helixlifeError(helixlifeErrorCode.INVALID_ARGUMENT, `${optionName} 必须是合法 JSON 对象`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
async function parseJsonObjectInput(raw, filePath) {
|
|
83
|
+
if (filePath?.trim()) {
|
|
84
|
+
const content = await readFile(filePath.trim(), "utf8");
|
|
85
|
+
return parseJsonObject(content, "--input-file");
|
|
86
|
+
}
|
|
87
|
+
return parseJsonObject(raw, "--input-json");
|
|
88
|
+
}
|
|
89
|
+
async function readTextInput(text, filePath) {
|
|
90
|
+
if (filePath?.trim()) {
|
|
91
|
+
return readFile(filePath.trim(), "utf8");
|
|
92
|
+
}
|
|
93
|
+
if (text === undefined) {
|
|
94
|
+
throw new helixlifeError(helixlifeErrorCode.INVALID_ARGUMENT, "缺少 --text 或 --text-file");
|
|
95
|
+
}
|
|
96
|
+
return text;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* 判断流程命令是否携带了需要同步到上一节点的正文。
|
|
100
|
+
*
|
|
101
|
+
* @param text 命令行直接传入的正文。
|
|
102
|
+
* @param filePath 正文文件路径。
|
|
103
|
+
* @returns 任一正文来源已提供时返回 true。
|
|
104
|
+
*/
|
|
105
|
+
function hasTextInput(text, filePath) {
|
|
106
|
+
return text !== undefined || Boolean(filePath?.trim());
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* 从写作接口响应中尝试读取完整正文。
|
|
110
|
+
*
|
|
111
|
+
* @param data 写作生成、查询或节点输出接口返回的数据。
|
|
112
|
+
* @returns 响应中存在非空 `text` 正文时返回该正文;否则返回 undefined。
|
|
113
|
+
*/
|
|
114
|
+
function tryExtractWritingText(data) {
|
|
115
|
+
if (typeof data === "string" && data.trim()) {
|
|
116
|
+
return data;
|
|
117
|
+
}
|
|
118
|
+
if (data && typeof data === "object") {
|
|
119
|
+
const payload = data;
|
|
120
|
+
const text = payload.text;
|
|
121
|
+
if (typeof text === "string" && text.trim()) {
|
|
122
|
+
return text;
|
|
123
|
+
}
|
|
124
|
+
const nestedData = tryExtractWritingText(payload.data);
|
|
125
|
+
if (nestedData) {
|
|
126
|
+
return nestedData;
|
|
127
|
+
}
|
|
128
|
+
const nestedOutput = tryExtractWritingText(payload.output);
|
|
129
|
+
if (nestedOutput) {
|
|
130
|
+
return nestedOutput;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return undefined;
|
|
134
|
+
}
|
|
135
|
+
function tryExtractWritingImages(data) {
|
|
136
|
+
if (!data || typeof data !== "object") {
|
|
137
|
+
return undefined;
|
|
138
|
+
}
|
|
139
|
+
const payload = data;
|
|
140
|
+
const images = payload.images;
|
|
141
|
+
if (images && typeof images === "object" && !Array.isArray(images)) {
|
|
142
|
+
const entries = Object.entries(images).filter((entry) => typeof entry[1] === "string" && entry[1].trim().length > 0);
|
|
143
|
+
if (entries.length > 0) {
|
|
144
|
+
return Object.fromEntries(entries);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return tryExtractWritingImages(payload.data) ?? tryExtractWritingImages(payload.output);
|
|
148
|
+
}
|
|
149
|
+
function imageMarkdownUrl(imageData) {
|
|
150
|
+
return imageData.startsWith("data:")
|
|
151
|
+
? imageData
|
|
152
|
+
: `data:image/png;base64,${imageData}`;
|
|
153
|
+
}
|
|
154
|
+
function insertWritingResultImages(text, images) {
|
|
155
|
+
if (!images) {
|
|
156
|
+
return text;
|
|
157
|
+
}
|
|
158
|
+
const textWithPlots = text.replace(/\{insert-(\S+?)-plot\}/g, (match, placeholderKey) => {
|
|
159
|
+
const imageData = images[`${placeholderKey.replaceAll("-", "_")}_plot`];
|
|
160
|
+
return imageData
|
|
161
|
+
? `})`
|
|
162
|
+
: match;
|
|
163
|
+
});
|
|
164
|
+
const prismaPlot = images.prisma_plot;
|
|
165
|
+
return prismaPlot
|
|
166
|
+
? textWithPlots.replaceAll("{PRISMA流程图}", `})`)
|
|
167
|
+
: textWithPlots;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* 保存结果正文前,将展示用嵌入图还原为后端占位符。
|
|
171
|
+
*
|
|
172
|
+
* @param text 可能含 data URL 图的 Markdown 正文。
|
|
173
|
+
* @returns 还原占位符后的正文。
|
|
174
|
+
*/
|
|
175
|
+
function stripWritingResultImages(text) {
|
|
176
|
+
const withoutPlots = text.replace(/!\[insert-(\S+?)-plot\]\((?:data:image\/[^)]+|https?:\/\/[^)]+)\)/g, (_match, placeholderKey) => `{insert-${placeholderKey.replaceAll("_", "-")}-plot}`);
|
|
177
|
+
return withoutPlots.replace(/!\[PRISMA流程图\]\((?:data:image\/[^)]+|https?:\/\/[^)]+)\)/g, "{PRISMA流程图}");
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* 从全文查询响应中读取用于 Word 导出的正文。
|
|
181
|
+
*
|
|
182
|
+
* @param data 全文查询接口返回的数据。
|
|
183
|
+
* @returns 完整全文正文。
|
|
184
|
+
* @throws {helixlifeError} 响应中不存在可导出的正文时抛出。
|
|
185
|
+
*/
|
|
186
|
+
function extractWritingText(data) {
|
|
187
|
+
const text = tryExtractWritingText(data);
|
|
188
|
+
if (text) {
|
|
189
|
+
return text;
|
|
190
|
+
}
|
|
191
|
+
throw new helixlifeError(helixlifeErrorCode.INVALID_RESPONSE, "全文生成成功,但响应中缺少可导出的正文");
|
|
192
|
+
}
|
|
193
|
+
function extractNodePayload(node) {
|
|
194
|
+
if (!node) {
|
|
195
|
+
return {};
|
|
196
|
+
}
|
|
197
|
+
const output = node.output;
|
|
198
|
+
if (output && typeof output === "object") {
|
|
199
|
+
const outputObject = output;
|
|
200
|
+
if (outputObject.output && typeof outputObject.output === "object") {
|
|
201
|
+
return outputObject.output;
|
|
202
|
+
}
|
|
203
|
+
return outputObject;
|
|
204
|
+
}
|
|
205
|
+
if (node.input && typeof node.input === "object") {
|
|
206
|
+
return node.input;
|
|
207
|
+
}
|
|
208
|
+
return {};
|
|
209
|
+
}
|
|
210
|
+
function extractNodeOutput(node) {
|
|
211
|
+
if (node.output && typeof node.output === "object" && "output" in node.output) {
|
|
212
|
+
return node.output.output;
|
|
213
|
+
}
|
|
214
|
+
return node.output ?? {};
|
|
215
|
+
}
|
|
216
|
+
function joinSortingCriteria(output) {
|
|
217
|
+
let data = "";
|
|
218
|
+
if (output.inclusion_criteria) {
|
|
219
|
+
data += `Inclusion criteria include: ${String(output.inclusion_criteria)}\n\n`;
|
|
220
|
+
}
|
|
221
|
+
if (output.exclusion_criteria) {
|
|
222
|
+
data += `Exclusion criteria include: ${String(output.exclusion_criteria)}`;
|
|
223
|
+
}
|
|
224
|
+
return data;
|
|
225
|
+
}
|
|
226
|
+
async function getWorkflow(workflowId, configPath) {
|
|
227
|
+
return requestMeta(`${META_API_PREFIX}/workflow/runs/${encodeURIComponent(workflowId)}`, { configPath, action: "查询 Meta 工作流" });
|
|
228
|
+
}
|
|
229
|
+
function findLatestNode(workflow, nodeType) {
|
|
230
|
+
return [...(workflow.nodes ?? [])].reverse().find((node) => node.node_type === nodeType);
|
|
231
|
+
}
|
|
232
|
+
function inferTitle(workflow) {
|
|
233
|
+
const picosNode = findLatestNode(workflow, META_WRITING_NODE_TYPES.PICOS);
|
|
234
|
+
const picosInput = picosNode?.input;
|
|
235
|
+
if (typeof picosInput?.title === "string" && picosInput.title.trim()) {
|
|
236
|
+
return picosInput.title.trim();
|
|
237
|
+
}
|
|
238
|
+
const topicNode = findLatestNode(workflow, "generate_topic");
|
|
239
|
+
const topicOutput = extractNodePayload(topicNode);
|
|
240
|
+
const selected = topicOutput.selected;
|
|
241
|
+
if (typeof selected?.English === "string" && selected.English.trim()) {
|
|
242
|
+
return selected.English.trim();
|
|
243
|
+
}
|
|
244
|
+
if (typeof selected?.Chinese === "string" && selected.Chinese.trim()) {
|
|
245
|
+
return selected.Chinese.trim();
|
|
246
|
+
}
|
|
247
|
+
return "";
|
|
248
|
+
}
|
|
249
|
+
async function resolveNodeId(options) {
|
|
250
|
+
if (options.nodeId?.trim()) {
|
|
251
|
+
return options.nodeId.trim();
|
|
252
|
+
}
|
|
253
|
+
const workflow = await getWorkflow(options.workflowId, options.configPath);
|
|
254
|
+
const node = findLatestNode(workflow, options.nodeType);
|
|
255
|
+
if (!node) {
|
|
256
|
+
throw new helixlifeError(helixlifeErrorCode.INVALID_ARGUMENT, `当前工作流中未找到 ${options.label} 节点`);
|
|
257
|
+
}
|
|
258
|
+
return node.id;
|
|
259
|
+
}
|
|
260
|
+
function writingMeta(kind) {
|
|
261
|
+
if (kind === "method") {
|
|
262
|
+
return { nodeType: META_WRITING_NODE_TYPES.METHOD, getPath: "generate-method", editPath: "generate-method/edit", label: "方法内容" };
|
|
263
|
+
}
|
|
264
|
+
if (kind === "result") {
|
|
265
|
+
return { nodeType: META_WRITING_NODE_TYPES.RESULT, getPath: "generate-outcome", editPath: "generate-outcome/edit", label: "结果内容" };
|
|
266
|
+
}
|
|
267
|
+
return { nodeType: META_WRITING_NODE_TYPES.FULLTEXT, getPath: "generate-fulltext", editPath: "generate-fulltext/edit", label: "全文内容" };
|
|
268
|
+
}
|
|
269
|
+
async function buildMethodInput(options) {
|
|
270
|
+
const workflow = await getWorkflow(options.workflowId, options.configPath);
|
|
271
|
+
const picosNode = findLatestNode(workflow, META_WRITING_NODE_TYPES.PICOS);
|
|
272
|
+
const criteriaNode = findLatestNode(workflow, META_WRITING_NODE_TYPES.CRITERIA);
|
|
273
|
+
const picos = extractNodePayload(picosNode);
|
|
274
|
+
const criteria = extractNodePayload(criteriaNode);
|
|
275
|
+
const overrides = await parseJsonObjectInput(options.inputJson, options.inputFile);
|
|
276
|
+
const title = options.title?.trim() || inferTitle(workflow);
|
|
277
|
+
return {
|
|
278
|
+
criteria: joinSortingCriteria(criteria),
|
|
279
|
+
...picos,
|
|
280
|
+
title,
|
|
281
|
+
language: options.language?.trim() || "English",
|
|
282
|
+
...overrides,
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
async function buildWritingResultInput(options) {
|
|
286
|
+
const workflow = await getWorkflow(options.workflowId, options.configPath);
|
|
287
|
+
const params = {};
|
|
288
|
+
for (const node of workflow.nodes ?? []) {
|
|
289
|
+
if (node.node_type === META_WRITING_NODE_TYPES.BASELINE) {
|
|
290
|
+
params.baseline_info_node_id = node.id;
|
|
291
|
+
}
|
|
292
|
+
if (node.node_type === META_WRITING_NODE_TYPES.EFFECT) {
|
|
293
|
+
params.effect_quantity_plot_node_id = node.id;
|
|
294
|
+
}
|
|
295
|
+
if (node.node_type === META_WRITING_NODE_TYPES.BIAS) {
|
|
296
|
+
params.publication_bias_plot_node_id = node.id;
|
|
297
|
+
}
|
|
298
|
+
if (node.node_type === META_WRITING_NODE_TYPES.ASSESSMENT) {
|
|
299
|
+
params.quality_assessment_plot_node_id = node.id;
|
|
300
|
+
}
|
|
301
|
+
if (node.node_type === META_WRITING_NODE_TYPES.METHOD) {
|
|
302
|
+
const input = node.input;
|
|
303
|
+
params.language = input?.language;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
const overrides = await parseJsonObjectInput(options.inputJson, options.inputFile);
|
|
307
|
+
return {
|
|
308
|
+
title: options.title?.trim() || inferTitle(workflow),
|
|
309
|
+
...params,
|
|
310
|
+
...overrides,
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
async function buildFullTextInput(options) {
|
|
314
|
+
const workflow = await getWorkflow(options.workflowId, options.configPath);
|
|
315
|
+
const params = {};
|
|
316
|
+
for (const node of workflow.nodes ?? []) {
|
|
317
|
+
if (node.node_type === META_WRITING_NODE_TYPES.METHOD) {
|
|
318
|
+
params.generate_method_node_id = node.id;
|
|
319
|
+
const input = node.input;
|
|
320
|
+
params.language = input?.language;
|
|
321
|
+
}
|
|
322
|
+
if (node.node_type === META_WRITING_NODE_TYPES.RESULT) {
|
|
323
|
+
params.generate_outcome_node_id = node.id;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
return params;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* 读取后端已保存的 PRISMA 图片,并转换成全文生成接口需要的 base64 字符串。
|
|
330
|
+
*
|
|
331
|
+
* @param options 当前 Meta 工作流参数。
|
|
332
|
+
* @returns 可传给 `prisma_image` 的 base64 内容;没有图片时返回 undefined。
|
|
333
|
+
*/
|
|
334
|
+
async function queryPrismaImageForFullText(options) {
|
|
335
|
+
const data = await requestMeta(`${META_API_PREFIX}/prisma/image`, {
|
|
336
|
+
params: { run_id: options.workflowId },
|
|
337
|
+
configPath: options.configPath,
|
|
338
|
+
action: "获取 PRISMA 图片",
|
|
339
|
+
});
|
|
340
|
+
const payload = data && typeof data === "object" && "data" in data ? data.data : data;
|
|
341
|
+
if (!payload || typeof payload !== "object") {
|
|
342
|
+
return undefined;
|
|
343
|
+
}
|
|
344
|
+
const image = payload.image;
|
|
345
|
+
if (typeof image !== "string" || !image.trim()) {
|
|
346
|
+
return undefined;
|
|
347
|
+
}
|
|
348
|
+
return image.includes(",") ? image.split(",").pop() : image;
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* 校验当前工作流已经生成并上传 PRISMA PNG,阻止写作节点越过统计分析最后一步。
|
|
352
|
+
*
|
|
353
|
+
* @param options 当前 Meta 工作流参数。
|
|
354
|
+
* @returns 后端已保存的 PRISMA PNG base64 内容。
|
|
355
|
+
*/
|
|
356
|
+
async function requirePrismaImage(options) {
|
|
357
|
+
const image = await queryPrismaImageForFullText(options);
|
|
358
|
+
if (!image) {
|
|
359
|
+
throw new helixlifeError(helixlifeErrorCode.INVALID_ARGUMENT, "尚未完成 PRISMA 流程图:请先生成、上传并确认最新 PRISMA PNG,之后才能进入辅助写作");
|
|
360
|
+
}
|
|
361
|
+
return image;
|
|
362
|
+
}
|
|
363
|
+
async function createMethod(options) {
|
|
364
|
+
await requirePrismaImage(options);
|
|
365
|
+
const input = await buildMethodInput(options);
|
|
366
|
+
const progress = createStderrProgress(options.format === "json");
|
|
367
|
+
progress.start("正在生成方法内容...");
|
|
368
|
+
try {
|
|
369
|
+
const created = await createMetaNode({
|
|
370
|
+
workflowId: options.workflowId,
|
|
371
|
+
nodeType: META_WRITING_NODE_TYPES.METHOD,
|
|
372
|
+
input,
|
|
373
|
+
configPath: options.configPath,
|
|
374
|
+
});
|
|
375
|
+
await pollMetaNodeStatus({ workflowId: options.workflowId, nodeId: created.nodeId, configPath: options.configPath });
|
|
376
|
+
const output = await getMetaNodeOutput({ workflowId: options.workflowId, nodeId: created.nodeId, configPath: options.configPath });
|
|
377
|
+
progress.finish("方法内容生成完成,正在输出结果...");
|
|
378
|
+
return {
|
|
379
|
+
runnerId: options.workflowId,
|
|
380
|
+
nodeId: created.nodeId,
|
|
381
|
+
nodeType: META_WRITING_NODE_TYPES.METHOD,
|
|
382
|
+
status: output.data.status,
|
|
383
|
+
input,
|
|
384
|
+
output: extractNodeOutput(output.data),
|
|
385
|
+
node: output.data,
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
catch (error) {
|
|
389
|
+
progress.dispose();
|
|
390
|
+
throw error;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
async function createResult(options) {
|
|
394
|
+
await requirePrismaImage(options);
|
|
395
|
+
if (hasTextInput(options.methodText, options.methodTextFile)) {
|
|
396
|
+
await saveWriting("method", {
|
|
397
|
+
workflowId: options.workflowId,
|
|
398
|
+
nodeId: options.methodNodeId,
|
|
399
|
+
text: options.methodText,
|
|
400
|
+
textFile: options.methodTextFile,
|
|
401
|
+
configPath: options.configPath,
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
const input = await buildWritingResultInput(options);
|
|
405
|
+
const progress = createStderrProgress(options.format === "json");
|
|
406
|
+
progress.start("正在生成结果内容...");
|
|
407
|
+
try {
|
|
408
|
+
const created = await requestMeta(`${META_API_PREFIX}/generate-outcome/execute`, {
|
|
409
|
+
method: "POST",
|
|
410
|
+
params: { run_id: options.workflowId },
|
|
411
|
+
body: input,
|
|
412
|
+
configPath: options.configPath,
|
|
413
|
+
action: "生成结果内容",
|
|
414
|
+
});
|
|
415
|
+
if (!created.node_id) {
|
|
416
|
+
throw new helixlifeError(helixlifeErrorCode.INVALID_RESPONSE, "生成结果内容响应缺少 node_id");
|
|
417
|
+
}
|
|
418
|
+
await pollMetaNodeStatus({ workflowId: options.workflowId, nodeId: created.node_id, configPath: options.configPath });
|
|
419
|
+
const output = await getMetaNodeOutput({ workflowId: options.workflowId, nodeId: created.node_id, configPath: options.configPath });
|
|
420
|
+
progress.finish("结果内容生成完成,正在输出结果...");
|
|
421
|
+
return {
|
|
422
|
+
runnerId: options.workflowId,
|
|
423
|
+
nodeId: created.node_id,
|
|
424
|
+
nodeType: META_WRITING_NODE_TYPES.RESULT,
|
|
425
|
+
status: output.data.status,
|
|
426
|
+
input,
|
|
427
|
+
output: extractNodeOutput(output.data),
|
|
428
|
+
node: output.data,
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
catch (error) {
|
|
432
|
+
progress.dispose();
|
|
433
|
+
throw error;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
async function createFullText(options) {
|
|
437
|
+
if (hasTextInput(options.resultText, options.resultTextFile)) {
|
|
438
|
+
await saveWriting("result", {
|
|
439
|
+
workflowId: options.workflowId,
|
|
440
|
+
nodeId: options.resultNodeId,
|
|
441
|
+
text: options.resultText,
|
|
442
|
+
textFile: options.resultTextFile,
|
|
443
|
+
configPath: options.configPath,
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
else {
|
|
447
|
+
const currentResult = await getWriting("result", {
|
|
448
|
+
workflowId: options.workflowId,
|
|
449
|
+
nodeId: options.resultNodeId,
|
|
450
|
+
configPath: options.configPath,
|
|
451
|
+
});
|
|
452
|
+
const resultText = prepareWritingText("result", currentResult.data)
|
|
453
|
+
?? extractWritingText(currentResult.data);
|
|
454
|
+
await saveWriting("result", {
|
|
455
|
+
workflowId: options.workflowId,
|
|
456
|
+
nodeId: currentResult.nodeId,
|
|
457
|
+
text: resultText,
|
|
458
|
+
configPath: options.configPath,
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
const prismaImage = await requirePrismaImage(options);
|
|
462
|
+
const input = await buildFullTextInput(options);
|
|
463
|
+
input.prisma_image = prismaImage;
|
|
464
|
+
// 初稿全文+产物导出耗时长,启动前提示用户耐心等待
|
|
465
|
+
process.stderr.write(`${META_FULLTEXT_WAIT_HINT}\n`);
|
|
466
|
+
const progress = createStderrProgress(options.format === "json");
|
|
467
|
+
progress.start("正在生成全文内容...");
|
|
468
|
+
try {
|
|
469
|
+
const created = await requestMeta(`${META_API_PREFIX}/generate-fulltext/execute`, {
|
|
470
|
+
method: "POST",
|
|
471
|
+
params: { run_id: options.workflowId },
|
|
472
|
+
body: input,
|
|
473
|
+
configPath: options.configPath,
|
|
474
|
+
action: "生成全文内容",
|
|
475
|
+
});
|
|
476
|
+
if (!created.node_id) {
|
|
477
|
+
throw new helixlifeError(helixlifeErrorCode.INVALID_RESPONSE, "生成全文内容响应缺少 node_id");
|
|
478
|
+
}
|
|
479
|
+
await pollMetaNodeStatus({ workflowId: options.workflowId, nodeId: created.node_id, configPath: options.configPath });
|
|
480
|
+
const output = await getMetaNodeOutput({ workflowId: options.workflowId, nodeId: created.node_id, configPath: options.configPath });
|
|
481
|
+
progress.finish("全文内容生成完成,正在输出结果...");
|
|
482
|
+
return {
|
|
483
|
+
runnerId: options.workflowId,
|
|
484
|
+
nodeId: created.node_id,
|
|
485
|
+
nodeType: META_WRITING_NODE_TYPES.FULLTEXT,
|
|
486
|
+
status: output.data.status,
|
|
487
|
+
input,
|
|
488
|
+
output: extractNodeOutput(output.data),
|
|
489
|
+
node: output.data,
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
catch (error) {
|
|
493
|
+
progress.dispose();
|
|
494
|
+
throw error;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
async function getWriting(kind, options) {
|
|
498
|
+
const meta = writingMeta(kind);
|
|
499
|
+
const nodeId = await resolveNodeId({
|
|
500
|
+
workflowId: options.workflowId,
|
|
501
|
+
nodeId: options.nodeId,
|
|
502
|
+
nodeType: meta.nodeType,
|
|
503
|
+
label: meta.label,
|
|
504
|
+
configPath: options.configPath,
|
|
505
|
+
});
|
|
506
|
+
const data = await requestMeta(`${META_API_PREFIX}/${meta.getPath}`, {
|
|
507
|
+
params: { run_id: options.workflowId, node_id: nodeId },
|
|
508
|
+
configPath: options.configPath,
|
|
509
|
+
action: `获取${meta.label}`,
|
|
510
|
+
});
|
|
511
|
+
return { runnerId: options.workflowId, nodeId, data };
|
|
512
|
+
}
|
|
513
|
+
async function saveWriting(kind, options) {
|
|
514
|
+
const meta = writingMeta(kind);
|
|
515
|
+
const nodeId = await resolveNodeId({
|
|
516
|
+
workflowId: options.workflowId,
|
|
517
|
+
nodeId: options.nodeId,
|
|
518
|
+
nodeType: meta.nodeType,
|
|
519
|
+
label: meta.label,
|
|
520
|
+
configPath: options.configPath,
|
|
521
|
+
});
|
|
522
|
+
const rawText = await readTextInput(options.text, options.textFile);
|
|
523
|
+
// 结果节点:提交前去掉展示嵌入图,只保留占位符
|
|
524
|
+
const text = kind === "result" ? stripWritingResultImages(rawText) : rawText;
|
|
525
|
+
const data = await requestMeta(`${META_API_PREFIX}/${meta.editPath}`, {
|
|
526
|
+
method: "POST",
|
|
527
|
+
params: { run_id: options.workflowId, node_id: nodeId },
|
|
528
|
+
body: { text },
|
|
529
|
+
configPath: options.configPath,
|
|
530
|
+
action: `保存${meta.label}`,
|
|
531
|
+
});
|
|
532
|
+
return { runnerId: options.workflowId, nodeId, input: { text }, data };
|
|
533
|
+
}
|
|
534
|
+
async function rerunWriting(kind, options) {
|
|
535
|
+
const meta = writingMeta(kind);
|
|
536
|
+
const nodeId = await resolveNodeId({
|
|
537
|
+
workflowId: options.workflowId,
|
|
538
|
+
nodeId: options.nodeId,
|
|
539
|
+
nodeType: meta.nodeType,
|
|
540
|
+
label: meta.label,
|
|
541
|
+
configPath: options.configPath,
|
|
542
|
+
});
|
|
543
|
+
const data = await requestMeta(`${META_API_PREFIX}/nodes/re-execute`, {
|
|
544
|
+
method: "POST",
|
|
545
|
+
body: { run_id: options.workflowId, node_id: nodeId, node_type: meta.nodeType },
|
|
546
|
+
configPath: options.configPath,
|
|
547
|
+
action: `重新生成${meta.label}`,
|
|
548
|
+
});
|
|
549
|
+
await pollMetaNodeStatus({ workflowId: options.workflowId, nodeId, configPath: options.configPath });
|
|
550
|
+
return { runnerId: options.workflowId, nodeId, data };
|
|
551
|
+
}
|
|
552
|
+
function normalizeExportFilename(filename, extension) {
|
|
553
|
+
const safeName = basename(filename.trim()).replace(/[<>:"/\\|?*\u0000-\u001F]/g, "_");
|
|
554
|
+
if (!safeName || safeName === "." || safeName === "..") {
|
|
555
|
+
return `全文.${extension}`;
|
|
556
|
+
}
|
|
557
|
+
return extname(safeName).toLowerCase() === `.${extension.toLowerCase()}`
|
|
558
|
+
? safeName
|
|
559
|
+
: `${safeName}.${extension}`;
|
|
560
|
+
}
|
|
561
|
+
function validateDocxBuffer(buffer, source) {
|
|
562
|
+
if (buffer.length < 4 || buffer.subarray(0, 4).toString("binary") !== "PK\u0003\u0004") {
|
|
563
|
+
throw new helixlifeError(helixlifeErrorCode.INVALID_RESPONSE, `${source}不是有效的 DOCX:缺少 ZIP/OOXML 文件头`);
|
|
564
|
+
}
|
|
565
|
+
const binary = buffer.toString("binary");
|
|
566
|
+
for (const entry of ["[Content_Types].xml", "word/document.xml"]) {
|
|
567
|
+
if (!binary.includes(entry)) {
|
|
568
|
+
throw new helixlifeError(helixlifeErrorCode.INVALID_RESPONSE, `${source}不是有效的 DOCX:缺少 ${entry}`);
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
async function exportFullText(options) {
|
|
573
|
+
const nodeId = await resolveNodeId({
|
|
574
|
+
workflowId: options.workflowId,
|
|
575
|
+
nodeId: options.nodeId,
|
|
576
|
+
nodeType: META_WRITING_NODE_TYPES.FULLTEXT,
|
|
577
|
+
label: "全文内容",
|
|
578
|
+
configPath: options.configPath,
|
|
579
|
+
});
|
|
580
|
+
const hasExplicitText = options.text !== undefined || Boolean(options.textFile?.trim());
|
|
581
|
+
let text;
|
|
582
|
+
if (hasExplicitText) {
|
|
583
|
+
text = await readTextInput(options.text, options.textFile);
|
|
584
|
+
}
|
|
585
|
+
else {
|
|
586
|
+
const currentFullText = await getWriting("fulltext", {
|
|
587
|
+
workflowId: options.workflowId,
|
|
588
|
+
nodeId,
|
|
589
|
+
configPath: options.configPath,
|
|
590
|
+
});
|
|
591
|
+
text = prepareWritingText("fulltext", currentFullText.data)
|
|
592
|
+
?? extractWritingText(currentFullText.data);
|
|
593
|
+
}
|
|
594
|
+
const exportFormat = options.exportFormat?.trim() || "docx";
|
|
595
|
+
if (!text.trim()) {
|
|
596
|
+
throw new helixlifeError(helixlifeErrorCode.INVALID_ARGUMENT, "全文正文为空,禁止导出空 Word 文件");
|
|
597
|
+
}
|
|
598
|
+
const workflow = await getWorkflow(options.workflowId, options.configPath);
|
|
599
|
+
const requestFilename = normalizeExportFilename(options.filename?.trim() || inferTitle(workflow) || "全文", exportFormat);
|
|
600
|
+
const client = new ApiClient();
|
|
601
|
+
const result = await client.requestBinary(`${META_API_PREFIX}/generate-fulltext/export`, {
|
|
602
|
+
method: "POST",
|
|
603
|
+
params: { run_id: options.workflowId, node_id: nodeId, format: exportFormat },
|
|
604
|
+
body: { filename: requestFilename, text },
|
|
605
|
+
});
|
|
606
|
+
if (exportFormat.toLowerCase() === "docx") {
|
|
607
|
+
validateDocxBuffer(result.buffer, "后端导出响应");
|
|
608
|
+
}
|
|
609
|
+
const responseFilename = options.filename?.trim()
|
|
610
|
+
? requestFilename
|
|
611
|
+
: normalizeExportFilename(result.filename ?? requestFilename, exportFormat);
|
|
612
|
+
const outputTarget = options.output?.trim();
|
|
613
|
+
const outputStat = outputTarget ? await stat(outputTarget).catch(() => undefined) : undefined;
|
|
614
|
+
const outputPath = resolve(!outputTarget
|
|
615
|
+
? responseFilename
|
|
616
|
+
: outputStat?.isDirectory() || outputTarget.endsWith("/") || outputTarget.endsWith("\\")
|
|
617
|
+
? join(outputTarget, responseFilename)
|
|
618
|
+
: extname(outputTarget).toLowerCase() === `.${exportFormat.toLowerCase()}`
|
|
619
|
+
? outputTarget
|
|
620
|
+
: outputStat?.isFile()
|
|
621
|
+
? `${outputTarget}.${exportFormat}`
|
|
622
|
+
: join(outputTarget, responseFilename));
|
|
623
|
+
await mkdir(dirname(outputPath), { recursive: true });
|
|
624
|
+
await writeFile(outputPath, result.buffer);
|
|
625
|
+
const savedBuffer = await readFile(outputPath);
|
|
626
|
+
if (savedBuffer.length !== result.buffer.length) {
|
|
627
|
+
throw new helixlifeError(helixlifeErrorCode.INVALID_RESPONSE, `Word 文件写入不完整:期望 ${result.buffer.length} 字节,实际 ${savedBuffer.length} 字节`);
|
|
628
|
+
}
|
|
629
|
+
if (exportFormat.toLowerCase() === "docx") {
|
|
630
|
+
validateDocxBuffer(savedBuffer, "本地 Word 文件");
|
|
631
|
+
}
|
|
632
|
+
return {
|
|
633
|
+
runnerId: options.workflowId,
|
|
634
|
+
nodeId,
|
|
635
|
+
output: outputPath,
|
|
636
|
+
filename: responseFilename,
|
|
637
|
+
contentType: result.contentType ?? undefined,
|
|
638
|
+
size: savedBuffer.length,
|
|
639
|
+
};
|
|
640
|
+
}
|
|
641
|
+
/**
|
|
642
|
+
* 按写作节点的展示规则输出完整正文和节点信息。
|
|
643
|
+
*
|
|
644
|
+
* @param kind 写作节点类型。
|
|
645
|
+
* @param text 后端返回的完整正文。
|
|
646
|
+
* @param result 节点执行结果。
|
|
647
|
+
*/
|
|
648
|
+
function printWritingText(kind, text, result) {
|
|
649
|
+
console.log(`## ${writingMeta(kind).label}`);
|
|
650
|
+
console.log("");
|
|
651
|
+
console.log(text);
|
|
652
|
+
if (!result) {
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
655
|
+
console.log("");
|
|
656
|
+
console.log(renderListAsMarkdown([{ runnerId: result.runnerId, nodeId: result.nodeId, nodeType: result.nodeType, status: result.status }], [
|
|
657
|
+
{ key: "runnerId", label: "runnerId" },
|
|
658
|
+
{ key: "nodeId", label: "nodeId" },
|
|
659
|
+
{ key: "nodeType", label: "node_type" },
|
|
660
|
+
{ key: "status", label: "status" },
|
|
661
|
+
]));
|
|
662
|
+
}
|
|
663
|
+
function prepareWritingText(kind, data) {
|
|
664
|
+
const text = tryExtractWritingText(data);
|
|
665
|
+
if (!text) {
|
|
666
|
+
return undefined;
|
|
667
|
+
}
|
|
668
|
+
return kind === "result" || kind === "fulltext"
|
|
669
|
+
? insertWritingResultImages(text, tryExtractWritingImages(data))
|
|
670
|
+
: text;
|
|
671
|
+
}
|
|
672
|
+
function replaceWritingText(data, text) {
|
|
673
|
+
if (!data || typeof data !== "object" || Array.isArray(data)) {
|
|
674
|
+
return data;
|
|
675
|
+
}
|
|
676
|
+
return { ...data, text };
|
|
677
|
+
}
|
|
678
|
+
async function writeWritingMarkdown(kind, text, output) {
|
|
679
|
+
const filename = kind === "method"
|
|
680
|
+
? "方法.md"
|
|
681
|
+
: kind === "result"
|
|
682
|
+
? "结果.md"
|
|
683
|
+
: "全文.md";
|
|
684
|
+
const target = output?.trim();
|
|
685
|
+
const targetStat = target ? await stat(target).catch(() => undefined) : undefined;
|
|
686
|
+
const requestedPath = !target
|
|
687
|
+
? join(".", filename)
|
|
688
|
+
: targetStat?.isDirectory() || target.endsWith("/") || target.endsWith("\\")
|
|
689
|
+
? join(target, filename)
|
|
690
|
+
: extname(target).toLowerCase() === ".md"
|
|
691
|
+
? target
|
|
692
|
+
: extname(target)
|
|
693
|
+
? join(dirname(target), filename)
|
|
694
|
+
: join(target, filename);
|
|
695
|
+
const outputPath = resolve(requestedPath);
|
|
696
|
+
await mkdir(dirname(outputPath), { recursive: true });
|
|
697
|
+
const buffer = Buffer.from(text, "utf8");
|
|
698
|
+
await writeFile(outputPath, buffer);
|
|
699
|
+
return {
|
|
700
|
+
output: outputPath,
|
|
701
|
+
filename: outputPath.split(/[\\/]/).pop() || filename,
|
|
702
|
+
contentType: "text/markdown; charset=utf-8",
|
|
703
|
+
size: buffer.length,
|
|
704
|
+
};
|
|
705
|
+
}
|
|
706
|
+
function printWritingArtifact(artifact) {
|
|
707
|
+
console.log(renderListAsMarkdown([artifact], [
|
|
708
|
+
{ key: "output", label: "output" },
|
|
709
|
+
{ key: "filename", label: "filename" },
|
|
710
|
+
{ key: "contentType", label: "contentType" },
|
|
711
|
+
{ key: "size", label: "size" },
|
|
712
|
+
]));
|
|
713
|
+
}
|
|
714
|
+
/**
|
|
715
|
+
* 输出写作节点创建结果。
|
|
716
|
+
*
|
|
717
|
+
* @param kind 写作节点类型。
|
|
718
|
+
* @param result 节点创建和执行结果。
|
|
719
|
+
* @param format 输出格式。
|
|
720
|
+
*/
|
|
721
|
+
function printStepResult(kind, result, format) {
|
|
722
|
+
const text = prepareWritingText(kind, result.output);
|
|
723
|
+
if (format === "json") {
|
|
724
|
+
printOutput(text ? { ...result, text } : result, "json");
|
|
725
|
+
return;
|
|
726
|
+
}
|
|
727
|
+
if (text) {
|
|
728
|
+
printWritingText(kind, text, result);
|
|
729
|
+
return;
|
|
730
|
+
}
|
|
731
|
+
console.log(renderListAsMarkdown([{ runnerId: result.runnerId, nodeId: result.nodeId, nodeType: result.nodeType, status: result.status }], [
|
|
732
|
+
{ key: "runnerId", label: "runnerId" },
|
|
733
|
+
{ key: "nodeId", label: "nodeId" },
|
|
734
|
+
{ key: "nodeType", label: "node_type" },
|
|
735
|
+
{ key: "status", label: "status" },
|
|
736
|
+
]));
|
|
737
|
+
}
|
|
738
|
+
/**
|
|
739
|
+
* 输出写作节点查询、保存或重跑结果。
|
|
740
|
+
*
|
|
741
|
+
* @param result 操作结果。
|
|
742
|
+
* @param format 输出格式。
|
|
743
|
+
* @param kind 写作节点类型;传入时会优先展示完整正文。
|
|
744
|
+
*/
|
|
745
|
+
function printActionResult(result, format, kind) {
|
|
746
|
+
const text = kind ? prepareWritingText(kind, result) : undefined;
|
|
747
|
+
if (format === "json") {
|
|
748
|
+
if (text && result && typeof result === "object" && !Array.isArray(result)) {
|
|
749
|
+
const payload = result;
|
|
750
|
+
printOutput({
|
|
751
|
+
...payload,
|
|
752
|
+
data: replaceWritingText(payload.data, text),
|
|
753
|
+
text,
|
|
754
|
+
}, "json");
|
|
755
|
+
return;
|
|
756
|
+
}
|
|
757
|
+
printOutput(result, "json");
|
|
758
|
+
return;
|
|
759
|
+
}
|
|
760
|
+
if (kind && text) {
|
|
761
|
+
printWritingText(kind, text);
|
|
762
|
+
return;
|
|
763
|
+
}
|
|
764
|
+
console.log(renderListAsMarkdown([result], [{ key: "runnerId", label: "runnerId" }, { key: "nodeId", label: "nodeId" }]));
|
|
765
|
+
}
|
|
766
|
+
export async function runCreateWritingMethod(options) {
|
|
767
|
+
const created = await createMethod(options);
|
|
768
|
+
const result = await getWriting("method", {
|
|
769
|
+
workflowId: options.workflowId,
|
|
770
|
+
nodeId: created.nodeId,
|
|
771
|
+
configPath: options.configPath,
|
|
772
|
+
});
|
|
773
|
+
const text = prepareWritingText("method", result);
|
|
774
|
+
if (!text) {
|
|
775
|
+
printStepResult("method", created, options.format ?? "markdown");
|
|
776
|
+
return;
|
|
777
|
+
}
|
|
778
|
+
const artifact = await writeWritingMarkdown("method", text, options.output);
|
|
779
|
+
if ((options.format ?? "markdown") === "json") {
|
|
780
|
+
// JSON 带回完整 text,供 Agent 原文逐字完整展示方法正文
|
|
781
|
+
printOutput({
|
|
782
|
+
runnerId: created.runnerId,
|
|
783
|
+
nodeId: created.nodeId,
|
|
784
|
+
artifact,
|
|
785
|
+
text,
|
|
786
|
+
displayInstruction: WRITING_METHOD_DISPLAY_INSTRUCTION,
|
|
787
|
+
}, "json");
|
|
788
|
+
return;
|
|
789
|
+
}
|
|
790
|
+
printWritingArtifact(artifact);
|
|
791
|
+
}
|
|
792
|
+
export async function runGetWritingMethod(options) {
|
|
793
|
+
const result = await getWriting("method", options);
|
|
794
|
+
const text = prepareWritingText("method", result);
|
|
795
|
+
if (!text) {
|
|
796
|
+
printActionResult(result, options.format ?? "markdown", "method");
|
|
797
|
+
return;
|
|
798
|
+
}
|
|
799
|
+
const artifact = await writeWritingMarkdown("method", text, options.output);
|
|
800
|
+
if ((options.format ?? "markdown") === "json") {
|
|
801
|
+
// JSON 带回完整 text,供 Agent 原文逐字完整展示方法正文
|
|
802
|
+
printOutput({
|
|
803
|
+
runnerId: result.runnerId,
|
|
804
|
+
nodeId: result.nodeId,
|
|
805
|
+
artifact,
|
|
806
|
+
text,
|
|
807
|
+
displayInstruction: WRITING_METHOD_DISPLAY_INSTRUCTION,
|
|
808
|
+
}, "json");
|
|
809
|
+
return;
|
|
810
|
+
}
|
|
811
|
+
printWritingArtifact(artifact);
|
|
812
|
+
}
|
|
813
|
+
export async function runRerunWritingMethod(options) {
|
|
814
|
+
const rerun = await rerunWriting("method", options);
|
|
815
|
+
const result = await getWriting("method", {
|
|
816
|
+
workflowId: options.workflowId,
|
|
817
|
+
nodeId: rerun.nodeId,
|
|
818
|
+
configPath: options.configPath,
|
|
819
|
+
});
|
|
820
|
+
const text = prepareWritingText("method", result);
|
|
821
|
+
if (!text) {
|
|
822
|
+
printActionResult(rerun, options.format ?? "markdown");
|
|
823
|
+
return;
|
|
824
|
+
}
|
|
825
|
+
const artifact = await writeWritingMarkdown("method", text, options.output);
|
|
826
|
+
if ((options.format ?? "markdown") === "json") {
|
|
827
|
+
// JSON 带回完整 text,供 Agent 原文逐字完整展示方法正文
|
|
828
|
+
printOutput({
|
|
829
|
+
runnerId: result.runnerId,
|
|
830
|
+
nodeId: result.nodeId,
|
|
831
|
+
artifact,
|
|
832
|
+
text,
|
|
833
|
+
displayInstruction: WRITING_METHOD_DISPLAY_INSTRUCTION,
|
|
834
|
+
}, "json");
|
|
835
|
+
return;
|
|
836
|
+
}
|
|
837
|
+
printWritingArtifact(artifact);
|
|
838
|
+
}
|
|
839
|
+
/**
|
|
840
|
+
* 用户编辑方法正文后立即保存(不等下一步)。
|
|
841
|
+
*/
|
|
842
|
+
export async function runUpdateWritingMethod(options) {
|
|
843
|
+
await saveWriting("method", options);
|
|
844
|
+
const result = await getWriting("method", {
|
|
845
|
+
workflowId: options.workflowId,
|
|
846
|
+
nodeId: options.nodeId,
|
|
847
|
+
configPath: options.configPath,
|
|
848
|
+
});
|
|
849
|
+
const text = prepareWritingText("method", result);
|
|
850
|
+
if (!text) {
|
|
851
|
+
printActionResult(result, options.format ?? "markdown", "method");
|
|
852
|
+
return;
|
|
853
|
+
}
|
|
854
|
+
const artifact = await writeWritingMarkdown("method", text, options.output);
|
|
855
|
+
if ((options.format ?? "markdown") === "json") {
|
|
856
|
+
printOutput({
|
|
857
|
+
runnerId: result.runnerId,
|
|
858
|
+
nodeId: result.nodeId,
|
|
859
|
+
artifact,
|
|
860
|
+
text,
|
|
861
|
+
displayInstruction: WRITING_METHOD_DISPLAY_INSTRUCTION,
|
|
862
|
+
}, "json");
|
|
863
|
+
return;
|
|
864
|
+
}
|
|
865
|
+
printWritingArtifact(artifact);
|
|
866
|
+
}
|
|
867
|
+
export async function runCreateWritingResult(options) {
|
|
868
|
+
const result = await createResult(options);
|
|
869
|
+
const saved = await getWriting("result", {
|
|
870
|
+
workflowId: options.workflowId,
|
|
871
|
+
nodeId: result.nodeId,
|
|
872
|
+
configPath: options.configPath,
|
|
873
|
+
});
|
|
874
|
+
const text = prepareWritingText("result", saved);
|
|
875
|
+
const artifact = text ? await writeWritingMarkdown("result", text, options.output) : undefined;
|
|
876
|
+
if ((options.format ?? "markdown") === "json") {
|
|
877
|
+
printOutput(text
|
|
878
|
+
? {
|
|
879
|
+
runnerId: result.runnerId,
|
|
880
|
+
nodeId: result.nodeId,
|
|
881
|
+
nodeType: result.nodeType,
|
|
882
|
+
status: result.status,
|
|
883
|
+
artifact,
|
|
884
|
+
// JSON 带回完整 text;对话仅部分预览,完整内容见 artifact
|
|
885
|
+
text,
|
|
886
|
+
displayInstruction: WRITING_RESULT_DISPLAY_INSTRUCTION,
|
|
887
|
+
}
|
|
888
|
+
: result, "json");
|
|
889
|
+
return;
|
|
890
|
+
}
|
|
891
|
+
if (text) {
|
|
892
|
+
if (artifact) {
|
|
893
|
+
printWritingArtifact(artifact);
|
|
894
|
+
}
|
|
895
|
+
return;
|
|
896
|
+
}
|
|
897
|
+
printStepResult("result", result, options.format ?? "markdown");
|
|
898
|
+
}
|
|
899
|
+
export async function runGetWritingResult(options) {
|
|
900
|
+
const result = await getWriting("result", options);
|
|
901
|
+
const text = prepareWritingText("result", result);
|
|
902
|
+
if (!text) {
|
|
903
|
+
printActionResult(result, options.format ?? "markdown", "result");
|
|
904
|
+
return;
|
|
905
|
+
}
|
|
906
|
+
const artifact = await writeWritingMarkdown("result", text, options.output);
|
|
907
|
+
if ((options.format ?? "markdown") === "json") {
|
|
908
|
+
// JSON 带回完整 text;对话仅部分预览,完整内容见 artifact
|
|
909
|
+
printOutput({
|
|
910
|
+
runnerId: result.runnerId,
|
|
911
|
+
nodeId: result.nodeId,
|
|
912
|
+
artifact,
|
|
913
|
+
text,
|
|
914
|
+
displayInstruction: WRITING_RESULT_DISPLAY_INSTRUCTION,
|
|
915
|
+
}, "json");
|
|
916
|
+
return;
|
|
917
|
+
}
|
|
918
|
+
printWritingArtifact(artifact);
|
|
919
|
+
}
|
|
920
|
+
export async function runRerunWritingResult(options) {
|
|
921
|
+
const rerun = await rerunWriting("result", options);
|
|
922
|
+
const result = await getWriting("result", {
|
|
923
|
+
workflowId: options.workflowId,
|
|
924
|
+
nodeId: rerun.nodeId,
|
|
925
|
+
configPath: options.configPath,
|
|
926
|
+
});
|
|
927
|
+
const text = prepareWritingText("result", result);
|
|
928
|
+
if (!text) {
|
|
929
|
+
printActionResult(rerun, options.format ?? "markdown");
|
|
930
|
+
return;
|
|
931
|
+
}
|
|
932
|
+
const artifact = await writeWritingMarkdown("result", text, options.output);
|
|
933
|
+
if ((options.format ?? "markdown") === "json") {
|
|
934
|
+
// JSON 带回完整 text;对话仅部分预览,完整内容见 artifact
|
|
935
|
+
printOutput({
|
|
936
|
+
runnerId: result.runnerId,
|
|
937
|
+
nodeId: result.nodeId,
|
|
938
|
+
artifact,
|
|
939
|
+
text,
|
|
940
|
+
displayInstruction: WRITING_RESULT_DISPLAY_INSTRUCTION,
|
|
941
|
+
}, "json");
|
|
942
|
+
return;
|
|
943
|
+
}
|
|
944
|
+
printWritingArtifact(artifact);
|
|
945
|
+
}
|
|
946
|
+
/**
|
|
947
|
+
* 用户编辑结果正文后立即保存(不等下一步)。
|
|
948
|
+
*/
|
|
949
|
+
export async function runUpdateWritingResult(options) {
|
|
950
|
+
await saveWriting("result", options);
|
|
951
|
+
const result = await getWriting("result", {
|
|
952
|
+
workflowId: options.workflowId,
|
|
953
|
+
nodeId: options.nodeId,
|
|
954
|
+
configPath: options.configPath,
|
|
955
|
+
});
|
|
956
|
+
const text = prepareWritingText("result", result);
|
|
957
|
+
if (!text) {
|
|
958
|
+
printActionResult(result, options.format ?? "markdown", "result");
|
|
959
|
+
return;
|
|
960
|
+
}
|
|
961
|
+
const artifact = await writeWritingMarkdown("result", text, options.output);
|
|
962
|
+
if ((options.format ?? "markdown") === "json") {
|
|
963
|
+
printOutput({
|
|
964
|
+
runnerId: result.runnerId,
|
|
965
|
+
nodeId: result.nodeId,
|
|
966
|
+
artifact,
|
|
967
|
+
text,
|
|
968
|
+
displayInstruction: WRITING_RESULT_DISPLAY_INSTRUCTION,
|
|
969
|
+
}, "json");
|
|
970
|
+
return;
|
|
971
|
+
}
|
|
972
|
+
printWritingArtifact(artifact);
|
|
973
|
+
}
|
|
974
|
+
export async function runCreateWritingFullText(options) {
|
|
975
|
+
const result = await createFullText(options);
|
|
976
|
+
const fullText = await getWriting("fulltext", {
|
|
977
|
+
workflowId: options.workflowId,
|
|
978
|
+
nodeId: result.nodeId,
|
|
979
|
+
configPath: options.configPath,
|
|
980
|
+
});
|
|
981
|
+
const text = prepareWritingText("fulltext", fullText.data) ?? extractWritingText(fullText.data);
|
|
982
|
+
const fullTextArtifact = await exportFullText({
|
|
983
|
+
workflowId: options.workflowId,
|
|
984
|
+
nodeId: result.nodeId,
|
|
985
|
+
text,
|
|
986
|
+
output: options.output,
|
|
987
|
+
filename: "生成初稿.docx",
|
|
988
|
+
exportFormat: options.exportFormat,
|
|
989
|
+
configPath: options.configPath,
|
|
990
|
+
});
|
|
991
|
+
const bundleOutput = dirname(fullTextArtifact.output);
|
|
992
|
+
const companionArtifacts = await exportFullTextCompanionArtifacts({
|
|
993
|
+
workflowId: options.workflowId,
|
|
994
|
+
configPath: options.configPath,
|
|
995
|
+
outputDirectory: bundleOutput,
|
|
996
|
+
});
|
|
997
|
+
const artifacts = [
|
|
998
|
+
...companionArtifacts,
|
|
999
|
+
fullTextArtifact,
|
|
1000
|
+
];
|
|
1001
|
+
if ((options.format ?? "markdown") === "json") {
|
|
1002
|
+
// text 供 Agent 做部分正文预览;完整初稿以 Word 产物为准
|
|
1003
|
+
printOutput({
|
|
1004
|
+
runnerId: result.runnerId,
|
|
1005
|
+
nodeId: result.nodeId,
|
|
1006
|
+
nodeType: result.nodeType,
|
|
1007
|
+
status: result.status,
|
|
1008
|
+
artifact: artifacts,
|
|
1009
|
+
...(text ? { text } : {}),
|
|
1010
|
+
displayInstruction: WRITING_FULLTEXT_DISPLAY_INSTRUCTION,
|
|
1011
|
+
}, "json");
|
|
1012
|
+
return;
|
|
1013
|
+
}
|
|
1014
|
+
console.log(renderListAsMarkdown(artifacts, [
|
|
1015
|
+
{ key: "output", label: "output" },
|
|
1016
|
+
{ key: "filename", label: "filename" },
|
|
1017
|
+
{ key: "contentType", label: "contentType" },
|
|
1018
|
+
{ key: "size", label: "size" },
|
|
1019
|
+
]));
|
|
1020
|
+
}
|
|
1021
|
+
export async function runGetWritingFullText(options) {
|
|
1022
|
+
const result = await getWriting("fulltext", options);
|
|
1023
|
+
const text = prepareWritingText("fulltext", result.data) ?? extractWritingText(result.data);
|
|
1024
|
+
// 历史切入与 create 一致:导出初稿 Word,并下载同次交付的全部配套产物
|
|
1025
|
+
const fullTextArtifact = await exportFullText({
|
|
1026
|
+
workflowId: options.workflowId,
|
|
1027
|
+
nodeId: result.nodeId,
|
|
1028
|
+
text,
|
|
1029
|
+
output: options.output,
|
|
1030
|
+
filename: "生成初稿.docx",
|
|
1031
|
+
configPath: options.configPath,
|
|
1032
|
+
});
|
|
1033
|
+
const companionArtifacts = await exportFullTextCompanionArtifacts({
|
|
1034
|
+
workflowId: options.workflowId,
|
|
1035
|
+
configPath: options.configPath,
|
|
1036
|
+
outputDirectory: dirname(fullTextArtifact.output),
|
|
1037
|
+
});
|
|
1038
|
+
const artifacts = [
|
|
1039
|
+
...companionArtifacts,
|
|
1040
|
+
fullTextArtifact,
|
|
1041
|
+
];
|
|
1042
|
+
if ((options.format ?? "markdown") === "json") {
|
|
1043
|
+
// text 供 Agent 做部分正文预览;完整初稿以 Word 产物为准
|
|
1044
|
+
printOutput({
|
|
1045
|
+
runnerId: result.runnerId,
|
|
1046
|
+
nodeId: result.nodeId,
|
|
1047
|
+
artifact: artifacts,
|
|
1048
|
+
...(text ? { text } : {}),
|
|
1049
|
+
displayInstruction: WRITING_FULLTEXT_DISPLAY_INSTRUCTION,
|
|
1050
|
+
}, "json");
|
|
1051
|
+
return;
|
|
1052
|
+
}
|
|
1053
|
+
console.log(renderListAsMarkdown(artifacts, [
|
|
1054
|
+
{ key: "output", label: "output" },
|
|
1055
|
+
{ key: "filename", label: "filename" },
|
|
1056
|
+
{ key: "contentType", label: "contentType" },
|
|
1057
|
+
{ key: "size", label: "size" },
|
|
1058
|
+
]));
|
|
1059
|
+
}
|
|
1060
|
+
export async function runRerunWritingFullText(options) {
|
|
1061
|
+
printActionResult(await rerunWriting("fulltext", options), options.format ?? "markdown");
|
|
1062
|
+
}
|
|
1063
|
+
export async function runExportWritingFullText(options) {
|
|
1064
|
+
const result = await exportFullText(options);
|
|
1065
|
+
if ((options.format ?? "markdown") === "json") {
|
|
1066
|
+
printOutput(result, "json");
|
|
1067
|
+
return;
|
|
1068
|
+
}
|
|
1069
|
+
console.log(renderListAsMarkdown([result], [
|
|
1070
|
+
{ key: "runnerId", label: "runnerId" },
|
|
1071
|
+
{ key: "nodeId", label: "nodeId" },
|
|
1072
|
+
{ key: "output", label: "output" },
|
|
1073
|
+
{ key: "filename", label: "filename" },
|
|
1074
|
+
{ key: "size", label: "size" },
|
|
1075
|
+
]));
|
|
1076
|
+
}
|
|
1077
|
+
//# sourceMappingURL=writing.js.map
|