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,913 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { createStderrProgress, helixlifeError, helixlifeErrorCode, printOutput, renderListAsMarkdown, } from "../../core/index.js";
|
|
3
|
+
import { requestMeta } from "./api.js";
|
|
4
|
+
import { META_API_PREFIX } from "./constants.js";
|
|
5
|
+
import { createMetaNode, getMetaNodeOutput, pollMetaNodeStatus, } from "./node.js";
|
|
6
|
+
const META_RETRIEVE_NODE_TYPES = {
|
|
7
|
+
PICOS: "generate_picos",
|
|
8
|
+
EXPRESSION: "generate_retrieve_expression",
|
|
9
|
+
LITERATURE: "literature_retrieve",
|
|
10
|
+
};
|
|
11
|
+
/** 四库检索式字段名(与网站 RETRIEVE_LIST_ENUMS / API 一致;Cochrane 字段为 conchrane)。 */
|
|
12
|
+
const RETRIEVE_DATABASE_KEYS = ["pubmed", "wos", "embase", "conchrane"];
|
|
13
|
+
/** 选择器展示名 → API 字段名(编辑检索式第一步选项)。 */
|
|
14
|
+
const RETRIEVE_DATABASE_LABEL_TO_KEY = {
|
|
15
|
+
Pubmed: "pubmed",
|
|
16
|
+
PubMed: "pubmed",
|
|
17
|
+
pubmed: "pubmed",
|
|
18
|
+
WOS: "wos",
|
|
19
|
+
wos: "wos",
|
|
20
|
+
Embase: "embase",
|
|
21
|
+
embase: "embase",
|
|
22
|
+
Cochrane: "conchrane",
|
|
23
|
+
conchrane: "conchrane",
|
|
24
|
+
};
|
|
25
|
+
function parseJsonObject(raw, optionName) {
|
|
26
|
+
const jsonText = raw?.replace(/^\uFEFF/, "").trim();
|
|
27
|
+
if (!jsonText) {
|
|
28
|
+
return {};
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
const parsed = JSON.parse(jsonText);
|
|
32
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
33
|
+
throw new Error("not an object");
|
|
34
|
+
}
|
|
35
|
+
return parsed;
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
throw new helixlifeError(helixlifeErrorCode.INVALID_ARGUMENT, `${optionName} 须为合法 JSON 对象`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
async function parseJsonObjectInput(raw, filePath, optionName, fileOptionName) {
|
|
42
|
+
if (filePath?.trim()) {
|
|
43
|
+
const content = await readFile(filePath.trim(), "utf8");
|
|
44
|
+
return parseJsonObject(content, fileOptionName);
|
|
45
|
+
}
|
|
46
|
+
if (!raw?.trim()) {
|
|
47
|
+
throw new helixlifeError(helixlifeErrorCode.INVALID_ARGUMENT, `缺少 ${optionName} 或 ${fileOptionName}`);
|
|
48
|
+
}
|
|
49
|
+
return parseJsonObject(raw, optionName);
|
|
50
|
+
}
|
|
51
|
+
function extractNodeOutput(node) {
|
|
52
|
+
if (node.output &&
|
|
53
|
+
typeof node.output === "object" &&
|
|
54
|
+
"output" in node.output) {
|
|
55
|
+
return node.output.output;
|
|
56
|
+
}
|
|
57
|
+
return node.output ?? {};
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* 判断值是否为合法的四库 select 字段。
|
|
61
|
+
*
|
|
62
|
+
* @param value 候选 select。
|
|
63
|
+
* @returns 合法时返回字段名,否则 undefined。
|
|
64
|
+
*/
|
|
65
|
+
function resolveRetrieveDatabaseKey(value) {
|
|
66
|
+
if (typeof value !== "string" || !value.trim()) {
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
const trimmed = value.trim();
|
|
70
|
+
if (RETRIEVE_DATABASE_KEYS.includes(trimmed)) {
|
|
71
|
+
return trimmed;
|
|
72
|
+
}
|
|
73
|
+
return RETRIEVE_DATABASE_LABEL_TO_KEY[trimmed];
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* 将检索式节点输出归一化为四个数据库检索式。
|
|
77
|
+
*
|
|
78
|
+
* 四库均可展示与编辑保存。
|
|
79
|
+
*
|
|
80
|
+
* @param output 检索式节点原始输出。
|
|
81
|
+
* @returns 包含四个数据库检索式和 select 的展示/提交数据。
|
|
82
|
+
*/
|
|
83
|
+
function normalizeRetrieveExpressionOutput(output) {
|
|
84
|
+
if (typeof output === "string") {
|
|
85
|
+
return normalizeRetrieveExpressionPayload({ pubmed: output });
|
|
86
|
+
}
|
|
87
|
+
if (!output || typeof output !== "object" || Array.isArray(output)) {
|
|
88
|
+
return normalizeRetrieveExpressionPayload({});
|
|
89
|
+
}
|
|
90
|
+
return normalizeRetrieveExpressionPayload(output);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* 将检索式数据归一化为后端需要的完整数据库字段结构。
|
|
94
|
+
*
|
|
95
|
+
* 保存接口一次提交 `select` + `pubmed`/`wos`/`embase`/`conchrane` 四库全文。
|
|
96
|
+
* 用户可只改其中一库;未改字段由 fallback(当前节点输出)补齐。
|
|
97
|
+
*
|
|
98
|
+
* @param input 检索式原始输出或用户编辑后的输入。
|
|
99
|
+
* @param fallback 可选的原始节点输出,用于补齐未编辑的库。
|
|
100
|
+
* @returns 可直接提交给保存或检索接口的完整检索式结构。
|
|
101
|
+
*/
|
|
102
|
+
function normalizeRetrieveExpressionPayload(input, fallback = {}) {
|
|
103
|
+
const source = { ...fallback, ...input };
|
|
104
|
+
const pubmed = source.pubmed ??
|
|
105
|
+
source.PubMed ??
|
|
106
|
+
source.pubMed ??
|
|
107
|
+
source.pubmed_expression ??
|
|
108
|
+
"";
|
|
109
|
+
const select = resolveRetrieveDatabaseKey(source.select) ??
|
|
110
|
+
resolveRetrieveDatabaseKey(fallback.select) ??
|
|
111
|
+
"pubmed";
|
|
112
|
+
return {
|
|
113
|
+
select,
|
|
114
|
+
pubmed: typeof pubmed === "string" ? pubmed : String(pubmed ?? ""),
|
|
115
|
+
wos: typeof source.wos === "string" ? source.wos : String(source.wos ?? ""),
|
|
116
|
+
embase: typeof source.embase === "string"
|
|
117
|
+
? source.embase
|
|
118
|
+
: String(source.embase ?? ""),
|
|
119
|
+
conchrane: typeof source.conchrane === "string"
|
|
120
|
+
? source.conchrane
|
|
121
|
+
: String(source.conchrane ?? ""),
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
/** 检索式展示指令:必须以 expressionMarkdown 为唯一展示源(含编辑/重检前展示)。 */
|
|
125
|
+
const EXPRESSION_DISPLAY_INSTRUCTION = "必须将 expressionMarkdown 整段原样复制进回复(禁止重打、改写、摘要):" +
|
|
126
|
+
"PubMed / WOS / Embase / Cochrane 四库均须完整输出;禁止用 ... / … / 「及后续完整内容」等占位截断。" +
|
|
127
|
+
"保持原文换行,勿按 AND/OR 自行拆成多行。" +
|
|
128
|
+
"编辑细则分别见 meta.md「检索式 / 编辑检索式」与「检索结果 / 编辑检索式并重新检索」。";
|
|
129
|
+
/**
|
|
130
|
+
* 将四库检索式格式化为可原样展示的 Markdown。
|
|
131
|
+
*
|
|
132
|
+
* @param output 已归一化的四库检索式字段。
|
|
133
|
+
* @returns 四库均可编辑的完整 Markdown(无只读标注)。
|
|
134
|
+
*/
|
|
135
|
+
function buildExpressionMarkdown(output) {
|
|
136
|
+
return [
|
|
137
|
+
"## PubMed 检索式",
|
|
138
|
+
"",
|
|
139
|
+
String(output.pubmed ?? ""),
|
|
140
|
+
"",
|
|
141
|
+
"## Web of Science 检索式",
|
|
142
|
+
"",
|
|
143
|
+
String(output.wos ?? ""),
|
|
144
|
+
"",
|
|
145
|
+
"## Embase 检索式",
|
|
146
|
+
"",
|
|
147
|
+
String(output.embase ?? ""),
|
|
148
|
+
"",
|
|
149
|
+
"## Cochrane 检索式",
|
|
150
|
+
"",
|
|
151
|
+
String(output.conchrane ?? ""),
|
|
152
|
+
].join("\n");
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* 归一化检索式结果,附加 expressionMarkdown 供 Agent 原样展示四库全文。
|
|
156
|
+
*
|
|
157
|
+
* @param result 检索式节点执行或读取结果。
|
|
158
|
+
* @returns 带 displayOutput / expressionMarkdown 的结果。
|
|
159
|
+
*/
|
|
160
|
+
function normalizeRetrieveExpressionResult(result) {
|
|
161
|
+
if (result.nodeType !== META_RETRIEVE_NODE_TYPES.EXPRESSION) {
|
|
162
|
+
return result;
|
|
163
|
+
}
|
|
164
|
+
const output = normalizeRetrieveExpressionOutput(result.output);
|
|
165
|
+
return {
|
|
166
|
+
...result,
|
|
167
|
+
output,
|
|
168
|
+
displayOutput: output,
|
|
169
|
+
displayInstruction: EXPRESSION_DISPLAY_INSTRUCTION,
|
|
170
|
+
expressionMarkdown: buildExpressionMarkdown(output),
|
|
171
|
+
node: {
|
|
172
|
+
...result.node,
|
|
173
|
+
output: { output },
|
|
174
|
+
},
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
function splitListField(value) {
|
|
178
|
+
if (typeof value === "string") {
|
|
179
|
+
return value
|
|
180
|
+
.split(/[,,;]/)
|
|
181
|
+
.map((item) => item.trim())
|
|
182
|
+
.filter(Boolean);
|
|
183
|
+
}
|
|
184
|
+
return value;
|
|
185
|
+
}
|
|
186
|
+
function normalizePublicationDate(value) {
|
|
187
|
+
if (typeof value !== "string") {
|
|
188
|
+
return value;
|
|
189
|
+
}
|
|
190
|
+
const trimmed = value.trim();
|
|
191
|
+
if (!trimmed) {
|
|
192
|
+
return undefined;
|
|
193
|
+
}
|
|
194
|
+
const timestamp = /^\d{4}-\d{2}-\d{2}$/.test(trimmed)
|
|
195
|
+
? Date.parse(`${trimmed}T00:00:00Z`)
|
|
196
|
+
: Date.parse(trimmed);
|
|
197
|
+
return Number.isNaN(timestamp) ? value : Math.floor(timestamp / 1000);
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* 将补充文献输入转换为网站接口使用的数据结构。
|
|
201
|
+
*
|
|
202
|
+
* 仅保留网站补充文献表单支持的字段,并统一作者、发表类型和发表日期格式。
|
|
203
|
+
*
|
|
204
|
+
* @param input 用户提交的补充文献数据。
|
|
205
|
+
* @returns 可发送给补充文献接口的数据。
|
|
206
|
+
*/
|
|
207
|
+
function normalizeLiteratureInput(input) {
|
|
208
|
+
const allowedKeys = [
|
|
209
|
+
"id",
|
|
210
|
+
"author",
|
|
211
|
+
"title",
|
|
212
|
+
"doi",
|
|
213
|
+
"abstract",
|
|
214
|
+
"publication_type",
|
|
215
|
+
"publication_date",
|
|
216
|
+
"pmid",
|
|
217
|
+
"pmc",
|
|
218
|
+
];
|
|
219
|
+
const normalized = Object.fromEntries(Object.entries(input).filter(([key]) => allowedKeys.includes(key)));
|
|
220
|
+
if ("author" in normalized) {
|
|
221
|
+
normalized.author = splitListField(normalized.author);
|
|
222
|
+
}
|
|
223
|
+
if ("publication_type" in normalized) {
|
|
224
|
+
normalized.publication_type = splitListField(normalized.publication_type);
|
|
225
|
+
}
|
|
226
|
+
if ("publication_date" in normalized) {
|
|
227
|
+
const publicationDate = normalizePublicationDate(normalized.publication_date);
|
|
228
|
+
if (publicationDate === undefined) {
|
|
229
|
+
delete normalized.publication_date;
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
normalized.publication_date = publicationDate;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return normalized;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* 校验网站补充文献表单在创建模式下要求的必填字段。
|
|
239
|
+
*
|
|
240
|
+
* @param input 已归一化的补充文献数据。
|
|
241
|
+
* @throws {helixlifeError} 缺少 author、title、abstract 或 publication_date 时抛出。
|
|
242
|
+
*/
|
|
243
|
+
function validateLiteratureInput(input) {
|
|
244
|
+
const requiredFields = ["author", "title", "abstract", "publication_date"];
|
|
245
|
+
const missingFields = requiredFields.filter((field) => {
|
|
246
|
+
const value = input[field];
|
|
247
|
+
if (Array.isArray(value)) {
|
|
248
|
+
return value.length === 0;
|
|
249
|
+
}
|
|
250
|
+
return value === undefined || value === null || String(value).trim() === "";
|
|
251
|
+
});
|
|
252
|
+
if (missingFields.length > 0) {
|
|
253
|
+
throw new helixlifeError(helixlifeErrorCode.INVALID_ARGUMENT, `补充文献缺少必填字段:${missingFields.join(", ")}`);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
async function getWorkflow(workflowId, configPath) {
|
|
257
|
+
return requestMeta(`${META_API_PREFIX}/workflow/runs/${encodeURIComponent(workflowId)}`, {
|
|
258
|
+
configPath,
|
|
259
|
+
action: "查询 Meta 工作流",
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
function findLatestNode(workflow, nodeType) {
|
|
263
|
+
return [...(workflow.nodes ?? [])]
|
|
264
|
+
.reverse()
|
|
265
|
+
.find((node) => node.node_type === nodeType);
|
|
266
|
+
}
|
|
267
|
+
async function resolveNodeId(options) {
|
|
268
|
+
if (options.nodeId?.trim()) {
|
|
269
|
+
return options.nodeId.trim();
|
|
270
|
+
}
|
|
271
|
+
const workflow = await getWorkflow(options.workflowId, options.configPath);
|
|
272
|
+
const node = findLatestNode(workflow, options.nodeType);
|
|
273
|
+
if (!node) {
|
|
274
|
+
throw new helixlifeError(helixlifeErrorCode.INVALID_ARGUMENT, `当前工作流中未找到 ${options.label} 节点`);
|
|
275
|
+
}
|
|
276
|
+
return node.id;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* 读取当前检索式节点的原始输出,用于保存或检索时补齐隐藏数据库字段。
|
|
280
|
+
*
|
|
281
|
+
* @param options 工作流和节点定位参数。
|
|
282
|
+
* @returns 检索式节点输出对象;无法读取为对象时返回空对象。
|
|
283
|
+
*/
|
|
284
|
+
async function getRetrieveExpressionFallback(options) {
|
|
285
|
+
const nodeId = await resolveNodeId({
|
|
286
|
+
workflowId: options.workflowId,
|
|
287
|
+
nodeId: options.nodeId,
|
|
288
|
+
nodeType: META_RETRIEVE_NODE_TYPES.EXPRESSION,
|
|
289
|
+
label: "检索式",
|
|
290
|
+
configPath: options.configPath,
|
|
291
|
+
});
|
|
292
|
+
const output = await getMetaNodeOutput({
|
|
293
|
+
workflowId: options.workflowId,
|
|
294
|
+
nodeId,
|
|
295
|
+
configPath: options.configPath,
|
|
296
|
+
});
|
|
297
|
+
const rawOutput = extractNodeOutput(output.data);
|
|
298
|
+
return {
|
|
299
|
+
nodeId,
|
|
300
|
+
output: rawOutput && typeof rawOutput === "object" && !Array.isArray(rawOutput)
|
|
301
|
+
? rawOutput
|
|
302
|
+
: {},
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
async function runRetrieveNode(options) {
|
|
306
|
+
const progress = createStderrProgress(options.format === "json");
|
|
307
|
+
progress.start(options.progressMessage);
|
|
308
|
+
try {
|
|
309
|
+
const created = await createMetaNode({
|
|
310
|
+
workflowId: options.workflowId,
|
|
311
|
+
nodeType: options.nodeType,
|
|
312
|
+
input: options.input,
|
|
313
|
+
configPath: options.configPath,
|
|
314
|
+
});
|
|
315
|
+
await pollMetaNodeStatus({
|
|
316
|
+
workflowId: options.workflowId,
|
|
317
|
+
nodeId: created.nodeId,
|
|
318
|
+
configPath: options.configPath,
|
|
319
|
+
});
|
|
320
|
+
const output = await getMetaNodeOutput({
|
|
321
|
+
workflowId: options.workflowId,
|
|
322
|
+
nodeId: created.nodeId,
|
|
323
|
+
configPath: options.configPath,
|
|
324
|
+
});
|
|
325
|
+
progress.finish("Meta 节点执行完成,正在输出结果...");
|
|
326
|
+
return {
|
|
327
|
+
runnerId: options.workflowId,
|
|
328
|
+
nodeId: created.nodeId,
|
|
329
|
+
nodeType: options.nodeType,
|
|
330
|
+
status: output.data.status,
|
|
331
|
+
input: options.input,
|
|
332
|
+
output: extractNodeOutput(output.data),
|
|
333
|
+
node: output.data,
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
catch (error) {
|
|
337
|
+
progress.dispose();
|
|
338
|
+
throw error;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* 输出文献检索 create 结果;JSON 仅暴露 tableMarkdown,避免 Agent 从 rows 自行拼缩略表。
|
|
343
|
+
*
|
|
344
|
+
* @param result create 返回的检索步骤结果。
|
|
345
|
+
* @param format 输出格式。
|
|
346
|
+
*/
|
|
347
|
+
function printLiteratureCreateResult(result, format) {
|
|
348
|
+
if (format === "json") {
|
|
349
|
+
printOutput({
|
|
350
|
+
runnerId: result.runnerId,
|
|
351
|
+
nodeId: result.nodeId,
|
|
352
|
+
nodeType: result.nodeType,
|
|
353
|
+
status: result.status,
|
|
354
|
+
displayInstruction: result.displayInstruction,
|
|
355
|
+
tableMarkdown: result.tableMarkdown,
|
|
356
|
+
total: result.total,
|
|
357
|
+
page: result.page,
|
|
358
|
+
limit: result.limit,
|
|
359
|
+
}, "json");
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
console.log(result.tableMarkdown ?? "");
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* 输出文献检索 list 结果;JSON 仅暴露 tableMarkdown 与分页字段。
|
|
366
|
+
*
|
|
367
|
+
* @param result list 返回的检索列表结果。
|
|
368
|
+
* @param format 输出格式。
|
|
369
|
+
*/
|
|
370
|
+
function printLiteratureListResult(result, format) {
|
|
371
|
+
if (format === "json") {
|
|
372
|
+
printOutput({
|
|
373
|
+
runnerId: result.runnerId,
|
|
374
|
+
nodeId: result.nodeId,
|
|
375
|
+
displayInstruction: result.displayInstruction,
|
|
376
|
+
tableMarkdown: result.tableMarkdown,
|
|
377
|
+
total: result.total,
|
|
378
|
+
page: result.page,
|
|
379
|
+
limit: result.limit,
|
|
380
|
+
}, "json");
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
console.log(result.tableMarkdown ?? "");
|
|
384
|
+
}
|
|
385
|
+
function printRetrieveStepResult(result, format) {
|
|
386
|
+
if (result.nodeType === META_RETRIEVE_NODE_TYPES.LITERATURE) {
|
|
387
|
+
printLiteratureCreateResult(result, format);
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
if (format === "json") {
|
|
391
|
+
if (result.nodeType === META_RETRIEVE_NODE_TYPES.EXPRESSION) {
|
|
392
|
+
printOutput({
|
|
393
|
+
runnerId: result.runnerId,
|
|
394
|
+
nodeId: result.nodeId,
|
|
395
|
+
nodeType: result.nodeType,
|
|
396
|
+
status: result.status,
|
|
397
|
+
displayInstruction: result.displayInstruction,
|
|
398
|
+
expressionMarkdown: result.expressionMarkdown,
|
|
399
|
+
displayOutput: result.displayOutput,
|
|
400
|
+
}, "json");
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
printOutput(result, "json");
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
if (result.expressionMarkdown) {
|
|
407
|
+
console.log(result.expressionMarkdown);
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
console.log(renderListAsMarkdown([
|
|
411
|
+
{
|
|
412
|
+
runnerId: result.runnerId,
|
|
413
|
+
nodeType: result.nodeType,
|
|
414
|
+
status: result.status,
|
|
415
|
+
},
|
|
416
|
+
], [
|
|
417
|
+
{ key: "runnerId", label: "runnerId" },
|
|
418
|
+
{ key: "nodeType", label: "节点类型" },
|
|
419
|
+
{ key: "status", label: "状态" },
|
|
420
|
+
]));
|
|
421
|
+
console.log("\n输出:");
|
|
422
|
+
console.log(typeof result.output === "string"
|
|
423
|
+
? result.output
|
|
424
|
+
: JSON.stringify(result.output, null, 2));
|
|
425
|
+
}
|
|
426
|
+
export async function createRetrieveExpression(options) {
|
|
427
|
+
const picosNodeId = options.picosNodeId?.trim() ??
|
|
428
|
+
(await resolveNodeId({
|
|
429
|
+
workflowId: options.workflowId,
|
|
430
|
+
nodeType: META_RETRIEVE_NODE_TYPES.PICOS,
|
|
431
|
+
label: "PICOS",
|
|
432
|
+
configPath: options.configPath,
|
|
433
|
+
}));
|
|
434
|
+
const progress = createStderrProgress(options.format === "json");
|
|
435
|
+
progress.start("正在生成检索式...");
|
|
436
|
+
try {
|
|
437
|
+
const created = await requestMeta(`${META_API_PREFIX}/generate-retrieve-expression/execute`, {
|
|
438
|
+
method: "POST",
|
|
439
|
+
params: {
|
|
440
|
+
run_id: options.workflowId,
|
|
441
|
+
picos_node_id: picosNodeId,
|
|
442
|
+
},
|
|
443
|
+
configPath: options.configPath,
|
|
444
|
+
action: "生成检索式",
|
|
445
|
+
});
|
|
446
|
+
if (!created.node_id) {
|
|
447
|
+
throw new helixlifeError(helixlifeErrorCode.INVALID_RESPONSE, "生成检索式响应缺少 node_id");
|
|
448
|
+
}
|
|
449
|
+
await pollMetaNodeStatus({
|
|
450
|
+
workflowId: options.workflowId,
|
|
451
|
+
nodeId: created.node_id,
|
|
452
|
+
configPath: options.configPath,
|
|
453
|
+
});
|
|
454
|
+
const output = await getMetaNodeOutput({
|
|
455
|
+
workflowId: options.workflowId,
|
|
456
|
+
nodeId: created.node_id,
|
|
457
|
+
configPath: options.configPath,
|
|
458
|
+
});
|
|
459
|
+
progress.finish("检索式生成完成,正在输出结果...");
|
|
460
|
+
return normalizeRetrieveExpressionResult({
|
|
461
|
+
runnerId: options.workflowId,
|
|
462
|
+
nodeId: created.node_id,
|
|
463
|
+
nodeType: META_RETRIEVE_NODE_TYPES.EXPRESSION,
|
|
464
|
+
status: output.data.status,
|
|
465
|
+
input: { picos_node_id: picosNodeId },
|
|
466
|
+
output: extractNodeOutput(output.data),
|
|
467
|
+
node: output.data,
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
catch (error) {
|
|
471
|
+
progress.dispose();
|
|
472
|
+
throw error;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
export async function saveRetrieveExpression(options) {
|
|
476
|
+
const fallback = await getRetrieveExpressionFallback({
|
|
477
|
+
workflowId: options.workflowId,
|
|
478
|
+
nodeId: options.nodeId,
|
|
479
|
+
nodeType: META_RETRIEVE_NODE_TYPES.EXPRESSION,
|
|
480
|
+
label: "检索式",
|
|
481
|
+
configPath: options.configPath,
|
|
482
|
+
});
|
|
483
|
+
const parsedInput = await parseJsonObjectInput(options.expressionJson, options.expressionFile, "--expression-json", "--expression-file");
|
|
484
|
+
const input = normalizeRetrieveExpressionPayload(parsedInput, fallback.output);
|
|
485
|
+
const data = await requestMeta(`${META_API_PREFIX}/generate-retrieve-expression`, {
|
|
486
|
+
method: "PUT",
|
|
487
|
+
params: {
|
|
488
|
+
run_id: options.workflowId,
|
|
489
|
+
node_id: fallback.nodeId,
|
|
490
|
+
},
|
|
491
|
+
body: input,
|
|
492
|
+
configPath: options.configPath,
|
|
493
|
+
action: "保存检索式",
|
|
494
|
+
});
|
|
495
|
+
return {
|
|
496
|
+
runnerId: options.workflowId,
|
|
497
|
+
nodeId: fallback.nodeId,
|
|
498
|
+
input,
|
|
499
|
+
data,
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
export async function checkRetrieveExpression(options) {
|
|
503
|
+
const nodeId = await resolveNodeId({
|
|
504
|
+
workflowId: options.workflowId,
|
|
505
|
+
nodeId: options.nodeId,
|
|
506
|
+
nodeType: META_RETRIEVE_NODE_TYPES.EXPRESSION,
|
|
507
|
+
label: "检索式",
|
|
508
|
+
configPath: options.configPath,
|
|
509
|
+
});
|
|
510
|
+
const data = await requestMeta(`${META_API_PREFIX}/generate-retrieve-expression/check-before-next`, {
|
|
511
|
+
params: {
|
|
512
|
+
run_id: options.workflowId,
|
|
513
|
+
node_id: nodeId,
|
|
514
|
+
},
|
|
515
|
+
configPath: options.configPath,
|
|
516
|
+
action: "校验检索式",
|
|
517
|
+
});
|
|
518
|
+
return {
|
|
519
|
+
runnerId: options.workflowId,
|
|
520
|
+
nodeId,
|
|
521
|
+
data,
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* 读取当前已生成的检索式(不重新执行),用于历史切换后展示。
|
|
526
|
+
*
|
|
527
|
+
* @param options 工作流与可选节点 ID。
|
|
528
|
+
* @returns 归一化后的检索式结果(含 expressionMarkdown)。
|
|
529
|
+
*/
|
|
530
|
+
export async function getRetrieveExpression(options) {
|
|
531
|
+
const nodeId = await resolveNodeId({
|
|
532
|
+
workflowId: options.workflowId,
|
|
533
|
+
nodeId: options.nodeId,
|
|
534
|
+
nodeType: META_RETRIEVE_NODE_TYPES.EXPRESSION,
|
|
535
|
+
label: "检索式",
|
|
536
|
+
configPath: options.configPath,
|
|
537
|
+
});
|
|
538
|
+
const output = await getMetaNodeOutput({
|
|
539
|
+
workflowId: options.workflowId,
|
|
540
|
+
nodeId,
|
|
541
|
+
configPath: options.configPath,
|
|
542
|
+
});
|
|
543
|
+
return normalizeRetrieveExpressionResult({
|
|
544
|
+
runnerId: options.workflowId,
|
|
545
|
+
nodeId,
|
|
546
|
+
nodeType: META_RETRIEVE_NODE_TYPES.EXPRESSION,
|
|
547
|
+
status: output.data.status,
|
|
548
|
+
input: {},
|
|
549
|
+
output: extractNodeOutput(output.data),
|
|
550
|
+
node: output.data,
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
export async function rerunRetrieveExpression(options) {
|
|
554
|
+
const fallback = await getRetrieveExpressionFallback({
|
|
555
|
+
workflowId: options.workflowId,
|
|
556
|
+
nodeId: options.nodeId,
|
|
557
|
+
nodeType: META_RETRIEVE_NODE_TYPES.EXPRESSION,
|
|
558
|
+
label: "检索式",
|
|
559
|
+
configPath: options.configPath,
|
|
560
|
+
});
|
|
561
|
+
const progress = createStderrProgress(options.format === "json");
|
|
562
|
+
progress.start("正在重新生成检索式...");
|
|
563
|
+
try {
|
|
564
|
+
await requestMeta(`${META_API_PREFIX}/nodes/re-execute`, {
|
|
565
|
+
method: "POST",
|
|
566
|
+
body: {
|
|
567
|
+
run_id: options.workflowId,
|
|
568
|
+
node_id: fallback.nodeId,
|
|
569
|
+
node_type: META_RETRIEVE_NODE_TYPES.EXPRESSION,
|
|
570
|
+
},
|
|
571
|
+
configPath: options.configPath,
|
|
572
|
+
action: "重新生成检索式",
|
|
573
|
+
});
|
|
574
|
+
await pollMetaNodeStatus({
|
|
575
|
+
workflowId: options.workflowId,
|
|
576
|
+
nodeId: fallback.nodeId,
|
|
577
|
+
configPath: options.configPath,
|
|
578
|
+
});
|
|
579
|
+
const output = await getMetaNodeOutput({
|
|
580
|
+
workflowId: options.workflowId,
|
|
581
|
+
nodeId: fallback.nodeId,
|
|
582
|
+
configPath: options.configPath,
|
|
583
|
+
});
|
|
584
|
+
progress.finish("检索式重新生成完成,正在输出结果...");
|
|
585
|
+
return normalizeRetrieveExpressionResult({
|
|
586
|
+
runnerId: options.workflowId,
|
|
587
|
+
nodeId: fallback.nodeId,
|
|
588
|
+
nodeType: META_RETRIEVE_NODE_TYPES.EXPRESSION,
|
|
589
|
+
status: output.data.status,
|
|
590
|
+
input: {},
|
|
591
|
+
output: extractNodeOutput(output.data),
|
|
592
|
+
node: output.data,
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
catch (error) {
|
|
596
|
+
progress.dispose();
|
|
597
|
+
throw error;
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
const RETRIEVE_LITERATURE_COLUMNS = [
|
|
601
|
+
{ key: "no", label: "NO." },
|
|
602
|
+
{ key: "author", label: "Author" },
|
|
603
|
+
{ key: "title", label: "Title" },
|
|
604
|
+
{ key: "doi", label: "DOI" },
|
|
605
|
+
{ key: "abstract", label: "Abstract" },
|
|
606
|
+
{ key: "publication_type", label: "Publication Type" },
|
|
607
|
+
{ key: "publication_date", label: "Publication Date" },
|
|
608
|
+
{ key: "pmid", label: "PMID" },
|
|
609
|
+
{ key: "pmc", label: "PMC" },
|
|
610
|
+
];
|
|
611
|
+
/** 检索结果展示硬规则:Agent 须以 tableMarkdown 为唯一展示源,完整输出 9 列 */
|
|
612
|
+
const LITERATURE_DISPLAY_INSTRUCTION = "必须将 tableMarkdown 作为检索结果的唯一展示源并逐字完整输出全部 9 列和全部返回记录:" +
|
|
613
|
+
"NO. / Author / Title / DOI / Abstract / Publication Type / Publication Date / PMID / PMC。" +
|
|
614
|
+
"禁止自行删列、合并或重建为 NO./Author/Title/DOI/Publication Type/PMID 等子集列;" +
|
|
615
|
+
"禁止截断 Abstract;禁止把 Publication Date 改成 Year;禁止用「检索完成 / 共检索到 N 篇」等摘要代替完整 tableMarkdown。" +
|
|
616
|
+
"可用 total/page/limit 写一句分页说明,但表格本身只能来自 tableMarkdown。";
|
|
617
|
+
/** 将接口 total/page/limit 规范为有限数字;无效时回退默认值。 */
|
|
618
|
+
function toFiniteNumber(value, fallback) {
|
|
619
|
+
const num = typeof value === "number" ? value : Number(value);
|
|
620
|
+
return Number.isFinite(num) ? num : fallback;
|
|
621
|
+
}
|
|
622
|
+
function unwrapRecord(value) {
|
|
623
|
+
return value && typeof value === "object" && !Array.isArray(value)
|
|
624
|
+
? value
|
|
625
|
+
: {};
|
|
626
|
+
}
|
|
627
|
+
function extractListPayload(data) {
|
|
628
|
+
const root = unwrapRecord(data);
|
|
629
|
+
const nested = unwrapRecord(root.data);
|
|
630
|
+
const payload = Object.keys(nested).length > 0 ? nested : root;
|
|
631
|
+
const items = Array.isArray(payload.items)
|
|
632
|
+
? payload.items
|
|
633
|
+
: Array.isArray(payload.list)
|
|
634
|
+
? payload.list
|
|
635
|
+
: Array.isArray(payload.records)
|
|
636
|
+
? payload.records
|
|
637
|
+
: Array.isArray(payload.results)
|
|
638
|
+
? payload.results
|
|
639
|
+
: Array.isArray(payload.data)
|
|
640
|
+
? payload.data
|
|
641
|
+
: Array.isArray(data)
|
|
642
|
+
? data
|
|
643
|
+
: [];
|
|
644
|
+
return {
|
|
645
|
+
items,
|
|
646
|
+
total: payload.total ?? payload.count,
|
|
647
|
+
page: payload.page,
|
|
648
|
+
limit: payload.limit,
|
|
649
|
+
};
|
|
650
|
+
}
|
|
651
|
+
function formatListField(value) {
|
|
652
|
+
if (Array.isArray(value)) {
|
|
653
|
+
return value
|
|
654
|
+
.map((item) => String(item ?? ""))
|
|
655
|
+
.filter(Boolean)
|
|
656
|
+
.join(", ");
|
|
657
|
+
}
|
|
658
|
+
return value === undefined || value === null ? "" : String(value);
|
|
659
|
+
}
|
|
660
|
+
function formatPublicationDateForDisplay(value) {
|
|
661
|
+
if (typeof value === "number" && Number.isFinite(value)) {
|
|
662
|
+
return new Date(value * 1000).toISOString().slice(0, 10);
|
|
663
|
+
}
|
|
664
|
+
if (typeof value === "string") {
|
|
665
|
+
const trimmed = value.trim();
|
|
666
|
+
if (/^\d{4}-\d{2}-\d{2}/.test(trimmed)) {
|
|
667
|
+
return trimmed.slice(0, 10);
|
|
668
|
+
}
|
|
669
|
+
const timestamp = Date.parse(trimmed);
|
|
670
|
+
if (!Number.isNaN(timestamp)) {
|
|
671
|
+
return new Date(timestamp).toISOString().slice(0, 10);
|
|
672
|
+
}
|
|
673
|
+
return trimmed;
|
|
674
|
+
}
|
|
675
|
+
return "";
|
|
676
|
+
}
|
|
677
|
+
function buildRetrieveLiteratureTable(data, options) {
|
|
678
|
+
const { items } = extractListPayload(data);
|
|
679
|
+
const page = options.page ?? 1;
|
|
680
|
+
const limit = options.limit ?? 10;
|
|
681
|
+
const rows = items.map((item, index) => {
|
|
682
|
+
const record = unwrapRecord(item);
|
|
683
|
+
return {
|
|
684
|
+
no: (page - 1) * limit + index + 1,
|
|
685
|
+
author: formatListField(record.author),
|
|
686
|
+
title: formatListField(record.title),
|
|
687
|
+
doi: formatListField(record.doi),
|
|
688
|
+
abstract: formatListField(record.abstract),
|
|
689
|
+
publication_type: formatListField(record.publication_type),
|
|
690
|
+
publication_date: formatPublicationDateForDisplay(record.publication_date),
|
|
691
|
+
pmid: formatListField(record.pmid),
|
|
692
|
+
pmc: formatListField(record.pmc),
|
|
693
|
+
};
|
|
694
|
+
});
|
|
695
|
+
return { columns: [...RETRIEVE_LITERATURE_COLUMNS], rows };
|
|
696
|
+
}
|
|
697
|
+
/** 与网站 NODE_PENDING_STATUS 对齐:进行中的检索结果节点需先等完成再清理重建。 */
|
|
698
|
+
const LITERATURE_PENDING_STATUSES = new Set([
|
|
699
|
+
"queued",
|
|
700
|
+
"pending",
|
|
701
|
+
"running",
|
|
702
|
+
"more_coming",
|
|
703
|
+
]);
|
|
704
|
+
/**
|
|
705
|
+
* 对齐网站 getWorkflowInfo:已存在 literature_retrieve 时先内部 backoff,再允许 execute-as-create。
|
|
706
|
+
* 供「编辑检索式并重新检索」在检索结果节点直接重跑;Agent 无需自行 workflow backoff。
|
|
707
|
+
*
|
|
708
|
+
* @param options 工作流与配置。
|
|
709
|
+
*/
|
|
710
|
+
async function clearExistingLiteratureRetrieveNode(options) {
|
|
711
|
+
const workflow = await getWorkflow(options.workflowId, options.configPath);
|
|
712
|
+
const existing = findLatestNode(workflow, META_RETRIEVE_NODE_TYPES.LITERATURE);
|
|
713
|
+
if (!existing?.id) {
|
|
714
|
+
return false;
|
|
715
|
+
}
|
|
716
|
+
// 进行中则先等到终态,再清理,否则无法带上新检索式重建
|
|
717
|
+
if (LITERATURE_PENDING_STATUSES.has(String(existing.status ?? ""))) {
|
|
718
|
+
await pollMetaNodeStatus({
|
|
719
|
+
workflowId: options.workflowId,
|
|
720
|
+
nodeId: existing.id,
|
|
721
|
+
configPath: options.configPath,
|
|
722
|
+
});
|
|
723
|
+
}
|
|
724
|
+
const latest = await getWorkflow(options.workflowId, options.configPath);
|
|
725
|
+
const node = findLatestNode(latest, META_RETRIEVE_NODE_TYPES.LITERATURE);
|
|
726
|
+
if (!node?.id) {
|
|
727
|
+
return false;
|
|
728
|
+
}
|
|
729
|
+
const head = latest.head?.trim();
|
|
730
|
+
if (head && head !== node.id) {
|
|
731
|
+
throw new helixlifeError(helixlifeErrorCode.INVALID_ARGUMENT, "当前工作流头已越过文献检索节点,无法在此直接重新检索。" +
|
|
732
|
+
"请先回退到检索结果节点后再执行「编辑检索式并重新检索」。");
|
|
733
|
+
}
|
|
734
|
+
// 内部清理旧检索结果节点(对齐网站 backoff(literature_retrieve)),不向 Agent 暴露回退指引
|
|
735
|
+
await requestMeta(`${META_API_PREFIX}/workflow/runs/${encodeURIComponent(options.workflowId)}/backoff`, {
|
|
736
|
+
method: "POST",
|
|
737
|
+
params: { node_id: node.id },
|
|
738
|
+
configPath: options.configPath,
|
|
739
|
+
action: "清理旧文献检索节点",
|
|
740
|
+
});
|
|
741
|
+
return true;
|
|
742
|
+
}
|
|
743
|
+
/**
|
|
744
|
+
* 执行文献检索;若当前已在检索结果节点,会先内部清理旧节点再带检索式重建(对齐网站 retrieve 页)。
|
|
745
|
+
*
|
|
746
|
+
* @param options 工作流与可选编辑后的检索式。
|
|
747
|
+
* @returns 检索步骤结果(含 tableMarkdown)。
|
|
748
|
+
*/
|
|
749
|
+
export async function createRetrieveLiterature(options) {
|
|
750
|
+
const fallback = await getRetrieveExpressionFallback({
|
|
751
|
+
workflowId: options.workflowId,
|
|
752
|
+
configPath: options.configPath,
|
|
753
|
+
});
|
|
754
|
+
const hasInlineExpression = Boolean(options.expressionJson?.trim());
|
|
755
|
+
const hasExpressionFile = Boolean(options.expressionFile?.trim());
|
|
756
|
+
const hasEditedExpression = hasInlineExpression || hasExpressionFile;
|
|
757
|
+
const parsedInput = hasEditedExpression
|
|
758
|
+
? await parseJsonObjectInput(options.expressionJson, options.expressionFile, "--expression-json", "--expression-file")
|
|
759
|
+
: fallback.output;
|
|
760
|
+
const input = normalizeRetrieveExpressionPayload(parsedInput, fallback.output);
|
|
761
|
+
// literature_retrieve 的 execute-as-create:input.select 默认 pubmed
|
|
762
|
+
const literatureInput = { ...input, select: "pubmed" };
|
|
763
|
+
// 编辑检索式重跑:先同步写回检索式节点,便于后续 expression get;再校验
|
|
764
|
+
if (hasEditedExpression) {
|
|
765
|
+
await requestMeta(`${META_API_PREFIX}/generate-retrieve-expression`, {
|
|
766
|
+
method: "PUT",
|
|
767
|
+
params: {
|
|
768
|
+
run_id: options.workflowId,
|
|
769
|
+
node_id: fallback.nodeId,
|
|
770
|
+
},
|
|
771
|
+
body: input,
|
|
772
|
+
configPath: options.configPath,
|
|
773
|
+
action: "同步保存编辑后的检索式",
|
|
774
|
+
});
|
|
775
|
+
await checkRetrieveExpression({
|
|
776
|
+
workflowId: options.workflowId,
|
|
777
|
+
nodeId: fallback.nodeId,
|
|
778
|
+
configPath: options.configPath,
|
|
779
|
+
});
|
|
780
|
+
}
|
|
781
|
+
const cleared = await clearExistingLiteratureRetrieveNode({
|
|
782
|
+
workflowId: options.workflowId,
|
|
783
|
+
configPath: options.configPath,
|
|
784
|
+
});
|
|
785
|
+
const stepResult = await runRetrieveNode({
|
|
786
|
+
workflowId: options.workflowId,
|
|
787
|
+
nodeType: META_RETRIEVE_NODE_TYPES.LITERATURE,
|
|
788
|
+
input: literatureInput,
|
|
789
|
+
format: options.format,
|
|
790
|
+
configPath: options.configPath,
|
|
791
|
+
progressMessage: cleared
|
|
792
|
+
? "已清理旧检索结果,正在按更新后的检索式重新检索文献..."
|
|
793
|
+
: "正在检索文献...",
|
|
794
|
+
});
|
|
795
|
+
// create 完成后自动拉第 1 页列表并挂 tableMarkdown(对齐 screening create)
|
|
796
|
+
const listResult = await listRetrieveLiterature({
|
|
797
|
+
workflowId: options.workflowId,
|
|
798
|
+
nodeId: stepResult.nodeId,
|
|
799
|
+
page: 1,
|
|
800
|
+
limit: 10,
|
|
801
|
+
configPath: options.configPath,
|
|
802
|
+
});
|
|
803
|
+
return {
|
|
804
|
+
...stepResult,
|
|
805
|
+
displayInstruction: LITERATURE_DISPLAY_INSTRUCTION,
|
|
806
|
+
tableMarkdown: listResult.tableMarkdown,
|
|
807
|
+
total: listResult.total,
|
|
808
|
+
page: listResult.page,
|
|
809
|
+
limit: listResult.limit,
|
|
810
|
+
};
|
|
811
|
+
}
|
|
812
|
+
export async function listRetrieveLiterature(options) {
|
|
813
|
+
const nodeId = await resolveNodeId({
|
|
814
|
+
workflowId: options.workflowId,
|
|
815
|
+
nodeId: options.nodeId,
|
|
816
|
+
nodeType: META_RETRIEVE_NODE_TYPES.LITERATURE,
|
|
817
|
+
label: "文献检索",
|
|
818
|
+
configPath: options.configPath,
|
|
819
|
+
});
|
|
820
|
+
const data = await requestMeta(`${META_API_PREFIX}/literature-retrieve-result`, {
|
|
821
|
+
params: {
|
|
822
|
+
run_id: options.workflowId,
|
|
823
|
+
node_id: nodeId,
|
|
824
|
+
page: options.page,
|
|
825
|
+
limit: options.limit,
|
|
826
|
+
sort: options.sort,
|
|
827
|
+
order: options.order,
|
|
828
|
+
publication_type: options.publicationType?.join(","),
|
|
829
|
+
},
|
|
830
|
+
configPath: options.configPath,
|
|
831
|
+
action: "查询文献检索结果",
|
|
832
|
+
});
|
|
833
|
+
const payload = extractListPayload(data);
|
|
834
|
+
const page = options.page ?? toFiniteNumber(payload.page, 1);
|
|
835
|
+
const limit = options.limit ?? toFiniteNumber(payload.limit, 10);
|
|
836
|
+
const table = buildRetrieveLiteratureTable(data, { ...options, page, limit });
|
|
837
|
+
const total = toFiniteNumber(payload.total, table.rows.length);
|
|
838
|
+
return {
|
|
839
|
+
runnerId: options.workflowId,
|
|
840
|
+
nodeId,
|
|
841
|
+
data,
|
|
842
|
+
displayInstruction: LITERATURE_DISPLAY_INSTRUCTION,
|
|
843
|
+
columns: table.columns,
|
|
844
|
+
rows: table.rows,
|
|
845
|
+
displayColumns: table.columns.map((column) => column.label),
|
|
846
|
+
displayRows: table.rows,
|
|
847
|
+
tableMarkdown: renderListAsMarkdown(table.rows, table.columns),
|
|
848
|
+
table,
|
|
849
|
+
total,
|
|
850
|
+
page,
|
|
851
|
+
limit,
|
|
852
|
+
};
|
|
853
|
+
}
|
|
854
|
+
export async function addRetrieveLiterature(options) {
|
|
855
|
+
const nodeId = await resolveNodeId({
|
|
856
|
+
workflowId: options.workflowId,
|
|
857
|
+
nodeId: options.nodeId,
|
|
858
|
+
nodeType: META_RETRIEVE_NODE_TYPES.LITERATURE,
|
|
859
|
+
label: "文献检索",
|
|
860
|
+
configPath: options.configPath,
|
|
861
|
+
});
|
|
862
|
+
const input = normalizeLiteratureInput(await parseJsonObjectInput(options.literatureJson, options.literatureFile, "--literature-json", "--literature-file"));
|
|
863
|
+
validateLiteratureInput(input);
|
|
864
|
+
const data = await requestMeta(`${META_API_PREFIX}/literature-retrieve-result`, {
|
|
865
|
+
method: "POST",
|
|
866
|
+
params: {
|
|
867
|
+
run_id: options.workflowId,
|
|
868
|
+
node_id: nodeId,
|
|
869
|
+
},
|
|
870
|
+
body: input,
|
|
871
|
+
configPath: options.configPath,
|
|
872
|
+
action: "补充文献",
|
|
873
|
+
});
|
|
874
|
+
return {
|
|
875
|
+
runnerId: options.workflowId,
|
|
876
|
+
nodeId,
|
|
877
|
+
input,
|
|
878
|
+
data,
|
|
879
|
+
};
|
|
880
|
+
}
|
|
881
|
+
export async function runCreateRetrieveExpression(options) {
|
|
882
|
+
const result = await createRetrieveExpression(options);
|
|
883
|
+
printRetrieveStepResult(result, options.format ?? "markdown");
|
|
884
|
+
}
|
|
885
|
+
export async function runSaveRetrieveExpression(options) {
|
|
886
|
+
const result = await saveRetrieveExpression(options);
|
|
887
|
+
printOutput(result, options.format ?? "markdown");
|
|
888
|
+
}
|
|
889
|
+
export async function runCheckRetrieveExpression(options) {
|
|
890
|
+
const result = await checkRetrieveExpression(options);
|
|
891
|
+
printOutput(result, options.format ?? "markdown");
|
|
892
|
+
}
|
|
893
|
+
export async function runGetRetrieveExpression(options) {
|
|
894
|
+
const result = await getRetrieveExpression(options);
|
|
895
|
+
printRetrieveStepResult(result, options.format ?? "markdown");
|
|
896
|
+
}
|
|
897
|
+
export async function runRerunRetrieveExpression(options) {
|
|
898
|
+
const result = await rerunRetrieveExpression(options);
|
|
899
|
+
printRetrieveStepResult(result, options.format ?? "markdown");
|
|
900
|
+
}
|
|
901
|
+
export async function runCreateRetrieveLiterature(options) {
|
|
902
|
+
const result = await createRetrieveLiterature(options);
|
|
903
|
+
printRetrieveStepResult(result, options.format ?? "markdown");
|
|
904
|
+
}
|
|
905
|
+
export async function runListRetrieveLiterature(options) {
|
|
906
|
+
const result = await listRetrieveLiterature(options);
|
|
907
|
+
printLiteratureListResult(result, options.format ?? "markdown");
|
|
908
|
+
}
|
|
909
|
+
export async function runAddRetrieveLiterature(options) {
|
|
910
|
+
const result = await addRetrieveLiterature(options);
|
|
911
|
+
printOutput(result, options.format ?? "markdown");
|
|
912
|
+
}
|
|
913
|
+
//# sourceMappingURL=retrieve.js.map
|