minimal-agent 0.8.2 → 0.10.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 +14 -12
- package/package.json +34 -1
- package/plugins/cron-runner/.claude-plugin/plugin.json +5 -0
- package/plugins/cron-runner/commands/cron.md +26 -0
- package/plugins/cron-runner/commands/crons.md +7 -0
- package/plugins/cron-runner/plugin.js +34 -0
- package/plugins/cron-runner/src/commands.js +348 -0
- package/plugins/cron-runner/src/cronTime.js +148 -0
- package/plugins/cron-runner/src/lock.js +68 -0
- package/plugins/cron-runner/src/runs.js +89 -0
- package/plugins/cron-runner/src/scheduleEngine.js +72 -0
- package/plugins/cron-runner/src/scheduler.js +355 -0
- package/plugins/cron-runner/src/schema.js +140 -0
- package/plugins/cron-runner/src/service.js +167 -0
- package/plugins/cron-runner/src/store.js +298 -0
- package/plugins/cron-runner/src/types.js +1 -0
- package/plugins/workflow-runner/commands/workflow.md +4 -4
- package/plugins/workflow-runner/commands/workflows.md +1 -1
- package/plugins/workflow-runner/plugin.js +3 -1
- package/plugins/workflow-runner/src/agentCommon.js +249 -51
- package/plugins/workflow-runner/src/dslManifest.js +72 -0
- package/plugins/workflow-runner/src/expressions.js +198 -15
- package/plugins/workflow-runner/src/index.js +40 -8
- package/plugins/workflow-runner/src/jsonPayload.js +1 -1
- package/plugins/workflow-runner/src/loader.js +286 -72
- package/plugins/workflow-runner/src/multimodal.js +37 -0
- package/plugins/workflow-runner/src/recovery.js +49 -39
- package/plugins/workflow-runner/src/runner.js +802 -287
- package/plugins/workflow-runner/src/stepExecutors/agent.js +157 -39
- package/plugins/workflow-runner/src/stepExecutors/assert.js +16 -3
- package/plugins/workflow-runner/src/stepExecutors/llm.js +60 -111
- package/plugins/workflow-runner/src/stepExecutors/skill.js +47 -47
- package/plugins/workflow-runner/src/stepExecutors/tool.js +76 -10
- package/plugins/workflow-runner/src/stepExecutors/verify.js +27 -10
- package/plugins/workflow-runner/src/taskIdentity.js +296 -0
- package/plugins/workflow-runner/src/types.js +19 -9
- package/plugins/workflow-runner/src/workflowState.js +516 -33
- package/skills/adversarial-review/SKILL.md +0 -1
- package/skills/ai-image/SKILL.md +89 -0
- package/skills/ai-image/scripts/generate.mjs +497 -0
- package/skills/ai-image/scripts/generate_from_plan.mjs +469 -0
- package/skills/ai-image/scripts/generate_from_plan_test.mjs +223 -0
- package/skills/ai-image/scripts/generate_test.mjs +74 -0
- package/skills/browser-automation/SKILL.md +47 -0
- package/skills/docx/SKILL.md +25 -3
- package/skills/docx/scripts/office/helpers/__pycache__/__init__.cpython-314.pyc +0 -0
- package/skills/docx/scripts/office/helpers/__pycache__/merge_runs.cpython-314.pyc +0 -0
- package/skills/docx/scripts/office/helpers/__pycache__/simplify_redlines.cpython-314.pyc +0 -0
- package/skills/docx/scripts/office/validators/__pycache__/__init__.cpython-314.pyc +0 -0
- package/skills/docx/scripts/office/validators/__pycache__/base.cpython-314.pyc +0 -0
- package/skills/docx/scripts/office/validators/__pycache__/docx.cpython-314.pyc +0 -0
- package/skills/docx/scripts/office/validators/__pycache__/pptx.cpython-314.pyc +0 -0
- package/skills/docx/scripts/office/validators/__pycache__/redlining.cpython-314.pyc +0 -0
- package/skills/docx/scripts/opc_check.py +253 -0
- package/skills/image-gen-openrouter/SKILL.md +10 -2
- package/skills/image-stats/SKILL.md +65 -0
- package/skills/image-stats/scripts/__pycache__/image_stats.cpython-314.pyc +0 -0
- package/skills/image-stats/scripts/__pycache__/image_stats_test.cpython-314.pyc +0 -0
- package/skills/image-stats/scripts/image_stats.py +368 -0
- package/skills/image-stats/scripts/image_stats_test.py +181 -0
- package/skills/pptx/SKILL.md +123 -95
- package/skills/pptx/design.md +82 -0
- package/skills/pptx/examples/README.md +29 -0
- package/skills/pptx/examples/hybrid_example.mjs +107 -0
- package/skills/pptx/examples/hybrid_example.pptx +0 -0
- package/skills/pptx/pptxgenjs.md +41 -0
- package/skills/pptx/scripts/deck_helpers.mjs +224 -0
- package/skills/pptx/scripts/layout_lint.py +293 -0
- package/skills/pptx/scripts/layout_lint_test.py +160 -0
- package/skills/pptx/scripts/opc_check.py +339 -0
- package/skills/pptx/scripts/svg_fallback.mjs +145 -0
- package/skills/pptx/svg.md +67 -0
- package/skills/tts-zh/SKILL.md +19 -2
- package/skills/ui-design/SKILL.md +158 -0
- package/skills/ui-design/claude_design.md +309 -0
- package/skills/ui-design/evals/evals.json +254 -0
- package/skills/ui-design/references/aesthetic-direction.md +83 -0
- package/skills/ui-design/references/claude-design-protocol.md +36 -0
- package/skills/ui-design/references/design-context.md +53 -0
- package/skills/ui-design/references/design-execution-playbook.md +82 -0
- package/skills/ui-design/references/export-pptx.md +124 -0
- package/skills/ui-design/references/layout-composition.md +654 -0
- package/skills/ui-design/references/preview-feedback.md +37 -0
- package/skills/ui-design/references/source-image-layout.md +189 -0
- package/skills/ui-design/references/starter-components.md +78 -0
- package/skills/ui-design/references/vi-aegis-vector.md +144 -0
- package/skills/ui-design/references/vi-amber-prism.md +133 -0
- package/skills/ui-design/references/vi-aqua-glass.md +200 -0
- package/skills/ui-design/references/vi-comfort-vision.md +147 -0
- package/skills/ui-design/references/vi-ember-prism.md +140 -0
- package/skills/ui-design/references/vi-nebula-console.md +151 -0
- package/skills/ui-design/references/vi-obsidian-optics.md +139 -0
- package/skills/ui-design/references/vi-obsidian-xui.md +143 -0
- package/skills/ui-design/references/vi-precision-horizon-dark.md +117 -0
- package/skills/ui-design/references/vi-precision-horizon.md +215 -0
- package/skills/ui-design/references/vi-solar-relay.md +130 -0
- package/skills/ui-design/references/vi-template-workflow.md +48 -0
- package/skills/ui-design/references/vi-verdant-grid.md +141 -0
- package/skills/ui-design/references/vi-violet-meridian.md +172 -0
- package/skills/ui-design/scripts/__pycache__/assemble_material.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/assemble_material_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/chart_sanity_check.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/check_language_policy.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/check_ui_artifact.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/check_ui_artifact_pptx_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/deck_pages_check.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/deck_pages_check_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/deck_visual_style_check.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/deck_visual_style_check_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/design_budget_check.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/design_budget_check_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/design_repair_hints.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/design_repair_hints_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/design_style_check.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/design_style_check_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/draft_coverage_check.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/extract_source_assets.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/extract_source_assets_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/generated_image_review_collect.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/generated_image_review_collect_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/image_plan_lint.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/image_plan_lint_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/image_prompt_rewrite.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/image_prompt_rewrite_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/layout_balance.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/layout_balance_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/normalize_design_json.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/normalize_design_json_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/plan_source_layout.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/plan_source_layout_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/resolve_source_hint.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/resolve_source_hint_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/resolve_source_input.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/resolve_source_input_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/scaffold_ui_artifact.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/source_usage_check.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/source_usage_check_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/text_readability_pixel.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/visual_quality_gate.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/__pycache__/visual_quality_gate_test.cpython-314.pyc +0 -0
- package/skills/ui-design/scripts/assemble_material.py +217 -0
- package/skills/ui-design/scripts/assemble_material_test.py +149 -0
- package/skills/ui-design/scripts/browser_check_ui_artifact.mjs +221 -0
- package/skills/ui-design/scripts/chart_sanity_check.py +261 -0
- package/skills/ui-design/scripts/chart_sanity_check_test.py +165 -0
- package/skills/ui-design/scripts/check_language_policy.py +351 -0
- package/skills/ui-design/scripts/check_ui_artifact.py +435 -0
- package/skills/ui-design/scripts/check_ui_artifact_pptx_test.py +251 -0
- package/skills/ui-design/scripts/deck_pages_check.py +158 -0
- package/skills/ui-design/scripts/deck_pages_check_test.py +134 -0
- package/skills/ui-design/scripts/deck_visual_style_check.py +767 -0
- package/skills/ui-design/scripts/deck_visual_style_check_test.py +713 -0
- package/skills/ui-design/scripts/design_budget_check.py +271 -0
- package/skills/ui-design/scripts/design_budget_check_test.py +183 -0
- package/skills/ui-design/scripts/design_repair_hints.py +162 -0
- package/skills/ui-design/scripts/design_repair_hints_test.py +54 -0
- package/skills/ui-design/scripts/design_style_check.py +397 -0
- package/skills/ui-design/scripts/design_style_check_test.py +233 -0
- package/skills/ui-design/scripts/draft_coverage_check.py +184 -0
- package/skills/ui-design/scripts/draft_coverage_check_test.py +131 -0
- package/skills/ui-design/scripts/export_pptx_from_html.mjs +2367 -0
- package/skills/ui-design/scripts/extract_source_assets.py +607 -0
- package/skills/ui-design/scripts/extract_source_assets_test.py +256 -0
- package/skills/ui-design/scripts/generated_image_review_collect.py +206 -0
- package/skills/ui-design/scripts/generated_image_review_collect_test.py +91 -0
- package/skills/ui-design/scripts/image_plan_lint.py +571 -0
- package/skills/ui-design/scripts/image_plan_lint_test.py +515 -0
- package/skills/ui-design/scripts/image_prompt_rewrite.py +713 -0
- package/skills/ui-design/scripts/image_prompt_rewrite_test.py +966 -0
- package/skills/ui-design/scripts/layout_balance.py +881 -0
- package/skills/ui-design/scripts/layout_balance_test.py +927 -0
- package/skills/ui-design/scripts/normalize_design_json.py +272 -0
- package/skills/ui-design/scripts/normalize_design_json_test.py +119 -0
- package/skills/ui-design/scripts/plan_source_layout.py +1450 -0
- package/skills/ui-design/scripts/plan_source_layout_test.py +1136 -0
- package/skills/ui-design/scripts/resolve_source_input.py +270 -0
- package/skills/ui-design/scripts/resolve_source_input_test.py +98 -0
- package/skills/ui-design/scripts/scaffold_ui_artifact.py +377 -0
- package/skills/ui-design/scripts/source_usage_check.py +581 -0
- package/skills/ui-design/scripts/source_usage_check_test.py +427 -0
- package/skills/ui-design/scripts/text_readability_pixel.py +340 -0
- package/skills/ui-design/scripts/text_readability_pixel_test.py +219 -0
- package/skills/ui-design/scripts/visual_quality_gate.py +301 -0
- package/skills/ui-design/scripts/visual_quality_gate_test.py +233 -0
- package/skills/ui-design/tests/e2e/prompts/deck.md +19 -0
- package/skills/ui-design/tests/e2e/prompts/webpage.md +17 -0
- package/skills/ui-design/tests/e2e/render_check.mjs +101 -0
- package/skills/ui-design/tests/e2e/rubric.json +54 -0
- package/skills/ui-design/tests/e2e/runs/aegis-vector-preview-1/checks/browser-check.json +49 -0
- package/skills/ui-design/tests/e2e/runs/aegis-vector-preview-1/checks/language-check.txt +12 -0
- package/skills/ui-design/tests/e2e/runs/aegis-vector-preview-1/checks/static-check.txt +15 -0
- package/skills/ui-design/tests/e2e/runs/aegis-vector-preview-1/outputs/index.html +837 -0
- package/skills/ui-design/tests/e2e/runs/aegis-vector-preview-1/prompt.md +12 -0
- package/skills/ui-design/tests/e2e/runs/aegis-vector-preview-1/review.md +21 -0
- package/skills/ui-design/tests/e2e/runs/aegis-vector-preview-1/screenshots/desktop.png +0 -0
- package/skills/ui-design/tests/e2e/runs/aegis-vector-preview-1/screenshots/mobile.png +0 -0
- package/skills/ui-design/tests/e2e/runs/amber-prism-screenshot-check-1/outputs/homepage.html +373 -0
- package/skills/ui-design/tests/e2e/runs/amber-prism-screenshot-check-1/outputs/platform.html +378 -0
- package/skills/ui-design/tests/e2e/runs/amber-prism-screenshot-check-1/prompt.md +13 -0
- package/skills/ui-design/tests/e2e/runs/amber-prism-screenshot-check-1/review.md +26 -0
- package/skills/ui-design/tests/e2e/runs/amber-prism-screenshot-check-1/screenshots/homepage/browser-check.json +49 -0
- package/skills/ui-design/tests/e2e/runs/amber-prism-screenshot-check-1/screenshots/homepage/desktop.png +0 -0
- package/skills/ui-design/tests/e2e/runs/amber-prism-screenshot-check-1/screenshots/homepage/mobile.png +0 -0
- package/skills/ui-design/tests/e2e/runs/amber-prism-screenshot-check-1/screenshots/platform/browser-check.json +49 -0
- package/skills/ui-design/tests/e2e/runs/amber-prism-screenshot-check-1/screenshots/platform/desktop.png +0 -0
- package/skills/ui-design/tests/e2e/runs/amber-prism-screenshot-check-1/screenshots/platform/mobile.png +0 -0
- package/skills/ui-design/tests/e2e/runs/aqua-glass-iteration-1/checks/static-check.txt +2 -0
- package/skills/ui-design/tests/e2e/runs/aqua-glass-iteration-1/outputs/index.html +656 -0
- package/skills/ui-design/tests/e2e/runs/aqua-glass-iteration-1/prompt.md +12 -0
- package/skills/ui-design/tests/e2e/runs/aqua-glass-iteration-1/render_check.mjs +67 -0
- package/skills/ui-design/tests/e2e/runs/aqua-glass-iteration-2/checks/static-check.txt +2 -0
- package/skills/ui-design/tests/e2e/runs/aqua-glass-iteration-2/outputs/index.html +587 -0
- package/skills/ui-design/tests/e2e/runs/aqua-glass-iteration-2/prompt.md +12 -0
- package/skills/ui-design/tests/e2e/runs/aqua-glass-iteration-2/review.md +36 -0
- package/skills/ui-design/tests/e2e/runs/aqua-glass-volcano-refresh-1/checks/browser-check.json +49 -0
- package/skills/ui-design/tests/e2e/runs/aqua-glass-volcano-refresh-1/checks/language-check.txt +8 -0
- package/skills/ui-design/tests/e2e/runs/aqua-glass-volcano-refresh-1/checks/static-check.txt +16 -0
- package/skills/ui-design/tests/e2e/runs/aqua-glass-volcano-refresh-1/outputs/index.html +739 -0
- package/skills/ui-design/tests/e2e/runs/aqua-glass-volcano-refresh-1/prompt.md +11 -0
- package/skills/ui-design/tests/e2e/runs/aqua-glass-volcano-refresh-1/review.md +22 -0
- package/skills/ui-design/tests/e2e/runs/aqua-glass-volcano-refresh-1/screenshots/desktop.png +0 -0
- package/skills/ui-design/tests/e2e/runs/aqua-glass-volcano-refresh-1/screenshots/mobile.png +0 -0
- package/skills/ui-design/tests/e2e/runs/comfort-vision-preview-1/checks/browser-check.json +52 -0
- package/skills/ui-design/tests/e2e/runs/comfort-vision-preview-1/outputs/index.html +641 -0
- package/skills/ui-design/tests/e2e/runs/comfort-vision-preview-1/screenshots/desktop.png +0 -0
- package/skills/ui-design/tests/e2e/runs/comfort-vision-preview-1/screenshots/mobile.png +0 -0
- package/skills/ui-design/tests/e2e/runs/ember-prism-red-preview-1/outputs/index.html +467 -0
- package/skills/ui-design/tests/e2e/runs/ember-prism-red-preview-1/screenshots/browser-check.json +49 -0
- package/skills/ui-design/tests/e2e/runs/ember-prism-red-preview-1/screenshots/desktop.png +0 -0
- package/skills/ui-design/tests/e2e/runs/ember-prism-red-preview-1/screenshots/mobile.png +0 -0
- package/skills/ui-design/tests/e2e/runs/ember-prism-screenshot-check-1/outputs/homepage.html +373 -0
- package/skills/ui-design/tests/e2e/runs/ember-prism-screenshot-check-1/outputs/platform.html +378 -0
- package/skills/ui-design/tests/e2e/runs/ember-prism-screenshot-check-1/prompt.md +13 -0
- package/skills/ui-design/tests/e2e/runs/ember-prism-screenshot-check-1/review.md +26 -0
- package/skills/ui-design/tests/e2e/runs/ember-prism-screenshot-check-1/screenshots/homepage/browser-check.json +49 -0
- package/skills/ui-design/tests/e2e/runs/ember-prism-screenshot-check-1/screenshots/homepage/desktop.png +0 -0
- package/skills/ui-design/tests/e2e/runs/ember-prism-screenshot-check-1/screenshots/homepage/mobile.png +0 -0
- package/skills/ui-design/tests/e2e/runs/ember-prism-screenshot-check-1/screenshots/platform/browser-check.json +49 -0
- package/skills/ui-design/tests/e2e/runs/ember-prism-screenshot-check-1/screenshots/platform/desktop.png +0 -0
- package/skills/ui-design/tests/e2e/runs/ember-prism-screenshot-check-1/screenshots/platform/mobile.png +0 -0
- package/skills/ui-design/tests/e2e/runs/empty-agent-protocol-check/checks/browser-check.json +49 -0
- package/skills/ui-design/tests/e2e/runs/empty-agent-protocol-check/checks/language-check.txt +4 -0
- package/skills/ui-design/tests/e2e/runs/empty-agent-protocol-check/checks/static-check.txt +2 -0
- package/skills/ui-design/tests/e2e/runs/empty-agent-protocol-check/execution_notes.md +10 -0
- package/skills/ui-design/tests/e2e/runs/empty-agent-protocol-check/outputs/index.html +587 -0
- package/skills/ui-design/tests/e2e/runs/empty-agent-protocol-check/prompt.md +14 -0
- package/skills/ui-design/tests/e2e/runs/empty-agent-protocol-check/review.md +13 -0
- package/skills/ui-design/tests/e2e/runs/empty-agent-protocol-check/screenshots/desktop.png +0 -0
- package/skills/ui-design/tests/e2e/runs/empty-agent-protocol-check/screenshots/mobile.png +0 -0
- package/skills/ui-design/tests/e2e/runs/iteration-1/deck/checks/browser-check.json +24 -0
- package/skills/ui-design/tests/e2e/runs/iteration-1/deck/checks/static-check.txt +2 -0
- package/skills/ui-design/tests/e2e/runs/iteration-1/deck/execution_notes.md +21 -0
- package/skills/ui-design/tests/e2e/runs/iteration-1/deck/outputs/deck.html +451 -0
- package/skills/ui-design/tests/e2e/runs/iteration-1/deck/screenshots/slide-01.png +0 -0
- package/skills/ui-design/tests/e2e/runs/iteration-1/deck/screenshots/slide-02.png +0 -0
- package/skills/ui-design/tests/e2e/runs/iteration-1/review.md +79 -0
- package/skills/ui-design/tests/e2e/runs/iteration-1/webpage/checks/browser-check.json +26 -0
- package/skills/ui-design/tests/e2e/runs/iteration-1/webpage/checks/static-check.txt +2 -0
- package/skills/ui-design/tests/e2e/runs/iteration-1/webpage/execution_notes.md +20 -0
- package/skills/ui-design/tests/e2e/runs/iteration-1/webpage/outputs/index.html +534 -0
- package/skills/ui-design/tests/e2e/runs/iteration-1/webpage/screenshots/desktop.png +0 -0
- package/skills/ui-design/tests/e2e/runs/iteration-1/webpage/screenshots/mobile.png +0 -0
- package/skills/ui-design/tests/e2e/runs/nebula-console-iteration-1/checks/browser-check.json +64 -0
- package/skills/ui-design/tests/e2e/runs/nebula-console-iteration-1/checks/language-check.txt +7 -0
- package/skills/ui-design/tests/e2e/runs/nebula-console-iteration-1/checks/quick-validate.txt +1 -0
- package/skills/ui-design/tests/e2e/runs/nebula-console-iteration-1/checks/static-console.txt +2 -0
- package/skills/ui-design/tests/e2e/runs/nebula-console-iteration-1/checks/static-homepage.txt +2 -0
- package/skills/ui-design/tests/e2e/runs/nebula-console-iteration-1/outputs/console.html +600 -0
- package/skills/ui-design/tests/e2e/runs/nebula-console-iteration-1/outputs/homepage.html +556 -0
- package/skills/ui-design/tests/e2e/runs/nebula-console-iteration-1/prompt.md +29 -0
- package/skills/ui-design/tests/e2e/runs/nebula-console-iteration-1/review.md +57 -0
- package/skills/ui-design/tests/e2e/runs/nebula-console-iteration-1/screenshots/console-desktop.png +0 -0
- package/skills/ui-design/tests/e2e/runs/nebula-console-iteration-1/screenshots/console-mobile.png +0 -0
- package/skills/ui-design/tests/e2e/runs/nebula-console-iteration-1/screenshots/homepage-desktop.png +0 -0
- package/skills/ui-design/tests/e2e/runs/nebula-console-iteration-1/screenshots/homepage-mobile.png +0 -0
- package/skills/ui-design/tests/e2e/runs/obsidian-optics-iteration-1/checks/browser-check.json +33 -0
- package/skills/ui-design/tests/e2e/runs/obsidian-optics-iteration-1/checks/language-check.txt +6 -0
- package/skills/ui-design/tests/e2e/runs/obsidian-optics-iteration-1/checks/quick-validate.txt +1 -0
- package/skills/ui-design/tests/e2e/runs/obsidian-optics-iteration-1/checks/static-check.txt +2 -0
- package/skills/ui-design/tests/e2e/runs/obsidian-optics-iteration-1/outputs/index.html +682 -0
- package/skills/ui-design/tests/e2e/runs/obsidian-optics-iteration-1/prompt.md +13 -0
- package/skills/ui-design/tests/e2e/runs/obsidian-optics-iteration-1/review.md +59 -0
- package/skills/ui-design/tests/e2e/runs/obsidian-optics-iteration-1/screenshots/desktop.png +0 -0
- package/skills/ui-design/tests/e2e/runs/obsidian-optics-iteration-1/screenshots/mobile.png +0 -0
- package/skills/ui-design/tests/e2e/runs/obsidian-xui-screenshot-check-1/outputs/page-01.html +466 -0
- package/skills/ui-design/tests/e2e/runs/obsidian-xui-screenshot-check-1/outputs/page-02.html +433 -0
- package/skills/ui-design/tests/e2e/runs/obsidian-xui-screenshot-check-1/prompt.md +13 -0
- package/skills/ui-design/tests/e2e/runs/obsidian-xui-screenshot-check-1/screenshots/page-01/browser-check.json +49 -0
- package/skills/ui-design/tests/e2e/runs/obsidian-xui-screenshot-check-1/screenshots/page-01/desktop.png +0 -0
- package/skills/ui-design/tests/e2e/runs/obsidian-xui-screenshot-check-1/screenshots/page-01/mobile.png +0 -0
- package/skills/ui-design/tests/e2e/runs/obsidian-xui-screenshot-check-1/screenshots/page-02/browser-check.json +49 -0
- package/skills/ui-design/tests/e2e/runs/obsidian-xui-screenshot-check-1/screenshots/page-02/desktop.png +0 -0
- package/skills/ui-design/tests/e2e/runs/obsidian-xui-screenshot-check-1/screenshots/page-02/mobile.png +0 -0
- package/skills/ui-design/tests/e2e/runs/precision-horizon-iteration-1/checks/browser-check.json +49 -0
- package/skills/ui-design/tests/e2e/runs/precision-horizon-iteration-1/checks/language-check.txt +3 -0
- package/skills/ui-design/tests/e2e/runs/precision-horizon-iteration-1/checks/static-check.txt +2 -0
- package/skills/ui-design/tests/e2e/runs/precision-horizon-iteration-1/execution_notes.md +24 -0
- package/skills/ui-design/tests/e2e/runs/precision-horizon-iteration-1/outputs/index.html +723 -0
- package/skills/ui-design/tests/e2e/runs/precision-horizon-iteration-1/prompt.md +15 -0
- package/skills/ui-design/tests/e2e/runs/precision-horizon-iteration-1/review.md +26 -0
- package/skills/ui-design/tests/e2e/runs/precision-horizon-iteration-1/screenshots/desktop.png +0 -0
- package/skills/ui-design/tests/e2e/runs/precision-horizon-iteration-1/screenshots/mobile.png +0 -0
- package/skills/ui-design/tests/e2e/runs/precision-horizon-iteration-2/checks/browser-dark.json +49 -0
- package/skills/ui-design/tests/e2e/runs/precision-horizon-iteration-2/checks/browser-light.json +49 -0
- package/skills/ui-design/tests/e2e/runs/precision-horizon-iteration-2/checks/language-check.txt +11 -0
- package/skills/ui-design/tests/e2e/runs/precision-horizon-iteration-2/checks/static-dark.txt +2 -0
- package/skills/ui-design/tests/e2e/runs/precision-horizon-iteration-2/checks/static-light.txt +3 -0
- package/skills/ui-design/tests/e2e/runs/precision-horizon-iteration-2/execution_notes.md +23 -0
- package/skills/ui-design/tests/e2e/runs/precision-horizon-iteration-2/outputs/dark.html +392 -0
- package/skills/ui-design/tests/e2e/runs/precision-horizon-iteration-2/outputs/light.html +476 -0
- package/skills/ui-design/tests/e2e/runs/precision-horizon-iteration-2/prompt.md +23 -0
- package/skills/ui-design/tests/e2e/runs/precision-horizon-iteration-2/review.md +41 -0
- package/skills/ui-design/tests/e2e/runs/precision-horizon-iteration-2/screenshots/dark/desktop.png +0 -0
- package/skills/ui-design/tests/e2e/runs/precision-horizon-iteration-2/screenshots/dark/mobile.png +0 -0
- package/skills/ui-design/tests/e2e/runs/precision-horizon-iteration-2/screenshots/light/desktop.png +0 -0
- package/skills/ui-design/tests/e2e/runs/precision-horizon-iteration-2/screenshots/light/mobile.png +0 -0
- package/skills/ui-design/tests/e2e/runs/solar-relay-iteration-1/checks/browser-check.json +54 -0
- package/skills/ui-design/tests/e2e/runs/solar-relay-iteration-1/checks/language-check.txt +5 -0
- package/skills/ui-design/tests/e2e/runs/solar-relay-iteration-1/checks/quick-validate.txt +1 -0
- package/skills/ui-design/tests/e2e/runs/solar-relay-iteration-1/checks/static-check.txt +2 -0
- package/skills/ui-design/tests/e2e/runs/solar-relay-iteration-1/outputs/index.html +765 -0
- package/skills/ui-design/tests/e2e/runs/solar-relay-iteration-1/prompt.md +15 -0
- package/skills/ui-design/tests/e2e/runs/solar-relay-iteration-1/review.md +59 -0
- package/skills/ui-design/tests/e2e/runs/solar-relay-iteration-1/screenshots/desktop.png +0 -0
- package/skills/ui-design/tests/e2e/runs/solar-relay-iteration-1/screenshots/mobile.png +0 -0
- package/skills/ui-design/tests/e2e/runs/verdant-grid-preview-1/outputs/index.html +508 -0
- package/skills/ui-design/tests/e2e/runs/verdant-grid-preview-1/screenshots/browser-check.json +49 -0
- package/skills/ui-design/tests/e2e/runs/verdant-grid-preview-1/screenshots/desktop.png +0 -0
- package/skills/ui-design/tests/e2e/runs/verdant-grid-preview-1/screenshots/mobile.png +0 -0
- package/skills/ui-design/tests/e2e/runs/violet-meridian-iteration-1/checks/browser-check.json +54 -0
- package/skills/ui-design/tests/e2e/runs/violet-meridian-iteration-1/checks/language-check.txt +6 -0
- package/skills/ui-design/tests/e2e/runs/violet-meridian-iteration-1/checks/quick-validate.txt +1 -0
- package/skills/ui-design/tests/e2e/runs/violet-meridian-iteration-1/checks/static-check.txt +2 -0
- package/skills/ui-design/tests/e2e/runs/violet-meridian-iteration-1/outputs/index.html +788 -0
- package/skills/ui-design/tests/e2e/runs/violet-meridian-iteration-1/prompt.md +14 -0
- package/skills/ui-design/tests/e2e/runs/violet-meridian-iteration-1/review.md +60 -0
- package/skills/ui-design/tests/e2e/runs/violet-meridian-iteration-1/screenshots/desktop.png +0 -0
- package/skills/ui-design/tests/e2e/runs/violet-meridian-iteration-1/screenshots/mobile.png +0 -0
- package/skills/video-compose/SKILL.md +8 -1
- package/skills/web-crawler/SKILL.md +70 -0
- package/skills/web-crawler/scripts/crawl.mjs +538 -0
- package/skills/web-crawler/scripts/crawl.test.mjs +204 -0
- package/skills/xlsx/SKILL.md +12 -0
- package/skills/xlsx/scripts/opc_check.py +253 -0
- package/src/advisorState.js +22 -0
- package/src/askBridge.js +97 -3
- package/src/bootstrap/workingDir.js +12 -1
- package/src/cli/args.js +17 -1
- package/src/cli/configMenu.js +236 -0
- package/src/cli/configWizard.js +7 -5
- package/src/cli/print.js +37 -4
- package/src/cli/streamJson.js +77 -24
- package/src/cli/wizards/advisorWizard.js +147 -0
- package/src/cli/wizards/fieldForm.js +149 -0
- package/src/cli/wizards/imageWizard.js +60 -0
- package/src/cli/wizards/openRouterWizard.js +23 -0
- package/src/cli/wizards/providerPresets.js +95 -0
- package/src/cli/wizards/providerWizard.js +219 -0
- package/src/cli/wizards/searchWizard.js +23 -0
- package/src/cli/wizards/ttsWizard.js +34 -0
- package/src/config/configFile.js +441 -83
- package/src/config/configService.js +446 -0
- package/src/config.js +24 -64
- package/src/context/agentHome.js +9 -0
- package/src/context/archive.js +7 -2
- package/src/context/compact.js +8 -5
- package/src/context/contextLock.js +81 -0
- package/src/context/persistContext.js +30 -11
- package/src/context/reactiveCompact.js +4 -2
- package/src/context/recentDirs.js +21 -61
- package/src/context/sessionPath.js +97 -23
- package/src/context/sessionRegistry.js +303 -24
- package/src/context/tokenCounter.js +18 -0
- package/src/context/workspaceIndex.js +731 -0
- package/src/infra/verification.js +28 -15
- package/src/llm/client.js +394 -159
- package/src/llm/providers/anthropicFormat.js +241 -0
- package/src/llm/providers/openaiFormat.js +190 -0
- package/src/loop.js +219 -32
- package/src/main.js +61 -11
- package/src/messageQueue.js +97 -0
- package/src/multimodal.js +203 -0
- package/src/plugin-sdk.js +15 -0
- package/src/plugins/commandRouter.js +3 -0
- package/src/plugins/hookEngine.js +5 -1
- package/src/plugins/pluginLifecycle.js +28 -0
- package/src/plugins/pluginLoader.js +2 -1
- package/src/plugins/pluginRunner.js +49 -21
- package/src/plugins/transcript.js +4 -3
- package/src/prompts/pluginList.js +5 -5
- package/src/prompts/projectInstructions.js +3 -3
- package/src/prompts/promptAssembly.js +133 -144
- package/src/prompts/skillList.js +12 -22
- package/src/prompts/system.js +0 -1
- package/src/session/runAgentTurn.js +70 -0
- package/src/session/runTurn.js +41 -6
- package/src/toolGate.js +17 -0
- package/src/tools/advisor/advisor.js +379 -0
- package/src/tools/agent/agent.js +555 -0
- package/src/tools/agent/agentTypes.js +59 -0
- package/src/tools/agent/coordinator.js +93 -0
- package/src/tools/agent/worktree.js +270 -0
- package/src/tools/ask/ask.js +7 -2
- package/src/tools/bash/bash.js +112 -18
- package/src/tools/download/download.js +144 -0
- package/src/tools/edit/edit.js +1 -0
- package/src/tools/edit/multi-edit.js +1 -0
- package/src/tools/genimage/genimage.js +242 -0
- package/src/tools/genspeech/genspeech.js +67 -0
- package/src/tools/glob/glob.js +1 -0
- package/src/tools/grep/grep.js +3 -0
- package/src/tools/grep/rgPath.js +2 -0
- package/src/tools/index.js +25 -2
- package/src/tools/read/read.js +1 -0
- package/src/tools/shared/killTree.js +52 -0
- package/src/tools/toolProgressBridge.js +48 -0
- package/src/tools/webbrowser/agentBrowserPath.js +258 -0
- package/src/tools/webbrowser/browser.js +59 -42
- package/src/tools/webbrowser/browserControl.js +118 -0
- package/src/tools/webbrowser/browserDaemon.js +97 -0
- package/src/tools/webbrowser/browserService.js +27 -0
- package/src/tools/webbrowser/browserStream.js +119 -0
- package/src/tools/webbrowser/webbrowser.js +699 -130
- package/src/tools/webfetch/webfetch.js +1 -0
- package/src/tools/websearch/websearch.js +134 -51
- package/src/tools/write/write.js +1 -0
- package/src/ui/App.js +249 -22
- package/src/ui/AskQuestion.js +29 -10
- package/src/ui/InputBox.js +104 -12
- package/src/ui/LiveArea.js +112 -19
- package/src/ui/MessageList.js +100 -14
- package/src/ui/ModelPicker.js +56 -0
- package/src/ui/QueuedMessagesBanner.js +14 -0
- package/src/ui/Root.js +18 -10
- package/src/ui/SessionPicker.js +102 -0
- package/src/ui/StatusLine.js +13 -4
- package/src/ui/WorkspacePicker.js +55 -0
- package/src/ui/figures.js +44 -0
- package/src/ui/hooks/askSlot.js +82 -0
- package/src/ui/hooks/useChat.js +358 -64
- package/src/ui/hooks/usePasteHandler.js +11 -1
- package/src/ui/hooks/useTextBuffer.js +1 -3
- package/src/ui/liveViewport.js +5 -1
- package/src/ui/markdown.js +206 -0
- package/src/ui/textBuffer.js +0 -7
- package/src/ui/theme.js +32 -0
- package/src/utils/debugLog.js +0 -4
- package/src/utils/resourcePaths.js +2 -2
- package/src/utils/stripThink.js +50 -0
- package/src/web/browserBridge.js +447 -0
- package/src/web/protocol.js +19 -0
- package/workflows/adaptive-research.yaml +13 -5
- package/workflows/book-review-short.yaml +36 -10
- package/workflows/e2e-write-greet.yaml +6 -2
- package/workflows/illustrate.yaml +227 -0
- package/workflows/plan.yaml +460 -179
- package/workflows/ppt.yaml +1659 -0
- package/workflows/ralph-loop.yaml +199 -0
- package/workflows/schema.json +81 -23
- package/workflows/webppt.yaml +496 -0
- package/workflows/word.yaml +710 -0
- package/workflows/youtube-shorts.yaml +46 -15
- package/MINIMAL-TRACE.md +0 -77
- package/plugins/HOW-TO-WRITE-A-PLUGIN.md +0 -186
- package/plugins/ralph-wiggum/.claude-plugin/plugin.json +0 -9
- package/plugins/ralph-wiggum/README.md +0 -197
- package/plugins/ralph-wiggum/commands/cancel-ralph.md +0 -18
- package/plugins/ralph-wiggum/commands/help.md +0 -137
- package/plugins/ralph-wiggum/commands/ralph-loop.md +0 -85
- package/plugins/ralph-wiggum/hooks/hooks.json +0 -15
- package/plugins/ralph-wiggum/hooks/stop-hook.sh +0 -191
- package/plugins/ralph-wiggum/plugin.js +0 -280
- package/plugins/ralph-wiggum/src/goalState.js +0 -258
- package/plugins/ralph-wiggum/src/sentinels.js +0 -76
- package/plugins/ralph-wiggum/src/stopHookRunner.js +0 -104
- package/plugins/ralph-wiggum/src/verificationGate.js +0 -202
- package/plugins/workflow-runner/src/miniReAct.js +0 -223
- package/plugins/workflow-runner/src/voteHelpers.js +0 -110
- package/skills/config/SKILL.md +0 -123
- package/skills/frontend-design/LICENSE.txt +0 -177
- package/skills/frontend-design/SKILL.md +0 -42
- package/src/ui/ProgressPanel.js +0 -54
- package/src/ui/StreamingBlock.js +0 -11
- package/src/ui/ToolStatus.js +0 -11
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ============================================================
|
|
3
|
+
* src/llm/providers/anthropicFormat.ts —— Anthropic Messages API 协议
|
|
4
|
+
* ------------------------------------------------------------
|
|
5
|
+
* ⚠️ 未经真实端点验证:本机没有任何 Anthropic 兼容的 key/代理,这里的请求体形状
|
|
6
|
+
* 和 SSE 事件字段完全照 Anthropic 官方文档(Messages API,2023-06-01)实现,配了
|
|
7
|
+
* 手写的 SSE 录像单测,但没有做过一次真实 round-trip。拿到真实 key 后务必先跑一次
|
|
8
|
+
* 真实对话冒烟测试,见 test/llm.anthropicFormat.test.ts 头注。
|
|
9
|
+
*
|
|
10
|
+
* 与 openaiFormat.ts 的分工一致:这里只做「内部 Message[]/Tool[] ⇄ Anthropic 协议
|
|
11
|
+
* 形状」的翻译 + SSE 逐行解析;重试/退避/空闲看门狗等协议无关骨架留在 client.ts。
|
|
12
|
+
*
|
|
13
|
+
* v1 明确不支持(写清楚,不装作支持):
|
|
14
|
+
* - output_schema 结构化输出(Anthropic 的强制工具输出模式跟 OpenAI 的
|
|
15
|
+
* response_format.json_schema 形状不同)——client.ts 在请求前直接抛错。
|
|
16
|
+
* - OpenAI 特有的「400 文本嗅探退化」(不支持 response_format/max_tokens 时自动
|
|
17
|
+
* 摘字段重发)无 Anthropic 对应逻辑;Anthropic 的 400 直接暴露。
|
|
18
|
+
* - 视频输入(ChatContentPart 的 video_url):Anthropic 无对应协议,退化成文本占位。
|
|
19
|
+
* ============================================================
|
|
20
|
+
*/
|
|
21
|
+
const ANTHROPIC_VERSION = '2023-06-01';
|
|
22
|
+
function toAnthropicUserContent(content) {
|
|
23
|
+
if (typeof content === 'string')
|
|
24
|
+
return [{ type: 'text', text: content }];
|
|
25
|
+
return content.map((part) => {
|
|
26
|
+
if (part.type === 'text')
|
|
27
|
+
return { type: 'text', text: part.text };
|
|
28
|
+
if (part.type === 'image_url') {
|
|
29
|
+
const url = part.image_url.url;
|
|
30
|
+
if (url.startsWith('data:')) {
|
|
31
|
+
const match = /^data:([^;]+);base64,([\s\S]+)$/.exec(url);
|
|
32
|
+
if (match)
|
|
33
|
+
return { type: 'image', source: { type: 'base64', media_type: match[1], data: match[2] } };
|
|
34
|
+
}
|
|
35
|
+
return { type: 'image', source: { type: 'url', url } };
|
|
36
|
+
}
|
|
37
|
+
// video_url:Anthropic 无对应协议,退化成文本占位(v1 范围限制)。
|
|
38
|
+
return { type: 'text', text: '[视频内容未发送:Anthropic 格式的 provider 暂不支持视频输入]' };
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* 内部 Message[](OpenAI 形状:role 含 tool、assistant.tool_calls、tool.tool_call_id)
|
|
43
|
+
* → Anthropic 形状:{system, messages}。
|
|
44
|
+
*
|
|
45
|
+
* 关键翻译规则:
|
|
46
|
+
* - 所有 system 角色内容拼成顶层 system 字符串,从 messages 数组里摘除。
|
|
47
|
+
* - tool 角色 → {role:'user', content:[{type:'tool_result', tool_use_id, content}]}。
|
|
48
|
+
* - assistant 的 tool_calls[i] → {type:'tool_use', id, name, input}(arguments 是内部的
|
|
49
|
+
* JSON 字符串,Anthropic 的 input 要解析后的对象;parse 失败兜底空对象)。
|
|
50
|
+
* - **必须合并连续同角色消息**:Anthropic 强制 user/assistant 严格交替,1:1 硬映射会因
|
|
51
|
+
* 「assistant 调工具 → tool 结果(→user) → 下一条也是 user 的正常对话」之类的连续同角色
|
|
52
|
+
* 序列而 400。
|
|
53
|
+
*/
|
|
54
|
+
export function toAnthropicMessages(messages) {
|
|
55
|
+
const systemParts = [];
|
|
56
|
+
const pieces = [];
|
|
57
|
+
for (const m of messages) {
|
|
58
|
+
if (m.role === 'system') {
|
|
59
|
+
systemParts.push(m.content);
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (m.role === 'user') {
|
|
63
|
+
pieces.push({ role: 'user', content: toAnthropicUserContent(m.content) });
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
if (m.role === 'assistant') {
|
|
67
|
+
const content = [];
|
|
68
|
+
if (m.content)
|
|
69
|
+
content.push({ type: 'text', text: m.content });
|
|
70
|
+
for (const call of m.tool_calls ?? []) {
|
|
71
|
+
let input = {};
|
|
72
|
+
try {
|
|
73
|
+
input = JSON.parse(call.function.arguments || '{}');
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
input = {};
|
|
77
|
+
}
|
|
78
|
+
content.push({ type: 'tool_use', id: call.id, name: call.function.name, input });
|
|
79
|
+
}
|
|
80
|
+
// 退化 assistant 消息(content 为 null/空字符串且没有 tool_calls——如模型只吐了
|
|
81
|
+
// reasoning 就被中断)整条跳过,而不是塞一个空文本块:Anthropic 拒绝空 text block
|
|
82
|
+
// ("text content blocks must be non-empty"),塞了会让下一轮请求直接 400。
|
|
83
|
+
if (content.length > 0)
|
|
84
|
+
pieces.push({ role: 'assistant', content });
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
// role === 'tool'
|
|
88
|
+
pieces.push({ role: 'user', content: [{ type: 'tool_result', tool_use_id: m.tool_call_id, content: m.content }] });
|
|
89
|
+
}
|
|
90
|
+
const merged = [];
|
|
91
|
+
for (const piece of pieces) {
|
|
92
|
+
const last = merged[merged.length - 1];
|
|
93
|
+
if (last && last.role === piece.role)
|
|
94
|
+
last.content.push(...piece.content);
|
|
95
|
+
else
|
|
96
|
+
merged.push({ role: piece.role, content: [...piece.content] });
|
|
97
|
+
}
|
|
98
|
+
return { system: systemParts.join('\n\n'), messages: merged };
|
|
99
|
+
}
|
|
100
|
+
function toAnthropicTools(tools) {
|
|
101
|
+
return tools.map((t) => ({
|
|
102
|
+
name: t.name,
|
|
103
|
+
description: typeof t.description === 'function' ? t.description() : t.description,
|
|
104
|
+
input_schema: t.parameters,
|
|
105
|
+
}));
|
|
106
|
+
}
|
|
107
|
+
function looksLikeVersionedBase(url) {
|
|
108
|
+
try {
|
|
109
|
+
const u = new URL(url);
|
|
110
|
+
const path = u.pathname.replace(/\/+$/, '');
|
|
111
|
+
if (path === '' || path === '/')
|
|
112
|
+
return true;
|
|
113
|
+
const segments = path.split('/');
|
|
114
|
+
const last = segments[segments.length - 1];
|
|
115
|
+
return /^v\d+/.test(last);
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
export function buildAnthropicUrl(provider) {
|
|
122
|
+
// baseURL 是完整端点 URL(以 /v1/messages 结尾)。
|
|
123
|
+
// 向后兼容:旧格式 baseURL(根域名或版本化基础路径)自动补全 /v1/messages 后缀。
|
|
124
|
+
const url = provider.baseURL.trim().replace(/\/+$/, '');
|
|
125
|
+
if (url.endsWith('/chat/completions') || url.endsWith('/v1/messages'))
|
|
126
|
+
return url;
|
|
127
|
+
if (url.length === 0)
|
|
128
|
+
return url;
|
|
129
|
+
if (looksLikeVersionedBase(url)) {
|
|
130
|
+
console.warn(`[minimal-agent] 旧格式 baseURL 检测:"${provider.baseURL}" 未包含端点后缀,` +
|
|
131
|
+
`已自动补全为 "${url}/v1/messages"。请在设置页更新为完整端点地址。`);
|
|
132
|
+
return `${url}/v1/messages`;
|
|
133
|
+
}
|
|
134
|
+
return url;
|
|
135
|
+
}
|
|
136
|
+
export function buildAnthropicRequest(args) {
|
|
137
|
+
const { provider, cleanedMessages, tools } = args;
|
|
138
|
+
const { system, messages } = toAnthropicMessages(cleanedMessages);
|
|
139
|
+
const anthropicTools = toAnthropicTools(tools);
|
|
140
|
+
const body = {
|
|
141
|
+
model: provider.model,
|
|
142
|
+
...(system ? { system } : {}),
|
|
143
|
+
messages,
|
|
144
|
+
// Anthropic 的 max_tokens 是必填字段;解析层(configService.ts::resolveProvider)已保证
|
|
145
|
+
// provider.maxTokens 一定有值(defaultMaxTokens() 兜底),这里直接透传不做协商退化——
|
|
146
|
+
// OpenAI 那套「不支持就摘掉重发」的 400 文本嗅探对 Anthropic 无对应逻辑,见文件头注。
|
|
147
|
+
max_tokens: provider.maxTokens,
|
|
148
|
+
stream: true,
|
|
149
|
+
};
|
|
150
|
+
// tools: [] 会被部分 provider 拒绝或产生意外行为——空数组直接不发这个字段。
|
|
151
|
+
if (anthropicTools.length > 0)
|
|
152
|
+
body.tools = anthropicTools;
|
|
153
|
+
return {
|
|
154
|
+
url: buildAnthropicUrl(provider),
|
|
155
|
+
headers: {
|
|
156
|
+
'content-type': 'application/json',
|
|
157
|
+
'x-api-key': provider.apiKey,
|
|
158
|
+
'anthropic-version': ANTHROPIC_VERSION,
|
|
159
|
+
},
|
|
160
|
+
body: JSON.stringify(body),
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* 每个请求一个新实例;把逐条 SSE `data:` 行的内容转换成 LlmStreamEvent(0..N 个)。
|
|
165
|
+
*
|
|
166
|
+
* Anthropic 的 SSE 每帧是 `event: <type>` + `data: <json>` 两行,但 data 的 JSON payload
|
|
167
|
+
* 自身也带 `type` 字段(与 event 行的值相同)——client.ts 的共享读取骨架只识别 `data:`
|
|
168
|
+
* 开头的行(继承自 OpenAI 分支的既有约定),所以这里直接从 JSON payload 的 `.type` 分支,
|
|
169
|
+
* 不需要读 `event:` 行,共享骨架的行拆分逻辑不用为 Anthropic 特殊改动。
|
|
170
|
+
*/
|
|
171
|
+
export function createAnthropicSSEParser() {
|
|
172
|
+
let stopReason = 'unknown';
|
|
173
|
+
let usagePromptTokens;
|
|
174
|
+
return {
|
|
175
|
+
buildFallbackDone() {
|
|
176
|
+
return { type: 'done', stopReason, promptTokens: usagePromptTokens };
|
|
177
|
+
},
|
|
178
|
+
handleData(dataStr) {
|
|
179
|
+
let data;
|
|
180
|
+
try {
|
|
181
|
+
data = JSON.parse(dataStr);
|
|
182
|
+
}
|
|
183
|
+
catch {
|
|
184
|
+
return [];
|
|
185
|
+
}
|
|
186
|
+
switch (data.type) {
|
|
187
|
+
case 'message_start': {
|
|
188
|
+
const inputTokens = data.message?.usage?.input_tokens;
|
|
189
|
+
if (typeof inputTokens === 'number')
|
|
190
|
+
usagePromptTokens = inputTokens;
|
|
191
|
+
return [];
|
|
192
|
+
}
|
|
193
|
+
case 'content_block_start': {
|
|
194
|
+
// tool_use 块的 id/name 在 start 事件里一次性给出(不像 OpenAI 分片在 delta 里),
|
|
195
|
+
// 这里补发一条只带 id/name、不带 argumentsDelta 的 tool_call_delta 把它们「种」进
|
|
196
|
+
// loop.ts::mergeToolCallDelta 的累积槽;后续同 index 的 input_json_delta 只带参数增量。
|
|
197
|
+
const block = data.content_block;
|
|
198
|
+
if (block?.type === 'tool_use') {
|
|
199
|
+
return [{ type: 'tool_call_delta', index: data.index, id: block.id, name: block.name }];
|
|
200
|
+
}
|
|
201
|
+
return [];
|
|
202
|
+
}
|
|
203
|
+
case 'content_block_delta': {
|
|
204
|
+
const delta = data.delta;
|
|
205
|
+
if (delta?.type === 'text_delta')
|
|
206
|
+
return [{ type: 'text_delta', delta: delta.text }];
|
|
207
|
+
if (delta?.type === 'input_json_delta') {
|
|
208
|
+
return [{ type: 'tool_call_delta', index: data.index, argumentsDelta: delta.partial_json }];
|
|
209
|
+
}
|
|
210
|
+
if (delta?.type === 'thinking_delta') {
|
|
211
|
+
return [{ type: 'reasoning_delta', field: 'reasoning', delta: delta.thinking }];
|
|
212
|
+
}
|
|
213
|
+
// signature_delta(扩展思维签名)等其它 delta 类型:v1 不处理,安全忽略。
|
|
214
|
+
return [];
|
|
215
|
+
}
|
|
216
|
+
case 'message_delta': {
|
|
217
|
+
// ⚠️ stop_reason 嵌套在 delta.stop_reason 下,不是 message_delta 顶层。
|
|
218
|
+
const sr = data.delta?.stop_reason;
|
|
219
|
+
if (sr === 'end_turn' || sr === 'stop_sequence')
|
|
220
|
+
stopReason = 'stop';
|
|
221
|
+
else if (sr === 'tool_use')
|
|
222
|
+
stopReason = 'tool_calls';
|
|
223
|
+
else if (sr === 'max_tokens')
|
|
224
|
+
stopReason = 'length';
|
|
225
|
+
else if (sr)
|
|
226
|
+
stopReason = 'unknown';
|
|
227
|
+
return [];
|
|
228
|
+
}
|
|
229
|
+
case 'message_stop':
|
|
230
|
+
return [{ type: 'done', stopReason, promptTokens: usagePromptTokens }];
|
|
231
|
+
case 'error':
|
|
232
|
+
// 中途错误事件(如 overloaded_error/529):不能静默结束流,必须让调用方看到失败——
|
|
233
|
+
// 抛出后由 client.ts 共享读取循环的 try/finally 传播给上层(与其它流中断失败同一路径)。
|
|
234
|
+
throw new Error(`Anthropic 流式响应报错:${JSON.stringify(data.error ?? data)}`);
|
|
235
|
+
default:
|
|
236
|
+
// 含 ping、content_block_stop 及未来可能新增的事件类型——已知安全的 no-op,不抛错。
|
|
237
|
+
return [];
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
};
|
|
241
|
+
}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ============================================================
|
|
3
|
+
* src/llm/providers/openaiFormat.ts —— OpenAI Chat Completions 协议
|
|
4
|
+
* ------------------------------------------------------------
|
|
5
|
+
* 从 client.ts 拆出来的格式相关部分:请求体构造 + SSE chunk → LlmStreamEvent。
|
|
6
|
+
* 重试/退避/空闲看门狗等协议无关的骨架留在 client.ts,两个格式模块共用。
|
|
7
|
+
* ============================================================
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* 判断一个 400 是否在抱怨 response_format(json_schema)不被支持。
|
|
11
|
+
* 各 provider 文案不一(火山 GLM:`json_schema is not supported by this model`),
|
|
12
|
+
* 故宽松匹配:"提到 response_format" 且 "出现 not support / unsupported / not valid / invalid"。
|
|
13
|
+
*/
|
|
14
|
+
export function isResponseFormatUnsupported(status, errText) {
|
|
15
|
+
if (status !== 400)
|
|
16
|
+
return false;
|
|
17
|
+
const t = errText.toLowerCase();
|
|
18
|
+
if (!t.includes('response_format'))
|
|
19
|
+
return false;
|
|
20
|
+
return (t.includes('not support') ||
|
|
21
|
+
t.includes('unsupported') ||
|
|
22
|
+
t.includes('not valid') ||
|
|
23
|
+
t.includes('invalid'));
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* 判断一个 400 是否在抱怨 max_tokens(不支持 / 超模型上限 / 取值非法)。
|
|
27
|
+
* 文案各家不一,故宽松匹配:"提到 max_tokens" 且 "出现 not support / invalid /
|
|
28
|
+
* exceed / too large / out of range / maximum"。命中后去掉 max_tokens 重发即可。
|
|
29
|
+
*/
|
|
30
|
+
export function isMaxTokensRejected(status, errText) {
|
|
31
|
+
if (status !== 400)
|
|
32
|
+
return false;
|
|
33
|
+
const t = errText.toLowerCase();
|
|
34
|
+
if (!t.includes('max_tokens') && !t.includes('max tokens'))
|
|
35
|
+
return false;
|
|
36
|
+
return (t.includes('not support') ||
|
|
37
|
+
t.includes('unsupported') ||
|
|
38
|
+
t.includes('not valid') ||
|
|
39
|
+
t.includes('invalid') ||
|
|
40
|
+
t.includes('exceed') ||
|
|
41
|
+
t.includes('too large') ||
|
|
42
|
+
t.includes('out of range') ||
|
|
43
|
+
t.includes('maximum'));
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* 判断一个 4xx 是否在抱怨图片/image_url/多模态输入不被支持。
|
|
47
|
+
* 匹配关键词:image_url、image、vision、multimodal + not support/unsupported/invalid 等。
|
|
48
|
+
*/
|
|
49
|
+
export function isImageInputRejected(status, errText) {
|
|
50
|
+
if (status !== 400 && status !== 404)
|
|
51
|
+
return false;
|
|
52
|
+
const t = errText.toLowerCase();
|
|
53
|
+
const hasImageKw = t.includes('image_url') || t.includes('image') || t.includes('vision') || t.includes('multimodal') || t.includes('不支持图片') || t.includes('图片输入');
|
|
54
|
+
if (!hasImageKw)
|
|
55
|
+
return false;
|
|
56
|
+
return (t.includes('not support') ||
|
|
57
|
+
t.includes('unsupported') ||
|
|
58
|
+
t.includes('not valid') ||
|
|
59
|
+
t.includes('invalid') ||
|
|
60
|
+
t.includes('not allowed') ||
|
|
61
|
+
t.includes('does not support') ||
|
|
62
|
+
t.includes('不支持'));
|
|
63
|
+
}
|
|
64
|
+
function looksLikeVersionedBase(url) {
|
|
65
|
+
try {
|
|
66
|
+
const u = new URL(url);
|
|
67
|
+
const path = u.pathname.replace(/\/+$/, '');
|
|
68
|
+
if (path === '' || path === '/')
|
|
69
|
+
return true;
|
|
70
|
+
const segments = path.split('/');
|
|
71
|
+
const last = segments[segments.length - 1];
|
|
72
|
+
return /^v\d+/.test(last);
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
export function buildOpenAIUrl(provider) {
|
|
79
|
+
// baseURL 是完整端点 URL(以 /chat/completions 结尾)。
|
|
80
|
+
// 向后兼容:旧格式 baseURL(版本化基础路径,如 /v1)自动补全后缀,并打 warning。
|
|
81
|
+
const url = provider.baseURL.trim().replace(/\/+$/, '');
|
|
82
|
+
if (url.endsWith('/chat/completions') || url.endsWith('/v1/messages'))
|
|
83
|
+
return url;
|
|
84
|
+
if (url.length === 0)
|
|
85
|
+
return url;
|
|
86
|
+
if (looksLikeVersionedBase(url)) {
|
|
87
|
+
console.warn(`[minimal-agent] 旧格式 baseURL 检测:"${provider.baseURL}" 未包含端点后缀,` +
|
|
88
|
+
`已自动补全为 "${url}/chat/completions"。请在设置页更新为完整端点地址。`);
|
|
89
|
+
return `${url}/chat/completions`;
|
|
90
|
+
}
|
|
91
|
+
return url;
|
|
92
|
+
}
|
|
93
|
+
export function buildOpenAIRequest(args) {
|
|
94
|
+
const { provider, cleanedMessages, tools, withResponseFormat, withMaxTokens, includeUsage, responseFormat } = args;
|
|
95
|
+
const openaiTools = tools.map((t) => ({
|
|
96
|
+
type: 'function',
|
|
97
|
+
function: {
|
|
98
|
+
name: t.name,
|
|
99
|
+
description: typeof t.description === 'function' ? t.description() : t.description,
|
|
100
|
+
parameters: t.parameters,
|
|
101
|
+
},
|
|
102
|
+
}));
|
|
103
|
+
return {
|
|
104
|
+
url: buildOpenAIUrl(provider),
|
|
105
|
+
headers: {
|
|
106
|
+
'Content-Type': 'application/json',
|
|
107
|
+
Authorization: `Bearer ${provider.apiKey}`,
|
|
108
|
+
},
|
|
109
|
+
body: JSON.stringify({
|
|
110
|
+
model: provider.model,
|
|
111
|
+
messages: cleanedMessages,
|
|
112
|
+
tools: openaiTools.length > 0 ? openaiTools : undefined,
|
|
113
|
+
stream: true,
|
|
114
|
+
// 显式输出上限:兜住默认上限偏小的 provider(豆包默认 4096)。缺省 undefined 不出现在 body。
|
|
115
|
+
max_tokens: withMaxTokens ? provider.maxTokens : undefined,
|
|
116
|
+
// stream_options.include_usage:让 provider 在流末附带真实 prompt_tokens,
|
|
117
|
+
// 供上层自动压缩判断用;provider 不支持时 usagePromptTokens 保持 undefined,上层 fallback 本地估算。
|
|
118
|
+
...(includeUsage ? { stream_options: { include_usage: true } } : {}),
|
|
119
|
+
// tool_choice: 'auto' 是默认值,可不写;某些 provider 必须显式
|
|
120
|
+
tool_choice: openaiTools.length > 0 ? 'auto' : undefined,
|
|
121
|
+
// ADR-05: structured output;缺省 undefined 不出现在 body(JSON.stringify 自动剥离)
|
|
122
|
+
response_format: withResponseFormat ? responseFormat : undefined,
|
|
123
|
+
}),
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
/** 每个请求一个新实例;把逐条 SSE `data:` 行的内容转换成 LlmStreamEvent(0..N 个)。 */
|
|
127
|
+
export function createOpenAISSEParser() {
|
|
128
|
+
let stopReason = 'unknown';
|
|
129
|
+
let usagePromptTokens;
|
|
130
|
+
return {
|
|
131
|
+
buildFallbackDone() {
|
|
132
|
+
return { type: 'done', stopReason, promptTokens: usagePromptTokens };
|
|
133
|
+
},
|
|
134
|
+
handleData(dataStr) {
|
|
135
|
+
if (dataStr === '[DONE]')
|
|
136
|
+
return [{ type: 'done', stopReason, promptTokens: usagePromptTokens }];
|
|
137
|
+
let chunk;
|
|
138
|
+
try {
|
|
139
|
+
chunk = JSON.parse(dataStr);
|
|
140
|
+
}
|
|
141
|
+
catch {
|
|
142
|
+
// 罕见:某些 provider 会发空行或心跳,忽略
|
|
143
|
+
return [];
|
|
144
|
+
}
|
|
145
|
+
const events = [];
|
|
146
|
+
// usage chunk:include_usage 开启时,provider 通常在流末单独发一帧,
|
|
147
|
+
// 此帧 choices 为空(没有 delta),必须在 `if (!delta) return` 之前读取,
|
|
148
|
+
// 否则会被跳过,永远拿不到真实 prompt_tokens。
|
|
149
|
+
if (chunk.usage && typeof chunk.usage.prompt_tokens === 'number') {
|
|
150
|
+
usagePromptTokens = chunk.usage.prompt_tokens;
|
|
151
|
+
}
|
|
152
|
+
const delta = chunk.choices?.[0]?.delta;
|
|
153
|
+
const finish = chunk.choices?.[0]?.finish_reason;
|
|
154
|
+
if (finish) {
|
|
155
|
+
stopReason = finish === 'stop' || finish === 'tool_calls' || finish === 'length' ? finish : 'unknown';
|
|
156
|
+
}
|
|
157
|
+
if (!delta)
|
|
158
|
+
return events;
|
|
159
|
+
// 文本增量。注意:MiniMax 等模型默认会把 <think>...</think> 标签直接放在
|
|
160
|
+
// content 字段里——我们原样累积,不剥离,确保下一轮工具调用时思维链完整回传。
|
|
161
|
+
if (typeof delta.content === 'string' && delta.content.length > 0) {
|
|
162
|
+
events.push({ type: 'text_delta', delta: delta.content });
|
|
163
|
+
}
|
|
164
|
+
// tool_calls 增量(OpenAI 协议下 tool_calls 也是分片返回的)
|
|
165
|
+
if (Array.isArray(delta.tool_calls)) {
|
|
166
|
+
for (const tc of delta.tool_calls) {
|
|
167
|
+
events.push({
|
|
168
|
+
type: 'tool_call_delta',
|
|
169
|
+
index: tc.index ?? 0,
|
|
170
|
+
id: tc.id,
|
|
171
|
+
name: tc.function?.name,
|
|
172
|
+
argumentsDelta: tc.function?.arguments,
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
// 思维链增量(DeepSeek-R1 / MiniMax reasoning_split / OpenRouter)
|
|
177
|
+
// 三种字段名都见过:reasoning_content / reasoning / reasoning_details
|
|
178
|
+
if (typeof delta.reasoning_content === 'string' && delta.reasoning_content.length > 0) {
|
|
179
|
+
events.push({ type: 'reasoning_delta', field: 'reasoning_content', delta: delta.reasoning_content });
|
|
180
|
+
}
|
|
181
|
+
if (typeof delta.reasoning === 'string' && delta.reasoning.length > 0) {
|
|
182
|
+
events.push({ type: 'reasoning_delta', field: 'reasoning', delta: delta.reasoning });
|
|
183
|
+
}
|
|
184
|
+
if (Array.isArray(delta.reasoning_details) && delta.reasoning_details.length > 0) {
|
|
185
|
+
events.push({ type: 'reasoning_delta', field: 'reasoning_details', items: delta.reasoning_details });
|
|
186
|
+
}
|
|
187
|
+
return events;
|
|
188
|
+
},
|
|
189
|
+
};
|
|
190
|
+
}
|