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,163 @@
|
|
|
1
|
+
import { Unzip, UnzipInflate } from "fflate";
|
|
2
|
+
import { AgentSkillError } from "./contracts.js";
|
|
3
|
+
export const SKILL_LIMITS = {
|
|
4
|
+
archive: 4 * 1024 * 1024,
|
|
5
|
+
total: 16 * 1024 * 1024,
|
|
6
|
+
file: 4 * 1024 * 1024,
|
|
7
|
+
markdown: 128 * 1024,
|
|
8
|
+
entries: 128,
|
|
9
|
+
};
|
|
10
|
+
function invalid(message: string, status = 400): never {
|
|
11
|
+
throw new AgentSkillError("SKILL_PACKAGE_INVALID", message, status);
|
|
12
|
+
}
|
|
13
|
+
export function skillPath(value: string): string {
|
|
14
|
+
if (
|
|
15
|
+
!value ||
|
|
16
|
+
value.length > 240 ||
|
|
17
|
+
value.includes("\\") ||
|
|
18
|
+
value.startsWith("/") ||
|
|
19
|
+
[...value].some(
|
|
20
|
+
(char) =>
|
|
21
|
+
char === ":" || char.charCodeAt(0) < 32 || char.charCodeAt(0) === 127,
|
|
22
|
+
)
|
|
23
|
+
)
|
|
24
|
+
invalid("技能包包含非法路径");
|
|
25
|
+
const parts = value.replace(/\/$/, "").split("/");
|
|
26
|
+
if (parts.some((part) => !part || part.startsWith(".") || part.length > 100))
|
|
27
|
+
invalid("技能包不能包含隐藏路径、父目录或空路径");
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
30
|
+
function inspectZip(bytes: Uint8Array) {
|
|
31
|
+
if (bytes.length > SKILL_LIMITS.archive || bytes.length < 22)
|
|
32
|
+
invalid("ZIP 超过 4 MiB 或格式无效", 413);
|
|
33
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
34
|
+
let end = bytes.length - 22;
|
|
35
|
+
while (
|
|
36
|
+
end >= Math.max(0, bytes.length - 65557) &&
|
|
37
|
+
view.getUint32(end, true) !== 0x06054b50
|
|
38
|
+
)
|
|
39
|
+
end--;
|
|
40
|
+
if (end < 0 || end < bytes.length - 65557) invalid("ZIP 目录无效");
|
|
41
|
+
const count = view.getUint16(end + 10, true),
|
|
42
|
+
start = view.getUint32(end + 16, true);
|
|
43
|
+
if (
|
|
44
|
+
view.getUint16(end + 4, true) ||
|
|
45
|
+
view.getUint16(end + 6, true) ||
|
|
46
|
+
count !== view.getUint16(end + 8, true) ||
|
|
47
|
+
!count ||
|
|
48
|
+
count > SKILL_LIMITS.entries ||
|
|
49
|
+
start + view.getUint32(end + 12, true) !== end ||
|
|
50
|
+
end + 22 + view.getUint16(end + 20, true) !== bytes.length
|
|
51
|
+
)
|
|
52
|
+
invalid("ZIP 文件数量或分卷格式不支持");
|
|
53
|
+
let cursor = start,
|
|
54
|
+
total = 0;
|
|
55
|
+
const names = new Map<string, { name: string; size: number }>();
|
|
56
|
+
for (let i = 0; i < count; i++) {
|
|
57
|
+
if (cursor + 46 > end || view.getUint32(cursor, true) !== 0x02014b50)
|
|
58
|
+
invalid("ZIP 目录损坏");
|
|
59
|
+
const size = view.getUint32(cursor + 24, true),
|
|
60
|
+
length = view.getUint16(cursor + 28, true),
|
|
61
|
+
extra = view.getUint16(cursor + 30, true),
|
|
62
|
+
comment = view.getUint16(cursor + 32, true);
|
|
63
|
+
const mode = (view.getUint32(cursor + 38, true) >>> 16) & 0xf000;
|
|
64
|
+
if (
|
|
65
|
+
cursor + 46 + length + extra + comment > end ||
|
|
66
|
+
view.getUint16(cursor + 8, true) & 1 ||
|
|
67
|
+
![0, 8].includes(view.getUint16(cursor + 10, true)) ||
|
|
68
|
+
![0, 0x8000, 0x4000].includes(mode)
|
|
69
|
+
)
|
|
70
|
+
invalid("ZIP 包含加密、特殊文件或不支持的压缩方式");
|
|
71
|
+
const name = skillPath(
|
|
72
|
+
new TextDecoder("utf-8", { fatal: true }).decode(
|
|
73
|
+
bytes.subarray(cursor + 46, cursor + 46 + length),
|
|
74
|
+
),
|
|
75
|
+
);
|
|
76
|
+
const key = name.replace(/\/$/, "").toLowerCase();
|
|
77
|
+
if (
|
|
78
|
+
names.has(key) ||
|
|
79
|
+
size > SKILL_LIMITS.file ||
|
|
80
|
+
(total += size) > SKILL_LIMITS.total
|
|
81
|
+
)
|
|
82
|
+
invalid("ZIP 路径重复或展开体积过大", 413);
|
|
83
|
+
names.set(key, { name, size });
|
|
84
|
+
cursor += 46 + length + extra + comment;
|
|
85
|
+
}
|
|
86
|
+
if (cursor !== end) invalid("ZIP 目录不完整");
|
|
87
|
+
return names;
|
|
88
|
+
}
|
|
89
|
+
export function decodeSkillZip(bytes: Uint8Array): Record<string, Uint8Array> {
|
|
90
|
+
const advertised = inspectZip(bytes),
|
|
91
|
+
files: Record<string, Uint8Array> = Object.create(null),
|
|
92
|
+
seen = new Set<string>();
|
|
93
|
+
let expanded = 0,
|
|
94
|
+
failure: Error | undefined;
|
|
95
|
+
const archive = new Unzip((entry) => {
|
|
96
|
+
const name = skillPath(entry.name),
|
|
97
|
+
known = advertised.get(name.replace(/\/$/, "").toLowerCase());
|
|
98
|
+
if (!known || known.name !== name || seen.has(name))
|
|
99
|
+
invalid("ZIP 本地目录与中央目录不一致");
|
|
100
|
+
seen.add(name);
|
|
101
|
+
const chunks: Uint8Array[] = [];
|
|
102
|
+
let size = 0;
|
|
103
|
+
entry.ondata = (error, chunk, final) => {
|
|
104
|
+
if (error) {
|
|
105
|
+
failure = error;
|
|
106
|
+
entry.terminate();
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
size += chunk.length;
|
|
110
|
+
expanded += chunk.length;
|
|
111
|
+
if (
|
|
112
|
+
size > known.size ||
|
|
113
|
+
size > SKILL_LIMITS.file ||
|
|
114
|
+
expanded > SKILL_LIMITS.total
|
|
115
|
+
) {
|
|
116
|
+
failure = new AgentSkillError(
|
|
117
|
+
"SKILL_PACKAGE_INVALID",
|
|
118
|
+
"ZIP 展开体积超限",
|
|
119
|
+
413,
|
|
120
|
+
);
|
|
121
|
+
entry.terminate();
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
chunks.push(chunk);
|
|
125
|
+
if (final && !name.endsWith("/")) {
|
|
126
|
+
if (size !== known.size) {
|
|
127
|
+
failure = new Error("ZIP 文件长度不一致");
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
const output = new Uint8Array(size);
|
|
131
|
+
let offset = 0;
|
|
132
|
+
for (const part of chunks) {
|
|
133
|
+
output.set(part, offset);
|
|
134
|
+
offset += part.length;
|
|
135
|
+
}
|
|
136
|
+
files[name] = output;
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
entry.start();
|
|
140
|
+
});
|
|
141
|
+
archive.register(UnzipInflate);
|
|
142
|
+
for (let offset = 0; offset < bytes.length; offset += 1024) {
|
|
143
|
+
archive.push(
|
|
144
|
+
bytes.subarray(offset, offset + 1024),
|
|
145
|
+
offset + 1024 >= bytes.length,
|
|
146
|
+
);
|
|
147
|
+
if (failure) throw failure;
|
|
148
|
+
}
|
|
149
|
+
if (seen.size !== advertised.size) invalid("ZIP 文件目录不完整");
|
|
150
|
+
const keys = Object.keys(files),
|
|
151
|
+
markdown = keys.filter(
|
|
152
|
+
(name) => name === "SKILL.md" || /^[^/]+\/SKILL\.md$/.test(name),
|
|
153
|
+
);
|
|
154
|
+
if (markdown.length !== 1) invalid("ZIP 必须只包含一个技能目录及其 SKILL.md");
|
|
155
|
+
const prefix = markdown[0]!.slice(0, -8),
|
|
156
|
+
result: Record<string, Uint8Array> = Object.create(null);
|
|
157
|
+
for (const key of keys) {
|
|
158
|
+
if (!key.startsWith(prefix) || key === prefix)
|
|
159
|
+
invalid("ZIP 含技能目录之外的文件");
|
|
160
|
+
result[skillPath(key.slice(prefix.length))] = files[key]!;
|
|
161
|
+
}
|
|
162
|
+
return result;
|
|
163
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import { zipSync, strToU8 } from "fflate";
|
|
3
|
+
import { parseSkillBundle } from "./bundle.js";
|
|
4
|
+
const markdown =
|
|
5
|
+
"---\nname: safe-query\ndescription: 安全查询\n---\n仅使用已授权工具。\n";
|
|
6
|
+
function archive(files: Record<string, Uint8Array>) {
|
|
7
|
+
return {
|
|
8
|
+
format: "zip" as const,
|
|
9
|
+
content: Buffer.from(zipSync(files)).toString("base64"),
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
describe("shared DSH skill import", () => {
|
|
13
|
+
test("imports one directory with binary attachments and a stable digest", () => {
|
|
14
|
+
const imported = parseSkillBundle(
|
|
15
|
+
archive({
|
|
16
|
+
"safe-query/SKILL.md": strToU8(markdown),
|
|
17
|
+
"safe-query/assets/sample.bin": Uint8Array.from([0, 1, 255]),
|
|
18
|
+
}),
|
|
19
|
+
);
|
|
20
|
+
expect(imported.name).toBe("safe-query");
|
|
21
|
+
expect(imported.files).toHaveLength(2);
|
|
22
|
+
expect(
|
|
23
|
+
imported.files.find((file) => file.path === "assets/sample.bin")
|
|
24
|
+
?.contentBase64,
|
|
25
|
+
).toBe("AAH/");
|
|
26
|
+
expect(
|
|
27
|
+
parseSkillBundle(
|
|
28
|
+
archive({
|
|
29
|
+
"safe-query/assets/sample.bin": Uint8Array.from([0, 1, 255]),
|
|
30
|
+
"safe-query/SKILL.md": strToU8(markdown),
|
|
31
|
+
}),
|
|
32
|
+
).digest,
|
|
33
|
+
).toBe(imported.digest);
|
|
34
|
+
});
|
|
35
|
+
test("rejects traversal, multiple skills and unrelated root files", () => {
|
|
36
|
+
const invalidBundles: Record<string, Uint8Array>[] = [
|
|
37
|
+
{ "../SKILL.md": strToU8(markdown) },
|
|
38
|
+
{ "a/SKILL.md": strToU8(markdown), "b/SKILL.md": strToU8(markdown) },
|
|
39
|
+
{
|
|
40
|
+
"safe-query/SKILL.md": strToU8(markdown),
|
|
41
|
+
"unrelated.txt": strToU8("x"),
|
|
42
|
+
},
|
|
43
|
+
];
|
|
44
|
+
for (const files of invalidBundles)
|
|
45
|
+
expect(() => parseSkillBundle(archive(files))).toThrow();
|
|
46
|
+
});
|
|
47
|
+
test("rejects duplicate YAML, malformed flags, invalid UTF-8 and oversized markdown", () => {
|
|
48
|
+
for (const content of [
|
|
49
|
+
markdown.replace("description:", "name: duplicate\ndescription:"),
|
|
50
|
+
markdown.replace("---\n仅", "user-invocable: yes\n---\n仅"),
|
|
51
|
+
`---\nname: safe-query\ndescription: 安全\n---\n${"x".repeat(128 * 1024)}`,
|
|
52
|
+
])
|
|
53
|
+
expect(() => parseSkillBundle({ format: "markdown", content })).toThrow();
|
|
54
|
+
expect(() =>
|
|
55
|
+
parseSkillBundle(archive({ "SKILL.md": Uint8Array.from([255, 255]) })),
|
|
56
|
+
).toThrow();
|
|
57
|
+
});
|
|
58
|
+
test("rejects Unix symlinks and advertised expanded-size bombs before decompression", () => {
|
|
59
|
+
const bytes = zipSync({ "SKILL.md": strToU8(markdown) });
|
|
60
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
61
|
+
let cursor = 0;
|
|
62
|
+
while (view.getUint32(cursor, true) !== 0x02014b50) cursor++;
|
|
63
|
+
view.setUint32(cursor + 38, 0xa1ff << 16, true);
|
|
64
|
+
expect(() =>
|
|
65
|
+
parseSkillBundle({
|
|
66
|
+
format: "zip",
|
|
67
|
+
content: Buffer.from(bytes).toString("base64"),
|
|
68
|
+
}),
|
|
69
|
+
).toThrow();
|
|
70
|
+
view.setUint32(cursor + 38, 0x81a4 << 16, true);
|
|
71
|
+
view.setUint32(cursor + 24, 0x7fffffff, true);
|
|
72
|
+
expect(() =>
|
|
73
|
+
parseSkillBundle({
|
|
74
|
+
format: "zip",
|
|
75
|
+
content: Buffer.from(bytes).toString("base64"),
|
|
76
|
+
}),
|
|
77
|
+
).toThrow();
|
|
78
|
+
});
|
|
79
|
+
});
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { parseDocument } from "yaml";
|
|
3
|
+
import type {
|
|
4
|
+
AgentSkillBundle,
|
|
5
|
+
ImportAgentSkillRequest,
|
|
6
|
+
} from "@southwind-ai/shared";
|
|
7
|
+
import { AgentSkillError } from "./contracts.js";
|
|
8
|
+
import { decodeSkillZip, SKILL_LIMITS } from "./bundle-zip.js";
|
|
9
|
+
export function skillKey(value: unknown): string {
|
|
10
|
+
if (
|
|
11
|
+
typeof value !== "string" ||
|
|
12
|
+
value.length > 64 ||
|
|
13
|
+
!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(value)
|
|
14
|
+
)
|
|
15
|
+
throw new AgentSkillError(
|
|
16
|
+
"SKILL_PACKAGE_INVALID",
|
|
17
|
+
"技能标识须为小写英文、数字和连字符,最长 64 字符",
|
|
18
|
+
);
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
export function parseSkillBundle(
|
|
22
|
+
input: Pick<ImportAgentSkillRequest, "format" | "content">,
|
|
23
|
+
): AgentSkillBundle {
|
|
24
|
+
if (typeof input.content !== "string")
|
|
25
|
+
throw new AgentSkillError(
|
|
26
|
+
"SKILL_PACKAGE_INVALID",
|
|
27
|
+
"请选择 SKILL.md 或 ZIP 文件",
|
|
28
|
+
);
|
|
29
|
+
let files: Record<string, Uint8Array>;
|
|
30
|
+
if (input.format === "markdown")
|
|
31
|
+
files = { "SKILL.md": new TextEncoder().encode(input.content) };
|
|
32
|
+
else if (input.format === "zip") {
|
|
33
|
+
if (
|
|
34
|
+
input.content.length > Math.ceil(SKILL_LIMITS.archive / 3) * 4 ||
|
|
35
|
+
!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(
|
|
36
|
+
input.content,
|
|
37
|
+
)
|
|
38
|
+
)
|
|
39
|
+
throw new AgentSkillError(
|
|
40
|
+
"SKILL_PACKAGE_INVALID",
|
|
41
|
+
"ZIP 编码或体积无效",
|
|
42
|
+
413,
|
|
43
|
+
);
|
|
44
|
+
files = decodeSkillZip(Buffer.from(input.content, "base64"));
|
|
45
|
+
} else
|
|
46
|
+
throw new AgentSkillError(
|
|
47
|
+
"SKILL_PACKAGE_INVALID",
|
|
48
|
+
"仅支持 SKILL.md 或 ZIP",
|
|
49
|
+
);
|
|
50
|
+
const markdown = files["SKILL.md"];
|
|
51
|
+
if (!markdown || markdown.length > SKILL_LIMITS.markdown)
|
|
52
|
+
throw new AgentSkillError(
|
|
53
|
+
"SKILL_PACKAGE_INVALID",
|
|
54
|
+
"SKILL.md 超过 128 KiB",
|
|
55
|
+
413,
|
|
56
|
+
);
|
|
57
|
+
let raw: string;
|
|
58
|
+
try {
|
|
59
|
+
raw = new TextDecoder("utf-8", { fatal: true }).decode(markdown);
|
|
60
|
+
} catch {
|
|
61
|
+
throw new AgentSkillError("SKILL_PACKAGE_INVALID", "SKILL.md 必须为 UTF-8");
|
|
62
|
+
}
|
|
63
|
+
const metadata = skillDocument(raw);
|
|
64
|
+
const encoded = Object.keys(files)
|
|
65
|
+
.sort()
|
|
66
|
+
.map((path) => ({
|
|
67
|
+
path,
|
|
68
|
+
contentBase64: Buffer.from(files[path]!).toString("base64"),
|
|
69
|
+
}));
|
|
70
|
+
return { ...metadata, digest: hashSkillValue(encoded), files: encoded };
|
|
71
|
+
}
|
|
72
|
+
export function hashSkillValue(value: unknown): string {
|
|
73
|
+
return `sha256:${createHash("sha256").update(JSON.stringify(value)).digest("hex")}`;
|
|
74
|
+
}
|
|
75
|
+
function skillDocument(raw: string) {
|
|
76
|
+
const match = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)([\s\S]*)$/.exec(raw);
|
|
77
|
+
if (!match || !match[2]!.trim() || raw.includes("\0"))
|
|
78
|
+
throw new AgentSkillError(
|
|
79
|
+
"SKILL_PACKAGE_INVALID",
|
|
80
|
+
"SKILL.md 需要 YAML 头部(name、description)及正文",
|
|
81
|
+
);
|
|
82
|
+
const doc = parseDocument(match[1]!, { uniqueKeys: true });
|
|
83
|
+
if (doc.errors.length)
|
|
84
|
+
throw new AgentSkillError("SKILL_PACKAGE_INVALID", "技能 YAML 格式无效");
|
|
85
|
+
let value: unknown;
|
|
86
|
+
try {
|
|
87
|
+
value = doc.toJS({ maxAliasCount: 20 }) as unknown;
|
|
88
|
+
} catch {
|
|
89
|
+
throw new AgentSkillError("SKILL_PACKAGE_INVALID", "技能 YAML 引用过多");
|
|
90
|
+
}
|
|
91
|
+
const meta = record(value),
|
|
92
|
+
name = skillKey(meta.name),
|
|
93
|
+
description = meta.description;
|
|
94
|
+
if (
|
|
95
|
+
typeof description !== "string" ||
|
|
96
|
+
!description.trim() ||
|
|
97
|
+
description.length > 2048
|
|
98
|
+
)
|
|
99
|
+
throw new AgentSkillError(
|
|
100
|
+
"SKILL_PACKAGE_INVALID",
|
|
101
|
+
"请填写不超过 2048 字符的技能说明",
|
|
102
|
+
);
|
|
103
|
+
for (const field of ["user-invocable", "disable-model-invocation"])
|
|
104
|
+
if (meta[field] !== undefined && typeof meta[field] !== "boolean")
|
|
105
|
+
throw new AgentSkillError(
|
|
106
|
+
"SKILL_PACKAGE_INVALID",
|
|
107
|
+
`${field} 必须为布尔值`,
|
|
108
|
+
);
|
|
109
|
+
const displayName = record(meta.metadata).displayName;
|
|
110
|
+
if (
|
|
111
|
+
displayName !== undefined &&
|
|
112
|
+
(typeof displayName !== "string" ||
|
|
113
|
+
!displayName.trim() ||
|
|
114
|
+
displayName.length > 60 ||
|
|
115
|
+
[...displayName].some(
|
|
116
|
+
(char) => char.charCodeAt(0) < 32 || char.charCodeAt(0) === 127,
|
|
117
|
+
))
|
|
118
|
+
)
|
|
119
|
+
throw new AgentSkillError(
|
|
120
|
+
"SKILL_PACKAGE_INVALID",
|
|
121
|
+
"技能中文名称须为 1–60 字符的单行文字",
|
|
122
|
+
);
|
|
123
|
+
return {
|
|
124
|
+
name,
|
|
125
|
+
displayName: typeof displayName === "string" ? displayName.trim() : name,
|
|
126
|
+
description: description.trim(),
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
function record(value: unknown): Record<string, unknown> {
|
|
130
|
+
return value && typeof value === "object" && !Array.isArray(value)
|
|
131
|
+
? (value as Record<string, unknown>)
|
|
132
|
+
: {};
|
|
133
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AgentSkillBundle,
|
|
3
|
+
AgentSkillVersion,
|
|
4
|
+
AuditEvent,
|
|
5
|
+
} from "@southwind-ai/shared";
|
|
6
|
+
|
|
7
|
+
export class AgentSkillError extends Error {
|
|
8
|
+
constructor(
|
|
9
|
+
readonly code: string,
|
|
10
|
+
message: string,
|
|
11
|
+
readonly status = 400,
|
|
12
|
+
) {
|
|
13
|
+
super(message);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export interface StoredAgentSkill {
|
|
17
|
+
readonly metadata: AgentSkillVersion;
|
|
18
|
+
readonly bundle: AgentSkillBundle;
|
|
19
|
+
readonly auditCommitted: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface SkillMutationIdentity {
|
|
22
|
+
readonly tenantId: string;
|
|
23
|
+
readonly actorId: string;
|
|
24
|
+
readonly idempotencyKey: string;
|
|
25
|
+
readonly requestDigest: string;
|
|
26
|
+
}
|
|
27
|
+
export interface SkillMutationReceipt extends SkillMutationIdentity {
|
|
28
|
+
readonly result: AgentSkillVersion;
|
|
29
|
+
readonly audit: AuditEvent;
|
|
30
|
+
readonly auditCommitted: boolean;
|
|
31
|
+
}
|
|
32
|
+
export interface AgentSkillRepository {
|
|
33
|
+
versions(
|
|
34
|
+
tenantId: string,
|
|
35
|
+
key?: string,
|
|
36
|
+
): Promise<readonly StoredAgentSkill[]>;
|
|
37
|
+
mutate(
|
|
38
|
+
input: SkillMutationIdentity & { key: string; expectedVersion: number },
|
|
39
|
+
change: (
|
|
40
|
+
current: StoredAgentSkill | undefined,
|
|
41
|
+
versions: readonly StoredAgentSkill[],
|
|
42
|
+
) => Promise<{ record: StoredAgentSkill; audit: AuditEvent }>,
|
|
43
|
+
): Promise<SkillMutationReceipt>;
|
|
44
|
+
pendingAudits(): Promise<readonly SkillMutationReceipt[]>;
|
|
45
|
+
acknowledge(receipt: SkillMutationReceipt): Promise<void>;
|
|
46
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { and, asc, eq, sql } from "drizzle-orm";
|
|
2
|
+
import type { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
3
|
+
import {
|
|
4
|
+
agentSkillMutations,
|
|
5
|
+
agentSkillVersions,
|
|
6
|
+
} from "@southwind-ai/database";
|
|
7
|
+
import type {
|
|
8
|
+
AgentSkillRepository,
|
|
9
|
+
SkillMutationReceipt,
|
|
10
|
+
} from "./contracts.js";
|
|
11
|
+
import { assertSkillMutation, assertSkillReplay } from "./repository.js";
|
|
12
|
+
|
|
13
|
+
export class DrizzleAgentSkillRepository implements AgentSkillRepository {
|
|
14
|
+
constructor(private readonly db: NodePgDatabase) {}
|
|
15
|
+
async versions(tenantId: string, key?: string) {
|
|
16
|
+
return this.db
|
|
17
|
+
.select({
|
|
18
|
+
metadata: agentSkillVersions.metadata,
|
|
19
|
+
bundle: agentSkillVersions.bundle,
|
|
20
|
+
auditCommitted: agentSkillVersions.auditCommitted,
|
|
21
|
+
})
|
|
22
|
+
.from(agentSkillVersions)
|
|
23
|
+
.where(
|
|
24
|
+
and(
|
|
25
|
+
eq(agentSkillVersions.tenantId, tenantId),
|
|
26
|
+
key ? eq(agentSkillVersions.skillKey, key) : undefined,
|
|
27
|
+
),
|
|
28
|
+
)
|
|
29
|
+
.orderBy(asc(agentSkillVersions.version));
|
|
30
|
+
}
|
|
31
|
+
async mutate(
|
|
32
|
+
input: Parameters<AgentSkillRepository["mutate"]>[0],
|
|
33
|
+
change: Parameters<AgentSkillRepository["mutate"]>[1],
|
|
34
|
+
) {
|
|
35
|
+
return this.db.transaction(async (tx) => {
|
|
36
|
+
// Serialize both the new-key case and actor-wide mutation receipts before CAS.
|
|
37
|
+
await tx.execute(
|
|
38
|
+
sql`select pg_advisory_xact_lock(hashtextextended(${`agent-skill:${input.tenantId}`}, 0))`,
|
|
39
|
+
);
|
|
40
|
+
const [replay] = await tx
|
|
41
|
+
.select()
|
|
42
|
+
.from(agentSkillMutations)
|
|
43
|
+
.where(
|
|
44
|
+
and(
|
|
45
|
+
eq(agentSkillMutations.tenantId, input.tenantId),
|
|
46
|
+
eq(agentSkillMutations.actorId, input.actorId),
|
|
47
|
+
eq(agentSkillMutations.idempotencyKey, input.idempotencyKey),
|
|
48
|
+
),
|
|
49
|
+
)
|
|
50
|
+
.limit(1);
|
|
51
|
+
if (replay) {
|
|
52
|
+
assertSkillReplay(replay, input);
|
|
53
|
+
return replay;
|
|
54
|
+
}
|
|
55
|
+
const versions = await tx
|
|
56
|
+
.select({
|
|
57
|
+
metadata: agentSkillVersions.metadata,
|
|
58
|
+
bundle: agentSkillVersions.bundle,
|
|
59
|
+
auditCommitted: agentSkillVersions.auditCommitted,
|
|
60
|
+
})
|
|
61
|
+
.from(agentSkillVersions)
|
|
62
|
+
.where(
|
|
63
|
+
and(
|
|
64
|
+
eq(agentSkillVersions.tenantId, input.tenantId),
|
|
65
|
+
eq(agentSkillVersions.skillKey, input.key),
|
|
66
|
+
),
|
|
67
|
+
)
|
|
68
|
+
.orderBy(asc(agentSkillVersions.version));
|
|
69
|
+
assertSkillMutation(versions.at(-1), input.expectedVersion);
|
|
70
|
+
const { record, audit } = await change(versions.at(-1), versions);
|
|
71
|
+
const receipt = {
|
|
72
|
+
...input,
|
|
73
|
+
result: record.metadata,
|
|
74
|
+
audit,
|
|
75
|
+
auditCommitted: false,
|
|
76
|
+
};
|
|
77
|
+
await tx.insert(agentSkillVersions).values({
|
|
78
|
+
tenantId: input.tenantId,
|
|
79
|
+
skillKey: input.key,
|
|
80
|
+
version: record.metadata.version,
|
|
81
|
+
metadata: record.metadata,
|
|
82
|
+
bundle: record.bundle,
|
|
83
|
+
auditCommitted: false,
|
|
84
|
+
});
|
|
85
|
+
await tx.insert(agentSkillMutations).values({
|
|
86
|
+
...receipt,
|
|
87
|
+
skillKey: input.key,
|
|
88
|
+
version: record.metadata.version,
|
|
89
|
+
});
|
|
90
|
+
return receipt;
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
async pendingAudits() {
|
|
94
|
+
return this.db
|
|
95
|
+
.select()
|
|
96
|
+
.from(agentSkillMutations)
|
|
97
|
+
.where(eq(agentSkillMutations.auditCommitted, false))
|
|
98
|
+
.limit(500);
|
|
99
|
+
}
|
|
100
|
+
async acknowledge(receipt: SkillMutationReceipt) {
|
|
101
|
+
await this.db.transaction(async (tx) => {
|
|
102
|
+
await tx
|
|
103
|
+
.update(agentSkillVersions)
|
|
104
|
+
.set({ auditCommitted: true })
|
|
105
|
+
.where(
|
|
106
|
+
and(
|
|
107
|
+
eq(agentSkillVersions.tenantId, receipt.tenantId),
|
|
108
|
+
eq(agentSkillVersions.skillKey, receipt.result.key),
|
|
109
|
+
eq(agentSkillVersions.version, receipt.result.version),
|
|
110
|
+
),
|
|
111
|
+
);
|
|
112
|
+
await tx
|
|
113
|
+
.update(agentSkillMutations)
|
|
114
|
+
.set({ auditCommitted: true })
|
|
115
|
+
.where(
|
|
116
|
+
and(
|
|
117
|
+
eq(agentSkillMutations.tenantId, receipt.tenantId),
|
|
118
|
+
eq(agentSkillMutations.actorId, receipt.actorId),
|
|
119
|
+
eq(agentSkillMutations.idempotencyKey, receipt.idempotencyKey),
|
|
120
|
+
eq(agentSkillMutations.requestDigest, receipt.requestDigest),
|
|
121
|
+
),
|
|
122
|
+
);
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ImportAgentSkillRequest } from "@southwind-ai/shared";
|
|
2
|
+
import { AgentSkillError } from "./contracts.js";
|
|
3
|
+
export function version(value: number) {
|
|
4
|
+
if (!Number.isSafeInteger(value) || value < 0)
|
|
5
|
+
throw new AgentSkillError(
|
|
6
|
+
"SKILL_INPUT_INVALID",
|
|
7
|
+
"expectedVersion 必须为非负整数",
|
|
8
|
+
);
|
|
9
|
+
}
|
|
10
|
+
export function validateImport(input: ImportAgentSkillRequest) {
|
|
11
|
+
version(input.expectedVersion);
|
|
12
|
+
if (!["personal", "department", "tenant"].includes(input.scope))
|
|
13
|
+
throw new AgentSkillError("SKILL_INPUT_INVALID", "技能共享范围无效");
|
|
14
|
+
if (
|
|
15
|
+
(input.requirements?.length ?? 0) > 64 ||
|
|
16
|
+
(input.safetyConstraints?.length ?? 0) > 32
|
|
17
|
+
)
|
|
18
|
+
throw new AgentSkillError("SKILL_INPUT_INVALID", "技能依赖或约束数量过多");
|
|
19
|
+
for (const item of input.requirements ?? [])
|
|
20
|
+
if (
|
|
21
|
+
![item.toolKey, item.permissionKey, item.featureKey].every(
|
|
22
|
+
(key) => typeof key === "string" && key.length > 0 && key.length <= 160,
|
|
23
|
+
)
|
|
24
|
+
)
|
|
25
|
+
throw new AgentSkillError("SKILL_INPUT_INVALID", "技能依赖无效");
|
|
26
|
+
for (const item of input.safetyConstraints ?? [])
|
|
27
|
+
if (typeof item !== "string" || !item.trim() || item.length > 1000)
|
|
28
|
+
throw new AgentSkillError("SKILL_INPUT_INVALID", "技能安全约束无效");
|
|
29
|
+
}
|