create-windy 0.8.3 → 0.9.1
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/dist/cli.js +838 -560
- package/package.json +1 -1
- package/template/.windy-template.json +2 -2
- package/template/apps/agent-server/Dockerfile +92 -22
- package/template/apps/agent-server/README.md +47 -85
- package/template/apps/agent-server/documents/office.py +216 -0
- package/template/apps/agent-server/documents/query_report.py +136 -0
- package/template/apps/agent-server/documents/smoke.py +177 -0
- package/template/apps/agent-server/documents/test_boundaries.py +185 -0
- package/template/apps/agent-server/host-contracts.ts +56 -0
- package/template/apps/agent-server/install-native.ts +167 -0
- package/template/apps/agent-server/main.ts +179 -0
- package/template/apps/agent-server/native/EXTENSIONS.md +46 -0
- package/template/apps/agent-server/native/admission.ts +73 -0
- package/template/apps/agent-server/native/authorization.test.ts +176 -0
- package/template/apps/agent-server/native/authorization.ts +118 -0
- package/template/apps/agent-server/native/boundary-io.ts +93 -0
- package/template/apps/agent-server/native/boundary-product.ts +107 -0
- package/template/apps/agent-server/native/boundary-project.test.ts +247 -0
- package/template/apps/agent-server/native/boundary-project.ts +188 -0
- package/template/apps/agent-server/native/boundary.ts +188 -0
- package/template/apps/agent-server/native/compaction-policy.test.ts +175 -0
- package/template/apps/agent-server/native/config.ts +95 -0
- package/template/apps/agent-server/native/conversation-instructions.ts +9 -0
- package/template/apps/agent-server/native/extensions.test.ts +190 -0
- package/template/apps/agent-server/native/extensions.ts +31 -0
- package/template/apps/agent-server/native/host-profile.test.ts +91 -0
- package/template/apps/agent-server/native/host-profile.ts +33 -0
- package/template/apps/agent-server/native/host-test-fixture.ts +13 -0
- package/template/apps/agent-server/native/http.ts +129 -0
- package/template/apps/agent-server/native/lifecycle.test.ts +285 -0
- package/template/apps/agent-server/native/lifecycle.ts +136 -0
- package/template/apps/agent-server/native/manager.ts +292 -0
- package/template/apps/agent-server/native/native.test.ts +207 -0
- package/template/apps/agent-server/native/office-preview.test.ts +50 -0
- package/template/apps/agent-server/native/office-preview.ts +25 -0
- package/template/apps/agent-server/native/parallel-harness.ts +242 -0
- package/template/apps/agent-server/native/parallel-mcp-fixture.ts +97 -0
- package/template/apps/agent-server/native/parallel.test.ts +256 -0
- package/template/apps/agent-server/native/profile-composition.test.ts +147 -0
- package/template/apps/agent-server/native/profile.ts +307 -0
- package/template/apps/agent-server/native/request.ts +61 -0
- package/template/apps/agent-server/native/session-conflict.test.ts +235 -0
- package/template/apps/agent-server/native/session-conflict.ts +21 -0
- package/template/apps/agent-server/native/shared-skills.test.ts +128 -0
- package/template/apps/agent-server/native/shared-skills.ts +240 -0
- package/template/apps/agent-server/native/socket-lifecycle.test.ts +48 -0
- package/template/apps/agent-server/native/socket.ts +130 -0
- package/template/apps/agent-server/native/storage-lifecycle.test.ts +217 -0
- package/template/apps/agent-server/native/storage.ts +188 -0
- package/template/apps/agent-server/native/stream-authorization.test.ts +89 -0
- package/template/apps/agent-server/native/worker.ts +77 -0
- package/template/apps/agent-server/native-download.test.ts +119 -0
- package/template/apps/agent-server/native-download.ts +145 -0
- package/template/apps/agent-server/package.json +63 -0
- package/template/apps/agent-server/plugins/access.mjs +126 -0
- package/template/apps/agent-server/plugins/branding/README.md +9 -0
- package/template/apps/agent-server/plugins/branding/brand.css +85 -0
- package/template/apps/agent-server/plugins/branding/client.js +338 -0
- package/template/apps/agent-server/plugins/branding/index.mjs +35 -0
- package/template/apps/agent-server/plugins/branding/loading.d.mts +2 -0
- package/template/apps/agent-server/plugins/branding/loading.mjs +66 -0
- package/template/apps/agent-server/plugins/branding/loading.test.ts +89 -0
- package/template/apps/agent-server/plugins/branding/package.json +21 -0
- package/template/apps/agent-server/plugins/branding.test.ts +294 -0
- package/template/apps/agent-server/plugins/compaction.mjs +83 -0
- package/template/apps/agent-server/plugins/compaction.test.ts +91 -0
- package/template/apps/agent-server/plugins/confine-network.py +57 -0
- package/template/apps/agent-server/plugins/default-skills.test.ts +62 -0
- package/template/apps/agent-server/plugins/downloads/README.md +28 -0
- package/template/apps/agent-server/plugins/downloads/client.js +126 -0
- package/template/apps/agent-server/plugins/downloads/downloads.test.ts +222 -0
- package/template/apps/agent-server/plugins/downloads/index.d.mts +19 -0
- package/template/apps/agent-server/plugins/downloads/index.mjs +180 -0
- package/template/apps/agent-server/plugins/downloads/package.json +20 -0
- package/template/apps/agent-server/plugins/drop-overlay/README.md +24 -0
- package/template/apps/agent-server/plugins/drop-overlay/drop-overlay.test.ts +199 -0
- package/template/apps/agent-server/plugins/drop-overlay/index.d.mts +8 -0
- package/template/apps/agent-server/plugins/drop-overlay/index.mjs +12 -0
- package/template/apps/agent-server/plugins/drop-overlay/style.css +102 -0
- package/template/apps/agent-server/plugins/locale/client.js +61 -0
- package/template/apps/agent-server/plugins/locale/index.d.mts +9 -0
- package/template/apps/agent-server/plugins/locale/index.mjs +16 -0
- package/template/apps/agent-server/plugins/locale/locale.test.ts +217 -0
- package/template/apps/agent-server/plugins/locale/package.json +19 -0
- package/template/apps/agent-server/plugins/parallel.mjs +146 -0
- package/template/apps/agent-server/plugins/preset-registry.d.mts +2 -0
- package/template/apps/agent-server/plugins/preset-registry.mjs +41 -0
- package/template/apps/agent-server/plugins/preset-registry.test.ts +46 -0
- package/template/apps/agent-server/plugins/questions.d.mts +25 -0
- package/template/apps/agent-server/plugins/questions.mjs +142 -0
- package/template/apps/agent-server/plugins/questions.test.ts +105 -0
- package/template/apps/agent-server/plugins/settings/README.md +17 -0
- package/template/apps/agent-server/plugins/settings/client.js +102 -0
- package/template/apps/agent-server/plugins/settings/index.mjs +17 -0
- package/template/apps/agent-server/plugins/settings/package.json +19 -0
- package/template/apps/agent-server/plugins/settings/settings.test.ts +129 -0
- package/template/apps/agent-server/plugins/settings-controller.d.mts +4 -0
- package/template/apps/agent-server/plugins/settings-controller.mjs +31 -0
- package/template/apps/agent-server/plugins/settings-controller.test.ts +17 -0
- package/template/apps/agent-server/plugins/settings-dispatch.test.ts +34 -0
- package/template/apps/agent-server/plugins/shared-skills.d.mts +15 -0
- package/template/apps/agent-server/plugins/shared-skills.mjs +82 -0
- package/template/apps/agent-server/plugins/shared-skills.test.ts +51 -0
- package/template/apps/agent-server/plugins/skill-library/README.md +11 -0
- package/template/apps/agent-server/plugins/skill-library/archive.test.ts +43 -0
- package/template/apps/agent-server/plugins/skill-library/bundle.mjs +234 -0
- package/template/apps/agent-server/plugins/skill-library/client-chunks.test.ts +107 -0
- package/template/apps/agent-server/plugins/skill-library/client-form-mount.test.ts +139 -0
- package/template/apps/agent-server/plugins/skill-library/client-form.test.ts +261 -0
- package/template/apps/agent-server/plugins/skill-library/client-ui.test.ts +268 -0
- package/template/apps/agent-server/plugins/skill-library/client-use.test.ts +158 -0
- package/template/apps/agent-server/plugins/skill-library/client.editor.js +93 -0
- package/template/apps/agent-server/plugins/skill-library/client.form.js +316 -0
- package/template/apps/agent-server/plugins/skill-library/client.js +348 -0
- package/template/apps/agent-server/plugins/skill-library/client.request.js +52 -0
- package/template/apps/agent-server/plugins/skill-library/client.transfer.js +48 -0
- package/template/apps/agent-server/plugins/skill-library/client.use.js +46 -0
- package/template/apps/agent-server/plugins/skill-library/default-roots.test.ts +84 -0
- package/template/apps/agent-server/plugins/skill-library/draft.d.mts +17 -0
- package/template/apps/agent-server/plugins/skill-library/draft.mjs +152 -0
- package/template/apps/agent-server/plugins/skill-library/draft.test.ts +287 -0
- package/template/apps/agent-server/plugins/skill-library/index.d.mts +49 -0
- package/template/apps/agent-server/plugins/skill-library/index.mjs +226 -0
- package/template/apps/agent-server/plugins/skill-library/package.json +24 -0
- package/template/apps/agent-server/plugins/skill-library/presentation/README.md +27 -0
- package/template/apps/agent-server/plugins/skill-library/presentation/UPSTREAM.md +54 -0
- package/template/apps/agent-server/plugins/skill-library/presentation/boot.test.ts +150 -0
- package/template/apps/agent-server/plugins/skill-library/presentation/client.js +146 -0
- package/template/apps/agent-server/plugins/skill-library/presentation/client.test.ts +195 -0
- package/template/apps/agent-server/plugins/skill-library/presentation/index.d.mts +9 -0
- package/template/apps/agent-server/plugins/skill-library/presentation/index.mjs +30 -0
- package/template/apps/agent-server/plugins/skill-library/presentation/metadata.test.ts +82 -0
- package/template/apps/agent-server/plugins/skill-library/presentation/package.json +21 -0
- package/template/apps/agent-server/plugins/skill-library/presentation/react-boot.test.ts +162 -0
- package/template/apps/agent-server/plugins/skill-library/skills.test.ts +342 -0
- package/template/apps/agent-server/plugins/skill-library/storage.mjs +293 -0
- package/template/apps/agent-server/plugins/skill-library/style.css +229 -0
- package/template/apps/agent-server/plugins/skill-library/test-fixture.ts +77 -0
- package/template/apps/agent-server/plugins/skill-library/workflow.d.mts +18 -0
- package/template/apps/agent-server/plugins/skill-library/workflow.mjs +189 -0
- package/template/apps/agent-server/plugins/skill-library/workflow.test.ts +164 -0
- package/template/apps/agent-server/plugins/skills/README.md +5 -0
- package/template/apps/agent-server/plugins/skills/windy-data-summary/SKILL.md +14 -0
- package/template/apps/agent-server/plugins/skills/windy-extension-guide/SKILL.md +14 -0
- package/template/apps/agent-server/plugins/skills/windy-office/SKILL.md +14 -0
- package/template/apps/agent-server/plugins/skills/windy-skill-capture/SKILL.md +14 -0
- package/template/apps/agent-server/plugins/skills/windy-source-compare/SKILL.md +14 -0
- package/template/apps/agent-server/plugins/subprocess.mjs +40 -0
- package/template/apps/agent-server/plugins/theme/README.md +18 -0
- package/template/apps/agent-server/plugins/theme/client.js +18 -0
- package/template/apps/agent-server/plugins/theme/index.d.mts +9 -0
- package/template/apps/agent-server/plugins/theme/index.mjs +18 -0
- package/template/apps/agent-server/plugins/theme/package.json +19 -0
- package/template/apps/agent-server/plugins/theme/source-tokens.ts +82 -0
- package/template/apps/agent-server/plugins/theme/sync-tokens.ts +12 -0
- package/template/apps/agent-server/plugins/theme/theme.test.ts +193 -0
- package/template/apps/agent-server/plugins/theme/tokens.json +166 -0
- package/template/apps/agent-server/plugins/tool-catalog/README.md +79 -0
- package/template/apps/agent-server/plugins/tool-catalog/categories.mjs +111 -0
- package/template/apps/agent-server/plugins/tool-catalog/categories.test.ts +118 -0
- package/template/apps/agent-server/plugins/tool-catalog/client-cache.test.ts +264 -0
- package/template/apps/agent-server/plugins/tool-catalog/client.js +333 -0
- package/template/apps/agent-server/plugins/tool-catalog/client.test.ts +136 -0
- package/template/apps/agent-server/plugins/tool-catalog/discovery.d.mts +42 -0
- package/template/apps/agent-server/plugins/tool-catalog/discovery.mjs +242 -0
- package/template/apps/agent-server/plugins/tool-catalog/discovery.test.ts +229 -0
- package/template/apps/agent-server/plugins/tool-catalog/index.d.mts +5 -0
- package/template/apps/agent-server/plugins/tool-catalog/index.mjs +91 -0
- package/template/apps/agent-server/plugins/tool-catalog/package.json +23 -0
- package/template/apps/agent-server/plugins/tool-catalog/presentation.d.mts +21 -0
- package/template/apps/agent-server/plugins/tool-catalog/presentation.mjs +153 -0
- package/template/apps/agent-server/plugins/tool-catalog/presentation.test.ts +166 -0
- package/template/apps/agent-server/plugins/tool-catalog/routes.test.ts +209 -0
- package/template/apps/agent-server/plugins/tool-catalog/style.css +155 -0
- package/template/apps/agent-server/plugins/tool-catalog/use-tool.test.ts +160 -0
- package/template/apps/agent-server/plugins/tool-presentation/README.md +7 -0
- package/template/apps/agent-server/plugins/tool-presentation/build-client.ts +29 -0
- package/template/apps/agent-server/plugins/tool-presentation/client.js +312 -0
- package/template/apps/agent-server/plugins/tool-presentation/client.results.js +9 -0
- package/template/apps/agent-server/plugins/tool-presentation/client.test.ts +178 -0
- package/template/apps/agent-server/plugins/tool-presentation/index.mjs +10 -0
- package/template/apps/agent-server/plugins/tool-presentation/package.json +24 -0
- package/template/apps/agent-server/plugins/tool-presentation/result-discovery.mjs +43 -0
- package/template/apps/agent-server/plugins/tool-presentation/result-model.d.mts +51 -0
- package/template/apps/agent-server/plugins/tool-presentation/result-model.mjs +96 -0
- package/template/apps/agent-server/plugins/workspace/README.md +5 -0
- package/template/apps/agent-server/plugins/workspace/index.mjs +8 -0
- package/template/apps/agent-server/plugins/workspace/package.json +10 -0
- package/template/apps/agent-server/plugins/workspace/style.css +124 -0
- package/template/apps/agent-server/project/host.ts +13 -0
- package/template/apps/agent-server/runtime/artifacts.ts +115 -0
- package/template/apps/agent-server/runtime/audit.nodecheck.ts +60 -0
- package/template/apps/agent-server/runtime/capacity.ts +61 -0
- package/template/apps/agent-server/runtime/client-completion-budget.nodecheck.ts +92 -0
- package/template/apps/agent-server/runtime/compatibility.ts +33 -0
- package/template/apps/agent-server/runtime/completions.ts +320 -0
- package/template/apps/agent-server/runtime/config.ts +246 -0
- package/template/apps/agent-server/runtime/context-budget.ts +70 -0
- package/template/apps/agent-server/runtime/context-plugin.ts +306 -0
- package/template/apps/agent-server/runtime/context.nodecheck.ts +241 -0
- package/template/apps/agent-server/runtime/contracts.ts +201 -0
- package/template/apps/agent-server/runtime/dsh-engine.ts +196 -0
- package/template/apps/agent-server/runtime/evaluation-plugin.ts +115 -0
- package/template/apps/agent-server/runtime/evaluation.nodecheck.ts +194 -0
- package/template/apps/agent-server/runtime/events.ts +71 -0
- package/template/apps/agent-server/runtime/governance.ts +194 -0
- package/template/apps/agent-server/runtime/index.ts +339 -0
- package/template/apps/agent-server/runtime/internal-output.ts +37 -0
- package/template/apps/agent-server/runtime/isolation.nodecheck.ts +287 -0
- package/template/apps/agent-server/runtime/model-payload.ts +97 -0
- package/template/apps/agent-server/runtime/model-plugin.ts +308 -0
- package/template/apps/agent-server/runtime/model-route.ts +34 -0
- package/template/apps/agent-server/runtime/model-usage.ts +51 -0
- package/template/apps/agent-server/runtime/model-wire.ts +45 -0
- package/template/apps/agent-server/runtime/native-authorization.nodecheck.ts +126 -0
- package/template/apps/agent-server/runtime/native-completion.nodecheck.ts +81 -0
- package/template/apps/agent-server/runtime/output-validation.ts +66 -0
- package/template/apps/agent-server/runtime/production-capacity.nodecheck.ts +121 -0
- package/template/apps/agent-server/runtime/questions-workflow.nodecheck.ts +249 -0
- package/template/apps/agent-server/runtime/report-breakdown.ts +79 -0
- package/template/apps/agent-server/runtime/reporting.ts +219 -0
- package/template/apps/agent-server/runtime/run-completion.ts +39 -0
- package/template/apps/agent-server/runtime/run-request-digest.ts +18 -0
- package/template/apps/agent-server/runtime/runtime-test-fixtures.ts +264 -0
- package/template/apps/agent-server/runtime/runtime.nodecheck.ts +150 -0
- package/template/apps/agent-server/runtime/store-idempotency.nodecheck.ts +74 -0
- package/template/apps/agent-server/runtime/store.ts +324 -0
- package/template/apps/agent-server/runtime/structured-output-mode.nodecheck.ts +51 -0
- package/template/apps/agent-server/runtime/tool-name.ts +6 -0
- package/template/apps/agent-server/runtime/tool-plugin.ts +201 -0
- package/template/apps/agent-server/runtime/vision-readiness.ts +200 -0
- package/template/apps/agent-server/scripts/confinement-check.mjs +103 -0
- package/template/apps/agent-server/scripts/coordinator-check.mjs +344 -0
- package/template/apps/agent-server/scripts/documents-delivery-check.mjs +309 -0
- package/template/apps/agent-server/scripts/office-preview-check.mjs +92 -0
- package/template/apps/agent-server/scripts/test-confinement.ts +58 -0
- package/template/apps/agent-server/scripts/test-coordinator.ts +36 -0
- package/template/apps/agent-server/scripts/test-runtime.ts +46 -0
- package/template/apps/agent-server/tsconfig.json +21 -0
- package/template/apps/server/Dockerfile +3 -0
- package/template/apps/server/package.json +5 -1
- package/template/apps/server/scripts/check-dsh-platform-example.ts +251 -0
- package/template/apps/server/src/agent/dsh-runtime-wire.test.ts +33 -0
- package/template/apps/server/src/agent/governance-runtime.ts +41 -0
- package/template/apps/server/src/agent/remote-runtime-response.ts +1 -1
- package/template/apps/server/src/agent/run-contracts.ts +1 -0
- package/template/apps/server/src/agent/run-definition-support.ts +9 -0
- package/template/apps/server/src/agent/runtime-tool-composition.ts +2 -0
- package/template/apps/server/src/agent/workflow-runtime-bootstrap.ts +9 -0
- package/template/apps/server/src/agent-skills/access.ts +88 -0
- package/template/apps/server/src/agent-skills/bootstrap.ts +49 -0
- package/template/apps/server/src/agent-skills/builtin-registration.ts +83 -0
- package/template/apps/server/src/agent-skills/builtins.ts +19 -0
- package/template/apps/server/src/agent-skills/bundle-zip.ts +163 -0
- package/template/apps/server/src/agent-skills/bundle.test.ts +79 -0
- package/template/apps/server/src/agent-skills/bundle.ts +133 -0
- package/template/apps/server/src/agent-skills/contracts.ts +46 -0
- package/template/apps/server/src/agent-skills/drizzle-repository.ts +125 -0
- package/template/apps/server/src/agent-skills/input.ts +29 -0
- package/template/apps/server/src/agent-skills/postgres.integration.test.ts +348 -0
- package/template/apps/server/src/agent-skills/read-routes.test.ts +116 -0
- package/template/apps/server/src/agent-skills/reader.ts +108 -0
- package/template/apps/server/src/agent-skills/repository.ts +105 -0
- package/template/apps/server/src/agent-skills/routes.ts +176 -0
- package/template/apps/server/src/agent-skills/service.test.ts +295 -0
- package/template/apps/server/src/agent-skills/service.ts +301 -0
- package/template/apps/server/src/agent-workflow/preset-registry.test.ts +137 -0
- package/template/apps/server/src/agent-workflow/preset-registry.ts +191 -0
- package/template/apps/server/src/agent-workflow/preset-routes.test.ts +94 -0
- package/template/apps/server/src/agent-workflow/preset-routes.ts +45 -0
- package/template/apps/server/src/ai-runtime-report/service.test.ts +10 -7
- package/template/apps/server/src/ai-runtime-report/service.ts +1 -1
- package/template/apps/server/src/app/agent-workflow-presets.ts +4 -0
- package/template/apps/server/src/app/dsh-skill-draft-audit.test.ts +195 -0
- package/template/apps/server/src/app/dsh-skill-draft-audit.ts +115 -0
- package/template/apps/server/src/app/dsh-workbench-audit.test.ts +71 -0
- package/template/apps/server/src/app/dsh-workbench-audit.ts +34 -0
- package/template/apps/server/src/app/dsh-workbench-handshake.test.ts +63 -0
- package/template/apps/server/src/app/dsh-workbench-handshake.ts +48 -0
- package/template/apps/server/src/app/dsh-workbench-http.test.ts +96 -0
- package/template/apps/server/src/app/dsh-workbench-lan-origin.test.ts +114 -0
- package/template/apps/server/src/app/dsh-workbench-launch.test.ts +70 -0
- package/template/apps/server/src/app/dsh-workbench-origin.test.ts +54 -0
- package/template/apps/server/src/app/dsh-workbench-proxy.ts +205 -0
- package/template/apps/server/src/app/dsh-workbench-session-conflict.test.ts +61 -0
- package/template/apps/server/src/app/dsh-workbench-session.ts +59 -0
- package/template/apps/server/src/app/dsh-workbench-socket-audit.test.ts +115 -0
- package/template/apps/server/src/app/dsh-workbench-socket.test.ts +246 -0
- package/template/apps/server/src/app/dsh-workbench-socket.ts +272 -0
- package/template/apps/server/src/app/dsh-workbench-test-support.ts +158 -0
- package/template/apps/server/src/app/dsh-workbench.test.ts +213 -0
- package/template/apps/server/src/app/dsh-workbench.ts +279 -0
- package/template/apps/server/src/app/workbench-public-origin.ts +16 -0
- package/template/apps/server/src/data-governance/user-plaintext-routes.test.ts +3 -0
- package/template/apps/server/src/http-app.ts +31 -0
- package/template/apps/server/src/mcp/adapter.ts +1 -0
- package/template/apps/server/src/module-composition.test.ts +23 -0
- package/template/apps/server/src/module-composition.ts +9 -2
- package/template/apps/server/src/observability/bootstrap.ts +12 -0
- package/template/apps/server/src/observability/diagnostic-failure-recorder.ts +94 -0
- package/template/apps/server/src/observability/diagnostic-http-contract.test.ts +42 -0
- package/template/apps/server/src/observability/diagnostic-index.test.ts +89 -0
- package/template/apps/server/src/observability/diagnostic-index.ts +88 -0
- package/template/apps/server/src/observability/diagnostic-repository.ts +67 -0
- package/template/apps/server/src/platform-app-bootstrap.ts +42 -0
- package/template/apps/server/src/platform-http-runtime.ts +6 -0
- package/template/apps/server/src/runtime-development.test.ts +25 -0
- package/template/apps/server/src/runtime-development.ts +6 -44
- package/template/apps/server/src/system/diagnostic-routes.test.ts +78 -0
- package/template/apps/server/src/system/diagnostic-routes.ts +66 -0
- package/template/apps/web/Dockerfile +9 -1
- package/template/apps/web/dev/start.ts +21 -10
- package/template/apps/web/dsh-workbench-location.ts +21 -0
- package/template/apps/web/dsh-workbench-proxy.test.ts +121 -0
- package/template/apps/web/dsh-workbench-proxy.ts +194 -0
- package/template/apps/web/package.json +3 -1
- package/template/apps/web/server.ts +27 -6
- package/template/apps/web/src/composables/useLoginFlow.ts +13 -1
- package/template/apps/web/src/pages/errors/PlatformErrorPage.vue +6 -0
- package/template/apps/web/src/pages/errors/PlatformErrorPage.webtest.ts +14 -1
- package/template/apps/web/src/pages/errors/error-page-extension.ts +1 -0
- package/template/apps/web/src/pages/system/AgentNativePage.vue +44 -0
- package/template/apps/web/src/pages/system/AgentWorkflowPage.vue +20 -7
- package/template/apps/web/src/pages/system/DiagnosticLookupPage.vue +56 -0
- package/template/apps/web/src/pages/system/DiagnosticLookupPage.webtest.ts +99 -0
- package/template/apps/web/src/pages/system/SystemAgentSkillsPage.vue +88 -0
- package/template/apps/web/src/pages/system/components/DiagnosticRecordDetails.vue +52 -0
- package/template/apps/web/src/pages/system/components/agent-skills/AgentSkillDetailDialog.vue +166 -0
- package/template/apps/web/src/pages/system/components/agent-skills/AgentSkillGovernanceActionDialog.vue +51 -0
- package/template/apps/web/src/pages/system/components/agent-skills/AgentSkillImportDialog.vue +320 -0
- package/template/apps/web/src/pages/system/components/agent-skills/AgentSkillImportDialog.webtest.ts +96 -0
- package/template/apps/web/src/pages/system/components/agent-skills/AgentSkillsTable.vue +69 -0
- package/template/apps/web/src/pages/system/components/agent-workflow/WorkflowPresetCatalog.vue +82 -0
- package/template/apps/web/src/pages/system/components/agent-workflow/WorkflowPresetCatalog.webtest.ts +57 -0
- package/template/apps/web/src/pages/system/composables/useAgentSkillsGovernance.ts +105 -0
- package/template/apps/web/src/pages/system/composables/useAgentWorkflowPresets.ts +44 -0
- package/template/apps/web/src/pages/system/composables/useDiagnosticLookup.ts +64 -0
- package/template/apps/web/src/router/error-navigation.ts +3 -1
- package/template/apps/web/src/router/error-navigation.webtest.ts +14 -2
- package/template/apps/web/src/router/index.ts +8 -49
- package/template/apps/web/src/router/platform-admin-pages.ts +79 -0
- package/template/apps/web/src/router/platform-admin-route-bindings.ts +8 -0
- package/template/apps/web/src/services/agent-skills-api.ts +55 -0
- package/template/apps/web/src/services/agent-workflow-api.ts +12 -0
- package/template/apps/web/src/services/diagnostics-api.ts +12 -0
- package/template/apps/web/src/services/http.ts +18 -0
- package/template/apps/web/src/services/http.webtest.ts +51 -0
- package/template/apps/web/vite.config.ts +39 -0
- package/template/deploy/dsh/README.md +5 -0
- package/template/deploy/dsh/documents/README.md +9 -0
- package/template/deploy/dsh/documents/requirements.in +6 -0
- package/template/deploy/dsh/documents/requirements.lock +72 -0
- package/template/docker-compose.yml +24 -10
- package/template/docs/adr/0004-embedded-dsh-runtime.md +9 -0
- package/template/docs/architecture/agent-admin-workbench-implementation.md +73 -0
- package/template/docs/architecture/agent-admin-workbench-plan.md +41 -0
- package/template/docs/architecture/agent-harness.md +2 -0
- package/template/docs/architecture/agent-runtime-compatibility.md +2 -0
- package/template/docs/architecture/embedded-dsh-integration.md +44 -0
- package/template/docs/development/dsh-plugins.md +55 -0
- package/template/docs/operations/dsh-agent-migration.md +98 -0
- package/template/docs/platform/agent-production-store.md +5 -78
- package/template/docs/platform/agent-runtime-observability.md +2 -0
- package/template/docs/platform/agent-runtime.md +2 -0
- package/template/docs/platform/agent-skills.md +25 -0
- package/template/package.json +4 -3
- package/template/packages/database/drizzle/0064_dsh_skills_diagnostics.sql +42 -0
- package/template/packages/database/drizzle/meta/0064_snapshot.json +15349 -0
- package/template/packages/database/drizzle/meta/_journal.json +7 -0
- package/template/packages/database/package.json +2 -2
- package/template/packages/database/src/schema/agent-skills.ts +65 -0
- package/template/packages/database/src/schema/diagnostics.ts +27 -0
- package/template/packages/database/src/schema/index.ts +8 -0
- package/template/packages/modules/package.json +1 -1
- package/template/packages/modules/src/system-admin-routes.ts +24 -0
- package/template/packages/modules/src/system-admin-ui-catalog.ts +17 -10
- package/template/packages/modules/src/system-agent-admin-bindings.ts +2 -0
- package/template/packages/modules/src/system-agent-admin-menus.ts +20 -0
- package/template/packages/modules/src/system-agent-audit-actions.ts +3 -0
- package/template/packages/modules/src/system-agent-dsh.ts +119 -0
- package/template/packages/modules/src/system-api-permissions.ts +9 -0
- package/template/packages/modules/src/system-audit-actions.ts +11 -0
- package/template/packages/modules/src/system-features.ts +5 -0
- package/template/packages/modules/src/system-module-audit-selection.ts +25 -0
- package/template/packages/modules/src/system-module-catalog.ts +12 -32
- package/template/packages/modules/src/system-modules.ts +14 -3
- package/template/packages/modules/src/system-permissions.ts +10 -0
- package/template/packages/server-sdk/package.json +2 -2
- package/template/packages/shared/index.ts +12 -0
- package/template/packages/shared/package.json +1 -1
- package/template/packages/shared/src/agent-skills.ts +68 -0
- package/template/packages/shared/src/agent-workflow-presets.ts +26 -0
- package/template/packages/shared/src/diagnostics.ts +13 -0
- package/template/packages/shared/src/rbac.ts +1 -0
- package/template/apps/agent-server/install-python-dependencies.sh +0 -92
- package/template/apps/agent-server/pyproject.toml +0 -51
- package/template/apps/agent-server/src/southwind_agent_server/__init__.py +0 -5
- package/template/apps/agent-server/src/southwind_agent_server/app.py +0 -344
- package/template/apps/agent-server/src/southwind_agent_server/approval_resolution.py +0 -30
- package/template/apps/agent-server/src/southwind_agent_server/artifact_input.py +0 -153
- package/template/apps/agent-server/src/southwind_agent_server/asgi.py +0 -8
- package/template/apps/agent-server/src/southwind_agent_server/attempt_context.py +0 -199
- package/template/apps/agent-server/src/southwind_agent_server/attempt_context_projection.py +0 -203
- package/template/apps/agent-server/src/southwind_agent_server/client_completion_contracts.py +0 -61
- package/template/apps/agent-server/src/southwind_agent_server/client_completion_governance.py +0 -82
- package/template/apps/agent-server/src/southwind_agent_server/client_completion_routes.py +0 -121
- package/template/apps/agent-server/src/southwind_agent_server/client_completion_runtime.py +0 -158
- package/template/apps/agent-server/src/southwind_agent_server/config.py +0 -267
- package/template/apps/agent-server/src/southwind_agent_server/context_message_digest.py +0 -24
- package/template/apps/agent-server/src/southwind_agent_server/context_version_contracts.py +0 -71
- package/template/apps/agent-server/src/southwind_agent_server/context_version_port.py +0 -307
- package/template/apps/agent-server/src/southwind_agent_server/contracts.py +0 -297
- package/template/apps/agent-server/src/southwind_agent_server/deterministic.py +0 -63
- package/template/apps/agent-server/src/southwind_agent_server/engine.py +0 -134
- package/template/apps/agent-server/src/southwind_agent_server/engine_capacity.py +0 -31
- package/template/apps/agent-server/src/southwind_agent_server/engine_identity.py +0 -2
- package/template/apps/agent-server/src/southwind_agent_server/fingerprint.py +0 -61
- package/template/apps/agent-server/src/southwind_agent_server/health_routes.py +0 -93
- package/template/apps/agent-server/src/southwind_agent_server/http_helpers.py +0 -62
- package/template/apps/agent-server/src/southwind_agent_server/lease.py +0 -15
- package/template/apps/agent-server/src/southwind_agent_server/multimodal.py +0 -76
- package/template/apps/agent-server/src/southwind_agent_server/openai_engine.py +0 -329
- package/template/apps/agent-server/src/southwind_agent_server/openai_engine_validation.py +0 -165
- package/template/apps/agent-server/src/southwind_agent_server/openai_provider.py +0 -345
- package/template/apps/agent-server/src/southwind_agent_server/postgres_report_insert.py +0 -37
- package/template/apps/agent-server/src/southwind_agent_server/postgres_report_queries.py +0 -235
- package/template/apps/agent-server/src/southwind_agent_server/postgres_report_replay.py +0 -44
- package/template/apps/agent-server/src/southwind_agent_server/postgres_report_status.py +0 -83
- package/template/apps/agent-server/src/southwind_agent_server/postgres_report_store.py +0 -336
- package/template/apps/agent-server/src/southwind_agent_server/postgres_report_summary.py +0 -304
- package/template/apps/agent-server/src/southwind_agent_server/postgres_store.py +0 -335
- package/template/apps/agent-server/src/southwind_agent_server/postgres_store_backend.py +0 -333
- package/template/apps/agent-server/src/southwind_agent_server/provider_audit.py +0 -144
- package/template/apps/agent-server/src/southwind_agent_server/provider_governance.py +0 -309
- package/template/apps/agent-server/src/southwind_agent_server/provider_output_guidance.py +0 -34
- package/template/apps/agent-server/src/southwind_agent_server/readiness_pin.py +0 -37
- package/template/apps/agent-server/src/southwind_agent_server/report_lifecycle.py +0 -218
- package/template/apps/agent-server/src/southwind_agent_server/report_metrics.py +0 -149
- package/template/apps/agent-server/src/southwind_agent_server/report_presenter.py +0 -300
- package/template/apps/agent-server/src/southwind_agent_server/report_routes.py +0 -132
- package/template/apps/agent-server/src/southwind_agent_server/report_store.py +0 -298
- package/template/apps/agent-server/src/southwind_agent_server/report_store_protocol.py +0 -75
- package/template/apps/agent-server/src/southwind_agent_server/report_types.py +0 -118
- package/template/apps/agent-server/src/southwind_agent_server/run_admission.py +0 -64
- package/template/apps/agent-server/src/southwind_agent_server/run_capacity.py +0 -59
- package/template/apps/agent-server/src/southwind_agent_server/runtime_budget.py +0 -74
- package/template/apps/agent-server/src/southwind_agent_server/runtime_compatibility.py +0 -89
- package/template/apps/agent-server/src/southwind_agent_server/runtime_factory.py +0 -105
- package/template/apps/agent-server/src/southwind_agent_server/runtime_logging.py +0 -57
- package/template/apps/agent-server/src/southwind_agent_server/service.py +0 -325
- package/template/apps/agent-server/src/southwind_agent_server/service_control.py +0 -64
- package/template/apps/agent-server/src/southwind_agent_server/service_errors.py +0 -4
- package/template/apps/agent-server/src/southwind_agent_server/service_execution.py +0 -34
- package/template/apps/agent-server/src/southwind_agent_server/service_tasks.py +0 -34
- package/template/apps/agent-server/src/southwind_agent_server/signal_events.py +0 -53
- package/template/apps/agent-server/src/southwind_agent_server/sqlite_catalog.py +0 -118
- package/template/apps/agent-server/src/southwind_agent_server/sqlite_errors.py +0 -2
- package/template/apps/agent-server/src/southwind_agent_server/sqlite_schema.py +0 -73
- package/template/apps/agent-server/src/southwind_agent_server/sqlite_serialization.py +0 -16
- package/template/apps/agent-server/src/southwind_agent_server/sqlite_store.py +0 -350
- package/template/apps/agent-server/src/southwind_agent_server/sse.py +0 -41
- package/template/apps/agent-server/src/southwind_agent_server/store.py +0 -255
- package/template/apps/agent-server/src/southwind_agent_server/store_cipher.py +0 -40
- package/template/apps/agent-server/src/southwind_agent_server/structured_logging.py +0 -145
- package/template/apps/agent-server/src/southwind_agent_server/telemetry.py +0 -93
- package/template/apps/agent-server/src/southwind_agent_server/tool_host.py +0 -152
- package/template/apps/agent-server/src/southwind_agent_server/trajectory.py +0 -137
- package/template/apps/agent-server/src/southwind_agent_server/unavailable_engine.py +0 -58
- package/template/apps/agent-server/src/southwind_agent_server/vision_probe.py +0 -87
- package/template/apps/agent-server/src/southwind_agent_server/vision_requirement.py +0 -28
- package/template/apps/agent-server/src/southwind_agent_server/vlm_readiness.py +0 -247
- package/template/apps/agent-server/tests/__init__.py +0 -1
- package/template/apps/agent-server/tests/openai_provider_test_support.py +0 -131
- package/template/apps/agent-server/tests/test_api.py +0 -305
- package/template/apps/agent-server/tests/test_artifact_input.py +0 -110
- package/template/apps/agent-server/tests/test_client_completion.py +0 -230
- package/template/apps/agent-server/tests/test_config.py +0 -106
- package/template/apps/agent-server/tests/test_fingerprint.py +0 -10
- package/template/apps/agent-server/tests/test_multimodal.py +0 -81
- package/template/apps/agent-server/tests/test_openai_provider.py +0 -320
- package/template/apps/agent-server/tests/test_postgres_report_status.py +0 -59
- package/template/apps/agent-server/tests/test_postgres_report_summary.py +0 -298
- package/template/apps/agent-server/tests/test_postgres_store.py +0 -135
- package/template/apps/agent-server/tests/test_provider_attempt_reporting.py +0 -140
- package/template/apps/agent-server/tests/test_provider_governance.py +0 -276
- package/template/apps/agent-server/tests/test_report_attempt_lifecycle.py +0 -126
- package/template/apps/agent-server/tests/test_report_resilience.py +0 -183
- package/template/apps/agent-server/tests/test_report_routes.py +0 -143
- package/template/apps/agent-server/tests/test_report_store.py +0 -347
- package/template/apps/agent-server/tests/test_report_summary_parity.py +0 -116
- package/template/apps/agent-server/tests/test_report_terminal_sync.py +0 -177
- package/template/apps/agent-server/tests/test_run_capacity.py +0 -112
- package/template/apps/agent-server/tests/test_run_operational_logging.py +0 -114
- package/template/apps/agent-server/tests/test_runtime_compatibility.py +0 -119
- package/template/apps/agent-server/tests/test_runtime_factory_readiness.py +0 -52
- package/template/apps/agent-server/tests/test_sqlite_store.py +0 -182
- package/template/apps/agent-server/tests/test_structured_logging.py +0 -142
- package/template/apps/agent-server/tests/test_telemetry.py +0 -25
- package/template/apps/agent-server/tests/test_tool_approval.py +0 -28
- package/template/apps/agent-server/tests/test_tool_structured_output.py +0 -347
- package/template/apps/agent-server/tests/test_trajectory.py +0 -91
- package/template/apps/agent-server/tests/test_vision_readiness_enforcement.py +0 -72
- package/template/apps/agent-server/tests/test_vlm_readiness.py +0 -106
- package/template/apps/agent-server/uv.lock +0 -831
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { test } from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { runtime } from "./runtime-test-fixtures.js";
|
|
4
|
+
|
|
5
|
+
function completion(tools: unknown[]) {
|
|
6
|
+
return new Request("http://runtime/internal/boundary/v1/chat/completions", {
|
|
7
|
+
method: "POST",
|
|
8
|
+
body: JSON.stringify({
|
|
9
|
+
stream: true,
|
|
10
|
+
messages: [
|
|
11
|
+
{
|
|
12
|
+
role: "system",
|
|
13
|
+
content: "最终答案必须只包含符合以下 JSON Schema",
|
|
14
|
+
},
|
|
15
|
+
{ role: "user", content: "Synthetic test only" },
|
|
16
|
+
],
|
|
17
|
+
tools,
|
|
18
|
+
}),
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const authority = () => ({
|
|
23
|
+
actorId: "fixture-user",
|
|
24
|
+
signal: AbortSignal.timeout(5000),
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const fixtureTools = (count: number) =>
|
|
28
|
+
Array.from({ length: count }, (_, index) => ({
|
|
29
|
+
type: "function",
|
|
30
|
+
function: {
|
|
31
|
+
name: `mcp__windy__fixture_${index}`,
|
|
32
|
+
description: "业务工具 test.count (synthetic)",
|
|
33
|
+
parameters: { type: "object", properties: {} },
|
|
34
|
+
},
|
|
35
|
+
}));
|
|
36
|
+
|
|
37
|
+
test("native workbench admits the full authorized MCP inventory plus local DSH tools", async () => {
|
|
38
|
+
const handler = runtime();
|
|
39
|
+
// Current product MCP exposes 76 query tools; native DSH adds its own tools.
|
|
40
|
+
try {
|
|
41
|
+
const response = await handler.handleNativeCompletion(
|
|
42
|
+
completion(fixtureTools(96)),
|
|
43
|
+
authority(),
|
|
44
|
+
);
|
|
45
|
+
assert.equal(response.status, 200, await response.clone().text());
|
|
46
|
+
assert.match(await response.text(), /tool_calls/);
|
|
47
|
+
} finally {
|
|
48
|
+
await handler.close();
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test("native inventory remains bounded", async () => {
|
|
53
|
+
const handler = runtime();
|
|
54
|
+
try {
|
|
55
|
+
const response = await handler.handleNativeCompletion(
|
|
56
|
+
completion(fixtureTools(129)),
|
|
57
|
+
authority(),
|
|
58
|
+
);
|
|
59
|
+
assert.equal(response.status, 400);
|
|
60
|
+
assert.equal((await response.json()).code, "INVALID_INPUT");
|
|
61
|
+
} finally {
|
|
62
|
+
await handler.close();
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
test("malformed native completion reports invalid input without leaking payloads", async () => {
|
|
67
|
+
const handler = runtime();
|
|
68
|
+
try {
|
|
69
|
+
const response = await handler.handleNativeCompletion(
|
|
70
|
+
completion([{ type: "function", function: { name: "invalid.name" } }]),
|
|
71
|
+
authority(),
|
|
72
|
+
);
|
|
73
|
+
assert.equal(response.status, 400);
|
|
74
|
+
const body = await response.json();
|
|
75
|
+
assert.equal(body.code, "INVALID_INPUT");
|
|
76
|
+
assert.equal(body.retryable, false);
|
|
77
|
+
assert.doesNotMatch(JSON.stringify(body), /invalid\.name|Synthetic/);
|
|
78
|
+
} finally {
|
|
79
|
+
await handler.close();
|
|
80
|
+
}
|
|
81
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { ENGINE_ID } from "./compatibility.js";
|
|
2
|
+
import Ajv, { type ErrorObject } from "ajv";
|
|
3
|
+
import { SafeError } from "./contracts.js";
|
|
4
|
+
export interface OutputValidationContext {
|
|
5
|
+
runId: string;
|
|
6
|
+
operationKey: string;
|
|
7
|
+
outputSchemaKey: string;
|
|
8
|
+
}
|
|
9
|
+
function safePath(value: string): string {
|
|
10
|
+
return value
|
|
11
|
+
.split("/")
|
|
12
|
+
.slice(0, 16)
|
|
13
|
+
.map((segment) =>
|
|
14
|
+
/^(?:#|[A-Za-z_$][A-Za-z0-9_$-]{0,63}|[0-9]{1,5})$/.test(segment) ||
|
|
15
|
+
!segment
|
|
16
|
+
? segment
|
|
17
|
+
: "[field]",
|
|
18
|
+
)
|
|
19
|
+
.join("/")
|
|
20
|
+
.slice(0, 512);
|
|
21
|
+
}
|
|
22
|
+
export function validateStructuredOutput(
|
|
23
|
+
raw: string,
|
|
24
|
+
schema: Record<string, unknown>,
|
|
25
|
+
context: OutputValidationContext,
|
|
26
|
+
log: (value: string) => void = console.warn,
|
|
27
|
+
): unknown {
|
|
28
|
+
const failed = (validationKind: string, error?: ErrorObject): never => {
|
|
29
|
+
log(
|
|
30
|
+
JSON.stringify({
|
|
31
|
+
event: "agent.output.validation.failed",
|
|
32
|
+
engineId: ENGINE_ID,
|
|
33
|
+
runId: context.runId,
|
|
34
|
+
operationKey: context.operationKey.slice(0, 200),
|
|
35
|
+
outputSchemaKey: context.outputSchemaKey.slice(0, 200),
|
|
36
|
+
validationKind,
|
|
37
|
+
...(error
|
|
38
|
+
? {
|
|
39
|
+
keyword: error.keyword,
|
|
40
|
+
instancePath: safePath(error.instancePath),
|
|
41
|
+
schemaPath: safePath(error.schemaPath),
|
|
42
|
+
}
|
|
43
|
+
: {}),
|
|
44
|
+
}),
|
|
45
|
+
);
|
|
46
|
+
throw new SafeError("OUTPUT_VALIDATION_FAILED", "模型输出未通过格式校验");
|
|
47
|
+
};
|
|
48
|
+
let value: unknown;
|
|
49
|
+
try {
|
|
50
|
+
value = JSON.parse(raw);
|
|
51
|
+
} catch {
|
|
52
|
+
return failed("json-syntax");
|
|
53
|
+
}
|
|
54
|
+
let validate;
|
|
55
|
+
try {
|
|
56
|
+
validate = new Ajv({
|
|
57
|
+
strict: false,
|
|
58
|
+
allErrors: false,
|
|
59
|
+
validateFormats: false,
|
|
60
|
+
}).compile(schema);
|
|
61
|
+
} catch {
|
|
62
|
+
return failed("schema-definition");
|
|
63
|
+
}
|
|
64
|
+
if (!validate(value)) return failed("schema-instance", validate.errors?.[0]);
|
|
65
|
+
return value;
|
|
66
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { test } from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import {
|
|
4
|
+
runtime,
|
|
5
|
+
request,
|
|
6
|
+
input,
|
|
7
|
+
providerCalls,
|
|
8
|
+
} from "./runtime-test-fixtures.js";
|
|
9
|
+
|
|
10
|
+
test("single-slot production capacity accepts consecutive completed canonical runs", async () => {
|
|
11
|
+
const handler = runtime({
|
|
12
|
+
AI_PROVIDER_MAX_CONCURRENT_RUNS: "1",
|
|
13
|
+
AI_PROVIDER_MAX_QUEUE_DEPTH: "0",
|
|
14
|
+
});
|
|
15
|
+
try {
|
|
16
|
+
for (let i = 0; i < 10; i++) {
|
|
17
|
+
const started = await handler(
|
|
18
|
+
request("/api/agent/runs", "POST", input(), `consecutive-${i}`),
|
|
19
|
+
);
|
|
20
|
+
assert.equal(
|
|
21
|
+
started?.status,
|
|
22
|
+
200,
|
|
23
|
+
`run ${i}: ${started?.status === 200 ? "ok" : await started?.text()}`,
|
|
24
|
+
);
|
|
25
|
+
const run = (await started!.json()) as { eventsUrl: string };
|
|
26
|
+
assert.match(
|
|
27
|
+
await (await handler(request(run.eventsUrl)))!.text(),
|
|
28
|
+
/event: run.completed/,
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
} finally {
|
|
32
|
+
await handler.close();
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test("failed and cancelled runs release their slot before announcing terminal state", async () => {
|
|
37
|
+
const handler = runtime({
|
|
38
|
+
AI_PROVIDER_MAX_CONCURRENT_RUNS: "1",
|
|
39
|
+
AI_PROVIDER_MAX_QUEUE_DEPTH: "0",
|
|
40
|
+
});
|
|
41
|
+
try {
|
|
42
|
+
for (const kind of ["failed", "cancelled"] as const) {
|
|
43
|
+
const body = input();
|
|
44
|
+
if (kind === "failed") body.providerDataPolicy.envelopeFields = [];
|
|
45
|
+
else body.userPrompt = "hold-model";
|
|
46
|
+
const started = await handler(
|
|
47
|
+
request("/api/agent/runs", "POST", body, kind),
|
|
48
|
+
);
|
|
49
|
+
assert.equal(started?.status, 200);
|
|
50
|
+
const run = (await started!.json()) as {
|
|
51
|
+
runId: string;
|
|
52
|
+
eventsUrl: string;
|
|
53
|
+
};
|
|
54
|
+
if (kind === "cancelled")
|
|
55
|
+
await handler(
|
|
56
|
+
request(`/api/agent/runs/${run.runId}/cancel`, "POST", {}),
|
|
57
|
+
);
|
|
58
|
+
assert.match(
|
|
59
|
+
await (await handler(request(run.eventsUrl)))!.text(),
|
|
60
|
+
new RegExp(`event: run.${kind}`),
|
|
61
|
+
);
|
|
62
|
+
const next = await handler(
|
|
63
|
+
request("/api/agent/runs", "POST", input(), `after-${kind}`),
|
|
64
|
+
);
|
|
65
|
+
assert.equal(next?.status, 200);
|
|
66
|
+
const following = (await next!.json()) as { eventsUrl: string };
|
|
67
|
+
assert.match(
|
|
68
|
+
await (await handler(request(following.eventsUrl)))!.text(),
|
|
69
|
+
/event: run.completed/,
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
} finally {
|
|
73
|
+
await handler.close();
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
test("an active run still blocks a second run with no queue and retains one physical model call", async () => {
|
|
78
|
+
const callsBefore = providerCalls;
|
|
79
|
+
const handler = runtime({
|
|
80
|
+
AI_PROVIDER_MAX_CONCURRENT_RUNS: "1",
|
|
81
|
+
AI_PROVIDER_MAX_QUEUE_DEPTH: "0",
|
|
82
|
+
});
|
|
83
|
+
try {
|
|
84
|
+
const body = input();
|
|
85
|
+
body.userPrompt = "hold-model";
|
|
86
|
+
const started = await handler(
|
|
87
|
+
request("/api/agent/runs", "POST", body, "active"),
|
|
88
|
+
);
|
|
89
|
+
const run = (await started!.json()) as { eventsUrl: string };
|
|
90
|
+
let activeCalls = 0;
|
|
91
|
+
for (let attempt = 0; attempt < 100 && activeCalls === 0; attempt++) {
|
|
92
|
+
const health = (await (await handler(
|
|
93
|
+
request("/health/ready"),
|
|
94
|
+
))!.json()) as {
|
|
95
|
+
activeModelCalls: number;
|
|
96
|
+
};
|
|
97
|
+
activeCalls = health.activeModelCalls;
|
|
98
|
+
if (!activeCalls) await new Promise((resolve) => setTimeout(resolve, 5));
|
|
99
|
+
}
|
|
100
|
+
assert.equal(activeCalls, 1);
|
|
101
|
+
const denied = await handler(
|
|
102
|
+
request("/api/agent/runs", "POST", input(), "while-active"),
|
|
103
|
+
);
|
|
104
|
+
assert.equal(denied?.status, 429);
|
|
105
|
+
assert.equal(
|
|
106
|
+
((await denied!.json()) as { code: string }).code,
|
|
107
|
+
"BUDGET_EXCEEDED",
|
|
108
|
+
);
|
|
109
|
+
assert.match(
|
|
110
|
+
await (await handler(request(run.eventsUrl)))!.text(),
|
|
111
|
+
/event: run.completed/,
|
|
112
|
+
);
|
|
113
|
+
const idle = (await (await handler(request("/health/ready")))!.json()) as {
|
|
114
|
+
activeModelCalls: number;
|
|
115
|
+
};
|
|
116
|
+
assert.equal(idle.activeModelCalls, 0);
|
|
117
|
+
assert.equal(providerCalls - callsBefore, 1);
|
|
118
|
+
} finally {
|
|
119
|
+
await handler.close();
|
|
120
|
+
}
|
|
121
|
+
});
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { test } from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { mkdtemp, mkdir, readFile, realpath, rm } from "node:fs/promises";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import { Context } from "@deepseek-ai/cordis";
|
|
7
|
+
import AgentRegistry from "@deepseek-ai/dsh-agent";
|
|
8
|
+
import AgentLoop from "@deepseek-ai/dsh-agent-loop";
|
|
9
|
+
import SessionStore, { SessionId } from "@deepseek-ai/dsh-session";
|
|
10
|
+
import SessionProjections from "@deepseek-ai/dsh-session-projection";
|
|
11
|
+
import LlmRuntime, {
|
|
12
|
+
LlmAdapter,
|
|
13
|
+
MessageId,
|
|
14
|
+
ToolCallId,
|
|
15
|
+
type GenerateOptions,
|
|
16
|
+
type StreamChunk,
|
|
17
|
+
} from "@deepseek-ai/dsh-llm";
|
|
18
|
+
import ToolRuntime from "@deepseek-ai/dsh-tools";
|
|
19
|
+
import SystemPrompt from "@deepseek-ai/dsh-system-prompt";
|
|
20
|
+
import UserQuestions from "@deepseek-ai/dsh-user-questions";
|
|
21
|
+
import * as AskUser from "@deepseek-ai/dsh-tool-ask-user";
|
|
22
|
+
import { createQuestionBridge } from "../plugins/questions.mjs";
|
|
23
|
+
import { registerWorkflowTool } from "../plugins/skill-library/workflow.mjs";
|
|
24
|
+
import type { SkillContext } from "../plugins/skill-library/index.mjs";
|
|
25
|
+
|
|
26
|
+
class ScenarioModel extends LlmAdapter {
|
|
27
|
+
calls = 0;
|
|
28
|
+
results: unknown[] = [];
|
|
29
|
+
constructor(
|
|
30
|
+
readonly tool: string,
|
|
31
|
+
readonly args: object,
|
|
32
|
+
) {
|
|
33
|
+
super();
|
|
34
|
+
}
|
|
35
|
+
override async *stream(
|
|
36
|
+
options: GenerateOptions,
|
|
37
|
+
): AsyncGenerator<StreamChunk> {
|
|
38
|
+
options.signal?.throwIfAborted();
|
|
39
|
+
if (++this.calls === 1) {
|
|
40
|
+
const call = {
|
|
41
|
+
type: "tool-call" as const,
|
|
42
|
+
id: ToolCallId("scenario-call"),
|
|
43
|
+
name: this.tool,
|
|
44
|
+
arguments: JSON.stringify(this.args),
|
|
45
|
+
};
|
|
46
|
+
yield { type: "block-start", index: 0, blockType: "tool-call" };
|
|
47
|
+
yield {
|
|
48
|
+
type: "tool-call-delta",
|
|
49
|
+
index: 0,
|
|
50
|
+
id: call.id,
|
|
51
|
+
name: call.name,
|
|
52
|
+
argumentsDelta: call.arguments,
|
|
53
|
+
};
|
|
54
|
+
yield { type: "block-end", index: 0, block: call };
|
|
55
|
+
yield { type: "finish", reason: { kind: "tool-calls" } };
|
|
56
|
+
} else {
|
|
57
|
+
this.results = options.messages.filter(
|
|
58
|
+
(message) => message.role === "tool",
|
|
59
|
+
);
|
|
60
|
+
yield { type: "block-start", index: 0, blockType: "text" };
|
|
61
|
+
yield {
|
|
62
|
+
type: "text-delta",
|
|
63
|
+
index: 0,
|
|
64
|
+
text: "已根据用户确认继续完成合成测试。",
|
|
65
|
+
};
|
|
66
|
+
yield {
|
|
67
|
+
type: "block-end",
|
|
68
|
+
index: 0,
|
|
69
|
+
block: { type: "text", text: "已根据用户确认继续完成合成测试。" },
|
|
70
|
+
};
|
|
71
|
+
yield { type: "finish", reason: { kind: "stop" } };
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async function scenario(tool: string, args: object, skillRoot?: string) {
|
|
77
|
+
const ctx = new Context();
|
|
78
|
+
const fibers: { dispose(): Promise<void> }[] = [];
|
|
79
|
+
const bridge = createQuestionBridge();
|
|
80
|
+
let ready!: () => void;
|
|
81
|
+
const asked = new Promise<void>((done) => {
|
|
82
|
+
ready = done;
|
|
83
|
+
});
|
|
84
|
+
for (const plugin of [
|
|
85
|
+
LlmRuntime,
|
|
86
|
+
SessionStore,
|
|
87
|
+
SessionProjections,
|
|
88
|
+
AgentRegistry,
|
|
89
|
+
ToolRuntime,
|
|
90
|
+
UserQuestions,
|
|
91
|
+
])
|
|
92
|
+
fibers.push(await ctx.plugin(plugin));
|
|
93
|
+
fibers.push(
|
|
94
|
+
await ctx.plugin(SystemPrompt, {
|
|
95
|
+
includeHarnessIdentity: false,
|
|
96
|
+
includeRuntimeContext: false,
|
|
97
|
+
}),
|
|
98
|
+
);
|
|
99
|
+
fibers.push(
|
|
100
|
+
await ctx.plugin(AgentLoop, { maxParallelToolCalls: 1, agents: [] }),
|
|
101
|
+
);
|
|
102
|
+
fibers.push(await ctx.plugin(AskUser));
|
|
103
|
+
ctx.on(
|
|
104
|
+
"user-questions/request",
|
|
105
|
+
(request, next) => {
|
|
106
|
+
const waiting = bridge.ask(request, next);
|
|
107
|
+
ready();
|
|
108
|
+
return waiting;
|
|
109
|
+
},
|
|
110
|
+
{ prepend: true },
|
|
111
|
+
);
|
|
112
|
+
if (skillRoot) {
|
|
113
|
+
const root = join(skillRoot, "owner"),
|
|
114
|
+
defaults = join(skillRoot, "defaults");
|
|
115
|
+
await mkdir(root);
|
|
116
|
+
await mkdir(defaults);
|
|
117
|
+
const host: SkillContext = {
|
|
118
|
+
tools: ctx.tools,
|
|
119
|
+
userQuestions: ctx.userQuestions,
|
|
120
|
+
workingDirectory: { get: () => root },
|
|
121
|
+
sandboxPolicy: { workspaceRoot: root },
|
|
122
|
+
workspaceRegistry: {
|
|
123
|
+
get: () => ({ path: root }),
|
|
124
|
+
list: () => [{ id: "owned-workspace", path: root }],
|
|
125
|
+
},
|
|
126
|
+
effect: (effect) => {
|
|
127
|
+
ctx.effect(() => {
|
|
128
|
+
const dispose = effect();
|
|
129
|
+
return () => {
|
|
130
|
+
if (typeof dispose === "function") dispose();
|
|
131
|
+
};
|
|
132
|
+
});
|
|
133
|
+
},
|
|
134
|
+
on() {},
|
|
135
|
+
connection: { requestRejection: () => undefined },
|
|
136
|
+
webServer: { register: () => () => {} },
|
|
137
|
+
};
|
|
138
|
+
registerWorkflowTool(host, { enabled: true, defaultSkillDir: defaults });
|
|
139
|
+
}
|
|
140
|
+
const model = new ScenarioModel(tool, args);
|
|
141
|
+
ctx.llm.registerAdapter(["synthetic"], model);
|
|
142
|
+
const handle = await ctx.agents.create({
|
|
143
|
+
sessionId: SessionId("scenario-session"),
|
|
144
|
+
signal: AbortSignal.timeout(10000),
|
|
145
|
+
agentOptions: {
|
|
146
|
+
provider: "synthetic",
|
|
147
|
+
model: "scenario-model",
|
|
148
|
+
maxTokens: 2048,
|
|
149
|
+
},
|
|
150
|
+
});
|
|
151
|
+
handle.agent.followup({
|
|
152
|
+
id: MessageId("scenario-prompt"),
|
|
153
|
+
role: "user",
|
|
154
|
+
source: { kind: "user" },
|
|
155
|
+
content: [{ type: "text", text: "请按合成测试场景处理" }],
|
|
156
|
+
});
|
|
157
|
+
const pendingQuestion = Promise.race([
|
|
158
|
+
asked,
|
|
159
|
+
handle.agent.whenIdle().then(() => {
|
|
160
|
+
throw new Error(
|
|
161
|
+
`Scenario ended without a question: ${JSON.stringify(handle.agent.session.snapshotEvents())}`,
|
|
162
|
+
);
|
|
163
|
+
}),
|
|
164
|
+
]);
|
|
165
|
+
return {
|
|
166
|
+
ctx,
|
|
167
|
+
bridge,
|
|
168
|
+
model,
|
|
169
|
+
handle,
|
|
170
|
+
asked: pendingQuestion,
|
|
171
|
+
async close() {
|
|
172
|
+
bridge.close();
|
|
173
|
+
await handle.dispose();
|
|
174
|
+
for (const fiber of fibers.reverse()) await fiber.dispose();
|
|
175
|
+
},
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
test("official DSH Loop asks options, waits without a second model call, accepts floating reply and continues", async () => {
|
|
180
|
+
const f = await scenario("ask_user_question", {
|
|
181
|
+
questions: [
|
|
182
|
+
{
|
|
183
|
+
id: "format",
|
|
184
|
+
question: "生成哪种报告?",
|
|
185
|
+
options: [{ label: "HTML" }, { label: "PPT" }],
|
|
186
|
+
},
|
|
187
|
+
],
|
|
188
|
+
});
|
|
189
|
+
try {
|
|
190
|
+
await f.asked;
|
|
191
|
+
const [question] = f.bridge.list("scenario-session");
|
|
192
|
+
assert.equal(f.model.calls, 1);
|
|
193
|
+
assert.equal(question?.questions[0]?.question, "生成哪种报告?");
|
|
194
|
+
f.bridge.answer("scenario-session", question!.id, {
|
|
195
|
+
answers: [{ id: "format", selected: ["HTML"] }],
|
|
196
|
+
});
|
|
197
|
+
await f.handle.agent.whenIdle();
|
|
198
|
+
assert.equal(f.model.calls, 2);
|
|
199
|
+
assert.match(JSON.stringify(f.model.results), /HTML/);
|
|
200
|
+
assert.equal(f.bridge.list("scenario-session").length, 0);
|
|
201
|
+
const end = f.handle.agent.session
|
|
202
|
+
.snapshotEvents()
|
|
203
|
+
.filter((event) => event.type === "turn/end")
|
|
204
|
+
.at(-1);
|
|
205
|
+
assert.equal(end?.data.reason.kind, "completed");
|
|
206
|
+
} finally {
|
|
207
|
+
await f.close();
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
test("official DSH Loop reviews Chinese named workflow, persists confirmed skill and returns saved receipt to model", async () => {
|
|
212
|
+
const temporary = await realpath(
|
|
213
|
+
await mkdtemp(join(tmpdir(), "windy-skill-loop-")),
|
|
214
|
+
);
|
|
215
|
+
const f = await scenario(
|
|
216
|
+
"save_workflow_skill",
|
|
217
|
+
{
|
|
218
|
+
name: "每周案件简报",
|
|
219
|
+
description: "整理本次授权材料。",
|
|
220
|
+
workflow:
|
|
221
|
+
"输入:用户选择的材料。\n步骤:核对来源,整理简报,回读核验。\n输出:附来源的简报。",
|
|
222
|
+
},
|
|
223
|
+
temporary,
|
|
224
|
+
);
|
|
225
|
+
try {
|
|
226
|
+
await f.asked;
|
|
227
|
+
const [question] = f.bridge.list("scenario-session");
|
|
228
|
+
assert.match(question!.questions[0]!.detail!, /每周案件简报/);
|
|
229
|
+
assert.equal(f.model.calls, 1);
|
|
230
|
+
f.bridge.answer("scenario-session", question!.id, {
|
|
231
|
+
answers: [{ id: "save-skill", selected: ["保存个人技能"] }],
|
|
232
|
+
});
|
|
233
|
+
await f.handle.agent.whenIdle();
|
|
234
|
+
assert.equal(f.model.calls, 2);
|
|
235
|
+
assert.match(JSON.stringify(f.model.results), /saved/);
|
|
236
|
+
const draft = question!.questions[0]!.detail!;
|
|
237
|
+
const name = /^name: (.+)$/m.exec(draft)![1]!;
|
|
238
|
+
assert.equal(
|
|
239
|
+
await readFile(
|
|
240
|
+
join(temporary, "owner", ".dsh", "skills", name, "SKILL.md"),
|
|
241
|
+
"utf8",
|
|
242
|
+
),
|
|
243
|
+
draft,
|
|
244
|
+
);
|
|
245
|
+
} finally {
|
|
246
|
+
await f.close();
|
|
247
|
+
await rm(temporary, { recursive: true, force: true });
|
|
248
|
+
}
|
|
249
|
+
});
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { RuntimeStore, StoredRun } from "./store.js";
|
|
2
|
+
export function reportBreakdown(runs: StoredRun[], store: RuntimeStore) {
|
|
3
|
+
const byModel = new Map<
|
|
4
|
+
string,
|
|
5
|
+
{
|
|
6
|
+
deploymentKey: string;
|
|
7
|
+
model: string;
|
|
8
|
+
attempts: number;
|
|
9
|
+
inputTokens: number | null;
|
|
10
|
+
outputTokens: number | null;
|
|
11
|
+
cachedInputTokens: number | null;
|
|
12
|
+
reasoningTokens: number | null;
|
|
13
|
+
totalTokens: number | null;
|
|
14
|
+
unknownUsageCount: number;
|
|
15
|
+
}
|
|
16
|
+
>();
|
|
17
|
+
const activity = new Map<
|
|
18
|
+
string,
|
|
19
|
+
{
|
|
20
|
+
date: string;
|
|
21
|
+
runs: number;
|
|
22
|
+
completed: number;
|
|
23
|
+
failed: number;
|
|
24
|
+
totalTokens: number | null;
|
|
25
|
+
}
|
|
26
|
+
>();
|
|
27
|
+
for (const run of runs) {
|
|
28
|
+
const date = run.createdAt.slice(0, 10),
|
|
29
|
+
point = activity.get(date) ?? {
|
|
30
|
+
date,
|
|
31
|
+
runs: 0,
|
|
32
|
+
completed: 0,
|
|
33
|
+
failed: 0,
|
|
34
|
+
totalTokens: null,
|
|
35
|
+
};
|
|
36
|
+
point.runs++;
|
|
37
|
+
if (run.status === "completed") point.completed++;
|
|
38
|
+
if (run.status === "failed") point.failed++;
|
|
39
|
+
for (const attempt of store.attempts(run.id)) {
|
|
40
|
+
const deploymentKey = String(attempt.deploymentKey),
|
|
41
|
+
model = String(attempt.model),
|
|
42
|
+
key = `${deploymentKey}\0${model}`;
|
|
43
|
+
const group = byModel.get(key) ?? {
|
|
44
|
+
deploymentKey,
|
|
45
|
+
model,
|
|
46
|
+
attempts: 0,
|
|
47
|
+
inputTokens: null,
|
|
48
|
+
outputTokens: null,
|
|
49
|
+
cachedInputTokens: null,
|
|
50
|
+
reasoningTokens: null,
|
|
51
|
+
totalTokens: null,
|
|
52
|
+
unknownUsageCount: 0,
|
|
53
|
+
};
|
|
54
|
+
group.attempts++;
|
|
55
|
+
if (attempt.usageSource === "unknown") group.unknownUsageCount++;
|
|
56
|
+
for (const field of [
|
|
57
|
+
"inputTokens",
|
|
58
|
+
"outputTokens",
|
|
59
|
+
"cachedInputTokens",
|
|
60
|
+
"reasoningTokens",
|
|
61
|
+
"totalTokens",
|
|
62
|
+
] as const) {
|
|
63
|
+
const value = attempt[field];
|
|
64
|
+
if (typeof value === "number")
|
|
65
|
+
group[field] = (group[field] ?? 0) + value;
|
|
66
|
+
}
|
|
67
|
+
if (typeof attempt.totalTokens === "number")
|
|
68
|
+
point.totalTokens = (point.totalTokens ?? 0) + attempt.totalTokens;
|
|
69
|
+
byModel.set(key, group);
|
|
70
|
+
}
|
|
71
|
+
activity.set(date, point);
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
byModel: [...byModel.values()],
|
|
75
|
+
activity: [...activity.values()].sort((a, b) =>
|
|
76
|
+
a.date.localeCompare(b.date),
|
|
77
|
+
),
|
|
78
|
+
};
|
|
79
|
+
}
|